コード例 #1
0
    def createTreeView(self):
        """
        Set up the tree view.
        """
        self.treeView = object_treeview.ObjectTreeView()
        self.ui.treeViewLayout.addWidget(self.treeView)

        root = object_nodes.ObjectNode('root')
        self.model = object_nodes.ObjectModel(root, font=self.font)
        self.filterModel = QtCore.QSortFilterProxyModel()
        self.filterModel.setSourceModel(self.model)
        self.filterModel.setDynamicSortFilter(False)
        self.header = QtWidgets.QHeaderView(QtCore.Qt.Horizontal,
                                            parent=self.treeView)
        Qt.QtCompat.QHeaderView.setSectionResizeMode(
            self.header, QtWidgets.QHeaderView.ResizeToContents)
        self.treeView.setHeader(self.header)
        self.treeView.setModel(self.filterModel)
        self.treeView.setSortingEnabled(True)
        self.treeView.sortByColumn(0, QtCore.Qt.AscendingOrder)
        self.treeView.setSelectionMode(
            QtWidgets.QAbstractItemView.MultiSelection)
        self.selModel = self.treeView.selectionModel()
        self.selModel.selectionChanged.connect(self.selectionChanged)

        # Always hide the UUID Column - it's used for selection of
        # ModelIndexes with Maya node UUIDs only.
        hidden = True
        column = self.model.getColumnIndexFromColumnName(
            const.OBJECT_COLUMN_NAME_UUID)
        self.treeView.setColumnHidden(column, hidden)
        return
コード例 #2
0
 def createTreeView(self):
     """
     Set up the tree view.
     """
     root = object_nodes.ObjectNode('root')
     self.model = object_nodes.ObjectModel(root, font=self.font)
     self.filterModel = QtCore.QSortFilterProxyModel()
     self.filterModel.setSourceModel(self.model)
     self.filterModel.setDynamicSortFilter(False)
     self.header = QtWidgets.QHeaderView(QtCore.Qt.Horizontal,
                                         parent=self.treeView)
     Qt.QtCompat.QHeaderView.setSectionResizeMode(
         self.header, QtWidgets.QHeaderView.ResizeToContents)
     self.treeView.setHeader(self.header)
     self.treeView.setModel(self.filterModel)
     self.treeView.setSortingEnabled(True)
     self.treeView.sortByColumn(0, QtCore.Qt.AscendingOrder)
     self.treeView.setSelectionMode(
         QtWidgets.QAbstractItemView.MultiSelection)
     self.selModel = self.treeView.selectionModel()
     self.selModel.selectionChanged.connect(self.selectionChanged)
     return
