Blame view

js/app/models/PlotObjects/PlotPanelObject.js 28.6 KB
abe09878   Benjamin Renard   Add panels and ax...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Project      : AMDA-NG
 * Name         : PlotPanelObject.js
 * @class   amdaPlotObj.PlotPanelObject
 * @extends Ext.data.Model
 * @brief   Plot Panel Business Object Definition 
 * @author  Benjamin Renard
 * @version $Id: PlotPanelObject.js benjamin $
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	:           :13/08/2015: BRE  - file creation
 */
 
 		
Ext.define('amdaPlotObj.PlotPanelObject', {
	extend: 'Ext.data.Model',
dbb7bcbe   Benjamin Renard   Add curves defint...
18
	idProperty: 'id',
17433635   Benjamin Renard   Add series and sp...
19
	
abe09878   Benjamin Renard   Add panels and ax...
20
21
	requires: [
	           'amdaPlotObj.PlotObjectConfig',
17433635   Benjamin Renard   Add series and sp...
22
	           'amdaPlotObj.PlotAxisObject',
94abdb37   Benjamin Renard   Add params legend...
23
	           'amdaPlotObj.PlotParamObject',
339866c4   Benjamin Renard   Add text legend d...
24
	           'amdaPlotObj.PlotLegendSeriesObject',
829160b3   Benjamin Renard   Add constants def...
25
	           'amdaPlotObj.PlotLegendTextObject',
a8c54fb9   Benjamin Renard   Add text object p...
26
	           'amdaPlotObj.PlotConstantObject',
dbb7bcbe   Benjamin Renard   Add curves defint...
27
	           'amdaPlotObj.PlotTextObject',
486cc3c7   Benjamin Renard   Add fill elements...
28
29
	           'amdaPlotObj.PlotCurveObject',
	           'amdaPlotObj.PlotFillObject'
abe09878   Benjamin Renard   Add panels and ax...
30
31
32
33
	],
	
	fields : [
	          {name: 'id', type: 'string'},
7f23e0f7   Erdogan Furkan   #5119 -Done. Adde...
34
			  {name: 'info', type: 'string'},
2a0b8d2c   Benjamin Renard   Restore node stat...
35
36
37
38
39
40
41
42
	          {name: 'panel-node-state', type: 'int', defaultValue: 2}, //0 : collapsed, 1 : expanded, 2 : not set 
	          {name: 'axes-node-state', type: 'int', defaultValue: 2}, //0 : collapsed, 1 : expanded, 2 : not set 
	          {name: 'params-node-state', type: 'int', defaultValue: 2}, //0 : collapsed, 1 : expanded, 2 : not set 
	          {name: 'add-objects-node-state', type: 'int', defaultValue: 2}, //0 : collapsed, 1 : expanded, 2 : not set 
	          {name: 'legends-node-state', type: 'int', defaultValue: 2}, //0 : collapsed, 1 : expanded, 2 : not set 
	          {name: 'text-legends-node-state', type: 'int', defaultValue: 2}, //0 : collapsed, 1 : expanded, 2 : not set 
	          {name: 'drawing-objects-node-state', type: 'int', defaultValue: 2}, //0 : collapsed, 1 : expanded, 2 : not set 
	          {name: 'fills-node-state', type: 'int', defaultValue: 2}, //0 : collapsed, 1 : expanded, 2 : not set 
509bf9fa   Benjamin Renard   Replace panel ID ...
43
	          {name: 'panel-index', type: 'int'},
abe09878   Benjamin Renard   Add panels and ax...
44
	          {name: 'panel-background-color', type: 'string'},
255b183d   Benjamin Renard   Fix
45
		{ name: 'panel-plotareabackground-color', type: 'string', defaultValue: 'none' },
abe09878   Benjamin Renard   Add panels and ax...
46
47
48
49
50
51
52
53
54
              {name: 'panel-title-text', type: 'string'},
              {name: 'panel-title-color', type: 'string'},
              {name: 'panel-title-position', type: 'string'},
              {name: 'panel-title-alignment', type: 'string'},
              {name: 'panel-title-font-activated', type: 'boolean'},
              {name: 'panel-title-font-name', type: 'string'},
              {name: 'panel-title-font-size', type: 'int'},
              {name: 'panel-title-font-bold', type: 'boolean'},
              {name: 'panel-title-font-italic', type: 'boolean'},
afd10dba   Erdogan Furkan   #11242 - Done.
55
			  {name: 'panel-showint-info', type: 'boolean'},
abe09878   Benjamin Renard   Add panels and ax...
56
57
58
59
60
              {name: 'panel-plot-type', type: 'string'},
              {name: 'panel-font-activated', type: 'boolean'},
              {name: 'panel-font-name', type: 'string'},
              {name: 'panel-font-size', type: 'int'},
              {name: 'panel-font-bold', type: 'boolean'},
a0bf9157   Benjamin Renard   Add tick plot and...
61
              {name: 'panel-font-italic', type: 'boolean'},
003ba315   Benjamin Renard   Add Epoch Plot an...
62
63
64
65
66
67
68
69
70
71
72
73
              //Only used with layout Manual
              {name: 'panel-bounds-x', type: 'float'},
              {name: 'panel-bounds-y', type: 'float'},
              {name: 'panel-bounds-width', type: 'float'},
              {name: 'panel-bounds-height', type: 'float'},
              {name: 'panel-margin-left', type: 'float', useNull:true},
              {name: 'panel-margin-right', type: 'float', useNull:true},
              //Only used with layout Vertical
              {name: 'panel-prefered-width', type: 'float', useNull:true},
              {name: 'panel-prefered-height', type: 'float', useNull:true},
              //Only used for xyPlot
              {name: 'panel-scatter-isotropic', type: 'boolean'},
a0bf9157   Benjamin Renard   Add tick plot and...
74
75
76
77
              //Only used for statusPlot and timePlot
              {name: 'panel-status-position', type: 'string'},
              {name: 'panel-status-colormap', type: 'int'},
              //Only used for tickPlot and timePlot
003ba315   Benjamin Renard   Add Epoch Plot an...
78
79
              {name: 'panel-tick-format', type: 'int'},
              //Only used for epochPlot
6a801541   Benjamin Renard   Add possibility t...
80
81
82
83
84
85
86
87
88
89
90
91
              {name: 'panel-epoch-centertimeid', type: 'string'},
              //Only used for instantPlot
              {name: 'panel-instant-time', type: 'date',
            	  defaultValue:Ext.Date.add(Ext.Date.clearTime(new Date()),Ext.Date.DAY,-1),
            	  convert: function(value,rec) {
            		  if (!Ext.isDate(value)) {
            		    var valueString = new String(value);
            		    var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' '));
            		      return date;
            		  }
            		  return value;
            	  }
94abdb37   Benjamin Renard   Add params legend...
92
93
              },
              //Only used for timePlot, xyPlot, epochPlot and instantPlot
dbb7bcbe   Benjamin Renard   Add curves defint...
94
95
96
97
98
99
              {name: 'panel-legend-series', type: 'auto', defaultValue: null},
              
              {name: 'last-param-id', type: 'int', defaultValue:0},
              {name: 'last-textlegend-id', type: 'int', defaultValue:0},
              {name: 'last-constant-id', type: 'int', defaultValue:0},
              {name: 'last-textobj-id', type: 'int', defaultValue:0},
486cc3c7   Benjamin Renard   Add fill elements...
100
101
              {name: 'last-curve-id', type: 'int', defaultValue:0},
              {name: 'last-fill-id', type: 'int', defaultValue:0}
abe09878   Benjamin Renard   Add panels and ax...
102
103
104
105
106
107
108
109
110
    ],
    
    associations : [
              {
            	  type : 'hasMany', 
            	  model : 'amdaPlotObj.PlotAxisObject',
            	  name  : 'axes'
              },
              {
17433635   Benjamin Renard   Add series and sp...
111
112
113
114
115
            	  type : 'hasMany', 
            	  model : 'amdaPlotObj.PlotParamObject',
            	  name  : 'params'
              },
              {
339866c4   Benjamin Renard   Add text legend d...
116
117
118
119
120
            	  type : 'hasMany', 
            	  model : 'amdaPlotObj.PlotLegendTextObject',
            	  name  : 'textLegends'
              },
              {
829160b3   Benjamin Renard   Add constants def...
121
122
123
124
125
            	  type : 'hasMany', 
            	  model : 'amdaPlotObj.PlotConstantObject',
            	  name  : 'constants'
              },
              {
a8c54fb9   Benjamin Renard   Add text object p...
126
127
128
129
130
            	  type : 'hasMany',
            	  model : 'amdaPlotObj.PlotTextObject',
            	  name : 'textObjs'
              },
              {
dbb7bcbe   Benjamin Renard   Add curves defint...
131
132
133
134
135
            	  type : 'hasMany',
            	  model : 'amdaPlotObj.PlotCurveObject',
            	  name : 'curves'
              },
              {
486cc3c7   Benjamin Renard   Add fill elements...
136
137
138
139
140
            	  type : 'hasMany',
            	  model : 'amdaPlotObj.PlotFillObject',
            	  name : 'fills'
              },
              {
abe09878   Benjamin Renard   Add panels and ax...
141
            	  type  : 'belongsTo',
17433635   Benjamin Renard   Add series and sp...
142
                  model : 'amdaPlotObj.PlotTabObject'
abe09878   Benjamin Renard   Add panels and ax...
143
144
145
              }
    ],
    
