PlotParamObject.js
7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/**
* 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',
idProperty: 'id',
requires: [
'amdaPlotObj.PlotObjectConfig',
'amdaPlotObj.PlotSerieObject',
'amdaPlotObj.PlotOrbitSerieObject',
'amdaPlotObj.PlotSpectroObject',
'amdaPlotObj.PlotStatusBarObject',
'amdaPlotObj.PlotTickBarObject',
'amdaPlotObj.PlotInstantSerieObject',
'amdaPlotObj.PlotInstantSpectroObject'
],
fields : [
{name: 'id', type: 'int'},
{name: 'param-id', type: 'string'},
{name: 'param-type', type: 'int'},
{name: 'param-dim-1', type: 'string'},
{name: 'param-dim-2', type: 'string'},
{name: 'param-drawing-type', type: 'string'},
{name: 'param-drawing-object', type: 'auto'}
],
associations : [
{
type : 'belongsTo',
model : 'amdaPlotObj.PlotPanelObject',
getterName : 'Panel'
}
],
constructor: function(){
var me = this;
me.callParent(arguments);
if ((arguments.length > 0) && arguments[0])
{
if (arguments[0]['param-drawing-object'])
me.loadDrawingObject(arguments[0]['param-drawing-object']);
}
this.dirty = false;
},
loadDrawingObject: function(drawing)
{
var drawingObject = this.get('param-drawing-object');
if (drawingObject == null)
return;
this.set('param-drawing-object', this.createDrawingObjectByType(this.get('param-drawing-type'), drawing));
drawingObject.dirty = false;
},
createDrawingObjectByType : function(type, data)
{
//Create drawing object in relation with the type
switch (type)
{
case 'serie' :
return new amdaPlotObj.PlotSerieObject(data);
case 'orbit-serie' :
return new amdaPlotObj.PlotOrbitSerieObject(data);
case 'spectro' :
return new amdaPlotObj.PlotSpectroObject(data);
case 'status-bar' :
return new amdaPlotObj.PlotStatusBarObject(data);
case 'tick-bar' :
return new amdaPlotObj.PlotTickBarObject(data);
case 'iserie' :
return new amdaPlotObj.PlotInstantSerieObject(data);
case 'ispectro' :
return new amdaPlotObj.PlotInstantSpectroObject(data);
default :
return null;
}
},
changeDrawingType: function(type, drawData)
{
if (type == this.get('param-drawing-type'))
return;
this.set('param-drawing-type', type);
this.set('param-drawing-object', this.createDrawingObjectByType(type));
//Set drawing object to default status
if (this.get('param-drawing-object') != null)
{
this.get('param-drawing-object').setDefaultValues();
if (this.get('param-drawing-object').loadFromData && drawData)
this.get('param-drawing-object').loadFromData(drawData);
}
},
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 [
{'key' : 'iserie', 'value' : 'Serie'},
{'key' : 'ispectro', 'value' : 'Spectro'}
];
case 'statusPlot' :
return [
{'key' : 'status-bar', 'value' : 'Status Bar'}
];
case 'tickPlot' :
return [
{'key' : 'tick-bar', 'value' : 'Tick Bar'}
];
}
return [];
},
setDefaultValues: function(type)
{
this.changeDrawingType(type);
},
getShortInfo : function(plotType)
{
var availableDrawingObjects = this.getAvailableDrawingObjectByPlotType(plotType);
var type = amdaPlotObj.PlotObjectConfig.getValueByKey(availableDrawingObjects, this.get('param-drawing-type'));
var info = '';
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+')';
}
switch (plotType)
{
case 'xyPlot' :
if (this.get('param-drawing-type') == 'orbit-serie')
{
var projection = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableOrbitSerieProjections, this.get('param-drawing-object').get('serie-projection'));
info = this.get('param-id')+paramIndexes+', '+projection;
}
else
info = this.get('param-id')+paramIndexes+' = f('+this.get('param-drawing-object').get('serie-xaxis-param')+', t)';
break;
case 'instantPlot' :
info = this.get('param-id')+paramIndexes;
break;
default :
info = this.get('param-id')+paramIndexes+' = f(t)';
}
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;
},
isDirty : function()
{
if (this.dirty)
return true;
if (this.get('param-drawing-object') != null)
return this.get('param-drawing-object').dirty;
return false;
},
getJsonValues : function()
{
var paramValues = new Object();
paramValues['id'] = this.get('id');
paramValues['param-id'] = this.get('param-id');
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');
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;
}
});