Python PyQt5.QtGui.QPainterPath() Examples

The following are code examples for showing how to use PyQt5.QtGui.QPainterPath(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: eddy   Author: obdasystems   File: qt.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, width, height, color, border=None):
        """
        Initialize the icon.
        :type width: T <= int | float
        :type height: T <= int | float
        :type color: str
        :type border: str
        """
        pixmap = QtGui.QPixmap(width, height)
        painter = QtGui.QPainter(pixmap)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        path = QtGui.QPainterPath()
        path.addRect(QtCore.QRectF(QtCore.QPointF(0, 0), QtCore.QPointF(width, height)))
        painter.fillPath(path, QtGui.QBrush(QtGui.QColor(color)))
        if border:
            painter.setPen(QtGui.QPen(QtGui.QColor(border), 0, QtCore.Qt.SolidLine))
            painter.drawPath(path)
        painter.end()
        super().__init__(pixmap) 
Example 2
Project: eddy   Author: obdasystems   File: membership.py    GNU General Public License v3.0 6 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())
        path.addPolygon(self.head.geometry())

        if self.isSelected():
            for polygon in self.handles:
                path.addEllipse(polygon.geometry())
            for polygon in self.anchors.values():
                path.addEllipse(polygon.geometry())

        return path 
Example 3
Project: eddy   Author: obdasystems   File: attribute.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, width=20, height=20, brush=None, remaining_characters='attribute', **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)
        brush = brush or AttributeNode.DefaultBrush
        pen = AttributeNode.DefaultPen
        self.fpolygon = Polygon(QtGui.QPainterPath())
        self.background = Polygon(QtCore.QRectF(-14, -14, 28, 28))
        self.selection = Polygon(QtCore.QRectF(-14, -14, 28, 28))
        self.polygon = Polygon(QtCore.QRectF(-10, -10, 20, 20), brush, pen)

        self.remaining_characters = remaining_characters

        self.label = NodeLabel(template='attribute', pos=lambda: self.center() - QtCore.QPointF(0, 22), parent=self, editable=True)
        self.label.setAlignment(QtCore.Qt.AlignCenter)



    #############################################
    #   INTERFACE
    ################################# 
Example 4
Project: eddy   Author: obdasystems   File: common.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, geometry=QtGui.QPolygonF(),
         brush=QtGui.QBrush(QtCore.Qt.NoBrush),
         pen=QtGui.QPen(QtCore.Qt.NoPen)):
        """
        Initialize the polygon.
        :type geometry: T <= QRectF|QtGui.QPolygonF|QPainterPath
        :type brush: QBrush
        :type pen: QPen
        """
        self._geometry = geometry
        self._brush = brush
        self._pen = pen

    #############################################
    #   INTERFACE
    ################################# 
Example 5
Project: labelOCT   Author: HaozheLiu-ST   File: QtImageViewer.py    GNU General Public License v3.0 6 votes vote down vote up
def mouseReleaseEvent(self, event):
        """ Stop mouse pan or zoom mode (apply zoom if valid).
        """
        QGraphicsView.mouseReleaseEvent(self, event)
        scenePos = self.mapToScene(event.pos())
        if event.button() == Qt.LeftButton:
            self.setDragMode(QGraphicsView.NoDrag)
            self.leftMouseButtonReleased.emit(scenePos.x(), scenePos.y())
        elif event.button() == Qt.RightButton:
            if self.canZoom:
                viewBBox = self.zoomStack[-1] if len(self.zoomStack) else self.sceneRect()
                selectionBBox = self.scene.selectionArea().boundingRect().intersected(viewBBox)
                self.scene.setSelectionArea(QPainterPath())  # Clear current selection area.
                if selectionBBox.isValid() and (selectionBBox != viewBBox):
                    self.zoomStack.append(selectionBBox)
                    self.updateViewer()
            self.setDragMode(QGraphicsView.NoDrag)
            self.rightMouseButtonReleased.emit(scenePos.x(), scenePos.y()) 
