From a81112fb761cf41eabec452eeba8414548cf748d Mon Sep 17 00:00:00 2001 From: Erdogan Furkan Date: Mon, 1 Aug 2022 08:02:59 +0000 Subject: [PATCH] #9980 - Coordinates are now showed in a 'preview plot' --- js/app/views/PlotComponents/PlotPreviewUI.js | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 84 insertions(+), 10 deletions(-) diff --git a/js/app/views/PlotComponents/PlotPreviewUI.js b/js/app/views/PlotComponents/PlotPreviewUI.js index eaf5b60..bf40b14 100644 --- a/js/app/views/PlotComponents/PlotPreviewUI.js +++ b/js/app/views/PlotComponents/PlotPreviewUI.js @@ -50,6 +50,18 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile; }, + toPixelOnSourceImage: function (value) { + return value * 100 / this.sliderPage.getValue(); + }, + + toPixelOnResultImage: function (value) { + return value * this.sliderPage.getValue() / 100; + }, + getAxisValue: function (axis, pixelMin, pixelMax, pixelVal) { + var val = amdaPlotComp.PlotContextManager.toAxisValue(axis, pixelMin, pixelMax, pixelVal); + return parseFloat(val).toPrecision(5); + }, + createPlotImage: function(resultFolder, plotFile) { var me = this; var size = this.getImageSize(); @@ -57,6 +69,62 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { src : this.getImageUrl(resultFolder, plotFile), width : size.width, height : size.height, + onMouseMove: function (x, y) { + if (!me.crtContext) + return; + + var sourceXPos = me.toPixelOnSourceImage(x); + var sourceYPos = me.toPixelOnSourceImage(y); + var panel = amdaPlotComp.PlotContextManager.getPanel(me.crtContext, sourceXPos, sourceYPos); + + var text = ''; + if (me.panelImage) { + if (!panel) { + me.panelImage.resetCursor(); + text += 'No panel'; + } + else { + text += 'Panel Id : '; + text += panel.id; + if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos)) { + /*me.panelImage.updateCursor( + me.toPixelOnResultImage(panel.plotArea.x), + me.toPixelOnResultImage(panel.plotArea.y), + me.toPixelOnResultImage(panel.plotArea.width), + me.toPixelOnResultImage(panel.plotArea.height), + x, y);*/ + me.panelImage.updateCursor( + me.toPixelOnResultImage(0), + me.toPixelOnResultImage(0), + me.toPixelOnResultImage(me.crtContext.page.width), + me.toPixelOnResultImage(me.crtContext.page.height), + x, y); + + var xText = ''; + var yLeftText = ''; + Ext.each(panel.plotArea.axes, function (axis) { + switch (axis.id) { + case 'y-left': + yLeftText = me.getAxisValue(axis, panel.plotArea.y + panel.plotArea.height, panel.plotArea.y, sourceYPos); + break; + case 'xaxis_id': + xText = me.getAxisValue(axis, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos); + break; + } + + }); + + if (xText != '') + text += (', X : ' + xText); + if (yLeftText != '') + text += (', Y : ' + yLeftText); + } + else + me.panelImage.resetCursor(); + } + } + me.coordinatesField.setText(text); + }, onContextMenu : function(absoluteX, absoluteY, imageX, imageY) { me.contextualMenu.showAt(absoluteX, absoluteY); } @@ -82,6 +150,11 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { this.crtContext = configResult.context; this.interactiveId = configResult.interactiveId; + this.coordinatesField = new Ext.toolbar.TextItem({ + width: 300, + text: '' + }); + this.sliderPage = new Ext.slider.Single({ width: 130, value: 75, @@ -102,15 +175,16 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { } }); - var bottomToolbar = { - xtype: 'toolbar', - height: 25, - dock: 'bottom', - items:[ - '->', - this.sliderPage - ] - }; + var mouseToolbar = { + xtype: 'toolbar', + height: 25, + dock: 'bottom', + items: [ + this.coordinatesField, + '->', + this.sliderPage + ] + }; this.contextualMenu = Ext.create('Ext.menu.Menu', { width: 200, @@ -153,7 +227,7 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { items: [ this.createPlotImage(configResult.folder, configResult.plotFile) ], - dockedItems: [bottomToolbar] + dockedItems: [mouseToolbar] }; Ext.apply(this , plotPreviewPanelConfig); -- libgit2 0.21.2