Merge pull request #721 from campagnola/viewbox-wheel-fix
Viewbox wheel fix
This commit is contained in:
commit
e99eb67677
@ -19,6 +19,7 @@ examples = OrderedDict([
|
|||||||
('Data Slicing', 'DataSlicing.py'),
|
('Data Slicing', 'DataSlicing.py'),
|
||||||
('Plot Customization', 'customPlot.py'),
|
('Plot Customization', 'customPlot.py'),
|
||||||
('Image Analysis', 'imageAnalysis.py'),
|
('Image Analysis', 'imageAnalysis.py'),
|
||||||
|
('ViewBox Features', 'ViewBoxFeatures.py'),
|
||||||
('Dock widgets', 'dockarea.py'),
|
('Dock widgets', 'dockarea.py'),
|
||||||
('Console', 'ConsoleWidget.py'),
|
('Console', 'ConsoleWidget.py'),
|
||||||
('Histograms', 'histogram.py'),
|
('Histograms', 'histogram.py'),
|
||||||
@ -50,7 +51,7 @@ examples = OrderedDict([
|
|||||||
('Text Item', 'text.py'),
|
('Text Item', 'text.py'),
|
||||||
('Linked Views', 'linkedViews.py'),
|
('Linked Views', 'linkedViews.py'),
|
||||||
('Arrow', 'Arrow.py'),
|
('Arrow', 'Arrow.py'),
|
||||||
('ViewBox', 'ViewBox.py'),
|
('ViewBox', 'ViewBoxFeatures.py'),
|
||||||
('Custom Graphics', 'customGraphicsItem.py'),
|
('Custom Graphics', 'customGraphicsItem.py'),
|
||||||
('Labeled Graph', 'CustomGraphItem.py'),
|
('Labeled Graph', 'CustomGraphItem.py'),
|
||||||
])),
|
])),
|
||||||
|
@ -662,21 +662,13 @@ class ViewBox(GraphicsWidget):
|
|||||||
cause slight changes due to floating-point error).
|
cause slight changes due to floating-point error).
|
||||||
"""
|
"""
|
||||||
if s is not None:
|
if s is not None:
|
||||||
scale = Point(s)
|
x, y = s[0], s[1]
|
||||||
else:
|
|
||||||
scale = [x, y]
|
|
||||||
|
|
||||||
affect = [True, True]
|
affect = [x is not None, y is not None]
|
||||||
if scale[0] is None and scale[1] is None:
|
if not any(affect):
|
||||||
return
|
return
|
||||||
elif scale[0] is None:
|
|
||||||
affect[0] = False
|
|
||||||
scale[0] = 1.0
|
|
||||||
elif scale[1] is None:
|
|
||||||
affect[1] = False
|
|
||||||
scale[1] = 1.0
|
|
||||||
|
|
||||||
scale = Point(scale)
|
scale = Point([1.0 if x is None else x, 1.0 if y is None else y])
|
||||||
|
|
||||||
if self.state['aspectLocked'] is not False:
|
if self.state['aspectLocked'] is not False:
|
||||||
scale[0] = scale[1]
|
scale[0] = scale[1]
|
||||||
@ -1133,18 +1125,18 @@ class ViewBox(GraphicsWidget):
|
|||||||
return self.mapSceneToView(item.sceneBoundingRect()).boundingRect()
|
return self.mapSceneToView(item.sceneBoundingRect()).boundingRect()
|
||||||
|
|
||||||
def wheelEvent(self, ev, axis=None):
|
def wheelEvent(self, ev, axis=None):
|
||||||
mask = np.array(self.state['mouseEnabled'], dtype=np.float)
|
|
||||||
if axis is not None and axis >= 0 and axis < len(mask):
|
if axis is not None and axis >= 0 and axis < len(mask):
|
||||||
mv = mask[axis]
|
mask = [False, False]
|
||||||
mask[:] = 0
|
mask[axis] = self.state['mouseEnabled'][axis]
|
||||||
mask[axis] = mv
|
else:
|
||||||
s = ((mask * 0.02) + 1) ** (ev.delta() * self.state['wheelScaleFactor']) # actual scaling factor
|
mask = self.state['mouseEnabled'][:]
|
||||||
|
s = 1.02 ** (ev.delta() * self.state['wheelScaleFactor']) # actual scaling factor
|
||||||
|
s = [(None if m is False else s) for m in mask]
|
||||||
center = Point(fn.invertQTransform(self.childGroup.transform()).map(ev.pos()))
|
center = Point(fn.invertQTransform(self.childGroup.transform()).map(ev.pos()))
|
||||||
|
|
||||||
self._resetTarget()
|
self._resetTarget()
|
||||||
self.scaleBy(s, center)
|
self.scaleBy(s, center)
|
||||||
self.sigRangeChangedManually.emit(self.state['mouseEnabled'])
|
self.sigRangeChangedManually.emit(mask)
|
||||||
ev.accept()
|
ev.accept()
|
||||||
|
|
||||||
def mouseClickEvent(self, ev):
|
def mouseClickEvent(self, ev):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user