def addClicked(self):
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add markers, active collection is not defined.'
            LOG.warning(msg)
            return

        sel = lib_maya_utils.get_scene_selection()
        mkr_list = lib_maya_utils.get_markers_from_selection()
        if len(mkr_list) == 0:
            msg = 'Please select objects, found no markers.'
            LOG.warning(msg)
            return
        lib_marker.add_markers_to_collection(mkr_list, col)

        # Add Callbacks
        callback_manager = self.callback_manager
        if callback_manager is not None:
            lib_marker.add_callbacks_to_markers(
                mkr_list,
                callback_manager
            )

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
    def removeClicked(self):
        col = lib_state.get_active_collection()
        if col is None:
            return

        sel = lib_maya_utils.get_scene_selection()
        ui_nodes = lib_uiquery.get_selected_ui_nodes(
            self.treeView,
            self.filterModel
        )
        nodes = lib_uiquery.convert_ui_nodes_to_nodes(ui_nodes, 'marker')
        lib_marker.remove_markers_from_collection(nodes, col)

        # Remove Callbacks
        callback_manager = self.callback_manager
        if callback_manager is not None:
            lib_marker.remove_callbacks_from_markers(
                nodes,
                callback_manager
            )

        self.dataChanged.emit()
        self.viewUpdated.emit()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
Exemplo n.º 3
0
 def rename_marker_bundles(self):
     node_list = _get_selected_maya_nodes(self)
     LOG.debug("Rename Markers and Bundles: %r", node_list)
     import mmSolver.tools.markerbundlerename.tool as tool
     lib_maya_utils.set_scene_selection(node_list)
     tool.main()
     return
Exemplo n.º 4
0
    def attrRemoveClicked(self):
        col = lib_state.get_active_collection()
        if col is None:
            return

        sel = lib_maya_utils.get_scene_selection()
        ui_nodes = lib_uiquery.get_selected_ui_nodes(
            self.attribute_treeView,
            self.attribute_filterModel
        )
        attr_list = lib_uiquery.convert_ui_nodes_to_nodes(ui_nodes, 'data')
        lib_attr.remove_attr_from_collection(attr_list, col)

        # Remove Callbacks
        callback_manager = self.getCallbackManager()
        if callback_manager is not None:
            lib_attr.remove_callbacks_from_attributes(
                attr_list,
                callback_manager
            )

        self.updateAttributeModel()
        self.updateSolveValidState()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
