Blame view

js/app/views/PlotTabResultUI.js 23.9 KB
16035364   Benjamin Renard   First commit
1
2
3
/**
 * Project   : AMDA-NG
 * Name      : PlotTabResultUI.js
18d4a11e   Benjamin Renard   Save and load plo...
4
5
 * @class    amdaUI.PlotTabResultUI
 * @extends  Ext. panel.Panel
16035364   Benjamin Renard   First commit
6
7
 * @brief    Plot Tab Result UI definition (View)
 * @author    
bab90f22   Elena.Budnik   format + #5668
8
 * @version  $Id: PlotTabResultUI.js benjamin 
16035364   Benjamin Renard   First commit
9
10
11
 */

Ext.define('amdaUI.PlotTabResultUI', {
bab90f22   Elena.Budnik   format + #5668
12
	extend: 'Ext.panel.Panel',
16035364   Benjamin Renard   First commit
13

bab90f22   Elena.Budnik   format + #5668
14
15
16
17
18
	alias: 'widget.plotTabResult',

	requires: [
		'amdaPlotComp.PlotZoomPlug',
		'amdaPlotComp.PlotExtendShiftPlug',
bab90f22   Elena.Budnik   format + #5668
19
20
21
		'amdaPlotComp.PlotContextManager',
		'amdaPlotComp.PlotResultImage'
	],
8c88a270   Erdogan Furkan   10312 - Navigatio...
22
23
24
25
26
27
28

	panelImage: null,
	crtContext: null,
	interactiveId: '',
	navToolBar: null,
	isTTNavBar: false,
	crtTTFileIndex: 0,
bab90f22   Elena.Budnik   format + #5668
29
	disableSynchronize: false,
27a055f4   Benjamin Renard   Multiplot (#8314)
30
	multiplot: false,
55b10506   Benjamin Renard   Update correctly ...
31
	plotName: '',
8c88a270   Erdogan Furkan   10312 - Navigatio...
32

bab90f22   Elena.Budnik   format + #5668
33
	hiddenForm: null,
8c88a270   Erdogan Furkan   10312 - Navigatio...
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

	constructor: function (config) {
		this.addEvents({ 'pagesize': true });

		this.init(config);
		this.callParent(arguments);
	},

	updateConfig: function (name, multiplot) {
		this.multiplot = multiplot;
		this.plotName = name;
		this.findParentByType('window').setTitle(this.plotName + (this.multiplot ? ' - Synchronized to Multiplot' : ''));
	},

	getImageSize: function () {
bab90f22   Elena.Budnik   format + #5668
49
50
		if (!this.crtContext)
			return {
8c88a270   Erdogan Furkan   10312 - Navigatio...
51
52
				width: 0,
				height: 0
bab90f22   Elena.Budnik   format + #5668
53
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
54
55
56
57
58

		return {
			width: this.crtContext.page.width * this.sliderPage.getValue() / 100.,
			height: this.crtContext.page.height * this.sliderPage.getValue() / 100.
		}
bab90f22   Elena.Budnik   format + #5668
59
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
60
61
62

	getImageUrl: function (resultFolder, plotFile) {
		return 'data/' + sessionID + '/RES/' + resultFolder + '/' + plotFile;
bab90f22   Elena.Budnik   format + #5668
63
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
64
65
66

	toPixelOnSourceImage: function (value) {
		return value * 100 / this.sliderPage.getValue();
d0b61b72   Benjamin Renard   Show coordinates ...
67
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
68
69
70

	toPixelOnResultImage: function (value) {
		return value * this.sliderPage.getValue() / 100;
d0b61b72   Benjamin Renard   Show coordinates ...
71
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
72
73

	createZoomItemsForPanel: function (panelId) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
74
75
76
		var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
		if (zoomPlugin == null)
			return;
8c88a270   Erdogan Furkan   10312 - Navigatio...
77

9f08f4eb   Benjamin Renard   Zoom in interacti...
78
		var panelContext = amdaPlotComp.PlotContextManager.getPanelById(this.crtContext, panelId);
caff798e   Benjamin Renard   Fix zoom bar for ...
79
		var size = this.getImageSize();
8c88a270   Erdogan Furkan   10312 - Navigatio...
80

9f08f4eb   Benjamin Renard   Zoom in interacti...
81
		var me = this;
8b11b1af   Benjamin Renard   Insert intervals ...
82
		var insertIntervalItem = null;
9f08f4eb   Benjamin Renard   Zoom in interacti...
83
84
85
86
87
88
89
		Ext.each(panelContext.plotArea.axes, function (axis) {
			//Events for zoom on a time axis
			var onMinTimeSelection = function (posX) {
				//Panel and axis context must be retrieved by using the crtContext
				var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId);
				var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id);
				var sourceXPos = me.toPixelOnSourceImage(posX);
8c88a270   Erdogan Furkan   10312 - Navigatio...
90
91
				var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x + panelContext.plotArea.width, sourceXPos);
				var crtTime = new Date(crtTimestamp * 1000);
9f08f4eb   Benjamin Renard   Zoom in interacti...
92
93
94
				crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
				zoomPlugin.setMinValue(crtTime);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
95

9f08f4eb   Benjamin Renard   Zoom in interacti...
96
97
98
99
100
			var onMaxTimeSelection = function (posX) {
				//Panel and axis context must be retrieved by using the crtContext
				var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId);
				var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id);
				var sourceXPos = me.toPixelOnSourceImage(posX);
8c88a270   Erdogan Furkan   10312 - Navigatio...
101
102
				var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x + panelContext.plotArea.width, sourceXPos);
				var crtTime = new Date(crtTimestamp * 1000);
9f08f4eb   Benjamin Renard   Zoom in interacti...
103
104
105
				crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
				zoomPlugin.setMaxValue(crtTime);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
106

9f08f4eb   Benjamin Renard   Zoom in interacti...
107
			//Events for zoom on a Y axis
8c88a270   Erdogan Furkan   10312 - Navigatio...
108
			var onMinYValueSelection = function (posY) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
109
110
111
112
				//Panel and axis context must be retrieved by using the crtContext
				var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId);
				var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id);
				var sourceYPos = me.toPixelOnSourceImage(posY);
8c88a270   Erdogan Furkan   10312 - Navigatio...
113
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.y + panelContext.plotArea.height, panelContext.plotArea.y, sourceYPos);
9f08f4eb   Benjamin Renard   Zoom in interacti...
114
115
				zoomPlugin.setMinValue(crtValue);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
116
117

			var onMaxYValueSelection = function (posY) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
118
119
120
121
				//Panel and axis context must be retrieved by using the crtContext
				var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId);
				var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id);
				var sourceYPos = me.toPixelOnSourceImage(posY);
8c88a270   Erdogan Furkan   10312 - Navigatio...
122
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.y + panelContext.plotArea.height, panelContext.plotArea.y, sourceYPos);
9f08f4eb   Benjamin Renard   Zoom in interacti...
123
124
				zoomPlugin.setMaxValue(crtValue);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
