ToolDblSided.py 23 KB

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