Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ViewBox: individual axis panning

- pan the plot along a certain axis by press&move of the left mouse button on a scale item
  • Loading branch information...
commit e17fdd8cccc0df9cc837cb67cb9048aa758f5e32 1 parent 0eef825
@ibressler authored
Showing with 15 additions and 3 deletions.
  1. +11 −0 graphicsItems/AxisItem.py
  2. +4 −3 graphicsItems/ViewBox.py
View
11 graphicsItems/AxisItem.py
@@ -398,3 +398,14 @@ def wheelEvent(self, ev):
else:
self.linkedView().wheelEvent(ev, axis=0)
ev.accept()
+
+ def mouseMoveEvent(self, ev):
+ if self.linkedView is None or self.linkedView() is None: return
+ if self.orientation in ['left', 'right']:
+ self.linkedView().mouseMoveEvent(ev, axis=1)
+ else:
+ self.linkedView().mouseMoveEvent(ev, axis=0)
+ ev.accept()
+
+ def mousePressEvent(self, ev):
+ self.linkedView().mousePressEvent(ev)
View
7 graphicsItems/ViewBox.py
@@ -249,15 +249,16 @@ def wheelEvent(self, ev, axis=None):
self.sigRangeChangedManually.emit(self.mouseEnabled)
ev.accept()
- def mouseMoveEvent(self, ev):
+ def mouseMoveEvent(self, ev, axis=None):
QtGui.QGraphicsWidget.mouseMoveEvent(self, ev)
pos = np.array([ev.pos().x(), ev.pos().y()])
dif = pos - self.mousePos
+ if axis is not None and axis in (0, 1):
+ # restrict transform to single axis if given
+ dif[1-axis] = 0
dif *= -1
self.mousePos = pos
-
-
## Ignore axes if mouse is disabled
mask = np.array(self.mouseEnabled, dtype=np.float)
Please sign in to comment.
Something went wrong with that request. Please try again.