Blame view

js/app/views/PlotTabResultUI.js 22 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
19
20
21
	alias: 'widget.plotTabResult',

	requires: [
		'amdaPlotComp.PlotZoomPlug',
		'amdaPlotComp.PlotExtendShiftPlug',
		'amdaPlotComp.PlotContextManager',
		'amdaPlotComp.PlotResultImage'
	],
18d4a11e   Benjamin Renard   Save and load plo...
22
    
bab90f22   Elena.Budnik   format + #5668
23
24
	panelImage : null,
	crtContext : null,
b39c9d1d   Benjamin Renard   Fix interactive n...
25
	interactiveId : '',
bab90f22   Elena.Budnik   format + #5668
26
27
28
29
	navToolBar : null,
	isTTNavBar : false,
	crtTTFileIndex : 0,
	disableSynchronize: false,
27a055f4   Benjamin Renard   Multiplot (#8314)
30
	multiplot: false,
bab90f22   Elena.Budnik   format + #5668
31
32
	
	hiddenForm: null,
37e81bff   Benjamin Renard   Direct save of pl...
33
    
bab90f22   Elena.Budnik   format + #5668
34
35
36
37
38
39
	constructor: function(config) {
		this.addEvents({'pagesize':true});
		
		this.init(config);	 
		this.callParent(arguments);	 
	},  
27a055f4   Benjamin Renard   Multiplot (#8314)
40
41

        updateMultiplot : function(multiplot) {
b9dc631b   Benjamin Renard   Update plot tab r...
42
            this.multiplot = multiplot;
27a055f4   Benjamin Renard   Multiplot (#8314)
43
44
            this.findParentByType('window').updateTitle(this.multiplot);
        },
16035364   Benjamin Renard   First commit
45
    
bab90f22   Elena.Budnik   format + #5668
46
47
48
49
50
51
52
53
54
55
56
57
	getImageSize : function() {
		if (!this.crtContext)
			return {
				width : 0,
				height : 0
			};
			
		return  {
				width  : this.crtContext.page.width * this.sliderPage.getValue()/100.,
				height : this.crtContext.page.height * this.sliderPage.getValue()/100.
			} 
	},
16035364   Benjamin Renard   First commit
58
    
bab90f22   Elena.Budnik   format + #5668
59
60
61
	getImageUrl: function(resultFolder, plotFile) {
		return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile;
	},
16035364   Benjamin Renard   First commit
62
    
bab90f22   Elena.Budnik   format + #5668
63
	toPixelOnSourceImage : function(value) {
d0b61b72   Benjamin Renard   Show coordinates ...
64
65
66
67
68
69
70
		return value*100/this.sliderPage.getValue();
	},
	
	toPixelOnResultImage : function(value) {
		return value*this.sliderPage.getValue()/100;
	},
	
9f08f4eb   Benjamin Renard   Zoom in interacti...
71
72
73
74
75
76
	createZoomItemsForPanel: function(panelId) {
		var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
		if (zoomPlugin == null)
			return;
		
		var panelContext = amdaPlotComp.PlotContextManager.getPanelById(this.crtContext, panelId);
caff798e   Benjamin Renard   Fix zoom bar for ...
77
		var size = this.getImageSize();
9f08f4eb   Benjamin Renard   Zoom in interacti...
78
79
		
		var me = this;
8b11b1af   Benjamin Renard   Insert intervals ...
80
		var insertIntervalItem = null;
9f08f4eb   Benjamin Renard   Zoom in interacti...
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
		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);
				var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x+panelContext.plotArea.width, sourceXPos);
				var crtTime = new Date(crtTimestamp*1000);
				crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
				zoomPlugin.setMinValue(crtTime);
			};
			
			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);
				var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x+panelContext.plotArea.width, sourceXPos);
				var crtTime = new Date(crtTimestamp*1000);
				crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
				zoomPlugin.setMaxValue(crtTime);
			};
			
			//Events for zoom on a Y axis
			var onMinYValueSelection = function(posY) {
				//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);
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.y+panelContext.plotArea.height, panelContext.plotArea.y, sourceYPos);
				zoomPlugin.setMinValue(crtValue);
			};
			
			var onMaxYValueSelection = function(posY) {
				//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);
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.y+panelContext.plotArea.height, panelContext.plotArea.y, sourceYPos);
				zoomPlugin.setMaxValue(crtValue);
			};
			
			//Events for zoom on X axis
			var onMinXValueSelection = 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);
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x + panelContext.plotArea.width, sourceXPos);
				zoomPlugin.setMinValue(crtValue);
			};
			
			var onMaxXValueSelection = 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);
				var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x + panelContext.plotArea.width, sourceXPos);
				zoomPlugin.setMaxValue(crtValue);
			};
			
			switch (axis.id)
			{
			case 'timeAxis':
				me.contextualMenu.add({
					text:'Zoom on Time Axis',
					handler : function(item, e) {
b39c9d1d   Benjamin Renard   Fix interactive n...
149
						zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
9f08f4eb   Benjamin Renard   Zoom in interacti...
150
						zoomPlugin.resetMinMaxValue();
caff798e   Benjamin Renard   Fix zoom bar for ...
151
						me.panelImage.startZoom(true, 0/*me.toPixelOnResultImage(panelContext.y)*/, size.height /*me.toPixelOnResultImage(panelContext.height)*/, onMinTimeSelection, onMaxTimeSelection);
9f08f4eb   Benjamin Renard   Zoom in interacti...
152
153
154
					},
					scope: this
				});
8b11b1af   Benjamin Renard   Insert intervals ...
155
156
157
				insertIntervalItem = {
					text:'Insert Interval in TimeTable or Catalog',
					handler : function(item, e) {
b39c9d1d   Benjamin Renard   Fix interactive n...
158
						zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
8b11b1af   Benjamin Renard   Insert intervals ...
159
160
161
162
163
						zoomPlugin.resetMinMaxValue();
						me.panelImage.startZoom(true, 0/*me.toPixelOnResultImage(panelContext.y)*/, size.height /*me.toPixelOnResultImage(panelContext.height)*/, onMinTimeSelection, onMaxTimeSelection);
					},
					scope: this
				};
9f08f4eb   Benjamin Renard   Zoom in interacti...
164
165
166
167
168
				break;
			case 'y-left' :
				me.contextualMenu.add({
					text:'Zoom on Y Left Axis',
					handler : function(item, e) {
b39c9d1d   Benjamin Renard   Fix interactive n...
169
						zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
9f08f4eb   Benjamin Renard   Zoom in interacti...
170
171
172
173
174
175
176
177
178
						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) {
b39c9d1d   Benjamin Renard   Fix interactive n...
179
						zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
9f08f4eb   Benjamin Renard   Zoom in interacti...
180
181
182
183
184
185
186
187
188
						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) {
b39c9d1d   Benjamin Renard   Fix interactive n...
189
						zoomPlugin.show(me.interactiveId, axis.id, panelContext.id);
9f08f4eb   Benjamin Renard   Zoom in interacti...
190
191
192
193
194
195
196
197
198
199
200
						zoomPlugin.resetMinMaxValue();
						me.panelImage.startZoom(true, me.toPixelOnResultImage(panelContext.y), me.toPixelOnResultImage(panelContext.height), onMinXValueSelection, onMaxXValueSelection);
					}
				});
				break;
			case 'epochAxis' :
				//Nothing to add
				break;
			}
			
		});
