Пример #1
0
    def populateAttributeModel(self, model):
        valid = uiutils.isValidQtObject(model)
        if valid is False:
            return
        col = lib_state.get_active_collection()
        attr_list = []
        if col is not None:
            attr_list = lib_attr.get_attributes_from_collection(col)

        def update_func():
            if uiutils.isValidQtObject(self) is False:
                return
            self.updateAttributeModel()
            return

        # Add Callbacks
        #
        # When querying attributes, we must make sure they have a Maya
        # callback attached to the node to update the UI.
        callback_manager = self.getCallbackManager()
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                update_func,
                callback_manager
            )
        root = convert_to_ui.attributesToUINodes(attr_list)
        model.setRootNode(root)
        return
    def populateModel(self, model):
        valid = uiutils.isValidQtObject(model)
        if valid is False:
            return
        col = lib_state.get_active_collection()
        attr_list = []
        show_anm = const.ATTRIBUTE_TOGGLE_ANIMATED_DEFAULT_VALUE
        show_stc = const.ATTRIBUTE_TOGGLE_STATIC_DEFAULT_VALUE
        show_lck = const.ATTRIBUTE_TOGGLE_LOCKED_DEFAULT_VALUE
        if col is not None:
            attr_list = lib_attr.get_attributes_from_collection(col)
            show_anm = lib_col.get_attribute_toggle_animated_from_collection(
                col)
            show_stc = lib_col.get_attribute_toggle_static_from_collection(col)
            show_lck = lib_col.get_attribute_toggle_locked_from_collection(col)

        def update_func():
            if uiutils.isValidQtObject(self) is False:
                return
            self.dataChanged.emit()
            return

        # Add Callbacks
        #
        # When querying attributes, we must make sure they have a Maya
        # callback attached to the node to update the UI.
        callback_manager = self.callback_manager
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(attr_list, update_func,
                                                 callback_manager)
        root = convert_to_ui.attributesToUINodes(col, attr_list, show_anm,
                                                 show_stc, show_lck)
        model.setRootNode(root)
        return
    def populateModel(self, model, col):
        s = time.time()
        valid = uiutils.isValidQtObject(model)
        if valid is False:
            return
        attr_list = []
        show_anm = const.ATTRIBUTE_TOGGLE_ANIMATED_DEFAULT_VALUE
        show_stc = const.ATTRIBUTE_TOGGLE_STATIC_DEFAULT_VALUE
        show_lck = const.ATTRIBUTE_TOGGLE_LOCKED_DEFAULT_VALUE
        if col is not None:
            attr_list = lib_attr.get_attributes_from_collection(col)
            show_anm = lib_col.get_attribute_toggle_animated_from_collection(
                col)
            show_stc = lib_col.get_attribute_toggle_static_from_collection(col)
            show_lck = lib_col.get_attribute_toggle_locked_from_collection(col)

        # Add Callbacks
        #
        # When querying attributes, we must make sure they have a Maya
        # callback attached to the node to update the UI.
        callback_manager = self.callback_manager
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                callback_manager,
            )
        root = convert_to_ui.attributesToUINodes(col, attr_list, show_anm,
                                                 show_stc, show_lck)
        model.setRootNode(root)

        e = time.time()
        LOG.debug('populateModel: %r', e - s)
        return
Пример #4
0
    def attrAddClicked(self):
        attr_list = lib_maya_utils.get_selected_maya_attributes()
        if len(attr_list) == 0:
            msg = 'Please select attributes in the channel box, none where found.'
            LOG.warning(msg)
            return
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add attributes, active collection is not defined.'
            LOG.warning(msg)
            return
        lib_attr.add_attributes_to_collection(attr_list, col)

        def update_func():
            self.updateAttributeModel()
            self.updateSolveValidState()
            self.setStatusLine(const.STATUS_READY)
            return

        # Add Callbacks
        callback_manager = self.getCallbackManager()
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                update_func,
                callback_manager,
            )

        update_func()
        return
