Commit 57e1521439f07489cd942130a113a585eb7422a8

Authored by Benjamin Renard
1 parent 495fc7a3

Fix addParameter + remove plot

js/app/controllers/PlotModule.js
@@ -208,5 +208,20 @@ Ext.define('amdaDesktop.PlotModule', { @@ -208,5 +208,20 @@ Ext.define('amdaDesktop.PlotModule', {
208 getWindowResult: function(winResultId){ 208 getWindowResult: function(winResultId){
209 if (!this.plotResultWindowsManager.get(winResultId)) return null; 209 if (!this.plotResultWindowsManager.get(winResultId)) return null;
210 return this.plotResultWindowsManager.get(winResultId); 210 return this.plotResultWindowsManager.get(winResultId);
  211 + },
  212 +
  213 + addParameter : function(paramNode) {
  214 + var me = this;
  215 + var desktop = this.app.getDesktop();
  216 + var win = desktop.getWindow(this.id);
  217 + if (win) {
  218 + me.getUiContent().addParameter(paramNode, false);
  219 + win.show();
  220 + }
  221 + else {
  222 + this.createWindow(function () {
  223 + me.getUiContent().addParameter(paramNode, true);
  224 + });
  225 + }
211 } 226 }
212 }); 227 });
js/app/models/InteractiveNode.js
@@ -454,16 +454,7 @@ Ext.define('amdaModel.InteractiveNode', { @@ -454,16 +454,7 @@ Ext.define('amdaModel.InteractiveNode', {
454 { 454 {
455 if (node.get('disable')) return; 455 if (node.get('disable')) return;
456 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { 456 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
457 - if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.plot.id)) {  
458 - var request = Ext.create(amdaPlotObj.PlotRequestObject.$className);  
459 - var newNode = Ext.create(amdaModel.PlotNode.$className, { object : request });  
460 - // edit newNode into Plot Module with node as contextNode  
461 - newNode.editInModule();  
462 - if((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) {  
463 - module.getUiContent().setTimeFromData(node.getTimeFromNode(node));  
464 - }  
465 - }  
466 - module.getUiContent().addParameter(node); 457 + module.addParameter(node);
467 }); 458 });
468 }, 459 },
469 460
js/app/models/MultiplotNode.js
@@ -21,4 +21,5 @@ Ext.define('amdaModel.MultiplotNode', { @@ -21,4 +21,5 @@ Ext.define('amdaModel.MultiplotNode', {
21 this.set('nodeType',this.self.nodeType); 21 this.set('nodeType',this.self.nodeType);
22 this.set('leaf', true); 22 this.set('leaf', true);
23 } 23 }
  24 +
24 }); 25 });
js/app/models/PlotObjects/MultiplotRequestObject.js
@@ -54,7 +54,10 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { @@ -54,7 +54,10 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', {
54 return this.plots().getAt(this.plots().count()-1); 54 return this.plots().getAt(this.plots().count()-1);
55 }, 55 },
56 56
57 - removePlotById: function(id) { 57 + removePlotByInternalId: function(internalId) {
  58 + var plotNode = this.plots().data.getByKey(internalId);
  59 + if (plotNode)
  60 + this.plots().remove(plotNode);
58 }, 61 },
59 62
60 addPlot: function(plotNode) { 63 addPlot: function(plotNode) {
js/app/models/PlotObjects/PlotRequestObject.js
@@ -231,6 +231,8 @@ Ext.define('amdaPlotObj.PlotRequestObject', { @@ -231,6 +231,8 @@ Ext.define('amdaPlotObj.PlotRequestObject', {
231 getJsonValues : function() 231 getJsonValues : function()
232 { 232 {
233 var requestValues = new Object(); 233 var requestValues = new Object();
  234 +
  235 + requestValues['nodeType'] = 'request';
234 236
235 requestValues['id'] = this.get('id'); 237 requestValues['id'] = this.get('id');
236 238
js/app/views/PlotComponents/PlotTabContent.js
@@ -30,6 +30,11 @@ Ext.define('amdaPlotComp.PlotTabContent', { @@ -30,6 +30,11 @@ Ext.define('amdaPlotComp.PlotTabContent', {
30 this.init(config); 30 this.init(config);
31 this.callParent(arguments); 31 this.callParent(arguments);
32 }, 32 },
  33 +
  34 + setTime : function(startDate, stopDate) {
  35 + this.timeSelector.intervalSel.setInterval(startDate, stopDate);
  36 +
  37 + },
33 38
34 updateTimeObject : function() { 39 updateTimeObject : function() {
35 var timeSource = this.timeSelector.getActiveTimeSource(); 40 var timeSource = this.timeSelector.getActiveTimeSource();
@@ -39,7 +44,11 @@ Ext.define('amdaPlotComp.PlotTabContent', { @@ -39,7 +44,11 @@ Ext.define('amdaPlotComp.PlotTabContent', {
39 if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) 44 if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
40 this.plotNode.get('object').set('timeTables',this.timeSelector.TTGrid.getStore().data.items); 45 this.plotNode.get('object').set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
41 }, 46 },
42 - 47 +
  48 + doPlot : function() {
  49 + this.plotNode.execute();
  50 + },
  51 +
43 init : function(config) { 52 init : function(config) {
44 var me = this; 53 var me = this;
45 me.plotNode = config.plotNode; 54 me.plotNode = config.plotNode;
js/app/views/PlotComponents/PlotTabPanel.js
@@ -43,6 +43,7 @@ Ext.define('amdaPlotComp.PlotTabPanel', { @@ -43,6 +43,7 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
43 var me = this; 43 var me = this;
44 var tabComp = this.add({ 44 var tabComp = this.add({
45 title: (plotNode.get('text') != '') ? plotNode.get('text') : 'Plot '+tabNumber, 45 title: (plotNode.get('text') != '') ? plotNode.get('text') : 'Plot '+tabNumber,
  46 + isRendered: false,
46 closable: true, 47 closable: true,
47 layout: 'fit', 48 layout: 'fit',
48 bodyStyle: 'background: none', 49 bodyStyle: 'background: none',
@@ -63,8 +64,8 @@ Ext.define('amdaPlotComp.PlotTabPanel', { @@ -63,8 +64,8 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
63 return true; 64 return true;
64 }, 65 },
65 close: function( tab, eOpts ) { 66 close: function( tab, eOpts ) {
66 - if (tab.items.getAt(0).object)  
67 - this.object.removeTabById(tab.items.getAt(0).object.get('id')); 67 + if (tab.items.getAt(0).plotNode)
  68 + this.multiplot_object.removePlotByInternalId(tab.items.getAt(0).plotNode.internalId);
68 }, 69 },
69 destroy: function(tab, eOpts) { 70 destroy: function(tab, eOpts) {
70 this.updatePlotTabs(); 71 this.updatePlotTabs();
@@ -80,7 +81,22 @@ Ext.define('amdaPlotComp.PlotTabPanel', { @@ -80,7 +81,22 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
80 81
81 updatePlotTabs: function() 82 updatePlotTabs: function()
82 { 83 {
83 - // ToDo - BRE 84 + for (i = 0; i < this.items.getCount(); ++i)
  85 + {
  86 + var tabItem = this.items.getAt(i);
  87 + var tabContent = tabItem.items.getAt(0);
  88 + var plotNode = tabContent.plotNode;
  89 + var title = (plotNode.get('text') != '') ? plotNode.get('text') : 'Plot '+(i + 1);
  90 + tabItem.setTitle(title);
  91 + if (!this.getActiveTab())
  92 + this.setActiveTab(tabItem);
  93 + }
  94 + },
  95 +
  96 + getCurrentPlotTabContent : function() {
  97 + if (this.getActiveTab())
  98 + return this.getActiveTab().child();
  99 + return null;
84 }, 100 },
85 101
86 updateTimeObject : function() { 102 updateTimeObject : function() {
js/app/views/PlotUI.js
@@ -93,22 +93,33 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, { @@ -93,22 +93,33 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
93 amdaModel.DownloadNode.editInModule(); 93 amdaModel.DownloadNode.editInModule();
94 }, 94 },
95 95
96 - addParameter : function(node){  
97 - var crtTree = this.plotTabs.getTreeFromPlotTab(this.plotTabs.getActiveTab());  
98 - crtTree.dropRecord(node,null,'append');  
99 - }, 96 + addParameter : function(node, updateTime){
  97 + var crtTree = this.plotTabs.getTreeFromPlotTab(this.plotTabs.getActiveTab());
  98 + if (crtTree) {
  99 + crtTree.dropRecord(node,null,'append');
  100 + if (updateTime) {
  101 + if((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) {
  102 + this.setTimeFromData(node.getTimeFromNode(node));
  103 + }
  104 + }
  105 + }
  106 + },
100 107
101 /** 108 /**
102 * plot method called by 'Do Plot' button to launch the plot process 109 * plot method called by 'Do Plot' button to launch the plot process
103 */ 110 */
104 - doPlot : function(){ 111 + doPlot : function(){
  112 + var plotTab = this.plotTabs.getCurrentPlotTabContent()
  113 + if (plotTab)
  114 + plotTab.doPlot();
105 115
106 - this.updateObject(); 116 + /*this.updateObject();
107 this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId()); 117 this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId());
108 var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); 118 var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
109 if (plotModule) 119 if (plotModule)
110 - plotModule.linkedNode.execute();  
111 - }, 120 + plotModule.linkedNode.execute();*/
  121 +
  122 + },
112 123
113 /** 124 /**
114 * Check if changes were made before closing window 125 * Check if changes were made before closing window
@@ -142,23 +153,19 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, { @@ -142,23 +153,19 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
142 crtTimeSelector.addTT(newTTName,newTTid); 153 crtTimeSelector.addTT(newTTName,newTTid);
143 }, 154 },
144 155
145 - /**  
146 - * Set Start-Stop from parameter info (Local & MyData)  
147 - */  
148 - setTimeFromData : function(obj) {  
149 - if (!obj.start || !obj.stop)  
150 - return;  
151 - var dateStart = new Date(obj.start.replace(/[T|Z]/g,' ').replace(/\-/g,'\/'));  
152 - var dateStop = new Date(obj.stop.replace(/[T|Z]/g,' ').replace(/\-/g,'\/')); 156 + /**
  157 + * Set Start-Stop from parameter info (Local & MyData)
  158 + */
  159 + setTimeFromData : function(obj) {
  160 + if (!obj.start || !obj.stop)
  161 + return;
  162 + var dateStart = new Date(obj.start.replace(/[T|Z]/g,' ').replace(/\-/g,'\/'));
  163 + var dateStop = new Date(obj.stop.replace(/[T|Z]/g,' ').replace(/\-/g,'\/'));
153 164
154 - for (var i = 0; i < this.plotTabs.items.getCount(); ++i) {  
155 - var plotTab = this.plotTabs.items.getAt(i).items.getAt(0);  
156 - plotTab.items.getAt(1).intervalSel.setInterval(dateStart, dateStop);  
157 - //TBD plotTab.updateTimeObject();  
158 - }  
159 -  
160 - this.timeSelector.intervalSel.setInterval(dateStart, dateStop);  
161 - }, 165 + var plotTab = this.plotTabs.getCurrentPlotTabContent();
  166 + if (plotTab)
  167 + plotTab.setTime(dateStart, dateStop);
  168 + },
162 169
163 forceActiveTab : function(tabId) { 170 forceActiveTab : function(tabId) {
164 for (var i = 0; i < this.plotTabs.items.getCount(); ++i) { 171 for (var i = 0; i < this.plotTabs.items.getCount(); ++i) {