def __init__(self, item, timeline_range, *args, **kwargs):
        super(BaseItem, self).__init__(*args, **kwargs)
        self.item = item
        self.timeline_range = timeline_range

        # List of otio.core.SerializableObject
        # it excludes decorator widgets as QLabel ...
        self._otio_sub_items = list()

        self.setFlags(QtWidgets.QGraphicsItem.ItemIsSelectable)
        self.setBrush(QtGui.QBrush(QtGui.QColor(180, 180, 180, 255)))

        pen = QtGui.QPen()
        pen.setWidth(0)
        pen.setCosmetic(True)
        self.setPen(pen)

        self.source_in_label = QtWidgets.QGraphicsSimpleTextItem(self)
        self.source_out_label = QtWidgets.QGraphicsSimpleTextItem(self)
        self.source_name_label = QtWidgets.QGraphicsSimpleTextItem(self)

        self._add_markers()
        self._add_effects()
        self._set_labels()
        self._set_tooltip()
Beispiel #2
0
    def draw(self, cordinates):
        painter_path = QtGui.QPainterPath()

        textItem = QtWidgets.QGraphicsSimpleTextItem(self.name,
                                                     self.graphics_item)
        itemFont = QtGui.QFont().setPointSize(10)
        textItem.setFont(itemFont)
        textItem.setPos(5, 10)
        fm = QtGui.QFontMetrics(itemFont)
        width = 100 if fm.width(self.name) < 100 else fm.width(self.name)

        fun_size = len(self.functions) * 30
        fun_size = 30 if fun_size == 0 else fun_size

        for i, function in enumerate(self.functions, 1):
            textItem = QtWidgets.QGraphicsSimpleTextItem(
                str(function), self.graphics_item)
            textItem.setFont(itemFont)
            textItem.setPos(5, 10 + 30 * i)
            width = fm.width(
                str(function)) if fm.width(str(function)) > width else width

        width = width + 10
        painter_path.addRect(QtCore.QRect(0, 0, width, 30))
        painter_path.addRect(QtCore.QRect(0, 30, width, fun_size))

        self.graphics_item.setBrush(QtGui.QBrush(QtGui.QColor(
            self.item_color)))
        self.graphics_item.setFlag(
            QtWidgets.QGraphicsRectItem.ItemIsSelectable)
        self.graphics_item.setFlag(QtWidgets.QGraphicsRectItem.ItemIsMovable)

        self.graphics_item.setPath(painter_path)
        self.graphics_item.setPos(cordinates)
