예제 #1
0
    def _generate_items_from_node_dict(self):
        node_names = sorted(self._node_dict.keys())
        node_types = sorted(self._node_dict.values())

        self._menus.clear()
        self._actions.clear()
        self._searched_actions.clear()

        for node_type in node_types:
            menu_name = ".".join(node_type.split(".")[:-1])
            if menu_name not in self._menus.keys():
                new_menu = QtWidgets.QMenu(menu_name)
                new_menu.setStyleSheet(STYLE_QMENU)
                self._menus[menu_name] = new_menu
                self.SearchMenu.addMenu(new_menu)

        for name in node_names:
            action = QtWidgets.QAction(name, self)
            action.setText(name)
            action.triggered.connect(self._on_search_submitted)
            self._actions.append(action)

            menu_name = self._node_dict[name]
            menu_name = ".".join(menu_name.split(".")[:-1])

            if menu_name in self._menus.keys():
                self._menus[menu_name].addAction(action)
            else:
                self.SearchMenu.addAction(action)
예제 #2
0
    def __init__(self, parent=None, node_graph=None):
        super(PropertiesBinWidget, self).__init__(parent)
        self.setWindowTitle('Properties Bin')
        self._prop_list = PropertiesList()
        self._limit = QtWidgets.QSpinBox()
        self._limit.setToolTip('Set display nodes limit.')
        self._limit.setMaximum(10)
        self._limit.setMinimum(0)
        self._limit.setValue(5)
        self._limit.valueChanged.connect(self.__on_limit_changed)
        self.resize(400, 400)

        self._block_signal = False

        btn_clr = QtWidgets.QPushButton('clear')
        btn_clr.setToolTip('Clear the properties bin.')
        btn_clr.clicked.connect(self.clear_bin)

        top_layout = QtWidgets.QHBoxLayout()
        top_layout.addWidget(self._limit)
        top_layout.addStretch(1)
        top_layout.addWidget(btn_clr)

        layout = QtWidgets.QVBoxLayout(self)
        layout.addLayout(top_layout)
        layout.addWidget(self._prop_list, 1)

        # wire up node graph.
        node_graph.add_properties_bin(self)
        node_graph.node_double_clicked.connect(self.add_node)
        node_graph.property_changed.connect(self.__on_graph_property_changed)
예제 #3
0
    def __init__(self, parent=None, name='', label='', text='', ext="*"):
        super(NodeLineEdit, self).__init__(parent, name, label)
        self._ledit = QtWidgets.QLineEdit()
        self._ledit.setStyleSheet(STYLE_QLINEEDIT)
        self._ledit.setAlignment(QtCore.Qt.AlignCenter)
        self._ledit.editingFinished.connect(self._value_changed)
        self._ledit.clearFocus()

        _button = QtWidgets.QPushButton()
        _button.setStyleSheet(STYLE_QPUSHBUTTON)
        _button.setIcon(self.get_icon(21))

        widget = QtWidgets.QWidget()
        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self._ledit)
        hbox.addWidget(_button)
        widget.setLayout(hbox)
        widget.setStyleSheet(STYLE_QWIDGET)

        group = _NodeGroupBox(label)
        group.add_node_widget(widget)
        self.text = text

        _button.clicked.connect(self._on_select_file)
        self.setWidget(group)
        self._ext = ext
예제 #4
0
    def __init__(self, parent=None):
        super(PropWindow, self).__init__(parent)
        self.__layout = QtWidgets.QGridLayout()
        self.__layout.setColumnStretch(1, 1)
        self.__layout.setSpacing(6)

        layout = QtWidgets.QVBoxLayout(self)
        layout.setAlignment(QtCore.Qt.AlignTop)
        layout.addLayout(self.__layout)
