Пример #1
0
 def delete_point(self, row: Optional[int] = None) -> None:
     """Push delete point command to stack."""
     if row is None:
         row = self.entities_point.currentRow()
     if row < 0:
         return
     args = self.entities_point.row_data(row)
     args.links = ''
     self.command_stack.beginMacro(f"Delete {{Point{row}}}")
     for i in reversed([
             i
             for i, (b, d, _) in enumerate(self.inputs_widget.input_pairs())
             if row in {b, d}
     ]):
         self.inputs_widget.remove_var(i)
     self.command_stack.push(
         EditPointTable(row, self.vpoint_list, self.vlink_list,
                        self.entities_point, self.entities_link, args))
     for i in range(self.entities_link.rowCount()):
         self.command_stack.push(
             FixSequenceNumber(self.vlink_list, self.entities_link, i, row))
     self.command_stack.push(
         DeleteTable(row,
                     self.vpoint_list,
                     self.entities_point,
                     is_rename=True))
     self.inputs_widget.variable_excluding(row)
     self.command_stack.endMacro()
     if self.prefer.auto_remove_link_option:
         self.delete_redundant_links()
Пример #2
0
 def constrain_link(self,
                    row1: Optional[int] = None,
                    row2: int = 0) -> None:
     """Turn a link to ground, then delete this link."""
     if row1 is None:
         row1 = self.entities_link.currentRow()
     vlink1 = self.vlink_list[row1]
     link_args = self.entities_link.row_data(row1)
     link_args.points = ''
     new_points = sorted(
         set(self.vlink_list[0].points) | set(vlink1.points))
     base_args = self.entities_link.row_data(row2)
     base_args.points = ','.join(f"Point{e}" for e in new_points if e)
     self.command_stack.beginMacro(
         f"Constrain {{Link: {vlink1.name}}} to ground")
     # Turn to ground
     self.command_stack.push(
         EditLinkTable(row2, self.vpoint_list, self.vlink_list,
                       self.entities_point, self.entities_link, base_args))
     # Free all points and delete the link
     self.command_stack.push(
         EditLinkTable(row1, self.vpoint_list, self.vlink_list,
                       self.entities_point, self.entities_link, link_args))
     self.command_stack.push(
         DeleteTable(row1,
                     self.vlink_list,
                     self.entities_link,
                     is_rename=False))
     self.command_stack.endMacro()
Пример #3
0
    def delete_link(self, row: Optional[int] = None) -> None:
        """Push delete link command to stack.

        Remove link will not remove the points.
        """
        if row is None:
            row = self.entities_link.currentRow()
        if row < 1:
            return
        args = self.entities_link.row_data(row)
        args.points = ''
        self.cmd_stack.beginMacro(
            f"Delete {{Link: {self.vlink_list[row].name}}}")
        self.cmd_stack.push(EditLinkTable(
            row,
            self.vpoint_list,
            self.vlink_list,
            self.entities_point,
            self.entities_link,
            args
        ))
        self.cmd_stack.push(DeleteTable(
            row,
            self.vlink_list,
            self.entities_link,
            is_rename=False
        ))
        self.cmd_stack.endMacro()