125

9f08f4eb   Benjamin Renard   Zoom in interacti...
126
			//Events for zoom on X axis
8c88a270   Erdogan Furkan   10312 - Navigatio...
127
			var onMinXValueSelection = function (posX) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
128
129
130
131
132
133
134
				//Panel and axis context must be retrieved by using the crtContext
				var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId);
				var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id);
				var sourceXPos = me.toPixelOnSourceImage(posX);
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x + panelContext.plotArea.width, sourceXPos);
				zoomPlugin.setMinValue(crtValue);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
135
136

			var onMaxXValueSelection = function (posX) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
137
138
139
140
141
142
143
				//Panel and axis context must be retrieved by using the crtContext
				var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId);
				var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id);
				var sourceXPos = me.toPixelOnSourceImage(posX);
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x + panelContext.plotArea.width, sourceXPos);
				zoomPlugin.setMaxValue(crtValue);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198

			switch (axis.id) {
				case 'timeAxis':
					me.contextualMenu.add({
						text: 'Zoom on Time Axis',
						handler: function (item, e) {
							zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
							zoomPlugin.resetMinMaxValue();
							me.panelImage.startZoom(true, 0/*me.toPixelOnResultImage(panelContext.y)*/, size.height /*me.toPixelOnResultImage(panelContext.height)*/, onMinTimeSelection, onMaxTimeSelection);
						},
						scope: this
					});
					insertIntervalItem = {
						text: 'Insert Interval in TimeTable or Catalog',
						handler: function (item, e) {
							zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
							zoomPlugin.resetMinMaxValue();
							me.panelImage.startZoom(true, 0/*me.toPixelOnResultImage(panelContext.y)*/, size.height /*me.toPixelOnResultImage(panelContext.height)*/, onMinTimeSelection, onMaxTimeSelection);
						},
						scope: this
					};
					break;
				case 'y-left':
					me.contextualMenu.add({
						text: 'Zoom on Y Left Axis',
						handler: function (item, e) {
							zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
							zoomPlugin.resetMinMaxValue();
							me.panelImage.startZoom(false, me.toPixelOnResultImage(panelContext.x), me.toPixelOnResultImage(panelContext.width), onMinYValueSelection, onMaxYValueSelection);
						}
					});
					break;
				case 'y-right':
					me.contextualMenu.add({
						text: 'Zoom on Y Right Axis',
						handler: function (item, e) {
							zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
							zoomPlugin.resetMinMaxValue();
							me.panelImage.startZoom(false, me.toPixelOnResultImage(panelContext.x), me.toPixelOnResultImage(panelContext.width), onMinYValueSelection, onMaxYValueSelection);
						}
					});
					break;
				case 'xaxis_id':
					me.contextualMenu.add({
						text: 'Zoom on X Axis',
						handler: function (item, e) {
							zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
							zoomPlugin.resetMinMaxValue();
							me.panelImage.startZoom(true, me.toPixelOnResultImage(panelContext.y), me.toPixelOnResultImage(panelContext.height), onMinXValueSelection, onMaxXValueSelection);
						}
					});
					break;
				case 'epochAxis':
					//Nothing to add
					break;
9f08f4eb   Benjamin Renard   Zoom in interacti...
199
			}
8c88a270   Erdogan Furkan   10312 - Navigatio...
200

9f08f4eb   Benjamin Renard   Zoom in interacti...
201
		});