예제 #5
0
    def __init__(self, parent=None):
        super(NodeViewer, self).__init__(parent)
        if parent is not None:
            self.setWindowFlags(QtCore.Qt.Window)

        scene_pos = (SCENE_AREA / 2) * -1
        self.setScene(NodeScene(self))
        self.setSceneRect(scene_pos, scene_pos, SCENE_AREA, SCENE_AREA)
        self.setRenderHint(QtGui.QPainter.Antialiasing, True)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setViewportUpdateMode(QtWidgets.QGraphicsView.FullViewportUpdate)
        self.setAcceptDrops(True)
        self.resize(1000, 800)

        self._pipe_layout = PIPE_LAYOUT_CURVED
        self._detached_port = None
        self._start_port = None
        self._origin_pos = None
        self._previous_pos = QtCore.QPoint(self.width(), self.height())
        self._prev_selection = []
        self._node_positions = {}
        self._rubber_band = QtWidgets.QRubberBand(
            QtWidgets.QRubberBand.Rectangle, self)

        self._LIVE_PIPE = LivePipe()
        self._LIVE_PIPE.setVisible(False)
        self.scene().addItem(self._LIVE_PIPE)

        self._SLICER_PIPE = SlicerPipe()
        self._SLICER_PIPE.setVisible(False)
        self.scene().addItem(self._SLICER_PIPE)

        self._undo_stack = QtWidgets.QUndoStack(self)
        self._context_menu = QtWidgets.QMenu('main', self)
        self._context_menu.setStyleSheet(STYLE_QMENU)
        self._search_widget = TabSearchWidget(self)
        self._search_widget.search_submitted.connect(self._on_search_submitted)

        # workaround fix for shortcuts from the non-native menu actions
        # don't seem to trigger so we create a hidden menu bar.
        menu_bar = QtWidgets.QMenuBar(self)
        menu_bar.setNativeMenuBar(False)
        # shortcuts don't work with "setVisibility(False)".
        menu_bar.resize(0, 0)
        menu_bar.addMenu(self._context_menu)

        self.acyclic = True
        self.LMB_state = False
        self.RMB_state = False
        self.MMB_state = False
        self.ALT_state = False
        self.CTRL_state = False
        self.SHIFT_state = False
예제 #6
0
    def widget(self):
        """
        The node graph widget for adding into a layout.

        Returns:
            QtWidgets.QWidget: node graph widget.
        """
        if self._widget is None:
            self._widget = QtWidgets.QWidget()
            layout = QtWidgets.QVBoxLayout(self._widget)
            layout.setContentsMargins(0, 0, 0, 0)
            layout.addWidget(self._viewer)
        return self._widget
예제 #7
0
    def __init__(self, parent=None):
        super(PropColorPicker, self).__init__(parent)
        self._color = (0, 0, 0)
        self._label = QtWidgets.QLabel()
        self._button = QtWidgets.QPushButton()
        self._update_color()

        self._button.clicked.connect(self._on_select_color)
        layout = QtWidgets.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 8, 0)
        layout.setSpacing(4)
        layout.addWidget(self._label, 0, QtCore.Qt.AlignCenter)
        layout.addWidget(self._button, 1, QtCore.Qt.AlignLeft)
예제 #8
0
 def __init__(self, name='node', parent=None):
     super(NodeItem, self).__init__(name, parent)
     pixmap = QtGui.QPixmap(ICON_NODE_BASE)
     if pixmap.size().height() > NODE_ICON_SIZE:
         pixmap = pixmap.scaledToHeight(NODE_ICON_SIZE,
                                        QtCore.Qt.SmoothTransformation)
     self._properties['icon'] = ICON_NODE_BASE
     self._icon_item = QtWidgets.QGraphicsPixmapItem(pixmap, self)
     self._icon_item.setTransformationMode(QtCore.Qt.SmoothTransformation)
     self._text_item = QtWidgets.QGraphicsTextItem(self.name, self)
     self._x_item = XDisabledItem(self, 'DISABLED')
     self._input_items = {}
     self._output_items = {}
     self._widgets = {}
예제 #9
0
    def __init__(self, parent=None):
        super(NodeGraph, self).__init__(parent)
        self.setObjectName('NodeGraphQt')
        self._model = NodeGraphModel()
        self._viewer = NodeViewer(parent)
        self._node_factory = NodeFactory()
        self._undo_stack = QtWidgets.QUndoStack(self)

        tab = QtWidgets.QAction('Search Nodes', self)
        tab.setShortcut('tab')
        tab.triggered.connect(self._toggle_tab_search)
        self._viewer.addAction(tab)

        self._wire_signals()
예제 #10
0
    def __init__(self, parent=None):
        super(NodeGraph, self).__init__(parent)
        self.setObjectName('NodeGraphQt')
        self._widget = None
        self._model = NodeGraphModel()
        self._viewer = NodeViewer()
        self._node_factory = NodeFactory()
        self._undo_stack = QtWidgets.QUndoStack(self)

        tab = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Tab), self._viewer)
        tab.activated.connect(self._toggle_tab_search)
        self._viewer.need_show_tab_search.connect(self._toggle_tab_search)

        self._wire_signals()
        self.widget.setAcceptDrops(True)
