Commit c855ad547dcb47d7542d511ef8dacff43783f81f

Authored by Benjamin Renard
2 parents fa055b2f 1f5ef6b6

Merge branch 'MAZ_11427' into amdadev

js/app/views/PlotComponents/PlotZoomPlug.js
@@ -10,498 +10,124 @@ @@ -10,498 +10,124 @@
10 ******************************************************************************** 10 ********************************************************************************
11 * FT Id : Date : Name - Description 11 * FT Id : Date : Name - Description
12 ******************************************************************************* 12 *******************************************************************************
13 - * :  
14 */ 13 */
15 14
16 - 15 +// Define a new class 'amdaPlotComp.PlotZoomPlug' that extends 'Ext.util.Observable'
17 Ext.define('amdaPlotComp.PlotZoomPlug', { 16 Ext.define('amdaPlotComp.PlotZoomPlug', {
18 extend: 'Ext.util.Observable', 17 extend: 'Ext.util.Observable',
19 alias: 'plugin.plotZoomPlugin', 18 alias: 'plugin.plotZoomPlugin',
20 - requires: [  
21 - 'amdaPlotComp.plotFunction.ParamField', 'amdaPlotComp.plotFunction.FunctionType', 'amdaPlotComp.plotFunction.CreatePlot'],  
22 -  
23 - //id: 'plot-zoom-plug',  
24 -  
25 - ttModuleId: 'timetab-win',  
26 - catModuleId: 'catalog-win', 19 + requires: ['amdaPlotComp.intervalSelection.IntervalSelection'],
27 20
28 - win: null,  
29 - form: null,  
30 - zoomType: '',  
31 - interactiveId: '',  
32 - panelId: -1,  
33 -  
34 - linkedTTCatNode: null,  
35 - /**  
36 - * Un composant de 'PlotFunction' qui permet d'afficher le min samplig de chaque paramètre et le nombre de points théoriques entre un start time et stop time  
37 - */  
38 - plotFunctionParamField: null,  
39 - /**  
40 - * Un composant de 'PlotFunction' qui permet à l'utilisateur de séléctionner le type de fonction à appliquer : FFT, SUM, ...  
41 - */  
42 - plotFunctionType: null, 21 + // Declare a variable to hold the interval selection component
  22 + intervalSelectionCmp: null,
43 23
  24 + // Constructor function for the class
44 constructor: function (config) { 25 constructor: function (config) {
  26 + // Apply the configuration to this instance and call the parent class's constructor
45 Ext.apply(this, config); 27 Ext.apply(this, config);
46 this.callParent(arguments); 28 this.callParent(arguments);
47 }, 29 },
48 30
  31 + // Function to be called when the object is destroyed
49 onDestroy: function () { 32 onDestroy: function () {
50 - this.win = null; 33 + // Set the interval selection component to null
  34 + this.intervalSelectionCmp = null;
51 }, 35 },
52 36
  37 + // Initialization function for the class
53 init: function (cmp) { 38 init: function (cmp) {
  39 + // Set the host component for this instance
54 this.hostCmp = cmp; 40 this.hostCmp = cmp;
55 }, 41 },
56 42
57 - /**  
58 - * Set different parameters displayed on the current panel  
59 - * @param {*} listParams_ parameters displayed on the current panel  
60 - */  
61 - /*setParameters: function (listParams_) {  
62 - this.listParams = listParams_;  
63 - //this.plotFunctionParamField = new amdaPlotComp.plotFunction.ParamField({ params: this.listParams });  
64 - this.plotFunctionType = new amdaPlotComp.plotFunction.FunctionType({});  
65 - },*/  
66 -  
67 - 43 + // Function to set the minimum value of the interval selection component
68 setMinValue: function (min) { 44 setMinValue: function (min) {
69 - if (!this.form) 45 + if (!this.intervalSelectionCmp)
70 return; 46 return;
71 -  
72 - if (this.zoomType == 'timeAxis') {  
73 - this.form.getForm().findField('zoom-min-time').setValue(min);  
74 -  
75 - }  
76 - else  
77 - this.form.getForm().findField('zoom-min-float').setValue(min); 47 + this.intervalSelectionCmp.setField1Value(min);
78 }, 48 },
79 49
  50 + // Function to set the maximum value of the interval selection component
80 setMaxValue: function (max) { 51 setMaxValue: function (max) {
81 - if (!this.form)  
82 - return;  
83 -  
84 - if (this.zoomType == 'timeAxis') {  
85 - var minValue = this.form.getForm().findField('zoom-min-time').getValue();  
86 - if (minValue <= max) {  
87 - this.form.getForm().findField('zoom-max-time').setValue(max);  
88 - //if (this.isPlotFunction)  
89 - //this.plotFunctionParamField.setValues(minValue, max);  
90 - }  
91 - else {  
92 - this.form.getForm().findField('zoom-min-time').setValue(max);  
93 - this.form.getForm().findField('zoom-max-time').setValue(minValue);  
94 - // if (this.isPlotFunction)  
95 - // this.plotFunctionParamField.setValues(max, minValue);  
96 - }  
97 - }  
98 - else {  
99 - var minValue = this.form.getForm().findField('zoom-min-float').getValue();  
100 - if (minValue <= max)  
101 - this.form.getForm().findField('zoom-max-float').setValue(max);  
102 - else {  
103 - this.form.getForm().findField('zoom-min-float').setValue(max);  
104 - this.form.getForm().findField('zoom-max-float').setValue(minValue);  
105 - }  
106 - }  
107 - },  
108 -  
109 - /**  
110 - * add Interval to Time table  
111 - **/  
112 - insertInterval: function () {  
113 - if (this.zoomType != 'timeAxis') 52 + if (!this.intervalSelectionCmp)
114 return; 53 return;
115 -  
116 - var start = this.form.getForm().findField('zoom-min-time').getValue();  
117 - var stop = this.form.getForm().findField('zoom-max-time').getValue();  
118 -  
119 - var TTCatType = this.form.getForm().findField('ttcat-type').getValue();  
120 - var isCatalog = (TTCatType == 'catalog');  
121 -  
122 - myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) {  
123 - var targetModuleUI = module.getUiContent();  
124 - if (targetModuleUI)  
125 - targetModuleUI.addInterval(start, stop);  
126 - }); 54 + this.intervalSelectionCmp.setField2Value(max);
127 }, 55 },
128 56
129 /** 57 /**
130 - * creation of the window 58 + * Function to create and show a window with specific configuration
131 */ 59 */
132 - show: function (interactiveId, zoomType, panelId, isPlotFunction_ = false) {  
133 - this.isPlotFunction = isPlotFunction_;  
134 - if (this.win) { this.close() };  
135 - this.win = new Ext.Window({  
136 - id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID  
137 - width: 250,  
138 - x: 0, y: 0,  
139 - baseCls: 'x-panel',  
140 - title: 'Zoom',  
141 - constrain: true,  
142 - collapsible: true,  
143 - resizable: false,  
144 - ghost: false,  
145 - renderTo: this.hostCmp.ownerCt.body,  
146 - items: this.getFormConfig(),  
147 - listeners: {  
148 - scope: this,  
149 - beforeclose: function () {  
150 - this.hostCmp.panelImage.hidePanelMarker();  
151 - this.hostCmp.panelImage.stopZoom();  
152 - },  
153 - show: function(win, eOpts) {  
154 - this.hostCmp.panelImage.showPanelMarker(panelId);  
155 - } 60 + show: function (interactiveId, zoomType, panelId) {
  61 + let config = {
  62 + id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(),
  63 + interactiveId: interactiveId,
  64 + panelId: panelId,
  65 + hostCmp: this.hostCmp,
  66 + renderTo: this.hostCmp.ownerCt.body,
  67 + listeners: {
  68 + scope: this,
  69 + beforeclose: function () {
  70 + this.hostCmp.panelImage.hidePanelMarker();
  71 + this.hostCmp.panelImage.stopZoom();
156 }, 72 },
157 - getConstrainVector: function (constrainTo) {  
158 - var me = this;  
159 - if (me.constrain || me.constrainHeader) {  
160 - constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();  
161 - return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);  
162 - } 73 + show: function (win, eOpts) {
  74 + this.hostCmp.panelImage.showPanelMarker(panelId);
163 } 75 }
164 - });  
165 -  
166 - this.win.on('destroy', this.onDestroy, this);  
167 -  
168 - this.interactiveId = interactiveId;  
169 - this.updateWinByType(zoomType, panelId);  
170 - this.win.show();  
171 - this.win.setPosition(0, 0);  
172 - },  
173 -  
174 - close: function () {  
175 - if (this.win == null)  
176 - return;  
177 - this.win.close();  
178 - }, 76 + },
  77 + getConstrainVector: function (constrainTo) {
  78 + const self = this;
  79 + if (self.constrain || self.constrainHeader) {
  80 + constrainTo = constrainTo || (self.floatParent && self.floatParent.getTargetEl()) || self.container || self.el.getScopeParent();
  81 + return (self.constrainHeader ? self.header.el : self.el).getConstrainVector(constrainTo);
  82 + }
  83 + }
  84 + };
179 85
180 - updateWinByType: function (zoomType, panelId) {  
181 - if (this.win == null)  
182 - return; 86 + if (this.intervalSelectionCmp) { this.close() };
183 87
184 - this.zoomType = zoomType;  
185 - this.panelId = panelId; 88 + let intervalSelectionCmpType;
186 89
187 switch (zoomType) { 90 switch (zoomType) {
188 case 'timeAxis': 91 case 'timeAxis':
189 - if (this.isPlotFunction) {  
190 - const title = "Apply a Fct on Interval";  
191 - this.win.setTitle(title + '-Panel Id: ' + panelId);  
192 - } else {  
193 - this.win.setTitle('Zoom on time axis & Interval selection - Panel Id : ' + panelId);  
194 - } 92 + intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.DateZoomIntervalSelection';
195 break; 93 break;
196 case 'y-left': 94 case 'y-left':
197 - this.win.setTitle('Zoom on Y Left axis - Panel Id : ' + panelId);  
198 - break;  
199 case 'y-right': 95 case 'y-right':
200 - this.win.setTitle('Zoom on Y Right axis - Panel Id : ' + panelId);  
201 - break;  
202 case 'xaxis_id': 96 case 'xaxis_id':
203 - this.win.setTitle('Zoom on X axis - Panel Id : ' + panelId); 97 + intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.NumberZoomIntervalSelection';
  98 + let title = "";
  99 + if (zoomType === 'y-left') {
  100 + title = 'Zoom on Y Left axis';
  101 + } else if (zoomType === 'y-right') {
  102 + title = 'Zoom on Y Right axis';
  103 + } else {
  104 + title = 'Zoom on X axis';
  105 + }
  106 + config["type"] = zoomType;
  107 + config["title"] = title;
  108 + break;
  109 + case 'plotFunction':
  110 + intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection';
204 break; 111 break;
205 } 112 }
206 113
207 - this.form.getForm().findField('zoom-min-time').setVisible(this.zoomType == 'timeAxis');  
208 - this.form.getForm().findField('zoom-max-time').setVisible(this.zoomType == 'timeAxis');  
209 -  
210 - this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis');  
211 - this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis');  
212 -  
213 - var ttCatNameField = this.form.getForm().findField('ttcat-name');  
214 - if (ttCatNameField)  
215 - ttCatNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); 114 + // Create a new instance of the interval selection component with the specified type and configuration
  115 + this.intervalSelectionCmp = Ext.create(intervalSelectionCmpType, config);
  116 + // Add a listener for the destroy event of the interval selection component
  117 + this.intervalSelectionCmp.on('destroy', this.onDestroy, this);
  118 + // Show the interval selection component
  119 + this.intervalSelectionCmp.show();
216 }, 120 },
217 121
218 - resetMinMaxValue: function () {  
219 - if (this.zoomType == 'timeAxis') {  
220 - this.form.getForm().findField('zoom-min-time').setValue('');  
221 - this.form.getForm().findField('zoom-max-time').setValue('');  
222 - }  
223 - else {  
224 - this.form.getForm().findField('zoom-min-float').setValue(null);  
225 - this.form.getForm().findField('zoom-max-float').setValue(null);  
226 - }  
227 -  
228 - this.hostCmp.panelImage.resetZoom();  
229 - },  
230 - setTimePlot: function () {  
231 - var timeObj = new Object();  
232 - timeObj.start = this.form.getForm().findField('zoom-min-time').getValue();  
233 - timeObj.stop = this.form.getForm().findField('zoom-max-time').getValue();  
234 - timeObj.interactiveId = this.interactiveId;  
235 - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);  
236 - plotModule.setTimeInterval(timeObj);  
237 - },  
238 - /**  
239 - * Main form  
240 - */  
241 - getFormConfig: function () {  
242 - var intervalFieldSet = {  
243 - xtype: 'fieldset',  
244 - title: 'Interval Selection',  
245 - name: 'interval-selection-fieldset',  
246 - collapsible: false,  
247 - layout: {  
248 - type: 'vbox',  
249 - pack: 'start',  
250 - align: 'stretch'  
251 - },  
252 - items: [  
253 - {  
254 - xtype: 'datefield', name: 'zoom-min-time', fieldLabel: 'Start Time',  
255 - format: 'Y/m/d H:i:s.u',  
256 - },  
257 - {  
258 - xtype: 'datefield', name: 'zoom-max-time', fieldLabel: 'Stop Time',  
259 - format: 'Y/m/d H:i:s.u'  
260 - },  
261 - {  
262 - xtype: 'numberfield', name: 'zoom-min-float', fieldLabel: 'Min Value'  
263 - },  
264 - {  
265 - xtype: 'numberfield', name: 'zoom-max-float', fieldLabel: 'Max Value'  
266 - },  
267 - {  
268 - xtype: 'button',  
269 - width: 100,  
270 - text: 'Reset',  
271 - scope: this,  
272 - handler: function () {  
273 - this.resetMinMaxValue();  
274 - }  
275 - },  
276 - {  
277 - xtype: 'button',  
278 - width: 100,  
279 - text: 'Use in Time Selection',  
280 - scope: this,  
281 - handler: function () {  
282 - this.setTimePlot();  
283 - }  
284 - }  
285 - ]  
286 - };  
287 -  
288 - var insertTypeStore = Ext.create('Ext.data.Store', {  
289 - fields: ['key', 'name'],  
290 - data: [  
291 - { "key": "timeTable", "name": "TimeTable" },  
292 - { "key": "catalog", "name": "Catalog" }  
293 - ]  
294 - });  
295 -  
296 - var me = this;  
297 - this.insertTTFieldSet = {  
298 - xtype: 'fieldset',  
299 - title: 'Add in Time Table or Catalog',  
300 - name: 'tt-insertion-fieldset',  
301 - collapsible: false,  
302 - layout: {  
303 - type: 'vbox',  
304 - pack: 'start',  
305 - align: 'stretch'  
306 - },  
307 - items: [  
308 - {  
309 - xtype: 'combo',  
310 - fieldLabel: 'Insert In',  
311 - store: insertTypeStore,  
312 - queryMode: 'local',  
313 - displayField: 'name',  
314 - valueField: 'key',  
315 - editable: false,  
316 - value: 'timeTable',  
317 - name: 'ttcat-type'  
318 - },  
319 - {  
320 - xtype: 'textfield',  
321 - fieldLabel: 'Name',  
322 - name: 'ttcat-name',  
323 - listeners:  
324 - {  
325 - render: function (o, op) {  
326 - var field = this;  
327 - var el = this.el;  
328 - var dropTarget = Ext.create('Ext.dd.DropTarget', el, {  
329 - ddGroup: 'explorerTree',  
330 - notifyOver: function (ddSource, e, data) {  
331 - var TTCatType = me.form.getForm().findField('ttcat-type').getValue();  
332 - if (data.records[0].data.leaf && (data.records[0].data.nodeType == TTCatType)) {  
333 - this.valid = true;  
334 - return this.dropAllowed;  
335 - }  
336 - this.valid = false;  
337 - return this.dropNotAllowed;  
338 - },  
339 - notifyDrop: function (ddSource, e, data) {  
340 - if (!this.valid)  
341 - return false;  
342 - field.setValue(data.records[0].get('text'));  
343 - return true;  
344 - }  
345 - });  
346 - }  
347 - }  
348 - },  
349 - {  
350 - xtype: 'button',  
351 - width: 100,  
352 - text: 'Insert Interval',  
353 - scope: this,  
354 - handler: function () {  
355 - var me = this;  
356 -  
357 - var TTCatType = this.form.getForm().findField('ttcat-type').getValue();  
358 - var TTCatName = this.form.getForm().findField('ttcat-name').getValue();  
359 -  
360 - var isCatalog = (TTCatType == 'catalog');  
361 - myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) {  
362 - var targetModuleUI = module.getUiContent();  
363 - if (me.linkedTTCatNode && (me.linkedTTCatNode.get('text') == TTCatName) && (me.linkedTTCatNode.get('nodeType') == TTCatType)) {  
364 - if (targetModuleUI)  
365 - me.insertInterval();  
366 - else {  
367 - me.linkedTTCatNode.editLeaf(function () {  
368 - me.insertInterval();  
369 - });  
370 - }  
371 - }  
372 - else {  
373 - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);  
374 - var ttCatRootNode = explorerTree.getRootNode().findChild('id', isCatalog ? 'catalog-treeRootNode' : 'timeTable-treeRootNode', true);  
375 - amdaModel.InteractiveNode.preloadNodes(ttCatRootNode, function () {  
376 - var nodeWithSameName = null;  
377 -  
378 - if (TTCatName != '')  
379 - nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true);  
380 -  
381 - if (nodeWithSameName !== null)  
382 - me.linkedTTCatNode = nodeWithSameName;  
383 - else {  
384 - module.createLinkedNode();  
385 - module.getLinkedNode().set('text', TTCatName);  
386 - me.linkedTTCatNode = module.getLinkedNode();  
387 - var obj = {  
388 - name: TTCatName,  
389 - fromPlugin: true  
390 - };  
391 - if (isCatalog) {  
392 - Ext.Msg.prompt('Define Parameters', 'Please enter parameters number for the new catalog:', function (btn, text) {  
393 - if (btn == 'ok') {  
394 - obj.nbParameters = parseInt(text, 10);  
395 - if (isNaN(obj.nbParameters)) {  
396 - obj.nbParameters = 1;  
397 - }  
398 - module.createObject(obj);  
399 - me.linkedTTCatNode.editLeaf(function () {  
400 - me.insertInterval();  
401 - });  
402 - }  
403 - });  
404 - return;  
405 - }  
406 - else {  
407 - module.createObject(obj);  
408 - }  
409 - }  
410 -  
411 - me.linkedTTCatNode.editLeaf(function () {  
412 - me.insertInterval();  
413 - });  
414 - });  
415 - }  
416 - });  
417 - }  
418 - }  
419 - ]  
420 - };  
421 -  
422 - this.plotFunctionType = new amdaPlotComp.plotFunction.FunctionType({});  
423 -  
424 - this.form = new Ext.form.FormPanel({  
425 - frame: true,  
426 - width: 255,  
427 - layout: {  
428 - type: 'vbox',  
429 - pack: 'start',  
430 - align: 'stretch'  
431 - },  
432 - fieldDefaults: {  
433 - labelWidth: 60  
434 - },  
435 - items: [  
436 - intervalFieldSet,  
437 - this.isPlotFunction ? this.plotFunctionType : this.insertTTFieldSet  
438 - ],  
439 - fbar: [  
440 - {  
441 - text: me.isPlotFunction ? "Apply The Function" : 'Apply Zoom',  
442 - width: me.isPlotFunction ? 200 : 100,  
443 - scope: this,  
444 - handler: function () {  
445 - if (this.zoomType == 'timeAxis') {  
446 - var minZoom = Ext.Date.format(this.form.getForm().findField('zoom-min-time').getValue(), 'Y-m-d\\TH:i:s.u');  
447 - var maxZoom = Ext.Date.format(this.form.getForm().findField('zoom-max-time').getValue(), 'Y-m-d\\TH:i:s.u');  
448 - }  
449 - else {  
450 - var minZoom = this.form.getForm().findField('zoom-min-float').getValue();  
451 - var maxZoom = this.form.getForm().findField('zoom-max-float').getValue();  
452 - }  
453 -  
454 - if (!maxZoom || !minZoom || !this.form.getForm().isValid()) {  
455 - myDesktopApp.warningMsg('Error in values definition');  
456 - return;  
457 - }  
458 -  
459 - if (me.isPlotFunction) {  
460 - let request_to_send = {};  
461 -  
462 - request_to_send = Object.assign({}, me.plotFunctionType.getValues()/*, me.plotFunctionParamField.getValues()*/);  
463 - request_to_send = Object.assign({}, request_to_send, {  
464 - 'action': 'plotFunction',  
465 - 'interactiveId': this.interactiveId,  
466 - 'panelId': this.panelId,  
467 - 'starttime': minZoom,  
468 - 'stoptime': maxZoom  
469 - });  
470 -  
471 - this.hostCmp.callInteractivePlot(request_to_send);  
472 - } else {  
473 - this.hostCmp.callInteractivePlot({  
474 - 'action': 'zoom',  
475 - 'interactiveId': this.interactiveId,  
476 - 'panelId': this.panelId,  
477 - 'axeId': this.zoomType,  
478 - 'min': minZoom,  
479 - 'max': maxZoom  
480 - });  
481 - }  
482 -  
483 - this.hostCmp.panelImage.resetZoom();  
484 - }  
485 - },  
486 - me.isPlotFunction ? null :  
487 - {  
488 - text: 'Undo Zoom',  
489 - width: 100,  
490 - scope: this,  
491 - handler: function () {  
492 - this.hostCmp.callInteractivePlot({  
493 - 'action': 'undozoom',  
494 - 'interactiveId': this.interactiveId,  
495 - 'panelId': this.panelId,  
496 - 'axeId': this.zoomType  
497 - });  
498 - this.hostCmp.panelImage.resetZoom();  
499 - }  
500 - }  
501 - ]  
502 - });  
503 -  
504 - return this.form; 122 + // Function to close the interval selection component
  123 + close: function () {
  124 + if (this.intervalSelectionCmp == null)
  125 + return;
  126 + this.intervalSelectionCmp.close();
505 }, 127 },
506 128
  129 + // Function to reset the minimum and maximum values of the interval selection component
  130 + resetMinMaxValue: function () {
  131 + this.intervalSelectionCmp.reset();
  132 + }
