Blame view

js/app/views/PlotTabResultUI.js 25.3 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    
18d4a11e   Benjamin Renard   Save and load plo...
8
 * @version  $Id: PlotTabResultUI.js benjamin $
16035364   Benjamin Renard   First commit
9
10
11
12
13
14
15
16
17
18
19
20
 ********************************************************************************
 *    FT Id     :   Date   : Name - Description
 *******************************************************************************
 *              
 */

Ext.define('amdaUI.PlotTabResultUI', {
    extend: 'Ext.panel.Panel',
 
    alias: 'widget.plotTabResult',

    requires: [
9f08f4eb   Benjamin Renard   Zoom in interacti...
21
        'amdaPlotComp.PlotZoomPlug',
b74e48d4   Benjamin Renard   Add Extend/Shift ...
22
        'amdaPlotComp.PlotExtendShiftPlug',
d0b61b72   Benjamin Renard   Show coordinates ...
23
        'amdaPlotComp.PlotContextManager'
16035364   Benjamin Renard   First commit
24
25
    ],
    
d0b61b72   Benjamin Renard   Show coordinates ...
26
27
    panelImage : null,
    crtContext : null,
9f08f4eb   Benjamin Renard   Zoom in interacti...
28
    tabId : '',
87658ba0   Benjamin Renard   TT Navigation in ...
29
30
31
32
    multiPlotCheck : null,
    navToolBar : null,
    isTTNavBar : false,
    crtTTFileIndex : 0,
488b1401   Benjamin Renard   Interactive multi...
33
    disableSynchronize: false,
18d4a11e   Benjamin Renard   Save and load plo...
34
    
37e81bff   Benjamin Renard   Direct save of pl...
35
36
    hiddenForm: null,
    
16035364   Benjamin Renard   First commit
37
    constructor: function(config) {
16035364   Benjamin Renard   First commit
38
39
40
41
42
43
        this.addEvents({'pagesize':true});
        
        this.init(config);	 
        this.callParent(arguments);	 
    },  
    
18d4a11e   Benjamin Renard   Save and load plo...
44
    getImageSize : function() {
d0b61b72   Benjamin Renard   Show coordinates ...
45
46
47
48
49
50
51
52
53
    	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.
18d4a11e   Benjamin Renard   Save and load plo...
54
	    } 
16035364   Benjamin Renard   First commit
55
56
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
57
58
    getImageUrl: function(resultFolder, plotFile) {
    	return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile;
16035364   Benjamin Renard   First commit
59
60
    },
    
488b1401   Benjamin Renard   Interactive multi...
61
    getInteractiveMultiPlotState: function() {
6c154091   Benjamin Renard   Disabled nav bar ...
62
63
    	if (!this.multiPlotCheck)
    		return false;
488b1401   Benjamin Renard   Interactive multi...
64
65
66
    	return this.multiPlotCheck.getValue();
    },
    
d0b61b72   Benjamin Renard   Show coordinates ...
67
68
69
70
71
72
73
74
    toPixelOnSourceImage : function(value) {
		return value*100/this.sliderPage.getValue();
	},
	
	toPixelOnResultImage : function(value) {
		return value*this.sliderPage.getValue()/100;
	},
	
9f08f4eb   Benjamin Renard   Zoom in interacti...
75
76
77
78
79
80
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
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
	createZoomItemsForPanel: function(panelId) {
		var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
		if (zoomPlugin == null)
			return;
		
		var panelContext = amdaPlotComp.PlotContextManager.getPanelById(this.crtContext, panelId);
		
		var me = this;
		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) {
						zoomPlugin.show(me.tabId, axis.id, panelContext.id);
						zoomPlugin.resetMinMaxValue();
						me.panelImage.startZoom(true, me.toPixelOnResultImage(panelContext.y), 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.tabId, 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.tabId, 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.tabId, 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;
			}
			
		});
	},
	
