ToolDblSided.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. from FlatCAMTool import FlatCAMTool
  2. from FlatCAMObj import *
  3. from shapely.geometry import Point
  4. from shapely import affinity
  5. from PyQt5 import QtCore
  6. import gettext
  7. import FlatCAMTranslation as fcTranslate
  8. fcTranslate.apply_language('ToolDblSided')
  9. import builtins
  10. if '_' not in builtins.__dict__:
  11. _ = gettext.gettext
  12. class DblSidedTool(FlatCAMTool):
  13. toolName = _("2-Sided PCB")
  14. def __init__(self, app):
  15. FlatCAMTool.__init__(self, app)
  16. ## Title
  17. title_label = QtWidgets.QLabel("%s" % self.toolName)
  18. title_label.setStyleSheet("""
  19. QLabel
  20. {
  21. font-size: 16px;
  22. font-weight: bold;
  23. }
  24. """)
  25. self.layout.addWidget(title_label)
  26. self.empty_lb = QtWidgets.QLabel("")
  27. self.layout.addWidget(self.empty_lb)
  28. ## Grid Layout
  29. grid_lay = QtWidgets.QGridLayout()
  30. self.layout.addLayout(grid_lay)
  31. ## Gerber Object to mirror
  32. self.gerber_object_combo = QtWidgets.QComboBox()
  33. self.gerber_object_combo.setModel(self.app.collection)
  34. self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
  35. self.gerber_object_combo.setCurrentIndex(1)
  36. self.botlay_label = QtWidgets.QLabel("<b>GERBER:</b>")
  37. self.botlay_label.setToolTip(
  38. "Gerber to be mirrored."
  39. )
  40. self.mirror_gerber_button = QtWidgets.QPushButton(_("Mirror"))
  41. self.mirror_gerber_button.setToolTip(
  42. _("Mirrors (flips) the specified object around \n"
  43. "the specified axis. Does not create a new \n"
  44. "object, but modifies it.")
  45. )
  46. self.mirror_gerber_button.setFixedWidth(40)
  47. # grid_lay.addRow("Bottom Layer:", self.object_combo)
  48. grid_lay.addWidget(self.botlay_label, 0, 0)
  49. grid_lay.addWidget(self.gerber_object_combo, 1, 0, 1, 2)
  50. grid_lay.addWidget(self.mirror_gerber_button, 1, 3)
  51. ## Excellon Object to mirror
  52. self.exc_object_combo = QtWidgets.QComboBox()
  53. self.exc_object_combo.setModel(self.app.collection)
  54. self.exc_object_combo.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex()))
  55. self.exc_object_combo.setCurrentIndex(1)
  56. self.excobj_label = QtWidgets.QLabel("<b>EXCELLON:</b>")
  57. self.excobj_label.setToolTip(
  58. _("Excellon Object to be mirrored.")
  59. )
  60. self.mirror_exc_button = QtWidgets.QPushButton(_("Mirror"))
  61. self.mirror_exc_button.setToolTip(
  62. _("Mirrors (flips) the specified object around \n"
  63. "the specified axis. Does not create a new \n"
  64. "object, but modifies it.")
  65. )
  66. self.mirror_exc_button.setFixedWidth(40)
  67. # grid_lay.addRow("Bottom Layer:", self.object_combo)
  68. grid_lay.addWidget(self.excobj_label, 2, 0)
  69. grid_lay.addWidget(self.exc_object_combo, 3, 0, 1, 2)
  70. grid_lay.addWidget(self.mirror_exc_button, 3, 3)
  71. ## Geometry Object to mirror
  72. self.geo_object_combo = QtWidgets.QComboBox()
  73. self.geo_object_combo.setModel(self.app.collection)
  74. self.geo_object_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))
  75. self.geo_object_combo.setCurrentIndex(1)
  76. self.geoobj_label = QtWidgets.QLabel("<b>GEOMETRY</b>:")
  77. self.geoobj_label.setToolTip(
  78. _("Geometry Obj to be mirrored.")
  79. )
  80. self.mirror_geo_button = QtWidgets.QPushButton(_("Mirror"))
  81. self.mirror_geo_button.setToolTip(
  82. _("Mirrors (flips) the specified object around \n"
  83. "the specified axis. Does not create a new \n"
  84. "object, but modifies it.")
  85. )
  86. self.mirror_geo_button.setFixedWidth(40)
  87. # grid_lay.addRow("Bottom Layer:", self.object_combo)
  88. grid_lay.addWidget(self.geoobj_label, 4, 0)
  89. grid_lay.addWidget(self.geo_object_combo, 5, 0, 1, 2)
  90. grid_lay.addWidget(self.mirror_geo_button, 5, 3)
  91. ## Axis
  92. self.mirror_axis = RadioSet([{'label': 'X', 'value': 'X'},
  93. {'label': 'Y', 'value': 'Y'}])
  94. self.mirax_label = QtWidgets.QLabel(_("Mirror Axis:"))
  95. self.mirax_label.setToolTip(
  96. _("Mirror vertically (X) or horizontally (Y).")
  97. )
  98. # grid_lay.addRow("Mirror Axis:", self.mirror_axis)
  99. self.empty_lb1 = QtWidgets.QLabel("")
  100. grid_lay.addWidget(self.empty_lb1, 6, 0)
  101. grid_lay.addWidget(self.mirax_label, 7, 0)
  102. grid_lay.addWidget(self.mirror_axis, 7, 1)
  103. ## Axis Location
  104. self.axis_location = RadioSet([{'label': 'Point', 'value': 'point'},
  105. {'label': 'Box', 'value': 'box'}])
  106. self.axloc_label = QtWidgets.QLabel(_("Axis Ref:"))
  107. self.axloc_label.setToolTip(
  108. _("The axis should pass through a <b>point</b> or cut\n "
  109. "a specified <b>box</b> (in a FlatCAM object) through \n"
  110. "the center.")
  111. )
  112. # grid_lay.addRow("Axis Location:", self.axis_location)
  113. grid_lay.addWidget(self.axloc_label, 8, 0)
  114. grid_lay.addWidget(self.axis_location, 8, 1)
  115. self.empty_lb2 = QtWidgets.QLabel("")
  116. grid_lay.addWidget(self.empty_lb2, 9, 0)
  117. ## Point/Box
  118. self.point_box_container = QtWidgets.QVBoxLayout()
  119. self.pb_label = QtWidgets.QLabel("<b>%s</b>" % _('Point/Box Reference:'))
  120. self.pb_label.setToolTip(
  121. _("If 'Point' is selected above it store the coordinates (x, y) through which\n"
  122. "the mirroring axis passes.\n"
  123. "If 'Box' is selected above, select here a FlatCAM object (Gerber, Exc or Geo).\n"
  124. "Through the center of this object pass the mirroring axis selected above.")
  125. )
  126. self.add_point_button = QtWidgets.QPushButton(_("Add"))
  127. self.add_point_button.setToolTip(
  128. _("Add the coordinates in format <b>(x, y)</b> through which the mirroring axis \n "
  129. "selected in 'MIRROR AXIS' pass.\n"
  130. "The (x, y) coordinates are captured by pressing SHIFT key\n"
  131. "and left mouse button click on canvas or you can enter the coords manually.")
  132. )
  133. self.add_point_button.setFixedWidth(40)
  134. grid_lay.addWidget(self.pb_label, 10, 0)
  135. grid_lay.addLayout(self.point_box_container, 11, 0, 1, 3)
  136. grid_lay.addWidget(self.add_point_button, 11, 3)
  137. self.point_entry = EvalEntry()
  138. self.point_box_container.addWidget(self.point_entry)
  139. self.box_combo = QtWidgets.QComboBox()
  140. self.box_combo.setModel(self.app.collection)
  141. self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
  142. self.box_combo.setCurrentIndex(1)
  143. self.box_combo_type = QtWidgets.QComboBox()
  144. self.box_combo_type.addItem(_("Gerber Reference Box Object"))
  145. self.box_combo_type.addItem(_("Excellon Reference Box Object"))
  146. self.box_combo_type.addItem(_("Geometry Reference Box Object"))
  147. self.point_box_container.addWidget(self.box_combo_type)
  148. self.point_box_container.addWidget(self.box_combo)
  149. self.box_combo.hide()
  150. self.box_combo_type.hide()
  151. ## Alignment holes
  152. self.ah_label = QtWidgets.QLabel("<b%s</b>" % _('>Alignment Drill Coordinates:'))
  153. self.ah_label.setToolTip(
  154. _( "Alignment holes (x1, y1), (x2, y2), ... "
  155. "on one side of the mirror axis. For each set of (x, y) coordinates\n"
  156. "entered here, a pair of drills will be created:\n\n"
  157. "- one drill at the coordinates from the field\n"
  158. "- one drill in mirror position over the axis selected above in the 'Mirror Axis'.")
  159. )
  160. self.layout.addWidget(self.ah_label)
  161. grid_lay1 = QtWidgets.QGridLayout()
  162. self.layout.addLayout(grid_lay1)
  163. self.alignment_holes = EvalEntry()
  164. self.add_drill_point_button = QtWidgets.QPushButton(_("Add"))
  165. self.add_drill_point_button.setToolTip(
  166. _("Add alignment drill holes coords in the format: (x1, y1), (x2, y2), ... \n"
  167. "on one side of the mirror axis.\n\n"
  168. "The coordinates set can be obtained:\n"
  169. "- press SHIFT key and left mouse clicking on canvas. Then click Add.\n"
  170. "- press SHIFT key and left mouse clicking on canvas. Then CTRL+V in the field.\n"
  171. "- press SHIFT key and left mouse clicking on canvas. Then RMB click in the field and click Paste.\n"
  172. "- by entering the coords manually in the format: (x1, y1), (x2, y2), ...")
  173. )
  174. self.add_drill_point_button.setFixedWidth(40)
  175. grid_lay1.addWidget(self.alignment_holes, 0, 0, 1, 2)
  176. grid_lay1.addWidget(self.add_drill_point_button, 0, 3)
  177. ## Drill diameter for alignment holes
  178. self.dt_label = QtWidgets.QLabel("<b>%s</b>:" % _('Alignment Drill Diameter'))
  179. self.dt_label.setToolTip(
  180. _("Diameter of the drill for the "
  181. "alignment holes.")
  182. )
  183. self.layout.addWidget(self.dt_label)
  184. grid_lay2 = QtWidgets.QGridLayout()
  185. self.layout.addLayout(grid_lay2)
  186. self.drill_dia = FCEntry()
  187. self.dd_label = QtWidgets.QLabel(_("Drill diam.:"))
  188. self.dd_label.setToolTip(
  189. _("Diameter of the drill for the "
  190. "alignment holes.")
  191. )
  192. grid_lay2.addWidget(self.dd_label, 0, 0)
  193. grid_lay2.addWidget(self.drill_dia, 0, 1)
  194. ## Buttons
  195. self.create_alignment_hole_button = QtWidgets.QPushButton(_("Create Excellon Object"))
  196. self.create_alignment_hole_button.setToolTip(
  197. _("Creates an Excellon Object containing the\n"
  198. "specified alignment holes and their mirror\n"
  199. "images.")
  200. )
  201. # self.create_alignment_hole_button.setFixedWidth(40)
  202. grid_lay2.addWidget(self.create_alignment_hole_button, 1,0, 1, 2)
  203. self.reset_button = QtWidgets.QPushButton(_("Reset"))
  204. self.reset_button.setToolTip(
  205. _("Resets all the fields.")
  206. )
  207. self.reset_button.setFixedWidth(40)
  208. grid_lay2.addWidget(self.reset_button, 1, 2)
  209. self.layout.addStretch()
  210. ## Signals
  211. self.create_alignment_hole_button.clicked.connect(self.on_create_alignment_holes)
  212. self.mirror_gerber_button.clicked.connect(self.on_mirror_gerber)
  213. self.mirror_exc_button.clicked.connect(self.on_mirror_exc)
  214. self.mirror_geo_button.clicked.connect(self.on_mirror_geo)
  215. self.add_point_button.clicked.connect(self.on_point_add)
  216. self.add_drill_point_button.clicked.connect(self.on_drill_add)
  217. self.reset_button.clicked.connect(self.reset_fields)
  218. self.box_combo_type.currentIndexChanged.connect(self.on_combo_box_type)
  219. self.axis_location.group_toggle_fn = self.on_toggle_pointbox
  220. self.drill_values = ""
  221. def install(self, icon=None, separator=None, **kwargs):
  222. FlatCAMTool.install(self, icon, separator, shortcut='ALT+D', **kwargs)
  223. def run(self, toggle=True):
  224. self.app.report_usage("Tool2Sided()")
  225. if toggle:
  226. # if the splitter is hidden, display it, else hide it but only if the current widget is the same
  227. if self.app.ui.splitter.sizes()[0] == 0:
  228. self.app.ui.splitter.setSizes([1, 1])
  229. else:
  230. try:
  231. if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
  232. self.app.ui.splitter.setSizes([0, 1])
  233. except AttributeError:
  234. pass
  235. FlatCAMTool.run(self)
  236. self.set_tool_ui()
  237. self.app.ui.notebook.setTabText(2, _("2-Sided Tool"))
  238. def set_tool_ui(self):
  239. self.reset_fields()
  240. self.point_entry.set_value("")
  241. self.alignment_holes.set_value("")
  242. self.mirror_axis.set_value(self.app.defaults["tools_2sided_mirror_axis"])
  243. self.axis_location.set_value(self.app.defaults["tools_2sided_axis_loc"])
  244. self.drill_dia.set_value(self.app.defaults["tools_2sided_drilldia"])
  245. def on_combo_box_type(self):
  246. obj_type = self.box_combo_type.currentIndex()
  247. self.box_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
  248. self.box_combo.setCurrentIndex(0)
  249. def on_create_alignment_holes(self):
  250. axis = self.mirror_axis.get_value()
  251. mode = self.axis_location.get_value()
  252. if mode == "point":
  253. try:
  254. px, py = self.point_entry.get_value()
  255. except TypeError:
  256. self.app.inform.emit(_("[WARNING_NOTCL] 'Point' reference is selected and 'Point' coordinates "
  257. "are missing. Add them and retry."))
  258. return
  259. else:
  260. selection_index = self.box_combo.currentIndex()
  261. model_index = self.app.collection.index(selection_index, 0, self.gerber_object_combo.rootModelIndex())
  262. try:
  263. bb_obj = model_index.internalPointer().obj
  264. except AttributeError:
  265. model_index = self.app.collection.index(selection_index, 0, self.exc_object_combo.rootModelIndex())
  266. try:
  267. bb_obj = model_index.internalPointer().obj
  268. except AttributeError:
  269. model_index = self.app.collection.index(selection_index, 0,
  270. self.geo_object_combo.rootModelIndex())
  271. try:
  272. bb_obj = model_index.internalPointer().obj
  273. except AttributeError:
  274. self.app.inform.emit(
  275. _("[WARNING_NOTCL] There is no Box reference object loaded. Load one and retry."))
  276. return
  277. xmin, ymin, xmax, ymax = bb_obj.bounds()
  278. px = 0.5 * (xmin + xmax)
  279. py = 0.5 * (ymin + ymax)
  280. xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis]
  281. try:
  282. dia = float(self.drill_dia.get_value())
  283. except ValueError:
  284. # try to convert comma to decimal point. if it's still not working error message and return
  285. try:
  286. dia = float(self.drill_dia.get_value().replace(',', '.'))
  287. self.drill_dia.set_value(dia)
  288. except ValueError:
  289. self.app.inform.emit(_("[WARNING_NOTCL] Tool diameter value is missing or wrong format. "
  290. "Add it and retry."))
  291. return
  292. if dia is '':
  293. self.app.inform.emit(_("[WARNING_NOTCL]No value or wrong format in Drill Dia entry. Add it and retry."))
  294. return
  295. tools = {"1": {"C": dia}}
  296. # holes = self.alignment_holes.get_value()
  297. holes = eval('[{}]'.format(self.alignment_holes.text()))
  298. if not holes:
  299. self.app.inform.emit(_("[WARNING_NOTCL] There are no Alignment Drill Coordinates to use. Add them and retry."))
  300. return
  301. drills = []
  302. for hole in holes:
  303. point = Point(hole)
  304. point_mirror = affinity.scale(point, xscale, yscale, origin=(px, py))
  305. drills.append({"point": point, "tool": "1"})
  306. drills.append({"point": point_mirror, "tool": "1"})
  307. if 'solid_geometry' not in tools:
  308. tools["1"]['solid_geometry'] = []
  309. else:
  310. tools["1"]['solid_geometry'].append(point_mirror)
  311. def obj_init(obj_inst, app_inst):
  312. obj_inst.tools = tools
  313. obj_inst.drills = drills
  314. obj_inst.create_geometry()
  315. self.app.new_object("excellon", "Alignment Drills", obj_init)
  316. self.drill_values = ''
  317. self.app.inform.emit(_("[success] Excellon object with alignment drills created..."))
  318. def on_mirror_gerber(self):
  319. selection_index = self.gerber_object_combo.currentIndex()
  320. # fcobj = self.app.collection.object_list[selection_index]
  321. model_index = self.app.collection.index(selection_index, 0, self.gerber_object_combo.rootModelIndex())
  322. try:
  323. fcobj = model_index.internalPointer().obj
  324. except Exception as e:
  325. self.app.inform.emit(_("[WARNING_NOTCL] There is no Gerber object loaded ..."))
  326. return
  327. if not isinstance(fcobj, FlatCAMGerber):
  328. self.app.inform.emit(_("[ERROR_NOTCL] Only Gerber, Excellon and Geometry objects can be mirrored."))
  329. return
  330. axis = self.mirror_axis.get_value()
  331. mode = self.axis_location.get_value()
  332. if mode == "point":
  333. try:
  334. px, py = self.point_entry.get_value()
  335. except TypeError:
  336. self.app.inform.emit(_("[WARNING_NOTCL] 'Point' coordinates missing. "
  337. "Using Origin (0, 0) as mirroring reference."))
  338. px, py = (0, 0)
  339. else:
  340. selection_index_box = self.box_combo.currentIndex()
  341. model_index_box = self.app.collection.index(selection_index_box, 0, self.box_combo.rootModelIndex())
  342. try:
  343. bb_obj = model_index_box.internalPointer().obj
  344. except Exception as e:
  345. self.app.inform.emit(_("[WARNING_NOTCL] There is no Box object loaded ..."))
  346. return
  347. xmin, ymin, xmax, ymax = bb_obj.bounds()
  348. px = 0.5 * (xmin + xmax)
  349. py = 0.5 * (ymin + ymax)
  350. fcobj.mirror(axis, [px, py])
  351. self.app.object_changed.emit(fcobj)
  352. fcobj.plot()
  353. self.app.inform.emit(_("[success] Gerber %s was mirrored...") % str(fcobj.options['name']))
  354. def on_mirror_exc(self):
  355. selection_index = self.exc_object_combo.currentIndex()
  356. # fcobj = self.app.collection.object_list[selection_index]
  357. model_index = self.app.collection.index(selection_index, 0, self.exc_object_combo.rootModelIndex())
  358. try:
  359. fcobj = model_index.internalPointer().obj
  360. except Exception as e:
  361. self.app.inform.emit(_("[WARNING_NOTCL] There is no Excellon object loaded ..."))
  362. return
  363. if not isinstance(fcobj, FlatCAMExcellon):
  364. self.app.inform.emit(_("[ERROR_NOTCL] Only Gerber, Excellon and Geometry objects can be mirrored."))
  365. return
  366. axis = self.mirror_axis.get_value()
  367. mode = self.axis_location.get_value()
  368. if mode == "point":
  369. try:
  370. px, py = self.point_entry.get_value()
  371. except Exception as e:
  372. log.debug("DblSidedTool.on_mirror_geo() --> %s" % str(e))
  373. self.app.inform.emit(_("[WARNING_NOTCL] There are no Point coordinates in the Point field. "
  374. "Add coords and try again ..."))
  375. return
  376. else:
  377. selection_index_box = self.box_combo.currentIndex()
  378. model_index_box = self.app.collection.index(selection_index_box, 0, self.box_combo.rootModelIndex())
  379. try:
  380. bb_obj = model_index_box.internalPointer().obj
  381. except Exception as e:
  382. log.debug("DblSidedTool.on_mirror_geo() --> %s" % str(e))
  383. self.app.inform.emit(_("[WARNING_NOTCL] There is no Box object loaded ..."))
  384. return
  385. xmin, ymin, xmax, ymax = bb_obj.bounds()
  386. px = 0.5 * (xmin + xmax)
  387. py = 0.5 * (ymin + ymax)
  388. fcobj.mirror(axis, [px, py])
  389. self.app.object_changed.emit(fcobj)
  390. fcobj.plot()
  391. self.app.inform.emit(_("[success] Excellon %s was mirrored...") % str(fcobj.options['name']))
  392. def on_mirror_geo(self):
  393. selection_index = self.geo_object_combo.currentIndex()
  394. # fcobj = self.app.collection.object_list[selection_index]
  395. model_index = self.app.collection.index(selection_index, 0, self.geo_object_combo.rootModelIndex())
  396. try:
  397. fcobj = model_index.internalPointer().obj
  398. except Exception as e:
  399. self.app.inform.emit(_("[WARNING_NOTCL] There is no Geometry object loaded ..."))
  400. return
  401. if not isinstance(fcobj, FlatCAMGeometry):
  402. self.app.inform.emit(_("[ERROR_NOTCL] Only Gerber, Excellon and Geometry objects can be mirrored."))
  403. return
  404. axis = self.mirror_axis.get_value()
  405. mode = self.axis_location.get_value()
  406. if mode == "point":
  407. px, py = self.point_entry.get_value()
  408. else:
  409. selection_index_box = self.box_combo.currentIndex()
  410. model_index_box = self.app.collection.index(selection_index_box, 0, self.box_combo.rootModelIndex())
  411. try:
  412. bb_obj = model_index_box.internalPointer().obj
  413. except Exception as e:
  414. self.app.inform.emit(_("[WARNING_NOTCL] There is no Box object loaded ..."))
  415. return
  416. xmin, ymin, xmax, ymax = bb_obj.bounds()
  417. px = 0.5 * (xmin + xmax)
  418. py = 0.5 * (ymin + ymax)
  419. fcobj.mirror(axis, [px, py])
  420. self.app.object_changed.emit(fcobj)
  421. fcobj.plot()
  422. self.app.inform.emit(_("[success] Geometry %s was mirrored...") % str(fcobj.options['name']))
  423. def on_point_add(self):
  424. val = self.app.defaults["global_point_clipboard_format"] % (self.app.pos[0], self.app.pos[1])
  425. self.point_entry.set_value(val)
  426. def on_drill_add(self):
  427. self.drill_values += (self.app.defaults["global_point_clipboard_format"] %
  428. (self.app.pos[0], self.app.pos[1])) + ','
  429. self.alignment_holes.set_value(self.drill_values)
  430. def on_toggle_pointbox(self):
  431. if self.axis_location.get_value() == "point":
  432. self.point_entry.show()
  433. self.box_combo.hide()
  434. self.box_combo_type.hide()
  435. self.add_point_button.setDisabled(False)
  436. else:
  437. self.point_entry.hide()
  438. self.box_combo.show()
  439. self.box_combo_type.show()
  440. self.add_point_button.setDisabled(True)
  441. def reset_fields(self):
  442. self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
  443. self.exc_object_combo.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex()))
  444. self.geo_object_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))
  445. self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
  446. self.gerber_object_combo.setCurrentIndex(0)
  447. self.exc_object_combo.setCurrentIndex(0)
  448. self.geo_object_combo.setCurrentIndex(0)
  449. self.box_combo.setCurrentIndex(0)
  450. self.box_combo_type.setCurrentIndex(0)
  451. self.drill_values = ""