ToolOptimal.py 24 KB

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