Blame view

js/app/views/PlotComponents/PlotParamForm.js 6.1 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
17
		'amdaPlotComp.PlotSerieForm',
		'amdaPlotComp.PlotOrbitSerieForm',
		'amdaPlotComp.PlotSpectroForm',
5b3c2c8a   Hacene SI HADJ MOHAND   ihm for sauvaud plot
18
                                        'amdaPlotComp.PlotSauvaudForm',
4dbd97ec   Menouard AZIB   Goal is reached b...
19
20
21
22
23
24
		'amdaPlotComp.PlotStatusBarForm',
		'amdaPlotComp.PlotTickBarForm',
		'amdaPlotComp.PlotInstantSerieForm',
		'amdaPlotComp.PlotInstantSpectroForm',
		'amdaPlotComp.PlotIntervalsForm',
		'amdaUI.ParamArgumentsUI'
17433635   Benjamin Renard   Add series and sp...
25
	],
4dbd97ec   Menouard AZIB   Goal is reached b...
26

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

	drawingOptionsFormsManager: new Ext.AbstractManager(),

	paramArgs: null,

	isFirstMsg: true,

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

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

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

17433635   Benjamin Renard   Add series and sp...
56
		formId += '-drawing-options-form';
4dbd97ec   Menouard AZIB   Goal is reached b...
57
58
		if (!this.drawingOptionsFormsManager.get(formId)) {
			switch (type) {
17433635   Benjamin Renard   Add series and sp...
59
				//Create drawing options form
4dbd97ec   Menouard AZIB   Goal is reached b...
60
61
				case 'serie':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotSerieForm({ id: formId }));
17433635   Benjamin Renard   Add series and sp...
62
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
63
64
				case 'orbit-serie':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotOrbitSerieForm({ id: formId }));
e84ed2cf   Benjamin Renard   Add Interval Tick...
65
					break;
5b3c2c8a   Hacene SI HADJ MOHAND   ihm for sauvaud plot
66
                                                                                case 'sauvaud':
9b729ba5   Hacene SI HADJ MOHAND   adding warning me...
67
68
69
70
71
                                                                                                    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
72
73
                                                                                                    this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotSauvaudForm({ id: formId }));
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
74
75
				case 'spectro':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotSpectroForm({ id: formId }));
17433635   Benjamin Renard   Add series and sp...
76
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
77
78
				case 'status-bar':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotStatusBarForm({ id: formId }));
a0bf9157   Benjamin Renard   Add tick plot and...
79
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
80
81
				case 'tick-bar':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotTickBarForm({ id: formId }));
a0bf9157   Benjamin Renard   Add tick plot and...
82
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
83
84
				case 'iserie':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotInstantSerieForm({ id: formId }));
6a801541   Benjamin Renard   Add possibility t...
85
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
86
87
				case 'ispectro':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotInstantSpectroForm({ id: formId }));
6a801541   Benjamin Renard   Add possibility t...
88
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
89
90
				case 'intervals':
					this.drawingOptionsFormsManager.register(new amdaPlotComp.PlotIntervalsForm({ id: formId }));
ebebd92d   Benjamin Renard   Add intervals dra...
91
					break;
4dbd97ec   Menouard AZIB   Goal is reached b...
92
93
				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...
94
95
			}
		}
4dbd97ec   Menouard AZIB   Goal is reached b...
96

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

17433635   Benjamin Renard   Add series and sp...
99
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
100
101

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

a0bf9157   Benjamin Renard   Add tick plot and...
104
105
		var availableDrawingObjects = this.object.getAvailableDrawingObjectByPlotType(this.crtTree.getSelectedPlotType());
		typeField.getStore().loadData(availableDrawingObjects);
a971060f   Benjamin Renard   Fix some bugs
106
107
108
		typeField.suspendEvents();
		typeField.setValue(drawingType);
		typeField.resumeEvents(false);
4dbd97ec   Menouard AZIB   Goal is reached b...
109

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

a0bf9157   Benjamin Renard   Add tick plot and...
112
		var drawingOptionsForm = this.getDrawingOptionsForm(drawingType);
17433635   Benjamin Renard   Add series and sp...
113
114
115
116
		this.drawingOptionsContainer.add(drawingOptionsForm);
		drawingOptionsForm.crtTree = this.crtTree;
		if (drawingOptionsForm.setObject)
			drawingOptionsForm.setObject(this.object);
7ac3ce50   Benjamin Renard   First implementat...
117
		if (this.paramArgs && paramId)
bb6e93d9   Benjamin Renard   Implement templat...
118
			this.paramArgs.editParameter(this.object, this, function (uiScope) {
7ac3ce50   Benjamin Renard   First implementat...
119
120
121
				uiScope.crtTree.refresh();
			});
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
122
123

	onChangeParamArgs: function (uiScope, args_key, newValue, oldValue, isTemplateArg) {
eac92219   Benjamin Renard   Do not call onCha...
124
		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...
125
			(uiScope.object.get('dim1-index') == '*') && (uiScope.object.get('dim2-index') == '*') &&  (uiScope.object.get('param-drawing-type') != 'sauvaud')) {
eac92219   Benjamin Renard   Do not call onCha...
126
127
128
			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...
129
		uiScope.crtTree.refresh();
17433635   Benjamin Renard   Add series and sp...
130
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
131
132

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

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

7ac3ce50   Benjamin Renard   First implementat...
139
		this.paramArgs = Ext.create('amdaUI.ParamArgumentsUI', {
4dbd97ec   Menouard AZIB   Goal is reached b...
140
			onChange: me.onChangeParamArgs,
7ac3ce50   Benjamin Renard   First implementat...
141
142
			scope: me
		});
4dbd97ec   Menouard AZIB   Goal is reached b...
143

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

17433635   Benjamin Renard   Add series and sp...
148
		return [
4dbd97ec   Menouard AZIB   Goal is reached b...
149
150
151
152
153
154
155
156
157
158
			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...
159
160
		];
	}
ecac355e   Benjamin Renard   Destroy plot elem...
161
});