def __init__(self, new=True): super().__init__() super().__init__() if new: self._to = None self._from = None self._points = [ControlPoint() for i in range(0, 2)] for point in self._points: point.setPos(QPointF(0, 0)) self.setupConnections() self._pen = Pen(Qt.black, 1.5, Qt.SolidLine) self._editPen = Pen(QColor(255, 255, 0, 240), 1.5, Qt.SolidLine) self._textPos = [] self._reversed = False self._arrowHead = None self.setAcceptHoverEvents(True) self.setFlag(self.ItemIsMovable, False) self.setFlag(self.ItemIsSelectable, True) self.setFlag(self.ItemIsFocusable, False) self.setFlag(self.ItemSendsGeometryChanges, True) self._contextMenu = None self._editTimer = None self._updatingPos = False self._snapToGrid = False self.hoverLeaveSlot()
def __init__(self, new=True): super().__init__() self._snapToGrid = True if new: self._editable = True self._editPen = Pen(QColor(Qt.green), 1.0) self._penSave = None self._pen = Pen(Qt.NoPen) self._brush = SimpleBrush(Qt.NoBrush) self._locked = False self._constraints = [] self._zoomThreshold = self.DefaultZoomThreshold self._zoom = 0 self._commands = [] self._uid = str(uuid4())
def setExists(self, exists): if exists != self._exists: pen = self.pen() if exists: style = Qt.DotLine else: style = Qt.SolidLine self.setPen( Pen(pen.color(), pen.widthF(), style, pen.capStyle(), pen.joinStyle())) self._exists = exists self.update()
def __init__(self, new=True): super().__init__(new) if new: label = TextItem("x") self.addLabel(label) self.centerChild(label) #label.setFlag(self.ItemIsMovable, False) self.setBrush(SimpleBrush(QColor(255, 255, 255, 0))) # Transparent self.setPen(Pen(QColor(255, 50, 0, 200), 0.88)) self._insetPadding = self.DefaultInsetPadding / 3 self._graphAlgoVisited = False self._editor = None
def __init__(self, new=True): super().__init__(new) if new: r = self.DefaultRadius self._rect = QRectF(-r, -r, 2 * r, 2 * r) self._radius = self.DefaultRadius self.setBrush(SimpleBrush(Qt.yellow)) self.setPen(Pen(Qt.NoPen)) self._snapToGrid = False self.setFlags(self.ItemIsMovable | self.ItemIsFocusable | self.ItemSendsGeometryChanges | \ self.ItemSendsScenePositionChanges | self.ItemIsSelectable) self._dragging = False
def __init__(self, new=True): self._objects = {} self._morphisms = {} super().__init__(new) self._editing = False if new: self.setBrush(SimpleBrush(QColor(10, 255, 12, 70))) # Semi-transparent self.setPen(Pen(Qt.NoPen)) self.setLabelText(0, "C") pos = self.label(0).pos() self.label(0).setPos( pos.x(), pos.y() - self.label(0).boundingRect().height()) self._insetPadding = 3 * self._insetPadding
def __init__(self, new=True): super().__init__(new) super().__init__(new) self._contextMenu = None self._shape = self.RoundedRect if new: self._insetPadding = self.DefaultInsetPadding self._defaultRect = self.DefaultRect self._cornerRadius = self.DefaultCornerRadius self._arrows = [] self._boundScale = (1.0, 1.0) self._brush = SimpleBrush(Qt.cyan) self._pen = Pen(Qt.yellow, 2.0) self.setupConnections() self.setFiltersChildEvents(True) self._renderHints = QPainter.Antialiasing | QPainter.HighQualityAntialiasing | QPainter.SmoothPixmapTransform self.setAcceptHoverEvents(True) self._hover = False
def shape(self): stroker = QPainterPathStroker(Pen(Qt.black, self.arrowHeadSize() * 2)) return stroker.createStroke(self.tailPath())