507 }); 133 });
js/app/views/PlotComponents/intervalSelection/DateZoomIntervalSelection.js 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +Ext.define('amdaPlotComp.intervalSelection.DateZoomIntervalSelection', {
  2 + extend: 'amdaPlotComp.intervalSelection.ZoomIntervalSelection', // This class extends from amdaPlotComp.intervalSelection.ZoomIntervalSelection
  3 + requires: ['amdaPlotComp.intervalSelection.InsertToTTCatlog'], // This class requires the InsertToTTCatlog class from amdaPlotComp.intervalSelection
  4 +
  5 + type: 'timeAxis', // The type of axis for this interval selection is timeAxis
  6 + title: "Zoom on time axis & Interval selection", // The title of this interval selection
  7 + insertToTTCatlog: null, // An instance of the InsertToTTCatlog class, initially set to null
  8 +
  9 + /**
  10 + * Initializes the component.
  11 + * It calls the parent's initComponent method, then creates a new instance of InsertToTTCatlog and adds it to the form.
  12 + */
  13 + initComponent: function () {
  14 + this.callParent(arguments);
  15 + this.insertToTTCatlog = new amdaPlotComp.intervalSelection.InsertToTTCatlog({ parent: this });
  16 + this.form.add(this.insertToTTCatlog);
  17 + },
  18 +
  19 +});
