예제 #1
0
    def createNodeTree(self, parent, node_path=None):
        """Builds node tree from node"""
        if not node_path:
            # create root node item
            root_item = QtGui.QTreeWidgetItem(self)
            root_item.setExpanded(True)
            root_item.setIcon(0, QtGui.QIcon(engine.iconName()))
            root_item.setText(0, "/")
            root_item.setText(1, "/")
            self.nodes_map["/"] = root_item
            self.createNodeTree(root_item, "/")
        else:
            node = engine.node(node_path)
            if node:
                for child_node in node.children():
                    item = QtGui.QTreeWidgetItem(parent)
                    item.setExpanded(True)

                    if child_node.iconName():
                        item.setIcon(0, QtGui.QIcon(child_node.iconName()))

                    item.setText(0, child_node.name())
                    item.setText(1, child_node.path())
                    self.nodes_map[child_node.path()] = item
                    if child_node.children():
                        self.createNodeTree(item, child_node.path())

        self.sortByColumn(0, QtCore.Qt.AscendingOrder)
예제 #2
0
    def selectNode(self, node_path):
        if node_path not in self.nodes_map:
            # If node is not in map we need to rebuild visual network
            self.buildNetworkLevel(engine.node(node_path).parent().path())

        # highlight selected node
        self.nodes_map[node_path].select()
 def dragEnterEvent(self, event):
     if event.mimeData().hasFormat("text/plain"):
         node_path = str(event.mimeData().text())
         node = hou.node(node_path)
         if node:
             if node.type().category().name() == "Cop2":
                 event.acceptProposedAction()
예제 #4
0
    def buildPathBar(self, node_path=None):
        node = engine.node(node_path)
        if not node:
            return False
        elif node.isRoot():
            btn = QtGui.QPushButton()
        else:
            parent = node.parent()
            if parent.isRoot():
                parent = node

            for i in reversed(range(self.path_layout.count())): 
                self.path_layout.itemAt(i).widget().deleteLater()

            btn = None

            path_nodes = parent.pathAsNodeList()

            for node in path_nodes:
                btn = QtGui.QPushButton()
                btn.setIcon(QtGui.QIcon(node.iconName()))
                btn.setText(node.name())
                btn.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)

                menu = QtGui.QMenu()
                menu.addAction('This is Action 1')
                menu.addAction('This is Action 2')
                btn.setMenu(menu)

                self.path_layout.addWidget(btn)

        if btn:
            btn.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)

        return True
예제 #5
0
 def addNode(self, node_path=None):
     if node_path:
         node = engine.node(node_path)
         if node:
             node_item= NodeItem(node)
             self.addItem(node_item)
             self.nodes_map[node_path] = node_item
             node_item.autoPlace()
예제 #6
0
 def buildNetworkLevel(self, node_path=None):
     node = engine.node(node_path)
     if node:
         self.network_level = node_path
         self.nodes_map = {}
         self.clear()
         # build node boxes
         for child in node.children():
             self.addNode(child.path())
    def updateNodeDisplay(self, node_path=None):
        node = hou.node(node_path)
        if node and node == self.node:  # ensure we a re updating the same node as shown before
            print "Updating node display: %s" % node.path()
            if node.needsToCook():
                self.node.cook()

            self.image_width = self.node.xRes()
            self.image_height = self.node.yRes()
            self.rebuild_node_image = True

            self.updateGL()
    def setNodeToDisplay(self, node_path=None):
        node = hou.node(node_path)
        if node:
            print "Showing node %s" % node.path()
            node_path = str(node_path)
            if self.node != node:
                self.node = node
                if node.needsToCook():
                    self.node.cook()

                self.image_width = self.node.xRes()
                self.image_height = self.node.yRes()
                self.rebuild_node_image = True

        else:
            self.emptyView()

        self.updateGL()
예제 #9
0
    def contextMenuEvent(self, event):
        network_node = engine.node(self.network_level)

        menu = QtGui.QMenu(event.widget())
        group = QtGui.QActionGroup(menu)
        menu.addAction('Tool Menu...')

        add_operators_menu = menu.addMenu("Add")

        node_types = network_node.childTypeCategory().nodeTypes()
        for node_type_name, node_class in node_types.iteritems():
            icon = QtGui.QIcon(node_class.iconName())
            action = add_operators_menu.addAction(icon, node_type_name)
            action.setActionGroup(group)
            action.setData(node_type_name)
        
        group.triggered.connect(self.addOperator)

        menu.exec_(event.screenPos())
예제 #10
0
 def copperNodeCreated(self, node_path):
     node = engine.node(str(node_path))
     if node:
         if self.scene.network_level == node.parent().path():
             self.scene.addNode(str(node_path))
예제 #11
0
 def addOperator(self, action):
     network_node = engine.node(self.network_level)
     network_node.createNode(action.data().toPyObject())
예제 #12
0
    def nodeSelected(self, node_path=None):
        if node_path in [None, "/"]:
            return 

        node = engine.node(str(node_path))
        
        # remove old parms widgets
        clearLayout(self.header_bar)
        clearLayout(self.parm_box)

        # build header
        if node.iconName():
            icon = QtGui.QIcon(node.iconName())
        else:
            icon = self.default_icon

        node_btn = QtGui.QToolButton()
        node_btn.setIcon(icon)
        node_btn.setIconSize(QtCore.QSize(24,24))

        node_type = QtGui.QLabel(node.label())
        node_type.setStyleSheet("font-weight: bold")
   
        node_name = QtGui.QLineEdit(node.name())

        self.header_bar.addWidget(node_btn)
        self.header_bar.addWidget(node_type)
        self.header_bar.addWidget(node_name)
        
        # build new parms widgets
        i = 1
        for parm_template in node.parmGroups().keys():
            parm_template_type = parm_template.type()

            parms_layout = QtGui.QHBoxLayout()
            parms_layout.setSpacing(1)
            parms_layout.setContentsMargins(0, 0, 0, 0)
            for parm in node.parmGroups()[parm_template]:
                if parm_template_type is ParmTemplateType.Int:
                    # Int
                    widget = ParameterIntWidget(self, parm)

                elif parm_template_type is ParmTemplateType.Float:
                    # Float
                    widget = ParameterFloatWidget(self, parm)
                
                elif parm_template_type is ParmTemplateType.Button:
                    # Button
                    widget = ParameterButtonWidget(self, parm)

                elif parm_template_type is ParmTemplateType.Menu:
                    # Menu
                    widget = ParameterMenuWidget(self, parm)

                elif parm_template_type is ParmTemplateType.Toggle:
                    # Toggle
                    widget = ParameterToggleWidget(self, parm)

                elif parm_template_type is ParmTemplateType.String:
                    # String
                    widget = ParameterStringWidget(self, parm)

                parms_layout.addWidget(widget) 
                

            hbox = QtGui.QHBoxLayout()
            if parm_template_type not in [ParmTemplateType.Toggle, ParmTemplateType.Button]:
                label = QtGui.QLabel(parm_template.label())
                if parm_template.numComponents() == 1:
                    label.setToolTip("Parameter: %s" % parm.name())
                else:
                    label.setToolTip("Parameters: %s" % [parm.name() for parm in node.parmGroups()[parm_template]])

                label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
                label.setStatusTip(parm.name())
                label.setFixedWidth(140)
                hbox.addWidget(label)
            else:
                hbox.addSpacing(143)

            hbox.addLayout(parms_layout)

            self.parm_box.addLayout(hbox)

            i+=1

        self.parm_box.addStretch(1)