Exemplo n.º 5
0
    def objectAddClicked(self):
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add markers, active collection is not defined.'
            LOG.warning(msg)
            return

        sel = lib_maya_utils.get_scene_selection()
        mkr_list = lib_maya_utils.get_markers_from_selection()
        if len(mkr_list) == 0:
            msg = 'Please select objects, found no markers.'
            LOG.warning(msg)
            return
        lib_marker.add_markers_to_collection(mkr_list, col)

        def update_func():
            if uiutils.isValidQtObject(self) is False:
                return
            self.updateObjectToggleButtons()
            self.updateObjectColumnVisibility()
            self.updateObjectModel()
            self.updateSolveValidState()
            return

        # Add Callbacks
        callback_manager = self.getCallbackManager()
        if callback_manager is not None:
            lib_marker.add_callbacks_to_markers(mkr_list, update_func,
                                                callback_manager)

        update_func()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
    def addClicked(self):
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add markers, active collection is not defined.'
            LOG.warning(msg)
            return

        sel = lib_maya_utils.get_scene_selection()
        mkr_list = lib_maya_utils.get_markers_from_selection()
        if len(mkr_list) == 0:
            msg = 'Please select objects, found no markers.'
            LOG.warning(msg)
            return
        lib_marker.add_markers_to_collection(mkr_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_marker.add_callbacks_to_markers(mkr_list, update_func,
                                                callback_manager)

        update_func()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
Exemplo n.º 7
0
    def objectRemoveClicked(self):
        col = lib_state.get_active_collection()
        if col is None:
            return

        sel = lib_maya_utils.get_scene_selection()
        ui_nodes = lib_uiquery.get_selected_ui_nodes(
            self.object_treeView,
            self.object_filterModel
        )
        nodes = lib_uiquery.convert_ui_nodes_to_nodes(ui_nodes, 'marker')
        lib_marker.remove_markers_from_collection(nodes, col)

        # Remove Callbacks
        callback_manager = self.getCallbackManager()
        if callback_manager is not None:
            lib_marker.remove_callbacks_from_markers(
                nodes,
                callback_manager
            )

        self.updateObjectToggleButtons()
        self.updateObjectModel()
        self.updateSolveValidState()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
Exemplo n.º 8
0
 def selection_both_markers_bundles(self):
     node_list = _get_selected_maya_nodes(self)
     LOG.debug("Both Markers and Bundles: %r", node_list)
     import mmSolver.tools.selection.tools as tools
     lib_maya_utils.set_scene_selection(node_list)
     tools.select_both_markers_and_bundles()
     return
Exemplo n.º 9
0
 def selection_swap(self):
     node_list = _get_selected_maya_nodes(self)
     LOG.debug("Swap Selection: %r", node_list)
     import mmSolver.tools.selection.tools as tools
     lib_maya_utils.set_scene_selection(node_list)
     tools.swap_between_selected_markers_and_bundles()
     return
Exemplo n.º 10
0
 def objectNodeCurrentChanged(self, index, prevIndex):
     """
     Look up the Maya node from the data at index, then add it to the
     selection.
     """
     # TODO: Based on the Maya selection key modifiers, we should
     # add to the current selection, or toggle, as needed.
     # TODO: When an object node tree item is selected, the attr nodes tree
     # view must all be deselected.
     ui_node = lib_uiquery.get_ui_node_from_index(index,
                                                  self.object_filterModel)
     if ui_node is None:
         return
     # Type info will be 'marker', 'bundle' or 'camera' based on
     # the selected node type.
     typeInfo = ui_node.typeInfo
     nodes = lib_uiquery.convert_ui_nodes_to_nodes([ui_node], typeInfo)
     maya_nodes = []
     if typeInfo == 'camera':
         maya_nodes = [x.get_shape_node() for x in nodes]
     else:
         # For bundles and markers
         maya_nodes = [x.get_node() for x in nodes]
     lib_maya_utils.set_scene_selection(maya_nodes)
     return
Exemplo n.º 11
0
    def removeClicked(self):
        """
        Remove the selected nodes or node attributes from the output
        attributes data model.
        """
        col = lib_state.get_active_collection()
        if col is None:
            return

        sel = lib_maya_utils.get_scene_selection()
        ui_nodes = lib_uiquery.get_selected_ui_nodes(self.treeView,
                                                     self.filterModel)
        attr_list = lib_uiquery.convert_ui_nodes_to_nodes(ui_nodes, 'data')
        lib_attr.remove_attr_from_collection(attr_list, col)

        # Remove Callbacks
        callback_manager = self.callback_manager
        if callback_manager is not None:
            lib_attr.remove_callbacks_from_attributes(attr_list,
                                                      callback_manager)

        self.dataChanged.emit()
        self.viewUpdated.emit()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
Exemplo n.º 12
0
 def attrNodeCurrentChanged(self, index, prevIndex):
     ui_node = lib_uiquery.get_ui_node_from_index(
         index, self.attribute_filterModel)
     if ui_node is None:
         return
     nodes = lib_uiquery.convert_ui_nodes_to_nodes([ui_node], 'data')
     maya_nodes = [x.get_node() for x in nodes]
     lib_maya_utils.set_scene_selection(maya_nodes)
     return
    def removeClicked(self):
        """
        Remove the selected nodes or node attributes from the output
        attributes data model.
        """
        try:
            mmapi.set_solver_running(True)  # disable selection callback.

            s = time.time()
            col = lib_state.get_active_collection()
            if col is None:
                return
            e = time.time()
            LOG.debug("attribute removeClicked1: t=%s", e - s)

            s = time.time()
            sel = lib_maya_utils.get_scene_selection()
            ui_nodes = lib_uiquery.get_selected_ui_nodes(
                self.treeView, self.filterModel)
            node_list = lib_uiquery.convert_ui_nodes_to_nodes(ui_nodes, 'data')
            e = time.time()
            LOG.debug("attribute removeClicked2: t=%s", e - s)

            s = time.time()
            attr_list = _convertNodeListToAttrList(node_list)
            lib_attr.remove_attr_from_collection(attr_list, col)

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

            # Remove Callbacks
            s = time.time()
            callback_manager = self.callback_manager
            if callback_manager is not None:
                lib_attr.remove_callbacks_from_attributes(
                    attr_list, callback_manager)
            e = time.time()
            LOG.debug("attribute removeClicked4: t=%s", e - s)
        finally:
            mmapi.set_solver_running(False)  # enable selection callback

        s = time.time()
        self.dataChanged.emit()
        self.viewUpdated.emit()
        e = time.time()
        LOG.debug("attribute removeClicked5: t=%s", e - s)

        # Restore selection.
        s = time.time()
        lib_maya_utils.set_scene_selection(sel)
        e = time.time()
        LOG.debug("attribute removeClicked5: t=%s", e - s)
        return
    def addClicked(self):
        """
        Add the selected nodes or node attributes to the data model.
        """
        # Store the selection, in case any tools or callbacks
        # accidentally change the scene selection.
        sel = lib_maya_utils.get_scene_selection()

        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()
        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_node_default_attributes(sel)
            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)

        # Restore selection.
        s = time.time()
        lib_maya_utils.set_scene_selection(sel)
        e = time.time()
        LOG.debug("attribute addClicked6: t=%s", e - s)
        return
Exemplo n.º 15
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
Exemplo n.º 16
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
    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