Ejemplo n.º 1
0
    def __init__(self, parent, scene, view):
        super(QNodesEditor, self).__init__(parent)

        self.scene = scene
        self.scene.installEventFilter(self)

        gridSize = 25
        gridMap = QPixmap(gridSize,gridSize)
        gridPainter = QPainter(gridMap)
        gridPainter.fillRect(0,0,gridSize,gridSize, QApplication.palette().window().color().darker(103))
        gridPainter.fillRect(1,1,gridSize-2,gridSize-2, QApplication.palette().window())
        gridPainter.end()
        self.scene.setBackgroundBrush( QBrush(gridMap) )

        originSize = 50
        originItem = QGraphicsPathItem()
        path = QPainterPath()
        path.moveTo(0,-originSize)
        path.lineTo(0,originSize)
        path.moveTo(-originSize,0)
        path.lineTo(originSize,0)
        originItem.setPath(path)
        originItem.setPen(QPen(QApplication.palette().window().color().darker(110),2))
        originItem.setZValue(-2)
        self.scene.addItem(originItem)

        self.view = view
        self.view.setDragMode(QGraphicsView.RubberBandDrag)
        self.view.setRenderHint(QPainter.Antialiasing)

        self.connection = None
Ejemplo n.º 2
0
    def __init__(self, parent):
        super(QNEBlock, self).__init__(parent)

        self.m_nodeEditor = None
        self.m_name = ""
        self.m_uuid = ""

        self.normalBrush = QApplication.palette().dark()
        normalColor = self.normalBrush.color()
        normalColor.setAlphaF(0.8)
        self.normalBrush.setColor(normalColor)

        self.selectedBrush = QApplication.palette().light()
        selectedColor = self.selectedBrush.color()
        selectedColor.setAlphaF(0.8)
        self.selectedBrush.setColor(selectedColor)

        self.pen = QPen(QApplication.palette().text().color(), 1)

        path = QPainterPath()
        path.addRoundedRect(-50, -15, 100, 30, 5, 5)
        self.setPath(path)
        self.setBrush(self.normalBrush)
        self.setFlag(QGraphicsItem.ItemIsMovable)
        self.setFlag(QGraphicsItem.ItemIsSelectable)

        self.effect = QGraphicsDropShadowEffect(None)
        self.effect.setBlurRadius(8)
        self.effect.setOffset(2, 2)
        self.setGraphicsEffect(self.effect)

        self.horzMargin = 20
        self.vertMargin = 5
        self.width = self.horzMargin
        self.height = self.vertMargin
Ejemplo n.º 3
0
    def __init__(self, parent):
        super(QNEConnection, self).__init__(parent)

        self.normalPen = QPen(QApplication.palette().text().color(), 2)
        self.selectedPen = QPen(QApplication.palette().text().color(), 2, Qt.DashLine)
        self.setPen(self.normalPen)
        self.setBrush(QBrush(Qt.NoBrush))
        self.setZValue(-1)
        self.setFlag(QGraphicsItem.ItemIsSelectable)

        self.m_port1 = None
        self.m_port2 = None

        self.pos1 = QPointF()
        self.pos2 = QPointF()
Ejemplo n.º 4
0
    def __init__(self, parent):
        super(QNEConnection, self).__init__(parent)

        self.normalPen = QPen(QApplication.palette().text().color(), 2)
        self.selectedPen = QPen(QApplication.palette().text().color(), 2,
                                Qt.DashLine)
        self.setPen(self.normalPen)
        self.setBrush(QBrush(Qt.NoBrush))
        self.setZValue(-1)
        self.setFlag(QGraphicsItem.ItemIsSelectable)

        self.m_port1 = None
        self.m_port2 = None

        self.pos1 = QPointF()
        self.pos2 = QPointF()
    def __init__(self, pix_ico, parent=None):
        super(StatusToolbarButton, self).__init__(parent)

        self.icon = QPixmap(pix_ico)
        self.setFlat(True)
        self.setFixedSize(TOOLBAR_BUTTON_SIZE, TOOLBAR_BUTTON_SIZE)
        self.new_ui = float(cmds.about(version=True)) >= 2016

        palette = QApplication.palette()
        self.highlight = palette.highlight().color()