Example 6
Project: BUAAAIHomeWork   Author: potato-cat   File: small_arrow.py    GNU General Public License v3.0 6 votes vote down vote up
def paint(self, painter, option, widget):
        path = QPainterPath()
        l_arrow = self.end - self.start
        path.moveTo(self.start)
        path.lineTo(self.end)

        length = math.sqrt(l_arrow.x() ** 2 + l_arrow.y() ** 2)
        sita = math.atan2(l_arrow.y(), l_arrow.x())
        p1 = self.end - QPointF(SMALL_ARROW_WIDTH * math.cos(sita),
                                SMALL_ARROW_WIDTH * math.sin(sita))
        p2 = p1 - QPointF(-(SMALL_ARROW_WIDTH / 2) * math.sin(sita),
                          (SMALL_ARROW_WIDTH / 2) * math.cos(sita))
        p3 = p1 + QPointF(-SMALL_ARROW_WIDTH / 2 * math.sin(sita),
                          SMALL_ARROW_WIDTH / 2 * math.cos(sita))
        path.addPolygon(QPolygonF([p2, p3, self.end, p2]))
        # path = path.simplified()
        painter.setPen(QPen(self.color, 2))
        painter.setBrush(self.color)
        painter.drawPath(path)
        painter.setPen(Qt.red)
        painter.drawPoint(p1) 
Example 7
Project: BUAAAIHomeWork   Author: potato-cat   File: big_arrow.py    GNU General Public License v3.0 6 votes vote down vote up
def paint(self, painter, option, widget):
        path = QPainterPath()
        l_arrow = self.end - self.start
        length = math.sqrt(l_arrow.x() ** 2 + l_arrow.y() ** 2)
        sita = math.atan2(l_arrow.y(), l_arrow.x())
        p1 = self.start + QPointF(-(BIG_ARROW_WIDTH / 2) * math.sin(sita),
                                  (BIG_ARROW_WIDTH / 2) * math.cos(sita))
        p2 = self.start - QPointF(-(BIG_ARROW_WIDTH / 2) * math.sin(sita),
                                  (BIG_ARROW_WIDTH / 2) * math.cos(sita))
        p3 = p2 + QPointF((length - BIG_ARROW_WIDTH) * math.cos(sita),
                          (length - BIG_ARROW_WIDTH) * math.sin(sita))
        p4 = p3 - QPointF(-BIG_ARROW_WIDTH / 2 * math.sin(sita),
                          BIG_ARROW_WIDTH / 2 * math.cos(sita))
        p5 = self.end
        p7 = p1 + QPointF((length - BIG_ARROW_WIDTH) * math.cos(sita),
                          (length - BIG_ARROW_WIDTH) * math.sin(sita))
        p6 = p7 + QPointF(-BIG_ARROW_WIDTH / 2 * math.sin(sita),
                          BIG_ARROW_WIDTH / 2 * math.cos(sita))
        path.addPolygon(QPolygonF([p1, p2, p3, p4, p5, p6, p7, p1]))
        # path = path.simplified()
        painter.setPen(Qt.black)
        painter.setBrush(Qt.yellow)
        painter.drawPath(path) 
Example 8
Project: NetDebug   Author: BeiChenYx   File: mytitlebar.py    MIT License 6 votes vote down vote up
def paintEvent(self, event):
        """
        绘制标题栏背景色
        """
        painter = QtGui.QPainter(self)
        pathBack = QtGui.QPainterPath()
        pathBack.setFillRule(QtCore.Qt.WindingFill)
        pathBack.addRoundedRect(
            QtCore.QRectF(0, 0, self.width(), self.height()),
            3, 3
        )
        painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform, True)
        painter.fillPath(
            pathBack,
            QtGui.QBrush(QtGui.QColor(
                self.m_colorR, self.m_colorG, self.m_colorB
            ))
        )
        # print(self.width())
        # print(self.parentWidget().width()) 
        # 当窗口最大化或者还原后,窗口长度变了,标题的长度应该一起改变
        if self.width() != self.parentWidget().width():
            self.setFixedWidth(self.parentWidget().width())

        # return QtWidgets.QWidget.paintEvent(event) 
