python - QGraphicsView vector edit: update path when moving node – properly? -


i creating vector editing window. add elements qgraphicsscene , display it. yet writing code when moving node, moves underlying path well.
how move 2 joints of path lead point try move? first need break qpainterpath subpaths (how? method breaks subpaths seems tosubpathpolygon polygon set of point looses curve information…) find point before 1 trying change. how go doing that?

see screenshots: http://imgur.com/a/q7yy1
when moving node, 1 joint gets updated.

the square nodes defined this:

class oncurvepointitem(qgraphicsrectitem):     def __init__(self, x, y, width, height, pointx, pointy, pen=none, brush=none, parent=none):         super(oncurvepointitem, self).__init__(x, y, width, height, parent)         self.setflag(qgraphicsitem.itemismovable)         self.setflag(qgraphicsitem.itemisselectable)         self.setflag(qgraphicsitem.itemsendsgeometrychanges)         if pen not none: self.setpen(pen)         if brush not none: self.setbrush(brush)          # absolute coordinates of points in path         self._pointx = pointx         self._pointy = pointy      """ # disabled, trying use itemchange instead.     def mousemoveevent(self, event):         pos = event.pos()         print(pos)         super(oncurvepointitem, self).mousemoveevent(event)         path = self.scene()._outlineitem.path()         path.setelementpositionat(0, pos.x(), pos.y())         self.scene()._outlineitem.setpath(path)         #self.scene().update()     """      def itemchange(self, change, value):         #print(change)         if change == qgraphicsitem.itempositionhaschanged:             # outline path mutate, stashed in scene             path = self.scene()._outlineitem.path()              #for in range(path.elementcount()):             #    elem = path.elementat(i)             #    if elem.iscurveto(): kind = "curve"             #    elif elem.islineto(): kind = "line"             #    else: kind = "move"             #    print("{}: {} {}".format(kind, elem.x, elem.y))             #print()              # self.pos() relative original position in scene             # hardcoding element 0 till store index in item object             path.setelementpositionat(0, self._pointx+self.pos().x(), self._pointy+self.pos().y())             self.scene()._outlineitem.setpath(path)         return qgraphicsitem.itemchange(self, change, value) 

thank you, i'm rather stuck here. there simple qt example of vector edition know of?
found piece of software called carve codebase rather intricated , can't find relevant doing here…

in end chose use points coordinates on each move create new updated path scratch , calling qgraphicspathitem.updatepath() when move happens.

this avoid need low-level manipulation, qpainterpath isn’t made anyway.


Comments