PlotParamObject.js
4.28 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
/**
* 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',
requires: [
'amdaPlotObj.PlotObjectConfig',
'amdaPlotObj.PlotSerieObject',
'amdaPlotObj.PlotSpectroObject',
'amdaPlotObj.PlotStatusBarObject',
'amdaPlotObj.PlotTickBarObject'
],
fields : [
{name: 'id', type: 'string'},
{name: 'param-id', 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);
me.updateDrawingType(this.get('param-drawing-type'), true);
if ((arguments.length > 0) && arguments[0])
{
if (arguments[0]['param-drawing-object'])
me.loadDrawingObject(arguments[0]['param-drawing-object']);
}
},
loadDrawingObject: function(drawing)
{
var drawingObject = this.get('param-drawing-object');
if (drawingObject == null)
return;
Ext.Object.each(drawing, function(key,value) {
drawingObject.set(key,value);
});
},
updateDrawingType: function(type, forceUpdate)
{
forceUpdate = (typeof forceUpdate !== 'undefined') ? forceUpdate : false;
if (!forceUpdate && (type == this.get('param-drawing-type')))
return;
this.set('param-drawing-type', type);
//Create drawing object in relation with the type
switch (type)
{
case 'serie' :
this.set('param-drawing-object', new amdaPlotObj.PlotSerieObject());
break;
case 'spectro' :
this.set('param-drawing-object', new amdaPlotObj.PlotSpectroObject());
break;
case 'status-bar' :
this.set('param-drawing-object', new amdaPlotObj.PlotStatusBarObject());
break;
case 'tick-bar' :
this.set('param-drawing-object', new amdaPlotObj.PlotTickBarObject());
break;
default :
this.set('param-drawing-object', null);
}
//Set drawing object to default status
if (this.get('param-drawing-object') != null)
this.get('param-drawing-object').setDefaultValues();
},
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' : 'serie', 'value' : 'Serie'},
{'key' : 'spectro', '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.updateDrawingType(type, true);
},
getJsonValues : function()
{
var paramValues = new Object();
paramValues['param-id'] = this.get('param-id');
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;
}
});