Blame view

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

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

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