Ejemplo n.º 1
0
    def __init__(self, node, text, secondaryText="", icon=None, parent=None):
        super(NodeHeader, self).__init__(parent)
        self._node = node

        self.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))

        layout = QtWidgets.QGraphicsLinearLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.setOrientation(QtCore.Qt.Horizontal)
        self.setLayout(layout)
        self.headerIcon = HeaderPixmap(pixmap=icon or "", parent=self)
        layout.addItem(self.headerIcon)
        if not icon:
            self.headerIcon.hide()
        self._createLabels(text, secondaryText, layout)
        layout.addStretch(1)
        headerButton = NodeHeaderButton(size=12,
                                        color=node.model.headerButtonColor())
        headerButton.stateChanged.connect(self.headerButtonStateChanged.emit)
        layout.addItem(headerButton)
        layout.setAlignment(headerButton,
                            QtCore.Qt.AlignCenter | QtCore.Qt.AlignCenter)
Ejemplo n.º 2
0
    def init(self):
        layout = QtWidgets.QGraphicsLinearLayout(parent=self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.setOrientation(QtCore.Qt.Vertical)
        self.header = NodeHeader(self,
                                 self.model.text(),
                                 self.model.secondaryText(),
                                 parent=self)
        self.header.headerTextChanged.connect(self.onHeaderTextChanged)
        self.header.headerButtonStateChanged.connect(
            self.onHeaderButtonStateChanged)
        self.attributeContainer = graphicitems.ItemContainer(parent=self)
        self.attributeContainer.layout().setSpacing(0)
        self.setToolTip(self.model.toolTip())
        layout.addItem(self.header)
        layout.addItem(self.attributeContainer)
        # bind the objectModel signals to this qNode
        self.model.addAttributeSig.connect(self.addAttribute)
        self.model.attributeNameChangedSig.connect(self.setAttributeName)
        self.model.nodeNameChangedSig.connect(self.header.setText)
        self.model.removeAttributeSig.connect(self.removeAttribute)

        self.model.selectionChangedSig.connect(self.setSelected)
        # objectModel.progressUpdatedSig.connect(self)
        # objectModel.parentChangedSig.connect(self)
        self.setLayout(layout)
        # now bind the attributes from the model if it has any
        for attr in self.model.attributes(
                inputs=True,
                outputs=True,
                attributeVisLevel=ATTRIBUTE_VIS_LEVEL_ONE):
            self.addAttribute(attr)
Ejemplo n.º 3
0
 def __init__(self, orientation=QtCore.Qt.Vertical, parent=None):
     super(ItemContainer, self).__init__(parent=parent)
     self.setSizePolicy(
         QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                               QtWidgets.QSizePolicy.Expanding))
     layout = QtWidgets.QGraphicsLinearLayout()
     layout.setSpacing(2)
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setOrientation(orientation)
     self.setLayout(layout)
Ejemplo n.º 4
0
    def __init__(self, node, text, parent=None):
        super(NodeHeader, self).__init__(parent)
        self._node = node
        self.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))

        layout = QtWidgets.QGraphicsLinearLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.setOrientation(QtCore.Qt.Horizontal)
        self.setLayout(layout)
        self._createLabel(text, layout)
        layout.addStretch(1)
Ejemplo n.º 5
0
    def __init__(self, text, *args, **kwargs):
        super(TextContainer, self).__init__(*args, **kwargs)
        self.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))
        layout = QtWidgets.QGraphicsLinearLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.setOrientation(QtCore.Qt.Horizontal)
        self.setLayout(layout)

        self.title = GraphicsText(text, parent=self)
        layout.addItem(self.title)
        layout.setAlignment(self.title,
                            QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop)
Ejemplo n.º 6
0
 def __init__(self, model, acceptsContextMenu=True, parent=None):
     super(PanelWidget, self).__init__(parent=parent)
     self.setFlag(self.ItemSendsScenePositionChanges)
     self.setFlag(self.ItemIgnoresTransformations)
     self.model = model
     self.leftPanel = Panel(model,
                            ioType="Input",
                            acceptsContextMenu=acceptsContextMenu)
     self.rightPanel = Panel(model,
                             ioType="Output",
                             acceptsContextMenu=acceptsContextMenu)
     self.leftPanel.setMaximumWidth(model.config.panelWidth)
     self.rightPanel.setMaximumWidth(model.config.panelWidth)
     layout = QtWidgets.QGraphicsLinearLayout(parent=self)
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(0)
     layout.setOrientation(QtCore.Qt.Horizontal)
     layout.addItem(self.leftPanel)
     layout.addStretch(1)
     layout.addItem(self.rightPanel)
     self.setLayout(layout)
Ejemplo n.º 7
0
    def __init__(self, pixmap, title="", parent=None):
        super(GraphicsThumbnailWidget, self).__init__(parent)
        self.selected = False
        self._size = QtCore.QSizeF()

        layout = QtWidgets.QGraphicsLinearLayout(QtCore.Qt.Vertical, self)
        layout.setSpacing(2)
        layout.setContentsMargins(5, 5, 5, 5)
        self.setContentsMargins(0, 0, 0, 0)

        self.pixmapWidget = graphicspixmap.GraphicsPixmapWidget(pixmap, self)
        self.labelWidget = graphicitems.TextContainer(title, self)

        layout.addItem(self.pixmapWidget)
        layout.addItem(self.labelWidget)

        layout.setAlignment(self.pixmapWidget, QtCore.Qt.AlignCenter)
        layout.setAlignment(self.labelWidget, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom)
        self.setLayout(layout)

        self.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                           QtWidgets.QSizePolicy.MinimumExpanding)
Ejemplo n.º 8
0
    def __init__(self,
                 objectModel,
                 ioType,
                 acceptsContextMenu=False,
                 parent=None):
        super(Panel, self).__init__(parent=parent)
        self.model = objectModel
        self.ioType = ioType
        layout = QtWidgets.QGraphicsLinearLayout(parent=self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(1)
        layout.setOrientation(QtCore.Qt.Vertical)
        self.attributeContainer = graphicitems.ItemContainer(parent=self)
        layout.addItem(self.attributeContainer)
        self.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))
        self.acceptsContextMenu = acceptsContextMenu

        self.setLayout(layout)
        self.setFlags(self.flags() & QtCore.Qt.ItemIsSelectable)
        self.setZValue(100)
        self.refresh()