예제 #1
0
 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()
예제 #2
0
    def createNodeTree(self, parent, node_path=None):
        """Builds node tree from node"""
        if not node_path:
            # create root node item
            root_item = QtWidgets.QTreeWidgetItem(self)
            root_item.setExpanded(True)
            root_item.setIcon(0, QtGui.QIcon(hou.iconName()))
            root_item.setText(0, "/")
            root_item.setText(1, "/")
            self.nodes_map["/"] = root_item
            self.createNodeTree(root_item, "/")
        else:
            node = hou.node(node_path)
            if node:
                for child_node in node.children():
                    item = QtWidgets.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)
예제 #3
0
    def createNodeTree(self, parent, node_path=None):
        """Builds node tree from node"""
        if not node_path:
            # create root node item
            root_item = QtWidgets.QTreeWidgetItem(self)
            root_item.setExpanded(True)
            root_item.setIcon(0, QtGui.QIcon(hou.iconName()))
            root_item.setText(0, "/")
            root_item.setText(1, "/")
            self.nodes_map["/"] = root_item
            self.createNodeTree(root_item, "/")
        else:
            node = hou.node(node_path)
            if node:
                for child_node in node.children():
                    item = QtWidgets.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)
예제 #4
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()
예제 #5
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()
예제 #6
0
    def buildPathBar(self, node_path=None):
        node = engine.node(node_path)
        if not node:
            return False
        elif node.isRoot():
            btn = QtWidgets.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 = QtWidgets.QPushButton()
                btn.setIcon(QtGui.QIcon(node.iconName()))
                btn.setText(node.name())
                btn.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)

                menu = QtWidgets.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(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)

        return True
예제 #7
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()
예제 #8
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()
예제 #9
0
    def init(self):
        if not self._initialized:
            self.grid = SimpleGrid(self)
            self.origin = SimpleOrigin(self)

            for node in hou.node("/obj").children():
                self.getObjNodeDrawable(node)

            self._initialized = True
예제 #10
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())
예제 #11
0
    def drawSceneObjects(self):
        glPolygonMode(GL_BACK, GL_LINE)
        #glPolygonMode(GL_BACK, GL_POINT)

        glTranslatef(0.0, 0.0, 0.0)

        for node in hou.node("/obj").children():
            ogl_obj_cache = SceneViewWidget.OGL_Scene_Manager.getObjNodeGeometry(node)

            if ogl_obj_cache:
                logger.debug("Drawing node: %s" % node.path())

                transform = node.worldTransform()
                glPushMatrix()
                glMultMatrixf(transform.m)

                # draw points
                glColor4f(0.0, 0.0, 1.0, 1.0)
                if ogl_obj_cache.pointsCount() > 0:
                    logger.debug("Drawing points for: %s" % node.path())
                    glPointSize( 3.0 )
                    glBindBuffer (GL_ARRAY_BUFFER, ogl_obj_cache.pointsVBO())

                    glEnableClientState(GL_VERTEX_ARRAY)

                    glVertexPointer (3, GL_FLOAT, 0, None)
                    glDrawArrays (GL_POINTS, 0, ogl_obj_cache.pointsCount())

                    glDisableClientState(GL_VERTEX_ARRAY)

                    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) # reset

                # draw polygons
                glColor4f(1.0, 1.0, 1.0, 1.0)
                glUseProgram(SceneViewWidget.OGL_Scene_Manager.defaultShaderProgram())
                if ogl_obj_cache.polyCount() > 0:
                    logger.debug("Drawing %s polys for: %s" % (ogl_obj_cache.polyCount(), node.path()))

                    glEnable(GL_LIGHTING)

                    glBindBuffer (GL_ARRAY_BUFFER, ogl_obj_cache.pointsVBO())
                    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ogl_obj_cache.polyIndicesVBO())

                    glEnableClientState(GL_VERTEX_ARRAY)

                    glVertexPointer (3, GL_FLOAT, 0, None)
                    glDrawElements(GL_TRIANGLES, ogl_obj_cache.polyCount()*3, GL_UNSIGNED_INT, None)

                    glDisableClientState(GL_VERTEX_ARRAY)

                    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)
                    glBindBuffer (GL_ARRAY_BUFFER, 0)

                    glDisable(GL_LIGHTING)

                glPopMatrix()
                glUseProgram(0)
예제 #12
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())
예제 #13
0
    def dropEvent(self, event):
        if event.mimeData().hasFormat("node/path"):
            if not self.isPin():
                from copper import hou
                node_path = event.mimeData().nodePath()
                node = hou.node(node_path)
                self.setCurrentNode(node, pick_node=False)
                self.signals.nodeDropped.emit(node)

            event.acceptProposedAction()
