diff --git a/js/app/views/PlotComponents/PlotZoomPlug.js b/js/app/views/PlotComponents/PlotZoomPlug.js index a327cad..fdd57bf 100644 --- a/js/app/views/PlotComponents/PlotZoomPlug.js +++ b/js/app/views/PlotComponents/PlotZoomPlug.js @@ -13,33 +13,14 @@ * : */ - Ext.define('amdaPlotComp.PlotZoomPlug', { extend: 'Ext.util.Observable', alias: 'plugin.plotZoomPlugin', - requires: ['amdaPlotComp.intervalSelection.IntervalSelection', 'amdaPlotComp.plotFunction.FunctionType'], - - //id: 'plot-zoom-plug', - - ttModuleId: 'timetab-win', - catModuleId: 'catalog-win', - + requires: ['amdaPlotComp.intervalSelection.IntervalSelection'], win: null, - form: null, zoomType: '', interactiveId: '', panelId: -1, - myChildWindow: null, - - linkedTTCatNode: null, - /** - * 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 - */ - plotFunctionParamField: null, - /** - * Un composant de 'PlotFunction' qui permet à l'utilisateur de séléctionner le type de fonction à appliquer : FFT, SUM, ... - */ - plotFunctionType: null, constructor: function (config) { Ext.apply(this, config); @@ -57,7 +38,6 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { setMinValue: function (min) { if (!this.win) return; - console.log(min); this.win.setField1Value(min); }, @@ -67,25 +47,6 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { this.win.setField2Value(max); }, - /** - * add Interval to Time table - **/ - insertInterval: function () { - if (this.zoomType != 'timeAxis') - return; - - var start = this.form.getForm().findField('zoom-min-time').getValue(); - var stop = this.form.getForm().findField('zoom-max-time').getValue(); - - var TTCatType = this.form.getForm().findField('ttcat-type').getValue(); - var isCatalog = (TTCatType == 'catalog'); - - myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { - var targetModuleUI = module.getUiContent(); - if (targetModuleUI) - targetModuleUI.addInterval(start, stop); - }); - }, /** * creation of the window @@ -96,7 +57,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { this.interactiveId = interactiveId; let config = { - id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID + id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), interactiveId: interactiveId, panelId: panelId, hostCmp: this.hostCmp, @@ -159,332 +120,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { this.win.close(); }, - updateWinByType: function (zoomType, panelId) { - if (this.win == null) - return; - - this.zoomType = zoomType; - this.panelId = panelId; - - switch (zoomType) { - case 'timeAxis': - if (this.isPlotFunction) { - const title = "Apply a Fct on Interval"; - this.win.setTitle(title + '-Panel Id: ' + panelId); - } else { - this.win.setTitle('Zoom on time axis & Interval selection - Panel Id : ' + panelId); - } - break; - case 'y-left': - this.win.setTitle('Zoom on Y Left axis - Panel Id : ' + panelId); - break; - case 'y-right': - this.win.setTitle('Zoom on Y Right axis - Panel Id : ' + panelId); - break; - case 'xaxis_id': - this.win.setTitle('Zoom on X axis - Panel Id : ' + panelId); - break; - } - - this.form.getForm().findField('zoom-min-time').setVisible(this.zoomType == 'timeAxis'); - this.form.getForm().findField('zoom-max-time').setVisible(this.zoomType == 'timeAxis'); - - this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis'); - this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis'); - - var ttCatNameField = this.form.getForm().findField('ttcat-name'); - if (ttCatNameField) - ttCatNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); - }, - resetMinMaxValue: function () { - /* - if (this.zoomType == 'timeAxis') { - this.form.getForm().findField('zoom-min-time').setValue(''); - this.form.getForm().findField('zoom-max-time').setValue(''); - } - else { - this.form.getForm().findField('zoom-min-float').setValue(null); - this.form.getForm().findField('zoom-max-float').setValue(null); - }*/ - - this.hostCmp.panelImage.resetZoom(); - }, - setTimePlot: function () { - var timeObj = new Object(); - timeObj.start = this.form.getForm().findField('zoom-min-time').getValue(); - timeObj.stop = this.form.getForm().findField('zoom-max-time').getValue(); - timeObj.interactiveId = this.interactiveId; - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); - plotModule.setTimeInterval(timeObj); - }, - /** - * Main form - */ - getFormConfig: function () { - var intervalFieldSet = { - xtype: 'fieldset', - title: 'Interval Selection', - name: 'interval-selection-fieldset', - collapsible: false, - layout: { - type: 'vbox', - pack: 'start', - align: 'stretch' - }, - items: [ - { - xtype: 'datefield', name: 'zoom-min-time', fieldLabel: 'Start Time', - format: 'Y/m/d H:i:s.u', - }, - { - xtype: 'datefield', name: 'zoom-max-time', fieldLabel: 'Stop Time', - format: 'Y/m/d H:i:s.u' - }, - { - xtype: 'numberfield', name: 'zoom-min-float', fieldLabel: 'Min Value' - }, - { - xtype: 'numberfield', name: 'zoom-max-float', fieldLabel: 'Max Value' - }, - { - xtype: 'button', - width: 100, - text: 'Reset', - scope: this, - handler: function () { - this.resetMinMaxValue(); - } - }, - { - xtype: 'button', - width: 100, - text: 'Use in Time Selection', - scope: this, - handler: function () { - this.setTimePlot(); - } - } - ] - }; - - var insertTypeStore = Ext.create('Ext.data.Store', { - fields: ['key', 'name'], - data: [ - { "key": "timeTable", "name": "TimeTable" }, - { "key": "catalog", "name": "Catalog" } - ] - }); - - var me = this; - this.insertTTFieldSet = { - xtype: 'fieldset', - title: 'Add in Time Table or Catalog', - name: 'tt-insertion-fieldset', - collapsible: false, - layout: { - type: 'vbox', - pack: 'start', - align: 'stretch' - }, - items: [ - { - xtype: 'combo', - fieldLabel: 'Insert In', - store: insertTypeStore, - queryMode: 'local', - displayField: 'name', - valueField: 'key', - editable: false, - value: 'timeTable', - name: 'ttcat-type' - }, - { - xtype: 'textfield', - fieldLabel: 'Name', - name: 'ttcat-name', - listeners: - { - render: function (o, op) { - var field = this; - var el = this.el; - var dropTarget = Ext.create('Ext.dd.DropTarget', el, { - ddGroup: 'explorerTree', - notifyOver: function (ddSource, e, data) { - var TTCatType = me.form.getForm().findField('ttcat-type').getValue(); - if (data.records[0].data.leaf && (data.records[0].data.nodeType == TTCatType)) { - this.valid = true; - return this.dropAllowed; - } - this.valid = false; - return this.dropNotAllowed; - }, - notifyDrop: function (ddSource, e, data) { - if (!this.valid) - return false; - field.setValue(data.records[0].get('text')); - return true; - } - }); - } - } - }, - { - xtype: 'button', - width: 100, - text: 'Insert Interval', - scope: this, - handler: function () { - var me = this; - - var TTCatType = this.form.getForm().findField('ttcat-type').getValue(); - var TTCatName = this.form.getForm().findField('ttcat-name').getValue(); - - var isCatalog = (TTCatType == 'catalog'); - myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { - var targetModuleUI = module.getUiContent(); - if (me.linkedTTCatNode && (me.linkedTTCatNode.get('text') == TTCatName) && (me.linkedTTCatNode.get('nodeType') == TTCatType)) { - if (targetModuleUI) - me.insertInterval(); - else { - me.linkedTTCatNode.editLeaf(function () { - me.insertInterval(); - }); - } - } - else { - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); - var ttCatRootNode = explorerTree.getRootNode().findChild('id', isCatalog ? 'catalog-treeRootNode' : 'timeTable-treeRootNode', true); - amdaModel.InteractiveNode.preloadNodes(ttCatRootNode, function () { - var nodeWithSameName = null; - - if (TTCatName != '') - nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true); - - if (nodeWithSameName !== null) - me.linkedTTCatNode = nodeWithSameName; - else { - module.createLinkedNode(); - module.getLinkedNode().set('text', TTCatName); - me.linkedTTCatNode = module.getLinkedNode(); - var obj = { - name: TTCatName, - fromPlugin: true - }; - if (isCatalog) { - Ext.Msg.prompt('Define Parameters', 'Please enter parameters number for the new catalog:', function (btn, text) { - if (btn == 'ok') { - obj.nbParameters = parseInt(text, 10); - if (isNaN(obj.nbParameters)) { - obj.nbParameters = 1; - } - module.createObject(obj); - me.linkedTTCatNode.editLeaf(function () { - me.insertInterval(); - }); - } - }); - return; - } - else { - module.createObject(obj); - } - } - - me.linkedTTCatNode.editLeaf(function () { - me.insertInterval(); - }); - }); - } - }); - } - } - ] - }; - - this.plotFunctionType = new amdaPlotComp.plotFunction.FunctionType({}); - - this.form = new Ext.form.FormPanel({ - frame: true, - width: 255, - layout: { - type: 'vbox', - pack: 'start', - align: 'stretch' - }, - fieldDefaults: { - labelWidth: 60 - }, - items: [ - intervalFieldSet, - this.isPlotFunction ? this.plotFunctionType : this.insertTTFieldSet - ], - fbar: [ - { - text: me.isPlotFunction ? "Apply The Function" : 'Apply Zoom', - width: me.isPlotFunction ? 200 : 100, - scope: this, - handler: function () { - if (this.zoomType == 'timeAxis') { - var minZoom = Ext.Date.format(this.form.getForm().findField('zoom-min-time').getValue(), 'Y-m-d\\TH:i:s.u'); - var maxZoom = Ext.Date.format(this.form.getForm().findField('zoom-max-time').getValue(), 'Y-m-d\\TH:i:s.u'); - } - else { - var minZoom = this.form.getForm().findField('zoom-min-float').getValue(); - var maxZoom = this.form.getForm().findField('zoom-max-float').getValue(); - } - - if (!maxZoom || !minZoom || !this.form.getForm().isValid()) { - myDesktopApp.warningMsg('Error in values definition'); - return; - } - - if (me.isPlotFunction) { - let request_to_send = {}; - - request_to_send = Object.assign({}, me.plotFunctionType.getValues()/*, me.plotFunctionParamField.getValues()*/); - request_to_send = Object.assign({}, request_to_send, { - 'action': 'plotFunction', - 'interactiveId': this.interactiveId, - 'panelId': this.panelId, - 'starttime': minZoom, - 'stoptime': maxZoom - }); - - this.hostCmp.callInteractivePlot(request_to_send); - } else { - this.hostCmp.callInteractivePlot({ - 'action': 'zoom', - 'interactiveId': this.interactiveId, - 'panelId': this.panelId, - 'axeId': this.zoomType, - 'min': minZoom, - 'max': maxZoom - }); - } - - this.hostCmp.panelImage.resetZoom(); - } - }, - me.isPlotFunction ? null : - { - text: 'Undo Zoom', - width: 100, - scope: this, - handler: function () { - this.hostCmp.callInteractivePlot({ - 'action': 'undozoom', - 'interactiveId': this.interactiveId, - 'panelId': this.panelId, - 'axeId': this.zoomType - }); - this.hostCmp.panelImage.resetZoom(); - } - } - ] - }); - - return this.form; - }, - + this.win.reset(); + } }); diff --git a/js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js b/js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js index 5d416e6..5e98d1c 100644 --- a/js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js +++ b/js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js @@ -10,6 +10,7 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { fieldTypeName: 'ttcat-name', ttModuleId: 'timetab-win', catModuleId: 'catalog-win', + linkedTTCatNode: null, parent: null, diff --git a/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js b/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js index 792d570..a610917 100644 --- a/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js +++ b/js/app/views/PlotComponents/intervalSelection/IntervalSelection.js @@ -86,9 +86,7 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { text: 'Reset', width: width, handler: function () { - me._getField1().reset(); - me._getField2().reset(); - me._resetHostCmpSelection(); + me.reset(); } }, { @@ -138,6 +136,20 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { return this.parent.down('#' + this.FIELD2_ITEM_ID); }, + _setTimeInterval: function () { + const timeObj = new Object(); + timeObj.start = this.getField1Value(); + timeObj.stop = this.getField2Value(); + timeObj.interactiveId = this.interactiveId; + const plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); + plotModule.setTimeInterval(timeObj); + }, + + _removeUseTimeButton: function () { + const buttonToHide = this.parent.down('#' + this.buttonUseTime); + buttonToHide.hide(); + }, + getField1Value: function () { return this._getField1().getValue(); }, @@ -154,17 +166,9 @@ Ext.define('amdaPlotComp.intervalSelection.IntervalSelection', { this._getField2().setValue(value); }, - _setTimeInterval: function () { - const timeObj = new Object(); - timeObj.start = this.getField1Value(); - timeObj.stop = this.getField2Value(); - timeObj.interactiveId = this.interactiveId; - const plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); - plotModule.setTimeInterval(timeObj); - }, - - _removeUseTimeButton: function () { - const buttonToHide = this.parent.down('#' + this.buttonUseTime); - buttonToHide.hide(); + reset: function () { + this._getField1().reset(); + this._getField2().reset(); + this._resetHostCmpSelection(); } }); -- libgit2 0.21.2