Beispiel #3
0
    def create_coordinate_markings(self):
        if self.white_at_bottom:
            vcoords = '87654321'
            hcoords = 'ABCDEFGH'
        else:
            vcoords = '12345678'
            hcoords = 'HGFEDCBA'

        for v in vcoords:
            vertical_coord_text_item = QtWidgets.QGraphicsSimpleTextItem()
            vertical_coord_text_item.setText(v)
            coord_bounding_rect = vertical_coord_text_item.boundingRect()
            vertical_coord_text_item.setPos(
                self.margin_size * 0.5 - coord_bounding_rect.width() * 0.5,
                self.margin_size + self.square_size *
                (vcoords.index(v) + 0.5) - coord_bounding_rect.height() * 0.5)

            self.coord_marking_text_items.append(vertical_coord_text_item)
            self.scene().addItem(vertical_coord_text_item)

        for h in hcoords:
            horizontal_coord_text_item = QtWidgets.QGraphicsSimpleTextItem()
            horizontal_coord_text_item.setText(h)
            coord_bounding_rect = horizontal_coord_text_item.boundingRect()
            horizontal_coord_text_item.setPos(
                self.margin_size + self.square_size *
                (hcoords.index(h) + 0.5) - coord_bounding_rect.width() * 0.5,
                self.margin_size * 1.5 + self.square_size * 8 -
                coord_bounding_rect.height() * 0.5)

            self.coord_marking_text_items.append(horizontal_coord_text_item)
            self.scene().addItem(horizontal_coord_text_item)
    def __init__(self, stream_index, width, colortype, parent_node):
        QtWidgets.QGraphicsRectItem.__init__(self, 0, 0, width, STRIPE_HEIGHT, parent=parent_node)

        # BASIC VISUAL PROPERTIES
        self.width = width

        # BASIC PROPERTIES
        self.parent_node = parent_node
        self.parent_class = parent_node.node_class
        self.index = stream_index

        self.input_stream = None
        self.input_line = None
        self.output_stream = None
        self.output_line = None

        # COLOR STYLE
        r, g, b = parent_node.r, parent_node.g, parent_node.b
        if colortype == 'light':
            r, g, b = r + 20, g + 20, b + 20
        grad = QtGui.QLinearGradient(0, 0, 0, STRIPE_HEIGHT)
        grad.setColorAt(0.0, QtGui.QColor(r, g, b))
        lighter_color = QtGui.QColor(r + 10, g + 10, b + 10)
        grad.setColorAt(1.0, lighter_color)
        self.setBrush(grad)

        # CONNECTORS
        self.input_connector = Connector('input', self, self.width) if self.parent_node.can_have_input else None
        self.output_connector = Connector('output', self, self.width) if self.parent_node.can_have_output else None

        # STREAM TEXTS
        stream_text = QtWidgets.QGraphicsSimpleTextItem('>> Stream {} >>'.format(self.index), parent=self)
        stream_text.moveBy(width / 2 - 48, 3)
    def __init__(self):

        # ID OF THE NODE
        GeneralNode.id_counter += 1
        self.id = GeneralNode.id_counter

        # BASIC NODE PROPERTIES
        self.extra_header = 0
        self.widget = None
        self.max_streams = 16
        self.is_selected = False

        # STREAMS
        self.stream_count = 0
        self.streams = []

        # GRAPHICS OF THE NODE
        QtWidgets.QGraphicsPathItem.__init__(self)
        self.setFlags(QtWidgets.QGraphicsPathItem.ItemIsMovable)

        self.id_text = QtWidgets.QGraphicsSimpleTextItem(parent=self)
        self.proxy_add_btn = QtWidgets.QGraphicsProxyWidget(parent=self)
        self.proxy_remove_btn = QtWidgets.QGraphicsProxyWidget(parent=self)

        self.marquee = QtWidgets.QGraphicsPathItem(parent=self)

        # SETUP
        self.setup_node()
        self.add_stream()
        self.setup_widget()
    def setup_node(self):

        if self.stream_class:
            self.extra_header = 30
            self.widget = self.stream_class(parent=None)

        # BASIC SHAPE
        self.reconstruct_shape()
        self.setPen(QtGui.QPen(QtCore.Qt.black))

        # NODE NAME
        class_text = QtWidgets.QGraphicsSimpleTextItem(self.node_class, parent=self)
        node_class_font = QtGui.QFont('arial', 12)
        node_class_font.setUnderline(True)
        class_text.setFont(node_class_font)
        class_text.setPos(8, 6)

        # NODE WIDGET
        if self.stream_class:
            self.widget.setFixedSize(self.node_width - 10, HEADER_HEIGHT - 6)
            proxy = QtWidgets.QGraphicsProxyWidget(parent=self)
            proxy.setWidget(self.widget)
            proxy.moveBy(5, HEADER_HEIGHT + 3)
            proxy.setZValue(20)

        # HELP
        help_btn = QtWidgets.QPushButton(parent=None)
        help_btn.setFixedSize(16, 16)
        help_btn.setText('i')
        help_btn.setFont(QtGui.QFont('Monotype Corsiva', 10))
        help_btn.clicked.connect(self.show_help)
        proxy = QtWidgets.QGraphicsProxyWidget(parent=self)
        proxy.setWidget(help_btn)
        proxy.moveBy(self.node_width - 25, 7)

        # NODE ID
        self.id_text.setText('ID: {}'.format(self.id))
        node_id_font = QtGui.QFont('arial', 8)
        self.id_text.setFont(node_id_font)

        # ADD / DELETE STREAMS BUTTONS
        add_btn = QtWidgets.QPushButton(parent=None)
        add_btn.setFixedSize(16, 16)
        add_btn.setText('+')
        add_btn.setStyleSheet('color:lime')
        add_btn.setFont(QtGui.QFont('Impact', 11))
        add_btn.clicked.connect(self.add_stream)
        self.proxy_add_btn.setWidget(add_btn)

        remove_btn = QtWidgets.QPushButton(parent=None)
        remove_btn.setFixedSize(16, 16)
        remove_btn.setText('-')
        remove_btn.setStyleSheet('color:red')
        remove_btn.setFont(QtGui.QFont('Impact', 11))
        remove_btn.clicked.connect(self.remove_stream)
        self.proxy_remove_btn.setWidget(remove_btn)
 def __init__(self, text, position, *args, **kwargs):
     super(FrameNumber, self).__init__(*args, **kwargs)
     self.frameNumber = QtWidgets.QGraphicsSimpleTextItem(self)
     self.frameNumber.setText("%s" % text)
     self.setBrush(QtGui.QBrush(QtGui.QColor(5, 55, 0, 255)))
     self.setPen(QtCore.Qt.NoPen)
     self.frameNumber.setBrush(QtGui.QBrush(QtGui.QColor(25, 255, 10, 255)))
     # if position < 0 then the frameNumber will appear on the left side
     # of the ruler
     self.position = position
