Blame view

js/app/views/PlotTabResultUI.js 24 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: '',
1f9f9178   Menouard AZIB   I have created a ...
32
	listParams: [],
8c88a270   Erdogan Furkan   10312 - Navigatio...
33

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

	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
50
51
		if (!this.crtContext)
			return {
8c88a270   Erdogan Furkan   10312 - Navigatio...
52
53
				width: 0,
				height: 0
bab90f22   Elena.Budnik   format + #5668
54
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
55
56
57
58
59

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

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

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

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

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

9f08f4eb   Benjamin Renard   Zoom in interacti...
79
		var panelContext = amdaPlotComp.PlotContextManager.getPanelById(this.crtContext, panelId);
caff798e   Benjamin Renard   Fix zoom bar for ...
80
		var size = this.getImageSize();
1f9f9178   Menouard AZIB   I have created a ...
81
82
		// We need a list of parameters to compute the number of points needed to apply FFT
		this.listParams = panelContext["parameters"];
1f9f9178   Menouard AZIB   I have created a ...
83
		zoomPlugin.setParameters(this.listParams);
8c88a270   Erdogan Furkan   10312 - Navigatio...
84

9f08f4eb   Benjamin Renard   Zoom in interacti...
85
		var me = this;
8b11b1af   Benjamin Renard   Insert intervals ...
86
		var insertIntervalItem = null;
9f08f4eb   Benjamin Renard   Zoom in interacti...
87
88
89
90
91
92
93
		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...
94
95
				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...
96
97
98
				crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
				zoomPlugin.setMinValue(crtTime);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
99

9f08f4eb   Benjamin Renard   Zoom in interacti...
100
101
102
103
104
			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...
105
106
				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...
107
108
109
				crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
				zoomPlugin.setMaxValue(crtTime);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
110

9f08f4eb   Benjamin Renard   Zoom in interacti...
111
			//Events for zoom on a Y axis
8c88a270   Erdogan Furkan   10312 - Navigatio...
112
			var onMinYValueSelection = function (posY) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
113
114
115
116
				//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...
117
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.y + panelContext.plotArea.height, panelContext.plotArea.y, sourceYPos);
9f08f4eb   Benjamin Renard   Zoom in interacti...
118
119
				zoomPlugin.setMinValue(crtValue);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
120
121

			var onMaxYValueSelection = function (posY) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
122
123
124
125
				//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...
126
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.y + panelContext.plotArea.height, panelContext.plotArea.y, sourceYPos);
9f08f4eb   Benjamin Renard   Zoom in interacti...
127
128
				zoomPlugin.setMaxValue(crtValue);
			};
8c88a270   Erdogan Furkan   10312 - Navigatio...
129

9f08f4eb   Benjamin Renard   Zoom in interacti...
130
			//Events for zoom on X axis
8c88a270   Erdogan Furkan   10312 - Navigatio...
131
			var onMinXValueSelection = function (posX) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
132
133
134
135
136
137
138
				//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...
139
140

			var onMaxXValueSelection = function (posX) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
141
142
143
144
145
146
147
				//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...
148
149
150
151
152
153
154
155
156
157
158
159

			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
					});
535d7638   Menouard AZIB   I have added a co...
160
					//plotFunction Menu
f401b3c7   Benjamin Renard   Fix
161
162
					plotFunctionItem = {
						text: 'Apply a Function on Interval',
535d7638   Menouard AZIB   I have added a co...
163
164
165
166
167
168
						handler: function (item, e) {
							zoomPlugin.show(me.interactiveId, axis.id, panelContext.id, true);
							zoomPlugin.resetMinMaxValue();
							me.panelImage.startZoom(true, 0, size.height, onMinTimeSelection, onMaxTimeSelection);
						},
						scope: this
f401b3c7   Benjamin Renard   Fix
169
					};
8c88a270   Erdogan Furkan   10312 - Navigatio...
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
					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...
213
			}
8c88a270   Erdogan Furkan   10312 - Navigatio...
214

9f08f4eb   Benjamin Renard   Zoom in interacti...
215
		});
8b11b1af   Benjamin Renard   Insert intervals ...
216
217
218
219
220

		if (insertIntervalItem != null) {
			me.contextualMenu.add('-');
			me.contextualMenu.add(insertIntervalItem);
		}
