Commit a81112fb761cf41eabec452eeba8414548cf748d
1 parent
2cd12bf9
Exists in
master
and in
56 other branches
#9980 - Coordinates are now showed in a 'preview plot'
Showing
1 changed file
with
84 additions
and
10 deletions
Show diff stats
js/app/views/PlotComponents/PlotPreviewUI.js
@@ -50,6 +50,18 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | @@ -50,6 +50,18 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | ||
50 | return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile; | 50 | return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile; |
51 | }, | 51 | }, |
52 | 52 | ||
53 | + toPixelOnSourceImage: function (value) { | ||
54 | + return value * 100 / this.sliderPage.getValue(); | ||
55 | + }, | ||
56 | + | ||
57 | + toPixelOnResultImage: function (value) { | ||
58 | + return value * this.sliderPage.getValue() / 100; | ||
59 | + }, | ||
60 | + getAxisValue: function (axis, pixelMin, pixelMax, pixelVal) { | ||
61 | + var val = amdaPlotComp.PlotContextManager.toAxisValue(axis, pixelMin, pixelMax, pixelVal); | ||
62 | + return parseFloat(val).toPrecision(5); | ||
63 | + }, | ||
64 | + | ||
53 | createPlotImage: function(resultFolder, plotFile) { | 65 | createPlotImage: function(resultFolder, plotFile) { |
54 | var me = this; | 66 | var me = this; |
55 | var size = this.getImageSize(); | 67 | var size = this.getImageSize(); |
@@ -57,6 +69,62 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | @@ -57,6 +69,62 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | ||
57 | src : this.getImageUrl(resultFolder, plotFile), | 69 | src : this.getImageUrl(resultFolder, plotFile), |
58 | width : size.width, | 70 | width : size.width, |
59 | height : size.height, | 71 | height : size.height, |
72 | + onMouseMove: function (x, y) { | ||
73 | + if (!me.crtContext) | ||
74 | + return; | ||
75 | + | ||
76 | + var sourceXPos = me.toPixelOnSourceImage(x); | ||
77 | + var sourceYPos = me.toPixelOnSourceImage(y); | ||
78 | + var panel = amdaPlotComp.PlotContextManager.getPanel(me.crtContext, sourceXPos, sourceYPos); | ||
79 | + | ||
80 | + var text = ''; | ||
81 | + if (me.panelImage) { | ||
82 | + if (!panel) { | ||
83 | + me.panelImage.resetCursor(); | ||
84 | + text += 'No panel'; | ||
85 | + } | ||
86 | + else { | ||
87 | + text += 'Panel Id : '; | ||
88 | + text += panel.id; | ||
89 | + if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos)) { | ||
90 | + /*me.panelImage.updateCursor( | ||
91 | + me.toPixelOnResultImage(panel.plotArea.x), | ||
92 | + me.toPixelOnResultImage(panel.plotArea.y), | ||
93 | + me.toPixelOnResultImage(panel.plotArea.width), | ||
94 | + me.toPixelOnResultImage(panel.plotArea.height), | ||
95 | + x, y);*/ | ||
96 | + me.panelImage.updateCursor( | ||
97 | + me.toPixelOnResultImage(0), | ||
98 | + me.toPixelOnResultImage(0), | ||
99 | + me.toPixelOnResultImage(me.crtContext.page.width), | ||
100 | + me.toPixelOnResultImage(me.crtContext.page.height), | ||
101 | + x, y); | ||
102 | + | ||
103 | + var xText = ''; | ||
104 | + var yLeftText = ''; | ||
105 | + Ext.each(panel.plotArea.axes, function (axis) { | ||
106 | + switch (axis.id) { | ||
107 | + case 'y-left': | ||
108 | + yLeftText = me.getAxisValue(axis, panel.plotArea.y + panel.plotArea.height, panel.plotArea.y, sourceYPos); | ||
109 | + break; | ||
110 | + case 'xaxis_id': | ||
111 | + xText = me.getAxisValue(axis, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos); | ||
112 | + break; | ||
113 | + } | ||
114 | + | ||
115 | + }); | ||
116 | + | ||
117 | + if (xText != '') | ||
118 | + text += (', X : ' + xText); | ||
119 | + if (yLeftText != '') | ||
120 | + text += (', Y : ' + yLeftText); | ||
121 | + } | ||
122 | + else | ||
123 | + me.panelImage.resetCursor(); | ||
124 | + } | ||
125 | + } | ||
126 | + me.coordinatesField.setText(text); | ||
127 | + }, | ||
60 | onContextMenu : function(absoluteX, absoluteY, imageX, imageY) { | 128 | onContextMenu : function(absoluteX, absoluteY, imageX, imageY) { |
61 | me.contextualMenu.showAt(absoluteX, absoluteY); | 129 | me.contextualMenu.showAt(absoluteX, absoluteY); |
62 | } | 130 | } |
@@ -82,6 +150,11 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | @@ -82,6 +150,11 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | ||
82 | this.crtContext = configResult.context; | 150 | this.crtContext = configResult.context; |
83 | this.interactiveId = configResult.interactiveId; | 151 | this.interactiveId = configResult.interactiveId; |
84 | 152 | ||
153 | + this.coordinatesField = new Ext.toolbar.TextItem({ | ||
154 | + width: 300, | ||
155 | + text: '' | ||
156 | + }); | ||
157 | + | ||
85 | this.sliderPage = new Ext.slider.Single({ | 158 | this.sliderPage = new Ext.slider.Single({ |
86 | width: 130, | 159 | width: 130, |
87 | value: 75, | 160 | value: 75, |
@@ -102,15 +175,16 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | @@ -102,15 +175,16 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | ||
102 | } | 175 | } |
103 | }); | 176 | }); |
104 | 177 | ||
105 | - var bottomToolbar = { | ||
106 | - xtype: 'toolbar', | ||
107 | - height: 25, | ||
108 | - dock: 'bottom', | ||
109 | - items:[ | ||
110 | - '->', | ||
111 | - this.sliderPage | ||
112 | - ] | ||
113 | - }; | 178 | + var mouseToolbar = { |
179 | + xtype: 'toolbar', | ||
180 | + height: 25, | ||
181 | + dock: 'bottom', | ||
182 | + items: [ | ||
183 | + this.coordinatesField, | ||
184 | + '->', | ||
185 | + this.sliderPage | ||
186 | + ] | ||
187 | + }; | ||
114 | 188 | ||
115 | this.contextualMenu = Ext.create('Ext.menu.Menu', { | 189 | this.contextualMenu = Ext.create('Ext.menu.Menu', { |
116 | width: 200, | 190 | width: 200, |
@@ -153,7 +227,7 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | @@ -153,7 +227,7 @@ Ext.define('amdaPlotComp.PlotPreviewUI', { | ||
153 | items: [ | 227 | items: [ |
154 | this.createPlotImage(configResult.folder, configResult.plotFile) | 228 | this.createPlotImage(configResult.folder, configResult.plotFile) |
155 | ], | 229 | ], |
156 | - dockedItems: [bottomToolbar] | 230 | + dockedItems: [mouseToolbar] |
157 | }; | 231 | }; |
158 | 232 | ||
159 | Ext.apply(this , plotPreviewPanelConfig); | 233 | Ext.apply(this , plotPreviewPanelConfig); |