Blame view

js/app/models/PlotObjects/PlotParamObject.js 7.37 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',
ebebd92d   Benjamin Renard   Add intervals dra...
22
		   'amdaPlotObj.PlotOrbitSerieObject',
a0bf9157   Benjamin Renard   Add tick plot and...
23
24
	           'amdaPlotObj.PlotSpectroObject',
	           'amdaPlotObj.PlotStatusBarObject',
6a801541   Benjamin Renard   Add possibility t...
25
26
	           'amdaPlotObj.PlotTickBarObject',
	           'amdaPlotObj.PlotInstantSerieObject',
ebebd92d   Benjamin Renard   Add intervals dra...
27
28
	           'amdaPlotObj.PlotInstantSpectroObject',
		   'amdaPlotObj.PlotIntervalsObject'
17433635   Benjamin Renard   Add series and sp...
29
30
31
	],
	
	fields : [
ea69a33c   Benjamin Renard   Allow drag&drop o...
32
                  {name: 'param-type', type: 'string', defaultValue: 'param'}, //Available types: param, ttcat
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
33
                  {name: 'param-ttcat-name', type: 'string'},
17433635   Benjamin Renard   Add series and sp...
34
	          {name: 'param-drawing-type', type: 'string'},
bb6e93d9   Benjamin Renard   Implement templat...
35
	          {name: 'param-drawing-object', type: 'auto'}
17433635   Benjamin Renard   Add series and sp...
36
37
38
39
40
41
42
43
44
45
    ],
    
    associations : [
              {
            	  type  : 'belongsTo',
                  model : 'amdaPlotObj.PlotPanelObject',
                  getterName : 'Panel'
              }
    ],
    
18d4a11e   Benjamin Renard   Save and load plo...
46
47
48
    constructor: function(){
        var me = this;
        me.callParent(arguments);
18d4a11e   Benjamin Renard   Save and load plo...
49
50
51
52
53
        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
54
        this.dirty = false;
18d4a11e   Benjamin Renard   Save and load plo...
55
56
57
58
59
60
61
    },
    
    loadDrawingObject: function(drawing)
    {
    	var drawingObject = this.get('param-drawing-object');
    	if (drawingObject == null)
    		return;
a971060f   Benjamin Renard   Fix some bugs
62
63
    	this.set('param-drawing-object', this.createDrawingObjectByType(this.get('param-drawing-type'), drawing));
    	drawingObject.dirty = false;
7b963397   Elena.Budnik   correct init for 2d
64
	 
18d4a11e   Benjamin Renard   Save and load plo...
65
66
    },
    
ea69a33c   Benjamin Renard   Allow drag&drop o...
67
    createDrawingObjectByType : function(drawingType, data)