ddfe608e   Elena.Budnik   redmine #4814
146
147
	 isComponent : false,
	  
18d4a11e   Benjamin Renard   Save and load plo...
148
149
150
151
152
153
154
155
156
    constructor: function(){
        var me = this;
        me.callParent(arguments);
        if ((arguments.length > 0) && arguments[0])
        {
        	if (arguments[0].axes)
        		me.loadAxes(arguments[0].axes);
        	if (arguments[0].params)
        		me.loadParams(arguments[0].params);
a971060f   Benjamin Renard   Fix some bugs
157
158
        	if (arguments[0]['text-legends'])
        		me.loadTextLegends(arguments[0]['text-legends']);
829160b3   Benjamin Renard   Add constants def...
159
160
        	if (arguments[0].constants)
        		me.loadConstants(arguments[0].constants);
a8c54fb9   Benjamin Renard   Add text object p...
161
162
        	if (arguments[0].textObjs)
        		me.loadTextObjs(arguments[0].textObjs);
dbb7bcbe   Benjamin Renard   Add curves defint...
163
164
        	if (arguments[0].curves)
        		me.loadCurves(arguments[0].curves);
486cc3c7   Benjamin Renard   Add fill elements...
165
166
        	if (arguments[0].fills)
        		me.loadFills(arguments[0].fills);
a971060f   Benjamin Renard   Fix some bugs
167
168
        	if (arguments[0]['panel-series-legend'])
        		me.loadSeriesLegend(arguments[0]['panel-series-legend']);
18d4a11e   Benjamin Renard   Save and load plo...
169
170
171
172
173
174
        }
        else
        {
        	//new object, set default fields values
        	me.setDefaultValues();
        }
a971060f   Benjamin Renard   Fix some bugs
175
        this.dirty = false;
18d4a11e   Benjamin Renard   Save and load plo...
176
177
178
179
180
181
182
183
184
    },
    
    loadAxes: function(axes)
    {
       this.axes().loadData(axes);
    },
    
    loadParams: function(params)
    {
b1a45580   Benjamin Renard   Add compatibility...
185
186
187
188
189
190
191
192
193
194
195
196
       /* Compatability mode */
       Ext.each(params, function(param, index) {
         if (param.hasOwnProperty('is-init')) {
            return;
         }
         params[index]['dim1-sum-type']  = param['dim1-is-range'] ? 1 : 0;
         params[index]['dim1-min-value'] = param['dim1-min-range'];
         params[index]['dim1-max-value'] = param['dim1-max-range'];
         params[index]['dim2-sum-type']  = param['dim2-is-range'] ? 1 : 0;
         params[index]['dim2-min-value'] = param['dim2-min-range'];
         params[index]['dim2-max-value'] = param['dim2-max-range'];
         params[index]['is-init'] = true;
7f23e0f7   Erdogan Furkan   #5119 -Done. Adde...
197
		 params[index]['info'] = param['info'];
b1a45580   Benjamin Renard   Add compatibility...
198
       });
18d4a11e   Benjamin Renard   Save and load plo...
199
200
201
       this.params().loadData(params);
    },
    
