ExcellonOptPrefGroupUI.py 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. from flatcamGUI.GUIElements import OptionalInputSection
  2. from flatcamGUI.preferences import machinist_setting
  3. from flatcamGUI.preferences.OptionUI import *
  4. from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
  5. import gettext
  6. import FlatCAMTranslation 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 ExcellonOptPrefGroupUI(OptionsGroupUI2):
  17. def __init__(self, decimals=4, **kwargs):
  18. self.decimals = decimals
  19. super().__init__(**kwargs)
  20. self.setTitle(str(_("Excellon Options")))
  21. self.pp_excellon_name_cb = self.option_dict()["excellon_ppname_e"].get_field()
  22. self.multidepth_cb = self.option_dict()["excellon_multidepth"].get_field()
  23. self.depthperpass_entry = self.option_dict()["excellon_depthperpass"].get_field()
  24. self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry])
  25. self.dwell_cb = self.option_dict()["excellon_dwell"].get_field()
  26. self.dwelltime_entry = self.option_dict()["excellon_dwelltime"].get_field()
  27. self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  28. # FIXME until this feature is implemented these are disabled
  29. self.option_dict()["excellon_gcode_type"].label_widget.hide()
  30. self.option_dict()["excellon_gcode_type"].get_field().hide()
  31. def build_options(self) -> [OptionUI]:
  32. return [
  33. HeadingOptionUI(
  34. label_text="Create CNC Job",
  35. label_tooltip="Parameters used to create a CNC Job object\n"
  36. "for this drill object."
  37. ),
  38. RadioSetOptionUI(
  39. option="excellon_operation",
  40. label_text="Operation",
  41. label_bold=True,
  42. label_tooltip="Operation type:\n"
  43. "- Drilling -> will drill the drills/slots associated with this tool\n"
  44. "- Milling -> will mill the drills/slots",
  45. choices=[
  46. {'label': _('Drilling'), 'value': 'drill'},
  47. {'label': _("Milling"), 'value': 'mill'}
  48. ]
  49. ),
  50. RadioSetOptionUI(
  51. option="excellon_milling_type",
  52. label_text="Milling Type",
  53. label_tooltip="Milling type:\n"
  54. "- Drills -> will mill the drills associated with this tool\n"
  55. "- Slots -> will mill the slots associated with this tool\n"
  56. "- Both -> will mill both drills and mills or whatever is available",
  57. choices=[
  58. {'label': _('Drills'), 'value': 'drills'},
  59. {'label': _("Slots"), 'value': 'slots'},
  60. {'label': _("Both"), 'value': 'both'},
  61. ]
  62. ),
  63. DoubleSpinnerOptionUI(
  64. option="excellon_milling_dia",
  65. label_text="Milling Diameter",
  66. label_tooltip="The diameter of the tool who will do the milling",
  67. min_value=0.0, max_value=9999.9999, step=0.1, decimals=self.decimals
  68. ),
  69. DoubleSpinnerOptionUI(
  70. option="excellon_cutz",
  71. label_text="Cut Z",
  72. label_tooltip="Drill depth (negative) \nbelow the copper surface.",
  73. min_value=-9999.9999, max_value=(9999.9999 if machinist_setting else 0.0),
  74. step=0.1, decimals=self.decimals
  75. ),
  76. CheckboxOptionUI(
  77. option="excellon_multidepth",
  78. label_text="Multi-Depth",
  79. label_tooltip="Use multiple passes to limit\n"
  80. "the cut depth in each pass. Will\n"
  81. "cut multiple times until Cut Z is\n"
  82. "reached."
  83. ),
  84. DoubleSpinnerOptionUI(
  85. option="excellon_depthperpass",
  86. label_text="Depth/Pass",
  87. label_tooltip="Depth of each pass (positive).",
  88. min_value=0, max_value=99999, step=0.1, decimals=self.decimals
  89. ),
  90. DoubleSpinnerOptionUI(
  91. option="excellon_travelz",
  92. label_text="Travel Z",
  93. label_tooltip="Tool height when travelling\nacross the XY plane.",
  94. min_value=(-9999.9999 if machinist_setting else 0.0001), max_value=9999.9999,
  95. step=0.1, decimals=self.decimals
  96. ),
  97. CheckboxOptionUI(
  98. option="excellon_toolchange",
  99. label_text="Tool change",
  100. label_tooltip="Include tool-change sequence\nin G-Code (Pause for tool change)."
  101. ),
  102. DoubleSpinnerOptionUI(
  103. option="excellon_toolchangez",
  104. label_text="Toolchange Z",
  105. label_tooltip="Z-axis position (height) for\ntool change.",
  106. min_value=(-9999.9999 if machinist_setting else 0.0), max_value=9999.9999,
  107. step=0.1, decimals=self.decimals
  108. ),
  109. DoubleSpinnerOptionUI(
  110. option="excellon_endz",
  111. label_text="End move Z",
  112. label_tooltip="Height of the tool after\nthe last move at the end of the job.",
  113. min_value=(-9999.9999 if machinist_setting else 0.0), max_value=9999.9999,
  114. step=0.1, decimals=self.decimals
  115. ),
  116. LineEntryOptionUI(
  117. option="excellon_endxy",
  118. label_text="End move X,Y",
  119. label_tooltip="End move X,Y position. In format (x,y).\n"
  120. "If no value is entered then there is no move\n"
  121. "on X,Y plane at the end of the job."
  122. ),
  123. DoubleSpinnerOptionUI(
  124. option="excellon_feedrate_z",
  125. label_text="Feedrate Z",
  126. label_tooltip="Tool speed while drilling\n"
  127. "(in units per minute).\n"
  128. "So called 'Plunge' feedrate.\n"
  129. "This is for linear move G01.",
  130. min_value=0, max_value=99999.9999, step=0.1, decimals=self.decimals
  131. ),
  132. SpinnerOptionUI(
  133. option="excellon_spindlespeed",
  134. label_text="Spindle speed",
  135. label_tooltip="Speed of the spindle in RPM (optional).",
  136. min_value=0, max_value=1000000, step=100
  137. ),
  138. CheckboxOptionUI(
  139. option="excellon_dwell",
  140. label_text="Enable Dwell",
  141. label_tooltip="Pause to allow the spindle to reach its\nspeed before cutting."
  142. ),
  143. DoubleSpinnerOptionUI(
  144. option="excellon_dwelltime",
  145. label_text="Duration",
  146. label_tooltip="Number of time units for spindle to dwell.",
  147. min_value=0, max_value=999999, step=0.5, decimals=self.decimals
  148. ),
  149. ComboboxOptionUI(
  150. option="excellon_ppname_e",
  151. label_text="Preprocessor",
  152. label_tooltip="The preprocessor JSON file that dictates\nGcode output.", # FIXME tooltip incorrect?
  153. choices=[] # Populated in App (FIXME)
  154. ),
  155. RadioSetOptionUI(
  156. option="excellon_gcode_type",
  157. label_text="Gcode",
  158. label_bold=True,
  159. label_tooltip="Choose what to use for GCode generation:\n"
  160. "'Drills', 'Slots' or 'Both'.\n"
  161. "When choosing 'Slots' or 'Both', slots will be\n"
  162. "converted to drills.",
  163. choices=[
  164. {'label': 'Drills', 'value': 'drills'},
  165. {'label': 'Slots', 'value': 'slots'},
  166. {'label': 'Both', 'value': 'both'}
  167. ]
  168. ),
  169. HeadingOptionUI(
  170. label_text="Mill Holes",
  171. label_tooltip="Create Geometry for milling holes."
  172. ),
  173. DoubleSpinnerOptionUI(
  174. option="excellon_tooldia",
  175. label_text="Drill Tool dia",
  176. label_tooltip="Diameter of the cutting tool",
  177. min_value=0.0, max_value=999.9999, step=0.1, decimals=self.decimals
  178. ),
  179. DoubleSpinnerOptionUI(
  180. option="excellon_slot_tooldia",
  181. label_text="Slot Tool dia",
  182. label_tooltip="Diameter of the cutting tool\nwhen milling slots.",
  183. min_value=0.0, max_value=999.9999, step=0.1, decimals=self.decimals
  184. )
  185. ]