17433635   Benjamin Renard   Add series and sp...
68
    {
ea69a33c   Benjamin Renard   Allow drag&drop o...
69
70
    	//Create drawing object in relation with the drawing type
    	switch (drawingType)
17433635   Benjamin Renard   Add series and sp...
71
72
    	{
    	case 'serie' :
a971060f   Benjamin Renard   Fix some bugs
73
    		return new amdaPlotObj.PlotSerieObject(data);
e84ed2cf   Benjamin Renard   Add Interval Tick...
74
75
		case 'orbit-serie' :
			return new amdaPlotObj.PlotOrbitSerieObject(data);
17433635   Benjamin Renard   Add series and sp...
76
    	case 'spectro' :
a971060f   Benjamin Renard   Fix some bugs
77
    		return new amdaPlotObj.PlotSpectroObject(data);
a0bf9157   Benjamin Renard   Add tick plot and...
78
    	case 'status-bar' :
a971060f   Benjamin Renard   Fix some bugs
79
    		return new amdaPlotObj.PlotStatusBarObject(data);
a0bf9157   Benjamin Renard   Add tick plot and...
80
    	case 'tick-bar' :
a971060f   Benjamin Renard   Fix some bugs
81
    		return new amdaPlotObj.PlotTickBarObject(data);
6a801541   Benjamin Renard   Add possibility t...
82
    	case 'iserie' :
a971060f   Benjamin Renard   Fix some bugs
83
    		return new amdaPlotObj.PlotInstantSerieObject(data);
6a801541   Benjamin Renard   Add possibility t...
84
    	case 'ispectro' :
a971060f   Benjamin Renard   Fix some bugs
85
    		return new amdaPlotObj.PlotInstantSpectroObject(data);
ebebd92d   Benjamin Renard   Add intervals dra...
86
87
	case 'intervals' :
		return new amdaPlotObj.PlotIntervalsObject(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
    },
    
ea69a33c   Benjamin Renard   Allow drag&drop o...
93
    changeDrawingType: function(drawingType, drawData)
a971060f   Benjamin Renard   Fix some bugs
94
    {
ea69a33c   Benjamin Renard   Allow drag&drop o...
95
    	if (drawingType == this.get('param-drawing-type'))
a971060f   Benjamin Renard   Fix some bugs
96
97
    		return;
    	
ea69a33c   Benjamin Renard   Allow drag&drop o...
98
    	this.set('param-drawing-type', drawingType);
a971060f   Benjamin Renard   Fix some bugs
99
    	
ea69a33c   Benjamin Renard   Allow drag&drop o...
100
    	this.set('param-drawing-object', this.createDrawingObjectByType(drawingType));
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();
ea69a33c   Benjamin Renard   Allow drag&drop o...
106
    		if (this.get('param-drawing-object').loadFromData && drawData && (drawingType == drawData.type))
ced82260   Benjamin Renard   Get initial plot ...
107
108
    			this.get('param-drawing-object').loadFromData(drawData);
    	}
17433635   Benjamin Renard   Add series and sp...
109
110
    },
    
a0bf9157   Benjamin Renard   Add tick plot and...
111
    getAvailableDrawingObjectByPlotType: function(plotType) {
ea69a33c   Benjamin Renard   Allow drag&drop o...
112
113
114
115
116
117
118
        switch (this.get('param-type'))
        {
        case 'param' :
    	    switch (plotType)
    	    {
    	    case 'timePlot'  :
    	    case 'epochPlot' :
a0bf9157   Benjamin Renard   Add tick plot and...
119
120
121
122
123
124
    		return [
    		        {'key' : 'serie', 'value' : 'Serie'},
    		        {'key' : 'spectro', 'value' : 'Spectro'},
    		        {'key' : 'tick-bar', 'value' : 'Tick Bar'},
    		        {'key' : 'status-bar', 'value' : 'Status Bar'}
    		];
ea69a33c   Benjamin Renard   Allow drag&drop o...
125
    	    case 'xyPlot' :
a0bf9157   Benjamin Renard   Add tick plot and...
126
127
128
129
    		return [
    		        {'key' : 'serie', 'value' : 'Serie'},
    		        {'key' : 'orbit-serie', 'value' : 'Orbit Serie'} 
    		];
ea69a33c   Benjamin Renard   Allow drag&drop o...
130
    	    case 'instantPlot' :
a0bf9157   Benjamin Renard   Add tick plot and...
131
    		return [
6a801541   Benjamin Renard   Add possibility t...
132
133
    		        {'key' : 'iserie', 'value' : 'Serie'},
    		        {'key' : 'ispectro', 'value' : 'Spectro'}
a0bf9157   Benjamin Renard   Add tick plot and...
134
    		];
ea69a33c   Benjamin Renard   Allow drag&drop o...
135
    	    case 'statusPlot' :
a0bf9157   Benjamin Renard   Add tick plot and...
136
137
138
    		return [
    		        {'key' : 'status-bar', 'value' : 'Status Bar'}
    		];
ea69a33c   Benjamin Renard   Allow drag&drop o...
139
    	    case 'tickPlot' :
a0bf9157   Benjamin Renard   Add tick plot and...
140
141
142
    		return [
    		        {'key' : 'tick-bar', 'value' : 'Tick Bar'}
    		];
ea69a33c   Benjamin Renard   Allow drag&drop o...
143
144
145
146
147
148
149
    	    }
            break;
        case 'ttcat':
            switch (plotType)
            {
            case 'timePlot':
                return [
ebebd92d   Benjamin Renard   Add intervals dra...
150
			{'key' : 'intervals', 'value' : 'Intervals'},
ea69a33c   Benjamin Renard   Allow drag&drop o...
151
152
153
154
155
156
157
158
159
160
                        {'key' : 'serie', 'value' : 'Serie'},
                        {'key' : 'status-bar', 'value' : 'Status Bar'}
                ];
            case 'statusPlot':
                return [
                        {'key' : 'status-bar', 'value' : 'Status Bar'}
                ];
            }
            break;
        }
a0bf9157   Benjamin Renard   Add tick plot and...
161
162
163
    	return [];
    },
    
ea69a33c   Benjamin Renard   Allow drag&drop o...
164
    setDefaultValues: function(drawingType)
17433635   Benjamin Renard   Add series and sp...
165
    {
ea69a33c   Benjamin Renard   Allow drag&drop o...
166
    	this.changeDrawingType(drawingType);
17433635   Benjamin Renard   Add series and sp...
167
    },
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
168

fd5552a4   Benjamin Renard   Info for plot ele...
169
170
171
    getShortInfo : function(plotType)
    {
    	var availableDrawingObjects = this.getAvailableDrawingObjectByPlotType(plotType);
ea69a33c   Benjamin Renard   Allow drag&drop o...
172
		var typeName = amdaPlotObj.PlotObjectConfig.getValueByKey(availableDrawingObjects, this.get('param-drawing-type'));
fd5552a4   Benjamin Renard   Info for plot ele...
173
		
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
174
175
176
177
178
179
180
		var fullName = '';
		if (this.get('param-type') == 'ttcat') {
			fullName = this.get('param-ttcat-name');
		}
		else {
			fullName = this.getParamFullName();
		}
7ac3ce50   Benjamin Renard   First implementat...
181
		
bb6e93d9   Benjamin Renard   Implement templat...
182
		var info = '';
51b7c77c   Benjamin Renard   Add templated par...
183
		
fd5552a4   Benjamin Renard   Info for plot ele...
184
185
186
		switch (plotType)
		{
		case 'xyPlot' :
e84ed2cf   Benjamin Renard   Add Interval Tick...
187
188
189
			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...
190
				info = fullName+', '+projection;
e84ed2cf   Benjamin Renard   Add Interval Tick...
191
192
			}
			else
bb6e93d9   Benjamin Renard   Implement templat...
193
				info = fullName+' = f('+this.get('param-drawing-object').get('serie-xaxis-param')+', t)';
fd5552a4   Benjamin Renard   Info for plot ele...
194
195
			break;
		case 'instantPlot' :
bb6e93d9   Benjamin Renard   Implement templat...
196
			info = fullName;
fd5552a4   Benjamin Renard   Info for plot ele...
197
198
			break;
		default :
bb6e93d9   Benjamin Renard   Implement templat...
199
			info = fullName+' = f(t)';
fd5552a4   Benjamin Renard   Info for plot ele...
200
201
		}
		
ea69a33c   Benjamin Renard   Allow drag&drop o...
202
		info += ', '+typeName;
fd5552a4   Benjamin Renard   Info for plot ele...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
		
		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
219
220
221
222
223
224
225
226
227
228
    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...
229
230
    getJsonValues : function() 
    {
bb6e93d9   Benjamin Renard   Implement templat...
231
    	var paramValues  = this.callParent(arguments);
ea69a33c   Benjamin Renard   Allow drag&drop o...
232
233

    	paramValues['param-type'] = this.get('param-type');
684bfc1c   Benjamin Renard   Save TT or catalo...
234
	paramValues['param-ttcat-name'] = this.get('param-ttcat-name');
17433635   Benjamin Renard   Add series and sp...
235
    	paramValues['param-drawing-type'] = this.get('param-drawing-type');
17433635   Benjamin Renard   Add series and sp...
236
237
238
    	if (this.get('param-drawing-object') != null)
    		paramValues['param-drawing-object'] = this.get('param-drawing-object').getJsonValues();
    	
17433635   Benjamin Renard   Add series and sp...
239
240
    	return paramValues;
    }
2b60247d   Benjamin Renard   Set drawing optio...
241
});