TargetItem fix + performance improvements
- avoid extra work when setLabelAngle would have no effect - fix errors from bad parent transform (usually the displaying widget has not been given a size yet)
This commit is contained in:
parent
cb48ec94b7
commit
f015f0879e
@ -39,8 +39,9 @@ class TargetItem(GraphicsObject):
|
|||||||
self._updateLabel()
|
self._updateLabel()
|
||||||
|
|
||||||
def setLabelAngle(self, angle):
|
def setLabelAngle(self, angle):
|
||||||
self.labelAngle = angle
|
if self.labelAngle != angle:
|
||||||
self._updateLabel()
|
self.labelAngle = angle
|
||||||
|
self._updateLabel()
|
||||||
|
|
||||||
def boundingRect(self):
|
def boundingRect(self):
|
||||||
if self._picture is None:
|
if self._picture is None:
|
||||||
@ -81,8 +82,14 @@ class TargetItem(GraphicsObject):
|
|||||||
|
|
||||||
# Note: could do this with self.pixelLength, but this is faster.
|
# Note: could do this with self.pixelLength, but this is faster.
|
||||||
o = self.mapToScene(QtCore.QPointF(0, 0))
|
o = self.mapToScene(QtCore.QPointF(0, 0))
|
||||||
px = abs(1.0 / (self.mapToScene(QtCore.QPointF(1, 0)) - o).x())
|
dx = (self.mapToScene(QtCore.QPointF(1, 0)) - o).x()
|
||||||
py = abs(1.0 / (self.mapToScene(QtCore.QPointF(0, 1)) - o).y())
|
dy = (self.mapToScene(QtCore.QPointF(0, 1)) - o).y()
|
||||||
|
if dx == 0 or dy == 0:
|
||||||
|
p.end()
|
||||||
|
self._bounds = QtCore.QRectF()
|
||||||
|
return
|
||||||
|
px = abs(1.0 / dx)
|
||||||
|
py = abs(1.0 / dy)
|
||||||
|
|
||||||
r, w, h = self._radii
|
r, w, h = self._radii
|
||||||
w = w * px
|
w = w * px
|
||||||
|
Loading…
Reference in New Issue
Block a user