ToolDblSided.py 23 KB

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