Commit 27b2a53e6eb15c624f2dc42b8b630ace149322c9

Authored by Benjamin Renard
1 parent 89c733f2

Link tab plot to multi plot or not

js/app/models/PlotObjects/PlotObjectConfig.js
... ... @@ -22,6 +22,9 @@ Ext.define('amdaPlotObj.PlotObjectConfig', {
22 22 output : 'INTERACTIVE',
23 23 oneFilePerInterval: false
24 24 },
  25 + tree : {
  26 + simplifiedView : false
  27 + },
25 28 page : {
26 29 xMargin : 15.,
27 30 yMargin : 20.,
... ...
js/app/models/PlotObjects/PlotTabObject.js
... ... @@ -2,7 +2,7 @@
2 2 * Project  : AMDA-NG
3 3 * Name : PlotTabObject.js
4 4 * @class amdaPlotObj.PlotTabObject
5   - * @extends Ext.data.Model
  5 + * @extends amdaModel.AmdaTimeObject
6 6 * @brief Plot Tab Business Object Definition
7 7 * @author Benjamin Renard
8 8 * @version $Id: PlotTabObject.js benjamin $
... ... @@ -14,7 +14,7 @@
14 14  
15 15  
16 16 Ext.define('amdaPlotObj.PlotTabObject', {
17   - extend: 'Ext.data.Model',
  17 + extend: 'amdaModel.AmdaTimeObject',
18 18 idProperty: 'id',
19 19  
20 20 requires: [
... ... @@ -27,6 +27,8 @@ Ext.define('amdaPlotObj.PlotTabObject', {
27 27  
28 28 fields : [
29 29 {name: 'id', type: 'int'},
  30 + {name: 'tree-simplified-view', type: 'boolean'},
  31 + {name: 'multi-plot-linked', type: 'boolean'},
30 32 {name: 'page-title-text', type: 'string'},
31 33 {name: 'page-title-color', type: 'string'},
32 34 {name: 'page-title-position', type: 'string'},
... ... @@ -146,6 +148,10 @@ Ext.define('amdaPlotObj.PlotTabObject', {
146 148  
147 149 setDefaultValues: function()
148 150 {
  151 + this.set('tree-simplified-view', amdaPlotObj.PlotObjectConfig.defaultValues.tree.simplifiedView);
  152 +
  153 + this.set('multi-plot-linked', false);
  154 +
149 155 this.set('page-title-text', '');
150 156 this.set('page-title-color', amdaPlotObj.PlotObjectConfig.defaultValues.page.title.color);
151 157 this.set('page-title-position', amdaPlotObj.PlotObjectConfig.defaultValues.page.title.position);
... ... @@ -196,6 +202,8 @@ Ext.define('amdaPlotObj.PlotTabObject', {
196 202 var tabValues = new Object();
197 203  
198 204 tabValues['id'] = this.get('id');
  205 + tabValues['tree-simplified-view'] = this.get('tree-simplified-view');
  206 + tabValues['multi-plot-linked'] = this.get('multi-plot-linked');
199 207 tabValues['page-title-text'] = this.get('page-title-text');
200 208 tabValues['page-title-color'] = this.get('page-title-color');
201 209 tabValues['page-title-position'] = this.get('page-title-position');
... ... @@ -218,6 +226,32 @@ Ext.define('amdaPlotObj.PlotTabObject', {
218 226 tabValues['page-font-bold'] = this.get('page-font-bold');
219 227 tabValues['page-font-italic'] = this.get('page-font-italic');
220 228  
  229 + tabValues['timesrc'] = this.get('timesrc');
  230 + // if there's at least one timeTable name into 'timeTables' collection
  231 + if (this.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0] && this.get('timeTables') && this.get('timeTables').length){
  232 + // get complete timeTables collection
  233 + var timeTables = this.get('timeTables');
  234 + // init an empty array for timeTables
  235 + tabValues['timeTables'] = [];
  236 + // for each interval record
  237 + Ext.Array.each(timeTables, function(item, index, all){
  238 + if (!item.$className) {
  239 + tabValues['timeTables'][index] = {timeTableName : item.timeTableName, id : item.id};
  240 + }
  241 + // get Json simplified value
  242 + else {
  243 + tabValues['timeTables'][index] = item.getJsonValues();
  244 + }
  245 + });
  246 + } else {
  247 + tabValues['startDate'] = this.get('startDate');
  248 + tabValues['stopDate'] = this.get('stopDate');
  249 + tabValues['durationDay'] = this.get('durationDay');
  250 + tabValues['durationHour'] = this.get('durationHour');
  251 + tabValues['durationMin'] = this.get('durationMin');
  252 + tabValues['durationSec'] = this.get('durationSec');
  253 + }
  254 +
221 255 tabValues['page-layout-type'] = this.get('page-layout-type');
222 256 if (this.get('page-layout-object') != null)
223 257 tabValues['page-layout-object'] = this.get('page-layout-object').getJsonValues();
... ...
js/app/views/PlotComponents/PlotPanelForm.js
... ... @@ -120,7 +120,7 @@ Ext.define('amdaPlotComp.PlotPanelForm', {
120 120 if (value != oldValue)
121 121 {
122 122 me.object.updatePlotType(value, true);
123   - if (!me.crtTree.isSimplifiedView)
  123 + if (!me.crtTree.tabObject.get('tree-simplified-view'))
124 124 {
125 125 me.crtTree.buildPanelAxesNode(me.object);
126 126 me.crtTree.buildPanelAdditionalObjectsNode(me.object);
... ...
js/app/views/PlotComponents/PlotTabContent.js
... ... @@ -21,6 +21,12 @@ Ext.define('amdaPlotComp.PlotTabContent', {
21 21 //Link to the Plot Element Panel
22 22 plotElementPanel: null,
23 23  
  24 + //linkk to the Plot Tab Panel
  25 + plotTabPanel : null,
  26 +
  27 + //Link to the time selctor
  28 + timeSelector : null,
  29 +
24 30 //Tab Object
25 31 object: null,
26 32  
... ... @@ -32,15 +38,31 @@ Ext.define('amdaPlotComp.PlotTabContent', {
32 38 setTabObject : function(object) {
33 39 this.object = object;
34 40 this.treePlot.buildTree(this.object);
  41 + this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate'));
  42 + },
  43 +
  44 + updateLinkedToMultiPlotMode : function (isLinkedToMultiPlotMode) {
  45 + this.timeSelector.setVisible(!isLinkedToMultiPlotMode);
  46 + this.plotTabPanel.updateLinkedToMultiPlotMode(isLinkedToMultiPlotMode);
  47 + },
  48 +
  49 + updateTimeObject : function() {
  50 + var timeSource = this.timeSelector.getActiveTimeSource();
  51 + var tabForm = this.getForm();
  52 + tabForm.updateRecord(this.object);
  53 + this.object.set('timesrc', timeSource);
  54 + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
  55 + this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
35 56 },
36 57  
37 58 init : function(config) {
38 59 var me = this;
39 60  
40 61 this.plotElementPanel = config.plotElementPanel;
  62 + this.plotTabPanel = config.plotTabPanel;
41 63  
42   - //var timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + config.tabObjectId, flex: 2, hidden: true} );
43   - this.treePlot = new amdaPlotComp.PlotTree({flex: 3, plotElementPanel: this.plotElementPanel});
  64 + this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + config.tabId, flex: 2, hidden: true} );
  65 + this.treePlot = new amdaPlotComp.PlotTree({flex: 3, plotElementPanel: this.plotElementPanel, plotTabContent: this});
44 66  
45 67 var myConf = {
46 68 bodyStyle: { background : '#dfe8f6' },
... ... @@ -53,8 +75,8 @@ Ext.define('amdaPlotComp.PlotTabContent', {
53 75 align: 'stretch'
54 76 },
55 77 items: [
56   - this.treePlot/*,
57   - timeSelector */
  78 + this.treePlot,
  79 + this.timeSelector
58 80 ]
59 81 };
60 82  
... ...
js/app/views/PlotComponents/PlotTabPanel.js
... ... @@ -17,6 +17,9 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
17 17  
18 18 //Link to the Plot Element Panel
19 19 plotElementPanel: null,
  20 +
  21 + //Link to the Plot UI
  22 + plotUI : null,
20 23  
21 24 //Request object
22 25 object: null,
... ... @@ -30,17 +33,19 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
30 33 {
31 34 this.object = object;
32 35 this.removeAll();
  36 + var isFirstTab = true;
33 37 this.object.tabs().each(function (rec) {
34   - this.addPlotTab(rec);
  38 + this.addPlotTab(rec, isFirstTab);
  39 + isFirstTab = false;
35 40 }, this);
36 41 },
37 42  
38   - addPlotTab: function(tabObject)
  43 + addPlotTab: function(tabObject, selectTab)
39 44 {
40 45 var tabNumber = this.getTabBar().items.getCount();
41   - var tabContent = new amdaPlotComp.PlotTabContent({plotElementPanel: this.plotElementPanel});
  46 + var tabContent = new amdaPlotComp.PlotTabContent({plotElementPanel: this.plotElementPanel, plotTabPanel : this, tabId : tabObject.get('id')});
42 47 tabContent.setTabObject(tabObject);
43   - this.add({
  48 + var tabComp = this.add({
44 49 title: 'Plot '+tabNumber,
45 50 closable: true,
46 51 layout: 'fit',
... ... @@ -69,7 +74,10 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
69 74 this.updatePlotTabs();
70 75 }
71 76 }
72   - }).show();
  77 + });
  78 +
  79 + if (selectTab)
  80 + this.setActiveTab(tabComp);
73 81  
74 82 return tabContent;
75 83 },
... ... @@ -85,6 +93,17 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
85 93 }
86 94 },
87 95  
  96 + updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) {
  97 + this.plotUI.updateLinkedToMultiPlotMode(isLinkedToMultiPlotMode);
  98 + },
  99 +
  100 + updateTimeObject : function() {
  101 + for (i = 0; i < this.items.getCount(); ++i)
  102 + {
  103 + this.items.getAt(i).items.getAt(0).updateTimeObject();
  104 + }
  105 + },
  106 +
88 107 getTreeFromPlotTab: function(plotTab)
89 108 {
90 109 return plotTab.child().treePlot;
... ... @@ -94,6 +113,7 @@ Ext.define(&#39;amdaPlotComp.PlotTabPanel&#39;, {
94 113 var me = this;
95 114  
96 115 this.plotElementPanel = config.plotElementPanel;
  116 + this.plotUI = config.plotUI;
97 117  
98 118 var myConf = {
99 119 plain: true,
... ... @@ -108,7 +128,7 @@ Ext.define(&#39;amdaPlotComp.PlotTabPanel&#39;, {
108 128 text:'+',
109 129 closable: false,
110 130 handler:function(btn,e){
111   - var tabContent = me.addPlotTab(me.object.createNewTab());
  131 + var tabContent = me.addPlotTab(me.object.createNewTab(), true);
112 132 }
113 133 }]
114 134 },
... ... @@ -121,6 +141,7 @@ Ext.define(&#39;amdaPlotComp.PlotTabPanel&#39;, {
121 141 me.plotElementPanel.resetElement();
122 142 else
123 143 me.plotElementPanel.setElement(selectedNode.type,selectedNode.object, newCardTree);
  144 + newCardTree.updateLinkedToMultiPlotMode();
124 145 },
125 146 scope: me
126 147 }
... ...
js/app/views/PlotComponents/PlotTree.js
... ... @@ -15,11 +15,16 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
15 15 'amdaPlotObj.PlotTreeNode'
16 16 ],
17 17  
18   - //
19   - isSimplifiedView: false,
  18 + //Link to the combo box to define the use of the simplified view
  19 + simplifiedViewCombo : null,
  20 +
  21 + //Link to the combo to attach the tab to the multi plot mode
20 22  
21 23 //Link to the Plot Element Panel
22 24 plotElementPanel: null,
  25 +
  26 + //Link to the Plot Tab Content Panel
  27 + plotTabContent : null,
23 28  
24 29 //Tab object
25 30 tabObject: null,
... ... @@ -32,18 +37,16 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
32 37 this.callParent(arguments);
33 38 },
34 39  
35   - setSimplifiedMode: function(isSimplifiedView) {
36   - this.isSimplifiedView = isSimplifiedView;
37   - this.buildTree(this.tabObject);
38   - },
39   -
40 40 buildTree: function(tabObject) {
41 41 if (this.store.getRootNode().hasChildNodes())
42 42 this.store.getRootNode().removeAll();
43 43  
44 44 this.tabObject = tabObject;
45 45  
46   - if (!this.isSimplifiedView)
  46 + this.simplifiedViewCombo.setValue(this.tabObject.get('tree-simplified-view'));
  47 + this.linkToMultiPlotCombo.setValue(this.tabObject.get('multi-plot-linked'));
  48 +
  49 + if (!this.tabObject.get('tree-simplified-view'))
47 50 {
48 51 //Page Node
49 52 var pageNode = this.store.getRootNode().appendChild(new amdaPlotObj.PlotPageTreeNode({object : tabObject}));
... ... @@ -129,7 +132,7 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
129 132 //Retrieve corresponding panel node
130 133 if (panelNode.object == panelObject)
131 134 {
132   - if (!me.isSimplifiedView)
  135 + if (!me.tabObject.get('tree-simplified-view'))
133 136 {
134 137 //Retrieve params node
135 138 paramsNode = panelNode.findChild('type', 'params');
... ... @@ -275,7 +278,7 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
275 278  
276 279 addPanelNode: function(panelObject) {
277 280 var panelNode = this.panelsNode.appendChild(new amdaPlotObj.PlotPanelTreeNode({object : panelObject}));
278   - if (!this.isSimplifiedView)
  281 + if (!this.tabObject.get('tree-simplified-view'))
279 282 {
280 283 //Axes node
281 284 this.buildPanelAxesNode(panelObject);
... ... @@ -379,7 +382,7 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
379 382 break;
380 383 case 'param' :
381 384 var panelObject = null;
382   - if (!this.isSimplifiedView)
  385 + if (!this.tabObject.get('tree-simplified-view'))
383 386 panelObject = record.parentNode.parentNode.object;
384 387 else
385 388 panelObject = record.parentNode.object;
... ... @@ -389,7 +392,7 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
389 392 break;
390 393 case 'text-legend' :
391 394 var panelObject = null;
392   - if (!this.isSimplifiedView)
  395 + if (!this.tabObject.get('tree-simplified-view'))
393 396 panelObject = record.parentNode.parentNode.object;
394 397 else
395 398 panelObject = record.parentNode.object;
... ... @@ -398,7 +401,7 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
398 401 break;
399 402 case 'constant' :
400 403 var panelObject = null;
401   - if (!this.isSimplifiedView)
  404 + if (!this.tabObject.get('tree-simplified-view'))
402 405 panelObject = record.parentNode.parentNode.object;
403 406 else
404 407 panelObject = record.parentNode.object;
... ... @@ -407,7 +410,7 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
407 410 break;
408 411 case 'text-obj' :
409 412 var panelObject = null;
410   - if (!this.isSimplifiedView)
  413 + if (!this.tabObject.get('tree-simplified-view'))
411 414 panelObject = record.parentNode.parentNode.object;
412 415 else
413 416 panelObject = record.parentNode.object;
... ... @@ -416,7 +419,7 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
416 419 break;
417 420 case 'curve' :
418 421 var panelObject = null;
419   - if (!this.isSimplifiedView)
  422 + if (!this.tabObject.get('tree-simplified-view'))
420 423 panelObject = record.parentNode.parentNode.object;
421 424 else
422 425 panelObject = record.parentNode.object;
... ... @@ -425,7 +428,7 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
425 428 break;
426 429 case 'fill' :
427 430 var panelObject = null;
428   - if (!this.isSimplifiedView)
  431 + if (!this.tabObject.get('tree-simplified-view'))
429 432 panelObject = record.parentNode.parentNode.object;
430 433 else
431 434 panelObject = record.parentNode.object;
... ... @@ -693,6 +696,10 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
693 696 }
694 697 },
695 698  
  699 + updateLinkedToMultiPlotMode : function() {
  700 + this.plotTabContent.updateLinkedToMultiPlotMode(this.tabObject.get('multi-plot-linked'));
  701 + },
  702 +
696 703 init : function(config) {
697 704 var me = this;
698 705  
... ... @@ -706,6 +713,35 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
706 713  
707 714 this.plotElementPanel = config.plotElementPanel;
708 715  
  716 + this.simplifiedViewCombo = Ext.create('Ext.form.field.Checkbox', {
  717 + xtype: 'checkbox',
  718 + boxLabel: 'Simplified View',
  719 + listeners: {
  720 + change: function(combo, newValue, oldValue, eOpts) {
  721 + if (this.tabObject)
  722 + this.tabObject.set('tree-simplified-view', newValue);
  723 + if (newValue != oldValue)
  724 + this.buildTree(this.tabObject);
  725 + },
  726 + scope: this
  727 + }
  728 + });
  729 +
  730 + this.linkToMultiPlotCombo = Ext.create('Ext.form.field.Checkbox', {
  731 + xtype: 'checkbox',
  732 + boxLabel: 'Link to MultiPlot',
  733 + listeners: {
  734 + change: function(combo, newValue, oldValue, eOpts) {
  735 + if (this.tabObject)
  736 + {
  737 + this.tabObject.set('multi-plot-linked', newValue);
  738 + this.updateLinkedToMultiPlotMode();
  739 + }
  740 + },
  741 + scope: this
  742 + }
  743 + });
  744 +
709 745 var myConf = {
710 746 store: store,
711 747 rootVisible: false,
... ... @@ -756,16 +792,9 @@ Ext.define(&#39;amdaPlotComp.PlotTree&#39;, {
756 792 scope: this
757 793 },
758 794 '->',
759   - {
760   - xtype: 'checkbox',
761   - boxLabel: 'Simplified View',
762   - listeners: {
763   - change: function(combo, newValue, oldValue, eOpts) {
764   - this.setSimplifiedMode(newValue);
765   - },
766   - scope: this
767   - }
768   - }
  795 + this.linkToMultiPlotCombo,
  796 + ' ',
  797 + this.simplifiedViewCombo
769 798 ]
770 799 };
771 800  
... ...
js/app/views/PlotUI.js
... ... @@ -24,6 +24,8 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
24 24  
25 25 formPanel: null,
26 26  
  27 + multiPlotIntervalPanel : null,
  28 +
27 29 plotOutput: null,
28 30  
29 31 plotTabs : null,
... ... @@ -76,11 +78,12 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
76 78 */
77 79 doPlot : function(){
78 80 var timeSource = this.timeSelector.getActiveTimeSource();
79   - var basicForm = this.formPanel.getForm();
80   - basicForm.updateRecord(this.object);
  81 + var multiPlotForm = this.multiPlotIntervalPanel.getForm();
  82 + multiPlotForm.updateRecord(this.object);
81 83 this.object.set('timesrc', timeSource);
82 84 if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
83 85 this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
  86 + this.plotTabs.updateTimeObject();
84 87  
85 88 // fire execution
86 89 var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
... ... @@ -122,14 +125,18 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
122 125 this.timeSelector.intervalSel.updateDuration();
123 126 },
124 127  
  128 + updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) {
  129 + this.multiPlotIntervalPanel.setVisible(isLinkedToMultiPlotMode);
  130 + },
  131 +
125 132 init : function(config) {
126   - this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelector' + config.id, flex: 1} );
  133 + this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelector' + config.id, flex: 1, title : 'MultiPlot Time Selection'} );
127 134  
128 135 this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 2});
129 136  
130 137 this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 3});
131 138  
132   - this.plotTabs = new amdaPlotComp.PlotTabPanel({flex: 2, plotElementPanel : this.plotElement});
  139 + this.plotTabs = new amdaPlotComp.PlotTabPanel({flex: 2, plotElementPanel : this.plotElement, plotUI : this});
133 140  
134 141 this.optionsPanel = new Ext.form.Panel({
135 142 layout: {
... ... @@ -147,6 +154,18 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
147 154 ]
148 155 });
149 156  
  157 + this.multiPlotIntervalPanel = new Ext.form.Panel({
  158 + layout: 'fit',
  159 + bodyStyle: { background : '#dfe8f6' },
  160 + visible : false,
  161 + defaults: {
  162 + border: false
  163 + },
  164 + items : [
  165 + this.timeSelector
  166 + ]
  167 + });
  168 +
150 169 this.formPanel = new Ext.form.Panel({
151 170 region: 'center',
152 171 layout: {
... ... @@ -173,7 +192,7 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
173 192 flex: 1,
174 193 items: [
175 194 this.plotTabs,
176   - this.timeSelector
  195 + this.multiPlotIntervalPanel
177 196 ]
178 197 },
179 198 {
... ...
js/app/views/TimeSelectorUI.js
... ... @@ -220,7 +220,7 @@ Ext.define(&#39;amdaUI.TimeSelectorUI&#39;,
220 220  
221 221 var config =
222 222 {
223   - title: 'Time Selection',
  223 + title: (!this.title) ? 'Time Selection' : this.title,
224 224 layout: 'fit',
225 225 items:
226 226 [
... ... @@ -228,7 +228,7 @@ Ext.define(&#39;amdaUI.TimeSelectorUI&#39;,
228 228 ]
229 229 };
230 230  
231   - Ext.apply(this, config);
  231 + Ext.apply(this, config);
232 232 this.callParent(arguments);
233 233 }
234 234 });
... ...