Blame view

js/app/models/PlotObjects/PlotParamObject.js 6.14 KB
17433635   Benjamin Renard   Add series and sp...
1
2
3
4
/**
 * Project      : AMDA-NG
 * Name         : PlotParamObject.js
 * @class   amdaPlotObj.PlotParamObject
bb6e93d9   Benjamin Renard   Implement templat...
5
 * @extends amdaModel.RequestParamObject
17433635   Benjamin Renard   Add series and sp...
6
7
8
9
10
11
12
13
14
15
16
 * @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', {
bb6e93d9   Benjamin Renard   Implement templat...
17
	extend: 'amdaModel.RequestParamObject',
17433635   Benjamin Renard   Add series and sp...
18
19
20
21
	
	requires: [
	           'amdaPlotObj.PlotObjectConfig',
	           'amdaPlotObj.PlotSerieObject',
e84ed2cf   Benjamin Renard   Add Interval Tick...
22
			   'amdaPlotObj.PlotOrbitSerieObject',
a0bf9157   Benjamin Renard   Add tick plot and...
23
24
	           'amdaPlotObj.PlotSpectroObject',
	           'amdaPlotObj.PlotStatusBarObject',
6a801541   Benjamin Renard   Add possibility t...
25
26
27
	           'amdaPlotObj.PlotTickBarObject',
	           'amdaPlotObj.PlotInstantSerieObject',
	           'amdaPlotObj.PlotInstantSpectroObject'
17433635   Benjamin Renard   Add series and sp...
28
29
30
	],
	
	fields : [
17433635   Benjamin Renard   Add series and sp...
31
	          {name: 'param-drawing-type', type: 'string'},
bb6e93d9   Benjamin Renard   Implement templat...
32
	          {name: 'param-drawing-object', type: 'auto'}
17433635   Benjamin Renard   Add series and sp...
33
34
35
36
37
38
39
40
41
42
    ],
    
    associations : [
              {
            	  type  : 'belongsTo',
                  model : 'amdaPlotObj.PlotPanelObject',
                  getterName : 'Panel'
              }
    ],
    
18d4a11e   Benjamin Renard   Save and load plo...
43
44
45
    constructor: function(){
        var me = this;
        me.callParent(arguments);
18d4a11e   Benjamin Renard   Save and load plo...
46
47
48
49
50
        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
51
        this.dirty = false;
18d4a11e   Benjamin Renard   Save and load plo...
52
53
54
55
56
57
58
    },
    
    loadDrawingObject: function(drawing)
    {
    	var drawingObject = this.get('param-drawing-object');
    	if (drawingObject == null)
    		return;
a971060f   Benjamin Renard   Fix some bugs
59
60
    	this.set('param-drawing-object', this.createDrawingObjectByType(this.get('param-drawing-type'), drawing));
    	drawingObject.dirty = false;
18d4a11e   Benjamin Renard   Save and load plo...
61
62
    },
    
a971060f   Benjamin Renard   Fix some bugs
63
    createDrawingObjectByType : function(type, data)
17433635   Benjamin Renard   Add series and sp...
64
    {
17433635   Benjamin Renard   Add series and sp...
65
66
67
68
    	//Create drawing object in relation with the type
    	switch (type)
    	{
    	case 'serie' :
a971060f   Benjamin Renard   Fix some bugs
69
    		return new amdaPlotObj.PlotSerieObject(data);
e84ed2cf   Benjamin Renard   Add Interval Tick...
70
71
		case 'orbit-serie' :
			return new amdaPlotObj.PlotOrbitSerieObject(data);
17433635   Benjamin Renard   Add series and sp...
72
    	case 'spectro' :
a971060f   Benjamin Renard   Fix some bugs
73
    		return new amdaPlotObj.PlotSpectroObject(data);
a0bf9157   Benjamin Renard   Add tick plot and...
74
    	case 'status-bar' :
a971060f   Benjamin Renard   Fix some bugs
75
    		return new amdaPlotObj.PlotStatusBarObject(data);
a0bf9157   Benjamin Renard   Add tick plot and...
76
    	case 'tick-bar' :
a971060f   Benjamin Renard   Fix some bugs
77
    		return new amdaPlotObj.PlotTickBarObject(data);
6a801541   Benjamin Renard   Add possibility t...
78
    	case 'iserie' :
a971060f   Benjamin Renard   Fix some bugs
79
    		return new amdaPlotObj.PlotInstantSerieObject(data);
6a801541   Benjamin Renard   Add possibility t...
80
    	case 'ispectro' :
a971060f   Benjamin Renard   Fix some bugs
81
    		return new amdaPlotObj.PlotInstantSpectroObject(data);
17433635   Benjamin Renard   Add series and sp...
82
    	default :
a971060f   Benjamin Renard   Fix some bugs
83
    		return null;
17433635   Benjamin Renard   Add series and sp...
84
    	}
a971060f   Benjamin Renard   Fix some bugs
85
86
    },
    
ced82260   Benjamin Renard   Get initial plot ...
87
    changeDrawingType: function(type, drawData)
a971060f   Benjamin Renard   Fix some bugs
88
89
90
91
92
93
94
    {
    	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...
95
96
97
    	
    	//Set drawing object to default status
    	if (this.get('param-drawing-object') != null)
ced82260   Benjamin Renard   Get initial plot ...
98
    	{
17433635   Benjamin Renard   Add series and sp...
99
    		this.get('param-drawing-object').setDefaultValues();
ced82260   Benjamin Renard   Get initial plot ...
100
101
102
    		if (this.get('param-drawing-object').loadFromData && drawData)
    			this.get('param-drawing-object').loadFromData(drawData);
    	}
17433635   Benjamin Renard   Add series and sp...
103
104
    },
    
a0bf9157   Benjamin Renard   Add tick plot and...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
    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...
123
124
    		        {'key' : 'iserie', 'value' : 'Serie'},
    		        {'key' : 'ispectro', 'value' : 'Spectro'}
a0bf9157   Benjamin Renard   Add tick plot and...
125
126
127
128
129
130
131
132
133
134
135
136
137
    		];
    	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...
138
139
    setDefaultValues: function(type)
    {
a971060f   Benjamin Renard   Fix some bugs
140
    	this.changeDrawingType(type);
17433635   Benjamin Renard   Add series and sp...
141
142
    },
    
fd5552a4   Benjamin Renard   Info for plot ele...
143
144
145
146
147
    getShortInfo : function(plotType)
    {
    	var availableDrawingObjects = this.getAvailableDrawingObjectByPlotType(plotType);
		var type = amdaPlotObj.PlotObjectConfig.getValueByKey(availableDrawingObjects, this.get('param-drawing-type'));
		
bb6e93d9   Benjamin Renard   Implement templat...
148
		var fullName = this.getParamFullName();
7ac3ce50   Benjamin Renard   First implementat...
149
		
bb6e93d9   Benjamin Renard   Implement templat...
150
		var info = '';
51b7c77c   Benjamin Renard   Add templated par...
151
		
fd5552a4   Benjamin Renard   Info for plot ele...
152
153
154
		switch (plotType)
		{
		case 'xyPlot' :
e84ed2cf   Benjamin Renard   Add Interval Tick...
155
156
157
			if (this.get('param-drawing-type') == 'orbit-serie')
			{
				var projection = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableOrbitSerieProjections, this.get('param-drawing-object').get('serie-projection'));
bb6e93d9   Benjamin Renard   Implement templat...
158
				info = fullName+', '+projection;
e84ed2cf   Benjamin Renard   Add Interval Tick...
159
160
			}
			else
bb6e93d9   Benjamin Renard   Implement templat...
161
				info = fullName+' = f('+this.get('param-drawing-object').get('serie-xaxis-param')+', t)';
fd5552a4   Benjamin Renard   Info for plot ele...
162
163
			break;
		case 'instantPlot' :
bb6e93d9   Benjamin Renard   Implement templat...
164
			info = fullName;
fd5552a4   Benjamin Renard   Info for plot ele...
165
166
			break;
		default :
bb6e93d9   Benjamin Renard   Implement templat...
167
			info = fullName+' = f(t)';
fd5552a4   Benjamin Renard   Info for plot ele...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
		}
		
		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
187
188
189
190
191
192
193
194
195
196
    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...
197
198
    getJsonValues : function() 
    {
bb6e93d9   Benjamin Renard   Implement templat...
199
    	var paramValues  = this.callParent(arguments);
17433635   Benjamin Renard   Add series and sp...
200
    	
17433635   Benjamin Renard   Add series and sp...
201
    	paramValues['param-drawing-type'] = this.get('param-drawing-type');
17433635   Benjamin Renard   Add series and sp...
202
203
204
    	if (this.get('param-drawing-object') != null)
    		paramValues['param-drawing-object'] = this.get('param-drawing-object').getJsonValues();
    	
17433635   Benjamin Renard   Add series and sp...
205
206
207
    	return paramValues;
    }
});