Пример #5
0
    def addClicked(self):
        """
        Add the selected nodes or node attributes to the data model.
        """
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add attributes, active collection is not defined.'
            LOG.warning(msg)
            return

        sel = lib_maya_utils.get_scene_selection()
        attr_list = lib_maya_utils.get_selected_maya_attributes()
        attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            attr_list = lib_maya_utils.get_selected_node_default_attributes()
            attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            msg = 'Please select nodes or attributes in the channel box.'
            LOG.warning(msg)
            return

        lib_attr.add_attributes_to_collection(attr_list, col)

        def update_func():
            if uiutils.isValidQtObject(self) is False:
                return
            self.dataChanged.emit()
            self.viewUpdated.emit()
            return

        # Add Callbacks
        callback_manager = self.callback_manager
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                update_func,
                callback_manager,
            )

        update_func()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
Пример #6
0
    def attrAddClicked(self):
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add attributes, active collection is not defined.'
            LOG.warning(msg)
            return

        sel = lib_maya_utils.get_scene_selection()
        attr_list = lib_maya_utils.get_selected_maya_attributes()
        attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            attr_list = lib_maya_utils.get_selected_node_default_attributes()
            attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            msg = 'Please select nodes or attributes in the channel box.'
            LOG.warning(msg)
            return

        lib_attr.add_attributes_to_collection(attr_list, col)

        def update_func():
            if uiutils.isValidQtObject(self) is False:
                return
            self.updateAttributeToggleButtons()
            self.updateAttributeColumnVisibility()
            self.updateAttributeModel()
            self.updateSolveValidState()
            return

        # Add Callbacks
        callback_manager = self.getCallbackManager()
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                update_func,
                callback_manager,
            )

        update_func()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
Пример #7
0
    def populateAttributeModel(self, model):
        col = lib_state.get_active_collection()
        if col is None:
            return
        attr_list = lib_attr.get_attributes_from_collection(col)

        # Add Callbacks
        #
        # When querying attributes, we must make sure they have a Maya
        # callback attached to the node to update the UI.
        callback_manager = self.getCallbackManager()
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                self.updateAttributeModel,
                callback_manager
            )
        root = convert_to_ui.attributesToUINodes(attr_list)
        model.setRootNode(root)
        return
    def addClicked(self):
        """
        Add the selected nodes or node attributes to the data model.
        """
        s = time.time()
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add attributes, active collection is not defined.'
            LOG.warning(msg)
            return
        e = time.time()
        LOG.debug("attribute addClicked1: t=%s", e - s)

        s = time.time()
        sel = lib_maya_utils.get_scene_selection()
        attr_list = lib_maya_utils.get_selected_maya_attributes()
        attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            attr_list = lib_maya_utils.get_selected_node_default_attributes()
            attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            msg = 'Please select nodes or attributes in the channel box.'
            LOG.warning(msg)
            return
        e = time.time()
        LOG.debug("attribute addClicked2: t=%s", e - s)

        s = time.time()
        try:
            mmapi.set_solver_running(True)  # disable selection callback.
            lib_attr.add_attributes_to_collection(attr_list, col)
        finally:
            mmapi.set_solver_running(False)  # enable selection callback
        e = time.time()
        LOG.debug("attribute addClicked3: t=%s", e - s)

        def update_func():
            if uiutils.isValidQtObject(self) is False:
                return
            self.dataChanged.emit()
            self.viewUpdated.emit()
            return

        # Add Callbacks
        s = time.time()
        callback_manager = self.callback_manager
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                update_func,
                callback_manager,
            )
        e = time.time()
        LOG.debug("attribute addClicked4: t=%s", e - s)

        s = time.time()
        update_func()
        e = time.time()
        LOG.debug("attribute addClicked5: t=%s", e - s)

        # Restore selection.
        s = time.time()
        lib_maya_utils.set_scene_selection(sel)
        e = time.time()
        LOG.debug("attribute addClicked6: t=%s", e - s)
        return