339866c4   Benjamin Renard   Add text legend d...
202
203
204
205
206
    loadTextLegends: function(textLegends)
    {
       this.textLegends().loadData(textLegends);
    },
    
829160b3   Benjamin Renard   Add constants def...
207
208
209
210
211
    loadConstants: function(constants)
    {
       this.constants().loadData(constants);
    },
    
a8c54fb9   Benjamin Renard   Add text object p...
212
213
214
215
216
    loadTextObjs: function(textObjs)
    {
    	this.textObjs().loadData(textObjs);
    },
    
dbb7bcbe   Benjamin Renard   Add curves defint...
217
218
219
220
221
    loadCurves: function(curves)
    {
    	this.curves().loadData(curves);
    },
    
486cc3c7   Benjamin Renard   Add fill elements...
222
223
224
225
226
    loadFills: function(fills)
    {
    	this.fills().loadData(fills);
    },
    
a971060f   Benjamin Renard   Fix some bugs
227
228
229
230
231
232
    loadSeriesLegend: function(seriesLegend)
    {
    	this.set('panel-legend-series', new amdaPlotObj.PlotLegendSeriesObject(seriesLegend));
    	this.get('panel-legend-series').dirty = false;
    },
    
abe09878   Benjamin Renard   Add panels and ax...
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
    initAxes : function()
    {
    	this.axes().removeAll();
    	switch (this.get('panel-plot-type'))
    	{
    	case 'timePlot' :
    		//Time axis
    		var recs = this.axes().add({id : 'time'});
        	recs[0].setDefaultValues('time');
        	//Y Left Axis
        	recs = this.axes().add({id : 'y-left'});
        	recs[0].setDefaultValues('y-left');
        	//Y Right Axis
        	recs = this.axes().add({id : 'y-right'});
        	recs[0].setDefaultValues('y-right');
        	//Color Axis
        	recs = this.axes().add({id : 'color'});
        	recs[0].setDefaultValues('color');
    		break;
2ac3a3f9   Erdogan Furkan   For now, histo1D ...
252
		case 'histoPlot':
abe09878   Benjamin Renard   Add panels and ax...
253
    	case 'xyPlot' :
abe09878   Benjamin Renard   Add panels and ax...
254
    		//X Axis
7ef7ea02   Benjamin Renard   Add erase button ...
255
    		var recs = this.axes().add({id : 'xaxis_id'});
abe09878   Benjamin Renard   Add panels and ax...
256
257
258
259
260
261
262
263
264
265
266
        	recs[0].setDefaultValues('x');
        	//Y Left Axis
        	recs = this.axes().add({id : 'y-left'});
        	recs[0].setDefaultValues('y-left');
        	//Y Right Axis
        	recs = this.axes().add({id : 'y-right'});
        	recs[0].setDefaultValues('y-right');
        	//Color Axis
        	recs = this.axes().add({id : 'color'});
        	recs[0].setDefaultValues('color');
    		break;
6a801541   Benjamin Renard   Add possibility t...
267
268
    	case 'instantPlot' :
    		//X Axis
7ef7ea02   Benjamin Renard   Add erase button ...
269
    		var recs = this.axes().add({id : 'xaxis_id'});
6a801541   Benjamin Renard   Add possibility t...
270
271
272
273
274
275
276
277
        	recs[0].setDefaultValues('x');
        	//Y Left Axis
        	recs = this.axes().add({id : 'y-left'});
        	recs[0].setDefaultValues('y-left');
        	//Color Axis
        	recs = this.axes().add({id : 'color'});
        	recs[0].setDefaultValues('color');
    		break;
abe09878   Benjamin Renard   Add panels and ax...
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
    	case 'epochPlot' :
    		//Epoch Axis
    		var recs = this.axes().add({id : 'epoch'});
        	recs[0].setDefaultValues('epoch');
        	//Y Left Axis
        	recs = this.axes().add({id : 'y-left'});
        	recs[0].setDefaultValues('y-left');
        	//Y Right Axis
        	recs = this.axes().add({id : 'y-right'});
        	recs[0].setDefaultValues('y-right');
        	//Color Axis
        	recs = this.axes().add({id : 'color'});
        	recs[0].setDefaultValues('color');
    		break;
    	case 'statusPlot' :
    	case 'tickPlot' :
    		//Time axis
    		var recs = this.axes().add({id : 'time'});
        	recs[0].setDefaultValues('time');
    		break;
    	}
    },
    
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
301
302
303
304
305
    createNewParam: function(paramId, data, onAfterCreate) {
	var isPlotOnly = (typeof data !== "undefined") && (typeof data.plotOnly !== "undefined") && data.plotOnly;
	var isTTCat = (typeof data !== "undefined") && (typeof data.isTTCat !== "undefined") && data.isTTCat;
	var isVector = (typeof data !== "undefined") && (typeof data.isVector !== "undefined") && data.isVector;
	var components = (typeof data !== "undefined") && (typeof data.components !== "undefined") && data.components ? data.components : null;
2fa56f95   Benjamin Renard   Predefined templa...
306
	var template_args = (typeof data !== "undefined") && (typeof data.template_args !== "undefined") && data.template_args ? data.template_args : null;
7f23e0f7   Erdogan Furkan   #5119 -Done. Adde...
307
	var info = (typeof data !== "undefined") && (typeof data.info !== "undefined") && data.info ? data.info : null;
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
308

dbb7bcbe   Benjamin Renard   Add curves defint...
309
    	this.set('last-param-id', this.get('last-param-id') + 1);
ced82260   Benjamin Renard   Get initial plot ...
310
311
    	
    	var emptyPanel = (this.params().getCount() == 0);
29dfb596   Benjamin Renard   Rework of ParamAr...
312
313
314
315

    	var obj = amdaModel.RequestParamObject.getEmptyObj();
	obj['id'] = this.get('last-param-id');
    	var recs = this.params().add(obj);
bb6e93d9   Benjamin Renard   Implement templat...
316
    	recs[0].set('paramid', paramId);
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
317
	recs[0].set('plotonly', isPlotOnly);
2fa56f95   Benjamin Renard   Predefined templa...
318
319
320
	if (template_args) {
		recs[0].set('template_args', template_args);
	}
7f23e0f7   Erdogan Furkan   #5119 -Done. Adde...
321
322
323
	if (info){
		recs[0].set('info', info);
	}
ddfe608e   Elena.Budnik   redmine #4814
324
		
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
325
326
    	if (components != null) {
    		if (components['index1']) {
29dfb596   Benjamin Renard   Rework of ParamAr...
327
			this.isComponent = true;
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
328
    			recs[0].set('dim1-index', components['index1']);
690e0a87   Benjamin Renard   Add sum in table ...
329
    		}
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
330
331
    		if (components['index2']) {
    			recs[0].set('dim2-index', components['index2']);
690e0a87   Benjamin Renard   Add sum in table ...
332
    		}
63ac7745   Benjamin Renard   Support component...
333
    	}
7b963397   Elena.Budnik   correct init for 2d
334

ea69a33c   Benjamin Renard   Allow drag&drop o...
335
	recs[0].set('param-type', isTTCat ? 'ttcat' : 'param');
a3c4d78a   Benjamin Renard   Use TT or Catlog ...
336
337
338
	if (isTTCat) {
		recs[0].set('param-ttcat-name', data.name);
	} 
ea69a33c   Benjamin Renard   Allow drag&drop o...
339

22dd7e8c   Elena.Budnik   Redmine #5142 : l...
340
341
342
343
344
345
346
    	// activate legend if vector & TimePlot
    	if ( isVector && this.get('panel-plot-type') == 'timePlot' ) {
			this.loadSeriesLegend();
			this.get('panel-legend-series').set('legend-series-activated',true);
		}
		
    	var me = this;		
ced82260   Benjamin Renard   Get initial plot ...
347
348
    	amdaPlotObj.PlotObjectConfig.getParamConfig(paramId, function (success, data) {
    		var availableDrawingObjects = null;
ddfe608e   Elena.Budnik   redmine #4814
349

ced82260   Benjamin Renard   Get initial plot ...
350
    		//Change type only if the panel is empty!
35c71481   Benjamin Renard   Set predefined dr...
351
    		if (success) {
ddfe608e   Elena.Budnik   redmine #4814
352
    			if (emptyPanel && !me.isComponent)
35c71481   Benjamin Renard   Set predefined dr...
353
    				me.changePlotType(data.panel.plotType);
f17b2e35   Hacene SI HADJ MOHAND   solving 8782
354
355
                        if(data.panel.isotropic)
                                me.setIsotropic(data.panel.isotropic);
ddfe608e   Elena.Budnik   redmine #4814
356
357
				
    			if (data.draw && !me.isComponent) {
35c71481   Benjamin Renard   Set predefined dr...
358
359
360
361
362
363
364
365
    				availableDrawingObjects = recs[0].getAvailableDrawingObjectByPlotType(me.get('panel-plot-type'));
    				
    				Ext.each(availableDrawingObjects, function (drawingObj) {
    					if (drawingObj.key == data.draw.type) {
    						availableDrawingObjects = [{'key' : data.draw.type}];
    					}
    				});
    			}
ced82260   Benjamin Renard   Get initial plot ...
366
367
368
369
370
371
372
373
374
    		}
    		
    		if (!availableDrawingObjects)
    			availableDrawingObjects = recs[0].getAvailableDrawingObjectByPlotType(me.get('panel-plot-type'));
    			
        	
    		recs[0].changeDrawingType(availableDrawingObjects[0].key, data ? data.draw : null);	

    		if (success && emptyPanel) {
22dd7e8c   Elena.Budnik   Redmine #5142 : l...
375

ced82260   Benjamin Renard   Get initial plot ...
376
377
378
379
380
381
    			if (data.additionalObjects && data.additionalObjects.curves) {
    				Ext.each(data.additionalObjects.curves, function (curveData) {
    					var newCurve = me.createNewCurve();
    					newCurve.loadFromData(curveData,recs[0].getId());
    				});
    			}
251a648a   Benjamin Renard   Load parameter ax...
382
383
384
385
386
387
388
389
390
391
392
393
    			
    			//Axes
    			if (data.draw && data.draw.axes) {
    				Ext.Object.each(data.draw.axes, function (axisKey, axisData) {
    					var axis = me.axes().getById(axisKey);
    					if (axis) {
    						Ext.Object.each(axisData, function (optKey, optData) {
    							axis.set(optKey, optData);
    						});
    					}
    				});
    			}
ced82260   Benjamin Renard   Get initial plot ...
394
395
396
397
398
399
    		}
    		
			me.dirty = true;
			
			onAfterCreate(recs[0]);
    	});
17433635   Benjamin Renard   Add series and sp...
400
401
402
403
404
405
406
407
    },
    
    removeParamById: function(paramId) {
    	//Retrieve param record
    	var paramRecord = this.params().getById(paramId);
    	if (paramRecord == null)
    		return false;
    	this.params().remove(paramRecord);
a971060f   Benjamin Renard   Fix some bugs
408
    	this.dirty = true;
981b1596   Benjamin Renard   Remove related ad...
409
410
411
412
413
414
415
	var curvesToRemove = [];
	this.curves().each(function(curve) {
		if (curve.get('curve-serie-id') == paramId) {
			curvesToRemove.push(curve);
		}
	});
	this.curves().remove(curvesToRemove);
17433635   Benjamin Renard   Add series and sp...
416
417
418
    	return true;
    },
    
