Blame view

js/app/models/PlotObjects/PlotParamObject.js 7.4 KB
17433635   Benjamin Renard   Add series and sp...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Project      : AMDA-NG
 * Name         : PlotParamObject.js
 * @class   amdaPlotObj.PlotParamObject
 * @extends Ext.data.Model
 * @brief   Plot Param Business Object Definition 
 * @author  Benjamin Renard
 * @version $Id: PlotParamObject.js benjamin $
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	:           :17/08/2015: BRE  - file creation
 */
 
 		
Ext.define('amdaPlotObj.PlotParamObject', {
	extend: 'Ext.data.Model',
dbb7bcbe   Benjamin Renard   Add curves defint...
18
	idProperty: 'id',
17433635   Benjamin Renard   Add series and sp...
19
20
21
22
	
	requires: [
	           'amdaPlotObj.PlotObjectConfig',
	           'amdaPlotObj.PlotSerieObject',
e84ed2cf   Benjamin Renard   Add Interval Tick...
23
			   'amdaPlotObj.PlotOrbitSerieObject',
a0bf9157   Benjamin Renard   Add tick plot and...
24
25
	           'amdaPlotObj.PlotSpectroObject',
	           'amdaPlotObj.PlotStatusBarObject',
6a801541   Benjamin Renard   Add possibility t...
26
27
28
	           'amdaPlotObj.PlotTickBarObject',
	           'amdaPlotObj.PlotInstantSerieObject',
	           'amdaPlotObj.PlotInstantSpectroObject'
17433635   Benjamin Renard   Add series and sp...
29
30
31
	],
	
	fields : [
fd5552a4   Benjamin Renard   Info for plot ele...
32
	          {name: 'id', type: 'int'},
17433635   Benjamin Renard   Add series and sp...
33
	          {name: 'param-id', type: 'string'},
7ac3ce50   Benjamin Renard   First implementat...
34
35
36
	          {name: 'param-type', type: 'int'},
	          {name: 'param-dim-1', type: 'string'},
	          {name: 'param-dim-2', type: 'string'},
17433635   Benjamin Renard   Add series and sp...
37
38
39
40
41
42
43
44
45
46
47
48
	          {name: 'param-drawing-type', type: 'string'},
	          {name: 'param-drawing-object', type: 'auto'}
    ],
    
    associations : [
              {
            	  type  : 'belongsTo',
                  model : 'amdaPlotObj.PlotPanelObject',
                  getterName : 'Panel'
              }
    ],
    
18d4a11e   Benjamin Renard   Save and load plo...
49
50
51
    constructor: function(){
        var me = this;
        me.callParent(arguments);
18d4a11e   Benjamin Renard   Save and load plo...
52
53
54
55
56
        if ((arguments.length > 0) && arguments[0])
        {
        	if (arguments[0]['param-drawing-object'])
        		me.loadDrawingObject(arguments[0]['param-drawing-object']);
        }
a971060f   Benjamin Renard   Fix some bugs
57
        this.dirty = false;
18d4a11e   Benjamin Renard   Save and load plo...
58
59
60
61
62
63
64
    },
    
    loadDrawingObject: function(drawing)
    {
    	var drawingObject = this.get('param-drawing-object');
    	if (drawingObject == null)
    		return;
a971060f   Benjamin Renard   Fix some bugs
65
66
    	this.set('param-drawing-object', this.createDrawingObjectByType(this.get('param-drawing-type'), drawing));
    	drawingObject.dirty = false;
18d4a11e   Benjamin Renard   Save and load plo...
67
68
    },
    
a971060f   Benjamin Renard   Fix some bugs
69
    createDrawingObjectByType : function(type, data)
17433635   Benjamin Renard   Add series and sp...
70
    {
17433635   Benjamin Renard   Add series and sp...
71
72
73
74
    	//Create drawing object in relation with the type
    	switch (type)
    	{
    	case 'serie' :
a971060f   Benjamin Renard   Fix some bugs
75
    		return new amdaPlotObj.PlotSerieObject(data);
e84ed2cf   Benjamin Renard   Add Interval Tick...
76
77
		case 'orbit-serie' :
			return new amdaPlotObj.PlotOrbitSerieObject(data);
17433635   Benjamin Renard   Add series and sp...
78
    	case 'spectro' :
a971060f   Benjamin Renard   Fix some bugs
79
    		return new amdaPlotObj.PlotSpectroObject(data);
a0bf9157   Benjamin Renard   Add tick plot and...
80
    	case 'status-bar' :
a971060f   Benjamin Renard   Fix some bugs
81
    		return new amdaPlotObj.PlotStatusBarObject(data);
a0bf9157   Benjamin Renard   Add tick plot and...
82
    	case 'tick-bar' :
a971060f   Benjamin Renard   Fix some bugs
83
    		return new amdaPlotObj.PlotTickBarObject(data);
6a801541   Benjamin Renard   Add possibility t...
84
    	case 'iserie' :
a971060f   Benjamin Renard   Fix some bugs
85
    		return new amdaPlotObj.PlotInstantSerieObject(data);
6a801541   Benjamin Renard   Add possibility t...
86
    	case 'ispectro' :
a971060f   Benjamin Renard   Fix some bugs
87
    		return new amdaPlotObj.PlotInstantSpectroObject(data);
17433635   Benjamin Renard   Add series and sp...
88
    	default :
a971060f   Benjamin Renard   Fix some bugs
89
    		return null;
17433635   Benjamin Renard   Add series and sp...
90
    	}
a971060f   Benjamin Renard   Fix some bugs
91
92
    },
    
ced82260   Benjamin Renard   Get initial plot ...
93
    changeDrawingType: function(type, drawData)
a971060f   Benjamin Renard   Fix some bugs
94
95
96
97
98
99
100
    {
    	if (type == this.get('param-drawing-type'))
    		return;
    	
    	this.set('param-drawing-type', type);
    	
    	this.set('param-drawing-object', this.createDrawingObjectByType(type));
17433635   Benjamin Renard   Add series and sp...
101
102
103
    	
    	//Set drawing object to default status
    	if (this.get('param-drawing-object') != null)
ced82260   Benjamin Renard   Get initial plot ...
104
    	{
17433635   Benjamin Renard   Add series and sp...
105
    		this.get('param-drawing-object').setDefaultValues();
ced82260   Benjamin Renard   Get initial plot ...
106
107
108
    		if (this.get('param-drawing-object').loadFromData && drawData)
    			this.get('param-drawing-object').loadFromData(drawData);
    	}
17433635   Benjamin Renard   Add series and sp...
109
110
    },
    
a0bf9157   Benjamin Renard   Add tick plot and...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
    getAvailableDrawingObjectByPlotType: function(plotType) {
    	switch (plotType)
    	{
    	case 'timePlot'  :
    	case 'epochPlot' :
    		return [
    		        {'key' : 'serie', 'value' : 'Serie'},
    		        {'key' : 'spectro', 'value' : 'Spectro'},
    		        {'key' : 'tick-bar', 'value' : 'Tick Bar'},
    		        {'key' : 'status-bar', 'value' : 'Status Bar'}
    		];
    	case 'xyPlot' :
    		return [
    		        {'key' : 'serie', 'value' : 'Serie'},
    		        {'key' : 'orbit-serie', 'value' : 'Orbit Serie'} 
    		];
    	case 'instantPlot' :
    		return [
6a801541   Benjamin Renard   Add possibility t...
129
130
    		        {'key' : 'iserie', 'value' : 'Serie'},
    		        {'key' : 'ispectro', 'value' : 'Spectro'}
a0bf9157   Benjamin Renard   Add tick plot and...
131
132
133
134
135
136
137
138
139
140
141
142
143
    		];
    	case 'statusPlot' :
    		return [
    		        {'key' : 'status-bar', 'value' : 'Status Bar'}
    		];
    	case 'tickPlot' :
    		return [
    		        {'key' : 'tick-bar', 'value' : 'Tick Bar'}
    		];
    	}
    	return [];
    },
    
17433635   Benjamin Renard   Add series and sp...
144
145
    setDefaultValues: function(type)
    {
a971060f   Benjamin Renard   Fix some bugs
146
    	this.changeDrawingType(type);
17433635   Benjamin Renard   Add series and sp...
147
148
    },
    
fd5552a4   Benjamin Renard   Info for plot ele...
149
150
151
152
153
154
    getShortInfo : function(plotType)
    {
    	var availableDrawingObjects = this.getAvailableDrawingObjectByPlotType(plotType);
		var type = amdaPlotObj.PlotObjectConfig.getValueByKey(availableDrawingObjects, this.get('param-drawing-type'));
		
		var info = '';
7ac3ce50   Benjamin Renard   First implementat...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
		
		var paramIndexes = '';
		switch (this.get('param-type')) {
  	  		case 0:
  	  			//scalar - nothing to do
  	  			break;
  	  		case 1:
  	  			//Tab1D
  	  			if ((this.get('param-dim-1') != '') && (this.get('param-dim-1') != '*'))
  	  				paramIndexes = '('+this.get('param-dim-1')+')';
  	  			else if ((this.get('param-dim-2') != '') && (this.get('param-dim-2') != '*'))
  	  				paramIndexes = '('+this.get('param-dim-2')+')';
  	  			break;
  	  		case 2:
  	  			//Tab2D
  	  			var dim1 = this.get('param-dim-1') != '' ? this.get('param-dim-1') : "*";
  	  			var dim2 = this.get('param-dim-2') != '' ? this.get('param-dim-2') : "*";
  	  			if ((dim1 != '*') || (dim2 != '*'))
  	  				paramIndexes = '('+dim1+','+dim2+')';
  	  	}
		
fd5552a4   Benjamin Renard   Info for plot ele...
176
177
178
		switch (plotType)
		{
		case 'xyPlot' :
e84ed2cf   Benjamin Renard   Add Interval Tick...
179
180
181
			if (this.get('param-drawing-type') == 'orbit-serie')
			{
				var projection = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableOrbitSerieProjections, this.get('param-drawing-object').get('serie-projection'));
7ac3ce50   Benjamin Renard   First implementat...
182
				info = this.get('param-id')+paramIndexes+', '+projection;
e84ed2cf   Benjamin Renard   Add Interval Tick...
183
184
			}
			else
7ac3ce50   Benjamin Renard   First implementat...
185
				info = this.get('param-id')+paramIndexes+' = f('+this.get('param-drawing-object').get('serie-xaxis-param')+', t)';
fd5552a4   Benjamin Renard   Info for plot ele...
186
187
			break;
		case 'instantPlot' :
7ac3ce50   Benjamin Renard   First implementat...
188
			info = this.get('param-id')+paramIndexes;
fd5552a4   Benjamin Renard   Info for plot ele...
189
190
			break;
		default :
7ac3ce50   Benjamin Renard   First implementat...
191
			info = this.get('param-id')+paramIndexes+' = f(t)';
fd5552a4   Benjamin Renard   Info for plot ele...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
		}
		
		info += ', '+type;
		
		switch (this.get('param-drawing-type'))
		{
		case 'serie' :
			var yAxis = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableYAxes, this.get('param-drawing-object').get('serie-yaxis'));
			info += ', Y '+yAxis;
			break;
		case 'spectro' :
			var yAxis = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableYAxes, this.get('param-drawing-object').get('spectro-yaxis'));
			info += ', Y '+yAxis;
			break;
		}
		
		return info;
    },
    
