PlotModule.js
3.84 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
/**
* 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'
],
contentId : 'plotUI',
linkedNode : null,
/**
* @cfg {String} data models
* @required
*/
nodeDataModel : 'amdaModel.PlotNode',
//objectDataModel : 'amdaPlotObj.PlotRequestObject',
/**
* @cfg {String} window definitions
* @required
*/
width: 600,
height: 620,
uiType : 'newPanelPlot',
helpTitle : 'Help on Plot Module',
plotResultWindowsManager : new Ext.AbstractManager(),
saveState: function() {
/*var uiContent = this.getUiContent();
var form = uiContent.down('form').getForm();
var values = form.getValues();
// Ext.state.Manager.set(this.id + '_form', values);
Ext.state.Manager.set('timeinterval', {'startDate' : values.startDate,'stopDate' : values.stopDate });*/
},
getState : function() {
// return Ext.state.Manager.get(this.id + '_form');
return Ext.state.Manager.get('timeinterval');
},
computeResultWindowSize : function(panelResult)
{
var size = panelResult.getImageSize();
size.width += 30;
size.height += 95;
return size;
},
updateInteractiveSession : function(session, newplot) {
var me = this;
Ext.each(session.result, function (tabResult, index) {
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,
superposeMode : tabResult.superposeMode,
isInterval: tabResult.isInterval,
ttName : tabResult.ttName,
ttIndex : tabResult.ttIndex,
ttNbIntervals : tabResult.ttNbIntervals,
ttFileIndex : tabResult.ttFileIndex
};
if (winResult == null) {
//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,
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();
});
},
getWindowResult: function(winResultId){
if (!this.plotResultWindowsManager.get(winResultId)) return null;
return this.plotResultWindowsManager.get(winResultId);
}
});