339866c4   Benjamin Renard   Add text legend d...
419
    createNewTextLegend: function() {
dbb7bcbe   Benjamin Renard   Add curves defint...
420
    	this.set('last-textlegend-id', this.get('last-textlegend-id') + 1);
fd5552a4   Benjamin Renard   Info for plot ele...
421
    	var recs = this.textLegends().add({id : this.get('last-textlegend-id')});
339866c4   Benjamin Renard   Add text legend d...
422
    	recs[0].setDefaultValues();
a971060f   Benjamin Renard   Fix some bugs
423
    	this.dirty = true;
339866c4   Benjamin Renard   Add text legend d...
424
425
426
427
428
429
430
431
432
    	return recs[0];
    },
    
    removeTextLegendById: function(legendId) {
    	//Retrieve text legend record
    	var textLegendRecord = this.textLegends().getById(legendId);
    	if (textLegendRecord == null)
    		return false;
    	this.textLegends().remove(textLegendRecord);
a971060f   Benjamin Renard   Fix some bugs
433
    	this.dirty = true;
339866c4   Benjamin Renard   Add text legend d...
434
435
436
    	return true;
    },
    
829160b3   Benjamin Renard   Add constants def...
437
    createNewConstant: function() {
dbb7bcbe   Benjamin Renard   Add curves defint...
438
    	this.set('last-constant-id', this.get('last-constant-id') + 1);
fd5552a4   Benjamin Renard   Info for plot ele...
439
    	var recs = this.constants().add({id : this.get('last-constant-id')});
829160b3   Benjamin Renard   Add constants def...
440
    	recs[0].setDefaultValues();
a971060f   Benjamin Renard   Fix some bugs
441
    	this.dirty = true;
829160b3   Benjamin Renard   Add constants def...
442
443
444
445
446
447
448
449
450
    	return recs[0];
    },
    
    removeConstantById: function(constantId) {
    	//Retrieve constant record
    	var constantRecord = this.constants().getById(constantId);
    	if (constantRecord == null)
    		return false;
    	this.constants().remove(constantRecord);
a971060f   Benjamin Renard   Fix some bugs
451
    	this.dirty = true;
829160b3   Benjamin Renard   Add constants def...
452
453
454
    	return true;
    },
    
