ToolPanelize.py 26 KB

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