Example 9
Project: NetDebug   Author: BeiChenYx   File: basewindow.py    MIT License 6 votes vote down vote up
def paintEvent(self, event):
        """
        设置背景色
        """
        painter = QtGui.QPainter(self)
        pathBack = QtGui.QPainterPath()
        pathBack.setFillRule(QtCore.Qt.WindingFill)
        pathBack.addRoundedRect(
            QtCore.QRectF(0, 0, self.width(), self.height()),
            3, 3
        )
        painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform, True)
        painter.fillPath(
            pathBack,
            QtGui.QBrush(QtGui.QColor( 238, 223, 204))
        )

        # return QtWidgets.QWidget.paintEvent(event) 
Example 10
Project: eddy   Author: danielepantaleone   File: qt.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, width, height, color, border=None):
        """
        Initialize the icon.
        :type width: T <= int | float
        :type height: T <= int | float
        :type color: str
        :type border: str
        """
        pixmap = QtGui.QPixmap(width, height)
        painter = QtGui.QPainter(pixmap)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        path = QtGui.QPainterPath()
        path.addRect(QtCore.QRectF(QtCore.QPointF(0, 0), QtCore.QPointF(width, height)))
        painter.fillPath(path, QtGui.QBrush(QtGui.QColor(color)))
        if border:
            painter.setPen(QtGui.QPen(QtGui.QColor(border), 0, QtCore.Qt.SolidLine))
            painter.drawPath(path)
        painter.end()
        super().__init__(pixmap) 
Example 11
Project: eddy   Author: danielepantaleone   File: membership.py    GNU General Public License v3.0 6 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())
        path.addPolygon(self.head.geometry())

        if self.isSelected():
            for polygon in self.handles:
                path.addEllipse(polygon.geometry())
            for polygon in self.anchors.values():
                path.addEllipse(polygon.geometry())

        return path 
Example 12
Project: eddy   Author: danielepantaleone   File: attribute.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, width=20, height=20, brush=None, **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)
        brush = brush or AttributeNode.DefaultBrush
        pen = AttributeNode.DefaultPen
        self.fpolygon = Polygon(QtGui.QPainterPath())
        self.background = Polygon(QtCore.QRectF(-14, -14, 28, 28))
        self.selection = Polygon(QtCore.QRectF(-14, -14, 28, 28))
        self.polygon = Polygon(QtCore.QRectF(-10, -10, 20, 20), brush, pen)
        self.label = NodeLabel(template='attribute', pos=lambda: self.center() - QtCore.QPointF(0, 22), parent=self)
        self.label.setAlignment(QtCore.Qt.AlignCenter)

    #############################################
    #   INTERFACE
    ################################# 
Example 13
Project: Lector   Author: BasioMeusPuga   File: definitionsdialog.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        super(DefinitionsUI, self).__init__()
        self.setupUi(self)
        self._translate = QtCore.QCoreApplication.translate

        self.parent = parent
        self.previous_position = None

        self.setWindowFlags(
            QtCore.Qt.Popup |
            QtCore.Qt.FramelessWindowHint)

        radius = 15
        path = QtGui.QPainterPath()
        path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)

        try:
            mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
            self.setMask(mask)
        except TypeError:  # Required for older versions of Qt
            pass

        self.definitionView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        self.app_id = 'bb7a91f9'
        self.app_key = 'fefacdf6775c347b52e9efa2efe642ef'

        self.root_url = 'https://od-api.oxforddictionaries.com:443/api/v1/inflections/'
        self.define_url = 'https://od-api.oxforddictionaries.com:443/api/v1/entries/'

        self.pronunciation_mp3 = None

        self.okButton.clicked.connect(self.hide)
        self.dialogBackground.clicked.connect(self.color_background)
        if multimedia_available:
            self.pronounceButton.clicked.connect(self.play_pronunciation)
        else:
            self.pronounceButton.setEnabled(False) 