Ejemplo n.º 6
0
    def __init__(self, parent):
        super(QNEValue, self).__init__(parent)
        self.parent = parent

        self.setTextWidth(-1)
        self.setZValue(1)

        self.port = None
        self.value = None

        self.background = QApplication.palette().light().color()
Ejemplo n.º 7
0
    def __init__(self, parent):
        super(QNEPort, self).__init__(parent)

        self.label = QGraphicsTextItem(self)
        self.radius_ = 4
        self.margin = 3
        self.widgetWidth = 50

        self.setPen(QPen(QApplication.palette().text().color(), 1))
        self.setBrush(QApplication.palette().highlight())
        self.setFlag(QGraphicsItem.ItemSendsScenePositionChanges)

        self.valueText = QNEValue(self)
        self.valueText.setPort(self)

        self.outputPort = QNEOutputPort(self)

        self.m_portFlags = 0
        self.hasInput_ = False
        self.hasOutput_ = False

        self.m_block = None
        self.m_connections = []
Ejemplo n.º 8
0
    def __init__(self, parent):
        super(QNEPort, self).__init__(parent)

        self.label = QGraphicsTextItem(self)
        self.radius_ = 4
        self.margin = 3
        self.widgetWidth = 50

        self.setPen(QPen(QApplication.palette().text().color(), 1))
        self.setBrush(QApplication.palette().highlight())
        self.setFlag(QGraphicsItem.ItemSendsScenePositionChanges)
        
        self.valueText = QNEValue(self)
        self.valueText.setPort(self)

        self.outputPort = QNEOutputPort(self)

        self.m_portFlags = 0
        self.hasInput_ = False
        self.hasOutput_ = False

        self.m_block = None
        self.m_connections = []
Ejemplo n.º 9
0
 def loadDefaults(self):
     """ 
     Loads defaults settings of pysumo.
     """
     self.setValue("configPath", pysumo.CONFIG_PATH)
     self.setValue("maxQueueSize", 10)
     self.setValue("maxUndoRedoQueueSize", 10)
     self.setValue("flushWriteQueuesTimeout", 10)
     self.setValue("logOutputPath", pysumo.CONFIG_PATH)
     self.setValue("socketOutputPath", pysumo.CONFIG_PATH)
     self.setValue("logLevel", 10)
     defFont = QApplication.font().family()
     defSize = QApplication.font().pointSize()
     self.setValue("keywordsFontFamily", defFont)
     self.setValue("keywordsFontSize", defSize)
     self.setValue("keywordsFontColor", QColor(Qt.darkGreen).name())
     self.setValue("keywordsBoldStyle", True)
     self.setValue("keywordsItalicStyle", False)
     self.setValue("keywordsUnderlinedStyle", False)
     self.setValue("logicExprFontFamily", defFont)
     self.setValue("logicExprFontSize", defSize)
     self.setValue("logicExprFontColor", QColor(Qt.black).name())
     self.setValue("logicExprBoldStyle", True)
     self.setValue("logicExprItalicStyle", False)
     self.setValue("logicExprUnderlinedStyle", False)
     self.setValue("commentFontFamily", defFont)
     self.setValue("commentFontSize", defSize)
     self.setValue("commentFontColor", QColor(Qt.darkMagenta).name())
     self.setValue("commentBoldStyle", False)
     self.setValue("commentItalicStyle", True)
     self.setValue("commentUnderlinedStyle", False)
     self.setValue("stringsFontFamily", defFont)
     self.setValue("stringsFontSize", defSize)
     self.setValue("stringsFontColor", QColor(Qt.red).name())
     self.setValue("stringsBoldStyle", False)
     self.setValue("stringsItalicStyle", False)
     self.setValue("stringsUnderlinedStyle", False)
     self.setValue("maxTextEditorWidgets", 10)
     self.setValue("maxDocumentationWidgets", 10)
     self.setValue("maxHierarchyWidgets", 10)
     self.setValue("maxGraphWidgets", 10)
     self.setValue("defaultFontSize", defSize)
     self.setValue("defaultFontFamily", defFont)
     self.setValue("defaultFontColor",
                   QApplication.palette().text().color().name())
     self.setValue("useHighlightingFontSize", False)