예제 #11
0
    def __init__(self, parent=None):
        super(PropColorPicker, self).__init__(parent)
        self._solid = _ColorSolid(self)
        self._solid.setMaximumHeight(15)
        self._label = QtWidgets.QLabel()
        self._update_label()

        button = QtWidgets.QPushButton('select color')
        button.clicked.connect(self._on_select_color)
        layout = QtWidgets.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 8, 0)
        layout.setSpacing(4)
        layout.addWidget(self._solid, 0, QtCore.Qt.AlignCenter)
        layout.addWidget(self._label, 0, QtCore.Qt.AlignCenter)
        layout.addWidget(button, 1, QtCore.Qt.AlignLeft)
예제 #12
0
 def __init__(self, parent=None, name='', label='', items=None):
     super(NodeComboBox, self).__init__(parent, name, label)
     self.setZValue(Z_VAL_NODE_WIDGET + 1)
     self._combo = QtWidgets.QComboBox()
     self._combo.setStyleSheet(STYLE_QCOMBOBOX)
     self._combo.setMinimumHeight(24)
     self._combo.currentIndexChanged.connect(self._value_changed)
     list_view = QtWidgets.QListView(self._combo)
     list_view.setStyleSheet(STYLE_QLISTVIEW)
     self._combo.setView(list_view)
     self._combo.clearFocus()
     self.add_items(items)
     group = _NodeGroupBox(label)
     group.add_node_widget(self._combo)
     self.setWidget(group)
예제 #13
0
def messageBox(text, title , buttons):
    msg = QtWidgets.QMessageBox()
    msg.setStyleSheet(STYLE_MESSAGEBOX)
    msg.setWindowTitle(title)
    msg.setInformativeText(text)
    msg.setStandardButtons(buttons)
    return msg.exec_()
예제 #14
0
    def add_node(self, node):
        """
        Add node to the properties bin.

        Args:
            node (NodeGraphQt.Node): node object.
        """
        if self.limit() == 0:
            return

        rows = self._prop_list.rowCount()
        if rows >= self.limit():
            self._prop_list.removeRow(rows - 1)

        itm_find = self._prop_list.findItems(node.id, QtCore.Qt.MatchExactly)
        if itm_find:
            self._prop_list.removeRow(itm_find[0].row())

        self._prop_list.insertRow(0)
        prop_widget = NodePropWidget(node=node)
        prop_widget.property_changed.connect(self.property_changed.emit)
        prop_widget.property_closed.connect(self.__on_prop_close)
        self._prop_list.setCellWidget(0, 0, prop_widget)

        item = QtWidgets.QTableWidgetItem(node.id)
        self._prop_list.setItem(0, 0, item)
        self._prop_list.selectRow(0)
예제 #15
0
    def __init__(self, visualScripting: VisualScripting, parentWindow=None):
        super().__init__()

        self.graph = NodeGraph()
        self.graphViewer = self.graph.viewer()

        self.graphManager = visualScripting.graphManager

        self.initNodes()
        self.setupPropertiesBin()

        self.window = asset_manager.loadUI("graphQt.ui")

        self.splitter = QtWidgets.QSplitter()
        self.window.bottomLayout.addWidget(self.splitter)
        self.splitter.addWidget(self.nodeTree)
        self.splitter.addWidget(self.graphViewer)
        self.splitter.addWidget(self.propertiesBin)

        self.setupMenuBar(self.graph)

        self.onSaveEvent = Event()

        self.dockWidgets: List[QtWidgets.QDockWidget] = []

        self.settingsViewer = SettingsViewer(self.window, visualScripting)
        self.setupDockWidget(self.settingsViewer.dockWidget)
예제 #16
0
    def add_widget(self, name, widget, value, label=None):
        """
        Add a property widget to the window.

        Args:
            name (str): property name to be displayed.
            widget (BaseProperty): property widget.
            value (object): property value.
            label (str): custom label to display.
        """
        widget.setToolTip(name)
        widget.set_value(value)
        if label is None:
            label = name
        row = self.__layout.rowCount()
        if row > 0:
            row += 1

        label = QtWidgets.QLabel(label)
        label_flags = QtCore.Qt.AlignCenter | QtCore.Qt.AlignRight
        if widget.__class__.__name__ == 'PropTextEdit':
            label_flags = label_flags | QtCore.Qt.AlignTop
        elif widget.__class__.__name__ == 'PropButton':
            label.setVisible(False)
            widget.setText(name)
        self.__layout.addWidget(label, row, 0, label_flags)
        self.__layout.addWidget(widget, row, 1)
예제 #17
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.parentNodeItem = parent
        self.resizeEventListener = None
        self.setZValue(Z_VAL_NODE_WIDGET)

        self._frame = QtWidgets.QFrame()
        self._frame.setObjectName("_mainNodeFrame")
        self._layout = QtWidgets.QVBoxLayout()
        self._layout.setSpacing(1)
        self._frame.setLayout(self._layout)
        self._frame.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding)

        self._frame.setStyleSheet(
            "QFrame#_mainNodeFrame { background-color:transparent; }")

        self.setWidget(self._frame)