js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js 0 → 100644
@@ -0,0 +1,173 @@ @@ -0,0 +1,173 @@
  1 +Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
  2 + extend: 'Ext.form.FieldSet',
  3 +
  4 + collapsible: false,
  5 + layout: LAYOUT_STYLE,
  6 + title: 'Add in Time Table or Catalog',
  7 + name: 'tt-insertion-fieldset',
  8 +
  9 + fieldTypeTTCat: 'ttcat-type',
  10 + fieldTypeName: 'ttcat-name',
  11 + ttModuleId: 'timetab-win',
  12 + catModuleId: 'catalog-win',
  13 + linkedTTCatNode: null,
  14 +
  15 + parent: null,
  16 +
  17 + initComponent: function () {
  18 + const self = this;
  19 +
  20 + const insertTypeStore = Ext.create('Ext.data.Store', {
  21 + fields: ['key', 'name'],
  22 + data: [
  23 + { "key": "timeTable", "name": "TimeTable" },
  24 + { "key": "catalog", "name": "Catalog" }
  25 + ]
  26 + });
  27 +
  28 + Ext.apply(self, {
  29 + items: [{
  30 + xtype: 'combo',
  31 + fieldLabel: 'Insert In',
  32 + store: insertTypeStore,
  33 + queryMode: 'local',
  34 + displayField: 'name',
  35 + valueField: 'key',
  36 + editable: false,
  37 + value: 'timeTable',
  38 + name: self.fieldTypeTTCat,
  39 + itemId: self.fieldTypeTTCat,
  40 + },
  41 + {
  42 + xtype: 'textfield',
  43 + fieldLabel: 'Name',
  44 + name: self.fieldTypeName,
  45 + itemId: self.fieldTypeName,
  46 + listeners:
  47 + {
  48 + render: function (o, op) {
  49 + var field = this;
  50 + var el = this.el;
  51 + Ext.create('Ext.dd.DropTarget', el, {
  52 + ddGroup: 'explorerTree',
  53 + notifyOver: function (ddSource, e, data) {
  54 + var TTCatType = self._getFieldTypeTTCat().getValue();
  55 + if (data.records[0].data.leaf && (data.records[0].data.nodeType == TTCatType)) {
  56 + this.valid = true;
  57 + return this.dropAllowed;
  58 + }
  59 + this.valid = false;
  60 + return this.dropNotAllowed;
  61 + },
  62 + notifyDrop: function (ddSource, e, data) {
  63 + if (!this.valid)
  64 + return false;
  65 + field.setValue(data.records[0].get('text'));
  66 + return true;
  67 + }
  68 + });
  69 + }
  70 + }
  71 + },
  72 + {
  73 + xtype: 'button',
  74 + width: width,
  75 + text: 'Insert Interval',
  76 + scope: this,
  77 + handler: function () {
  78 + var me = this;
  79 +
  80 + var TTCatType = self._getFieldTypeTTCat().getValue();
  81 + var TTCatName = self._getFieldNameTTCat().getValue();
  82 +
  83 + var isCatalog = (TTCatType == 'catalog');
  84 + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) {
  85 + var targetModuleUI = module.getUiContent();
  86 + if (me.linkedTTCatNode && (me.linkedTTCatNode.get('text') == TTCatName) && (me.linkedTTCatNode.get('nodeType') == TTCatType)) {
  87 + if (targetModuleUI)
  88 + me.insertInterval();
  89 + else {
  90 + me.linkedTTCatNode.editLeaf(function () {
  91 + me.insertInterval();
  92 + });
  93 + }
  94 + }
  95 + else {
  96 + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
  97 + var ttCatRootNode = explorerTree.getRootNode().findChild('id', isCatalog ? 'catalog-treeRootNode' : 'timeTable-treeRootNode', true);
  98 + amdaModel.InteractiveNode.preloadNodes(ttCatRootNode, function () {
  99 + var nodeWithSameName = null;
  100 +
  101 + if (TTCatName != '')
  102 + nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true);
  103 +
  104 + if (nodeWithSameName !== null)
  105 + me.linkedTTCatNode = nodeWithSameName;
  106 + else {
  107 + module.createLinkedNode();
  108 + module.getLinkedNode().set('text', TTCatName);
  109 + me.linkedTTCatNode = module.getLinkedNode();
  110 + var obj = {
  111 + name: TTCatName,
  112 + fromPlugin: true
  113 + };
  114 + if (isCatalog) {
  115 + Ext.Msg.prompt('Define Parameters', 'Please enter parameters number for the new catalog:', function (btn, text) {
  116 + if (btn == 'ok') {
  117 + obj.nbParameters = parseInt(text, 10);
  118 + if (isNaN(obj.nbParameters)) {
  119 + obj.nbParameters = 1;
  120 + }
  121 + module.createObject(obj);
  122 + me.linkedTTCatNode.editLeaf(function () {
  123 + me.insertInterval();
  124 + });
  125 + }
  126 + });
  127 + return;
  128 + }
  129 + else {
  130 + module.createObject(obj);
  131 + }
  132 + }
  133 +
  134 + me.linkedTTCatNode.editLeaf(function () {
  135 + me.insertInterval();
  136 + });
  137 + });
  138 + }
  139 + });
  140 + }
  141 + }
  142 + ]
  143 + });
  144 +
  145 + self.callParent(arguments);
  146 + },
  147 +
  148 +
  149 + _getFieldTypeTTCat: function () {
  150 + return this.down('#' + this.fieldTypeTTCat);
  151 + },
  152 +
  153 + _getFieldNameTTCat: function () {
  154 + return this.down('#' + this.fieldTypeName);
  155 + },
  156 +
  157 + /**
  158 + * add Interval to Time table or Catalog
  159 + */
  160 + insertInterval: function () {
  161 + const start = this.parent.getField1Value();
  162 + const stop = this.parent.getField2Value();
  163 +
  164 + const TTCatType = this._getFieldTypeTTCat().getValue();
  165 + const isCatalog = (TTCatType == 'catalog');
  166 +
  167 + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) {
  168 + var targetModuleUI = module.getUiContent();
  169 + if (targetModuleUI)
  170 + targetModuleUI.addInterval(start, stop);
  171 + });
  172 + }
  173 +});