Example 14
Project: Lector   Author: BasioMeusPuga   File: metadatadialog.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        super(MetadataUI, self).__init__()
        self.setupUi(self)
        self._translate = QtCore.QCoreApplication.translate

        self.setWindowFlags(
            QtCore.Qt.Popup |
            QtCore.Qt.FramelessWindowHint)

        self.parent = parent

        radius = 15
        path = QtGui.QPainterPath()
        path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)

        try:
            mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
            self.setMask(mask)
        except TypeError:  # Required for older versions of Qt
            pass

        self.parent = parent
        self.database_path = self.parent.database_path

        self.book_index = None
        self.book_year = None
        self.previous_position = None
        self.cover_for_database = None

        self.coverView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.coverView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        self.okButton.clicked.connect(self.ok_pressed)
        self.cancelButton.clicked.connect(self.cancel_pressed)
        self.dialogBackground.clicked.connect(self.color_background)

        self.titleLine.returnPressed.connect(self.ok_pressed)
        self.authorLine.returnPressed.connect(self.ok_pressed)
        self.yearLine.returnPressed.connect(self.ok_pressed)
        self.tagsLine.returnPressed.connect(self.ok_pressed) 
Example 15
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    GNU General Public License v3.0 5 votes vote down vote up
def showEvent(self, event=None):
        # TODO
        # See what happens when the size of the viewport is smaller
        # than the size of the dock

        viewport_bottomRight = self.contentView.mapToGlobal(
            self.contentView.viewport().rect().bottomRight())

        # Dock dimensions
        desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
        dock_width = desktop_size.width() // 4.5
        dock_height = 30

        dock_x = viewport_bottomRight.x() - dock_width - 30
        dock_y = viewport_bottomRight.y() - 70

        self.main_window.active_docks.append(self)
        self.setGeometry(dock_x, dock_y, dock_width, dock_height)

        # Rounded
        radius = 20
        path = QtGui.QPainterPath()
        path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
        try:
            mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
            self.setMask(mask)
        except TypeError:  # Required for older versions of Qt
            pass

        self.animation.start() 
Example 16
Project: eddy   Author: obdasystems   File: session.py    GNU General Public License v3.0 5 votes vote down vote up
def doSelectAll(self):
        """
        Select all the items in the active diagrsm.
        """
        diagram = self.mdi.activeDiagram()
        if diagram:
            path = QtGui.QPainterPath()
            path.addRect(diagram.sceneRect())
            diagram.setSelectionArea(path)
            diagram.setMode(DiagramMode.Idle) 
Example 17
Project: eddy   Author: obdasystems   File: different.py    GNU General Public License v3.0 5 votes vote down vote up
def boundingRect(self):
        """
        Returns the shape bounding rect.
        :rtype: QRectF
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())
        for polygon in self.handles:
            path.addEllipse(polygon.geometry())
        for polygon in self.anchors.values():
            path.addEllipse(polygon.geometry())
        return path.controlPointRect() 
Example 18
Project: eddy   Author: obdasystems   File: different.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.path.geometry())
        return path 
Example 19
Project: eddy   Author: obdasystems   File: different.py    GNU General Public License v3.0 5 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())

        if self.isSelected():
            for polygon in self.handles:
                path.addEllipse(polygon.geometry())
            for polygon in self.anchors.values():
                path.addEllipse(polygon.geometry())

        return path 
Example 20
Project: eddy   Author: obdasystems   File: equivalence.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.path.geometry())
        path.addPolygon(self.head.geometry())
        path.addPolygon(self.tail.geometry())
        return path 
Example 21
Project: eddy   Author: obdasystems   File: equivalence.py    GNU General Public License v3.0 5 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())
        path.addPolygon(self.head.geometry())
        path.addPolygon(self.tail.geometry())
        if self.isSelected():
            for polygon in self.handles:
                path.addEllipse(polygon.geometry())
            for polygon in self.anchors.values():
                path.addEllipse(polygon.geometry())
        return path 
Example 22
Project: eddy   Author: obdasystems   File: input.py    GNU General Public License v3.0 5 votes vote down vote up
def boundingRect(self):
        """
        Returns the shape bounding rect.
        :rtype: QRectF
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())
        path.addPolygon(self.head.geometry())
        for polygon in self.handles:
            path.addEllipse(polygon.geometry())
        for polygon in self.anchors.values():
            path.addEllipse(polygon.geometry())
        return path.controlPointRect() 
Example 23
Project: eddy   Author: obdasystems   File: input.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.path.geometry())
        path.addPolygon(self.head.geometry())
        return path 
