Exemple #1
0
    def __init__(self, action: 'Action', parent=None) -> 'ActionGraphics':
        """
		Constructs a Action Graphics object for the given action.
		
		:param action: The action for which this graphics item represents.
		:type action: Action
		:param parent: None
		:type parent: NoneType
		:return: The graphics of an action.
		:rtype: ActionGraphics
		"""
        QGraphicsItem.__init__(self, parent)
        self.setFlag(QGraphicsItem.ItemIsSelectable)
        self.setCursor(Qt.ArrowCursor)
        self._action = action
        QObject.connect(action, SIGNAL('updated()'), self.updateGraphics)

        self.color = ActionGraphics.COLOR

        self._inputPortGraphics = []
        self._outputPortGraphics = []
        self._wireGraphics = []
        self._actionGraphics = []

        self._inputPortMapping = {}
        self._outputPortMapping = {}

        self._interactivePorts = True
        ActionGraphics.updateGraphics(self)

        self._width = 0
        self._height = 0
Exemple #2
0
 def __init__(self, chart):
     QGraphicsItem.__init__(self, chart)
     self._chart = chart
     self._text = ""
     self._textRect = QRectF()
     self._anchor = QPointF()
     self._font = QFont()
     self._rect = QRectF()
Exemple #3
0
 def __init__(self, chart):
     QGraphicsItem.__init__(self, chart)
     self._chart = chart
     self._text = ""
     self._textRect = QRectF()
     self._anchor = QPointF()
     self._font = QFont()
     self._rect = QRectF()
Exemple #4
0
    def __init__(self, chart):
        QGraphicsItem.__init__(self, chart)

        self.chart = chart
        self.rect = QRectF()
        self.anchor = QPointF()
        self.text_rect = QRectF()
        self.text = ""
        self.font = QFont()
Exemple #5
0
    def __init__(self, color: QColor, x: int, y: int, parent=None):
        QGraphicsItem.__init__(self, parent)
        self.x = x
        self.y = y
        self.color = color
        self.stuff = []
        self.setZValue((x + y) % 2)

        self.setFlags(self.ItemIsSelectable | self.ItemIsMovable)
        self.setAcceptHoverEvents(True)
Exemple #6
0
    def __init__(self, parent: 'ActionPipelineGraphics'):
        """
		Constructs a ConnectionIndicator class
		
		:param parent: The ActionPipelineGraphics class that the indicator belongs to.
		:type parent: ActionPipelineGraphics
		"""
        QGraphicsItem.__init__(self, parent)
        self._srcPoint = QPointF(0, 0)
        self._destPoint = QPointF(0, 0)
        self.setZValue(100)  # stack on top of all siblings
        self.color = ConnectionIndicator.BASE_COLOR
Exemple #7
0
    def __init__(self, parent=None):
        QGraphicsItem.__init__(self, parent)

        self.positionX = 0
        self.positionY = 0
        self.width = 0
        self.height = 0
        self.paintPen = QPen(Qt.GlobalColor.lightGray)
        self.paintPen.setWidth(5)

        self.backColor = Qt.GlobalColor.lightGray
        self.backImageStr = None
Exemple #8
0
    def __init__(self,
                 port: 'Port',
                 parent: QGraphicsItem = None,
                 menuEnabled: bool = True):
        """
		Constructs a portGraphics object for the given Port object.
		
		:param port: The port for which this graphics item represents.
		:type port: Port
		:param parent: A QGraphicsItem (probably an actionGraphics object)
		:type parent: QGraphicsItem
		:param menuEnabled: If true, a context menu will be shown on right-click.
		:type menuEnabled: bool
		"""
        QGraphicsItem.__init__(self, parent)
        self.setAcceptDrops(True)
        self.setFlag(QGraphicsItem.ItemIsSelectable)
        self._port = port
        self._menuEnabled = menuEnabled
        self.menu = PortMenu()

        # If port is required and it's an input, make the border thicker
        if not self._port.isOptional() and self._port in self._port.getAction(
        ).getInputPorts():
            self.borderWidth = PortGraphics.REQUIRED_PEN_WIDTH
        else:
            self.borderWidth = PortGraphics.OPTIONAL_PEN_WIDTH

        # show port name and type
        if self._menuEnabled:
            fm = QFontMetricsF(PortGraphics.NAME_FONT)
            name = fm.elidedText(self._port.getName(), Qt.ElideRight,
                                 PortGraphics.SIDE_HEIGHT)
            self.nameItem = QGraphicsTextItem(name, self)
            self.nameItem.setFont(PortGraphics.NAME_FONT)
            self.nameItem.setRotation(90)
            self.nameItem.setPos(PortGraphics.WIDTH / 2 + 5,
                                 -PortGraphics.TOTAL_HEIGHT / 2)

            fm = QFontMetricsF(PortGraphics.TYPE_FONT)
            t = fm.elidedText(self._port.getDataType().__name__, Qt.ElideRight,
                              PortGraphics.SIDE_HEIGHT)
            self.typeItem = QGraphicsTextItem(t, self)
            self.typeItem.setFont(PortGraphics.TYPE_FONT)
            self.typeItem.setRotation(90)
            self.typeItem.setPos(5, -PortGraphics.TOTAL_HEIGHT / 2)
    def __init__(self, direction, parent=None) -> 'ActionGraphics':
        """
		Constructs an move button with either an up or down arrow

		:param direction: The direction to draw the button (up or down)
		:type direction: MoveButton.Direction
		:param parent: None
		:type parent: NoneType
		:return: The graphics for the button.
		:rtype: ActionGraphics
		"""
        QObject.__init__(self)
        QGraphicsItem.__init__(self, parent)
        self.setAcceptHoverEvents(True)

        self.direction = direction
        self.bgColor = MoveButton.BG_COLOR
        self.lineColor = MoveButton.LINE_COLOR
 def __init__(self, size, price_model):
     QGraphicsItem.__init__(self)
     self.size = size
     self.price_model = PriceModel()
     self.data = self.price_model.data
