ExcellonEditorPrefGroupUI.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from appGUI.GUIElements import FCSpinner, FCDoubleSpinner, RadioSet
  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 ExcellonEditorPrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. super(ExcellonEditorPrefGroupUI, self).__init__(self, parent=parent)
  19. self.setTitle(str(_("Excellon Editor")))
  20. self.decimals = decimals
  21. # Excellon Editor Parameters
  22. self.param_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
  23. self.param_label.setToolTip(
  24. _("A list of Excellon Editor parameters.")
  25. )
  26. self.layout.addWidget(self.param_label)
  27. grid0 = QtWidgets.QGridLayout()
  28. self.layout.addLayout(grid0)
  29. # Selection Limit
  30. self.sel_limit_label = QtWidgets.QLabel('%s:' % _("Selection limit"))
  31. self.sel_limit_label.setToolTip(
  32. _("Set the number of selected Excellon geometry\n"
  33. "items above which the utility geometry\n"
  34. "becomes just a selection rectangle.\n"
  35. "Increases the performance when moving a\n"
  36. "large number of geometric elements.")
  37. )
  38. self.sel_limit_entry = FCSpinner()
  39. self.sel_limit_entry.set_range(0, 99999)
  40. grid0.addWidget(self.sel_limit_label, 0, 0)
  41. grid0.addWidget(self.sel_limit_entry, 0, 1)
  42. # New Diameter
  43. self.addtool_entry_lbl = QtWidgets.QLabel('%s:' % _('New Dia'))
  44. self.addtool_entry_lbl.setToolTip(
  45. _("Diameter for the new tool")
  46. )
  47. self.addtool_entry = FCDoubleSpinner()
  48. self.addtool_entry.set_range(0.000001, 99.9999)
  49. self.addtool_entry.set_precision(self.decimals)
  50. grid0.addWidget(self.addtool_entry_lbl, 1, 0)
  51. grid0.addWidget(self.addtool_entry, 1, 1)
  52. # Number of drill holes in a drill array
  53. self.drill_array_size_label = QtWidgets.QLabel('%s:' % _('Nr of drills'))
  54. self.drill_array_size_label.setToolTip(
  55. _("Specify how many drills to be in the array.")
  56. )
  57. # self.drill_array_size_label.setMinimumWidth(100)
  58. self.drill_array_size_entry = FCSpinner()
  59. self.drill_array_size_entry.set_range(0, 9999)
  60. grid0.addWidget(self.drill_array_size_label, 2, 0)
  61. grid0.addWidget(self.drill_array_size_entry, 2, 1)
  62. self.drill_array_linear_label = QtWidgets.QLabel('<b>%s:</b>' % _('Linear Drill Array'))
  63. grid0.addWidget(self.drill_array_linear_label, 3, 0, 1, 2)
  64. # Linear Drill Array direction
  65. self.drill_axis_label = QtWidgets.QLabel('%s:' % _('Linear Direction'))
  66. self.drill_axis_label.setToolTip(
  67. _("Direction on which the linear array is oriented:\n"
  68. "- 'X' - horizontal axis \n"
  69. "- 'Y' - vertical axis or \n"
  70. "- 'Angle' - a custom angle for the array inclination")
  71. )
  72. # self.drill_axis_label.setMinimumWidth(100)
  73. self.drill_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
  74. {'label': _('Y'), 'value': 'Y'},
  75. {'label': _('Angle'), 'value': 'A'}])
  76. grid0.addWidget(self.drill_axis_label, 4, 0)
  77. grid0.addWidget(self.drill_axis_radio, 4, 1)
  78. # Linear Drill Array pitch distance
  79. self.drill_pitch_label = QtWidgets.QLabel('%s:' % _('Pitch'))
  80. self.drill_pitch_label.setToolTip(
  81. _("Pitch = Distance between elements of the array.")
  82. )
  83. # self.drill_pitch_label.setMinimumWidth(100)
  84. self.drill_pitch_entry = FCDoubleSpinner()
  85. self.drill_pitch_entry.set_range(0, 99999.9999)
  86. self.drill_pitch_entry.set_precision(self.decimals)
  87. grid0.addWidget(self.drill_pitch_label, 5, 0)
  88. grid0.addWidget(self.drill_pitch_entry, 5, 1)
  89. # Linear Drill Array custom angle
  90. self.drill_angle_label = QtWidgets.QLabel('%s:' % _('Angle'))
  91. self.drill_angle_label.setToolTip(
  92. _("Angle at which each element in circular array is placed.")
  93. )
  94. self.drill_angle_entry = FCDoubleSpinner()
  95. self.drill_pitch_entry.set_range(-360, 360)
  96. self.drill_pitch_entry.set_precision(self.decimals)
  97. self.drill_angle_entry.setWrapping(True)
  98. self.drill_angle_entry.setSingleStep(5)
  99. grid0.addWidget(self.drill_angle_label, 6, 0)
  100. grid0.addWidget(self.drill_angle_entry, 6, 1)
  101. self.drill_array_circ_label = QtWidgets.QLabel('<b>%s:</b>' % _('Circular Drill Array'))
  102. grid0.addWidget(self.drill_array_circ_label, 7, 0, 1, 2)
  103. # Circular Drill Array direction
  104. self.drill_circular_direction_label = QtWidgets.QLabel('%s:' % _('Circular Direction'))
  105. self.drill_circular_direction_label.setToolTip(
  106. _("Direction for circular array.\n"
  107. "Can be CW = clockwise or CCW = counter clockwise.")
  108. )
  109. self.drill_circular_dir_radio = RadioSet([{'label': _('CW'), 'value': 'CW'},
  110. {'label': _('CCW'), 'value': 'CCW'}])
  111. grid0.addWidget(self.drill_circular_direction_label, 8, 0)
  112. grid0.addWidget(self.drill_circular_dir_radio, 8, 1)
  113. # Circular Drill Array Angle
  114. self.drill_circular_angle_label = QtWidgets.QLabel('%s:' % _('Circular Angle'))
  115. self.drill_circular_angle_label.setToolTip(
  116. _("Angle at which each element in circular array is placed.")
  117. )
  118. self.drill_circular_angle_entry = FCDoubleSpinner()
  119. self.drill_circular_angle_entry.set_range(-360, 360)
  120. self.drill_circular_angle_entry.set_precision(self.decimals)
  121. self.drill_circular_angle_entry.setWrapping(True)
  122. self.drill_circular_angle_entry.setSingleStep(5)
  123. grid0.addWidget(self.drill_circular_angle_label, 9, 0)
  124. grid0.addWidget(self.drill_circular_angle_entry, 9, 1)
  125. # ##### SLOTS #####
  126. # #################
  127. self.drill_array_circ_label = QtWidgets.QLabel('<b>%s:</b>' % _('Slots'))
  128. grid0.addWidget(self.drill_array_circ_label, 10, 0, 1, 2)
  129. # Slot length
  130. self.slot_length_label = QtWidgets.QLabel('%s:' % _('Length'))
  131. self.slot_length_label.setToolTip(
  132. _("Length = The length of the slot.")
  133. )
  134. self.slot_length_label.setMinimumWidth(100)
  135. self.slot_length_entry = FCDoubleSpinner()
  136. self.slot_length_entry.set_range(0, 99999)
  137. self.slot_length_entry.set_precision(self.decimals)
  138. self.slot_length_entry.setWrapping(True)
  139. self.slot_length_entry.setSingleStep(1)
  140. grid0.addWidget(self.slot_length_label, 11, 0)
  141. grid0.addWidget(self.slot_length_entry, 11, 1)
  142. # Slot direction
  143. self.slot_axis_label = QtWidgets.QLabel('%s:' % _('Direction'))
  144. self.slot_axis_label.setToolTip(
  145. _("Direction on which the slot is oriented:\n"
  146. "- 'X' - horizontal axis \n"
  147. "- 'Y' - vertical axis or \n"
  148. "- 'Angle' - a custom angle for the slot inclination")
  149. )
  150. self.slot_axis_label.setMinimumWidth(100)
  151. self.slot_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
  152. {'label': _('Y'), 'value': 'Y'},
  153. {'label': _('Angle'), 'value': 'A'}])
  154. grid0.addWidget(self.slot_axis_label, 12, 0)
  155. grid0.addWidget(self.slot_axis_radio, 12, 1)
  156. # Slot custom angle
  157. self.slot_angle_label = QtWidgets.QLabel('%s:' % _('Angle'))
  158. self.slot_angle_label.setToolTip(
  159. _("Angle at which the slot is placed.\n"
  160. "The precision is of max 2 decimals.\n"
  161. "Min value is: -359.99 degrees.\n"
  162. "Max value is: 360.00 degrees.")
  163. )
  164. self.slot_angle_label.setMinimumWidth(100)
  165. self.slot_angle_spinner = FCDoubleSpinner()
  166. self.slot_angle_spinner.set_precision(self.decimals)
  167. self.slot_angle_spinner.setWrapping(True)
  168. self.slot_angle_spinner.setRange(-359.99, 360.00)
  169. self.slot_angle_spinner.setSingleStep(5)
  170. grid0.addWidget(self.slot_angle_label, 13, 0)
  171. grid0.addWidget(self.slot_angle_spinner, 13, 1)
  172. # #### SLOTS ARRAY #######
  173. # ########################
  174. self.slot_array_linear_label = QtWidgets.QLabel('<b>%s:</b>' % _('Linear Slot Array'))
  175. grid0.addWidget(self.slot_array_linear_label, 14, 0, 1, 2)
  176. # Number of slot holes in a drill array
  177. self.slot_array_size_label = QtWidgets.QLabel('%s:' % _('Nr of slots'))
  178. self.drill_array_size_label.setToolTip(
  179. _("Specify how many slots to be in the array.")
  180. )
  181. # self.slot_array_size_label.setMinimumWidth(100)
  182. self.slot_array_size_entry = FCSpinner()
  183. self.slot_array_size_entry.set_range(0, 999999)
  184. grid0.addWidget(self.slot_array_size_label, 15, 0)
  185. grid0.addWidget(self.slot_array_size_entry, 15, 1)
  186. # Linear Slot Array direction
  187. self.slot_array_axis_label = QtWidgets.QLabel('%s:' % _('Linear Direction'))
  188. self.slot_array_axis_label.setToolTip(
  189. _("Direction on which the linear array is oriented:\n"
  190. "- 'X' - horizontal axis \n"
  191. "- 'Y' - vertical axis or \n"
  192. "- 'Angle' - a custom angle for the array inclination")
  193. )
  194. # self.slot_axis_label.setMinimumWidth(100)
  195. self.slot_array_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
  196. {'label': _('Y'), 'value': 'Y'},
  197. {'label': _('Angle'), 'value': 'A'}])
  198. grid0.addWidget(self.slot_array_axis_label, 16, 0)
  199. grid0.addWidget(self.slot_array_axis_radio, 16, 1)
  200. # Linear Slot Array pitch distance
  201. self.slot_array_pitch_label = QtWidgets.QLabel('%s:' % _('Pitch'))
  202. self.slot_array_pitch_label.setToolTip(
  203. _("Pitch = Distance between elements of the array.")
  204. )
  205. # self.drill_pitch_label.setMinimumWidth(100)
  206. self.slot_array_pitch_entry = FCDoubleSpinner()
  207. self.slot_array_pitch_entry.set_precision(self.decimals)
  208. self.slot_array_pitch_entry.setWrapping(True)
  209. self.slot_array_pitch_entry.setRange(0, 999999)
  210. self.slot_array_pitch_entry.setSingleStep(1)
  211. grid0.addWidget(self.slot_array_pitch_label, 17, 0)
  212. grid0.addWidget(self.slot_array_pitch_entry, 17, 1)
  213. # Linear Slot Array custom angle
  214. self.slot_array_angle_label = QtWidgets.QLabel('%s:' % _('Angle'))
  215. self.slot_array_angle_label.setToolTip(
  216. _("Angle at which each element in circular array is placed.")
  217. )
  218. self.slot_array_angle_entry = FCDoubleSpinner()
  219. self.slot_array_angle_entry.set_precision(self.decimals)
  220. self.slot_array_angle_entry.setWrapping(True)
  221. self.slot_array_angle_entry.setRange(-360, 360)
  222. self.slot_array_angle_entry.setSingleStep(5)
  223. grid0.addWidget(self.slot_array_angle_label, 18, 0)
  224. grid0.addWidget(self.slot_array_angle_entry, 18, 1)
  225. self.slot_array_circ_label = QtWidgets.QLabel('<b>%s:</b>' % _('Circular Slot Array'))
  226. grid0.addWidget(self.slot_array_circ_label, 19, 0, 1, 2)
  227. # Circular Slot Array direction
  228. self.slot_array_circular_direction_label = QtWidgets.QLabel('%s:' % _('Circular Direction'))
  229. self.slot_array_circular_direction_label.setToolTip(
  230. _("Direction for circular array.\n"
  231. "Can be CW = clockwise or CCW = counter clockwise.")
  232. )
  233. self.slot_array_circular_dir_radio = RadioSet([{'label': _('CW'), 'value': 'CW'},
  234. {'label': _('CCW'), 'value': 'CCW'}])
  235. grid0.addWidget(self.slot_array_circular_direction_label, 20, 0)
  236. grid0.addWidget(self.slot_array_circular_dir_radio, 20, 1)
  237. # Circular Slot Array Angle
  238. self.slot_array_circular_angle_label = QtWidgets.QLabel('%s:' % _('Circular Angle'))
  239. self.slot_array_circular_angle_label.setToolTip(
  240. _("Angle at which each element in circular array is placed.")
  241. )
  242. self.slot_array_circular_angle_entry = FCDoubleSpinner()
  243. self.slot_array_circular_angle_entry.set_precision(self.decimals)
  244. self.slot_array_circular_angle_entry.setWrapping(True)
  245. self.slot_array_circular_angle_entry.setRange(-360, 360)
  246. self.slot_array_circular_angle_entry.setSingleStep(5)
  247. grid0.addWidget(self.slot_array_circular_angle_label, 21, 0)
  248. grid0.addWidget(self.slot_array_circular_angle_entry, 21, 1)
  249. self.layout.addStretch()