GerberOptPrefGroupUI.py 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from AppGUI.GUIElements import FCDoubleSpinner, FCSpinner, RadioSet, FCCheckBox
  4. from AppGUI.preferences.OptionsGroupUI import OptionsGroupUI
  5. import gettext
  6. import AppTranslation as fcTranslate
  7. import builtins
  8. fcTranslate.apply_language('strings')
  9. if '_' not in builtins.__dict__:
  10. _ = gettext.gettext
  11. settings = QSettings("Open Source", "FlatCAM")
  12. if settings.contains("machinist"):
  13. machinist_setting = settings.value('machinist', type=int)
  14. else:
  15. machinist_setting = 0
  16. class GerberOptPrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. # OptionsGroupUI.__init__(self, "Gerber Options Preferences", parent=parent)
  19. super(GerberOptPrefGroupUI, self).__init__(self, parent=parent)
  20. self.decimals = decimals
  21. self.setTitle(str(_("Gerber Options")))
  22. # ## Isolation Routing
  23. self.isolation_routing_label = QtWidgets.QLabel("<b>%s:</b>" % _("Isolation Routing"))
  24. self.isolation_routing_label.setToolTip(
  25. _("Create a Geometry object with\n"
  26. "toolpaths to cut outside polygons.")
  27. )
  28. self.layout.addWidget(self.isolation_routing_label)
  29. # Cutting Tool Diameter
  30. grid0 = QtWidgets.QGridLayout()
  31. self.layout.addLayout(grid0)
  32. tdlabel = QtWidgets.QLabel('%s:' % _('Tool dia'))
  33. tdlabel.setToolTip(
  34. _("Diameter of the cutting tool.")
  35. )
  36. grid0.addWidget(tdlabel, 0, 0)
  37. self.iso_tool_dia_entry = FCDoubleSpinner()
  38. self.iso_tool_dia_entry.set_precision(self.decimals)
  39. self.iso_tool_dia_entry.setSingleStep(0.1)
  40. self.iso_tool_dia_entry.set_range(-9999, 9999)
  41. grid0.addWidget(self.iso_tool_dia_entry, 0, 1)
  42. # Nr of passes
  43. passlabel = QtWidgets.QLabel('%s:' % _('# Passes'))
  44. passlabel.setToolTip(
  45. _("Width of the isolation gap in\n"
  46. "number (integer) of tool widths.")
  47. )
  48. self.iso_width_entry = FCSpinner()
  49. self.iso_width_entry.set_range(1, 999)
  50. grid0.addWidget(passlabel, 1, 0)
  51. grid0.addWidget(self.iso_width_entry, 1, 1)
  52. # Pass overlap
  53. overlabel = QtWidgets.QLabel('%s:' % _('Pass overlap'))
  54. overlabel.setToolTip(
  55. _("How much (percentage) of the tool width to overlap each tool pass.")
  56. )
  57. self.iso_overlap_entry = FCDoubleSpinner(suffix='%')
  58. self.iso_overlap_entry.set_precision(self.decimals)
  59. self.iso_overlap_entry.setWrapping(True)
  60. self.iso_overlap_entry.setRange(0.0000, 99.9999)
  61. self.iso_overlap_entry.setSingleStep(0.1)
  62. grid0.addWidget(overlabel, 2, 0)
  63. grid0.addWidget(self.iso_overlap_entry, 2, 1)
  64. # Isolation Scope
  65. self.iso_scope_label = QtWidgets.QLabel('%s:' % _('Scope'))
  66. self.iso_scope_label.setToolTip(
  67. _("Isolation scope. Choose what to isolate:\n"
  68. "- 'All' -> Isolate all the polygons in the object\n"
  69. "- 'Selection' -> Isolate a selection of polygons.")
  70. )
  71. self.iso_scope_radio = RadioSet([{'label': _('All'), 'value': 'all'},
  72. {'label': _('Selection'), 'value': 'single'}])
  73. grid0.addWidget(self.iso_scope_label, 3, 0)
  74. grid0.addWidget(self.iso_scope_radio, 3, 1, 1, 2)
  75. # Milling Type
  76. milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
  77. milling_type_label.setToolTip(
  78. _("Milling type:\n"
  79. "- climb / best for precision milling and to reduce tool usage\n"
  80. "- conventional / useful when there is no backlash compensation")
  81. )
  82. grid0.addWidget(milling_type_label, 4, 0)
  83. self.milling_type_radio = RadioSet([{'label': _('Climb'), 'value': 'cl'},
  84. {'label': _('Conventional'), 'value': 'cv'}])
  85. grid0.addWidget(self.milling_type_radio, 4, 1)
  86. # Combine passes
  87. self.combine_passes_cb = FCCheckBox(label=_('Combine Passes'))
  88. self.combine_passes_cb.setToolTip(
  89. _("Combine all passes into one object")
  90. )
  91. grid0.addWidget(self.combine_passes_cb, 5, 0, 1, 2)
  92. separator_line = QtWidgets.QFrame()
  93. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  94. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  95. grid0.addWidget(separator_line, 6, 0, 1, 2)
  96. # ## Clear non-copper regions
  97. self.clearcopper_label = QtWidgets.QLabel("<b>%s:</b>" % _("Non-copper regions"))
  98. self.clearcopper_label.setToolTip(
  99. _("Create polygons covering the\n"
  100. "areas without copper on the PCB.\n"
  101. "Equivalent to the inverse of this\n"
  102. "object. Can be used to remove all\n"
  103. "copper from a specified region.")
  104. )
  105. self.layout.addWidget(self.clearcopper_label)
  106. grid1 = QtWidgets.QGridLayout()
  107. self.layout.addLayout(grid1)
  108. # Margin
  109. bmlabel = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
  110. bmlabel.setToolTip(
  111. _("Specify the edge of the PCB\n"
  112. "by drawing a box around all\n"
  113. "objects with this minimum\n"
  114. "distance.")
  115. )
  116. grid1.addWidget(bmlabel, 0, 0)
  117. self.noncopper_margin_entry = FCDoubleSpinner()
  118. self.noncopper_margin_entry.set_precision(self.decimals)
  119. self.noncopper_margin_entry.setSingleStep(0.1)
  120. self.noncopper_margin_entry.set_range(-9999, 9999)
  121. grid1.addWidget(self.noncopper_margin_entry, 0, 1)
  122. # Rounded corners
  123. self.noncopper_rounded_cb = FCCheckBox(label=_("Rounded Geo"))
  124. self.noncopper_rounded_cb.setToolTip(
  125. _("Resulting geometry will have rounded corners.")
  126. )
  127. grid1.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  128. separator_line = QtWidgets.QFrame()
  129. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  130. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  131. grid1.addWidget(separator_line, 2, 0, 1, 2)
  132. # ## Bounding box
  133. self.boundingbox_label = QtWidgets.QLabel('<b>%s:</b>' % _('Bounding Box'))
  134. self.layout.addWidget(self.boundingbox_label)
  135. grid2 = QtWidgets.QGridLayout()
  136. self.layout.addLayout(grid2)
  137. bbmargin = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
  138. bbmargin.setToolTip(
  139. _("Distance of the edges of the box\n"
  140. "to the nearest polygon.")
  141. )
  142. self.bbmargin_entry = FCDoubleSpinner()
  143. self.bbmargin_entry.set_precision(self.decimals)
  144. self.bbmargin_entry.setSingleStep(0.1)
  145. self.bbmargin_entry.set_range(-9999, 9999)
  146. grid2.addWidget(bbmargin, 0, 0)
  147. grid2.addWidget(self.bbmargin_entry, 0, 1)
  148. self.bbrounded_cb = FCCheckBox(label='%s' % _("Rounded Geo"))
  149. self.bbrounded_cb.setToolTip(
  150. _("If the bounding box is \n"
  151. "to have rounded corners\n"
  152. "their radius is equal to\n"
  153. "the margin.")
  154. )
  155. grid2.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  156. self.layout.addStretch()