Commit 18d4a11e236eeff8445bffec05d1866937bcee16

Authored by Benjamin Renard
1 parent 003ba315

Save and load plot request

Clean old plot code
js/app/AmdaApp.js
... ... @@ -56,10 +56,10 @@ Ext.define('amdaApp.AmdaApp', {
56 56 useLauncher : true
57 57 },
58 58 plot : {
59   - id : 'new-plot-win',
  59 + id : 'plot-win',
60 60 icon : 'icon-plot',
61 61 title : 'Plot Manager',
62   - source : 'amdaDesktop.NewPlotModule',
  62 + source : 'amdaDesktop.PlotModule',
63 63 useLauncher : true
64 64 },
65 65 search : {
... ... @@ -132,13 +132,6 @@ Ext.define('amdaApp.AmdaApp', {
132 132 source : 'amdaDesktop.FiltersModule',
133 133 useLauncher : false
134 134 },
135   - interactive_plot : {
136   - id : 'plot-mgr',
137   - icon : 'icon-results',
138   - title : 'Multi Plot Manager',
139   - source : 'amdaDesktop.InteractivePlotMgr',
140   - useLauncher : false
141   - },
142 135 result : {
143 136 id : 'result-win',
144 137 contentId : 'resultUI',
... ... @@ -280,7 +273,7 @@ Ext.define('amdaApp.AmdaApp', {
280 273 data: [
281 274 { name: 'Help', iconCls: 'help', module: 'help-win' },
282 275 { name: 'Create/Modify parameter', iconCls: 'edit', module: 'param-win' },
283   - { name: 'Plot data', iconCls: 'plot', module: 'new-plot-win'},
  276 + { name: 'Plot data', iconCls: 'plot', module: 'plot-win'},
284 277 { name: 'Data mining', iconCls: 'search', module: 'search-win'},
285 278 { name: 'Statistics', iconCls: 'statistics', module: 'statistics-win'},
286 279 { name: 'Download data', iconCls: 'download_manager', module: 'down-win'},
... ...
js/app/controllers/ExplorerModule.js
... ... @@ -33,7 +33,7 @@ Ext.define('amdaDesktop.ExplorerModule', {
33 33 // Object Models
34 34 'amdaModel.Parameter',
35 35 'amdaModel.Search',
36   - 'amdaModel.Plot',
  36 + 'amdaPlotObj.PlotRequestObject',
37 37 'amdaModel.Download',
38 38 'amdaModel.TimeTable',
39 39 'amdaModel.Catalog',
... ...
js/app/controllers/InteractiveModule.js
... ... @@ -197,7 +197,7 @@ Ext.define('amdaDesktop.InteractiveModule', {
197 197 */
198 198 createObject : function (obj){
199 199  
200   - var object;
  200 + var object;
201 201 if (this.linkedNode.get('object')){
202 202 object = this.linkedNode.get('object');
203 203 } else {
... ...
js/app/controllers/InteractivePlotMgr.js deleted
... ... @@ -1,315 +0,0 @@
1   -
2   -/**
3   - * Project  : AMDA-NG
4   - * Name : InteractivePlotMgr.js
5   - * @class amdaDesktop.ResultModule
6   - * @extends amdaDesktop.InteractiveModule
7   - * @brief Result Module controller definition
8   - * @author
9   - * @version $Id: InteractivePlotMgr.js 1875 2013-11-22 15:02:50Z elena $
10   - *****************************************************************************
11   - * FT Id : Date : Name - Description
12   - *******************************************************************************
13   - *
14   - */
15   -
16   -Ext.define('amdaDesktop.InteractivePlotMgr', {
17   - extend: 'amdaDesktop.InteractiveModule',
18   -
19   - requires: [
20   - 'amdaUI.InteractivePlotUI',
21   - 'amdaUI.PlotTabResultUI'
22   - ],
23   -
24   - statics: {
25   - multiSelector: false,
26   -
27   - maxWinNumber : 5,
28   - imgOffset : { x : 70, y : 85 },
29   - winSize : {
30   - landscape : { width : 0, height : 0 },
31   - portrait : { width : 0, height : 0 }
32   - }
33   - },
34   -
35   - imgSize : {
36   - landscape : { width : 1052, height : 744 },
37   - portrait : { width : 744, height : 1052 }
38   - },
39   -
40   - maxWinNumber : 5,
41   - contentId : 'InteractivePlotUI',
42   - /**
43   - * @cfg {String} data models
44   - * @required
45   - */
46   - nodeDataModel : 'amdaModel.BkgJobNode',
47   - windowMgr : null,
48   - win: null,
49   -
50   - constructor : function(config) {
51   - this.callParent(arguments);
52   - if (!this.windowMgr) this.windowMgr = new Ext.AbstractManager();
53   - },
54   -
55   - init : function() {
56   - //force the launcher to null to don't add this item on start menu
57   - this.launcher = null;
58   - amdaDesktop.InteractivePlotMgr.winSize.landscape.width = this.imgSize.landscape.width + amdaDesktop.InteractivePlotMgr.imgOffset.x;
59   - amdaDesktop.InteractivePlotMgr.winSize.landscape.height = this.imgSize.landscape.height + amdaDesktop.InteractivePlotMgr.imgOffset.y;
60   - amdaDesktop.InteractivePlotMgr.winSize.portrait.width = this.imgSize.portrait.width + amdaDesktop.InteractivePlotMgr.imgOffset.x;
61   - amdaDesktop.InteractivePlotMgr.winSize.portrait.height = this.imgSize.portrait.height + amdaDesktop.InteractivePlotMgr.imgOffset.y;
62   - },
63   -
64   - computeWindowSize : function(panelResult)
65   - {
66   - var size = panelResult.getImageSize();
67   - size.width += 30;
68   - size.height += 95;
69   -
70   - return size;
71   - },
72   - /**
73   - * Window Creation method of the Module
74   - */
75   - createWindow : function () {
76   - // independent window manager to register all plot windows
77   - this.win = myDesktopApp.desktop.getWindow(this.id);
78   -
79   - if (!this.win) {
80   - this.win = myDesktopApp.desktop.createWindow({
81   - id : this.id,
82   - title : this.title,
83   - width : 320,
84   - height : 120,
85   - iconCls : this.icon,
86   - x : 3000,
87   - y : 5 ,
88   - border : false,
89   - constrainHeader : true,
90   - layout : 'fit',
91   - closable: false,
92   - maximizable: false,
93   - tools: [
94   - {
95   - type:'help',
96   - qtip: 'Help on Multi Plot',
97   - scope:this,
98   - handler: function(event, toolEl, panel){
99   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function (module) {
100   - module.createWindow('multiPlot', 'Help on Multi Plot');
101   - });
102   - }
103   - }
104   - ],
105   - items : [ { xtype : 'panelPlotMgr' } ]
106   - });
107   -
108   - this.win.on({
109   - scope: this,
110   - // on window closing event
111   - beforeclose: function(){
112   - this.windowMgr.each(function(key,win){
113   - win.close();
114   - });
115   - this.linkedNode = null;
116   - }
117   - });
118   - }
119   -
120   - var linkedNode = this.getLinkedNode();
121   -
122   - if (linkedNode) {
123   - // array of nodes for reference
124   - this.addLinkedNode(linkedNode);
125   - this.setResult({object: linkedNode.get('object')});
126   - }
127   -
128   - // this.win.show();
129   - // this.win.toFront();
130   -
131   - },
132   -
133   - setResult: function(configResult){
134   -
135   -// define window size depending on plot orientation
136   - var orientation = configResult.object.get('orientation');
137   -
138   - // get existing plot Result Plot Window with this resultId
139   - var id = 'plot'+configResult.object.get('tabId');
140   - var windowResultId = id + '-win';
141   -
142   - var windowResult = this.getWindowResult(windowResultId);
143   -
144   - // if no existing plot Tab Result Panel
145   - if (!windowResult) {
146   - N = eval(configResult.object.get('tabId'));
147   -
148   - var title = 'Plot '+ configResult.object.get('tabId');
149   - var panelResult = new amdaUI.PlotTabResultUI(configResult);
150   -
151   - var pageSize = Ext.state.Manager.getProvider().get(windowResultId+'_pagesize');
152   - if (!pageSize)
153   - pageSize = 75;
154   -
155   - var size = this.computeWindowSize(panelResult);
156   -
157   - var x = N * 50;
158   - var y = 100 + N * 20;
159   - var win = myDesktopApp.getDesktop().createWindow({
160   - id : windowResultId,
161   - mode : orientation,
162   - title : title,
163   - width : size.width,
164   - height : size.height,
165   - x : x,
166   - y : y,
167   - iconCls : this.icon,
168   - border : false,
169   - constrainHeader : true,
170   - layout : 'fit',
171   - items : [
172   - panelResult
173   - ],
174   - listeners: {
175   - scope: this,
176   - move: function(win,x,y){
177   - var panel = win.items.items[0];
178   - var image = panel.items.items[0];
179   - panel.setImageSettings(image);
180   - },
181   - resize: function(win, w, h){
182   - var panel = win.items.items[0];
183   - var image = panel.items.items[0];
184   - panel.setImageSettings(image);
185   - },
186   - beforeclose: function(win,opt){
187   - var linkedNodeKey = win.id;
188   - var linkedNode = this.getLinkedNodeByKey(linkedNodeKey);
189   - this.removeLinkedNode(linkedNodeKey);
190   - this.win.items.items[0].removePlotItem(linkedNodeKey);
191   -
192   - linkedNode.deleteNode();
193   - this.windowMgr.unregister(win);
194   - if (myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id) != null)
195   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id).multiSelector = false;
196   - },
197   - // destroy: function(win,opt){
198   - // if (this.windowMgr.getCount() === 0) this.win.close();
199   - // },
200   - show: function(o)
201   - {
202   - panelResult.setPageSize(pageSize);
203   - }
204   - }
205   - });
206   -
207   - panelResult.on({
208   - scope : this,
209   - pagesize : function(win,val)
210   - {
211   - Ext.state.Manager.getProvider().set(windowResultId+'_pagesize',val);
212   - }
213   - });
214   -
215   - // register new window
216   - this.windowMgr.register(win);
217   - if (this.linkedNodes) this.win.items.items[0].addPlotItem(N-1,windowResultId);
218   - win.show();
219   -
220   - } else {
221   -//update image (OUTPUTNAME!!!!) and timing in existing Tab result Panel
222   - var linkedNode = this.getLinkedNode();
223   - //resize window for changed orientation
224   - var resultId = linkedNode.get('object').get('folderId');
225   -
226   - //var outputName = linkedNode.get('object').get('outputName');
227   - var windowId = 'plot' + linkedNode.get('object').get('tabId') + '-win';
228   - panelResult = this.getWindowResult(windowId).items.items[0];
229   -
230   - //if (!outputName) {
231   - var outputName = linkedNode.get('object').get('resultId');;
232   - panelResult.updateObject(linkedNode.get('object'));
233   - //}
234   -//if orientation was changed : resize window and image
235   - if (windowResult.mode != orientation) {
236   - var size = this.computeWindowSize(panelResult);
237   - windowResult.setSize(size.width,size.height);
238   - windowResult.mode = orientation;
239   - var sizeImg = Ext.clone(size);
240   - var interactivePlotMgr = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id);
241   - if (interactivePlotMgr)
242   - panelResult.panelImage.setSize(sizeImg.width-amdaDesktop.InteractivePlotMgr.imgOffset.x,
243   - sizeImg.height-amdaDesktop.InteractivePlotMgr.imgOffset.y);
244   - }
245   -
246   - panelResult.panelImage.setSrc('data/'+sessionID +'/RES/'+resultId+'/'+ outputName +'.png');
247   - panelResult.currentStartTime = linkedNode.get('object').get('startDate');
248   -
249   - var stopTime = linkedNode.get('object').get('stopDate');
250   - panelResult.plotDurationInSec = Ext.Date.getElapsed(panelResult.currentStartTime, stopTime) / 1000;
251   -// reset mire and Start - Stop ONLY if Interactive Plugin is active
252   - var interactivePlugin = Ext.getCmp('interactiveInter-win-'+windowResultId);
253   - if (interactivePlugin) {
254   - panelResult.resetMire();
255   - interactivePlugin.items.getAt(0).getForm().findField('start').setValue('');
256   - interactivePlugin.items.getAt(0).getForm().findField('stop').setValue('');
257   - }
258   -
259   - panelResult.setImageSettings(panelResult.panelImage);
260   - windowResult.toFront();
261   -// if time interval => update Time in TimeSelector
262   - if (configResult.object.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[1]) {
263   - var timeSelector = Ext.getCmp('plotTimeSelector'+id);
264   - timeSelector.cardContainer.activeItem = 1;
265   - var intervalSelector = timeSelector.cardContainer.items[1];
266   - intervalSelector.setInterval(panelResult.currentStartTime, stopTime);
267   - }
268   - }
269   -//if plot for time table : set/update info
270   - if (configResult.object.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0]) {
271   - panelResult.updateTimeTableInfo(configResult.object);
272   - }
273   -
274   -// disable buttons if this Tab is checked in the multi plot selector
275   - var resWin = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id);
276   - if (!resWin) return;
277   - var checked = resWin.items.items[0].checkBoxGroup.getChecked();
278   - Ext.Array.each(checked, function(item, index){
279   - if (item.name.toLowerCase() === windowResultId){
280   - panelResult.disableButtons(true);
281   - return;
282   - }
283   - });
284   - },
285   -
286   -
287   - // getter on specific plot Tab result window
288   - getWindowResult: function(windowResultId){
289   - if (!this.windowMgr.get(windowResultId)) return null;
290   - return this.windowMgr.get(windowResultId);
291   - },
292   -
293   - addLinkedNode : function (myLinkedNode){
294   - if (!this.linkedNodes){
295   - this.linkedNodes = new Array();
296   - }
297   - var obj = myLinkedNode.get('object');
298   - if (obj.get('tabId')){
299   - // add new linkedNode to this module
300   - this.linkedNodes['plot'+obj.get('tabId') + '-win'] = myLinkedNode;
301   - }
302   - },
303   -
304   - getLinkedNodeByKey: function(linkedNodeKey){
305   - if (this.linkedNodes){
306   - return this.linkedNodes[linkedNodeKey];
307   - } else {
308   - return null;
309   - }
310   - },
311   -
312   - removeLinkedNode: function(linkedNodeKey){
313   - delete this.linkedNodes[linkedNodeKey];
314   - }
315   -});
316 0 \ No newline at end of file
js/app/controllers/NewPlotModule.js deleted
... ... @@ -1,144 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : NewPlotModule.js
4   - * @class amdaDesktop.NewPlotModule
5   - * @extends amdaDesktop.InteractiveModule
6   - * @brief New Plot Module controller definition
7   - * @author Benjamin Renard
8   - * $Id: NewPlotModule.js benjamin $
9   - */
10   -
11   -Ext.define('amdaDesktop.NewPlotModule', {
12   - extend: 'amdaDesktop.InteractiveModule',
13   -
14   - requires: [
15   - 'amdaUI.NewPlotUI',
16   - 'amdaPlotObj.PlotRequestObject',
17   - 'amdaModel.NewPlotNode',
18   - 'amdaUI.NewPlotTabResultUI'
19   - ],
20   -
21   - contentId : 'newPlotUI',
22   - linkedNode : null,
23   -
24   - /**
25   - * @cfg {String} data models
26   - * @required
27   - */
28   - nodeDataModel : 'amdaModel.NewPlotNode',
29   - //objectDataModel : 'amdaPlotObj.PlotRequestObject',
30   -
31   - /**
32   - * @cfg {String} window definitions
33   - * @required
34   - */
35   - width: 600,
36   - height: 620,
37   - uiType : 'newPanelPlot',
38   - helpTitle : 'Help on Plot Module',
39   -
40   - plotResultWindowsManager : new Ext.AbstractManager(),
41   -
42   - /**
43   - * @override
44   - */
45   - createWindow : function() {
46   - if (!this.linkedNode){
47   - this.setLinkedNode(amdaModel.NewPlotNode);
48   - }
49   - this.callParent(arguments);
50   - },
51   -
52   - saveState: function() {
53   - /*var uiContent = this.getUiContent();
54   - var form = uiContent.down('form').getForm();
55   - var values = form.getValues();
56   - // Ext.state.Manager.set(this.id + '_form', values);
57   - Ext.state.Manager.set('timeinterval', {'startDate' : values.startDate,'stopDate' : values.stopDate });*/
58   - },
59   -
60   - getState : function() {
61   - // return Ext.state.Manager.get(this.id + '_form');
62   - return Ext.state.Manager.get('timeinterval');
63   - },
64   -
65   - computeResultWindowSize : function(panelResult)
66   - {
67   - var size = panelResult.getImageSize();
68   - size.width += 30;
69   - size.height += 95;
70   -
71   - return size;
72   - },
73   -
74   - startInteractiveSession : function(session) {
75   - var me = this;
76   - Ext.each(session.result, function (tabResult, index) {
77   - var winResultId = tabResult.id+"-win";
78   -
79   - var winResult = me.getWindowResult(winResultId);
80   -
81   - var plotTabConfig = {
82   - folder : session.folder,
83   - plotFile : tabResult.plot,
84   - context : tabResult.context
85   - };
86   -
87   - if (winResult == null) {
88   - //create new result win
89   - var panelResult = new amdaUI.NewPlotTabResultUI(plotTabConfig);
90   -
91   - var size = me.computeResultWindowSize(panelResult);
92   -
93   - var win = myDesktopApp.getDesktop().createWindow({
94   - id : tabResult.id+"-win",
95   - title : 'Plot '+(index+1),
96   - width : size.width,
97   - height: size.height,
98   - layout: 'fit',
99   - items : [
100   - panelResult
101   - ],
102   - listeners: {
103   - scope: me,
104   - beforeclose: function(win,opt) {
105   - me.plotResultWindowsManager.unregister(win);
106   - }
107   - },
108   - getPanelResult: function() {
109   - return panelResult;
110   - }
111   - });
112   - win.show();
113   - me.plotResultWindowsManager.register(win);
114   - }
115   - else
116   - {
117   - //update result
118   - winResult.getPanelResult().updatePlotImage(plotTabConfig);
119   - //update window size
120   - var size = me.computeResultWindowSize(winResult.getPanelResult());
121   - winResult.setSize(size.width, size.height);
122   -
123   - winResult.toFront();
124   - }
125   - });
126   - },
127   -
128   - closeInteractiveSession : function() {
129   - var me = this;
130   - this.plotResultWindowsManager.each(function (key, value, length) {
131   - value.close();
132   - me.plotResultWindowsManager.unregister(value);
133   - });
134   - },
135   -
136   - updateInteractiveSession : function() {
137   -
138   - },
139   -
140   - getWindowResult: function(winResultId){
141   - if (!this.plotResultWindowsManager.get(winResultId)) return null;
142   - return this.plotResultWindowsManager.get(winResultId);
143   - }
144   -});
145 0 \ No newline at end of file
js/app/controllers/PlotModule.js
... ... @@ -3,194 +3,132 @@
3 3 * Name : PlotModule.js
4 4 * @class amdaDesktop.PlotModule
5 5 * @extends amdaDesktop.InteractiveModule
6   - * @brief Plot Module controller definition
7   - * @author Caroline DARMON
8   - * $Id: PlotModule.js 2152 2014-02-28 16:32:22Z elena $
  6 + * @brief New Plot Module controller definition
  7 + * @author Benjamin Renard
  8 + * $Id: PlotModule.js benjamin $
9 9 */
10 10  
11 11 Ext.define('amdaDesktop.PlotModule', {
12   -
13   - extend: 'amdaDesktop.InteractiveModule',
14   -
15   - requires: [
16   - 'amdaUI.TabPlotUI'
17   - ],
18   -
19   - contentId : 'tabPlotUI',
  12 + extend: 'amdaDesktop.InteractiveModule',
  13 +
  14 + requires: [
  15 + 'amdaUI.PlotUI',
  16 + 'amdaPlotObj.PlotRequestObject',
  17 + 'amdaModel.PlotNode',
  18 + 'amdaUI.PlotTabResultUI'
  19 + ],
  20 +
  21 + contentId : 'plotUI',
20 22 linkedNode : null,
21   - //array of linked nodes (TabPanel!!!)
22   - linkedNodes : null,
23 23  
24   -
25 24 /**
26   - * @cfg {String} data models
27   - * @required
28   - */
  25 + * @cfg {String} data models
  26 + * @required
  27 + */
29 28 nodeDataModel : 'amdaModel.PlotNode',
  29 + //objectDataModel : 'amdaPlotObj.PlotRequestObject',
30 30  
31 31 /**
32 32 * @cfg {String} window definitions
33 33 * @required
34 34 */
35   - height: 680,
36   - width: 850,
37   - uiType : 'tabPlot',
38   - helpTitle : 'Help on Plot Module',
39   -
40   - /**
41   - * Window Creation method of the Module
42   - */
43   - createWindow : function () {
44   - // init Result Win
45   - var win = myDesktopApp.desktop.getWindow(this.id);
46   -
47   - if (!win)
48   - {
49   - win = myDesktopApp.desktop.createWindow({
50   - id : this.id,
51   - title : this.title,
52   - width : this.width,
53   - // minWidth : this.width,
54   - height : this.height,
55   - minHeight: this.height,
56   - iconCls : this.icon,
57   - border : false,
58   - constrainHeader : true,
59   - layout : 'fit',
60   - stateful : true,
61   - stateId : this.id,
62   - stateEvents: ['move','show','resize'],
63   - tools: [
64   - {
65   - type:'help',
66   - qtip: this.helpTitle,
67   - scope:this,
68   - handler: function(event, toolEl, panel){
69   - var me = this;
70   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function (module) {
71   - module.createWindow('plotStart', me.helpTitle);
72   - });
73   - }
74   - }
75   - ],
76   - items : [
77   - {
78   - xtype : this.uiType,
79   - id : this.contentId
80   - }
81   - ]
82   - });
83   - this.closed = false;
84   - win.on({
85   - scope: this,
86   - activate: function(){
87   - // order to pin this Module with WsExplorer
88   - this.pin();
89   - },
90   - show: function(){
91   - var multiMgrWin = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id);
92   -
93   - if (!multiMgrWin) {
94   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id, true, function (module) {
95   - module.createWindow();
96   - module.win.show();
97   - });
98   - }
99   -
100   - },
101   - // on window closing event
102   - beforeclose: function(){
103   -
104   - this.saveState();
105   -
106   - var isDirty = win.down('form').getForm().isDirty();
107   - if (!this.closed && isDirty) {
108   - Ext.Msg.confirm('Close', 'Current window has been modified.\nDo you want to close the window ?' , function (btn, text){
109   - if (btn == 'yes'){
110   - // mark this.closed as true before the call to close() as that will fire the beforeclose event again
111   - this.closed = true;
112   - win.close();
113   - }
114   - },this);
115   - } else if (!isDirty) {
116   - this.closed = true;
117   - }
118   - if (this.closed) {
119   - // close Interactive Plot Mgr Window if exists
120   - var multiMgrWin = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id);
121   - if (multiMgrWin) multiMgrWin.close();
122   - if (this.linkedNodes) this.linkedNodes.clear();
123   - this.linkedNode.set('object','');
124   - // unlink Node
125   - this.setLinkedNode(null);
126   - this.unpin();
127   - }
128   - // Don't automatically close if the form is dirty, let the call to this.close() within the confirm box close the window.
129   - return this.closed;
130   - }
131   - });
132   - } // if !win
133   - win.show();
134   -
135   - this.linkedNode = this.getLinkedNode();
136   -
137   - if (!this.linkedNode) {
138   - this.createLinkedNode();
139   - this.createObject();
140   - }
141   -
142   - var tabId = this.getUiContent().tabPanel.getActiveTab().id;
143   - var editedNode = this.getTabNode(tabId);
144   - if (editedNode !== this.linkedNode) {
145   - this.getUiContent().setObject(this.linkedNode.get('object'));
146   - }
147   - // add linked node to the array of nodes and set object to UI (TabPlotUI)
148   - this.addLinkedNode(this.linkedNode, null);
149   - },
150   -
151   - /**
152   - * add the current node in this module
153   - * @param {amdaModel.InteractiveNode} myLinkedNode
154   - */
155   - addLinkedNode : function (myLinkedNode, tabId)
156   - {
157   -
158   - if (!this.linkedNodes){
159   - this.linkedNodes = new Ext.util.HashMap();
160   - }
161   - //TODO link the same request node to multi tabs - or interdit???
162   -
163   - if (!tabId) tabId = this.getUiContent().tabPanel.getActiveTab().id;
164   - this.linkedNodes.replace(tabId,myLinkedNode);
165   - },
166   -
167   - /**
168   - * get active Tab linked node in Plot module
169   - *
170   - */
171   - getTabNode : function (tabId)
172   - {
173   - if (!this.linkedNodes){
174   - return null;
175   - }
176   - // var tabId = this.getUiContent().tabPanel.getActiveTab().id;
177   - var linkedNode = this.linkedNodes.get(tabId);
178   - return linkedNode;
179   - },
180   -
  35 + width: 600,
  36 + height: 620,
  37 + uiType : 'newPanelPlot',
  38 + helpTitle : 'Help on Plot Module',
  39 +
  40 + plotResultWindowsManager : new Ext.AbstractManager(),
  41 +
181 42 saveState: function() {
182   - var uiContent = this.getUiContent();
183   - var form = uiContent.tabPanel.getActiveTab().down('form').getForm();
184   - var values = form.getValues();
185   - // Ext.state.Manager.set(this.id + '_form', values);
186   - Ext.state.Manager.set('timeinterval', {'startDate' : values.startDate,'stopDate' : values.stopDate });
187   -
  43 + /*var uiContent = this.getUiContent();
  44 + var form = uiContent.down('form').getForm();
  45 + var values = form.getValues();
  46 + // Ext.state.Manager.set(this.id + '_form', values);
  47 + Ext.state.Manager.set('timeinterval', {'startDate' : values.startDate,'stopDate' : values.stopDate });*/
188 48 },
189 49  
190   - getState : function() {
191   -
192   - // return Ext.state.Manager.get(this.id + '_form');
  50 + getState : function() {
  51 + // return Ext.state.Manager.get(this.id + '_form');
193 52 return Ext.state.Manager.get('timeinterval');
194   - }
  53 + },
  54 +
  55 + computeResultWindowSize : function(panelResult)
  56 + {
  57 + var size = panelResult.getImageSize();
  58 + size.width += 30;
  59 + size.height += 95;
  60 +
  61 + return size;
  62 + },
  63 +
  64 + startInteractiveSession : function(session) {
  65 + var me = this;
  66 + Ext.each(session.result, function (tabResult, index) {
  67 + var winResultId = tabResult.id+"-win";
  68 +
  69 + var winResult = me.getWindowResult(winResultId);
  70 +
  71 + var plotTabConfig = {
  72 + folder : session.folder,
  73 + plotFile : tabResult.plot,
  74 + context : tabResult.context
  75 + };
  76 +
  77 + if (winResult == null) {
  78 + //create new result win
  79 + var panelResult = new amdaUI.PlotTabResultUI(plotTabConfig);
  80 +
  81 + var size = me.computeResultWindowSize(panelResult);
  82 +
  83 + var win = myDesktopApp.getDesktop().createWindow({
  84 + id : tabResult.id+"-win",
  85 + title : 'Plot '+(index+1),
  86 + width : size.width,
  87 + height: size.height,
  88 + layout: 'fit',
  89 + items : [
  90 + panelResult
  91 + ],
  92 + listeners: {
  93 + scope: me,
  94 + beforeclose: function(win,opt) {
  95 + me.plotResultWindowsManager.unregister(win);
  96 + }
  97 + },
  98 + getPanelResult: function() {
  99 + return panelResult;
  100 + }
  101 + });
  102 + win.show();
  103 + me.plotResultWindowsManager.register(win);
  104 + }
  105 + else
  106 + {
  107 + //update result
  108 + winResult.getPanelResult().updatePlotImage(plotTabConfig);
  109 + //update window size
  110 + var size = me.computeResultWindowSize(winResult.getPanelResult());
  111 + winResult.setSize(size.width, size.height);
  112 +
  113 + winResult.toFront();
  114 + }
  115 + });
  116 + },
  117 +
  118 + closeInteractiveSession : function() {
  119 + var me = this;
  120 + this.plotResultWindowsManager.each(function (key, value, length) {
  121 + value.close();
  122 + me.plotResultWindowsManager.unregister(value);
  123 + });
  124 + },
  125 +
  126 + updateInteractiveSession : function() {
  127 +
  128 + },
195 129  
  130 + getWindowResult: function(winResultId){
  131 + if (!this.plotResultWindowsManager.get(winResultId)) return null;
  132 + return this.plotResultWindowsManager.get(winResultId);
  133 + }
196 134 });
197 135 \ No newline at end of file
... ...
js/app/models/BkgJobNode.js
... ... @@ -231,7 +231,7 @@ Ext.define('amdaModel.BkgJobNode', {
231 231 folderId : result.folder});
232 232 break;
233 233 case 'request' :
234   - obj = Ext.create('amdaModel.Plot',
  234 + obj = Ext.create('amdaPlotObj.PlotRequestObject.',
235 235 {name: result.name, format: result.format,
236 236 resultId : result.result,
237 237 folderId : result.folder});
... ...
js/app/models/DownloadNode.js
... ... @@ -68,45 +68,30 @@ Ext.define('amdaModel.DownloadNode', {
68 68 },
69 69  
70 70 decodeObject: function(obj) {
71   - var myValues = new Object();
72   - myValues.list=[];
  71 + console.log(obj);
  72 + var myValues = new Object();
  73 + myValues.list=[];
73 74  
74   - if (!obj) {
75   - var fullObject = this.get('realLinkedNode').get('object');
76   - }
77   - else {
78   - var fullObject = obj;
79   - }
  75 + if (!obj) {
  76 + var fullObject = this.get('realLinkedNode').get('object');
  77 + }
  78 + else {
  79 + var fullObject = obj;
  80 + }
80 81  
81   - var childrenArray = [];
82   - if (fullObject.childNodes){
83   - // use internal node attribute of NodeInterface to get children
84   - Ext.Array.each(fullObject.childNodes, function(panelItem) {
85   - childrenArray.push(panelItem.getJsonValues());
86   - });
87   - } else {
88   - // else if a json config has been past to the Plot constructor
89   - childrenArray = fullObject.get('children');
90   - }
91   -
92   - var panels = childrenArray;
93   - var i = 0;
94   - Ext.each(panels, function(item){
95   - var params = item.children;
96   - Ext.each(params,function(param){
97   - if (!param.plotOnly) {
98   - if (param.downloadParamArgs){
99   - myValues.list[i] = this.parseArgs(param);
100   - }
101   - else {
102   - myValues.list[i] = param.name;
103   - }
104   - i++;
105   - }
106   - }, this);
107   - }, this);
108   - myValues.name = fullObject.get('name');
109   - myValues.timesrc = fullObject.get('timesrc');
  82 + var i = 0;
  83 + fullObject.tabs().each(function (tab) {
  84 + tab.panels().each(function (panel) {
  85 + panel.params().each(function (param) {
  86 + myValues.list[i] = param.get('param-id');
  87 + ++i;
  88 + });
  89 + });
  90 +
  91 + });
  92 +
  93 + myValues.name = fullObject.get('name');
  94 + myValues.timesrc = fullObject.get('timesrc');
110 95 // if there's at least one timeTable name into 'timeTables' collection
111 96 if (myValues.timesrc == amdaModel.AmdaTimeObject.inputTimeSrc[0]
112 97 && fullObject.get('timeTables')
... ...
js/app/models/ExecutableNode.js
... ... @@ -106,7 +106,7 @@ Ext.define('amdaModel.ExecutableNode', {
106 106 {
107 107 case amdaModel.BkgJobNode.STATUS_LIST.DONE :
108 108 newNode.createJobNode(true);
109   - newNode.editNode(isNewTab, isInteractive);
  109 + newNode.editNode(true, false);
110 110 break;
111 111 case amdaModel.BkgJobNode.STATUS_LIST.IN_PROGRESS :
112 112 newNode.createJobNode(false);
... ... @@ -130,22 +130,7 @@ Ext.define('amdaModel.ExecutableNode', {
130 130 newobj.processId= res.id;
131 131 newobj.tabId = res.tabId;
132 132 newobj.name = res.name;
133   - if (this.get('object').$className == 'amdaModel.Plot' && obj.format == 'PNG') {
134   - if (obj.timesrc == amdaModel.AmdaTimeObject.inputTimeSrc[0]) {
135   - newobj.intervalN = res.intervalN;
136   - newobj.ttName = res.tableName;
137   - newobj.totalN = res.totalN;
138   - newobj.startDate = res.startDate;
139   - newobj.stopDate = res.stopDate;
140   - }
141   - else {
142   - newobj.stopDate = this.get('object').get('stopDate');
143   - }
144   -//TODO implement xmin/xmax, ymin/ymax for all panels
145   - newobj.xMin = res.children[0].xmin;
146   - newobj.xMax = res.children[0].xmax;
147   - }
148   - newobj = Ext.create(this.get('object').$className, newobj);
  133 + newobj = Ext.create(this.get('object').$className, newobj);
149 134 return newobj;
150 135 },
151 136 /**
... ...
js/app/models/InteractiveNode.js
... ... @@ -496,7 +496,7 @@ Ext.define('amdaModel.InteractiveNode', {
496 496 var me = this;
497 497 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
498 498 if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.plot.id)) {
499   - var request = Ext.create(amdaModel.Plot.$className);
  499 + var request = Ext.create(amdaPlotObj.PlotRequestObject.$className);
500 500 var newNode = Ext.create(amdaModel.PlotNode.$className, { object : request });
501 501 // edit newNode into Plot Module with node as contextNode
502 502 newNode.editInModule();
... ... @@ -505,7 +505,7 @@ Ext.define('amdaModel.InteractiveNode', {
505 505 module.getUiContent().setTimeFromData(me.getTimeFromNode(node));
506 506 }
507 507 }
508   - module.getUiContent().tabPanel.getActiveTab().dropRecord(node);
  508 + module.getUiContent().addParameter(node);
509 509 });
510 510 },
511 511  
... ...
js/app/models/NewPlotNode.js deleted
... ... @@ -1,131 +0,0 @@
1   -/**
2   - * Project : AMDA-NG4
3   - * Name : NewPlotNode.js
4   - * @class amdaModel.NewPlotNode
5   - * @extends amdaModel.ExecutableNode
6   - * @brief Basic Model of Node corresponding to a plot request
7   - * @author Benjamin Renard
8   - * @version $Id: $
9   - * @todo
10   - *******************************************************************************
11   - * FT Id : Date : Name - Description
12   - *******************************************************************************
13   - * : :21/08/2015: BRE - file creation
14   - */
15   -
16   -Ext.define('amdaModel.NewPlotNode', {
17   - singleton: true,
18   -
19   - extend: 'amdaModel.ExecutableNode',
20   -
21   - requires: [
22   - 'amdaPlotObj.PlotRequestObject'
23   - ],
24   -
25   - statics: {
26   - nodeType: 'request'
27   - },
28   -
29   - constructor : function(config){
30   -
31   - this.callParent(arguments);
32   - this.set('moduleId',myDesktopApp.dynamicModules.plot.id);
33   - this.set('objectDataModel',amdaPlotObj.PlotRequestObject.$className);
34   - this.set('ownerTreeId',amdaUI.ExplorerUI.OPE_TAB.TREE_ID);
35   - this.set('nodeType',amdaModel.PlotNode.nodeType);
36   - },
37   -
38   - allMenuItems : function() {
39   - var menuItems =
40   - [{
41   - fnId : 'root-createDir',
42   - text : 'Create Folder'
43   - }, {
44   - fnId : 'dire-createDir',
45   - text : 'Create Folder'
46   - }, {
47   - fnId : 'dire-renameNode',
48   - text : 'Rename Folder'
49   - }, {
50   - fnId : 'dire-deleteNode',
51   - text : 'Delete Folder'
52   - }, {
53   - fnId : 'leaf-editPlot',
54   - text : 'Plot By Request'
55   - }, {
56   - fnId : 'leaf-editDownload',
57   - text : 'Download By Request'
58   - }, {
59   - fnId : 'leaf-renameNode',
60   - text : 'Rename Request'
61   - }, {
62   - fnId : 'leaf-deleteNode',
63   - text : 'Delete Request'
64   - }];
65   -
66   - return menuItems;
67   - },
68   -
69   - allMenuMultiItems : function() {
70   - var menuMulti = [
71   - {
72   - fnId : 'mult-deleteMulti',
73   - text : 'Delete selected Requests'
74   - }
75   - ];
76   - return menuMulti;
77   - },
78   -
79   - getAllContextMenuItems: function(){
80   - return this.allMenuItems();
81   - },
82   -
83   - getMultiContextMenuItems: function(){
84   - return this.allMenuMultiItems();
85   - },
86   -
87   - onMenuItemClick : function(menu,item,event) {
88   - // fnId parsing :
89   - var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length);
90   -
91   - switch (fnId) {
92   -
93   - case 'createDir':
94   - this.createDir();
95   - break;
96   -
97   - case 'deleteNode':
98   - this.deleteNode();
99   - break;
100   -
101   - case 'renameNode':
102   - this.renameNode();
103   - break;
104   -
105   - case 'editPlot':
106   - this.editLeaf(this);
107   - break;
108   -
109   - case 'editDownload':
110   - amdaModel.DownloadNode.set('realLinkedNode',this);
111   -
112   - if (!this.get('object')){
113   - AmdaAction.getObject(this.get('id'), this.get('nodeType'), amdaModel.DownloadNode.getObjectCallback, this);
114   - }
115   - else {
116   - var downObject = amdaModel.DownloadNode.decodeObject();
117   - amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject));
118   - amdaModel.DownloadNode.editInModule();
119   - }
120   - break;
121   -
122   - case 'deleteMulti':
123   - this.deleteMulti();
124   - break;
125   -
126   - default:
127   - break;
128   - } // switch end
129   - }
130   -
131   -});
js/app/models/Plot.js deleted
... ... @@ -1,130 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : Plot.js
4   - * @class amdaModel.Plot
5   - * @extends amdaModel.PlotNodeObject
6   - * @brief Plot Request Business Object Definition
7   - * @author Caroline DARMON
8   - * @version $Id: Plot.js 2544 2014-10-03 10:21:56Z elena $
9   - ******************************************************************************
10   - * FT Id : Date : Name - Description
11   - ******************************************************************************
12   - * : :08/09/2011: CDA - file creation
13   - */
14   -
15   -
16   -Ext.define('amdaModel.Plot', {
17   - extend: 'amdaModel.AmdaTimeObject',
18   -
19   - fields : [
20   - {name: 'children'},
21   - {name: 'leaf', type: 'boolean', defaultValue: false},
22   - {name: 'outputName', type: 'string'},
23   - {name: 'orientation', type: 'string', defaultValue: 'LANDSCAPE'},
24   - {name: 'format', type: 'string', defaultValue: 'PNG'},
25   - {name: 'title', type: 'string'},
26   - {name: 'description', type: 'string'},
27   - {name: 'charSize', type: 'float', defaultValue: 1.3},
28   - {name: 'thickness', type: 'int', defaultValue: 1},
29   - {name: 'ppp', type: 'int', defaultValue: 3000},
30   - {name: 'forcedLayout', type: 'boolean', defaultValue: false},
31   - {name: 'forcedMulti', type: 'boolean', defaultValue: false},
32   - {name: 'resultId', type: 'string'},
33   - {name: 'resultFolder', type: 'string'},
34   - {name: 'tabId', type: 'string', defaultValue: '1'},
35   - {name: 'xMin', type: 'string'},
36   - {name: 'xMax', type: 'string'}
37   - ],
38   -
39   - hasMany: {model: 'amdaModel.PlotPanel', name: 'children'},
40   -
41   - propertiesToCopy : 'id,name,outputName,orientation,format,ppp,title,description,charSize,thickness,timesrc,startDate,stopDate,children',
42   -
43   - constructor: function(configPanel){
44   - this.callParent(arguments);
45   - this.set('leaf',false);
46   - },
47   -
48   - getParentPanel : function(paramObject){
49   - // for each panel
50   - for(var i=0;i<this.object.plotPanels().getCount();i++) {
51   - var panel = this.object.plotPanels().getAt(i);
52   - // if there's at least one param
53   - if (panel.plotParams()){
54   - // for each param
55   - for(var j=0;j<panel.plotParams().getCount();j++) {
56   - if (paramObject == panel.plotParams().getAt(j)){
57   - return panel;
58   - }
59   - }
60   - }
61   - }
62   - },
63   -
64   - getJsonValues : function(hasId){
65   -
66   - var myValues = new Object();
67   - if (hasId) {
68   - myValues.id = this.get('id');
69   - }
70   - if (this.get('resultId')) {
71   - myValues.resultId = this.get('resultId');
72   - }
73   - myValues.name = this.get('name');
74   -
75   - // myValues.text = this.get('text');
76   - myValues.tabId = this.get('tabId');
77   - myValues.outputName = this.get('outputName');
78   - myValues.orientation = this.get('orientation');
79   - myValues.format = this.get('format');
80   - myValues.title = this.get('title');
81   - myValues.description = this.get('description');
82   - myValues.charSize = this.get('charSize');
83   - myValues.thickness = this.get('thickness');
84   - myValues.ppp = this.get('ppp');
85   - myValues.forcedLayout = this.get('forcedLayout');
86   - myValues.forcedMulti = this.get('forcedMulti');
87   -
88   - var childrenArray = []; //PlotPanel.JsonValues!!!
89   - if (this.childNodes && this.childNodes.length > 0){
90   - // use internal node attribute of NodeInterface to get children
91   - Ext.Array.each(this.childNodes, function(panelItem, panelIndex, allPanelItem) {
92   - childrenArray.push(panelItem.getJsonValues());
93   - });
94   - } else {
95   - // else if a json config has been past to the Plot constructor
96   - childrenArray = this.get('children');
97   - }
98   - myValues.children = childrenArray;
99   - myValues.timesrc = this.get('timesrc');
100   - // if there's at least one timeTable name into 'timeTables' collection
101   - if (this.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0] && this.get('timeTables') && this.get('timeTables').length){
102   - // get complete timeTables collection
103   - var timeTables = this.get('timeTables');
104   - // init an empty array for timeTables
105   - myValues.timeTables=[];
106   - // for each interval record
107   - Ext.Array.each(timeTables, function(item, index, all){
108   - if (!item.$className) {
109   - myValues.timeTables[index] = {timeTableName : item.timeTableName, id : item.id};
110   - }
111   - // get Json simplified value
112   - else {
113   - myValues.timeTables[index] = item.getJsonValues();
114   - }
115   - });
116   - } else {
117   - myValues.startDate = this.get('startDate');
118   - myValues.stopDate = this.get('stopDate');
119   - myValues.durationDay = this.get('durationDay');
120   - myValues.durationHour = this.get('durationHour');
121   - myValues.durationMin = this.get('durationMin');
122   - myValues.durationSec = this.get('durationSec');
123   - }
124   -
125   - myValues.leaf = true;
126   - myValues.nodeType = amdaModel.PlotNode.nodeType;
127   - return myValues;
128   - }
129   -
130   -});
131 0 \ No newline at end of file
js/app/models/PlotNode.js
... ... @@ -4,23 +4,33 @@
4 4 * @class amdaModel.PlotNode
5 5 * @extends amdaModel.ExecutableNode
6 6 * @brief Basic Model of Node corresponding to a plot request
7   - * @author Caroline DARMON
  7 + * @author Benjamin Renard
8 8 * @version $Id: $
  9 + * @todo
  10 + *******************************************************************************
  11 + * FT Id : Date : Name - Description
  12 + *******************************************************************************
  13 + * : :21/08/2015: BRE - file creation
9 14 */
10 15  
11 16 Ext.define('amdaModel.PlotNode', {
12   -
13   - extend: 'amdaModel.ExecutableNode',
  17 + extend: 'amdaModel.ExecutableNode',
14 18  
  19 + requires: [
  20 + 'amdaPlotObj.PlotRequestObject'
  21 + ],
  22 +
15 23 statics: {
16 24 nodeType: 'request'
17 25 },
18 26  
19   - constructor : function(config)
20   - {
  27 + constructor : function(config){
  28 +
21 29 this.callParent(arguments);
22 30 this.set('moduleId',myDesktopApp.dynamicModules.plot.id);
23   - this.set('objectDataModel',amdaModel.Plot.$className);
  31 + this.set('objectDataModel',amdaPlotObj.PlotRequestObject.$className);
  32 + this.set('ownerTreeId',amdaUI.ExplorerUI.OPE_TAB.TREE_ID);
  33 + this.set('nodeType',this.self.nodeType);
24 34 },
25 35  
26 36 allMenuItems : function() {
... ... @@ -64,7 +74,14 @@ Ext.define(&#39;amdaModel.PlotNode&#39;, {
64 74 return menuMulti;
65 75 },
66 76  
67   -
  77 + getAllContextMenuItems: function(){
  78 + return this.allMenuItems();
  79 + },
  80 +
  81 + getMultiContextMenuItems: function(){
  82 + return this.allMenuMultiItems();
  83 + },
  84 +
68 85 onMenuItemClick : function(menu,item,event) {
69 86 // fnId parsing :
70 87 var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length);
... ...
js/app/models/PlotObject.js deleted
... ... @@ -1,33 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : PlotObject.js
4   - * @class amdaModel.PlotObject
5   - * @extends amdaModel.AmdaObject
6   - * @brief Plot Request Component Abstract Business Object Definition
7   - * @author Caroline DARMON
8   - * @version $Id: PlotObject.js 961 2012-06-28 14:58:24Z elena $
9   - ******************************************************************************
10   - * FT Id : Date : Name - Description
11   - ******************************************************************************
12   - * : :08/09/2011: CDA - file creation
13   - */
14   -
15   -
16   -Ext.define('amdaModel.PlotObject', {
17   - extend: 'amdaModel.AmdaObject',
18   -
19   - fields: [
20   - { name: 'leaf', type: 'boolean'},
21   - { name:'text', convert: function(value, rec) {
22   - return rec.get('name');
23   - }
24   - },
25   - //TODO:[CDA]test
26   - {name: 'rowCls', type: 'string'}
27   -
28   - ]//,
29   -
30   - // hasMany: {model: 'amdaModel.PlotPanel', name: 'children'}
31   -}, function () {
32   - Ext.data.NodeInterface.decorate(this);
33   -});
34 0 \ No newline at end of file
js/app/models/PlotObjects/PlotPanelObject.js
... ... @@ -80,6 +80,33 @@ Ext.define(&#39;amdaPlotObj.PlotPanelObject&#39;, {
80 80 }
81 81 ],
82 82  
  83 + constructor: function(){
  84 + var me = this;
  85 + me.callParent(arguments);
  86 + if ((arguments.length > 0) && arguments[0])
  87 + {
  88 + if (arguments[0].axes)
  89 + me.loadAxes(arguments[0].axes);
  90 + if (arguments[0].params)
  91 + me.loadParams(arguments[0].params);
  92 + }
  93 + else
  94 + {
  95 + //new object, set default fields values
  96 + me.setDefaultValues();
  97 + }
  98 + },
  99 +
  100 + loadAxes: function(axes)
  101 + {
  102 + this.axes().loadData(axes);
  103 + },
  104 +
  105 + loadParams: function(params)
  106 + {
  107 + this.params().loadData(params);
  108 + },
  109 +
83 110 initAxes : function()
84 111 {
85 112 this.axes().removeAll();
... ...
js/app/models/PlotObjects/PlotParamObject.js
... ... @@ -39,6 +39,27 @@ Ext.define(&#39;amdaPlotObj.PlotParamObject&#39;, {
39 39 }
40 40 ],
41 41  
  42 + constructor: function(){
  43 + var me = this;
  44 + me.callParent(arguments);
  45 + me.updateDrawingType(this.get('param-drawing-type'), true);
  46 + if ((arguments.length > 0) && arguments[0])
  47 + {
  48 + if (arguments[0]['param-drawing-object'])
  49 + me.loadDrawingObject(arguments[0]['param-drawing-object']);
  50 + }
  51 + },
  52 +
  53 + loadDrawingObject: function(drawing)
  54 + {
  55 + var drawingObject = this.get('param-drawing-object');
  56 + if (drawingObject == null)
  57 + return;
  58 + Ext.Object.each(drawing, function(key,value) {
  59 + drawingObject.set(key,value);
  60 + });
  61 + },
  62 +
42 63 updateDrawingType: function(type, forceUpdate)
43 64 {
44 65 forceUpdate = (typeof forceUpdate !== 'undefined') ? forceUpdate : false;
... ...
js/app/models/PlotObjects/PlotRequestObject.js
... ... @@ -29,13 +29,35 @@ Ext.define(&#39;amdaPlotObj.PlotRequestObject&#39;, {
29 29 {name: 'file-format', type: 'string'},
30 30 {name: 'file-output', type: 'string'},
31 31 {name: 'file-prefix', type: 'string'},
32   - {name: 'one-file-per-interval', type: 'boolean'},
33   - {name: 'request-name', type: 'string'}
  32 + {name: 'one-file-per-interval', type: 'boolean'}
34 33 ],
35 34  
36 35 hasMany: {
37 36 model : 'amdaPlotObj.PlotTabObject',
38   - name : 'tabs'
  37 + name : 'tabs',
  38 + associationKey:'tabs'
  39 + },
  40 +
  41 + constructor: function(){
  42 + var me = this;
  43 + me.callParent(arguments);
  44 + if ((arguments.length > 0) && arguments[0] && arguments[0].tabs)
  45 + {
  46 + if (arguments[0].tabs)
  47 + me.loadTabs(arguments[0].tabs);
  48 + }
  49 + else
  50 + {
  51 + //new object, set default fields values
  52 + me.setDefaultValues();
  53 + //New object, force the creation of the first tab
  54 + me.createNewTab();
  55 + }
  56 + },
  57 +
  58 + loadTabs: function(tabs)
  59 + {
  60 + this.tabs().loadData(tabs);
39 61 },
40 62  
41 63 setDefaultValues: function()
... ... @@ -44,7 +66,7 @@ Ext.define(&#39;amdaPlotObj.PlotRequestObject&#39;, {
44 66 this.set('file-output', amdaPlotObj.PlotObjectConfig.defaultValues.file.output);
45 67 this.set('file-prefix', '');
46 68 this.set('one-file-per-interval', amdaPlotObj.PlotObjectConfig.defaultValues.file.oneFilePerInterval);
47   - this.set('request-name', '');
  69 + this.set('name', '');
48 70 },
49 71  
50 72 createNewTab: function() {
... ... @@ -68,11 +90,13 @@ Ext.define(&#39;amdaPlotObj.PlotRequestObject&#39;, {
68 90 requestValues['id'] = this.get('id');
69 91 }
70 92  
  93 + requestValues['leaf'] = true;
  94 +
71 95 requestValues['file-format'] = this.get('file-format');
72 96 requestValues['file-output'] = this.get('file-output');
73 97 requestValues['file-prefix'] = this.get('file-prefix');
74 98 requestValues['one-file-per-interval'] = this.get('one-file-per-interval');
75   - requestValues['request-name'] = this.get('request-name');
  99 + requestValues['name'] = this.get('name');
76 100  
77 101 requestValues['timesrc'] = this.get('timesrc');
78 102 // if there's at least one timeTable name into 'timeTables' collection
... ...
js/app/models/PlotObjects/PlotTabObject.js
... ... @@ -51,7 +51,7 @@ Ext.define(&#39;amdaPlotObj.PlotTabObject&#39;, {
51 51 {name: 'page-font-bold', type: 'boolean'},
52 52 {name: 'page-font-italic', type: 'boolean'},
53 53 {name: 'page-layout-type', type: 'string'},
54   - {name: 'page-layout-object', type: 'auto'}
  54 + {name: 'page-layout-object', type: 'auto', defaultValue: null}
55 55 ],
56 56  
57 57 associations : [
... ... @@ -66,6 +66,39 @@ Ext.define(&#39;amdaPlotObj.PlotTabObject&#39;, {
66 66 }
67 67 ],
68 68  
  69 + constructor: function(){
  70 + var me = this;
  71 + me.callParent(arguments);
  72 + me.setLayout(this.get('page-layout-type'), true);
  73 + if ((arguments.length > 0) && arguments[0])
  74 + {
  75 + if (arguments[0].panels)
  76 + me.loadPanels(arguments[0].panels);
  77 + if (arguments[0]['page-layout-object'])
  78 + me.loadLayoutObject(arguments[0]['page-layout-object']);
  79 + }
  80 + else
  81 + {
  82 + //new object, set default fields values
  83 + me.setDefaultValues();
  84 + }
  85 + },
  86 +
  87 + loadPanels: function(panels)
  88 + {
  89 + this.panels().loadData(panels);
  90 + },
  91 +
  92 + loadLayoutObject: function(layout)
  93 + {
  94 + var layoutObject = this.get('page-layout-object');
  95 + if (layoutObject == null)
  96 + return;
  97 + Ext.Object.each(layout, function(key,value) {
  98 + layoutObject.set(key,value);
  99 + });
  100 + },
  101 +
69 102 createNewPanel: function() {
70 103 var recs = this.panels().add({id : this.lastPanelId});
71 104 ++this.lastPanelId;
... ...
js/app/models/PlotPanel.js deleted
... ... @@ -1,110 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : PlotPanel.js
4   - * @class amdaModel.PlotPanel
5   - * @extends amdaModel.PlotNodeObject
6   - * @brief PlotPanel Business Object Definition
7   - * @author Caroline DARMON
8   - * @version $Id: PlotPanel.js 1499 2013-05-22 13:50:03Z elena $
9   - ******************************************************************************
10   - * FT Id : Date : Name - Description
11   - ******************************************************************************
12   - * : :08/09/2011: CDA - file creation
13   - */
14   -
15   -Ext.define('amdaModel.PlotPanel', {
16   -
17   - extend: 'amdaModel.PlotObject',
18   -
19   - statics: {
20   - rowClass : 'plotPanelBgColor',
21   - ADD_PARAM_MODE : ['simple','function'],
22   - PLOT_TYPES : [
23   - {display:"Time", value:"TIME"},
24   - {display:"Scatter", value:"SCATTER"}
25   - ]
26   - },
27   -
28   - fields : [
29   - { name: 'children'},
30   - { name: 'width', type: 'float', defaultValue: 1 },
31   - { name: 'height', type: 'float', defaultValue: 0.4 },
32   - { name: 'xTitle', type: 'string' }, //TODO: TBD
33   - { name: 'xRangeMin', type: 'float', defaultValue: 0 },
34   - { name: 'xRangeMax', type: 'float', defaultValue: 0 },
35   - { name: 'y1Title', type: 'string', defaultValue: '' },
36   - { name: 'y1RangeMin', type: 'float', defaultValue: 0 },
37   - { name: 'y1RangeMax', type: 'float', defaultValue: 0 },
38   - { name: 'y2Title', type: 'string', defaultValue: '' },
39   - { name: 'y2RangeMin', type: 'float', defaultValue: 0 },
40   - { name: 'y2RangeMax', type: 'float', defaultValue: 0 },
41   - { name: 'plotType', type: 'string', defaultValue: 'TIME'},
42   - { name: 'panelArgs', type: 'string', defaultValue: 'select...'},
43   - { name : 'checked', defaultValue: null }
44   - ],
45   -
46   - constructor: function(configPanel){
47   - this.callParent(arguments);
48   -//TODO seems to be not needed!!!
49   - // if (configPanel && configPanel.scatterParam) {
50   - // this.set('scatterParam',Ext.create('amdaModel.AmdaObject',configPanel.scatterParam));
51   - // }
52   - // defaultValue plotType
53   - //if (!configPanel || !configPanel.plotType) {
54   - // this.set('plotType',amdaModel.PlotPanel.PLOT_TYPES[0].value);
55   - // }
56   - this.set('leaf',false);
57   - this.set('rowCls', this.getRowClass());
58   - this.set('id', Ext.id());
59   - this.set('expandable', true);
60   - // set this instance as unmodified
61   - this.commit();
62   - },
63   -
64   - belongsTo: 'amdaModel.Plot',
65   - hasMany: {model: 'amdaModel.PlotParam', name: 'children'},
66   -
67   - getJsonValues : function(){
68   -
69   - var myValues = new Object();
70   -
71   - myValues.name = this.get('name');
72   -
73   - myValues.leaf = false;
74   - myValues.text = this.get('text');
75   - myValues.width = this.get('width');
76   - myValues.height = this.get('height');
77   - myValues.xTitle = this.get('xTitle');
78   - myValues.xRangeMin = this.get('xRangeMin');
79   - myValues.xRangeMax = this.get('xRangeMax');
80   - myValues.y1Title = this.get('y1Title');
81   - myValues.y1RangeMin = this.get('y1RangeMin');
82   - myValues.y1RangeMax = this.get('y1RangeMax');
83   - myValues.y2Title = this.get('y2Title');
84   - myValues.y2RangeMin = this.get('y2RangeMin');
85   - myValues.y2RangeMax = this.get('y2RangeMax');
86   - myValues.plotType = this.get('plotType');
87   - myValues.scatterParam = this.get('scatterParam');
88   -
89   - var childrenArray = []; //PlotParam.JsonValues!!!
90   -
91   - if (this.childNodes){
92   - Ext.Array.each(this.childNodes, function(paramItem, paramIndex, allParamItem) {
93   - childrenArray.push(paramItem.getJsonValues());
94   - });
95   - } else {
96   - // else if a json config has been past to this constructor
97   - childrenArray = this.get('children');
98   - }
99   -
100   - myValues.children = childrenArray;
101   -
102   - return myValues;
103   -
104   - },
105   -
106   - getRowClass: function(){
107   - return amdaModel.PlotPanel.rowClass;
108   - }
109   -
110   -});
js/app/models/PlotParam.js deleted
... ... @@ -1,68 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : PlotParam.js
4   - * @class amdaModel.PlotParam
5   - * @extends amdaModel.PlotObject
6   - * @brief PlotParam Business Object Definition
7   - * @author Caroline DARMON
8   - * @version $Id: PlotParam.js 2490 2014-08-27 16:08:06Z elena $
9   - ******************************************************************************
10   - * FT Id : Date : Name - Description
11   - ******************************************************************************
12   - * : :08/09/2011: CDA - file creation
13   - */
14   -
15   -Ext.define('amdaModel.PlotParam', {
16   - extend: 'amdaModel.PlotObject',
17   -
18   - statics: {
19   - rowClass : 'plotParamBgColor',
20   - ADD_PARAM_MODE : ['simple','function']
21   - },
22   -
23   - fields : [ { name: 'paramArgs', type: 'string', defaultValue: 'select...' },
24   - { name: 'isScatter', type: 'boolean', defaultValue: true },
25   - { name: 'downloadParamArgs', defaultValue: null },
26   - { name: 'needsArgs', type: 'boolean', defaultValue: false },
27   - { name: 'plotOnly', type: 'boolean', defaultValue: false },
28   - { name: 'isSpectra', type: 'boolean', defaultValue: false },
29   - { name: 'yaxe', type: 'boolean', defaultValue: false },
30   - { name: 'checked', defaultValue: null }
31   - ],
32   -
33   - belongsTo: 'amdaModel.PlotPanel',
34   -
35   - constructor: function(configParam){
36   - this.callParent(arguments);
37   -
38   - this.set('id',Ext.id());
39   - this.set('leaf',true);
40   - this.set('rowCls', this.getRowClass());
41   - // set this instance as unmodified
42   - this.commit();
43   -
44   - },
45   -
46   - getJsonValues: function(){
47   - var myValues = new Object();
48   -
49   - myValues.name = this.get('name');
50   - myValues.leaf = true;
51   - myValues.text = this.get('text');
52   - myValues.paramArgs = this.get('paramArgs');
53   - myValues.isScatter = this.get('isScatter');
54   - myValues.needsArgs = this.get('needsArgs');
55   - myValues.plotOnly = this.get('plotOnly');
56   -
57   - if (this.get('downloadParamArgs')) {
58   - myValues.downloadParamArgs = this.get('downloadParamArgs');
59   - }
60   - myValues.yaxe = this.get('yaxe');
61   - return myValues;
62   - },
63   -
64   - getRowClass: function(){
65   - return amdaModel.PlotParam.rowClass;
66   - }
67   -
68   -});
js/app/stores/PlotReader.js deleted
... ... @@ -1,32 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : PlotReader.js
4   - * @class amdaReader.PlotReader
5   - * @extends amdaReader.AmdaTreeReader
6   - * @brief
7   - * @author Caroline DARMON
8   - * @version $Id: PlotReader.js 953 2012-06-23 09:50:13Z elena $
9   - ******************************************************************************
10   - * FT Id : Date : Name - Description
11   - ******************************************************************************
12   - * : :15/09/2011: CDA - file creation
13   - */
14   -
15   -Ext.define('amdaReader.PlotReader', {
16   - extend: 'amdaReader.AmdaTreeReader',
17   -
18   - alias: 'reader.plot',
19   -
20   - /**
21   - * @override amdaReader.AmdaTreeReader.getType
22   - */
23   - getType: function(node){
24   -
25   - if (!node.leaf) {
26   - return amdaModel.PlotPanel;
27   - } else {
28   - return amdaModel.PlotParam;
29   - }
30   -
31   - }
32   -});
33 0 \ No newline at end of file
js/app/views/InteractivePlotUI.js deleted
... ... @@ -1,410 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : InteractivePlotUI
4   - * @class amdaUI.ResultUI
5   - * @extends Ext.
6   - * @brief UI definition (View)
7   - * @author
8   - * @version $Id: InteractivePlotUI.js 2719 2015-01-26 10:23:22Z elena $
9   - ********************************************************************************
10   - * FT Id : Date : Name - Description
11   - *******************************************************************************
12   - *
13   - */
14   -
15   -Ext.define('amdaUI.InteractivePlotUI', {
16   - extend: 'Ext.form.Panel',
17   -
18   - alias: 'widget.panelPlotMgr',
19   -
20   - requires: [
21   - 'amdaUI.TimeSelectorUI'
22   - ],
23   -
24   - object : null,
25   -
26   - checkedTabs : null,
27   -
28   - constructor: function(config) {
29   - this.init(config);
30   - this.callParent(arguments);
31   - this.timeSelector.timeSrc.on('change', this.onChange, this);
32   - },
33   -
34   - // overwrite timeselector onchange function
35   - onChange : function(radio, newValue, oldValue, options){
36   - var ttIndex = newValue['timesrc_'+this.timeSelector.id] === amdaModel.AmdaTimeObject.inputTimeSrc[0] ? 0 : 1 ;
37   -
38   - if (this.rendered){
39   - radio.nextSibling().layout.setActiveItem(ttIndex);
40   - } else {
41   - this.timeSelector.cardContainer.activeItem = ttIndex;
42   - }
43   - },
44   -
45   - addPlotItem : function(num, itemId){
46   - var checkBox = this.checkBoxGroup.getComponent(itemId);
47   - if (checkBox) checkBox.enable();
48   - },
49   -
50   - removePlotItem : function(itemId){
51   - var checkBox = this.checkBoxGroup.getComponent(itemId);
52   - if (checkBox) {
53   - checkBox.reset();
54   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id);
55   - if (module && !module.multiSelector)
56   - checkBox.disable();
57   - }
58   - },
59   -
60   -/**
61   - * Disable/Enable docked buttons in the PlotTab Windows checked
62   - */
63   - disableDocked : function(disable, plotTab) {
64   - var docked = plotTab.formPanel.getDockedItems()[0];
65   -// Plot, GetData, Reset
66   - for (var i = 0; i < 3; i++) {
67   - if (disable) docked.items.getAt(i).disable();
68   - else docked.items.getAt(i).enable();
69   - }
70   - },
71   -
72   -/**
73   - * Disable/Enable TimeSelectors and buttons in the PlotTab Forms checked
74   - */
75   - disableTimeSelectors : function(disable, plotId) {
76   -
77   - if (plotId){
78   - var plotTab = Ext.getCmp(plotId);
79   - var timeSource = plotTab.timeSelector.timeSrc.getChecked()[0].getGroupValue();
80   -
81   - if (disable) {
82   - plotTab.timeSelector.disable();
83   - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
84   - plotTab.timeSelector.TTGrid.disable();
85   - }
86   - else {
87   - plotTab.timeSelector.enable();
88   - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
89   - plotTab.timeSelector.TTGrid.enable();
90   - }
91   - this.disableDocked(disable, plotTab);
92   - }
93   - else {
94   - var plotId;
95   - var checked = this.checkBoxGroup.getChecked();
96   - if (checked.length > 0) {
97   - Ext.Array.each(checked,function(item){
98   - var plotId = item.boxLabel.toLowerCase();
99   - var plotTab = Ext.getCmp(plotId);
100   - var timeSource = plotTab.timeSelector.timeSrc.getChecked()[0].getGroupValue();
101   -
102   - if (disable) {
103   - plotTab.timeSelector.disable();
104   - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
105   - plotTab.timeSelector.TTGrid.disable();
106   - }
107   - else {
108   - plotTab.timeSelector.enable();
109   - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
110   - plotTab.timeSelector.TTGrid.enable();
111   - }
112   - this.disableDocked(disable, plotTab);
113   - }, this);
114   - }
115   - }
116   - },
117   -
118   - /**
119   - * Start interactive session for checked PlotTabs
120   - */
121   - plot : function() {
122   - var checked = this.checkBoxGroup.getChecked();
123   - this.checkedTabs = [];
124   -
125   - if (checked.length > 0) {
126   -
127   - Ext.Array.each(checked,function(item){
128   - this.checkedTabs.push(item.boxLabel.substr(4,1));
129   - }, this);
130   -
131   - Ext.Array.each(checked,function(item){
132   -
133   - var plotId = item.boxLabel.toLowerCase();
134   - var plotTab = Ext.getCmp(plotId);
135   -
136   - if (plotTab.updateObject(true)){
137   - plotTab.doPlot();
138   - }
139   - }, this);
140   -
141   - this.multiSelector.setValue(false);
142   - }
143   - else
144   - myDesktopApp.warningMsg('Please select SOMETHING in \'Multi Plot Manager\' window');
145   -
146   - this.checkedTabs = null;
147   - },
148   -
149   -/**
150   - * Execute commands during interactive session for checked PlotTabs
151   - */
152   - execute : function(procedure, argName)
153   - {
154   - var checked = this.checkBoxGroup.getChecked();
155   - this.checkedTabs = [];
156   -
157   - if (checked.length > 0)
158   - {
159   - Ext.Array.each(checked,function(item){
160   - this.checkedTabs.push(item.boxLabel.substr(4,1));
161   - }, this);
162   -
163   - var isMulti = checked.length > 1;
164   - Ext.Array.each(checked,function(item, index, all)
165   - {
166   - var id = item.name;
167   - var win = myDesktopApp.getDesktop().getWindow(id);
168   - if (win)
169   - {
170   - var panelResult = win.items.items[0];
171   - panelResult.setObjectIntoNode();
172   - var argValue = panelResult.object.get(argName);
173   - if (procedure == 'goto') {
174   - var argValue = argName;
175   - }
176   - else {
177   - var argValue = panelResult.object.get(argName);
178   - }
179   - panelResult.object.fireEvent('execute', isMulti, procedure, argValue);
180   - }
181   - },this);
182   - }
183   - else
184   - myDesktopApp.warningMsg('Please select SOMETHING');
185   -
186   - this.checkedTabs = null;
187   - },
188   -
189   - /**
190   - * Set Start-Stop from parameter info (Local & MyData)
191   - */
192   - setTimeFromData : function(obj) {
193   -
194   - var dateStart = new Date(obj.start.replace(/[T|Z]/g,' ').replace(/\-/g,'\/'));
195   - var dateStop = new Date(obj.stop.replace(/[T|Z]/g,' ').replace(/\-/g,'\/'));
196   -
197   - this.getForm().setValues({ startDate : dateStart, stopDate : dateStop });
198   - },
199   -
200   -/**
201   - *
202   - */
203   - init : function(config){
204   - var items = [];
205   -
206   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id);
207   - if (!module)
208   - return;
209   -
210   - for (var i = 0; i < module.maxWinNumber; i++) {
211   - var label = i + 1;
212   - items[i] = new Ext.form.field.Checkbox({ width: 52, boxLabel: 'Plot' + label, disabled : true,
213   - id : 'plot' + label +'-win_box', name : 'plot' + label +'-win',
214   - itemId : 'plot' + label +'-win',
215   - listeners: {
216   - scope : this,
217   - change : function( cb, nv ){
218   - var plotId = cb.boxLabel.toLowerCase();
219   -
220   - var resWindow = myDesktopApp.desktop.getWindow(plotId + '-win');
221   - if (resWindow) {
222   - var resPlotUI =resWindow.items.getAt(0);
223   - }
224   - if (nv) {
225   - this.disableTimeSelectors(true, plotId);
226   - if (resPlotUI) resPlotUI.disableButtons(true);
227   - }
228   - else {
229   - this.disableTimeSelectors(false, plotId);
230   - if (resPlotUI) resPlotUI.disableButtons(false);
231   - }
232   - }
233   - }
234   - });
235   - }
236   -
237   - this.checkBoxGroup =
238   - new Ext.form.CheckboxGroup( {items : items });
239   -
240   - this.timeSelector = new amdaUI.TimeSelectorUI({ id: 'MultiPlotTimeSelector',
241   - style: { borderColor: '#98c0f4', borderWidth: '1px', marginBottom: '10px' },
242   - hidden : true
243   - });
244   -
245   - this.object = new amdaModel.AmdaTimeObject({timesrc : amdaModel.AmdaTimeObject.inputTimeSrc[1]});
246   -
247   - this.multiSelector = new Ext.form.field.Checkbox({
248   - padding: '0, 0, 0, 5',
249   - boxLabel: 'New Interactive Session for Selected Plot Requests',
250   - listeners: {
251   - scope : this,
252   - change: function (cb, nv, ov) {
253   -
254   -
255   - var win = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id);
256   -
257   - // multi Selector
258   - if (nv) {
259   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id);
260   - module.multiSelector = true;
261   -
262   - Ext.Array.each(this.checkBoxGroup.items.items, function(item){
263   - item.enable();
264   - });
265   -
266   - this.disableTimeSelectors(true);
267   - this.ttToolBar.hide();
268   - this.intervalToolBar.hide();
269   -
270   - this.plotToolBar.show();
271   - this.timeSelector.show();
272   - this.getForm().loadRecord(this.object);
273   -
274   - win.setHeight(270);
275   - }
276   - // individual Selectors
277   - else {
278   - // update multi time selector from form
279   - this.getForm().updateRecord(this.object);
280   -
281   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id);
282   - module.multiSelector = false;
283   -
284   - this.timeSelector.hide();
285   - this.plotToolBar.hide();
286   -
287   - if (this.timeSelector.timeSrc.getChecked()[0].getGroupValue() == amdaModel.AmdaTimeObject.inputTimeSrc[1]) {
288   - this.intervalToolBar.show();
289   - }
290   - else {
291   - this.ttToolBar.show();
292   - }
293   - var plotWinId;
294   - Ext.Array.each(this.checkBoxGroup.items.items, function(item){
295   - // disable only if plot window is closed
296   - plotWinId = item.name.toLowerCase();
297   - var resWindow = myDesktopApp.desktop.getWindow(plotWinId);
298   - if (!resWindow){
299   - item.disable();
300   - }
301   - });
302   - win.setHeight(120);
303   - }
304   - }
305   - }
306   - });
307   -
308   - this.plotToolBar = new Ext.toolbar.Toolbar({
309   - dock: 'bottom',
310   - hidden: true,
311   - items: [ '->', '-',
312   - {
313   - text: 'Plot',
314   - scope : this,
315   - handler: function () {
316   - this.plot();
317   - }
318   - }]
319   - });
320   -
321   - this.intervalToolBar = new Ext.toolbar.Toolbar({
322   - dock: 'bottom',
323   - items: [
324   - {
325   - text: 'Backward',
326   - scope: this,
327   - handler: function(){
328   - this.execute('back','startDate');
329   - }
330   - }, '-' ,
331   - {
332   - text: '1/2 Backward',
333   - scope: this,
334   - handler: function(){
335   - this.execute('halfback','startDate');
336   - }
337   - }, '-', {
338   - text: '1/2 Forward',
339   - scope: this,
340   - handler: function(){
341   - this.execute('halfnext','stopDate');
342   - }
343   - }, '-',
344   - {
345   - text: 'Forward',
346   - scope: this,
347   - handler: function(){
348   - this.execute('next','stopDate');
349   - }
350   - }]
351   - });
352   -
353   - this.ttToolBar = new Ext.toolbar.Toolbar({
354   - hidden: true,
355   - dock: 'bottom',
356   - items: [
357   - {
358   - text: 'Previous',
359   - scope: this,
360   - handler: function(){
361   - this.execute('backInt', 'intervalN');
362   - }
363   - }, '-' ,
364   - {
365   - text: 'Next',
366   - scope: this,
367   - handler: function(){
368   - this.execute('nextInt', 'intervalN');
369   - }
370   - },'-',
371   - {
372   - text: 'Go to Interval #',
373   - scope: this,
374   - handler: function(bt){
375   - var number = bt.nextSibling().getValue();
376   - // var intTot = this.getDockedItems()[0].items.getAt(11).getValue();
377   - // if (number <= intTot){
378   - this.execute('goto', number);
379   - // }
380   - // else {
381   - // myDesktopApp.warningMsg('Only '+ intTot +' intervals in the current Time Table');
382   - // }
383   - }
384   - }, {
385   - xtype: 'numberfield',
386   - hideTrigger: true,
387   - width: 40,
388   - minValue: 1
389   - }
390   - ]
391   - });
392   -
393   - var myConf = {
394   - // bodyStyle: { background: '#dfe8f6' },
395   - bodyStyle: { background: '#ffffdd' },
396   - items: [
397   - this.checkBoxGroup,
398   - this.multiSelector,
399   - this.timeSelector
400   - ],
401   - dockedItems: [
402   - this.intervalToolBar,
403   - this.ttToolBar,
404   - this.plotToolBar
405   - ]
406   - };
407   -
408   - Ext.apply (this , Ext.apply (arguments, myConf));
409   - }
410   -});
js/app/views/NewPlotTabResultUI.js deleted
... ... @@ -1,119 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : NewPlotTabResultUI.js
4   - * @class amdaUI.NewPlotTabResultUI
5   - * @extends Ext. panel.Panel
6   - * @brief Plot Tab Result UI definition (View)
7   - * @author
8   - * @version $Id: NewPlotTabResultUI.js benjamin $
9   - ********************************************************************************
10   - * FT Id : Date : Name - Description
11   - *******************************************************************************
12   - *
13   - */
14   -
15   -Ext.define('amdaUI.NewPlotTabResultUI', {
16   - extend: 'Ext.panel.Panel',
17   -
18   - alias: 'widget.newPlotTabResult',
19   -
20   - requires: [
21   - 'amdaUI.InteractiveIntervalPlugin'
22   - ],
23   -
24   - isPortrait : false,
25   - pageWidth : 0,
26   - pageHeight : 0,
27   -
28   - constructor: function(config) {
29   - this.addEvents({'pagesize':true});
30   -
31   - this.init(config);
32   - this.callParent(arguments);
33   - },
34   -
35   - getImageSize : function() {
36   - var size = {
37   - width : this.pageWidth * this.sliderPage.getValue()/100.,
38   - height : this.pageHeight * this.sliderPage.getValue()/100.
39   - }
40   - return size;
41   - },
42   -
43   - getImageUrl: function(resultFolder, plotFile) {
44   - return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile;
45   - },
46   -
47   - createPlotImage: function(resultFolder, plotFile, context) {
48   - var size = this.getImageSize();
49   - this.panelImage = Ext.create('Ext.Img', {
50   - src : this.getImageUrl(resultFolder, plotFile),
51   - width : size.width,
52   - height : size.height,
53   - refreshMe : function(){
54   - var el;
55   - if(el = this.el){
56   - el.dom.src = this.src + '?dc=' + new Date().getTime();
57   - }
58   - },
59   - listeners : {
60   - render : function(){
61   - this.refreshMe();
62   - }
63   - }
64   - });
65   -
66   - return this.panelImage;
67   - },
68   -
69   - updatePlotImage: function(configResult) {
70   - this.isPortrait = configResult.context.page.portrait;
71   - this.pageWidth = configResult.context.page.width;
72   - this.pageHeight = configResult.context.page.height;
73   -
74   - this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile));
75   -
76   - var size = this.getImageSize();
77   - this.panelImage.setSize(size.width, size.height);
78   -
79   - this.panelImage.refreshMe();
80   - },
81   -
82   - init: function(configResult){
83   - this.isPortrait = configResult.context.page.portrait;
84   - this.pageWidth = configResult.context.page.width;
85   - this.pageHeight = configResult.context.page.height;
86   -
87   - this.sliderPage = new Ext.slider.Single({
88   - width: 130,
89   - value: 75,
90   - increment: 5,
91   - minValue: 50,
92   - maxValue: 100,
93   - fieldLabel : 'Resize',
94   - labelWidth : 40,
95   - listeners: {
96   - scope : this,
97   - changecomplete: function(s, v)
98   - {
99   - //ToDo - this.resetMire();
100   - var size = this.getImageSize();
101   - this.panelImage.width = size.width;
102   - this.panelImage.height = size.height;
103   - this.panelImage.doComponentLayout();
104   - this.fireEvent('pagesize',this,v);
105   - }
106   - }
107   - });
108   -
109   - var newPlotResultTabPanelConfig = {
110   - preventHeader : true,
111   - autoScroll: true,
112   - items: [
113   - this.createPlotImage(configResult.folder, configResult.plotFile, configResult.context)
114   - ]
115   - };
116   -
117   - Ext.apply(this , newPlotResultTabPanelConfig);
118   - }
119   -});
120 0 \ No newline at end of file
js/app/views/NewPlotUI.js deleted
... ... @@ -1,196 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : NewPlotUI.js
4   - * @class amdaUI.NewPlotUI
5   - * @extends Ext.container.Container
6   - * @brief New Plot Module UI definition (View)
7   - * @author Benjamin Renard
8   - * @version $Id: NewPlotUI.js benjamin $
9   - */
10   -
11   -
12   -Ext.define('amdaUI.NewPlotUI', {
13   - extend: 'Ext.container.Container',
14   - alias: 'widget.newPanelPlot',
15   -
16   - requires: [
17   - 'amdaUI.TimeSelectorUI',
18   - 'amdaPlotComp.PlotTabPanel',
19   - 'amdaPlotComp.PlotOutputForm',
20   - 'amdaPlotComp.PlotElementPanel'
21   - ],
22   -
23   - formPanel: null,
24   -
25   - plotOutput: null,
26   -
27   - plotTabs : null,
28   -
29   - plotElement : null,
30   -
31   - constructor: function(config) {
32   - this.init(config);
33   - this.callParent(arguments);
34   - if (this.object)
35   - {
36   - //Force first tab creation
37   - this.object.setDefaultValues();
38   - this.object.createNewTab();
39   - this.setObject(this.object);
40   - }
41   - },
42   -
43   - setObject : function(object) {
44   - this.object = object;
45   - this.plotOutput.setObject(this.object);
46   - this.plotTabs.setRequestObject(this.object);
47   - this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate'));
48   - },
49   -
50   - /**
51   - * plot method called by 'Do Plot' button to launch the plot process
52   - */
53   - doPlot : function(){
54   - var timeSource = this.timeSelector.getActiveTimeSource();
55   - var basicForm = this.formPanel.getForm();
56   - basicForm.updateRecord(this.object);
57   - this.object.set('timesrc', timeSource);
58   - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
59   - this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
60   -
61   - // fire execution
62   - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
63   - if (plotModule)
64   - plotModule.linkedNode.execute();
65   - },
66   -
67   - /**
68   - * Check if changes were made before closing window
69   - * @return false
70   - */
71   - fclose : function() {
72   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
73   - module.closeInteractiveSession();
74   - });
75   -
76   - return false;
77   - },
78   -
79   - addTT : function(newTTName,newTTid)
80   - {
81   - this.timeSelector.addTT(newTTName,newTTid);
82   - },
83   -
84   - addTTs : function(TTarray) {
85   - // set TTTab
86   - this.timeSelector.setTTTab(TTarray);
87   - },
88   -
89   - init : function(config) {
90   - this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelector' + config.id, flex: 1} );
91   -
92   - this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 2});
93   -
94   - this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 3});
95   -
96   - this.plotTabs = new amdaPlotComp.PlotTabPanel({flex: 2, plotElementPanel : this.plotElement});
97   -
98   - this.optionsPanel = new Ext.form.Panel({
99   - layout: {
100   - type: 'vbox',
101   - pack: 'start',
102   - align: 'stretch'
103   - },
104   - bodyStyle: { background : '#dfe8f6' },
105   - defaults: {
106   - border: false
107   - },
108   - items: [
109   - this.plotElement,
110   - this.plotOutput
111   - ]
112   - });
113   -
114   - this.formPanel = new Ext.form.Panel({
115   - region: 'center',
116   - layout: {
117   - type: 'hbox',
118   - pack: 'start',
119   - align: 'stretch'
120   - },
121   - bodyStyle: { background : '#dfe8f6' },
122   - defaults: {
123   - border: false
124   - },
125   - items: [
126   - {
127   - xtype : 'panel',
128   - layout: {
129   - type: 'vbox',
130   - pack: 'start',
131   - align: 'stretch'
132   - },
133   - bodyStyle: { background : '#dfe8f6' },
134   - defaults: {
135   - border: false
136   - },
137   - flex: 1,
138   - items: [
139   - this.plotTabs,
140   - this.timeSelector
141   - ]
142   - },
143   - {
144   - xtype : 'panel',
145   - layout: 'fit',
146   - bodyStyle: { background : '#dfe8f6' },
147   - defaults: {
148   - border: false
149   - },
150   - flex: 1,
151   - items: [
152   - this.optionsPanel
153   - ]
154   - }
155   - ],
156   - fbar: [
157   - {
158   - xtype: 'button',
159   - text: 'Plot',
160   - scope: this,
161   - handler: function(button) {
162   - this.doPlot();
163   - }
164   - },
165   - ' ',
166   - { xtype: 'button', text: 'Get Data' },
167   - ' ',
168   - { xtype: 'button', text: 'Reset' },
169   - '->',
170   - { xtype: 'button', text: 'Save Request' }
171   - ]
172   - });
173   -
174   - var myConf = {
175   - layout: 'border',
176   - items: [
177   - this.formPanel,
178   - {
179   - xtype: 'panel',
180   - region: 'south',
181   - title: 'Information',
182   - collapsible: true,
183   - height: 100,
184   - autoHide: false,
185   - bodyStyle: 'padding:5px',
186   - iconCls: 'icon-information',
187   - loader: {
188   - autoLoad: true,
189   - url: helpDir+'plotHOWTO'
190   - }
191   - }
192   - ]
193   - };
194   - Ext.apply (this , Ext.apply (arguments, myConf));
195   - }
196   -});
197 0 \ No newline at end of file
js/app/views/PlotComponents/PlotOutputForm.js
... ... @@ -59,7 +59,7 @@ Ext.define(&#39;amdaPlotComp.PlotOutputForm&#39;, {
59 59 }),
60 60 this.addStandardText('file-prefix', 'File prefix'),
61 61 this.addStandardCheck('one-file-per-interval', 'One file per interval'),
62   - this.addStandardText('request-name', 'Request name')
  62 + this.addStandardText('name', 'Request name')
63 63 ];
64 64 }
65 65 });
66 66 \ No newline at end of file
... ...
js/app/views/PlotTabResultUI.js
1 1 /**
2 2 * Project  : AMDA-NG
3 3 * Name : PlotTabResultUI.js
4   - * @class amdaUI.ResultUI
5   - * @extends Ext.
  4 + * @class amdaUI.PlotTabResultUI
  5 + * @extends Ext. panel.Panel
6 6 * @brief Plot Tab Result UI definition (View)
7 7 * @author
8   - * @version $Id: PlotTabResultUI.js 2813 2015-03-12 13:46:38Z elena $
  8 + * @version $Id: PlotTabResultUI.js benjamin $
9 9 ********************************************************************************
10 10 * FT Id : Date : Name - Description
11 11 *******************************************************************************
... ... @@ -21,683 +21,99 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
21 21 'amdaUI.InteractiveIntervalPlugin'
22 22 ],
23 23  
  24 + isPortrait : false,
  25 + pageWidth : 0,
  26 + pageHeight : 0,
  27 +
24 28 constructor: function(config) {
25   - this.isMire1Visible = false;
26   - this.isMire1Draggable = false;
27   - this.isMire2Visible = false;
28   - this.isMire2Draggable = false;
29   -
30 29 this.addEvents({'pagesize':true});
31 30  
32 31 this.init(config);
33 32 this.callParent(arguments);
34 33 },
35 34  
36   -
37   - init: function(configResult){
38   -
39   - this.object = configResult.object;
40   - //timing from Start Stop
41   - this.currentStartTime = this.object.get('startDate');
42   - var stopTime = this.object.get('stopDate');
43   - this.plotDurationInSec = Ext.Date.getElapsed(this.currentStartTime, stopTime) / 1000;
44   -
45   - this.Smin = this.object.get('xMin'); // 0.0 !P.Region : !X.window = 0.18 0.114286 0.915714
46   - this.Smax = this.object.get('xMax'); // 0.9 !P.Region : !X.window = 0.89
47   -
48   - this.sliderPage = new Ext.slider.Single({
49   - width: 130,
50   - value: 75,
51   - increment: 5,
52   - minValue: 50,
53   - maxValue: 100,
54   - fieldLabel : 'Resize',
55   - labelWidth : 40,
56   - listeners: {
57   - scope : this,
58   - changecomplete: function(s, v)
59   - {
60   - this.resetMire();
61   - var size = this.getImageSize();
62   - this.panelImage.width = size.width;
63   - this.panelImage.height = size.height;
64   - this.panelImage.doComponentLayout();
65   - this.setImageSettings(this.panelImage);
66   - this.fireEvent('pagesize',this,v);
67   - }
68   - }
69   - });
70   -
71   - var panelResult = this.createPlotResultPanel(this.object.get('folderId'), this.object.get('resultId'));
72   -
73   - var tsrc = this.object.get('timesrc');
74   - var isTimeTable = tsrc == amdaModel.AmdaTimeObject.inputTimeSrc[0];
75   - var navToolbar = this.createToolBar(isTimeTable);
76   -
77   - this.mouseXField = new Ext.form.field.Date({
78   - hideTrigger: true,
79   - labelAlign: 'left',
80   - fieldLabel: 'X',
81   - labelWidth: 10,
82   - disabled: true,
83   - width: 150,
84   - format : 'Y-m-d\\TH:i:s'
85   - });
86   -
87   - this.mouseYField = new Ext.form.field.Number({
88   - hideTrigger: true,
89   - labelAlign: 'left',
90   - fieldLabel: 'Y',
91   - labelWidth: 10,
92   - disabled: true,
93   - minValue: 0,
94   - width: 50
95   - });
96   -
97   -
98   - var mouseToolbar = {
99   - xtype: 'toolbar',
100   - height: 25,
101   - dock: 'bottom',
102   - items:[ {
103   - xtype: 'form',
104   - layout: {
105   - type: 'hbox',
106   - align : 'stretch',
107   - pack : 'start'
108   - },
109   - height: 21,
110   - width: 200,
111   - border: false,
112   - bodyStyle: {background : '#dfe8f6'},
113   - items:[
114   - this.mouseXField,
115   - {
116   - xtype: 'container',
117   - width: 5
118   - },
119   - this.mouseYField,
120   - ]
121   - },
122   - this.sliderPage,
123   - '->',
124   - {
125   - xtype: 'button',
126   - text: 'Zoom in Time Interval',
127   - width: 130,
128   - scope: this,
129   - handler: function(){
130   -
131   - this.createMire(panelResult);
132   - panelResult.fireEvent('open');
133   - }
134   - }, '-' ,
135   - {
136   - xtype: 'button',
137   - text: 'Extend/Shift',
138   - width: 80,
139   - scope : this,
140   - handler: function(){
141   - // define customized prompt message
142   - //TODO without getCmp
143   - var msgId = 'extend_shift'+ this.id;
144   - var msg = Ext.getCmp(msgId);
145   - if (!msg) {
146   - var msg = new Ext.window.Window({
147   - constrain : true,
148   - renderTo : this.id,
149   - id : msgId,
150   - title: 'Extend,Shift',
151   - buttonAlign : 'left',
152   - ghost: false,
153   - border: false,
154   - getConstrainVector: function(constrainTo){
155   - var me = this;
156   - if (me.constrain || me.constrainHeader) {
157   - constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
158   - return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
159   - }
160   - },
161   - buttons:
162   - [ {
163   - text: 'Extend/Shrink',
164   - scope : this,
165   - handler: function(bt,event){
166   - var durationForm = bt.findParentByType('window').items.items[0].items.items[0].getValue();
167   - var durationUnit = bt.findParentByType('window').items.items[0].items.items[2].getValue();
168   - var duration = this.TranslateSec(durationForm, durationUnit);
169   - if (duration) {
170   - var start = this.object.get('startDate');
171   - this.setObjectIntoNode();
172   - this.object.fireEvent('execute', false, 'extend', duration, start);
173   - }
174   - else myDesktopApp.errorMsg('no duration');
175   - }
176   - },
177   - '->',{
178   - text: 'Shift',
179   - scope : this,
180   - handler: function(bt,event){
181   - var durationForm = bt.findParentByType('window').items.items[0].items.items[0].getValue();
182   - var durationUnit = bt.findParentByType('window').items.items[0].items.items[2].getValue();
183   - var duration = this.TranslateSec(durationForm, durationUnit);
184   - if (duration) {
185   - var start = this.object.get('startDate');
186   - this.setObjectIntoNode();
187   - this.object.fireEvent('execute', false, 'shift', duration, start);
188   - }
189   - else myDesktopApp.errorMsg('no duration');
190   - }
191   - }
192   - ],
193   - layout: 'fit',
194   - width: 230,
195   - items: {
196   - xtype: 'fieldcontainer',
197   - layout: 'hbox',
198   - fieldLabel: 'Duration to apply to the interval',
199   - labelAlign: 'top',
200   - bodyStyle: {background : '#dfe8f6'},
201   - border: false,
202   - items: [{
203   - xtype: 'numberfield',
204   - hideTrigger: true,
205   - name: 'duration',
206   - // minValue: 0,
207   - width: 150
208   - },
209   - { xtype: 'splitter', width: 5 },
210   - {
211   - xtype:'combo', name: 'durationUnit', store:['sec', 'min', 'hour', 'day'],
212   - editable: false, width: 60, value: 'sec', triggerAction: 'all'
213   - }]
214   - }
215   - });
216   - msg.show();
217   - }
218   - else {
219   - msg.toFront();
220   - }
221   - }
222   - }]
223   - };
224   -
225   - var newPlotResultTabPanelConfig = {
226   - id: configResult.object.get('resultId'),
227   - object: configResult.object,
228   - preventHeader : true,
229   - autoScroll: true,
230   - items: panelResult,
231   - dockedItems: [navToolbar,mouseToolbar]
232   - };
233   -
234   - Ext.apply(this , newPlotResultTabPanelConfig);
235   -
  35 + getImageSize : function() {
  36 + var size = {
  37 + width : this.pageWidth * this.sliderPage.getValue()/100.,
  38 + height : this.pageHeight * this.sliderPage.getValue()/100.
  39 + }
  40 + return size;
236 41 },
237 42  
238   - disableButtons: function(disable) {
239   - var toolBar = this.getDockedItems()[0];
240   - var timeSrc = this.object.get('timesrc');
241   - var isTimeTable = timeSrc == amdaModel.AmdaTimeObject.inputTimeSrc[0];
242   - var numButton = isTimeTable ? 5 : 7;
243   -
244   - for (var i = 0; i < numButton; i++) {
245   - if (disable) toolBar.items.getAt(i).disable();
246   - else toolBar.items.getAt(i).enable();
247   - }
248   - // disable/enable Extend/Shift
249   - var toolBarBottom = this.getDockedItems()[1];
250   - if (disable) toolBarBottom.items.getAt(5).disable();
251   - else toolBarBottom.items.getAt(5).enable();
252   -
  43 + getImageUrl: function(resultFolder, plotFile) {
  44 + return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile;
253 45 },
254 46  
255   - // Translate Duration for Extend,Shift in seconds
256   - TranslateSec: function(valueForm, valueUnit) {
257   -
258   - if (valueForm == "") return 0;
259   - else switch (valueUnit) {
260   - case "sec":
261   - return valueForm;
262   - case "min":
263   - return valueForm * 60;
264   - case "hour":
265   - return valueForm * 3600;
266   - case "day":
267   - return valueForm * 86400;
268   - default:
269   - return 0;
270   - }
271   - },
272   -
273   - createPlotResultPanel: function(resultFolder,resultId){
274   -
275   - var simplUrl = 'data/'+sessionID +'/RES/'+resultFolder+ '/' + resultId +'.png';
276   -
277   -//TODO if possible use window sizes
278   - var size = this.getImageSize();
279   - this.panelImage = Ext.create('Ext.Img', {
280   - src: simplUrl,
281   - width : size.width,
282   - height : size.height,
283   - listeners: {
284   - scope: this,
285   - afterrender: function(panel, opt){
286   - this.setImageSettings(panel);
287   - panel.getEl().on('click',function(e,i){
288   - this.setMireMode(panel);
289   - },this);
290   - panel.getEl().on('mousemove',function(e,el,opt){
291   - var clickX = this.trackMousePosition(e);
292   - this.setMirePosition(clickX,panel);
293   - },this);
294   - this.body.on('scroll',function(e,t,opt){
295   - var mir1 = this.getEl().getById("mire_vertical"+this.id);
296   - var mir2 = this.getEl().getById("mire_vertical2"+this.id);
297   - var scrollLeft = this.body.getScroll().left;
298   - if (mir1)
299   - mir1.setStyle("margin-left","-"+scrollLeft+"px");
300   - if (mir2)
301   - mir2.setStyle("margin-left","-"+scrollLeft+"px");
302   - },this);
303   - panel.getEl().on('contextmenu',function(e,i){
304   - e.preventDefault();
305   - var imgContextMenu = new Ext.menu.Menu({
306   - items: [
307   - {
308   - text: 'Show Image',
309   - // html: '<A HREF="'+panel.src+'">Save Image As...</A> ',
310   - handler:function(){
311   - // saveImageAs(panel.getEl());
312   - img = panel.src;
313   - window.win = open(img);
314   - // setTimeout('win.document.execCommand("SaveAs")', 500);
315   - // document.execCommand('saveas',false, 'test.txt');
316   - // document.location.href
317   - return false;
318   - }
319   - }
320   - //,{
321   -//// text: 'Show Start/Stop Plugin',
322   -//// iconCls: 'show',
323   -//// scope: this,
324   -//// handler: function(){
325   -//// this.createMire(panel);
326   -//// panel.fireEvent('open');
327   -//// }
328   -//// },{
329   -//// text: 'Reset Zoom',
330   -//// iconCls: 'reset',
331   -//// scope: this,
332   -//// handler: function(){
333   -//// alert('restore Plot original image');
334   -//// }
335   -// }
336   - ]
337   - });
338   -
339   - imgContextMenu.showAt(e.getXY());
340   - },this);
  47 + createPlotImage: function(resultFolder, plotFile, context) {
  48 + var size = this.getImageSize();
  49 + this.panelImage = Ext.create('Ext.Img', {
  50 + src : this.getImageUrl(resultFolder, plotFile),
  51 + width : size.width,
  52 + height : size.height,
  53 + refreshMe : function(){
  54 + var el;
  55 + if(el = this.el){
  56 + el.dom.src = this.src + '?dc=' + new Date().getTime();
  57 + }
  58 + },
  59 + listeners : {
  60 + render : function(){
  61 + this.refreshMe();
341 62 }
342   - },
343   - plugins: [ {ptype: 'interactiveIntervalPlugin'} ]
  63 + }
344 64 });
345 65  
346 66 return this.panelImage;
347   -
348   - },
349   -
350   - createMire: function(panel){
351   -
352   - this.isMire1Visible = true;
353   - this.isMire1Draggable = true;
354   - this.isMire2Visible = false;
355   - this.isMire2Draggable = false;
356   - var myContainer=document.getElementById(this.id);
357   -
358   - var scrollLeft = this.body.getScroll().left;
359   -
360   - if (!document.getElementById("mire_vertical"+this.id)){
361   - var newdiv1 = document.createElement('div');
362   - newdiv1.setAttribute('id', 'mire_vertical'+this.id);
363   - newdiv1.style.position = 'absolute';
364   - newdiv1.style.top = '26px';
365   - newdiv1.style.height = '990px';
366   - newdiv1.style.borderLeft = "1px solid rgb(0, 0, 0)";
367   - newdiv1.style.marginLeft = "-"+scrollLeft+"px";
368   - myContainer.appendChild(newdiv1);
369   - }
370   -
371   - if (!document.getElementById("mire_vertical2"+this.id)){
372   - var newdiv2 = document.createElement('div');
373   - newdiv2.setAttribute('id', 'mire_vertical2'+this.id);
374   - newdiv2.style.position = 'absolute';
375   - newdiv2.style.top = '26px';
376   - newdiv2.style.height = '990px';
377   - newdiv2.style.borderLeft = "1px solid rgb(0, 0, 0)";
378   - newdiv2.style.marginLeft = "-"+scrollLeft+"px";
379   - myContainer.appendChild(newdiv2);
380   - }
381   -
382   - this.resetMire();
383 67 },
384 68  
385   - setImageSettings: function(panel) {
386   -
387   - var imgSize = panel.getSize();
388   -
389   - this.imgPosition = panel.getPosition();
390   -
391   -//TODO if resizing influences this??
392   - this.leftOffset = Math.round(imgSize.width*this.Smin)+1;
393   - this.rightOffset = Math.round(imgSize.width*this.Smax);
394   - var timePanelWidth = this.rightOffset - this.leftOffset;
395   - this.pixelValue = this.plotDurationInSec / timePanelWidth;
396   - },
397   -
398   - trackMousePosition: function(event){
399   -
400   - var clickX = event.getX() - this.imgPosition[0];
401   - var clickY = event.getY() - this.imgPosition[1];
402   -
403   - var scrollX = this.body.getScroll().left;
404   - var scrollY = this.body.getScroll().top;
405   -
406   - if (clickX + scrollX >= this.leftOffset && clickX + scrollX <= this.rightOffset){
407   - var DeltaTimeX = clickX + scrollX - this.leftOffset;
408   - if (this.currentStartTime)
409   - {
410   - var realTimeX = Ext.Date.add(this.currentStartTime, Ext.Date.SECOND, this.pixelValue*DeltaTimeX);
411   - }
412   -
413   - this.mouseXField.setValue(realTimeX);
414   - this.mouseYField.setValue(clickY + scrollY);
415   - }
416   -
417   -
418   - return clickX + scrollX;
419   - },
420   -
421   - setMirePosition: function(clickX,panel){
422   - var mir1 = document.getElementById("mire_vertical"+this.id);
423   - var mir2 = document.getElementById("mire_vertical2"+this.id);
424   - if (this.isMire1Draggable){
425   - // set mire1 position
426   - if (mir1) mir1.style.left = clickX-1+"px";
427   - if (mir2) mir2.style.left = clickX-1+"px";
428   - } else if (this.isMire2Draggable){
429   - // set mire2 position
430   - if (mir2) mir2.style.left = clickX-1+"px";
431   - }
  69 + updatePlotImage: function(configResult) {
  70 + this.isPortrait = configResult.context.page.portrait;
  71 + this.pageWidth = configResult.context.page.width;
  72 + this.pageHeight = configResult.context.page.height;
  73 +
  74 + this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile));
  75 +
  76 + var size = this.getImageSize();
  77 + this.panelImage.setSize(size.width, size.height);
  78 +
  79 + this.panelImage.refreshMe();
432 80 },
433 81  
434   - setMireMode: function(panel){
435   -
436   - if (this.isMire1Draggable){
437   - // fix position of mire1
438   - this.isMire1Draggable = false;
439   - panel.fireEvent('startTime',this.mouseXField.getValue());
440   - if (!this.isMire2Draggable){
441   - var mir2 = document.getElementById("mire_vertical2"+this.id);
442   - if (mir2) {
443   - mir2.style.left = document.getElementById("mire_vertical"+this.id).style.left;
444   - // set mire2 visible
445   - mir2.style.borderTopStyle = "solid";
446   - this.isMire2Visible = true;
447   - this.isMire2Draggable = true;
448   - }
  82 + init: function(configResult){
  83 + this.isPortrait = configResult.context.page.portrait;
  84 + this.pageWidth = configResult.context.page.width;
  85 + this.pageHeight = configResult.context.page.height;
  86 +
  87 + this.sliderPage = new Ext.slider.Single({
  88 + width: 130,
  89 + value: 75,
  90 + increment: 5,
  91 + minValue: 50,
  92 + maxValue: 100,
  93 + fieldLabel : 'Resize',
  94 + labelWidth : 40,
  95 + listeners: {
  96 + scope : this,
  97 + changecomplete: function(s, v)
  98 + {
  99 + //ToDo - this.resetMire();
  100 + var size = this.getImageSize();
  101 + this.panelImage.width = size.width;
  102 + this.panelImage.height = size.height;
  103 + this.panelImage.doComponentLayout();
  104 + this.fireEvent('pagesize',this,v);
  105 + }
449 106 }
450   - } else if (this.isMire2Draggable){
451   - // fix position of mire2
452   - this.isMire2Draggable = false;
453   - panel.fireEvent('stopTime',this.mouseXField.getValue());
454   - }
455   - },
456   -
457   - resetMire: function(){
458   - this.isMire1Visible = true;
459   - this.isMire1Draggable = true;
460   - this.isMire2Visible = false;
461   - this.isMire2Draggable = false;
462   - // reinit position of mire1/2
463   - var mir1 = document.getElementById("mire_vertical"+this.id);
464   - var mir2 = document.getElementById("mire_vertical2"+this.id);
465   - if (mir1) {
466   - mir1.style.left = '126px';
467   - mir1.style.borderTopStyle = "solid";
468   - }
469   - if (mir2) {
470   - mir2.style.left = '126px';
471   - mir2.style.borderTopStyle = "none";
472   - }
473   - },
474   -
475   - destroyMire: function(){
476   - this.isMire1Visible = false;
477   - this.isMire1Draggable = false;
478   - this.isMire2Visible = false;
479   - this.isMire2Draggable = false;
480   - // get mire1 element
481   - var mire1 = document.getElementById("mire_vertical"+this.id);
482   - // set mire1 unvisible
483   - mire1.style.borderTopStyle = "none";
484   - // get mire2 element
485   - var mire2 = document.getElementById("mire_vertical2"+this.id);
486   - // set mire2 unvisible
487   - mire2.style.borderTopStyle = "none";
488   - //destroy mire1
489   - mire1.parentNode.removeChild(mire1);
490   - //destroy mire2
491   - mire2.parentNode.removeChild(mire2);
492   - },
493   -
494   - createToolBar : function(isTimeTable){
495   -
496   - var interoperItemCfg = {
497   - text: 'Get HST Data',
498   - scope: this,
499   - menu: [
500   - {
501   - text: 'Giant Planet Auroral Emissions',
502   - scope: this,
503   - handler: function()
504   - {
505   - var me = this;
506   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.astro.id, true, function (module) {
507   - module.createWindow(me.object.get('startDate'),me.object.get('stopDate'));
508   - });
509   - }
510   - }
511   - ]
512   - };
513   -
514   - if (isTimeTable) {
515   - var toolConfig = {
516   - dock: 'top',
517   - items: [{
518   - text: 'Previous',
519   - scope: this,
520   - handler: function(){
521   - var number = this.getDockedItems()[0].items.getAt(10).getValue();
522   - if (number > 1) {
523   - this.execute('backInt', number);
524   - }
525   - else {
526   - myDesktopApp.warningMsg('It is the very FIRST interval');
527   - }
528   - }
529   - }, '-', {
530   - text: 'Next',
531   - scope: this,
532   - handler: function(){
533   - var number = this.getDockedItems()[0].items.getAt(10).getValue();
534   - var intTot = this.getDockedItems()[0].items.getAt(11).getValue();
535   - if (parseInt(number) < parseInt(intTot)) {
536   - this.execute('nextInt', number);
537   - }
538   - else {
539   - myDesktopApp.warningMsg('It is the very LAST interval');
540   - }
541   - }
542   - }, '-', {
543   - text: 'Go to Interval #',
544   - scope: this,
545   - handler: function(bt){
546   - var number = bt.nextSibling().getValue();
547   - var intTot = this.getDockedItems()[0].items.getAt(11).getValue();
548   - if (parseInt(number) <= parseInt(intTot)){
549   - this.execute('goto', number);
550   - }
551   - else {
552   - myDesktopApp.warningMsg('Only '+ intTot +' intervals in the current Time Table');
553   - }
554   - }
555   - }, {
556   - xtype: 'numberfield',
557   - hideTrigger: true,
558   - width: 40,
559   - minValue: 1
560   - }, ' ',' ',' ',
561   - {
562   - xtype: 'textfield',
563   - labelAlign: 'right',
564   - labelWidth: 30,
565   - fieldLabel: 'Table',
566   - width: 130,
567   - disabled : true
568   - }, {
569   - xtype: 'textfield',
570   - labelAlign: 'right',
571   - labelWidth: 30,
572   - fieldLabel: 'Int #',
573   - width: 70,
574   - disabled : true
575   - }, {
576   - xtype: 'textfield',
577   - labelAlign: 'right',
578   - labelWidth: 30,
579   - fieldLabel: 'Total',
580   - width: 70,
581   - disabled : true
582   - }, '->',
583   - interoperItemCfg
584   - ]
585   - };
586   - }
587   - else {
588   - var toolConfig = {
589   - dock: 'top',
590   - items: [ {
591   - text: 'Backward',
592   - scope: this,
593   - handler: function(){
594   - this.execute('back', 'startDate');
595   - }
596   - }, '-' , {
597   - text: '1/2 Backward',
598   - scope: this,
599   - handler: function(){
600   - this.execute( 'halfback','startDate');
601   - }
602   - }, '-', {
603   - text: '1/2 Forward',
604   - scope: this,
605   - handler: function(){
606   - this.execute('halfnext','stopDate');
607   - }
608   - }, '-', {
609   - text: 'Forward',
610   - scope: this,
611   - handler: function(){
612   - this.execute('next','stopDate');
613   - }
614   - }, '->',
615   - interoperItemCfg
616   - ]
617   - };
618   - }
619   -
620   - var toolBar = Ext.create('Ext.toolbar.Toolbar', toolConfig);
621   - return toolBar;
622   - },
623   -
624   - execute: function(procedure, argName){
  107 + });
625 108  
626   - var isMulti = false;
627   - this.setObjectIntoNode();
628   - if (procedure == 'goto' || procedure == 'backInt'|| procedure == 'nextInt') var argValue = argName;
629   - else var argValue = this.object.get(argName);
630   -
631   - this.object.fireEvent('execute', isMulti, procedure, argValue);
632   - },
633   -
634   -// can't find event to listen to
635   - setObjectIntoNode: function() {
636   -
637   - var resModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id);
638   -
639   - //AKKA - modification to retrieve the linkedNode
640   - var linkedNodeKey = 'plot' + this.object.get('tabId') + '-win';
641   - //var linkedNodeKey = this.object.get('resultFolder').toLowerCase() + '-win';
642   -
643   -//TODO work with real ID
644   - var linkedNode = resModule.getLinkedNodeByKey(linkedNodeKey);
645   -
646   - if (!linkedNode.get('object')) {
647   - resModule.setLinkedNode(linkedNode);
648   - linkedNode.set('object',this.object);
649   - }
650   - },
651   -
652   -//Update object and toolbar
653   - updateObject: function(obj) {
654   - var newTsrc = obj.get('timesrc');
655   - var oldTsrc = this.object.get('timesrc');
656   - this.object = obj;
657   -// update toolbar
658   - if (newTsrc !== oldTsrc) {
659   - var isTimeTable = newTsrc == amdaModel.AmdaTimeObject.inputTimeSrc[0];
660   - var navToolbar = this.createToolBar(isTimeTable);
661   -
662   - var oldNavToolbar = this.getDockedItems()[0];
663   - this.removeDocked(oldNavToolbar,true);
664   - // dock = top by default
665   - this.addDocked(navToolbar);
666   - }
667   - },
668   -
669   - getImageSize : function() {
670   - var orientation = this.object.get('orientation');
671   -
672   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id);
673   -
674   - if (orientation.toLowerCase() == 'portrait') {
675   - var size = Ext.clone(module.self.winSize.portrait);
676   - }
677   - else {
678   - var size = Ext.clone(module.self.winSize.landscape);
679   - }
680   -
681   - size.width *= this.sliderPage.getValue()/100.;
682   - size.height *= this.sliderPage.getValue()/100.;
683   -
684   - size.width -= module.self.imgOffset.x;
685   - size.height -= module.self.imgOffset.y;
686   -
687   - return size;
688   - },
689   -
690   - setPageSize : function(size)
691   - {
692   - this.sliderPage.setValue(size);
693   - this.sliderPage.fireEvent('changecomplete',this.sliderPage,size);
694   - },
695   -
696   - updateTimeTableInfo: function(obj)
697   - {
698   - var toolBar = this.getDockedItems()[0];
699   - if (obj.get('ttName')) toolBar.items.getAt(9).setValue(obj.get('ttName'));
700   - if (obj.get('intervalN')) toolBar.items.getAt(10).setValue(obj.get('intervalN'));
701   - if (obj.get('totalN')) toolBar.items.getAt(11).setValue(obj.get('totalN'));
702   - }
703   -});
  109 + var plotResultTabPanelConfig = {
  110 + preventHeader : true,
  111 + autoScroll: true,
  112 + items: [
  113 + this.createPlotImage(configResult.folder, configResult.plotFile, configResult.context)
  114 + ]
  115 + };
  116 +
  117 + Ext.apply(this , plotResultTabPanelConfig);
  118 + }
  119 +});
704 120 \ No newline at end of file
... ...
js/app/views/PlotUI.js 100755 โ†’ 100644
... ... @@ -3,1548 +3,252 @@
3 3 * Name : PlotUI.js
4 4 * @class amdaUI.PlotUI
5 5 * @extends Ext.container.Container
6   - * @brief Plot Module UI definition (View)
7   - * @author Caroline DARMON
8   - * @version $Id: PlotUI.js 2641 2014-11-18 11:58:13Z elena $
  6 + * @brief New Plot Module UI definition (View)
  7 + * @author Benjamin Renard
  8 + * @version $Id: PlotUI.js benjamin $
9 9 */
10 10  
11 11  
12 12 Ext.define('amdaUI.PlotUI', {
13   - extend: 'Ext.container.Container',
14   - alias: 'widget.panelPlot',
15   -
16   - forcedLayout : false,
17   - forcedMulti : false,
18   -
19   - requires: [
20   - 'amdaUI.TimeSelectorUI',
21   - 'amdaReader.PlotReader',
22   - 'amdaUI.ParamEditorPlugin',
23   - 'Ext.ux.amdaGrid.HeaderToolTip'
24   - ],
25   -
26   - // cell decoration
27   - statics : {
28   - editable : 'border: 1px inset #a3bae9!important; margin:2px 3px 2px 3px; background-color: #ffffff',
29   - button : 'border: 1px outset #a3bae9!important; margin:2px 3px 2px 3px; background-color: #ffffff',
30   - important: 'color: red!important; text-decoration: blink;'
31   - },
32   -
33   - constructor: function(config) {
34   - this.addParamMode=amdaModel.PlotPanel.ADD_PARAM_MODE[0];
35   - this.waitingScatterPanel=null;
36   - this.init(config);
37   - this.callParent(arguments);
38   - // load object into view if exists
39   - if (this.object) this.loadObject();
40   - },
41   -
42   - addTT : function(newTTName,newTTid){
43   - this.timeSelector.addTT(newTTName,newTTid);
44   - },
45   -
46   - addTTs : function(TTarray) {
47   - this.timeSelector.setTTTab(TTarray);
48   - },
49   -
50   - addParam : function(targetNode, position, newParamName, isLeaf, isScatter, needsArgs, notyet) {
51   - var selModel = this.plotTree.getSelectionModel();
52   - if (this.addParamMode == amdaModel.PlotPanel.ADD_PARAM_MODE[0]) {
53   - // Create a new record instance
54   - var recEmptyParam = Ext.create('amdaModel.PlotParam',{ name: newParamName, isScatter: isScatter, needsArgs: needsArgs, plotOnly: notyet });
55   - // Move the record to the corresponding panel
56   - this.moveParam(recEmptyParam,targetNode,position);
57   - selModel.select(recEmptyParam);
58   -
59   - if (needsArgs){
60   - this.plotTree.fireEvent('openParamEditor',recEmptyParam);
61   - }
62   - }
63   - else if (isLeaf) {
64   - if (this.waitingScatterPanel) {
65   - var recScatter = Ext.create('amdaModel.AmdaObject',{name: newParamName});
66   - if (needsArgs) {
67   - Ext.Msg.alert('Warning', newParamName + ' can not be used as X in scatter mode');
68   - return;
69   - }
70   - this.waitingScatterPanel.set('scatterParam',recScatter);
71   - // simple add mode
72   - this.addParamMode = amdaModel.PlotPanel.ADD_PARAM_MODE[0];
73   - this.waitingScatterPanel = null;
74   - }
75   - }
76   - },
77   -
78   -
79   - addPanel : function()
80   - {
81   - // Create a new Panel record instance
82   - var recEmptyPanel = Ext.create('amdaModel.PlotPanel',{expanded: true});
83   - // Add the new panel under the root node
84   - this.plotTree.getRootNode().appendChild(recEmptyPanel);
85   - //TODO config : expand doesn't work????
86   - recEmptyPanel.expand();
87   - this.updatePanelsIndex();
88   -
89   - return recEmptyPanel;
90   - },
91   -
92   - dropRecord : function(record,targetNode,position)
93   - {
94   - var selModel = this.plotTree.getSelectionModel();
95   -
96   - //select the target node if defined
97   - if (targetNode)
98   - selModel.select(targetNode);
99   - else
100   - selModel.deselectAll();
101   -
102   - switch (record.$className)
103   - {
104   - case 'amdaModel.LocalParamNode' :
105   - case 'amdaModel.RemoteParamNode' :
106   - case 'amdaModel.RemoteSimuParamNode' :
107   - if (!record.get('isParameter') || record.get('disable'))
108   - return false;
109   -
110   - var needsArgs = false;
111   -
112   - if (record.$className == 'amdaModel.RemoteSimuParamNode') {
113   - needsArgs = record.get('needsArgs');
114   - }
115   - else if (record.$className == 'amdaModel.LocalParamNode') {
116   - needsArgs = record.get('needsArgs') && !record.get('isSpectra');
117   - }
118   -
119   - if (record.get('alias')!= "" )
120   - this.addParam(targetNode,position,"#"+record.get('alias'), record.isLeaf(), record.get('isScatter'), needsArgs );
121   - else
122   - this.addParam(targetNode,position,record.get('id'), record.isLeaf(), record.get('isScatter'), needsArgs, record.get('notyet'));
123   -
124   - return true;
125   - case 'amdaModel.AliasNode' :
126   - if (!record.isLeaf())
127   - return false;
128   - this.addParam(targetNode,position,"#"+record.get('text'), record.isLeaf(), record.get('isScatter'));
129   - return true;
130   - case 'amdaModel.DerivedParamNode' :
131   - if (!record.isLeaf())
132   - return false;
133   - this.addParam(targetNode,position,"ws_"+record.get('text'), record.isLeaf(), record.get('isScatter'));
134   - return true;
135   - case 'amdaModel.MyDataParamNode' :
136   - if (!record.isLeaf())
137   - return false;
138   - this.addParam(targetNode,position,"wsd_"+record.get('text'), record.isLeaf(), record.get('isScatter'));
139   - return true;
140   - case 'amdaModel.PlotParam' :
141   - return this.moveParam(record,targetNode,position);
142   - case 'amdaModel.PlotPanel' :
143   - return this.movePanel(record,targetNode,position);
144   - default :
145   - return false;
146   - }
147   - return false;
148   - },
149   -
150   - moveParam : function(record,targetNode,position)
151   - {
152   - if (record.$className != 'amdaModel.PlotParam')
153   - return false;
154   - //Create a new panel
155   - if (!targetNode)
156   - targetNode = this.addPanel();
157   -
158   - if (targetNode.$className == 'amdaModel.PlotPanel')
159   - {
160   - targetNode.expand();
161   - targetNode.appendChild(record);
162   - return true;
163   - }
164   - else if (targetNode.$className == 'amdaModel.PlotParam')
165   - {
166   - var panelNode = targetNode.parentNode;
167   - if (!panelNode)
168   - return false;
169   - switch (position)
170   - {
171   - case 'append' :
172   - return false;
173   - case 'before' :
174   - panelNode.insertBefore(record,targetNode);
175   - return true;
176   - case 'after' :
177   - if (panelNode.isLast())
178   - {
179   - panelNode = this.addPanel();
180   - panelNode.appendChild(record);
181   - }
182   - else
183   - panelNode.insertChild(targetNode.get('index')+1,record);
184   - return true;
185   - }
186   - }
187   - return false;
188   - },
  13 + extend: 'Ext.container.Container',
  14 + alias: 'widget.newPanelPlot',
189 15  
190   - movePanel : function(record,targetNode,position)
191   - {
192   - if (record.$className != 'amdaModel.PlotPanel')
193   - return false;
194   -
195   - switch (position)
196   - {
197   - case 'before' :
198   - this.plotTree.getRootNode().insertBefore(record,targetNode);
199   - this.updatePanelsIndex();
200   - return true;
201   - case 'after' :
202   - var refPanel = targetNode;
203   - switch (targetNode.$className)
204   - {
205   - case 'amdaModel.PlotPanel' :
206   - refPanel = targetNode;
207   - break;
208   - case 'amdaModel.PlotParam' :
209   - refPanel = targetNode.parentNode;
210   - break;
211   - default :
212   - return false;
213   - }
214   - this.plotTree.getRootNode().insertChild(refPanel.get('index')+1,record);
215   - this.updatePanelsIndex();
216   - return true;
217   - break;
218   - default :
219   - return false;
220   - }
221   -
222   - return true;
  16 + requires: [
  17 + 'amdaModel.DownloadNode',
  18 + 'amdaModel.Download',
  19 + 'amdaUI.TimeSelectorUI',
  20 + 'amdaPlotComp.PlotTabPanel',
  21 + 'amdaPlotComp.PlotOutputForm',
  22 + 'amdaPlotComp.PlotElementPanel'
  23 + ],
  24 +
  25 + formPanel: null,
  26 +
  27 + plotOutput: null,
  28 +
  29 + plotTabs : null,
  30 +
  31 + plotElement : null,
  32 +
  33 + constructor: function(config) {
  34 + this.init(config);
  35 + this.callParent(arguments);
  36 + if (this.object)
  37 + this.setObject(this.object);
223 38 },
224 39  
225   - isValidToDrop : function(record,targetNode,position)
226   - {
227   - switch (record.$className)
228   - {
229   - case 'amdaModel.LocalParamNode' :
230   - case 'amdaModel.RemoteParamNode' :
231   - case 'amdaModel.RemoteSimuParamNode' :
232   - return record.get('isParameter') && ! record.get('disable');
233   - case 'amdaModel.AliasNode' :
234   - case 'amdaModel.DerivedParamNode' :
235   - case 'amdaModel.MyDataParamNode' :
236   - return record.isLeaf();
237   - case 'amdaModel.PlotParam' :
238   - return true;
239   - case 'amdaModel.PlotPanel' :
240   - switch (position)
241   - {
242   - case 'append' :
243   - return false;
244   - case 'before' :
245   - return (targetNode.$className == 'amdaModel.PlotPanel');
246   - case 'after' :
247   - return ((targetNode.$className == 'amdaModel.PlotParam') && targetNode.isLast());
248   - }
249   - }
250   - return false;
  40 + setObject : function(object) {
  41 + this.object = object;
  42 + this.plotOutput.setObject(this.object);
  43 + this.plotTabs.setRequestObject(this.object);
  44 + this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate'));
251 45 },
252   -
253   -/**
254   - * replace alias by param and vise versa
255   - */
256   - updateConstruct : function(oldval,newval) {
257   - if (this.plotTree) {
258   - while (this.plotTree.getRootNode().findChild('name',oldval,true)) {
259   - var paramToMove = this.plotTree.getRootNode().findChild('name',oldval,true);
260   - if (paramToMove) {
261   - paramToMove.set('name',newval);
262   - paramToMove.set('text',newval);
263   - }
264   - }
265   - }
266   - },
267   -
268   - setObject : function(obj) {
269   - this.object = obj;
270   - this.loadObject();
271   - },
272   -
273   - loadTimeFromMulti : function() {
274   -// get individual basic form
275   - var thisForm = this.formPanel.getForm();
276   -
277   - var multiPlotWin = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id);
278   -
279   - var multiTimeSelector = multiPlotWin.items.items[0].timeSelector;
280   - var multiForm = multiPlotWin.items.items[0].getForm();
281   -// get values from multiPlot Form and set into individual one
282   - var multiTimeSource = multiTimeSelector.timeSrc.getChecked()[0].getGroupValue();
283   - var thisTimeSource = this.timeSelector.timeSrc.getChecked()[0].getGroupValue();
284   -
285   -// set timetables names from multiPlot Form - change to needed Time Source is automatic
286   - if (multiTimeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]){
287   - this.addTTs(multiTimeSelector.TTGrid.getStore().data.items);
288   - }
289   - else {
290   - if (thisTimeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]){
291   - this.timeSelector.setTTTab(false);
292   - }
293   -// get values from multiPlot Form and set into individual one
294   - var timeValuesFromMulti = multiForm.getValues();
295   - thisForm.setValues(timeValuesFromMulti);
296   - }
  46 +
  47 + /**
  48 + * save method called by Save button to launch the save process
  49 + */
  50 + saveProcess : function(){
  51 + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
  52 + console.log(plotModule.linkedNode);
  53 + if (plotModule)
  54 + plotModule.linkedNode.create();
297 55 },
298 56  
299   -
300   - /**
301   - * update this.object from form
302   - */
303   - updateObject : function(fromMulti){
304   -
305   -//if empty tree
306   - if (!this.plotTree.getStore().getRootNode().hasChildNodes())
307   - return false;
308   -
309   -// get the basic form
310   - var basicForm = this.formPanel.getForm();
311   - var timeSource = this.timeSelector.timeSrc.getChecked()[0].getGroupValue();
312   -
313   - var updateStatus = true;
314   - if (this.object) this.object.set('tabId', this.id.substr(4,1));
315   -
316   - var fieldsWithoutName = basicForm.getFields().items;
317   - Ext.Array.each(fieldsWithoutName, function(item, index,allItems){
318   - if(item !== this.fieldName) {
319   - if (!item.isValid()) {
320   - if ((timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) &&
321   - ((item.name == 'startDate') || (item.name == 'stopDate') || (item.name == 'duration'))) {
322   - updateStatus = true;
323   - }
324   - else {
325   - // set update isn't allowed
326   - updateStatus = false;
327   - return false;
328   - }
329   - }
330   - }
331   - }, this);
332   -
333   - if (!updateStatus)
334   - return false;
335   -
336   -// multiPlot time settings into this form
337   - if (fromMulti) {
338   - this.loadTimeFromMulti();
339   - }
340   -
341   - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0] // timeSource 'TimeTable'
342   - && this.timeSelector.TTGrid.getStore().count() == 0) {
343   - myDesktopApp.warningMsg(
344   - 'You chose Time Selection by TimeTable` but no timeTable was added!<br/>Please add one or change Time Selection');
345   - return false;
346   - }
347   -
348   -// if the update is allowed
349   - if (updateStatus) {
350   - // real object update
351   -
352   - //update object from multi plot mgr as this tt form is disabled
353   - if (fromMulti) {
354   - var resWin = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id);
355   - var multiForm = resWin.items.items[0].getForm();
356   - multiForm.updateRecord(this.object);
357   - }
358   - // update object with the content of form
359   - else {
360   - basicForm.updateRecord(this.object);
361   - }
362   - var orientation = basicForm.findField('orientation').getValue();
363   - this.object.set('orientation', orientation);
364   - var format = basicForm.findField('format').getValue();
365   - this.object.set('format', format);
366   -
367   - this.object.set('forcedLayout', this.forcedLayout);
368   - this.object.set('forcedMulti', this.forcedMulti);
369   -
370   - this.object.set('timesrc', timeSource);
371   - // update object with content of treePanel
372   - this.object.childNodes = this.plotTree.getRootNode().childNodes;
373   - // set valid intervals into TimeTable object
374   - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) {
375   - this.object.set('timeTables', this.timeSelector.TTGrid.getStore().data.items);
376   - }
377   - }
378   -
379   - // return the update status
380   - return updateStatus;
381   -
  57 + resetProcess : function(){
  58 + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
  59 + plotModule.createLinkedNode();
  60 + plotModule.createObject();
  61 + this.setObject(plotModule.linkedNode.get('object'));
382 62 },
383   -
384   - /**
385   - * load this.object into form
386   - */
387   - loadObject : function(){
388   -
389   - if (this.object.get('charSize') == 0)
390   - this.object.set('charSize', 1.3);
391 63  
392   - if (this.object.get('thickness') == 0)
393   - this.object.set('thickness', 1);
394   -
395   - if (!this.object.get('format'))
396   - this.object.set('format', 'PNG');
397   -
398   - if (!this.object.get('orientation'))
399   - this.object.set('orientation', 'LANDSCAPE');
400   -
401   - if (!this.object.get('ppp'))
402   - this.object.set('ppp', 3000);
403   -
404   - if (this.object.get('forcedLayout') || this.object.get('forcedMulti')) {
405   - var toolItems = this.plotTree.getDockedItems('toolbar')[0].items;
406   -
407   - if (this.object.get('forcedLayout')) toolItems.getAt(3).setValue(true);
408   - if (this.object.get('forcedMulti')) toolItems.getAt(5).setValue(true);
409   - }
410   - // load object into form
411   - this.formPanel.getForm().loadRecord(this.object);
412   -
413   - if (this.object.get('children') || this.object.childNodes) {
414   -
415   - var jsonObj = this.object.getJsonValues(this.object.get('id'));
416   - jsonObj.leaf = false;
417   -/* reset with keeping old object
418   - // clone jsonObj as setRootNode() spoiled this.object ??
419   - this.jsonObj = Ext.clone(jsonObj);
420   -*/
421   - this.plotTree.getStore().setRootNode(jsonObj);
422   - this.plotTree.getRootNode().expandChildren(true);
423   - }
424   -
425   - // set object's TTs into the timeselector
426   - if (this.object.get('timesrc') === amdaModel.AmdaTimeObject.inputTimeSrc[0])
427   - this.addTTs(this.object.get('timeTables'));
  64 + getDataProcess : function(){
  65 + var downObject = amdaModel.DownloadNode.decodeObject(this.object);
  66 + amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject));
  67 + amdaModel.DownloadNode.editInModule();
428 68 },
429   -
430   - /**
431   - * save method called by Save button to launch the save process
432   - */
433   - saveProcess : function(toRename){
434   - // if this object has been modified
435   - if (this.object.dirty) {
436   - // Plot module
437   - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
438   - var linkedNode = plotModule.getTabNode(this.id);
439   - plotModule.setLinkedNode(linkedNode);
440   -
441   - // if the name has been modified this is a creation
442   - if (this.object.isModified('name')){
443   -
444   - // if object already has an id : it's a 'rename' of an existing request
445   - if (this.object.get('id')){
446   -
447   - // the context Node is the parent node of current edited one
448   - var contextNode = plotModule.getTabNode(this.id).parentNode;
449   -
450   - // link a new node to the plotModule
451   - plotModule.createLinkedNode();
452   - plotModule.addLinkedNode(plotModule.linkedNode, this.id);
453   -
454   - // set the contextNode
455   - plotModule.linkedNode.set('contextNode',contextNode);
456   -
457   - // create a new object linked
458   - plotModule.createObject(this.object.getJsonValues());
459   - var plotObj = plotModule.linkedNode.get('object');
460   - // synchronisation of objects
461   - this.object = plotObj;
462   - if (toRename) plotModule.linkedNode.toRename = true;
463   - }
464   - plotModule.linkedNode.set('object',this.object);
465   - plotModule.linkedNode.create();
466   -
467   - } else {
468   - plotModule.linkedNode.set('object',this.object);
469   - plotModule.linkedNode.set('contextNode',plotModule.contextNode);
470   - plotModule.linkedNode.update();
471   - }
472   - }
  69 +
  70 + addParameter : function(node){
  71 + var crtTree = this.plotTabs.getTreeFromPlotTab(this.plotTabs.getActiveTab());
  72 + crtTree.dropRecord(node,null,'append');
473 73 },
474 74  
475   - /**
476   - * overwrite metod called by Save button
477   - */
478   - overwriteProcess : function(btn){
479   - if (btn == 'cancel') return;
480   -
481   - this.fieldName.clearInvalid();
482   - this.saveProcess(true);
483   - },
484   -
485   - /**
  75 + /**
486 76 * plot method called by 'Do Plot' button to launch the plot process
487 77 */
488 78 doPlot : function(){
489   - // fire execution
490   - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
491   - this.object.set('forcedLayout',this.forcedLayout);
492   - this.object.set('forcedMulti',this.forcedMulti);
493   - plotModule.getTabNode(this.id).set('object',this.object);
494   -
495   - plotModule.getTabNode(this.id).execute();
496   - },
497   - getPlotTreeColumns : function(){
498   -
499   - var typeStore = Ext.create('Ext.data.Store', {
500   - fields: ['display', 'value'],
501   - data : amdaModel.PlotPanel.PLOT_TYPES
502   - });
503   -
504   - return [
505   - {
506   - menuDisabled: true,
507   - align: 'left',
508   - width: 16,
509   - renderer: function(v,m,record){
510   - return'<div class="icon-small-remover" style="width: 16px; height: 16px; vertical-align: middle;"></div>';
511   - }
512   - },
513   - {
514   - xtype: 'treecolumn', //this is so we know which column will show the tree
515   - text: 'Name',
516   - dataIndex: 'name',
517   - width: 130,
518   - menuDisabled: true
519   - },
520   - //// Panel specific columns
521   - {
522   - text: 'Panel Properties',
523   - menuDisabled: true, align: 'center',
524   - columns: [
525   - {
526   - text: 'Plot Type&nbsp;<img amda_clicktip="plotType" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
527   - dataIndex : 'plotType',
528   - menuDisabled: true,
529   - width: 100, align: 'center',
530   - // tooltip: 'You may select one of two different plot types:<br/>Time-Y(<b>Time</b>,default) or X-Y(<b>Scatter</b>)',
531   - editor: {
532   -// selectOnFocus: true,
533   - xtype:'combo',
534   - editable: false,
535   - store: typeStore,
536   -// queryMode: 'local',
537   - displayField: 'value',
538   - valueField: 'value',
539   - onItemClick: function(picker,record){
540   - /*
541   - * Extract/Override of original extjs library code
542   - * If we're doing single selection, the selection change events won't fire when
543   - * clicking on the selected element. Detect it here.
544   - */
545   - var me = this,
546   - lastSelection = me.lastSelection,
547   - valueField = me.valueField,
548   - selected, selectedRow;
549   -
550   - if (!me.multiSelect && lastSelection) {
551   - selected = lastSelection[0];
552   - // SCATTER
553   - if (selected && record.get(valueField) === amdaModel.PlotPanel.PLOT_TYPES[1].value) {
554   - selectedRow = me.up('form').ownerCt.selectedRow;
555   - // SCATTER : RESET
556   - if (selected.get(valueField) === amdaModel.PlotPanel.PLOT_TYPES[1].value) {
557   - //TODO if it is needed???
558   - //Make sure we also update the display value if it's only partial
559   - //me.displayTplData = [record.data];
560   - //me.setRawValue(me.getDisplayValue());
561   - //me.collapse();
562   - // CDA: plug
563   - me.fireEvent('unchangedselect',me,record);
564   - }
565   - else if (selectedRow.get('scatterParam')) {
566   - selectedRow.set('scatterParam',null);
567   - }
568   - }
569   - //me.fireEvent('blur');
570   - }
571   - },
572   - listeners : {
573   - scope: this,
574   - select: function(combo, record, index) {
575   - // on select complete action
576   - combo.fireEvent('blur');
577   - },
578   - unchangedselect: function(combo, record){
579   - // if we're already waiting for scatter param
580   - if (this.addParamMode == amdaModel.PlotPanel.ADD_PARAM_MODE[1]) {
581   - Ext.Msg.alert('Warning', 'Panel '+ this.getPanelIndex(this.waitingScatterPanel) +' is already waiting for a scatter parameter!');
582   - } else {
583   - // reinit scatter selection of selected row
584   - this.selectedRow.set('scatterParam',null);
585   - // set the waiting scatter panel with the selected row
586   - this.waitingScatterPanel = this.selectedRow;
587   - // set scatter add mode
588   - this.addParamMode = amdaModel.PlotPanel.ADD_PARAM_MODE[1];
589   - // refresh view
590   - //this.plotTree.getView().refresh();
591   - }
592   - // complete action
593   - combo.fireEvent('blur');
594   - }
595   - }
596   - },
597   - renderer: function(v,m,record){
598   - if(!record.isLeaf()) {
599   - // if 'TIME'
600   - if (record.get('plotType') == amdaModel.PlotPanel.PLOT_TYPES[0].value) {
601   - m.style += amdaUI.PlotUI.editable;
602   - return record.get('plotType');
603   - } else if (record.get('scatterParam')) {
604   - m.style += amdaUI.PlotUI.editable;
605   - var scatterName = record.get('scatterParam').data.name;
606   - // return 'function of '+ record.get('scatterParam').get('name');
607   - return 'function of '+ scatterName;
608   - } else {
609   - m.style = amdaUI.PlotUI.important;
610   - record.set('width',record.get('height'));
611   - return 'Select Parameter...';
612   - }
613   - }
614   - }
615   -
616   - }, {
617   - text: 'Height',
618   - dataIndex : 'height',
619   - menuDisabled: true,
620   - width: 50, align: 'center',
621   - editor: {
622   - xtype: 'numberfield', minValue:0,
623   - allowDecimals : true,
624   - hideTrigger: true
625   - },
626   - renderer: function(value,metaData,record){
627   - if (record.$className === amdaModel.PlotPanel.$className){
628   - metaData.style += amdaUI.PlotUI.editable;
629   - }
630   - return value;
631   - }
632   - }, {
633   - menuDisabled: true,
634   - text: 'Width', align: 'center',
635   - dataIndex : 'width',
636   - width: 50,
637   - editor: {
638   - xtype: 'numberfield', minValue: 0,
639   - allowDecimals : true,
640   - decimalPrecision: 10,
641   - hideTrigger: true
642   - },
643   - renderer: function(value,metaData,record){
644   - if (record.$className == amdaModel.PlotPanel.$className){
645   - metaData.style += amdaUI.PlotUI.editable;
646   - }
647   - return value;
648   - }
649   - },
650   - {
651   - text: 'Xmin',
652   - menuDisabled: true,
653   - dataIndex : 'xRangeMin',
654   - width: 50, align: 'center',
655   - editor: {
656   - xtype: 'numberfield',
657   - allowDecimals : true, baseChars: '0123456789eE',
658   - decimalPrecision: 20,
659   - hideTrigger: true
660   - },
661   - renderer: function(value,metaData,record){
662   - if (record.$className == amdaModel.PlotPanel.$className){
663   - metaData.style += amdaUI.PlotUI.editable;
664   - }
665   - return value;
666   - }
667   - },
668   - {
669   - text: 'Xmax',
670   - menuDisabled: true,
671   - dataIndex : 'xRangeMax',
672   - width: 50, align: 'center',
673   - editor: {
674   - xtype: 'numberfield',
675   - allowDecimals : true, baseChars: '0123456789eE',
676   - decimalPrecision: 20,
677   - hideTrigger: true
678   - },
679   - renderer: function(value,metaData,record){
680   - if (record.$className == amdaModel.PlotPanel.$className){
681   - metaData.style += amdaUI.PlotUI.editable;
682   - }
683   - return value;
684   - }
685   - },
686   - {
687   - text: 'Ymin', align: 'center',
688   - menuDisabled: true,
689   -
690   - dataIndex : 'y1RangeMin',
691   - editor: {
692   - xtype: 'numberfield', baseChars: '0123456789eE',
693   - allowDecimals : true, decimalPrecision: 20,
694   - hideTrigger: true
695   - },
696   - width: 50,
697   - renderer: function(value,metaData,record){
698   - if (record.$className == amdaModel.PlotPanel.$className){
699   - metaData.style += amdaUI.PlotUI.editable;
700   - }
701   - return value;
702   - }
703   - },
704   - {
705   - text: 'Ymax', align: 'center',
706   - menuDisabled: true,
707   - dataIndex : 'y1RangeMax',
708   - editor: {
709   - xtype: 'numberfield',
710   - allowDecimals : true, baseChars: '0123456789eE',
711   - decimalPrecision: 20,
712   - hideTrigger: true
713   - },
714   - width: 50,
715   - renderer: function(value,metaData,record){
716   - if (record.$className == amdaModel.PlotPanel.$className){
717   - metaData.style += amdaUI.PlotUI.editable;
718   - }
719   - return value;
720   - }
721   - }, {
722   - text: 'Additional',
723   - menuDisabled: true, align: 'center',
724   - width: 100,
725   - dataIndex : 'panelArgs',
726   - tooltip: 'Panel generic arguments.....',
727   - renderer: function(value,metaData,record){
728   - if (record.$className === amdaModel.PlotPanel.$className){
729   - //TODO save it somehow at server side
730   - if (!value) value = 'select...';
731   - metaData.style += amdaUI.PlotUI.button;
732   - }
733   - else {value = ""};
734   - return value;
735   - }
736   - },
737   - ]
738   -
739   - },
740   - //// Param Arguments
741   - {
742   - text: 'Parameter Arguments',
743   - menuDisabled: true, align: 'center',
744   - width: 120,
745   - dataIndex : 'paramArgs',
746   - tooltip: 'Parameter specific arguments.....',
747   - renderer: function(value,metaData,record){
748   - if (record.$className === amdaModel.PlotParam.$className){
749   - metaData.style += amdaUI.PlotUI.button;
750   - var tooltip = value;
751   - if (value !== 'select...')
752   - metaData.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(tooltip) + '"';
753   - }
754   - else {value = ""};
755   - return value;
756   - }
757   - },
758   - {
759   - text: 'Y2',
760   - menuDisabled: true,
761   - dataIndex : 'yaxe',
762   - width: 30,
763   - tooltip: 'Y2 is not implemented yet',
764   - renderer: function(value,metaData,record){
765   - if (record.$className == amdaModel.PlotParam.$className){
766   - if (value) return '<input type="checkbox" disabled checked/>';
767   - else return '<input type="checkbox" disabled/>';
768   - }
769   - else return "";
770   - }
771   - }
772   - ];
773   - },
774   -
775   - updatePanelsIndex : function()
776   - {
777   - Ext.each(this.plotTree.getRootNode().childNodes, function(item)
778   - {
779   - if (item.$className == 'amdaModel.PlotPanel')
780   - {
781   - var index = this.getPanelIndex(item);
782   - item.set('name', 'Panel '+index);
783   - }
784   - },this);
785   - },
786   -
787   - removePanel : function(panel)
788   - {
789   - var selModel = this.plotTree.getSelectionModel();
790   - var plugin = this.plotTree.getPlugin('paramEditorPlugin');
791   -
792   - // if the panel to delete is not empty
793   - if (panel.hasChildNodes()) {
794   - // Prompt confirmation to the user if he wants to continue deletion
795   - Ext.Msg.confirm('non-empty panel', 'This Panel is non-empty!<br>Do you want to continue its deletion?', function(btn, text){
796   - if (btn == 'yes'){
797   - // remove panel
798   - selModel.deselect(panel);
799   - //if args plugin is open and is connected to removed record : close plugin
800   - Ext.Array.each(panel.childNodes, function(item){
801   - if (plugin && plugin.record && (plugin.record.get('id') == item.get('id')))
802   - plugin.win.close();
803   - });
804   - panel.remove();
805   - this.updatePanelsIndex();
806   - //this.plotTree.getView().refresh();
807   - }
808   - },this);
809   - }
810   - else {
811   - // remove panel
812   - selModel.deselect(panel);
813   - panel.remove();
814   - this.updatePanelsIndex();
815   - //this.plotTree.getView().refresh();
816   - }
817   - },
818   -
819   - getPanelIndex : function(panel){
820   - var root = this.plotTree.getRootNode(), index=1;
821   - root.eachChild(function(node){
822   - if (node == panel){
823   - return false;
824   - }
825   - index++;
826   - });
827   - return index;
828   - },
829   -
830   - init : function(config) {
831   -
832   - var me = this;
  79 + var timeSource = this.timeSelector.getActiveTimeSource();
  80 + var basicForm = this.formPanel.getForm();
  81 + basicForm.updateRecord(this.object);
  82 + this.object.set('timesrc', timeSource);
  83 + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
  84 + this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
833 85  
834   - var treeGridCellEditing = Ext.create('TreeGridCellEditor', {
835   - listeners: {
836   - scope: this,
837   - beforeedit: function(editor,object,opt){
838   -
839   - //TODO replace hardcoded column values
840   - // panel fields
841   - if ( 0 < object.colIdx && object.colIdx < 10 ){
842   -
843   - // desactivate editor in case of param
844   - if (object.record.isLeaf()){
845   - return false;
846   - }
847   -
848   - // fields Xmin - Xmax and plotType is 'TIME'
849   - if ( 4 < object.colIdx && object.colIdx < 7 &&
850   - object.record.get('plotType') === amdaModel.PlotPanel.PLOT_TYPES[0].value){
851   - //TODO temporary!!!! wait for new kernel
852   - if ((object.record.childNodes[0].get('paramArgs').match('OrbitPresentation=CYL')) ||
853   - (object.record.childNodes[0].get('paramArgs').match('OrbitPresentation=GLOBAL')))
854   - return true;
855   - // desactivate editor in case of TIME plot_type
856   - return false;
857   - }
858   -
859   - //TODO temporary!!! wait for new kernel; desactivate Plot_Type if parameter 'needsArs' or is 'not scattarable'
860   - if (object.colIdx == 2 && object.record.childNodes.length > 0) {
861   - var isScatter = true;
862   - Ext.Array.each(object.record.childNodes, function(item){
863   - if (item.get('needsArgs') || !item.get('isScatter')) {
864   - isScatter = false;
865   - Ext.Msg.alert('Warning', 'Scatter mode cannot be applied to '+item.get('name'));
866   - return false;
867   - }
868   - });
869   - return isScatter;
870   - }
871   - }
872   - },
873   - edit: function(editor,object){
874   - if (object.field == 'plotType'){
875   - if (object.value != object.originalValue){
876   - // 'SCATTER' selection
877   - if (object.value == amdaModel.PlotPanel.PLOT_TYPES[1].value){
878   - // if we're already waiting for scatter param
879   - if (this.addParamMode == amdaModel.PlotPanel.ADD_PARAM_MODE[1]) {
880   - Ext.Msg.alert('Warning', 'Panel '+ this.getPanelIndex(this.waitingScatterPanel) +' is already waiting for a scatter parameter!');
881   - object.record.set('plotType',amdaModel.PlotPanel.PLOT_TYPES[0].value);
882   - this.plotTree.getView().refresh();
883   - return false;
884   - } else {
885   - // erase X title
886   - object.record.set('xTitle','');
887   - // mode addScatterParam
888   - this.addParamMode=amdaModel.PlotPanel.ADD_PARAM_MODE[1];
889   - // set waitingScatterPanel
890   - this.waitingScatterPanel=object.record;
891   - }
892   -
893   - } else { // 'TIME' selection
894   - // if is in waiting mode for this panel
895   - if (this.waitingScatterPanel == object.record){
896   - // end of waiting mode
897   - this.addParamMode = amdaModel.PlotPanel.ADD_PARAM_MODE[0];
898   - this.waitingScatterPanel = null;
899   - }
900   - // set X title
901   - object.record.set('xTitle',object.value);
902   - object.record.set('width',1);
903   - }
904   - }
905   - }
906   -
907   - }
908   - }
909   - });
910   -
911   - var treeStore = Ext.create('Ext.data.TreeStore', {
912   - model: 'amdaModel.PlotObject',
913   - data : this.object,
914   - proxy: {
915   - type: 'memory',
916   - reader: {
917   - type: 'plot'
918   - }
919   - }
920   - });
921   -
922   -
923   - this.plotTree = Ext.create('Ext.tree.Panel', {
924   - store : treeStore,
925   - flex: 3,
926   - scroll: 'both',
927   - selType: 'treemodel',
928   - allowDeselect : true,
929   - rootVisible: false,
930   - viewConfig:{
931   - plugins:{
932   - ptype:'treeviewdragdrop',
933   - ddGroup:'explorerTree',
934   - enableDrag:true,
935   - enableDrop:true,
936   - appendOnly : false,
937   - allowContainerDrops : true,
938   - containerScroll : true,
939   - isValidDropPoint : function (node, position, dragZone, e, data)
940   - {
941   - if (!node || !data.item) {
942   - return false;
943   - }
944   -
945   - var view = this.view,
946   - targetNode = view.getRecord(node),
947   - draggedRecords = data.records,
948   - dataLength = draggedRecords.length,
949   - ln = draggedRecords.length,
950   - i, record;
951   - // No drop position, or dragged records: invalid drop point
952   - if (!(targetNode && position && dataLength)) {
953   - return false;
954   - }
955   -
956   - // If the targetNode is within the folder we are dragging
957   - for (i = 0; i < ln; i++) {
958   - record = draggedRecords[i];
959   - if (record.isNode && record.contains(targetNode)) {
960   - return false;
961   - }
962   - }
963   -
964   - // Respect the allowDrop field on Tree nodes
965   - if (position === 'append' && targetNode.get('allowDrop') === false) {
966   - return false;
967   - }
968   -
969   - // If the target record is in the dragged dataset, then invalid drop
970   - if (Ext.Array.contains(draggedRecords, targetNode)) {
971   - return false;
972   - }
973   -
974   - if (dataLength > 1)
975   - return false;
976   - var draggedRecord = draggedRecords[0];
977   -
978   - return me.isValidToDrop(draggedRecord,targetNode,position);
979   - },
980   - onPlotContainerDrop : function(dd, e, data){
981   - if (data.records.length != 1)
982   - return false;
983   - return me.dropRecord(data.records[0],null,null);
984   - },
985   - onPlotNodeDrop : function(n, dd, e, data){
986   - if (data.records.length != 1)
987   - return false;
988   - return me.dropRecord(data.records[0],this.view.getRecord(n),this.getPosition(e,n));
989   - },
990   - onPlotContainerOver : function(dd, e, data) {
991   - if (data.records.length != 1)
992   - return false;
993   - var draggedRecord = data.records[0];
994   - return me.isValidToDrop(draggedRecord,null,'append') ? this.dropAllowed : this.dropNotAllowed;
995   - },
996   - onViewRender : function(view) {
997   - var me = this;
998   -
999   - if (me.enableDrag) {
1000   - me.dragZone = Ext.create('Ext.tree.ViewDragZone', {
1001   - view: view,
1002   - ddGroup: me.dragGroup || me.ddGroup,
1003   - dragText: me.dragText,
1004   - repairHighlightColor: me.nodeHighlightColor,
1005   - repairHighlight: me.nodeHighlightOnRepair
1006   - });
1007   - }
1008   -
1009   - if (me.enableDrop) {
1010   - me.dropZone = Ext.create('Ext.tree.ViewDropZone', {
1011   - view: view,
1012   - ddGroup: me.dropGroup || me.ddGroup,
1013   - allowContainerDrops: me.allowContainerDrops,
1014   - appendOnly: me.appendOnly,
1015   - allowParentInserts: me.allowParentInserts,
1016   - expandDelay: me.expandDelay,
1017   - dropHighlightColor: me.nodeHighlightColor,
1018   - dropHighlight: me.nodeHighlightOnDrop,
1019   - isValidDropPoint : me.isValidDropPoint,
1020   - onContainerDrop : me.onPlotContainerDrop,
1021   - onNodeDrop : me.onPlotNodeDrop,
1022   - onContainerOver : me.onPlotContainerOver
1023   - });
1024   - }
1025   - }
1026   - },
1027   - toggleOnDblClick: false,
1028   - stripeRows: false,
1029   - getRowClass: function(record, rowIndex){
1030   - return record.getRowClass();
1031   - }
1032   - },
1033   - lines: false,
1034   - columns: this.getPlotTreeColumns(),
1035   - bodyBorder: true,
1036   - autoScroll: true,
1037   - dockedItems: [{
1038   - xtype: 'toolbar',
1039   - items: [{
1040   - iconCls: 'icon-add',
1041   - text: 'Add Panel',
1042   - scope: this,
1043   - tooltip: 'add Panel to this Plot',
1044   - handler: function(){
1045   - // Create a new record instance
1046   - var recEmptyParam = this.addPanel();
1047   - if (recEmptyParam)
1048   - {
1049   - var selModel = this.plotTree.getSelectionModel();
1050   - selModel.select(recEmptyParam);
1051   - }
1052   - }
1053   - }, {
1054   - iconCls: 'icon-delete',
1055   - text: 'Remove Panel',
1056   - itemId: 'delete',
1057   - tooltip: 'remove selected Panel from this Plot',
1058   - scope: this,
1059   - handler: function(){
1060   - // if there's a selectedRow (in tree)
1061   - var selModel = this.plotTree.getSelectionModel();
1062   - if (selModel.hasSelection()) {
1063   - var selectedRow = selModel.getSelection()[0];
1064   - if (selectedRow.get('leaf'))
1065   - selectedRow = selectedRow.parentNode;
1066   - }
1067   - if (selectedRow)
1068   - this.removePanel(selectedRow);
1069   - }
1070   - }, '->',
1071   - {
1072   - xtype : 'checkbox', boxLabel: 'AutoLayout&nbsp;<img amda_clicktip="autoLayout" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
1073   - name: 'forcedlLayout', checked: false,
1074   - scope: this,
1075   - handler: function(box, checked){
1076   - this.forcedLayout = checked;
1077   - }
1078   - },'', {
1079   - xtype : 'checkbox', boxLabel: 'AutoScale&nbsp;<img amda_clicktip="autoScale" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
1080   - name: 'forcedlMulti', checked: false,
1081   - scope: this,
1082   - handler: function(box, checked){
1083   - this.forcedMulti = checked;
1084   - }
1085   - }
1086   - ]
1087   - }
1088   - ],
1089   - plugins: [ treeGridCellEditing, {ptype: 'headertooltip'}, {ptype: 'paramEditorPlugin', pluginId: 'paramEditorPlugin'+this.id}]
1090   - });
1091   -
1092   - // this call is not needed - for documentation purposes only
1093   - this.plotTree.addEvents('edition', 'openParamEditor');
1094   -
1095   - // cell click actions : delete, edit, openPlug
1096   - this.plotTree.on('cellclick', function(view, el, columnIndex, record){
1097   - // param & panel arguments PLUGIN
1098   - if ( (columnIndex == 9 && !record.isLeaf()) ||
1099   - (columnIndex == 10 && record.isLeaf()) ) {
1100   - this.plotTree.fireEvent('openParamEditor',record);
1101   - }
1102   - else if (columnIndex == 11 && record.isLeaf()) {
1103   - if (!record.get('yaxe')) record.set('yaxe',true);
1104   - else record.set('yaxe', false);
1105   - }
1106   - // param remover
1107   - else if (columnIndex === 0) {
1108   - // select the clicked record
1109   - //this.selectedRow = record;
1110   - var selModel = this.plotTree.getSelectionModel();
1111   -
1112   - // if record is defined
1113   - if (record) {
1114   - var plugin = this.plotTree.getPlugin('paramEditorPlugin'+this.id);
1115   - // if plot parameter deletion
1116   - if (record.isLeaf()){
1117   - // get parent panel
1118   - var panelParent = record.parentNode;
1119   - // remove record
1120   - selModel.deselect(record);
1121   -
1122   - //if args plugin is open and is connected to removed record : close plugin
1123   - if (plugin && plugin.record && (plugin.record.get('id') == record.get('id'))) {
1124   - plugin.win.close();
1125   - }
1126   - record.remove();
1127   -
1128   - // if parent panel has no child anymore
1129   - if (panelParent && !panelParent.hasChildNodes()){
1130   - // remove parent panel too
1131   - this.removePanel(panelParent);
1132   - }
1133   - }
1134   - // else (plot panel deletion)
1135   - else
1136   - // if the panel to delete is not empty
1137   - this.removePanel(record);
1138   - }
1139   - }
1140   - // otherwise EDITION
1141   - else {
1142   - //select record to use in Scatter Reset
1143   - if (columnIndex == 2) {
1144   - this.selectedRow = record;
1145   - }
1146   - this.plotTree.fireEvent('edition', view, record, columnIndex);
1147   - }
1148   - },this);
1149   -
1150   - //Important! we need to have here 5 different TimeSelectors!!! RadioGroup Manager - singleton, searching items by NAME!!!
1151   - this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelector' + config.id, flex: 1 } );
1152   -
1153   - this.fieldName = new Ext.form.field.Text({
1154   - labelWidth: 90,
1155   - fieldLabel: 'Request Name',
1156   - allowBlank : false,
1157   - name : 'name',
1158   - validFlag: false,
1159   - validator : function() {
1160   - return this.validFlag;
1161   - },
1162   - validateOnChange : false,
1163   - validateOnBlur : false,
1164   - stripCharsRe: /(^\s+|\s+$)/g
1165   - });
  86 + // fire execution
  87 + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
  88 + if (plotModule)
  89 + plotModule.linkedNode.execute();
  90 + },
1166 91  
1167   - var orientation = [['landscape','LANDSCAPE'], ['portrait', 'PORTRAIT']];
1168   - var format = [['PNG','PNG'], ['PDF', 'PDF'], ['PS', 'PostScript']];
  92 + /**
  93 + * Check if changes were made before closing window
  94 + * @return false
  95 + */
  96 + fclose : function() {
  97 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
  98 + module.closeInteractiveSession();
  99 + });
  100 +
  101 + return false;
  102 + },
1169 103  
1170   - this.formPanel = new Ext.form.Panel({
1171   - region: 'center',
1172   - buttonAlign: 'left',
1173   - bodyStyle: { background : '#dfe8f6' },
1174   - border: false,
1175   - trackResetOnLoad: true, //reset to the last loaded record
1176   - layout: {type: 'vbox', align: 'stretch',
1177   - defaultMargins: {top:0, left:5, bottom:0, right:5}},
1178   - items : [
1179   - this.plotTree,
1180   - {
1181   - flex: 2,
1182   - xtype: 'container',
1183   - layout: {type: 'hbox', align: 'stretch',
1184   - defaultMargins: {top:8, left:8, bottom:0, right:5}},
1185   - items: [
1186   - this.timeSelector,
1187   - {
1188   - xtype: 'container', flex: 1,
1189   - defaults: {labelWidth: 90 },
1190   - layout: {type: 'vbox', align: 'stretch'},
1191   - items : [
1192   - {
1193   - xtype: 'textfield',
1194   - fieldLabel: 'Plot Title',
1195   - name: 'title',
1196   - disabled: true
1197   - },
1198   - {
1199   - xtype: 'numberfield',
1200   - fieldLabel: 'Char Size',
1201   - allowBlank: false,
1202   - validateOnChange: false, validateOnBlur: false,
1203   - name: 'charSize',
1204   - minValue: 0.5,
1205   - decimalPrecision: 1,
1206   - step: 0.1
1207   - },
1208   - {
1209   - xtype: 'combo',
1210   - fieldLabel: 'Orientation',
1211   - name: 'orientation',
1212   - store: orientation,
1213   - queryMode: 'local',
1214   - editable: false
1215   - },
1216   - {
1217   - xtype: 'textfield',
1218   - name: 'description',
1219   - xtype: 'textarea',
1220   - fieldLabel:'Description',
1221   - height: 40
1222   - }
1223   - ]
1224   - },
1225   - {
1226   - xtype: 'container', flex:1,
1227   - defaults: { labelWidth: 90 },
1228   - layout: {type: 'vbox', align: 'stretch'},
1229   - items: [
1230   - {
1231   - xtype: 'textfield',
1232   - fieldLabel: 'Plot File Name',
1233   - name: 'outputName'
1234   - },
1235   - {
1236   - xtype: 'numberfield',
1237   - fieldLabel: 'Line Thickness',
1238   - minValue: 1,
1239   - allowBlank: false,
1240   - validateOnChange: false, validateOnBlur: false,
1241   - name: 'thickness',
1242   - step: 1
1243   - },
1244   - {
1245   - xtype: 'combo',
1246   - fieldLabel: 'File Format',
1247   - name: 'format',
1248   - store : format,
1249   - queryMode: 'local',
1250   - editable: false
1251   - },
1252   - {
1253   - xtype: 'numberfield',
1254   - name: 'ppp',
1255   - step: 1000,
1256   - fieldLabel:'Points per Plot',
1257   - minValue : 1000,
1258   - maxValue : 10000,
1259   - value : 3000
1260   -
1261   - },
1262   - { xtype : 'component', flex: 0.1 },
1263   - this.fieldName
1264   - ]
1265   - }
1266   - ]
1267   - }],
1268   - fbar:[
1269   - {
1270   - text: 'Plot',
1271   - width: 75,
1272   - scope : this,
1273   - handler: function (button) {
1274   - // update object with user's values with name field validation
1275   - // if the return is true (object had been updated)
1276   - if(this.updateObject()){
1277   - this.doPlot();
1278   - }
1279   - }
1280   - },{
1281   - text: 'Get Data',
1282   - width: 75,
1283   - scope : this,
1284   - handler: function () {
1285   - // update object with user's values with name field validation
1286   - // if the return is true (object had been updated)
1287   - if(this.updateObject()){
1288   - var downObject = amdaModel.DownloadNode.decodeObject(this.object);
1289   - amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject));
1290   - amdaModel.DownloadNode.editInModule();
1291   - }
1292   - }
1293   - },
1294   - {
1295   - text: 'Reset',
1296   - width: 75,
1297   - scope : this,
1298   - handler: function () {
1299   - this.formPanel.getForm().reset();
1300   - this.plotTree.getRootNode().removeAll();
1301   - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
1302   - plotModule.createLinkedNode();
1303   - plotModule.createObject();
1304   - this.setObject(plotModule.linkedNode.get('object'));
1305   - plotModule.addLinkedNode(plotModule.linkedNode, this.id);
1306   - }
1307   - },'->',
1308   - {
1309   - text: 'Save Request',
1310   - width: 80,
1311   - scope : this,
1312   - handler: function () {
1313   - // update object with user's values with name field validation
1314   - // if the return is true (object had been updated)
1315   - if(this.updateObject()){
1316   -
1317   - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
1318   - if (!plotModule)
1319   - return;
1320   - var me = this;
1321   - plotModule.linkedNode.isValidName(this.fieldName.getValue(), function (res) {
1322   - if (!res)
1323   - {
1324   - me.fieldName.validFlag = 'Error during object validation';
1325   - myDesktopApp.errorMsg(me.fieldName.validFlag);
1326   - me.fieldName.validate();
1327   - return;
1328   - }
1329   -
1330   - if (!res.valid)
1331   - {
1332   - if (res.error)
1333   - {
1334   - if (res.error.search('subtree') != -1) {
1335   - Ext.MessageBox.show({title:'Warning',
1336   - msg: res.error+'<br/>Do you want to overwrite it?',
1337   - width: 300,
1338   - buttons: Ext.MessageBox.OKCANCEL,
1339   - fn : me.overwriteProcess,
1340   - icon: Ext.MessageBox.WARNING,
1341   - scope : me
1342   - });
1343   - me.fieldName.validFlag = true;
1344   - }
1345   - else
1346   - me.fieldName.validFlag = res.error;
1347   - }
1348   - else
1349   - {
1350   - me.fieldName.validFlag = 'Invalid object name';
1351   - myDesktopApp.errorMsg(me.fieldName.validFlag);
1352   - }
1353   - me.fieldName.validate();
1354   - return;
1355   - }
1356   -
1357   - me.fieldName.validFlag = true;
1358   - me.fieldName.validate();
1359   - me.saveProcess(false);
1360   - });
1361   - }
1362   - }
1363   - }
1364   - ]
1365   - });
1366   -
1367   - var myConf = {
1368   - layout: 'border',
1369   - defaults: { layout: 'fit', border: false },
1370   - items: [
1371   - this.formPanel
1372   - ],
1373   - listeners: {
1374   - scope : this,
1375   - activate: function(comp) {
1376   - if (!this.object && this.id != 'plot1'){
1377   - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
1378   - // open empty form
1379   -
1380   - plotModule.createLinkedNode();
1381   - plotModule.createObject();
1382   -// add linked node to the array of nodes and set object to UI (TabPlotUI)
1383   - this.setObject(plotModule.linkedNode.get('object'));
1384   - plotModule.addLinkedNode(plotModule.linkedNode, this.id);
1385   - }
1386   - },
1387   - click: {
1388   - element: 'el',
1389   - fn: function(e,t) {
1390   - var me = t,
1391   - text = me.getAttribute('amda_clicktip');
1392   - if (text) {
1393   - e.preventDefault();
1394   - AmdaAction.getInfo({name : text}, function(res,e) {
1395   - if (res.success) myDesktopApp.infoMsg(res.result);
1396   - });
1397   - }
1398   - }
1399   - }
1400   - }
1401   - };
1402   -
1403   - Ext.apply (this , Ext.apply (arguments, myConf));
1404   - }
1405   -
1406   -});
1407   -
1408   -Ext.define( 'TreeGridCellEditor', {
1409   - extend: 'Ext.grid.plugin.CellEditing',
1410   - alias: 'editing.treegrideditor',
1411   - // initialization method of plugin
1412   - init: function(cmp) {
1413   - var me = this;
1414   - me.hostCmp = cmp;
1415   - // on parent event
1416   - me.hostCmp.on({
1417   - // on edition event
1418   - edition : {
1419   - delay: 50,
1420   - fn : function(view, record, colIndex){
1421   - var selModel = me.hostCmp.getSelectionModel(),
1422   - columnHeader = me.hostCmp.headerCt.getHeaderAtIndex(colIndex);
1423   - // call the start edition method
1424   - me.startEdit(record, columnHeader);
1425   - },
1426   - scope: me
1427   - }
1428   - });
1429   - me.callParent(arguments);
1430   - },
1431   -
1432   - /**
1433   - * Cancel any active editing.
1434   - */
1435   - cancelEdit: function() {
1436   - var me = this,
1437   - activeEd = me.getActiveEditor(),
1438   - viewEl = me.grid.getView().getEl(me.getActiveColumn());
  104 + addTT : function(newTTName,newTTid)
  105 + {
  106 + this.timeSelector.addTT(newTTName,newTTid);
  107 + },
1439 108  
1440   - me.setActiveEditor(null);
1441   - me.setActiveColumn(null);
1442   - me.setActiveRecord(null);
1443   - if (activeEd) {
1444   - activeEd.cancelEdit();
1445   - viewEl.focus();
1446   - }
1447   - // if an editor is active and has 'new Folder' as startValue
1448   - if (activeEd && activeEd.startValue===amdaModel.AmdaNode.NEW_DIR_NAME) {
1449   - var editedNode = this.hostCmp.getSelectionModel().selected.items[0];
1450   - // if there is a selected Node without computed id
1451   - if (editedNode && !editedNode.get('id')) {
1452   - // remove it
1453   - editedNode.remove(true);
1454   - }
1455   - }
  109 + addTTs : function(TTarray) {
  110 + // set TTTab
  111 + this.timeSelector.setTTTab(TTarray);
1456 112 },
1457 113  
1458 114 /**
1459   - * overwrite the initEditTriggers to disable edition on click/dblclick
1460   - * and to add custom
1461   - */
1462   - initEditTriggers: function() {
1463   -
1464   - var me = this,
1465   - view = me.view;
1466   - // enable Enter key and Esc Key
1467   - view.on('render', function() {
1468   - me.keyNav = Ext.create('Ext.util.KeyNav', view.el, {
1469   - enter: me.onEnterKey,
1470   - esc: me.onEscKey,
1471   - scope: me
1472   - });
1473   - }, me, { single: true });
1474   - },
1475   -
1476   - /**
1477   - * @private
1478   - * Collects all information necessary for any subclasses to perform their editing functions.
1479   - * @param record
1480   - * @param columnHeader
1481   - * @returns {Object} The editing context based upon the passed record and column
1482   - */
1483   - getStandardEditingContext: function(record, columnHeader) {
1484   - var me = this,
1485   - grid = me.grid,
1486   - store = grid.store,
1487   - rowIdx,
1488   - colIdx,
1489   - view = grid.getView(),
1490   - value;
1491   -
1492   - // If they'd passed numeric row, column indices, look them up.
1493   - if (Ext.isNumber(record)) {
1494   - rowIdx = record;
1495   - record = store.getAt(rowIdx);
1496   - } else {
1497   - rowIdx = store.indexOf(record);
1498   - }
1499   - if (Ext.isNumber(columnHeader)) {
1500   - colIdx = columnHeader;
1501   - columnHeader = grid.headerCt.getHeaderAtIndex(colIdx);
1502   - } else {
1503   - colIdx = columnHeader.getIndex();
1504   - }
1505   -
1506   - value = record.get(columnHeader.dataIndex);
1507   - return {
1508   - grid: grid,
1509   - record: record,
1510   - field: columnHeader.dataIndex,
1511   - value: value,
1512   - row: view.getNode(rowIdx),
1513   - column: columnHeader,
1514   - rowIdx: rowIdx,
1515   - colIdx: colIdx,
1516   - view: columnHeader.getOwnerHeaderCt().view
1517   - };
  115 + * Set Start-Stop from parameter info (Local & MyData)
  116 + */
  117 + setTimeFromData : function(obj)
  118 + {
  119 + var dateStart = new Date(obj.start.replace(/[T|Z]/g,' ').replace(/\-/g,'\/'));
  120 + var dateStop = new Date(obj.stop.replace(/[T|Z]/g,' ').replace(/\-/g,'\/'));
  121 +
  122 + this.timeSelector.intervalSel.setInterval(dateStart, dateStop);
  123 + this.timeSelector.intervalSel.updateDuration();
1518 124 },
1519   -
1520   - //overwrite the getEditing context because we do not need the rowId
1521   - getEditingContext: function(record, columnHeader) {
1522   - var me = this,
1523   - grid = me.grid,
1524   - store = grid.store,
1525   - colIdx,
1526   - view = grid.getView(),
1527   - value;
1528   -
1529   - // getting colIdx and real columnHeader
1530   - if (Ext.isNumber(columnHeader)) {
1531   - colIdx = columnHeader;
1532   - columnHeader = grid.headerCt.getHeaderAtIndex(colIdx);
1533   - } else {
1534   - colIdx = columnHeader.getIndex();
1535   - }
1536   - // getting current value
1537   - value = record.get(columnHeader.dataIndex);
  125 +
  126 + init : function(config) {
  127 + this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelector' + config.id, flex: 1} );
  128 +
  129 + this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 2});
  130 +
  131 + this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 3});
1538 132  
1539   - // return editing context
1540   - return {
1541   - grid: grid,
1542   - record: record,
1543   - field: columnHeader.dataIndex,
1544   - value: value,
1545   - column: columnHeader,
1546   - colIdx: colIdx,
1547   - view: columnHeader.getOwnerHeaderCt().view
1548   - };
1549   - }
1550   -});
  133 + this.plotTabs = new amdaPlotComp.PlotTabPanel({flex: 2, plotElementPanel : this.plotElement});
  134 +
  135 + this.optionsPanel = new Ext.form.Panel({
  136 + layout: {
  137 + type: 'vbox',
  138 + pack: 'start',
  139 + align: 'stretch'
  140 + },
  141 + bodyStyle: { background : '#dfe8f6' },
  142 + defaults: {
  143 + border: false
  144 + },
  145 + items: [
  146 + this.plotElement,
  147 + this.plotOutput
  148 + ]
  149 + });
  150 +
  151 + this.formPanel = new Ext.form.Panel({
  152 + region: 'center',
  153 + layout: {
  154 + type: 'hbox',
  155 + pack: 'start',
  156 + align: 'stretch'
  157 + },
  158 + bodyStyle: { background : '#dfe8f6' },
  159 + defaults: {
  160 + border: false
  161 + },
  162 + items: [
  163 + {
  164 + xtype : 'panel',
  165 + layout: {
  166 + type: 'vbox',
  167 + pack: 'start',
  168 + align: 'stretch'
  169 + },
  170 + bodyStyle: { background : '#dfe8f6' },
  171 + defaults: {
  172 + border: false
  173 + },
  174 + flex: 1,
  175 + items: [
  176 + this.plotTabs,
  177 + this.timeSelector
  178 + ]
  179 + },
  180 + {
  181 + xtype : 'panel',
  182 + layout: 'fit',
  183 + bodyStyle: { background : '#dfe8f6' },
  184 + defaults: {
  185 + border: false
  186 + },
  187 + flex: 1,
  188 + items: [
  189 + this.optionsPanel
  190 + ]
  191 + }
  192 + ],
  193 + fbar: [
  194 + {
  195 + xtype: 'button',
  196 + text: 'Plot',
  197 + scope: this,
  198 + handler: function(button) {
  199 + this.doPlot();
  200 + }
  201 + },
  202 + ' ',
  203 + {
  204 + xtype: 'button',
  205 + text: 'Get Data',
  206 + scope: this,
  207 + handler: function(button) {
  208 + this.getDataProcess();
  209 + }
  210 + },
  211 + ' ',
  212 + {
  213 + xtype: 'button',
  214 + text: 'Reset',
  215 + scope: this,
  216 + handler: function(button) {
  217 + this.resetProcess();
  218 + }
  219 + },
  220 + '->',
  221 + {
  222 + xtype: 'button',
  223 + text: 'Save Request',
  224 + scope: this,
  225 + handler: function(button) {
  226 + this.saveProcess();
  227 + }
  228 + }
  229 + ]
  230 + });
  231 +
  232 + var myConf = {
  233 + layout: 'border',
  234 + items: [
  235 + this.formPanel,
  236 + {
  237 + xtype: 'panel',
  238 + region: 'south',
  239 + title: 'Information',
  240 + collapsible: true,
  241 + height: 100,
  242 + autoHide: false,
  243 + bodyStyle: 'padding:5px',
  244 + iconCls: 'icon-information',
  245 + loader: {
  246 + autoLoad: true,
  247 + url: helpDir+'plotHOWTO'
  248 + }
  249 + }
  250 + ]
  251 + };
  252 + Ext.apply (this , Ext.apply (arguments, myConf));
  253 + }
  254 +});
1551 255 \ No newline at end of file
... ...
js/app/views/ResultUI.js
... ... @@ -50,15 +50,12 @@ Ext.define(&#39;amdaUI.ResultUI&#39;, {
50 50 if (!format) format = 'unknown';
51 51 var compression = linkedNode.get('object').get('compression');
52 52 if (!compression) compression = 'unknown';
53   - var plotTab = linkedNode.get('tabId');
54   - if (!plotTab) plotTab = 'unknown';
55 53  
56 54 //TODO args as object ???
57 55 panelResult.addResult(
58 56 linkedNode.get('text'),
59 57 linkedNode.get('object').get('resultId'),
60 58 linkedNode.get('object').get('folderId'),
61   - plotTab,
62 59 compression.toLowerCase(),
63 60 format.toLowerCase(),
64 61 linkedNode.get('id'));
... ...
js/app/views/TabPlotUI.js deleted
... ... @@ -1,109 +0,0 @@
1   -/**
2   - * Project  : AMDA-NG
3   - * Name : TabPlotUI.js
4   - * @class amdaUI.TabPlotUI
5   - * @extends Ext.
6   - * @brief Plot Formular Module UI definition (View)
7   - * @author
8   - * @version $Id: TabPlotUI.js 2622 2014-11-07 14:50:09Z elena $
9   - ********************************************************************************
10   - * FT Id : Date : Name - Description
11   - *******************************************************************************
12   - *
13   - */
14   -
15   -Ext.define('amdaUI.TabPlotUI', {
16   - extend: 'Ext.container.Container',
17   - alias: 'widget.tabPlot',
18   -
19   - requires: [
20   - 'amdaUI.PlotUI',
21   - 'amdaModel.PlotParam',
22   - 'amdaModel.PlotPanel'
23   - ],
24   -
25   - constructor: function(config) {
26   - this.init(config);
27   - this.callParent(arguments);
28   - },
29   -
30   - getTabPlot: function() {
31   -
32   - return 0;
33   - },
34   -
35   - addTT : function(newTTName,newTTid){
36   - this.tabPanel.getActiveTab().addTT(newTTName,newTTid);
37   - },
38   -
39   - addTTs : function(TTarray) {
40   - // set TTTab
41   - this.tabPanel.getActiveTab().addTTs(TTarray);
42   - },
43   -
44   - /**
45   - * Set Start-Stop from parameter info (Local & MyData)
46   - */
47   - setTimeFromData : function(obj)
48   - {
49   - var dateStart = new Date(obj.start.replace(/[T|Z]/g,' ').replace(/\-/g,'\/'));
50   - var dateStop = new Date(obj.stop.replace(/[T|Z]/g,' ').replace(/\-/g,'\/'));
51   -
52   - this.tabPanel.getActiveTab().down('form').getForm().setValues({ startDate : dateStart, stopDate : dateStop });
53   - this.tabPanel.getActiveTab().timeSelector.intervalSel.updateDuration();
54   - },
55   -
56   - setObject: function(obj){
57   - this.tabPanel.getActiveTab().object = obj;
58   - this.tabPanel.getActiveTab().loadObject();
59   - },
60   -
61   - updateConstruct : function(oldval,newval)
62   - {
63   - Ext.Array.each(this.tabPanel.items.items, function(item){
64   - item.updateConstruct(oldval, newval);
65   - }, this);
66   -
67   - },
68   -
69   - init : function(config)
70   - {
71   - this.tabPanel = Ext.create('Ext.tab.Panel',{
72   - region: 'center',
73   - layout: { type :'vbox' },
74   - activeTab: 0,
75   - items : [
76   - Ext.create(amdaUI.PlotUI,{title: 'Plot 1', id : 'plot1'}),
77   - Ext.create(amdaUI.PlotUI,{title: 'Plot 2', id : 'plot2'}),
78   - Ext.create(amdaUI.PlotUI,{title: 'Plot 3', id : 'plot3'}),
79   - Ext.create(amdaUI.PlotUI,{title: 'Plot 4', id : 'plot4'}),
80   - Ext.create(amdaUI.PlotUI,{title: 'Plot 5', id : 'plot5'})
81   - ]
82   - });
83   -
84   -
85   - var myConf = {
86   - layout: 'border',
87   - defaults: { layout: 'fit', border: false },
88   - items: [
89   - this.tabPanel,
90   - {
91   - xtype: 'panel', region: 'south',
92   - title: 'Information',
93   - bodyStyle: 'padding:5px',
94   - collapsible: true,
95   - height: 100,
96   - autoHide: false,
97   - iconCls: 'icon-information',
98   - loader: {
99   - autoLoad: true,
100   - url: helpDir+'plotHOWTO'
101   - }
102   - }
103   - ]
104   - };
105   -
106   - Ext.apply (this , Ext.apply (arguments, myConf));
107   - }
108   -
109   -});
js/app/views/TabResultUI.js
... ... @@ -78,8 +78,8 @@ Ext.define(&#39;amdaUI.TabResultUI&#39;, {
78 78 Ext.apply(this, newConfig);
79 79 },
80 80  
81   - addResult: function(resultName, resultId, folderId, plotTab, compression, format, processId) {
82   - this.insert(0,[ {xtype : 'resultItem', type : this.type, title: resultName, plotTab : plotTab, folderId: folderId, resultId: resultId, compress : compression, format: format, processId: processId}]);
  81 + addResult: function(resultName, resultId, folderId, compression, format, processId) {
  82 + this.insert(0,[ {xtype : 'resultItem', type : this.type, title: resultName, folderId: folderId, resultId: resultId, compress : compression, format: format, processId: processId}]);
83 83 }
84 84 });
85 85  
... ... @@ -186,26 +186,14 @@ Ext.define(&#39;amdaUI.ResultItem&#39;, {
186 186 },
187 187  
188 188 initConfig: function(config){
189   - // Show title only for finished jobs
190   - if (Ext.util.Format.substr(config.title,0,2) === 'DD') {
191   - var jobtitle = config.plotTab? 'PlotTab_'+ config.plotTab : '' ;
192   - }
193   - else {
194   - var jobtitle = config.title;
195   - }
  189 + var jobtitle = config.title;
196 190  
197 191 switch (config.type) {
198 192  
199 193 case 'request' :
200   - if (config.format == 'unknown')
201   - config.format = 'png';
202   - var suffix = config.format;
203   - if (config.format != 'png')
204   - //auto compression
205   - suffix += '.tar.gz';
206   - var plotId = config.resultId;
  194 + var resultId = config.resultId;
207 195 var folderId = config.folderId;
208   - var href = 'data/'+sessionID+'/RES/'+ folderId + '/' + plotId + '.'+ suffix;
  196 + var href = 'data/'+sessionID+'/RES/'+ folderId + '/' + resultId;
209 197 break;
210 198 case 'download' :
211 199 //TODO suffix parsing
... ... @@ -297,7 +285,7 @@ Ext.define(&#39;amdaUI.ResultItem&#39;, {
297 285 var configPlot = {
298 286 intId : config.processId,
299 287 height : height,
300   - title : jobtitle + ' ' +config.format,
  288 + title : jobtitle,
301 289 collapsible: true,
302 290 defaultType: 'button',
303 291 items :[
... ...
js/app/views/TimeSelectorUI.js
... ... @@ -118,14 +118,6 @@ Ext.define(&#39;amdaUI.TimeSelectorUI&#39;,
118 118 {
119 119 if (!this.valid) return false;
120 120  
121   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interactive_plot.id);
122   - if (module && module.multiSelector)
123   - {
124   - var targetWin = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id);
125   - targetWin.items.items[0].timeSelector.addTT(data.records[0].get('text'),data.records[0].get('id'));
126   - }
127   - else
128   - {
129 121 var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
130 122 if (!explorerModule)
131 123 return false;
... ... @@ -133,7 +125,6 @@ Ext.define(&#39;amdaUI.TimeSelectorUI&#39;,
133 125 var targetModule = myDesktopApp.getLoadedModule(targetModuleId);
134 126 if (targetModule)
135 127 targetModule.getUiContent().addTT(data.records[0].get('text'),data.records[0].get('id'));
136   - }
137 128 return true;
138 129 }
139 130 });
... ...
php/MultiRequestMgr.php deleted
... ... @@ -1,240 +0,0 @@
1   -<?
2   -/**
3   - * MultiRequestMgr.php
4   - *
5   - * @version $Id: MultiRequestMgr.php 2886 2015-04-29 15:15:46Z myriam $
6   - */
7   -
8   - require 'config.php';
9   - $userDirs = array('USERWSDIR' => 'WS', 'USERREQDIR' => 'REQ', 'USERDATADIR' => 'DATA',
10   - 'USERWORKINGDIR' =>'RES', 'USERTTDIR' => 'TT', 'USERJOBDIR' => 'JOBS');
11   -
12   -
13   - $request = json_decode($argv[1]);
14   - $tempname = $argv[2];
15   - $user = $argv[3];
16   - $IP = $argv[4];
17   - $newname = $argv[5];
18   -
19   - define ("USERDIR", USERPATH."$user/");
20   -
21   - foreach ($userDirs as $key => $val) {
22   - $dir = USERDIR.$val;
23   - define("$key","$dir/");
24   - }
25   -
26   - $reqMgr = new RequestMgr();
27   - $ttMgr = new TimeTableMgr();
28   -
29   - if ($request->nodeType == 'request') copy(USERWORKINGDIR.$tempname.'_/'.$tempname,USERWORKINGDIR.$tempname.'_/request_.list');
30   -
31   -
32   - $timeTables = $request->timeTables;
33   - $i = 0;
34   - $badIntervals = 0;
35   -
36   -// check output file size for download
37   - $fileSize = 0.0;
38   -
39   - foreach ($timeTables as $timeTable) {
40   -
41   - $ttType = (substr($timeTable->id,0,6) == 'shared') ? 'sharedtimeTable' : 'timeTable';
42   -
43   - $tt = $ttMgr->loadIntervalsFromTT($timeTable->id, $ttType);
44   - $intervals = $tt['intervals'];
45   -
46   -//Everything is already ready => just loop over Time Intervals
47   - foreach ($intervals as $interval) {
48   - switch ($request->nodeType) {
49   - case 'condition' :
50   -
51   - if ((strtotime($interval['stop']) - strtotime($interval['start'])) >= $request->sampling * 2.0) {
52   -
53   - $reqMgr->createSearchRequestTime2($interval);
54   - // Run command
55   - $cmd = DDBIN."DD_Search ".$user." ".$IP." ".DDPROJECT." ".DDPROJLIB;
56   - $cmdResult = system($cmd);
57   - // if ($cmdResult === false)
58   - //TODO processError
59   -
60   - if (file_exists(USERTTDIR.$tempname.'.xml'))
61   - rename(USERTTDIR.$tempname.'.xml', USERTTDIR.$tempname.'_'.sprintf("%03d",$i).'.xml');
62   - if (file_exists(USERTTDIR.'Gaps_'.$tempname.'.xml'))
63   - rename(USERTTDIR.'Gaps_'.$tempname.'.xml', USERTTDIR.'Gaps_'.$tempname.'_'.sprintf("%03d",$i).'.xml');
64   - }
65   - else {
66   -//TODO create XML file with bad intervals to add to GAPS
67   - if (!$badIntervalsXml) {
68   - $badIntervalsXml = new DomDocument("1.0");
69   - $badRootElement = $badIntervalsXml->createElement("TimeTable");
70   - $badIntervalsXml->appendChild($badRootElement);
71   - }
72   - $badInt = $badIntervalsXml->createElement('Interval');
73   - $badInt->setAttribute('flag', 'less than 2*samplings');
74   - $badInt->appendChild($badIntervalsXml->createElement('Start',$interval['start']));
75   - $badInt->appendChild($badIntervalsXml->createElement('Stop',$interval['stop']));
76   - $badRootElement->appendChild($badInt);
77   -
78   - $badIntervals++;
79   - }
80   - break;
81   - case 'request' :
82   - $resultDir = USERWORKINGDIR.$tempname.'_/';
83   - copy($resultDir.'request_.list', $resultDir.$tempname);
84   - $reqMgr->updateTime($resultDir.$tempname, $interval);
85   - $cmd = DDBIN."DD_PS ".$tempname." ".$user." ".$IP." ".DDPROJECT." ".DDPROJLIB;
86   - $cmdResult = system($cmd);
87   -
88   - if (file_exists($resultDir.'idl.ps')) {
89   - rename($resultDir.'idl.ps', $resultDir.$tempname.sprintf("_%03d",$i).'.ps');
90   - }
91   - break;
92   - case 'download' :
93   - $resultDir = USERWORKINGDIR.$tempname.'_/';
94   - $reqMgr->updatePrintRequestTime($resultDir, $interval);
95   - $deltaT = strtotime($interval['stop']) - strtotime($interval['start']);
96   - if ($deltaT < $request->sampling) {
97   - $newSampling = $deltaT/2.0;
98   - $reqMgr->updatePrintSampling($resultDir, $newSampling);
99   - }
100   -
101   - $outputFileSize = $reqMgr->estimateOutputFileSize($request, $deltaT);
102   - if ( $outputFileSize + $fileSize < DISK_QUOTA ) {
103   - set_time_limit(3000);
104   - $cmd = DDBIN."DD_Print ".$user." ".$IP." ".DDPROJECT." ".DDPROJLIB;
105   - $cmdResult = system($cmd);
106   - foreach (glob($resultDir."*.txt") as $filename)
107   - if ($filename != $resultDir."header.txt") {
108   - if ($deltaT < $request->sampling*2.0) {
109   - $new_name = str_replace(".txt", "_NONSTANDARD_SAMPLING_".str_replace(".","_",$newSampling)."_".sprintf("%04d",$i).".asc", $filename);
110   - //sampling info
111   - $str = "Sampling Time : ".$newSampling;
112   - system("sed -i '1i\\#".$str."' '".$filename."'");
113   - }
114   - else {
115   - $new_name = str_replace(".txt", "_".sprintf("%04d",$i).".asc", $filename);
116   - }
117   -
118   - rename($filename, $new_name);
119   - $fileSize += filesize($new_name);
120   - }
121   - }
122   - else {
123   - $new_name = "DISK_QUOTA_EXCEEDED_".sprintf("%04d",$i).".asc";
124   - $error = 'Interval '.$i.': '.$interval['start'].' - '.$interval['stop'].' '.' cannot be downloaded'.PHP_EOL.
125   - 'You\'ve exceded the user disk quota'.PHP_EOL.'Decrease time interval OR put it into another Time Table'.PHP_EOL.
126   - 'And don\'t forget to clean up your workspace from time to time';
127   - file_put_contents($resultDir.$new_name, $error);
128   - }
129   - break;
130   - default :
131   - }
132   - $i++;
133   - }
134   - }
135   -//Postprocessing
136   -
137   - switch ($request->nodeType) {
138   - case 'download' :
139   - $resultDir = USERWORKINGDIR.$tempname.'_/';
140   -
141   - //get options
142   - $opts = $reqMgr->getPrintOptions($resultDir);
143   -
144   - //[['0','All In One File'], ['1','One File Per Time Interval'], ['2','One File Per Param/Interval']],
145   - if ($opts['structure'] == '0')
146   - {
147   - //all in one file
148   - exec("cat *.asc > ALL.txt");
149   - //remove asc files
150   - foreach (glob($resultDir."*.asc") as $filename)
151   - unlink($filename);
152   - }
153   - else
154   - {
155   - //rename *.asc files by *.txt
156   - foreach (glob($resultDir."*.asc") as $filename)
157   - {
158   - $new_name = str_replace(".asc", ".txt", $filename);
159   - rename($filename, $new_name);
160   - }
161   - }
162   -
163   - break;
164   - case 'condition' :
165   - $resultDir = USERTTDIR;
166   - $prefix = '';
167   - $buffer = new DomDocument("1.0");
168   - for ($i = 0; $i < 2; $i++) {
169   - $resultTT = new DomDocument("1.0");
170   - $rootElement = $resultTT->createElement("TimeTable");
171   - $rootElement->setAttribute("Name","");
172   -
173   - $rootElement->appendChild($resultTT->createElement("Created", date('F j Y H:i:s')));
174   -
175   - $history = '';
176   - foreach ($timeTables as $timeTable) {
177   - $history = $history." ".$timeTable->timeTableName;
178   - }
179   - $rootElement->appendChild($resultTT->createElement("History", $history));
180   -
181   - /*
182   - $rootElement->appendChild($tempXml->createElement("Chain", htmlentities($_POST['SearchCondition'])));
183   - $csection = htmlentities("AMDA Search: Time_Step ".$_POST['TimeAver'].
184   - " s; Data_absence_is_gap_for_gaps > ".$_POST['Thresh'].
185   - " Data_Sampling_Times; Start_Time: ".$ddStart." Time_Interval: ".$time_int);
186   - $rootElement->appendChild($tempXml->createElement("Source", $csection));
187   - */
188   -
189   - foreach (glob($resultDir.$prefix.$tempname.'_*.xml') as $xml) {
190   - $buffer->load($xml);
191   - $intervals_pp = $buffer->getElementsByTagName('Interval');
192   - foreach ($intervals_pp as $interval_pp) {
193   - $rootElement->appendChild($resultTT->importNode($interval_pp,true));
194   - }
195   - unlink($xml);
196   - }
197   - $resultTT->appendChild($rootElement);
198   - $resultTT->save($resultDir.$prefix.$tempname.'.xml');
199   - $prefix = 'Gaps_';
200   - }
201   -//add bad intervals to GAPS
202   -
203   - if ($badIntervals > 0) {
204   - $resultTT->load($resultDir.'Gaps_'.$tempname.'.xml');
205   - $rootElement = $resultTT->getElementsByTagName('TimeTable')->item(0);
206   - $intervals_bad = $badRootElement->getElementsByTagName('Interval');
207   -
208   - foreach ($intervals_bad as $interval_bad) {
209   - $rootElement->appendChild($resultTT->importNode($interval_bad,true));
210   - }
211   - $resultTT->save($resultDir.'Gaps_'.$tempname.'.xml');
212   - }
213   - break;
214   - case 'request' :
215   - $resultDir = USERWORKINGDIR.$tempname.'_/';
216   - switch ($request->format) {
217   - case 'PS' :
218   - $cmd = "gs -dBATCH -sPAPERSIZE=a4 -dNOPAUSE -q -sDEVICE=pswrite -sOutputFile=".$resultDir."idl.ps ";
219   - foreach (glob($resultDir.$tempname."_*.ps") as $aPS) $cmd .= $aPS." ";
220   - exec($cmd);
221   - exec("gzip ".$resultDir."idl.ps");
222   - rename($resultDir."idl.ps.gz",$resultDir.$newname.".ps.gz");
223   - break;
224   - case 'PDF' :
225   - foreach (glob($resultDir.$tempname."_*.ps") as $aPS) {
226   - exec("ps2pdf -sPAPERSIZE=a4 ".$aPS);
227   - unlink($aPS);
228   - }
229   - $cmd = "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=".$resultDir."idl.pdf ";
230   - foreach (glob($resultDir.$tempname."_*.pdf") as $aPDF) $cmd .= $aPDF." ";
231   - exec($cmd);
232   - break;
233   - default :
234   - }
235   -
236   - break;
237   - default :
238   - }
239   -
240   -?>
php/classes/AmdaAction.php
... ... @@ -1185,8 +1185,7 @@ class AmdaAction {
1185 1185 $myBaseMgr->delSimuFiles('mysimudata');
1186 1186 $myBaseMgr->delSimuFiles('mywsrdata');
1187 1187  
1188   - $jobsMgr = new JobsMgr();
1189   - $jobsMgr->deleteTmp();
  1188 + $this->cleanUserWS();
1190 1189 }
1191 1190 return;
1192 1191 }
... ...
php/classes/AmdaObjectMgr.php
... ... @@ -332,8 +332,6 @@
332 332 }
333 333  
334 334 function getObject($id){}
335   -
336   - function execute($id){}
337 335  
338 336 }
339 337 ?>
... ...
php/classes/JobsMgr.php deleted
... ... @@ -1,489 +0,0 @@
1   -<?php
2   -/**
3   - * @class JobsMgr
4   - * @brief Manage all batch jobs
5   - * @version $Id: JobsMgr.php 2757 2015-02-19 12:15:41Z elena $
6   - *
7   - */
8   -
9   - class JobsMgr {
10   -
11   - protected $jobXml, $jobXmlName;
12   -
13   - protected $bkgRootNode = array('condition' => 'bkgSearch-treeRootNode',
14   - 'request' => 'bkgPlot-treeRootNode',
15   - 'download' => 'bkgDown-treeRootNode');
16   -
17   - protected $resRootNode = array('condition' => 'resSearch-treeRootNode',
18   - 'request' => 'resPlot-treeRootNode',
19   - 'download' => 'resDown-treeRootNode');
20   -
21   - protected $jobPrefix = array( 'condition' => 'bkgrd_cond_',
22   - 'request' => 'bkgrd_req_',
23   - 'download' => 'bkgrd_down_');
24   -
25   - public $success = true;
26   -
27   - function __construct() {
28   -
29   - $this->jobXmlName = USERJOBDIR."jobs.xml";
30   - $this->jobXml = new DomDocument("1.0");
31   -
32   - if (!file_exists($this->jobXmlName)){
33   - $status = $this->generateXml();
34   - if (!$status) {
35   - error_log('Cannot create jobs.xml: Fatal Error',1,email);
36   - $this->success = false;
37   - }
38   - }
39   - else {
40   - $status = $this->jobXml->load($this->jobXmlName);
41   - if (!$status) {
42   - $status = $this->generateXml();
43   - $msg = $status ? 'Cannot load jobs.xml. New jobs.xml was created' :
44   - 'Cannot load jobs.xml. Cannot create jobs.xml: Fatal Error';
45   - error_log($msg,1,email);
46   - if (!$status) $this->success = false;
47   - }
48   - }
49   - }
50   -
51   -/*
52   -* Create jobs.xml if it doesn't exist or in case of loading problems
53   -*/
54   - private function generateXml() {
55   -
56   - $rootElement = $this->jobXml->createElement('jobs');
57   - $jobsInProgress = $this->jobXml->createElement('jobsInProgress');
58   -
59   - foreach ($this->bkgRootNode as $key => $value) {
60   - $element = $this->jobXml->createElement("$key");
61   - $element->setAttribute('xml:id',"$value");
62   - $jobsInProgress->appendChild($element);
63   - }
64   - $jobsFinished = $this->jobXml->createElement('jobsFinished');
65   -
66   - foreach ($this->resRootNode as $key => $value) {
67   - $element = $this->jobXml->createElement("$key");
68   - $element->setAttribute('xml:id',"$value");
69   - $jobsFinished->appendChild($element);
70   - }
71   -
72   - $rootElement->appendChild($jobsInProgress);
73   - $rootElement->appendChild($jobsFinished);
74   - $this->jobXml->appendChild($rootElement);
75   -
76   - $status = $this->jobXml->save($this->jobXmlName);
77   -
78   - return $status;
79   - }
80   -
81   -
82   - //TODO procedure to estimate STATUS
83   - protected function getStatus($pid) {
84   -
85   - return '20';
86   - }
87   -
88   -/*
89   -*
90   -*/
91   - protected function updateJobStatus($pid) {
92   -
93   - if ($this->isFinished($pid)) return 'done';
94   - $status = $this -> getStatus($pid);
95   - return $status;
96   - }
97   -
98   -/*
99   -*
100   -*/
101   - protected function saveResource($obj, $name) {
102   -
103   - $file = fopen(USERJOBDIR.$name, 'w');
104   - //TODO change id and name to job ones?
105   - fwrite($file, json_encode($obj));
106   - fclose($file);
107   - }
108   -
109   - // $obj => XML tag
110   - protected function deleteResource($obj) {
111   - // Delete request
112   - $request_name = $obj->getAttribute('xml:id');
113   - if (file_exists(USERJOBDIR.$request_name)) unlink(USERJOBDIR.$request_name);
114   -
115   - // Delete result Time Table
116   - if ($obj->getAttribute('jobType') == 'condition') {
117   - foreach (glob(USERTTDIR.'*'.$obj->getAttribute('name').'*.xml') as $filename)
118   - unlink($filename);
119   - }
120   -
121   - // Delete result PLOT : PDF and PS
122   - if ($obj->getAttribute('jobType') == 'request' || $obj->getAttribute('jobType') == 'download') {
123   - $resultDir = USERWORKINGDIR.$obj->getAttribute('rawname').'_/';
124   - if (is_dir($resultDir)) {
125   - foreach (glob($resultDir.'*') as $filename)
126   - unlink($filename);
127   - rmdir($resultDir);
128   - }
129   - }
130   - }
131   -
132   - // $obj => XML tag
133   - protected function updateResultName($obj) {
134   -
135   - switch ($obj->getAttribute('jobType'))
136   - {
137   - case 'condition':
138   -
139   - //TODO temporary dir?
140   - $old_tt = USERTTDIR.$obj->getAttribute('rawname').'.xml';
141   - $new_tt = USERTTDIR.$obj->getAttribute('name').'.xml';
142   - if (file_exists($old_tt)) rename($old_tt, $new_tt);
143   -
144   - $old_tt = USERTTDIR.'Gaps_'.$obj->getAttribute('rawname').'.xml';
145   - $new_tt = USERTTDIR.'Gaps_'.$obj->getAttribute('name').'.xml';
146   - if (file_exists($old_tt)) rename($old_tt, $new_tt);
147   - break;
148   -
149   - case 'request' :
150   -
151   - $resultDir = USERWORKINGDIR.$obj->getAttribute('rawname').'_/';
152   - $reqFile = USERJOBDIR.$obj->getAttribute('xml:id');
153   - if (file_exists($reqFile)) {
154   - $object = json_decode(file_get_contents($reqFile));
155   - $format = strtolower($object->format);
156   -
157   - $newName = $obj->getAttribute('name');
158   - switch ($format) {
159   - case 'ps':
160   - if (file_exists($resultDir.'idl.ps')){
161   - rename($resultDir.'idl.ps',$resultDir.$newName.'.ps');
162   - exec('gzip '.$resultDir.$newName.'.ps');
163   - }
164   - //PS for time table
165   - else {
166   - $filenames = glob($resultDir."*.ps.gz");
167   - if ($filenames && count($filenames) == 1) {
168   - rename($filenames[0],$resultDir.$newName.'.ps.gz');
169   - }
170   - }
171   - break;
172   - case 'pdf':
173   - if (file_exists($resultDir.'idl.ps')){
174   - exec('ps2pdf '.$resultDir.'idl.ps '.$resultDir.'idl.pdf');
175   - unlink($resultDir.'idl.ps');
176   - rename($resultDir.'idl.pdf',$resultDir.$newName.'.pdf');
177   - }
178   - // PDF for time tables
179   - if (file_exists($resultDir.'idl.pdf')){
180   - rename($resultDir.'idl.pdf',$resultDir.$newName.'.pdf');
181   - }
182   - break;
183   - case 'png' :
184   - rename($resultDir.$obj->getAttribute('rawname').'.png', $resultDir.$newName.'.png');
185   - break;
186   - default :
187   - }
188   - }
189   - break;
190   -
191   - case 'download' :
192   -
193   - $rawId = $obj->getAttribute('rawname');
194   - $name = $obj->getAttribute('name');
195   -
196   - $reqMgr = new RequestMgr('download');
197   -
198   - $resultDir = USERWORKINGDIR.$rawId.'_/';
199   -
200   - $res = $reqMgr->initResDir($rawId);
201   -
202   - if (!$res['success'])
203   - return $res;
204   - $resultDir = $res['resdir'];
205   -
206   - //get options
207   - $opts = $reqMgr->getPrintOptions($rawId);
208   -
209   - // Start PostProcessing - lock dir from Client Requests
210   - if (!file_exists($resultDir."/POSTPROCESSING"))
211   - touch($resultDir."/POSTPROCESSING");
212   - // Is still PostProcessing - return
213   - else return true;
214   -
215   - $reqMgr->postProcessing($rawId,$name);
216   - if (file_exists($resultDir."/POSTPROCESSING"))
217   - unlink($resultDir."/POSTPROCESSING");
218   - break;
219   -
220   - default :
221   -
222   - }
223   - return false;
224   - }
225   -
226   -/*****************************************************************
227   -* PUBLIC FUNCTIONS
228   -*****************************************************************/
229   -
230   - public function isFinished($PID){
231   -
232   - exec("ps $PID", $ProcessState);
233   - if (count($ProcessState) >= 2 ) return false;
234   -
235   - return true;
236   - }
237   -
238   -/*
239   -*
240   -*/
241   - public function addJob($obj, $pid, $tmpname, $newname) {
242   -
243   - /* [id] => cond_2
244   - [name] => longtest
245   - [sampling] => 60
246   - [gap] => 5
247   - [expression] => imf(0) > 0
248   - [startDate] => 2000-09-27T13:50:51
249   - [durationDay] => 0665
250   - [durationHour] => 12
251   - [durationMin] => 00
252   - [durationSec] => 00
253   - [leaf] => 1
254   - [nodeType] => condition
255   - */
256   -
257   - $newJob = $this->jobXml->createElement('job');
258   -
259   - $newJob->setAttribute('jobType', $obj->nodeType);
260   - $newJob->setAttribute('pid', $pid);
261   - $newJob->setAttribute('start', date('d-m-Y H:i:s'));
262   - if ($pid) {
263   - $newJob->setAttribute('status', $this->getStatus($pid));
264   - $newJob->setAttribute('name', 'job_'.$pid);
265   - }
266   - else {
267   - $newJob->setAttribute('status', 'done');
268   - $newJob->setAttribute('name', $newname);
269   - }
270   -
271   - $newJob->setAttribute('rawname', $tmpname);
272   -
273   - switch ($obj->nodeType)
274   - {
275   - case 'condition':
276   - $newJob->setAttribute('info', $obj->expression);
277   - break;
278   - case 'download' :
279   - $info = '';
280   - foreach ($obj->list as $param)
281   - {
282   - if ($obj->downloadSrc == '2') //fits image
283   - $info = $info.' '.$param->url;
284   - else
285   - $info = $info.' '.$param; //data
286   - }
287   - $newJob->setAttribute('info', $info);
288   - break;
289   - case 'request' :
290   - $info = '';
291   - for ($i=0; $i < count($obj->children); $i++) {
292   - for ($j=0; $j < count($obj->children[$i]->children); $j++) {
293   - $info = $info.' '.$obj->children[$i]->children[$j]->name;
294   - }
295   - }
296   - $newJob->setAttribute('info', $info);
297   - break;
298   - default:
299   - }
300   -
301   - if ($pid) {
302   - $newJob->setAttribute('xml:id',$this->jobPrefix[$obj->nodeType].$pid);
303   - $rootJobNode = $this->jobXml->getElementById($this->bkgRootNode[$obj->nodeType]);
304   - if (!$rootJobNode) {
305   - $key = $obj->nodeType;
306   - $rootJobNode = $this->jobXml->createElement("$key");
307   - $rootJobNode->setAttribute('xml:id', $this->bkgRootNode[$obj->nodeType]);
308   - $jobsInProgress = $this->jobXml->getElementsByTagName('jobsInProgress')->item(0);
309   - $jobsInProgress->appendChild($rootJobNode);
310   - }
311   - }
312   - else {
313   - $newJob->setAttribute('xml:id', $tmpname);
314   - $rootJobNode = $this->jobXml->getElementById($this->resRootNode[$obj->nodeType]);
315   - if (!$rootJobNode) {
316   - $key = $obj->nodeType;
317   - $rootJobNode = $this->jobXml->createElement("$key");
318   - $rootJobNode->setAttribute('xml:id', $this->resRootNode[$obj->nodeType]);
319   - $jobsInProgress = $this->jobXml->getElementsByTagName('jobsFinished')->item(0);
320   - $jobsInProgress->appendChild($rootJobNode);
321   - }
322   - }
323   -
324   - //TODO if status 'error'...
325   - $rootJobNode->appendChild($newJob);
326   - $ok = $this->jobXml->save($this->jobXmlName);
327   -
328   - if ($pid)
329   - $this->saveResource($obj, $newJob->getAttribute('xml:id'));
330   -
331   - return $newJob->getAttribute('xml:id');
332   -
333   - }
334   -
335   -/*
336   -* object : id, leaf, nodeType
337   -*/
338   - public function deleteObject($obj) {
339   -
340   - $job = $this->jobXml->getElementById($obj->id);
341   -
342   - if (!$job) return array('id' => $obj->id);
343   -
344   - $pid = $job->getAttribute('pid');
345   -
346   - // Check if it is temporary result
347   - if ($pid == '0') {
348   -
349   - $resultDir = USERWORKINGDIR.$obj->id.'_';
350   - if (is_dir($resultDir)) {
351   - foreach (glob($resultDir.'/*') as $filename)
352   - unlink($filename);
353   - rmdir($resultDir);
354   - }
355   - //TT temporary
356   - foreach (glob(USERTTDIR.'*'.$obj->id.'*.xml') as $filename)
357   - unlink($filename);
358   -
359   - $job->parentNode->removeChild($job);
360   - $this->jobXml->save($this->jobXmlName);
361   -
362   - return array('id' => $obj->id);
363   - }
364   -
365   - if (!$this->isFinished($pid)) {
366   - $cmd = 'kill -9 '.$pid;
367   - exec($cmd);
368   - }
369   -
370   - $this->deleteResource($job);
371   -
372   - $job->parentNode->removeChild($job);
373   - $this->jobXml->save($this->jobXmlName);
374   -
375   - return array('id' => $obj->id);
376   - }
377   -
378   -/*
379   -*
380   -*/
381   - public function getObject($id) {
382   -
383   - $job = $this->jobXml->getElementById($id);
384   - $format = 'unknown';
385   - $compression = 'unknown';
386   - if($job) {
387   - $rawname = $job->getAttribute('rawname');
388   - if ($job->getAttribute('jobType') == 'request') {
389   - if (file_exists(USERJOBDIR.$id)) {
390   - $obj = json_decode(file_get_contents(USERJOBDIR.$id));
391   - $format = strtolower($obj->format);
392   - };
393   - }
394   - if ($job->getAttribute('jobType') == 'download') {
395   - if (file_exists(USERJOBDIR.$id)) {
396   - $obj = json_decode(file_get_contents(USERJOBDIR.$id));
397   - $compression = strtolower($obj->compression);
398   - };
399   - }
400   - }
401   - return array('id' => $id, 'name' => $rawname, 'format' => $format, 'compression' => $compression);
402   - }
403   -
404   -/*
405   -* Real Update
406   -*/
407   - public function getCurrentJobsStatus() {
408   -
409   - $jobs = $this->jobXml->getElementsByTagName('job');
410   -
411   - foreach ($jobs as $job) {
412   - $pid = $job->getAttribute('pid');
413   - $status = $job->getAttribute('status');
414   -
415   - // Already in Result => do not process
416   - if ($status == 'error' || $status == 'done') {
417   - $stop = $job->getAttribute('stop');
418   - $jobType = $job->getAttribute('jobType');
419   - $status = 'old';
420   - }
421   - else {
422   - $status = $this -> updateJobStatus($pid);
423   - $stop = 'unknown';
424   - $job->setAttribute('status',$status);
425   - $jobType = $job->getAttribute('jobType');
426   -
427   - if ($status == 'error' || $status == 'done') {
428   -
429   - $stop = date('d-m-Y H:i:s');
430   - $job->setAttribute('stop', $stop);
431   - // new array !!! otherwise $jobs array decreased
432   - if ($jobType != null) {
433   - $jobsToMove[] = $job;
434   - }
435   - if ($status == 'done') {
436   - // Could take long time - special truck to avoid interference of TaskMgr requests
437   - // check if ResDir is locked
438   - $postProccesing = $this->updateResultName($job);
439   - if ($postProccesing) {
440   - // is already PostProcessing -> return something not-used
441   - return array('id' => 'postprocessing');
442   - }
443   - }
444   - }
445   - }
446   -
447   - $allJobs[] = array('name' => $job->getAttribute('name'),
448   - 'id' => $job->getAttribute('xml:id'),
449   - 'nodeType' => 'bkgWorks', 'leaf' => true,
450   - 'pid' => $pid, 'status' => $status,
451   - 'start' => $job->getAttribute('start'),
452   - 'stop' => $stop, 'jobType' => $jobType);
453   -
454   - }
455   -
456   - foreach ($jobsToMove as $job)
457   - $this->jobXml->getElementById($this->resRootNode[$job->getAttribute('jobType')])->appendChild($job);
458   -
459   - $this->jobXml->save($this->jobXmlName);
460   -
461   - return $allJobs;
462   - }
463   -
464   -/*
465   -* Delete all temporary products
466   -*/
467   - public function deleteTmp()
468   - {
469   - // Clean up temporary directory
470   - if (is_dir(USERTEMPDIR))
471   - foreach ( glob(USERTEMPDIR.'*') as $filename ) unlink($filename);
472   -
473   - // Clean up immediate jobs
474   - $xp = new domxpath($this->jobXml);
475   - $tmps = $xp->query("//job[@pid='0']");
476   - if ($tmps->length == 0) return;
477   -
478   - foreach ($tmps as $tmp) {
479   - $this->deleteResource($tmp);
480   - $tmp->parentNode->removeChild($tmp);
481   - }
482   -
483   - $this->jobXml->save($this->jobXmlName);
484   -
485   - return;
486   - }
487   -
488   -}
489   -?>
php/classes/PlotMgr.php deleted
... ... @@ -1,388 +0,0 @@
1   -<?php
2   -/**
3   - * @class PlotMgr
4   - * @brief Interactive Plot session
5   - * @version $Id: PlotMgr.php 2412 2014-06-10 09:47:41Z natacha $
6   - *
7   - */
8   -
9   -
10   - class PlotMgr {
11   -
12   - protected $currentInt, $totalInt, $ttName;
13   - protected $TimeTableMgr;
14   -
15   -//DD notation 'YYYY:DOY:HH:MM:SS' DOY => DOY-1
16   - protected function getDdTime($date) {
17   - $ddStart = getdate(strtotime($date));
18   - $DDTime = sprintf("%04d",$ddStart['year']).':'.sprintf("%03d", $ddStart['yday']).':'.
19   - sprintf("%02d",$ddStart['hours']).':'.sprintf("%02d",$ddStart['minutes']).':'.
20   - sprintf("%02d",$ddStart['seconds']);
21   -
22   - return $DDTime;
23   - }
24   - /* Stop Time from StartTime and Interval*/
25   - protected function getStopTime($startDate, $interval){
26   - $time = strtotime($startDate) + $interval;
27   - $stopTime = date('Y-m-d',$time).'T'.date('H:i:s',$time);
28   -
29   - return $stopTime;
30   - }
31   - /* StartTime from StopTime and Interval*/
32   - protected function getStartTime($stopDate, $interval){
33   -
34   - $time = strtotime($stopDate) - $interval;
35   - $startTime = date('Y-m-d',$time).'T'.date('H:i:s',$time);
36   -
37   - return $startTime;
38   - }
39   -
40   -/* get Interval*/
41   -//TODO make session info file ???
42   - protected function getTimeInt($requestName){
43   -
44   - $requestFile = file($requestName);
45   - $nObjects = 2 + $requestFile[0];
46   - $timeIntString = $requestFile[$nObjects];
47   - $timeInt = explode(':', $timeIntString);
48   -
49   - $interval = $timeInt[0]*86400 +
50   - $timeInt[1]*3600 +
51   - $timeInt[2]*60 + $timeInt[3];
52   -
53   - return $interval;
54   - }
55   -
56   -
57   -// Update StartTime in request
58   - protected function updateStartTime($requestName, $start) {
59   -
60   - $requestFile = file($requestName);
61   - $request = fopen($requestName,'w');
62   -
63   - $nObjects = 1 + $requestFile[0];
64   -
65   - for ($k = 0; $k < $nObjects; $k++) fwrite($request,$requestFile[$k]);
66   -
67   - fwrite($request,$this->getDdTime($start).PHP_EOL);
68   - $timeIntString = $requestFile[$nObjects + 1];
69   - fwrite($request,$timeIntString);
70   -
71   - fclose($request);
72   - }
73   -
74   - protected function getNextTable($tabId, $step) {
75   -
76   - $allTables = file('tt');
77   -
78   - for ($i = 0; $i < count($allTables); $i++) {
79   - $currTT = json_decode($allTables[$i]);
80   - if ($currTT->id == $tabId) {
81   - if (($i == count($allTables) - 1) && $step == 1) {
82   - return null;
83   - }
84   - if (($i == 0) && $step == -1) {
85   - return null;
86   - }
87   - $newTT = json_decode($allTables[$i+$step]);
88   - $newTabId = $newTT->id;
89   - $this->ttName = $newTT->timeTableName;
90   - break;
91   - }
92   - }
93   - $tt =$this->TimeTableMgr->loadIntervalsFromTT($newTabId);
94   - $intervals = $tt['intervals'];
95   - $this->totalInt = $tt['totalCount'];
96   -
97   - $ff = fopen('current', 'w');
98   - fwrite($ff, $this->totalInt.PHP_EOL);
99   - fwrite($ff,$allTables[$i+$step]);
100   - fclose($ff);
101   - return $intervals;
102   - }
103   -
104   - protected function getNewInterval($obj) {
105   -
106   - $currentInfo = file('current');
107   - $currInt = (int)$obj->action->arg1 - 1;
108   - $totalNum = $currentInfo[0];
109   - $ttObject = json_decode($currentInfo[1]);
110   - $this->TimeTableMgr = new TimeTableMgr();
111   -
112   - $ttType = (substr($ttObject->id,0,6) == 'shared') ? 'sharedtimeTable' : 'timeTable';
113   - $tt = $this->TimeTableMgr->loadIntervalsFromTT($ttObject->id, $ttType);
114   - $this->ttName = $ttObject->timeTableName;
115   - $intervals = $tt['intervals'];
116   -
117   - $this->totalInt = $tt['totalCount'];
118   - switch ($obj->action->name) {
119   - case 'nextInt':
120   - $number = $currInt+1;
121   - if ($number == $totalNum) {
122   - $newIntervals = $this->getNextTable($ttObject->id, 1);
123   - if ($newIntervals) {
124   - $number = 0;
125   - $intervals = $newIntervals;
126   - }
127   - else
128   - $number = $totalNum - 1;
129   - }
130   - break;
131   - case 'backInt':
132   - $number = $currInt-1;
133   - if ($number == -1) {
134   - $newIntervals = $this->getNextTable($ttObject->id, -1);
135   - if ($newIntervals) {
136   - $intervals = $newIntervals;
137   - $number = count($intervals)-1;
138   -
139   - }
140   - else
141   - $number = 0;
142   -
143   - }
144   - break;
145   - case 'goto':
146   - $number = $currInt;
147   -//TODO check another table ?
148   - if ($number >= $totalNum) {
149   - $number = $totalNum - 1;
150   - }
151   - break;
152   - default:
153   - }
154   - $this->currentInt = $number+1;
155   - return $intervals[$number];
156   - }
157   -
158   -// create file with 'zoom' intervals used in unzoom
159   - protected function addZoomInterval($interval){
160   - $zoomFile = 'zoom_intervals';
161   - $ff = fopen($zoomFile, 'a');
162   - fwrite($ff,json_encode($interval).PHP_EOL);
163   - fclose($ff);
164   - }
165   -
166   -// remove 'zoom' intervals used in unzoom
167   - protected function removeZoomInterval(){
168   - $zoomFile = 'zoom_intervals';
169   -
170   - $intervals = file($zoomFile);
171   - if (!file_exists($zoomFile)) return null;
172   -
173   - if (count($intervals) === 1) {
174   - $currInt = json_decode($intervals[0]);
175   - $interval['start'] = $currInt->start;
176   - $interval['stop'] = $currInt->stop;
177   -
178   - return $interval;
179   - }
180   - $ff = fopen($zoomFile, 'w');
181   - for ($i = 0; $i < count($intervals)-1; $i++)
182   - fwrite($ff,$intervals[$i]);
183   - fclose($ff);
184   - $currInt = json_decode($intervals[count($intervals)-2]);
185   - $interval['start'] = $currInt->start;
186   - $interval['stop'] = $currInt->stop;
187   - return $interval;
188   - }
189   -
190   -// reset start zoom on every action : next, back,...
191   - protected function resetZoomInterval($interval){
192   - $ff = fopen('zoom_intervals','w');
193   - fwrite($ff, json_encode($interval).PHP_EOL);
194   - fclose($ff);
195   - }
196   -
197   -/*****************************************************************
198   -* PUBLIC FUNCTIONS
199   -*****************************************************************/
200   -
201   - public function rrmdir($dir){
202   - if (is_dir($dir)) {
203   - $objects = scandir($dir);
204   -
205   - foreach ($objects as $object) { // Recursively delete a directory that is not empty and directorys in directory
206   - if ($object != "." && $object != "..") { // If object isn't a directory recall recursively this function
207   - if (filetype($dir."/".$object) == "dir")
208   - $this->rrmdir($dir."/".$object);
209   - else
210   - unlink($dir."/".$object);
211   - }
212   - }
213   - reset($objects);
214   - rmdir($dir);
215   - }
216   - }
217   -
218   -// Delete 'interactive session'
219   - public function deleteObject($obj) {
220   -
221   - $sessionID = substr($obj->id, 0, 5);
222   -
223   - if (is_dir(USERWORKINGDIR.$sessionID.'_'))
224   - $this->rrmdir(USERWORKINGDIR.$sessionID.'_');
225   -
226   - return array('id' => $sessionID);
227   -
228   - }
229   -
230   -// interactive session
231   - public function execute($obj) {
232   -
233   - $sessionID = $obj->resultId;
234   -
235   - if (!is_dir(USERWORKINGDIR.$sessionID.'_'))
236   - return array('error' => 'interactive plot session was closed');
237   -
238   - $currDir = USERWORKINGDIR.$sessionID.'_/';
239   - chdir($currDir);
240   -
241   -// Interval or TimeTable session
242   - if (file_exists('current')) {
243   - $isTimeTable = true;
244   - }
245   - else
246   - $isTimeTable = false;
247   -
248   - if (!file_exists('request_.list'))
249   - return array('error' => 'interactive plot session was closed');
250   -
251   - copy('request_.list', $sessionID);
252   -
253   - $action = $obj->action->name;
254   - $interval = array();
255   - $reqMgr = new RequestMgr();
256   - $requestName = $sessionID;
257   -
258   - $timeInt = $this->getTimeInt($currDir.$requestName);
259   -
260   - switch ($action) {
261   - case 'next':
262   - $interval['start'] = $obj->action->arg1;
263   - $interval['stop'] = $this->getStopTime($interval['start'], $timeInt);
264   - $this->resetZoomInterval($interval);
265   - $this->updateStartTime($currDir.$requestName, $interval['start']);
266   - break;
267   - case 'halfnext':
268   - $interval['stop'] = $this->getStopTime($obj->action->arg1, $timeInt/2);
269   - $interval['start'] = $this->getStartTime($interval['stop'], $timeInt);
270   - $this->resetZoomInterval($interval);
271   - $this->updateStartTime($currDir.$requestName, $interval['start']);
272   - break;
273   - case 'back':
274   - $interval['stop'] = $obj->action->arg1;
275   - $interval['start'] = $this->getStartTime($interval['stop'], $timeInt);
276   - $this->resetZoomInterval($interval);
277   - $this->updateStartTime($currDir.$requestName, $interval['start']);
278   - break;
279   - case 'halfback':
280   - $interval['start'] = $this->getStartTime($obj->action->arg1, $timeInt/2);
281   - $interval['stop'] = $this->getStopTime($interval['start'], $timeInt);
282   - $this->resetZoomInterval($interval);
283   - $this->updateStartTime($currDir.$requestName, $interval['start']);
284   - break;
285   - case 'nextInt':
286   - case 'backInt':
287   - case 'goto':
288   - $interval = $this->getNewInterval($obj);
289   - $this->resetZoomInterval($interval);
290   - $reqMgr->updateTime($currDir.$requestName, $interval);
291   - break;
292   - case 'extend':
293   - $shift = $obj->action->arg1;
294   - $interval['start'] = $this->getStartTime($obj->action->arg2, $shift);
295   - $interval['stop'] = $this->getStopTime($obj->action->arg2, $timeInt+$shift);
296   - $this->resetZoomInterval($interval);
297   - $reqMgr->updateTime($currDir.$requestName, $interval);
298   - break;
299   - case 'shift':
300   - $shift = $obj->action->arg1;
301   - $interval['start'] = $this->getStartTime($obj->action->arg2, (-1.)*$shift);
302   - $interval['stop'] = $this->getStopTime($obj->action->arg2, $timeInt+$shift);
303   - $this->resetZoomInterval($interval);
304   - $reqMgr->updateTime($currDir.$requestName, $interval);
305   - break;
306   - case 'zoom':
307   - $requestName = 'zoom';
308   - copy('request_.list', $requestName);
309   - $interval['start'] = $obj->action->arg1;
310   - $interval['stop'] = $obj->action->arg2;
311   - $this->addZoomInterval($interval);
312   - $reqMgr->updateTime($currDir.$requestName, $interval);
313   - break;
314   - case 'resetzoom':
315   - $interval = $this->removeZoomInterval();
316   - copy('request_.list', $requestName);
317   - if ($interval)
318   - $reqMgr->updateTime($currDir.$requestName, $interval);
319   - else
320   - return array('warning' => 'to implement');
321   - break;
322   - case 'changetime': break;
323   - default:
324   - return array('error' => 'unknown action');
325   - }
326   -//TODO Delete *png ??? or use them ????
327   - foreach (glob('Plot*.png') as $filename)
328   - unlink($filename);
329   -//TODO define user in AmdaAction constructor : SESSION_ID
330   - $dd = new UserMgr();
331   -
332   - if ($dd -> ddCheckUser() != 0)
333   - return array('error' => 'sorry, your AMDA session was closed');
334   -
335   - $cmd = DDBIN."DD_Plot ".$requestName." ".$dd->user." ".$dd->IP." ".DDPROJECT." ".DDPROJLIB;
336   - $pid = $reqMgr->background($cmd);
337   -
338   - $jobMgr = new JobsMgr();
339   -//TODO return ERRORS also
340   - for ($cycle = 0; $cycle < PLOT_CYCLES_NUMBER; $cycle++) {
341   - sleep(JOBTIMEOUT);
342   -
343   - if ( is_dir(USERWORKINGDIR."CANCELPLOT") ) {
344   - if (file_exists(USERWORKINGDIR."CANCELPLOT/".substr($sessionID,4,1)))
345   - rename(USERWORKINGDIR."CANCELPLOT/".substr($sessionID,4,1),$currDir."/cancelplot");
346   -
347   - if (count(scandir(USERWORKINGDIR."CANCELPLOT")) == 2) rmdir(USERWORKINGDIR."CANCELPLOT");
348   -
349   - }
350   -
351   - if (file_exists($currDir."/cancelplot"))
352   - {
353   - if (!$jobMgr->isFinished($pid))
354   - {
355   - $cmd = 'kill -9 '.$pid;
356   - exec($cmd);
357   - }
358   -
359   - if (file_exists($currDir."/cancelplot"))
360   - unlink($currDir."/cancelplot");
361   -
362   - return array('error' => "Plot canceled!");
363   - }
364   -
365   - if ($jobMgr->isFinished($pid)) {
366   - $cachekiller = time();
367   - rename($requestName.'.png', $sessionID.'_'.$cachekiller.'.png');
368   - $arrayMain = array('pid' => '0', 'name' => $sessionID.'_'.$cachekiller,
369   - 'id' => $sessionID, 'startDate' => $interval['start'], 'stopDate' => $interval['stop']);
370   -
371   - if ($isTimeTable) {
372   - $arrayTable = array(
373   - 'intervalN' => $this->currentInt,
374   - 'totalN' => $this->totalInt,
375   - 'tableName' => $this->ttName);
376   - return array_merge($arrayMain, $arrayTable);
377   - }
378   - return $arrayMain;
379   - }
380   - }
381   -
382   - $cmd = 'kill -9 '.$pid;
383   - exec($cmd);
384   -
385   - return array('error' => "too long : Plot canceled!");
386   - }
387   - }
388   -?>
php/classes/RequestMgr.php
... ... @@ -81,1847 +81,36 @@ class RequestMgr extends AmdaObjectMgr {
81 81 /*********************************************************************
82 82 * BEGIN : generic functions
83 83 **********************************************************************/
84   - protected function getWsdVars($vars){
85   -
86   - foreach($vars as $var) {
87   - if(strpos($var, 'wsd_') === 0)
88   - {
89   - $wsdVars[] = $var;
90   - }
91   - }
92   -
93   - if (isset($wsdVars)) return $wsdVars;
94   - return false;
95   - }
96   -
97   - protected function getImpexVars($vars){
98   -
99   - foreach($vars as $var) {
100   - foreach($this->impex_prefix as $prefix) {
101   - if(strpos($var, $prefix) === 0)
102   - {
103   - $impexVars[] = $var;
104   - }
105   - }
106   - }
107 84  
108   - if (isset($impexVars)) return $impexVars;
109   - return false;
110   - }
111   -
112   - protected function param2dd($paramID)
113   - {
114   - $pairs = array("-" => "_", "%" => "_","\\" => "_","$" => "_",":" => "_","+" =>" _","-" => "_","#" => "_","@" => "_", "." => "_",">" => "_", "<" => "_");
115   - return strtr($paramID, $pairs);
116   - }
117   -
118   - protected function param2dd_print($paramID)
119   - {
120   - $pairs = array("-" => "_", ":" => "_", "%" => "_","\\" => "_","$" => "_","+" =>" _","-" => "_","#" => "_","@" => "_", "." => "_",">" => "_", "<" => "_");
121   - return strtr($paramID, $pairs);
122   - }
123 85  
124 86 protected function setObject($obj)
125 87 {
126 88 $this->obj = $obj;
127 89 }
128 90  
129   - /* temp name for output */
130   - protected function getRandomName()
131   - {
132   - $length = 6;
133   - $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
134   - $string = '';
135   -
136   - for ($p = 0; $p < $length; $p++) {
137   - $string .= $characters[mt_rand(0, strlen($characters))];
138   - }
139   -
140   - return 'DD'.$string;
141   - }
142   -
143   - //DD notation 'DDDD:HH:MM:SS' ATTENTION!!! DDDD => 4 digits!!!
144   - protected function getDdInterval()
145   - {
146   - return $this->obj->durationDay.':'.$this->obj->durationHour.':'.
147   - $this->obj->durationMin.':'.$this->obj->durationSec;
148   - }
149   -
150   -
151   - //DD notation 'YYYY:DOY:HH:MM:SS' DOY => DOY-1
152   - protected function getDdTime($date)
153   - {
154   - $ddStart = getdate(strtotime($date));
155   - $DDTime = sprintf("%04d",$ddStart['year']).':'.sprintf("%03d", $ddStart['yday']).':'.
156   - sprintf("%02d",$ddStart['hours']).':'.sprintf("%02d",$ddStart['minutes']).':'.
157   - sprintf("%02d",$ddStart['seconds']);
158   -
159   - return $DDTime;
160   - }
161   -
162   -/*
163   - *
164   - */
165   -/*public function isValidRequest()
166   -{
167   - $usrMgr = new UserMgr();
168   - foreach ($this->obj->list as $param)
169   - {
170   - $usrMgr->isAvailableParamForUser();
171   - }
172   -}*/
173   - protected function makeOrbitParam($stl)
174   - {
175   - $params = array( 'cluster1' => 'c1_xyz', 'cluster2' => 'c2_xyz', 'cluster3' => 'c3_xyz', 'cluster4' => 'c4_xyz',
176   - 'themisa'=> 'tha_xyz', 'themisb'=> 'thb_xyz', 'themisc'=> 'thc_xyz', 'themisd'=> 'thd_xyz', 'themise'=> 'the_xyz',
177   - 'geotail' => 'gtl_xyz',
178   - 'mex' => 'mex_xyz', 'mgs' => 'xyz_mgs_mso', 'maven' => 'mav_xyz_mso');
179   -
180   - $this->makeLocalParams(array($params[strtolower($stl)]));
181   -
182   - }
183   -
184   - protected function makeSWMonitorParam($swm)
185   - {
186   - $params = array('omni' => array('omni5_sw_v', 'omni5_sw_n', 'omni5_imf'),
187   - 'amda' => array('ace_xyz', 'wnd_xyz', 'imp8_xyz', 'imf', 'wnd_b', 'imp8_b',
188   - 'swp_n', 'swp_v', 'wnd_swe_n', 'wnd_swe_vmag', 'imp_mit_nfit', 'imp_mit_vfit'));
189   -
190   - $this->makeLocalParams($params[strtolower($swm)]);
191   - }
192   -
193   - /*
194   - * plot objects - check Local Params without code
195   - */
196   - protected function isParamWithoutCode($id)
197   - {
198   - if (!$this->paramsWithoutCode) return false;
199   - $localParams = new DomDocument('1.0');
200   - $localParams->load(paramListXml);
201   - $xp = new domxpath($localParams);
202   - if ($xp->query('//PARAM[.="'.$id.'"]')->length != 0) {
203   - $this->paramBuilder->paramLocalBuild($id);
204   - return true;
205   - }
206   - return false;
207   - }
208   -
209   - /*
210   - * plot objects - check and create Remote Params
211   - */
212   - protected function isRemoteParam($object)
213   - {
214   - if (!$this->dataBases) return false;
215   -
216   - foreach ($this->dataBases as $dataBase){
217   - $dataBaseId = $dataBase->getAttribute('xml:id');
218   - if (strncmp($object, $dataBaseId, strlen($dataBaseId)) === 0) {
219   - return true;
220   - }
221   - }
222   - return false;
223   - }
224   -
225   - protected function makePlotRemoteParams($object, $file_name, $comp)
226   - {
227   - require_once('paramBuild.php');
228   -
229   - paramBuild($object);
230   - $SED = "sed 's/".$object."/".$this->param2dd($object)."/g' ".$file_name." > temp";
231   - system($SED);
232   -
233   - copy('temp',$file_name);
234   -
235   - if ($comp == 0)
236   - $comp = "0";
237   - if ($comp != -1)
238   - paramBuildComp($object, $comp);
239   - return true;
240   -
241   -}
242   -
243   - /*
244   - * Process Local Params without codes if exist
245   - */
246   - protected function makeLocalParams($realVars)
247   - {
248   - $localParams = new DomDocument('1.0');
249   - $localParams->load(paramListXml);
250   - $xp = new domxpath($localParams);
251   - foreach ($realVars as $var) {
252   - // process component
253   - if (strpos($var, '(') !== false) {
254   - $var_arr = explode('(', $var);
255   - $var = $var_arr[0];
256   - }
257   - if ($xp->query('//PARAM[.="'.$var.'"]')->length != 0)
258   - $this->paramBuilder->paramLocalBuild($var);
259   - }
260   -
261   - }
262   -
263   - /*
264   - * Process External Objects if exist
265   - */
266   - protected function makeRemoteParams($realVars)
267   - {
268   - require_once 'paramBuild.php';
269   -
270   - foreach ($realVars as $var)
271   - {
272   - foreach ($this->dataBases as $dataBase)
273   - {
274   - $id = $dataBase->getAttribute('xml:id');
275   - if ($dataBase->getAttribute('group') != 'IMPEX') {
276   - $pos = strpos($var, $id);
277   - if ($pos === false)
278   - continue;
279   - $arrComp = explode('(', $var);
280   - $var_ = $arrComp[0];
281   - paramBuild_($var_);
282   - $this->searchChain = strtr($this->searchChain, $var, param2dd($var));
283   - $var = param2dd($var);
284   - break;
285   - }
286   - }
287   - }
288   - }
289   -
290   - /*
291   - * process WS parameters
292   - */
293   - protected function makeWsParams($realVars) {
294   -
295   - if (!$this->derivedParamMgr) $this->derivedParamMgr = new DerivedParamMgr('derivedParam');
296   -
297   - foreach ($realVars as $var){
298   - // Derived Params
299   - if (strncmp(strtolower($var), 'ws_', 3) == 0) {
300   - // check if resource file exists
301   - $varName = substr($var,3);
302   -
303   - if (!$this->derivedParamMgr->objectExistsByName($varName)) {
304   - return false; //TODO error processing
305   - }
306   - $varId = $this->derivedParamMgr->getObjectIdByName($varName);
307   - $resFile = $varId.'.res';
308   -
309   - if(!file_exists(USERWORKINGDIR.$resFile)) {
310   - return false; //TODO process error
311   - }
312   - copy(USERWORKINGDIR.$resFile, $var.'.res');
313   -
314   - //TODO if needed to replace alias???
315   - $realObject = $this->parser->replaceAll($var);
316   -
317   - $realWsVars = $this->parser->getVars($realObject);
318   - foreach ($realWsVars as $wsVar) {
319   - if ((strncmp($wsVar, "impex___", 8) === 0) || (strncmp($wsVar, "spase___", 8) === 0)){
320   - $tmpArr = explode('_',$wsVar);
321   - $n = count($tmpArr);
322   - if ((strncmp($wsVar, "impex___LATMOS_", 15) === 0) || (strncmp($wsVar, "spase___IMPEX_NumericalOutput_LATMOS_", 37)=== 0)) {
323   - $newVar = str_replace ("_".$tmpArr[$n-2]."_".$tmpArr[$n-1], "", $wsVar);
324   - }
325   - else {
326   - $newVar = str_replace ("_".$tmpArr[$n-1], "", $wsVar);
327   - }
328   - $texte = file_get_contents($var.'.res');
329   - $newText = str_replace($wsVar, $newVar,$texte);
330   - file_put_contents($var.'.res' , $newText);
331   - }
332   - }
333   - //functions for plotting parameter
334   - $this->paramBuilder->makeWsParamPlot($var);
335 91  
336   - // $realWsVars = $this->parser->getVars($realObject);
337   -
338   - /*Check if WS_ is from Local Params without codes*/
339   - if ($this->paramsWithoutCode) {
340   - $this->makeLocalParams($realWsVars);
341   - }
342   -
343   - /*Check if WS_ is from Spectra Params */
344   - if ($this->spectraParams) {
345   - $this->makeSpectraParams($realWsVars);
346   - }
347   -
348   - /*Check if WS_ is from Remote Params */
349   - if ($this->dataBases) {
350   - $this->makeRemoteParams($realWsVars);
351   - }
352   -
353   - /*Check if WS_ is from WS_ or WSD_ Params ONE LEVEL OF NESTING ONLY!!! */
354   - foreach ($realWsVars as $wsVar) {
355   - if (strncmp(strtolower($wsVar), 'ws_', 3) === 0) {
356   - $this->paramBuilder->makeWsParamPlot($wsVar);
357   - $wsVarName = substr($wsVar,3);
358   - $varId = $this->derivedParamMgr->getObjectIdByName($wsVarName);
359   - $tempObj = $this->derivedParamMgr->getObject($varId);
360   - $expression = $this->parser->replaceAll($tempObj["buildchain"]);
361   - $resFile = $varId.'.res';
362   - if(!file_exists(USERWORKINGDIR.$resFile))
363   - return false; //TODO process error
364   -
365   - copy(USERWORKINGDIR.$resFile, $wsVar.'.res');
366   - $lines = file($wsVar.'.res');
367   - $wsWsVarsStr = explode(' ',$lines[0]);
368   -
369   - $wsWsVars = array();
370   - foreach ($wsWsVarsStr as $wsWsVar) if (trim($wsWsVar) != '') $wsWsVars[] = $wsWsVar;
371   - $this->paramBuilder->makeParamCalcul($this->parser->convert2Idl($expression), $wsWsVars, $wsVar);
372   - /*Check if WS_ is from Local Params without codes*/
373   - if ($this->paramsWithoutCode) {
374   - $this->makeLocalParams($wsWsVars);
375   - }
376   - }
377   - elseif (strncmp(strtolower($wsVar), 'wsd_', 4) === 0)
378   - $this->makeWsdParams(array($wsVar));
379   - elseif ((strncmp($wsVar, "impex___", 8) === 0) || (strncmp($wsVar, "spase___", 8) === 0)){
380   - $imp = array('realVars'=> array($wsVar), 'fromWS' => true);
381   - $this->makeWsrParams($imp);
382   - }
383   - }
384   - //function to calculate parameter
385   - $this->paramBuilder->makeParamCalcul($this->parser->convert2Idl($realObject),$realWsVars,$var);
386   - }
387   - }
388   -
389   - }
390   -
391   - /* Process WSD objects */
392   - protected function makeWsdParams($realVars)
393   - {
394   - $paramMgr = new DerivedParamMgr('myDataParam');
395   - $xpd = new domxpath($paramMgr->contentDom);
396   -
397   - foreach ($realVars as $var)
398   - if (strncmp($var, "wsd_", 4) == 0) {
399   - $name = explode('wsd_',$var);
400   - $params = $xpd->query("//mydata[@name='".$name[1]."']");
401   - if ($params->length > 0)
402   - $this->paramBuilder->makeWsdParam($params->item(0)->getAttribute('xml:id'));
403   - }
404   - elseif ((strncmp($var, "impex___", 8) === 0) || (strncmp($var, "spase___", 8) === 0)) {
405   -
406   - }
407   - }
408   -
409   -
410   - /* Process SIMU et INSITU request param*/
411   - protected function makeWsrParams($imp){
412   - $realVars = $imp['realVars'];
413   - $fromWS = $imp['fromWS'];
414   -
415   - $isMulti = $this->obj->timeTables ? true: false;
416   - if (!$isMulti){
417   - $startDate = $this->obj->startDate;
418   - $stopDate = $this->getStopDate();
419   - }
420   - else {
421   - $interval = $this->getFirstTimeTableInterval();
422   - $startDate = $interval['start'];
423   - $stopDate = $interval['stop'];
424   - }
425   -
426   - $paramMgr = new DerivedParamMgr('mySimuParam');
427   -
428   - $simuParamMgr = new SimuParamMgr();
429   - $myWsrParamMgr = new WsrParamMgr();
430   -
431   - $myBaseManager = new BaseManager();
432   - $xpd = new domxpath($myBaseManager->baseDom);
433   - $data = array();
434   -
435   - $paramDom = new DomDocument("1.0");
436   - $paramDom->load(getenv('USER_WS_PATH').'WsParams.xml');
437   - $xpdSimu = new domxpath($paramDom);
438   -
439   - foreach ($realVars as $var) {
440   -
441   - $isVector = false;
442   - $isSimu = strncmp($var, "impex___", 8) === 0 || strncmp($var, "spase___", 8) === 0;
443   - $isClWeb = strncmp($var, "CLWEB_", 6) === 0;
444   -
445   - // All simulation parameters and arguments has prefix "spase___" or "impex___" (old version)
446   - if ($isSimu || $isClWeb) {
447   - if ($fromWS && !$isClWeb) {
448   - $this->argumentsByParam = $this->cutSimuArgs($var);
449   - foreach ($this->argumentsByParam as $key => $value)
450   - $var = $key;
451   - }
452   - else $var = $this->param2dd($var);
453   -
454   - $fileExists = false;
455   - // ClWeb
456   - if ($isClWeb ){
457   - $data['paramID'] = $var;
458   - $data['startDate'] = $startDate;
459   - $data['stopDate'] = $stopDate;
460   - // Creation request parameters
461   - $myWsrParamMgr->setParams($data);
462   - // definitions mask for wsr parameter
463   - $mask = $myWsrParamMgr->getMask();
464   - // definitions download file name for wsr parameter
465   - $fileName = $myWsrParamMgr->getFileName();
466   -// $dataType = "mywsrdata";
467   - }
468   - // Simulation
469   - else {
470   - // Creation request simu parameters
471   - $simuParamMgr->setParams($var, $startDate, $stopDate, $this->argumentsByParam);
472   - // definitions mask for simu parameter
473   - $mask = $simuParamMgr->getMask();
474   - // definitions download file name for simu parameter
475   - $fileName = $simuParamMgr->getFileName();
476   - // test if request parameter is Vector
477   - $isVector = $simuParamMgr->isVector();
478   -// $dataType = "mysimudata";
479   - }
480   -
481   - // definition query for seaching mask in base.xml
482   - $params = $xpd->query("//vi[mask='".$mask."']");
483   -
484   -if (file_exists('/home/budnik/public_html/AMDA-NG4/trunk/data/budnik/LOG'))
485   - unlink('/home/budnik/public_html/AMDA-NG4/trunk/data/budnik/LOG');
486   - // VI exists!!!
487   - if ($params->length > 0) {
488   - // IMPORTANT !!! It is the public method of baseManager class to define ALL needed intervals to request!!!
489   - // Used in moreData.php also
490   - //TODO move from moreData.php to PlotMgr.php for new kernel
491   - $intervalsToGet = $myBaseManager->intervalsToGet(strtotime($startDate), strtotime($stopDate),$mask);
492   - $paramsWsr = $xpdSimu->query("//*[@mask='".$mask."']");
493   - $wsrID = $paramsWsr->item(0)->getAttribute('xml:id');
494   - // data recuperation
495   - $start = $intervalsToGet['start'];
496   - $stop = $intervalsToGet['stop'];
497   -
498   - if (count($start) > 0) {
499   - for ($i = 0; $i < count($start); $i++) {
500   - if ($isClWeb) {
501   - $myWsrParamMgr->updateInterval($start[$i],$stop[$i]);
502   - $fileNames = $myWsrParamMgr->getData();
503   - }
504   - else {
505   - $simuParamMgr->updateInterval($start[$i],$stop[$i]);
506   - $fileNames = $simuParamMgr->getSimuData();
507   - }
508   - }
509   - // if (!$isClWeb) $isVector = $simuParamMgr->isVector();
510   - }
511   - $this->paramBuilder->makeWsdParam($wsrID);
512   - }
513   - // No such VI - It is the very first request
514   - else {
515   - if ($isClWeb){
516   - $fileNames = $myWsrParamMgr->getData();
517   - $var = $this->param2dd($var);
518   - }
519   - else {
520   - $fileNames = $simuParamMgr->getSimuData();
521   - $isVector = $simuParamMgr->isVector();
522   - }
523   -
524   - $input = (object)array(
525   - "varName" => $var,
526   - "isVector"=> $isVector,
527   - "fileName"=> $fileName,
528   - "mask"=> $mask,
529   - "startDate"=> strtotime($startDate),
530   - "stopDate"=> strtotime($stopDate)
531   - );
532   -
533   - if ($fileNames[$var]){
534   - if ($isClWeb){
535   - $tmpObj = $this->makeWsrParamsObj($input, $isClWeb);
536   - $res = $paramMgr->createWsrParameter($tmpObj,'myWsrParam');
537   - }
538   - else {
539   - $tmpObj = $this->makeWsrParamsObj($input);
540   - $res = $paramMgr->createWsrParameter($tmpObj,'mySimuParam');
541   - }
542   - }
543   - if ($res['id'])
544   - $this->paramBuilder->makeWsdParam($res['id']);
545   - }
546   - }
547   - }
548   - }
549   - /* Protected request param*/
550   - protected function makeWsrParamsObj($input, $isClWeb) {
551   -
552   - $params = explode( '_', $input->varName);
553   -
554   - if (!$isClWeb){
555   - // Recuperation names of argument(s)
556   - if (!$input->isVector)
557   - $varName = $params[count($params) -1];
558   - else
559   - $varName = $params[count($params) -3].'_'.$params[count($params) -2].'_'.$params[count($params) -1];
560   - }
561   - else {
562   -
563   - $dom = new DomDocument();
564   - $dom->load(baseDirCLWEB);
565   - $param = $dom->getElementById($input->varName);
566   - // Name of parameter in CLWeb
567   - $varName = $param->getAttribute('var');
568   - // To know if it's Spectra data in ws param we need to indicate "plottype" => $spectra, but in RemoteParams.xml the atribute 'display_type' == 'spectrogram'
569   - // so we need create variable = 'Spectra'
570   - if ($param->hasAttribute('display_type') && ($param->getAttribute('display_type') == 'spectrogram')) $spectra = 'Spectra';
571   - }
572   -
573   - $myFileManager = new FilesMgr();
574   - $object = (object)array(
575   - "file"=> $input->fileName,
576   - "format"=> "nc",
577   - "varName" => $this->param2dd($varName),
578   - "mask"=> $input->mask
579   - );
580   -
581   - if (!$isClWeb){
582   - //delete different possible IMPEx prefix
583   - $tmpTmp = str_replace ("impex___", "", $this->parameterID);
584   - $tmpT = str_replace ("spase___IMPEX_NumericalOutput_", "", $tmpTmp);
585   - $tmp = str_replace ("spase___IMPEX_SimulationRun_", "", $tmpT);
586   - $tmpArr = explode('_',$tmp);
587   - $format = "vot";
588   - $parentTag = "mysimudataList";
589   - $contentRootId = "mySimuParam-treeRootNode";
590   - if ($this->getVotFileMgr($input->fileName)) {
591   - $infos = $this->fileMgr->getFieldInfoByID($varName);
592   - $samplings = $this->fileMgr->getSamplings();
593   - $id = $infos['id'];
594   - $type = $infos['type'];
595   - $units = $infos['unit'];
596   - }
597   - }
598   - else {
599   - $tmpArr[0] = $this->parameterID;
600   - $format = "nc";
601   - $parentTag = "mywsrdataList";
602   - $varName = $input->varName;
603   - $contentRootId = "myWsrParam-treeRootNode";
604   - $infos = $myFileManager->getParamInfo($object);
605   - $samplings['minSampling'] = $infos["info"]["minsampling"];
606   - $samplings['maxSampling'] = $infos["info"]["maxsampling"];
607   - $id = $infos["info"]["name"];
608   - $type = $infos["info"]["type"];
609   - $units = $infos["info"]["unit"];
610   - }
611   -
612   - //size definition
613   - if (($infos['size'] == '') && ($infos["info"]["size"] == ''))
614   - $size = 1;
615   - else {
616   - if ($infos["info"]["size"] != '') $size = $infos["info"]["size"];
617   - else
618   - $size = $infos['size'];
619   - }
620   -
621   - $obj = (object)array(
622   - "name" => $input->varName,
623   - "format"=> $format,
624   - "size"=> $size,
625   - "realvar"=> $id,
626   - "file"=> $input->fileName,
627   - "minsampling" => $samplings['minSampling'],
628   - "maxsampling" => $samplings['maxSampling'],
629   - "type" => $type,
630   - "units" => $units,
631   -// "ytitle" => str_replace ("impex___", "", $input->varName),
632   - "ytitle" => $tmpArr[0].' '.$varName,
633   - "mask"=> $input->mask,
634   - "args"=> $this->argumentsByParam,
635   - "start"=> $input->startDate,
636   - "stop"=> $input->stopDate,
637   - "parentTag"=> $parentTag,
638   - "contentRootId" => $contentRootId,
639   - "plottype" => $spectra
640   - );
641   -
642   -
643   - return $obj;
644   - }
645   -/*
646   - * Recuperation arguments from request variable name for download parameter
647   - */
648   - protected function cutSimuArgs ($var){
649   - $args = array();
650   - $tmpTmp = str_replace ("impex___", "", $var);
651   - $tmpT = str_replace ("spase___IMPEX_NumericalOutput_", "", $tmpTmp);
652   - $tmp = str_replace ("spase___IMPEX_SimulationRun_", "", $tmpT);
653   - $tmpArr = explode('_',$tmp);
654   - $n = count($tmpArr);
655   - //LATMOS parameters have 2 arguments: Satellite & ClockAngle others simulations have only Satellite arguments.
656   - //Exceptions: LESIA simulations and SINP simulations with target different to Earth.
657   - if ($tmpArr[0] == 'LATMOS') {
658   - $args['Satellite'] = $tmpArr[$n-2];
659   - $args['ClockAngle'] = $tmpArr[$n-1];
660   - $var = str_replace ("_".$tmpArr[$n-2]."_".$tmpArr[$n-1], "", $var);
661   - }
662   - else {
663   - $args['Satellite'] = $tmpArr[$n-1];
664   - $var = str_replace ("_".$tmpArr[$n-1], "", $var);
665   - }
666   - return array($var => $args);
667   - }
668   - /*
669   - * VOTable format processing done by an instance of VOTableMgr
670   - */
671   - protected function getVotFileMgr($fileName) {
672   - if (!$this->fileMgr)
673   - $this->fileMgr = new VOTableMgr();
674   -
675   - $this->fileMgr->load(USERDATADIR.$fileName);
676   - if ($this->fileMgr)
677   - return true;
678   - else
679   - return false;
680   - }
681   -
682   - /* Interval from StartTime and Stop Time */
683   - protected function calculateTimeInt($interval){
684   - $int = strtotime($interval['stop']) - strtotime($interval['start']);
685   -
686   - $days = floor($int / 86400);
687   - $int -= $days * 86400;
688   -
689   - $hours = floor($int / 3600);
690   - $int -= $hours * 3600;
691   -
692   - $minutes = floor($int / 60);
693   - $secs = $int - $minutes*60;
694   -
695   - $DdInterval = sprintf("%04d:%02d:%02d:%02d", $days, $hours, $minutes, $secs);
696   -
697   - return $DdInterval;
698   -
699   - }
700 92 /*********************************************************************
701 93 * END : generic functions
702 94 **********************************************************************/
703 95  
704   -/*********************************************************************
705   -* BEGIN : Search specific functions
706   -**********************************************************************/
707   -
708   - /*
709   - * Check if local_param is Special Spectra Cases - to Create special PRO
710   - */
711   - protected function makeSpectraParams($realVars)
712   - {
713   - if ($this->spectraParams)
714   - {
715   - $spectraParams = new DomDocument('1.0');
716   - $spectraParams->load(spectraXml);
717   - $allSpectraParams = $spectraParams->getElementsByTagName("PARAM");
718   -
719   - foreach ($realVars as $theVar) {
720   - for ($j = 0; $j < $allSpectraParams->length; $j++) {
721   - $paramNode = $allSpectraParams->item($j);
722   - if (strpos($theVar, $paramNode->nodeValue) !== false) {
723   - $PRODIR = PRO;
724   - $temp = explode("_",$theVar);
725   - $EMIN = $temp[3];
726   - $EMAX = $temp[4];
727   - // generate all necessary codes for models
728   - if ($paramNode->hasAttribute('model')) {
729   - if ($temp[0] == "bcain" || $temp[0] == "bmorsch") {
730   - // satellite
731   - $EMIN = strtolower($temp[2]);
732   - // sampling
733   - $EMAX = strtolower($temp[3]);
734   - }
735   - else {
736   - // satellite
737   - $EMIN = strtolower($temp[1]);
738   - //monitor sw
739   - $EMAX = strtolower($temp[2]);
740   - $this->makeSWMonitorParam($EMAX);
741   - }
742   - $this->makeOrbitParam($EMIN);
743   - }
744   - else {
745   - $EMIN = $temp[3];
746   - $EMAX = $temp[4];
747   - }
748   -
749   - if ($EMAX) {
750   - $newFunctionName = $paramNode->nodeValue.$EMIN."_".$EMAX."_.pro";
751   - $SED = "sed 's/EMIN/".$EMIN."/g' ".$PRODIR.$paramNode->nodeValue.".pro | sed 's/EMAX/".$EMAX."/g' > ".$newFunctionName;
752   - }
753   - else {
754   - $newFunctionName = $paramNode->nodeValue.$EMIN."_.pro";
755   - $SED = "sed 's/EMIN/".$EMIN."/g' ".$PRODIR.$paramNode->nodeValue.".pro > ".$newFunctionName;
756   - }
757   - system($SED);
758   - }
759   - }
760   - }
761   - }
762   - }
763   -
764   -
765   - /*
766   - * Create search.list with timing for DD_Search
767   - */
768   - protected function createSearchRequestTime()
769   - {
770   - $this->request = fopen(USERWORKINGDIR.'search.list','w');
771   -
772   - fwrite($this->request,$this->getDdTime($this->obj->startDate).PHP_EOL);
773   - fwrite($this->request,$this->getDdInterval().PHP_EOL);
774   -
775   - fclose($this->request);
776   - }
777   -
778   - /*
779   - * Create resource file for DD_Search
780   - */
781   - protected function createSearchRequest($realVars, $New_Table)
782   - {
783   - $file = fopen(USERWORKINGDIR.'search.res','w');
784   - fwrite($file, $New_Table.PHP_EOL);
785   - fwrite($file,$this -> searchChain.PHP_EOL);
786   - foreach ($realVars as $var) fwrite($file, $var." ");
787   - fwrite($file,PHP_EOL.$this->obj->sampling.PHP_EOL);
788   - fwrite($file,$this->obj->gap.PHP_EOL);
789   - fclose($file);
790   - //TODO
791   - /*
792   - * Create file WITH VARS DESCRIPTION
793   - */
794   - // $file = fopen(USERWORKINGDIR.'search_info.res','w');
795   - // fwrite($file,count($realVars).PHP_EOL);
796   - // foreach ($realVars as $var) fwrite($file, $this->getFullName($searchChain, $var).PHP_EOL);
797   - // fclose($file);
798   - }
799   -
800   - /*
801   - * Generate codes for parameters wich are not 'hard-coded'
802   - */
803   - protected function makeSearchParams()
804   - {
805   - $searchChain = $this->parser->replaceAll($this->obj->expression);
806   - $realVars = $this->parser->getVars($searchChain);
807   - $this -> searchChain = $searchChain;
808   -
809   - // Check if local_param is Special Spectra Cases - to Create special PRO
810   - $this->makeSpectraParams($realVars);
811   -
812   - // Process Local Params without codes if exist
813   - $this->makeLocalParams($realVars);
814   -
815   - // Make external params
816   - $this->makeRemoteParams($realVars);
817   -
818   - // Make WS params
819   - $this->makeWsParams($realVars);
820   -
821   - // Make WSD params
822   - $this->makeWsdParams($realVars);
823   -
824   - $this->paramBuilder->makeParamCalcul($this->parser->convert2Idl($this->searchChain), $realVars, "");
825   -
826   - return $realVars;
827   - }
828   -
829   -/*****************************************************************************
830   -* END: Search specific functions
831   -******************************************************************************/
832   -
833   -/******************************************************************************
834   -* BEGIN : Plot specific functions
835   -******************************************************************************/
836   - /*
837   - * Generic Plot Settings: Orientation: portrait, landscape;
838   - * ColorTable;
839   - * Font;
840   - * PPP
841   - */
842   - protected function setPlot()
843   - {
844   - $resFile = file(USERWORKINGDIR.'DD_Request.res');
845   - $res = fopen('./DD_Request.res','w');
846   - fwrite($res, strtolower($this->obj->orientation).PHP_EOL);
847   - for ($k = 1; $k < 3; $k++) fwrite($res,$resFile[$k]);
848   - fwrite($res, $this->obj->ppp.PHP_EOL);
849   - fclose($res);
850   -
851   - $res = fopen('./DD_PlotSettings.res','w');
852   - fwrite($res,$this->obj->charSize.PHP_EOL);
853   - fwrite($res,$this->obj->thickness.PHP_EOL);
854   - fclose($res);
855   - //TODO forced layout with charsize
856   - $this->scatterOffsetX = $this->obj->format == 'PNG' && !$this->obj->forcedLayout ? $this->obj->charSize * 0.23 : 0.03;
857   - $this->scatterOffset = $this->obj->format == 'PNG' && !$this->obj->forcedLayout ? $this->obj->charSize * 0.05 : 0.06;
858   - $this->firstOffset = $this->obj->format == 'PNG' && !$this->obj->forcedLayout ? $this->obj->charSize * 0.07 : 0.08;
859   - }
860   -
861   - protected function cmp($a, $b){
862   - return $a->height < $b->height;
863   - }
864   -
865   -/*
866   - *
867   - */
868   - protected function makeForcedLayout($panels)
869   - {
870   - $TotalHeight = 0.0;
871   - $PWidth = 0.9;
872   - $ScatterCoef = 1;
873   -
874   - $PN = 1;
875   -
876   - $ScatterPanels = array();
877   - $TimePanels = array();
878   -
879   - foreach ($panels as $panel) {
880   - if ($panel->plotType == 'SCATTER') {
881   - if (strtolower($this->obj->orientation) == 'portrait') $panel->width *= 1.625;
882   - $ScatterPanels[] = $panel;
883   - }
884   - else $TimePanels[] = $panel;
885   - }
886   -
887   - usort($ScatterPanels, '$this->cmp');
888   -
889   - $widthArr = array();
890   - foreach ($ScatterPanels as $panel) $widthArr[] = $panel->width;
891   -
892   - $PlotPanels = array(array());
893   -
894   - for ($i = 0; $i < count($ScatterPanels); $i++)
895   - {
896   - $panel = $ScatterPanels[$i];
897   - if (!$panel->pN) {
898   - $width = $panel->width;
899   - $panel->pN = $PN;
900   - $PlotPanels[$PN][] = $panel;
901   - for ($j = 1; $j < count($widthArr); $j++) {
902   - $panel1 = $ScatterPanels[$j];
903   - if (!$panel1->pN) {
904   - $widthNew = $width + $widthArr[$j];
905   - if ($widthNew < $PWidth*$ScatterCoef) {
906   - $width = $widthNew;
907   - $panel1->pN = $PN;
908   - $PlotPanels[$PN][] = $panel1;
909   - if ($j == count($widthArr) -1) {
910   - $PN++; break 1;
911   - }
912   - }
913   - else if ($j < count($widthArr) -1) {
914   - continue;
915   - }
916   - else {
917   - $PN++; break 1;
918   - }
919   - }
920   - }
921   - }
922   - }
923   -
924   - foreach ($TimePanels as $panel) {
925   - $TotalHeight += $panel->height;
926   - }
927   -
928   - $ScatterMaxHeight = array();
929   - $ScatterTotalWidth = array();
930   - for ($i = 1; $i <= $PN; $i++) {
931   - $height = 0.0;
932   - $width = 0.0;
933   - foreach($PlotPanels[$i] as $panel){
934   - $height = $panel->height > $height ? $panel->height : $height;
935   - $width += $panel->width;
936   - }
937   - $ScatterMaxHeight[$i] = $height;
938   - $ScatterTotalWidth[$i] = $width;
939   - $TotalHeight +=$height;
940   - }
941   -
942   -
943   - $PHeight = 1.0 - $PN*$this->scatterOffset - $this->firstOffset;
944   - $heightCoeff = $TotalHeight > $PHeight ? $PHeight/$TotalHeight : 1.0;
945   -
946   - $first = true;
947   -
948   - foreach (array_reverse($TimePanels) as $panel)
949   - {
950   - if ($panel->children[0]->paramArgs == "OrbitPresentation=CYL") {
951   - $width = $panel->width*$heightCoeff;
952   - $panel->XPmin = ($PWidth - $width)/2.0;
953   - $panel->XPmax = $panel->XPmin + $width;
954   - }
955   - else {
956   - $panel->XPmin = 0.0;
957   - $panel->XPmax = $PWidth;
958   - }
959   - //Start from lower panel
960   - $panel->YPmin = $first ? $this->firstOffset : $YPmax;
961   - $YPmax = $panel->YPmin + $panel->height*$heightCoeff;
962   - $panel->YPmax = $YPmax;
963   - $first = false;
964   - }
965   -
966   - if ($first) $YPmax = $this->firstOffset + 0.03;
967   - else $YPmax += $this->scatterOffset;
968   -
969   - // Y coordinates
970   - for ($i = 1; $i <= $PN; $i++) {
971   - $newWidth = ($PN-1)*$this->scatterOffsetX;
972   - $realHeight = $ScatterMaxHeight[$i]*$heightCoeff;
973   - foreach ($PlotPanels[$i] as $panel) {
974   - $panelCoeff = $panel->height > $realHeight ? $realHeight/$panel->height : 1;
975   - $panel->YPmin = $YPmax;
976   - $panel->YPmax = $panel->YPmin + $panel->height*$panelCoeff;
977   - $width = $panel->width*$panelCoeff;
978   - $panel->panelCoeff = $panelCoeff;
979   - $newWidth += $width;
980   - }
981   - // X coordinates
982   - $xOffset = 0.0;
983   - foreach ($PlotPanels[$i] as $panel) {
984   - $width = $panel->width*$panel->panelCoeff;
985   - $panel->XPmin = ($PWidth - $newWidth)/2.0 + $xOffset;
986   - $panel->XPmax = $panel->XPmin + $width;
987   - $xOffset += $this->scatterOffsetX+$width;
988   - }
989   -
990   - $YPmax += $this->scatterOffset + $realHeight;
991   - }
992   - $arrayToReturn = array_reverse($TimePanels);
993   -
994   - for ($i = 1; $i <= $PN; $i++)
995   - foreach ($PlotPanels[$i] as $panel)
996   - $arrayToReturn[] = $panel;
997   -
998   - return $arrayToReturn;
999   - }
1000   -
1001   - /*
1002   - *
1003   - */
1004   - protected function makeLayout($panels)
1005   - {
1006   - $TotalHeight = 0.0;
1007   - $PWidth = 0.9;
1008   -
1009   - $ScatterN = 0;
1010   - $TimeN = 0;
1011   - foreach ($panels as $panel){
1012   - if ($panel->plotType == 'SCATTER') {
1013   - $ScatterN++;
1014   - if (strtolower($this->obj->orientation) == 'portrait')
1015   - $panel->width *= 1.625; //0.65/0.4; coeff for portrait
1016   - }
1017   - else $TimeN++;
1018   -
1019   - $TotalHeight += $panel->height;
1020   - }
1021   -
1022   - $addOffset = $TimeN > 0 && $panels[count($panels)-1]->plotType == 'SCATTER';
1023   -
1024   - $PHeight = 0.99 - $this->firstOffset - $ScatterN*$this->scatterOffset - $this->firstOffset*$addOffset;
1025   - $heightCoeff = $TotalHeight > $PHeight ? $PHeight/$TotalHeight : 1.0;
1026   -
1027   - //Loop through all panels
1028   - $first = true;
1029   - $firstTime = true;
1030   - $allPanels = array();
1031   -
1032   - foreach (array_reverse($panels) as $panel)
1033   - {
1034   - $isScatter = $panel->plotType == 'SCATTER';
1035   - // width for scatter
1036   - if ($isScatter) {
1037   - $width = $panel->width*$heightCoeff;
1038   - $panel->XPmin = ($PWidth - $width)/2.0;
1039   - $panel->XPmax = $panel->XPmin + $width;
1040   - }
1041   - else if ($panel->children[0]->paramArgs == "OrbitPresentation=CYL") {
1042   - $width = $panel->width*$heightCoeff;
1043   - $panel->XPmin = ($PWidth - $width)/2.0;
1044   - $panel->XPmax = $panel->XPmin + $width;
1045   - }
1046   - else {
1047   - $panel->XPmin = 0.0;
1048   - $panel->XPmax = $PWidth;
1049   - }
1050   -
1051   - //Start from lower panel
1052   - if ($first)
1053   - $panel->YPmin = $this->firstOffset;
1054   - else if ($isScatter)
1055   - $panel->YPmin = $YPmax+$this->scatterOffset;
1056   - else if ($addOffset && $firstTime && !$isScatter) {
1057   - $firstTime = false;
1058   - $panel->YPmin = $YPmax+$this->firstOffset;
1059   - }
1060   - else
1061   - $panel->YPmin = $YPmax;
1062   -
1063   - $YPmax = $panel->YPmin + $panel->height*$heightCoeff;
1064   - $panel->YPmax = $YPmax;
1065   - $first = false;
1066   - }
1067   - return array_reverse($panels);
1068   - }
1069   -
1070   - protected function setPlotObjects($panels,$tmpname,$isMulti){
1071   -
1072   - require_once 'paramBuild.php';
1073   -
1074   - $this->request = fopen($tmpname,'w');
1075   -
1076   - if ($this->obj->forcedLayout)
1077   - $panels = $this->makeForcedLayout($panels);
1078   - else
1079   - $panels = $this->makeLayout($panels);
1080   -
1081   - foreach ($panels as $panel){
1082   - // if it is SCATTER PLOT
1083   - $isScatter = $panel->plotType == 'SCATTER';
1084   - $Xmin = $panel->xRangeMin;
1085   - $Xmax = $panel->xRangeMax;
1086   - $Ymin = $panel->y1RangeMin;
1087   - $Ymax = $panel->y1RangeMax;
1088   -
1089   - $Ytitle = $panel->y1Title;
1090   - $Xtitle = $panel->xTitle;
1091   -
1092   - $objectsToDraw = $panel->children;
1093   -
1094   - $multiOnePanel = false;
1095   - // check if SPECIAL MULTI could be done
1096   - if (count($objectsToDraw) > 1 && $this->obj->forcedMulti && !$isScatter) {
1097   - $multiOnePanel = true;
1098   - foreach ($objectsToDraw as $objectToDraw) {
1099   - // only scalars
1100   - if (!$objectToDraw->isScatter) {
1101   - $multiOnePanel = false;
1102   - }
1103   - }
1104   - }
1105   -
1106   - if ($multiOnePanel) {
1107   - $aPanel = new stdClass();
1108   - $aPanel->XPmin = $panel->XPmin;
1109   - $aPanel->XPmax = $panel->XPmax;
1110   - $aPanel->YPmin = $panel->YPmin;
1111   - $aPanel->YPmax = $panel->YPmax;
1112   - $aPanel->Xmin = $Xmin;
1113   - $aPanel->Xmax = $Xmax;
1114   - $aPanel->Ymin = $Ymin;
1115   - $aPanel->Ymax = $Ymax;
1116   -
1117   - $aPanel->object = 'multi';
1118   - $aPanel->args = '';
1119   - foreach ($objectsToDraw as $objectToDraw) {
1120   - $aPanel->args .= '"'.$objectToDraw->name.'",';
1121   - $paramMulti = explode('(',$objectToDraw->name);
1122   - $paramList[] = $paramMulti[0];
1123   - }
1124   - $aPanel->args = substr($aPanel->args, 0, -1);
1125   - $allPanels[] = $aPanel;
1126   - }
1127   - // loop though parameters : each parameter == panel if not MULTI
1128   - else {
1129   - foreach ($objectsToDraw as $objectToDraw) {
1130   - $aPanel = new stdClass();
1131   - $aPanel->XPmin = $panel->XPmin;
1132   - $aPanel->XPmax = $panel->XPmax;
1133   - $aPanel->YPmin = $panel->YPmin;
1134   - $aPanel->YPmax = $panel->YPmax;
1135   - $aPanel->Xmin = $Xmin;
1136   - $aPanel->Xmax = $Xmax;
1137   - $aPanel->Ymin = $Ymin;
1138   - $aPanel->Ymax = $Ymax;
1139   -
1140   - if ($isScatter) {
1141   - $paramIDx = explode('(', $objectToDraw->name);
1142   - $paramList[] = $paramIDx[0];
1143   - $paramIDy = explode('(',$panel->scatterParam->data->name);
1144   -
1145   - $oneVI = $paramIDy[0] === $paramIDx[0] ? true : false;
1146   -
1147   - if ($this->isRemoteParam($paramIDx[0])) {
1148   -
1149   - if (!$infoMgr) $infoMgr = new ParamsInfoMgr();
1150   - $info = $infoMgr->getRemoteParamInfo($paramIDx[0]);
1151   -
1152   - paramBuild_($paramIDx[0]);
1153   - $paramIDx[0] = param2dd($paramIDx[0]);
1154   - $objectToDraw->name = implode('(', $paramIDx);
1155   -
1156   - $YTitle_default = $info['title'] ? $info['title'].'('.$paramIDx[1] : $objectToDraw->name;
1157   -
1158   - if ($oneVI) {
1159   - $paramIDy[0] = $paramIDx[0];
1160   - $panel->scatterParam->data->name = implode('(', $paramIDy);
1161   - $XTitle_default = $info['title'] ? $info['title'].'('.$paramIDy[1] : $panel->scatterParam->data->name;
1162   - }
1163   - }
1164   -
1165   - if (!$oneVI) {
1166   -
1167   - if ($this->isRemoteParam($paramIDy[0])) {
1168   -
1169   - if (!$infoMgr) $infoMgr = new ParamsInfoMgr();
1170   - $info = $infoMgr->getRemoteParamInfo($paramIDy[0]);
1171   -
1172   - paramBuild_($paramIDy[0]);
1173   - $paramIDy[0] = param2dd($paramIDy[0]);
1174   - $panel->scatterParam->data->name = implode('(', $paramIDy);
1175   - $XTitle_default = $info['title'] ? $info['title'].'('.$paramIDy[1] : $panel->scatterParam->data->name;
1176   - }
1177   - $paramList[] = $paramIDy[0];
1178   - }
1179   - $aPanel->object = 'scatter';
1180   - $aPanel->args = '"'.$objectToDraw->name.'",'.'"'.$panel->scatterParam->data->name.'"';
1181   - $aPanel->args .= $this->parseScatterArguments($objectToDraw->paramArgs);
1182   -
1183   - if ($Xtitle || $XTitle_default) {
1184   - $Xtitle_ = $Xtitle ? $Xtitle : $XTitle_default;
1185   - $aPanel->args .= ', XTITLE="'.$Xtitle_.'"';
1186   - }
1187   -
1188   - if ($Ytitle || $YTitle_default) {
1189   - $Ytitle_ = $Ytitle ? $Ytitle : $YTitle_default;
1190   - $aPanel->args .= ', Y1TITLE="'.$Ytitle_.'"';
1191   - }
1192   - }
1193   - else {
1194   - // to make proper AMDA objects
1195   - $comp = -1;
1196   - $addArgs = $this->parseSimuArguments($objectToDraw->paramArgs);
1197   - $this->argumentsByParam[$objectToDraw->name] = (array)$addArgs;
1198   - if (strpos($objectToDraw->name, '(') !== false) {
1199   - //first check params without codes
1200   - $paramID = explode('(', $objectToDraw->name);
1201   - $comp = substr($paramID[1], 0, -1);
1202   - //TODO double ??? of MakeLocalParam A CORRIGER
1203   - $paramWithoutCode = $this->isParamWithoutCode($paramID[0]);
1204   - $currPairs = array("(" => "_", ")" => "",":" => "_");
1205   - $objectToDraw->name = strtr($objectToDraw->name, $currPairs);
1206   - }
1207   - else {
1208   - $paramWithoutCode = $this->isParamWithoutCode($objectToDraw->name);
1209   - }
1210   - if ($this->isRemoteParam($objectToDraw->name)) {
1211   -
1212   - if ($comp != -1) $this->makePlotRemoteParams($paramID[0], $tmpname, $comp);
1213   - else $this->makePlotRemoteParams($objectToDraw->name, $tmpname, $comp);
1214   -
1215   - $currPairs = array(":" => "_", '-' => "_");
1216   - $objectToDraw->name = strtr($objectToDraw->name, $currPairs);
1217   - }
1218   - //================================================================
1219   - // TODO THEMIS_IRAP init is created from special templates!!!
1220   - $objToTest = str_replace("_", " ", $objectToDraw->name);
1221   - if (sscanf($objToTest, "th%s pe%s %s", $X, $mode, $property) == 3){
1222   - $themis = "th".$X;
1223   - $mode = "pe".$mode;
1224   - $SED = "sed 's/X/".$X."/g' ".TEMPLATES."thX_YYYY_".$property."_init.pro | sed 's/YYYY/".$mode."/g' > ./".$themis."_".$mode."_".$property."_init.pro";
1225   - system($SED);
1226   - if ($property == 'v' || $property == 't' || $property == 'mode' ) {
1227   - for ($j = 0; $j < 3; $j++) {
1228   - $SED = "sed 's/X/".$X."/g' ".TEMPLATES."thX_YYYY_".$property."_Z_init.pro | sed 's/YYYY/".$mode."/g' | sed 's/Z/".$j."/g' > ./".$themis."_".$mode."_".$property."_".$j."_init.pro";
1229   - system($SED);
1230   - }
1231   - }
1232   - }
1233   -
1234   - if (sscanf($objToTest, "th%s bh", $X) === 1){
1235   - $themis = "th".$X;
1236   - $SED = "sed 's/X/".$X."/g' ".TEMPLATES."thX_bh_init.pro > ./".$themis."_bh_init.pro";
1237   - system($SED);
1238   - for ($j = 0; $j < 3; $j++) {
1239   - $SED = "sed 's/X/".$X."/g' ".TEMPLATES."thX_bh_Z_init.pro | sed 's/Z/".$j."/g' > ./".$themis."_bh_".$j."_init.pro";
1240   - system($SED);
1241   - }
1242   -
1243   - }
1244   -//==================================================
1245   -
1246   - $aPanel->object = $objectToDraw->name;
1247   - if ($objectToDraw->paramArgs != $this->defaults) {
1248   - $aPanel->args = $this->parseArguments($objectToDraw->paramArgs);
1249   - }
1250   - // new Y Title
1251   - if ($Ytitle && ($paramWithoutCode || $this->isRemoteParam($objectToDraw->name) || (strncmp(strtolower($objectToDraw->name), 'ws_', 3) == 0))) {
1252   - if ($objectToDraw->paramArgs != $this->defaults) $aPanel->args .= ',';
1253   - $aPanel->args .= 'AY1TITLE="'.$Ytitle.'"';
1254   - }
1255   - // linear Z scaling for ros_mip
1256   - if (substr($objectToDraw->name,0,7) == 'ros_mip') {
1257   - if ($objectToDraw->paramArgs != $this->defaults) $aPanel->args .= ',';
1258   - $aPanel->args .= '/LLIN';
1259   - }
1260   - // linear Y scaling for ros_ies AZ, ELV
1261   - if (strpos($objectToDraw->name,'ros') === 0 &&
1262   - (strpos($objectToDraw->name,'elv') > 0 || strpos($objectToDraw->name,'az') > 0)) {
1263   - if ($objectToDraw->paramArgs != $this->defaults) $aPanel->args .= ',';
1264   - $aPanel->args .= '/LIN';
1265   - }
1266   - $paramList[] = $aPanel->object;
1267   -
1268   - }
1269   - $allPanels[] = $aPanel;
1270   - }
1271   - } //else
1272   - } //foreach ($panels as $panel)
1273   -
1274   - //Now write everything into request file
1275   - fwrite($this->request,count($allPanels).PHP_EOL);
1276   -
1277   - foreach ($allPanels as $aPanel) {
1278   - fwrite($this->request,
1279   - $aPanel->object.' '.$aPanel->XPmin.' '.$aPanel->YPmin.' '.$aPanel->XPmax.' '.$aPanel->YPmax.' '.
1280   - $aPanel->Xmin.' '.$aPanel->Xmax.' '.$aPanel->Ymin.' '.$aPanel->Ymax.' '.$aPanel->args.PHP_EOL);
1281   - }
1282   -
1283   - $this->nObjects = count($allPanels);
1284   -
1285   - // Finish request file by StartTime and TimeInterval if ONE time only
1286   - if (!$isMulti) {
1287   - $StartTime = $this->getDdTime($this->obj->startDate);
1288   - $TimeInt = $this->getDdInterval();
1289   - fwrite($this->request,$StartTime.PHP_EOL);
1290   - fwrite($this->request,$TimeInt.PHP_EOL);
1291   - }
1292   - fclose($this->request);
1293   -
1294   - return $paramList;
1295   - }
1296   -
1297   - /*
1298   - * Arguments parser
1299   - */
1300   - protected function getColor($value) {
1301   -
1302   - switch ($value) {
1303   - case 'black' : return 'COLOR = !dnc-1';
1304   - case 'red' : return 'COLOR = !dnc-2';
1305   - case 'orange' : return 'COLOR = !dnc*190/256';
1306   - case 'yellow' : return 'COLOR = !dnc*160/256';
1307   - case 'green' : return 'COLOR = !dnc*80/256';
1308   - case 'light-green' : return 'COLOR = !dnc*100/256';
1309   - case 'light-blue' : return 'COLOR = !dnc*40/256';
1310   - case 'blue' : return 'COLOR = !dnc*15/256';
1311   - default: return 'COLOR = !dnc-1';
1312   - }
1313   - }
1314   -
1315   - /*
1316   - * Arguments parser
1317   - */
1318   - protected function parseArguments($args)
1319   - {
1320   - $argArr = explode('&',$args);
1321   - foreach ($argArr as $key => &$arg) {
1322   - $temp = explode('=', $arg);
1323   - //translate some arguments
1324   - if ($temp[1] == 'no') unset($argArr[$key]);
1325   - if ($temp[1] == 'yes') $arg = '/'.$temp[0];
1326   - if ($temp[0] == 'Scale') $arg = '/'.$temp[1];
1327   - if ($temp[0] == 'RefFrame') $arg = 'FRAME="'.$temp[1].'"';
1328   - if ($temp[0] == 'OrbitPresentation') $arg = '/'.$temp[1];
1329   -
1330   - if ($temp[0] == 'Spacecraft') {
1331   - $arg = '/'.$temp[1];
1332   - $this->makeOrbitParam($temp[1]);
1333   - }
1334   -
1335   - if ($temp[0] == 'SW_Monitor') {
1336   - $arg = '/'.$temp[1];
1337   - $this->makeSWMonitorParam($temp[1]);
1338   - }
1339   -
1340   - if ($temp[0] == 'Color') {
1341   - $arg = $this->getColor($temp[1]);
1342   - }
1343   - if ($temp[0] == 'Channel' && ( $temp[1] == 'spectrogram' || $temp[1] == 'stack_plot')) unset($argArr[$key]);
1344   - if ( ($temp[0] == 'anode' || $temp[0] == 'channel') && $temp[1] == 'all') unset($argArr[$key]);
1345   -
1346   - if ($temp[0] == 'Symbol') {
1347   - if ($temp[1] == '0') $arg = 'PSYM = -3';
1348   - else $arg = 'PSYM = '.$temp[1];
1349   - }
1350   -// if ($temp[0] == 'energyCB') $arg = '/enaverage';
1351   - // if ($temp[0] == 'anodeCB') $arg = '/anaverage';
1352   - }
1353   -
1354   - $argArrModif = array_values($argArr);
1355   - return implode(',',$argArrModif);
1356   -}
1357   -
1358   - /*
1359   - * Scatter Arguments parser
1360   - */
1361   - protected function parseScatterArguments($args)
1362   - {
1363   - $argArr = explode('&',$args);
1364   -
1365   - foreach ($argArr as $key => &$arg) {
1366   -
1367   - $temp = explode('=', $arg);
1368   - if ($temp[0] != 'Color' && $temp[0] != 'Symbol') unset($argArr[$key]);
1369   -
1370   - if ($temp[0] == 'Color') {
1371   - $arg = $this->getColor($temp[1]);
1372   - }
1373   - if ($temp[0] == 'Symbol') {
1374   - if ($temp[1] == '0') $arg = 'PSYM = -3';
1375   - else $arg = 'PSYM = '.$temp[1];
1376   - }
1377   - }
1378   - $argArrModif = array_values($argArr);
1379   - if (count($argArrModif) > 0) return ','.implode(',',$argArrModif);
1380   - else return '';
1381   - }
1382   -
1383   - /*
1384   - * Simu Arguments parser
1385   - */
1386   - protected function parseSimuArguments($args)
1387   - {
1388   - $argArr = explode('&',$args);
1389   -
1390   - $arguments = array();
1391   - foreach ($argArr as $key => &$arg) {
1392   -
1393   - $temp = explode('=', $arg);
1394   -
1395   - $arguments[$temp[0]] = $temp[1];
1396   - }
1397   - return $arguments;
1398   - }
1399   -
1400   -
1401   - /*
1402   - * put down list of time tables (tt) and current table (current)
1403   - */
1404   - protected function prepareTimeTablePlot($dir)
1405   - {
1406   - //set time from first time table first interval
1407   - $ttMgr = new TimeTableMgr();
1408   - $timeTables = $this->obj->timeTables;
1409   - // $firstTable = $timeTables[0];
1410   - // $tt = $ttMgr->loadIntervalsFromTT($firstTable->id);
1411   - // $intervals = $tt['intervals'];
1412   - $offset = 0;
1413   - $file = fopen($dir.'/tt', 'w');
1414   - foreach ($timeTables as $timeTable) {
1415   - $ttType = (substr($timeTable->id,0,6) == 'shared') ? 'sharedtimeTable' : 'timeTable';
1416   - $tt = $ttMgr->loadIntervalsFromTT($timeTable->id, $ttType);
1417   - $intervals = $tt['intervals'];
1418   - $totalCount = $tt['totalCount'];
1419   - fwrite($file,json_encode($timeTable).PHP_EOL);
1420   - if ($offset == 0) {
1421   - $this->totalInt = $totalCount;
1422   - $this->ttName = $timeTable->timeTableName;
1423   - $this->currentInt = 1;
1424   - $ff = fopen($dir.'/current', 'w');
1425   - fwrite($ff, $this->totalInt.PHP_EOL);
1426   - fwrite($ff, json_encode($timeTable));
1427   - fclose($ff);
1428   - $firstInterval = $intervals[0];
1429   - }
1430   - $offset += $totalCount;
1431   - }
1432   - fclose($file);
1433   - //save current tt object (first one) and current time interval (first one)
1434   - return $firstInterval;
1435   - }
1436   -
1437   -
1438   - /*
1439   - * put down list of time tables (tt) and current table (current)
1440   - */
1441   - protected function getFirstTimeTableInterval()
1442   - {
1443   - //set time from first time table first interval
1444   - $ttMgr = new TimeTableMgr();
1445   - $timeTables = $this->obj->timeTables;
1446   -
1447   - $firstTable = $timeTables[0];
1448   - // $tt = $ttMgr->loadIntervalsFromTT($firstTable->id);
1449   - $ttType = (substr($firstTable->id,0,6) == 'shared') ? 'sharedtimeTable' : 'timeTable';
1450   - $tt = $ttMgr->loadIntervalsFromTT($firstTable->id, $ttType);
1451   - $intervals = $tt['intervals'];
1452   - //save current tt object (first one) and current time interval (first one)
1453   - $firstInterval = $intervals[0];
1454   - return $firstInterval;
1455   - }
1456   -/******************************************************************************
1457   - * END: Plot specific functions
1458   -*******************************************************************************/
1459   -
1460   - /*
1461   - * Change NAME in JSON resource
1462   - */
1463   - protected function renameInResource($name, $id) {
1464   -
1465   - $obj = json_decode(file_get_contents(USERREQDIR.$id));
1466   - $obj->name = $name;
1467   -
1468   - $file = fopen(USERREQDIR.$id, 'w');
1469   - fwrite($file, json_encode($obj));
1470   - fclose($file);
1471   - }
1472   -
1473   -
1474   - /*
1475   - * Make new request/condition resource file (JSON!!) and add it to content file
1476   - * ATTENTION : it is not DD parameter!!!
1477   - */
1478   -protected function createParameter($p)
1479   - {
1480   - if ($this -> objectExistsByName($p->name)) {
1481   - $p->id = $this->getObjectIdByName($p->name);
1482   - $this -> deleteObject($p);
1483   - }
1484   - $this->id = $this->setId();
1485   - if (!$this->id) return array('error' => ID_CREATION_ERROR);
1486   -
1487   - //if alias exists, replace alias name by parameter name
1488   - if (file_exists(USERWSDIR.'Alias.xml')) {
1489   - if ($this->type == 'condition') {
1490   - $p->expression = $this->resetAlias($p->expression);
1491   - $info = $p->expression;
1492   - }
1493   - else if ($this->type == 'request') {
1494   - $info = '';
1495   - for ($i=0; $i < count($p->children); $i++) {
1496   - for ($j=0; $j < count($p->children[$i]->children); $j++) {
1497   - $p->children[$i]->children[$j]->name = $this->resetAlias($p->children[$i]->children[$j]->name);
1498   - $info = $info.' '.$p->children[$i]->children[$j]->name;
1499   - }
1500   - }
1501   - }
1502   - }
1503   -
1504   - $this->descFileName = USERREQDIR.$this->id;
1505   - $p->id = $this->id;
1506   - // save request as json
1507   - $file = fopen($this->descFileName, 'w');
1508   - fwrite($file, json_encode($p));
1509   - fclose($file);
1510   -
1511   - $this -> addToContent($p, $folder);
1512   -
1513   - return array('id' => $this->id, 'info' => $info);
1514   -}
1515   -
1516   - /*
1517   - * Delete request/condition JSON file
1518   - */
1519   - protected function deleteParameter($id){
1520   -
1521   - if (file_exists(USERREQDIR.$id))
1522   - unlink(USERREQDIR.$id);
1523   - }
1524   -
1525   - /*
1526   - * TODO Check file JSON objects differ in names only
1527   - */
1528   -protected function renameOnly($p) {
1529   -
1530   -return false;
1531   - }
1532   -
1533   - /*
1534   - * Add header in download result
1535   - */
1536   -public function addHeaderInDownloadResult($opts)
1537   -{
1538   - //remove previous header if it exist
1539   - if (file_exists('header.txt'))
1540   - unlink('header.txt');
1541   -
1542   -//use ParamsInfoMgr to get infor about parameters
1543   -$infoMgr = new ParamsInfoMgr();
1544   -
1545   -$params = explode(' ',$opts['params']);
1546   -
1547   -if (strcmp($opts['header'],'0') === 0)
1548   -{
1549   - //header in data files
1550   - if (strcmp($opts['structure'],'2') === 0)
1551   - {
1552   - //one file by param
1553   - foreach ($params as $param)
1554   - {
1555   - $filenames = glob(strtoupper($param)."*.txt");
1556   - if (count($filenames) === 0)
1557   - continue;
1558   - foreach ($filenames as $filename) {
1559   - //parameter info
1560   - $infos = $infoMgr->GetParamInfo($param);
1561   - $str = $infoMgr->ParamInfosToString($infos);
1562   - system("sed -i '1i\\#".$str."' '".$filename."'");
1563   - //time info
1564   - $str = "Time Format : ".$opts['timeformat'];
1565   -
1566   - if (strcmp($opts['milli'],'1') === 0)
1567   - {
1568   - if (strcmp($opts['timeformat'],'YYYY-MM-DDThh:mm:ss') === 0)
1569   - $str .= ".mls";
1570   - else
1571   - $str .= " mls";
1572   - }
1573   -
1574   - system("sed -i '1i\\#".$str."' '".$filename."'");
1575   - }
1576   - }
1577   - }
1578   - else
1579   - {
1580   - //all in one file
1581   - $str = "";
1582   -
1583   - foreach ($params as $param)
1584   - {
1585   - $infos = $infoMgr->GetParamInfo($param);
1586   - $str .= ('#'.$infoMgr->ParamInfosToString($infos).PHP_EOL);
1587   - }
1588   -
1589   - $filenames = glob("ALL*.txt");
1590   - if (count($filenames) > 0)
1591   - foreach ($filenames as $filename)
1592   - {
1593   - $ex_str = explode(PHP_EOL,$str);
1594   -
1595   - //parameters info
1596   - for ($i = sizeof($ex_str)-1; $i >= 0 ; $i--)
1597   - system("sed -i '1i\\".$ex_str[$i]."' '".$filename."'");
1598   - //time info
1599   - $str = "Time Format : ".$opts['timeformat'];
1600   -
1601   - if (strcmp($opts['milli'],'1') === 0)
1602   - {
1603   - if (strcmp($opts['timeformat'],'YYYY-MM-DDThh:mm:ss') === 0)
1604   - $str .= ".mls";
1605   - else
1606   - $str .= " mls";
1607   - }
1608   -
1609   - system("sed -i '1i\\#".$str."' '".$filename."'");
1610   - if (strpos($filename, "NONSTANDARD_SAMPLING") === false) {
1611   - //sampling info
1612   - $str = "Sampling Time : ".$opts['sampling'];
1613   - system("sed -i '1i\\#".$str."' '".$filename."'");
1614   - }
1615   - }
1616   - }
1617   -}
1618   -else
1619   -{
1620   - //header in separate file
1621   - $header = fopen("header.txt","w");
1622   - if ($opts['structure'] != '2')
1623   - {
1624   -
1625   - //all in one file- add sampling info
1626   - fprintf($header,"#Sampling Time : ".$opts['sampling'].PHP_EOL);
1627   - }
1628   - //time info
1629   - $str = "#Time Format : ".$opts['timeformat'];
1630   -
1631   - if (strcmp($opts['milli'],'1') === 0)
1632   - {
1633   - if (strcmp($opts['timeformat'],'YYYY-MM-DDThh:mm:ss') === 0)
1634   - $str .= ".mls";
1635   - else
1636   - $str .= " mls";
1637   - }
1638   -
1639   - //fprintf($header,$str.PHP_EOL);
1640   - foreach ($params as $param)
1641   - {
1642   - //param info
1643   - $infos = $infoMgr->GetParamInfo($param);
1644   - $str = $infoMgr->ParamInfosToString($infos);
1645   - fprintf($header,"#".$str.PHP_EOL);
1646   - }
1647   - }
1648   - }
1649 96  
1650 97  
1651   - public function compressDownloadResult($id,$newName,$opts)
1652   - {
1653   - if ($opts['downloadSrc'] == '2')
1654   - $ext = "fits";
1655   - else
1656   - {
1657   - if (strcmp($opts['fileformat'],'vot') === 0)
1658   - $ext = "xml";
1659   - else
1660   - $ext = "txt";
1661   - }
1662   -
1663   - if (strncmp($opts['compression'],'zip',3) === 0)
1664   - {
1665   - system("zip -Dj ".$id." *.".$ext." 1> /dev/null 2> /dev/null");
1666   - if (strcmp($newname,$id) != 0)
1667   - rename($id.'.zip',$newName.'.zip');
1668   - }
1669   - else
1670   - {
1671   - exec("tar -czf ".$id.".tar.gz *.".$ext);
1672   - // exec("gzip ".$id.".tar");
1673   -
1674   - if (strcmp($newname,$id) != 0)
1675   - rename($id.'.tar.gz', $newName.'.tar.gz');
1676   - }
1677   -
1678   - foreach (glob("*.".$ext) as $file)
1679   - unlink($file);
1680   - }
1681   -
  98 +
1682 99  
1683 100 public function generateVOTableFromDownloadResult($id,$newName,$inputCompressed = true,$canBeAlreadyVOTable = false)
1684 101 {
1685   - $resultDir = USERWORKINGDIR.$id.'_/';
1686   - $opts = $this->getPrintOptions($resultDir);
1687   -
1688   - $votMgr = new BuildVOTable();
1689   - return $votMgr->downloadResultToVOTable($id,$newName,$opts,$inputCompressed,$canBeAlreadyVOTable);
  102 + //ToDo - use the new kernel
  103 + $res = array('success' => false, 'message' => 'NOT IMPLEMENTED => To implement with the new Kernel');
1690 104 }
1691 105  
1692   - /*
1693   - * Renaming and zipping of PDF/PS
1694   - */
1695   - public function postProcessing($id, $newName) {
1696 106  
1697   - switch ($this->type) {
1698   - case 'download' :
1699   - $resultDir = USERWORKINGDIR.$id.'_/';
1700   -
1701   - $opts = $this->getPrintOptions($resultDir);
1702   -
1703   - if ((strcmp($opts['downloadSrc'],'2') !== 0) && (strcmp($opts['fileformat'],'vot') !== 0))
1704   - {
1705   - //add header
1706   - $this->addHeaderInDownloadResult($opts);
1707   - }
1708   -
1709   - //generate votable if necessary
1710   - if ((strcmp($opts['fileformat'],'vot') === 0))
1711   - $this->generateVOTableFromDownloadResult($id,$newName,false,false);
1712   -
1713   - //compression
1714   - $this->compressDownloadResult($id,$newName,$opts);
1715   -
1716   - break;
1717   - case 'condition' :
1718   - break;
1719   - case 'request' :
1720   - $resultDir = USERWORKINGDIR.$id.'_/';
1721   - switch ($this->obj->format) {
1722   - case 'PS' :
1723   - if (file_exists($resultDir.'idl.ps')) {
1724   - rename($resultDir.'idl.ps',$resultDir.$newName.'.ps');
1725   - exec('gzip '.$resultDir.$newName.'.ps');
1726   - }
1727   - break;
1728   - case 'PDF' :
1729   - if (file_exists($resultDir.'idl.ps'))
1730   - exec('ps2pdf -sPAPERSIZE=a4 '.$resultDir.'idl.ps');
1731   - unlink($resultDir.'idl.ps');
1732   - rename($resultDir.'idl.pdf',$resultDir.$newName.'.pdf');
1733   - break;
1734   - default :
1735   - }
1736   - break;
1737 107  
1738   - default :
1739   - }
1740   - }
1741   -
1742   - /*
1743   - * Get real IDL plot settings : !x.window & !y.window for each panel
1744   - */
1745   - protected function getPlotSettings(){
1746   -
1747   - if (!file_exists('plotSettings')) return null;
1748   - $settings = file('plotSettings');
1749   - $plotSetting = new stdClass();
1750   -
1751   - for ($i = 0; $i < count($settings)/2; $i++) {
1752   - $xArr = explode(' ',trim($settings[$i*2]));
1753   - $yArr = explode(' ',trim($settings[$i*2+1]));
1754   - $plotSetting->xmin = $xArr[0];
1755   - $plotSetting->xmax = $xArr[count($xArr)-1];
1756   - $plotSetting->ymin = $yArr[0];
1757   - $plotSetting->ymax = $yArr[count($yArr)-1];
1758   - $plotSettings[$i] = $plotSetting;
1759   - }
1760   - return $plotSettings;
1761   - }
1762   -
1763   -/******************************************************************************
1764   -* Start: Print specific functions
1765   -******************************************************************************/
1766   -
1767   - protected function makePrintRequest($dir)
1768   - {
1769   - $ff = fopen($dir.'print.res','w');
1770   - foreach ($this->obj->list as $param) {
1771   - if ((strncmp($param, "impex___", 8) === 0) || (strncmp($param, "spase___", 8) === 0)){
1772   - $argumentsByParam = $this->cutSimuArgs($param);
1773   - foreach ($argumentsByParam as $key => $value) $param = $key;
1774   - }
1775   - fwrite($ff, $this->param2dd_print($param).' ');
1776   - }
1777   - if ($this->obj->structure == '2') {
1778   - fwrite($ff, PHP_EOL.'multi -1'.PHP_EOL);
1779   - }
1780   - else {
1781   - fwrite($ff, PHP_EOL.'uniq '.$this->obj->sampling.PHP_EOL);
1782   - }
1783   - fwrite($ff,'none'.PHP_EOL);
1784   - $timeFormatNumber = $this->obj->milli ?
1785   - $this->timeFormat[$this->obj->timeformat] + 4 : $this->timeFormat[$this->obj->timeformat];
1786   - fwrite($ff, $timeFormatNumber.PHP_EOL);
1787   - fclose($ff);
1788   - }
1789   -
1790   - protected function createPrintRequestTime($dir)
1791   - {
1792   - $ff = fopen($dir.'print.list','w');
1793   - fwrite($ff,$this->getDdTime($this->obj->startDate).PHP_EOL);
1794   - fwrite($ff,$this->getDdInterval().PHP_EOL);
1795   -
1796   - fclose($ff);
1797   - }
1798   -
1799   - protected function createPrintPostOptions($dir)
1800   - {
1801   - $ff = fopen($dir.'print.opt','w');
1802   - fwrite($ff,$this->obj->compression.PHP_EOL);
1803   - fwrite($ff,$this->obj->fileformat.PHP_EOL);
1804   - fwrite($ff,$this->obj->header.PHP_EOL);
1805   - fwrite($ff,$this->obj->structure.PHP_EOL);
1806   - foreach ($this->obj->list as $param)
1807   - {
1808   -
1809   - if ((strncmp($param, "impex___", 8) === 0) || (strncmp($param, "spase___", 8) === 0)){
1810   - $argumentsByParam = $this->cutSimuArgs($param);
1811   - foreach ($argumentsByParam as $key => $value) $param = $key;
1812   - }
1813   -
1814   - if ($this->obj->downloadSrc == '2')
1815   - fwrite($ff, $param->url.' ');
1816   - else
1817   - fwrite($ff, $param.' '); //data
1818   - }
1819   - fwrite($ff,PHP_EOL.$this->obj->sampling.PHP_EOL);
1820   - fwrite($ff,$this->obj->timeformat.PHP_EOL);
1821   - if ($this->obj->milli)
1822   - fwrite($ff,'1'.PHP_EOL);
1823   - else
1824   - fwrite($ff,'0'.PHP_EOL);
1825   - fwrite($ff,$this->obj->downloadSrc.PHP_EOL);
1826   - fclose($ff);
1827   - }
1828   -
1829   - protected function getDateArray()
1830   - {
1831   - if ($this->obj->startDate){
1832   - $matches=array();
1833   - $tmpArr = explode("T", $this->obj->startDate);
1834   - $dateArr = explode("-", $tmpArr[0]);
1835   - $timeArr = explode(":", $tmpArr[1]);
1836   - preg_match("/([0-9]+)/", $timeArr[2], $matches);
1837   -
1838   - return array("success" => true,
1839   - "year" => ($dateArr[0]),
1840   - "month" => ($dateArr[1]),
1841   - "day" => ($dateArr[2]),
1842   - "hour" => ($timeArr[0]),
1843   - "min" => ($timeArr[1]),
1844   - "sec" => ($matches[1])
1845   - );
1846   - }
1847   - else
1848   - return array('success' => false);
1849   - }
1850   -
1851   - protected function getStopDate()
1852   - {
1853   - $date = $this->getDateArray ();
1854   - return gmdate("Y-m-d\TH:i:s\Z", mktime($date['hour'] + intval($this->obj->durationHour), $date['min']+ intval($this->obj->durationMin), $date['sec']+ intval($this->obj->durationSec), $date['month'], $date['day']+ intval($this->obj->durationDay), $date['year']));
1855   - }
1856   -
1857   -
1858   -/******************************************************************************
1859   - * End: Print specific functions
1860   -*******************************************************************************/
1861 108  
1862 109 /*****************************************************************
1863 110 * PUBLIC FUNCTIONS
1864 111 *****************************************************************/
1865 112  
1866   - public function getPrintOptions($dir)
1867   - {
1868   - $postOptions = file($dir.'print.opt');
1869   - return array('compression' => trim($postOptions[0]),
1870   - 'fileformat' => trim($postOptions[1]),
1871   - 'header' => trim($postOptions[2]),
1872   - 'structure' => trim($postOptions[3]),
1873   - 'params' => trim($postOptions[4]),
1874   - 'sampling' => trim($postOptions[5]),
1875   - 'timeformat' => trim($postOptions[6]),
1876   - 'milli' => trim($postOptions[7]),
1877   - 'downloadSrc' => trim($postOptions[8]));
1878   - }
1879   -
1880   - public function updatePrintRequestTime($dir, $interval)
1881   - {
1882   - $ff = fopen($dir.'print.list','w');
1883   - fwrite($ff,$this->getDdTime($interval['start']).PHP_EOL);
1884   - fwrite($ff,$this->calculateTimeInt($interval).PHP_EOL);
1885   -
1886   - fclose($ff);
1887   - }
1888   -
1889   - public function updatePrintSampling($dir, $sampling)
1890   - {
1891   - $ff = file($dir.'print.res');
1892   - $newSampling = explode(' ',$ff[1]);
1893   - $ff[1] = $newSampling[0].' '.$sampling.PHP_EOL;
1894   -
1895   - file_put_contents($dir.'print.res',$ff);
1896   - }
1897   -
1898   - public function setZoomStart($interval)
1899   - {
1900   - if (!$interval) {
1901   - $time = strtotime($this->obj->startDate);
1902   - $dt = $this->obj->durationDay*86400 +
1903   - $this->obj->durationHour*3600 +
1904   - $this->obj->durationMin*60 + $this->obj->durationSec;
1905   -
1906   - $stopTime = gmdate("Y-m-d\TH:i:s",$time+$dt);
1907   - $interval['start'] = $this->obj->startDate;
1908   - $interval['stop'] = $stopTime;
1909   - }
1910   - $ff = fopen('zoom_intervals','w');
1911   - fwrite($ff, json_encode($interval).PHP_EOL);
1912   - fclose($ff);
1913   - }
1914 113  
1915   - /*
1916   - * Launch process in bkgr; return PID
1917   - */
1918   - public function background($Command)
1919   - {
1920   - $PID = exec("$Command 1> /dev/null 2> /dev/null & echo $!");
1921   - if ($PID != null) return $PID;
1922   -
1923   - return false;
1924   - }
1925 114  
1926 115 /* Stop Time from StartTime and Interval*/
1927 116 public function convertTime($obj)
... ... @@ -1938,34 +127,7 @@ else
1938 127 return $obj;
1939 128 }
1940 129  
1941   - /*
1942   - * Update Time in request
1943   - */
1944   - public function updateTime($requestName, $interval)
1945   - {
1946   - $requestFile = file($requestName);
1947   - $request = fopen($requestName,'w');
1948   -
1949   - $nObjects = 1 + $requestFile[0];
1950   -
1951   - for ($k = 0; $k < $nObjects; $k++) fwrite($request,$requestFile[$k]);
1952   -
1953   - fwrite($request,$this->getDdTime($interval['start']).PHP_EOL);
1954   - fwrite($request,$this->calculateTimeInt($interval).PHP_EOL);
1955   -
1956   - fclose($request);
1957   - }
1958   -
1959   - //From Start Time and Stop Time
1960   - public function createSearchRequestTime2($interval)
1961   - {
1962   - $this->request = fopen(USERWORKINGDIR.'search.list','w');
1963   -
1964   - fwrite($this->request,$this->getDdTime($interval['start']).PHP_EOL);
1965   - fwrite($this->request,$this->calculateTimeInt($interval).PHP_EOL);
1966   -
1967   - fclose($this->request);
1968   - }
  130 +
1969 131  
1970 132 //TODO
1971 133 public function markAsUndefined($paramId)
... ... @@ -2005,452 +167,9 @@ else
2005 167 return $obj;
2006 168 }
2007 169  
2008   - public function cachekiller()
2009   - {
2010   - $date = getdate();
2011   - $cachekiller = $date['mday'].$date['hours'].$date['minutes'].$date['seconds'];
2012   -
2013   - return $cachekiller;
2014   - }
2015   -
2016   - public function killPlot($tabId)
2017   - {
2018   - $tmpname = 'Plot'.$tabId;
2019   -
2020   - $resDirPng = USERWORKINGDIR.$tmpname.'_';
2021   -
2022   - if (!is_dir($resDirPng))
2023   - return array('success' => false, 'message' => 'Cannot find workind directory');
2024   -
2025   - touch($resDirPng."/cancelplot");
2026   -
2027   - return array('success' => true);
2028   - }
2029   -
2030   - public function killMultiPlot($tabIds)
2031   - {
2032   - if (!is_dir(USERWORKINGDIR."CANCELPLOT"))
2033   - mkdir(USERWORKINGDIR."CANCELPLOT");
2034   -
2035   - foreach ($tabIds as $tabId)
2036   - touch(USERWORKINGDIR."CANCELPLOT/".$tabId);
2037   -
2038   - return array('success' => true);
2039   - }
2040   -
2041   -
2042   - public function initResDir($tmpname)
2043   - {
2044   - $resDir = USERWORKINGDIR.$tmpname.'_/';
2045   -
2046   - if (!is_dir($resDir)) {
2047   - if (!mkdir($resDir, 0775))
2048   - return array('success' => false, 'error' => 'can\'t create directory');
2049   - }
2050   -
2051   - if (!chdir($resDir)){
2052   - return array('success' => false, 'error' => 'can\'t change directory');
2053   - }
2054   -
2055   - return array('success' => true, 'resdir' => $resDir);
2056   - }
2057   -
2058   - /*
2059   - * Try to estimate File Size from param size, time int and sampling
2060   - */
2061   - public function estimateOutputFileSize($obj, $ttInterval)
2062   - {
2063   - $timeConvert = array("s" => 1, "m" => 60, "h" => 3600);
2064   -
2065   - if (!$obj) $obj = $this->obj;
2066   -
2067   - $interval = $ttInterval ? $ttInterval : $obj->durationDay*86400 +
2068   - $obj->durationHour*3600 +
2069   - $obj->durationMin*60 + $obj->durationSec;
2070   -
2071   - $infoMgr = new ParamsInfoMgr();
2072   -
2073   - $multi = $obj->structure == 2;
2074   -
2075   - $timeLength = $obj->milli ? 25 : 20;
2076   -
2077   - $fileSize = $multi ? 0 : $timeLength;
2078   - $sampling_virtual = 60.0;
2079   - $size_virtual = 1;
2080   -
2081   - foreach ($obj->list as $param) {
2082   -
2083   - $info = $infoMgr->GetParamInfo($param);
2084   -
2085   - if (!$info['success']) {
2086   - $size = $size_virtual;
2087   - $sampling = $sampling_virtual;
2088   - }
2089   - else {
2090   - // derived parameter
2091   - if (strncmp(strtolower($param), 'ws_', 3) == 0) {
2092   - $size = 1;
2093   - if ($multi) {
2094   - $sampling = $info['infos']['timestep'];
2095   - }
2096   - }
2097   - // my data parameter
2098   - else if (strncmp(strtolower($param), 'wsd_', 4) == 0) {
2099   - $size = $info['infos']['size'];
2100   - $sampling = $info['infos']['minsampling'];
2101   - }
2102   - else {
2103   - $codeinfo = $info['codeinfos'];
2104   - $ddinfo = $info['ddinfos'];
2105   - if ($codeinfo) {
2106   - $size = $codeinfo['size'];
2107   - $sampling = $codeinfo['minsampling'];
2108   - }
2109   - else {
2110   - $size = $ddinfo['parameter']['size'];
2111   - $sampling = substr($ddinfo['dataset']['minsampling'], 0, -1);
2112   - $sampling *= $timeConvert[substr($ddinfo['dataset']['minsampling'], -1)];
2113   - }
2114   - // if component
2115   - if (sscanf($param,"%[^'('](%d)",$par,$cstart) == 2) $size = 1;
2116   - }
2117   - }
2118   -
2119   - if ($multi) {
2120   - $fileSize += $interval / $sampling * ($size * 13 + $timeLength);
2121   - }
2122   - else {
2123   - $fileSize += $size * 13;
2124   - }
2125   - }
2126   -
2127   - if (!$multi) {
2128   - $fileSize *= $interval / $obj->sampling;
2129   - }
2130   -
2131   - if ($obj->fileformat === 'vot')
2132   - $fileSize *= 1.8;
2133 170  
2134   - return $fileSize;
2135   - }
  171 +
2136 172  
2137   - /*
2138   - * THE MAIN EXECUTE PART
2139   - */
2140   - public function execute($obj)
2141   - {
2142   - $this -> setObject($obj);
2143 173  
2144   - //TODO define user in AmdaAction constructor : unique SESSION_ID
2145   - if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
2146   - {
2147   - $dd = new WSUserMgr();
2148   - $dd->init($obj->username,$obj->password,$obj->sessionID);
2149   - }
2150   - else
2151   - $dd = new UserMgr();
2152   -
2153   - //TODO error handling
2154   - if (($res = $dd -> ddCheckUser()) != 0) {
2155   - if ($res == 156)
2156   - return array('error' => 'Your AMDA session is expired.<br/> Login please!');
2157   -
2158   - return array('error' => 'ddLogin error: '.$res);
2159   - }
2160   -
2161   - if ($dd->user == 'impex') {
2162   - if ($dd->getWsSize() > DISK_QUOTA * 100)
2163   - error_log('Natacha! It is time to CLEAN UP IMPEX WS!',1,'nbourrel@irap.omp.eu');
2164   - }
2165   - else {
2166   - // check disk space
2167   - if ($dd->getWsSize() > DISK_QUOTA)
2168   - return array('error' => 'Please clean up your workspace.<br/>No more space is available');
2169   - }
2170   -
2171   - $isMulti = $this->obj->timeTables ? true: false;
2172   -
2173   - // AMDA Statistics
2174   - $amdaStat = new AmdaStats($dd->user);
2175   -
2176   - chdir(USERWORKINGDIR);
2177   -
2178   - // temp name for output
2179   - $cachekiller = $this->cachekiller();
2180   - $text = 'result';
2181   - if ($this->obj->name) $text = $this->obj->name;
2182   - if ($this->obj->output) $text = $this->obj->output;
2183   - if ($this->obj->outputName) $text = $this->obj->outputName;
2184   -
2185   - $newName = $text.'_'.$cachekiller;
2186   -
2187   - // temp name for output
2188   - $tmpname = $this->getRandomName();
2189   - $isPNG = false;
2190   -
2191   - if ($this->obj->format && $this->obj->format == 'PNG')
2192   - {
2193   - $isPNG = true;
2194   - $tmpname = 'Plot'.$this->obj->tabId;
2195   - }
2196   -
2197   - //TODO organize better : functions, classes?
2198   - switch ($this->type)
2199   - {
2200   - // DD Search
2201   - case 'condition':
2202   - $tmpname = $newName;
2203   - //if alias exists, replace alias name by parameter name
2204   - if (file_exists(USERWSDIR.'Alias.xml'))
2205   - {
2206   - $obj->expression = $this->resetAlias($obj->expression);
2207   - }
2208   - $realVars = $this -> makeSearchParams();
2209   -
2210   - if ($amdaStat->success)
2211   - $amdaStat->addTask('mining', $dd->user, $realVars);
2212   -
2213   - $this -> createSearchRequest($realVars, $tmpname);
2214   -
2215   - if ($this->paramsWithoutCode)
2216   - $this->makeLocalParams($realVars);
2217   -
2218   - if ($isMulti) {
2219   - $cmd = 'php '.CLASSPATH.'../MultiRequestMgr.php \''.json_encode($this->obj).'\' \''.$tmpname.'\' \''.$dd->user.'\' \''.$dd->IP.'\'';
2220   - }
2221   - else {
2222   - $this -> createSearchRequestTime();
2223   - $cmd = DDBIN."DD_Search ".$dd->user." ".$dd->IP." ".DDPROJECT." ".DDPROJLIB;
2224   - }
2225   - break;
2226   - // DD Print
2227   - case 'download':
2228   -
2229   - if ($this->obj->downloadSrc == 0) {
2230   - if (file_exists(USERWSDIR.'Alias.xml')) {
2231   - foreach($this->obj->list as &$param)
2232   - $param = $this->resetAlias($param);
2233   - }
2234   - $isSimu = false;
2235   - foreach ($this->impex_prefix as $impex_prefix) if (strpos($param, $impex_prefix) !== false) $isSimu = true;
2236   -
2237   - if ((!$isMulti) || (!$isSimu)) {
2238   - $outputFileSize = $this->estimateOutputFileSize();
2239   - if ( $outputFileSize > DISK_QUOTA ) { //DISK_QUOTA
2240   - $outputFileSize /= 1024*1024;
2241   - return array('error' => "Sorry! Requested file is too large: ".$outputFileSize."MB
2242   - <br/>Decrease requested time interval" );
2243   - }
2244   - }
2245   - }
2246   -
2247   - $res = $this->initResDir($tmpname);
2248   - if (!$res['success'])
2249   - return $res;
2250   -
2251   - $resDir = $res['resdir'];
2252   -
2253   - switch ($this->obj->downloadSrc)
2254   - {
2255   - case '2' : //fits images
2256   -
2257   - $this->createPrintPostOptions($resDir);
2258   - $cmd = '';
2259   - foreach ($this->obj->list as $file) {
2260   - if ($cmd != '')
2261   - $cmd .= "|";
2262   - $cmd .= "wget -O ".$file->name." \"".$file->url."\"";
2263   - }
2264   - break;
2265   -
2266   - case '0' : //data
2267   -
2268   - if ($amdaStat->success)
2269   - $amdaStat->addTask('print', $dd->user, $obj->list);
2270   -
2271   - if ($this->paramsWithoutCode)
2272   - $this->makeLocalParams($obj->list);
2273   - if ($this->spectraParams)
2274   - $this->makeSpectraParams($obj->list);
2275   - if ($this->dataBases)
2276   - $this->makeRemoteParams($obj->list);
2277   -
2278   - $this->makeWsParams($obj->list);
2279   -
2280   - $wsdVars = $this->getWsdVars($obj->list);
2281   - if ($wsdVars) $this->makeWsdParams($wsdVars);
2282   -
2283   - // if 'impex' in $realVars upload simulation data
2284   - $impexVars = $this->getImpexVars($obj->list);
2285   - $imp = array('realVars'=> $impexVars, 'fromWS' => true);
2286   - if ($impexVars) $this->makeWsrParams($imp);
2287   -
2288   - $this->makePrintRequest($resDir);
2289   - $this->createPrintPostOptions($resDir);
2290   -
2291   - if ($isMulti) {
2292   - $cmd = 'php '.CLASSPATH.'../MultiRequestMgr.php \''.json_encode($this->obj).'\' \''.$tmpname.'\' \''.$dd->user.'\' \''.$dd->IP.'\' \''.$newName.'\'';
2293   - }
2294   - else
2295   - {
2296   - $this->createPrintRequestTime($resDir);
2297   - $cmd = DDBIN.'DD_Print '.$dd->user.' '.$dd->IP.' '.DDPROJECT.' '.DDPROJLIB;
2298   - }
2299   - break;
2300   - }
2301   - break;
2302   - // DD Plot / DD PS
2303   - case 'request':
2304   - //if alias exists, replace alias name by parameter name
2305   - if (file_exists(USERWSDIR.'Alias.xml'))
2306   - {
2307   - for ($i=0; $i < count($obj->children); $i++)
2308   - {
2309   - for ($j=0; $j < count($obj->children[$i]->children); $j++)
2310   - {
2311   - $obj->children[$i]->children[$j]->name = $this->resetAlias($obj->children[$i]->children[$j]->name);
2312   - }
2313   - }
2314   - }
2315   -
2316   - // For PNG, PS, PDF
2317   - $res = $this->initResDir($tmpname);
2318   - if (!$res['success'])
2319   - return $res;
2320   - $resDirPng = $res['resdir'];
2321   -
2322   - if (file_exists($resDirPng."/cancelplot"))
2323   - unlink($resDirPng."/cancelplot");
2324   -
2325   - // general Plot settings : DD_request.res
2326   - $this -> setPlot();
2327   -
2328   - // amda statistics
2329   - if ($amdaStat->success) {
2330   - $varArray = array();
2331   - foreach ($this->obj->children as $panel)
2332   - foreach ($panel->children as $plotVar)
2333   - $varArray[] = $plotVar->text;
2334   - $amdaStat->addTask('plot', $dd->user, $varArray);
2335   - }
2336   -
2337   - // panels definitions with/without time
2338   - $realVars = $this->setPlotObjects($this->obj->children, $tmpname);
2339   - if ($this->paramsWithoutCode) $this->makeLocalParams($realVars);
2340   -
2341   - $this->makeWsParams($realVars);
2342   -
2343   - $wsdVars = $this->getWsdVars($realVars);
2344   - if ($wsdVars) $this->makeWsdParams($wsdVars);
2345   -
2346   - // if 'impex' in $realVars upload simulation data
2347   - $impexVars = $this->getImpexVars($realVars);
2348   - $imp = array('realVars'=> $impexVars, 'fromWS' => false);
2349   - if ($impexVars) $this->makeWsrParams($imp);
2350   -
2351   - //Interactive session : create special folder
2352   - if ($this->obj->format == 'PNG')
2353   - {
2354   - // Time table plot
2355   - if ($isMulti)
2356   - {
2357   - $interval = $this->prepareTimeTablePlot($resDirPng);
2358   - $this->updateTime('./'.$tmpname, $interval); //update/add time
2359   - $this->setZoomStart($interval);
2360   - }
2361   - else
2362   - $this->setZoomStart();
2363   - $cmd = DDBIN."DD_Plot ".$tmpname." ".$dd->user." ".$dd->IP." ".DDPROJECT." ".DDPROJLIB;
2364   - }
2365   - else
2366   - {
2367   - if ($isMulti) {
2368   - $cmd = 'php '.CLASSPATH.'../MultiRequestMgr.php \''.json_encode($this->obj).'\' \''.$tmpname.'\' \''.$dd->user.'\' \''.$dd->IP.'\' \''.$newName.'\'';
2369   - }
2370   - else {
2371   - $cmd = DDBIN."DD_PS ".$tmpname." ".$dd->user." ".$dd->IP." ".DDPROJECT." ".DDPROJLIB;
2372   - }
2373   - }
2374   - break;
2375   -
2376   - default :
2377   - return array('error' => $this->type." NOT IMPLEMENTED YET");
2378   - }
2379   - $pid = $this->background($cmd);
2380   - //TODO KILL method for real TIMEOUT
2381   - $jobMgr = new JobsMgr();
2382   - $cyclesNumber = $isPNG ? PLOT_CYCLES_NUMBER: JOB_CYCLES_NUMBER;
2383   -
2384   - $reqStart = time();
2385   -
2386   - //TODO return ERRORS also
2387   - for ($cycle = 0; $cycle < $cyclesNumber; $cycle++)
2388   - {
2389   - sleep(JOBTIMEOUT);
2390   -
2391   - $reqTime = time() - $reqStart;
2392   -
2393   - if ($reqTime > $cyclesNumber*JOBTIMEOUT)
2394   - break;
2395   -
2396   - if ( $isPNG && is_dir(USERWORKINGDIR."CANCELPLOT") ) {
2397   - if (file_exists(USERWORKINGDIR."CANCELPLOT/".$this->obj->tabId))
2398   - rename(USERWORKINGDIR."CANCELPLOT/".$this->obj->tabId,$resDirPng."/cancelplot");
2399   -
2400   - if (count(scandir(USERWORKINGDIR."CANCELPLOT")) == 2) rmdir(USERWORKINGDIR."CANCELPLOT");
2401   -
2402   - }
2403   - if ( $isPNG && file_exists($resDirPng."/cancelplot"))
2404   - {
2405   - if (!$jobMgr->isFinished($pid))
2406   - {
2407   - $cmd = 'kill -9 '.$pid;
2408   - exec($cmd);
2409   - }
2410   -
2411   - foreach (glob($resDirPng.'/*') as $filename)
2412   - unlink($filename);
2413   -
2414   - rmdir($resDirPng);
2415   -
2416   - return array('error' => "Plot canceled!");
2417   - }
2418   -
2419   - if ($jobMgr->isFinished($pid))
2420   - {
2421   - if (!$isPNG) $newId = $jobMgr->addJob($this->obj, 0, $tmpname, $newName);
2422   -
2423   - if ($tmpname !== $newName) $this->postProcessing($tmpname, $newName);
2424   - $arrayMain = array('pid' => '0', 'name' => $newName, 'id' => $tmpname);
2425   -
2426   - if ($isPNG)
2427   - {
2428   - $outputName = $this->obj->outputName? $this->obj->outputName : $tmpname;
2429   - rename($tmpname.'.png', $outputName.'_'.$cachekiller.'.png');
2430   - $arrayMain['name'] = $outputName.'_'.$cachekiller;
2431   -
2432   - $plotSettings = $this->getPlotSettings();
2433   - $arrayMain['children'] = $plotSettings;
2434   - $arrayMain['tabId'] = $this->obj->tabId;
2435   - // PNG plotting of time tables
2436   - if ($isMulti)
2437   - {
2438   - $arrayTable = array('startDate' => $interval['start'],
2439   - 'stopDate' => $interval['stop'],
2440   - 'intervalN' => $this->currentInt,
2441   - 'totalN' => $this->totalInt,
2442   - 'tableName' => $this->ttName);
2443   - return array_merge($arrayMain, $arrayTable);
2444   - }
2445   - }
2446   - return $arrayMain;
2447   - }
2448   - }
2449   -
2450   - // Add Job in BATCH MODE
2451   - $newId = $jobMgr->addJob($this->obj, $pid, $tmpname);
2452   -
2453   - return array('pid' => $pid, 'id' => $newId, 'rawname' => $tmpname);
2454   - }
2455 174 }
2456 175 ?>
... ...
php/classes/TimeTableMgr.php
... ... @@ -755,56 +755,6 @@ class TimeTableMgr extends AmdaObjectMgr
755 755 return $result;
756 756 }
757 757  
758   -/*
759   -* execute = download TT
760   -*/
761   - public function execute($obj) {
762   -
763   - $final = null;
764   - $liste = null;
765   -
766   - // Delete *.zip and *.gz
767   - foreach (glob(USERWORKINGDIR."*.gz") as $filename) unlink($filename);
768   - foreach (glob(USERWORKINGDIR."*.zip") as $filename) unlink($filename);
769   -
770   - $transform = "xsl2".$obj->fileformat;
771   - $format = $obj->timeformat;
772   - // shared or my
773   -
774   -
775   - for ($i=0; $i < count($obj->list); $i++) {
776   - $file = $obj->list[$i].'.xml';
777   - $pathid = (substr($obj->list[$i],0,6) == 'shared') ? SHAREDPATH.'TT/': USERTTDIR;
778   - if (file_exists($pathid.$file)) {
779   - $result = $this->$transform($pathid.$file,$format);
780   - $liste = $liste." ".substr(strrchr($result, "/"),1);
781   - $final = $final." ".$result;
782   - }
783   - }
784   - // Compress the result
785   - $archive = USERWORKINGDIR."Timetable_archive_".date('Ymd_Hi');
786   -
787   - if ($obj->compression == "zip")
788   - {
789   - system("zip -Dj ".$archive.".zip ".$final." 1> /dev/null 2> /dev/null");
790   - $outFile = $archive.".zip";
791   - }
792   - else if ($obj->compression == "tar+gzip")
793   - {
794   - system("tar cfz ".$archive.".tar.gz --directory=".USERWORKINGDIR." ".$liste."");
795   - $outFile = $archive.".tar.gz";
796   - }
797   -
798   - // Delete modified time tables (.txt or .xml)
799   - $tt = split(" ",$final);
800   - foreach ($tt as $name) {
801   - if (file_exists($name)) unlink($name);
802   - }
803   - $retFile = substr_replace($outFile,'', 0, strlen(BASE_PATH));
804   -
805   - return array('download' => $retFile);
806   -
807   - }
808 758  
809 759 function validNameObject($p){
810 760 // overwritten
... ...