js/app/views/PlotComponents/intervalSelection/IntervalSelection.js 0 → 100644
@@ -0,0 +1,245 @@ @@ -0,0 +1,245 @@
  1 +// Define a constant for the layout style of the form
  2 +const LAYOUT_STYLE = {
  3 + type: 'vbox', // vertical box layout
  4 + pack: 'start', // controls the vertical alignment of child items
  5 + align: 'stretch' // each child item is stretched to fill the width of the container
  6 +};
  7 +
  8 +// Width of button
  9 +const width = 100;
  10 +
  11 +// Define the parent class for all classes to use time interval selection.
  12 +Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', {
  13 + extend: 'Ext.window.Window', // This class extends from Ext.window.Window
  14 + // Window configurations
  15 + x: 0, y: 0, // The initial position of the window
  16 + title: 'Interval Selection', // The title of the window
  17 + constrain: true, // Constrains the window to within the boundaries of its containing element
  18 + collapsible: true, // Allows the window to be collapsed
  19 + resizable: false, // Prevents the window from being resizable
  20 + ghost: false, // Disables "ghosting" (semi-transparent representation of the window body) when moving or resizing
  21 +
  22 + form: null, // a panel which contains all components
  23 + hostCmp: null, // The host component from which this class is instantiated.
  24 + interactiveId: '',
  25 + panelId: -1,
  26 +
  27 + // Attributes of this class
  28 + config: {
  29 + field1Type: 'datefield', // The xtype of field1. By default is datefield because we are working with time series.
  30 + field1Label: 'Start Time', // The label of field1.
  31 + field1Format: 'Y/m/d H:i:s.u',
  32 + field2Type: 'datefield', // The xtype of field2. By default is datefield.
  33 + field2Label: 'Stop Time', // The label of field2.
  34 + field2Format: 'Y/m/d H:i:s.u',
  35 + buttonApply: 'Apply'
  36 + },
  37 +
  38 + // Define the itemIds as constants
  39 + // These will be used to reference the fields later in the code
  40 + FIELD1_ITEM_ID: 'field1',
  41 + FIELD2_ITEM_ID: 'field2',
  42 + buttonUseTime: 'button-use-time',
  43 +
  44 + initComponent: function () {
  45 + const self = this; // Reference to this instance for use in event handlers
  46 + this.form = new Ext.form.FormPanel({ // Create a new FormPanel instance and assign it to form
  47 + frame: true, // Display a frame around the panel
  48 + width: 255, // Set the width of the panel
  49 + layout: LAYOUT_STYLE, // Set the layout style of the panel
  50 + fieldDefaults: {
  51 + labelWidth: 60 // Set default label width for fields in this panel
  52 + },
  53 + items: [{
  54 + xtype: 'fieldset', // Create a new FieldSet to group related fields together
  55 + title: 'Interval Selection',
  56 + name: 'interval-selection-fieldset',
  57 + collapsible: false,
  58 + layout: LAYOUT_STYLE,
  59 + items: [{
  60 + xtype: this.field1Type,
  61 + fieldLabel: this.field1Label,
  62 + itemId: this.FIELD1_ITEM_ID,
  63 + format: this.field1Format,
  64 + listeners: {
  65 + change: function (field, newValue) {
  66 + if (newValue === null || newValue === undefined || newValue === '') return;
  67 + var field2 = self._getField2();
  68 + // Check if field2 is not empty
  69 + const value2 = field2.getValue();
  70 + if (value2 !== null && value2 !== undefined && value2 !== '') {
  71 + if (newValue > value2) {
  72 + // Update both field1 and field2 to the new values
  73 + field2.suspendEvents();
  74 + field2.setValue(newValue);
  75 + field.setValue(value2);
  76 + field2.resumeEvents();
  77 + }
  78 + }
  79 + }
  80 + }
  81 + },
  82 + {
  83 + xtype: this.field2Type,
  84 + fieldLabel: this.field2Label,
  85 + itemId: this.FIELD2_ITEM_ID,
  86 + format: this.field2Format,
  87 + listeners: {
  88 + change: function (field, newValue) {
  89 + if (newValue === null || newValue === undefined || newValue === '') return;
  90 + var field1 = self._getField1();
  91 + // Check if field1 is not empty
  92 + const value1 = field1.getValue();
  93 + if (value1 !== null && value1 !== undefined && value1 !== '') {
  94 + if (newValue < value1) {
  95 + // Update both field1 and field2 to the new values
  96 + field1.suspendEvents();
  97 + field1.setValue(newValue);
  98 + field.setValue(value1);
  99 + field1.resumeEvents();
  100 + }
  101 + }
  102 + }
  103 + }
  104 + }, {
  105 + xtype: 'button',
  106 + text: 'Reset',
  107 + width: width,
  108 + handler: function () {
  109 + self.reset();
  110 + }
  111 + },
  112 + {
  113 + xtype: 'button',
  114 + text: 'Use in Time Selection',
  115 + itemId: this.buttonUseTime,
  116 + handler: function () {
  117 + self._setTimeInterval();
  118 + }
  119 + }]
  120 + }],
  121 + fbar: [
  122 + {
  123 + xtype: 'button',
  124 + width: width,
  125 + text: this.buttonApply,
  126 + handler: function () {
  127 + self._apply();
  128 + }
  129 + }
  130 + ]
  131 + })
  132 +
  133 + Ext.apply(this, {
  134 + items: this.form
  135 + });
  136 +
  137 + this.setTitle(this.title + " - Panel Id : " + this.panelId);
  138 + this.callParent(arguments);
  139 + },
  140 +
  141 + /**
  142 + * Resets the time interval selection in the host component.
  143 + * This function calls the resetZoom method on the panelImage of the host component,
  144 + * effectively resetting any zoom applied to the image.
  145 + */
  146 + _resetHostCmpSelection: function () {
  147 + this.hostCmp.panelImage.resetZoom();
  148 + },
  149 +
  150 + /**
  151 + * Abstract method that must be implemented by subclasses.
  152 + * Throws an error if not overridden.
  153 + */
  154 + _apply: function () {
  155 + throw new Error('_apply() method must be implemented by subclass');
  156 + },
  157 +
  158 + /**
  159 + * Checks if the values of field1 and field2 are valid and if the form is valid.
  160 + * Returns true if any of these conditions are not met.
  161 + */
  162 + _notValidValues: function () {
  163 + return !this.getField1Value() || !this.getField2Value() || !this.form.getForm().isValid();
  164 + },
  165 +
  166 + /**
  167 + * Retrieves the component associated with FIELD1_ITEM_ID in the form.
  168 + * Returns the component if found, null otherwise.
  169 + */
  170 + _getField1: function () {
  171 + return this.form.down('#' + this.FIELD1_ITEM_ID);
  172 + },
  173 +
  174 + /**
  175 + * Retrieves the component associated with FIELD2_ITEM_ID in the form.
  176 + * Returns the component if found, null otherwise.
  177 + */
  178 + _getField2: function () {
  179 + return this.form.down('#' + this.FIELD2_ITEM_ID);
  180 + },
  181 +
  182 + /**
  183 + * Sets the time interval of the plot based on the values of the fields.
  184 + * This method is triggered when the buttonUseTime is clicked.
  185 + * It creates a new time object with start, stop, and interactiveId properties,
  186 + * and then calls the setTimeInterval method on the plot module with this object.
  187 + */
  188 + _setTimeInterval: function () {
  189 + const timeObj = new Object();
  190 + timeObj.start = this.getField1Value();
  191 + timeObj.stop = this.getField2Value();
  192 + timeObj.interactiveId = this.interactiveId;
  193 + const plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
  194 + plotModule.setTimeInterval(timeObj);
  195 + },
  196 +
  197 + /**
  198 + * Hides the buttonUseTime when it's not needed.
  199 + * For example, when we call Zoom on y-left axis we should not see this button.
  200 + * It finds the button by its ID and then calls the hide method on it.
  201 + */
  202 + _removeUseTimeButton: function () {
  203 + const buttonToHide = this.form.down('#' + this.buttonUseTime);
  204 + buttonToHide.hide();
  205 + },
  206 +
  207 + /**
  208 + * Retrieves the value of field1 from the form.
  209 + */
  210 + getField1Value: function () {
  211 + return this._getField1().getValue();
  212 + },
  213 +
  214 + /**
  215 + * Retrieves the value of field2 from the form.
  216 + */
  217 + getField2Value: function () {
  218 + return this._getField2().getValue();
  219 + },
  220 +
  221 + /**
  222 + * Sets a new value for field1 in the form.
  223 + */
  224 + setField1Value: function (value) {
  225 + this._getField1().setValue(value);
  226 + },
  227 +
  228 + /**
  229 + * Sets a new value for field2 in the form.
  230 + */
  231 + setField2Value: function (value) {
  232 + this._getField2().setValue(value);
  233 + },
  234 +
  235 + /**
  236 + * Resets the values of fields and host component selection.
  237 + * It calls the reset method on field1 and field2, and then calls _resetHostCmpSelection.
  238 + */
  239 + reset: function () {
  240 + this._getField1().reset();
  241 + this._getField2().reset();
  242 + this._resetHostCmpSelection();
  243 + }
  244 +
  245 +});