8b11b1af   Benjamin Renard   Insert intervals ...
202
203
204
205
206

		if (insertIntervalItem != null) {
			me.contextualMenu.add('-');
			me.contextualMenu.add(insertIntervalItem);
		}
9f08f4eb   Benjamin Renard   Zoom in interacti...
207
	},
2ea6eb0d   Benjamin Renard   Fix decimal preci...
208

8c88a270   Erdogan Furkan   10312 - Navigatio...
209
210
211
212
213
214
215
216
217
218
219
220
221
	getAxisValue: function (axis, pixelMin, pixelMax, pixelVal) {
		var val = amdaPlotComp.PlotContextManager.toAxisValue(axis, pixelMin, pixelMax, pixelVal);
		return parseFloat(val).toPrecision(5);
	},

	createPlotImage: function (resultFolder, plotFile) {
		var me = this;
		var size = this.getImageSize();
		this.panelImage = Ext.create('amdaPlotComp.PlotResultImage', {
			src: this.getImageUrl(resultFolder, plotFile),
			width: size.width,
			height: size.height,
			onMouseMove: function (x, y) {
d0b61b72   Benjamin Renard   Show coordinates ...
222
223
				if (!me.crtContext)
					return;
8c88a270   Erdogan Furkan   10312 - Navigatio...
224

d0b61b72   Benjamin Renard   Show coordinates ...
225
226
227
				var sourceXPos = me.toPixelOnSourceImage(x);
				var sourceYPos = me.toPixelOnSourceImage(y);
				var panel = amdaPlotComp.PlotContextManager.getPanel(me.crtContext, sourceXPos, sourceYPos);
2cd12bf9   Erdogan Furkan   #9326 - Showing T...
228

d0b61b72   Benjamin Renard   Show coordinates ...
229
				var text = '';
8c88a270   Erdogan Furkan   10312 - Navigatio...
230
231
				if (me.panelImage) {
					if (!panel) {
d0b61b72   Benjamin Renard   Show coordinates ...
232
233
234
						me.panelImage.resetCursor();
						text += 'No panel';
					}
8c88a270   Erdogan Furkan   10312 - Navigatio...
235
					else {
d0b61b72   Benjamin Renard   Show coordinates ...
236
237
						text += 'Panel Id : ';
						text += panel.id;
8c88a270   Erdogan Furkan   10312 - Navigatio...
238
						if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos)) {
d0b61b72   Benjamin Renard   Show coordinates ...
239
240
241
242
243
244
245
							/*me.panelImage.updateCursor(
								me.toPixelOnResultImage(panel.plotArea.x),
								me.toPixelOnResultImage(panel.plotArea.y),
								me.toPixelOnResultImage(panel.plotArea.width),
								me.toPixelOnResultImage(panel.plotArea.height),
								x, y);*/
							me.panelImage.updateCursor(
8c88a270   Erdogan Furkan   10312 - Navigatio...
246
247
248
249
250
251
								me.toPixelOnResultImage(0),
								me.toPixelOnResultImage(0),
								me.toPixelOnResultImage(me.crtContext.page.width),
								me.toPixelOnResultImage(me.crtContext.page.height),
								x, y);

d0b61b72   Benjamin Renard   Show coordinates ...
252
253
254
							var xText = '';
							var yLeftText = '';
							var yRightText = '';
2cd12bf9   Erdogan Furkan   #9326 - Showing T...
255
							var intervalText = '';
d0b61b72   Benjamin Renard   Show coordinates ...
256
							Ext.each(panel.plotArea.axes, function (axis) {
8c88a270   Erdogan Furkan   10312 - Navigatio...
257
258
259
260
								switch (axis.id) {
									case 'timeAxis':
										var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(axis, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos);
										var crtTime = new Date(crtTimestamp * 1000);
c2cc7749   Erdogan Furkan   #10098 - Modifica...
261
										intervalText = amdaPlotComp.PlotContextManager.getIntervalCoordInfo(me.crtContext, panel, crtTimestamp);
8c88a270   Erdogan Furkan   10312 - Navigatio...
262
										xText = crtTime.toJSON();
8c88a270   Erdogan Furkan   10312 - Navigatio...
263
264
265
266
267
268
269
270
271
272
273
274
275
										break;
									case 'y-left':
										yLeftText = me.getAxisValue(axis, panel.plotArea.y + panel.plotArea.height, panel.plotArea.y, sourceYPos);
										break;
									case 'y-right':
										yRightText = me.getAxisValue(axis, panel.plotArea.y + panel.plotArea.height, panel.plotArea.y, sourceYPos);
										break;
									case 'xaxis_id':
										xText = me.getAxisValue(axis, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos);
										break;
									case 'epochAxis':
										xText = me.getAxisValue(axis, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos);
										break;
d0b61b72   Benjamin Renard   Show coordinates ...
276
								}
8c88a270   Erdogan Furkan   10312 - Navigatio...
277

d0b61b72   Benjamin Renard   Show coordinates ...
278
							});
8c88a270   Erdogan Furkan   10312 - Navigatio...
279

d0b61b72   Benjamin Renard   Show coordinates ...
280
							if (xText != '')
8c88a270   Erdogan Furkan   10312 - Navigatio...
281
								text += (', X : ' + xText);
d0b61b72   Benjamin Renard   Show coordinates ...
282
							if (yLeftText != '')
8c88a270   Erdogan Furkan   10312 - Navigatio...
283
								text += (', Y Left : ' + yLeftText);
d0b61b72   Benjamin Renard   Show coordinates ...
284
							if (yRightText != '')
8c88a270   Erdogan Furkan   10312 - Navigatio...
285
								text += (', Y Right : ' + yRightText);
2cd12bf9   Erdogan Furkan   #9326 - Showing T...
286
							if (intervalText != '')
c2cc7749   Erdogan Furkan   #10098 - Modifica...
287
								text += (', ' + intervalText);
d0b61b72   Benjamin Renard   Show coordinates ...
288
289
290
291
292
293
294
						}
						else
							me.panelImage.resetCursor();
					}
				}
				me.coordinatesField.setText(text);
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
295
			onContextMenu: function (absoluteX, absoluteY, imageX, imageY) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
296
297
				if (!me.crtContext)
					return;
8c88a270   Erdogan Furkan   10312 - Navigatio...
298

87658ba0   Benjamin Renard   TT Navigation in ...
299
				me.contextualMenu.removeAll(true);
8c88a270   Erdogan Furkan   10312 - Navigatio...
300

9f08f4eb   Benjamin Renard   Zoom in interacti...
301
302
303
				var sourceXPos = me.toPixelOnSourceImage(imageX);
				var sourceYPos = me.toPixelOnSourceImage(imageY);
				var panel = amdaPlotComp.PlotContextManager.getPanel(me.crtContext, sourceXPos, sourceYPos);
c2cc7749   Erdogan Furkan   #10098 - Modifica...
304
305
306
307
				var timeAxisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panel, 'timeAxis');
				if (timeAxisContext == null)
					return;
				var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(timeAxisContext, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos);
8c88a270   Erdogan Furkan   10312 - Navigatio...
308
309
310

				if (panel != null) {
					if (panel.plotArea.hasSpectro) {
c9071a43   Benjamin Renard   Add instant plot ...
311
						me.contextualMenu.add([
bab90f22   Elena.Budnik   format + #5668
312
							{
8c88a270   Erdogan Furkan   10312 - Navigatio...
313
314
								text: 'Instant cut at this position',
								handler: function () {
c2cc7749   Erdogan Furkan   #10098 - Modifica...
315

8c88a270   Erdogan Furkan   10312 - Navigatio...
316
									var crtTime = new Date(crtTimestamp * 1000);
bab90f22   Elena.Budnik   format + #5668
317
									crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
8c88a270   Erdogan Furkan   10312 - Navigatio...
318
									me.callInteractivePlot({ 'action': 'instant', 'interactiveId': this.interactiveId, 'panelId': panel.id, 'time': crtTime });
bab90f22   Elena.Budnik   format + #5668
319
320
321
								},
								scope: me
							},
8c88a270   Erdogan Furkan   10312 - Navigatio...
322
							'-'
c9071a43   Benjamin Renard   Add instant plot ...
323
324
						]);
					}
9f08f4eb   Benjamin Renard   Zoom in interacti...
325
326
					if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos))
						me.createZoomItemsForPanel(panel.id);