d0b61b72   Benjamin Renard   Show coordinates ...
196
197
    createPlotImage: function(resultFolder, plotFile) {
    	var me = this;
18d4a11e   Benjamin Renard   Save and load plo...
198
    	var size = this.getImageSize();
d0b61b72   Benjamin Renard   Show coordinates ...
199
    	this.panelImage = Ext.create('amdaPlotComp.PlotResultImage', {
18d4a11e   Benjamin Renard   Save and load plo...
200
201
202
            src    : this.getImageUrl(resultFolder, plotFile),
            width  : size.width,
            height : size.height,
d0b61b72   Benjamin Renard   Show coordinates ...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
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
			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' :
									yLeftText = parseFloat(amdaPlotComp.PlotContextManager.toAxisValue(axis, panel.plotArea.y+panel.plotArea.height, panel.plotArea.y, sourceYPos).toPrecision(2));
									break;
								case 'y-right' :
									yRightText = parseFloat(amdaPlotComp.PlotContextManager.toAxisValue(axis, panel.plotArea.y+panel.plotArea.height, panel.plotArea.y, sourceYPos).toPrecision(2));
									break;
								case 'xaxis_id' :
									xText = parseFloat(amdaPlotComp.PlotContextManager.toAxisValue(axis, panel.plotArea.x, panel.plotArea.x+panel.plotArea.width, sourceXPos).toPrecision(2));
									break;
								case 'epochAxis' :
6c154091   Benjamin Renard   Disabled nav bar ...
258
									xText = parseFloat(amdaPlotComp.PlotContextManager.toAxisValue(axis, panel.plotArea.x, panel.plotArea.x+panel.plotArea.width, sourceXPos).toPrecision(2));
d0b61b72   Benjamin Renard   Show coordinates ...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
									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...
277
278
279
280
			onContextMenu : function(absoluteX, absoluteY, imageX, imageY) {
				if (!me.crtContext)
					return;
				
87658ba0   Benjamin Renard   TT Navigation in ...
281
				me.contextualMenu.removeAll(true);
9f08f4eb   Benjamin Renard   Zoom in interacti...
282
283
284
285
286
287
288
				
				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 ...
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
					if (panel.plotArea.hasSpectro)
					{
						me.contextualMenu.add([
						                       {
						                    	   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());
						                    		   me.callInteractivePlot({'action' : 'instant', 'tabId' : this.tabId, 'panelId' : panel.id, 'time' : crtTime});
						                    	   },
						                    	   scope: me
						                       },
						                       '-'             
						]);
					}
9f08f4eb   Benjamin Renard   Zoom in interacti...
309
310
311
312
313
314
315
					if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos))
						me.createZoomItemsForPanel(panel.id);
				}
				
				if (me.contextualMenu.items.getCount() > 0)
					me.contextualMenu.add('-');
					
37e81bff   Benjamin Renard   Direct save of pl...
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
				me.contextualMenu.add([
				                       {
				                    	   text:'Extend/Shift Time request',
				                    	   handler : function ()
				                    	   {
				                    		   var extendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id');
				                    		   extendShiftPlugin.show(me.tabId);
				                    	   },
				                    	   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:[
				                    				   ]
				                    			   });

				                    		   me.hiddenForm.getForm().submit({
				                    			   params: {
				                    				   sessionId: sessionID,
				                    				   tabId : me.tabId
				                    			   },
				                                   success: function(form, action) {
				                                   },
				                                   failure: function(form, action) {
				                                   }
				                    		   });
				                    	   }
				                       }
				]);
9f08f4eb   Benjamin Renard   Zoom in interacti...
358
359
360
				
				me.contextualMenu.showAt(absoluteX, absoluteY);
			}
16035364   Benjamin Renard   First commit
361
362
363
        });

        return this.panelImage;
16035364   Benjamin Renard   First commit
364
365
    },
    
87658ba0   Benjamin Renard   TT Navigation in ...
366
    updatePlotImage: function(configResult, newPlot) {
d0b61b72   Benjamin Renard   Show coordinates ...
367
    	this.crtContext = configResult.context;
18d4a11e   Benjamin Renard   Save and load plo...
368
    	
87658ba0   Benjamin Renard   TT Navigation in ...
369
370
    	this.crtTTFileIndex = configResult.ttFileIndex;
    	
6c154091   Benjamin Renard   Disabled nav bar ...
371
    	if (this.isTTNavBar != (!configResult.isInterval) || (this.isSuperposeMode != this.crtContext.page.superposeMode))
87658ba0   Benjamin Renard   TT Navigation in ...
372
373
    	{
    		//Update navigation bar
6c154091   Benjamin Renard   Disabled nav bar ...
374
    		this.updateNavToolBar(!configResult.isInterval, this.crtContext.page.superposeMode);
87658ba0   Benjamin Renard   TT Navigation in ...
375
376
377
378
    	}
    	
    	this.updateTimeTableInfo();
    	
6c154091   Benjamin Renard   Disabled nav bar ...
379
380
381
382
383
384
385
    	if (this.multiPlotCheck)
    	{
    		this.disableSynchronize = true;
    		this.multiPlotCheck.setValue(configResult.multiplot);
    		this.disableSynchronize = false;
    	}
    		
18d4a11e   Benjamin Renard   Save and load plo...
386
387
388
389
390
391
    	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
392
393
    },
    
