diff options
Diffstat (limited to '')
-rw-r--r-- | src/editorui.py | 86 |
1 files changed, 84 insertions, 2 deletions
diff --git a/src/editorui.py b/src/editorui.py index 6b0815c..b7d691a 100644 --- a/src/editorui.py +++ b/src/editorui.py @@ -248,7 +248,6 @@ class KPEditorObject(KPEditorItem): del obj - class KPEditorDoodad(QtGui.QGraphicsPixmapItem): def __init__(self, doodad, layer): QtGui.QGraphicsPixmapItem.__init__(self) @@ -496,6 +495,90 @@ class KPEditorDoodad(QtGui.QGraphicsPixmapItem): del doodad +class KPEditorNode(QtGui.QGraphicsPixmapItem): + def __init__(self, node, layer): + QtGui.QGraphicsPixmapItem.__init__(self) + self.setFlags( + self.ItemSendsGeometryChanges | + self.ItemIsSelectable | + self.ItemIsMovable + ) + +class KPEditorPathSegment(QtGui.QGraphicsPathItem): + def __init__(self, node, layer): + QtGui.QGraphicsPathItem.__init__(self) + self.setFlags( + self.ItemSendsGeometryChanges | + self.ItemIsSelectable | + self.ItemIsMovable + ) + + self.path = QtGui.QPainterPath() + self.brush = None + self.pen = None + + self.rotation = 0 + + + def makeStraight(self, start, end): + + self.path.moveTo(start) + self.path.addPolygon(QtGui.QPolygon([QtCore.QPointF(start.x(), start.y()-5.0), + QtCore.QPointF(end.x(), end.y()-5.0), + QtCore.QPointF(end.x(), end.y()+5.0), + QtCore.QPointF(start.x(), start.y()+5.0), + QtCore.QPointF(start.x(), start.y()-5.0)] + + + graduate = QtGui.QRadialGradiant(QtCore.QPointF((end.x()/2)-(start.x()/2), (end.y()/2)-(start.y()/2) + 16), (end.x()/2)-(start.x()/2), + graduate.setColorA(QColor(200, 210, 240)) + graduate.setColorB(QColor(150, 160, 190)) + + self.brush = QtGui.QBrush(graduate) + + self.pen = QtGui.QPen(QColor(120, 130, 160)) + self.pen.setWidth(4) + self.pen.setCapStyle(Qt.RoundCap) + self.pen.setJoinStyle(Qt.RoundJoin) + + + + def makeArc(self, start, end): + + self.path.moveTo(start) + self.path.addEllipse(start.x(), start.y(), end.x()-start.x(), end.y()-start.y()) + + r = QtGui.QPainterPath() + r.addEllipse(start.x(), start.y()-4, end.x()-start.x(), end.y()-start.y()-16) + + self.path.subtracted(r) + + + graduate = QtGui.QRadialGradiant(QtCore.QPointF((end.x()/2)-(start.x()/2), (end.y()/2)-(start.y()/2) + 16), (end.x()/2)-(start.x()/2), + graduate.setColorA(QColor(200, 210, 240)) + graduate.setColorB(QColor(150, 160, 190)) + + self.brush = QtGui.QBrush(graduate) + + self.pen = QtGui.QPen(QColor(120, 130, 160)) + self.pen.setWidth(4) + self.pen.setCapStyle(Qt.RoundCap) + self.pen.setJoinStyle(Qt.RoundJoin) + + + sX = start.x() + sY = start.y() + + eX = end.x() + eY = end.y() + + dy = eY - sY + dx = eX - sX + rads = math.atan2(dy, dx) + + self.rotate = math.degrees(rads) + + class KPMapScene(QtGui.QGraphicsScene): @@ -616,7 +699,6 @@ class KPMapScene(QtGui.QGraphicsScene): item.setFlag(flag, value) - class KPEditorWidget(QtGui.QGraphicsView): def __init__(self, scene, parent=None): QtGui.QGraphicsView.__init__(self, scene, parent) |