a8c54fb9   Benjamin Renard   Add text object p...
455
    createNewTextObject: function() {
dbb7bcbe   Benjamin Renard   Add curves defint...
456
    	this.set('last-textobj-id', this.get('last-textobj-id') + 1);
fd5552a4   Benjamin Renard   Info for plot ele...
457
    	var recs = this.textObjs().add({id : this.get('last-textobj-id')});
a8c54fb9   Benjamin Renard   Add text object p...
458
    	recs[0].setDefaultValues();
a971060f   Benjamin Renard   Fix some bugs
459
    	this.dirty = true;
a8c54fb9   Benjamin Renard   Add text object p...
460
461
462
463
464
465
466
467
468
    	return recs[0];
    },
    
    removeTextObjectById: function(textObjId) {
    	//Retrieve text object record
    	var textObjRecord = this.textObjs().getById(textObjId);
    	if (textObjRecord == null)
    		return false;
    	this.textObjs().remove(textObjRecord);
a971060f   Benjamin Renard   Fix some bugs
469
    	this.dirty = true;
a8c54fb9   Benjamin Renard   Add text object p...
470
471
472
    	return true;
    },
    
dbb7bcbe   Benjamin Renard   Add curves defint...
473
474
    createNewCurve: function() {
    	this.set('last-curve-id', this.get('last-curve-id') + 1);
fd5552a4   Benjamin Renard   Info for plot ele...
475
    	var recs = this.curves().add({id : this.get('last-curve-id')});
dbb7bcbe   Benjamin Renard   Add curves defint...
476
    	recs[0].setDefaultValues();
a971060f   Benjamin Renard   Fix some bugs
477
    	this.dirty = true;
dbb7bcbe   Benjamin Renard   Add curves defint...
478
479
480
481
482
483
484
485
486
    	return recs[0];
    },
    
    removeCurveById: function(curveId) {
    	//Retrieve curve record
    	var curveRecord = this.curves().getById(curveId);
    	if (curveRecord == null)
    		return false;
    	this.curves().remove(curveRecord);
a971060f   Benjamin Renard   Fix some bugs
487
    	this.dirty = true;
dbb7bcbe   Benjamin Renard   Add curves defint...
488
489
490
    	return true;
    },
    