87658ba0   Benjamin Renard   TT Navigation in ...
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
    updateTimeTableInfo: function()
    { 	
    	if (!this.navToolBar)
    		return;
    	
    	var ttNameField = this.navToolBar.items.get('tt-table-'+this.tabId);
    	if (ttNameField)
    		ttNameField.setValue(this.crtContext.page.ttName);
    	
    	var ttNumberField = this.navToolBar.items.get('tt-number-'+this.tabId);
    	if (ttNumberField)
    		ttNumberField.setValue(this.crtContext.page.ttIndex + 1);
    	
    	var ttTotalField = this.navToolBar.items.get('tt-total-'+this.tabId);
    	if (ttTotalField)
    		ttTotalField.setValue(this.crtContext.page.ttNbIntervals);
    },
    
9f08f4eb   Benjamin Renard   Zoom in interacti...
412
413
    callInteractivePlot : function(obj) {
    	loadMask.show(true);
488b1401   Benjamin Renard   Interactive multi...
414
415
416
417
418
    	
    	var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
    	var multiPlotState = plotModule.getInteractiveMultiPlotState();
    	
    	AmdaAction.interactivePlot(obj, multiPlotState, function (result, e) {
9f08f4eb   Benjamin Renard   Zoom in interacti...
419
420
421
422
423
424
425
426
    		loadMask.hide();
    		var t = e.getTransaction();
			if (e.status) 
			{	
				if (result)
				{
					if (result.success)
					{
488b1401   Benjamin Renard   Interactive multi...
427
						plotModule.updateInteractiveSession(result, false);
9f08f4eb   Benjamin Renard   Zoom in interacti...
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
					}
					else
						myDesktopApp.errorMsg('Interactive action error - '+result.message);
				}
				else
					myDesktopApp.errorMsg('Cannot execute interactive action');
			}
			else
			{
				// FAILURE
				myDesktopApp.errorMsg('Error System - '+e.message);
			} 
    	},this);	
    },
    
