Blame view

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

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

    	paramValues['param-type'] = this.get('param-type');
684bfc1c   Benjamin Renard   Save TT or catalo...
253
	paramValues['param-ttcat-name'] = this.get('param-ttcat-name');
17433635   Benjamin Renard   Add series and sp...
254
    	paramValues['param-drawing-type'] = this.get('param-drawing-type');
17433635   Benjamin Renard   Add series and sp...
255
256
257
    	if (this.get('param-drawing-object') != null)
    		paramValues['param-drawing-object'] = this.get('param-drawing-object').getJsonValues();
    	
17433635   Benjamin Renard   Add series and sp...
258
259
    	return paramValues;
    }
2b60247d   Benjamin Renard   Set drawing optio...
260
});