示例#1
0
 def __init__(self, *args):
     """Type name: "DXF module"."""
     super(DxfOutputDialog,
           self).__init__("DXF", "dxf.png",
                          "The part sketchs will including in the file.",
                          "There is only wire frame will be generated.",
                          *args)
     # DXF version option.
     version_label = QLabel("DXF version:", self)
     self.version_option = QComboBox(self)
     self.version_option.addItems(
         sorted((f"{name} - {DXF_VERSIONS_MAP[name]}"
                 for name in DXF_VERSIONS),
                key=lambda v: v.split()[-1]))
     self.version_option.setCurrentIndex(self.version_option.count() - 1)
     self.version_option.setSizePolicy(
         QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
     dxf_version_layout = QHBoxLayout()
     dxf_version_layout.addWidget(version_label)
     dxf_version_layout.addWidget(self.version_option)
     self.main_layout.insertLayout(3, dxf_version_layout)
     # Parts interval.
     self.interval_enable = QCheckBox("Parts interval:", self)
     self.interval_enable.setCheckState(Qt.Checked)
     self.interval_option = QDoubleSpinBox(self)
     self.interval_option.setValue(10)
     self.interval_enable.stateChanged.connect(
         self.interval_option.setEnabled)
     dxf_interval_layout = QHBoxLayout()
     dxf_interval_layout.addWidget(self.interval_enable)
     dxf_interval_layout.addItem(
         QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
     dxf_interval_layout.addWidget(self.interval_option)
     self.assembly_layout.insertLayout(2, dxf_interval_layout)
示例#2
0
class _ScaleDialog(QDialog):
    """Scale mechanism dialog."""
    def __init__(self, parent: QWidget):
        super(_ScaleDialog, self).__init__(parent)
        self.main_layout = QVBoxLayout(self)
        self.enlarge = QDoubleSpinBox(self)
        self.shrink = QDoubleSpinBox(self)
        self.__add_option("Enlarge", self.enlarge)
        self.__add_option("Shrink", self.shrink)

        button_box = QDialogButtonBox(self)
        button_box.setStandardButtons(QDialogButtonBox.Ok
                                      | QDialogButtonBox.Cancel)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        self.main_layout.addWidget(button_box)

    def __add_option(self, name: str, option: QDoubleSpinBox):
        """Add widgets for option."""
        layout = QHBoxLayout(self)
        label = QLabel(name, self)
        option.setValue(1)
        option.setMaximum(10000)
        option.setMinimum(0.01)
        layout.addWidget(label)
        layout.addWidget(option)
        self.main_layout.addLayout(layout)

    def factor(self) -> float:
        """Return scale value."""
        return self.enlarge.value() / self.shrink.value()
示例#3
0
    def __init__(self, parent: QWidget):
        super(_ScaleDialog, self).__init__(parent)
        self.main_layout = QVBoxLayout(self)
        self.enlarge = QDoubleSpinBox(self)
        self.shrink = QDoubleSpinBox(self)
        self.__add_option("Enlarge", self.enlarge)
        self.__add_option("Shrink", self.shrink)

        button_box = QDialogButtonBox(self)
        button_box.setStandardButtons(QDialogButtonBox.Ok
                                      | QDialogButtonBox.Cancel)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        self.main_layout.addWidget(button_box)
示例#4
0
 def writeTable(Length: List[Tuple[str, str, str]],
                Degrees: List[Tuple[str, str, str]]):
     """Use to write table data."""
     i = 0
     for Types, maxV, minV in zip([Length, Degrees], [1000., 360.],
                                  [0.1, 0.]):
         for name, vname, tooltip in Types:
             self.PLTable.insertRow(i)
             name_cell = QTableWidgetItem(name)
             name_cell.setToolTip(tooltip)
             self.PLTable.setItem(i, 0, name_cell)
             spinbox = QDoubleSpinBox()
             spinbox.setMaximum(maxV)
             spinbox.setMinimum(minV)
             spinbox.setToolTip(vname)
             self.PLTable.setCellWidget(i, 1, spinbox)
             i += 1
示例#5
0
 def __add_option(self, name: str, option: QDoubleSpinBox):
     """Add widgets for option."""
     layout = QHBoxLayout(self)
     label = QLabel(name, self)
     option.setValue(1)
     option.setMaximum(10000)
     option.setMinimum(0.01)
     layout.addWidget(label)
     layout.addWidget(option)
     self.main_layout.addLayout(layout)
示例#6
0
def _spinbox(value: float) -> QDoubleSpinBox:
    s = QDoubleSpinBox()
    s.setMaximum(10000)
    s.setValue(value)
    return s
示例#7
0
 def spinbox(v, prefix=False):
     s = QDoubleSpinBox(self)
     s.setMinimum(-1000000.0)
     s.setMaximum(1000000.0)
     s.setSingleStep(10.0)
     s.setValue(v)
     if prefix:
         s.setPrefix("±")
     return s
示例#8
0
class DxfOutputDialog(_OutputDialog):
    """Dialog for DXF format."""
    def __init__(self, *args):
        """Type name: "DXF module"."""
        super(DxfOutputDialog,
              self).__init__("DXF", "dxf.png",
                             "The part sketchs will including in the file.",
                             "There is only wire frame will be generated.",
                             *args)
        # DXF version option.
        version_label = QLabel("DXF version:", self)
        self.version_option = QComboBox(self)
        self.version_option.addItems(
            sorted((f"{name} - {DXF_VERSIONS_MAP[name]}"
                    for name in DXF_VERSIONS),
                   key=lambda v: v.split()[-1]))
        self.version_option.setCurrentIndex(self.version_option.count() - 1)
        self.version_option.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        dxf_version_layout = QHBoxLayout()
        dxf_version_layout.addWidget(version_label)
        dxf_version_layout.addWidget(self.version_option)
        self.main_layout.insertLayout(3, dxf_version_layout)
        # Parts interval.
        self.interval_enable = QCheckBox("Parts interval:", self)
        self.interval_enable.setCheckState(Qt.Checked)
        self.interval_option = QDoubleSpinBox(self)
        self.interval_option.setValue(10)
        self.interval_enable.stateChanged.connect(
            self.interval_option.setEnabled)
        dxf_interval_layout = QHBoxLayout()
        dxf_interval_layout.addWidget(self.interval_enable)
        dxf_interval_layout.addItem(
            QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
        dxf_interval_layout.addWidget(self.interval_option)
        self.assembly_layout.insertLayout(2, dxf_interval_layout)

    def do(self, dir_str: QDir) -> Optional[bool]:
        """Output types:

        + Boundary
        + Frame
        """
        file_name = dir_str.filePath(_get_name(self.filename_edit) + '.dxf')
        if isfile(file_name) and self.warn_radio.isChecked():
            self.exist_warning(file_name)
            return

        version = self.version_option.currentText().split()[0]

        if self.frame_radio.isChecked():
            # Frame
            dxf_frame(self.vpoints, self.v_to_slvs, version, file_name)
        elif self.assembly_radio.isChecked():
            # Boundary
            dxf_boundary(
                self.vpoints, self.link_radius.value(),
                self.interval_option.value() if
                self.interval_enable.isChecked() else None, version, file_name)

        return True
示例#9
0
 def spinbox(v: float,
             *,
             minimum: float = 0.,
             maximum: float = 9999.,
             prefix: bool = False) -> QDoubleSpinBox:
     double_spinbox = QDoubleSpinBox()
     double_spinbox.setMinimum(minimum)
     double_spinbox.setMaximum(maximum)
     double_spinbox.setSingleStep(10.0)
     double_spinbox.setValue(v)
     if prefix:
         double_spinbox.setPrefix("±")
     return double_spinbox