ToolPanelize.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. from FlatCAMTool import FlatCAMTool
  2. from copy import copy, deepcopy
  3. from ObjectCollection import *
  4. import time
  5. import gettext
  6. import FlatCAMTranslation as fcTranslate
  7. fcTranslate.apply_language('ToolPanelize')
  8. class Panelize(FlatCAMTool):
  9. toolName = _("Panelize PCB")
  10. def __init__(self, app):
  11. super(Panelize, self).__init__(self)
  12. self.app = app
  13. ## Title
  14. title_label = QtWidgets.QLabel("%s" % self.toolName)
  15. title_label.setStyleSheet("""
  16. QLabel
  17. {
  18. font-size: 16px;
  19. font-weight: bold;
  20. }
  21. """)
  22. self.layout.addWidget(title_label)
  23. ## Form Layout
  24. form_layout = QtWidgets.QFormLayout()
  25. self.layout.addLayout(form_layout)
  26. ## Type of object to be panelized
  27. self.type_obj_combo = QtWidgets.QComboBox()
  28. self.type_obj_combo.addItem("Gerber")
  29. self.type_obj_combo.addItem("Excellon")
  30. self.type_obj_combo.addItem("Geometry")
  31. self.type_obj_combo.setItemIcon(0, QtGui.QIcon("share/flatcam_icon16.png"))
  32. self.type_obj_combo.setItemIcon(1, QtGui.QIcon("share/drill16.png"))
  33. self.type_obj_combo.setItemIcon(2, QtGui.QIcon("share/geometry16.png"))
  34. self.type_obj_combo_label = QtWidgets.QLabel(_("Object Type:"))
  35. self.type_obj_combo_label.setToolTip(
  36. _("Specify the type of object to be panelized\n"
  37. "It can be of type: Gerber, Excellon or Geometry.\n"
  38. "The selection here decide the type of objects that will be\n"
  39. "in the Object combobox.")
  40. )
  41. form_layout.addRow(self.type_obj_combo_label, self.type_obj_combo)
  42. ## Object to be panelized
  43. self.object_combo = QtWidgets.QComboBox()
  44. self.object_combo.setModel(self.app.collection)
  45. self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
  46. self.object_combo.setCurrentIndex(1)
  47. self.object_label = QtWidgets.QLabel(_("Object:"))
  48. self.object_label.setToolTip(
  49. _("Object to be panelized. This means that it will\n"
  50. "be duplicated in an array of rows and columns.")
  51. )
  52. form_layout.addRow(self.object_label, self.object_combo)
  53. ## Type of Box Object to be used as an envelope for panelization
  54. self.type_box_combo = QtWidgets.QComboBox()
  55. self.type_box_combo.addItem("Gerber")
  56. self.type_box_combo.addItem("Excellon")
  57. self.type_box_combo.addItem("Geometry")
  58. # we get rid of item1 ("Excellon") as it is not suitable for use as a "box" for panelizing
  59. self.type_box_combo.view().setRowHidden(1, True)
  60. self.type_box_combo.setItemIcon(0, QtGui.QIcon("share/flatcam_icon16.png"))
  61. self.type_box_combo.setItemIcon(2, QtGui.QIcon("share/geometry16.png"))
  62. self.type_box_combo_label = QtWidgets.QLabel(_("Box Type:"))
  63. self.type_box_combo_label.setToolTip(
  64. _("Specify the type of object to be used as an container for\n"
  65. "panelization. It can be: Gerber or Geometry type.\n"
  66. "The selection here decide the type of objects that will be\n"
  67. "in the Box Object combobox.")
  68. )
  69. form_layout.addRow(self.type_box_combo_label, self.type_box_combo)
  70. ## Box
  71. self.box_combo = QtWidgets.QComboBox()
  72. self.box_combo.setModel(self.app.collection)
  73. self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
  74. self.box_combo.setCurrentIndex(1)
  75. self.box_combo_label = QtWidgets.QLabel(_("Box Object:"))
  76. self.box_combo_label.setToolTip(
  77. _("The actual object that is used a container for the\n "
  78. "selected object that is to be panelized.")
  79. )
  80. form_layout.addRow(self.box_combo_label, self.box_combo)
  81. ## Spacing Columns
  82. self.spacing_columns = FCEntry()
  83. self.spacing_columns_label = QtWidgets.QLabel(_("Spacing cols:"))
  84. self.spacing_columns_label.setToolTip(
  85. _("Spacing between columns of the desired panel.\n"
  86. "In current units.")
  87. )
  88. form_layout.addRow(self.spacing_columns_label, self.spacing_columns)
  89. ## Spacing Rows
  90. self.spacing_rows = FCEntry()
  91. self.spacing_rows_label = QtWidgets.QLabel(_("Spacing rows:"))
  92. self.spacing_rows_label.setToolTip(
  93. _("Spacing between rows of the desired panel.\n"
  94. "In current units.")
  95. )
  96. form_layout.addRow(self.spacing_rows_label, self.spacing_rows)
  97. ## Columns
  98. self.columns = FCEntry()
  99. self.columns_label = QtWidgets.QLabel(_("Columns:"))
  100. self.columns_label.setToolTip(
  101. _("Number of columns of the desired panel")
  102. )
  103. form_layout.addRow(self.columns_label, self.columns)
  104. ## Rows
  105. self.rows = FCEntry()
  106. self.rows_label = QtWidgets.QLabel(_("Rows:"))
  107. self.rows_label.setToolTip(
  108. _("Number of rows of the desired panel")
  109. )
  110. form_layout.addRow(self.rows_label, self.rows)
  111. ## Type of resulting Panel object
  112. self.panel_type_radio = RadioSet([{'label': 'Gerber', 'value': 'gerber'},
  113. {'label': 'Geometry', 'value': 'geometry'}])
  114. self.panel_type_label = QtWidgets.QLabel(_("Panel Type:"))
  115. self.panel_type_label.setToolTip(
  116. _("Choose the type of object for the panel object:\n"
  117. "- Geometry\n"
  118. "- Gerber")
  119. )
  120. form_layout.addRow(self.panel_type_label)
  121. form_layout.addRow(self.panel_type_radio)
  122. ## Constrains
  123. self.constrain_cb = FCCheckBox(_("Constrain panel within:"))
  124. self.constrain_cb.setToolTip(
  125. _("Area define by DX and DY within to constrain the panel.\n"
  126. "DX and DY values are in current units.\n"
  127. "Regardless of how many columns and rows are desired,\n"
  128. "the final panel will have as many columns and rows as\n"
  129. "they fit completely within selected area.")
  130. )
  131. form_layout.addRow(self.constrain_cb)
  132. self.x_width_entry = FCEntry()
  133. self.x_width_lbl = QtWidgets.QLabel(_("Width (DX):"))
  134. self.x_width_lbl.setToolTip(
  135. _("The width (DX) within which the panel must fit.\n"
  136. "In current units.")
  137. )
  138. form_layout.addRow(self.x_width_lbl, self.x_width_entry)
  139. self.y_height_entry = FCEntry()
  140. self.y_height_lbl = QtWidgets.QLabel(_("Height (DY):"))
  141. self.y_height_lbl.setToolTip(
  142. _("The height (DY)within which the panel must fit.\n"
  143. "In current units.")
  144. )
  145. form_layout.addRow(self.y_height_lbl, self.y_height_entry)
  146. self.constrain_sel = OptionalInputSection(
  147. self.constrain_cb, [self.x_width_lbl, self.x_width_entry, self.y_height_lbl, self.y_height_entry])
  148. ## Buttons
  149. hlay_2 = QtWidgets.QHBoxLayout()
  150. self.layout.addLayout(hlay_2)
  151. hlay_2.addStretch()
  152. self.panelize_object_button = QtWidgets.QPushButton(_("Panelize Object"))
  153. self.panelize_object_button.setToolTip(
  154. _("Panelize the specified object around the specified box.\n"
  155. "In other words it creates multiple copies of the source object,\n"
  156. "arranged in a 2D array of rows and columns.")
  157. )
  158. hlay_2.addWidget(self.panelize_object_button)
  159. self.layout.addStretch()
  160. ## Signals
  161. self.panelize_object_button.clicked.connect(self.on_panelize)
  162. self.type_obj_combo.currentIndexChanged.connect(self.on_type_obj_index_changed)
  163. self.type_box_combo.currentIndexChanged.connect(self.on_type_box_index_changed)
  164. # list to hold the temporary objects
  165. self.objs = []
  166. # final name for the panel object
  167. self.outname = ""
  168. # flag to signal the constrain was activated
  169. self.constrain_flag = False
  170. def run(self, toggle=False):
  171. self.app.report_usage("ToolPanelize()")
  172. if toggle:
  173. # if the splitter is hidden, display it, else hide it but only if the current widget is the same
  174. if self.app.ui.splitter.sizes()[0] == 0:
  175. self.app.ui.splitter.setSizes([1, 1])
  176. else:
  177. try:
  178. if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
  179. self.app.ui.splitter.setSizes([0, 1])
  180. except AttributeError:
  181. pass
  182. FlatCAMTool.run(self)
  183. self.set_tool_ui()
  184. self.app.ui.notebook.setTabText(2, "Panel. Tool")
  185. def install(self, icon=None, separator=None, **kwargs):
  186. FlatCAMTool.install(self, icon, separator, shortcut='ALT+Z', **kwargs)
  187. def set_tool_ui(self):
  188. self.reset_fields()
  189. sp_c = self.app.defaults["tools_panelize_spacing_columns"] if \
  190. self.app.defaults["tools_panelize_spacing_columns"] else 0.0
  191. self.spacing_columns.set_value(float(sp_c))
  192. sp_r = self.app.defaults["tools_panelize_spacing_rows"] if \
  193. self.app.defaults["tools_panelize_spacing_rows"] else 0.0
  194. self.spacing_rows.set_value(float(sp_r))
  195. rr = self.app.defaults["tools_panelize_rows"] if \
  196. self.app.defaults["tools_panelize_rows"] else 0.0
  197. self.rows.set_value(int(rr))
  198. cc = self.app.defaults["tools_panelize_columns"] if \
  199. self.app.defaults["tools_panelize_columns"] else 0.0
  200. self.columns.set_value(int(cc))
  201. c_cb = self.app.defaults["tools_panelize_constrain"] if \
  202. self.app.defaults["tools_panelize_constrain"] else False
  203. self.constrain_cb.set_value(c_cb)
  204. x_w = self.app.defaults["tools_panelize_constrainx"] if \
  205. self.app.defaults["tools_panelize_constrainx"] else 0.0
  206. self.x_width_entry.set_value(float(x_w))
  207. y_w = self.app.defaults["tools_panelize_constrainy"] if \
  208. self.app.defaults["tools_panelize_constrainy"] else 0.0
  209. self.y_height_entry.set_value(float(y_w))
  210. panel_type = self.app.defaults["tools_panelize_panel_type"] if \
  211. self.app.defaults["tools_panelize_panel_type"] else 'gerber'
  212. self.panel_type_radio.set_value(panel_type)
  213. def on_type_obj_index_changed(self):
  214. obj_type = self.type_obj_combo.currentIndex()
  215. self.object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
  216. self.object_combo.setCurrentIndex(0)
  217. def on_type_box_index_changed(self):
  218. obj_type = self.type_box_combo.currentIndex()
  219. self.box_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
  220. self.box_combo.setCurrentIndex(0)
  221. def on_panelize(self):
  222. name = self.object_combo.currentText()
  223. # Get source object.
  224. try:
  225. obj = self.app.collection.get_by_name(str(name))
  226. except:
  227. self.app.inform.emit(_("[ERROR_NOTCL]Could not retrieve object: %s") % name)
  228. return "Could not retrieve object: %s" % name
  229. panel_obj = obj
  230. if panel_obj is None:
  231. self.app.inform.emit(_("[ERROR_NOTCL]Object not found: %s") % panel_obj)
  232. return "Object not found: %s" % panel_obj
  233. boxname = self.box_combo.currentText()
  234. try:
  235. box = self.app.collection.get_by_name(boxname)
  236. except:
  237. self.app.inform.emit(_("[ERROR_NOTCL]Could not retrieve object: %s") % boxname)
  238. return "Could not retrieve object: %s" % boxname
  239. if box is None:
  240. self.app.inform.emit(_("[WARNING]No object Box. Using instead %s") % panel_obj)
  241. box = panel_obj
  242. self.outname = name + '_panelized'
  243. try:
  244. spacing_columns = float(self.spacing_columns.get_value())
  245. except ValueError:
  246. # try to convert comma to decimal point. if it's still not working error message and return
  247. try:
  248. spacing_columns = float(self.spacing_columns.get_value().replace(',', '.'))
  249. except ValueError:
  250. self.app.inform.emit(_("[ERROR_NOTCL]Wrong value format entered, "
  251. "use a number."))
  252. return
  253. spacing_columns = spacing_columns if spacing_columns is not None else 0
  254. try:
  255. spacing_rows = float(self.spacing_rows.get_value())
  256. except ValueError:
  257. # try to convert comma to decimal point. if it's still not working error message and return
  258. try:
  259. spacing_rows = float(self.spacing_rows.get_value().replace(',', '.'))
  260. except ValueError:
  261. self.app.inform.emit(_("[ERROR_NOTCL]Wrong value format entered, "
  262. "use a number."))
  263. return
  264. spacing_rows = spacing_rows if spacing_rows is not None else 0
  265. try:
  266. rows = int(self.rows.get_value())
  267. except ValueError:
  268. # try to convert comma to decimal point. if it's still not working error message and return
  269. try:
  270. rows = float(self.rows.get_value().replace(',', '.'))
  271. rows = int(rows)
  272. except ValueError:
  273. self.app.inform.emit(_("[ERROR_NOTCL]Wrong value format entered, "
  274. "use a number."))
  275. return
  276. rows = rows if rows is not None else 1
  277. try:
  278. columns = int(self.columns.get_value())
  279. except ValueError:
  280. # try to convert comma to decimal point. if it's still not working error message and return
  281. try:
  282. columns = float(self.columns.get_value().replace(',', '.'))
  283. columns = int(columns)
  284. except ValueError:
  285. self.app.inform.emit(_("[ERROR_NOTCL]Wrong value format entered, "
  286. "use a number."))
  287. return
  288. columns = columns if columns is not None else 1
  289. try:
  290. constrain_dx = float(self.x_width_entry.get_value())
  291. except ValueError:
  292. # try to convert comma to decimal point. if it's still not working error message and return
  293. try:
  294. constrain_dx = float(self.x_width_entry.get_value().replace(',', '.'))
  295. except ValueError:
  296. self.app.inform.emit(_("[ERROR_NOTCL]Wrong value format entered, "
  297. "use a number."))
  298. return
  299. try:
  300. constrain_dy = float(self.y_height_entry.get_value())
  301. except ValueError:
  302. # try to convert comma to decimal point. if it's still not working error message and return
  303. try:
  304. constrain_dy = float(self.y_height_entry.get_value().replace(',', '.'))
  305. except ValueError:
  306. self.app.inform.emit(_("[ERROR_NOTCL]Wrong value format entered, "
  307. "use a number."))
  308. return
  309. panel_type = str(self.panel_type_radio.get_value())
  310. if 0 in {columns, rows}:
  311. self.app.inform.emit(_("[ERROR_NOTCL]Columns or Rows are zero value. Change them to a positive integer."))
  312. return "Columns or Rows are zero value. Change them to a positive integer."
  313. xmin, ymin, xmax, ymax = box.bounds()
  314. lenghtx = xmax - xmin + spacing_columns
  315. lenghty = ymax - ymin + spacing_rows
  316. # check if constrain within an area is desired
  317. if self.constrain_cb.isChecked():
  318. panel_lengthx = ((xmax - xmin) * columns) + (spacing_columns * (columns - 1))
  319. panel_lengthy = ((ymax - ymin) * rows) + (spacing_rows * (rows - 1))
  320. # adjust the number of columns and/or rows so the panel will fit within the panel constraint area
  321. if (panel_lengthx > constrain_dx) or (panel_lengthy > constrain_dy):
  322. self.constrain_flag = True
  323. while panel_lengthx > constrain_dx:
  324. columns -= 1
  325. panel_lengthx = ((xmax - xmin) * columns) + (spacing_columns * (columns - 1))
  326. while panel_lengthy > constrain_dy:
  327. rows -= 1
  328. panel_lengthy = ((ymax - ymin) * rows) + (spacing_rows * (rows - 1))
  329. # def clean_temp():
  330. # # deselect all to avoid delete selected object when run delete from shell
  331. # self.app.collection.set_all_inactive()
  332. #
  333. # for del_obj in self.objs:
  334. # self.app.collection.set_active(del_obj.options['name'])
  335. # self.app.on_delete()
  336. #
  337. # self.objs[:] = []
  338. # def panelize():
  339. # if panel_obj is not None:
  340. # self.app.inform.emit("Generating panel ... Please wait.")
  341. #
  342. # self.app.progress.emit(10)
  343. #
  344. # if isinstance(panel_obj, FlatCAMExcellon):
  345. # currenty = 0.0
  346. # self.app.progress.emit(0)
  347. #
  348. # def initialize_local_excellon(obj_init, app):
  349. # obj_init.tools = panel_obj.tools
  350. # # drills are offset, so they need to be deep copied
  351. # obj_init.drills = deepcopy(panel_obj.drills)
  352. # obj_init.offset([float(currentx), float(currenty)])
  353. # obj_init.create_geometry()
  354. # self.objs.append(obj_init)
  355. #
  356. # self.app.progress.emit(0)
  357. # for row in range(rows):
  358. # currentx = 0.0
  359. # for col in range(columns):
  360. # local_outname = self.outname + ".tmp." + str(col) + "." + str(row)
  361. # self.app.new_object("excellon", local_outname, initialize_local_excellon, plot=False,
  362. # autoselected=False)
  363. # currentx += lenghtx
  364. # currenty += lenghty
  365. # else:
  366. # currenty = 0
  367. # self.app.progress.emit(0)
  368. #
  369. # def initialize_local_geometry(obj_init, app):
  370. # obj_init.solid_geometry = panel_obj.solid_geometry
  371. # obj_init.offset([float(currentx), float(currenty)])
  372. # self.objs.append(obj_init)
  373. #
  374. # self.app.progress.emit(0)
  375. # for row in range(rows):
  376. # currentx = 0
  377. #
  378. # for col in range(columns):
  379. # local_outname = self.outname + ".tmp." + str(col) + "." + str(row)
  380. # self.app.new_object("geometry", local_outname, initialize_local_geometry, plot=False,
  381. # autoselected=False)
  382. # currentx += lenghtx
  383. # currenty += lenghty
  384. #
  385. # def job_init_geometry(obj_fin, app_obj):
  386. # FlatCAMGeometry.merge(self.objs, obj_fin)
  387. #
  388. # def job_init_excellon(obj_fin, app_obj):
  389. # # merge expects tools to exist in the target object
  390. # obj_fin.tools = panel_obj.tools.copy()
  391. # FlatCAMExcellon.merge(self.objs, obj_fin)
  392. #
  393. # if isinstance(panel_obj, FlatCAMExcellon):
  394. # self.app.progress.emit(50)
  395. # self.app.new_object("excellon", self.outname, job_init_excellon, plot=True, autoselected=True)
  396. # else:
  397. # self.app.progress.emit(50)
  398. # self.app.new_object("geometry", self.outname, job_init_geometry, plot=True, autoselected=True)
  399. #
  400. # else:
  401. # self.app.inform.emit("[ERROR_NOTCL] Obj is None")
  402. # return "ERROR: Obj is None"
  403. # panelize()
  404. # clean_temp()
  405. def panelize_2():
  406. if panel_obj is not None:
  407. self.app.inform.emit(_("Generating panel ... Please wait."))
  408. self.app.progress.emit(0)
  409. def job_init_excellon(obj_fin, app_obj):
  410. currenty = 0.0
  411. self.app.progress.emit(10)
  412. obj_fin.tools = panel_obj.tools.copy()
  413. obj_fin.drills = []
  414. obj_fin.slots = []
  415. obj_fin.solid_geometry = []
  416. for option in panel_obj.options:
  417. if option is not 'name':
  418. try:
  419. obj_fin.options[option] = panel_obj.options[option]
  420. except:
  421. log.warning("Failed to copy option.", option)
  422. for row in range(rows):
  423. currentx = 0.0
  424. for col in range(columns):
  425. if panel_obj.drills:
  426. for tool_dict in panel_obj.drills:
  427. point_offseted = affinity.translate(tool_dict['point'], currentx, currenty)
  428. obj_fin.drills.append(
  429. {
  430. "point": point_offseted,
  431. "tool": tool_dict['tool']
  432. }
  433. )
  434. if panel_obj.slots:
  435. for tool_dict in panel_obj.slots:
  436. start_offseted = affinity.translate(tool_dict['start'], currentx, currenty)
  437. stop_offseted = affinity.translate(tool_dict['stop'], currentx, currenty)
  438. obj_fin.slots.append(
  439. {
  440. "start": start_offseted,
  441. "stop": stop_offseted,
  442. "tool": tool_dict['tool']
  443. }
  444. )
  445. currentx += lenghtx
  446. currenty += lenghty
  447. obj_fin.create_geometry()
  448. obj_fin.zeros = panel_obj.zeros
  449. obj_fin.units = panel_obj.units
  450. def job_init_geometry(obj_fin, app_obj):
  451. currentx = 0.0
  452. currenty = 0.0
  453. def translate_recursion(geom):
  454. if type(geom) == list:
  455. geoms = list()
  456. for local_geom in geom:
  457. geoms.append(translate_recursion(local_geom))
  458. return geoms
  459. else:
  460. return affinity.translate(geom, xoff=currentx, yoff=currenty)
  461. obj_fin.solid_geometry = []
  462. if isinstance(panel_obj, FlatCAMGeometry):
  463. obj_fin.multigeo = panel_obj.multigeo
  464. obj_fin.tools = deepcopy(panel_obj.tools)
  465. if panel_obj.multigeo is True:
  466. for tool in panel_obj.tools:
  467. obj_fin.tools[tool]['solid_geometry'][:] = []
  468. self.app.progress.emit(0)
  469. for row in range(rows):
  470. currentx = 0.0
  471. for col in range(columns):
  472. if isinstance(panel_obj, FlatCAMGeometry):
  473. if panel_obj.multigeo is True:
  474. for tool in panel_obj.tools:
  475. obj_fin.tools[tool]['solid_geometry'].append(translate_recursion(
  476. panel_obj.tools[tool]['solid_geometry'])
  477. )
  478. else:
  479. obj_fin.solid_geometry.append(
  480. translate_recursion(panel_obj.solid_geometry)
  481. )
  482. else:
  483. obj_fin.solid_geometry.append(
  484. translate_recursion(panel_obj.solid_geometry)
  485. )
  486. currentx += lenghtx
  487. currenty += lenghty
  488. if isinstance(panel_obj, FlatCAMExcellon):
  489. self.app.progress.emit(50)
  490. self.app.new_object("excellon", self.outname, job_init_excellon, plot=True, autoselected=True)
  491. else:
  492. self.app.progress.emit(50)
  493. self.app.new_object(panel_type, self.outname, job_init_geometry,
  494. plot=True, autoselected=True)
  495. if self.constrain_flag is False:
  496. self.app.inform.emit(_("[success]Panel done..."))
  497. else:
  498. self.constrain_flag = False
  499. self.app.inform.emit(_("[WARNING] Too big for the constrain area. Final panel has %s columns and %s rows") %
  500. (columns, rows))
  501. proc = self.app.proc_container.new(_("Generating panel ... Please wait."))
  502. def job_thread(app_obj):
  503. try:
  504. panelize_2()
  505. self.app.inform.emit(_("[success]Panel created successfully."))
  506. except Exception as e:
  507. proc.done()
  508. log.debug(str(e))
  509. return
  510. proc.done()
  511. self.app.collection.promise(self.outname)
  512. self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
  513. def reset_fields(self):
  514. self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
  515. self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))