486cc3c7   Benjamin Renard   Add fill elements...
491
492
493
494
    createNewFill: function() {
    	this.set('last-fill-id', this.get('last-fill-id') + 1);
    	var recs = this.fills().add({id : this.get('last-fill-id')});
    	recs[0].setDefaultValues();
a971060f   Benjamin Renard   Fix some bugs
495
    	this.dirty = true;
486cc3c7   Benjamin Renard   Add fill elements...
496
497
498
499
500
501
502
503
504
    	return recs[0];
    },
    
    removeFillById: function(fillId) {
    	//Retrieve fill record
    	var fillRecord = this.fills().getById(fillId);
    	if (fillRecord == null)
    		return false;
    	this.fills().remove(fillRecord);
a971060f   Benjamin Renard   Fix some bugs
505
    	this.dirty = true;
486cc3c7   Benjamin Renard   Add fill elements...
506
507
508
    	return true;
    },
    
f17b2e35   Hacene SI HADJ MOHAND   solving 8782
509
510
511
512
513
514
    setIsotropic: function (isotropic){
        if(this.get('panel-plot-type') !=  'xyPlot') 
            return;
        this.set('panel-scatter-isotropic', isotropic);
    },
    
a971060f   Benjamin Renard   Fix some bugs
515
516
    changePlotType: function(plotType) {
    	if (plotType == this.get('panel-plot-type'))
a0bf9157   Benjamin Renard   Add tick plot and...
517
518
519
520
521
522
523
524
525
526
527
528
529
530
    		return;
    	
    	this.set('panel-plot-type', plotType);
    	this.params().each(function (param, index) {
    		var availableDrawingObjects = param.getAvailableDrawingObjectByPlotType(plotType);
    		var compatibleDrawingType = false;
    		Ext.each(availableDrawingObjects, function (item, index) {
    			if (param.get('param-drawing-type') == item.key)
    			{
    				compatibleDrawingType = true;
    			}
    		});
    		if (!compatibleDrawingType)
    		{
a971060f   Benjamin Renard   Fix some bugs
531
    			param.changeDrawingType(availableDrawingObjects[0].key);
a0bf9157   Benjamin Renard   Add tick plot and...
532
533
534
    		}
    	});
    	this.initAxes();
94abdb37   Benjamin Renard   Add params legend...
535
536
537
538
539
540
    	
    	if ((plotType == 'timePlot') || (plotType == 'xyPlot') || (plotType == 'epochPlot') || (plotType == 'instantPlot'))
    	{
    		if (this.get('panel-legend-series') == null)
    		{
    			this.set('panel-legend-series', new amdaPlotObj.PlotLegendSeriesObject());
94abdb37   Benjamin Renard   Add params legend...
541
542
543
    		}
    	}
    	else
339866c4   Benjamin Renard   Add text legend d...
544
    	{
94abdb37   Benjamin Renard   Add params legend...
545
    		this.set('panel-legend-series', null);
339866c4   Benjamin Renard   Add text legend d...
546
547
    		this.textLegends().removeAll();
    	}
fd5552a4   Benjamin Renard   Info for plot ele...
548
549
550
551
552
553
    	
    	if ((plotType == 'tickPlot') || (plotType == 'statusPlot'))
    	{
    		this.textObjs().removeAll();
    		this.constants().removeAll();
    		this.curves().removeAll();
486cc3c7   Benjamin Renard   Add fill elements...
554
    		this.fills().removeAll();
fd5552a4   Benjamin Renard   Info for plot ele...
555
556
557
    	}
    	else if (plotType != 'xyPlot')
    		this.curves().removeAll();
a0bf9157   Benjamin Renard   Add tick plot and...
558
559
    },
    
abe09878   Benjamin Renard   Add panels and ax...
560
561
    setDefaultValues: function()
    {
b1dc2eb3   Erdogan Furkan   More modifications
562
563
    	this.set('panel-background-color', amdaDefaultValues.plot.panel.backgroundColor);
		this.set('panel-plotareabackground-color', amdaDefaultValues.plot.panel.backgroundColor);
abe09878   Benjamin Renard   Add panels and ax...
564
    	this.set('panel-title-text', '');
b1dc2eb3   Erdogan Furkan   More modifications
565
566
567
    	this.set('panel-title-color', amdaDefaultValues.plot.panel.title.color);
    	this.set('panel-title-position', amdaDefaultValues.plot.panel.title.position);
    	this.set('panel-title-alignment', amdaDefaultValues.plot.panel.title.alignment);
abe09878   Benjamin Renard   Add panels and ax...
568
569
    	
    	this.set('panel-title-font-activated', false);
b1dc2eb3   Erdogan Furkan   More modifications
570
571
    	this.set('panel-title-font-name', amdaDefaultValues.plot.panel.font.name);
    	this.set('panel-title-font-size', amdaDefaultValues.plot.panel.font.size);
abe09878   Benjamin Renard   Add panels and ax...
572
573
574
    	this.set('panel-title-font-bold', false);
    	this.set('panel-title-font-italic', false);
    	
afd10dba   Erdogan Furkan   #11242 - Done.
575
576
577

    	this.set('panel-showint-info', false);

abe09878   Benjamin Renard   Add panels and ax...
578
    	this.set('panel-font-activated', false);
b1dc2eb3   Erdogan Furkan   More modifications
579
580
    	this.set('panel-font-name', amdaDefaultValues.plot.panel.font.name);
    	this.set('panel-font-size', amdaDefaultValues.plot.panel.font.size);
abe09878   Benjamin Renard   Add panels and ax...
581
582
583
    	this.set('panel-font-bold', false);
    	this.set('panel-font-italic', false);
    	
003ba315   Benjamin Renard   Add Epoch Plot an...
584
585
586
587
588
589
590
591
592
593
594
    	this.set('panel-bounds-x', 0);
    	this.set('panel-bounds-y', 0);
    	this.set('panel-bounds-width', 1);
    	this.set('panel-bounds-height', 1);
    	
    	this.set('panel-margin-left', null);
    	this.set('panel-margin-right', null);
    	
    	this.set('panel-prefered-width', null);
    	this.set('panel-prefered-height', null);
    	
b1dc2eb3   Erdogan Furkan   More modifications
595
    	this.set('panel-scatter-isotropic', amdaDefaultValues.plot.panel.isotropic);
003ba315   Benjamin Renard   Add Epoch Plot an...
596
    	
b1dc2eb3   Erdogan Furkan   More modifications
597
598
    	this.set('panel-status-position', amdaDefaultValues.plot.panel.status.position);
    	this.set('panel-status-colormap', amdaDefaultValues.plot.panel.status.colorMap);
a0bf9157   Benjamin Renard   Add tick plot and...
599
600
601
    	
    	this.set('panel-tick-format', "");
    	
003ba315   Benjamin Renard   Add Epoch Plot an...
602
603
    	this.set('panel-epoch-centertimeid', "");
    	
b1dc2eb3   Erdogan Furkan   More modifications
604
    	this.changePlotType(amdaDefaultValues.plot.panel.plotType);
abe09878   Benjamin Renard   Add panels and ax...
605
606
    },
    