コード例 #3
0
    def __init__(self, parent=None, *args, **kwargs):
        super(SolverLayout, self).__init__(*args, **kwargs)
        self.setupUi(self)

        # Store the parent window class, so we can set the applyBtn enabled
        # state.
        self._parentObject = parent

        # Hide the Solve Info line until it's set up. GitHub Issue #56
        self.solveInfoLine_lineEdit.setVisible(False)

        # Collection Combo Box.
        self.collectionName_model = uimodels.StringDataListModel()
        self.collectionName_comboBox.setModel(self.collectionName_model)
        self.collectionName_comboBox.currentIndexChanged.connect(
            self.collectionIndexChanged
        )

        # Collection Select
        self.collectionSelect_pushButton.clicked.connect(
            self.collectionSelectClicked
        )

        # Object Nodes
        # TODO: Perhaps we should remove a tree view and research how
        # we can embed a Maya Outliner inside our layout with a filter
        # to only show markers (and their parents), this would provide
        # a lot of default functionality from Maya.
        root = object_nodes.ObjectNode('root')
        self.object_model = object_nodes.ObjectModel(root, font=self.font)
        self.object_filterModel = QtCore.QSortFilterProxyModel()
        self.object_filterModel.setSourceModel(self.object_model)
        self.object_filterModel.setDynamicSortFilter(False)
        self.object_treeView.setModel(self.object_filterModel)
        self.object_treeView.setSortingEnabled(True)
        self.object_treeView.sortByColumn(0, QtCore.Qt.AscendingOrder)
        self.object_treeView.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
        self.object_selModel = self.object_treeView.selectionModel()
        self.object_selModel.selectionChanged.connect(
            self.objectNodeSelectionChanged
        )
        self.objectToggleCamera_toolButton.clicked.connect(
            self.objectToggleCameraClicked,
        )
        self.objectToggleMarker_toolButton.clicked.connect(
            self.objectToggleMarkerClicked,
        )
        self.objectToggleBundle_toolButton.clicked.connect(
            self.objectToggleBundleClicked,
        )

        # Object Add and Remove buttons
        self.objectAdd_toolButton.clicked.connect(
            self.objectAddClicked
        )
        self.objectRemove_toolButton.clicked.connect(
            self.objectRemoveClicked
        )

        # Attr Nodes
        root = attr_nodes.PlugNode('root')
        self.attribute_model = attr_nodes.AttrModel(root, font=self.font)
        self.attribute_filterModel = QtCore.QSortFilterProxyModel()
        self.attribute_filterModel.setSourceModel(self.attribute_model)
        self.attribute_filterModel.setDynamicSortFilter(False)
        self.attribute_treeView.setModel(self.attribute_filterModel)
        self.attribute_treeView.setSortingEnabled(True)
        self.attribute_treeView.sortByColumn(0, QtCore.Qt.AscendingOrder)
        self.attribute_treeView.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
        self.attribute_selModel = self.attribute_treeView.selectionModel()
        self.attribute_selModel.selectionChanged.connect(
            self.attrNodeSelectionChanged
        )

        # Attr Add and Remove buttons
        self.attributeAdd_toolButton.clicked.connect(
            self.attrAddClicked
        )
        self.attributeRemove_toolButton.clicked.connect(
            self.attrRemoveClicked
        )

        # Solver Nodes
        self.solver_model = solver_nodes.SolverModel(font=self.font)
        self.solver_filterModel = QtCore.QSortFilterProxyModel()
        self.solver_filterModel.setSourceModel(self.solver_model)
        self.solver_filterModel.setDynamicSortFilter(False)
        self.solver_tableView.setModel(self.solver_filterModel)
        self.solver_tableView.setSortingEnabled(False)
        self.solver_selModel = self.solver_tableView.selectionModel()

        # Set up custom widgets for viewing and editing the columns.
        self.solver_attrFilterDelegate = solver_nodes.AttributeComboBoxDelegate()
        self.solver_tableView.setItemDelegateForColumn(
            2,
            self.solver_attrFilterDelegate,
        )
        self.solver_strategyDelegate = solver_nodes.StrategyComboBoxDelegate()
        self.solver_tableView.setItemDelegateForColumn(
            3,
            self.solver_strategyDelegate,
        )

        # Solver Add and Remove buttons
        self.solverAdd_toolButton.clicked.connect(
            self.solverAddClicked
        )
        self.solverRemove_toolButton.clicked.connect(
            self.solverRemoveClicked
        )

        # TODO: Write functions for Move Up/Down buttons. Until then,
        #       we'll hide the buttons to avoid confusion.
        self.solverMoveUp_toolButton.setVisible(False)
        self.solverMoveDown_toolButton.setVisible(False)
        # self.solverMoveUp_toolButton.clicked.connect(
        #     self.solverMoveUpClicked
        # )
        # self.solverMoveDown_toolButton.clicked.connect(
        #     self.solverMoveDownClicked
        # )

        # Override Current Frame
        self.overrideCurrentFrame_checkBox.stateChanged.connect(
            self.overrideCurrentFrameChanged
        )

        # Populate the UI with data.
        self.updateDynamicWindowTitle()
        self.updateCollectionModel()
        self.updateObjectToggleButtons()
        self.updateObjectModel()
        self.updateAttributeModel()
        self.updateSolverModel()
        self.updateSolveValidState()
        return
