ViewBox: make sure transform is up to date in all mapping functions
This commit is contained in:
parent
9d0779cc32
commit
b88a96c08c
@ -404,6 +404,7 @@ class ViewBox(GraphicsWidget):
|
|||||||
ch.setParentItem(None)
|
ch.setParentItem(None)
|
||||||
|
|
||||||
def resizeEvent(self, ev):
|
def resizeEvent(self, ev):
|
||||||
|
self._matrixNeedsUpdate = True
|
||||||
self.linkedXChanged()
|
self.linkedXChanged()
|
||||||
self.linkedYChanged()
|
self.linkedYChanged()
|
||||||
self.updateAutoRange()
|
self.updateAutoRange()
|
||||||
@ -553,11 +554,9 @@ class ViewBox(GraphicsWidget):
|
|||||||
# Note that aspect ratio constraints and auto-visible probably do not work together..
|
# Note that aspect ratio constraints and auto-visible probably do not work together..
|
||||||
if changed[0] and self.state['autoVisibleOnly'][1] and (self.state['autoRange'][0] is not False):
|
if changed[0] and self.state['autoVisibleOnly'][1] and (self.state['autoRange'][0] is not False):
|
||||||
self._autoRangeNeedsUpdate = True
|
self._autoRangeNeedsUpdate = True
|
||||||
#self.updateAutoRange() ## Maybe just indicate that auto range needs to be updated?
|
|
||||||
elif changed[1] and self.state['autoVisibleOnly'][0] and (self.state['autoRange'][1] is not False):
|
elif changed[1] and self.state['autoVisibleOnly'][0] and (self.state['autoRange'][1] is not False):
|
||||||
self._autoRangeNeedsUpdate = True
|
self._autoRangeNeedsUpdate = True
|
||||||
#self.updateAutoRange()
|
|
||||||
|
|
||||||
def setYRange(self, min, max, padding=None, update=True):
|
def setYRange(self, min, max, padding=None, update=True):
|
||||||
"""
|
"""
|
||||||
Set the visible Y range of the view to [*min*, *max*].
|
Set the visible Y range of the view to [*min*, *max*].
|
||||||
@ -1083,35 +1082,43 @@ class ViewBox(GraphicsWidget):
|
|||||||
|
|
||||||
def mapToView(self, obj):
|
def mapToView(self, obj):
|
||||||
"""Maps from the local coordinates of the ViewBox to the coordinate system displayed inside the ViewBox"""
|
"""Maps from the local coordinates of the ViewBox to the coordinate system displayed inside the ViewBox"""
|
||||||
|
self.updateMatrix()
|
||||||
m = fn.invertQTransform(self.childTransform())
|
m = fn.invertQTransform(self.childTransform())
|
||||||
return m.map(obj)
|
return m.map(obj)
|
||||||
|
|
||||||
def mapFromView(self, obj):
|
def mapFromView(self, obj):
|
||||||
"""Maps from the coordinate system displayed inside the ViewBox to the local coordinates of the ViewBox"""
|
"""Maps from the coordinate system displayed inside the ViewBox to the local coordinates of the ViewBox"""
|
||||||
|
self.updateMatrix()
|
||||||
m = self.childTransform()
|
m = self.childTransform()
|
||||||
return m.map(obj)
|
return m.map(obj)
|
||||||
|
|
||||||
def mapSceneToView(self, obj):
|
def mapSceneToView(self, obj):
|
||||||
"""Maps from scene coordinates to the coordinate system displayed inside the ViewBox"""
|
"""Maps from scene coordinates to the coordinate system displayed inside the ViewBox"""
|
||||||
|
self.updateMatrix()
|
||||||
return self.mapToView(self.mapFromScene(obj))
|
return self.mapToView(self.mapFromScene(obj))
|
||||||
|
|
||||||
def mapViewToScene(self, obj):
|
def mapViewToScene(self, obj):
|
||||||
"""Maps from the coordinate system displayed inside the ViewBox to scene coordinates"""
|
"""Maps from the coordinate system displayed inside the ViewBox to scene coordinates"""
|
||||||
|
self.updateMatrix()
|
||||||
return self.mapToScene(self.mapFromView(obj))
|
return self.mapToScene(self.mapFromView(obj))
|
||||||
|
|
||||||
def mapFromItemToView(self, item, obj):
|
def mapFromItemToView(self, item, obj):
|
||||||
"""Maps *obj* from the local coordinate system of *item* to the view coordinates"""
|
"""Maps *obj* from the local coordinate system of *item* to the view coordinates"""
|
||||||
|
self.updateMatrix()
|
||||||
return self.childGroup.mapFromItem(item, obj)
|
return self.childGroup.mapFromItem(item, obj)
|
||||||
#return self.mapSceneToView(item.mapToScene(obj))
|
#return self.mapSceneToView(item.mapToScene(obj))
|
||||||
|
|
||||||
def mapFromViewToItem(self, item, obj):
|
def mapFromViewToItem(self, item, obj):
|
||||||
"""Maps *obj* from view coordinates to the local coordinate system of *item*."""
|
"""Maps *obj* from view coordinates to the local coordinate system of *item*."""
|
||||||
|
self.updateMatrix()
|
||||||
return self.childGroup.mapToItem(item, obj)
|
return self.childGroup.mapToItem(item, obj)
|
||||||
|
|
||||||
def mapViewToDevice(self, obj):
|
def mapViewToDevice(self, obj):
|
||||||
|
self.updateMatrix()
|
||||||
return self.mapToDevice(self.mapFromView(obj))
|
return self.mapToDevice(self.mapFromView(obj))
|
||||||
|
|
||||||
def mapDeviceToView(self, obj):
|
def mapDeviceToView(self, obj):
|
||||||
|
self.updateMatrix()
|
||||||
return self.mapToView(self.mapFromDevice(obj))
|
return self.mapToView(self.mapFromDevice(obj))
|
||||||
|
|
||||||
def viewPixelSize(self):
|
def viewPixelSize(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user