ToolOptimal.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. # ##########################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # File Author: Marius Adrian Stanciu (c) #
  4. # Date: 09/27/2019 #
  5. # MIT Licence #
  6. # ##########################################################
  7. from PyQt5 import QtWidgets, QtCore, QtGui
  8. from FlatCAMTool import FlatCAMTool
  9. from flatcamGUI.GUIElements import OptionalHideInputSection, FCTextArea, FCEntry, FCSpinner, FCCheckBox, FCComboBox
  10. from FlatCAMObj import FlatCAMGerber
  11. import FlatCAMApp
  12. from shapely.geometry import MultiPolygon
  13. from shapely.ops import nearest_points
  14. import numpy as np
  15. import logging
  16. import gettext
  17. import FlatCAMTranslation as fcTranslate
  18. import builtins
  19. fcTranslate.apply_language('strings')
  20. if '_' not in builtins.__dict__:
  21. _ = gettext.gettext
  22. log = logging.getLogger('base')
  23. class ToolOptimal(FlatCAMTool):
  24. toolName = _("Optimal Tool")
  25. update_text = QtCore.pyqtSignal(list)
  26. update_sec_distances = QtCore.pyqtSignal(dict)
  27. def __init__(self, app):
  28. FlatCAMTool.__init__(self, app)
  29. self.units = self.app.defaults['units'].upper()
  30. self.decimals = self.app.decimals
  31. # ############################################################################
  32. # ############################ GUI creation ##################################
  33. # ## Title
  34. title_label = QtWidgets.QLabel("%s" % self.toolName)
  35. title_label.setStyleSheet(
  36. """
  37. QLabel
  38. {
  39. font-size: 16px;
  40. font-weight: bold;
  41. }
  42. """)
  43. self.layout.addWidget(title_label)
  44. # ## Form Layout
  45. form_lay = QtWidgets.QFormLayout()
  46. self.layout.addLayout(form_lay)
  47. form_lay.addRow(QtWidgets.QLabel(""))
  48. # ## Gerber Object to mirror
  49. self.gerber_object_combo = FCComboBox()
  50. self.gerber_object_combo.setModel(self.app.collection)
  51. self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
  52. self.gerber_object_combo.is_last = True
  53. self.gerber_object_combo.obj_type = "Gerber"
  54. self.gerber_object_label = QtWidgets.QLabel("<b>%s:</b>" % _("GERBER"))
  55. self.gerber_object_label.setToolTip(
  56. "Gerber object for which to find the minimum distance between copper features."
  57. )
  58. form_lay.addRow(self.gerber_object_label, self.gerber_object_combo)
  59. # Precision = nr of decimals
  60. self.precision_label = QtWidgets.QLabel('%s:' % _("Precision"))
  61. self.precision_label.setToolTip(_("Number of decimals kept for found distances."))
  62. self.precision_spinner = FCSpinner(callback=self.confirmation_message_int)
  63. self.precision_spinner.set_range(2, 10)
  64. self.precision_spinner.setWrapping(True)
  65. form_lay.addRow(self.precision_label, self.precision_spinner)
  66. # Results Title
  67. self.title_res_label = QtWidgets.QLabel('<b>%s:</b>' % _("Minimum distance"))
  68. self.title_res_label.setToolTip(_("Display minimum distance between copper features."))
  69. form_lay.addRow(self.title_res_label)
  70. # Result value
  71. self.result_label = QtWidgets.QLabel('%s:' % _("Determined"))
  72. self.result_entry = FCEntry()
  73. self.result_entry.setReadOnly(True)
  74. self.units_lbl = QtWidgets.QLabel(self.units.lower())
  75. self.units_lbl.setDisabled(True)
  76. hlay = QtWidgets.QHBoxLayout()
  77. hlay.addWidget(self.result_entry)
  78. hlay.addWidget(self.units_lbl)
  79. form_lay.addRow(self.result_label, hlay)
  80. # Frequency of minimum encounter
  81. self.freq_label = QtWidgets.QLabel('%s:' % _("Occurring"))
  82. self.freq_label.setToolTip(_("How many times this minimum is found."))
  83. self.freq_entry = FCEntry()
  84. self.freq_entry.setReadOnly(True)
  85. form_lay.addRow(self.freq_label, self.freq_entry)
  86. # Control if to display the locations of where the minimum was found
  87. self.locations_cb = FCCheckBox(_("Minimum points coordinates"))
  88. self.locations_cb.setToolTip(_("Coordinates for points where minimum distance was found."))
  89. form_lay.addRow(self.locations_cb)
  90. # Locations where minimum was found
  91. self.locations_textb = FCTextArea(parent=self)
  92. self.locations_textb.setPlaceholderText(
  93. _("Coordinates for points where minimum distance was found.")
  94. )
  95. self.locations_textb.setReadOnly(True)
  96. stylesheet = """
  97. QTextEdit { selection-background-color:blue;
  98. selection-color:white;
  99. }
  100. """
  101. self.locations_textb.setStyleSheet(stylesheet)
  102. form_lay.addRow(self.locations_textb)
  103. # Jump button
  104. self.locate_button = QtWidgets.QPushButton(_("Jump to selected position"))
  105. self.locate_button.setToolTip(
  106. _("Select a position in the Locations text box and then\n"
  107. "click this button.")
  108. )
  109. self.locate_button.setMinimumWidth(60)
  110. self.locate_button.setDisabled(True)
  111. form_lay.addRow(self.locate_button)
  112. # Other distances in Gerber
  113. self.title_second_res_label = QtWidgets.QLabel('<b>%s:</b>' % _("Other distances"))
  114. self.title_second_res_label.setToolTip(_("Will display other distances in the Gerber file ordered from\n"
  115. "the minimum to the maximum, not including the absolute minimum."))
  116. form_lay.addRow(self.title_second_res_label)
  117. # Control if to display the locations of where the minimum was found
  118. self.sec_locations_cb = FCCheckBox(_("Other distances points coordinates"))
  119. self.sec_locations_cb.setToolTip(_("Other distances and the coordinates for points\n"
  120. "where the distance was found."))
  121. form_lay.addRow(self.sec_locations_cb)
  122. # this way I can hide/show the frame
  123. self.sec_locations_frame = QtWidgets.QFrame()
  124. self.sec_locations_frame.setContentsMargins(0, 0, 0, 0)
  125. self.layout.addWidget(self.sec_locations_frame)
  126. self.distances_box = QtWidgets.QVBoxLayout()
  127. self.distances_box.setContentsMargins(0, 0, 0, 0)
  128. self.sec_locations_frame.setLayout(self.distances_box)
  129. # Other Distances label
  130. self.distances_label = QtWidgets.QLabel('%s' % _("Gerber distances"))
  131. self.distances_label.setToolTip(_("Other distances and the coordinates for points\n"
  132. "where the distance was found."))
  133. self.distances_box.addWidget(self.distances_label)
  134. # Other distances
  135. self.distances_textb = FCTextArea(parent=self)
  136. self.distances_textb.setPlaceholderText(
  137. _("Other distances and the coordinates for points\n"
  138. "where the distance was found.")
  139. )
  140. self.distances_textb.setReadOnly(True)
  141. stylesheet = """
  142. QTextEdit { selection-background-color:blue;
  143. selection-color:white;
  144. }
  145. """
  146. self.distances_textb.setStyleSheet(stylesheet)
  147. self.distances_box.addWidget(self.distances_textb)
  148. self.distances_box.addWidget(QtWidgets.QLabel(''))
  149. # Other Locations label
  150. self.locations_label = QtWidgets.QLabel('%s' % _("Points coordinates"))
  151. self.locations_label.setToolTip(_("Other distances and the coordinates for points\n"
  152. "where the distance was found."))
  153. self.distances_box.addWidget(self.locations_label)
  154. # Locations where minimum was found
  155. self.locations_sec_textb = FCTextArea(parent=self)
  156. self.locations_sec_textb.setPlaceholderText(
  157. _("Other distances and the coordinates for points\n"
  158. "where the distance was found.")
  159. )
  160. self.locations_sec_textb.setReadOnly(True)
  161. stylesheet = """
  162. QTextEdit { selection-background-color:blue;
  163. selection-color:white;
  164. }
  165. """
  166. self.locations_sec_textb.setStyleSheet(stylesheet)
  167. self.distances_box.addWidget(self.locations_sec_textb)
  168. # Jump button
  169. self.locate_sec_button = QtWidgets.QPushButton(_("Jump to selected position"))
  170. self.locate_sec_button.setToolTip(
  171. _("Select a position in the Locations text box and then\n"
  172. "click this button.")
  173. )
  174. self.locate_sec_button.setMinimumWidth(60)
  175. self.locate_sec_button.setDisabled(True)
  176. self.distances_box.addWidget(self.locate_sec_button)
  177. # GO button
  178. self.calculate_button = QtWidgets.QPushButton(_("Find Minimum"))
  179. self.calculate_button.setToolTip(
  180. _("Calculate the minimum distance between copper features,\n"
  181. "this will allow the determination of the right tool to\n"
  182. "use for isolation or copper clearing.")
  183. )
  184. self.calculate_button.setStyleSheet("""
  185. QPushButton
  186. {
  187. font-weight: bold;
  188. }
  189. """)
  190. self.calculate_button.setMinimumWidth(60)
  191. self.layout.addWidget(self.calculate_button)
  192. self.layout.addStretch()
  193. # ## Reset Tool
  194. self.reset_button = QtWidgets.QPushButton(_("Reset Tool"))
  195. self.reset_button.setToolTip(
  196. _("Will reset the tool parameters.")
  197. )
  198. self.reset_button.setStyleSheet("""
  199. QPushButton
  200. {
  201. font-weight: bold;
  202. }
  203. """)
  204. self.layout.addWidget(self.reset_button)
  205. self.loc_ois = OptionalHideInputSection(self.locations_cb, [self.locations_textb, self.locate_button])
  206. self.sec_loc_ois = OptionalHideInputSection(self.sec_locations_cb, [self.sec_locations_frame])
  207. # ################## Finished GUI creation ###################################
  208. # ############################################################################
  209. # this is the line selected in the textbox with the locations of the minimum
  210. self.selected_text = ''
  211. # this is the line selected in the textbox with the locations of the other distances found in the Gerber object
  212. self.selected_locations_text = ''
  213. # dict to hold the distances between every two elements in Gerber as keys and the actual locations where that
  214. # distances happen as values
  215. self.min_dict = {}
  216. # ############################################################################
  217. # ############################ Signals #######################################
  218. # ############################################################################
  219. self.calculate_button.clicked.connect(self.find_minimum_distance)
  220. self.locate_button.clicked.connect(self.on_locate_position)
  221. self.update_text.connect(self.on_update_text)
  222. self.locations_textb.cursorPositionChanged.connect(self.on_textbox_clicked)
  223. self.locate_sec_button.clicked.connect(self.on_locate_sec_position)
  224. self.update_sec_distances.connect(self.on_update_sec_distances_txt)
  225. self.distances_textb.cursorPositionChanged.connect(self.on_distances_textb_clicked)
  226. self.locations_sec_textb.cursorPositionChanged.connect(self.on_locations_sec_clicked)
  227. self.reset_button.clicked.connect(self.set_tool_ui)
  228. def install(self, icon=None, separator=None, **kwargs):
  229. FlatCAMTool.install(self, icon, separator, shortcut='Alt+O', **kwargs)
  230. def run(self, toggle=True):
  231. self.app.report_usage("ToolOptimal()")
  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. # if tab is populated with the tool but it does not have the focus, focus on it
  240. if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab:
  241. # focus on Tool Tab
  242. self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
  243. else:
  244. self.app.ui.splitter.setSizes([0, 1])
  245. except AttributeError:
  246. pass
  247. else:
  248. if self.app.ui.splitter.sizes()[0] == 0:
  249. self.app.ui.splitter.setSizes([1, 1])
  250. FlatCAMTool.run(self)
  251. self.set_tool_ui()
  252. self.app.ui.notebook.setTabText(2, _("Optimal Tool"))
  253. def set_tool_ui(self):
  254. self.result_entry.set_value(0.0)
  255. self.freq_entry.set_value('0')
  256. self.precision_spinner.set_value(int(self.app.defaults["tools_opt_precision"]))
  257. self.locations_textb.clear()
  258. # new cursor - select all document
  259. cursor = self.locations_textb.textCursor()
  260. cursor.select(QtGui.QTextCursor.Document)
  261. # clear previous selection highlight
  262. tmp = cursor.blockFormat()
  263. tmp.clearBackground()
  264. cursor.setBlockFormat(tmp)
  265. self.locations_textb.setVisible(False)
  266. self.locate_button.setVisible(False)
  267. self.result_entry.set_value(0.0)
  268. self.freq_entry.set_value('0')
  269. self.reset_fields()
  270. def find_minimum_distance(self):
  271. self.units = self.app.defaults['units'].upper()
  272. self.decimals = int(self.precision_spinner.get_value())
  273. selection_index = self.gerber_object_combo.currentIndex()
  274. model_index = self.app.collection.index(selection_index, 0, self.gerber_object_combo.rootModelIndex())
  275. try:
  276. fcobj = model_index.internalPointer().obj
  277. except Exception as e:
  278. log.debug("ToolOptimal.find_minimum_distance() --> %s" % str(e))
  279. self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
  280. return
  281. if not isinstance(fcobj, FlatCAMGerber):
  282. self.app.inform.emit('[ERROR_NOTCL] %s' % _("Only Gerber objects can be evaluated."))
  283. return
  284. proc = self.app.proc_container.new(_("Working..."))
  285. def job_thread(app_obj):
  286. app_obj.inform.emit(_("Optimal Tool. Started to search for the minimum distance between copper features."))
  287. try:
  288. old_disp_number = 0
  289. pol_nr = 0
  290. app_obj.proc_container.update_view_text(' %d%%' % 0)
  291. total_geo = []
  292. for ap in list(fcobj.apertures.keys()):
  293. if 'geometry' in fcobj.apertures[ap]:
  294. app_obj.inform.emit(
  295. '%s: %s' % (_("Optimal Tool. Parsing geometry for aperture"), str(ap)))
  296. for geo_el in fcobj.apertures[ap]['geometry']:
  297. if self.app.abort_flag:
  298. # graceful abort requested by the user
  299. raise FlatCAMApp.GracefulException
  300. if 'solid' in geo_el and geo_el['solid'] is not None and geo_el['solid'].is_valid:
  301. total_geo.append(geo_el['solid'])
  302. app_obj.inform.emit(
  303. _("Optimal Tool. Creating a buffer for the object geometry."))
  304. total_geo = MultiPolygon(total_geo)
  305. total_geo = total_geo.buffer(0)
  306. try:
  307. __ = iter(total_geo)
  308. geo_len = len(total_geo)
  309. geo_len = (geo_len * (geo_len - 1)) / 2
  310. except TypeError:
  311. app_obj.inform.emit('[ERROR_NOTCL] %s' %
  312. _("The Gerber object has one Polygon as geometry.\n"
  313. "There are no distances between geometry elements to be found."))
  314. return 'fail'
  315. app_obj.inform.emit(
  316. '%s: %s' % (_("Optimal Tool. Finding the distances between each two elements. Iterations"),
  317. str(geo_len)))
  318. self.min_dict = {}
  319. idx = 1
  320. for geo in total_geo:
  321. for s_geo in total_geo[idx:]:
  322. if self.app.abort_flag:
  323. # graceful abort requested by the user
  324. raise FlatCAMApp.GracefulException
  325. # minimize the number of distances by not taking into considerations those that are too small
  326. dist = geo.distance(s_geo)
  327. dist = float('%.*f' % (self.decimals, dist))
  328. loc_1, loc_2 = nearest_points(geo, s_geo)
  329. proc_loc = (
  330. (float('%.*f' % (self.decimals, loc_1.x)), float('%.*f' % (self.decimals, loc_1.y))),
  331. (float('%.*f' % (self.decimals, loc_2.x)), float('%.*f' % (self.decimals, loc_2.y)))
  332. )
  333. if dist in self.min_dict:
  334. self.min_dict[dist].append(proc_loc)
  335. else:
  336. self.min_dict[dist] = [proc_loc]
  337. pol_nr += 1
  338. disp_number = int(np.interp(pol_nr, [0, geo_len], [0, 100]))
  339. if old_disp_number < disp_number <= 100:
  340. app_obj.proc_container.update_view_text(' %d%%' % disp_number)
  341. old_disp_number = disp_number
  342. idx += 1
  343. app_obj.inform.emit(
  344. _("Optimal Tool. Finding the minimum distance."))
  345. min_list = list(self.min_dict.keys())
  346. min_dist = min(min_list)
  347. min_dist_string = '%.*f' % (self.decimals, float(min_dist))
  348. self.result_entry.set_value(min_dist_string)
  349. freq = len(self.min_dict[min_dist])
  350. freq = '%d' % int(freq)
  351. self.freq_entry.set_value(freq)
  352. min_locations = self.min_dict.pop(min_dist)
  353. self.update_text.emit(min_locations)
  354. self.update_sec_distances.emit(self.min_dict)
  355. app_obj.inform.emit('[success] %s' % _("Optimal Tool. Finished successfully."))
  356. except Exception as ee:
  357. proc.done()
  358. log.debug(str(ee))
  359. return
  360. proc.done()
  361. self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
  362. def on_locate_position(self):
  363. # cursor = self.locations_textb.textCursor()
  364. # self.selected_text = cursor.selectedText()
  365. try:
  366. if self.selected_text != '':
  367. loc = eval(self.selected_text)
  368. else:
  369. return 'fail'
  370. except Exception as e:
  371. log.debug("ToolOptimal.on_locate_position() --> first try %s" % str(e))
  372. self.app.inform.emit("[ERROR_NOTCL] The selected text is no valid location in the format "
  373. "((x0, y0), (x1, y1)).")
  374. return 'fail'
  375. try:
  376. loc_1 = loc[0]
  377. loc_2 = loc[1]
  378. dx = loc_1[0] - loc_2[0]
  379. dy = loc_1[1] - loc_2[1]
  380. loc = (float('%.*f' % (self.decimals, (min(loc_1[0], loc_2[0]) + (abs(dx) / 2)))),
  381. float('%.*f' % (self.decimals, (min(loc_1[1], loc_2[1]) + (abs(dy) / 2)))))
  382. self.app.on_jump_to(custom_location=loc)
  383. except Exception as e:
  384. log.debug("ToolOptimal.on_locate_position() --> sec try %s" % str(e))
  385. return 'fail'
  386. def on_update_text(self, data):
  387. txt = ''
  388. for loc in data:
  389. if loc:
  390. txt += '%s, %s\n' % (str(loc[0]), str(loc[1]))
  391. self.locations_textb.setPlainText(txt)
  392. self.locate_button.setDisabled(False)
  393. def on_textbox_clicked(self):
  394. # new cursor - select all document
  395. cursor = self.locations_textb.textCursor()
  396. cursor.select(QtGui.QTextCursor.Document)
  397. # clear previous selection highlight
  398. tmp = cursor.blockFormat()
  399. tmp.clearBackground()
  400. cursor.setBlockFormat(tmp)
  401. # new cursor - select the current line
  402. cursor = self.locations_textb.textCursor()
  403. cursor.select(QtGui.QTextCursor.LineUnderCursor)
  404. # highlight the current selected line
  405. tmp = cursor.blockFormat()
  406. tmp.setBackground(QtGui.QBrush(QtCore.Qt.yellow))
  407. cursor.setBlockFormat(tmp)
  408. self.selected_text = cursor.selectedText()
  409. def on_update_sec_distances_txt(self, data):
  410. distance_list = sorted(list(data.keys()))
  411. txt = ''
  412. for loc in distance_list:
  413. txt += '%s\n' % str(loc)
  414. self.distances_textb.setPlainText(txt)
  415. self.locate_sec_button.setDisabled(False)
  416. def on_distances_textb_clicked(self):
  417. # new cursor - select all document
  418. cursor = self.distances_textb.textCursor()
  419. cursor.select(QtGui.QTextCursor.Document)
  420. # clear previous selection highlight
  421. tmp = cursor.blockFormat()
  422. tmp.clearBackground()
  423. cursor.setBlockFormat(tmp)
  424. # new cursor - select the current line
  425. cursor = self.distances_textb.textCursor()
  426. cursor.select(QtGui.QTextCursor.LineUnderCursor)
  427. # highlight the current selected line
  428. tmp = cursor.blockFormat()
  429. tmp.setBackground(QtGui.QBrush(QtCore.Qt.yellow))
  430. cursor.setBlockFormat(tmp)
  431. distance_text = cursor.selectedText()
  432. key_in_min_dict = eval(distance_text)
  433. self.on_update_locations_text(dist=key_in_min_dict)
  434. def on_update_locations_text(self, dist):
  435. distance_list = self.min_dict[dist]
  436. txt = ''
  437. for loc in distance_list:
  438. if loc:
  439. txt += '%s, %s\n' % (str(loc[0]), str(loc[1]))
  440. self.locations_sec_textb.setPlainText(txt)
  441. def on_locations_sec_clicked(self):
  442. # new cursor - select all document
  443. cursor = self.locations_sec_textb.textCursor()
  444. cursor.select(QtGui.QTextCursor.Document)
  445. # clear previous selection highlight
  446. tmp = cursor.blockFormat()
  447. tmp.clearBackground()
  448. cursor.setBlockFormat(tmp)
  449. # new cursor - select the current line
  450. cursor = self.locations_sec_textb.textCursor()
  451. cursor.select(QtGui.QTextCursor.LineUnderCursor)
  452. # highlight the current selected line
  453. tmp = cursor.blockFormat()
  454. tmp.setBackground(QtGui.QBrush(QtCore.Qt.yellow))
  455. cursor.setBlockFormat(tmp)
  456. self.selected_locations_text = cursor.selectedText()
  457. def on_locate_sec_position(self):
  458. try:
  459. if self.selected_locations_text != '':
  460. loc = eval(self.selected_locations_text)
  461. else:
  462. return 'fail'
  463. except Exception as e:
  464. log.debug("ToolOptimal.on_locate_sec_position() --> first try %s" % str(e))
  465. self.app.inform.emit("[ERROR_NOTCL] The selected text is no valid location in the format "
  466. "((x0, y0), (x1, y1)).")
  467. return 'fail'
  468. try:
  469. loc_1 = loc[0]
  470. loc_2 = loc[1]
  471. dx = loc_1[0] - loc_2[0]
  472. dy = loc_1[1] - loc_2[1]
  473. loc = (float('%.*f' % (self.decimals, (min(loc_1[0], loc_2[0]) + (abs(dx) / 2)))),
  474. float('%.*f' % (self.decimals, (min(loc_1[1], loc_2[1]) + (abs(dy) / 2)))))
  475. self.app.on_jump_to(custom_location=loc)
  476. except Exception as e:
  477. log.debug("ToolOptimal.on_locate_sec_position() --> sec try %s" % str(e))
  478. return 'fail'
  479. def reset_fields(self):
  480. self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
  481. self.gerber_object_combo.setCurrentIndex(0)