js/app/views/PlotComponents/intervalSelection/NumberZoomIntervalSelection.js 0 → 100644
@@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
  1 +Ext.define('amdaPlotComp.intervalSelection.NumberZoomIntervalSelection', {
  2 + extend: 'amdaPlotComp.intervalSelection.ZoomIntervalSelection', // This class extends from amdaPlotComp.intervalSelection.ZoomIntervalSelection
  3 +
  4 + field1Type: 'numberfield', // The type of the first field is a number field
  5 + field1Label: 'Min Value', // The label for the first field is 'Min Value'
  6 + field1Format: null, // The format for the first field is initially set to null
  7 + field2Type: 'numberfield', // The type of the second field is a number field
  8 + field2Label: 'Max value', // The label for the second field is 'Max value'
  9 + field2Format: null, // The format for the second field is initially set to null
  10 +
  11 + type: null, // The type of interval selection is initially set to null
  12 +
  13 + /**
  14 + * Initializes the component.
  15 + * It calls the parent's initComponent method, then removes the use time button.
  16 + */
  17 + initComponent: function () {
  18 + this.callParent(arguments);
  19 + this._removeUseTimeButton();
  20 + }
  21 +});
js/app/views/PlotComponents/intervalSelection/PlotFunctionIntervalSelection.js 0 → 100644
@@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
  1 +Ext.define('amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection', {
  2 + extend: 'amdaPlotComp.intervalSelection.IntervalSelection', // This class extends from amdaPlotComp.intervalSelection.IntervalSelection
  3 + requires: ['amdaPlotComp.plotFunction.FunctionType'], // This class requires the FunctionType class from amdaPlotComp.plotFunction
  4 +
  5 + title: "Plot Function", // The title of the window
  6 + plotFunctionType: null, // An instance of the FunctionType class, initially set to null
  7 +
  8 + /**
  9 + * Initializes the component.
  10 + * It calls the parent's initComponent method, then creates a new instance of FunctionType and adds it to the form.
  11 + */
  12 + initComponent: function () {
  13 + this.callParent(arguments);
  14 + this.plotFunctionType = new amdaPlotComp.plotFunction.FunctionType();
  15 + this.form.add(this.plotFunctionType);
  16 + },
  17 +
  18 + /**
  19 + * Applies the plot function based on the values of the fields.
  20 + * If the values are not valid, it shows a warning message.
  21 + * Otherwise, it calls the interactive plot with the plotFunction action and resets the host component selection.
  22 + */
  23 + _apply: function () {
  24 + if (this._notValidValues()) {
  25 + myDesktopApp.warningMsg('Please note that either the Start Time or the Stop Time has not been defined. To proceed, ensure both times are properly set.');
  26 + } else {
  27 + const request_to_send = Object.assign({}, this.plotFunctionType.getValues(), {
  28 + 'action': 'plotFunction',
  29 + 'interactiveId': this.interactiveId,
  30 + 'panelId': this.panelId,
  31 + 'starttime': this.getField1Value(),
  32 + 'stoptime': this.getField2Value(),
  33 + });
  34 +
  35 + this.hostCmp.callInteractivePlot(request_to_send);
  36 + this._resetHostCmpSelection();
  37 + }
  38 + },
  39 +
  40 +});
js/app/views/PlotComponents/intervalSelection/ZoomIntervalSelection.js 0 → 100644
@@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
  1 +Ext.define('amdaPlotComp.intervalSelection.ZoomIntervalSelection', {
  2 + extend: 'amdaPlotComp.intervalSelection.IntervalSelection', // This class extends from amdaPlotComp.intervalSelection.IntervalSelection
  3 +
  4 + buttonApply: "Apply Zoom",
  5 + type: null,
  6 +
  7 + /**
  8 + * Initializes the component.
  9 + * Adds an 'Undo Zoom' button to the bottom toolbar of the form.
  10 + */
  11 + initComponent: function () {
  12 + const self = this;
  13 + this.callParent(arguments);
  14 + this.form.getDockedItems('toolbar[dock="bottom"]')[0].add({
  15 + xtype: 'button',
  16 + width: width,
  17 + text: 'Undo Zoom',
  18 + handler: function () {
  19 + self._undoZoom();
  20 + }
  21 + });
  22 + },
  23 +
  24 + /**
  25 + * Applies the zoom based on the values of the fields.
  26 + * If the values are not valid, it shows a warning message.
  27 + * Otherwise, it calls the interactive plot with the zoom action and resets the host component selection.
  28 + */
  29 + _apply: function () {
  30 + if (this._notValidValues()) {
  31 + myDesktopApp.warningMsg('The Input Values are not defined');
  32 + } else {
  33 + this.hostCmp.callInteractivePlot({
  34 + 'action': 'zoom',
  35 + 'interactiveId': this.interactiveId,
  36 + 'panelId': this.panelId,
  37 + 'axeId': this.type,
  38 + 'min': this.getField1Value(),
  39 + 'max': this.getField2Value()
  40 + });
  41 +
  42 + this._resetHostCmpSelection();
  43 + }
  44 + },
  45 +
  46 + /**
  47 + * Undoes the zoom.
  48 + * It calls the interactive plot with the undozoom action and resets the host component selection.
  49 + */
  50 + _undoZoom: function () {
  51 + this.hostCmp.callInteractivePlot({
  52 + 'action': 'undozoom',
  53 + 'interactiveId': this.interactiveId,
  54 + 'panelId': this.panelId,
  55 + 'axeId': this.type
  56 + });
  57 +
  58 + this._resetHostCmpSelection();
  59 + }
  60 +
  61 +});
