Blame view

js/app/views/PlotComponents/PlotParamForm.js 6.56 KB
17433635   Benjamin Renard   Add series and sp...
1
2
3
4
/**
 * Project   : AMDA-NG
 * Name      : PlotParamForm.js
 * @class   amdaPlotComp.PlotParamForm
a0bf9157   Benjamin Renard   Add tick plot and...
5
 * @extends amdaPlotComp.amdaPlotComp.PlotStandardForm
17433635   Benjamin Renard   Add series and sp...
6
7
8
9
10
11
12
 * @brief   Form to define specifics param options
 * @author  Benjamin Renard
 * @version $Id: PlotParamForm.js benjamin $
 */

Ext.define('amdaPlotComp.PlotParamForm', {
	extend: 'amdaPlotComp.PlotStandardForm',
4dbd97ec   Menouard AZIB   Goal is reached b...
13

17433635   Benjamin Renard   Add series and sp...
14
	requires: [
4dbd97ec   Menouard AZIB   Goal is reached b...
15
16
		'amdaPlotComp.PlotSerieForm',
		'amdaPlotComp.PlotOrbitSerieForm',
6e83f9b9   Erdogan Furkan   Done
17
		'amdaPlotComp.PlotHistogram2DSerieForm',
2ac3a3f9   Erdogan Furkan   For now, histo1D ...
18
		'amdaPlotComp.PlotHistogram1DSerieForm',
4dbd97ec   Menouard AZIB   Goal is reached b...
19
		'amdaPlotComp.PlotSpectroForm',
5b3c2c8a   Hacene SI HADJ MOHAND   ihm for sauvaud plot
20
                                        'amdaPlotComp.PlotSauvaudForm',
4dbd97ec   Menouard AZIB   Goal is reached b...
21
22
23
24
25
26
		'amdaPlotComp.PlotStatusBarForm',
		'amdaPlotComp.PlotTickBarForm',
		'amdaPlotComp.PlotInstantSerieForm',
		'amdaPlotComp.PlotInstantSpectroForm',
		'amdaPlotComp.PlotIntervalsForm',
		'amdaUI.ParamArgumentsUI'
17433635   Benjamin Renard   Add series and sp...
27
	],
4dbd97ec   Menouard AZIB   Goal is reached b...
28

17433635   Benjamin Renard   Add series and sp...
29
	drawingOptionsContainer: null,
4dbd97ec   Menouard AZIB   Goal is reached b...
30
31
32
33
34
35
36
37

	drawingOptionsFormsManager: new Ext.AbstractManager(),

	paramArgs: null,

	isFirstMsg: true,

	destroy: function () {
a971060f   Benjamin Renard   Fix some bugs
38
		this.drawingOptionsFormsManager.each(function (key, value, length) {
4dbd97ec   Menouard AZIB   Goal is reached b...
39
			this.drawingOptionsFormsManager.unregister(value);
ecac355e   Benjamin Renard   Destroy plot elem...
40
			value.destroy();
4dbd97ec   Menouard AZIB   Goal is reached b...
41
		}, this);
a971060f   Benjamin Renard   Fix some bugs
42
43
		this.callParent();
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
44
45

	setObject: function (object) {
17433635   Benjamin Renard   Add series and sp...
46
47
		this.object = object;
		this.loadRecord(this.object);
bb6e93d9   Benjamin Renard   Implement templat...
48
		this.updateDrawingOptions(this.object.get('param-drawing-type'), this.object.get('paramid'));
17433635   Benjamin Renard   Add series and sp...
49
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
50
51

	getDrawingOptionsForm: function (type) {
17433635   Benjamin Renard   Add series and sp...
52
53
54
55
56
		var formId = '';
		if (!type || (type == ''))
			formId = 'none';
		else
			formId = type;
4dbd97ec   Menouard AZIB   Goal is reached b...
57

17433635   Benjamin Renard   Add series and sp...
58
		formId += '-drawing-options-form';
4dbd97ec   Menouard AZIB   Goal is reached b...
59
60
		if (!this.drawingOptionsFormsManager.get(formId)) {
			switch (type) {
17433635   Benjamin Renard   Add series and sp...
61
				//Create drawing options form
4dbd97ec   Menouard AZIB   Goal is reached b...
62
63
				case 'serie':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotSerieForm({ id: formId }));
17433635   Benjamin Renard   Add series and sp...
64
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
65
66
				case 'orbit-serie':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotOrbitSerieForm({ id: formId }));
e84ed2cf   Benjamin Renard   Add Interval Tick...
67
					break;
6e83f9b9   Erdogan Furkan   Done
68
69
70
				case 'histogram2d':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotHistogram2DSerieForm({ id: formId }));
					break;
2ac3a3f9   Erdogan Furkan   For now, histo1D ...
71
72
73
				case 'histogram1d':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotHistogram1DSerieForm({ id: formId }));
					break;
5b3c2c8a   Hacene SI HADJ MOHAND   ihm for sauvaud plot
74
                                                                                case 'sauvaud':
9b729ba5   Hacene SI HADJ MOHAND   adding warning me...
75
76
77
78
79
                                                                                                    if(this.object.get('type') !=2){
                                                                                                        myDesktopApp.warningMsg('Sauvaud Plot requires <b>2D Parameter</b> ');
                                                                                                    }else if(this.object.get('dim1-index') != '*' ||  this.object.get('dim2-index') != '*' ){
                                                                                                        myDesktopApp.warningMsg('Sauvaud Plot requires the selection of <b>All Arguments</b> in both directions');
                                                                                                    }
5b3c2c8a   Hacene SI HADJ MOHAND   ihm for sauvaud plot
80
81
                                                                                                    this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotSauvaudForm({ id: formId }));
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
82
83
				case 'spectro':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotSpectroForm({ id: formId }));
17433635   Benjamin Renard   Add series and sp...
84
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
85
86
				case 'status-bar':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotStatusBarForm({ id: formId }));
