diff --git a/js/app/views/PlotComponents/plotFunction/FunctionType.js b/js/app/views/PlotComponents/plotFunction/FunctionType.js index 5d00460..e4364f6 100644 --- a/js/app/views/PlotComponents/plotFunction/FunctionType.js +++ b/js/app/views/PlotComponents/plotFunction/FunctionType.js @@ -1,27 +1,32 @@ /** - * Un composant de 'PlotFunction' qui permet à l'utilisateur de séléctionner le type de fonction à appliquer : FFT, SUM, ... + * A 'PlotFunction' component that allows the user to select the type of function to apply: FFT, SUM, etc. */ Ext.define('amdaPlotComp.plotFunction.FunctionType', { extend: 'Ext.form.Panel', - view: null, - currentModule: null, + view: null, // A reference to the view of this component + currentModule: null, // A reference to the current module of this component - functionComboBox: "type", - x_axis: { label: "X Axis", value: "scale_abscisse" }, - y_axis: { label: "Y Axis", value: "scale_ordonnee" }, + functionComboBox: "type", // The name of the function combo box + x_axis: { label: "X Axis", value: "scale_abscisse" }, // The label and value for the x-axis combo box + y_axis: { label: "Y Axis", value: "scale_ordonnee" }, // The label and value for the y-axis combo box scaleOptions: { - linear: { label: "Linear", value: "linear" }, - logarithmic: { label: "Logarithmic", value: "logarithmic" } + linear: { label: "Linear", value: "linear" }, // The label and value for the linear scale option + logarithmic: { label: "Logarithmic", value: "logarithmic" } // The label and value for the logarithmic scale option }, functionOptions: { - fft: { label: "FFT (Magnitude^2)", value: "FFT" }, - dft: { label: "DFT (Magnitude^2)", value: "DFT" }, - sum: { label: "SUM", value: "SUM" }, - avg: { label: "AVG", value: "AVG" }, - hist: { label: "Histogram Plot 1D", value: 'histoPlot' } + fft: { label: "FFT (Magnitude^2)", value: "FFT" }, // The label and value for the FFT function option + dft: { label: "DFT (Magnitude^2)", value: "DFT" }, // The label and value for the DFT function option + sum: { label: "SUM", value: "SUM" }, // The label and value for the SUM function option + avg: { label: "AVG", value: "AVG" }, // The label and value for the AVG function option + hist: { label: "Histogram Plot 1D", value: 'histoPlot' } // The label and value for the Histogram Plot 1D function option }, + /** + * Creates a combo box for selecting the function type. + * @param {String} defaultSelection The default selected value for the combo box. + * @returns {Ext.form.field.ComboBox} The created combo box. + */ createFunctionComboBox: function (defaultSelection) { const self = this; const comboStore = Ext.create('Ext.data.Store', { @@ -48,6 +53,11 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', { return combo; }, + /** + * Creates a combo box for selecting the scale type for an axis. + * @param {Object} axis An object with a label and a value for the axis. + * @returns {Ext.form.field.ComboBox} The created combo box. + */ createAxisComboBox: function (axis) { const comboStore = Ext.create('Ext.data.Store', { fields: ['label', 'value'], @@ -69,6 +79,10 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', { }, + /** + * Handles the change of function type by removing the current module and adding a new one based on the selected value. + * @param {String} value The selected value from the function combo box. + */ handleFunction: function (value) { if (this.currentModule) { this.view.remove(this.currentModule, true); @@ -93,6 +107,9 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', { }, + /** + * Initializes the component by creating a field set with a function combo box and two axis combo boxes. + */ initComponent: function () { this.view = Ext.create('Ext.form.FieldSet', { collapsible: false, @@ -113,25 +130,21 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', { }, /** - * Retournes les valeurs des comboboxes associées à ce composant - * @returns les valeurs des comboboxes se forme d'un dictionnaire + * Returns the values of the combo boxes associated with this component. + * @returns {Object} An object with properties set to the values of the combo boxes. */ getValues: function () { - const xAxisScale = this.getForm().findField(this.x_axis.value).getValue(); - const yAxisScale = this.getForm().findField(this.y_axis.value).getValue(); - const functionType = this.getForm().findField(this.functionComboBox).getValue(); - let out = {}; - out[this.functionComboBox] = functionType; - out[this.x_axis.value] = xAxisScale; - out[this.y_axis.value] = yAxisScale; - + let out = { + [this.functionComboBox]: this.getForm().findField(this.functionComboBox).getValue(), + [this.x_axis.value]: this.getForm().findField(this.x_axis.value).getValue(), + [this.y_axis.value]: this.getForm().findField(this.y_axis.value).getValue() + }; if (this.currentModule) { - const values = this.currentModule.getValues(); - // Adding values to out - Object.assign(out, values); + Object.assign(out, this.currentModule.getValues()); } return out; } -}); \ No newline at end of file +}); + -- libgit2 0.21.2