/** * Project  : AMDA-NG * Name : PlotZoomPlug.js * @plugin amdaPlotComp.PlotZoomPlug * @extends Ext.util.Observable * @ptype plotZoomPlugin * @brief Plot Zoom UI (View) * @author Benjamin * @version $Id: PlotZoomPlug.js ******************************************************************************** * FT Id : Date : Name - Description ******************************************************************************* */ // Define a new class 'amdaPlotComp.PlotZoomPlug' that extends 'Ext.util.Observable' Ext.define('amdaPlotComp.PlotZoomPlug', { extend: 'Ext.util.Observable', alias: 'plugin.plotZoomPlugin', requires: ['amdaPlotComp.intervalSelection.IntervalSelection'], // Declare a variable to hold the interval selection component intervalSelectionCmp: null, // Constructor function for the class constructor: function (config) { // Apply the configuration to this instance and call the parent class's constructor Ext.apply(this, config); this.callParent(arguments); }, // Function to be called when the object is destroyed onDestroy: function () { // Set the interval selection component to null this.intervalSelectionCmp = null; }, // Initialization function for the class init: function (cmp) { // Set the host component for this instance this.hostCmp = cmp; }, // Function to set the minimum value of the interval selection component setMinValue: function (min) { if (!this.intervalSelectionCmp) return; this.intervalSelectionCmp.setField1Value(min); }, // Function to set the maximum value of the interval selection component setMaxValue: function (max) { if (!this.intervalSelectionCmp) return; this.intervalSelectionCmp.setField2Value(max); }, /** * Function to create and show a window with specific configuration */ show: function (interactiveId, zoomType, panelId) { let config = { id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), interactiveId: interactiveId, panelId: panelId, hostCmp: this.hostCmp, renderTo: this.hostCmp.ownerCt.body, listeners: { scope: this, beforeclose: function () { this.hostCmp.panelImage.hidePanelMarker(); this.hostCmp.panelImage.stopZoom(); }, show: function (win, eOpts) { this.hostCmp.panelImage.showPanelMarker(panelId); } }, getConstrainVector: function (constrainTo) { const self = this; if (self.constrain || self.constrainHeader) { constrainTo = constrainTo || (self.floatParent && self.floatParent.getTargetEl()) || self.container || self.el.getScopeParent(); return (self.constrainHeader ? self.header.el : self.el).getConstrainVector(constrainTo); } } }; if (this.intervalSelectionCmp) { this.close() }; let intervalSelectionCmpType; switch (zoomType) { case 'timeAxis': intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.DateZoomIntervalSelection'; break; case 'y-left': case 'y-right': case 'xaxis_id': intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.NumberZoomIntervalSelection'; let title = ""; if (zoomType === 'y-left') { title = 'Zoom on Y Left axis'; } else if (zoomType === 'y-right') { title = 'Zoom on Y Right axis'; } else { title = 'Zoom on X axis'; } config["type"] = zoomType; config["title"] = title; break; case 'plotFunction': intervalSelectionCmpType = 'amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection'; break; } // Create a new instance of the interval selection component with the specified type and configuration this.intervalSelectionCmp = Ext.create(intervalSelectionCmpType, config); // Add a listener for the destroy event of the interval selection component this.intervalSelectionCmp.on('destroy', this.onDestroy, this); // Show the interval selection component this.intervalSelectionCmp.show(); }, // Function to close the interval selection component close: function () { if (this.intervalSelectionCmp == null) return; this.intervalSelectionCmp.close(); }, // Function to reset the minimum and maximum values of the interval selection component resetMinMaxValue: function () { this.intervalSelectionCmp.reset(); } });