diff --git a/js/app/views/PlotComponents/PlotPreviewUI.js b/js/app/views/PlotComponents/PlotPreviewUI.js index 209d36f..38b0659 100644 --- a/js/app/views/PlotComponents/PlotPreviewUI.js +++ b/js/app/views/PlotComponents/PlotPreviewUI.js @@ -13,49 +13,50 @@ */ Ext.define('amdaPlotComp.PlotPreviewUI', { - extend: 'Ext.panel.Panel', - - alias: 'widget.plotPreview', + extend: 'Ext.panel.Panel', - requires: [ - 'amdaPlotComp.PlotContextManager', - 'amdaPlotComp.PlotResultImage', + alias: 'widget.plotPreview', + + requires: [ + 'amdaPlotComp.PlotContextManager', + 'amdaPlotComp.PlotResultImage', 'amdaUI.PlotTabResultUI' - ], - - panelImage : null, - crtContext : null, - sliderPage : null, - contextualMenu : null, - hiddenForm: null, - panelResultInstance:null, + ], + + isPlotFunction: false, + panelImage: null, + crtContext: null, + sliderPage: null, + contextualMenu: null, + hiddenForm: null, + panelResultInstance: null, - setPanelResultInstance: function(panelResultInstance_) - { + setPanelResultInstance: function (panelResultInstance_) { this.panelResultInstance = panelResultInstance_; }, - constructor: function(config) { - this.init(config); - this.callParent(arguments); - }, - - getImageSize : function() { - if (!this.crtContext) - return { - width : 0, - height : 0 - }; - - return { - width : this.crtContext.page.width * this.sliderPage.getValue()/100., - height : this.crtContext.page.height * this.sliderPage.getValue()/100. - } - }, - - getImageUrl: function(resultFolder, plotFile) { - return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile; - }, - + + constructor: function (config) { + this.init(config); + this.callParent(arguments); + }, + + getImageSize: function () { + if (!this.crtContext) + return { + width: 0, + height: 0 + }; + + return { + width: this.crtContext.page.width * this.sliderPage.getValue() / 100., + height: this.crtContext.page.height * this.sliderPage.getValue() / 100. + } + }, + + getImageUrl: function (resultFolder, plotFile) { + return 'data/' + sessionID + '/RES/' + resultFolder + '/' + plotFile; + }, + toPixelOnSourceImage: function (value) { return value * 100 / this.sliderPage.getValue(); }, @@ -68,13 +69,13 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { return parseFloat(val).toPrecision(5); }, - createPlotImage: function(resultFolder, plotFile) { - var me = this; - var size = this.getImageSize(); - this.panelImage = Ext.create('amdaPlotComp.PlotResultImage', { - src : this.getImageUrl(resultFolder, plotFile), - width : size.width, - height : size.height, + createPlotImage: function (resultFolder, plotFile) { + var me = this; + var size = this.getImageSize(); + this.panelImage = Ext.create('amdaPlotComp.PlotResultImage', { + src: this.getImageUrl(resultFolder, plotFile), + width: size.width, + height: size.height, onMouseMove: function (x, y) { if (!me.crtContext) return; @@ -131,70 +132,70 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { } me.coordinatesField.setText(text); }, - onContextMenu : function(absoluteX, absoluteY, imageX, imageY) { - me.contextualMenu.showAt(absoluteX, absoluteY); - } - }); + onContextMenu: function (absoluteX, absoluteY, imageX, imageY) { + me.contextualMenu.showAt(absoluteX, absoluteY); + } + }); - return this.panelImage; - }, - - updatePlotImage: function(configResult, newPlot) { - this.crtContext = configResult.context; + return this.panelImage; + }, + + updatePlotImage: function (configResult, newPlot) { + this.crtContext = configResult.context; - this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile)); + this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile)); var newTime = new Date(configResult.time); newTime = Ext.Date.add(newTime, Ext.Date.MINUTE, newTime.getTimezoneOffset()); Ext.getCmp('plotPreview-goto-Date' + configResult.interactiveId).setValue(newTime); - var size = this.getImageSize(); - this.panelImage.setSize(size.width, size.height); - - this.panelImage.refreshMe(); - }, - - init: function(configResult){ - var me = this; + var size = this.getImageSize(); + this.panelImage.setSize(size.width, size.height); + + this.panelImage.refreshMe(); + }, + + init: function (configResult) { + var me = this; - this.crtContext = configResult.context; - this.interactiveId = configResult.interactiveId; + this.crtContext = configResult.context; + this.interactiveId = configResult.interactiveId; this.time = new Date(configResult.time); this.time = Ext.Date.add(this.time, Ext.Date.MINUTE, this.time.getTimezoneOffset()); - this.panelId= configResult.panelId - + this.panelId = configResult.panelId; + this.isPlotFunction = configResult.plotFile.includes("plotFunction"); + this.coordinatesField = new Ext.toolbar.TextItem({ width: 300, text: '' }); - this.sliderPage = new Ext.slider.Single({ - width: 130, - value: 75, - increment: 5, - minValue: 50, - maxValue: 100, - fieldLabel : 'Resize', - labelWidth : 40, - listeners: { - scope : this, - changecomplete: function(s, v) - { - var size = this.getImageSize(); - this.panelImage.width = size.width; - this.panelImage.height = size.height; - this.panelImage.doComponentLayout(); - } - } - }); - var topToolbar= + this.sliderPage = new Ext.slider.Single({ + width: 130, + value: 75, + increment: 5, + minValue: 50, + maxValue: 100, + fieldLabel: 'Resize', + labelWidth: 40, + listeners: { + scope: this, + changecomplete: function (s, v) { + var size = this.getImageSize(); + this.panelImage.width = size.width; + this.panelImage.height = size.height; + this.panelImage.doComponentLayout(); + } + } + }); + var topToolbar = { - xtype:'toolbar', - dock:'top', - items:[{ + xtype: 'toolbar', + dock: 'top', + items: [{ xtype: 'datefield', - allowBlank:true, + allowBlank: true, format: 'Y-m-d\\TH:i:s.u', id: 'plotPreview-goto-Date' + this.interactiveId, - value:this.time, + value: this.time, width: 175, renderer: function (value) { if (value != null) { @@ -208,33 +209,33 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { } } - },'-', - { - text: 'Change cut time', - scope: this, - handler: function (bt) { - var newTime = Ext.getCmp('plotPreview-goto-Date' + me.interactiveId).getValue(); - newTime = Ext.Date.add(newTime, Ext.Date.MINUTE, -newTime.getTimezoneOffset()); - me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString()}); - } - }, + }, '-', + { + text: 'Change cut time', + scope: this, + handler: function (bt) { + var newTime = Ext.getCmp('plotPreview-goto-Date' + me.interactiveId).getValue(); + newTime = Ext.Date.add(newTime, Ext.Date.MINUTE, -newTime.getTimezoneOffset()); + me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() }); + } + }, '-', - { - xtype:'button', - text : 'Previous', - handler: function(){ - var newTime = new Date(amdaPlotComp.PlotContextManager.getInstantTimePrev(me.crtContext)*1000); - me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString()}); - } - }, - { - xtype:'button', - text : 'Next', - handler: function(){ - var newTime = new Date(amdaPlotComp.PlotContextManager.getInstantTimeNext(me.crtContext) *1000); - me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString()}); - } + { + xtype: 'button', + text: 'Previous', + handler: function () { + var newTime = new Date(amdaPlotComp.PlotContextManager.getInstantTimePrev(me.crtContext) * 1000); + me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() }); + } + }, + { + xtype: 'button', + text: 'Next', + handler: function () { + var newTime = new Date(amdaPlotComp.PlotContextManager.getInstantTimeNext(me.crtContext) * 1000); + me.panelResultInstance.callInteractivePlot({ 'action': 'instant', 'interactiveId': me.panelResultInstance.interactiveId, 'panelId': me.panelId, 'time': newTime.toISOString() }); } + } ] } var mouseToolbar = { @@ -248,50 +249,49 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { ] }; - this.contextualMenu = Ext.create('Ext.menu.Menu', { - width: 200, - plain: true, - items: [ - { - text: 'Save Plot', - handler : function () + this.contextualMenu = Ext.create('Ext.menu.Menu', { + width: 200, + plain: true, + items: [ { - if (me.hiddenForm == null) - me.hiddenForm = Ext.create('Ext.form.Panel', { - title:'hiddenForm', - renderTo: Ext.getBody(), - standardSubmit: true, - url: 'php/downloadPlot.php', - timeout: 120000, - height:100, - width: 100, - hidden:true, - items:[] - }); + text: 'Save Plot', + handler: function () { + if (me.hiddenForm == null) + me.hiddenForm = Ext.create('Ext.form.Panel', { + title: 'hiddenForm', + renderTo: Ext.getBody(), + standardSubmit: true, + url: 'php/downloadPlot.php', + timeout: 120000, + height: 100, + width: 100, + hidden: true, + items: [] + }); - me.hiddenForm.getForm().submit({ - params: { - sessionId: sessionID, - interactiveId : me.interactiveId, - preview: true - }, - success: function(form, action) {}, - failure: function(form, action) {} - }); + me.hiddenForm.getForm().submit({ + params: { + sessionId: sessionID, + interactiveId: me.interactiveId, + preview: true + }, + success: function (form, action) { }, + failure: function (form, action) { } + }); + } } - } - ] - }); - - var plotPreviewPanelConfig = { - preventHeader : true, - autoScroll: false, - items: [ - this.createPlotImage(configResult.folder, configResult.plotFile) - ], - dockedItems: [topToolbar,mouseToolbar] - }; - - Ext.apply(this , plotPreviewPanelConfig); - } + ] + }); + + var plotPreviewPanelConfig = { + preventHeader: true, + autoScroll: false, + items: [ + this.createPlotImage(configResult.folder, configResult.plotFile) + ], + dockedItems: me.isPlotFunction ? [mouseToolbar] : [topToolbar, mouseToolbar] + }; + + Ext.apply(this, plotPreviewPanelConfig); + } }); -- libgit2 0.21.2