Blame view

js/app/views/PlotComponents/PlotFillForm.js 2.99 KB
486cc3c7   Benjamin Renard   Add fill elements...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
53
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
/**
 * Project   : AMDA-NG
 * Name      : PlotFillForm.js
 * @class   amdaPlotComp.PlotFillForm
 * @extends amdaPlotComp.PlotStandardForm
 * @brief   Form to define specifics fill options
 * @author  Benjamin Renard
 * @version $Id: PlotFillForm.js benjamin $
 */

Ext.define('amdaPlotComp.PlotFillForm', {
	extend: 'amdaPlotComp.PlotStandardForm',
	
	requires: [
	           'amdaPlotObj.PlotCurveDef'
	],
	
	setObject : function(object) {
		this.object = object;
		if (this.object != null)
		{
			this.updateSerieIdLists();
			this.updateConstantIdList();
			this.loadRecord(this.object);
		}
	},
	
	updateOptions : function() {
		var typeField = this.getForm().findField('fill-type');
		var secondSerieField = this.getForm().findField('fill-secondserie-id');
		var constantField = this.getForm().findField('fill-constant-id');
		
		var isSerieSerie = (typeField.getValue() == 'serie-serie');
		
		secondSerieField.setVisible(isSerieSerie);
		constantField.setVisible(!isSerieSerie);
	},
	
	updateSerieIdLists: function() {
		var firstSerieField = this.getForm().findField('fill-firstserie-id');
		var secondSerieField = this.getForm().findField('fill-secondserie-id');
		
		firstSerieField.getStore().removeAll();
		secondSerieField.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'))
			{
				firstSerieField.getStore().add({key : paramObject.get('id'), value : paramObject.getShortInfo(panelObject.get('panel-plot-type'))});
				secondSerieField.getStore().add({key : paramObject.get('id'), value : paramObject.getShortInfo(panelObject.get('panel-plot-type'))});
			}
		});
	},
	
	updateConstantIdList: function() {
		var constantField = this.getForm().findField('fill-constant-id');
		
		constantField.getStore().removeAll();
		
		var panelObject = this.crtTree.getSelectedPanelObject();
		if (panelObject == null)
			return;
		
		panelObject.constants().each(function(constantObject) {
			constantField.getStore().add({key : constantObject.get('id'), value : constantObject.getShortInfo()});
		});
	},
	
	getFormItems: function() {
		var me = this;
		
		return [
		        
		        this.addStandardCombo('fill-type', 'Fill type', amdaPlotObj.PlotObjectConfig.availableFillTypes, function(name, value, oldValue) {
		        	me.updateOptions();
		        	me.crtTree.getView().refresh();
		        }),
		        this.addStandardCombo('fill-firstserie-id', 'First serie Id', []),
		        this.addStandardCombo('fill-secondserie-id', 'Second serie Id', []),
		        this.addStandardCombo('fill-constant-id', 'Constant Id', []),
		        this.addStandardColor('fill-greater-color', 'Greater Color', amdaPlotObj.PlotObjectConfig.availableBackgroundColors),
		        this.addStandardColor('fill-less-color', 'Less Color', amdaPlotObj.PlotObjectConfig.availableBackgroundColors)
        ];
	}
});