8b11b1af   Benjamin Renard   Insert intervals ...
201
202
203
204
205

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

    getAxisValue: function(axis, pixelMin, pixelMax, pixelVal) {
        var val = amdaPlotComp.PlotContextManager.toAxisValue(axis, pixelMin, pixelMax, pixelVal);
864d0212   Benjamin Renard   Precision set to ...
210
        return parseFloat(val).toPrecision(5);
2ea6eb0d   Benjamin Renard   Fix decimal preci...
211
    },
9f08f4eb   Benjamin Renard   Zoom in interacti...
212
	
d0b61b72   Benjamin Renard   Show coordinates ...
213
214
    createPlotImage: function(resultFolder, plotFile) {
    	var me = this;
18d4a11e   Benjamin Renard   Save and load plo...
215
    	var size = this.getImageSize();
d0b61b72   Benjamin Renard   Show coordinates ...
216
    	this.panelImage = Ext.create('amdaPlotComp.PlotResultImage', {
18d4a11e   Benjamin Renard   Save and load plo...
217
218
219
            src    : this.getImageUrl(resultFolder, plotFile),
            width  : size.width,
            height : size.height,
d0b61b72   Benjamin Renard   Show coordinates ...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
			onMouseMove : function(x, y) {
				if (!me.crtContext)
					return;
				
				var sourceXPos = me.toPixelOnSourceImage(x);
				var sourceYPos = me.toPixelOnSourceImage(y);
				var panel = amdaPlotComp.PlotContextManager.getPanel(me.crtContext, sourceXPos, sourceYPos);
				var text = '';
				if (me.panelImage)
				{
					if (!panel)
					{
						me.panelImage.resetCursor();
						text += 'No panel';
					}
					else
					{
						text += 'Panel Id : ';
						text += panel.id;
						if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos))
						{
							/*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(
									me.toPixelOnResultImage(0),
									me.toPixelOnResultImage(0),
									me.toPixelOnResultImage(me.crtContext.page.width),
									me.toPixelOnResultImage(me.crtContext.page.height),
									x, y);
							
							var xText = '';
							var yLeftText = '';
							var yRightText = '';
							Ext.each(panel.plotArea.axes, function (axis) {
								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);
									xText = crtTime.toJSON();
									break;
								case 'y-left' :
2ea6eb0d   Benjamin Renard   Fix decimal preci...
266
									yLeftText = me.getAxisValue(axis, panel.plotArea.y+panel.plotArea.height, panel.plotArea.y, sourceYPos);
d0b61b72   Benjamin Renard   Show coordinates ...
267
268
									break;
								case 'y-right' :
2ea6eb0d   Benjamin Renard   Fix decimal preci...
269
									yRightText = me.getAxisValue(axis, panel.plotArea.y+panel.plotArea.height, panel.plotArea.y, sourceYPos);
d0b61b72   Benjamin Renard   Show coordinates ...
270
271
									break;
								case 'xaxis_id' :
2ea6eb0d   Benjamin Renard   Fix decimal preci...
272
									xText = me.getAxisValue(axis, panel.plotArea.x, panel.plotArea.x+panel.plotArea.width, sourceXPos);
d0b61b72   Benjamin Renard   Show coordinates ...
273
274
									break;
								case 'epochAxis' :
2ea6eb0d   Benjamin Renard   Fix decimal preci...
275
									xText = me.getAxisValue(axis, panel.plotArea.x, panel.plotArea.x+panel.plotArea.width, sourceXPos);
d0b61b72   Benjamin Renard   Show coordinates ...
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
									break;
								}
								
							});
							
							if (xText != '')
								text += (', X : '+xText);
							if (yLeftText != '')
								text += (', Y Left : '+yLeftText);
							if (yRightText != '')
								text += (', Y Right : '+yRightText);
						}
						else
							me.panelImage.resetCursor();
					}
				}
				me.coordinatesField.setText(text);
			},
9f08f4eb   Benjamin Renard   Zoom in interacti...
294
295
296
297
			onContextMenu : function(absoluteX, absoluteY, imageX, imageY) {
				if (!me.crtContext)
					return;
				
87658ba0   Benjamin Renard   TT Navigation in ...
298
				me.contextualMenu.removeAll(true);
9f08f4eb   Benjamin Renard   Zoom in interacti...
299
300
301
302
303
304
305
				
				var sourceXPos = me.toPixelOnSourceImage(imageX);
				var sourceYPos = me.toPixelOnSourceImage(imageY);
				var panel = amdaPlotComp.PlotContextManager.getPanel(me.crtContext, sourceXPos, sourceYPos);
				
				if (panel != null)
				{
c9071a43   Benjamin Renard   Add instant plot ...
306
307
308
					if (panel.plotArea.hasSpectro)
					{
						me.contextualMenu.add([
bab90f22   Elena.Budnik   format + #5668
309
310
311
312
313
314
315
316
317
318
							{
								text:'Instant cut at this position',
								handler : function ()
								{
									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);
									var crtTime = new Date(crtTimestamp*1000);
									crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
b39c9d1d   Benjamin Renard   Fix interactive n...
319
									me.callInteractivePlot({'action' : 'instant', 'interactiveId' : this.interactiveId, 'panelId' : panel.id, 'time' : crtTime});
bab90f22   Elena.Budnik   format + #5668
320
321
322
323
								},
								scope: me
							},
							'-' 
c9071a43   Benjamin Renard   Add instant plot ...
324
325
						]);
					}
9f08f4eb   Benjamin Renard   Zoom in interacti...
326
327
328
					if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos))
						me.createZoomItemsForPanel(panel.id);
				}
8b11b1af   Benjamin Renard   Insert intervals ...
329

9f08f4eb   Benjamin Renard   Zoom in interacti...
330
331
332
				if (me.contextualMenu.items.getCount() > 0)
					me.contextualMenu.add('-');
					
37e81bff   Benjamin Renard   Direct save of pl...
333
				me.contextualMenu.add([
bab90f22   Elena.Budnik   format + #5668
334
					{
c4fa05f8   Elena.Budnik   title change
335
						text:'Extend/Shift Time interval',
c49cd4b0   Elena.Budnik   redmine 6302 : sh...
336
						disabled : me.isTTNavBar,
bab90f22   Elena.Budnik   format + #5668
337
338
339
						handler : function ()
						{
							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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
						},
						scope: me
					},
					'-',
					{
						text: 'Save Plot',
						handler : function ()
						{
							if (me.hiddenForm == null)
								me.hiddenForm = Ext.create('Ext.form.Panel', {
									title:'hiddenForm',
									renderTo: Ext.getBody(),
									standardSubmit: true,
									url: 'php/downloadPlot.php',
									timeout: 120000,
									height:100,
									width: 100,
									hidden:true,
									items:[]
								});
37e81bff   Benjamin Renard   Direct save of pl...
361

bab90f22   Elena.Budnik   format + #5668
362
363
364
							me.hiddenForm.getForm().submit({
								params: {
									sessionId: sessionID,
b39c9d1d   Benjamin Renard   Fix interactive n...
365
									interactiveId : me.interactiveId
bab90f22   Elena.Budnik   format + #5668
366
367
368
369
370
371
								},
								success: function(form, action) {},
								failure: function(form, action) {}
							});
						}
					}
37e81bff   Benjamin Renard   Direct save of pl...
372
				]);
9f08f4eb   Benjamin Renard   Zoom in interacti...
373
374
375
				
				me.contextualMenu.showAt(absoluteX, absoluteY);
			}
bab90f22   Elena.Budnik   format + #5668
376
		});
16035364   Benjamin Renard   First commit
377

bab90f22   Elena.Budnik   format + #5668
378
379
		return this.panelImage;
	},
16035364   Benjamin Renard   First commit
380
    
bab90f22   Elena.Budnik   format + #5668
381
382
	updatePlotImage: function(configResult, newPlot) {
		this.crtContext = configResult.context;
ff29610c   Hacene SI HADJ MOHAND   7522 Ok
383
                                        
bab90f22   Elena.Budnik   format + #5668
384
385
386
387
388
389
390
391
392
393
394
		
		this.crtTTFileIndex = configResult.ttFileIndex;
		
		if (this.isTTNavBar != (!configResult.isInterval) || (this.isSuperposeMode != this.crtContext.page.superposeMode))
		{
			//Update navigation bar
			this.updateNavToolBar(!configResult.isInterval, this.crtContext.page.superposeMode);
		}
		
		this.updateTimeTableInfo();
		
bab90f22   Elena.Budnik   format + #5668
395
396
397
398
399
400
401
		this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile));
		
		var size = this.getImageSize();
		this.panelImage.setSize(size.width, size.height);
		
		this.panelImage.refreshMe();
	},
16035364   Benjamin Renard   First commit
402
    
bab90f22   Elena.Budnik   format + #5668
403
404
405
406
407
	updateTimeTableInfo: function()
	{ 	
		if (!this.navToolBar)
			return;
		
b39c9d1d   Benjamin Renard   Fix interactive n...
408
		var ttNameField = this.navToolBar.items.get('tt-table-'+this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
409
410
411
		if (ttNameField)
			ttNameField.setValue(this.crtContext.page.ttName);
		
b39c9d1d   Benjamin Renard   Fix interactive n...
412
		var ttNumberField = this.navToolBar.items.get('tt-number-'+this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
413
414
415
		if (ttNumberField)
			ttNumberField.setValue(this.crtContext.page.ttIndex + 1);
		
b39c9d1d   Benjamin Renard   Fix interactive n...
416
		var ttTotalField = this.navToolBar.items.get('tt-total-'+this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
417
418
419
		if (ttTotalField)
			ttTotalField.setValue(this.crtContext.page.ttNbIntervals);
	},
87658ba0   Benjamin Renard   TT Navigation in ...
420
    
bab90f22   Elena.Budnik   format + #5668
421
422
423
424
	callInteractivePlot : function(obj) {
		loadMask.show(true);
		
		var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
27a055f4   Benjamin Renard   Multiplot (#8314)
425
		obj['multiplot'] = this.multiplot;
bab90f22   Elena.Budnik   format + #5668
426
		
b0a1c31b   Benjamin Renard   Remove multi-plot...
427
		AmdaAction.interactivePlot(obj, function (result, e) {
bab90f22   Elena.Budnik   format + #5668
428
429
			loadMask.hide();
			var t = e.getTransaction();
9f08f4eb   Benjamin Renard   Zoom in interacti...
430
431
432
433
434
435
			if (e.status) 
			{	
				if (result)
				{
					if (result.success)
					{
488b1401   Benjamin Renard   Interactive multi...
436
						plotModule.updateInteractiveSession(result, false);
9f08f4eb   Benjamin Renard   Zoom in interacti...
437
438
439
440
441
442
443
444
445
446
447
448
					}
					else
						myDesktopApp.errorMsg('Interactive action error - '+result.message);
				}
				else
					myDesktopApp.errorMsg('Cannot execute interactive action');
			}
			else
			{
				// FAILURE
				myDesktopApp.errorMsg('Error System - '+e.message);
			} 
bab90f22   Elena.Budnik   format + #5668
449
450
		},this);	
	},
a971060f   Benjamin Renard   Fix some bugs
451
    
bab90f22   Elena.Budnik   format + #5668
452
453
454
455
	updateNavToolBar : function(isTimeTable, isSuperposeMode) {
		if (this.navToolBar)
			this.navToolBar.removeAll(true);
		
bab90f22   Elena.Budnik   format + #5668
456
		var commonItemsCfg = [
db88c034   Elena.Budnik   redmine 5668 corr...
457
		'-',
bab90f22   Elena.Budnik   format + #5668
458
459
		{
			xtype: 'tbspacer',
db88c034   Elena.Budnik   redmine 5668 corr...
460
461
			width: 20
		},		
bab90f22   Elena.Budnik   format + #5668
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
		'->',
		{
			text: 'Get HST Data',
			scope: this,
			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){
			var navigationItemsCfg = [{
				text: 'Previous',
				scope: this,
				handler: function(){
					var ttFileIndex = this.crtTTFileIndex;
					var ttintervalIndex = this.crtContext.page.ttIndex;
					
ff29610c   Hacene SI HADJ MOHAND   7522 Ok
494
495
					if (ttintervalIndex <= 0 && ttFileIndex>0){  
                                                                                                                     --ttFileIndex;                                                                                                      
bab90f22   Elena.Budnik   format + #5668
496
497
498
					}
					else
						--ttintervalIndex;
b39c9d1d   Benjamin Renard   Fix interactive n...
499
					this.callInteractivePlot({'action' : 'goto', 'interactiveId' : this.interactiveId, 'ttFileIndex' : ttFileIndex, 'intIndex' : ttintervalIndex});
bab90f22   Elena.Budnik   format + #5668
500
501
502
503
504
505
506
507
508
509
510
				}                   
			},
			'-',
			{
				text: 'Next',
				scope: this,
				handler: function(){
					var ttFileIndex = this.crtTTFileIndex;
					var ttintervalIndex = this.crtContext.page.ttIndex;
					
					if (ttintervalIndex >= this.crtContext.page.ttNbIntervals-1){
ff29610c   Hacene SI HADJ MOHAND   7522 Ok
511
                                                                                                          
bab90f22   Elena.Budnik   format + #5668
512
513
514
515
516
517
						++ttFileIndex;
						ttintervalIndex = 0;
					}
					else
						++ttintervalIndex;

b39c9d1d   Benjamin Renard   Fix interactive n...
518
					this.callInteractivePlot({'action' : 'goto', 'interactiveId' : this.interactiveId, 'ttFileIndex' : ttFileIndex, 'intIndex' : ttintervalIndex});
bab90f22   Elena.Budnik   format + #5668
519
520
521
522
523
524
525
				}
			},
			'-',
			{		 
				text: 'Go to Interval #',  
				scope: this,
				handler: function(bt){
b39c9d1d   Benjamin Renard   Fix interactive n...
526
					var ttGotoNumberField = this.navToolBar.items.get('tt-goto-number-'+this.interactiveId);
bab90f22   Elena.Budnik   format + #5668
527
528
529
530
					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
b39c9d1d   Benjamin Renard   Fix interactive n...
531
						this.callInteractivePlot({'action' : 'goto', 'interactiveId' : this.interactiveId, 'ttFileIndex' : this.crtTTFileIndex, 'intIndex' : goToIndex});
bab90f22   Elena.Budnik   format + #5668
532
533
534
535
				}
			},
			{
				xtype: 'numberfield',
b39c9d1d   Benjamin Renard   Fix interactive n...
536
				id : 'tt-goto-number-'+this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
537
538
539
540
541
542
543
544
545
				hideTrigger: true,                        
				width: 50, 
				minValue: 1
			},
			' ',
			' ',
			' ',    
			{   
				xtype: 'textfield',
b39c9d1d   Benjamin Renard   Fix interactive n...
546
				id: 'tt-table-'+this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
547
548
549
550
551
552
553
554
				labelAlign: 'right',
				labelWidth: 30,
				fieldLabel: 'Table',
				width: 130,
				disabled : true			
			},
			{		               
				xtype: 'textfield',
b39c9d1d   Benjamin Renard   Fix interactive n...
555
				id: 'tt-number-'+this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
556
557
558
559
560
561
562
563
				labelAlign: 'right',
				labelWidth: 30,
				fieldLabel: 'Int #',
				width: 90,
				disabled : true
			},
			{                        
				xtype: 'textfield',  
b39c9d1d   Benjamin Renard   Fix interactive n...
564
				id: 'tt-total-'+this.interactiveId,
bab90f22   Elena.Budnik   format + #5668
565
566
567
568
569
570
571
572
573
574
575
576
577
578
				labelAlign: 'right',
				labelWidth: 30,
				fieldLabel: 'Total',
				width: 90,
				disabled : true    
			}];
		}
		else
		{
			var navigationItemsCfg = [
			{
				text: 'Backward', 
				scope: this,
				handler: function(){
b39c9d1d   Benjamin Renard   Fix interactive n...
579
					this.callInteractivePlot({'action' : 'backward', 'interactiveId' : this.interactiveId});
bab90f22   Elena.Budnik   format + #5668
580
581
582
583
584
585
586
				}
			},
			'-',
			{
				text: '1/2 Backward',
				scope: this,
				handler: function(){
b39c9d1d   Benjamin Renard   Fix interactive n...
587
					this.callInteractivePlot({'action' : 'halfbackward', 'interactiveId' : this.interactiveId});
bab90f22   Elena.Budnik   format + #5668
588
589
590
591
592
593
594
				}
			},
			'-',
			{
				text: '1/2 Forward',
				scope: this,
				handler: function(){
b39c9d1d   Benjamin Renard   Fix interactive n...
595
					this.callInteractivePlot({'action' : 'halfforward', 'interactiveId' : this.interactiveId});
bab90f22   Elena.Budnik   format + #5668
596
597
598
599
600
601
602
				}
			},
			'-',
			{
				text: 'Forward',
				scope: this,
				handler: function(){
b39c9d1d   Benjamin Renard   Fix interactive n...
603
					this.callInteractivePlot({'action' : 'forward', 'interactiveId' : this.interactiveId});
bab90f22   Elena.Budnik   format + #5668
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
				}
			}];
		}

		var toolItemsCfg = navigationItemsCfg;
		Ext.each(commonItemsCfg, function(item){
			toolItemsCfg.push(item);
		});
	
		if (!this.navToolBar)
		{
			var toolConfig = {
				dock: 'top',
				items: toolItemsCfg                      
			};

			this.navToolBar =  Ext.create('Ext.toolbar.Toolbar', toolConfig);
		}
		else
			this.navToolBar.add(toolItemsCfg);

		this.navToolBar.setDisabled(isSuperposeMode);

		this.isTTNavBar = isTimeTable;
		this.isSuperposeMode = isSuperposeMode;
	}, 
	
	init: function(configResult){
		this.crtContext = configResult.context;
b39c9d1d   Benjamin Renard   Fix interactive n...
633
		this.interactiveId = configResult.interactiveId;
27a055f4   Benjamin Renard   Multiplot (#8314)
634
		this.multiplot = (configResult.multiplot == true);
bab90f22   Elena.Budnik   format + #5668
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
666
667
668
669
670
671
672
673

		this.coordinatesField = new Ext.toolbar.TextItem({
			width: 300,
			text : ''
		});

		this.sliderPage = new Ext.slider.Single({
				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;
					this.panelImage.height = size.height;
					this.panelImage.doComponentLayout();
					this.fireEvent('pagesize',this,v);
						}
				}
			});
	
		var mouseToolbar = {
			xtype: 'toolbar',
			height: 25,
			dock: 'bottom',
			items:[
				this.coordinatesField,
				'->',
				this.sliderPage
			]
		};
d0b61b72   Benjamin Renard   Show coordinates ...
674
            
bab90f22   Elena.Budnik   format + #5668
675
676
677
678
679
680
681
682
683
684
		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
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
		var plotResultTabPanelConfig = {
			preventHeader : true,
			autoScroll: true,       
			items: [ this.createPlotImage(configResult.folder, configResult.plotFile)],
			dockedItems: [this.navToolBar, mouseToolbar],
			plugins: [
			{
				ptype: 'plotZoomPlugin',
				pluginId : 'plot-zoom-plugin-id'
			},
			{
				ptype: 'plotExtendShiftPlugin',
				pluginId : 'plot-extendshift-plugin-id'
			}],
			listeners: {
				scope : this,
				destroy : function () {
					var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
					if (zoomPlugin)
						zoomPlugin.close();
					var exttendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id');
					if (exttendShiftPlugin)
						exttendShiftPlugin.close();
				}
			}
		};
 
		Ext.apply(this , plotResultTabPanelConfig);	
	}
});