def __init__(self, obj, parent=None):
NodeGfx.__init__(self, obj)
self.
setRect(QRectF(0,
0,
100,
100)) # TODO DEBUG REMOVE:
def paint(self, painter, item, widget):
GfxObject.paint(self, painter, item, widget)
painter.setPen(self.pen())
painter.setBrush(self.brush())
painter.drawRect(self.rect())
# DBG
self._dbgPaint(painter, item, widget)
def resize(self, children=None):
if children == None:
children = self.childItems()
rects
= [child.
mapToItem(self,
QPolygonF(child.
rect())).
boundingRect() for child in children
] rects.append(self.boundingRect())
rect = minBoundingRect(rects)
#self.setPos_(self.sceneTransform().map(rect.topLeft()))
#rect = self.mapFromScene(rect).boundingRect()
pos = self.sceneTransform().map(rect.topLeft())
self.setPos_(pos)
self.
setRect(QRectF(0,
0, rect.
width(), rect.
height())) parent = self.parentItem()
if parent and isinstance(parent, NodeGfx):
parent.resize(children=[self])
#def selectionPath(self):
#pass
#def sceneBoundingPolygon(self):
#return self.sceneTransform().map(QPolygonF(self.boundingRect()))
class RoundedRectNodeGfx(NodeGfx, QGraphicsRectItem):
def __init__(self, obj, parent=None):
QGraphicsRectItem.__init__(self, parent)
NodeGfx.__init__(self, obj)
self.setRect(QRectF(0,0,100,100))
# TODO DEBUG REMOVE:
self.setBrush(QBrush(QColor(255, 255, 0, 255)))
self.setPen(QPen(QColor(0, 255, 255, 255), 2.5))
def paint(self, painter, item, widget):
GfxObject.paint(self, painter, item, widget)
painter.setPen(self.pen())
painter.setBrush(self.brush())
painter.drawRect(self.rect())
# DBG
self._dbgPaint(painter, item, widget)
def resize(self, children=None):
if children == None:
children = self.childItems()
rects = [child.mapToItem(self, QPolygonF(child.rect())).boundingRect() for child in children]
rects.append(self.boundingRect())
rect = minBoundingRect(rects)
#self.setPos_(self.sceneTransform().map(rect.topLeft()))
#rect = self.mapFromScene(rect).boundingRect()
pos = self.sceneTransform().map(rect.topLeft())
self.setPos_(pos)
self.setRect(QRectF(0,0, rect.width(), rect.height()))
parent = self.parentItem()
if parent and isinstance(parent, NodeGfx):
parent.resize(children=[self])
#def selectionPath(self):
#pass
#def sceneBoundingPolygon(self):
#return self.sceneTransform().map(QPolygonF(self.boundingRect()))
To copy to clipboard, switch view to plain text mode
Bookmarks