예제 #1
0
    def deleteSelection(self) -> None:
        if not Application.getInstance().getController().getToolsEnabled():
            return

        removed_group_nodes = []
        op = GroupedOperation()
        nodes = Selection.getAllSelectedObjects()

        for node in nodes:
            print_mode_enabled = Application.getInstance(
            ).getGlobalContainerStack().getProperty("print_mode", "enabled")
            if print_mode_enabled:
                node_dup = PrintModeManager.getInstance().getDuplicatedNode(
                    node)
                op.addOperation(RemoveNodesOperation(node_dup))
            else:
                op.addOperation(RemoveSceneNodeOperation(node))
            group_node = node.getParent()
            if group_node and group_node.callDecoration(
                    "isGroup") and group_node not in removed_group_nodes:
                remaining_nodes_in_group = list(
                    set(group_node.getChildren()) - set(nodes))
                if len(remaining_nodes_in_group) == 1:
                    removed_group_nodes.append(group_node)
                    op.addOperation(
                        SetParentOperation(remaining_nodes_in_group[0],
                                           group_node.getParent()))
                    op.addOperation(RemoveSceneNodeOperation(group_node))
        op.push()
예제 #2
0
    def ungroupSelected(self):
        selected_objects = Selection.getAllSelectedObjects().copy()
        for node in selected_objects:
            if node.callDecoration("isGroup"):
                op = GroupedOperation()

                group_parent = node.getParent()
                children = node.getChildren().copy()
                for child in children:
                    # Set the parent of the children to the parent of the group-node
                    op.addOperation(SetParentOperation(child, group_parent))

                    # Add all individual nodes to the selection
                    Selection.add(child)

                op.push()
예제 #3
0
 def deleteSelection(self):
     if not self.getController().getToolsEnabled():
         return
     removed_group_nodes = []
     op = GroupedOperation()
     nodes = Selection.getAllSelectedObjects()
     for node in nodes:
         op.addOperation(RemoveSceneNodeOperation(node))
         group_node = node.getParent()
         if group_node and group_node.callDecoration("isGroup") and group_node not in removed_group_nodes:
             remaining_nodes_in_group = list(set(group_node.getChildren()) - set(nodes))
             if len(remaining_nodes_in_group) == 1:
                 removed_group_nodes.append(group_node)
                 op.addOperation(SetParentOperation(remaining_nodes_in_group[0], group_node.getParent()))
                 op.addOperation(RemoveSceneNodeOperation(group_node))
     op.push()
예제 #4
0
    def deleteObject(self, object_id):
        if not self.getController().getToolsEnabled():
            return

        node = self.getController().getScene().findObject(object_id)

        if not node and object_id != 0:  # Workaround for tool handles overlapping the selected object
            node = Selection.getSelectedObject(0)

        if node:
            group_node = None
            if node.getParent():
                group_node = node.getParent()
                op = RemoveSceneNodeOperation(node)

            op.push()
            if group_node:
                if len(group_node.getChildren()) == 1 and group_node.callDecoration("isGroup"):
                    op.addOperation(SetParentOperation(group_node.getChildren()[0], group_node.getParent()))
                    op = RemoveSceneNodeOperation(group_node)
                    op.push()
예제 #5
0
    def deleteObject(self, object_id):
        if not self.getController().getToolsEnabled():
            return

        node = self.getController().getScene().findObject(object_id)

        if not node and object_id != 0:  # Workaround for tool handles overlapping the selected object
            node = Selection.getSelectedObject(0)

        if node:
            op = GroupedOperation()
            op.addOperation(RemoveSceneNodeOperation(node))

            group_node = node.getParent()
            if group_node:
                # Note that at this point the node has not yet been deleted
                if len(group_node.getChildren()) <= 2 and group_node.callDecoration("isGroup"):
                    op.addOperation(SetParentOperation(group_node.getChildren()[0], group_node.getParent()))
                    op.addOperation(RemoveSceneNodeOperation(group_node))

            op.push()