Fix ViewBox axis zoom in RectMode and examples/customPlot.py (#1443)
* Fix examples/customPlot.py: mouseDragEvent misses axis argument Fixes #1277 * customPlot.py: Update methodolgy to disable menu If there's an argument for this, we should use it * customPlot.py: Show how to disable axis interaction * Fix ViewBox: Moving axis in RectMode not implemented => use normal move mode Grabbing an axis in RectMode leads to the zoom rectangle being displayed in unreasonable positions. In this case, fall back to normal mode. * customPlot.py: Only disable right-click zoom for demonstration In cases where continuous zooming is not wished (e.g. in case of complicated rebinning after zooming), this might come in handy and there is no reason not to show it. Co-authored-by: 2xB <2xB@users.noreply.github.com>
This commit is contained in:
parent
75048c473b
commit
c359d5fad9
@ -14,6 +14,7 @@ import time
|
||||
|
||||
class CustomViewBox(pg.ViewBox):
|
||||
def __init__(self, *args, **kwds):
|
||||
kwds['enableMenu'] = False
|
||||
pg.ViewBox.__init__(self, *args, **kwds)
|
||||
self.setMouseMode(self.RectMode)
|
||||
|
||||
@ -22,11 +23,12 @@ class CustomViewBox(pg.ViewBox):
|
||||
if ev.button() == QtCore.Qt.RightButton:
|
||||
self.autoRange()
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.RightButton:
|
||||
## reimplement mouseDragEvent to disable continuous axis zoom
|
||||
def mouseDragEvent(self, ev, axis=None):
|
||||
if axis is not None and ev.button() == QtCore.Qt.RightButton:
|
||||
ev.ignore()
|
||||
else:
|
||||
pg.ViewBox.mouseDragEvent(self, ev)
|
||||
pg.ViewBox.mouseDragEvent(self, ev, axis=axis)
|
||||
|
||||
|
||||
app = pg.mkQApp()
|
||||
|
@ -1267,7 +1267,7 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
## Scale or translate based on mouse button
|
||||
if ev.button() & (QtCore.Qt.LeftButton | QtCore.Qt.MidButton):
|
||||
if self.state['mouseMode'] == ViewBox.RectMode:
|
||||
if self.state['mouseMode'] == ViewBox.RectMode and axis is None:
|
||||
if ev.isFinish(): ## This is the final move in the drag; change the view scale now
|
||||
#print "finish"
|
||||
self.rbScaleBox.hide()
|
||||
|
Loading…
Reference in New Issue
Block a user