예제 #18
0
    def __init__(self, parent=None, dim=3):
        super(PropVector, self).__init__(parent)
        hbox = QtWidgets.QHBoxLayout()
        self._value = []
        self._items = []

        for i in range(dim):
            self._add_item(i, hbox)

        self._can_emit = True
        self.setLayout(hbox)
예제 #19
0
    def __init__(self, parent=None):
        super(PropFilePath, self).__init__(parent)
        self._ledit = QtWidgets.QLineEdit()
        self._ledit.setAlignment(QtCore.Qt.AlignLeft)
        self._ledit.editingFinished.connect(self._on_value_change)
        self._ledit.clearFocus()

        icon = self.style().standardIcon(QtWidgets.QStyle.StandardPixmap(21))
        _button = QtWidgets.QPushButton()
        _button.setIcon(icon)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self._ledit)
        hbox.addWidget(_button)
        self.setLayout(hbox)
        _button.clicked.connect(self._on_select_file)

        self._ledit.setStyleSheet("QLineEdit{border:1px solid}")
        _button.setStyleSheet("QPushButton{border:1px solid}")
        self._ext = "*"
예제 #20
0
    def __init__(self, onClick, parent=None, name='', label=''):
        super(NodeButton, self).__init__(parent, name, label)
        self.btn = QtWidgets.QPushButton()
        self.btn.setText(name)
        self.btn.clicked.connect(onClick)
        group = _NodeGroupBox(label)

        group.add_node_widget(self.btn)
        group.setAlignment(QtCore.Qt.AlignCenter)
        group._layout.setAlignment(QtCore.Qt.AlignCenter)
        self.setWidget(group)
예제 #21
0
 def __init__(self, parent=None, name='', label='', text=''):
     super(NodeLineEdit, self).__init__(parent, name, label)
     self._ledit = QtWidgets.QLineEdit()
     self._ledit.setStyleSheet(STYLE_QLINEEDIT)
     self._ledit.setAlignment(QtCore.Qt.AlignCenter)
     self._ledit.returnPressed.connect(self._value_changed)
     self._ledit.clearFocus()
     group = _NodeGroupBox(label)
     group.add_node_widget(self._ledit)
     self.setWidget(group)
     self.text = text
예제 #22
0
    def __init__(self, parent=None, node=None):
        super(NodePropWidget, self).__init__(parent)
        self.__node_id = node.id
        self.__tab_windows = {}
        self.__tab = QtWidgets.QTabWidget()

        close_btn = QtWidgets.QPushButton('X')
        close_btn.setToolTip('close property')
        close_btn.clicked.connect(self._on_close)

        self.name_wgt = PropLineEdit()
        self.name_wgt.setToolTip('name')
        self.name_wgt.set_value(node.name())
        self.name_wgt.value_changed.connect(self._on_property_changed)

        self.type_wgt = QtWidgets.QLabel(node.type_)
        self.type_wgt.setAlignment(QtCore.Qt.AlignRight)
        self.type_wgt.setToolTip('type_')
        font = self.type_wgt.font()
        font.setPointSize(10)
        self.type_wgt.setFont(font)

        name_layout = QtWidgets.QHBoxLayout()
        name_layout.setContentsMargins(0, 0, 0, 0)
        name_layout.addWidget(QtWidgets.QLabel('name'))
        name_layout.addWidget(self.name_wgt)
        name_layout.addWidget(close_btn)
        layout = QtWidgets.QVBoxLayout(self)
        layout.setSpacing(4)
        layout.addLayout(name_layout)
        layout.addWidget(self.__tab)
        layout.addWidget(self.type_wgt)
        self._read_node(node)
예제 #23
0
    def add_menu(self, name):
        """
        Adds a child menu to the current menu.

        Args:
            name (str): menu name.

        Returns:
            NodeGraphQt.Menu: the appended menu item.
        """
        menu = QtWidgets.QMenu(name, self.qmenu)
        self.qmenu.addMenu(menu)
        return Menu(self.__viewer, menu)
예제 #24
0
    def __init__(self, label, parent=None):
        super(_NodeGroupBox, self).__init__(parent)
        margin = (0, 0, 0, 0)
        padding_top = '14px'
        if label == '':
            margin = (0, 2, 0, 0)
            padding_top = '2px'
        style = STYLE_QGROUPBOX.replace('$PADDING_TOP', padding_top)
        self.setTitle(label)
        self.setStyleSheet(style)

        self._layout = QtWidgets.QVBoxLayout(self)
        self._layout.setContentsMargins(*margin)
        self._layout.setSpacing(1)
