示例#1
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
示例#2
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
示例#3
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
示例#4
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
    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
示例#6
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
示例#7
0
    def __lookupAttrNodes(indexes, model):
        maya_nodes = []
        for idx in indexes:
            ui_node = lib_uiquery.get_ui_node_from_index(idx, model)
            if ui_node is None:
                continue

            nodes = lib_uiquery.convert_ui_nodes_to_nodes([ui_node], 'data')
            maya_nodes += [x.get_node() for x in nodes]
        return maya_nodes
示例#8
0
def _get_selected_maya_nodes(cls_obj):
    tree_view = cls_obj
    filter_model = cls_obj.model()
    ui_nodes = lib_uiquery.get_selected_ui_nodes(
        tree_view,
        filter_model,
    )
    uuid_list = lib_uiquery.convert_ui_nodes_to_nodes(ui_nodes, 'uuid')
    nodes = lib_maya_utils.get_node_names_from_uuids(uuid_list)
    return nodes
    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
示例#10
0
 def solverRemoveClicked(self):
     ui_nodes = lib_uiquery.get_selected_ui_table_row(
         self.solver_tableView, self.solver_model, self.solver_filterModel)
     names = map(lambda x: x.name(), ui_nodes)
     col_nodes = lib_uiquery.convert_ui_nodes_to_nodes(
         ui_nodes, 'collection_node')
     assert len(names) == len(col_nodes)
     for name, col in zip(names, col_nodes):
         step = lib_col.get_named_solver_step_from_collection(col, name)
         lib_col.remove_solver_step_from_collection(col, step)
     self.updateSolverModel()
     self.updateSolveValidState()
     return
示例#11
0
    def removeClicked(self):
        ui_nodes = lib_uiquery.get_selected_ui_table_row(
            self.tableView, self.model, self.filterModel)
        names = map(lambda x: x.name(), ui_nodes)
        col_nodes = lib_uiquery.convert_ui_nodes_to_nodes(
            ui_nodes, 'collection_node')
        assert len(names) == len(col_nodes)
        for name, col in zip(names, col_nodes):
            step = lib_col.get_named_solver_step_from_collection(col, name)
            lib_col.remove_solver_step_from_collection(col, step)

        self.itemRemoved.emit()
        self.dataChanged.emit()
        self.viewUpdated.emit()
        return
def _get_selected_attrs(cls_obj):
    tree_view = cls_obj
    filter_model = cls_obj.model()
    ui_nodes = lib_uiquery.get_selected_ui_nodes(
        tree_view,
        filter_model,
    )
    attr_ui_nodes = [x for x in ui_nodes if isinstance(x, attr_nodes.AttrNode)]
    attr_list = lib_uiquery.convert_ui_nodes_to_nodes(attr_ui_nodes, 'data')
    # maya_ui_nodes = [x for x in ui_nodes if isinstance(x, attr_nodes.MayaNode)]
    # for maya_ui_node in maya_ui_nodes:
    #     # Maya nodes will contain all the attributes added into the UI
    #     # in the 'data' key name on the data of the MayaNode.
    #     attr_list += maya_ui_node.data().get('data')
    return attr_list
示例#13
0
    def __lookupObjectNodes(indexes, model):
        maya_nodes = []
        for idx in indexes:
            ui_node = lib_uiquery.get_ui_node_from_index(idx, model)
            if ui_node is None:
                continue

            # 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)
            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]
        return maya_nodes
def _lookupUINodesFromIndexes(indexes, model):
    """
    Find the UI nodes, from the list of Qt indexes.
    """
    maya_nodes = []
    for idx in indexes:
        ui_node = lib_uiquery.get_ui_node_from_index(idx, model)
        if ui_node is None:
            continue

        # 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)
        if typeInfo == 'camera':
            maya_nodes += [x.get_transform_node() for x in nodes]
        else:
            # For bundles and markers
            maya_nodes += [x.get_node() for x in nodes]
    return maya_nodes
def _lookupMayaNodesFromAttrUINodes(indexes, model):
    maya_nodes = []
    for idx in indexes:
        ui_node = lib_uiquery.get_ui_node_from_index(idx, model)
        if ui_node is None:
            continue
        # For both AttrNode and MayaNodes we ensure we only add a new
        # Maya node if the existing node name is not in the
        # accumulated list. We do not remove the order of the nodes
        # only ensure that no duplicates are added.
        if isinstance(ui_node, attr_nodes.AttrNode):
            nodes = lib_uiquery.convert_ui_nodes_to_nodes([ui_node], 'data')
            node_names = [x.get_node() for x in nodes]
            maya_nodes += [x for x in node_names if x not in maya_nodes]
        elif isinstance(ui_node, attr_nodes.MayaNode):
            node_uuid = ui_node.data().get('uuid')
            node_names = lib_maya_utils.get_node_names_from_uuids([node_uuid])
            maya_nodes += [x for x in node_names if x not in maya_nodes]
        else:
            LOG.error("Invalid node type: %r", ui_node)
    return maya_nodes
示例#16
0
    def objectRemoveClicked(self):
        col = lib_state.get_active_collection()
        if col is None:
            return
        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.updateObjectModel()
        self.updateSolveValidState()
        self.setStatusLine(const.STATUS_READY)
        return