a971060f   Benjamin Renard   Fix some bugs
211
212
213
214
215
216
217
218
219
220
    isDirty : function()
    {
    	if (this.dirty)
    		return true;
    	if (this.get('param-drawing-object') != null)
    		return this.get('param-drawing-object').dirty;
    	
    	return false;
    },
    
17433635   Benjamin Renard   Add series and sp...
221
222
223
224
    getJsonValues : function() 
    {
    	var paramValues  = new Object();
    	
dbb7bcbe   Benjamin Renard   Add curves defint...
225
226
    	paramValues['id'] = this.get('id');
    	
17433635   Benjamin Renard   Add series and sp...
227
    	paramValues['param-id'] = this.get('param-id');
7ac3ce50   Benjamin Renard   First implementat...
228
229
230
    	paramValues['param-type'] = this.get('param-type');
    	paramValues['param-dim-1'] = this.get('param-dim-1');
    	paramValues['param-dim-2'] = this.get('param-dim-2');
17433635   Benjamin Renard   Add series and sp...
231
232
233
234
235
236
237
238
    	paramValues['param-drawing-type'] = this.get('param-drawing-type');
    	
    	if (this.get('param-drawing-object') != null)
    		paramValues['param-drawing-object'] = this.get('param-drawing-object').getJsonValues();
    	
    	return paramValues;
    }
});