Blame view

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

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

    	paramValues['param-type'] = this.get('param-type');
684bfc1c   Benjamin Renard   Save TT or catalo...
242
	paramValues['param-ttcat-name'] = this.get('param-ttcat-name');
17433635   Benjamin Renard   Add series and sp...
243
    	paramValues['param-drawing-type'] = this.get('param-drawing-type');
17433635   Benjamin Renard   Add series and sp...
244
245
246
    	if (this.get('param-drawing-object') != null)
    		paramValues['param-drawing-object'] = this.get('param-drawing-object').getJsonValues();
    	
17433635   Benjamin Renard   Add series and sp...
247
248
    	return paramValues;
    }
2b60247d   Benjamin Renard   Set drawing optio...
249
});