コード例 #4
0
    def __init__(self, parent=None, *args, **kwargs):
        super(SolverLayout, self).__init__(*args, **kwargs)
        self.setupUi(self)

        # Store the parent window class, so we can set the applyBtn enabled
        # state.
        self._parentObject = parent

        # Collection Combo Box.
        self.collectionName_model = uimodels.StringDataListModel()
        self.collectionName_comboBox.setModel(self.collectionName_model)
        self.collectionName_comboBox.currentIndexChanged.connect(
            self.collectionIndexChanged)

        # Collection Select
        self.collectionSelect_pushButton.clicked.connect(
            self.collectionSelectClicked)

        # Object Nodes
        root = object_nodes.ObjectNode('root')
        self.object_model = object_nodes.ObjectModel(root, font=self.font)
        self.object_filterModel = QtCore.QSortFilterProxyModel()
        self.object_filterModel.setSourceModel(self.object_model)
        self.object_filterModel.setDynamicSortFilter(False)
        self.object_header = QtWidgets.QHeaderView(QtCore.Qt.Horizontal,
                                                   parent=self.object_treeView)
        self.object_header.setSectionResizeMode(
            QtWidgets.QHeaderView.ResizeToContents)
        self.object_treeView.setHeader(self.object_header)
        self.object_treeView.setModel(self.object_filterModel)
        self.object_treeView.setSortingEnabled(True)
        self.object_treeView.sortByColumn(0, QtCore.Qt.AscendingOrder)
        self.object_treeView.setSelectionMode(
            QtWidgets.QAbstractItemView.MultiSelection)
        self.object_selModel = self.object_treeView.selectionModel()
        self.object_selModel.selectionChanged.connect(
            self.objectNodeSelectionChanged)
        self.objectToggleCamera_toolButton.clicked.connect(
            self.objectToggleCameraClicked, )
        self.objectToggleMarker_toolButton.clicked.connect(
            self.objectToggleMarkerClicked, )
        self.objectToggleBundle_toolButton.clicked.connect(
            self.objectToggleBundleClicked, )

        # Object Add and Remove buttons
        self.objectAdd_toolButton.clicked.connect(self.objectAddClicked)
        self.objectRemove_toolButton.clicked.connect(self.objectRemoveClicked)

        # Attr Nodes
        root = attr_nodes.PlugNode('root')
        self.attribute_model = attr_nodes.AttrModel(root, font=self.font)
        self.attribute_filterModel = QtCore.QSortFilterProxyModel()
        self.attribute_filterModel.setSourceModel(self.attribute_model)
        self.attribute_filterModel.setDynamicSortFilter(False)
        self.attribute_header = QtWidgets.QHeaderView(
            QtCore.Qt.Horizontal, parent=self.attribute_treeView)
        self.attribute_header.setSectionResizeMode(
            QtWidgets.QHeaderView.ResizeToContents)
        self.attribute_treeView.setHeader(self.attribute_header)

        self.attribute_treeView.setModel(self.attribute_filterModel)
        self.attribute_treeView.setSortingEnabled(True)
        self.attribute_treeView.sortByColumn(0, QtCore.Qt.AscendingOrder)
        self.attribute_treeView.setSelectionMode(
            QtWidgets.QAbstractItemView.MultiSelection)
        self.attribute_selModel = self.attribute_treeView.selectionModel()
        self.attribute_selModel.selectionChanged.connect(
            self.attrNodeSelectionChanged)
        self.attributeToggleAnimated_toolButton.clicked.connect(
            self.attributeToggleAnimatedClicked, )
        self.attributeToggleStatic_toolButton.clicked.connect(
            self.attributeToggleStaticClicked, )
        self.attributeToggleLocked_toolButton.clicked.connect(
            self.attributeToggleLockedClicked, )

        # Attr Add and Remove buttons
        self.attributeAdd_toolButton.clicked.connect(self.attrAddClicked)
        self.attributeRemove_toolButton.clicked.connect(self.attrRemoveClicked)

        # Solver Nodes
        self.solver_model = solver_nodes.SolverModel(font=self.font)
        self.solver_filterModel = QtCore.QSortFilterProxyModel()
        self.solver_filterModel.setSourceModel(self.solver_model)
        self.solver_filterModel.setDynamicSortFilter(False)
        self.solver_tableView.setModel(self.solver_filterModel)
        self.solver_tableView.setSortingEnabled(False)
        self.solver_selModel = self.solver_tableView.selectionModel()

        # Set up custom widgets for viewing and editing the columns.
        self.solver_attrFilterDelegate = solver_nodes.AttributeComboBoxDelegate(
        )
        attr_idx = self.solver_model.getColumnIndexFromColumnName(
            const.SOLVER_COLUMN_NAME_ATTRIBUTES)
        strategy_idx = self.solver_model.getColumnIndexFromColumnName(
            const.SOLVER_COLUMN_NAME_STRATEGY)
        self.solver_tableView.setItemDelegateForColumn(
            attr_idx,
            self.solver_attrFilterDelegate,
        )
        self.solver_strategyDelegate = solver_nodes.StrategyComboBoxDelegate()
        self.solver_tableView.setItemDelegateForColumn(
            strategy_idx,
            self.solver_strategyDelegate,
        )

        # Solver Add and Remove buttons
        self.solverAdd_toolButton.clicked.connect(self.solverAddClicked)
        self.solverRemove_toolButton.clicked.connect(self.solverRemoveClicked)

        # TODO: Write functions for Move Up/Down buttons. Until then,
        #       we'll hide the buttons to avoid confusion.
        self.solverMoveUp_toolButton.setVisible(False)
        self.solverMoveDown_toolButton.setVisible(False)
        # self.solverMoveUp_toolButton.clicked.connect(
        #     self.solverMoveUpClicked
        # )
        # self.solverMoveDown_toolButton.clicked.connect(
        #     self.solverMoveDownClicked
        # )

        # Override Current Frame
        self.overrideCurrentFrame_checkBox.stateChanged.connect(
            self.overrideCurrentFrameChanged)

        # Populate the UI with data.
        self.updateDynamicWindowTitle()
        self.updateCollectionModel()
        self.updateObjectToggleButtons()
        self.updateObjectColumnVisibility()
        self.updateObjectModel()
        self.updateAttributeToggleButtons()
        self.updateAttributeColumnVisibility()
        self.updateAttributeModel()
        self.updateSolverModel()
        self.updateSolveValidState()
        return