Blame view

js/app/controllers/PlotModule.js 12.1 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
/** 
 * Project   : AMDA-NG
 * Name      : PlotModule.js
 * @class    amdaDesktop.PlotModule
 * @extends  amdaDesktop.InteractiveModule
18d4a11e   Benjamin Renard   Save and load plo...
6
7
8
 * @brief    New Plot Module controller definition 
 * @author   Benjamin Renard
 * $Id: PlotModule.js benjamin $
16035364   Benjamin Renard   First commit
9
10
11
 */

Ext.define('amdaDesktop.PlotModule', {
bd8d75af   Menouard AZIB   Disable paramter ...
12
13
14
15
16
17
18
19
20
21
22
23
24
    extend: 'amdaDesktop.InteractiveModule',

    requires: [
        'amdaUI.PlotUI',
        'amdaPlotObj.MultiplotRequestObject',
        'amdaModel.MultiplotNode',
        'amdaUI.PlotTabResultUI',
        'amdaPlotComp.PlotPreviewUI',
        'amdaUI.MultiPlotUI'
    ],

    contentId: 'plotUI',
    linkedNode: null,
235edd5f   Menouard AZIB   Updates from dev
25
    panelResultInstance: null,
bd8d75af   Menouard AZIB   Disable paramter ...
26

16035364   Benjamin Renard   First commit
27
    /**
18d4a11e   Benjamin Renard   Save and load plo...
28
29
30
     * @cfg {String} data models
     * @required
     */
bd8d75af   Menouard AZIB   Disable paramter ...
31
32
    nodeDataModel: 'amdaModel.MultiplotNode',

16035364   Benjamin Renard   First commit
33
34
35
36
    /**
     * @cfg {String} window definitions
     * @required
     */
bd8d75af   Menouard AZIB   Disable paramter ...
37
    width: 650,
d341347d   Elena.Budnik   Plot Mgr ameliora...
38
    height: 670,
bd8d75af   Menouard AZIB   Disable paramter ...
39
40
41
42
43
44
    uiType: 'newPanelPlot',
    helpTitle: 'Help on Plot Module',
    helpFile: 'plotHelp',

    plotResultWindowsManager: new Ext.AbstractManager(),

4efeb459   Benjamin Renard   First version for...
45
    multiPlotWin: null,
bd8d75af   Menouard AZIB   Disable paramter ...
46
47

    computeResultWindowSize: function (panelResult) {
5c744625   Benjamin Renard   Synchronize reque...
48
        var size = panelResult.getImageSize();
bd8d75af   Menouard AZIB   Disable paramter ...
49
        size.width += 30;
5c744625   Benjamin Renard   Synchronize reque...
50
51
52
        size.height += 95;
        return size;
    },
bd8d75af   Menouard AZIB   Disable paramter ...
53
54

    computePreviewWindowSize: function (previewContent) {
5c744625   Benjamin Renard   Synchronize reque...
55
        var size = previewContent.getImageSize();
bd8d75af   Menouard AZIB   Disable paramter ...
56
        size.width += 30;
a0db7984   Erdogan Furkan   #10663 - Done
57
        size.height += 100;
5c744625   Benjamin Renard   Synchronize reque...
58
59
        return size;
    },
592d7b65   Menouard AZIB   Merge develop int...
60

d0692c05   Menouard AZIB   Everthing works well
61
    updateInteractiveSession: function (session, newplot, panelId_, time_) {
5c744625   Benjamin Renard   Synchronize reque...
62
        var me = this;
2cfa3a1a   Benjamin Renard   Give the possibil...
63

5c744625   Benjamin Renard   Synchronize reque...
64
65

        Ext.each(session.result, function (tabResult, index) {
5c744625   Benjamin Renard   Synchronize reque...
66
            if (logExecTime && tabResult.exectime) {
bd8d75af   Menouard AZIB   Disable paramter ...
67
                console.log("CMD EXEC TIME FOR " + tabResult.plot + " = " + tabResult.exectime + "ms");
5c744625   Benjamin Renard   Synchronize reque...
68
69
70
71
            }

            if (tabResult.preview) {
                var plotPreviewConfig = {
bd8d75af   Menouard AZIB   Disable paramter ...
72
73
74
                    folder: session.folder,
                    plotFile: tabResult.plot,
                    context: tabResult.context,
d0692c05   Menouard AZIB   Everthing works well
75
76
                    time: time_,
                    panelId: panelId_,
bd8d75af   Menouard AZIB   Disable paramter ...
77
                    interactiveId: tabResult.id
5c744625   Benjamin Renard   Synchronize reque...
78
79
80
81
82
                };
                me.updatePreview(plotPreviewConfig);
                return;
            }

bd8d75af   Menouard AZIB   Disable paramter ...
83
84
            var winResultId = tabResult.id + "-win";

5c744625   Benjamin Renard   Synchronize reque...
85
            var winResult = me.getWindowResult(winResultId);
bd8d75af   Menouard AZIB   Disable paramter ...
86

5c744625   Benjamin Renard   Synchronize reque...
87
            var plotTabConfig = {
bd8d75af   Menouard AZIB   Disable paramter ...
88
89
90
91
                folder: session.folder,
                plotFile: tabResult.plot,
                context: tabResult.context,
                interactiveId: tabResult.id,
5c744625   Benjamin Renard   Synchronize reque...
92
                isInterval: tabResult.isInterval,
bd8d75af   Menouard AZIB   Disable paramter ...
93
94
95
96
                ttName: tabResult.ttName,
                ttIndex: tabResult.ttIndex,
                ttNbIntervals: tabResult.ttNbIntervals,
                ttFileIndex: tabResult.ttFileIndex,
27a055f4   Benjamin Renard   Multiplot (#8314)
97
                multiplot: tabResult.multiplot
5c744625   Benjamin Renard   Synchronize reque...
98
            };
bd8d75af   Menouard AZIB   Disable paramter ...
99

5c744625   Benjamin Renard   Synchronize reque...
100
101
102
103
104
            if (winResult == null) {
                var x = 50 + tabResult.index * 50;
                var y = 100 + tabResult.index * 20;
                //create new result win
                var panelResult = new amdaUI.PlotTabResultUI(plotTabConfig);
592d7b65   Menouard AZIB   Merge develop int...
105
                me.panelResultInstance = panelResult;
5c744625   Benjamin Renard   Synchronize reque...
106
107
108
                var size = me.computeResultWindowSize(panelResult);

                var win = myDesktopApp.getDesktop().createWindow({
bd8d75af   Menouard AZIB   Disable paramter ...
109
110
111
                    id: tabResult.id + "-win",
                    title: tabResult.title,
                    width: size.width,
5c744625   Benjamin Renard   Synchronize reque...
112
                    height: size.height,
bd8d75af   Menouard AZIB   Disable paramter ...
113
114
                    x: x,
                    y: y,
5c744625   Benjamin Renard   Synchronize reque...
115
                    layout: 'fit',
bd8d75af   Menouard AZIB   Disable paramter ...
116
117
                    items: [
                        panelResult
5c744625   Benjamin Renard   Synchronize reque...
118
119
                    ],
                    listeners: {
bd8d75af   Menouard AZIB   Disable paramter ...
120
121
                        scope: me,
                        beforeclose: function (win, opt) {
5c744625   Benjamin Renard   Synchronize reque...
122
                            me.plotResultWindowsManager.unregister(win);
27a055f4   Benjamin Renard   Multiplot (#8314)
123
                        },
bd8d75af   Menouard AZIB   Disable paramter ...
124
                        afterrender: function (win, opt) {
55b10506   Benjamin Renard   Update correctly ...
125
                            win.getPanelResult().updateConfig(tabResult.title, tabResult.multiplot);
5c744625   Benjamin Renard   Synchronize reque...
126
127
                        }
                    },
bd8d75af   Menouard AZIB   Disable paramter ...
128
                    getPanelResult: function () {
5c744625   Benjamin Renard   Synchronize reque...
129
                        return panelResult;
27a055f4   Benjamin Renard   Multiplot (#8314)
130
                    },
bd8d75af   Menouard AZIB   Disable paramter ...
131
                    updateTitle: function (multiplot) {
27a055f4   Benjamin Renard   Multiplot (#8314)
132
                        win.setTitle(tabResult.title + (multiplot ? ' - Synchronized to multiplot' : ''));
5c744625   Benjamin Renard   Synchronize reque...
133
134
135
136
137
138
139
                    }
                });
                win.show();
                me.plotResultWindowsManager.register(win);
            }
            else {
                //update result
55b10506   Benjamin Renard   Update correctly ...
140
                winResult.getPanelResult().updateConfig(tabResult.title, tabResult.multiplot);
5c744625   Benjamin Renard   Synchronize reque...
141
                winResult.getPanelResult().updatePlotImage(plotTabConfig, newplot);
bb30f90e   Hacene SI HADJ MOHAND   9010 ok
142
143
144
                //update window size => not done see https://projects.irap.omp.eu/issues/9010
                //var size = me.computeResultWindowSize(winResult.getPanelResult());
                //winResult.setSize(size.width, size.height);
5c744625   Benjamin Renard   Synchronize reque...
145
146
147
                winResult.toFront();
            }
        });
18d4a11e   Benjamin Renard   Save and load plo...
148
    },
bd8d75af   Menouard AZIB   Disable paramter ...
149
150

    closeInteractiveSession: function () {
5c744625   Benjamin Renard   Synchronize reque...
151
152
153
154
        var me = this;
        this.plotResultWindowsManager.each(function (key, value, length) {
            value.close();
        });
bd8d75af   Menouard AZIB   Disable paramter ...
155
156
157
        if (this.multiPlotWin) {
            this.multiPlotWin.close();
        }
18d4a11e   Benjamin Renard   Save and load plo...
158
    },
5c744625   Benjamin Renard   Synchronize reque...
159

bd8d75af   Menouard AZIB   Disable paramter ...
160
161
    updatePlotResultTitle: function (tabIndex, title) {
        var winResultId = 'plot_' + tabIndex + '-win';
d4ab05cd   Benjamin Renard   Update interactiv...
162
163
164
165
166
167
168
        var winResult = this.getWindowResult(winResultId);
        if (winResult) {
            winResult.setTitle(title);
            myDesktopApp.getDesktop().taskbar.windowBar.items.each(function (item) {
                if (winResult == item.win) {
                    item.setText(title);
                }
bd8d75af   Menouard AZIB   Disable paramter ...
169
            });
d4ab05cd   Benjamin Renard   Update interactiv...
170
171
172
        }
    },

bd8d75af   Menouard AZIB   Disable paramter ...
173
    updatePreview: function (plotPreviewConfig) {
5c744625   Benjamin Renard   Synchronize reque...
174
175
176
177
178
179
180
        var winPreviewId = "plot-preview-win";

        var winPreview = this.getWindowResult(winPreviewId);

        if (winPreview == null) {
            //create new preview win
            var previewContent = new amdaPlotComp.PlotPreviewUI(plotPreviewConfig);
a0db7984   Erdogan Furkan   #10663 - Done
181
182
            previewContent.setPanelResultInstance(this.panelResultInstance);
            //previewContent.setPanelId
5c744625   Benjamin Renard   Synchronize reque...
183
184
185
            var size = this.computePreviewWindowSize(previewContent);

            var win = myDesktopApp.getDesktop().createWindow({
bd8d75af   Menouard AZIB   Disable paramter ...
186
187
188
                id: winPreviewId,
                title: 'Plot Preview',
                width: size.width,
5c744625   Benjamin Renard   Synchronize reque...
189
190
                height: size.height,
                layout: 'fit',
bd8d75af   Menouard AZIB   Disable paramter ...
191
192
                items: [
                    previewContent
5c744625   Benjamin Renard   Synchronize reque...
193
194
                ],
                listeners: {
bd8d75af   Menouard AZIB   Disable paramter ...
195
196
                    scope: this,
                    beforeclose: function (win, opt) {
5c744625   Benjamin Renard   Synchronize reque...
197
198
199
                        this.plotResultWindowsManager.unregister(win);
                    }
                },
bd8d75af   Menouard AZIB   Disable paramter ...
200
                getPreviewContent: function () {
5c744625   Benjamin Renard   Synchronize reque...
201
202
203
204
205
206
207
208
209
210
211
212
213
214
                    return previewContent;
                }
            });
            win.show();
            this.plotResultWindowsManager.register(win);
        }
        else {
            //update result
            winPreview.getPreviewContent().updatePlotImage(plotPreviewConfig);
            //update window size
            var size = this.computePreviewWindowSize(winPreview.getPreviewContent());
            winPreview.setSize(size.width, size.height);
            winPreview.toFront();
        }
c9071a43   Benjamin Renard   Add instant plot ...
215
    },
bd8d75af   Menouard AZIB   Disable paramter ...
216
217
218
219

    getWindowResult: function (winResultId) {
        if (!this.plotResultWindowsManager.get(winResultId)) return null;
        return this.plotResultWindowsManager.get(winResultId);
57e15214   Benjamin Renard   Fix addParameter ...
220
    },
bd8d75af   Menouard AZIB   Disable paramter ...
221
222
223

    setTimeInterval: function (timeObj) {
        var me = this;
67210d01   Hacene SI HADJ MOHAND   #9800
224
225
226
227
228
229
230
231
232
233
234
235
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow(this.id);
        if (win) {
            me.getUiContent().setTimeFromData(timeObj);
            win.show();
        }
        else {
            this.createWindow(function () {
                me.getUiContent().setTimeFromData(timeObj);
            });
        }
    },
57e15214   Benjamin Renard   Fix addParameter ...
236

bd8d75af   Menouard AZIB   Disable paramter ...
237
    addParameter: function (paramNode) {
57e15214   Benjamin Renard   Fix addParameter ...
238
239
240
241
242
243
244
245
246
247
248
249
        var me = this;
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow(this.id);
        if (win) {
            me.getUiContent().addParameter(paramNode, false);
            win.show();
        }
        else {
            this.createWindow(function () {
                me.getUiContent().addParameter(paramNode, true);
            });
        }
2048f5bc   Benjamin Renard   Fix save & edit plot
250
    },
bd8d75af   Menouard AZIB   Disable paramter ...
251
    editPlot: function (plotNode) {
2048f5bc   Benjamin Renard   Fix save & edit plot
252
253
254
255
256
        var me = this;
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow(this.id);
        if (win) {
            // Plot UI is opened => add plot in a new tab
55fa3bbc   Benjamin Renard   Reset plot reques...
257
            me.linkedNode.get('object').plots().add(plotNode);
2048f5bc   Benjamin Renard   Fix save & edit plot
258
259
260
261
262
            me.getUiContent().editPlot(plotNode);
            win.show();
        }
        else {
            // Plot UI is closed
bd8d75af   Menouard AZIB   Disable paramter ...
263
            this.createWindow(null, function () {
2048f5bc   Benjamin Renard   Fix save & edit plot
264
265
266
267
268
269
                //This is the onAfterCreateObject callback
                //Add plot node to the multiplot object
                me.linkedNode.get('object').plots().removeAll();
                me.linkedNode.get('object').plots().add(plotNode);
            });
        }
84d442b4   Benjamin Renard   Synchronize plot ...
270
271
    },

bd8d75af   Menouard AZIB   Disable paramter ...
272
    syncAfterRename: function (renamedNode) {
84d442b4   Benjamin Renard   Synchronize plot ...
273
274
275
276
277
        var me = this;
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow(this.id);
        if (win) {
            me.getUiContent().updateTabs();
5c744625   Benjamin Renard   Synchronize reque...
278
            me.getUiContent().updateRequestName(renamedNode);
84d442b4   Benjamin Renard   Synchronize plot ...
279
        }
4efeb459   Benjamin Renard   First version for...
280
281
    },

bd8d75af   Menouard AZIB   Disable paramter ...
282
283
    showMultiplotWin: function () {
        var me = this;
4efeb459   Benjamin Renard   First version for...
284
285
286
287
288
289
290
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow(this.id);

        if (!win) {
            return;
        }

bd8d75af   Menouard AZIB   Disable paramter ...
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
        if (!this.multiPlotWin) {
            var multiPlotPanel = Ext.create('amdaUI.MultiPlotUI',
                {
                    plotWin: me.getUiContent()
                }
            );
            this.multiPlotWin = myDesktopApp.getDesktop().createWindow({
                id: "multiplot-win",
                title: "Multi Plot Manager",
                width: 320,
                height: 320,
                minHeight: 300,
                minWidth: 320,
                layout: 'fit',
                items: [
                    multiPlotPanel
                ],
                listeners: {
                    beforeclose: function (win, opt) {
                        me.multiPlotWin = null;
                        me.getUiContent().enableSinglePlot(true);
                        me.plotResultWindowsManager.each(function (key, value, length) {
                            value.getPanelResult().updateConfig(value.getPanelResult().plotName, false);
                        });
                    }
                }
            });
        }
4efeb459   Benjamin Renard   First version for...
319

d4a8d462   Benjamin Renard   Improve MultiPlot...
320
        this.getUiContent().enableSinglePlot(false);
bd8d75af   Menouard AZIB   Disable paramter ...
321
        this.multiPlotWin.show();
4efeb459   Benjamin Renard   First version for...
322
323
324

    },

bd8d75af   Menouard AZIB   Disable paramter ...
325
    refreshMultiPlot: function () {
4efeb459   Benjamin Renard   First version for...
326
327
328
        if (this.multiPlotWin) {
            this.multiPlotWin.items.items[0].refreshMultiPlot();
        }
d4a8d462   Benjamin Renard   Improve MultiPlot...
329
        this.getUiContent().enableSinglePlot(!this.isMultiPlot());
4efeb459   Benjamin Renard   First version for...
330
331
    },

bd8d75af   Menouard AZIB   Disable paramter ...
332
    isMultiPlot: function () {
4efeb459   Benjamin Renard   First version for...
333
        return this.multiPlotWin && !this.multiPlotWin.isHidden();
0e540b69   Benjamin Renard   Finalize save of ...
334
335
    },

bd8d75af   Menouard AZIB   Disable paramter ...
336
    editInDownloadModule: function (plotNode) {
0e540b69   Benjamin Renard   Finalize save of ...
337
338
339
340
341
342
343
344
345
        var plotValues = plotNode.get('object').getJsonValues();
        var downloadValues = new Object();
        downloadValues.timesrc = plotValues.timesrc;
        downloadValues.startDate = plotValues.startDate;
        downloadValues.stopDate = plotValues.stopDate;
        downloadValues.durationDay = plotValues.durationDay;
        downloadValues.durationHour = plotValues.durationHour;
        downloadValues.durationMin = plotValues.durationMin;
        downloadValues.durationSec = plotValues.durationSec;
b852834a   Hacene SI HADJ MOHAND   progress
346
        downloadValues.durationMs = plotValues.durationMs;
0e540b69   Benjamin Renard   Finalize save of ...
347
348
349
350
351
        if (plotValues.timeTables)
            downloadValues.timeTables = plotValues.timeTables;
        downloadValues.list = [];
        plotNode.get('object').panels().each(function (panel) {
            panel.params().each(function (param) {
4248c353   Benjamin Renard   Fix get data from...
352
353
354
                paramObj = param.getJsonValues();
                paramObj.id = "";
                downloadValues.list.push(paramObj);
0e540b69   Benjamin Renard   Finalize save of ...
355
356
357
358
359
            });
        });
        myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) {
            module.editFromJsonData(downloadValues);
        });
ebbb3638   Benjamin Renard   Edit plot tab on ...
360
    }
2cfa3a1a   Benjamin Renard   Give the possibil...
361
});