fd5552a4   Benjamin Renard   Info for plot ele...
607
608
    getPanelShortInfo : function()
    {
4f728fd9   Erdogan Furkan   For now 2
609
    	var type = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaDefaultConfigs.availablePlotTypes, this.get('panel-plot-type'));
509bf9fa   Benjamin Renard   Replace panel ID ...
610
		var info = '#'+this.get('panel-index')+', '+type;
fd5552a4   Benjamin Renard   Info for plot ele...
611
612
613
614
615
616
617
618
619
620
		switch (this.get('panel-plot-type'))
		{
		case 'instantPlot' :
			info += (', '+Ext.Date.format(this.get('panel-instant-time'), "Y/m/d H:i:s"));
			break;
		case 'epochPlot' :
			info += (', '+this.get('panel-epoch-centertimeid'));
			break;
		case 'xyPlot' :
			if (this.get('panel-scatter-isotropic'))
2dfd23b1   Benjamin Renard   Commit missing file
621
				info += ', Orthonormal';
fd5552a4   Benjamin Renard   Info for plot ele...
622
623
624
625
626
			break;
		}
		return info;
    },
    
a971060f   Benjamin Renard   Fix some bugs
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
    isDirty : function()
    {
    	if (this.dirty)
    		return true;
    	var d = false;
    	
    	this.axes().each(function (axe, index) {
    		if (axe.isDirty())
    			d = true;
    	});
    	if (d)
    		return d;
    	
    	this.params().each(function (param, index) {
    		if (param.isDirty())
    			d = true;
    	});
    	if (d)
    		return d;
    	
    	this.textLegends().each(function (text, index) {
    		if (text.dirty)
    			d = true;
    	});
    	if (d)
    		return d;
    	
    	this.constants().each(function (constant, index) {
    		if (constant.dirty)
    			d = true;
    	});
    	if (d)
    		return d;
    	
    	this.textObjs().each(function (textObj, index) {
    		if (textObj.dirty)
    			d = true;
    	});
    	if (d)
    		return d;
    	
    	this.curves().each(function (curve, index) {
    		if (curve.isDirty())
    			d = true;
    	});
    	if (d)
    		return d;
    	
    	this.fills().each(function (fill, index) {
    		if (fill.dirty)
    			d = true;
    	});
    	if (d)
    		return d;
    	
    	if (this.get('panel-legend-series') != null)
    		if (this.get('panel-legend-series').dirty)
    			return true;
    	
    	return false;
    },
    
17433635   Benjamin Renard   Add series and sp...
689
    getJsonValues : function() 
