Blame view

js/app/models/PlotObjects/PlotParamObject.js 6.17 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;
7b963397   Elena.Budnik   correct init for 2d
61
	 
18d4a11e   Benjamin Renard   Save and load plo...
62
63
    },
    
a971060f   Benjamin Renard   Fix some bugs
64
    createDrawingObjectByType : function(type, data)
17433635   Benjamin Renard   Add series and sp...
65
    {
17433635   Benjamin Renard   Add series and sp...
66
67
68
69
    	//Create drawing object in relation with the type
    	switch (type)
    	{
    	case 'serie' :
a971060f   Benjamin Renard   Fix some bugs
70
    		return new amdaPlotObj.PlotSerieObject(data);
e84ed2cf   Benjamin Renard   Add Interval Tick...
71
72
		case 'orbit-serie' :
			return new amdaPlotObj.PlotOrbitSerieObject(data);
17433635   Benjamin Renard   Add series and sp...
73
    	case 'spectro' :
a971060f   Benjamin Renard   Fix some bugs
74
    		return new amdaPlotObj.PlotSpectroObject(data);
a0bf9157   Benjamin Renard   Add tick plot and...
75
    	case 'status-bar' :
a971060f   Benjamin Renard   Fix some bugs
76
    		return new amdaPlotObj.PlotStatusBarObject(data);
a0bf9157   Benjamin Renard   Add tick plot and...
77
    	case 'tick-bar' :
a971060f   Benjamin Renard   Fix some bugs
78
    		return new amdaPlotObj.PlotTickBarObject(data);
6a801541   Benjamin Renard   Add possibility t...
79
    	case 'iserie' :
a971060f   Benjamin Renard   Fix some bugs
80
    		return new amdaPlotObj.PlotInstantSerieObject(data);
6a801541   Benjamin Renard   Add possibility t...
81
    	case 'ispectro' :
a971060f   Benjamin Renard   Fix some bugs
82
    		return new amdaPlotObj.PlotInstantSpectroObject(data);
17433635   Benjamin Renard   Add series and sp...
83
    	default :
a971060f   Benjamin Renard   Fix some bugs
84
    		return null;
17433635   Benjamin Renard   Add series and sp...
85
    	}
a971060f   Benjamin Renard   Fix some bugs
86
87
    },
    
ced82260   Benjamin Renard   Get initial plot ...
88
    changeDrawingType: function(type, drawData)
a971060f   Benjamin Renard   Fix some bugs
89
90
91
92
93
94
95
    {
    	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...
96
97
98
    	
    	//Set drawing object to default status
    	if (this.get('param-drawing-object') != null)
ced82260   Benjamin Renard   Get initial plot ...
99
    	{
17433635   Benjamin Renard   Add series and sp...
100
    		this.get('param-drawing-object').setDefaultValues();
2b60247d   Benjamin Renard   Set drawing optio...
101
    		if (this.get('param-drawing-object').loadFromData && drawData && (type == drawData.type))
ced82260   Benjamin Renard   Get initial plot ...
102
103
    			this.get('param-drawing-object').loadFromData(drawData);
    	}
17433635   Benjamin Renard   Add series and sp...
104
105
    },
    
a0bf9157   Benjamin Renard   Add tick plot and...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
    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...
124
125
    		        {'key' : 'iserie', 'value' : 'Serie'},
    		        {'key' : 'ispectro', 'value' : 'Spectro'}
a0bf9157   Benjamin Renard   Add tick plot and...
126
127
128
129
130
131
132
133
134
135
136
137
138
    		];
    	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...
139
140
    setDefaultValues: function(type)
    {
a971060f   Benjamin Renard   Fix some bugs
141
    	this.changeDrawingType(type);
17433635   Benjamin Renard   Add series and sp...
142
143
    },
    
fd5552a4   Benjamin Renard   Info for plot ele...
144
145
146
147
148
    getShortInfo : function(plotType)
    {
    	var availableDrawingObjects = this.getAvailableDrawingObjectByPlotType(plotType);
		var type = amdaPlotObj.PlotObjectConfig.getValueByKey(availableDrawingObjects, this.get('param-drawing-type'));
		
bb6e93d9   Benjamin Renard   Implement templat...
149
		var fullName = this.getParamFullName();
7ac3ce50   Benjamin Renard   First implementat...
150
		
bb6e93d9   Benjamin Renard   Implement templat...
151
		var info = '';
51b7c77c   Benjamin Renard   Add templated par...
152
		
fd5552a4   Benjamin Renard   Info for plot ele...
153
154
155
		switch (plotType)
		{
		case 'xyPlot' :
e84ed2cf   Benjamin Renard   Add Interval Tick...
156
157
158
			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...
159
				info = fullName+', '+projection;
e84ed2cf   Benjamin Renard   Add Interval Tick...
160
161
			}
			else
bb6e93d9   Benjamin Renard   Implement templat...
162
				info = fullName+' = f('+this.get('param-drawing-object').get('serie-xaxis-param')+', t)';
fd5552a4   Benjamin Renard   Info for plot ele...
163
164
			break;
		case 'instantPlot' :
bb6e93d9   Benjamin Renard   Implement templat...
165
			info = fullName;
fd5552a4   Benjamin Renard   Info for plot ele...
166
167
			break;
		default :
bb6e93d9   Benjamin Renard   Implement templat...
168
			info = fullName+' = f(t)';
fd5552a4   Benjamin Renard   Info for plot ele...
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
		}
		
		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
188
189
190
191
192
193
194
195
196
197
    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...
198
199
    getJsonValues : function() 
    {
bb6e93d9   Benjamin Renard   Implement templat...
200
    	var paramValues  = this.callParent(arguments);
17433635   Benjamin Renard   Add series and sp...
201
    	
17433635   Benjamin Renard   Add series and sp...
202
    	paramValues['param-drawing-type'] = this.get('param-drawing-type');
17433635   Benjamin Renard   Add series and sp...
203
204
205
    	if (this.get('param-drawing-object') != null)
    		paramValues['param-drawing-object'] = this.get('param-drawing-object').getJsonValues();
    	
17433635   Benjamin Renard   Add series and sp...
206
207
    	return paramValues;
    }
2b60247d   Benjamin Renard   Set drawing optio...
208
});