Commit 87658ba04e2d7efbe249d612ac4f205e976168bf

Authored by Benjamin Renard
1 parent b74e48d4

TT Navigation in plot interactive mode

js/app/controllers/PlotModule.js
... ... @@ -61,7 +61,7 @@ Ext.define('amdaDesktop.PlotModule', {
61 61 return size;
62 62 },
63 63  
64   - updateInteractiveSession : function(session) {
  64 + updateInteractiveSession : function(session, newplot) {
65 65 var me = this;
66 66 Ext.each(session.result, function (tabResult, index) {
67 67 var winResultId = tabResult.id+"-win";
... ... @@ -72,7 +72,14 @@ Ext.define('amdaDesktop.PlotModule', {
72 72 folder : session.folder,
73 73 plotFile : tabResult.plot,
74 74 context : tabResult.context,
75   - tabId : tabResult.id
  75 + tabId : tabResult.id,
  76 + multiplot : tabResult.multiplot,
  77 + superposeMode : tabResult.superposeMode,
  78 + isInterval: tabResult.isInterval,
  79 + ttName : tabResult.ttName,
  80 + ttIndex : tabResult.ttIndex,
  81 + ttNbIntervals : tabResult.ttNbIntervals,
  82 + ttFileIndex : tabResult.ttFileIndex
76 83 };
77 84  
78 85 if (winResult == null) {
... ... @@ -83,7 +90,7 @@ Ext.define('amdaDesktop.PlotModule', {
83 90  
84 91 var win = myDesktopApp.getDesktop().createWindow({
85 92 id : tabResult.id+"-win",
86   - title : 'Plot '+(index+1),
  93 + title : 'Plot '+(tabResult.index+1),
87 94 width : size.width,
88 95 height: size.height,
89 96 layout: 'fit',
... ... @@ -106,7 +113,7 @@ Ext.define('amdaDesktop.PlotModule', {
106 113 else
107 114 {
108 115 //update result
109   - winResult.getPanelResult().updatePlotImage(plotTabConfig);
  116 + winResult.getPanelResult().updatePlotImage(plotTabConfig, newplot);
110 117 //update window size
111 118 var size = me.computeResultWindowSize(winResult.getPanelResult());
112 119 winResult.setSize(size.width, size.height);
... ...
js/app/models/ExecutableNode.js
... ... @@ -80,7 +80,7 @@ Ext.define('amdaModel.ExecutableNode', {
80 80 if (isInteractivePlot)
81 81 {
82 82 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
83   - module.updateInteractiveSession(res);
  83 + module.updateInteractiveSession(res, true);
84 84 });
85 85 }
86 86 else
... ...
js/app/models/PlotObjects/PlotRequestObject.js
... ... @@ -28,6 +28,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', {
28 28 {name: 'file-output', type: 'string'},
29 29 {name: 'file-prefix', type: 'string'},
30 30 {name: 'one-file-per-interval', type: 'boolean'},
  31 + {name: 'last-plotted-tab', type: 'int', defaultValue: 0},
31 32 {name: 'last-tab-id', type: 'int', defaultValue: 0}
32 33 ],
33 34  
... ... @@ -65,6 +66,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', {
65 66 this.set('file-output', amdaPlotObj.PlotObjectConfig.defaultValues.file.output);
66 67 this.set('file-prefix', '');
67 68 this.set('one-file-per-interval', amdaPlotObj.PlotObjectConfig.defaultValues.file.oneFilePerInterval);
  69 + this.set('last-plotted-tab', 0);
68 70 this.set('name', '');
69 71 },
70 72  
... ... @@ -118,6 +120,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', {
118 120 requestValues['file-output'] = this.get('file-output');
119 121 requestValues['file-prefix'] = this.get('file-prefix');
120 122 requestValues['one-file-per-interval'] = this.get('one-file-per-interval');
  123 + requestValues['last-plotted-tab'] = this.get('last-plotted-tab');
121 124 requestValues['name'] = this.get('name');
122 125  
123 126 requestValues['timesrc'] = this.get('timesrc');
... ...
js/app/views/PlotComponents/PlotTabPanel.js
... ... @@ -109,6 +109,13 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
109 109 return plotTab.child().treePlot;
110 110 },
111 111  
  112 + getSelectedTabId: function()
  113 + {
  114 + if (this.getActiveTab())
  115 + return this.getActiveTab().child().tabId;
  116 + return 0;
  117 + },
  118 +
112 119 init : function(config) {
113 120 var me = this;
114 121  
... ...
js/app/views/PlotTabResultUI.js
... ... @@ -26,6 +26,10 @@ Ext.define('amdaUI.PlotTabResultUI', {
26 26 panelImage : null,
27 27 crtContext : null,
28 28 tabId : '',
  29 + multiPlotCheck : null,
  30 + navToolBar : null,
  31 + isTTNavBar : false,
  32 + crtTTFileIndex : 0,
29 33  
30 34 constructor: function(config) {
31 35 this.addEvents({'pagesize':true});
... ... @@ -266,7 +270,7 @@ Ext.define('amdaUI.PlotTabResultUI', {
266 270 if (!me.crtContext)
267 271 return;
268 272  
269   - me.contextualMenu.removeAll();
  273 + me.contextualMenu.removeAll(true);
270 274  
271 275 var sourceXPos = me.toPixelOnSourceImage(imageX);
272 276 var sourceYPos = me.toPixelOnSourceImage(imageY);
... ... @@ -298,9 +302,21 @@ Ext.define('amdaUI.PlotTabResultUI', {
298 302 return this.panelImage;
299 303 },
300 304  
301   - updatePlotImage: function(configResult) {
  305 + updatePlotImage: function(configResult, newPlot) {
302 306 this.crtContext = configResult.context;
303 307  
  308 + this.crtTTFileIndex = configResult.ttFileIndex;
  309 +
  310 + if (this.isTTNavBar != (!configResult.isInterval))
  311 + {
  312 + //Update navigation bar
  313 + this.updateNavToolBar(!configResult.isInterval);
  314 + }
  315 +
  316 + this.updateTimeTableInfo();
  317 +
  318 + this.multiPlotCheck.setValue(configResult.multiplot);
  319 +
304 320 this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile));
305 321  
306 322 var size = this.getImageSize();
... ... @@ -309,6 +325,24 @@ Ext.define('amdaUI.PlotTabResultUI', {
309 325 this.panelImage.refreshMe();
310 326 },
311 327  
  328 + updateTimeTableInfo: function()
  329 + {
  330 + if (!this.navToolBar)
  331 + return;
  332 +
  333 + var ttNameField = this.navToolBar.items.get('tt-table-'+this.tabId);
  334 + if (ttNameField)
  335 + ttNameField.setValue(this.crtContext.page.ttName);
  336 +
  337 + var ttNumberField = this.navToolBar.items.get('tt-number-'+this.tabId);
  338 + if (ttNumberField)
  339 + ttNumberField.setValue(this.crtContext.page.ttIndex + 1);
  340 +
  341 + var ttTotalField = this.navToolBar.items.get('tt-total-'+this.tabId);
  342 + if (ttTotalField)
  343 + ttTotalField.setValue(this.crtContext.page.ttNbIntervals);
  344 + },
  345 +
312 346 callInteractivePlot : function(obj) {
313 347 loadMask.show(true);
314 348 AmdaAction.interactivePlot(obj, function (result, e) {
... ... @@ -321,7 +355,7 @@ Ext.define('amdaUI.PlotTabResultUI', {
321 355 if (result.success)
322 356 {
323 357 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
324   - module.updateInteractiveSession(result);
  358 + module.updateInteractiveSession(result, false);
325 359 });
326 360 }
327 361 else
... ... @@ -338,129 +372,202 @@ Ext.define('amdaUI.PlotTabResultUI', {
338 372 },this);
339 373 },
340 374  
341   - createToolBar : function(isTimeTable) {
342   - var interoperItemCfg = {
343   - text: 'Get HST Data',
344   - scope: this,
345   - menu: [
346   - {
347   - text: 'Giant Planet Auroral Emissions',
348   - scope: this,
349   - handler: function()
350   - {
351   - var me = this;
352   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.astro.id, true, function (module) {
353   - //module.createWindow(me.object.get('startDate'),me.object.get('stopDate'));
354   - });
355   - }
356   - }
357   - ]
358   - };
359   -
360   - if (isTimeTable) {
361   - var toolConfig = {
362   - dock: 'top',
363   - items: [
364   - {
365   - text: 'Previous',
366   - scope: this,
367   - handler: function(){
368   - }
369   - },
370   - '-',
371   - {
372   - text: 'Next',
373   - scope: this,
374   - handler: function(){
375   - }
376   - },
377   - '-',
378   - {
379   - text: 'Go to Interval #',
380   - scope: this,
381   - handler: function(bt){
382   - }
383   - },
384   - {
385   - xtype: 'numberfield',
386   - hideTrigger: true,
387   - width: 40,
388   - minValue: 1
389   - },
390   - ' ',
391   - ' ',
392   - ' ',
393   - {
394   - xtype: 'textfield',
395   - labelAlign: 'right',
396   - labelWidth: 30,
397   - fieldLabel: 'Table',
398   - width: 130,
399   - disabled : true
400   - },
401   - {
402   - xtype: 'textfield',
403   - labelAlign: 'right',
404   - labelWidth: 30,
405   - fieldLabel: 'Int #',
406   - width: 70,
407   - disabled : true
408   - },
409   - {
410   - xtype: 'textfield',
411   - labelAlign: 'right',
412   - labelWidth: 30,
413   - fieldLabel: 'Total',
414   - width: 70,
415   - disabled : true
416   - },
417   - '->',
418   - interoperItemCfg
419   - ]
420   - };
  375 + updateNavToolBar : function(isTimeTable) {
  376 + if (this.navToolBar)
  377 + this.navToolBar.removeAll(true);
  378 +
  379 + this.multiPlotCheck = Ext.create('Ext.form.field.Checkbox', {
  380 + boxLabel : 'Linked to Multi Plot Mode',
  381 + scope: this,
  382 + handler: function(check, checked) {
  383 + }
  384 + });
  385 +
  386 + var commonItemsCfg = [
  387 + {
  388 + xtype: 'tbspacer',
  389 + width: 50
  390 + },
  391 + this.multiPlotCheck,
  392 + '->',
  393 + {
  394 + text: 'Get HST Data',
  395 + scope: this,
  396 + menu: [
  397 + {
  398 + text: 'Giant Planet Auroral Emissions',
  399 + scope: this,
  400 + handler: function()
  401 + {
  402 + var me = this;
  403 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.astro.id, true, function (module) {
  404 + var startTime = new Date(me.crtContext.page.startTime*1000);
  405 + startTime = Ext.Date.add(startTime, Ext.Date.MINUTE, startTime.getTimezoneOffset());
  406 +
  407 + var stopTime = new Date(me.crtContext.page.stopTime*1000);
  408 + stopTime = Ext.Date.add(stopTime, Ext.Date.MINUTE, stopTime.getTimezoneOffset());
  409 +
  410 + module.createWindow(startTime,stopTime);
  411 + });
  412 + }
  413 + }
  414 + ]
  415 + }
  416 + ];
  417 +
  418 + if (isTimeTable)
  419 + {
  420 + var navigationItemsCfg = [
  421 + {
  422 + text: 'Previous',
  423 + scope: this,
  424 + handler: function(){
  425 + var ttFileIndex = this.crtTTFileIndex;
  426 + var ttintervalIndex = this.crtContext.page.ttIndex;
  427 +
  428 + if (ttintervalIndex <= 0)
  429 + {
  430 + if (ttFileIndex <= 0)
  431 + {
  432 + myDesktopApp.errorMsg('You are on the first interval of your request');
  433 + return;
  434 + }
  435 + else
  436 + {
  437 + --ttFileIndex;
  438 + ttintervalIndex = 0;
  439 + }
  440 + }
  441 + else
  442 + --ttintervalIndex;
  443 + this.callInteractivePlot({'action' : 'goto', 'tabId' : this.tabId, 'ttFileIndex' : ttFileIndex, 'intIndex' : ttintervalIndex});
  444 + }
  445 + },
  446 + '-',
  447 + {
  448 + text: 'Next',
  449 + scope: this,
  450 + handler: function(){
  451 + var ttFileIndex = this.crtTTFileIndex;
  452 + var ttintervalIndex = this.crtContext.page.ttIndex;
  453 +
  454 + if (ttintervalIndex >= this.crtContext.page.ttNbIntervals-1)
  455 + {
  456 + ++ttFileIndex;
  457 + ttintervalIndex = 0;
  458 + }
  459 + else
  460 + ++ttintervalIndex;
  461 + this.callInteractivePlot({'action' : 'goto', 'tabId' : this.tabId, 'ttFileIndex' : ttFileIndex, 'intIndex' : ttintervalIndex});
  462 + }
  463 + },
  464 + '-',
  465 + {
  466 + text: 'Go to Interval #',
  467 + scope: this,
  468 + handler: function(bt){
  469 + var ttGotoNumberField = this.navToolBar.items.get('tt-goto-number-'+this.tabId);
  470 + var goToIndex = ttGotoNumberField.getValue() - 1;
  471 + if ((goToIndex < 0) || (goToIndex >= this.crtContext.page.ttNbIntervals))
  472 + myDesktopApp.errorMsg('This interval number is outside of the current timeTable');
  473 + else
  474 + this.callInteractivePlot({'action' : 'goto', 'tabId' : this.tabId, 'ttFileIndex' : this.crtTTFileIndex, 'intIndex' : goToIndex});
  475 + }
  476 + },
  477 + {
  478 + xtype: 'numberfield',
  479 + id : 'tt-goto-number-'+this.tabId,
  480 + hideTrigger: true,
  481 + width: 40,
  482 + minValue: 1
  483 + },
  484 + ' ',
  485 + ' ',
  486 + ' ',
  487 + {
  488 + xtype: 'textfield',
  489 + id: 'tt-table-'+this.tabId,
  490 + labelAlign: 'right',
  491 + labelWidth: 30,
  492 + fieldLabel: 'Table',
  493 + width: 130,
  494 + disabled : true
  495 + },
  496 + {
  497 + xtype: 'textfield',
  498 + id: 'tt-number-'+this.tabId,
  499 + labelAlign: 'right',
  500 + labelWidth: 30,
  501 + fieldLabel: 'Int #',
  502 + width: 70,
  503 + disabled : true
  504 + },
  505 + {
  506 + xtype: 'textfield',
  507 + id: 'tt-total-'+this.tabId,
  508 + labelAlign: 'right',
  509 + labelWidth: 30,
  510 + fieldLabel: 'Total',
  511 + width: 70,
  512 + disabled : true
  513 + }
  514 + ];
  515 + }
  516 + else
  517 + {
  518 + var navigationItemsCfg = [
  519 + {
  520 + text: 'Backward',
  521 + scope: this,
  522 + handler: function(){
  523 + this.callInteractivePlot({'action' : 'backward', 'tabId' : this.tabId});
  524 + }
  525 + },
  526 + '-',
  527 + {
  528 + text: '1/2 Backward',
  529 + scope: this,
  530 + handler: function(){
  531 + this.callInteractivePlot({'action' : 'halfbackward', 'tabId' : this.tabId});
  532 + }
  533 + },
  534 + '-',
  535 + {
  536 + text: '1/2 Forward',
  537 + scope: this,
  538 + handler: function(){
  539 + this.callInteractivePlot({'action' : 'halfforward', 'tabId' : this.tabId});
  540 + }
  541 + },
  542 + '-',
  543 + {
  544 + text: 'Forward',
  545 + scope: this,
  546 + handler: function(){
  547 + this.callInteractivePlot({'action' : 'forward', 'tabId' : this.tabId});
  548 + }
  549 + }
  550 + ];
421 551 }
422   - else {
423   - var toolConfig = {
  552 +
  553 + var toolItemsCfg = navigationItemsCfg;
  554 + Ext.each(commonItemsCfg, function(item){
  555 + toolItemsCfg.push(item);
  556 + });
  557 +
  558 + if (!this.navToolBar)
  559 + {
  560 + var toolConfig = {
424 561 dock: 'top',
425   - items: [ {
426   - text: 'Backward',
427   - scope: this,
428   - handler: function(){
429   - this.callInteractivePlot({'action' : 'backward', 'tabId' : this.tabId});
430   - }
431   - },
432   - '-' ,
433   - {
434   - text: '1/2 Backward',
435   - scope: this,
436   - handler: function(){
437   - this.callInteractivePlot({'action' : 'halfbackward', 'tabId' : this.tabId});
438   - }
439   - },
440   - '-',
441   - {
442   - text: '1/2 Forward',
443   - scope: this,
444   - handler: function(){
445   - this.callInteractivePlot({'action' : 'halfforward', 'tabId' : this.tabId});
446   - }
447   - },
448   - '-',
449   - {
450   - text: 'Forward',
451   - scope: this,
452   - handler: function(){
453   - this.callInteractivePlot({'action' : 'forward', 'tabId' : this.tabId});
454   - }
455   - },
456   - '->',
457   - interoperItemCfg
458   - ]
  562 + items: toolItemsCfg
459 563 };
  564 +
  565 + this.navToolBar = Ext.create('Ext.toolbar.Toolbar', toolConfig);
460 566 }
461   -
462   - var toolBar = Ext.create('Ext.toolbar.Toolbar', toolConfig);
463   - return toolBar;
  567 + else
  568 + this.navToolBar.add(toolItemsCfg);
  569 +
  570 + this.isTTNavBar = isTimeTable;
464 571 },
465 572  
466 573 init: function(configResult){
... ... @@ -512,7 +619,11 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
512 619 items: []
513 620 });
514 621  
515   - var navToolBar = this.createToolBar(false);
  622 + this.updateNavToolBar(!configResult.isInterval);
  623 +
  624 + this.updateTimeTableInfo();
  625 +
  626 + this.multiPlotCheck.setValue(configResult.multiplot);
516 627  
517 628 var plotResultTabPanelConfig = {
518 629 preventHeader : true,
... ... @@ -520,7 +631,7 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
520 631 items: [
521 632 this.createPlotImage(configResult.folder, configResult.plotFile)
522 633 ],
523   - dockedItems: [navToolBar, mouseToolbar],
  634 + dockedItems: [this.navToolBar, mouseToolbar],
524 635 plugins: [
525 636 {
526 637 ptype: 'plotZoomPlugin',
... ...
js/app/views/PlotUI.js
... ... @@ -113,6 +113,7 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
113 113 */
114 114 doPlot : function(){
115 115 this.updateObject();
  116 + this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId());
116 117 var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
117 118 if (plotModule)
118 119 plotModule.linkedNode.execute();
... ...