]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
new feature : QStatusBar added to the PlotWidget.ui, containing the hovered X,Y coord...
authorjh777916 <juba.hamma@cea.fr>
Wed, 25 Oct 2023 13:07:02 +0000 (15:07 +0200)
committerjh777916 <juba.hamma@cea.fr>
Wed, 25 Oct 2023 13:34:15 +0000 (15:34 +0200)
tools/CurvePlot/src/python/ui/PlotWidget.py
tools/CurvePlot/src/python/ui/PlotWidget.ui
tools/CurvePlot/src/python/views/XYView.py

index 2e3eea5f134a18633cbf067f29570dc0befb8ef7..fd5c29fe9aa7a379d2d4d56f40657c5345d57e09 100644 (file)
@@ -32,4 +32,5 @@ class PlotWidget(QtWidgets.QMainWindow):
     So clean up manually. 
     """
     self.toolBar = None
+    self.statusBar = None
     self.setCentralWidget(None)
index d4bbfe16c35be3784449d06fa6928a48b6f86b51..2a60ed3910b0acdec4f392b59fc77dda243a959b 100644 (file)
     <bool>false</bool>
    </attribute>
   </widget>
+  <widget class="QStatusBar" name="statusBar">
+   <property name="windowTitle">
+    <string>statusBar</string>
+   </property>
+  </widget>
+
  </widget>
  <resources/>
  <connections/>
index 6b0bdedf29061589dce8f39dc8247d33e1616379..bb8083192f340c3906ffb3ea64085422f64e042a 100644 (file)
@@ -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