예제 #1
0
    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)
예제 #2
0
    def __init__(self, facet=None, width=80, height=40, brush=None, **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        :type facet: Facet
        """
        super().__init__(**kwargs)
        self.background = Polygon(self.createPolygon(88, 48))
        self.selection = Polygon(self.createPolygon(88, 48))
        self.polygon = Polygon(self.createPolygon(80, 40))
        self.polygonA = Polygon(self.createPolygonA(80, 40),
                                FacetNode.DefaultBrushA, FacetNode.DefaultPenA)
        self.polygonB = Polygon(self.createPolygonA(80, 40),
                                FacetNode.DefaultBrushB, FacetNode.DefaultPenB)
        self._facet = facet

        self.labelA = NodeLabel('Empty',
                                pos=self.centerA,
                                editable=False,
                                movable=False,
                                parent=self)
        self.labelB = FacetQuotedLabel(template='"Empty"',
                                       movable=False,
                                       pos=self.centerB,
                                       parent=self)
        self.updateNode()
        self.updateTextPos()
예제 #3
0
    def __init__(self, iri=None, width=60, height=60, brush=None, **kwargs):
        """
        Initialize the node.
        :type iri: IRI
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(iri=iri, **kwargs)
        w = max(width, 60)
        h = max(height, 60)
        brush = brush or IndividualNode.DefaultBrush
        pen = IndividualNode.DefaultPen

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

        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.updateNode()
예제 #4
0
    def __init__(self, source, target=None, breakpoints=None, **kwargs):
        """
        Initialize the edge.
        :type source: AbstractNode
        :type target: AbstractNode
        :type breakpoints: list
        """
        super().__init__(**kwargs)

        self.source = source
        self.target = target

        self.anchors = {}  # {AbstractNode: Polygon}
        self.breakpoints = breakpoints or []  # [QtCore.QPointF]
        self.handles = []  # [Polygon]
        self.head = Polygon(QtGui.QPolygonF())
        self.path = Polygon(QtGui.QPainterPath())
        self.selection = Polygon(QtGui.QPainterPath())

        self.mp_AnchorNode = None
        self.mp_AnchorNodePos = None
        self.mp_BreakPoint = None
        self.mp_BreakPointPos = None
        self.mp_Pos = None

        self.setAcceptHoverEvents(True)
        self.setCacheMode(AbstractItem.DeviceCoordinateCache)
        self.setFlag(AbstractItem.ItemIsSelectable, True)
예제 #5
0
    def __init__(self,
                 width=110,
                 height=50,
                 brush=None,
                 remaining_characters='concept',
                 **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)
        w = max(width, 110)
        h = max(height, 50)
        brush = brush or ConceptNode.DefaultBrush
        pen = ConceptNode.DefaultPen
        self.background = Polygon(
            QtCore.QRectF(-(w + 8) / 2, -(h + 8) / 2, w + 8, h + 8))
        self.selection = Polygon(
            QtCore.QRectF(-(w + 8) / 2, -(h + 8) / 2, w + 8, h + 8))
        self.polygon = Polygon(QtCore.QRectF(-w / 2, -h / 2, w, h), brush, pen)

        self.remaining_characters = remaining_characters

        self.label = NodeLabel(template='concept',
                               pos=self.center,
                               parent=self,
                               editable=True)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.updateNode()
        self.updateTextPos()
예제 #6
0
    def __init__(self, iri = None, width=70, height=50, brush=None, **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(iri=iri,**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.updateNode()
예제 #7
0
    def __init__(self,
                 width=90,
                 height=40,
                 brush=None,
                 remaining_characters='valuedomain',
                 **kwargs):
        """
        Initialize the ValueDomain node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)
        brush = brush or ValueDomainNode.DefaultBrush
        pen = ValueDomainNode.DefaultPen
        self.background = Polygon(QtCore.QRectF(-49, -24, 98, 48))
        self.selection = Polygon(QtCore.QRectF(-49, -24, 98, 48))
        self.polygon = Polygon(QtCore.QRectF(-45, -20, 90, 40), brush, pen)

        self.remaining_characters = remaining_characters

        self.label = NodeLabel(Datatype.string.value,
                               pos=self.center,
                               editable=False,
                               movable=False,
                               parent=self)
        self.updateNode()
        self.updateTextPos()
예제 #8
0
파일: role.py 프로젝트: sdash-redhat/eddy
    def __init__(self, width=70, height=50, brush=None, **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.label = NodeLabel(template='role', pos=self.center, parent=self)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.updateNode()
        self.updateTextPos()
예제 #9
0
    def __init__(self, width=60, height=60, brush=None, **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)

        w = max(width, 60)
        h = max(height, 60)
        brush = brush or IndividualNode.DefaultBrush
        pen = IndividualNode.DefaultPen

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

        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.label = NodeLabel(template='individual', pos=self.center, parent=self)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.updateNode()
        self.updateTextPos()
예제 #10
0
 def __init__(self, iri=None, width=20, height=20, brush=None, **kwargs):
     """
     Initialize the node.
     :type width: int
     :type height: int
     :type brush: QBrush
     """
     super().__init__(iri=iri, **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)
예제 #11
0
 def __init__(self, width=52, height=30, brush=None, inputs=None, **kwargs):
     """
     Initialize the node.
     :type width: int
     :type height: int
     :type brush: QBrush
     :type inputs: DistinctList
     """
     super().__init__(**kwargs)
     brush = PropertyAssertionNode.DefaultBrush
     pen = PropertyAssertionNode.DefaultPen
     self.inputs = inputs or DistinctList()
     self.background = Polygon(QtCore.QRectF(-34, -19, 68, 38))
     self.selection = Polygon(QtCore.QRectF(-34, -19, 68, 38))
     self.polygon = Polygon(QtCore.QRectF(-26, -15, 52, 30), brush, pen)
예제 #12
0
 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 RestrictionNode.DefaultBrush
     pen = RestrictionNode.DefaultPen
     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(
         Restriction.Exists.toString(),
         pos=lambda: self.center() - QtCore.QPointF(0, 22),
         editable=False,
         parent=self)
예제 #13
0
    def __init__(self, iri=None, width=110, height=50, brush=None, **kwargs):
        """
        Initialize the node.
        :type iri: IRI
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(iri=iri, **kwargs)
        w = max(width, 110)
        h = max(height, 50)
        brush = brush or ConceptNode.DefaultBrush
        pen = ConceptNode.DefaultPen
        self.background = Polygon(
            QtCore.QRectF(-(w + 8) / 2, -(h + 8) / 2, w + 8, h + 8))
        self.selection = Polygon(
            QtCore.QRectF(-(w + 8) / 2, -(h + 8) / 2, w + 8, h + 8))
        self.polygon = Polygon(QtCore.QRectF(-w / 2, -h / 2, w, h), brush, pen)

        self.updateNode()
예제 #14
0
    def __init__(self, width=80, height=40, brush=None, remaining_characters='facet', **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)
        self.background = Polygon(self.createPolygon(88, 48))
        self.selection = Polygon(self.createPolygon(88, 48))
        self.polygon = Polygon(self.createPolygon(80, 40))
        self.polygonA = Polygon(self.createPolygonA(80, 40), FacetNode.DefaultBrushA, FacetNode.DefaultPenA)
        self.polygonB = Polygon(self.createPolygonA(80, 40), FacetNode.DefaultBrushB, FacetNode.DefaultPenB)

        self.remaining_characters = remaining_characters

        self.labelA = NodeLabel(Facet.length.value, pos=self.centerA, editable=False, movable=False, parent=self)
        self.labelB = FacetQuotedLabel(template='"32"', movable=False, pos=self.centerB, parent=self)
        self.updateNode()
        self.updateTextPos()
예제 #15
0
    def __init__(self, width=50, height=30, brush=None, **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)

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

        self.background = Polygon(createPolygon(58, 38))
        self.selection = Polygon(createPolygon(58, 38))
        self.polygon = Polygon(createPolygon(50, 30), brush
                               or OperatorNode.DefaultBrush,
                               OperatorNode.DefaultPen)
예제 #16
0
    def __init__(self, **kwargs):
        """
        Initialize the node.
        """
        super().__init__(**kwargs)

        self.handles = [Polygon(QtCore.QRectF()) for _ in range(8)]

        self.mp_Background = None
        self.mp_Selection = None
        self.mp_Polygon = None
        self.mp_Bound = None
        self.mp_Data = None
        self.mp_Handle = None
        self.mp_Pos = None
예제 #17
0
 def __init__(self, **kwargs):
     """
     Initialize the edge.
     """
     super().__init__(**kwargs)
     self.tail = Polygon(QtGui.QPolygonF())
예제 #18
0
    def updateEdge(self,
                   selected=None,
                   visible=None,
                   breakpoint=None,
                   anchor=None,
                   **kwargs):
        """
        Update the current edge.
        :type selected: bool
        :type visible: bool
        :type breakpoint: int
        :type anchor: AbstractNode
        """

        edge_in_axiom = kwargs.get('edge_in_axiom', None)

        if selected is None:
            selected = self.isSelected()
        if visible is None:
            visible = self.canDraw()

        source = self.source
        target = self.target

        ## ANCHORS (GEOMETRY) --> NB: THE POINTS ARE IN THE ENDPOINTS
        if source and target:
            p = source.anchor(self)
            self.anchors[source] = Polygon(
                QtCore.QRectF(p.x() - 4,
                              p.y() - 4, 8, 8))
            p = target.anchor(self)
            self.anchors[target] = Polygon(
                QtCore.QRectF(p.x() - 4,
                              p.y() - 4, 8, 8))

        ## BREAKPOINTS (GEOMETRY)
        self.handles = [
            Polygon(QtCore.QRectF(p.x() - 4,
                                  p.y() - 4, 8, 8)) for p in self.breakpoints
        ]

        ## ANCHORS + BREAKPOINTS + SELECTION (BRUSH + PEN)
        if visible and selected:
            apBrush = QtGui.QBrush(QtGui.QColor(66, 165, 245, 255))
            apPen = QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1,
                               QtCore.Qt.SolidLine, QtCore.Qt.RoundCap,
                               QtCore.Qt.RoundJoin)
            bpBrush = QtGui.QBrush(QtGui.QColor(66, 165, 245, 255))
            bpPen = QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1,
                               QtCore.Qt.SolidLine, QtCore.Qt.RoundCap,
                               QtCore.Qt.RoundJoin)
            selectionBrush = QtGui.QBrush(QtGui.QColor(248, 255, 72, 255))
            if edge_in_axiom is True:
                selectionBrush = QtGui.QBrush(QtGui.QColor(72, 72, 248, 255))
        else:
            apBrush = QtGui.QBrush(QtCore.Qt.NoBrush)
            apPen = QtGui.QPen(QtCore.Qt.NoPen)
            bpBrush = QtGui.QBrush(QtCore.Qt.NoBrush)
            bpPen = QtGui.QPen(QtCore.Qt.NoPen)
            selectionBrush = QtGui.QBrush(QtCore.Qt.NoBrush)
        for polygon in self.anchors.values():
            polygon.setBrush(apBrush)
            polygon.setPen(apPen)
        for polygon in self.handles:
            polygon.setBrush(bpBrush)
            polygon.setPen(bpPen)
        self.selection.setBrush(selectionBrush)

        ## Z-VALUE (DEPTH)
        try:
            zValue = max(*(x.zValue() for x in self.collidingItems())) + 0.1
        except TypeError:
            zValue = source.zValue() + 0.1
            if source.label:
                zValue = max(zValue, source.label.zValue())
            if target:
                zValue = max(zValue, target.zValue())
                if target.label:
                    zValue = max(zValue, target.label.zValue())
        self.setZValue(zValue)

        ## FORCE CACHE REGENERATION
        self.setCacheMode(AbstractItem.NoCache)
        self.setCacheMode(AbstractItem.DeviceCoordinateCache)