ArrowItem: rotate painterpath instead of the item
This makes it easier to attach text to the arrow.
This commit is contained in:
parent
9d0779cc32
commit
ea9e8a720b
@ -39,7 +39,6 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
|||||||
|
|
||||||
self.setStyle(**defaultOpts)
|
self.setStyle(**defaultOpts)
|
||||||
|
|
||||||
self.rotate(self.opts['angle'])
|
|
||||||
self.moveBy(*self.opts['pos'])
|
self.moveBy(*self.opts['pos'])
|
||||||
|
|
||||||
def setStyle(self, **opts):
|
def setStyle(self, **opts):
|
||||||
@ -72,7 +71,10 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
|||||||
self.opts.update(opts)
|
self.opts.update(opts)
|
||||||
|
|
||||||
opt = dict([(k,self.opts[k]) for k in ['headLen', 'tipAngle', 'baseAngle', 'tailLen', 'tailWidth']])
|
opt = dict([(k,self.opts[k]) for k in ['headLen', 'tipAngle', 'baseAngle', 'tailLen', 'tailWidth']])
|
||||||
self.path = fn.makeArrowPath(**opt)
|
tr = QtGui.QTransform()
|
||||||
|
tr.rotate(self.opts['angle'])
|
||||||
|
self.path = tr.map(fn.makeArrowPath(**opt))
|
||||||
|
|
||||||
self.setPath(self.path)
|
self.setPath(self.path)
|
||||||
|
|
||||||
self.setPen(fn.mkPen(self.opts['pen']))
|
self.setPen(fn.mkPen(self.opts['pen']))
|
||||||
@ -83,6 +85,7 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
|||||||
else:
|
else:
|
||||||
self.setFlags(self.flags() & ~self.ItemIgnoresTransformations)
|
self.setFlags(self.flags() & ~self.ItemIgnoresTransformations)
|
||||||
|
|
||||||
|
|
||||||
def paint(self, p, *args):
|
def paint(self, p, *args):
|
||||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||||
QtGui.QGraphicsPathItem.paint(self, p, *args)
|
QtGui.QGraphicsPathItem.paint(self, p, *args)
|
||||||
|
Loading…
Reference in New Issue
Block a user