Ejemplo n.º 10
0
    def paint(self, painter, option, index):
        # NODE_REFERENCE ---------------------------------------------------
        if index.column() == NODE_REFERENCE:

            # backup painter
            painter.save()

            # paint background
            palette = QApplication.palette()
            if option.state & QStyle.State_Selected:
                bg_color = palette.highlight().color()
            else:
                bg_color = Qt.transparent
            painter.fillRect(option.rect, bg_color)

            # paint
            value = float(index.model().data(index))
            if value == 0.0:
                painter.setPen(
                    Qt.black
                    if option.state & QStyle.State_Selected
                    else Qt.darkGray
                )
                painter.setBrush(Qt.NoBrush)
                mid_size = 3.0
            else:
                painter.setPen(Qt.darkCyan)
                painter.setBrush(Qt.cyan)
                mid_size = 4.0

            h_center = round(option.rect.x() + (option.rect.width() * .5))
            v_center = round(option.rect.y() + (option.rect.height() * .5))
            losange = QPolygonF()
            losange.append(QPointF(h_center, v_center - mid_size))
            losange.append(QPointF(h_center - mid_size, v_center))
            losange.append(QPointF(h_center, v_center + mid_size))
            losange.append(QPointF(h_center + mid_size, v_center))

            painter.drawPolygon(losange)

            # restore painter
            painter.restore()

        # FILE_STATE -------------------------------------------------------
        elif index.column() == FILE_STATE:

            # backup painter
            painter.save()

            # paint background
            palette = QApplication.palette()
            bg_color = palette.highlight().color() \
                if option.state & QStyle.State_Selected \
                else Qt.transparent
            painter.fillRect(option.rect, bg_color)

            # paint circle
            value = index.model().data(index)

            pen_color = [
                Qt.darkRed,
                Qt.black if option.state & QStyle.State_Selected else Qt.gray,
                Qt.darkGreen][value + 1]
            brush_color = [Qt.red, Qt.NoBrush, Qt.green][value + 1]

            painter.setPen(pen_color)
            painter.setBrush(brush_color)

            h_center = round(option.rect.x() + (option.rect.width() * .5))
            v_center = round(option.rect.y() + (option.rect.height() * .5))
            center = QPointF(h_center, v_center)

            painter.drawEllipse(center, 3.0, 3.0)

            # restore painter
            painter.restore()

        # NODE_NAME --------------------------------------------------------
        elif index.column() == NODE_NAME:
            text = index.model().data(index, Qt.DisplayRole)
            palette = QApplication.palette()
            bg_color = palette.highlight().color() \
                if option.state & QStyle.State_Selected \
                else Qt.transparent
            txt_color = palette.highlightedText().color() \
                if option.state & QStyle.State_Selected \
                else palette.text().color()

            if MTTSettings.value('vizWrongNameState') \
                    and not MTTSettings.value('showWrongNameState'):
                file_name = os.path.splitext(os.path.basename(
                    index.model().data(
                        index.sibling(index.row(), NODE_FILE),
                        Qt.DisplayRole
                    )
                ))[0]
                if not re.split('[0-9]*$', text.rsplit(':')[-1])[0] == \
                        re.split('[0-9]*$', file_name)[0]:
                    bg_color = QBrush(
                        Qt.red
                        if option.state & QStyle.State_Selected
                        else Qt.darkRed,
                        Qt.Dense4Pattern
                    )

            if not MTTSettings.value('showNamespaceState'):
                splits = text.split(':')
                text = splits[len(splits) > 1]

            painter.save()
            painter.fillRect(option.rect, bg_color)
            painter.setPen(txt_color)
            rect = option.rect
            rect.setX(4)
            QApplication.style().drawItemText(
                painter, rect, Qt.AlignLeft | Qt.AlignVCenter,
                palette, True, text
            )
            painter.restore()

        # NODE_FILE ------------------------------------------------------------
        elif index.column() == NODE_FILE:
            palette = QApplication.palette()
            bg_color = palette.highlight().color() \
                if option.state & QStyle.State_Selected \
                else Qt.transparent
            txt_color = palette.highlightedText().color() \
                if option.state & QStyle.State_Selected \
                else palette.text().color()

            text = index.model().data(index, Qt.DisplayRole)
            if MTTSettings.value('vizExternalState'):
                if not text.startswith(self.ws_path):
                    bg_color = QBrush(
                        '#ef7900'
                        if option.state & QStyle.State_Selected
                        else '#b05100',
                        Qt.Dense4Pattern)

            if MTTSettings.value('vizWrongPathState'):
                if not re.match(MTTSettings.PATH_PATTERN, text):
                    bg_color = QBrush(
                        Qt.red
                        if option.state & QStyle.State_Selected
                        else Qt.darkRed,
                        Qt.Dense4Pattern)

            if MTTSettings.value('showBasenameState'):
                text = os.path.basename(text)
            elif not MTTSettings.value('showRealAttributeValue'):
                if not text.startswith('\\'):
                    text = os.path.normpath(cmds.workspace(projectPath=text))

            painter.save()
            painter.fillRect(option.rect, bg_color)
            painter.setPen(txt_color)
            QApplication.style().drawItemText(
                painter, option.rect, Qt.AlignLeft | Qt.AlignVCenter,
                palette, True, text)
            painter.restore()
        else:
            QStyledItemDelegate.paint(self, painter, option, index)
