Commit c3e75a07e47c1b842690e9d1a29ac72420ab6e57
1 parent
4dbd97ec
Exists in
master
and in
73 other branches
IHM is finished and I added comments
Showing
3 changed files
with
114 additions
and
116 deletions
Show diff stats
js/app/models/PlotObjects/PlotObjectConfig.js
... | ... | @@ -512,7 +512,8 @@ Ext.define('amdaPlotObj.PlotObjectConfig', { |
512 | 512 | key: "background_sub_value", |
513 | 513 | textinputkey: "background_sub_by_value", |
514 | 514 | dimlabel: 'Dim ', |
515 | - dimkey: 'background_sub_dim' | |
515 | + dimkey: 'background_sub_dim', | |
516 | + dimNullValue: -1 | |
516 | 517 | } |
517 | 518 | }, |
518 | 519 | |
... | ... |
js/app/models/PlotObjects/PlotSpectroObject.js
... | ... | @@ -69,7 +69,7 @@ Ext.define('amdaPlotObj.PlotSpectroObject', { |
69 | 69 | this.set(amdaPlotObj.PlotObjectConfig.bgSubstraction.name, false); |
70 | 70 | this.set(amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key, null); |
71 | 71 | this.set(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, -1); |
72 | - this.set(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, -1); | |
72 | + this.set(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimNullValue); | |
73 | 73 | }, |
74 | 74 | |
75 | 75 | getJsonValues: function () { |
... | ... |
js/app/views/PlotComponents/PlotSpectroForm.js
... | ... | @@ -33,67 +33,46 @@ Ext.define('amdaPlotComp.PlotSpectroForm', { |
33 | 33 | ]; |
34 | 34 | }, |
35 | 35 | |
36 | - | |
37 | - populateComboBoxValue: (ref, index) => { | |
38 | - const valueType = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key).getValue(); | |
39 | - | |
40 | - if (amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values[valueType] === undefined) { | |
41 | - console.warn("Undefined value : ", valueType); | |
36 | + /** | |
37 | + * Populate the comboBoxValue by the set of channel data related to the selected dimension | |
38 | + * @param {*} ref the reference of the current instance of this class | |
39 | + * @param {*} index dimension's index | |
40 | + * @param {*} comboBoxV the comboBoxValue | |
41 | + * @returns | |
42 | + */ | |
43 | + populateComboBoxValue: (ref, index, comboBoxV) => { | |
44 | + if (ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName][index].variable) | |
42 | 45 | return; |
43 | - } | |
44 | - | |
45 | - const newValue = amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values[valueType]; | |
46 | - | |
47 | - const comboBoxV = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key); | |
48 | - const textInputV = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.textinputkey); | |
49 | 46 | |
50 | - comboBoxV.setValue(null); | |
51 | - comboBoxV.setVisible(false); | |
47 | + const channelsData = ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName][index] | |
48 | + [amdaPlotObj.PlotObjectConfig.bgSubstraction.tableChannels]; | |
52 | 49 | |
53 | - textInputV.setVisible(false); | |
54 | - textInputV.setValue(null); | |
55 | - | |
56 | - if (newValue === amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values.bychannel) { | |
57 | - if (ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName][index].variable) | |
58 | - return; | |
59 | - | |
60 | - comboBoxV.setVisible(true); | |
61 | - | |
62 | - const channelsData = ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName][index] | |
63 | - [amdaPlotObj.PlotObjectConfig.bgSubstraction.tableChannels]; | |
64 | - | |
65 | - const keyTemp = amdaPlotObj.PlotObjectConfig.fieldComboBox.key; | |
66 | - const valueTemp = amdaPlotObj.PlotObjectConfig.fieldComboBox.value; | |
50 | + const keyTemp = amdaPlotObj.PlotObjectConfig.fieldComboBox.key; | |
51 | + const valueTemp = amdaPlotObj.PlotObjectConfig.fieldComboBox.value; | |
67 | 52 | |
68 | - const newDataForStore = []; | |
69 | - //Loop through the channels | |
70 | - for (channelIndex in channelsData) { | |
71 | - const channelData = channelsData[channelIndex]; | |
72 | - let item = {}; | |
73 | - item[keyTemp] = channelIndex; | |
74 | - item[valueTemp] = channelIndex + " : [" + channelData.min + " , " + channelData.max + "]"; | |
75 | - newDataForStore.push(item); | |
76 | - } | |
77 | - | |
78 | - //Update the label of the field | |
79 | - comboBoxV.setFieldLabel(ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName][index]["name"] | |
80 | - + " (" + ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName][index]["units"] + ") "); | |
81 | - | |
82 | - comboBoxV.store.loadData(newDataForStore); | |
83 | - } | |
84 | - else if (newValue === amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values.fixedvalue) { | |
85 | - textInputV.setVisible(true); | |
86 | - } | |
87 | - else { | |
88 | - console.warn("Unknown value : ", valueType, newValue); | |
53 | + const newDataForStore = []; | |
54 | + //Loop through the channels | |
55 | + for (channelIndex in channelsData) { | |
56 | + const channelData = channelsData[channelIndex]; | |
57 | + let item = {}; | |
58 | + item[keyTemp] = channelIndex; | |
59 | + item[valueTemp] = channelIndex + " : [" + channelData.min + " , " + channelData.max + "]"; | |
60 | + newDataForStore.push(item); | |
89 | 61 | } |
90 | - }, | |
91 | 62 | |
63 | + //Update the label of the field | |
64 | + comboBoxV.setFieldLabel(ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName][index]["name"] | |
65 | + + " (" + ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName][index]["units"] + ") "); | |
92 | 66 | |
93 | - populateComboBoxDim: (ref) => { | |
94 | - const comboBoxDim = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey); | |
95 | - comboBoxDim.setValue(null); | |
67 | + comboBoxV.store.loadData(newDataForStore); | |
68 | + }, | |
96 | 69 | |
70 | + /** | |
71 | + * Populate the comboBoxDim by the set of dimensions related to the selected parameter | |
72 | + * @param {*} ref the reference of the current instance of this class | |
73 | + * @param {*} comboBoxDim the comboBoxDim reference | |
74 | + */ | |
75 | + populateComboBoxDim: (ref, comboBoxDim) => { | |
97 | 76 | const keyTemp = amdaPlotObj.PlotObjectConfig.fieldComboBox.key; |
98 | 77 | const valueTemp = amdaPlotObj.PlotObjectConfig.fieldComboBox.value; |
99 | 78 | |
... | ... | @@ -110,8 +89,12 @@ Ext.define('amdaPlotComp.PlotSpectroForm', { |
110 | 89 | comboBoxDim.store.loadData(newDataForStore); |
111 | 90 | }, |
112 | 91 | |
113 | - | |
114 | - addTextInput: (ref) => { | |
92 | + /** | |
93 | + * Add a textInput which holds Background Substraction value when fixedvalue is selected | |
94 | + * @param {*} ref the reference of the current instance of this class | |
95 | + * @returns addStandardFloat2 | |
96 | + */ | |
97 | + addComboBoxBackgroundSubFixedValue: (ref) => { | |
115 | 98 | return ref.addStandardFloat2(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.textinputkey, |
116 | 99 | amdaPlotObj.PlotObjectConfig.bgSubstraction.value.textinputlabel, 0 |
117 | 100 | , Number.MAX_VALUE, true, true, (name, newValue, oldValue) => { |
... | ... | @@ -122,30 +105,28 @@ Ext.define('amdaPlotComp.PlotSpectroForm', { |
122 | 105 | }); |
123 | 106 | }, |
124 | 107 | |
125 | - resetValues: (ref) => { | |
126 | - const comboBoxV = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key); | |
127 | - comboBoxV.setVisible(false); | |
128 | - comboBoxV.setValue(null); | |
108 | + /** | |
109 | + * Reset ComboBoxDim and textInput | |
110 | + * | |
111 | + * @param {*} ref the reference of the current instance of this class | |
112 | + */ | |
113 | + resetDependentComponents: (ref) => { | |
114 | + const comboBoxDim = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey); | |
115 | + ref.populateComboBoxDim(ref, comboBoxDim); | |
116 | + comboBoxDim.setVisible(false); | |
117 | + comboBoxDim.setValue(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimNullValue); | |
129 | 118 | |
130 | 119 | const textInputV = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.textinputkey); |
131 | 120 | textInputV.setVisible(false); |
132 | 121 | textInputV.setValue(null); |
133 | 122 | }, |
134 | 123 | |
135 | - emptyComboBoxDim: (ref) => { | |
136 | - const comboBoxDim = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey); | |
137 | - comboBoxDim.setValue(null); | |
138 | - comboBoxDim.store.loadData([]); | |
139 | - | |
140 | - ref.resetValues(ref); | |
141 | - }, | |
142 | - | |
143 | 124 | /** |
144 | - * Add the first comboBox (Background Substraction type) | |
145 | - * @param {*} ref ref to this class | |
125 | + * Add a comboBox which holds Background Substraction type : bychannel, fixedvalue | |
126 | + * @param {*} ref the reference of the current instance of this class | |
146 | 127 | * @returns StandardCombo |
147 | 128 | */ |
148 | - addComboBoxBgSType: (ref) => { | |
129 | + addComboBoxBackgroundSubType: (ref) => { | |
149 | 130 | const data = []; |
150 | 131 | for (value in amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values) { |
151 | 132 | const keyTemp = amdaPlotObj.PlotObjectConfig.fieldComboBox.key; |
... | ... | @@ -160,33 +141,46 @@ Ext.define('amdaPlotComp.PlotSpectroForm', { |
160 | 141 | amdaPlotObj.PlotObjectConfig.bgSubstraction.type.label, data, |
161 | 142 | (name, newKey, oldKey) => { |
162 | 143 | if (newKey !== oldKey) { |
163 | - | |
164 | - if (newKey === null || amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values[newKey] === undefined) { | |
165 | - ref.emptyComboBoxDim(ref); | |
144 | + const newValue = amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values[newKey]; | |
145 | + if (newKey === null || newValue === undefined) { | |
146 | + ref.resetDependentComponents(ref); | |
166 | 147 | return; |
167 | 148 | } |
168 | 149 | |
169 | - ref.populateComboBoxDim(ref); | |
170 | - | |
150 | + //ComboBoxDim | |
171 | 151 | const comboBoxDim = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey); |
172 | - | |
173 | - if (ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName].length === 1) { | |
174 | - comboBoxDim.setValue(0); | |
175 | - comboBoxDim.setVisible(false); | |
176 | - return; | |
152 | + //Fixed value input | |
153 | + const textInputV = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.textinputkey); | |
154 | + | |
155 | + //By channel | |
156 | + if (newValue === amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values.bychannel) { | |
157 | + const nbDims = ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName].length; | |
158 | + //Show comboBoxDim | |
159 | + comboBoxDim.select(comboBoxDim.store.getAt(0)); | |
160 | + if (nbDims > 1) | |
161 | + comboBoxDim.setVisible(true); | |
162 | + | |
163 | + //Hide comboBoxDim | |
164 | + else | |
165 | + comboBoxDim.setVisible(false); | |
166 | + | |
167 | + //Hide text input | |
168 | + textInputV.setValue(null); | |
169 | + textInputV.setVisible(false); | |
177 | 170 | } |
178 | - | |
179 | - | |
180 | - | |
181 | - if (amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values.fixedvalue === | |
182 | - amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values[newKey]) { | |
183 | - comboBoxDim.setValue(0); | |
171 | + //By fixed value | |
172 | + else if (newValue === amdaPlotObj.PlotObjectConfig.bgSubstraction.type.values.fixedvalue) { | |
173 | + //Hide comboBoxDim | |
184 | 174 | comboBoxDim.setVisible(false); |
185 | - } else { | |
186 | - comboBoxDim.setVisible(true); | |
175 | + comboBoxDim.setValue(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimNullValue); | |
176 | + //Show text input | |
177 | + textInputV.setValue(null); | |
178 | + textInputV.setVisible(true); | |
179 | + } | |
180 | + //Another value | |
181 | + else { | |
182 | + console.warn("Unkown key : ", newKey); | |
187 | 183 | } |
188 | - | |
189 | - | |
190 | 184 | } |
191 | 185 | }); |
192 | 186 | |
... | ... | @@ -194,70 +188,73 @@ Ext.define('amdaPlotComp.PlotSpectroForm', { |
194 | 188 | }, |
195 | 189 | |
196 | 190 | /** |
197 | - * Add the second comboBox (Background Substraction value) | |
198 | - * @param {*} ref ref to this class | |
191 | + * Add a comboBox which holds Background Substraction value | |
192 | + * @param {*} ref the reference of the current instance of this class | |
199 | 193 | * @returns StandardCombo |
200 | 194 | */ |
201 | - addComboBoxBgSValue: (ref) => { | |
195 | + addComboBoxBackgroundSubValue: (ref) => { | |
202 | 196 | const comboBoxValue = ref.addStandardCombo(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, |
203 | 197 | "", [], |
204 | 198 | (name, newKey, oldKey) => { |
205 | 199 | if (newKey !== oldKey) { |
206 | 200 | ref.object.set(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, |
207 | 201 | newKey); |
208 | - console.log(newKey); | |
209 | 202 | } |
210 | 203 | }); |
211 | 204 | |
212 | 205 | return comboBoxValue; |
213 | 206 | }, |
214 | 207 | |
215 | - addComboBoxBgSDim: (ref) => { | |
208 | + /** | |
209 | + * Add a comboBox which holds Background Substraction dimension | |
210 | + * @param {*} ref the reference of the current instance of this class | |
211 | + * @returns StandardCombo | |
212 | + */ | |
213 | + addComboBoxBackgroundSubDim: (ref) => { | |
216 | 214 | const comboBoxDim = ref.addStandardCombo(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, |
217 | 215 | amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimlabel, [], |
218 | 216 | (name, newKey, oldKey) => { |
219 | - if (newKey !== null && newKey !== undefined) | |
220 | - ref.populateComboBoxValue(ref, newKey); | |
221 | - else if (newKey === null) { | |
222 | - ref.resetValues(ref); | |
217 | + const comboBoxV = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key); | |
218 | + comboBoxV.setValue(null); | |
219 | + if (newKey === amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimNullValue) { | |
220 | + comboBoxV.setVisible(false); | |
221 | + return; | |
222 | + } | |
223 | + | |
224 | + if (newKey !== null && newKey !== undefined) { | |
225 | + comboBoxV.setVisible(true); | |
226 | + ref.populateComboBoxValue(ref, newKey, comboBoxV); | |
223 | 227 | } |
228 | + | |
224 | 229 | ref.object.set(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, |
225 | 230 | newKey); |
226 | 231 | |
227 | - console.log(newKey); | |
228 | 232 | }); |
229 | 233 | |
230 | 234 | return comboBoxDim; |
231 | 235 | }, |
232 | 236 | |
233 | 237 | /** |
234 | - * Add Background Substraction field which contains the two comboBoxes | |
238 | + * Add Background Substraction items | |
235 | 239 | * @returns StandardFieldSet |
236 | 240 | */ |
237 | - getBgSubstractionItems: function () { | |
241 | + getBackgroundSubItems: function () { | |
238 | 242 | return [ |
239 | - this.addComboBoxBgSType(this), | |
240 | - this.addComboBoxBgSDim(this), | |
241 | - this.addComboBoxBgSValue(this), | |
242 | - this.addTextInput(this) | |
243 | + this.addComboBoxBackgroundSubType(this), | |
244 | + this.addComboBoxBackgroundSubDim(this), | |
245 | + this.addComboBoxBackgroundSubValue(this), | |
246 | + this.addComboBoxBackgroundSubFixedValue(this) | |
243 | 247 | ]; |
244 | 248 | }, |
245 | 249 | |
246 | 250 | getFormItems: function () { |
247 | 251 | const ref = this; |
248 | 252 | const field = this.addStandardFieldSet(amdaPlotObj.PlotObjectConfig.bgSubstraction.name, |
249 | - amdaPlotObj.PlotObjectConfig.bgSubstraction.name, this.getBgSubstractionItems(), | |
253 | + amdaPlotObj.PlotObjectConfig.bgSubstraction.name, this.getBackgroundSubItems(), | |
250 | 254 | function (name, newKey, oldKey) { |
251 | 255 | if (newKey !== oldKey) { |
252 | 256 | const comboBoxType = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key); |
253 | 257 | comboBoxType.setValue(null); |
254 | - | |
255 | - const nbDims = ref.data[amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName].length | |
256 | - if (nbDims === 1) { | |
257 | - const comboBoxDim = ref.getForm().findField(amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey); | |
258 | - comboBoxDim.setValue(0); | |
259 | - comboBoxDim.setVisible(false); | |
260 | - } | |
261 | 258 | } |
262 | 259 | }); |
263 | 260 | |
... | ... |