js/app/views/PlotComponents/plotFunction/BaseComponent.js
1 // Define the base class 1 // Define the base class
2 Ext.define('amdaPlotComp.plotFunction.BaseComponent', { 2 Ext.define('amdaPlotComp.plotFunction.BaseComponent', {
3 extend: 'Ext.form.FieldSet', 3 extend: 'Ext.form.FieldSet',
  4 +
  5 + collapsible: false,
  6 + layout: LAYOUT_STYLE,
4 7
5 /** 8 /**
6 * Subclasses are expected to implement this method to retrieve values. 9 * Subclasses are expected to implement this method to retrieve values.
js/app/views/PlotComponents/plotFunction/CreatePlot.js deleted
@@ -1,195 +0,0 @@ @@ -1,195 +0,0 @@
1 -/**  
2 - * Un composant de 'PlotFunction' qui permet à l'utilisateur de séléctionner le type de fonction à appliquer : FFT, SUM, ...  
3 - */  
4 -Ext.define('amdaPlotComp.plotFunction.CreatePlot', {  
5 - extend: 'Ext.window.Window',  
6 - requires: [  
7 - 'amdaUI.PlotlyContainer'  
8 - ],  
9 -  
10 - initComponent: function () {  
11 -  
12 - this.emptyChartConfig = {  
13 - xtype: 'amdaUI.PlotlyContainer',  
14 - id: 'visu-chart',  
15 - };  
16 -  
17 - const config =  
18 - {  
19 - title: 'Apply a Function on Interval',  
20 - width: 700,  
21 - height: 500,  
22 - layout: 'fit',  
23 - bodyStyle: { background: '#FFFFFF' },  
24 - modal: false,  
25 - resizable: true,  
26 - maximizable: true,  
27 - items: [  
28 - this.emptyChartConfig  
29 - ]  
30 - };  
31 -  
32 - Ext.apply(this, config);  
33 - this.callParent(arguments);  
34 - },  
35 -  
36 - getXYData: function (data, serie_label) {  
37 - const separatorItems = "|";  
38 - const separator = ";";  
39 -  
40 - let legends = serie_label.split(separator);  
41 - legends.pop();  
42 -  
43 - let items = data.split(separatorItems);  
44 - items.pop();  
45 -  
46 - const xs = [];  
47 - const ys = [];  
48 - const labels = [];  
49 - for (j = 0; j < legends.length; j++) {  
50 - let i;  
51 - const y = [];  
52 - const x = [];  
53 - for (i = 0; i < items.length; i++) {  
54 - const temp = items[i].split(separator);  
55 - x.push(this.timeConverter(temp[0]));  
56 - y.push(temp[j + 1]);  
57 - }  
58 - ys.push(y);  
59 - xs.push(x);  
60 - labels.push(legends[j]);  
61 - }  
62 -  
63 - return { xs: xs, ys: ys, labels: labels };  
64 - },  
65 -  
66 - timeConverter: function (_timestamp) {  
67 - var a = new Date(_timestamp * 1000);  
68 - var year = a.getUTCFullYear();  
69 - var month = a.getUTCMonth() + 1;  
70 - var date = a.getUTCDate();  
71 - var hour = a.getUTCHours();  
72 - var min = a.getUTCMinutes();  
73 - var sec = a.getUTCSeconds();  
74 - var time = year + '-' + month + '-' + date + ' ' + hour + ':' + min + ':' + sec;  
75 - return time;  
76 - },  
77 -  
78 - applyFunction: function (y, dimSize) {  
79 - const type = this.plotFunctionType;  
80 - const valDict = type.getValues();  
81 - const fct = valDict[type.plotFunctionItems.type.name];  
82 - let out_y = [];  
83 - switch (fct) {  
84 - case type.plotFunctionItems.type.values.sum:  
85 - out_y = y;  
86 - break;  
87 - case type.plotFunctionItems.type.values.fft:  
88 -  
89 - break;  
90 - case type.plotFunctionItems.type.values.avg:  
91 - if (dimSize === -1) {  
92 - out_y = y.map(e => e / y.length);  
93 - } else {  
94 - out_y = y.map(e => e / dimSize);  
95 - }  
96 - break;  
97 -  
98 - default:  
99 - break;  
100 - }  
101 - return out_y;  
102 - },  
103 -  
104 -  
105 -  
106 - plot: function () {  
107 - const param = this.xmlDoc.getElementsByTagName('parameter');  
108 - const traces = [];  
109 - let yAxisLabel = "";  
110 - let i;  
111 - for (i = 0; i < param.length; i++) {  
112 - const param_name = param[i].getAttribute('name');  
113 - const param_unit = param[i].getAttribute('unit');  
114 - const serie = param[i].getElementsByTagName('serie');  
115 -  
116 - yAxisLabel += param_unit + "<br>";  
117 -  
118 - for (let si = 0; si < serie.length; si++) {  
119 - const serie_label = serie[si].getAttribute('serie_label');  
120 - const data_ = this.getXYData(serie[si].getAttribute('data'), serie_label);  
121 - let k;  
122 -  
123 - const dimSize = serie[si].getAttribute('dimSize');  
124 -  
125 - for (k = 0; k < data_.ys.length; k++) {  
126 - let trace = {};  
127 - trace.x = data_.xs[k];  
128 - trace.y = this.applyFunction(data_.ys[k], parseInt(dimSize));  
129 - trace.mode = 'lines+markers';  
130 - trace.name = param_name + " (" + data_.labels[k] + ")";  
131 - trace.type = 'scatter';  
132 -  
133 - traces.push(trace);  
134 - }  
135 - }  
136 - }  
137 -  
138 - var chart = Ext.getCmp(this.emptyChartConfig.id);  
139 -  
140 - var config = this.emptyChartConfig;  
141 -  
142 - config.data = traces;  
143 -  
144 - const config_ = {  
145 - showgrid: true,  
146 - zeroline: true,  
147 - showline: true,  
148 - mirror: 'ticks',  
149 - gridcolor: '#bdbdbd',  
150 - gridwidth: 1,  
151 - zerolinecolor: '#969696',  
152 - zerolinewidth: 1,  
153 - linecolor: '#636363',  
154 - linewidth: 1  
155 - };  
156 -  
157 - let config_x = {  
158 - title: {  
159 - text: "Time, UT"  
160 - },  
161 - type: 'date',  
162 - };  
163 -  
164 - let config_y = {  
165 - title: {  
166 - text: this.format_label(yAxisLabel)  
167 - },  
168 - exponentformat: "e"  
169 - }  
170 -  
171 - for (var key in config_) {  
172 - config_x[key] = config_[key];  
173 - config_y[key] = config_[key];  
174 - }  
175 -  
176 - config.layout = {  
177 - xaxis: config_x,  
178 - yaxis: config_y  
179 - };  
180 -  
181 - if (chart) {  
182 - var chartPanel = chart.up();  
183 - chartPanel.remove(chart);  
184 - }  
185 - var testPlotly = new amdaUI.PlotlyContainer(config);  
186 - chartPanel.insert(testPlotly);  
187 - },  
188 - format_label: function (label) {  
189 - const power_2 = "\xB2";  
190 - const power_3 = "\xB3";  
191 - const amda_power_2 = "#u2";  
192 - const amda_space = "#d";  
193 - return label.replace(amda_power_2, power_2).replace(amda_space, " ");  
194 - }  
195 -});  
196 \ No newline at end of file 0 \ No newline at end of file
js/app/views/PlotComponents/plotFunction/FFTCmpt.js
1 Ext.define('amdaPlotComp.plotFunction.FFTCmpt', { 1 Ext.define('amdaPlotComp.plotFunction.FFTCmpt', {
2 - extend: 'amdaPlotComp.plotFunction.BaseComponent',  
3 - title: "FFT Arguments",  
4 - id: 'fftComboBox',  
5 - 2 + extend: 'amdaPlotComp.plotFunction.BaseComponent', // This class extends from amdaPlotComp.plotFunction.BaseComponent
  3 + title: "FFT Arguments", // The title of this component
  4 + id: 'fftComboBox', // The id of this component
  5 +
  6 + /**
  7 + * Initializes the component.
  8 + * It creates a combo box with two options, 'Frequency' and 'Period', and adds it to the component.
  9 + */
6 initComponent: function () { 10 initComponent: function () {
7 const me = this; 11 const me = this;
8 12
@@ -34,8 +38,12 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FFTCmpt&#39;, { @@ -34,8 +38,12 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FFTCmpt&#39;, {
34 me.callParent(arguments); 38 me.callParent(arguments);
35 }, 39 },
36 40
  41 + /**
  42 + * Retrieves the selected value from the combo box.
  43 + * Returns an object with a property 'abscisse' set to the selected value.
  44 + */
37 getValues: function () { 45 getValues: function () {
38 - const fftComboBox = this.down('#'+this.id); // Retrieve ComboBox by itemId 46 + const fftComboBox = this.down('#' + this.id); // Retrieve ComboBox by itemId
39 const selectedValue = fftComboBox.getValue(); // Get selected value 47 const selectedValue = fftComboBox.getValue(); // Get selected value
40 48
41 return { 49 return {
js/app/views/PlotComponents/plotFunction/FunctionType.js
1 /** 1 /**
2 - * Un composant de 'PlotFunction' qui permet à l'utilisateur de séléctionner le type de fonction à appliquer : FFT, SUM, ... 2 + * A 'PlotFunction' component that allows the user to select the type of function to apply: FFT, SUM, etc.
3 */ 3 */
4 Ext.define('amdaPlotComp.plotFunction.FunctionType', { 4 Ext.define('amdaPlotComp.plotFunction.FunctionType', {
5 extend: 'Ext.form.Panel', 5 extend: 'Ext.form.Panel',
6 6
7 - view: null,  
8 - currentModule: null, 7 + view: null, // A reference to the view of this component
  8 + currentModule: null, // A reference to the current module of this component
9 9
10 - functionComboBox: "type",  
11 - x_axis: { label: "X Axis", value: "scale_abscisse" },  
12 - y_axis: { label: "Y Axis", value: "scale_ordonnee" }, 10 + functionComboBox: "type", // The name of the function combo box
  11 + x_axis: { label: "X Axis", value: "scale_abscisse" }, // The label and value for the x-axis combo box
  12 + y_axis: { label: "Y Axis", value: "scale_ordonnee" }, // The label and value for the y-axis combo box
13 scaleOptions: { 13 scaleOptions: {
14 - linear: { label: "Linear", value: "linear" },  
15 - logarithmic: { label: "Logarithmic", value: "logarithmic" } 14 + linear: { label: "Linear", value: "linear" }, // The label and value for the linear scale option
  15 + logarithmic: { label: "Logarithmic", value: "logarithmic" } // The label and value for the logarithmic scale option
16 }, 16 },
17 functionOptions: { 17 functionOptions: {
18 - fft: { label: "FFT (Magnitude^2)", value: "FFT" },  
19 - dft: { label: "DFT (Magnitude^2)", value: "DFT" },  
20 - sum: { label: "SUM", value: "SUM" },  
21 - avg: { label: "AVG", value: "AVG" },  
22 - hist: { label: "Histogram Plot 1D", value: 'histoPlot' } 18 + fft: { label: "FFT (Magnitude^2)", value: "FFT" }, // The label and value for the FFT function option
  19 + dft: { label: "DFT (Magnitude^2)", value: "DFT" }, // The label and value for the DFT function option
  20 + sum: { label: "SUM", value: "SUM" }, // The label and value for the SUM function option
  21 + avg: { label: "AVG", value: "AVG" }, // The label and value for the AVG function option
  22 + hist: { label: "Histogram Plot 1D", value: 'histoPlot' } // The label and value for the Histogram Plot 1D function option
23 }, 23 },
24 24
  25 + /**
  26 + * Creates a combo box for selecting the function type.
  27 + * @param {String} defaultSelection The default selected value for the combo box.
  28 + * @returns {Ext.form.field.ComboBox} The created combo box.
  29 + */
25 createFunctionComboBox: function (defaultSelection) { 30 createFunctionComboBox: function (defaultSelection) {
26 const self = this; 31 const self = this;
27 const comboStore = Ext.create('Ext.data.Store', { 32 const comboStore = Ext.create('Ext.data.Store', {
@@ -48,6 +53,11 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FunctionType&#39;, { @@ -48,6 +53,11 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FunctionType&#39;, {
48 return combo; 53 return combo;
49 }, 54 },
50 55
  56 + /**
  57 + * Creates a combo box for selecting the scale type for an axis.
  58 + * @param {Object} axis An object with a label and a value for the axis.
  59 + * @returns {Ext.form.field.ComboBox} The created combo box.
  60 + */
51 createAxisComboBox: function (axis) { 61 createAxisComboBox: function (axis) {
52 const comboStore = Ext.create('Ext.data.Store', { 62 const comboStore = Ext.create('Ext.data.Store', {
53 fields: ['label', 'value'], 63 fields: ['label', 'value'],
@@ -69,6 +79,10 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FunctionType&#39;, { @@ -69,6 +79,10 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FunctionType&#39;, {
69 }, 79 },
70 80
71 81
  82 + /**
  83 + * Handles the change of function type by removing the current module and adding a new one based on the selected value.
  84 + * @param {String} value The selected value from the function combo box.
  85 + */
72 handleFunction: function (value) { 86 handleFunction: function (value) {
73 if (this.currentModule) { 87 if (this.currentModule) {
74 this.view.remove(this.currentModule, true); 88 this.view.remove(this.currentModule, true);
@@ -93,14 +107,13 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FunctionType&#39;, { @@ -93,14 +107,13 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FunctionType&#39;, {
93 }, 107 },
94 108
95 109
  110 + /**
  111 + * Initializes the component by creating a field set with a function combo box and two axis combo boxes.
  112 + */
96 initComponent: function () { 113 initComponent: function () {
97 this.view = Ext.create('Ext.form.FieldSet', { 114 this.view = Ext.create('Ext.form.FieldSet', {
98 collapsible: false, 115 collapsible: false,
99 - layout: {  
100 - type: 'vbox',  
101 - pack: 'start',  
102 - align: 'stretch',  
103 - }, 116 + layout: LAYOUT_STYLE,
104 bodyStyle: 'background: none', 117 bodyStyle: 'background: none',
105 items: [this.createFunctionComboBox(), this.createAxisComboBox(this.x_axis), this.createAxisComboBox(this.y_axis)] 118 items: [this.createFunctionComboBox(), this.createAxisComboBox(this.x_axis), this.createAxisComboBox(this.y_axis)]
106 }); 119 });
@@ -117,25 +130,21 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FunctionType&#39;, { @@ -117,25 +130,21 @@ Ext.define(&#39;amdaPlotComp.plotFunction.FunctionType&#39;, {
117 }, 130 },
118 131
119 /** 132 /**
120 - * Retournes les valeurs des comboboxes associées à ce composant  
121 - * @returns les valeurs des comboboxes se forme d'un dictionnaire 133 + * Returns the values of the combo boxes associated with this component.
  134 + * @returns {Object} An object with properties set to the values of the combo boxes.
122 */ 135 */
123 getValues: function () { 136 getValues: function () {
124 - const xAxisScale = this.getForm().findField(this.x_axis.value).getValue();  
125 - const yAxisScale = this.getForm().findField(this.y_axis.value).getValue();  
126 - const functionType = this.getForm().findField(this.functionComboBox).getValue();  
127 - let out = {};  
128 - out[this.functionComboBox] = functionType;  
129 - out[this.x_axis.value] = xAxisScale;  
130 - out[this.y_axis.value] = yAxisScale;  
131 - 137 + let out = {
  138 + [this.functionComboBox]: this.getForm().findField(this.functionComboBox).getValue(),
  139 + [this.x_axis.value]: this.getForm().findField(this.x_axis.value).getValue(),
  140 + [this.y_axis.value]: this.getForm().findField(this.y_axis.value).getValue()
  141 + };
132 142
133 if (this.currentModule) { 143 if (this.currentModule) {
134 - const values = this.currentModule.getValues();  
135 - // Adding values to out  
136 - Object.assign(out, values); 144 + Object.assign(out, this.currentModule.getValues());
137 } 145 }
138 - 146 +
139 return out; 147 return out;
140 } 148 }
141 -});  
142 \ No newline at end of file 149 \ No newline at end of file
  150 +});
  151 +
js/app/views/PlotComponents/plotFunction/Histogram.js
1 Ext.define('amdaPlotComp.plotFunction.Histogram', { 1 Ext.define('amdaPlotComp.plotFunction.Histogram', {
2 - extend: 'amdaPlotComp.plotFunction.BaseComponent',  
3 - title: "Histogram Arguments", 2 + extend: 'amdaPlotComp.plotFunction.BaseComponent', // This class extends from amdaPlotComp.plotFunction.BaseComponent
  3 + title: "Histogram Arguments", // The title of this component
4 4
  5 + // Define the IDs for the function, bins, and xMin and xMax fields
5 functionId: 'histo1d-function', 6 functionId: 'histo1d-function',
6 binsId: 'histo1d-xbinnumber', 7 binsId: 'histo1d-xbinnumber',
7 xMinId: "histo1d-xmin", 8 xMinId: "histo1d-xmin",
8 xMaxId: 'histo1d-xmax', 9 xMaxId: 'histo1d-xmax',
9 10
  11 + /**
  12 + * Initializes the component.
  13 + * It creates a combo box for selecting the density type and number fields for entering the xMin, xMax, and number of bins.
  14 + */
10 initComponent: function () { 15 initComponent: function () {
11 - const me = this; 16 + const self = this;
12 17
  18 + // Define combo box store
13 const comboStore = Ext.create('Ext.data.Store', { 19 const comboStore = Ext.create('Ext.data.Store', {
14 fields: ['label', 'value'], 20 fields: ['label', 'value'],
15 data: [ 21 data: [
@@ -18,9 +24,10 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, { @@ -18,9 +24,10 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, {
18 ] 24 ]
19 }); 25 });
20 26
  27 + // Create combo box for selecting the density type
21 const densityTypeCombo = Ext.create('Ext.form.field.ComboBox', { 28 const densityTypeCombo = Ext.create('Ext.form.field.ComboBox', {
22 fieldLabel: 'Density Type', 29 fieldLabel: 'Density Type',
23 - name: me.functionId, 30 + name: self.functionId,
24 store: comboStore, 31 store: comboStore,
25 queryMode: 'local', 32 queryMode: 'local',
26 displayField: 'label', 33 displayField: 'label',
@@ -29,12 +36,13 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, { @@ -29,12 +36,13 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, {
29 value: 'density' 36 value: 'density'
30 }); 37 });
31 38
32 - Ext.apply(me, { 39 + // Add items to the component
  40 + Ext.apply(self, {
33 items: [ 41 items: [
34 { 42 {
35 xtype: 'numberfield', 43 xtype: 'numberfield',
36 fieldLabel: 'X Min', 44 fieldLabel: 'X Min',
37 - name: me.xMinId, 45 + name: self.xMinId,
38 allowDecimals: true, 46 allowDecimals: true,
39 hideTrigger: true, 47 hideTrigger: true,
40 keyNavEnabled: false, 48 keyNavEnabled: false,
@@ -42,7 +50,7 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, { @@ -42,7 +50,7 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, {
42 { 50 {
43 xtype: 'numberfield', 51 xtype: 'numberfield',
44 fieldLabel: 'X Max', 52 fieldLabel: 'X Max',
45 - name: me.xMaxId, 53 + name: self.xMaxId,
46 allowDecimals: true, 54 allowDecimals: true,
47 hideTrigger: true, 55 hideTrigger: true,
48 keyNavEnabled: false, 56 keyNavEnabled: false,
@@ -50,7 +58,7 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, { @@ -50,7 +58,7 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, {
50 { 58 {
51 xtype: 'numberfield', 59 xtype: 'numberfield',
52 fieldLabel: 'Number of Bins', 60 fieldLabel: 'Number of Bins',
53 - name: me.binsId, 61 + name: self.binsId,
54 minValue: 1, 62 minValue: 1,
55 value: 100, 63 value: 100,
56 allowDecimals: false, 64 allowDecimals: false,
@@ -60,9 +68,14 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, { @@ -60,9 +68,14 @@ Ext.define(&#39;amdaPlotComp.plotFunction.Histogram&#39;, {
60 ] 68 ]
61 }); 69 });
62 70
63 - me.callParent(arguments); 71 + // Call the parent class's initComponent method
  72 + self.callParent(arguments);
64 }, 73 },
65 74
  75 + /**
  76 + * Retrieves the selected values from the combo box and number fields.
  77 + * Returns an object with properties set to these values.
  78 + */
66 getValues: function () { 79 getValues: function () {
67 const densityTypeCombo = this.query('[name=' + this.functionId + ']')[0]; 80 const densityTypeCombo = this.query('[name=' + this.functionId + ']')[0];
68 const densityTypeValue = densityTypeCombo.getValue(); 81 const densityTypeValue = densityTypeCombo.getValue();
js/app/views/PlotComponents/plotFunction/ParamField.js deleted
@@ -1,124 +0,0 @@ @@ -1,124 +0,0 @@
1 -/**  
2 - * Un composant de 'PlotFunction' qui permet d'afficher le min samplig de chaque paramètre et le nombre de points théoriques entre un start time et stop time  
3 - */  
4 -Ext.define('amdaPlotComp.plotFunction.ParamField', {  
5 - extend: 'Ext.form.Panel',  
6 - /**  
7 - * id du composant de type numberfield qui hébérge le min sampling  
8 - */  
9 - label_number_field: "NUMBERFIELD",  
10 - /**  
11 - * id du composant de type numberfield qui hébérge le nombre de points  
12 - */  
13 - label_number_field1: "NUMBERFIELD1",  
14 - /**  
15 - * Le composant parent de celui-ci  
16 - */  
17 - parent: null,  
18 -  
19 - initComponent: function () {  
20 - const items_params = [];  
21 - const minSampling = "Sampling Time (s)";  
22 - const minValue = 0;  
23 - const labelWitdh = 120;  
24 - const width = 30;  
25 -  
26 - for (p in this.params) {  
27 - const param = this.params[p];  
28 - const fieldSet = {  
29 - xtype: 'fieldset',  
30 - name: 'FIELDSET' + param.id,  
31 - title: param.id,  
32 - collapsible: false,  
33 - layout: {  
34 - type: 'vbox',  
35 - align: 'stretch',  
36 - },  
37 - items: [  
38 - {  
39 - xtype: 'numberfield',  
40 - name: this.label_number_field + param.id,  
41 - labelWidth: labelWitdh,  
42 - width: width,  
43 - value: param.MinSampling,  
44 - minValue: minValue,  
45 - disabled: true,  
46 - fieldLabel: minSampling  
47 - },  
48 - {  
49 - xtype: 'numberfield',  
50 - name: this.label_number_field1 + param.id,  
51 - labelWidth: labelWitdh,  
52 - width: width,  
53 - value: 0,  
54 - minValue: minValue,  
55 - fieldLabel: "Nb Points"  
56 - }  
57 - ]  
58 - };  
59 -  
60 - items_params.push(fieldSet);  
61 - }  
62 -  
63 - const tabParams = Ext.create('Ext.tab.Panel', {  
64 - layout: 'fit',  
65 - plain: true,  
66 - bodyStyle: 'background: none',  
67 - items: items_params  
68 - });  
69 -  
70 - const config =  
71 - {  
72 - title: 'Parameters Sampling',  
73 - layout: 'fit',  
74 - bodyStyle: { background: '#dfe8f6' },  
75 - items: [tabParams]  
76 - };  
77 -  
78 - Ext.apply(this, config);  
79 - //Les arguments sont les paramètres, chaque paramètre contient un id et un min Sampling  
80 - this.callParent(arguments);  
81 - },  
82 -  
83 - /**  
84 - * Set parent  
85 - * @param {*} parent_ le parent qui contient ce composant  
86 - */  
87 - setParent: function (parent_) {  
88 - this.parent = parent_;  
89 - },  
90 -  
91 - /**  
92 - * Retourne les valeurs d'id, min sampling et nb_points de tout les parametres passés comme argument  
93 - * @returns id1@minSampling1@nb_points1@id2@minSampling2@nb_points2....  
94 - */  
95 - getValues: function () {  
96 - let list = "";  
97 - const delimeter = "@";  
98 - let i = 0;  
99 - for (p in this.params) {  
100 - let param = this.params[p];  
101 - const ui_item = this.parent.findField(this.label_number_field1 + param.id);  
102 - if (i > 0) list += delimeter;  
103 - if (ui_item !== undefined && ui_item !== null) {  
104 - list += param.id + delimeter + param.MinSampling + delimeter + ui_item.getValue() + delimeter + "5";  
105 - }  
106 - i++;  
107 - }  
108 - return { "param_nb_points": list };  
109 - },  
110 -  
111 - /**  
112 - * Mettre à jour le nb_points en fonction de la valeur de start time et stop time passés en paramètres  
113 - * @param {*} startTime le start time issu du ZoomPlugin  
114 - * @param {*} stopTime le stop time issu du ZoomPlugin  
115 - */  
116 - setValues: function (startTime, stopTime) {  
117 - for (p in this.params) {  
118 - let param = this.params[p];  
119 - const nb_points = (stopTime.getTime() - startTime.getTime()) / (1000. * param.MinSampling);  
120 - const ui_item = this.parent.findField(this.label_number_field1 + param.id);  
121 - ui_item.setValue(parseInt(nb_points));  
122 - }  
123 - }  
124 -});  
js/app/views/PlotTabResultUI.js
@@ -163,7 +163,7 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, { @@ -163,7 +163,7 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
163 plotFunctionItem = { 163 plotFunctionItem = {
164 text: 'Apply a Function on Interval', 164 text: 'Apply a Function on Interval',
165 handler: function (item, e) { 165 handler: function (item, e) {
166 - zoomPlugin.show(me.interactiveId, axis.id, panelContext.id, true); 166 + zoomPlugin.show(me.interactiveId, "plotFunction", panelContext.id);
167 zoomPlugin.resetMinMaxValue(); 167 zoomPlugin.resetMinMaxValue();
168 me.panelImage.startZoom(true, 0, size.height, onMinTimeSelection, onMaxTimeSelection); 168 me.panelImage.startZoom(true, 0, size.height, onMinTimeSelection, onMaxTimeSelection);
169 }, 169 },