Beispiel #8
0
    def __init__(self, item, timeline_range, *args, **kwargs):
        super(_BaseItem, self).__init__(*args, **kwargs)
        self.item = item
        self.timeline_range = timeline_range

        self.setFlags(QtWidgets.QGraphicsItem.ItemIsSelectable)
        self.setBrush(QtGui.QBrush(QtGui.QColor(180, 180, 180, 255)))

        pen = QtGui.QPen()
        pen.setWidth(0)
        self.setPen(pen)

        self.source_in_label = QtWidgets.QGraphicsSimpleTextItem(self)
        self.source_out_label = QtWidgets.QGraphicsSimpleTextItem(self)
        self.source_name_label = QtWidgets.QGraphicsSimpleTextItem(self)

        self._add_markers()
        self._set_labels()
        self._set_tooltip()
    def update_text(self):
        self.key = self.keys[self.index]
        if not self.text_over_mouse:
            return
        color = self.colors[self.index]
        line_color = QColor(color[0], color[1], color[2], color[3])
        face_color = QColor(color[0], color[1], color[2], int(color[3] * 0.3))
        pen = QPen(line_color, 0.5, Qt.SolidLine, Qt.FlatCap, Qt.MiterJoin)
        brush = QBrush(face_color)
        if self.text is None:
            self.text = QtWidgets.QGraphicsSimpleTextItem(self.key)
            self.scene.addItem(self.text)

        self.text.setText(self.key)
        self.text.setBrush(brush)
        self.text.setPen(pen)
Beispiel #10
0
    def show_point_tooltip(self, point: QtCore.QPointF, state: bool):
        point_coord = self.chart.mapToPosition(point)
        point_coord = self.chart.mapToScene(point_coord)
        mouse_box = QtCore.QRect(
            point_coord.toPoint() - QtCore.QPoint(10, 10),
            point_coord.toPoint() + QtCore.QPoint(10, 10),
        )
        # print(mouse_box)
        for data_point in self.series.points():
            data_point_coord = self.chart.mapToPosition(data_point)
            data_point_coord = self.chart.mapToScene(data_point_coord)
            if mouse_box.contains(data_point_coord.toPoint()):
                if (str(data_point_coord) not in self.point_tool_tip_dict
                        and self.point_tool_tip_dict):
                    # print("remove item")
                    # print(data_point.toPoint())
                    for key in self.point_tool_tip_dict:
                        self.chart.scene().removeItem(
                            self.point_tool_tip_dict[key])

                    self.point_tool_tip_dict = {}

                if not self.point_tool_tip_dict:
                    # print(data_point.toPoint())
                    point_tool_tip = QtWidgets.QGraphicsSimpleTextItem()
                    point_tool_tip.setText("Transaction: " +
                                           str(data_point.toPoint().x()) +
                                           " " + "Balance: " +
                                           str(data_point.toPoint().y()))

                    point_tool_tip.setPos(data_point_coord -
                                          QtCore.QPoint(30, 30))
                    # print("add item")
                    self.chart.scene().addItem(point_tool_tip)
                    self.point_tool_tip_dict[str(
                        data_point_coord)] = point_tool_tip
                break
Beispiel #11
0
    def __init__(self, *args, **kwargs):
        super(AbstractBaseCell, self).__init__(*args, **kwargs)
        self.source_name_label = QtWidgets.QGraphicsSimpleTextItem(self)

        self._enable = True
        self._active = True
 def _build_simple_text_item(self, text: str) -> QtWidgets.QGraphicsSimpleTextItem:
     text_item = QtWidgets.QGraphicsSimpleTextItem(text, self)
     text_item.setFont(Conf.symexec_font)
     text_item.setBrush(QtCore.Qt.black)
     text_item.setPos(self.HORIZONTAL_PADDING, self.VERTICAL_PADDING + self._y_off)
     return text_item