ZoomIntervalSelection.js 1.9 KB
Ext.define('amdaPlotComp.intervalSelection.ZoomIntervalSelection', {
    extend: 'amdaPlotComp.intervalSelection.IntervalSelection', // This class extends from amdaPlotComp.intervalSelection.IntervalSelection

    buttonApply: "Apply Zoom",
    type: null,

    /**
     * Initializes the component.
     * Adds an 'Undo Zoom' button to the bottom toolbar of the form.
     */
    initComponent: function () {
        const self = this;
        this.callParent(arguments);
        this.form.getDockedItems('toolbar[dock="bottom"]')[0].add({
            xtype: 'button',
            width: width,
            text: 'Undo Zoom',
            handler: function () {
                self._undoZoom();
            }
        });
    },

    /**
     * Applies the zoom based on the values of the fields.
     * If the values are not valid, it shows a warning message.
     * Otherwise, it calls the interactive plot with the zoom action and resets the host component selection.
     */
    _apply: function () {
        if (this._notValidValues()) {
            myDesktopApp.warningMsg('The Input Values are not defined');
        } else {
            this.hostCmp.callInteractivePlot({
                'action': 'zoom',
                'interactiveId': this.interactiveId,
                'panelId': this.panelId,
                'axeId': this.type,
                'min': this.getField1Value(),
                'max': this.getField2Value()
            });

            this._resetHostCmpSelection();
        }
    },

    /**
     * Undoes the zoom.
     * It calls the interactive plot with the undozoom action and resets the host component selection.
     */
    _undoZoom: function () {
        this.hostCmp.callInteractivePlot({
            'action': 'undozoom',
            'interactiveId': this.interactiveId,
            'panelId': this.panelId,
            'axeId': this.type
        });

        this._resetHostCmpSelection();
    }

});