f401b3c7   Benjamin Renard   Fix
221
222
223
224
		if (plotFunctionItem != null) {
			me.contextualMenu.insert(0,'-');
			me.contextualMenu.insert(0, plotFunctionItem);
		}
9f08f4eb   Benjamin Renard   Zoom in interacti...
225
	},
2ea6eb0d   Benjamin Renard   Fix decimal preci...
226

8c88a270   Erdogan Furkan   10312 - Navigatio...
227
228
229
230
231
232
233
234
235
236
237
238
239
	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 ...
240
241
				if (!me.crtContext)
					return;
8c88a270   Erdogan Furkan   10312 - Navigatio...
242

d0b61b72   Benjamin Renard   Show coordinates ...
243
244
245
				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...
246

d0b61b72   Benjamin Renard   Show coordinates ...
247
				var text = '';
8c88a270   Erdogan Furkan   10312 - Navigatio...
248
249
				if (me.panelImage) {
					if (!panel) {
d0b61b72   Benjamin Renard   Show coordinates ...
250
251
252
						me.panelImage.resetCursor();
						text += 'No panel';
					}
8c88a270   Erdogan Furkan   10312 - Navigatio...
253
					else {
d0b61b72   Benjamin Renard   Show coordinates ...
254
255
						text += 'Panel Id : ';
						text += panel.id;
8c88a270   Erdogan Furkan   10312 - Navigatio...
256
						if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos)) {
d0b61b72   Benjamin Renard   Show coordinates ...
257
258
259
260
261
262
263
							/*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...
264
265
266
267
268
269
								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 ...
270
271
272
							var xText = '';
							var yLeftText = '';
							var yRightText = '';
2cd12bf9   Erdogan Furkan   #9326 - Showing T...
273
							var intervalText = '';
d0b61b72   Benjamin Renard   Show coordinates ...
274
							Ext.each(panel.plotArea.axes, function (axis) {
8c88a270   Erdogan Furkan   10312 - Navigatio...
275
276
277
278
								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...
279
										intervalText = amdaPlotComp.PlotContextManager.getIntervalCoordInfo(me.crtContext, panel, crtTimestamp);
8c88a270   Erdogan Furkan   10312 - Navigatio...
280
										xText = crtTime.toJSON();
8c88a270   Erdogan Furkan   10312 - Navigatio...
281
282
283
284
285
286
287
288
289
290
291
292
293
										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 ...
294
								}
8c88a270   Erdogan Furkan   10312 - Navigatio...
295

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

d0b61b72   Benjamin Renard   Show coordinates ...
298
							if (xText != '')
8c88a270   Erdogan Furkan   10312 - Navigatio...
299
								text += (', X : ' + xText);
d0b61b72   Benjamin Renard   Show coordinates ...
300
							if (yLeftText != '')
8c88a270   Erdogan Furkan   10312 - Navigatio...
301
								text += (', Y Left : ' + yLeftText);
d0b61b72   Benjamin Renard   Show coordinates ...
302
							if (yRightText != '')
8c88a270   Erdogan Furkan   10312 - Navigatio...
303
								text += (', Y Right : ' + yRightText);
2cd12bf9   Erdogan Furkan   #9326 - Showing T...
304
							if (intervalText != '')
c2cc7749   Erdogan Furkan   #10098 - Modifica...
305
								text += (', ' + intervalText);
d0b61b72   Benjamin Renard   Show coordinates ...
306
307
308
309
310
311
312
						}
						else
							me.panelImage.resetCursor();
					}
				}
				me.coordinatesField.setText(text);
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
313
			onContextMenu: function (absoluteX, absoluteY, imageX, imageY) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
314
315
				if (!me.crtContext)
					return;
8c88a270   Erdogan Furkan   10312 - Navigatio...
316

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

9f08f4eb   Benjamin Renard   Zoom in interacti...
319
320
321
				var sourceXPos = me.toPixelOnSourceImage(imageX);
				var sourceYPos = me.toPixelOnSourceImage(imageY);
				var panel = amdaPlotComp.PlotContextManager.getPanel(me.crtContext, sourceXPos, sourceYPos);
c2cc7749   Erdogan Furkan   #10098 - Modifica...
322
323
324
325
				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...
326
327
328

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

8c88a270   Erdogan Furkan   10312 - Navigatio...
334
									var crtTime = new Date(crtTimestamp * 1000);
bab90f22   Elena.Budnik   format + #5668
335
									crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
8c88a270   Erdogan Furkan   10312 - Navigatio...
336
									me.callInteractivePlot({ 'action': 'instant', 'interactiveId': this.interactiveId, 'panelId': panel.id, 'time': crtTime });
bab90f22   Elena.Budnik   format + #5668
337
338
339
								},
								scope: me
							},
8c88a270   Erdogan Furkan   10312 - Navigatio...
340
							'-'
c9071a43   Benjamin Renard   Add instant plot ...
341
342
						]);
					}
9f08f4eb   Benjamin Renard   Zoom in interacti...
343
344
					if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos))
						me.createZoomItemsForPanel(panel.id);
c2cc7749   Erdogan Furkan   #10098 - Modifica...
345
346


9f08f4eb   Benjamin Renard   Zoom in interacti...
347
				}
8b11b1af   Benjamin Renard   Insert intervals ...
348

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

37e81bff   Benjamin Renard   Direct save of pl...
352
				me.contextualMenu.add([
bab90f22   Elena.Budnik   format + #5668
353
					{
8c88a270   Erdogan Furkan   10312 - Navigatio...
354
355
356
						text: 'Extend/Shift Time interval',
						disabled: me.isTTNavBar,
						handler: function () {
bab90f22   Elena.Budnik   format + #5668
357
							var extendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id');
b39c9d1d   Benjamin Renard   Fix interactive n...
358
							extendShiftPlugin.show(me.interactiveId);
bab90f22   Elena.Budnik   format + #5668
359
360
361
362
363
364
						},
						scope: me
					},
					'-',
					{
						text: 'Save Plot',
8c88a270   Erdogan Furkan   10312 - Navigatio...
365
						handler: function () {
bab90f22   Elena.Budnik   format + #5668
366
367
							if (me.hiddenForm == null)
								me.hiddenForm = Ext.create('Ext.form.Panel', {
8c88a270   Erdogan Furkan   10312 - Navigatio...
368
									title: 'hiddenForm',
bab90f22   Elena.Budnik   format + #5668
369
370
371
372
									renderTo: Ext.getBody(),
									standardSubmit: true,
									url: 'php/downloadPlot.php',
									timeout: 120000,
8c88a270   Erdogan Furkan   10312 - Navigatio...
373
									height: 100,
bab90f22   Elena.Budnik   format + #5668
374
									width: 100,
8c88a270   Erdogan Furkan   10312 - Navigatio...
375
376
									hidden: true,
									items: []
bab90f22   Elena.Budnik   format + #5668
377
								});
37e81bff   Benjamin Renard   Direct save of pl...
378

bab90f22   Elena.Budnik   format + #5668
379
380
381
							me.hiddenForm.getForm().submit({
								params: {
									sessionId: sessionID,
8c88a270   Erdogan Furkan   10312 - Navigatio...
382
									interactiveId: me.interactiveId
bab90f22   Elena.Budnik   format + #5668
383
								},
8c88a270   Erdogan Furkan   10312 - Navigatio...
384
385
								success: function (form, action) { },
								failure: function (form, action) { }
bab90f22   Elena.Budnik   format + #5668
386
387
388
							});
						}
					}
37e81bff   Benjamin Renard   Direct save of pl...
389
				]);
8c88a270   Erdogan Furkan   10312 - Navigatio...
390

c2cc7749   Erdogan Furkan   #10098 - Modifica...
391
392
393
394
395
396
				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...
397
398
							var menu = Ext.create('Ext.menu.Menu', { plain: true });
							var realLinks = amdaPlotComp.PlotContextManager.setIntervalsRef(links, menu);
c2cc7749   Erdogan Furkan   #10098 - Modifica...
399
400
401
							me.contextualMenu.add('-');
							me.contextualMenu.add([
								{
1be6ea03   Erdogan Furkan   #10098 - Final co...
402
403
									text: 'Open references (' + realLinks.length + ')',
									menu: menu,
c2cc7749   Erdogan Furkan   #10098 - Modifica...
404
405
406
407
408
409
									scope: me
								}]);
						}
					}
				}

9f08f4eb   Benjamin Renard   Zoom in interacti...
410
411
				me.contextualMenu.showAt(absoluteX, absoluteY);
			}
bab90f22   Elena.Budnik   format + #5668
412
		});
16035364   Benjamin Renard   First commit
413

bab90f22   Elena.Budnik   format + #5668
414
415
		return this.panelImage;
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
416
417

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


bab90f22   Elena.Budnik   format + #5668
421
		this.crtTTFileIndex = configResult.ttFileIndex;
8c88a270   Erdogan Furkan   10312 - Navigatio...
422
423

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

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

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

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

bab90f22   Elena.Budnik   format + #5668
435
436
		this.panelImage.refreshMe();
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
437
438

	updateTimeTableInfo: function () {
bab90f22   Elena.Budnik   format + #5668
439
440
		if (!this.navToolBar)
			return;
8c88a270   Erdogan Furkan   10312 - Navigatio...
441
442

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

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

		var ttTotalField = this.navToolBar.items.get('tt-total-' + this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
451
452
453
		if (ttTotalField)
			ttTotalField.setValue(this.crtContext.page.ttNbIntervals);
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
454
455

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

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

b0a1c31b   Benjamin Renard   Remove multi-plot...
461
		AmdaAction.interactivePlot(obj, function (result, e) {
bab90f22   Elena.Budnik   format + #5668
462
463
			loadMask.hide();
			var t = e.getTransaction();
8c88a270   Erdogan Furkan   10312 - Navigatio...
464
465
466
			if (e.status) {
				if (result) {
					if (result.success) {
488b1401   Benjamin Renard   Interactive multi...
467
						plotModule.updateInteractiveSession(result, false);
9f08f4eb   Benjamin Renard   Zoom in interacti...
468
469
					}
					else
8c88a270   Erdogan Furkan   10312 - Navigatio...
470
						myDesktopApp.errorMsg('Interactive action error - ' + result.message);
9f08f4eb   Benjamin Renard   Zoom in interacti...
471
472
473
474
				}
				else
					myDesktopApp.errorMsg('Cannot execute interactive action');
			}
8c88a270   Erdogan Furkan   10312 - Navigatio...
475
			else {
9f08f4eb   Benjamin Renard   Zoom in interacti...
476
				// FAILURE
8c88a270   Erdogan Furkan   10312 - Navigatio...
477
478
479
				myDesktopApp.errorMsg('Error System - ' + e.message);
			}
		}, this);
bab90f22   Elena.Budnik   format + #5668
480
	},
8c88a270   Erdogan Furkan   10312 - Navigatio...
481
482

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

bab90f22   Elena.Budnik   format + #5668
486
		var commonItemsCfg = [
8c88a270   Erdogan Furkan   10312 - Navigatio...
487
488
489
490
491
492
			'-',
			{
				xtype: 'tbspacer',
				width: 20
			},
			'->',
bab90f22   Elena.Budnik   format + #5668
493
			{
8c88a270   Erdogan Furkan   10312 - Navigatio...
494
				text: 'Get HST Data',
bab90f22   Elena.Budnik   format + #5668
495
				scope: this,
8c88a270   Erdogan Furkan   10312 - Navigatio...
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
				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
516
517
518
			var navigationItemsCfg = [{
				text: 'Previous',
				scope: this,
8c88a270   Erdogan Furkan   10312 - Navigatio...
519
				handler: function () {
bab90f22   Elena.Budnik   format + #5668
520
521
					var ttFileIndex = this.crtTTFileIndex;
					var ttintervalIndex = this.crtContext.page.ttIndex;
8c88a270   Erdogan Furkan   10312 - Navigatio...
522
523
524

					if (ttintervalIndex <= 0 && ttFileIndex > 0) {
						--ttFileIndex;
bab90f22   Elena.Budnik   format + #5668
525
526
527
					}
					else
						--ttintervalIndex;
8c88a270   Erdogan Furkan   10312 - Navigatio...
528
529
					this.callInteractivePlot({ 'action': 'goto', 'interactiveId': this.interactiveId, 'ttFileIndex': ttFileIndex, 'intIndex': ttintervalIndex });
				}
bab90f22   Elena.Budnik   format + #5668
530
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
531
				'-',
bab90f22   Elena.Budnik   format + #5668
532
533
534
			{
				text: 'Next',
				scope: this,
8c88a270   Erdogan Furkan   10312 - Navigatio...
535
				handler: function () {
bab90f22   Elena.Budnik   format + #5668
536
537
					var ttFileIndex = this.crtTTFileIndex;
					var ttintervalIndex = this.crtContext.page.ttIndex;
8c88a270   Erdogan Furkan   10312 - Navigatio...
538
539
540

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

bab90f22   Elena.Budnik   format + #5668
541
542
543
544
545
546
						++ttFileIndex;
						ttintervalIndex = 0;
					}
					else
						++ttintervalIndex;

8c88a270   Erdogan Furkan   10312 - Navigatio...
547
					this.callInteractivePlot({ 'action': 'goto', 'interactiveId': this.interactiveId, 'ttFileIndex': ttFileIndex, 'intIndex': ttintervalIndex });
bab90f22   Elena.Budnik   format + #5668
548
549
				}
			},
535d7638   Menouard AZIB   I have added a co...
550
				'-',
8c88a270   Erdogan Furkan   10312 - Navigatio...
551
			{
46bd4591   Hacene SI HADJ MOHAND   us ok
552
553
				text: 'Use This Time Inteval',
				scope: this,
535d7638   Menouard AZIB   I have added a co...
554
555
556
557
558
559
560
				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());
46bd4591   Hacene SI HADJ MOHAND   us ok
561
562

					var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
535d7638   Menouard AZIB   I have added a co...
563
					plotModule.setTimeInterval(timeObj);
46bd4591   Hacene SI HADJ MOHAND   us ok
564
565
				}
			},
535d7638   Menouard AZIB   I have added a co...
566
567
568
				'-',
			{
				text: 'Go to Interval #',
bab90f22   Elena.Budnik   format + #5668
569
				scope: this,
8c88a270   Erdogan Furkan   10312 - Navigatio...
570
571
				handler: function (bt) {
					var ttGotoNumberField = this.navToolBar.items.get('tt-goto-number-' + this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
572
573
574
575
					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...
576
						this.callInteractivePlot({ 'action': 'goto', 'interactiveId': this.interactiveId, 'ttFileIndex': this.crtTTFileIndex, 'intIndex': goToIndex });
bab90f22   Elena.Budnik   format + #5668
577
578
579
580
				}
			},
			{
				xtype: 'numberfield',
8c88a270   Erdogan Furkan   10312 - Navigatio...
581
582
583
				id: 'tt-goto-number-' + this.interactiveId,
				hideTrigger: true,
				width: 50,
bab90f22   Elena.Budnik   format + #5668
584
585
				minValue: 1
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
586
587
588
589
				' ',
				' ',
				' ',
			{
bab90f22   Elena.Budnik   format + #5668
590
				xtype: 'textfield',
8c88a270   Erdogan Furkan   10312 - Navigatio...
591
				id: 'tt-table-' + this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
592
593
594
595
				labelAlign: 'right',
				labelWidth: 30,
				fieldLabel: 'Table',
				width: 130,
8c88a270   Erdogan Furkan   10312 - Navigatio...
596
				disabled: true
bab90f22   Elena.Budnik   format + #5668
597
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
598
			{
bab90f22   Elena.Budnik   format + #5668
599
				xtype: 'textfield',
8c88a270   Erdogan Furkan   10312 - Navigatio...
600
				id: 'tt-number-' + this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
601
602
603
604
				labelAlign: 'right',
				labelWidth: 30,
				fieldLabel: 'Int #',
				width: 90,
8c88a270   Erdogan Furkan   10312 - Navigatio...
605
				disabled: true
bab90f22   Elena.Budnik   format + #5668
606
			},
8c88a270   Erdogan Furkan   10312 - Navigatio...
607
608
609
			{
				xtype: 'textfield',
				id: 'tt-total-' + this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
610
611
612
613
				labelAlign: 'right',
				labelWidth: 30,
				fieldLabel: 'Total',
				width: 90,
8c88a270   Erdogan Furkan   10312 - Navigatio...
614
				disabled: true
bab90f22   Elena.Budnik   format + #5668
615
616
			}];
		}
8c88a270   Erdogan Furkan   10312 - Navigatio...
617
		else {
bab90f22   Elena.Budnik   format + #5668
618
			var navigationItemsCfg = [
8c88a270   Erdogan Furkan   10312 - Navigatio...
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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
				{
					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
666
667
668
		}

		var toolItemsCfg = navigationItemsCfg;
8c88a270   Erdogan Furkan   10312 - Navigatio...
669
		Ext.each(commonItemsCfg, function (item) {
bab90f22   Elena.Budnik   format + #5668
670
671
			toolItemsCfg.push(item);
		});
8c88a270   Erdogan Furkan   10312 - Navigatio...
672
673

		if (!this.navToolBar) {
bab90f22   Elena.Budnik   format + #5668
674
675
			var toolConfig = {
				dock: 'top',
8c88a270   Erdogan Furkan   10312 - Navigatio...
676
				items: toolItemsCfg
bab90f22   Elena.Budnik   format + #5668
677
678
			};

8c88a270   Erdogan Furkan   10312 - Navigatio...
679
			this.navToolBar = Ext.create('Ext.toolbar.Toolbar', toolConfig);
bab90f22   Elena.Budnik   format + #5668
680
681
682
683
684
685
686
687
		}
		else
			this.navToolBar.add(toolItemsCfg);

		this.navToolBar.setDisabled(isSuperposeMode);

		this.isTTNavBar = isTimeTable;
		this.isSuperposeMode = isSuperposeMode;
8c88a270   Erdogan Furkan   10312 - Navigatio...
688
689
690
	},

	init: function (configResult) {
bab90f22   Elena.Budnik   format + #5668
691
		this.crtContext = configResult.context;
b39c9d1d   Benjamin Renard   Fix interactive n...
692
		this.interactiveId = configResult.interactiveId;
27a055f4   Benjamin Renard   Multiplot (#8314)
693
		this.multiplot = (configResult.multiplot == true);
bab90f22   Elena.Budnik   format + #5668
694
695
696

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

		this.sliderPage = new Ext.slider.Single({
8c88a270   Erdogan Furkan   10312 - Navigatio...
701
702
703
704
705
706
707
708
709
710
711
712
713
714
			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
715
716
					this.panelImage.height = size.height;
					this.panelImage.doComponentLayout();
8c88a270   Erdogan Furkan   10312 - Navigatio...
717
					this.fireEvent('pagesize', this, v);
bab90f22   Elena.Budnik   format + #5668
718
				}
8c88a270   Erdogan Furkan   10312 - Navigatio...
719
720
721
			}
		});

bab90f22   Elena.Budnik   format + #5668
722
723
724
725
		var mouseToolbar = {
			xtype: 'toolbar',
			height: 25,
			dock: 'bottom',
8c88a270   Erdogan Furkan   10312 - Navigatio...
726
			items: [
bab90f22   Elena.Budnik   format + #5668
727
728
729
730
731
				this.coordinatesField,
				'->',
				this.sliderPage
			]
		};
8c88a270   Erdogan Furkan   10312 - Navigatio...
732

bab90f22   Elena.Budnik   format + #5668
733
734
735
736
737
738
739
740
741
742
		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
743
		var plotResultTabPanelConfig = {
8c88a270   Erdogan Furkan   10312 - Navigatio...
744
745
746
			preventHeader: true,
			autoScroll: true,
			items: [this.createPlotImage(configResult.folder, configResult.plotFile)],
bab90f22   Elena.Budnik   format + #5668
747
748
			dockedItems: [this.navToolBar, mouseToolbar],
			plugins: [
8c88a270   Erdogan Furkan   10312 - Navigatio...
749
750
751
752
753
754
755
				{
					ptype: 'plotZoomPlugin',
					pluginId: 'plot-zoom-plugin-id'
				},
				{
					ptype: 'plotExtendShiftPlugin',
					pluginId: 'plot-extendshift-plugin-id'
8c88a270   Erdogan Furkan   10312 - Navigatio...
756
				}],
bab90f22   Elena.Budnik   format + #5668
757
			listeners: {
8c88a270   Erdogan Furkan   10312 - Navigatio...
758
759
				scope: this,
				destroy: function () {
bab90f22   Elena.Budnik   format + #5668
760
761
762
763
764
765
					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
766
767
768
				}
			}
		};
8c88a270   Erdogan Furkan   10312 - Navigatio...
769
770

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