コード例 #1
0
 def release_ground(self) -> None:
     """Clone ground to a new link, then make ground no points."""
     name = self.__get_link_serial_number()
     args = LinkArgs(name, 'Blue', self.entities_link.item(0, 2).text())
     self.cmd_stack.beginMacro(f"Release ground to {{Link: {name}}}")
     # Free all points
     self.cmd_stack.push(EditLinkTable(
         0,
         self.vpoint_list,
         self.vlink_list,
         self.entities_point,
         self.entities_link,
         LinkArgs(VLink.FRAME, 'White', '')
     ))
     # Create new link
     self.cmd_stack.push(AddTable(self.vlink_list, self.entities_link))
     self.cmd_stack.push(EditLinkTable(
         self.entities_link.rowCount() - 1,
         self.vpoint_list,
         self.vlink_list,
         self.entities_point,
         self.entities_link,
         args
     ))
     self.cmd_stack.endMacro()
コード例 #2
0
ファイル: entities.py プロジェクト: s40723103/Pyslvs-UI
    def __edit_link(self, row: Union[int, bool] = False) -> None:
        """Edit link function."""
        dlg = EditLinkDialog(self.vpoint_list, self.vlink_list, row, self)
        dlg.show()
        if not dlg.exec_():
            dlg.deleteLater()
            return

        name = dlg.name_edit.text()
        args = LinkArgs(
            name, dlg.color_box.currentText(), ','.join(
                dlg.selected.item(point).text()
                for point in range(dlg.selected.count())))
        if row is False:
            self.command_stack.beginMacro(f"Add {{Link: {name}}}")
            self.command_stack.push(
                AddTable(self.vlink_list, self.entities_link))
            row = self.entities_link.rowCount() - 1
        else:
            row = dlg.name_box.currentIndex()
            self.command_stack.beginMacro(f"Edit {{Link: {name}}}")

        dlg.deleteLater()

        self.command_stack.push(
            EditLinkTable(row, self.vpoint_list, self.vlink_list,
                          self.entities_point, self.entities_link, args))
        self.command_stack.endMacro()
コード例 #3
0
ファイル: entities.py プロジェクト: s40723103/Pyslvs-UI
 def add_link(self,
              name: str,
              color: str,
              points: Optional[Sequence[int]] = None) -> None:
     """Push a new link command to stack."""
     if points is None:
         points = []
     args = LinkArgs(name, color, ','.join(f'Point{i}' for i in points))
     self.command_stack.beginMacro(f"Add {{Link: {name}}}")
     self.command_stack.push(AddTable(self.vlink_list, self.entities_link))
     self.command_stack.push(
         EditLinkTable(self.entities_link.rowCount() - 1, self.vpoint_list,
                       self.vlink_list, self.entities_point,
                       self.entities_link, args))
     self.command_stack.endMacro()
コード例 #4
0
 def clear(self) -> None:
     """We should keep the frame left."""
     super(LinkTableWidget, self).clear()
     self.setRowCount(1)
     self.edit_link(0, LinkArgs(VLink.FRAME, 'White', ''))
コード例 #5
0
 def row_data(self, row: int) -> LinkArgs:
     """Return row data for 'edit_link' method."""
     return LinkArgs(*self.row_text(row, has_name=True))
コード例 #6
0
 def __init__(self, parent: QWidget) -> None:
     super(LinkTableWidget, self).__init__(1, parent)
     self.setDragDropMode(QAbstractItemView.DropOnly)
     self.setAcceptDrops(True)
     self.edit_link(0, LinkArgs(VLink.FRAME, 'White', ''))