Exemple #11
0
 def __init__(self, size, price_model):
     QGraphicsItem.__init__(self)
     self.size = size
     self.price_model = price_model
     self.data = self.price_model.vol_data
Exemple #12
0
 def __init__(self, size, pen, type=1):
     QGraphicsItem.__init__(self)
     self.size = size
     self.pen = pen
     self.type = type
Exemple #13
0
 def __init__(self, size, max, min):
     QGraphicsItem.__init__(self)
     self.size = size
     self.max = max
     self.min = min
    def __init__(self,
                 dataComponent: 'Component',
                 rect: tuple = (),
                 parent=None):
        """
		Constructs a ComponentGraphics object

		:param dataComponent: get the data of a Component
		:type dataComponent: Component
		:param parent: parent ComponentGraphics
		:type parent: ComponentGraphics
		"""

        QGraphicsItem.__init__(self, parent)
        self.setFlag(QGraphicsItem.ItemIsSelectable)

        if parent is None:
            self.isRoot = True  # TODO: Have to resize scene to smallest possible
        else:
            self.isRoot = False

        self._dataComponent = dataComponent

        # force components to have at least the minimum size
        self._x = rect[0]
        self._y = rect[1]
        self._numMoves = 0

        # --- This is where the components get resized to avoid collisions. ---

        if self._dataComponent.getParent() is None:
            # No margin: we want the normal size
            # TODO: Might not do anything
            self._margin = 0
            self._width = max(ComponentGraphics.MIN_WIDTH, 2 * rect[2])
            self._height = max(ComponentGraphics.MIN_HEIGHT, 2 * rect[3])
            self.setPos(max(0, 2 * rect[0]), max(0, 2 * rect[1]))
        elif self._dataComponent.getParent().getParent() is None:
            # We want just a titlebar
            self._margin = 0
            self._width = max(ComponentGraphics.MIN_WIDTH, 2 * rect[2])
            self._height = max(ComponentGraphics.MIN_HEIGHT,
                               2 * rect[3] + ComponentGraphics.TITLEBAR_H)
            self.setPos(max(0, 2 * rect[0]),
                        max(0, 2 * rect[1] + ComponentGraphics.TITLEBAR_H))
        else:
            # Margin is dynamically assigned, with a max/min value to use
            self._margin = max(
                ComponentGraphics.MIN_MARGIN,
                min(ComponentGraphics.MAX_MARGIN,
                    ComponentGraphics.MARGIN_PROP * min(rect[2], rect[3])))

            self._width = max(ComponentGraphics.MIN_WIDTH,
                              2 * (rect[2] - self._margin))
            self._height = max(
                ComponentGraphics.MIN_HEIGHT,
                2 * (rect[3] - self._margin) + ComponentGraphics.TITLEBAR_H)
            self.setPos(
                max(0, 2 * rect[0] + self._margin),
                max(0,
                    2 * rect[1] + self._margin + ComponentGraphics.TITLEBAR_H))

        self.adjustPositioning()
        self.menu = ComponentMenu()
        self.menu.onBlink(
            lambda: self.scene().blinkComponent(self._dataComponent.getId()))

        try:
            self.triggerSceneUpdate()
        except:
            pass
Exemple #15
0
 def __init__(self, size, text, align):
     QGraphicsItem.__init__(self)
     self.size = size
     self.text = text
     self.align = align