Example 24
Project: eddy   Author: obdasystems   File: input.py    GNU General Public License v3.0 5 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())
        path.addPolygon(self.head.geometry())
        if self.isSelected():
            for polygon in self.handles:
                path.addEllipse(polygon.geometry())
            for polygon in self.anchors.values():
                path.addEllipse(polygon.geometry())
        return path 
Example 25
Project: eddy   Author: obdasystems   File: same.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.path.geometry())
        return path 
Example 26
Project: eddy   Author: obdasystems   File: same.py    GNU General Public License v3.0 5 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())

        if self.isSelected():
            for polygon in self.handles:
                path.addEllipse(polygon.geometry())
            for polygon in self.anchors.values():
                path.addEllipse(polygon.geometry())

        return path 
Example 27
Project: eddy   Author: obdasystems   File: inclusion.py    GNU General Public License v3.0 5 votes vote down vote up
def boundingRect(self):
        """
        Returns the shape bounding rect.
        :rtype: QRectF
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())
        path.addPolygon(self.head.geometry())
        for polygon in self.handles:
            path.addEllipse(polygon.geometry())
        for polygon in self.anchors.values():
            path.addEllipse(polygon.geometry())
        return path.controlPointRect() 
Example 28
Project: eddy   Author: obdasystems   File: inclusion.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.path.geometry())
        path.addPolygon(self.head.geometry())
        return path 
Example 29
Project: eddy   Author: obdasystems   File: inclusion.py    GNU General Public License v3.0 5 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())
        path.addPolygon(self.head.geometry())
        if self.isSelected():
            for polygon in self.handles:
                path.addEllipse(polygon.geometry())
            for polygon in self.anchors.values():
                path.addEllipse(polygon.geometry())
        return path 
Example 30
Project: eddy   Author: obdasystems   File: membership.py    GNU General Public License v3.0 5 votes vote down vote up
def boundingRect(self):
        """
        Returns the shape bounding rect.
        :rtype: QRectF
        """
        path = QtGui.QPainterPath()
        path.addPath(self.selection.geometry())
        path.addPolygon(self.head.geometry())
        for polygon in self.handles:
            path.addEllipse(polygon.geometry())
        for polygon in self.anchors.values():
            path.addEllipse(polygon.geometry())
        return path.controlPointRect() 
Example 31
Project: eddy   Author: obdasystems   File: membership.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPath(self.path.geometry())
        path.addPolygon(self.head.geometry())
        return path 
Example 32
Project: eddy   Author: obdasystems   File: attribute.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addEllipse(self.polygon.geometry())
        return path 
Example 33
Project: eddy   Author: obdasystems   File: attribute.py    GNU General Public License v3.0 5 votes vote down vote up
def updateNode(self, functional=None, **kwargs):
        """
        Update the current node.
        :type functional: bool
        """
        if functional is None:
            functional = self.isFunctional()

        # FUNCTIONAL POLYGON (SHAPE)
        path1 = QtGui.QPainterPath()
        path1.addEllipse(self.polygon.geometry())
        path2 = QtGui.QPainterPath()
        path2.addEllipse(QtCore.QRectF(-7, -7, 14, 14))
        self.fpolygon.setGeometry(path1.subtracted(path2))

        # FUNCTIONAL POLYGON (PEN & BRUSH)
        pen = QtGui.QPen(QtCore.Qt.NoPen)
        brush = QtGui.QBrush(QtCore.Qt.NoBrush)
        if functional:
            pen = QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)
            brush = QtGui.QBrush(QtGui.QColor(252, 252, 252, 255))
        self.fpolygon.setPen(pen)
        self.fpolygon.setBrush(brush)

        # SELECTION + BACKGROUND + CACHE REFRESH
        super().updateNode(**kwargs) 
Example 34
Project: eddy   Author: obdasystems   File: individual.py    GNU General Public License v3.0 5 votes vote down vote up
def boundingRect(self):
        """
        Returns the shape bounding rectangle.
        :rtype: QtCore.QRectF
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.selection.geometry())
        return path.boundingRect() 
Example 35
Project: eddy   Author: obdasystems   File: individual.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.polygon.geometry())
        return path 
