Blame view

js/app/models/PlotObjects/PlotConstantObject.js 3.15 KB
829160b3   Benjamin Renard   Add constants def...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Project      : AMDA-NG
 * Name         : PlotConstantObject.js
 * @class   amdaPlotObj.PlotConstantObject
 * @extends Ext.data.Model
 * @brief   Plot Constant Business Object Definition 
 * @author  Benjamin Renard
 * @version $Id: PlotConstantObject.js benjamin $
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	:           :01/09/2015: BRE  - file creation
 */
 
 		
Ext.define('amdaPlotObj.PlotConstantObject', {
	extend: 'Ext.data.Model',
dbb7bcbe   Benjamin Renard   Add curves defint...
18
	idProperty: 'id',
829160b3   Benjamin Renard   Add constants def...
19
20
21
22
23
24
	
	requires: [
	           'amdaPlotObj.PlotObjectConfig'
	],
	
	fields : [
fd5552a4   Benjamin Renard   Info for plot ele...
25
	          {name: 'id', type: 'int'},
829160b3   Benjamin Renard   Add constants def...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	          {name: 'constant-axis-id', type: 'string'},
	          {name: 'constant-time-value', 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;
            	  }
              },
	          {name: 'constant-float-value', type: 'float'},
	          {name: 'constant-line-style', type: 'string'},
	          {name: 'constant-line-width', type: 'float'},
	          {name: 'constant-line-color', type: 'string'}
    ],
    
a971060f   Benjamin Renard   Fix some bugs
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    constructor: function(){
        var me = this;
        me.callParent(arguments);
        if ((arguments.length > 0) && arguments[0])
        {
        }
        else
        {
        	//new object, set default fields values
        	me.setDefaultValues();
        }
        this.dirty = false;
    },
    
829160b3   Benjamin Renard   Add constants def...
58
59
60
61
62
63
64
65
66
    setDefaultValues: function()
    {
    	this.set('constant-axis-id', amdaPlotObj.PlotObjectConfig.defaultValues.constants.axisId);
    	this.set('constant-float-value', 0.);
    	this.set('constant-line-style', amdaPlotObj.PlotObjectConfig.defaultValues.constants.line.style);
    	this.set('constant-line-width', amdaPlotObj.PlotObjectConfig.defaultValues.constants.line.width);
    	this.set('constant-line-color', amdaPlotObj.PlotObjectConfig.defaultValues.constants.line.color);
    },
    
fd5552a4   Benjamin Renard   Info for plot ele...
67
68
69
70
71
72
    getShortInfo : function()
    {
    	var axis = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableConstantAxes, this.get('constant-axis-id'));
		return 'Id : '+this.get('id')+', '+axis;
    },
    
829160b3   Benjamin Renard   Add constants def...
73
74
75
76
    getJsonValues : function() 
    {
    	var constantValues  = new Object();
    	
dbb7bcbe   Benjamin Renard   Add curves defint...
77
78
    	constantValues['id'] = this.get('id');
    	
829160b3   Benjamin Renard   Add constants def...
79
80
81
82
83
84
85
86
87
88
    	constantValues['constant-axis-id'] = this.get('constant-axis-id');
    	constantValues['constant-time-value'] = this.get('constant-time-value');
    	constantValues['constant-float-value'] = this.get('constant-float-value');
    	constantValues['constant-line-style'] = this.get('constant-line-style');
    	constantValues['constant-line-width'] = this.get('constant-line-width');
    	constantValues['constant-line-color'] = this.get('constant-line-color');
    	
    	return constantValues;
    }
});