Ejemplo n.º 11
0
def paint_redock_overlay(widget):
    painter = QPainter(widget)
    brush = QBrush(QApplication.palette().color(QPalette.Highlight),
                   Qt.Dense6Pattern)
    painter.fillRect(widget.rect(), brush)
Ejemplo n.º 12
0
    def paint(self, painter, option, index):
        # NODE_REFERENCE ---------------------------------------------------
        if index.column() == NODE_REFERENCE:

            # backup painter
            painter.save()

            # paint background
            palette = QApplication.palette()
            if option.state & QStyle.State_Selected:
                bg_color = palette.highlight().color()
            else:
                bg_color = Qt.transparent
            painter.fillRect(option.rect, bg_color)

            # paint
            value = float(index.model().data(index))
            if value == 0.0:
                painter.setPen(Qt.black if option.state
                               & QStyle.State_Selected else Qt.darkGray)
                painter.setBrush(Qt.NoBrush)
                mid_size = 3.0
            else:
                painter.setPen(Qt.darkCyan)
                painter.setBrush(Qt.cyan)
                mid_size = 4.0

            h_center = round(option.rect.x() + (option.rect.width() * .5))
            v_center = round(option.rect.y() + (option.rect.height() * .5))
            losange = QPolygonF()
            losange.append(QPointF(h_center, v_center - mid_size))
            losange.append(QPointF(h_center - mid_size, v_center))
            losange.append(QPointF(h_center, v_center + mid_size))
            losange.append(QPointF(h_center + mid_size, v_center))

            painter.drawPolygon(losange)

            # restore painter
            painter.restore()

        # FILE_STATE -------------------------------------------------------
        elif index.column() == FILE_STATE:

            # backup painter
            painter.save()

            # paint background
            palette = QApplication.palette()
            bg_color = palette.highlight().color() \
                if option.state & QStyle.State_Selected \
                else Qt.transparent
            painter.fillRect(option.rect, bg_color)

            # paint circle
            value = index.model().data(index)

            pen_color = [
                Qt.darkRed,
                Qt.black if option.state & QStyle.State_Selected else Qt.gray,
                Qt.darkGreen
            ][value + 1]
            brush_color = [Qt.red, Qt.NoBrush, Qt.green][value + 1]

            painter.setPen(pen_color)
            painter.setBrush(brush_color)

            h_center = round(option.rect.x() + (option.rect.width() * .5))
            v_center = round(option.rect.y() + (option.rect.height() * .5))
            center = QPointF(h_center, v_center)

            painter.drawEllipse(center, 3.0, 3.0)

            # restore painter
            painter.restore()

        # NODE_NAME --------------------------------------------------------
        elif index.column() == NODE_NAME:
            text = index.model().data(index, Qt.DisplayRole)
            palette = QApplication.palette()
            bg_color = palette.highlight().color() \
                if option.state & QStyle.State_Selected \
                else Qt.transparent
            txt_color = palette.highlightedText().color() \
                if option.state & QStyle.State_Selected \
                else palette.text().color()

            if MTTSettings.value('vizWrongNameState') \
                    and not MTTSettings.value('showWrongNameState'):
                file_name = os.path.splitext(
                    os.path.basename(index.model().data(
                        index.sibling(index.row(), NODE_FILE),
                        Qt.DisplayRole)))[0]
                if not re.split('[0-9]*$', text.rsplit(':')[-1])[0] == \
                        re.split('[0-9]*$', file_name)[0]:
                    bg_color = QBrush(
                        Qt.red if option.state
                        & QStyle.State_Selected else Qt.darkRed,
                        Qt.Dense4Pattern)

            if not MTTSettings.value('showNamespaceState'):
                splits = text.split(':')
                text = splits[len(splits) > 1]

            painter.save()
            painter.fillRect(option.rect, bg_color)
            painter.setPen(txt_color)
            rect = option.rect
            rect.setX(4)
            QApplication.style().drawItemText(painter, rect,
                                              Qt.AlignLeft | Qt.AlignVCenter,
                                              palette, True, text)
            painter.restore()

        # NODE_FILE ------------------------------------------------------------
        elif index.column() == NODE_FILE:
            palette = QApplication.palette()
            bg_color = palette.highlight().color() \
                if option.state & QStyle.State_Selected \
                else Qt.transparent
            txt_color = palette.highlightedText().color() \
                if option.state & QStyle.State_Selected \
                else palette.text().color()

            text = index.model().data(index, Qt.DisplayRole)
            if MTTSettings.value('vizExternalState'):
                if not text.startswith(self.ws_path):
                    bg_color = QBrush(
                        '#ef7900' if option.state
                        & QStyle.State_Selected else '#b05100',
                        Qt.Dense4Pattern)

            if MTTSettings.value('vizWrongPathState'):
                if not re.match(MTTSettings.PATH_PATTERN, text):
                    bg_color = QBrush(
                        Qt.red if option.state
                        & QStyle.State_Selected else Qt.darkRed,
                        Qt.Dense4Pattern)

            if MTTSettings.value('showBasenameState'):
                text = os.path.basename(text)
            elif not MTTSettings.value('showRealAttributeValue'):
                if not text.startswith('\\'):
                    text = os.path.normpath(cmds.workspace(projectPath=text))

            painter.save()
            painter.fillRect(option.rect, bg_color)
            painter.setPen(txt_color)
            QApplication.style().drawItemText(painter, option.rect,
                                              Qt.AlignLeft | Qt.AlignVCenter,
                                              palette, True, text)
            painter.restore()
        else:
            QStyledItemDelegate.paint(self, painter, option, index)