ObjectUI.py 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296
  1. # ##########################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # http://flatcam.org #
  4. # Author: Juan Pablo Caram (c) #
  5. # Date: 2/5/2014 #
  6. # MIT Licence #
  7. # ##########################################################
  8. # ##########################################################
  9. # File Modified (major mod): Marius Adrian Stanciu #
  10. # Date: 3/10/2019 #
  11. # ##########################################################
  12. from appGUI.GUIElements import *
  13. import sys
  14. import gettext
  15. import appTranslation as fcTranslate
  16. import builtins
  17. fcTranslate.apply_language('strings')
  18. if '_' not in builtins.__dict__:
  19. _ = gettext.gettext
  20. settings = QtCore.QSettings("Open Source", "FlatCAM")
  21. if settings.contains("machinist"):
  22. machinist_setting = settings.value('machinist', type=int)
  23. else:
  24. machinist_setting = 0
  25. class ObjectUI(QtWidgets.QWidget):
  26. """
  27. Base class for the UI of FlatCAM objects. Deriving classes should
  28. put UI elements in ObjectUI.custom_box (QtWidgets.QLayout).
  29. """
  30. def __init__(self, app, icon_file='assets/resources/flatcam_icon32.png', title=_('App Object'),
  31. parent=None, common=True):
  32. QtWidgets.QWidget.__init__(self, parent=parent)
  33. self.app = app
  34. self.decimals = app.decimals
  35. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  36. if theme_settings.contains("theme"):
  37. theme = theme_settings.value('theme', type=str)
  38. else:
  39. theme = 'white'
  40. if theme == 'white':
  41. self.resource_loc = 'assets/resources'
  42. else:
  43. self.resource_loc = 'assets/resources'
  44. layout = QtWidgets.QVBoxLayout()
  45. self.setLayout(layout)
  46. # ## Page Title box (spacing between children)
  47. self.title_box = QtWidgets.QHBoxLayout()
  48. layout.addLayout(self.title_box)
  49. # ## Page Title icon
  50. pixmap = QtGui.QPixmap(icon_file.replace('assets/resources', self.resource_loc))
  51. self.icon = QtWidgets.QLabel()
  52. self.icon.setPixmap(pixmap)
  53. self.title_box.addWidget(self.icon, stretch=0)
  54. # ## Title label
  55. self.title_label = QtWidgets.QLabel("<font size=5><b>%s</b></font>" % title)
  56. self.title_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  57. self.title_box.addWidget(self.title_label, stretch=1)
  58. # ## App Level label
  59. self.level = QtWidgets.QLabel("")
  60. self.level.setToolTip(
  61. _(
  62. "BASIC is suitable for a beginner. Many parameters\n"
  63. "are hidden from the user in this mode.\n"
  64. "ADVANCED mode will make available all parameters.\n\n"
  65. "To change the application LEVEL, go to:\n"
  66. "Edit -> Preferences -> General and check:\n"
  67. "'APP. LEVEL' radio button."
  68. )
  69. )
  70. self.level.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  71. self.title_box.addWidget(self.level)
  72. # ## Box box for custom widgets
  73. # This gets populated in offspring implementations.
  74. self.custom_box = QtWidgets.QVBoxLayout()
  75. layout.addLayout(self.custom_box)
  76. # ###########################
  77. # ## Common to all objects ##
  78. # ###########################
  79. if common is True:
  80. self.common_grid = QtWidgets.QGridLayout()
  81. self.common_grid.setColumnStretch(0, 1)
  82. self.common_grid.setColumnStretch(1, 0)
  83. layout.addLayout(self.common_grid)
  84. # self.common_grid.addWidget(QtWidgets.QLabel(''), 1, 0, 1, 2)
  85. separator_line = QtWidgets.QFrame()
  86. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  87. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  88. self.common_grid.addWidget(separator_line, 1, 0, 1, 2)
  89. self.transform_label = QtWidgets.QLabel('<b>%s</b>' % _('Transformations'))
  90. self.transform_label.setToolTip(
  91. _("Geometrical transformations of the current object.")
  92. )
  93. self.common_grid.addWidget(self.transform_label, 2, 0, 1, 2)
  94. # ### Scale ####
  95. self.scale_entry = NumericalEvalEntry(border_color='#0069A9')
  96. self.scale_entry.set_value(1.0)
  97. self.scale_entry.setToolTip(
  98. _("Factor by which to multiply\n"
  99. "geometric features of this object.\n"
  100. "Expressions are allowed. E.g: 1/25.4")
  101. )
  102. # GO Button
  103. self.scale_button = QtWidgets.QPushButton(_('Scale'))
  104. self.scale_button.setToolTip(
  105. _("Perform scaling operation.")
  106. )
  107. self.scale_button.setMinimumWidth(70)
  108. self.common_grid.addWidget(self.scale_entry, 3, 0)
  109. self.common_grid.addWidget(self.scale_button, 3, 1)
  110. # ### Offset ####
  111. self.offsetvector_entry = NumericalEvalTupleEntry(border_color='#0069A9')
  112. self.offsetvector_entry.setText("(0.0, 0.0)")
  113. self.offsetvector_entry.setToolTip(
  114. _("Amount by which to move the object\n"
  115. "in the x and y axes in (x, y) format.\n"
  116. "Expressions are allowed. E.g: (1/3.2, 0.5*3)")
  117. )
  118. self.offset_button = QtWidgets.QPushButton(_('Offset'))
  119. self.offset_button.setToolTip(
  120. _("Perform the offset operation.")
  121. )
  122. self.offset_button.setMinimumWidth(70)
  123. self.common_grid.addWidget(self.offsetvector_entry, 4, 0)
  124. self.common_grid.addWidget(self.offset_button, 4, 1)
  125. self.transformations_button = QtWidgets.QPushButton(_('Transformations'))
  126. self.transformations_button.setIcon(QtGui.QIcon(self.app.resource_location + '/transform.png'))
  127. self.transformations_button.setToolTip(
  128. _("Geometrical transformations of the current object.")
  129. )
  130. self.common_grid.addWidget(self.transformations_button, 5, 0, 1, 2)
  131. layout.addStretch()
  132. def confirmation_message(self, accepted, minval, maxval):
  133. if accepted is False:
  134. self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%.*f, %.*f]' % (_("Edited value is out of range"),
  135. self.decimals,
  136. minval,
  137. self.decimals,
  138. maxval), False)
  139. else:
  140. self.app.inform[str, bool].emit('[success] %s' % _("Edited value is within limits."), False)
  141. def confirmation_message_int(self, accepted, minval, maxval):
  142. if accepted is False:
  143. self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%d, %d]' %
  144. (_("Edited value is out of range"), minval, maxval), False)
  145. else:
  146. self.app.inform[str, bool].emit('[success] %s' % _("Edited value is within limits."), False)
  147. class GerberObjectUI(ObjectUI):
  148. """
  149. User interface for Gerber objects.
  150. """
  151. def __init__(self, app, parent=None):
  152. self.decimals = app.decimals
  153. self.app = app
  154. ObjectUI.__init__(self, title=_('Gerber Object'), parent=parent, app=self.app)
  155. # Plot options
  156. grid0 = QtWidgets.QGridLayout()
  157. grid0.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  158. self.custom_box.addLayout(grid0)
  159. grid0.setColumnStretch(0, 0)
  160. grid0.setColumnStretch(1, 1)
  161. self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  162. self.plot_options_label.setMinimumWidth(90)
  163. grid0.addWidget(self.plot_options_label, 0, 0)
  164. # Solid CB
  165. self.solid_cb = FCCheckBox(label=_('Solid'))
  166. self.solid_cb.setToolTip(
  167. _("Solid color polygons.")
  168. )
  169. self.solid_cb.setMinimumWidth(50)
  170. grid0.addWidget(self.solid_cb, 0, 1)
  171. # Multicolored CB
  172. self.multicolored_cb = FCCheckBox(label=_('Multi-Color'))
  173. self.multicolored_cb.setToolTip(
  174. _("Draw polygons in different colors.")
  175. )
  176. self.multicolored_cb.setMinimumWidth(55)
  177. grid0.addWidget(self.multicolored_cb, 0, 2)
  178. # ## Object name
  179. self.name_hlay = QtWidgets.QHBoxLayout()
  180. grid0.addLayout(self.name_hlay, 1, 0, 1, 3)
  181. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  182. self.name_entry = FCEntry()
  183. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  184. self.name_hlay.addWidget(name_label)
  185. self.name_hlay.addWidget(self.name_entry)
  186. # Plot CB
  187. self.plot_lbl = FCLabel('%s:' % _("Plot"))
  188. self.plot_lbl.setToolTip(_("Plot (show) this object."))
  189. self.plot_cb = FCCheckBox()
  190. grid0.addWidget(self.plot_lbl, 2, 0)
  191. grid0.addWidget(self.plot_cb, 2, 1)
  192. # generate follow
  193. self.follow_cb = FCCheckBox('%s' % _("Follow"))
  194. self.follow_cb.setToolTip(_("Generate a 'Follow' geometry.\n"
  195. "This means that it will cut through\n"
  196. "the middle of the trace."))
  197. self.follow_cb.setMinimumWidth(55)
  198. grid0.addWidget(self.follow_cb, 2, 2)
  199. hlay_plot = QtWidgets.QHBoxLayout()
  200. self.custom_box.addLayout(hlay_plot)
  201. # ### Gerber Apertures ####
  202. self.apertures_table_label = QtWidgets.QLabel('%s:' % _('Apertures'))
  203. self.apertures_table_label.setToolTip(
  204. _("Apertures Table for the Gerber Object.")
  205. )
  206. self.apertures_table_label.setMinimumWidth(90)
  207. hlay_plot.addWidget(self.apertures_table_label)
  208. # Aperture Table Visibility CB
  209. self.aperture_table_visibility_cb = FCCheckBox()
  210. self.aperture_table_visibility_cb.setToolTip(
  211. _("Toggle the display of the Tools Table.")
  212. )
  213. # self.aperture_table_visibility_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  214. hlay_plot.addWidget(self.aperture_table_visibility_cb)
  215. hlay_plot.addStretch()
  216. # Aperture Mark all CB
  217. self.mark_all_cb = FCCheckBox(_('Mark All'))
  218. self.mark_all_cb.setToolTip(
  219. _("When checked it will display all the apertures.\n"
  220. "When unchecked, it will delete all mark shapes\n"
  221. "that are drawn on canvas.")
  222. )
  223. self.mark_all_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  224. hlay_plot.addWidget(self.mark_all_cb)
  225. self.apertures_table = FCTable()
  226. self.custom_box.addWidget(self.apertures_table)
  227. self.apertures_table.setColumnCount(6)
  228. self.apertures_table.setHorizontalHeaderLabels(['#', _('Code'), _('Type'), _('Size'), _('Dim'), 'M'])
  229. self.apertures_table.setSortingEnabled(False)
  230. self.apertures_table.horizontalHeaderItem(0).setToolTip(
  231. _("Index"))
  232. self.apertures_table.horizontalHeaderItem(1).setToolTip(
  233. _("Aperture Code"))
  234. self.apertures_table.horizontalHeaderItem(2).setToolTip(
  235. _("Type of aperture: circular, rectangle, macros etc"))
  236. self.apertures_table.horizontalHeaderItem(4).setToolTip(
  237. _("Aperture Size:"))
  238. self.apertures_table.horizontalHeaderItem(4).setToolTip(
  239. _("Aperture Dimensions:\n"
  240. " - (width, height) for R, O type.\n"
  241. " - (dia, nVertices) for P type"))
  242. self.apertures_table.horizontalHeaderItem(5).setToolTip(
  243. _("Mark the aperture instances on canvas."))
  244. # self.apertures_table.setColumnHidden(5, True)
  245. # start with apertures table hidden
  246. self.apertures_table.setVisible(False)
  247. # Buffer Geometry
  248. self.create_buffer_button = QtWidgets.QPushButton(_('Buffer Solid Geometry'))
  249. self.create_buffer_button.setToolTip(
  250. _("This button is shown only when the Gerber file\n"
  251. "is loaded without buffering.\n"
  252. "Clicking this will create the buffered geometry\n"
  253. "required for isolation.")
  254. )
  255. self.custom_box.addWidget(self.create_buffer_button)
  256. # Editor
  257. self.editor_button = QtWidgets.QPushButton(_('Gerber Editor'))
  258. self.editor_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
  259. self.editor_button.setToolTip(
  260. _("Edit an Gerber object.")
  261. )
  262. self.editor_button.setStyleSheet("""
  263. QPushButton
  264. {
  265. font-weight: bold;
  266. }
  267. """)
  268. self.custom_box.addWidget(self.editor_button)
  269. separator_line = QtWidgets.QFrame()
  270. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  271. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  272. self.custom_box.addWidget(separator_line)
  273. # ###########################################
  274. # ########## NEW GRID #######################
  275. # ###########################################
  276. grid2 = QtWidgets.QGridLayout()
  277. self.custom_box.addLayout(grid2)
  278. grid2.setColumnStretch(0, 0)
  279. grid2.setColumnStretch(1, 1)
  280. self.tool_lbl = QtWidgets.QLabel('<b>%s</b>' % _("TOOLS"))
  281. grid2.addWidget(self.tool_lbl, 0, 0, 1, 2)
  282. # Isolation Tool - will create isolation paths around the copper features
  283. self.iso_button = QtWidgets.QPushButton(_('Isolation Routing'))
  284. # self.iso_button.setIcon(QtGui.QIcon(self.app.resource_location + '/iso_16.png'))
  285. self.iso_button.setToolTip(
  286. _("Create a Geometry object with\n"
  287. "toolpaths to cut around polygons.")
  288. )
  289. self.iso_button.setStyleSheet("""
  290. QPushButton
  291. {
  292. font-weight: bold;
  293. }
  294. """)
  295. grid2.addWidget(self.iso_button, 1, 0, 1, 2)
  296. # ## Clear non-copper regions
  297. self.generate_ncc_button = QtWidgets.QPushButton(_('NCC Tool'))
  298. self.generate_ncc_button.setIcon(QtGui.QIcon(self.app.resource_location + '/eraser26.png'))
  299. self.generate_ncc_button.setToolTip(
  300. _("Create the Geometry Object\n"
  301. "for non-copper routing.")
  302. )
  303. self.generate_ncc_button.setStyleSheet("""
  304. QPushButton
  305. {
  306. font-weight: bold;
  307. }
  308. """)
  309. grid2.addWidget(self.generate_ncc_button, 2, 0, 1, 2)
  310. # ## Board cutout
  311. self.generate_cutout_button = QtWidgets.QPushButton(_('Cutout Tool'))
  312. self.generate_cutout_button.setIcon(QtGui.QIcon(self.app.resource_location + '/cut32_bis.png'))
  313. self.generate_cutout_button.setToolTip(
  314. _("Generate the geometry for\n"
  315. "the board cutout.")
  316. )
  317. self.generate_cutout_button.setStyleSheet("""
  318. QPushButton
  319. {
  320. font-weight: bold;
  321. }
  322. """)
  323. grid2.addWidget(self.generate_cutout_button, 3, 0, 1, 2)
  324. separator_line = QtWidgets.QFrame()
  325. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  326. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  327. grid2.addWidget(separator_line, 4, 0, 1, 2)
  328. # ## Non-copper regions
  329. self.noncopper_label = QtWidgets.QLabel("<b>%s</b>" % _("Non-copper regions"))
  330. self.noncopper_label.setToolTip(
  331. _("Create polygons covering the\n"
  332. "areas without copper on the PCB.\n"
  333. "Equivalent to the inverse of this\n"
  334. "object. Can be used to remove all\n"
  335. "copper from a specified region.")
  336. )
  337. grid2.addWidget(self.noncopper_label, 5, 0, 1, 2)
  338. # Margin
  339. bmlabel = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
  340. bmlabel.setToolTip(
  341. _("Specify the edge of the PCB\n"
  342. "by drawing a box around all\n"
  343. "objects with this minimum\n"
  344. "distance.")
  345. )
  346. bmlabel.setMinimumWidth(90)
  347. self.noncopper_margin_entry = FCDoubleSpinner(callback=self.confirmation_message)
  348. self.noncopper_margin_entry.set_range(-9999.9999, 9999.9999)
  349. self.noncopper_margin_entry.set_precision(self.decimals)
  350. self.noncopper_margin_entry.setSingleStep(0.1)
  351. grid2.addWidget(bmlabel, 6, 0)
  352. grid2.addWidget(self.noncopper_margin_entry, 6, 1)
  353. # Rounded corners
  354. self.noncopper_rounded_cb = FCCheckBox(label=_("Rounded Geo"))
  355. self.noncopper_rounded_cb.setToolTip(
  356. _("Resulting geometry will have rounded corners.")
  357. )
  358. self.noncopper_rounded_cb.setMinimumWidth(90)
  359. self.generate_noncopper_button = QtWidgets.QPushButton(_('Generate Geo'))
  360. grid2.addWidget(self.noncopper_rounded_cb, 7, 0)
  361. grid2.addWidget(self.generate_noncopper_button, 7, 1)
  362. separator_line1 = QtWidgets.QFrame()
  363. separator_line1.setFrameShape(QtWidgets.QFrame.HLine)
  364. separator_line1.setFrameShadow(QtWidgets.QFrame.Sunken)
  365. grid2.addWidget(separator_line1, 8, 0, 1, 2)
  366. # ## Bounding box
  367. self.boundingbox_label = QtWidgets.QLabel('<b>%s</b>' % _('Bounding Box'))
  368. self.boundingbox_label.setToolTip(
  369. _("Create a geometry surrounding the Gerber object.\n"
  370. "Square shape.")
  371. )
  372. grid2.addWidget(self.boundingbox_label, 9, 0, 1, 2)
  373. bbmargin = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
  374. bbmargin.setToolTip(
  375. _("Distance of the edges of the box\n"
  376. "to the nearest polygon.")
  377. )
  378. bbmargin.setMinimumWidth(90)
  379. self.bbmargin_entry = FCDoubleSpinner(callback=self.confirmation_message)
  380. self.bbmargin_entry.set_range(-9999.9999, 9999.9999)
  381. self.bbmargin_entry.set_precision(self.decimals)
  382. self.bbmargin_entry.setSingleStep(0.1)
  383. grid2.addWidget(bbmargin, 10, 0)
  384. grid2.addWidget(self.bbmargin_entry, 10, 1)
  385. self.bbrounded_cb = FCCheckBox(label=_("Rounded Geo"))
  386. self.bbrounded_cb.setToolTip(
  387. _("If the bounding box is \n"
  388. "to have rounded corners\n"
  389. "their radius is equal to\n"
  390. "the margin.")
  391. )
  392. self.bbrounded_cb.setMinimumWidth(90)
  393. self.generate_bb_button = QtWidgets.QPushButton(_('Generate Geo'))
  394. self.generate_bb_button.setToolTip(
  395. _("Generate the Geometry object.")
  396. )
  397. grid2.addWidget(self.bbrounded_cb, 11, 0)
  398. grid2.addWidget(self.generate_bb_button, 11, 1)
  399. class ExcellonObjectUI(ObjectUI):
  400. """
  401. User interface for Excellon objects.
  402. """
  403. def __init__(self, app, parent=None):
  404. self.decimals = app.decimals
  405. self.app = app
  406. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  407. if theme_settings.contains("theme"):
  408. theme = theme_settings.value('theme', type=str)
  409. else:
  410. theme = 'white'
  411. if theme == 'white':
  412. self.resource_loc = 'assets/resources'
  413. else:
  414. self.resource_loc = 'assets/resources'
  415. ObjectUI.__init__(self, title=_('Excellon Object'),
  416. icon_file=self.resource_loc + '/drill32.png',
  417. parent=parent,
  418. app=self.app)
  419. # Plot options
  420. grid_h = QtWidgets.QGridLayout()
  421. grid_h.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  422. self.custom_box.addLayout(grid_h)
  423. grid_h.setColumnStretch(0, 0)
  424. grid_h.setColumnStretch(1, 1)
  425. self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  426. # self.plot_options_label.setMinimumWidth(90)
  427. grid_h.addWidget(self.plot_options_label, 0, 0)
  428. # Solid CB
  429. self.solid_cb = FCCheckBox(label=_('Solid'))
  430. self.solid_cb.setToolTip(
  431. _("Solid circles.")
  432. )
  433. # self.solid_cb.setMinimumWidth(50)
  434. grid_h.addWidget(self.solid_cb, 0, 1)
  435. # Multicolored CB
  436. self.multicolored_cb = FCCheckBox(label=_('Multi-Color'))
  437. self.multicolored_cb.setToolTip(
  438. _("Draw polygons in different colors.")
  439. )
  440. # self.multicolored_cb.setMinimumWidth(55)
  441. grid_h.addWidget(self.multicolored_cb, 0, 2)
  442. # ## Object name
  443. self.name_hlay = QtWidgets.QHBoxLayout()
  444. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  445. self.name_entry = FCEntry()
  446. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  447. self.name_hlay.addWidget(name_label)
  448. self.name_hlay.addWidget(self.name_entry)
  449. grid_h.addLayout(self.name_hlay, 1, 0, 1, 3)
  450. # ### Tools Drills ####
  451. self.tools_table_label = QtWidgets.QLabel('<b>%s</b>' % _('Tools Table'))
  452. self.tools_table_label.setToolTip(
  453. _("Tools in this Excellon object\n"
  454. "when are used for drilling.")
  455. )
  456. # Table Visibility CB
  457. self.table_visibility_cb = FCCheckBox()
  458. self.table_visibility_cb.setToolTip(
  459. _("Toggle the display of the Tools Table.")
  460. )
  461. # Plot CB
  462. hlay_plot = QtWidgets.QHBoxLayout()
  463. self.plot_cb = FCCheckBox(_('Plot'))
  464. self.plot_cb.setToolTip(
  465. _("Plot (show) this object.")
  466. )
  467. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  468. hlay_plot.addStretch()
  469. hlay_plot.addWidget(self.plot_cb)
  470. grid_h.addWidget(self.tools_table_label, 2, 0)
  471. grid_h.addWidget(self.table_visibility_cb, 2, 1)
  472. grid_h.addLayout(hlay_plot, 2, 2)
  473. # add a frame and inside add a vertical box layout. Inside this vbox layout I add all the Drills widgets
  474. # this way I can hide/show the frame
  475. self.drills_frame = QtWidgets.QFrame()
  476. self.drills_frame.setContentsMargins(0, 0, 0, 0)
  477. self.custom_box.addWidget(self.drills_frame)
  478. self.tools_box = QtWidgets.QVBoxLayout()
  479. self.tools_box.setContentsMargins(0, 0, 0, 0)
  480. self.drills_frame.setLayout(self.tools_box)
  481. self.tools_table = FCTable()
  482. self.tools_table.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
  483. self.tools_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
  484. self.tools_box.addWidget(self.tools_table)
  485. self.tools_table.setColumnCount(6)
  486. self.tools_table.setHorizontalHeaderLabels(['#', _('Diameter'), _('Drills'), _('Slots'),
  487. "NOT USED", 'P'])
  488. self.tools_table.setSortingEnabled(False)
  489. self.tools_table.horizontalHeaderItem(0).setToolTip(
  490. _("This is the Tool Number.\n"
  491. "When ToolChange is checked, on toolchange event this value\n"
  492. "will be showed as a T1, T2 ... Tn in the Machine Code.\n\n"
  493. "Here the tools are selected for G-code generation."))
  494. self.tools_table.horizontalHeaderItem(1).setToolTip(
  495. _("Tool Diameter. It's value (in current FlatCAM units) \n"
  496. "is the cut width into the material."))
  497. self.tools_table.horizontalHeaderItem(2).setToolTip(
  498. _("The number of Drill holes. Holes that are drilled with\n"
  499. "a drill bit."))
  500. self.tools_table.horizontalHeaderItem(3).setToolTip(
  501. _("The number of Slot holes. Holes that are created by\n"
  502. "milling them with an endmill bit."))
  503. self.tools_table.horizontalHeaderItem(5).setToolTip(
  504. _("Toggle display of the drills for the current tool.\n"
  505. "This does not select the tools for G-code generation."))
  506. # this column is not used; reserved for future usage
  507. self.tools_table.setColumnHidden(4, True)
  508. # Excellon Tools autoload from DB
  509. # Auto Load Tools from DB
  510. self.autoload_db_cb = FCCheckBox('%s' % _("Auto load from DB"))
  511. self.autoload_db_cb.setToolTip(
  512. _("Automatic replacement of the tools from related application tools\n"
  513. "with tools from DB that have a close diameter value.")
  514. )
  515. self.tools_box.addWidget(self.autoload_db_cb)
  516. # Editor
  517. self.editor_button = QtWidgets.QPushButton(_('Excellon Editor'))
  518. self.editor_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
  519. self.editor_button.setToolTip(
  520. _("Edit an Excellon object.")
  521. )
  522. self.editor_button.setStyleSheet("""
  523. QPushButton
  524. {
  525. font-weight: bold;
  526. }
  527. """)
  528. self.tools_box.addWidget(self.editor_button)
  529. # #################################################################
  530. # ########## TOOLS GRID ###########################################
  531. # #################################################################
  532. grid2 = QtWidgets.QGridLayout()
  533. self.tools_box.addLayout(grid2)
  534. grid2.setColumnStretch(0, 0)
  535. grid2.setColumnStretch(1, 1)
  536. separator_line = QtWidgets.QFrame()
  537. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  538. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  539. grid2.addWidget(separator_line, 0, 0, 1, 2)
  540. self.tool_lbl = QtWidgets.QLabel('<b>%s</b>' % _("TOOLS"))
  541. grid2.addWidget(self.tool_lbl, 2, 0, 1, 2)
  542. # Drilling Tool - will create GCode for drill holes
  543. self.drill_button = QtWidgets.QPushButton(_('Drilling Tool'))
  544. self.drill_button.setIcon(QtGui.QIcon(self.app.resource_location + '/drilling_tool32.png'))
  545. self.drill_button.setToolTip(
  546. _("Generate GCode out of drill holes in an Excellon object.")
  547. )
  548. self.drill_button.setStyleSheet("""
  549. QPushButton
  550. {
  551. font-weight: bold;
  552. }
  553. """)
  554. grid2.addWidget(self.drill_button, 4, 0, 1, 2)
  555. # Milling Tool - will create GCode for slot holes
  556. self.milling_button = QtWidgets.QPushButton(_('Milling Tool'))
  557. self.milling_button.setIcon(QtGui.QIcon(self.app.resource_location + '/milling_tool32.png'))
  558. self.milling_button.setToolTip(
  559. _("Generate GCode out of slot holes in an Excellon object.")
  560. )
  561. self.milling_button.setStyleSheet("""
  562. QPushButton
  563. {
  564. font-weight: bold;
  565. }
  566. """)
  567. grid2.addWidget(self.milling_button, 6, 0, 1, 2)
  568. separator_line = QtWidgets.QFrame()
  569. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  570. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  571. grid2.addWidget(separator_line, 8, 0, 1, 2)
  572. # #################################################################
  573. # ################# GRID LAYOUT 6 ###############################
  574. # #################################################################
  575. self.grid6 = QtWidgets.QGridLayout()
  576. self.grid6.setColumnStretch(0, 0)
  577. self.grid6.setColumnStretch(1, 1)
  578. self.tools_box.addLayout(self.grid6)
  579. # ### Milling Holes Drills ####
  580. self.mill_hole_label = QtWidgets.QLabel('<b>%s</b>' % _('Milling Geometry'))
  581. self.mill_hole_label.setToolTip(
  582. _("Create Geometry for milling holes.\n"
  583. "Select from the Tools Table above the hole dias to be\n"
  584. "milled. Use the # column to make the selection.")
  585. )
  586. self.grid6.addWidget(self.mill_hole_label, 5, 0, 1, 3)
  587. self.tdlabel = QtWidgets.QLabel('%s:' % _('Tool Dia'))
  588. self.tdlabel.setToolTip(
  589. _("Diameter of the cutting tool.")
  590. )
  591. self.grid6.addWidget(self.tdlabel, 6, 0, 1, 3)
  592. self.tooldia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  593. self.tooldia_entry.set_precision(self.decimals)
  594. self.tooldia_entry.set_range(0.0, 9999.9999)
  595. self.tooldia_entry.setSingleStep(0.1)
  596. self.generate_milling_button = QtWidgets.QPushButton(_('Mill Drills'))
  597. self.generate_milling_button.setToolTip(
  598. _("Create the Geometry Object\n"
  599. "for milling DRILLS toolpaths.")
  600. )
  601. self.generate_milling_button.setStyleSheet("""
  602. QPushButton
  603. {
  604. font-weight: bold;
  605. }
  606. """)
  607. self.grid6.addWidget(self.tooldia_entry, 7, 0, 1, 2)
  608. self.grid6.addWidget(self.generate_milling_button, 7, 2)
  609. self.slot_tooldia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  610. self.slot_tooldia_entry.set_precision(self.decimals)
  611. self.slot_tooldia_entry.set_range(0.0, 9999.9999)
  612. self.slot_tooldia_entry.setSingleStep(0.1)
  613. self.generate_milling_slots_button = QtWidgets.QPushButton(_('Mill Slots'))
  614. self.generate_milling_slots_button.setToolTip(
  615. _("Create the Geometry Object\n"
  616. "for milling SLOTS toolpaths.")
  617. )
  618. self.generate_milling_slots_button.setStyleSheet("""
  619. QPushButton
  620. {
  621. font-weight: bold;
  622. }
  623. """)
  624. self.grid6.addWidget(self.slot_tooldia_entry, 8, 0, 1, 2)
  625. self.grid6.addWidget(self.generate_milling_slots_button, 8, 2)
  626. def hide_drills(self, state=True):
  627. if state is True:
  628. self.drills_frame.hide()
  629. else:
  630. self.drills_frame.show()
  631. class GeometryObjectUI(ObjectUI):
  632. """
  633. User interface for Geometry objects.
  634. """
  635. def __init__(self, app, parent=None):
  636. self.decimals = app.decimals
  637. self.app = app
  638. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  639. if theme_settings.contains("theme"):
  640. theme = theme_settings.value('theme', type=str)
  641. else:
  642. theme = 'white'
  643. if theme == 'white':
  644. self.resource_loc = 'assets/resources'
  645. else:
  646. self.resource_loc = 'assets/resources'
  647. super(GeometryObjectUI, self).__init__(
  648. title=_('Geometry Object'),
  649. icon_file=self.resource_loc + '/geometry32.png', parent=parent, app=self.app
  650. )
  651. # Plot options
  652. grid_header = QtWidgets.QGridLayout()
  653. grid_header.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  654. self.custom_box.addLayout(grid_header)
  655. grid_header.setColumnStretch(0, 0)
  656. grid_header.setColumnStretch(1, 1)
  657. self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  658. self.plot_options_label.setMinimumWidth(90)
  659. grid_header.addWidget(self.plot_options_label, 0, 0)
  660. # Multicolored CB
  661. self.multicolored_cb = FCCheckBox(label=_('Multi-Color'))
  662. self.multicolored_cb.setToolTip(
  663. _("Draw polygons in different colors.")
  664. )
  665. self.multicolored_cb.setMinimumWidth(55)
  666. grid_header.addWidget(self.multicolored_cb, 0, 2)
  667. # ## Object name
  668. self.name_hlay = QtWidgets.QHBoxLayout()
  669. grid_header.addLayout(self.name_hlay, 1, 0, 1, 3)
  670. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  671. self.name_entry = FCEntry()
  672. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  673. self.name_hlay.addWidget(name_label)
  674. self.name_hlay.addWidget(self.name_entry)
  675. # add a frame and inside add a vertical box layout. Inside this vbox layout I add all the Tools widgets
  676. # this way I can hide/show the frame
  677. self.geo_tools_frame = QtWidgets.QFrame()
  678. self.geo_tools_frame.setContentsMargins(0, 0, 0, 0)
  679. self.custom_box.addWidget(self.geo_tools_frame)
  680. self.geo_tools_box = QtWidgets.QVBoxLayout()
  681. self.geo_tools_box.setContentsMargins(0, 0, 0, 0)
  682. self.geo_tools_frame.setLayout(self.geo_tools_box)
  683. # ************************************************************************
  684. # ************** TABLE BOX FRAME *****************************************
  685. # ************************************************************************
  686. self.geo_table_frame = QtWidgets.QFrame()
  687. self.geo_table_frame.setContentsMargins(0, 0, 0, 0)
  688. self.geo_tools_box.addWidget(self.geo_table_frame)
  689. self.geo_table_box = QtWidgets.QVBoxLayout()
  690. self.geo_table_box.setContentsMargins(0, 0, 0, 0)
  691. self.geo_table_frame.setLayout(self.geo_table_box)
  692. grid0 = QtWidgets.QGridLayout()
  693. self.geo_table_box.addLayout(grid0)
  694. grid0.setColumnStretch(0, 0)
  695. grid0.setColumnStretch(1, 1)
  696. # ### Tools ####
  697. self.tools_table_label = QtWidgets.QLabel('<b>%s:</b>' % _('Tools Table'))
  698. self.tools_table_label.setToolTip(
  699. _("Tools in this Geometry object used for cutting.\n"
  700. "The 'Offset' entry will set an offset for the cut.\n"
  701. "'Offset' can be inside, outside, on path (none) and custom.\n"
  702. "'Type' entry is only informative and it allow to know the \n"
  703. "intent of using the current tool. \n"
  704. "It can be Rough(ing), Finish(ing) or Iso(lation).\n"
  705. "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n"
  706. "ball(B), or V-Shaped(V). \n"
  707. "When V-shaped is selected the 'Type' entry is automatically \n"
  708. "set to Isolation, the CutZ parameter in the UI form is\n"
  709. "grayed out and Cut Z is automatically calculated from the newly \n"
  710. "showed UI form entries named V-Tip Dia and V-Tip Angle.")
  711. )
  712. grid0.addWidget(self.tools_table_label, 0, 0)
  713. # Plot CB
  714. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  715. self.plot_cb = FCCheckBox(_('Plot Object'))
  716. self.plot_cb.setToolTip(
  717. _("Plot (show) this object.")
  718. )
  719. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  720. grid0.addWidget(self.plot_cb, 0, 1)
  721. self.geo_tools_table = FCTable(drag_drop=True)
  722. grid0.addWidget(self.geo_tools_table, 1, 0, 1, 2)
  723. self.geo_tools_table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
  724. self.geo_tools_table.setColumnCount(7)
  725. self.geo_tools_table.setColumnWidth(0, 20)
  726. self.geo_tools_table.setHorizontalHeaderLabels(['#', _('Dia'), _('Offset'), _('Type'), _('TT'), '', 'P'])
  727. self.geo_tools_table.setColumnHidden(5, True)
  728. # stylesheet = "::section{Background-color:rgb(239,239,245)}"
  729. # self.geo_tools_table.horizontalHeader().setStyleSheet(stylesheet)
  730. self.geo_tools_table.horizontalHeaderItem(0).setToolTip(
  731. _(
  732. "This is the Tool Number.\n"
  733. "When ToolChange is checked, on toolchange event this value\n"
  734. "will be showed as a T1, T2 ... Tn")
  735. )
  736. self.geo_tools_table.horizontalHeaderItem(1).setToolTip(
  737. _(
  738. "Tool Diameter. It's value (in current FlatCAM units) \n"
  739. "is the cut width into the material."
  740. ))
  741. self.geo_tools_table.horizontalHeaderItem(2).setToolTip(
  742. _(
  743. "The value for the Offset can be:\n"
  744. "- Path -> There is no offset, the tool cut will be done through the geometry line.\n"
  745. "- In(side) -> The tool cut will follow the geometry inside. It will create a 'pocket'.\n"
  746. "- Out(side) -> The tool cut will follow the geometry line on the outside."
  747. ))
  748. self.geo_tools_table.horizontalHeaderItem(3).setToolTip(
  749. _(
  750. "The (Operation) Type has only informative value. Usually the UI form values \n"
  751. "are choose based on the operation type and this will serve as a reminder.\n"
  752. "Can be 'Roughing', 'Finishing' or 'Isolation'.\n"
  753. "For Roughing we may choose a lower Feedrate and multiDepth cut.\n"
  754. "For Finishing we may choose a higher Feedrate, without multiDepth.\n"
  755. "For Isolation we need a lower Feedrate as it use a milling bit with a fine tip."
  756. ))
  757. self.geo_tools_table.horizontalHeaderItem(4).setToolTip(
  758. _(
  759. "The Tool Type (TT) can be:\n"
  760. "- Circular with 1 ... 4 teeth -> it is informative only. Being circular the cut width in material\n"
  761. "is exactly the tool diameter.\n"
  762. "- Ball -> informative only and make reference to the Ball type endmill.\n"
  763. "- V-Shape -> it will disable Z-Cut parameter in the UI form and enable two additional UI form\n"
  764. "fields: V-Tip Dia and V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such\n"
  765. "as the cut width into material will be equal with the value in the Tool "
  766. "Diameter column of this table.\n"
  767. "Choosing the V-Shape Tool Type automatically will select the Operation Type as Isolation."
  768. ))
  769. self.geo_tools_table.horizontalHeaderItem(6).setToolTip(
  770. _(
  771. "Plot column. It is visible only for MultiGeo geometries, meaning geometries that holds the geometry\n"
  772. "data into the tools. For those geometries, deleting the tool will delete the geometry data also,\n"
  773. "so be WARNED. From the checkboxes on each row it can be enabled/disabled the plot on canvas\n"
  774. "for the corresponding tool."
  775. ))
  776. # self.geo_tools_table.setSortingEnabled(False)
  777. # self.geo_tools_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
  778. # Editor
  779. self.editor_button = QtWidgets.QPushButton(_('Geometry Editor'))
  780. self.editor_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
  781. self.editor_button.setToolTip(
  782. _("Edit an Geometry object.")
  783. )
  784. self.editor_button.setStyleSheet("""
  785. QPushButton
  786. {
  787. font-weight: bold;
  788. }
  789. """)
  790. grid0.addWidget(self.editor_button, 3, 0, 1, 2)
  791. # Tool Offset
  792. grid1 = QtWidgets.QGridLayout()
  793. self.geo_table_box.addLayout(grid1)
  794. grid1.setColumnStretch(0, 0)
  795. grid1.setColumnStretch(1, 1)
  796. self.tool_offset_lbl = QtWidgets.QLabel('%s:' % _('Tool Offset'))
  797. self.tool_offset_lbl.setToolTip(
  798. _(
  799. "The value to offset the cut when \n"
  800. "the Offset type selected is 'Offset'.\n"
  801. "The value can be positive for 'outside'\n"
  802. "cut and negative for 'inside' cut."
  803. )
  804. )
  805. self.tool_offset_entry = FCDoubleSpinner(callback=self.confirmation_message)
  806. self.tool_offset_entry.set_precision(self.decimals)
  807. self.tool_offset_entry.set_range(-9999.9999, 9999.9999)
  808. self.tool_offset_entry.setSingleStep(0.1)
  809. grid1.addWidget(self.tool_offset_lbl, 0, 0)
  810. grid1.addWidget(self.tool_offset_entry, 0, 1)
  811. separator_line = QtWidgets.QFrame()
  812. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  813. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  814. grid1.addWidget(separator_line, 1, 0, 1, 2)
  815. self.tool_sel_label = QtWidgets.QLabel('<b>%s</b>' % _("New Tool"))
  816. grid1.addWidget(self.tool_sel_label, 2, 0, 1, 2)
  817. self.addtool_entry_lbl = QtWidgets.QLabel('<b>%s:</b>' % _('Tool Dia'))
  818. self.addtool_entry_lbl.setToolTip(
  819. _("Diameter for the new tool")
  820. )
  821. self.addtool_entry = FCDoubleSpinner(callback=self.confirmation_message)
  822. self.addtool_entry.set_precision(self.decimals)
  823. self.addtool_entry.set_range(0.00001, 9999.9999)
  824. self.addtool_entry.setSingleStep(0.1)
  825. grid1.addWidget(self.addtool_entry_lbl, 3, 0)
  826. grid1.addWidget(self.addtool_entry, 3, 1)
  827. bhlay = QtWidgets.QHBoxLayout()
  828. self.addtool_btn = QtWidgets.QPushButton(_('Add'))
  829. self.addtool_btn.setToolTip(
  830. _("Add a new tool to the Tool Table\n"
  831. "with the diameter specified above.")
  832. )
  833. self.addtool_from_db_btn = QtWidgets.QPushButton(_('Add from DB'))
  834. self.addtool_from_db_btn.setToolTip(
  835. _("Add a new tool to the Tool Table\n"
  836. "from the Tool Database.\n"
  837. "Tool database administration in Menu: Options -> Tools Database")
  838. )
  839. bhlay.addWidget(self.addtool_btn)
  840. bhlay.addWidget(self.addtool_from_db_btn)
  841. grid1.addLayout(bhlay, 5, 0, 1, 2)
  842. separator_line = QtWidgets.QFrame()
  843. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  844. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  845. grid1.addWidget(separator_line, 9, 0, 1, 2)
  846. grid2 = QtWidgets.QGridLayout()
  847. self.geo_table_box.addLayout(grid2)
  848. self.copytool_btn = QtWidgets.QPushButton(_('Copy'))
  849. self.copytool_btn.setToolTip(
  850. _("Copy a selection of tools in the Tool Table\n"
  851. "by first selecting a row in the Tool Table.")
  852. )
  853. self.deltool_btn = QtWidgets.QPushButton(_('Delete'))
  854. self.deltool_btn.setToolTip(
  855. _("Delete a selection of tools in the Tool Table\n"
  856. "by first selecting a row in the Tool Table.")
  857. )
  858. grid2.addWidget(self.copytool_btn, 0, 0)
  859. grid2.addWidget(self.deltool_btn, 0, 1)
  860. self.geo_table_box.addWidget(QtWidgets.QLabel(''))
  861. # ###########################################################
  862. # ############# Create CNC Job ##############################
  863. # ###########################################################
  864. self.geo_param_frame = QtWidgets.QFrame()
  865. self.geo_param_frame.setContentsMargins(0, 0, 0, 0)
  866. self.geo_tools_box.addWidget(self.geo_param_frame)
  867. self.geo_param_box = QtWidgets.QVBoxLayout()
  868. self.geo_param_box.setContentsMargins(0, 0, 0, 0)
  869. self.geo_param_frame.setLayout(self.geo_param_box)
  870. separator_line = QtWidgets.QFrame()
  871. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  872. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  873. self.geo_param_box.addWidget(separator_line)
  874. # #################################################################
  875. # ################# GRID LAYOUT 3 ###############################
  876. # #################################################################
  877. self.grid3 = QtWidgets.QGridLayout()
  878. self.grid3.setColumnStretch(0, 0)
  879. self.grid3.setColumnStretch(1, 1)
  880. self.geo_param_box.addLayout(self.grid3)
  881. # ### Tools Data ## ##
  882. self.tool_data_label = QtWidgets.QLabel(
  883. "<b>%s: <font color='#0000FF'>%s %d</font></b>" % (_('Parameters for'), _("Tool"), int(1)))
  884. self.tool_data_label.setToolTip(
  885. _(
  886. "The data used for creating GCode.\n"
  887. "Each tool store it's own set of such data."
  888. )
  889. )
  890. self.grid3.addWidget(self.tool_data_label, 0, 0, 1, 2)
  891. # Tip Dia
  892. self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia'))
  893. self.tipdialabel.setToolTip(
  894. _(
  895. "The tip diameter for V-Shape Tool"
  896. )
  897. )
  898. self.tipdia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  899. self.tipdia_entry.set_precision(self.decimals)
  900. self.tipdia_entry.set_range(0.00001, 9999.9999)
  901. self.tipdia_entry.setSingleStep(0.1)
  902. self.grid3.addWidget(self.tipdialabel, 1, 0)
  903. self.grid3.addWidget(self.tipdia_entry, 1, 1)
  904. # Tip Angle
  905. self.tipanglelabel = QtWidgets.QLabel('%s:' % _('V-Tip Angle'))
  906. self.tipanglelabel.setToolTip(
  907. _(
  908. "The tip angle for V-Shape Tool.\n"
  909. "In degree."
  910. )
  911. )
  912. self.tipangle_entry = FCDoubleSpinner(callback=self.confirmation_message)
  913. self.tipangle_entry.set_precision(self.decimals)
  914. self.tipangle_entry.set_range(1.0, 180.0)
  915. self.tipangle_entry.setSingleStep(1)
  916. self.grid3.addWidget(self.tipanglelabel, 2, 0)
  917. self.grid3.addWidget(self.tipangle_entry, 2, 1)
  918. # Cut Z
  919. self.cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
  920. self.cutzlabel.setToolTip(
  921. _(
  922. "Cutting depth (negative)\n"
  923. "below the copper surface."
  924. )
  925. )
  926. self.cutz_entry = FCDoubleSpinner(callback=self.confirmation_message)
  927. self.cutz_entry.set_precision(self.decimals)
  928. if machinist_setting == 0:
  929. self.cutz_entry.set_range(-9999.9999, 0.0000)
  930. else:
  931. self.cutz_entry.set_range(-9999.9999, 9999.9999)
  932. self.cutz_entry.setSingleStep(0.1)
  933. self.grid3.addWidget(self.cutzlabel, 3, 0)
  934. self.grid3.addWidget(self.cutz_entry, 3, 1)
  935. # Multi-pass
  936. self.mpass_cb = FCCheckBox('%s:' % _("Multi-Depth"))
  937. self.mpass_cb.setToolTip(
  938. _(
  939. "Use multiple passes to limit\n"
  940. "the cut depth in each pass. Will\n"
  941. "cut multiple times until Cut Z is\n"
  942. "reached."
  943. )
  944. )
  945. self.maxdepth_entry = FCDoubleSpinner(callback=self.confirmation_message)
  946. self.maxdepth_entry.set_precision(self.decimals)
  947. self.maxdepth_entry.set_range(0, 9999.9999)
  948. self.maxdepth_entry.setSingleStep(0.1)
  949. self.maxdepth_entry.setToolTip(
  950. _(
  951. "Depth of each pass (positive)."
  952. )
  953. )
  954. self.ois_mpass_geo = OptionalInputSection(self.mpass_cb, [self.maxdepth_entry])
  955. self.grid3.addWidget(self.mpass_cb, 4, 0)
  956. self.grid3.addWidget(self.maxdepth_entry, 4, 1)
  957. # Travel Z
  958. self.travelzlabel = QtWidgets.QLabel('%s:' % _('Travel Z'))
  959. self.travelzlabel.setToolTip(
  960. _("Height of the tool when\n"
  961. "moving without cutting.")
  962. )
  963. self.travelz_entry = FCDoubleSpinner(callback=self.confirmation_message)
  964. self.travelz_entry.set_precision(self.decimals)
  965. if machinist_setting == 0:
  966. self.travelz_entry.set_range(0.00001, 9999.9999)
  967. else:
  968. self.travelz_entry.set_range(-9999.9999, 9999.9999)
  969. self.travelz_entry.setSingleStep(0.1)
  970. self.grid3.addWidget(self.travelzlabel, 5, 0)
  971. self.grid3.addWidget(self.travelz_entry, 5, 1)
  972. # Feedrate X-Y
  973. self.frlabel = QtWidgets.QLabel('%s:' % _('Feedrate X-Y'))
  974. self.frlabel.setToolTip(
  975. _("Cutting speed in the XY\n"
  976. "plane in units per minute")
  977. )
  978. self.cncfeedrate_entry = FCDoubleSpinner(callback=self.confirmation_message)
  979. self.cncfeedrate_entry.set_precision(self.decimals)
  980. self.cncfeedrate_entry.set_range(0, 99999.9999)
  981. self.cncfeedrate_entry.setSingleStep(0.1)
  982. self.grid3.addWidget(self.frlabel, 10, 0)
  983. self.grid3.addWidget(self.cncfeedrate_entry, 10, 1)
  984. # Feedrate Z (Plunge)
  985. self.frzlabel = QtWidgets.QLabel('%s:' % _('Feedrate Z'))
  986. self.frzlabel.setToolTip(
  987. _("Cutting speed in the XY\n"
  988. "plane in units per minute.\n"
  989. "It is called also Plunge.")
  990. )
  991. self.feedrate_z_entry = FCDoubleSpinner(callback=self.confirmation_message)
  992. self.feedrate_z_entry.set_precision(self.decimals)
  993. self.feedrate_z_entry.set_range(0, 99999.9999)
  994. self.feedrate_z_entry.setSingleStep(0.1)
  995. self.grid3.addWidget(self.frzlabel, 11, 0)
  996. self.grid3.addWidget(self.feedrate_z_entry, 11, 1)
  997. # Feedrate rapids
  998. self.fr_rapidlabel = QtWidgets.QLabel('%s:' % _('Feedrate Rapids'))
  999. self.fr_rapidlabel.setToolTip(
  1000. _("Cutting speed in the XY plane\n"
  1001. "(in units per minute).\n"
  1002. "This is for the rapid move G00.\n"
  1003. "It is useful only for Marlin,\n"
  1004. "ignore for any other cases.")
  1005. )
  1006. self.feedrate_rapid_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1007. self.feedrate_rapid_entry.set_precision(self.decimals)
  1008. self.feedrate_rapid_entry.set_range(0, 99999.9999)
  1009. self.feedrate_rapid_entry.setSingleStep(0.1)
  1010. self.grid3.addWidget(self.fr_rapidlabel, 12, 0)
  1011. self.grid3.addWidget(self.feedrate_rapid_entry, 12, 1)
  1012. # default values is to hide
  1013. self.fr_rapidlabel.hide()
  1014. self.feedrate_rapid_entry.hide()
  1015. # Cut over 1st point in path
  1016. self.extracut_cb = FCCheckBox('%s:' % _('Re-cut'))
  1017. self.extracut_cb.setToolTip(
  1018. _("In order to remove possible\n"
  1019. "copper leftovers where first cut\n"
  1020. "meet with last cut, we generate an\n"
  1021. "extended cut over the first cut section.")
  1022. )
  1023. self.e_cut_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1024. self.e_cut_entry.set_range(0, 99999)
  1025. self.e_cut_entry.set_precision(self.decimals)
  1026. self.e_cut_entry.setSingleStep(0.1)
  1027. self.e_cut_entry.setWrapping(True)
  1028. self.e_cut_entry.setToolTip(
  1029. _("In order to remove possible\n"
  1030. "copper leftovers where first cut\n"
  1031. "meet with last cut, we generate an\n"
  1032. "extended cut over the first cut section.")
  1033. )
  1034. self.grid3.addWidget(self.extracut_cb, 13, 0)
  1035. self.grid3.addWidget(self.e_cut_entry, 13, 1)
  1036. # Spindlespeed
  1037. self.spindle_label = QtWidgets.QLabel('%s:' % _('Spindle speed'))
  1038. self.spindle_label.setToolTip(
  1039. _(
  1040. "Speed of the spindle in RPM (optional).\n"
  1041. "If LASER preprocessor is used,\n"
  1042. "this value is the power of laser."
  1043. )
  1044. )
  1045. self.cncspindlespeed_entry = FCSpinner(callback=self.confirmation_message_int)
  1046. self.cncspindlespeed_entry.set_range(0, 1000000)
  1047. self.cncspindlespeed_entry.set_step(100)
  1048. self.grid3.addWidget(self.spindle_label, 14, 0)
  1049. self.grid3.addWidget(self.cncspindlespeed_entry, 14, 1)
  1050. # Dwell
  1051. self.dwell_cb = FCCheckBox('%s:' % _('Dwell'))
  1052. self.dwell_cb.setToolTip(
  1053. _(
  1054. "Pause to allow the spindle to reach its\n"
  1055. "speed before cutting."
  1056. )
  1057. )
  1058. self.dwelltime_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1059. self.dwelltime_entry.set_precision(self.decimals)
  1060. self.dwelltime_entry.set_range(0, 9999.9999)
  1061. self.dwelltime_entry.setSingleStep(0.1)
  1062. self.dwelltime_entry.setToolTip(
  1063. _("Number of time units for spindle to dwell.")
  1064. )
  1065. self.ois_dwell_geo = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  1066. self.grid3.addWidget(self.dwell_cb, 15, 0)
  1067. self.grid3.addWidget(self.dwelltime_entry, 15, 1)
  1068. # Probe depth
  1069. self.pdepth_label = QtWidgets.QLabel('%s:' % _("Probe Z depth"))
  1070. self.pdepth_label.setToolTip(
  1071. _("The maximum depth that the probe is allowed\n"
  1072. "to probe. Negative value, in current units.")
  1073. )
  1074. self.pdepth_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1075. self.pdepth_entry.set_precision(self.decimals)
  1076. self.pdepth_entry.set_range(-9999.9999, 9999.9999)
  1077. self.pdepth_entry.setSingleStep(0.1)
  1078. self.grid3.addWidget(self.pdepth_label, 17, 0)
  1079. self.grid3.addWidget(self.pdepth_entry, 17, 1)
  1080. self.pdepth_label.hide()
  1081. self.pdepth_entry.setVisible(False)
  1082. # Probe feedrate
  1083. self.feedrate_probe_label = QtWidgets.QLabel('%s:' % _("Feedrate Probe"))
  1084. self.feedrate_probe_label.setToolTip(
  1085. _("The feedrate used while the probe is probing.")
  1086. )
  1087. self.feedrate_probe_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1088. self.feedrate_probe_entry.set_precision(self.decimals)
  1089. self.feedrate_probe_entry.set_range(0.0, 9999.9999)
  1090. self.feedrate_probe_entry.setSingleStep(0.1)
  1091. self.grid3.addWidget(self.feedrate_probe_label, 18, 0)
  1092. self.grid3.addWidget(self.feedrate_probe_entry, 18, 1)
  1093. self.feedrate_probe_label.hide()
  1094. self.feedrate_probe_entry.setVisible(False)
  1095. # #################################################################
  1096. # ################# GRID LAYOUT 4 ###############################
  1097. # #################################################################
  1098. grid4 = QtWidgets.QGridLayout()
  1099. grid4.setColumnStretch(0, 0)
  1100. grid4.setColumnStretch(1, 1)
  1101. self.geo_param_box.addLayout(grid4)
  1102. separator_line2 = QtWidgets.QFrame()
  1103. separator_line2.setFrameShape(QtWidgets.QFrame.HLine)
  1104. separator_line2.setFrameShadow(QtWidgets.QFrame.Sunken)
  1105. grid4.addWidget(separator_line2, 0, 0, 1, 2)
  1106. self.apply_param_to_all = FCButton(_("Apply parameters to all tools"))
  1107. self.apply_param_to_all.setToolTip(
  1108. _("The parameters in the current form will be applied\n"
  1109. "on all the tools from the Tool Table.")
  1110. )
  1111. grid4.addWidget(self.apply_param_to_all, 1, 0, 1, 2)
  1112. separator_line2 = QtWidgets.QFrame()
  1113. separator_line2.setFrameShape(QtWidgets.QFrame.HLine)
  1114. separator_line2.setFrameShadow(QtWidgets.QFrame.Sunken)
  1115. grid4.addWidget(separator_line2, 2, 0, 1, 2)
  1116. # General Parameters
  1117. self.gen_param_label = QtWidgets.QLabel('<b>%s</b>' % _("Common Parameters"))
  1118. self.gen_param_label.setToolTip(
  1119. _("Parameters that are common for all tools.")
  1120. )
  1121. grid4.addWidget(self.gen_param_label, 3, 0, 1, 2)
  1122. # Tool change Z
  1123. self.toolchangeg_cb = FCCheckBox('%s:' % _("Tool change Z"))
  1124. self.toolchangeg_cb.setToolTip(
  1125. _(
  1126. "Include tool-change sequence\n"
  1127. "in the Machine Code (Pause for tool change)."
  1128. )
  1129. )
  1130. self.toolchangez_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1131. self.toolchangez_entry.set_precision(self.decimals)
  1132. self.toolchangez_entry.setToolTip(
  1133. _(
  1134. "Z-axis position (height) for\n"
  1135. "tool change."
  1136. )
  1137. )
  1138. if machinist_setting == 0:
  1139. self.toolchangez_entry.set_range(0, 9999.9999)
  1140. else:
  1141. self.toolchangez_entry.set_range(-9999.9999, 9999.9999)
  1142. self.toolchangez_entry.setSingleStep(0.1)
  1143. self.ois_tcz_geo = OptionalInputSection(self.toolchangeg_cb, [self.toolchangez_entry])
  1144. grid4.addWidget(self.toolchangeg_cb, 6, 0)
  1145. grid4.addWidget(self.toolchangez_entry, 6, 1)
  1146. # The Z value for the start move
  1147. # startzlabel = QtWidgets.QLabel('Start move Z:')
  1148. # startzlabel.setToolTip(
  1149. # "Tool height just before starting the work.\n"
  1150. # "Delete the value if you don't need this feature."
  1151. #
  1152. # )
  1153. # grid3.addWidget(startzlabel, 8, 0)
  1154. # self.gstartz_entry = FloatEntry()
  1155. # grid3.addWidget(self.gstartz_entry, 8, 1)
  1156. # The Z value for the end move
  1157. self.endz_label = QtWidgets.QLabel('%s:' % _('End move Z'))
  1158. self.endz_label.setToolTip(
  1159. _("Height of the tool after\n"
  1160. "the last move at the end of the job.")
  1161. )
  1162. self.endz_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1163. self.endz_entry.set_precision(self.decimals)
  1164. if machinist_setting == 0:
  1165. self.endz_entry.set_range(0, 9999.9999)
  1166. else:
  1167. self.endz_entry.set_range(-9999.9999, 9999.9999)
  1168. self.endz_entry.setSingleStep(0.1)
  1169. grid4.addWidget(self.endz_label, 9, 0)
  1170. grid4.addWidget(self.endz_entry, 9, 1)
  1171. # End Move X,Y
  1172. endmove_xy_label = QtWidgets.QLabel('%s:' % _('End move X,Y'))
  1173. endmove_xy_label.setToolTip(
  1174. _("End move X,Y position. In format (x,y).\n"
  1175. "If no value is entered then there is no move\n"
  1176. "on X,Y plane at the end of the job.")
  1177. )
  1178. self.endxy_entry = NumericalEvalTupleEntry(border_color='#0069A9')
  1179. self.endxy_entry.setPlaceholderText(_("X,Y coordinates"))
  1180. grid4.addWidget(endmove_xy_label, 10, 0)
  1181. grid4.addWidget(self.endxy_entry, 10, 1)
  1182. # preprocessor selection
  1183. pp_label = QtWidgets.QLabel('%s:' % _("Preprocessor"))
  1184. pp_label.setToolTip(
  1185. _("The Preprocessor file that dictates\n"
  1186. "the Machine Code (like GCode, RML, HPGL) output.")
  1187. )
  1188. self.pp_geometry_name_cb = FCComboBox()
  1189. self.pp_geometry_name_cb.setFocusPolicy(QtCore.Qt.StrongFocus)
  1190. grid4.addWidget(pp_label, 11, 0)
  1191. grid4.addWidget(self.pp_geometry_name_cb, 11, 1)
  1192. # grid4.addWidget(QtWidgets.QLabel(''), 12, 0, 1, 2)
  1193. # ------------------------------------------------------------------------------------------------------------
  1194. # ------------------------- EXCLUSION AREAS ------------------------------------------------------------------
  1195. # ------------------------------------------------------------------------------------------------------------
  1196. # Exclusion Areas
  1197. self.exclusion_cb = FCCheckBox('%s' % _("Add exclusion areas"))
  1198. self.exclusion_cb.setToolTip(
  1199. _(
  1200. "Include exclusion areas.\n"
  1201. "In those areas the travel of the tools\n"
  1202. "is forbidden."
  1203. )
  1204. )
  1205. grid4.addWidget(self.exclusion_cb, 12, 0, 1, 2)
  1206. self.exclusion_frame = QtWidgets.QFrame()
  1207. self.exclusion_frame.setContentsMargins(0, 0, 0, 0)
  1208. grid4.addWidget(self.exclusion_frame, 14, 0, 1, 2)
  1209. self.exclusion_box = QtWidgets.QVBoxLayout()
  1210. self.exclusion_box.setContentsMargins(0, 0, 0, 0)
  1211. self.exclusion_frame.setLayout(self.exclusion_box)
  1212. self.exclusion_table = FCTable()
  1213. self.exclusion_box.addWidget(self.exclusion_table)
  1214. self.exclusion_table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
  1215. self.exclusion_table.setColumnCount(4)
  1216. self.exclusion_table.setColumnWidth(0, 20)
  1217. self.exclusion_table.setHorizontalHeaderLabels(['#', _('Object'), _('Strategy'), _('Over Z')])
  1218. self.exclusion_table.horizontalHeaderItem(0).setToolTip(_("This is the Area ID."))
  1219. self.exclusion_table.horizontalHeaderItem(1).setToolTip(
  1220. _("Type of the object where the exclusion area was added."))
  1221. self.exclusion_table.horizontalHeaderItem(2).setToolTip(
  1222. _("The strategy used for exclusion area. Go around the exclusion areas or over it."))
  1223. self.exclusion_table.horizontalHeaderItem(3).setToolTip(
  1224. _("If the strategy is to go over the area then this is the height at which the tool will go to avoid the "
  1225. "exclusion area."))
  1226. self.exclusion_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
  1227. grid_a1 = QtWidgets.QGridLayout()
  1228. grid_a1.setColumnStretch(0, 0)
  1229. grid_a1.setColumnStretch(1, 1)
  1230. self.exclusion_box.addLayout(grid_a1)
  1231. # Chose Strategy
  1232. self.strategy_label = FCLabel('%s:' % _("Strategy"))
  1233. self.strategy_label.setToolTip(_("The strategy followed when encountering an exclusion area.\n"
  1234. "Can be:\n"
  1235. "- Over -> when encountering the area, the tool will go to a set height\n"
  1236. "- Around -> will avoid the exclusion area by going around the area"))
  1237. self.strategy_radio = RadioSet([{'label': _('Over'), 'value': 'over'},
  1238. {'label': _('Around'), 'value': 'around'}])
  1239. grid_a1.addWidget(self.strategy_label, 1, 0)
  1240. grid_a1.addWidget(self.strategy_radio, 1, 1)
  1241. # Over Z
  1242. self.over_z_label = FCLabel('%s:' % _("Over Z"))
  1243. self.over_z_label.setToolTip(_("The height Z to which the tool will rise in order to avoid\n"
  1244. "an interdiction area."))
  1245. self.over_z_entry = FCDoubleSpinner()
  1246. self.over_z_entry.set_range(0.000, 9999.9999)
  1247. self.over_z_entry.set_precision(self.decimals)
  1248. grid_a1.addWidget(self.over_z_label, 2, 0)
  1249. grid_a1.addWidget(self.over_z_entry, 2, 1)
  1250. # Button Add Area
  1251. self.add_area_button = QtWidgets.QPushButton(_('Add area:'))
  1252. self.add_area_button.setToolTip(_("Add an Exclusion Area."))
  1253. # Area Selection shape
  1254. self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
  1255. {'label': _("Polygon"), 'value': 'polygon'}])
  1256. self.area_shape_radio.setToolTip(
  1257. _("The kind of selection shape used for area selection.")
  1258. )
  1259. grid_a1.addWidget(self.add_area_button, 4, 0)
  1260. grid_a1.addWidget(self.area_shape_radio, 4, 1)
  1261. h_lay_1 = QtWidgets.QHBoxLayout()
  1262. self.exclusion_box.addLayout(h_lay_1)
  1263. # Button Delete All Areas
  1264. self.delete_area_button = QtWidgets.QPushButton(_('Delete All'))
  1265. self.delete_area_button.setToolTip(_("Delete all exclusion areas."))
  1266. # Button Delete Selected Areas
  1267. self.delete_sel_area_button = QtWidgets.QPushButton(_('Delete Selected'))
  1268. self.delete_sel_area_button.setToolTip(_("Delete all exclusion areas that are selected in the table."))
  1269. h_lay_1.addWidget(self.delete_area_button)
  1270. h_lay_1.addWidget(self.delete_sel_area_button)
  1271. self.ois_exclusion_geo = OptionalHideInputSection(self.exclusion_cb, [self.exclusion_frame])
  1272. # -------------------------- EXCLUSION AREAS END -------------------------------------------------------------
  1273. # ------------------------------------------------------------------------------------------------------------
  1274. # Add Polish
  1275. self.polish_cb = FCCheckBox(label=_('Add Polish'))
  1276. self.polish_cb.setToolTip(_(
  1277. "Will add a Paint section at the end of the GCode.\n"
  1278. "A metallic brush will clean the material after milling."))
  1279. self.polish_cb.setObjectName("g_polish")
  1280. grid4.addWidget(self.polish_cb, 15, 0, 1, 2)
  1281. # Polish Tool Diameter
  1282. self.polish_dia_lbl = QtWidgets.QLabel('%s:' % _('Tool Dia'))
  1283. self.polish_dia_lbl.setToolTip(
  1284. _("Diameter for the polishing tool.")
  1285. )
  1286. self.polish_dia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1287. self.polish_dia_entry.set_precision(self.decimals)
  1288. self.polish_dia_entry.set_range(0.000, 9999.9999)
  1289. self.polish_dia_entry.setObjectName("g_polish_dia")
  1290. grid4.addWidget(self.polish_dia_lbl, 16, 0)
  1291. grid4.addWidget(self.polish_dia_entry, 16, 1)
  1292. # Polish Pressure
  1293. self.polish_pressure_lbl = QtWidgets.QLabel('%s:' % _('Pressure'))
  1294. self.polish_pressure_lbl.setToolTip(
  1295. _("Negative value. The higher the absolute value\n"
  1296. "the stronger the pressure of the brush on the material.")
  1297. )
  1298. self.polish_pressure_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1299. self.polish_pressure_entry.set_precision(self.decimals)
  1300. self.polish_pressure_entry.set_range(-9999.9999, 9999.9999)
  1301. self.polish_pressure_entry.setObjectName("g_polish_pressure")
  1302. grid4.addWidget(self.polish_pressure_lbl, 17, 0)
  1303. grid4.addWidget(self.polish_pressure_entry, 17, 1)
  1304. # Polish Overlap
  1305. self.polish_over_lbl = QtWidgets.QLabel('%s:' % _('Overlap'))
  1306. self.polish_over_lbl.setToolTip(
  1307. _("How much (percentage) of the tool width to overlap each tool pass.")
  1308. )
  1309. self.polish_over_entry = FCDoubleSpinner(suffix='%', callback=self.confirmation_message)
  1310. self.polish_over_entry.set_precision(self.decimals)
  1311. self.polish_over_entry.setWrapping(True)
  1312. self.polish_over_entry.set_range(0.0000, 99.9999)
  1313. self.polish_over_entry.setSingleStep(0.1)
  1314. self.polish_over_entry.setObjectName("g_polish_overlap")
  1315. grid4.addWidget(self.polish_over_lbl, 18, 0)
  1316. grid4.addWidget(self.polish_over_entry, 18, 1)
  1317. # Polish Method
  1318. self.polish_method_lbl = QtWidgets.QLabel('%s:' % _('Method'))
  1319. self.polish_method_lbl.setToolTip(
  1320. _("Algorithm for polishing:\n"
  1321. "- Standard: Fixed step inwards.\n"
  1322. "- Seed-based: Outwards from seed.\n"
  1323. "- Line-based: Parallel lines.")
  1324. )
  1325. self.polish_method_combo = FCComboBox()
  1326. self.polish_method_combo.addItems(
  1327. [_("Standard"), _("Seed"), _("Lines")]
  1328. )
  1329. self.polish_method_combo.setObjectName('g_polish_method')
  1330. grid4.addWidget(self.polish_method_lbl, 20, 0)
  1331. grid4.addWidget(self.polish_method_combo, 20, 1)
  1332. self.polish_dia_lbl.hide()
  1333. self.polish_dia_entry.hide()
  1334. self.polish_pressure_lbl.hide()
  1335. self.polish_pressure_entry.hide()
  1336. self.polish_over_lbl.hide()
  1337. self.polish_over_entry.hide()
  1338. self.polish_method_lbl.hide()
  1339. self.polish_method_combo.hide()
  1340. self.ois_polish = OptionalHideInputSection(
  1341. self.polish_cb,
  1342. [
  1343. self.polish_dia_lbl,
  1344. self.polish_dia_entry,
  1345. self.polish_pressure_lbl,
  1346. self.polish_pressure_entry,
  1347. self.polish_over_lbl,
  1348. self.polish_over_entry,
  1349. self.polish_method_lbl,
  1350. self.polish_method_combo
  1351. ]
  1352. )
  1353. separator_line2 = QtWidgets.QFrame()
  1354. separator_line2.setFrameShape(QtWidgets.QFrame.HLine)
  1355. separator_line2.setFrameShadow(QtWidgets.QFrame.Sunken)
  1356. grid4.addWidget(separator_line2, 22, 0, 1, 2)
  1357. # Button
  1358. self.generate_cnc_button = QtWidgets.QPushButton(_('Generate CNCJob object'))
  1359. self.generate_cnc_button.setToolTip('%s\n%s' % (
  1360. _("Generate CNCJob object."),
  1361. _(
  1362. "Add / Select at least one tool in the tool-table.\n"
  1363. "Click the # header to select all, or Ctrl + LMB\n"
  1364. "for custom selection of tools.")))
  1365. self.generate_cnc_button.setStyleSheet("""
  1366. QPushButton
  1367. {
  1368. font-weight: bold;
  1369. }
  1370. """)
  1371. grid4.addWidget(self.generate_cnc_button, 24, 0, 1, 2)
  1372. grid4.addWidget(QtWidgets.QLabel(''), 26, 0, 1, 2)
  1373. # ##############
  1374. # Paint area ##
  1375. # ##############
  1376. self.tools_label = QtWidgets.QLabel('<b>%s</b>' % _('TOOLS'))
  1377. self.tools_label.setToolTip(
  1378. _("Launch Paint Tool in Tools Tab.")
  1379. )
  1380. grid4.addWidget(self.tools_label, 28, 0, 1, 2)
  1381. # Paint Button
  1382. self.paint_tool_button = QtWidgets.QPushButton(_('Paint Tool'))
  1383. self.paint_tool_button.setToolTip(
  1384. _(
  1385. "Creates tool paths to cover the\n"
  1386. "whole area of a polygon (remove\n"
  1387. "all copper). You will be asked\n"
  1388. "to click on the desired polygon."
  1389. )
  1390. )
  1391. self.paint_tool_button.setStyleSheet("""
  1392. QPushButton
  1393. {
  1394. font-weight: bold;
  1395. }
  1396. """)
  1397. grid4.addWidget(self.paint_tool_button, 30, 0, 1, 2)
  1398. # NCC Tool
  1399. self.generate_ncc_button = QtWidgets.QPushButton(_('NCC Tool'))
  1400. self.generate_ncc_button.setToolTip(
  1401. _("Create the Geometry Object\n"
  1402. "for non-copper routing.")
  1403. )
  1404. self.generate_ncc_button.setStyleSheet("""
  1405. QPushButton
  1406. {
  1407. font-weight: bold;
  1408. }
  1409. """)
  1410. grid4.addWidget(self.generate_ncc_button, 32, 0, 1, 2)
  1411. class CNCObjectUI(ObjectUI):
  1412. """
  1413. User interface for CNCJob objects.
  1414. """
  1415. def __init__(self, app, parent=None):
  1416. """
  1417. Creates the user interface for CNCJob objects. GUI elements should
  1418. be placed in ``self.custom_box`` to preserve the layout.
  1419. """
  1420. self.decimals = app.decimals
  1421. self.app = app
  1422. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  1423. if theme_settings.contains("theme"):
  1424. theme = theme_settings.value('theme', type=str)
  1425. else:
  1426. theme = 'white'
  1427. if theme == 'white':
  1428. self.resource_loc = 'assets/resources'
  1429. else:
  1430. self.resource_loc = 'assets/resources'
  1431. ObjectUI.__init__(
  1432. self, title=_('CNC Job Object'),
  1433. icon_file=self.resource_loc + '/cnc32.png', parent=parent,
  1434. app=self.app)
  1435. for i in range(0, self.common_grid.count()):
  1436. self.common_grid.itemAt(i).widget().hide()
  1437. f_lay = QtWidgets.QGridLayout()
  1438. f_lay.setColumnStretch(0, 0)
  1439. f_lay.setColumnStretch(1, 1)
  1440. self.custom_box.addLayout(f_lay)
  1441. # Plot Options
  1442. self.cncplot_method_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  1443. self.cncplot_method_label.setToolTip(
  1444. _(
  1445. "This selects the kind of geometries on the canvas to plot.\n"
  1446. "Those can be either of type 'Travel' which means the moves\n"
  1447. "above the work piece or it can be of type 'Cut',\n"
  1448. "which means the moves that cut into the material."
  1449. )
  1450. )
  1451. self.cncplot_method_combo = RadioSet([
  1452. {"label": _("All"), "value": "all"},
  1453. {"label": _("Travel"), "value": "travel"},
  1454. {"label": _("Cut"), "value": "cut"}
  1455. ], stretch=False)
  1456. f_lay.addWidget(self.cncplot_method_label, 0, 0)
  1457. f_lay.addWidget(self.cncplot_method_combo, 0, 1, 1, 2)
  1458. self.name_hlay = QtWidgets.QHBoxLayout()
  1459. f_lay.addLayout(self.name_hlay, 1, 0, 1, 3)
  1460. # ## Object name
  1461. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  1462. self.name_entry = FCEntry()
  1463. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  1464. self.name_hlay.addWidget(name_label)
  1465. self.name_hlay.addWidget(self.name_entry)
  1466. # Annotation
  1467. self.annotation_cb = FCCheckBox(_("Display Annotation"))
  1468. self.annotation_cb.setToolTip(
  1469. _("This selects if to display text annotation on the plot.\n"
  1470. "When checked it will display numbers in order for each end\n"
  1471. "of a travel line.")
  1472. )
  1473. f_lay.addWidget(self.annotation_cb, 2, 0, 1, 3)
  1474. separator_line = QtWidgets.QFrame()
  1475. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  1476. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  1477. f_lay.addWidget(separator_line, 3, 0, 1, 3)
  1478. # Travelled Distance
  1479. self.t_distance_label = QtWidgets.QLabel("<b>%s:</b>" % _("Travelled distance"))
  1480. self.t_distance_label.setToolTip(
  1481. _("This is the total travelled distance on X-Y plane.\n"
  1482. "In current units.")
  1483. )
  1484. self.t_distance_entry = FCEntry()
  1485. self.units_label = QtWidgets.QLabel()
  1486. f_lay.addWidget(self.t_distance_label, 5, 0)
  1487. f_lay.addWidget(self.t_distance_entry, 5, 1)
  1488. f_lay.addWidget(self.units_label, 5, 2)
  1489. # Estimated Time
  1490. self.t_time_label = QtWidgets.QLabel("<b>%s:</b>" % _("Estimated time"))
  1491. self.t_time_label.setToolTip(
  1492. _("This is the estimated time to do the routing/drilling,\n"
  1493. "without the time spent in ToolChange events.")
  1494. )
  1495. self.t_time_entry = FCEntry()
  1496. self.units_time_label = QtWidgets.QLabel()
  1497. f_lay.addWidget(self.t_time_label, 7, 0)
  1498. f_lay.addWidget(self.t_time_entry, 7, 1)
  1499. f_lay.addWidget(self.units_time_label, 7, 2)
  1500. self.t_distance_label.hide()
  1501. self.t_distance_entry.setVisible(False)
  1502. self.t_time_label.hide()
  1503. self.t_time_entry.setVisible(False)
  1504. separator_line = QtWidgets.QFrame()
  1505. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  1506. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  1507. f_lay.addWidget(separator_line, 9, 0, 1, 3)
  1508. hlay = QtWidgets.QHBoxLayout()
  1509. self.custom_box.addLayout(hlay)
  1510. # CNC Tools Table for plot
  1511. self.cnc_tools_table_label = QtWidgets.QLabel('<b>%s</b>' % _('CNC Tools Table'))
  1512. self.cnc_tools_table_label.setToolTip(
  1513. _(
  1514. "Tools in this CNCJob object used for cutting.\n"
  1515. "The tool diameter is used for plotting on canvas.\n"
  1516. "The 'Offset' entry will set an offset for the cut.\n"
  1517. "'Offset' can be inside, outside, on path (none) and custom.\n"
  1518. "'Type' entry is only informative and it allow to know the \n"
  1519. "intent of using the current tool. \n"
  1520. "It can be Rough(ing), Finish(ing) or Iso(lation).\n"
  1521. "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n"
  1522. "ball(B), or V-Shaped(V)."
  1523. )
  1524. )
  1525. hlay.addWidget(self.cnc_tools_table_label)
  1526. # Plot CB
  1527. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  1528. self.plot_cb = FCCheckBox(_('Plot Object'))
  1529. self.plot_cb.setToolTip(
  1530. _("Plot (show) this object.")
  1531. )
  1532. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  1533. hlay.addStretch()
  1534. hlay.addWidget(self.plot_cb)
  1535. self.cnc_tools_table = FCTable()
  1536. self.custom_box.addWidget(self.cnc_tools_table)
  1537. self.cnc_tools_table.setColumnCount(7)
  1538. self.cnc_tools_table.setColumnWidth(0, 20)
  1539. self.cnc_tools_table.setHorizontalHeaderLabels(['#', _('Dia'), _('Offset'), _('Type'), _('TT'), '', _('P')])
  1540. self.cnc_tools_table.setColumnHidden(5, True)
  1541. # stylesheet = "::section{Background-color:rgb(239,239,245)}"
  1542. # self.cnc_tools_table.horizontalHeader().setStyleSheet(stylesheet)
  1543. self.exc_cnc_tools_table = FCTable()
  1544. self.custom_box.addWidget(self.exc_cnc_tools_table)
  1545. self.exc_cnc_tools_table.setColumnCount(7)
  1546. self.exc_cnc_tools_table.setColumnWidth(0, 20)
  1547. self.exc_cnc_tools_table.setHorizontalHeaderLabels(['#', _('Dia'), _('Drills'), _('Slots'), '', _("Cut Z"),
  1548. _('P')])
  1549. self.exc_cnc_tools_table.setColumnHidden(4, True)
  1550. self.tooldia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1551. self.tooldia_entry.set_range(0, 9999.9999)
  1552. self.tooldia_entry.set_precision(self.decimals)
  1553. self.tooldia_entry.setSingleStep(0.1)
  1554. self.custom_box.addWidget(self.tooldia_entry)
  1555. # Update plot button
  1556. self.updateplot_button = QtWidgets.QPushButton(_('Update Plot'))
  1557. self.updateplot_button.setToolTip(
  1558. _("Update the plot.")
  1559. )
  1560. self.custom_box.addWidget(self.updateplot_button)
  1561. # Editor
  1562. self.editor_button = QtWidgets.QPushButton(_('GCode Editor'))
  1563. self.editor_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
  1564. self.editor_button.setToolTip(
  1565. _("Edit an GCode object.")
  1566. )
  1567. self.editor_button.setStyleSheet("""
  1568. QPushButton
  1569. {
  1570. font-weight: bold;
  1571. }
  1572. """)
  1573. self.custom_box.addWidget(self.editor_button)
  1574. separator_line = QtWidgets.QFrame()
  1575. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  1576. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  1577. self.custom_box.addWidget(separator_line)
  1578. # ####################
  1579. # ## Export G-Code ##
  1580. # ####################
  1581. self.export_gcode_label = QtWidgets.QLabel("<b>%s:</b>" % _("Export CNC Code"))
  1582. self.export_gcode_label.setToolTip(
  1583. _("Export and save G-Code to\n"
  1584. "make this object to a file.")
  1585. )
  1586. self.custom_box.addWidget(self.export_gcode_label)
  1587. # Prepend text to GCode
  1588. prependlabel = QtWidgets.QLabel('%s:' % _('Prepend to CNC Code'))
  1589. prependlabel.setToolTip(
  1590. _("Type here any G-Code commands you would\n"
  1591. "like to add at the beginning of the G-Code file.")
  1592. )
  1593. self.custom_box.addWidget(prependlabel)
  1594. self.prepend_text = FCTextArea()
  1595. self.prepend_text.setPlaceholderText(
  1596. _("Type here any G-Code commands you would\n"
  1597. "like to add at the beginning of the G-Code file.")
  1598. )
  1599. self.custom_box.addWidget(self.prepend_text)
  1600. # Append text to GCode
  1601. appendlabel = QtWidgets.QLabel('%s:' % _('Append to CNC Code'))
  1602. appendlabel.setToolTip(
  1603. _("Type here any G-Code commands you would\n"
  1604. "like to append to the generated file.\n"
  1605. "I.e.: M2 (End of program)")
  1606. )
  1607. self.custom_box.addWidget(appendlabel)
  1608. self.append_text = FCTextArea()
  1609. self.append_text.setPlaceholderText(
  1610. _("Type here any G-Code commands you would\n"
  1611. "like to append to the generated file.\n"
  1612. "I.e.: M2 (End of program)")
  1613. )
  1614. self.custom_box.addWidget(self.append_text)
  1615. self.cnc_frame = QtWidgets.QFrame()
  1616. self.cnc_frame.setContentsMargins(0, 0, 0, 0)
  1617. self.custom_box.addWidget(self.cnc_frame)
  1618. self.cnc_box = QtWidgets.QVBoxLayout()
  1619. self.cnc_box.setContentsMargins(0, 0, 0, 0)
  1620. self.cnc_frame.setLayout(self.cnc_box)
  1621. # Toolchange Custom G-Code
  1622. self.toolchangelabel = QtWidgets.QLabel('%s:' % _('Toolchange G-Code'))
  1623. self.toolchangelabel.setToolTip(
  1624. _(
  1625. "Type here any G-Code commands you would\n"
  1626. "like to be executed when Toolchange event is encountered.\n"
  1627. "This will constitute a Custom Toolchange GCode,\n"
  1628. "or a Toolchange Macro.\n"
  1629. "The FlatCAM variables are surrounded by '%' symbol.\n\n"
  1630. "WARNING: it can be used only with a preprocessor file\n"
  1631. "that has 'toolchange_custom' in it's name and this is built\n"
  1632. "having as template the 'Toolchange Custom' posprocessor file."
  1633. )
  1634. )
  1635. self.cnc_box.addWidget(self.toolchangelabel)
  1636. self.toolchange_text = FCTextArea()
  1637. self.toolchange_text.setPlaceholderText(
  1638. _(
  1639. "Type here any G-Code commands you would\n"
  1640. "like to be executed when Toolchange event is encountered.\n"
  1641. "This will constitute a Custom Toolchange GCode,\n"
  1642. "or a Toolchange Macro.\n"
  1643. "The FlatCAM variables are surrounded by '%' symbol.\n"
  1644. "WARNING: it can be used only with a preprocessor file\n"
  1645. "that has 'toolchange_custom' in it's name."
  1646. )
  1647. )
  1648. self.cnc_box.addWidget(self.toolchange_text)
  1649. cnclay = QtWidgets.QHBoxLayout()
  1650. self.cnc_box.addLayout(cnclay)
  1651. # Toolchange Replacement Enable
  1652. self.toolchange_cb = FCCheckBox(label='%s' % _('Use Toolchange Macro'))
  1653. self.toolchange_cb.setToolTip(
  1654. _("Check this box if you want to use\n"
  1655. "a Custom Toolchange GCode (macro).")
  1656. )
  1657. # Variable list
  1658. self.tc_variable_combo = FCComboBox()
  1659. self.tc_variable_combo.setToolTip(
  1660. _(
  1661. "A list of the FlatCAM variables that can be used\n"
  1662. "in the Toolchange event.\n"
  1663. "They have to be surrounded by the '%' symbol"
  1664. )
  1665. )
  1666. # Populate the Combo Box
  1667. variables = [_('Parameters'), 'tool', 'tooldia', 't_drills', 'x_toolchange', 'y_toolchange', 'z_toolchange',
  1668. 'z_cut', 'z_move', 'z_depthpercut', 'spindlespeed', 'dwelltime']
  1669. self.tc_variable_combo.addItems(variables)
  1670. self.tc_variable_combo.setItemData(0, _("FlatCAM CNC parameters"), Qt.ToolTipRole)
  1671. self.tc_variable_combo.setItemData(1, "tool = " + _("tool number"), Qt.ToolTipRole)
  1672. self.tc_variable_combo.setItemData(2, "tooldia = " + _("tool diameter"), Qt.ToolTipRole)
  1673. self.tc_variable_combo.setItemData(3, "t_drills = " + _("for Excellon, total number of drills"),
  1674. Qt.ToolTipRole)
  1675. self.tc_variable_combo.setItemData(4, "x_toolchange = " + _("X coord for Toolchange"), Qt.ToolTipRole)
  1676. self.tc_variable_combo.setItemData(5, "y_toolchange = " + _("Y coord for Toolchange"), Qt.ToolTipRole)
  1677. self.tc_variable_combo.setItemData(6, "z_toolchange = " + _("Z coord for Toolchange"), Qt.ToolTipRole)
  1678. self.tc_variable_combo.setItemData(7, "z_cut = " + _("depth where to cut"), Qt.ToolTipRole)
  1679. self.tc_variable_combo.setItemData(8, "z_move = " + _("height where to travel"), Qt.ToolTipRole)
  1680. self.tc_variable_combo.setItemData(9, "z_depthpercut = " + _("the step value for multidepth cut"),
  1681. Qt.ToolTipRole)
  1682. self.tc_variable_combo.setItemData(10, "spindlesspeed = " + _("the value for the spindle speed"),
  1683. Qt.ToolTipRole)
  1684. self.tc_variable_combo.setItemData(11, "dwelltime = " + _("time to dwell to allow the "
  1685. "spindle to reach it's set RPM"),
  1686. Qt.ToolTipRole)
  1687. cnclay.addWidget(self.toolchange_cb)
  1688. cnclay.addStretch()
  1689. cnclay.addWidget(self.tc_variable_combo)
  1690. self.toolch_ois = OptionalInputSection(self.toolchange_cb,
  1691. [self.toolchangelabel, self.toolchange_text, self.tc_variable_combo])
  1692. h_lay = QtWidgets.QHBoxLayout()
  1693. h_lay.setAlignment(QtCore.Qt.AlignVCenter)
  1694. self.custom_box.addLayout(h_lay)
  1695. #
  1696. # # Edit GCode Button
  1697. # self.modify_gcode_button = QtWidgets.QPushButton(_('View CNC Code'))
  1698. # self.modify_gcode_button.setToolTip(
  1699. # _("Opens TAB to view/modify/print G-Code\n"
  1700. # "file.")
  1701. # )
  1702. # GO Button
  1703. self.export_gcode_button = QtWidgets.QPushButton(_('Save CNC Code'))
  1704. self.export_gcode_button.setToolTip(
  1705. _("Opens dialog to save G-Code\n"
  1706. "file.")
  1707. )
  1708. # h_lay.addWidget(self.modify_gcode_button)
  1709. h_lay.addWidget(self.export_gcode_button)
  1710. # self.custom_box.addWidget(self.export_gcode_button)
  1711. class ScriptObjectUI(ObjectUI):
  1712. """
  1713. User interface for Script objects.
  1714. """
  1715. def __init__(self, app, parent=None):
  1716. """
  1717. Creates the user interface for Script objects. GUI elements should
  1718. be placed in ``self.custom_box`` to preserve the layout.
  1719. """
  1720. self.decimals = app.decimals
  1721. self.app = app
  1722. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  1723. if theme_settings.contains("theme"):
  1724. theme = theme_settings.value('theme', type=str)
  1725. else:
  1726. theme = 'white'
  1727. if theme == 'white':
  1728. self.resource_loc = 'assets/resources'
  1729. else:
  1730. self.resource_loc = 'assets/resources'
  1731. ObjectUI.__init__(self, title=_('Script Object'),
  1732. icon_file=self.resource_loc + '/script_new24.png',
  1733. parent=parent,
  1734. common=False,
  1735. app=self.app)
  1736. # ## Object name
  1737. self.name_hlay = QtWidgets.QHBoxLayout()
  1738. self.custom_box.addLayout(self.name_hlay)
  1739. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  1740. self.name_entry = FCEntry()
  1741. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  1742. self.name_hlay.addWidget(name_label)
  1743. self.name_hlay.addWidget(self.name_entry)
  1744. h_lay = QtWidgets.QHBoxLayout()
  1745. h_lay.setAlignment(QtCore.Qt.AlignVCenter)
  1746. self.custom_box.addLayout(h_lay)
  1747. self.autocomplete_cb = FCCheckBox("%s" % _("Auto Completer"))
  1748. self.autocomplete_cb.setToolTip(
  1749. _("This selects if the auto completer is enabled in the Script Editor.")
  1750. )
  1751. self.autocomplete_cb.setStyleSheet(
  1752. """
  1753. QCheckBox {font-weight: bold; color: black}
  1754. """
  1755. )
  1756. h_lay.addWidget(self.autocomplete_cb)
  1757. h_lay.addStretch()
  1758. # Plot CB - this is added only for compatibility; other FlatCAM objects expect it and the mechanism is already
  1759. # established and I don't want to changed it right now
  1760. self.plot_cb = FCCheckBox()
  1761. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  1762. self.custom_box.addWidget(self.plot_cb)
  1763. self.plot_cb.hide()
  1764. self.custom_box.addStretch()
  1765. class DocumentObjectUI(ObjectUI):
  1766. """
  1767. User interface for Notes objects.
  1768. """
  1769. def __init__(self, app, parent=None):
  1770. """
  1771. Creates the user interface for Notes objects. GUI elements should
  1772. be placed in ``self.custom_box`` to preserve the layout.
  1773. """
  1774. self.decimals = app.decimals
  1775. self.app = app
  1776. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  1777. if theme_settings.contains("theme"):
  1778. theme = theme_settings.value('theme', type=str)
  1779. else:
  1780. theme = 'white'
  1781. if theme == 'white':
  1782. self.resource_loc = 'assets/resources'
  1783. else:
  1784. self.resource_loc = 'assets/resources'
  1785. ObjectUI.__init__(self, title=_('Document Object'),
  1786. icon_file=self.resource_loc + '/notes16_1.png',
  1787. parent=parent,
  1788. common=False,
  1789. app=self.app)
  1790. # ## Object name
  1791. self.name_hlay = QtWidgets.QHBoxLayout()
  1792. self.custom_box.addLayout(self.name_hlay)
  1793. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  1794. self.name_entry = FCEntry()
  1795. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  1796. self.name_hlay.addWidget(name_label)
  1797. self.name_hlay.addWidget(self.name_entry)
  1798. # Plot CB - this is added only for compatibility; other FlatCAM objects expect it and the mechanism is already
  1799. # established and I don't want to changed it right now
  1800. self.plot_cb = FCCheckBox()
  1801. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  1802. self.custom_box.addWidget(self.plot_cb)
  1803. self.plot_cb.hide()
  1804. h_lay = QtWidgets.QHBoxLayout()
  1805. h_lay.setAlignment(QtCore.Qt.AlignVCenter)
  1806. self.custom_box.addLayout(h_lay)
  1807. self.autocomplete_cb = FCCheckBox("%s" % _("Auto Completer"))
  1808. self.autocomplete_cb.setToolTip(
  1809. _("This selects if the auto completer is enabled in the Document Editor.")
  1810. )
  1811. self.autocomplete_cb.setStyleSheet(
  1812. """
  1813. QCheckBox {font-weight: bold; color: black}
  1814. """
  1815. )
  1816. h_lay.addWidget(self.autocomplete_cb)
  1817. h_lay.addStretch()
  1818. # ##############################################################
  1819. # ############ FORM LAYOUT #####################################
  1820. # ##############################################################
  1821. self.form_box = QtWidgets.QFormLayout()
  1822. self.custom_box.addLayout(self.form_box)
  1823. # Font
  1824. self.font_type_label = QtWidgets.QLabel('%s:' % _("Font Type"))
  1825. if sys.platform == "win32":
  1826. f_current = QtGui.QFont("Arial")
  1827. elif sys.platform == "linux":
  1828. f_current = QtGui.QFont("FreeMono")
  1829. else:
  1830. f_current = QtGui.QFont("Helvetica Neue")
  1831. self.font_name = f_current.family()
  1832. self.font_type_cb = QtWidgets.QFontComboBox(self)
  1833. self.font_type_cb.setCurrentFont(f_current)
  1834. self.form_box.addRow(self.font_type_label, self.font_type_cb)
  1835. # Font Size
  1836. self.font_size_label = QtWidgets.QLabel('%s:' % _("Font Size"))
  1837. self.font_size_cb = FCComboBox()
  1838. self.font_size_cb.setEditable(True)
  1839. self.font_size_cb.setMinimumContentsLength(3)
  1840. self.font_size_cb.setMaximumWidth(70)
  1841. font_sizes = ['6', '7', '8', '9', '10', '11', '12', '13', '14',
  1842. '15', '16', '18', '20', '22', '24', '26', '28',
  1843. '32', '36', '40', '44', '48', '54', '60', '66',
  1844. '72', '80', '88', '96']
  1845. for i in font_sizes:
  1846. self.font_size_cb.addItem(i)
  1847. size_hlay = QtWidgets.QHBoxLayout()
  1848. size_hlay.addWidget(self.font_size_cb)
  1849. size_hlay.addStretch()
  1850. self.font_bold_tb = QtWidgets.QToolButton()
  1851. self.font_bold_tb.setCheckable(True)
  1852. self.font_bold_tb.setIcon(QtGui.QIcon(self.resource_loc + '/bold32.png'))
  1853. size_hlay.addWidget(self.font_bold_tb)
  1854. self.font_italic_tb = QtWidgets.QToolButton()
  1855. self.font_italic_tb.setCheckable(True)
  1856. self.font_italic_tb.setIcon(QtGui.QIcon(self.resource_loc + '/italic32.png'))
  1857. size_hlay.addWidget(self.font_italic_tb)
  1858. self.font_under_tb = QtWidgets.QToolButton()
  1859. self.font_under_tb.setCheckable(True)
  1860. self.font_under_tb.setIcon(QtGui.QIcon(self.resource_loc + '/underline32.png'))
  1861. size_hlay.addWidget(self.font_under_tb)
  1862. self.form_box.addRow(self.font_size_label, size_hlay)
  1863. # Alignment Choices
  1864. self.alignment_label = QtWidgets.QLabel('%s:' % _("Alignment"))
  1865. al_hlay = QtWidgets.QHBoxLayout()
  1866. self.al_left_tb = QtWidgets.QToolButton()
  1867. self.al_left_tb.setToolTip(_("Align Left"))
  1868. self.al_left_tb.setIcon(QtGui.QIcon(self.resource_loc + '/align_left32.png'))
  1869. al_hlay.addWidget(self.al_left_tb)
  1870. self.al_center_tb = QtWidgets.QToolButton()
  1871. self.al_center_tb.setToolTip(_("Center"))
  1872. self.al_center_tb.setIcon(QtGui.QIcon(self.resource_loc + '/align_center32.png'))
  1873. al_hlay.addWidget(self.al_center_tb)
  1874. self.al_right_tb = QtWidgets.QToolButton()
  1875. self.al_right_tb.setToolTip(_("Align Right"))
  1876. self.al_right_tb.setIcon(QtGui.QIcon(self.resource_loc + '/align_right32.png'))
  1877. al_hlay.addWidget(self.al_right_tb)
  1878. self.al_justify_tb = QtWidgets.QToolButton()
  1879. self.al_justify_tb.setToolTip(_("Justify"))
  1880. self.al_justify_tb.setIcon(QtGui.QIcon(self.resource_loc + '/align_justify32.png'))
  1881. al_hlay.addWidget(self.al_justify_tb)
  1882. self.form_box.addRow(self.alignment_label, al_hlay)
  1883. # Font Color
  1884. self.font_color_label = QtWidgets.QLabel('%s:' % _('Font Color'))
  1885. self.font_color_label.setToolTip(
  1886. _("Set the font color for the selected text")
  1887. )
  1888. self.font_color_entry = FCEntry()
  1889. self.font_color_button = QtWidgets.QPushButton()
  1890. self.font_color_button.setFixedSize(15, 15)
  1891. self.form_box_child_1 = QtWidgets.QHBoxLayout()
  1892. self.form_box_child_1.addWidget(self.font_color_entry)
  1893. self.form_box_child_1.addWidget(self.font_color_button)
  1894. self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1895. self.form_box.addRow(self.font_color_label, self.form_box_child_1)
  1896. # Selection Color
  1897. self.sel_color_label = QtWidgets.QLabel('%s:' % _('Selection Color'))
  1898. self.sel_color_label.setToolTip(
  1899. _("Set the selection color when doing text selection.")
  1900. )
  1901. self.sel_color_entry = FCEntry()
  1902. self.sel_color_button = QtWidgets.QPushButton()
  1903. self.sel_color_button.setFixedSize(15, 15)
  1904. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  1905. self.form_box_child_2.addWidget(self.sel_color_entry)
  1906. self.form_box_child_2.addWidget(self.sel_color_button)
  1907. self.form_box_child_2.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1908. self.form_box.addRow(self.sel_color_label, self.form_box_child_2)
  1909. # Tab size
  1910. self.tab_size_label = QtWidgets.QLabel('%s:' % _('Tab Size'))
  1911. self.tab_size_label.setToolTip(
  1912. _("Set the tab size. In pixels. Default value is 80 pixels.")
  1913. )
  1914. self.tab_size_spinner = FCSpinner(callback=self.confirmation_message_int)
  1915. self.tab_size_spinner.set_range(0, 1000)
  1916. self.form_box.addRow(self.tab_size_label, self.tab_size_spinner)
  1917. self.custom_box.addStretch()
  1918. # end of file