a0bf9157   Benjamin Renard   Add tick plot and...
87
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
88
89
				case 'tick-bar':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotTickBarForm({ id: formId }));
a0bf9157   Benjamin Renard   Add tick plot and...
90
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
91
92
				case 'iserie':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotInstantSerieForm({ id: formId }));
6a801541   Benjamin Renard   Add possibility t...
93
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
94
95
				case 'ispectro':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotInstantSpectroForm({ id: formId }));
6a801541   Benjamin Renard   Add possibility t...
96
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
97
98
				case 'intervals':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotIntervalsForm({ id: formId }));
ebebd92d   Benjamin Renard   Add intervals dra...
99
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
100
101
				default:
					this.drawingOptionsFormsManager.register(new Ext.form.Label({ id: formId, text: 'No available options for this drawing type' }));
17433635   Benjamin Renard   Add series and sp...
102
103
			}
		}
4dbd97ec   Menouard AZIB   Goal is reached b...
104

17433635   Benjamin Renard   Add series and sp...
105
		return this.drawingOptionsFormsManager.get(formId);
4dbd97ec   Menouard AZIB   Goal is reached b...
106

17433635   Benjamin Renard   Add series and sp...
107
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
108
109

	updateDrawingOptions: function (drawingType, paramId) {
17433635   Benjamin Renard   Add series and sp...
110
		var typeField = this.getForm().findField('param-drawing-type');
4dbd97ec   Menouard AZIB   Goal is reached b...
111

a0bf9157   Benjamin Renard   Add tick plot and...
112
113
		var availableDrawingObjects = this.object.getAvailableDrawingObjectByPlotType(this.crtTree.getSelectedPlotType());
		typeField.getStore().loadData(availableDrawingObjects);
a971060f   Benjamin Renard   Fix some bugs
114
115
116
		typeField.suspendEvents();
		typeField.setValue(drawingType);
		typeField.resumeEvents(false);
4dbd97ec   Menouard AZIB   Goal is reached b...
117

17433635   Benjamin Renard   Add series and sp...
118
		this.drawingOptionsContainer.removeAll(false);
4dbd97ec   Menouard AZIB   Goal is reached b...
119

a0bf9157   Benjamin Renard   Add tick plot and...
120
		var drawingOptionsForm = this.getDrawingOptionsForm(drawingType);
17433635   Benjamin Renard   Add series and sp...
121
122
123
124
		this.drawingOptionsContainer.add(drawingOptionsForm);
		drawingOptionsForm.crtTree = this.crtTree;
		if (drawingOptionsForm.setObject)
			drawingOptionsForm.setObject(this.object);
8caed468   Benjamin Renard   Fix axes ranges d...
125
126
		if (drawingOptionsForm.setParentObject)
			drawingOptionsForm.setParentObject(this.parentObject);
7ac3ce50   Benjamin Renard   First implementat...
127
		if (this.paramArgs && paramId)
bb6e93d9   Benjamin Renard   Implement templat...
128
			this.paramArgs.editParameter(this.object, this, function (uiScope) {
7ac3ce50   Benjamin Renard   First implementat...
129
130
131
				uiScope.crtTree.refresh();
			});
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
132
133

	onChangeParamArgs: function (uiScope, args_key, newValue, oldValue, isTemplateArg) {
eac92219   Benjamin Renard   Do not call onCha...
134
		if ((uiScope.isFirstMsg) && (uiScope.object.get('type') == 2) && (uiScope.object.get('dim1-sum-type') == 0) && (uiScope.object.get('dim2-sum-type') == 0) &&
9b729ba5   Hacene SI HADJ MOHAND   adding warning me...
135
			(uiScope.object.get('dim1-index') == '*') && (uiScope.object.get('dim2-index') == '*') &&  (uiScope.object.get('param-drawing-type') != 'sauvaud')) {
eac92219   Benjamin Renard   Do not call onCha...
136
137
138
			uiScope.isFirstMsg = false;
			myDesktopApp.warningMsg('If argument <i>All</i> is set for both dimensions output will be the total sum <b>(not spectra!)</b>');
		}
7ac3ce50   Benjamin Renard   First implementat...
139
		uiScope.crtTree.refresh();
17433635   Benjamin Renard   Add series and sp...
140
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
141
142

	getFormItems: function () {
17433635   Benjamin Renard   Add series and sp...
143
		var me = this;
4dbd97ec   Menouard AZIB   Goal is reached b...
144

17433635   Benjamin Renard   Add series and sp...
145
146
147
		this.drawingOptionsContainer = Ext.create('Ext.container.Container', {
			layout: 'fit'
		});
4dbd97ec   Menouard AZIB   Goal is reached b...
148

7ac3ce50   Benjamin Renard   First implementat...
149
		this.paramArgs = Ext.create('amdaUI.ParamArgumentsUI', {
4dbd97ec   Menouard AZIB   Goal is reached b...
150
			onChange: me.onChangeParamArgs,
7ac3ce50   Benjamin Renard   First implementat...
151
152
			scope: me
		});
4dbd97ec   Menouard AZIB   Goal is reached b...
153

7ac3ce50   Benjamin Renard   First implementat...
154
		//ToDoparamArgsPlug
7ac3ce50   Benjamin Renard   First implementat...
155
156
		var paramInfoFieldSet = this.addStandardFieldSet('Arguments', '', [this.paramArgs]);
		paramInfoFieldSet.collapsed = false;
4dbd97ec   Menouard AZIB   Goal is reached b...
157

17433635   Benjamin Renard   Add series and sp...
158
		return [
4dbd97ec   Menouard AZIB   Goal is reached b...
159
160
161
162
163
164
165
166
167
168
			paramInfoFieldSet,
			this.addStandardCombo('param-drawing-type', 'Drawing type', [{ 'key': '', 'value': 'None' }], function (name, value, oldValue) {
				if (me.object.get('param-drawing-type') != value) {
					me.object.changeDrawingType(value);
					me.object.set('param-drawing-type', value);
					me.crtTree.refresh();
					me.updateDrawingOptions(value);
				}
			}),
			this.drawingOptionsContainer
17433635   Benjamin Renard   Add series and sp...
169
170
		];
	}
ecac355e   Benjamin Renard   Destroy plot elem...
171
});