abe09878   Benjamin Renard   Add panels and ax...
690
691
692
    {
    	var panelValues  = new Object();
    	
dbb7bcbe   Benjamin Renard   Add curves defint...
693
694
    	panelValues['id'] = this.get('id');
    	
2a0b8d2c   Benjamin Renard   Restore node stat...
695
696
697
698
699
700
701
702
703
    	panelValues['panel-node-state'] = this.get('panel-node-state');
    	panelValues['axes-node-state'] = this.get('axes-node-state');
    	panelValues['params-node-state'] = this.get('params-node-state');
    	panelValues['add-objects-node-state'] = this.get('add-objects-node-state');
    	panelValues['legends-node-state'] = this.get('legends-node-state');
    	panelValues['text-legends-node-state'] = this.get('text-legends-node-state');
    	panelValues['drawing-objects-node-state'] = this.get('drawing-objects-node-state');
    	panelValues['fills-node-state'] = this.get('fills-node-state');
    	
509bf9fa   Benjamin Renard   Replace panel ID ...
704
705
    	panelValues['panel-index'] = this.get('panel-index');
    	
abe09878   Benjamin Renard   Add panels and ax...
706
    	panelValues['panel-background-color'] = this.get('panel-background-color');
2fb8bbf3   Erdogan Furkan   #5390 - First mod...
707
		panelValues['panel-plotareabackground-color'] = this.get('panel-plotareabackground-color');
abe09878   Benjamin Renard   Add panels and ax...
708
709
710
711
712
713
714
715
716
    	panelValues['panel-title-text'] = this.get('panel-title-text');
    	panelValues['panel-title-color'] = this.get('panel-title-color');
    	panelValues['panel-title-position'] = this.get('panel-title-position');
    	panelValues['panel-title-alignment'] = this.get('panel-title-alignment');
    	panelValues['panel-title-font-activated'] = this.get('panel-title-font-activated');
    	panelValues['panel-title-font-name'] = this.get('panel-title-font-name');
    	panelValues['panel-title-font-size'] = this.get('panel-title-font-size');
    	panelValues['panel-title-font-bold'] = this.get('panel-title-font-bold');
    	panelValues['panel-title-font-italic'] = this.get('panel-title-font-italic');
afd10dba   Erdogan Furkan   #11242 - Done.
717
718
719

    	panelValues['panel-showint-info'] = this.get('panel-showint-info');

abe09878   Benjamin Renard   Add panels and ax...
720
721
722
723
724
725
726
    	panelValues['panel-plot-type'] = this.get('panel-plot-type');
    	panelValues['panel-font-activated'] = this.get('panel-font-activated');
    	panelValues['panel-font-name'] = this.get('panel-font-name');
    	panelValues['panel-font-size'] = this.get('panel-font-size');
    	panelValues['panel-font-bold'] = this.get('panel-font-bold');
    	panelValues['panel-font-italic'] = this.get('panel-font-italic');
    	
003ba315   Benjamin Renard   Add Epoch Plot an...
727
728
729
730
731
732
733
734
735
736
737
738
739
740
    	panelValues['panel-bounds-x']      = this.get('panel-bounds-x');
    	panelValues['panel-bounds-y']      = this.get('panel-bounds-y');
    	panelValues['panel-bounds-width']  = this.get('panel-bounds-width');
    	panelValues['panel-bounds-height'] = this.get('panel-bounds-height');
    	
    	panelValues['panel-margin-left'] = this.get('panel-margin-left') ? this.get('panel-margin-left') : -1;
    	panelValues['panel-margin-right'] = this.get('panel-margin-right') ? this.get('panel-margin-right') : -1;
    	
    	panelValues['panel-prefered-width'] = this.get('panel-prefered-width') ? this.get('panel-prefered-width') : -1;
    	panelValues['panel-prefered-height'] = this.get('panel-prefered-height') ? this.get('panel-prefered-height') : -1;
    	
    	if (this.get('panel-plot-type') == 'xyPlot')
    		panelValues['panel-scatter-isotropic'] = this.get('panel-scatter-isotropic');
    	
a0bf9157   Benjamin Renard   Add tick plot and...
741
742
743
744
745
746
747
748
749
750
751
    	if ((this.get('panel-plot-type') == 'statusPlot') || (this.get('panel-plot-type') == 'timePlot'))
    	{
    		panelValues['panel-status-position'] = this.get('panel-status-position');
    		panelValues['panel-status-colormap'] = this.get('panel-status-colormap');
    	}
    	
    	if ((this.get('panel-plot-type') == 'tickPlot') || (this.get('panel-plot-type') == 'timePlot'))
    	{
    		panelValues['panel-tick-format'] = this.get('panel-tick-format');
    	}
    	
003ba315   Benjamin Renard   Add Epoch Plot an...
752
753
754
    	if (this.get('panel-plot-type') == 'epochPlot')
    		panelValues['panel-epoch-centertimeid'] = this.get('panel-epoch-centertimeid');
    	
6a801541   Benjamin Renard   Add possibility t...
755
756
757
    	if (this.get('panel-plot-type') == 'instantPlot')
    		panelValues['panel-instant-time'] = this.get('panel-instant-time');
    	
a971060f   Benjamin Renard   Fix some bugs
758
    	if (this.get('panel-legend-series') != null)
94abdb37   Benjamin Renard   Add params legend...
759
760
    		panelValues['panel-series-legend'] = this.get('panel-legend-series').getJsonValues();
    	
339866c4   Benjamin Renard   Add text legend d...
761
762
763
764
765
766
    	panelValues['text-legends'] = [];
    	
    	this.textLegends().each(function (legend, index) {
    		panelValues['text-legends'][index] = legend.getJsonValues();
    	});
    	
829160b3   Benjamin Renard   Add constants def...
767
768
769
770
771
772
    	panelValues['constants'] = [];
    	
    	this.constants().each(function (constant, index) {
    		panelValues['constants'][index] = constant.getJsonValues();
    	});
    	
a8c54fb9   Benjamin Renard   Add text object p...
773
774
775
776
777
778
    	panelValues['textObjs'] = [];
    	
    	this.textObjs().each(function (textObj, index) {
    		panelValues['textObjs'][index] = textObj.getJsonValues();
    	});
    	
dbb7bcbe   Benjamin Renard   Add curves defint...
779
780
781
782
783
784
    	panelValues['curves'] = [];
    	
    	this.curves().each(function (curve, index) {
    		panelValues['curves'][index] = curve.getJsonValues();
    	});
    	
486cc3c7   Benjamin Renard   Add fill elements...
785
786
787
788
789
790
    	panelValues['fills'] = [];
    	
    	this.fills().each(function (fill, index) {
    		panelValues['fills'][index] = fill.getJsonValues();
    	});
    	
abe09878   Benjamin Renard   Add panels and ax...
791
792
793
794
795
796
    	panelValues['axes'] = [];
    	
    	this.axes().each(function (axe, index) {
    		panelValues['axes'][index] = axe.getJsonValues();
    	});
    	
17433635   Benjamin Renard   Add series and sp...
797
798
799
800
801
802
    	panelValues['params'] = [];
    	
    	this.params().each(function (param, index) {
    		panelValues['params'][index] = param.getJsonValues();
    	});
    	
dbb7bcbe   Benjamin Renard   Add curves defint...
803
804
805
806
807
    	panelValues['last-param-id'] = this.get('last-param-id');
    	panelValues['last-textlegend-id'] = this.get('last-textlegend-id');
    	panelValues['last-constant-id'] = this.get('last-constant-id');
    	panelValues['last-textobj-id'] = this.get('last-textobj-id');
    	panelValues['last-curve-id'] = this.get('last-curve-id');
486cc3c7   Benjamin Renard   Add fill elements...
808
    	panelValues['last-fill-id'] = this.get('last-fill-id');
dbb7bcbe   Benjamin Renard   Add curves defint...
809
    	
abe09878   Benjamin Renard   Add panels and ax...
810
811
    	return panelValues;
    }
981b1596   Benjamin Renard   Remove related ad...
812
});