Blame view

js/app/controllers/PlotModule.js 5.31 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
     */
18d4a11e   Benjamin Renard   Save and load plo...
35
36
37
38
    width: 600, 
    height: 620,
    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) {
c9071a43   Benjamin Renard   Add instant plot ...
67
68
69
70
71
72
73
74
75
76
77
78
    		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...
79
80
81
82
    		var winResultId = tabResult.id+"-win";
    		
    		var winResult = me.getWindowResult(winResultId);
    		
18d4a11e   Benjamin Renard   Save and load plo...
83
84
85
    		var plotTabConfig = {
					folder   : session.folder,
					plotFile : tabResult.plot,
9f08f4eb   Benjamin Renard   Zoom in interacti...
86
					context  : tabResult.context,
87658ba0   Benjamin Renard   TT Navigation in ...
87
88
					tabId    : tabResult.id,
					multiplot : tabResult.multiplot,
87658ba0   Benjamin Renard   TT Navigation in ...
89
90
91
92
93
					isInterval: tabResult.isInterval,
					ttName : tabResult.ttName,
					ttIndex : tabResult.ttIndex,
					ttNbIntervals : tabResult.ttNbIntervals,
					ttFileIndex : tabResult.ttFileIndex
18d4a11e   Benjamin Renard   Save and load plo...
94
95
96
			};
    		
    		if (winResult == null) {
3ad64fc0   Benjamin Renard   Set plot result w...
97
98
99
100
    			
    			var x = 50 + tabResult.index * 50;
    		    var y = 100 + tabResult.index * 20;
    			
18d4a11e   Benjamin Renard   Save and load plo...
101
102
103
104
105
106
107
    			//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 ...
108
    				title : 'Plot '+(tabResult.index+1),
18d4a11e   Benjamin Renard   Save and load plo...
109
110
    				width : size.width,
    				height: size.height,
3ad64fc0   Benjamin Renard   Set plot result w...
111
112
    				x : x,
    				y : y,
18d4a11e   Benjamin Renard   Save and load plo...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    				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 ...
133
    			winResult.getPanelResult().updatePlotImage(plotTabConfig, newplot);
18d4a11e   Benjamin Renard   Save and load plo...
134
135
136
137
138
139
140
141
142
143
144
145
146
    			//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...
147
148
149
    	});
    },
    
c9071a43   Benjamin Renard   Add instant plot ...
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
    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...
194
195
196
    getInteractiveMultiPlotState : function() {
    	var state = {};
    	this.plotResultWindowsManager.each(function (key, value, length) {
c9071a43   Benjamin Renard   Add instant plot ...
197
198
    		if (value.getPanelResult)
    			state[value.getPanelResult().tabId] = value.getPanelResult().getInteractiveMultiPlotState();
488b1401   Benjamin Renard   Interactive multi...
199
200
201
202
    	});
    	return state;
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
203
204
205
206
    getWindowResult: function(winResultId){
	    if (!this.plotResultWindowsManager.get(winResultId)) return null;
	    return this.plotResultWindowsManager.get(winResultId);	    
	}
16035364   Benjamin Renard   First commit
207
});