6c154091   Benjamin Renard   Disabled nav bar ...
443
    updateNavToolBar : function(isTimeTable, isSuperposeMode) {
87658ba0   Benjamin Renard   TT Navigation in ...
444
445
446
447
448
449
450
    	if (this.navToolBar)
    		this.navToolBar.removeAll(true);
    	
    	this.multiPlotCheck = Ext.create('Ext.form.field.Checkbox', {
    		boxLabel : 'Linked to Multi Plot Mode',
    		scope: this,
        	handler: function(check, checked) {
488b1401   Benjamin Renard   Interactive multi...
451
452
453
454
        		if (!this.disableSynchronize)
        			this.callInteractivePlot({'action' : 'synchronize', 'tabId' : this.tabId});
        	},
        	scope: this
87658ba0   Benjamin Renard   TT Navigation in ...
455
456
457
458
459
460
461
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
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
    	});
    	
    	var commonItemsCfg = [
    	        {
    	        	xtype: 'tbspacer',
    	        	width: 50
    	        },
    	        this.multiPlotCheck,
    	        '->',
    	        {
    	        	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;
			        		
			        		if (ttintervalIndex <= 0)
			        		{
			        			if (ttFileIndex <= 0)
			        			{
			        				myDesktopApp.errorMsg('You are on the first interval of your request');
			        				return;
			        			}
			        			else
			        			{
			        				--ttFileIndex;
			        				ttintervalIndex = 0;
			        			}
			        		}
			        		else
			        			--ttintervalIndex;
			        		this.callInteractivePlot({'action' : 'goto', 'tabId' : this.tabId, 'ttFileIndex' : ttFileIndex, 'intIndex' : ttintervalIndex});
			        	}                   
			        },
			        '-',
			        {
			        	text: 'Next',
			        	scope: this,
			        	handler: function(){
			        		var ttFileIndex = this.crtTTFileIndex;
			        		var ttintervalIndex = this.crtContext.page.ttIndex;
			        		
			        		if (ttintervalIndex >= this.crtContext.page.ttNbIntervals-1)
			        		{
			        			++ttFileIndex;
			        			ttintervalIndex = 0;
			        		}
			        		else
			        			++ttintervalIndex;
			        		this.callInteractivePlot({'action' : 'goto', 'tabId' : this.tabId, 'ttFileIndex' : ttFileIndex, 'intIndex' : ttintervalIndex});
			        	}
			        },
			        '-',
			        {		 
			        	text: 'Go to Interval #',  
			        	scope: this,
			        	handler: function(bt){
			        		var ttGotoNumberField = this.navToolBar.items.get('tt-goto-number-'+this.tabId);
			        		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
			        			this.callInteractivePlot({'action' : 'goto', 'tabId' : this.tabId, 'ttFileIndex' : this.crtTTFileIndex, 'intIndex' : goToIndex});
			        	}
			        },
			        {
			        	xtype: 'numberfield',
			        	id : 'tt-goto-number-'+this.tabId,
			        	hideTrigger: true,                        
			        	width: 40, 
			        	minValue: 1			
			        },
			        ' ',
			        ' ',
			        ' ',		    			    
			        {   
			        	xtype: 'textfield',
			        	id: 'tt-table-'+this.tabId,
			        	labelAlign: 'right',
			        	labelWidth: 30,
			        	fieldLabel: 'Table',
			        	width: 130,
			        	disabled : true			
			        },
			        {		               
			        	xtype: 'textfield',
			        	id: 'tt-number-'+this.tabId,
			        	labelAlign: 'right',
			        	labelWidth: 30,
			        	fieldLabel: 'Int #',
			        	width: 70,
			        	disabled : true
			        },
			        {                        
			        	xtype: 'textfield',  
			        	id: 'tt-total-'+this.tabId,
			        	labelAlign: 'right',
			        	labelWidth: 30,
			        	fieldLabel: 'Total',
			        	width: 70,
			        	disabled : true    
			        }
    		];
    	}
    	else
    	{
    		var navigationItemsCfg = [
    		        {
    		        	text: 'Backward', 
    		        	scope: this,
    		        	handler: function(){
    		        		this.callInteractivePlot({'action' : 'backward', 'tabId' : this.tabId});
    		        	}
    		        },
    		        '-',
    		        {
    		        	text: '1/2 Backward',
    		        	scope: this,
    		        	handler: function(){
    		        		this.callInteractivePlot({'action' : 'halfbackward', 'tabId' : this.tabId});
    		        	}
    		        },
    		        '-',
    		        {
    		        	text: '1/2 Forward',
    		        	scope: this,
    		        	handler: function(){
    		        		this.callInteractivePlot({'action' : 'halfforward', 'tabId' : this.tabId});
    		        	}
    		        },
    		        '-',
    		        {
    		        	text: 'Forward',
    		        	scope: this,
    		        	handler: function(){
    		        		this.callInteractivePlot({'action' : 'forward', 'tabId' : this.tabId});
    		        	}
    		        }               
    		];
a971060f   Benjamin Renard   Fix some bugs
622
    	}
87658ba0   Benjamin Renard   TT Navigation in ...
623
624
625
626
627
628
629
630
631
    	
    	var toolItemsCfg = navigationItemsCfg;
    	Ext.each(commonItemsCfg, function(item){
    		toolItemsCfg.push(item);
    	});
    	
    	if (!this.navToolBar)
    	{
    		var toolConfig = {
a971060f   Benjamin Renard   Fix some bugs
632
    				dock: 'top',
87658ba0   Benjamin Renard   TT Navigation in ...
633
    				items: toolItemsCfg                      
a971060f   Benjamin Renard   Fix some bugs
634
    		};
87658ba0   Benjamin Renard   TT Navigation in ...
635
636
    	
    		this.navToolBar =  Ext.create('Ext.toolbar.Toolbar', toolConfig);
a971060f   Benjamin Renard   Fix some bugs
637
    	}
87658ba0   Benjamin Renard   TT Navigation in ...
638
639
640
    	else
    		this.navToolBar.add(toolItemsCfg);
    	
