From: jh777916 Date: Wed, 25 Oct 2023 13:07:02 +0000 (+0200) Subject: new feature : QStatusBar added to the PlotWidget.ui, containing the hovered X,Y coord... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b7fb1aac27f441be5947bb8b2157b63fe055db29;p=modules%2Fgui.git new feature : QStatusBar added to the PlotWidget.ui, containing the hovered X,Y coordinates in the canvas --- diff --git a/tools/CurvePlot/src/python/ui/PlotWidget.py b/tools/CurvePlot/src/python/ui/PlotWidget.py index 2e3eea5f1..fd5c29fe9 100644 --- a/tools/CurvePlot/src/python/ui/PlotWidget.py +++ b/tools/CurvePlot/src/python/ui/PlotWidget.py @@ -32,4 +32,5 @@ class PlotWidget(QtWidgets.QMainWindow): So clean up manually. """ self.toolBar = None + self.statusBar = None self.setCentralWidget(None) diff --git a/tools/CurvePlot/src/python/ui/PlotWidget.ui b/tools/CurvePlot/src/python/ui/PlotWidget.ui index d4bbfe16c..2a60ed391 100644 --- a/tools/CurvePlot/src/python/ui/PlotWidget.ui +++ b/tools/CurvePlot/src/python/ui/PlotWidget.ui @@ -25,6 +25,12 @@ false + + + statusBar + + + diff --git a/tools/CurvePlot/src/python/views/XYView.py b/tools/CurvePlot/src/python/views/XYView.py index 6b0bdedf2..bb8083192 100644 --- a/tools/CurvePlot/src/python/views/XYView.py +++ b/tools/CurvePlot/src/python/views/XYView.py @@ -86,6 +86,7 @@ class XYView(View): self._plotWidget = None self._sgPyQt = self._controller._sgPyQt self._toolbar = None + self._statusbar = None self._mplNavigationActions = {} self._toobarMPL = None self._grid = None @@ -189,6 +190,19 @@ class XYView(View): self._lastMarkerID = -1 self.update() + def onMove(self,event): + """ get the x and y pixel coords """ + + fmtXcoord = ".4f" + fmtYcoord = ".4f" + + if self._axisXSciNotation : fmtXcoord = ".4e" + if self._axisYSciNotation : fmtYcoord = ".4e" + + if event.inaxes: + self._statusbar.showMessage( + f"x, y = {event.xdata:{fmtXcoord}}, {event.ydata:{fmtYcoord}}") + def onPick(self, event): """ MPL callback when picking """ @@ -271,6 +285,7 @@ class XYView(View): self._mplNavigationActions[actionName] = act self._plotWidget.setCentralWidget(self._mplCanvas) self._toolbar = self._plotWidget.toolBar + self._statusbar = self._plotWidget.statusBar self.populateToolbar() self._popupMenu = QtWidgets.QMenu() @@ -287,6 +302,8 @@ class XYView(View): self._mplCanvas.customContextMenuRequested.connect(self.onContextMenu) self._mplCanvas.mpl_connect('scroll_event', self.onScroll) self._mplCanvas.mpl_connect('button_press_event', self.onMousePress) + self._mplCanvas.mpl_connect('motion_notify_event', self.onMove) + def populateToolbar(self): # Action to dump view in a file