Exemplo n.º 1
0
    def removeCollectionNode(self):
        col = lib_state.get_active_collection()
        if col is None:
            LOG.warning('No active collection to delete.')
            return

        cols = lib_col.get_collections()
        prev_col = lib_col.get_previous_collection(cols, col)

        steps = lib_col.get_solver_steps_from_collection(col)
        for step in steps:
            lib_col.remove_solver_step_from_collection(col, step)

        lib_col.delete_collection(col)
        lib_state.set_active_collection(prev_col)

        self.updateDynamicWindowTitle()
        self.updateStatusWithSolveResult()
        self.updateCollectionModel()
        self.updateObjectToggleButtons()
        self.updateObjectColumnVisibility()
        self.updateObjectModel()
        self.updateAttributeToggleButtons()
        self.updateAttributeColumnVisibility()
        self.updateAttributeModel()
        self.updateSolverModel()
        self.updateSolveValidState()
        return
Exemplo n.º 2
0
    def updateModel(self):
        """
        Refresh the name_comboBox with the current Maya scene state.
        """
        self.populateModel(self.model)

        index = None
        col = lib_state.get_active_collection()
        if col is None:
            cols = lib_col.get_collections()
            if len(cols) > 0:
                # If there is no active collection, but there are
                # collections already created, we make sure the first
                # collection is marked active.
                col = cols[0]
                lib_state.set_active_collection(col)
        else:
            index = self.getActiveIndex(self.model, col)

        block = self.blockSignals(True)
        if index is not None:
            self.name_comboBox.setCurrentIndex(index)
        self.nameChanged.emit()
        self.blockSignals(block)
        return
Exemplo n.º 3
0
    def removeActiveNode(self):
        """
        Delete the currently active collection.
        """
        col = lib_state.get_active_collection()
        if col is None:
            LOG.warning('No active collection to delete.')
            return
        title = 'Remove Collection?'
        text = 'Would you like to remove the current Collection?'
        text += '\n\nRemove "' + str(col.get_node()) + '"?'
        clicked_button = QtWidgets.QMessageBox.question(self, title, text)
        if clicked_button != QtWidgets.QMessageBox.Yes:
            LOG.warn('User cancelled operation.')
            return

        cols = lib_col.get_collections()
        prev_col = lib_col.get_previous_collection(cols, col)

        steps = lib_col.get_solver_steps_from_collection(col)
        for step in steps:
            lib_col.remove_solver_step_from_collection(col, step)

        lib_col.delete_collection(col)
        lib_state.set_active_collection(prev_col)

        self.itemRemoved.emit()
        self.itemChanged.emit()
        self.nameChanged.emit()
        return
Exemplo n.º 4
0
    def createNewNode(self):
        """
        Create a new Collection node, and set it active.
        """
        col = lib_col.create_collection()
        lib_state.set_active_collection(col)

        self.itemAdded.emit()
        self.itemChanged.emit()
        self.nameChanged.emit()
        return
Exemplo n.º 5
0
    def createNewCollectionNode(self):
        col = lib_col.create_collection()
        lib_state.set_active_collection(col)

        self.updateDynamicWindowTitle()
        self.updateCollectionModel()
        self.updateObjectToggleButtons()
        self.updateObjectModel()
        self.updateAttributeModel()
        self.updateSolverModel()
        self.updateSolveValidState()
        return
Exemplo n.º 6
0
    def createNewCollectionNode(self):
        col = lib_col.create_collection()
        lib_state.set_active_collection(col)

        self.updateDynamicWindowTitle()
        self.updateCollectionModel()
        self.updateObjectModel()
        self.updateAttributeModel()
        self.updateSolverModel()
        self.updateSolveValidState()

        self.setStatusLine(const.STATUS_READY)
        return
Exemplo n.º 7
0
 def indexChanged(self, index):
     """
     Run when the name_comboBox index is changed.
     """
     if index < 0:
         return
     model_index = self.model.index(index, 0)
     data = self.model.data(model_index, role=QtCore.Qt.UserRole)
     if data is None:
         return
     lib_state.set_active_collection(data)
     self.itemChanged.emit()
     self.nameChanged.emit()
     return
Exemplo n.º 8
0
    def collectionIndexChanged(self, index):
        if index < 0:
            return
        model_index = self.collectionName_model.index(index, 0)
        data = self.collectionName_model.data(model_index,
                                              role=QtCore.Qt.UserRole)
        if data is None:
            return
        lib_state.set_active_collection(data)

        self.updateDynamicWindowTitle()
        self.updateObjectToggleButtons()
        self.updateObjectModel()
        self.updateAttributeModel()
        self.updateSolverModel()
        self.updateSolveValidState()
        return
Exemplo n.º 9
0
    def updateCollectionModel(self):
        self.populateCollectionModel(self.collectionName_model)

        col = lib_state.get_active_collection()
        if col is None:
            cols = lib_col.get_collections()
            if len(cols) > 0:
                # If there is no active collection, but there are
                # collections already created, we make sure the first
                # collection is marked active.
                col = cols[0]
                lib_state.set_active_collection(col)

        if col is not None:
            index = self.getDefaultCollectionIndex(self.collectionName_model, col)
            if index is not None:
                self.collectionName_comboBox.setCurrentIndex(index)

        self.updateDynamicWindowTitle()
        return
Exemplo n.º 10
0
    def removeActiveNode(self):
        """
        Delete the currently active collection.
        """
        col = lib_state.get_active_collection()
        if col is None:
            LOG.warning('No active collection to delete.')
            return

        cols = lib_col.get_collections()
        prev_col = lib_col.get_previous_collection(cols, col)

        steps = lib_col.get_solver_steps_from_collection(col)
        for step in steps:
            lib_col.remove_solver_step_from_collection(col, step)

        lib_col.delete_collection(col)
        lib_state.set_active_collection(prev_col)

        self.itemRemoved.emit()
        self.itemChanged.emit()
        self.nameChanged.emit()
        return
Exemplo n.º 11
0
    def removeCollectionNode(self):
        col = lib_state.get_active_collection()
        if col is not None:
            # FIXME: Solver Steps continue to hold a reference to the
            # Collection after the collection node is deleted.
            steps = lib_col.get_solver_steps_from_collection(col)
            for step in steps:
                lib_col.remove_solver_step_from_collection(col, step)
            lib_col.delete_collection(col)
            lib_state.set_active_collection(None)
        else:
            LOG.warning('No active collection to delete.')
            return

        self.updateDynamicWindowTitle()
        self.updateCollectionModel()
        self.updateObjectModel()
        self.updateAttributeModel()
        self.updateSolverModel()
        self.updateSolveValidState()

        self.setStatusLine(const.STATUS_READY)
        return
Exemplo n.º 12
0
 def setActiveCollection(self, col):
     assert isinstance(col, mmapi.Collection)
     lib_state.set_active_collection(col)
     self.triggerCollectionUpdate()
     return