6c154091   Benjamin Renard   Disabled nav bar ...
641
642
    	this.navToolBar.setDisabled(isSuperposeMode);
    	
87658ba0   Benjamin Renard   TT Navigation in ...
643
    	this.isTTNavBar = isTimeTable;
6c154091   Benjamin Renard   Disabled nav bar ...
644
    	this.isSuperposeMode = isSuperposeMode;
a971060f   Benjamin Renard   Fix some bugs
645
646
    }, 
    
18d4a11e   Benjamin Renard   Save and load plo...
647
    init: function(configResult){
d0b61b72   Benjamin Renard   Show coordinates ...
648
    	this.crtContext = configResult.context;
9f08f4eb   Benjamin Renard   Zoom in interacti...
649
    	this.tabId = configResult.tabId;
d0b61b72   Benjamin Renard   Show coordinates ...
650
651
652
653
654
    	
        this.coordinatesField = new Ext.toolbar.TextItem({
            width: 300,
            text : ''
        });
18d4a11e   Benjamin Renard   Save and load plo...
655
656
657
658
659
660
661
662
663
664
665
666
667
    	
    	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)
                {
9f08f4eb   Benjamin Renard   Zoom in interacti...
668
669
                	var zoomPlugin = this.getPlugin('plot-zoom-plugin-id');
                	zoomPlugin.close();
18d4a11e   Benjamin Renard   Save and load plo...
670
671
672
673
674
675
        			var size = this.getImageSize();	 
        			this.panelImage.width  = size.width;
        			this.panelImage.height = size.height;
        			this.panelImage.doComponentLayout();
        			this.fireEvent('pagesize',this,v);
                }
16035364   Benjamin Renard   First commit
676
            }
18d4a11e   Benjamin Renard   Save and load plo...
677
        });
16035364   Benjamin Renard   First commit
678
    	
d0b61b72   Benjamin Renard   Show coordinates ...
679
680
681
682
683
684
    	var mouseToolbar = {
    		xtype: 'toolbar',
    		height: 25,
            dock: 'bottom',
            items:[
                   this.coordinatesField,
9f08f4eb   Benjamin Renard   Zoom in interacti...
685
                   '->',
d0b61b72   Benjamin Renard   Show coordinates ...
686
687
688
689
                   this.sliderPage
            ]
    	};
            
9f08f4eb   Benjamin Renard   Zoom in interacti...
690
691
692
693
694
    	this.contextualMenu = Ext.create('Ext.menu.Menu', {
    		width: 200,
    		plain: true,
    		items: []
    	});
d0b61b72   Benjamin Renard   Show coordinates ...
695
    	
6c154091   Benjamin Renard   Disabled nav bar ...
696
    	this.updateNavToolBar(!configResult.isInterval, this.crtContext.page.superposeMode);
87658ba0   Benjamin Renard   TT Navigation in ...
697
698
699
    	
    	this.updateTimeTableInfo();
    	
6c154091   Benjamin Renard   Disabled nav bar ...
700
701
702
703
704
705
706
    	if (this.multiPlotCheck)
    	{
    		this.disableSynchronize = true;
    		this.multiPlotCheck.setValue(configResult.multiplot);
    		this.disableSynchronize = false;
    	}
    		
18d4a11e   Benjamin Renard   Save and load plo...
707
708
709
710
    	var plotResultTabPanelConfig = {
    			preventHeader : true,
                autoScroll: true,       
                items: [
d0b61b72   Benjamin Renard   Show coordinates ...
711
712
                        this.createPlotImage(configResult.folder, configResult.plotFile)
                ],
87658ba0   Benjamin Renard   TT Navigation in ...
713
                dockedItems: [this.navToolBar, mouseToolbar],
b74e48d4   Benjamin Renard   Add Extend/Shift ...
714
715
716
717
718
719
720
721
722
723
                plugins: [
                          {
                        	  ptype: 'plotZoomPlugin',
                        	  pluginId : 'plot-zoom-plugin-id'
                          },
                          {
                        	  ptype: 'plotExtendShiftPlugin',
                        	  pluginId : 'plot-extendshift-plugin-id'
                          }
                ]
18d4a11e   Benjamin Renard   Save and load plo...
724
725
726
727
728
    	};
            
    	Ext.apply(this , plotResultTabPanelConfig);	
    }
});