Esempio n. 1
0
    def __refresh(self):
        if self.__building:
            return

        if str(self.__scopePopup.currentText()).startswith('Upstream'):
            self.__shadingNetworkMaterialsPopup.show()
        else:
            self.__shadingNetworkMaterialsPopup.hide()

        sm = Widgets.ScrollAreaMemory.ScrollAreaMemory(self.__tree)

        selectedItems = set(x.getItemData()['key'] \
                for x in self.__tree.selectedItems())
        closedItems = set()
        for i in xrange(self.__tree.topLevelItemCount()):
            item = self.__tree.topLevelItem(i)
            if not item.isExpanded():
                closedItems.add(item.getItemData()['key'])

        self.__tree.clear()

        with self.__tree.getUpdateSuppressor():
            for node in self.__getScopedNodes():
                item = QT4Widgets.SortableTreeWidgetItem(
                    self.__tree, node.getName())
                item.setIcon(self.COLUMN_SOURCE_NAME,
                             UI4.Util.IconManager.GetIcon('Icons/node16.png'))

                key = hash(node)

                item.setItemData({'name': node.getName(), 'key': key})

                if key in selectedItems:
                    item.setSelected(True)

                self.__buildNodeChildren(item, selectedItems)
                item.setExpanded(key not in closedItems)

                item.setText(
                    self.COLUMN_PUBLIC_NAME,
                    node.getParameter('publicInterface.namePrefix').getValue(
                        0))
                item.setText(
                    self.COLUMN_PUBLIC_PAGE,
                    node.getParameter('publicInterface.pagePrefix').getValue(
                        0))

                item.setHiliteColor(QtGui.QColor(52, 64, 64))
            self.__filterUpdate()
Esempio n. 2
0
    def update(self):
        """
        Is called to update the UI
        """
        passes = self.__node.getRenderPasses()
        
        scrollToSelection = False
        
        if self.__preselectionKey is not None:
            selectedKeys = [self.__preselectionKey]
            self.__preselectionKey = None
            scrollToSelection = True
        else:
            selectedKeys = [hash(item.getItemData().getShadowBranchNode())
                    for item in self.__treeWidget.selectedItems()]
        
        scrollMemory = UI4.Widgets.ScrollAreaMemory.ScrollAreaMemory(
                self.__treeWidget)
        
        # Set updating flag, so __selectionChangedCallback will not update
        # the UI while we are re-building the list
        self.__updating = True
        try:
            with self.__treeWidget.getUpdateSuppressor():
                # Clear tree widget holding render passes
                self.__treeWidget.clear()

                # Add pass items
                for renderPassItem in self.__node.getRenderPasses():
                    item = QT4Widgets.SortableTreeWidgetItem(
                            self.__treeWidget, renderPassItem.getName(),
                                    data=renderPassItem)
                    shadowBranch = renderPassItem.getShadowBranchNode()
                    if hash(shadowBranch) in selectedKeys:
                        item.setSelected(True)

                    item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
                    item.setIcon(0, getIcon('render16.png'))


            selectedItems = self.__treeWidget.selectedItems()
            if selectedItems:
                if scrollToSelection:
                    del scrollMemory
                    self.__treeWidget.scrollToItem(selectedItems[0])

        finally:
            self.__updating = False
            self.__selectionChangedCallback()
Esempio n. 3
0
    def __updateTreeContents(self):
        scrollToPreselect = False
        scrollToItem = None
        vScrollbar = self.__treeWidget.verticalScrollBar()
        if vScrollbar and vScrollbar.isVisible():
            yPos = vScrollbar.value()
        else:
            vScrollbar = None

        try:
            self.__rebuilding = True
            node = self.__node

            selectedTable, openTable = self.__treeWidget.getExpandedAndSelectionTables(
            )

            if self.__preselectName:
                scrollToPreselect = True
                selectedNames = set([self.__preselectName])
                self.__preselectName = None
            else:
                selectedNames = set(
                    [str(x.text(0)) for x in selectedTable.itervalues()])

            self.__treeWidget.clear()

            ponyNames = node.getPonyNames()
            for ponyName in ponyNames:
                item = QT4Widgets.SortableTreeWidgetItem(self.__treeWidget,
                                                         ponyName,
                                                         data=None)
                selected = ponyName in selectedNames
                item.setSelected(selected)
                if scrollToPreselect and selected:
                    scrollToItem = item

        finally:
            if scrollToItem:
                self.__treeWidget.scrollToItem(scrollToItem)
            else:
                if vScrollbar:
                    vScrollbar.setValue(yPos)

            self.__rebuilding = False

        self.__treeWidgetSelectionChanged()
Esempio n. 4
0
    def updateLightList(self, refreshCustomParams=True):
        """
        Will update the light passes in the lightWidget
        """
        # Set updating flag, so __lightSelectionChangedCallback will not update
        # the UI while we are re-building the list
        self.__updating = True

        selectedItems = self.__treeWidget.selectedItems()
        if selectedItems:
            passScriptItem = selectedItems[0].getItemData()
            scrollToSelection = False

            try:
                with self.__lightWidget.getUpdateSuppressor():

                    if self.__lightselectionKey is not None:
                        selectedKeys = [self.__lightselectionKey]
                        self.__lightselectionKey = None
                        scrollToSelection = True
                    else:
                        selectedKeys = [hash(item.getItemData().getGroupNode())
                                for item in self.__lightWidget.selectedItems()]


                    # Clear light pass list
                    self.__lightWidget.clear()

                    # Build light list for selected pass
                    lightPasses = self.__node.getLightPasses(passScriptItem)
                    for lightPassItem in lightPasses:
                        item = QT4Widgets.SortableTreeWidgetItem(
                                self.__lightWidget, lightPassItem.getName(),
                                        data=lightPassItem)
                        passGroup = lightPassItem.getGroupNode()
                        if hash(passGroup) in selectedKeys:
                            item.setSelected(True)
                        item.setIcon(0, getIcon('render16.png'))
            finally:
                self.__updating = False

                if refreshCustomParams:
                    self.__lightSelectionChangedCallback()
Esempio n. 5
0
    def __buildNodeChildren(self, nodeItem, selectedItems):
        node = NodegraphAPI.GetNode(nodeItem.getItemData()['name'])

        for param in node.getParameter('parameters').getChildren():
            name = param.getName()
            if name == '__unused':
                continue

            if param.getType() != 'group':
                continue

            item = QT4Widgets.SortableTreeWidgetItem(nodeItem, name)

            key = hash(param)
            item.setItemData({'name': param.getName(), 'key': key})

            if key in selectedItems:
                item.setSelected(True)

            self.__updateParamItem(item, param)