c2cc7749   Erdogan Furkan   #10098 - Modifica...
327
328


9f08f4eb   Benjamin Renard   Zoom in interacti...
329
				}
8b11b1af   Benjamin Renard   Insert intervals ...
330

9f08f4eb   Benjamin Renard   Zoom in interacti...
331
332
				if (me.contextualMenu.items.getCount() > 0)
					me.contextualMenu.add('-');
8c88a270   Erdogan Furkan   10312 - Navigatio...
333

37e81bff   Benjamin Renard   Direct save of pl...
334
				me.contextualMenu.add([
bab90f22   Elena.Budnik   format + #5668
335
					{
8c88a270   Erdogan Furkan   10312 - Navigatio...
336
337
338
						text: 'Extend/Shift Time interval',
						disabled: me.isTTNavBar,
						handler: function () {
bab90f22   Elena.Budnik   format + #5668
339
							var extendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id');
b39c9d1d   Benjamin Renard   Fix interactive n...
340
							extendShiftPlugin.show(me.interactiveId);
bab90f22   Elena.Budnik   format + #5668
341
342
343
344
345
346
						},
						scope: me
					},
					'-',
					{
						text: 'Save Plot',
8c88a270   Erdogan Furkan   10312 - Navigatio...
347
						handler: function () {
bab90f22   Elena.Budnik   format + #5668
348
349
							if (me.hiddenForm == null)
								me.hiddenForm = Ext.create('Ext.form.Panel', {
8c88a270   Erdogan Furkan   10312 - Navigatio...
350
									title: 'hiddenForm',
bab90f22   Elena.Budnik   format + #5668
351
352
353
354
									renderTo: Ext.getBody(),
									standardSubmit: true,
									url: 'php/downloadPlot.php',
									timeout: 120000,
8c88a270   Erdogan Furkan   10312 - Navigatio...
355
									height: 100,
bab90f22   Elena.Budnik   format + #5668
356
									width: 100,
8c88a270   Erdogan Furkan   10312 - Navigatio...
357
358
									hidden: true,
									items: []
bab90f22   Elena.Budnik   format + #5668
359
								});
37e81bff   Benjamin Renard   Direct save of pl...
360

bab90f22   Elena.Budnik   format + #5668
361
362
363
							me.hiddenForm.getForm().submit({
								params: {
									sessionId: sessionID,
8c88a270   Erdogan Furkan   10312 - Navigatio...
364
									interactiveId: me.interactiveId
bab90f22   Elena.Budnik   format + #5668
365
								},
8c88a270   Erdogan Furkan   10312 - Navigatio...
366
367
								success: function (form, action) { },
								failure: function (form, action) { }
bab90f22   Elena.Budnik   format + #5668
368
369
370
							});
						}
					}
37e81bff   Benjamin Renard   Direct save of pl...
371
				]);
