Blame view

js/app/views/PlotComponents/PlotCurveForm.js 3.54 KB
dbb7bcbe   Benjamin Renard   Add curves defint...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * Project   : AMDA-NG
 * Name      : PlotCurveForm.js
 * @class   amdaPlotComp.PlotCurveForm
 * @extends amdaPlotComp.PlotStandardForm
 * @brief   Form to define specifics curve options
 * @author  Benjamin Renard
 * @version $Id: PlotCurveForm.js benjamin $
 */

Ext.define('amdaPlotComp.PlotCurveForm', {
	extend: 'amdaPlotComp.PlotStandardForm',
	
	requires: [
	           'amdaPlotObj.PlotCurveDef'
	],
	
	curveParamsContainer : null,
	
	setObject : function(object) {
		this.object = object;
		if (this.object != null)
		{
fd5552a4   Benjamin Renard   Info for plot ele...
24
			this.updateSerieIdList();
dbb7bcbe   Benjamin Renard   Add curves defint...
25
26
			this.loadRecord(this.object);
			this.updateParamsContainer();
dbb7bcbe   Benjamin Renard   Add curves defint...
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
		}
	},
	
	updateParamsContainer: function() {
		if (this.curveParamsContainer == null)
			return;
		
		var curveNameField = this.getForm().findField('curve-name');
		
		this.curveParamsContainer.removeAll();
		
		if (curveNameField.getValue() == '')
			return;
		
		var me = this;
		this.object.params().each(function (param) {
			if (param.get('curve-param-internal'))
				return;
			
			var newParamField = Ext.create('Ext.form.field.Number', {
				name: param.get('curve-param-name'),
				fieldLabel: param.get('curve-param-name'),
				decimalPrecision : 3,
				value: param.get('curve-param-value'),
				listeners: {
					change: function(field, newValue, oldValue, eOpts) {
a971060f   Benjamin Renard   Fix some bugs
53
						param.set('curve-param-value', newValue);
dbb7bcbe   Benjamin Renard   Add curves defint...
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
					},
					scope: me
				}
			});
			me.curveParamsContainer.add(newParamField);
		});
	},
	
	updateCurveList: function(onReady) {
		var curvesDefStore = Ext.data.StoreManager.lookup('curvesDefStore');

		var curveNameField = this.getForm().findField('curve-name');
		
		if (!curvesDefStore)
		{
			curvesDefStore = Ext.create('Ext.data.Store', {
				model: 'amdaPlotObj.PlotCurveDef',
				storeId: 'curvesDefStore'
			});
			
			curveNameField.getStore().removeAll();
			curvesDefStore.load({
				scope: this,
				callback: function(records, operation, success) {
					curvesDefStore.each(function (curveDef) {
						curveNameField.getStore().add({key : curveDef.get('id'), value : curveDef.get('name')});
					});
					if (onReady != null)
						onReady();
				}
			});
		}
		else
		{
			curveNameField.getStore().removeAll();
			curvesDefStore.each(function (curveDef) {
				curveNameField.getStore().add({key : curveDef.get('id'), value : curveDef.get('name')});
			});
			if (onReady != null)
				onReady();
		}
	},
	
	updateSerieIdList: function() {
		var attachedSerieField = this.getForm().findField('curve-serie-id');
		attachedSerieField.getStore().removeAll();
		
		var panelObject = this.crtTree.getSelectedPanelObject();
		if (panelObject == null)
			return;
		
		panelObject.params().each(function(paramObject) {
			var drawingType = paramObject.get('param-drawing-type');
			if ((drawingType == 'serie') || (drawingType == 'orbit-serie'))
			{
fd5552a4   Benjamin Renard   Info for plot ele...
109
				attachedSerieField.getStore().add({key : paramObject.get('id'), value : paramObject.getShortInfo(panelObject.get('panel-plot-type'))});
dbb7bcbe   Benjamin Renard   Add curves defint...
110
111
			}
		});
dbb7bcbe   Benjamin Renard   Add curves defint...
112
113
114
115
116
117
118
119
120
121
122
	},
	
	getFormItems: function() {
		var me = this;
		
		this.curveParamsContainer = Ext.create('Ext.container.Container', {
			layout: 'fit'
		});
		
		return [
		        this.addStandardCombo('curve-name', 'Curve name', [], function(name, value, oldValue) {
a971060f   Benjamin Renard   Fix some bugs
123
124
125
126
		        	if (me.object.get('curve-name') != value)
		        		me.object.setCurveName(value, function (){
		        			me.updateParamsContainer();
		        		});
dbb7bcbe   Benjamin Renard   Add curves defint...
127
128
129
130
131
132
133
		        }),
		        this.addStandardCombo('curve-serie-id', 'Attached serie', []),
		        this.addStandardFieldSet('Lines', '', this.addStandardLineItems('curve-line')),
		        this.curveParamsContainer
        ];
	}
});