Blame view

js/app/controllers/PlotModule.js 4.12 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
18
19
20
21
	extend: 'amdaDesktop.InteractiveModule',
	
	requires: [
	           'amdaUI.PlotUI',
	           'amdaPlotObj.PlotRequestObject',
	           'amdaModel.PlotNode',
	           'amdaUI.PlotTabResultUI'
	],
	
	contentId : 'plotUI',
16035364   Benjamin Renard   First commit
22
    linkedNode : null,
16035364   Benjamin Renard   First commit
23
    
16035364   Benjamin Renard   First commit
24
    /**
18d4a11e   Benjamin Renard   Save and load plo...
25
26
27
     * @cfg {String} data models
     * @required
     */
16035364   Benjamin Renard   First commit
28
    nodeDataModel : 'amdaModel.PlotNode',
18d4a11e   Benjamin Renard   Save and load plo...
29
    //objectDataModel : 'amdaPlotObj.PlotRequestObject',
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
39
40
41
    width: 600, 
    height: 620,
    uiType : 'newPanelPlot',
    helpTitle : 'Help on Plot Module',
    
    plotResultWindowsManager : new Ext.AbstractManager(),
    
16035364   Benjamin Renard   First commit
42
    saveState: function() {
18d4a11e   Benjamin Renard   Save and load plo...
43
44
45
46
47
            /*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 });*/
16035364   Benjamin Renard   First commit
48
49
    },
       
18d4a11e   Benjamin Renard   Save and load plo...
50
51
    getState : function() {            
        //   return Ext.state.Manager.get(this.id + '_form'); 
16035364   Benjamin Renard   First commit
52
        return Ext.state.Manager.get('timeinterval'); 
18d4a11e   Benjamin Renard   Save and load plo...
53
54
55
56
57
58
59
60
61
62
63
    },
    
    computeResultWindowSize : function(panelResult)
	{
	    var size = panelResult.getImageSize();
	    size.width  += 30;
	    size.height += 95;
	    
	    return size;
	},
    
87658ba0   Benjamin Renard   TT Navigation in ...
64
    updateInteractiveSession : function(session, newplot) {
18d4a11e   Benjamin Renard   Save and load plo...
65
66
67
68
69
70
71
72
73
    	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,
9f08f4eb   Benjamin Renard   Zoom in interacti...
74
					context  : tabResult.context,
87658ba0   Benjamin Renard   TT Navigation in ...
75
76
77
78
79
80
81
82
					tabId    : tabResult.id,
					multiplot : tabResult.multiplot,
					superposeMode : tabResult.superposeMode,
					isInterval: tabResult.isInterval,
					ttName : tabResult.ttName,
					ttIndex : tabResult.ttIndex,
					ttNbIntervals : tabResult.ttNbIntervals,
					ttFileIndex : tabResult.ttFileIndex
18d4a11e   Benjamin Renard   Save and load plo...
83
84
85
86
87
88
89
90
91
92
			};
    		
    		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",
87658ba0   Benjamin Renard   TT Navigation in ...
93
    				title : 'Plot '+(tabResult.index+1),
18d4a11e   Benjamin Renard   Save and load plo...
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    				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
87658ba0   Benjamin Renard   TT Navigation in ...
116
    			winResult.getPanelResult().updatePlotImage(plotTabConfig, newplot);
18d4a11e   Benjamin Renard   Save and load plo...
117
118
119
120
121
122
123
124
125
126
127
128
129
    			//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...
130
131
132
    	});
    },
    
488b1401   Benjamin Renard   Interactive multi...
133
134
135
136
137
138
139
140
    getInteractiveMultiPlotState : function() {
    	var state = {};
    	this.plotResultWindowsManager.each(function (key, value, length) {
    		state[value.getPanelResult().tabId] = value.getPanelResult().getInteractiveMultiPlotState();
    	});
    	return state;
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
141
142
143
144
    getWindowResult: function(winResultId){
	    if (!this.plotResultWindowsManager.get(winResultId)) return null;
	    return this.plotResultWindowsManager.get(winResultId);	    
	}
16035364   Benjamin Renard   First commit
145
});