Commit 594fc71973c129693d29013a55a92925d66316b6

Authored by Menouar AZIB
1 parent 6c264222

Add comments to FunctionType.js

Showing 1 changed file with 40 additions and 27 deletions   Show diff stats
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 4 Ext.define('amdaPlotComp.plotFunction.FunctionType', {
5 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 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 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 30 createFunctionComboBox: function (defaultSelection) {
26 31 const self = this;
27 32 const comboStore = Ext.create('Ext.data.Store', {
... ... @@ -48,6 +53,11 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', {
48 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 61 createAxisComboBox: function (axis) {
52 62 const comboStore = Ext.create('Ext.data.Store', {
53 63 fields: ['label', 'value'],
... ... @@ -69,6 +79,10 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', {
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 86 handleFunction: function (value) {
73 87 if (this.currentModule) {
74 88 this.view.remove(this.currentModule, true);
... ... @@ -93,6 +107,9 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', {
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 113 initComponent: function () {
97 114 this.view = Ext.create('Ext.form.FieldSet', {
98 115 collapsible: false,
... ... @@ -113,25 +130,21 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', {
113 130 },
114 131  
115 132 /**
116   - * Retournes les valeurs des comboboxes associées à ce composant
117   - * @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.
118 135 */
119 136 getValues: function () {
120   - const xAxisScale = this.getForm().findField(this.x_axis.value).getValue();
121   - const yAxisScale = this.getForm().findField(this.y_axis.value).getValue();
122   - const functionType = this.getForm().findField(this.functionComboBox).getValue();
123   - let out = {};
124   - out[this.functionComboBox] = functionType;
125   - out[this.x_axis.value] = xAxisScale;
126   - out[this.y_axis.value] = yAxisScale;
127   -
  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 + };
128 142  
129 143 if (this.currentModule) {
130   - const values = this.currentModule.getValues();
131   - // Adding values to out
132   - Object.assign(out, values);
  144 + Object.assign(out, this.currentModule.getValues());
133 145 }
134 146  
135 147 return out;
136 148 }
137   -});
138 149 \ No newline at end of file
  150 +});
  151 +
... ...