예제 #14
0
    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
            logger.debug("Updating node %s for display" % 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()
예제 #15
0
    def setNodeToDisplay(self, node_path=None):
        node = hou.node(node_path)
        if node:
            logger.debug("Setting node %s as current to display" % 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()
예제 #16
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())
예제 #17
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())
예제 #18
0
    def createNodeTree(self, parent, node=None):
        """Builds node tree from node"""
        if not node:
            # create root node item
            root_node = hou.node("/")
            root_item = QtWidgets.QTreeWidgetItem(self)
            root_item.setExpanded(True)
            root_item.setIcon(0, QtGui.QIcon(root_node.iconName()))
            root_item.setText(0, "/")
            root_item.setText(1, "/")
            root_item.setData(2, Qt.Qt.UserRole, None)
            #self.nodes_map["/"] = root_item
            self.createNodeTree(root_item, root_node)
        else:
            if node:
                for child_node in node.children():
                    node_path = child_node.path()
                    item = QtWidgets.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, node_path)
                    item.setData(2, Qt.Qt.UserRole, child_node)
                    self.nodes_map[child_node.id()] = item

                    # connect signals
                    child_node.signals.opCookingStarted.connect(
                        lambda node_path=node_path: self.nodeMarkClean(
                            node_path))
                    child_node.signals.opCookingFailed.connect(
                        lambda node_path=node_path: self.nodeMarkFailed(
                            node_path))

                    if child_node.children():
                        self.createNodeTree(item, child_node)

        self.sortByColumn(0, QtCore.Qt.AscendingOrder)
예제 #19
0
    def buildPathBar(self, node_path=None):
        node = engine.node(node_path)
        if not node:
            return False
        elif node.isRoot():
            btn = QtWidgets.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 = QtWidgets.QPushButton()
                btn.setIcon(QtGui.QIcon(node.iconName()))
                btn.setText(node.name())
                btn.setSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                  QtWidgets.QSizePolicy.Fixed)

                menu = QtWidgets.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(QtWidgets.QSizePolicy.Expanding,
                              QtWidgets.QSizePolicy.Fixed)

        return True
예제 #20
0
 def addOperator(self, action):
     network_node = hou.node(self.network_level.path())
     network_node.createNode(action.data())
예제 #21
0
    def drawSceneObjects(self):
        glPolygonMode(GL_BACK, GL_LINE)
        #glPolygonMode(GL_BACK, GL_POINT)

        glTranslatef(0.0, 0.0, 0.0)

        for node in hou.node("/obj").children():
            ogl_obj_cache = SceneViewWidget.OGL_Scene_Manager.getObjNodeGeometry(
                node)

            if ogl_obj_cache:
                logger.debug("Drawing node: %s" % node.path())

                transform = node.worldTransform()
                glPushMatrix()
                glMultMatrixf(transform.m)

                # draw points
                glColor4f(0.0, 0.0, 1.0, 1.0)
                if ogl_obj_cache.pointsCount() > 0:
                    logger.debug("Drawing points for: %s" % node.path())
                    glPointSize(3.0)
                    glBindBuffer(GL_ARRAY_BUFFER, ogl_obj_cache.pointsVBO())

                    glEnableClientState(GL_VERTEX_ARRAY)

                    glVertexPointer(3, GL_FLOAT, 0, None)
                    glDrawArrays(GL_POINTS, 0, ogl_obj_cache.pointsCount())

                    glDisableClientState(GL_VERTEX_ARRAY)

                    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)  # reset

                # draw polygons
                glColor4f(1.0, 1.0, 1.0, 1.0)
                glUseProgram(
                    SceneViewWidget.OGL_Scene_Manager.defaultShaderProgram())
                if ogl_obj_cache.polyCount() > 0:
                    logger.debug("Drawing %s polys for: %s" %
                                 (ogl_obj_cache.polyCount(), node.path()))

                    glEnable(GL_LIGHTING)

                    glBindBuffer(GL_ARRAY_BUFFER, ogl_obj_cache.pointsVBO())
                    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
                                 ogl_obj_cache.polyIndicesVBO())

                    glEnableClientState(GL_VERTEX_ARRAY)

                    glVertexPointer(3, GL_FLOAT, 0, None)
                    glDrawElements(GL_TRIANGLES,
                                   ogl_obj_cache.polyCount() * 3,
                                   GL_UNSIGNED_INT, None)

                    glDisableClientState(GL_VERTEX_ARRAY)

                    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)
                    glBindBuffer(GL_ARRAY_BUFFER, 0)

                    glDisable(GL_LIGHTING)

                glPopMatrix()
                glUseProgram(0)
예제 #22
0
 def addOperator(self, action):
     network_node = engine.node(self.network_level)
     network_node.createNode(action.data().toPyObject())
예제 #23
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))
예제 #24
0
 def addOperator(self, action):
     network_node = engine.node(self.network_level)
     network_node.createNode(action.data().toPyObject())
예제 #25
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))
예제 #26
0
    def nodeSelected(self, node_path=None):
        if node_path in [None, "/"]:
            return 

        node = hou.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 = QtWidgets.QToolButton()
        node_btn.setIcon(icon)
        node_btn.setIconSize(QtCore.QSize(24,24))

        node_type = QtWidgets.QLabel(node.label())
        node_type.setStyleSheet("font-weight: bold")
   
        node_name = QtWidgets.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 = QtWidgets.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 = QtWidgets.QHBoxLayout()
            if parm_template_type not in [ParmTemplateType.Toggle, ParmTemplateType.Button]:
                label = QtWidgets.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)
예제 #27
0
    def init(self):
        self.background = SimpleBackground(self.ctx)
        for node in hou.node("/obj").children():
            self.addObject(node)

        print("Scene shapes %s" % self._shapes)