예제 #25
0
    def widget(self):
        """
        The node graph widget for adding into a layout.

        Returns:
            PySide2.QtWidgets.QWidget: node graph widget.
        """
        if self._widget is None:
            self._widget = QWidgetDrops()
            self._widget.import_session = self.import_session
            
                        layout = QtWidgets.QVBoxLayout(self._widget)
            layout.setContentsMargins(0, 0, 0, 0)
            layout.addWidget(self._viewer)
예제 #26
0
    def __init__(self, parent=None, node_dict=None):
        super(TabSearchMenuWidget, self).__init__(parent)
        self.setAttribute(QtCore.Qt.WA_MacShowFocusRect, 0)
        self.setStyleSheet(STYLE_TABSEARCH)
        self.setMinimumSize(200, 22)
        self.setTextMargins(2, 0, 2, 0)

        self._node_dict = node_dict or {}
        if self._node_dict:
            self._generate_items_from_node_dict()

        self.SearchMenu = QtWidgets.QMenu()
        searchWidget = QtWidgets.QWidgetAction(self)
        searchWidget.setDefaultWidget(self)
        self.SearchMenu.addAction(searchWidget)
        self.SearchMenu.setStyleSheet(STYLE_QMENU)

        self._actions = []
        self._menus = {}
        self._searched_actions = []

        self.returnPressed.connect(self._on_search_submitted)
        self.textChanged.connect(self._on_text_changed)
예제 #27
0
    def __init__(self, parent=None):
        super(PropertiesBinWidget, self).__init__(parent)
        self.setWindowTitle('Properties Bin')
        self._prop_list = PropertiesList()
        self._limit = QtWidgets.QSpinBox()
        self._limit.setToolTip('Set node limit to display.')
        self._limit.setMaximum(10)
        self._limit.setMinimum(0)
        self._limit.setValue(10)
        self._limit.valueChanged.connect(self.__on_limit_changed)
        self.resize(400, 400)

        btn_clr = QtWidgets.QPushButton('clear')
        btn_clr.setToolTip('Clear the properties bin.')
        btn_clr.clicked.connect(self.clear_bin)

        top_layout = QtWidgets.QHBoxLayout()
        top_layout.addWidget(self._limit)
        top_layout.addStretch(1)
        top_layout.addWidget(btn_clr)

        layout = QtWidgets.QVBoxLayout(self)
        layout.addLayout(top_layout)
        layout.addWidget(self._prop_list, 1)
예제 #28
0
 def _init(self):
     self._slider.setOrientation(QtCore.Qt.Horizontal)
     self._slider.setTickPosition(QtWidgets.QSlider.TicksBelow)
     self._slider.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                QtWidgets.QSizePolicy.Preferred)
     self._spnbox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
     layout = QtWidgets.QHBoxLayout(self)
     layout.addWidget(self._spnbox)
     layout.addWidget(self._slider)
     self._spnbox.valueChanged.connect(self._on_spnbox_changed)
     self._slider.valueChanged.connect(self._on_slider_changed)
     # store the original press event.
     self._slider_press_event = self._slider.mousePressEvent
     self._slider.mousePressEvent = self.sliderMousePressEvent
     self._slider.mouseReleaseEvent = self.sliderMouseReleaseEvent
예제 #29
0
 def __init__(self, parent=None, name='', label='', text='', state=False):
     super(NodeCheckBox, self).__init__(parent, name, label)
     self._cbox = QtWidgets.QCheckBox(text)
     self._cbox.setChecked(state)
     self._cbox.setMinimumWidth(80)
     self._cbox.setStyleSheet(STYLE_QCHECKBOX)
     font = self._cbox.font()
     font.setPointSize(11)
     self._cbox.setFont(font)
     self._cbox.stateChanged.connect(self._value_changed)
     group = _NodeGroupBox(label)
     group.add_node_widget(self._cbox)
     self.setWidget(group)
     self.text = text
     self.state = state
예제 #30
0
    def __init__(self, parent=None):
        super(_valueSliderEdit, self).__init__(parent)
        self._edit = _valueEdit()
        self._edit.valueChanged.connect(self._on_edit_changed)
        self._edit.setMaximumWidth(70)
        self._slider = _slider()
        self._slider.valueChanged.connect(self._on_slider_changed)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self._edit)
        hbox.addWidget(self._slider)
        self.setLayout(hbox)

        self._mul = 1000.0
        self.set_min(0)
        self.set_max(10)
        self.set_data_type(float)
        self._lock = False