8c88a270   Erdogan Furkan   10312 - Navigatio...
372

c2cc7749   Erdogan Furkan   #10098 - Modifica...
373
374
375
376
377
378
				if (amdaPlotComp.PlotContextManager.isInterval(me.crtContext, panel, crtTimestamp)) {
					var allintervalParams = amdaPlotComp.PlotContextManager.getAllIntervalParams(me.crtContext, panel, crtTimestamp);
					if (allintervalParams.length > 0) {

						var links = amdaPlotComp.PlotContextManager.getIntervalLinks(allintervalParams);
						if (links.length > 0) {
1be6ea03   Erdogan Furkan   #10098 - Final co...
379
380
							var menu = Ext.create('Ext.menu.Menu', { plain: true });
							var realLinks = amdaPlotComp.PlotContextManager.setIntervalsRef(links, menu);
c2cc7749   Erdogan Furkan   #10098 - Modifica...
381
382
383
							me.contextualMenu.add('-');
							me.contextualMenu.add([
								{
1be6ea03   Erdogan Furkan   #10098 - Final co...
384
385
									text: 'Open references (' + realLinks.length + ')',
									menu: menu,
c2cc7749   Erdogan Furkan   #10098 - Modifica...
386
387
388
389
390
391
									scope: me
								}]);
						}
					}
				}

9f08f4eb   Benjamin Renard   Zoom in interacti...
392
393
				me.contextualMenu.showAt(absoluteX, absoluteY);
			}
bab90f22   Elena.Budnik   format + #5668
394
		});
16035364   Benjamin Renard   First commit
395

bab90f22   Elena.Budnik   format + #5668
396
397
		return this.panelImage;
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
398
399

	updatePlotImage: function (configResult, newPlot) {
bab90f22   Elena.Budnik   format + #5668
400
		this.crtContext = configResult.context;
8c88a270   Erdogan Furkan   10312 - Navigatio...
401
402


bab90f22   Elena.Budnik   format + #5668
403
		this.crtTTFileIndex = configResult.ttFileIndex;
8c88a270   Erdogan Furkan   10312 - Navigatio...
404
405

		if (this.isTTNavBar != (!configResult.isInterval) || (this.isSuperposeMode != this.crtContext.page.superposeMode)) {
bab90f22   Elena.Budnik   format + #5668
406
407
408
			//Update navigation bar
			this.updateNavToolBar(!configResult.isInterval, this.crtContext.page.superposeMode);
		}
8c88a270   Erdogan Furkan   10312 - Navigatio...
409

bab90f22   Elena.Budnik   format + #5668
410
		this.updateTimeTableInfo();
8c88a270   Erdogan Furkan   10312 - Navigatio...
411

bab90f22   Elena.Budnik   format + #5668
412
		this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile));
8c88a270   Erdogan Furkan   10312 - Navigatio...
413

bab90f22   Elena.Budnik   format + #5668
414
415
		var size = this.getImageSize();
		this.panelImage.setSize(size.width, size.height);
8c88a270   Erdogan Furkan   10312 - Navigatio...
416

