PlotModule.js
5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/**
* Project : AMDA-NG
* Name : PlotModule.js
* @class amdaDesktop.PlotModule
* @extends amdaDesktop.InteractiveModule
* @brief New Plot Module controller definition
* @author Benjamin Renard
* $Id: PlotModule.js benjamin $
*/
Ext.define('amdaDesktop.PlotModule', {
extend: 'amdaDesktop.InteractiveModule',
requires: [
'amdaUI.PlotUI',
'amdaPlotObj.PlotRequestObject',
'amdaModel.PlotNode',
'amdaUI.PlotTabResultUI',
'amdaPlotComp.PlotPreviewUI'
],
contentId : 'plotUI',
linkedNode : null,
/**
* @cfg {String} data models
* @required
*/
nodeDataModel : 'amdaModel.PlotNode',
/**
* @cfg {String} window definitions
* @required
*/
width: 650,
height: 670,
uiType : 'newPanelPlot',
helpTitle : 'Help on Plot Module',
helpFile : 'plotHelp',
plotResultWindowsManager : new Ext.AbstractManager(),
computeResultWindowSize : function(panelResult)
{
var size = panelResult.getImageSize();
size.width += 30;
size.height += 95;
return size;
},
computePreviewWindowSize : function(previewContent)
{
var size = previewContent.getImageSize();
size.width += 30;
size.height += 65;
return size;
},
updateInteractiveSession : function(session, newplot) {
var me = this;
Ext.each(session.result, function (tabResult, index) {
if (logExecTime && tabResult.exectime)
{
console.log("CMD EXEC TIME FOR "+tabResult.plot+" = "+tabResult.exectime+"ms");
}
if (tabResult.preview)
{
var plotPreviewConfig = {
folder : session.folder,
plotFile : tabResult.plot,
context : tabResult.context,
tabId : tabResult.id
};
me.updatePreview(plotPreviewConfig);
return;
}
var winResultId = tabResult.id+"-win";
var winResult = me.getWindowResult(winResultId);
var plotTabConfig = {
folder : session.folder,
plotFile : tabResult.plot,
context : tabResult.context,
tabId : tabResult.id,
multiplot : tabResult.multiplot,
isInterval: tabResult.isInterval,
ttName : tabResult.ttName,
ttIndex : tabResult.ttIndex,
ttNbIntervals : tabResult.ttNbIntervals,
ttFileIndex : tabResult.ttFileIndex
};
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);
var size = me.computeResultWindowSize(panelResult);
var win = myDesktopApp.getDesktop().createWindow({
id : tabResult.id+"-win",
title : 'Plot '+(tabResult.index+1),
width : size.width,
height: size.height,
x : x,
y : y,
layout: 'fit',
items : [
panelResult
],
listeners: {
scope: me,
beforeclose: function(win,opt) {
me.plotResultWindowsManager.unregister(win);
}
},
getPanelResult: function() {
return panelResult;
}
});
win.show();
me.plotResultWindowsManager.register(win);
}
else
{
//update result
winResult.getPanelResult().updatePlotImage(plotTabConfig, newplot);
//update window size
var size = me.computeResultWindowSize(winResult.getPanelResult());
winResult.setSize(size.width, size.height);
winResult.toFront();
}
});
},
closeInteractiveSession : function() {
var me = this;
this.plotResultWindowsManager.each(function (key, value, length) {
value.close();
});
},
updatePreview : function(plotPreviewConfig) {
var winPreviewId = "plot-preview-win";
var winPreview = this.getWindowResult(winPreviewId);
if (winPreview == null) {
//create new preview win
var previewContent = new amdaPlotComp.PlotPreviewUI(plotPreviewConfig);
var size = this.computePreviewWindowSize(previewContent);
var win = myDesktopApp.getDesktop().createWindow({
id : winPreviewId,
title : 'Plot Preview',
width : size.width,
height: size.height,
layout: 'fit',
items : [
previewContent
],
listeners: {
scope: this,
beforeclose: function(win,opt) {
this.plotResultWindowsManager.unregister(win);
}
},
getPreviewContent: function() {
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();
}
},
getInteractiveMultiPlotState : function() {
var state = {};
this.plotResultWindowsManager.each(function (key, value, length) {
if (value.getPanelResult)
state[value.getPanelResult().tabId] = value.getPanelResult().getInteractiveMultiPlotState();
});
return state;
},
getWindowResult: function(winResultId){
if (!this.plotResultWindowsManager.get(winResultId)) return null;
return this.plotResultWindowsManager.get(winResultId);
}
});