Example 36
Project: eddy   Author: obdasystems   File: individual.py    GNU General Public License v3.0 5 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.polygon.geometry())
        for polygon in self.handles:
            path.addEllipse(polygon.geometry())
        return path 
Example 37
Project: eddy   Author: obdasystems   File: property_assertion.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addRoundedRect(self.polygon.geometry(), 16, 16)
        return path 
Example 38
Project: eddy   Author: obdasystems   File: value_domain.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addRoundedRect(self.polygon.geometry(), 8, 8)
        return path 
Example 39
Project: eddy   Author: obdasystems   File: value_domain.py    GNU General Public License v3.0 5 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addRoundedRect(self.polygon.geometry(), 8, 8)
        return path 
Example 40
Project: eddy   Author: obdasystems   File: role.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, width=70, height=50, brush=None, remaining_characters='role', **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)
        
        w = max(width, 70)
        h = max(height, 50)
        brush = brush or RoleNode.DefaultBrush
        pen = RoleNode.DefaultPen

        createPolygon = lambda x, y: QtGui.QPolygonF([
            QtCore.QPointF(-x / 2, 0),
            QtCore.QPointF(0, +y / 2),
            QtCore.QPointF(+x / 2, 0),
            QtCore.QPointF(0, -y / 2),
            QtCore.QPointF(-x / 2, 0)
        ])

        self.fpolygon = Polygon(QtGui.QPainterPath())
        self.ipolygon = Polygon(QtGui.QPainterPath())
        self.background = Polygon(createPolygon(w + 8, h + 8))
        self.selection = Polygon(createPolygon(w + 8, h + 8))
        self.polygon = Polygon(createPolygon(w, h), brush, pen)

        self.remaining_characters = remaining_characters

        self.label = NodeLabel(template='role', pos=self.center, parent=self, editable=True)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.updateNode()
        self.updateTextPos()

    #############################################
    #   INTERFACE
    ################################# 
Example 41
Project: eddy   Author: obdasystems   File: role.py    GNU General Public License v3.0 5 votes vote down vote up
def boundingRect(self):
        """
        Returns the shape bounding rectangle.
        :rtype: QtCore.QRectF
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.selection.geometry())
        return path.boundingRect() 
Example 42
Project: eddy   Author: obdasystems   File: role.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.polygon.geometry())
        return path 
Example 43
Project: eddy   Author: obdasystems   File: facet.py    GNU General Public License v3.0 5 votes vote down vote up
def boundingRect(self):
        """
        Returns the shape bounding rectangle.
        :rtype: QtCore.QRectF
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.selection.geometry())
        return path.boundingRect() 
Example 44
Project: eddy   Author: obdasystems   File: facet.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.polygon.geometry())
        return path 
Example 45
Project: eddy   Author: obdasystems   File: facet.py    GNU General Public License v3.0 5 votes vote down vote up
def shape(self):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.polygon.geometry())
        return path 
Example 46
Project: eddy   Author: obdasystems   File: operator.py    GNU General Public License v3.0 5 votes vote down vote up
def boundingRect(self):
        """
        Returns the shape bounding rectangle.
        :rtype: QtCore.QRectF
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.selection.geometry())
        return path.boundingRect() 
Example 47
Project: eddy   Author: obdasystems   File: operator.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addPolygon(self.polygon.geometry())
        return path 
Example 48
Project: eddy   Author: obdasystems   File: restriction.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addRect(self.polygon.geometry())
        return path 
Example 49
Project: eddy   Author: obdasystems   File: restriction.py    GNU General Public License v3.0 5 votes vote down vote up
def shape(self, *args, **kwargs):
        """
        Returns the shape of this item as a QPainterPath in local coordinates.
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addRect(self.polygon.geometry())
        return path 
Example 50
Project: eddy   Author: obdasystems   File: concept.py    GNU General Public License v3.0 5 votes vote down vote up
def painterPath(self):
        """
        Returns the current shape as QtGui.QPainterPath (used for collision detection).
        :rtype: QPainterPath
        """
        path = QtGui.QPainterPath()
        path.addRect(self.polygon.geometry())
        return path