bab90f22   Elena.Budnik   format + #5668
417
418
		this.panelImage.refreshMe();
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
419
420

	updateTimeTableInfo: function () {
bab90f22   Elena.Budnik   format + #5668
421
422
		if (!this.navToolBar)
			return;
8c88a270   Erdogan Furkan   10312 - Navigatio...
423
424

		var ttNameField = this.navToolBar.items.get('tt-table-' + this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
425
426
		if (ttNameField)
			ttNameField.setValue(this.crtContext.page.ttName);
8c88a270   Erdogan Furkan   10312 - Navigatio...
427
428

		var ttNumberField = this.navToolBar.items.get('tt-number-' + this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
429
430
		if (ttNumberField)
			ttNumberField.setValue(this.crtContext.page.ttIndex + 1);
8c88a270   Erdogan Furkan   10312 - Navigatio...
431
432

		var ttTotalField = this.navToolBar.items.get('tt-total-' + this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
433
434
435
		if (ttTotalField)
			ttTotalField.setValue(this.crtContext.page.ttNbIntervals);
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
436
437

	callInteractivePlot: function (obj) {
bab90f22   Elena.Budnik   format + #5668
438
		loadMask.show(true);
8c88a270   Erdogan Furkan   10312 - Navigatio...
439

bab90f22   Elena.Budnik   format + #5668
440
		var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
27a055f4   Benjamin Renard   Multiplot (#8314)
441
		obj['multiplot'] = this.multiplot;
8c88a270   Erdogan Furkan   10312 - Navigatio...
442

b0a1c31b   Benjamin Renard   Remove multi-plot...
443
		AmdaAction.interactivePlot(obj, function (result, e) {
bab90f22   Elena.Budnik   format + #5668
444
445
			loadMask.hide();
			var t = e.getTransaction();
8c88a270   Erdogan Furkan   10312 - Navigatio...
446
447
448
			if (e.status) {
				if (result) {
					if (result.success) {
488b1401   Benjamin Renard   Interactive multi...
449
						plotModule.updateInteractiveSession(result, false);
9f08f4eb   Benjamin Renard   Zoom in interacti...
450
451
					}
					else
8c88a270   Erdogan Furkan   10312 - Navigatio...
452
						myDesktopApp.errorMsg('Interactive action error - ' + result.message);
9f08f4eb   Benjamin Renard   Zoom in interacti...
453
454
455
456
				}
				else
					myDesktopApp.errorMsg('Cannot execute interactive action');
			}
8c88a270   Erdogan Furkan   10312 - Navigatio...
457
			else {
9f08f4eb   Benjamin Renard   Zoom in interacti...
458
				// FAILURE
8c88a270   Erdogan Furkan   10312 - Navigatio...
459
460
461
				myDesktopApp.errorMsg('Error System - ' + e.message);
			}
		}, this);
bab90f22   Elena.Budnik   format + #5668
462
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
463
464

	updateNavToolBar: function (isTimeTable, isSuperposeMode) {
bab90f22   Elena.Budnik   format + #5668
465
466
		if (this.navToolBar)
			this.navToolBar.removeAll(true);
8c88a270   Erdogan Furkan   10312 - Navigatio...
467

bab90f22   Elena.Budnik   format + #5668
468
		var commonItemsCfg = [
8c88a270   Erdogan Furkan   10312 - Navigatio...
469
470
471
472
473
474
			'-',
			{
				xtype: 'tbspacer',
				width: 20
			},
			'->',
bab90f22   Elena.Budnik   format + #5668
475
			{
8c88a270   Erdogan Furkan   10312 - Navigatio...
476
				text: 'Get HST Data',
bab90f22   Elena.Budnik   format + #5668
477
				scope: this,
8c88a270   Erdogan Furkan   10312 - Navigatio...
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
				menu: [
					{
						text: 'Giant Planet Auroral Emissions',
						scope: this,
						handler: function () {
							var me = this;
							myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.astro.id, true, function (module) {
								var startTime = new Date(me.crtContext.page.startTime * 1000);
								startTime = Ext.Date.add(startTime, Ext.Date.MINUTE, startTime.getTimezoneOffset());

								var stopTime = new Date(me.crtContext.page.stopTime * 1000);
								stopTime = Ext.Date.add(stopTime, Ext.Date.MINUTE, stopTime.getTimezoneOffset());

								module.createWindow(startTime, stopTime);
							});
						}
					}]
			}];

		if (isTimeTable) {
bab90f22   Elena.Budnik   format + #5668
498
499
500
			var navigationItemsCfg = [{
				text: 'Previous',
				scope: this,
8c88a270   Erdogan Furkan   10312 - Navigatio...
501
				handler: function () {
bab90f22   Elena.Budnik   format + #5668
502
503
					var ttFileIndex = this.crtTTFileIndex;
					var ttintervalIndex = this.crtContext.page.ttIndex;
8c88a270   Erdogan Furkan   10312 - Navigatio...
504
505
506

					if (ttintervalIndex <= 0 && ttFileIndex > 0) {
						--ttFileIndex;
bab90f22   Elena.Budnik   format + #5668
507
508
509
					}
					else
						--ttintervalIndex;
8c88a270   Erdogan Furkan   10312 - Navigatio...
510
511
					this.callInteractivePlot({ 'action': 'goto', 'interactiveId': this.interactiveId, 'ttFileIndex': ttFileIndex, 'intIndex': ttintervalIndex });
				}
bab90f22   Elena.Budnik   format + #5668
512
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
513
				'-',
bab90f22   Elena.Budnik   format + #5668
514
515
516
			{
				text: 'Next',
				scope: this,
8c88a270   Erdogan Furkan   10312 - Navigatio...
517
				handler: function () {
bab90f22   Elena.Budnik   format + #5668
518
519
					var ttFileIndex = this.crtTTFileIndex;
					var ttintervalIndex = this.crtContext.page.ttIndex;
8c88a270   Erdogan Furkan   10312 - Navigatio...
520
521
522

					if (ttintervalIndex >= this.crtContext.page.ttNbIntervals - 1) {

bab90f22   Elena.Budnik   format + #5668
523
524
525
526
527
528
						++ttFileIndex;
						ttintervalIndex = 0;
					}
					else
						++ttintervalIndex;

8c88a270   Erdogan Furkan   10312 - Navigatio...
529
					this.callInteractivePlot({ 'action': 'goto', 'interactiveId': this.interactiveId, 'ttFileIndex': ttFileIndex, 'intIndex': ttintervalIndex });
bab90f22   Elena.Budnik   format + #5668
530
531
				}
			},
0cde4f76   Erdogan Furkan   10312 Merge fixed
532
            '-',
8c88a270   Erdogan Furkan   10312 - Navigatio...
533
			{
46bd4591   Hacene SI HADJ MOHAND   us ok
534
535
536
537
538
539
540
541
542
543
544
545
546
547
				text: 'Use This Time Inteval',
				scope: this,
				handler: function(){
                                                                                                    var timeObj = new Object();
                                                                                                    var startTime = new Date(this.crtContext.page.startTime*1000);
                                                                                                    timeObj.start  = Ext.Date.add(startTime, Ext.Date.MINUTE, startTime.getTimezoneOffset());
                                                                                                    
                                                                                                    var stopTime = new Date(this.crtContext.page.stopTime*1000);
					timeObj.stop  = Ext.Date.add(stopTime, Ext.Date.MINUTE, stopTime.getTimezoneOffset());

					var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
                                                                                                    plotModule.setTimeInterval(timeObj);
				}
			},
bab90f22   Elena.Budnik   format + #5668
548
549
550
			'-',
			{		 
				text: 'Go to Interval #',  
bab90f22   Elena.Budnik   format + #5668
551
				scope: this,
8c88a270   Erdogan Furkan   10312 - Navigatio...
552
553
				handler: function (bt) {
					var ttGotoNumberField = this.navToolBar.items.get('tt-goto-number-' + this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
554
555
556
557
					var goToIndex = ttGotoNumberField.getValue() - 1;
					if ((goToIndex < 0) || (goToIndex >= this.crtContext.page.ttNbIntervals))
						myDesktopApp.errorMsg('This interval number is outside of the current timeTable');
					else
8c88a270   Erdogan Furkan   10312 - Navigatio...
558
						this.callInteractivePlot({ 'action': 'goto', 'interactiveId': this.interactiveId, 'ttFileIndex': this.crtTTFileIndex, 'intIndex': goToIndex });
bab90f22   Elena.Budnik   format + #5668
559
560
561
562
				}
			},
			{
				xtype: 'numberfield',
8c88a270   Erdogan Furkan   10312 - Navigatio...
563
564
565
				id: 'tt-goto-number-' + this.interactiveId,
				hideTrigger: true,
				width: 50,
bab90f22   Elena.Budnik   format + #5668
566
567
				minValue: 1
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
568
569
570
571
				' ',
				' ',
				' ',
			{
bab90f22   Elena.Budnik   format + #5668
572
				xtype: 'textfield',
8c88a270   Erdogan Furkan   10312 - Navigatio...
573
				id: 'tt-table-' + this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
574
575
576
577
				labelAlign: 'right',
				labelWidth: 30,
				fieldLabel: 'Table',
				width: 130,
8c88a270   Erdogan Furkan   10312 - Navigatio...
578
				disabled: true
bab90f22   Elena.Budnik   format + #5668
579
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
580
			{
bab90f22   Elena.Budnik   format + #5668
581
				xtype: 'textfield',
8c88a270   Erdogan Furkan   10312 - Navigatio...
582
				id: 'tt-number-' + this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
583
584
585
586
				labelAlign: 'right',
				labelWidth: 30,
				fieldLabel: 'Int #',
				width: 90,
8c88a270   Erdogan Furkan   10312 - Navigatio...
587
				disabled: true
bab90f22   Elena.Budnik   format + #5668
588
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
589
590
591
			{
				xtype: 'textfield',
				id: 'tt-total-' + this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
592
593
594
595
				labelAlign: 'right',
				labelWidth: 30,
				fieldLabel: 'Total',
				width: 90,
8c88a270   Erdogan Furkan   10312 - Navigatio...
596
				disabled: true
bab90f22   Elena.Budnik   format + #5668
597
598
			}];
		}
8c88a270   Erdogan Furkan   10312 - Navigatio...
599
		else {
bab90f22   Elena.Budnik   format + #5668
600
			var navigationItemsCfg = [
8c88a270   Erdogan Furkan   10312 - Navigatio...
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
				{
					text: 'Backward',
					scope: this,
					handler: function () {
						this.callInteractivePlot({ 'action': 'backward', 'interactiveId': this.interactiveId });
					}
				},
				'-',
				{
					text: '1/2 Backward',
					scope: this,
					handler: function () {
						this.callInteractivePlot({ 'action': 'halfbackward', 'interactiveId': this.interactiveId });
					}
				},
				'-',
				{
					text: '1/4 Backward',
					scope: this,
					handler: function () {
						this.callInteractivePlot({ 'action': 'quarterbackward', 'interactiveId': this.interactiveId });
					}
				},
				'-',
				{
					text: '1/4 Forward',
					scope: this,
					handler: function () {
						this.callInteractivePlot({ 'action': 'quarterforward', 'interactiveId': this.interactiveId });
					}
				},
				'-',
				{
					text: '1/2 Forward',
					scope: this,
					handler: function () {
						this.callInteractivePlot({ 'action': 'halfforward', 'interactiveId': this.interactiveId });
					}
				},
				'-',
				{
					text: 'Forward',
					scope: this,
					handler: function () {
						this.callInteractivePlot({ 'action': 'forward', 'interactiveId': this.interactiveId });
					}
				}];
bab90f22   Elena.Budnik   format + #5668
648
649
650
		}

		var toolItemsCfg = navigationItemsCfg;
8c88a270   Erdogan Furkan   10312 - Navigatio...
651
		Ext.each(commonItemsCfg, function (item) {
bab90f22   Elena.Budnik   format + #5668
652
653
			toolItemsCfg.push(item);
		});
8c88a270   Erdogan Furkan   10312 - Navigatio...
654
655

		if (!this.navToolBar) {
bab90f22   Elena.Budnik   format + #5668
656
657
			var toolConfig = {
				dock: 'top',
8c88a270   Erdogan Furkan   10312 - Navigatio...
658
				items: toolItemsCfg
bab90f22   Elena.Budnik   format + #5668
659
660
			};

8c88a270   Erdogan Furkan   10312 - Navigatio...
661
			this.navToolBar = Ext.create('Ext.toolbar.Toolbar', toolConfig);
bab90f22   Elena.Budnik   format + #5668
662
663
664
665
666
667
668
669
		}
		else
			this.navToolBar.add(toolItemsCfg);

		this.navToolBar.setDisabled(isSuperposeMode);

		this.isTTNavBar = isTimeTable;
		this.isSuperposeMode = isSuperposeMode;
8c88a270   Erdogan Furkan   10312 - Navigatio...
670
671
672
	},

	init: function (configResult) {
bab90f22   Elena.Budnik   format + #5668
673
		this.crtContext = configResult.context;
b39c9d1d   Benjamin Renard   Fix interactive n...
674
		this.interactiveId = configResult.interactiveId;
27a055f4   Benjamin Renard   Multiplot (#8314)
675
		this.multiplot = (configResult.multiplot == true);
bab90f22   Elena.Budnik   format + #5668
676
677
678

		this.coordinatesField = new Ext.toolbar.TextItem({
			width: 300,
8c88a270   Erdogan Furkan   10312 - Navigatio...
679
			text: ''
bab90f22   Elena.Budnik   format + #5668
680
681
682
		});

		this.sliderPage = new Ext.slider.Single({
8c88a270   Erdogan Furkan   10312 - Navigatio...
683
684
685
686
687
688
689
690
691
692
693
694
695
696
			width: 130,
			value: 75,
			increment: 5,
			minValue: 50,
			maxValue: 100,
			fieldLabel: 'Resize',
			labelWidth: 40,
			listeners: {
				scope: this,
				changecomplete: function (s, v) {
					var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
					zoomPlugin.close();
					var size = this.getImageSize();
					this.panelImage.width = size.width;
bab90f22   Elena.Budnik   format + #5668
697
698
					this.panelImage.height = size.height;
					this.panelImage.doComponentLayout();
8c88a270   Erdogan Furkan   10312 - Navigatio...
699
					this.fireEvent('pagesize', this, v);
bab90f22   Elena.Budnik   format + #5668
700
				}
8c88a270   Erdogan Furkan   10312 - Navigatio...
701
702
703
			}
		});

bab90f22   Elena.Budnik   format + #5668
704
705
706
707
		var mouseToolbar = {
			xtype: 'toolbar',
			height: 25,
			dock: 'bottom',
8c88a270   Erdogan Furkan   10312 - Navigatio...
708
			items: [
bab90f22   Elena.Budnik   format + #5668
709
710
711
712
713
				this.coordinatesField,
				'->',
				this.sliderPage
			]
		};
8c88a270   Erdogan Furkan   10312 - Navigatio...
714

bab90f22   Elena.Budnik   format + #5668
715
716
717
718
719
720
721
722
723
724
		this.contextualMenu = Ext.create('Ext.menu.Menu', {
			width: 200,
			plain: true,
			items: []
		});

		this.updateNavToolBar(!configResult.isInterval, this.crtContext.page.superposeMode);

		this.updateTimeTableInfo();

bab90f22   Elena.Budnik   format + #5668
725
		var plotResultTabPanelConfig = {
8c88a270   Erdogan Furkan   10312 - Navigatio...
726
727
728
			preventHeader: true,
			autoScroll: true,
			items: [this.createPlotImage(configResult.folder, configResult.plotFile)],
bab90f22   Elena.Budnik   format + #5668
729
730
			dockedItems: [this.navToolBar, mouseToolbar],
			plugins: [
8c88a270   Erdogan Furkan   10312 - Navigatio...
731
732
733
734
735
736
737
				{
					ptype: 'plotZoomPlugin',
					pluginId: 'plot-zoom-plugin-id'
				},
				{
					ptype: 'plotExtendShiftPlugin',
					pluginId: 'plot-extendshift-plugin-id'
8c88a270   Erdogan Furkan   10312 - Navigatio...
738
				}],
bab90f22   Elena.Budnik   format + #5668
739
			listeners: {
8c88a270   Erdogan Furkan   10312 - Navigatio...
740
741
				scope: this,
				destroy: function () {
bab90f22   Elena.Budnik   format + #5668
742
743
744
745
746
747
					var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
					if (zoomPlugin)
						zoomPlugin.close();
					var exttendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id');
					if (exttendShiftPlugin)
						exttendShiftPlugin.close();
bab90f22   Elena.Budnik   format + #5668
748
749
750
				}
			}
		};
8c88a270   Erdogan Furkan   10312 - Navigatio...
751
752

		Ext.apply(this, plotResultTabPanelConfig);
bab90f22   Elena.Budnik   format + #5668
753
754
	}
});