Blame view

js/app/controllers/PlotModule.js 5.44 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', {
18d4a11e   Benjamin Renard   Save and load plo...
12
13
14
15
16
17
	extend: 'amdaDesktop.InteractiveModule',
	
	requires: [
	           'amdaUI.PlotUI',
	           'amdaPlotObj.PlotRequestObject',
	           'amdaModel.PlotNode',
c9071a43   Benjamin Renard   Add instant plot ...
18
19
	           'amdaUI.PlotTabResultUI',
	           'amdaPlotComp.PlotPreviewUI'
18d4a11e   Benjamin Renard   Save and load plo...
20
21
22
	],
	
	contentId : 'plotUI',
16035364   Benjamin Renard   First commit
23
    linkedNode : null,
16035364   Benjamin Renard   First commit
24
    
16035364   Benjamin Renard   First commit
25
    /**
18d4a11e   Benjamin Renard   Save and load plo...
26
27
28
     * @cfg {String} data models
     * @required
     */
16035364   Benjamin Renard   First commit
29
    nodeDataModel : 'amdaModel.PlotNode',
16035364   Benjamin Renard   First commit
30
31
32
33
34
    
    /**
     * @cfg {String} window definitions
     * @required
     */
d341347d   Elena.Budnik   Plot Mgr ameliora...
35
36
    width: 650, 
    height: 670,
18d4a11e   Benjamin Renard   Save and load plo...
37
38
    uiType : 'newPanelPlot',
    helpTitle : 'Help on Plot Module',
6cf1dca2   Elena.Budnik   help file
39
40
    helpFile : 'plotHelp',
     
18d4a11e   Benjamin Renard   Save and load plo...
41
42
    plotResultWindowsManager : new Ext.AbstractManager(),
    
18d4a11e   Benjamin Renard   Save and load plo...
43
44
45
46
47
48
49
50
    computeResultWindowSize : function(panelResult)
	{
	    var size = panelResult.getImageSize();
	    size.width  += 30;
	    size.height += 95;
	    
	    return size;
	},
c9071a43   Benjamin Renard   Add instant plot ...
51
52
53
54
55
56
57
58
59
	
	computePreviewWindowSize : function(previewContent)
	{
	    var size = previewContent.getImageSize();
	    size.width  += 30;
	    size.height += 65;
	    
	    return size;
	},
18d4a11e   Benjamin Renard   Save and load plo...
60
    
87658ba0   Benjamin Renard   TT Navigation in ...
61
    updateInteractiveSession : function(session, newplot) {
18d4a11e   Benjamin Renard   Save and load plo...
62
    	var me = this;
c9071a43   Benjamin Renard   Add instant plot ...
63
64
65
    	
    	
    	
18d4a11e   Benjamin Renard   Save and load plo...
66
    	Ext.each(session.result, function (tabResult, index) {
2cfa3a1a   Benjamin Renard   Give the possibil...
67
68
69
70
71
		if (logExecTime && tabResult.exectime)
		{
			console.log("CMD EXEC TIME FOR "+tabResult.plot+" = "+tabResult.exectime+"ms");
		}

c9071a43   Benjamin Renard   Add instant plot ...
72
73
74
75
76
77
78
79
80
81
82
83
    		if (tabResult.preview)
        	{
    			var plotPreviewConfig = {
    					folder   : session.folder,
    					plotFile : tabResult.plot,
    					context  : tabResult.context,
    					tabId    : tabResult.id		
    			};
    			me.updatePreview(plotPreviewConfig);
        		return;
        	}
    		
18d4a11e   Benjamin Renard   Save and load plo...
84
85
86
87
    		var winResultId = tabResult.id+"-win";
    		
    		var winResult = me.getWindowResult(winResultId);
    		
18d4a11e   Benjamin Renard   Save and load plo...
88
89
90
    		var plotTabConfig = {
					folder   : session.folder,
					plotFile : tabResult.plot,
9f08f4eb   Benjamin Renard   Zoom in interacti...
91
					context  : tabResult.context,
87658ba0   Benjamin Renard   TT Navigation in ...
92
93
					tabId    : tabResult.id,
					multiplot : tabResult.multiplot,
87658ba0   Benjamin Renard   TT Navigation in ...
94
95
96
97
98
					isInterval: tabResult.isInterval,
					ttName : tabResult.ttName,
					ttIndex : tabResult.ttIndex,
					ttNbIntervals : tabResult.ttNbIntervals,
					ttFileIndex : tabResult.ttFileIndex
18d4a11e   Benjamin Renard   Save and load plo...
99
100
101
			};
    		
    		if (winResult == null) {
3ad64fc0   Benjamin Renard   Set plot result w...
102
103
104
105
    			
    			var x = 50 + tabResult.index * 50;
    		    var y = 100 + tabResult.index * 20;
    			
18d4a11e   Benjamin Renard   Save and load plo...
106
107
108
109
110
111
112
    			//create new result win
    			var panelResult = new amdaUI.PlotTabResultUI(plotTabConfig);
    		
    			var size = me.computeResultWindowSize(panelResult);
    		
    			var win = myDesktopApp.getDesktop().createWindow({
    				id    : tabResult.id+"-win",
87658ba0   Benjamin Renard   TT Navigation in ...
113
    				title : 'Plot '+(tabResult.index+1),
18d4a11e   Benjamin Renard   Save and load plo...
114
115
    				width : size.width,
    				height: size.height,
3ad64fc0   Benjamin Renard   Set plot result w...
116
117
    				x : x,
    				y : y,
18d4a11e   Benjamin Renard   Save and load plo...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
    				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
87658ba0   Benjamin Renard   TT Navigation in ...
138
    			winResult.getPanelResult().updatePlotImage(plotTabConfig, newplot);
18d4a11e   Benjamin Renard   Save and load plo...
139
140
141
142
143
144
145
146
147
148
149
150
151
    			//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();
18d4a11e   Benjamin Renard   Save and load plo...
152
153
154
    	});
    },
    
c9071a43   Benjamin Renard   Add instant plot ...
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
    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();
		}
    },
    
488b1401   Benjamin Renard   Interactive multi...
199
200
201
    getInteractiveMultiPlotState : function() {
    	var state = {};
    	this.plotResultWindowsManager.each(function (key, value, length) {
c9071a43   Benjamin Renard   Add instant plot ...
202
203
    		if (value.getPanelResult)
    			state[value.getPanelResult().tabId] = value.getPanelResult().getInteractiveMultiPlotState();
488b1401   Benjamin Renard   Interactive multi...
204
205
206
207
    	});
    	return state;
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
208
209
210
211
    getWindowResult: function(winResultId){
	    if (!this.plotResultWindowsManager.get(winResultId)) return null;
	    return this.plotResultWindowsManager.get(winResultId);	    
	}
2cfa3a1a   Benjamin Renard   Give the possibil...
212
});