Blame view

js/app/controllers/PlotModule.js 3.67 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
64
65
66
67
68
69
70
71
72
73
    },
    
    computeResultWindowSize : function(panelResult)
	{
	    var size = panelResult.getImageSize();
	    size.width  += 30;
	    size.height += 95;
	    
	    return size;
	},
    
    startInteractiveSession : function(session) {
    	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
75
					context  : tabResult.context,
					tabId    : tabResult.id
18d4a11e   Benjamin Renard   Save and load plo...
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
			};
    		
    		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 '+(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);
    			//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();
    		me.plotResultWindowsManager.unregister(value);
    	});
    },
    
9f08f4eb   Benjamin Renard   Zoom in interacti...
127
    updateInteractiveSession : function(interactiveResult) {
18d4a11e   Benjamin Renard   Save and load plo...
128
129
    	
    },
16035364   Benjamin Renard   First commit
130
    
18d4a11e   Benjamin Renard   Save and load plo...
131
132
133
134
    getWindowResult: function(winResultId){
	    if (!this.plotResultWindowsManager.get(winResultId)) return null;
	    return this.plotResultWindowsManager.get(winResultId);	    
	}
16035364   Benjamin Renard   First commit
135
});