ObjectUI.py 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833
  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. grid0.addWidget(self.plot_options_label, 0, 0)
  163. # Solid CB
  164. self.solid_cb = FCCheckBox(label=_('Solid'))
  165. self.solid_cb.setToolTip(
  166. _("Solid color polygons.")
  167. )
  168. grid0.addWidget(self.solid_cb, 0, 1)
  169. # Multicolored CB
  170. self.multicolored_cb = FCCheckBox(label=_('Multi-Color'))
  171. self.multicolored_cb.setToolTip(
  172. _("Draw polygons in different colors.")
  173. )
  174. grid0.addWidget(self.multicolored_cb, 0, 2)
  175. # ## Object name
  176. self.name_hlay = QtWidgets.QHBoxLayout()
  177. grid0.addLayout(self.name_hlay, 1, 0, 1, 3)
  178. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  179. self.name_entry = FCEntry()
  180. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  181. self.name_hlay.addWidget(name_label)
  182. self.name_hlay.addWidget(self.name_entry)
  183. # Plot CB
  184. self.plot_lbl = FCLabel('%s:' % _("Plot"))
  185. self.plot_lbl.setToolTip(_("Plot (show) this object."))
  186. self.plot_cb = FCCheckBox()
  187. grid0.addWidget(self.plot_lbl, 2, 0)
  188. grid0.addWidget(self.plot_cb, 2, 1)
  189. # Generate 'Follow'
  190. self.follow_cb = FCCheckBox('%s' % _("Follow"))
  191. self.follow_cb.setToolTip(_("Generate a 'Follow' geometry.\n"
  192. "This means that it will cut through\n"
  193. "the middle of the trace."))
  194. grid0.addWidget(self.follow_cb, 2, 2)
  195. # Editor
  196. self.editor_button = QtWidgets.QPushButton(_('Gerber Editor'))
  197. self.editor_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
  198. self.editor_button.setToolTip(
  199. _("Edit an Gerber object.")
  200. )
  201. self.editor_button.setStyleSheet("""
  202. QPushButton
  203. {
  204. font-weight: bold;
  205. }
  206. """)
  207. grid0.addWidget(self.editor_button, 4, 0, 1, 3)
  208. # PROPERTIES CB
  209. self.properties_lbl = FCLabel('<b>%s</b>:' % _("PROPERTIES"))
  210. self.properties_lbl.setToolTip(_("Show the Properties."))
  211. self.properties_cb = FCCheckBox()
  212. grid0.addWidget(self.properties_lbl, 6, 0)
  213. grid0.addWidget(self.properties_cb, 6, 1, 1, 2)
  214. # PROPERTIES Frame
  215. self.properties_frame = QtWidgets.QFrame()
  216. self.properties_frame.setContentsMargins(0, 0, 0, 0)
  217. grid0.addWidget(self.properties_frame, 7, 0, 1, 3)
  218. self.properties_box = QtWidgets.QVBoxLayout()
  219. self.properties_box.setContentsMargins(0, 0, 0, 0)
  220. self.properties_frame.setLayout(self.properties_box)
  221. self.properties_frame.hide()
  222. self.treeWidget = FCTree(columns=2)
  223. self.properties_box.addWidget(self.treeWidget)
  224. self.properties_box.setStretch(0, 0)
  225. # ### Gerber Apertures ####
  226. self.apertures_table_label = QtWidgets.QLabel('%s:' % _('Apertures'))
  227. self.apertures_table_label.setToolTip(
  228. _("Apertures Table for the Gerber Object.")
  229. )
  230. grid0.addWidget(self.apertures_table_label, 8, 0)
  231. # Aperture Table Visibility CB
  232. self.aperture_table_visibility_cb = FCCheckBox()
  233. self.aperture_table_visibility_cb.setToolTip(
  234. _("Toggle the display of the Tools Table.")
  235. )
  236. # self.aperture_table_visibility_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  237. grid0.addWidget(self.aperture_table_visibility_cb, 8, 1)
  238. hlay_plot = QtWidgets.QHBoxLayout()
  239. grid0.addLayout(hlay_plot, 8, 2)
  240. # Aperture Mark all CB
  241. self.mark_all_cb = FCCheckBox(_('Mark All'))
  242. self.mark_all_cb.setToolTip(
  243. _("When checked it will display all the apertures.\n"
  244. "When unchecked, it will delete all mark shapes\n"
  245. "that are drawn on canvas.")
  246. )
  247. self.mark_all_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  248. hlay_plot.addStretch()
  249. hlay_plot.addWidget(self.mark_all_cb)
  250. # Apertures Table
  251. self.apertures_table = FCTable()
  252. grid0.addWidget(self.apertures_table, 10, 0, 1, 3)
  253. self.apertures_table.setColumnCount(6)
  254. self.apertures_table.setHorizontalHeaderLabels(['#', _('Code'), _('Type'), _('Size'), _('Dim'), 'M'])
  255. self.apertures_table.setSortingEnabled(False)
  256. self.apertures_table.horizontalHeaderItem(0).setToolTip(
  257. _("Index"))
  258. self.apertures_table.horizontalHeaderItem(1).setToolTip(
  259. _("Aperture Code"))
  260. self.apertures_table.horizontalHeaderItem(2).setToolTip(
  261. _("Type of aperture: circular, rectangle, macros etc"))
  262. self.apertures_table.horizontalHeaderItem(4).setToolTip(
  263. _("Aperture Size:"))
  264. self.apertures_table.horizontalHeaderItem(4).setToolTip(
  265. _("Aperture Dimensions:\n"
  266. " - (width, height) for R, O type.\n"
  267. " - (dia, nVertices) for P type"))
  268. self.apertures_table.horizontalHeaderItem(5).setToolTip(
  269. _("Mark the aperture instances on canvas."))
  270. # self.apertures_table.setColumnHidden(5, True)
  271. # start with apertures table hidden
  272. self.apertures_table.setVisible(False)
  273. # Buffer Geometry
  274. self.create_buffer_button = QtWidgets.QPushButton(_('Buffer Solid Geometry'))
  275. self.create_buffer_button.setToolTip(
  276. _("This button is shown only when the Gerber file\n"
  277. "is loaded without buffering.\n"
  278. "Clicking this will create the buffered geometry\n"
  279. "required for isolation.")
  280. )
  281. grid0.addWidget(self.create_buffer_button, 12, 0, 1, 3)
  282. separator_line1 = QtWidgets.QFrame()
  283. separator_line1.setFrameShape(QtWidgets.QFrame.HLine)
  284. separator_line1.setFrameShadow(QtWidgets.QFrame.Sunken)
  285. grid0.addWidget(separator_line1, 13, 0, 1, 3)
  286. self.tool_lbl = QtWidgets.QLabel('<b>%s</b>' % _("TOOLS"))
  287. grid0.addWidget(self.tool_lbl, 14, 0, 1, 3)
  288. # Isolation Tool - will create isolation paths around the copper features
  289. self.iso_button = QtWidgets.QPushButton(_('Isolation Routing'))
  290. # self.iso_button.setIcon(QtGui.QIcon(self.app.resource_location + '/iso_16.png'))
  291. self.iso_button.setToolTip(
  292. _("Create a Geometry object with\n"
  293. "toolpaths to cut around polygons.")
  294. )
  295. self.iso_button.setStyleSheet("""
  296. QPushButton
  297. {
  298. font-weight: bold;
  299. }
  300. """)
  301. grid0.addWidget(self.iso_button, 16, 0, 1, 3)
  302. # ## Clear non-copper regions
  303. self.generate_ncc_button = QtWidgets.QPushButton(_('NCC Tool'))
  304. self.generate_ncc_button.setIcon(QtGui.QIcon(self.app.resource_location + '/eraser26.png'))
  305. self.generate_ncc_button.setToolTip(
  306. _("Create the Geometry Object\n"
  307. "for non-copper routing.")
  308. )
  309. self.generate_ncc_button.setStyleSheet("""
  310. QPushButton
  311. {
  312. font-weight: bold;
  313. }
  314. """)
  315. grid0.addWidget(self.generate_ncc_button, 18, 0, 1, 3)
  316. # ## Board cutout
  317. self.generate_cutout_button = QtWidgets.QPushButton(_('Cutout Tool'))
  318. self.generate_cutout_button.setIcon(QtGui.QIcon(self.app.resource_location + '/cut32_bis.png'))
  319. self.generate_cutout_button.setToolTip(
  320. _("Generate the geometry for\n"
  321. "the board cutout.")
  322. )
  323. self.generate_cutout_button.setStyleSheet("""
  324. QPushButton
  325. {
  326. font-weight: bold;
  327. }
  328. """)
  329. grid0.addWidget(self.generate_cutout_button, 20, 0, 1, 3)
  330. separator_line = QtWidgets.QFrame()
  331. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  332. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  333. grid0.addWidget(separator_line, 22, 0, 1, 3)
  334. # ## Non-copper regions
  335. self.noncopper_label = QtWidgets.QLabel("<b>%s</b>" % _("Non-copper regions"))
  336. self.noncopper_label.setToolTip(
  337. _("Create polygons covering the\n"
  338. "areas without copper on the PCB.\n"
  339. "Equivalent to the inverse of this\n"
  340. "object. Can be used to remove all\n"
  341. "copper from a specified region.")
  342. )
  343. grid0.addWidget(self.noncopper_label, 24, 0, 1, 3)
  344. # Margin
  345. bmlabel = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
  346. bmlabel.setToolTip(
  347. _("Specify the edge of the PCB\n"
  348. "by drawing a box around all\n"
  349. "objects with this minimum\n"
  350. "distance.")
  351. )
  352. self.noncopper_margin_entry = FCDoubleSpinner(callback=self.confirmation_message)
  353. self.noncopper_margin_entry.set_range(-9999.9999, 9999.9999)
  354. self.noncopper_margin_entry.set_precision(self.decimals)
  355. self.noncopper_margin_entry.setSingleStep(0.1)
  356. grid0.addWidget(bmlabel, 26, 0)
  357. grid0.addWidget(self.noncopper_margin_entry, 26, 1, 1, 2)
  358. # Rounded corners
  359. self.noncopper_rounded_cb = FCCheckBox(label=_("Rounded"))
  360. self.noncopper_rounded_cb.setToolTip(
  361. _("Resulting geometry will have rounded corners.")
  362. )
  363. self.generate_noncopper_button = QtWidgets.QPushButton(_('Generate Geometry'))
  364. self.generate_noncopper_button.setIcon(QtGui.QIcon(self.app.resource_location + '/geometry32.png'))
  365. grid0.addWidget(self.noncopper_rounded_cb, 28, 0)
  366. grid0.addWidget(self.generate_noncopper_button, 28, 1, 1, 2)
  367. separator_line1 = QtWidgets.QFrame()
  368. separator_line1.setFrameShape(QtWidgets.QFrame.HLine)
  369. separator_line1.setFrameShadow(QtWidgets.QFrame.Sunken)
  370. grid0.addWidget(separator_line1, 30, 0, 1, 3)
  371. # ## Bounding box
  372. self.boundingbox_label = QtWidgets.QLabel('<b>%s</b>' % _('Bounding Box'))
  373. self.boundingbox_label.setToolTip(
  374. _("Create a geometry surrounding the Gerber object.\n"
  375. "Square shape.")
  376. )
  377. grid0.addWidget(self.boundingbox_label, 32, 0, 1, 3)
  378. bbmargin = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
  379. bbmargin.setToolTip(
  380. _("Distance of the edges of the box\n"
  381. "to the nearest polygon.")
  382. )
  383. self.bbmargin_entry = FCDoubleSpinner(callback=self.confirmation_message)
  384. self.bbmargin_entry.set_range(-9999.9999, 9999.9999)
  385. self.bbmargin_entry.set_precision(self.decimals)
  386. self.bbmargin_entry.setSingleStep(0.1)
  387. grid0.addWidget(bbmargin, 34, 0)
  388. grid0.addWidget(self.bbmargin_entry, 34, 1, 1, 2)
  389. self.bbrounded_cb = FCCheckBox(label=_("Rounded"))
  390. self.bbrounded_cb.setToolTip(
  391. _("If the bounding box is \n"
  392. "to have rounded corners\n"
  393. "their radius is equal to\n"
  394. "the margin.")
  395. )
  396. self.generate_bb_button = QtWidgets.QPushButton(_('Generate Geometry'))
  397. self.generate_bb_button.setIcon(QtGui.QIcon(self.app.resource_location + '/geometry32.png'))
  398. self.generate_bb_button.setToolTip(
  399. _("Generate the Geometry object.")
  400. )
  401. grid0.addWidget(self.bbrounded_cb, 36, 0)
  402. grid0.addWidget(self.generate_bb_button, 36, 1, 1, 2)
  403. class ExcellonObjectUI(ObjectUI):
  404. """
  405. User interface for Excellon objects.
  406. """
  407. def __init__(self, app, parent=None):
  408. self.decimals = app.decimals
  409. self.app = app
  410. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  411. if theme_settings.contains("theme"):
  412. theme = theme_settings.value('theme', type=str)
  413. else:
  414. theme = 'white'
  415. if theme == 'white':
  416. self.resource_loc = 'assets/resources'
  417. else:
  418. self.resource_loc = 'assets/resources'
  419. ObjectUI.__init__(self, title=_('Excellon Object'),
  420. icon_file=self.resource_loc + '/drill32.png',
  421. parent=parent,
  422. app=self.app)
  423. grid0 = QtWidgets.QGridLayout()
  424. grid0.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  425. grid0.setColumnStretch(0, 0)
  426. grid0.setColumnStretch(1, 1)
  427. self.custom_box.addLayout(grid0)
  428. # Plot options
  429. self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  430. # Solid CB
  431. self.solid_cb = FCCheckBox(label=_('Solid'))
  432. self.solid_cb.setToolTip(
  433. _("Solid circles.")
  434. )
  435. # Multicolored CB
  436. self.multicolored_cb = FCCheckBox(label=_('Multi-Color'))
  437. self.multicolored_cb.setToolTip(
  438. _("Draw polygons in different colors.")
  439. )
  440. grid0.addWidget(self.plot_options_label, 0, 0)
  441. grid0.addWidget(self.solid_cb, 0, 1)
  442. grid0.addWidget(self.multicolored_cb, 0, 2)
  443. # ## Object name
  444. self.name_hlay = QtWidgets.QHBoxLayout()
  445. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  446. self.name_entry = FCEntry()
  447. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  448. self.name_hlay.addWidget(name_label)
  449. self.name_hlay.addWidget(self.name_entry)
  450. grid0.addLayout(self.name_hlay, 2, 0, 1, 3)
  451. # Editor
  452. self.editor_button = QtWidgets.QPushButton(_('Excellon Editor'))
  453. self.editor_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
  454. self.editor_button.setToolTip(
  455. _("Edit an Excellon object.")
  456. )
  457. self.editor_button.setStyleSheet("""
  458. QPushButton
  459. {
  460. font-weight: bold;
  461. }
  462. """)
  463. grid0.addWidget(self.editor_button, 4, 0, 1, 3)
  464. # PROPERTIES CB
  465. self.properties_lbl = FCLabel('<b>%s</b>:' % _("PROPERTIES"))
  466. self.properties_lbl.setToolTip(_("Show the Properties."))
  467. self.properties_cb = FCCheckBox()
  468. grid0.addWidget(self.properties_lbl, 6, 0)
  469. grid0.addWidget(self.properties_cb, 6, 1, 1, 2)
  470. # PROPERTIES Frame
  471. self.properties_frame = QtWidgets.QFrame()
  472. self.properties_frame.setContentsMargins(0, 0, 0, 0)
  473. grid0.addWidget(self.properties_frame, 7, 0, 1, 3)
  474. self.properties_box = QtWidgets.QVBoxLayout()
  475. self.properties_box.setContentsMargins(0, 0, 0, 0)
  476. self.properties_frame.setLayout(self.properties_box)
  477. self.properties_frame.hide()
  478. self.treeWidget = FCTree(columns=2)
  479. self.properties_box.addWidget(self.treeWidget)
  480. self.properties_box.setStretch(0, 0)
  481. # ### Tools Drills ####
  482. self.tools_table_label = QtWidgets.QLabel('<b>%s</b>' % _('Tools Table'))
  483. self.tools_table_label.setToolTip(
  484. _("Tools in this Excellon object\n"
  485. "when are used for drilling.")
  486. )
  487. # Table Visibility CB
  488. self.table_visibility_cb = FCCheckBox()
  489. self.table_visibility_cb.setToolTip(
  490. _("Toggle the display of the Tools Table.")
  491. )
  492. # Plot CB
  493. hlay_plot = QtWidgets.QHBoxLayout()
  494. self.plot_cb = FCCheckBox(_('Plot'))
  495. self.plot_cb.setToolTip(
  496. _("Plot (show) this object.")
  497. )
  498. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  499. hlay_plot.addStretch()
  500. hlay_plot.addWidget(self.plot_cb)
  501. grid0.addWidget(self.tools_table_label, 8, 0)
  502. grid0.addWidget(self.table_visibility_cb, 8, 1)
  503. grid0.addLayout(hlay_plot, 8, 2)
  504. # #############################################################################################################
  505. # #############################################################################################################
  506. # add a frame and inside add a vertical box layout. Inside this vbox layout I add all the Drills widgets
  507. # this way I can hide/show the frame
  508. # #############################################################################################################
  509. # #############################################################################################################
  510. self.drills_frame = QtWidgets.QFrame()
  511. self.drills_frame.setContentsMargins(0, 0, 0, 0)
  512. self.custom_box.addWidget(self.drills_frame)
  513. self.tools_box = QtWidgets.QVBoxLayout()
  514. self.tools_box.setContentsMargins(0, 0, 0, 0)
  515. self.drills_frame.setLayout(self.tools_box)
  516. self.tools_table = FCTable()
  517. self.tools_table.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
  518. self.tools_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
  519. self.tools_box.addWidget(self.tools_table)
  520. self.tools_table.setColumnCount(6)
  521. self.tools_table.setHorizontalHeaderLabels(['#', _('Diameter'), _('Drills'), _('Slots'),
  522. "C", 'P'])
  523. self.tools_table.setSortingEnabled(False)
  524. self.tools_table.horizontalHeaderItem(0).setToolTip(
  525. _("This is the Tool Number.\n"
  526. "When ToolChange is checked, on toolchange event this value\n"
  527. "will be showed as a T1, T2 ... Tn in the Machine Code.\n\n"
  528. "Here the tools are selected for G-code generation."))
  529. self.tools_table.horizontalHeaderItem(1).setToolTip(
  530. _("Tool Diameter. It's value (in current FlatCAM units) \n"
  531. "is the cut width into the material."))
  532. self.tools_table.horizontalHeaderItem(2).setToolTip(
  533. _("The number of Drill holes. Holes that are drilled with\n"
  534. "a drill bit."))
  535. self.tools_table.horizontalHeaderItem(3).setToolTip(
  536. _("The number of Slot holes. Holes that are created by\n"
  537. "milling them with an endmill bit."))
  538. self.tools_table.horizontalHeaderItem(4).setToolTip(
  539. _("Show the color of the drill holes when using multi-color."))
  540. self.tools_table.horizontalHeaderItem(5).setToolTip(
  541. _("Toggle display of the drills for the current tool.\n"
  542. "This does not select the tools for G-code generation."))
  543. # this column is not used; reserved for future usage
  544. # self.tools_table.setColumnHidden(4, True)
  545. # Excellon Tools autoload from DB
  546. # Auto Load Tools from DB
  547. self.autoload_db_cb = FCCheckBox('%s' % _("Auto load from DB"))
  548. self.autoload_db_cb.setToolTip(
  549. _("Automatic replacement of the tools from related application tools\n"
  550. "with tools from DB that have a close diameter value.")
  551. )
  552. self.tools_box.addWidget(self.autoload_db_cb)
  553. # #################################################################
  554. # ########## TOOLS GRID ###########################################
  555. # #################################################################
  556. grid2 = QtWidgets.QGridLayout()
  557. self.tools_box.addLayout(grid2)
  558. grid2.setColumnStretch(0, 0)
  559. grid2.setColumnStretch(1, 1)
  560. separator_line = QtWidgets.QFrame()
  561. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  562. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  563. grid2.addWidget(separator_line, 0, 0, 1, 2)
  564. self.tool_lbl = QtWidgets.QLabel('<b>%s</b>' % _("TOOLS"))
  565. grid2.addWidget(self.tool_lbl, 2, 0, 1, 2)
  566. # Drilling Tool - will create GCode for drill holes
  567. self.drill_button = QtWidgets.QPushButton(_('Drilling Tool'))
  568. self.drill_button.setIcon(QtGui.QIcon(self.app.resource_location + '/drilling_tool32.png'))
  569. self.drill_button.setToolTip(
  570. _("Generate GCode out of drill holes in an Excellon object.")
  571. )
  572. self.drill_button.setStyleSheet("""
  573. QPushButton
  574. {
  575. font-weight: bold;
  576. }
  577. """)
  578. grid2.addWidget(self.drill_button, 4, 0, 1, 2)
  579. # Milling Tool - will create GCode for slot holes
  580. self.milling_button = QtWidgets.QPushButton(_('Milling Tool'))
  581. self.milling_button.setIcon(QtGui.QIcon(self.app.resource_location + '/milling_tool32.png'))
  582. self.milling_button.setToolTip(
  583. _("Generate GCode out of slot holes in an Excellon object.")
  584. )
  585. self.milling_button.setStyleSheet("""
  586. QPushButton
  587. {
  588. font-weight: bold;
  589. }
  590. """)
  591. grid2.addWidget(self.milling_button, 6, 0, 1, 2)
  592. separator_line = QtWidgets.QFrame()
  593. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  594. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  595. grid2.addWidget(separator_line, 8, 0, 1, 2)
  596. # #################################################################
  597. # ################# GRID LAYOUT 6 ###############################
  598. # #################################################################
  599. self.grid6 = QtWidgets.QGridLayout()
  600. self.grid6.setColumnStretch(0, 0)
  601. self.grid6.setColumnStretch(1, 1)
  602. self.tools_box.addLayout(self.grid6)
  603. # ### Milling Holes Drills ####
  604. self.mill_hole_label = QtWidgets.QLabel('<b>%s</b>' % _('Milling Geometry'))
  605. self.mill_hole_label.setToolTip(
  606. _("Create Geometry for milling holes.\n"
  607. "Select from the Tools Table above the hole dias to be\n"
  608. "milled. Use the # column to make the selection.")
  609. )
  610. self.grid6.addWidget(self.mill_hole_label, 5, 0, 1, 3)
  611. self.tdlabel = QtWidgets.QLabel('%s:' % _('Tool Dia'))
  612. self.tdlabel.setToolTip(
  613. _("Diameter of the cutting tool.")
  614. )
  615. self.grid6.addWidget(self.tdlabel, 6, 0, 1, 3)
  616. self.tooldia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  617. self.tooldia_entry.set_precision(self.decimals)
  618. self.tooldia_entry.set_range(0.0, 9999.9999)
  619. self.tooldia_entry.setSingleStep(0.1)
  620. self.generate_milling_button = QtWidgets.QPushButton(_('Mill Drills'))
  621. self.generate_milling_button.setToolTip(
  622. _("Create the Geometry Object\n"
  623. "for milling DRILLS toolpaths.")
  624. )
  625. self.generate_milling_button.setStyleSheet("""
  626. QPushButton
  627. {
  628. font-weight: bold;
  629. }
  630. """)
  631. self.grid6.addWidget(self.tooldia_entry, 7, 0, 1, 2)
  632. self.grid6.addWidget(self.generate_milling_button, 7, 2)
  633. self.slot_tooldia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  634. self.slot_tooldia_entry.set_precision(self.decimals)
  635. self.slot_tooldia_entry.set_range(0.0, 9999.9999)
  636. self.slot_tooldia_entry.setSingleStep(0.1)
  637. self.generate_milling_slots_button = QtWidgets.QPushButton(_('Mill Slots'))
  638. self.generate_milling_slots_button.setToolTip(
  639. _("Create the Geometry Object\n"
  640. "for milling SLOTS toolpaths.")
  641. )
  642. self.generate_milling_slots_button.setStyleSheet("""
  643. QPushButton
  644. {
  645. font-weight: bold;
  646. }
  647. """)
  648. self.grid6.addWidget(self.slot_tooldia_entry, 8, 0, 1, 2)
  649. self.grid6.addWidget(self.generate_milling_slots_button, 8, 2)
  650. def hide_drills(self, state=True):
  651. if state is True:
  652. self.drills_frame.hide()
  653. else:
  654. self.drills_frame.show()
  655. class GeometryObjectUI(ObjectUI):
  656. """
  657. User interface for Geometry objects.
  658. """
  659. def __init__(self, app, parent=None):
  660. self.decimals = app.decimals
  661. self.app = app
  662. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  663. if theme_settings.contains("theme"):
  664. theme = theme_settings.value('theme', type=str)
  665. else:
  666. theme = 'white'
  667. if theme == 'white':
  668. self.resource_loc = 'assets/resources'
  669. else:
  670. self.resource_loc = 'assets/resources'
  671. super(GeometryObjectUI, self).__init__(
  672. title=_('Geometry Object'),
  673. icon_file=self.resource_loc + '/geometry32.png', parent=parent, app=self.app
  674. )
  675. # Plot options
  676. grid_header = QtWidgets.QGridLayout()
  677. grid_header.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  678. self.custom_box.addLayout(grid_header)
  679. grid_header.setColumnStretch(0, 0)
  680. grid_header.setColumnStretch(1, 1)
  681. self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  682. self.plot_options_label.setMinimumWidth(90)
  683. grid_header.addWidget(self.plot_options_label, 0, 0)
  684. # Multicolored CB
  685. self.multicolored_cb = FCCheckBox(label=_('Multi-Color'))
  686. self.multicolored_cb.setToolTip(
  687. _("Draw polygons in different colors.")
  688. )
  689. self.multicolored_cb.setMinimumWidth(55)
  690. grid_header.addWidget(self.multicolored_cb, 0, 2)
  691. # ## Object name
  692. self.name_hlay = QtWidgets.QHBoxLayout()
  693. grid_header.addLayout(self.name_hlay, 2, 0, 1, 3)
  694. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  695. self.name_entry = FCEntry()
  696. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  697. self.name_hlay.addWidget(name_label)
  698. self.name_hlay.addWidget(self.name_entry)
  699. # Editor
  700. self.editor_button = QtWidgets.QPushButton(_('Geometry Editor'))
  701. self.editor_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
  702. self.editor_button.setToolTip(
  703. _("Edit an Geometry object.")
  704. )
  705. self.editor_button.setStyleSheet("""
  706. QPushButton
  707. {
  708. font-weight: bold;
  709. }
  710. """)
  711. grid_header.addWidget(self.editor_button, 4, 0, 1, 3)
  712. # PROPERTIES CB
  713. self.properties_lbl = FCLabel('<b>%s</b>:' % _("PROPERTIES"))
  714. self.properties_lbl.setToolTip(_("Show the Properties."))
  715. self.properties_cb = FCCheckBox()
  716. grid_header.addWidget(self.properties_lbl, 6, 0)
  717. grid_header.addWidget(self.properties_cb, 6, 1, 1, 2)
  718. # PROPERTIES Frame
  719. self.properties_frame = QtWidgets.QFrame()
  720. self.properties_frame.setContentsMargins(0, 0, 0, 0)
  721. grid_header.addWidget(self.properties_frame, 7, 0, 1, 3)
  722. self.properties_box = QtWidgets.QVBoxLayout()
  723. self.properties_box.setContentsMargins(0, 0, 0, 0)
  724. self.properties_frame.setLayout(self.properties_box)
  725. self.properties_frame.hide()
  726. self.treeWidget = FCTree(columns=2)
  727. self.properties_box.addWidget(self.treeWidget)
  728. self.properties_box.setStretch(0, 0)
  729. # add a frame and inside add a vertical box layout. Inside this vbox layout I add all the Tools widgets
  730. # this way I can hide/show the frame
  731. self.geo_tools_frame = QtWidgets.QFrame()
  732. self.geo_tools_frame.setContentsMargins(0, 0, 0, 0)
  733. self.custom_box.addWidget(self.geo_tools_frame)
  734. self.geo_tools_box = QtWidgets.QVBoxLayout()
  735. self.geo_tools_box.setContentsMargins(0, 0, 0, 0)
  736. self.geo_tools_frame.setLayout(self.geo_tools_box)
  737. # ************************************************************************
  738. # ************** TABLE BOX FRAME *****************************************
  739. # ************************************************************************
  740. self.geo_table_frame = QtWidgets.QFrame()
  741. self.geo_table_frame.setContentsMargins(0, 0, 0, 0)
  742. self.geo_tools_box.addWidget(self.geo_table_frame)
  743. self.geo_table_box = QtWidgets.QVBoxLayout()
  744. self.geo_table_box.setContentsMargins(0, 0, 0, 0)
  745. self.geo_table_frame.setLayout(self.geo_table_box)
  746. grid0 = QtWidgets.QGridLayout()
  747. self.geo_table_box.addLayout(grid0)
  748. grid0.setColumnStretch(0, 0)
  749. grid0.setColumnStretch(1, 1)
  750. # ### Tools ####
  751. self.tools_table_label = QtWidgets.QLabel('<b>%s:</b>' % _('Tools Table'))
  752. self.tools_table_label.setToolTip(
  753. _("Tools in this Geometry object used for cutting.\n"
  754. "The 'Offset' entry will set an offset for the cut.\n"
  755. "'Offset' can be inside, outside, on path (none) and custom.\n"
  756. "'Type' entry is only informative and it allow to know the \n"
  757. "intent of using the current tool. \n"
  758. "It can be Rough(ing), Finish(ing) or Iso(lation).\n"
  759. "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n"
  760. "ball(B), or V-Shaped(V). \n"
  761. "When V-shaped is selected the 'Type' entry is automatically \n"
  762. "set to Isolation, the CutZ parameter in the UI form is\n"
  763. "grayed out and Cut Z is automatically calculated from the newly \n"
  764. "showed UI form entries named V-Tip Dia and V-Tip Angle.")
  765. )
  766. grid0.addWidget(self.tools_table_label, 0, 0)
  767. # Plot CB
  768. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  769. self.plot_cb = FCCheckBox(_('Plot Object'))
  770. self.plot_cb.setToolTip(
  771. _("Plot (show) this object.")
  772. )
  773. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  774. grid0.addWidget(self.plot_cb, 0, 1)
  775. self.geo_tools_table = FCTable(drag_drop=True)
  776. grid0.addWidget(self.geo_tools_table, 1, 0, 1, 2)
  777. self.geo_tools_table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
  778. self.geo_tools_table.setColumnCount(7)
  779. self.geo_tools_table.setColumnWidth(0, 20)
  780. self.geo_tools_table.setHorizontalHeaderLabels(['#', _('Dia'), _('Offset'), _('Type'), _('TT'), '', 'P'])
  781. self.geo_tools_table.setColumnHidden(5, True)
  782. # stylesheet = "::section{Background-color:rgb(239,239,245)}"
  783. # self.geo_tools_table.horizontalHeader().setStyleSheet(stylesheet)
  784. self.geo_tools_table.horizontalHeaderItem(0).setToolTip(
  785. _(
  786. "This is the Tool Number.\n"
  787. "When ToolChange is checked, on toolchange event this value\n"
  788. "will be showed as a T1, T2 ... Tn")
  789. )
  790. self.geo_tools_table.horizontalHeaderItem(1).setToolTip(
  791. _(
  792. "Tool Diameter. It's value (in current FlatCAM units) \n"
  793. "is the cut width into the material."
  794. ))
  795. self.geo_tools_table.horizontalHeaderItem(2).setToolTip(
  796. _(
  797. "The value for the Offset can be:\n"
  798. "- Path -> There is no offset, the tool cut will be done through the geometry line.\n"
  799. "- In(side) -> The tool cut will follow the geometry inside. It will create a 'pocket'.\n"
  800. "- Out(side) -> The tool cut will follow the geometry line on the outside."
  801. ))
  802. self.geo_tools_table.horizontalHeaderItem(3).setToolTip(
  803. _(
  804. "The (Operation) Type has only informative value. Usually the UI form values \n"
  805. "are choose based on the operation type and this will serve as a reminder.\n"
  806. "Can be 'Roughing', 'Finishing' or 'Isolation'.\n"
  807. "For Roughing we may choose a lower Feedrate and multiDepth cut.\n"
  808. "For Finishing we may choose a higher Feedrate, without multiDepth.\n"
  809. "For Isolation we need a lower Feedrate as it use a milling bit with a fine tip."
  810. ))
  811. self.geo_tools_table.horizontalHeaderItem(4).setToolTip(
  812. _(
  813. "The Tool Type (TT) can be:\n"
  814. "- Circular with 1 ... 4 teeth -> it is informative only. Being circular the cut width in material\n"
  815. "is exactly the tool diameter.\n"
  816. "- Ball -> informative only and make reference to the Ball type endmill.\n"
  817. "- V-Shape -> it will disable Z-Cut parameter in the UI form and enable two additional UI form\n"
  818. "fields: V-Tip Dia and V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such\n"
  819. "as the cut width into material will be equal with the value in the Tool "
  820. "Diameter column of this table.\n"
  821. "Choosing the V-Shape Tool Type automatically will select the Operation Type as Isolation."
  822. ))
  823. self.geo_tools_table.horizontalHeaderItem(6).setToolTip(
  824. _(
  825. "Plot column. It is visible only for MultiGeo geometries, meaning geometries that holds the geometry\n"
  826. "data into the tools. For those geometries, deleting the tool will delete the geometry data also,\n"
  827. "so be WARNED. From the checkboxes on each row it can be enabled/disabled the plot on canvas\n"
  828. "for the corresponding tool."
  829. ))
  830. # Tool Offset
  831. grid1 = QtWidgets.QGridLayout()
  832. self.geo_table_box.addLayout(grid1)
  833. grid1.setColumnStretch(0, 0)
  834. grid1.setColumnStretch(1, 1)
  835. self.tool_offset_lbl = QtWidgets.QLabel('%s:' % _('Tool Offset'))
  836. self.tool_offset_lbl.setToolTip(
  837. _(
  838. "The value to offset the cut when \n"
  839. "the Offset type selected is 'Offset'.\n"
  840. "The value can be positive for 'outside'\n"
  841. "cut and negative for 'inside' cut."
  842. )
  843. )
  844. self.tool_offset_entry = FCDoubleSpinner(callback=self.confirmation_message)
  845. self.tool_offset_entry.set_precision(self.decimals)
  846. self.tool_offset_entry.set_range(-9999.9999, 9999.9999)
  847. self.tool_offset_entry.setSingleStep(0.1)
  848. grid1.addWidget(self.tool_offset_lbl, 0, 0)
  849. grid1.addWidget(self.tool_offset_entry, 0, 1)
  850. separator_line = QtWidgets.QFrame()
  851. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  852. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  853. grid1.addWidget(separator_line, 1, 0, 1, 2)
  854. self.tool_sel_label = QtWidgets.QLabel('<b>%s</b>' % _("Add from DB"))
  855. grid1.addWidget(self.tool_sel_label, 2, 0, 1, 2)
  856. self.addtool_entry_lbl = QtWidgets.QLabel('%s:' % _('Tool Dia'))
  857. self.addtool_entry_lbl.setToolTip(
  858. _("Diameter for the new tool")
  859. )
  860. self.addtool_entry = FCDoubleSpinner(callback=self.confirmation_message)
  861. self.addtool_entry.set_precision(self.decimals)
  862. self.addtool_entry.set_range(0.00001, 9999.9999)
  863. self.addtool_entry.setSingleStep(0.1)
  864. grid1.addWidget(self.addtool_entry_lbl, 3, 0)
  865. grid1.addWidget(self.addtool_entry, 3, 1)
  866. bhlay = QtWidgets.QHBoxLayout()
  867. self.addtool_btn = QtWidgets.QPushButton(_('Search and Add'))
  868. self.addtool_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/plus16.png'))
  869. self.addtool_btn.setToolTip(
  870. _("Add a new tool to the Tool Table\n"
  871. "with the diameter specified above.")
  872. )
  873. self.addtool_from_db_btn = QtWidgets.QPushButton(_('Pick from DB'))
  874. self.addtool_from_db_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/search_db32.png'))
  875. self.addtool_from_db_btn.setToolTip(
  876. _("Add a new tool to the Tool Table\n"
  877. "from the Tools Database.\n"
  878. "Tools database administration in in:\n"
  879. "Menu: Options -> Tools Database")
  880. )
  881. bhlay.addWidget(self.addtool_btn)
  882. bhlay.addWidget(self.addtool_from_db_btn)
  883. grid1.addLayout(bhlay, 5, 0, 1, 2)
  884. separator_line = QtWidgets.QFrame()
  885. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  886. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  887. grid1.addWidget(separator_line, 9, 0, 1, 2)
  888. grid2 = QtWidgets.QGridLayout()
  889. self.geo_table_box.addLayout(grid2)
  890. self.copytool_btn = QtWidgets.QPushButton(_('Copy'))
  891. self.copytool_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/copy16.png'))
  892. self.copytool_btn.setToolTip(
  893. _("Copy a selection of tools in the Tool Table\n"
  894. "by first selecting a row in the Tool Table.")
  895. )
  896. self.deltool_btn = QtWidgets.QPushButton(_('Delete'))
  897. self.deltool_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/trash16.png'))
  898. self.deltool_btn.setToolTip(
  899. _("Delete a selection of tools in the Tool Table\n"
  900. "by first selecting a row in the Tool Table.")
  901. )
  902. grid2.addWidget(self.copytool_btn, 0, 0)
  903. grid2.addWidget(self.deltool_btn, 0, 1)
  904. self.geo_table_box.addWidget(QtWidgets.QLabel(''))
  905. # ###########################################################
  906. # ############# Create CNC Job ##############################
  907. # ###########################################################
  908. self.geo_param_frame = QtWidgets.QFrame()
  909. self.geo_param_frame.setContentsMargins(0, 0, 0, 0)
  910. self.geo_tools_box.addWidget(self.geo_param_frame)
  911. self.geo_param_box = QtWidgets.QVBoxLayout()
  912. self.geo_param_box.setContentsMargins(0, 0, 0, 0)
  913. self.geo_param_frame.setLayout(self.geo_param_box)
  914. separator_line = QtWidgets.QFrame()
  915. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  916. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  917. self.geo_param_box.addWidget(separator_line)
  918. # #################################################################
  919. # ################# GRID LAYOUT 3 ###############################
  920. # #################################################################
  921. self.grid3 = QtWidgets.QGridLayout()
  922. self.grid3.setColumnStretch(0, 0)
  923. self.grid3.setColumnStretch(1, 1)
  924. self.geo_param_box.addLayout(self.grid3)
  925. # ### Tools Data ## ##
  926. self.tool_data_label = QtWidgets.QLabel(
  927. "<b>%s: <font color='#0000FF'>%s %d</font></b>" % (_('Parameters for'), _("Tool"), int(1)))
  928. self.tool_data_label.setToolTip(
  929. _(
  930. "The data used for creating GCode.\n"
  931. "Each tool store it's own set of such data."
  932. )
  933. )
  934. self.grid3.addWidget(self.tool_data_label, 0, 0, 1, 2)
  935. # Tip Dia
  936. self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia'))
  937. self.tipdialabel.setToolTip(
  938. _(
  939. "The tip diameter for V-Shape Tool"
  940. )
  941. )
  942. self.tipdia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  943. self.tipdia_entry.set_precision(self.decimals)
  944. self.tipdia_entry.set_range(0.00001, 9999.9999)
  945. self.tipdia_entry.setSingleStep(0.1)
  946. self.grid3.addWidget(self.tipdialabel, 1, 0)
  947. self.grid3.addWidget(self.tipdia_entry, 1, 1)
  948. # Tip Angle
  949. self.tipanglelabel = QtWidgets.QLabel('%s:' % _('V-Tip Angle'))
  950. self.tipanglelabel.setToolTip(
  951. _(
  952. "The tip angle for V-Shape Tool.\n"
  953. "In degree."
  954. )
  955. )
  956. self.tipangle_entry = FCDoubleSpinner(callback=self.confirmation_message)
  957. self.tipangle_entry.set_precision(self.decimals)
  958. self.tipangle_entry.set_range(1.0, 180.0)
  959. self.tipangle_entry.setSingleStep(1)
  960. self.grid3.addWidget(self.tipanglelabel, 2, 0)
  961. self.grid3.addWidget(self.tipangle_entry, 2, 1)
  962. # Cut Z
  963. self.cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
  964. self.cutzlabel.setToolTip(
  965. _(
  966. "Cutting depth (negative)\n"
  967. "below the copper surface."
  968. )
  969. )
  970. self.cutz_entry = FCDoubleSpinner(callback=self.confirmation_message)
  971. self.cutz_entry.set_precision(self.decimals)
  972. if machinist_setting == 0:
  973. self.cutz_entry.set_range(-9999.9999, 0.0000)
  974. else:
  975. self.cutz_entry.set_range(-9999.9999, 9999.9999)
  976. self.cutz_entry.setSingleStep(0.1)
  977. self.grid3.addWidget(self.cutzlabel, 3, 0)
  978. self.grid3.addWidget(self.cutz_entry, 3, 1)
  979. # Multi-pass
  980. self.mpass_cb = FCCheckBox('%s:' % _("Multi-Depth"))
  981. self.mpass_cb.setToolTip(
  982. _(
  983. "Use multiple passes to limit\n"
  984. "the cut depth in each pass. Will\n"
  985. "cut multiple times until Cut Z is\n"
  986. "reached."
  987. )
  988. )
  989. self.maxdepth_entry = FCDoubleSpinner(callback=self.confirmation_message)
  990. self.maxdepth_entry.set_precision(self.decimals)
  991. self.maxdepth_entry.set_range(0, 9999.9999)
  992. self.maxdepth_entry.setSingleStep(0.1)
  993. self.maxdepth_entry.setToolTip(
  994. _(
  995. "Depth of each pass (positive)."
  996. )
  997. )
  998. self.ois_mpass_geo = OptionalInputSection(self.mpass_cb, [self.maxdepth_entry])
  999. self.grid3.addWidget(self.mpass_cb, 4, 0)
  1000. self.grid3.addWidget(self.maxdepth_entry, 4, 1)
  1001. # Travel Z
  1002. self.travelzlabel = QtWidgets.QLabel('%s:' % _('Travel Z'))
  1003. self.travelzlabel.setToolTip(
  1004. _("Height of the tool when\n"
  1005. "moving without cutting.")
  1006. )
  1007. self.travelz_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1008. self.travelz_entry.set_precision(self.decimals)
  1009. if machinist_setting == 0:
  1010. self.travelz_entry.set_range(0.00001, 9999.9999)
  1011. else:
  1012. self.travelz_entry.set_range(-9999.9999, 9999.9999)
  1013. self.travelz_entry.setSingleStep(0.1)
  1014. self.grid3.addWidget(self.travelzlabel, 5, 0)
  1015. self.grid3.addWidget(self.travelz_entry, 5, 1)
  1016. # Feedrate X-Y
  1017. self.frlabel = QtWidgets.QLabel('%s:' % _('Feedrate X-Y'))
  1018. self.frlabel.setToolTip(
  1019. _("Cutting speed in the XY\n"
  1020. "plane in units per minute")
  1021. )
  1022. self.cncfeedrate_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1023. self.cncfeedrate_entry.set_precision(self.decimals)
  1024. self.cncfeedrate_entry.set_range(0, 99999.9999)
  1025. self.cncfeedrate_entry.setSingleStep(0.1)
  1026. self.grid3.addWidget(self.frlabel, 10, 0)
  1027. self.grid3.addWidget(self.cncfeedrate_entry, 10, 1)
  1028. # Feedrate Z (Plunge)
  1029. self.frzlabel = QtWidgets.QLabel('%s:' % _('Feedrate Z'))
  1030. self.frzlabel.setToolTip(
  1031. _("Cutting speed in the XY\n"
  1032. "plane in units per minute.\n"
  1033. "It is called also Plunge.")
  1034. )
  1035. self.feedrate_z_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1036. self.feedrate_z_entry.set_precision(self.decimals)
  1037. self.feedrate_z_entry.set_range(0, 99999.9999)
  1038. self.feedrate_z_entry.setSingleStep(0.1)
  1039. self.grid3.addWidget(self.frzlabel, 11, 0)
  1040. self.grid3.addWidget(self.feedrate_z_entry, 11, 1)
  1041. # Feedrate rapids
  1042. self.fr_rapidlabel = QtWidgets.QLabel('%s:' % _('Feedrate Rapids'))
  1043. self.fr_rapidlabel.setToolTip(
  1044. _("Cutting speed in the XY plane\n"
  1045. "(in units per minute).\n"
  1046. "This is for the rapid move G00.\n"
  1047. "It is useful only for Marlin,\n"
  1048. "ignore for any other cases.")
  1049. )
  1050. self.feedrate_rapid_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1051. self.feedrate_rapid_entry.set_precision(self.decimals)
  1052. self.feedrate_rapid_entry.set_range(0, 99999.9999)
  1053. self.feedrate_rapid_entry.setSingleStep(0.1)
  1054. self.grid3.addWidget(self.fr_rapidlabel, 12, 0)
  1055. self.grid3.addWidget(self.feedrate_rapid_entry, 12, 1)
  1056. # default values is to hide
  1057. self.fr_rapidlabel.hide()
  1058. self.feedrate_rapid_entry.hide()
  1059. # Cut over 1st point in path
  1060. self.extracut_cb = FCCheckBox('%s:' % _('Re-cut'))
  1061. self.extracut_cb.setToolTip(
  1062. _("In order to remove possible\n"
  1063. "copper leftovers where first cut\n"
  1064. "meet with last cut, we generate an\n"
  1065. "extended cut over the first cut section.")
  1066. )
  1067. self.e_cut_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1068. self.e_cut_entry.set_range(0, 99999)
  1069. self.e_cut_entry.set_precision(self.decimals)
  1070. self.e_cut_entry.setSingleStep(0.1)
  1071. self.e_cut_entry.setWrapping(True)
  1072. self.e_cut_entry.setToolTip(
  1073. _("In order to remove possible\n"
  1074. "copper leftovers where first cut\n"
  1075. "meet with last cut, we generate an\n"
  1076. "extended cut over the first cut section.")
  1077. )
  1078. self.grid3.addWidget(self.extracut_cb, 13, 0)
  1079. self.grid3.addWidget(self.e_cut_entry, 13, 1)
  1080. # Spindlespeed
  1081. self.spindle_label = QtWidgets.QLabel('%s:' % _('Spindle speed'))
  1082. self.spindle_label.setToolTip(
  1083. _(
  1084. "Speed of the spindle in RPM (optional).\n"
  1085. "If LASER preprocessor is used,\n"
  1086. "this value is the power of laser."
  1087. )
  1088. )
  1089. self.cncspindlespeed_entry = FCSpinner(callback=self.confirmation_message_int)
  1090. self.cncspindlespeed_entry.set_range(0, 1000000)
  1091. self.cncspindlespeed_entry.set_step(100)
  1092. self.grid3.addWidget(self.spindle_label, 14, 0)
  1093. self.grid3.addWidget(self.cncspindlespeed_entry, 14, 1)
  1094. # Dwell
  1095. self.dwell_cb = FCCheckBox('%s:' % _('Dwell'))
  1096. self.dwell_cb.setToolTip(
  1097. _(
  1098. "Pause to allow the spindle to reach its\n"
  1099. "speed before cutting."
  1100. )
  1101. )
  1102. self.dwelltime_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1103. self.dwelltime_entry.set_precision(self.decimals)
  1104. self.dwelltime_entry.set_range(0, 9999.9999)
  1105. self.dwelltime_entry.setSingleStep(0.1)
  1106. self.dwelltime_entry.setToolTip(
  1107. _("Number of time units for spindle to dwell.")
  1108. )
  1109. self.ois_dwell_geo = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  1110. self.grid3.addWidget(self.dwell_cb, 15, 0)
  1111. self.grid3.addWidget(self.dwelltime_entry, 15, 1)
  1112. # Probe depth
  1113. self.pdepth_label = QtWidgets.QLabel('%s:' % _("Probe Z depth"))
  1114. self.pdepth_label.setToolTip(
  1115. _("The maximum depth that the probe is allowed\n"
  1116. "to probe. Negative value, in current units.")
  1117. )
  1118. self.pdepth_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1119. self.pdepth_entry.set_precision(self.decimals)
  1120. self.pdepth_entry.set_range(-9999.9999, 9999.9999)
  1121. self.pdepth_entry.setSingleStep(0.1)
  1122. self.grid3.addWidget(self.pdepth_label, 17, 0)
  1123. self.grid3.addWidget(self.pdepth_entry, 17, 1)
  1124. self.pdepth_label.hide()
  1125. self.pdepth_entry.setVisible(False)
  1126. # Probe feedrate
  1127. self.feedrate_probe_label = QtWidgets.QLabel('%s:' % _("Feedrate Probe"))
  1128. self.feedrate_probe_label.setToolTip(
  1129. _("The feedrate used while the probe is probing.")
  1130. )
  1131. self.feedrate_probe_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1132. self.feedrate_probe_entry.set_precision(self.decimals)
  1133. self.feedrate_probe_entry.set_range(0.0, 9999.9999)
  1134. self.feedrate_probe_entry.setSingleStep(0.1)
  1135. self.grid3.addWidget(self.feedrate_probe_label, 18, 0)
  1136. self.grid3.addWidget(self.feedrate_probe_entry, 18, 1)
  1137. self.feedrate_probe_label.hide()
  1138. self.feedrate_probe_entry.setVisible(False)
  1139. # #################################################################
  1140. # ################# GRID LAYOUT 4 ###############################
  1141. # #################################################################
  1142. self.grid4 = QtWidgets.QGridLayout()
  1143. self.grid4.setColumnStretch(0, 0)
  1144. self.grid4.setColumnStretch(1, 1)
  1145. self.geo_param_box.addLayout(self.grid4)
  1146. separator_line2 = QtWidgets.QFrame()
  1147. separator_line2.setFrameShape(QtWidgets.QFrame.HLine)
  1148. separator_line2.setFrameShadow(QtWidgets.QFrame.Sunken)
  1149. self.grid4.addWidget(separator_line2, 0, 0, 1, 2)
  1150. self.apply_param_to_all = FCButton(_("Apply parameters to all tools"))
  1151. self.apply_param_to_all.setIcon(QtGui.QIcon(self.app.resource_location + '/param_all32.png'))
  1152. self.apply_param_to_all.setToolTip(
  1153. _("The parameters in the current form will be applied\n"
  1154. "on all the tools from the Tool Table.")
  1155. )
  1156. self.grid4.addWidget(self.apply_param_to_all, 1, 0, 1, 2)
  1157. separator_line2 = QtWidgets.QFrame()
  1158. separator_line2.setFrameShape(QtWidgets.QFrame.HLine)
  1159. separator_line2.setFrameShadow(QtWidgets.QFrame.Sunken)
  1160. self.grid4.addWidget(separator_line2, 2, 0, 1, 2)
  1161. # General Parameters
  1162. self.gen_param_label = QtWidgets.QLabel('<b>%s</b>' % _("Common Parameters"))
  1163. self.gen_param_label.setToolTip(
  1164. _("Parameters that are common for all tools.")
  1165. )
  1166. self.grid4.addWidget(self.gen_param_label, 3, 0, 1, 2)
  1167. # Tool change Z
  1168. self.toolchangeg_cb = FCCheckBox('%s:' % _("Tool change Z"))
  1169. self.toolchangeg_cb.setToolTip(
  1170. _(
  1171. "Include tool-change sequence\n"
  1172. "in the Machine Code (Pause for tool change)."
  1173. )
  1174. )
  1175. self.toolchangez_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1176. self.toolchangez_entry.set_precision(self.decimals)
  1177. self.toolchangez_entry.setToolTip(
  1178. _(
  1179. "Z-axis position (height) for\n"
  1180. "tool change."
  1181. )
  1182. )
  1183. if machinist_setting == 0:
  1184. self.toolchangez_entry.set_range(0, 9999.9999)
  1185. else:
  1186. self.toolchangez_entry.set_range(-9999.9999, 9999.9999)
  1187. self.toolchangez_entry.setSingleStep(0.1)
  1188. self.ois_tcz_geo = OptionalInputSection(self.toolchangeg_cb, [self.toolchangez_entry])
  1189. self.grid4.addWidget(self.toolchangeg_cb, 6, 0)
  1190. self.grid4.addWidget(self.toolchangez_entry, 6, 1)
  1191. # The Z value for the start move
  1192. # startzlabel = QtWidgets.QLabel('Start move Z:')
  1193. # startzlabel.setToolTip(
  1194. # "Tool height just before starting the work.\n"
  1195. # "Delete the value if you don't need this feature."
  1196. #
  1197. # )
  1198. # grid3.addWidget(startzlabel, 8, 0)
  1199. # self.gstartz_entry = FloatEntry()
  1200. # grid3.addWidget(self.gstartz_entry, 8, 1)
  1201. # The Z value for the end move
  1202. self.endz_label = QtWidgets.QLabel('%s:' % _('End move Z'))
  1203. self.endz_label.setToolTip(
  1204. _("Height of the tool after\n"
  1205. "the last move at the end of the job.")
  1206. )
  1207. self.endz_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1208. self.endz_entry.set_precision(self.decimals)
  1209. if machinist_setting == 0:
  1210. self.endz_entry.set_range(0, 9999.9999)
  1211. else:
  1212. self.endz_entry.set_range(-9999.9999, 9999.9999)
  1213. self.endz_entry.setSingleStep(0.1)
  1214. self.grid4.addWidget(self.endz_label, 9, 0)
  1215. self.grid4.addWidget(self.endz_entry, 9, 1)
  1216. # End Move X,Y
  1217. endmove_xy_label = QtWidgets.QLabel('%s:' % _('End move X,Y'))
  1218. endmove_xy_label.setToolTip(
  1219. _("End move X,Y position. In format (x,y).\n"
  1220. "If no value is entered then there is no move\n"
  1221. "on X,Y plane at the end of the job.")
  1222. )
  1223. self.endxy_entry = NumericalEvalTupleEntry(border_color='#0069A9')
  1224. self.endxy_entry.setPlaceholderText(_("X,Y coordinates"))
  1225. self.grid4.addWidget(endmove_xy_label, 10, 0)
  1226. self.grid4.addWidget(self.endxy_entry, 10, 1)
  1227. # preprocessor selection
  1228. pp_label = QtWidgets.QLabel('%s:' % _("Preprocessor"))
  1229. pp_label.setToolTip(
  1230. _("The Preprocessor file that dictates\n"
  1231. "the Machine Code (like GCode, RML, HPGL) output.")
  1232. )
  1233. self.pp_geometry_name_cb = FCComboBox()
  1234. self.pp_geometry_name_cb.setFocusPolicy(QtCore.Qt.StrongFocus)
  1235. self.grid4.addWidget(pp_label, 11, 0)
  1236. self.grid4.addWidget(self.pp_geometry_name_cb, 11, 1)
  1237. # self.grid4.addWidget(QtWidgets.QLabel(''), 12, 0, 1, 2)
  1238. # ------------------------------------------------------------------------------------------------------------
  1239. # ------------------------- EXCLUSION AREAS ------------------------------------------------------------------
  1240. # ------------------------------------------------------------------------------------------------------------
  1241. # Exclusion Areas
  1242. self.exclusion_cb = FCCheckBox('%s' % _("Add exclusion areas"))
  1243. self.exclusion_cb.setToolTip(
  1244. _(
  1245. "Include exclusion areas.\n"
  1246. "In those areas the travel of the tools\n"
  1247. "is forbidden."
  1248. )
  1249. )
  1250. self.grid4.addWidget(self.exclusion_cb, 12, 0, 1, 2)
  1251. self.exclusion_frame = QtWidgets.QFrame()
  1252. self.exclusion_frame.setContentsMargins(0, 0, 0, 0)
  1253. self.grid4.addWidget(self.exclusion_frame, 14, 0, 1, 2)
  1254. self.exclusion_box = QtWidgets.QVBoxLayout()
  1255. self.exclusion_box.setContentsMargins(0, 0, 0, 0)
  1256. self.exclusion_frame.setLayout(self.exclusion_box)
  1257. self.exclusion_table = FCTable()
  1258. self.exclusion_box.addWidget(self.exclusion_table)
  1259. self.exclusion_table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
  1260. self.exclusion_table.setColumnCount(4)
  1261. self.exclusion_table.setColumnWidth(0, 20)
  1262. self.exclusion_table.setHorizontalHeaderLabels(['#', _('Object'), _('Strategy'), _('Over Z')])
  1263. self.exclusion_table.horizontalHeaderItem(0).setToolTip(_("This is the Area ID."))
  1264. self.exclusion_table.horizontalHeaderItem(1).setToolTip(
  1265. _("Type of the object where the exclusion area was added."))
  1266. self.exclusion_table.horizontalHeaderItem(2).setToolTip(
  1267. _("The strategy used for exclusion area. Go around the exclusion areas or over it."))
  1268. self.exclusion_table.horizontalHeaderItem(3).setToolTip(
  1269. _("If the strategy is to go over the area then this is the height at which the tool will go to avoid the "
  1270. "exclusion area."))
  1271. self.exclusion_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
  1272. grid_a1 = QtWidgets.QGridLayout()
  1273. grid_a1.setColumnStretch(0, 0)
  1274. grid_a1.setColumnStretch(1, 1)
  1275. self.exclusion_box.addLayout(grid_a1)
  1276. # Chose Strategy
  1277. self.strategy_label = FCLabel('%s:' % _("Strategy"))
  1278. self.strategy_label.setToolTip(_("The strategy followed when encountering an exclusion area.\n"
  1279. "Can be:\n"
  1280. "- Over -> when encountering the area, the tool will go to a set height\n"
  1281. "- Around -> will avoid the exclusion area by going around the area"))
  1282. self.strategy_radio = RadioSet([{'label': _('Over'), 'value': 'over'},
  1283. {'label': _('Around'), 'value': 'around'}])
  1284. grid_a1.addWidget(self.strategy_label, 1, 0)
  1285. grid_a1.addWidget(self.strategy_radio, 1, 1)
  1286. # Over Z
  1287. self.over_z_label = FCLabel('%s:' % _("Over Z"))
  1288. self.over_z_label.setToolTip(_("The height Z to which the tool will rise in order to avoid\n"
  1289. "an interdiction area."))
  1290. self.over_z_entry = FCDoubleSpinner()
  1291. self.over_z_entry.set_range(0.000, 9999.9999)
  1292. self.over_z_entry.set_precision(self.decimals)
  1293. grid_a1.addWidget(self.over_z_label, 2, 0)
  1294. grid_a1.addWidget(self.over_z_entry, 2, 1)
  1295. # Button Add Area
  1296. self.add_area_button = QtWidgets.QPushButton(_('Add area:'))
  1297. self.add_area_button.setToolTip(_("Add an Exclusion Area."))
  1298. # Area Selection shape
  1299. self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
  1300. {'label': _("Polygon"), 'value': 'polygon'}])
  1301. self.area_shape_radio.setToolTip(
  1302. _("The kind of selection shape used for area selection.")
  1303. )
  1304. grid_a1.addWidget(self.add_area_button, 4, 0)
  1305. grid_a1.addWidget(self.area_shape_radio, 4, 1)
  1306. h_lay_1 = QtWidgets.QHBoxLayout()
  1307. self.exclusion_box.addLayout(h_lay_1)
  1308. # Button Delete All Areas
  1309. self.delete_area_button = QtWidgets.QPushButton(_('Delete All'))
  1310. self.delete_area_button.setToolTip(_("Delete all exclusion areas."))
  1311. # Button Delete Selected Areas
  1312. self.delete_sel_area_button = QtWidgets.QPushButton(_('Delete Selected'))
  1313. self.delete_sel_area_button.setToolTip(_("Delete all exclusion areas that are selected in the table."))
  1314. h_lay_1.addWidget(self.delete_area_button)
  1315. h_lay_1.addWidget(self.delete_sel_area_button)
  1316. self.ois_exclusion_geo = OptionalHideInputSection(self.exclusion_cb, [self.exclusion_frame])
  1317. # -------------------------- EXCLUSION AREAS END -------------------------------------------------------------
  1318. # ------------------------------------------------------------------------------------------------------------
  1319. # Add Polish
  1320. self.polish_cb = FCCheckBox(label=_('Add Polish'))
  1321. self.polish_cb.setToolTip(_(
  1322. "Will add a Paint section at the end of the GCode.\n"
  1323. "A metallic brush will clean the material after milling."))
  1324. self.polish_cb.setObjectName("g_polish")
  1325. self.grid4.addWidget(self.polish_cb, 15, 0, 1, 2)
  1326. # Polish Tool Diameter
  1327. self.polish_dia_lbl = QtWidgets.QLabel('%s:' % _('Tool Dia'))
  1328. self.polish_dia_lbl.setToolTip(
  1329. _("Diameter for the polishing tool.")
  1330. )
  1331. self.polish_dia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1332. self.polish_dia_entry.set_precision(self.decimals)
  1333. self.polish_dia_entry.set_range(0.000, 9999.9999)
  1334. self.polish_dia_entry.setObjectName("g_polish_dia")
  1335. self.grid4.addWidget(self.polish_dia_lbl, 16, 0)
  1336. self.grid4.addWidget(self.polish_dia_entry, 16, 1)
  1337. # Polish Pressure
  1338. self.polish_pressure_lbl = QtWidgets.QLabel('%s:' % _('Pressure'))
  1339. self.polish_pressure_lbl.setToolTip(
  1340. _("Negative value. The higher the absolute value\n"
  1341. "the stronger the pressure of the brush on the material.")
  1342. )
  1343. self.polish_pressure_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1344. self.polish_pressure_entry.set_precision(self.decimals)
  1345. self.polish_pressure_entry.set_range(-9999.9999, 9999.9999)
  1346. self.polish_pressure_entry.setObjectName("g_polish_pressure")
  1347. self.grid4.addWidget(self.polish_pressure_lbl, 17, 0)
  1348. self.grid4.addWidget(self.polish_pressure_entry, 17, 1)
  1349. # Polish Overlap
  1350. self.polish_over_lbl = QtWidgets.QLabel('%s:' % _('Overlap'))
  1351. self.polish_over_lbl.setToolTip(
  1352. _("How much (percentage) of the tool width to overlap each tool pass.")
  1353. )
  1354. self.polish_over_entry = FCDoubleSpinner(suffix='%', callback=self.confirmation_message)
  1355. self.polish_over_entry.set_precision(self.decimals)
  1356. self.polish_over_entry.setWrapping(True)
  1357. self.polish_over_entry.set_range(0.0000, 99.9999)
  1358. self.polish_over_entry.setSingleStep(0.1)
  1359. self.polish_over_entry.setObjectName("g_polish_overlap")
  1360. self.grid4.addWidget(self.polish_over_lbl, 18, 0)
  1361. self.grid4.addWidget(self.polish_over_entry, 18, 1)
  1362. # Polish Method
  1363. self.polish_method_lbl = QtWidgets.QLabel('%s:' % _('Method'))
  1364. self.polish_method_lbl.setToolTip(
  1365. _("Algorithm for polishing:\n"
  1366. "- Standard: Fixed step inwards.\n"
  1367. "- Seed-based: Outwards from seed.\n"
  1368. "- Line-based: Parallel lines.")
  1369. )
  1370. self.polish_method_combo = FCComboBox()
  1371. self.polish_method_combo.addItems(
  1372. [_("Standard"), _("Seed"), _("Lines")]
  1373. )
  1374. self.polish_method_combo.setObjectName('g_polish_method')
  1375. self.grid4.addWidget(self.polish_method_lbl, 20, 0)
  1376. self.grid4.addWidget(self.polish_method_combo, 20, 1)
  1377. self.polish_dia_lbl.hide()
  1378. self.polish_dia_entry.hide()
  1379. self.polish_pressure_lbl.hide()
  1380. self.polish_pressure_entry.hide()
  1381. self.polish_over_lbl.hide()
  1382. self.polish_over_entry.hide()
  1383. self.polish_method_lbl.hide()
  1384. self.polish_method_combo.hide()
  1385. self.ois_polish = OptionalHideInputSection(
  1386. self.polish_cb,
  1387. [
  1388. self.polish_dia_lbl,
  1389. self.polish_dia_entry,
  1390. self.polish_pressure_lbl,
  1391. self.polish_pressure_entry,
  1392. self.polish_over_lbl,
  1393. self.polish_over_entry,
  1394. self.polish_method_lbl,
  1395. self.polish_method_combo
  1396. ]
  1397. )
  1398. separator_line2 = QtWidgets.QFrame()
  1399. separator_line2.setFrameShape(QtWidgets.QFrame.HLine)
  1400. separator_line2.setFrameShadow(QtWidgets.QFrame.Sunken)
  1401. self.grid4.addWidget(separator_line2, 22, 0, 1, 2)
  1402. # Button
  1403. self.generate_cnc_button = QtWidgets.QPushButton(_('Generate CNCJob object'))
  1404. self.generate_cnc_button.setIcon(QtGui.QIcon(self.app.resource_location + '/cnc16.png'))
  1405. self.generate_cnc_button.setToolTip('%s\n%s' % (
  1406. _("Generate CNCJob object."),
  1407. _(
  1408. "Add / Select at least one tool in the tool-table.\n"
  1409. "Click the # header to select all, or Ctrl + LMB\n"
  1410. "for custom selection of tools.")))
  1411. self.generate_cnc_button.setStyleSheet("""
  1412. QPushButton
  1413. {
  1414. font-weight: bold;
  1415. }
  1416. """)
  1417. self.grid4.addWidget(self.generate_cnc_button, 24, 0, 1, 2)
  1418. self.grid4.addWidget(QtWidgets.QLabel(''), 26, 0, 1, 2)
  1419. # ##############
  1420. # Paint area ##
  1421. # ##############
  1422. self.tools_label = QtWidgets.QLabel('<b>%s</b>' % _('TOOLS'))
  1423. self.tools_label.setToolTip(
  1424. _("Launch Paint Tool in Tools Tab.")
  1425. )
  1426. self.grid4.addWidget(self.tools_label, 28, 0, 1, 2)
  1427. # Paint Button
  1428. self.paint_tool_button = QtWidgets.QPushButton(_('Paint Tool'))
  1429. self.paint_tool_button.setIcon(QtGui.QIcon(self.app.resource_location + '/paint20_1.png'))
  1430. self.paint_tool_button.setToolTip(
  1431. _(
  1432. "Creates tool paths to cover the\n"
  1433. "whole area of a polygon (remove\n"
  1434. "all copper). You will be asked\n"
  1435. "to click on the desired polygon."
  1436. )
  1437. )
  1438. self.paint_tool_button.setStyleSheet("""
  1439. QPushButton
  1440. {
  1441. font-weight: bold;
  1442. }
  1443. """)
  1444. self.grid4.addWidget(self.paint_tool_button, 30, 0, 1, 2)
  1445. # NCC Tool
  1446. self.generate_ncc_button = QtWidgets.QPushButton(_('NCC Tool'))
  1447. self.generate_ncc_button.setIcon(QtGui.QIcon(self.app.resource_location + '/eraser26.png'))
  1448. self.generate_ncc_button.setToolTip(
  1449. _("Create the Geometry Object\n"
  1450. "for non-copper routing.")
  1451. )
  1452. self.generate_ncc_button.setStyleSheet("""
  1453. QPushButton
  1454. {
  1455. font-weight: bold;
  1456. }
  1457. """)
  1458. self.grid4.addWidget(self.generate_ncc_button, 32, 0, 1, 2)
  1459. class CNCObjectUI(ObjectUI):
  1460. """
  1461. User interface for CNCJob objects.
  1462. """
  1463. def __init__(self, app, parent=None):
  1464. """
  1465. Creates the user interface for CNCJob objects. GUI elements should
  1466. be placed in ``self.custom_box`` to preserve the layout.
  1467. """
  1468. self.decimals = app.decimals
  1469. self.app = app
  1470. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  1471. if theme_settings.contains("theme"):
  1472. theme = theme_settings.value('theme', type=str)
  1473. else:
  1474. theme = 'white'
  1475. if theme == 'white':
  1476. self.resource_loc = 'assets/resources'
  1477. else:
  1478. self.resource_loc = 'assets/resources'
  1479. ObjectUI.__init__(
  1480. self, title=_('CNC Job Object'),
  1481. icon_file=self.resource_loc + '/cnc32.png', parent=parent,
  1482. app=self.app)
  1483. for i in range(0, self.common_grid.count()):
  1484. self.common_grid.itemAt(i).widget().hide()
  1485. f_lay = QtWidgets.QGridLayout()
  1486. f_lay.setColumnStretch(0, 0)
  1487. f_lay.setColumnStretch(1, 1)
  1488. self.custom_box.addLayout(f_lay)
  1489. # Plot Options
  1490. self.cncplot_method_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  1491. self.cncplot_method_label.setToolTip(
  1492. _(
  1493. "This selects the kind of geometries on the canvas to plot.\n"
  1494. "Those can be either of type 'Travel' which means the moves\n"
  1495. "above the work piece or it can be of type 'Cut',\n"
  1496. "which means the moves that cut into the material."
  1497. )
  1498. )
  1499. self.cncplot_method_combo = RadioSet([
  1500. {"label": _("All"), "value": "all"},
  1501. {"label": _("Travel"), "value": "travel"},
  1502. {"label": _("Cut"), "value": "cut"}
  1503. ], stretch=False)
  1504. f_lay.addWidget(self.cncplot_method_label, 0, 0)
  1505. f_lay.addWidget(self.cncplot_method_combo, 0, 1, 1, 2)
  1506. self.name_hlay = QtWidgets.QHBoxLayout()
  1507. f_lay.addLayout(self.name_hlay, 2, 0, 1, 3)
  1508. # ## Object name
  1509. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  1510. self.name_entry = FCEntry()
  1511. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  1512. self.name_hlay.addWidget(name_label)
  1513. self.name_hlay.addWidget(self.name_entry)
  1514. # Editor
  1515. self.editor_button = FCButton(_('GCode Editor'))
  1516. self.editor_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
  1517. self.editor_button.setToolTip(
  1518. _("Edit an GCode object.")
  1519. )
  1520. self.editor_button.setStyleSheet("""
  1521. QPushButton
  1522. {
  1523. font-weight: bold;
  1524. }
  1525. """)
  1526. f_lay.addWidget(self.editor_button, 4, 0, 1, 3)
  1527. # PROPERTIES CB
  1528. self.properties_lbl = FCLabel('<b>%s</b>:' % _("PROPERTIES"))
  1529. self.properties_lbl.setToolTip(_("Show the Properties."))
  1530. self.properties_cb = FCCheckBox()
  1531. f_lay.addWidget(self.properties_lbl, 6, 0)
  1532. f_lay.addWidget(self.properties_cb, 6, 1, 1, 2)
  1533. # PROPERTIES Frame
  1534. self.properties_frame = QtWidgets.QFrame()
  1535. self.properties_frame.setContentsMargins(0, 0, 0, 0)
  1536. f_lay.addWidget(self.properties_frame, 7, 0, 1, 3)
  1537. self.properties_box = QtWidgets.QVBoxLayout()
  1538. self.properties_box.setContentsMargins(0, 0, 0, 0)
  1539. self.properties_frame.setLayout(self.properties_box)
  1540. self.properties_frame.hide()
  1541. self.treeWidget = FCTree(columns=2)
  1542. self.properties_box.addWidget(self.treeWidget)
  1543. self.properties_box.setStretch(0, 0)
  1544. # Annotation
  1545. self.annotation_cb = FCCheckBox(_("Display Annotation"))
  1546. self.annotation_cb.setToolTip(
  1547. _("This selects if to display text annotation on the plot.\n"
  1548. "When checked it will display numbers in order for each end\n"
  1549. "of a travel line.")
  1550. )
  1551. f_lay.addWidget(self.annotation_cb, 8, 0, 1, 3)
  1552. separator_line = QtWidgets.QFrame()
  1553. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  1554. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  1555. f_lay.addWidget(separator_line, 10, 0, 1, 3)
  1556. # Travelled Distance
  1557. self.t_distance_label = QtWidgets.QLabel("<b>%s:</b>" % _("Travelled distance"))
  1558. self.t_distance_label.setToolTip(
  1559. _("This is the total travelled distance on X-Y plane.\n"
  1560. "In current units.")
  1561. )
  1562. self.t_distance_entry = FCEntry()
  1563. self.units_label = QtWidgets.QLabel()
  1564. f_lay.addWidget(self.t_distance_label, 12, 0)
  1565. f_lay.addWidget(self.t_distance_entry, 12, 1)
  1566. f_lay.addWidget(self.units_label, 12, 2)
  1567. # Estimated Time
  1568. self.t_time_label = QtWidgets.QLabel("<b>%s:</b>" % _("Estimated time"))
  1569. self.t_time_label.setToolTip(
  1570. _("This is the estimated time to do the routing/drilling,\n"
  1571. "without the time spent in ToolChange events.")
  1572. )
  1573. self.t_time_entry = FCEntry()
  1574. self.units_time_label = QtWidgets.QLabel()
  1575. f_lay.addWidget(self.t_time_label, 14, 0)
  1576. f_lay.addWidget(self.t_time_entry, 14, 1)
  1577. f_lay.addWidget(self.units_time_label, 14, 2)
  1578. self.t_distance_label.hide()
  1579. self.t_distance_entry.setVisible(False)
  1580. self.t_time_label.hide()
  1581. self.t_time_entry.setVisible(False)
  1582. separator_line = QtWidgets.QFrame()
  1583. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  1584. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  1585. f_lay.addWidget(separator_line, 16, 0, 1, 3)
  1586. hlay = QtWidgets.QHBoxLayout()
  1587. self.custom_box.addLayout(hlay)
  1588. # CNC Tools Table for plot
  1589. self.cnc_tools_table_label = QtWidgets.QLabel('<b>%s</b>' % _('CNC Tools Table'))
  1590. self.cnc_tools_table_label.setToolTip(
  1591. _(
  1592. "Tools in this CNCJob object used for cutting.\n"
  1593. "The tool diameter is used for plotting on canvas.\n"
  1594. "The 'Offset' entry will set an offset for the cut.\n"
  1595. "'Offset' can be inside, outside, on path (none) and custom.\n"
  1596. "'Type' entry is only informative and it allow to know the \n"
  1597. "intent of using the current tool. \n"
  1598. "It can be Rough(ing), Finish(ing) or Iso(lation).\n"
  1599. "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n"
  1600. "ball(B), or V-Shaped(V)."
  1601. )
  1602. )
  1603. hlay.addWidget(self.cnc_tools_table_label)
  1604. # Plot CB
  1605. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  1606. self.plot_cb = FCCheckBox(_('Plot Object'))
  1607. self.plot_cb.setToolTip(
  1608. _("Plot (show) this object.")
  1609. )
  1610. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  1611. hlay.addStretch()
  1612. hlay.addWidget(self.plot_cb)
  1613. self.cnc_tools_table = FCTable()
  1614. self.custom_box.addWidget(self.cnc_tools_table)
  1615. self.cnc_tools_table.setColumnCount(7)
  1616. self.cnc_tools_table.setColumnWidth(0, 20)
  1617. self.cnc_tools_table.setHorizontalHeaderLabels(['#', _('Dia'), _('Offset'), _('Type'), _('TT'), '', _('P')])
  1618. self.cnc_tools_table.setColumnHidden(5, True)
  1619. # stylesheet = "::section{Background-color:rgb(239,239,245)}"
  1620. # self.cnc_tools_table.horizontalHeader().setStyleSheet(stylesheet)
  1621. self.exc_cnc_tools_table = FCTable()
  1622. self.custom_box.addWidget(self.exc_cnc_tools_table)
  1623. self.exc_cnc_tools_table.setColumnCount(7)
  1624. self.exc_cnc_tools_table.setColumnWidth(0, 20)
  1625. self.exc_cnc_tools_table.setHorizontalHeaderLabels(['#', _('Dia'), _('Drills'), _('Slots'), '', _("Cut Z"),
  1626. _('P')])
  1627. self.exc_cnc_tools_table.setColumnHidden(4, True)
  1628. self.tooldia_entry = FCDoubleSpinner(callback=self.confirmation_message)
  1629. self.tooldia_entry.set_range(0, 9999.9999)
  1630. self.tooldia_entry.set_precision(self.decimals)
  1631. self.tooldia_entry.setSingleStep(0.1)
  1632. self.custom_box.addWidget(self.tooldia_entry)
  1633. # Update plot button
  1634. self.updateplot_button = QtWidgets.QPushButton(_('Update Plot'))
  1635. self.updateplot_button.setToolTip(
  1636. _("Update the plot.")
  1637. )
  1638. self.custom_box.addWidget(self.updateplot_button)
  1639. separator_line = QtWidgets.QFrame()
  1640. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  1641. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  1642. self.custom_box.addWidget(separator_line)
  1643. # CNC Code snippets
  1644. self.snippets_cb = FCCheckBox(_("Use CNC Code Snippets"))
  1645. self.snippets_cb.setToolTip(
  1646. _("When selected, it will include CNC Code snippets (append and prepend)\n"
  1647. "defined in the Preferences.")
  1648. )
  1649. self.custom_box.addWidget(self.snippets_cb)
  1650. # Autolevelling
  1651. self.sal_cb = FCCheckBox(_("Autolevelling"))
  1652. self.sal_cb.setToolTip(
  1653. _("Enable the autolevelling feature.")
  1654. )
  1655. self.custom_box.addWidget(self.sal_cb)
  1656. self.al_frame = QtWidgets.QFrame()
  1657. self.al_frame.setContentsMargins(0, 0, 0, 0)
  1658. self.custom_box.addWidget(self.al_frame)
  1659. self.al_box = QtWidgets.QVBoxLayout()
  1660. self.al_box.setContentsMargins(0, 0, 0, 0)
  1661. self.al_frame.setLayout(self.al_box)
  1662. grid0 = QtWidgets.QGridLayout()
  1663. grid0.setColumnStretch(0, 0)
  1664. grid0.setColumnStretch(1, 1)
  1665. self.al_box.addLayout(grid0)
  1666. al_title = FCLabel('<b>%s</b>' % _("Probe Points Table"))
  1667. al_title.setToolTip(_("Generate GCode that will obtain the height map"))
  1668. self.show_al_table = FCCheckBox(_("Show"))
  1669. self.show_al_table.setToolTip(_("Toggle the display of the Probe Points table."))
  1670. self.show_al_table.setChecked(True)
  1671. hor_lay = QtWidgets.QHBoxLayout()
  1672. hor_lay.addWidget(al_title)
  1673. hor_lay.addStretch()
  1674. hor_lay.addWidget(self.show_al_table, alignment=QtCore.Qt.AlignRight)
  1675. grid0.addLayout(hor_lay, 0, 0, 1, 2)
  1676. self.al_probe_points_table = FCTable()
  1677. self.al_probe_points_table.setColumnCount(3)
  1678. self.al_probe_points_table.setColumnWidth(0, 20)
  1679. self.al_probe_points_table.setHorizontalHeaderLabels(['#', _('X-Y Coordinates'), _('Height')])
  1680. grid0.addWidget(self.al_probe_points_table, 1, 0, 1, 2)
  1681. self.plot_probing_pts_cb = FCCheckBox(_("Plot probing points"))
  1682. self.plot_probing_pts_cb.setToolTip(
  1683. _("Plot the probing points in the table.\n"
  1684. "If a Voronoi method is used then\n"
  1685. "the Voronoi areas are also plotted.")
  1686. )
  1687. grid0.addWidget(self.plot_probing_pts_cb, 3, 0, 1, 2)
  1688. separator_line = QtWidgets.QFrame()
  1689. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  1690. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  1691. grid0.addWidget(separator_line, 5, 0, 1, 2)
  1692. # #############################################################################################################
  1693. # ############### Probe GCode Generation ######################################################################
  1694. # #############################################################################################################
  1695. self.probe_gc_label = FCLabel('<b>%s</b>:' % _("Probe GCode Generation"))
  1696. self.probe_gc_label.setToolTip(
  1697. _("Will create a GCode which will be sent to the controller,\n"
  1698. "either through a file or directly, with the intent to get the height map\n"
  1699. "that is to modify the original GCode to level the cutting height.")
  1700. )
  1701. grid0.addWidget(self.probe_gc_label, 7, 0, 1, 2)
  1702. # Travel Z Probe
  1703. self.ptravelz_label = QtWidgets.QLabel('%s:' % _("Probe Z travel"))
  1704. self.ptravelz_label.setToolTip(
  1705. _("The safe Z for probe travelling between probe points.")
  1706. )
  1707. self.ptravelz_entry = FCDoubleSpinner()
  1708. self.ptravelz_entry.set_precision(self.decimals)
  1709. self.ptravelz_entry.set_range(0.0000, 9999.9999)
  1710. grid0.addWidget(self.ptravelz_label, 9, 0)
  1711. grid0.addWidget(self.ptravelz_entry, 9, 1)
  1712. # Probe depth
  1713. self.pdepth_label = QtWidgets.QLabel('%s:' % _("Probe Z depth"))
  1714. self.pdepth_label.setToolTip(
  1715. _("The maximum depth that the probe is allowed\n"
  1716. "to probe. Negative value, in current units.")
  1717. )
  1718. self.pdepth_entry = FCDoubleSpinner()
  1719. self.pdepth_entry.set_precision(self.decimals)
  1720. self.pdepth_entry.set_range(-99999.9999, 0.0000)
  1721. grid0.addWidget(self.pdepth_label, 11, 0)
  1722. grid0.addWidget(self.pdepth_entry, 11, 1)
  1723. # Probe feedrate
  1724. self.feedrate_probe_label = QtWidgets.QLabel('%s:' % _("Probe Feedrate"))
  1725. self.feedrate_probe_label.setToolTip(
  1726. _("The feedrate used while the probe is probing.")
  1727. )
  1728. self.feedrate_probe_entry = FCDoubleSpinner()
  1729. self.feedrate_probe_entry.set_precision(self.decimals)
  1730. self.feedrate_probe_entry.set_range(0, 99999.9999)
  1731. grid0.addWidget(self.feedrate_probe_label, 13, 0)
  1732. grid0.addWidget(self.feedrate_probe_entry, 13, 1)
  1733. separator_line = QtWidgets.QFrame()
  1734. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  1735. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  1736. grid0.addWidget(separator_line, 15, 0, 1, 2)
  1737. # AUTOLEVELL MODE
  1738. al_mode_lbl = FCLabel('<b>%s</b>:' % _("Mode"))
  1739. al_mode_lbl.setToolTip(_("Choose a mode for height map generation.\n"
  1740. "- Manual: will pick a selection of probe points by clicking on canvas\n"
  1741. "- Grid: will automatically generate a grid of probe points"))
  1742. self.al_mode_radio = RadioSet(
  1743. [
  1744. {'label': _('Manual'), 'value': 'manual'},
  1745. {'label': _('Grid'), 'value': 'grid'}
  1746. ])
  1747. grid0.addWidget(al_mode_lbl, 16, 0)
  1748. grid0.addWidget(self.al_mode_radio, 16, 1)
  1749. # AUTOLEVELL METHOD
  1750. self.al_method_lbl = FCLabel('%s:' % _("Method"))
  1751. self.al_method_lbl.setToolTip(_("Choose a method for approximation of heights from autolevelling data.\n"
  1752. "- Voronoi: will generate a Voronoi diagram\n"
  1753. "- Bilinear: will use bilinear interpolation. Usable only for grid mode."))
  1754. self.al_method_radio = RadioSet(
  1755. [
  1756. {'label': _('Voronoi'), 'value': 'v'},
  1757. {'label': _('Bilinear'), 'value': 'b'}
  1758. ])
  1759. self.al_method_lbl.setDisabled(True)
  1760. self.al_method_radio.setDisabled(True)
  1761. self.al_method_radio.set_value('v')
  1762. grid0.addWidget(self.al_method_lbl, 17, 0)
  1763. grid0.addWidget(self.al_method_radio, 17, 1)
  1764. # ## Columns
  1765. self.al_columns_entry = FCSpinner()
  1766. self.al_columns_entry.setMinimum(2)
  1767. self.al_columns_label = QtWidgets.QLabel('%s:' % _("Columns"))
  1768. self.al_columns_label.setToolTip(
  1769. _("The number of grid columns.")
  1770. )
  1771. grid0.addWidget(self.al_columns_label, 19, 0)
  1772. grid0.addWidget(self.al_columns_entry, 19, 1)
  1773. # ## Rows
  1774. self.al_rows_entry = FCSpinner()
  1775. self.al_rows_entry.setMinimum(2)
  1776. self.al_rows_label = QtWidgets.QLabel('%s:' % _("Rows"))
  1777. self.al_rows_label.setToolTip(
  1778. _("The number of gird rows.")
  1779. )
  1780. grid0.addWidget(self.al_rows_label, 21, 0)
  1781. grid0.addWidget(self.al_rows_entry, 21, 1)
  1782. self.al_add_button = FCButton(_("Add Probe Points"))
  1783. grid0.addWidget(self.al_add_button, 23, 0, 1, 2)
  1784. separator_line = QtWidgets.QFrame()
  1785. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  1786. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  1787. grid0.addWidget(separator_line, 25, 0, 1, 2)
  1788. self.al_controller_label = FCLabel('<b>%s</b>:' % _("Controller"))
  1789. self.al_controller_label.setToolTip(
  1790. _("The kind of controller for which to generate\n"
  1791. "height map gcode.")
  1792. )
  1793. self.al_controller_combo = FCComboBox()
  1794. self.al_controller_combo.addItems(["MACH3", "MACH4", "LinuxCNC", "GRBL"])
  1795. grid0.addWidget(self.al_controller_label, 27, 0)
  1796. grid0.addWidget(self.al_controller_combo, 27, 1)
  1797. # #############################################################################################################
  1798. # ########################## GRBL frame #######################################################################
  1799. # #############################################################################################################
  1800. self.grbl_frame = QtWidgets.QFrame()
  1801. self.grbl_frame.setContentsMargins(0, 0, 0, 0)
  1802. grid0.addWidget(self.grbl_frame, 29, 0, 1, 2)
  1803. self.grbl_box = QtWidgets.QVBoxLayout()
  1804. self.grbl_box.setContentsMargins(0, 0, 0, 0)
  1805. self.grbl_frame.setLayout(self.grbl_box)
  1806. # #############################################################################################################
  1807. # ########################## GRBL TOOLBAR #####################################################################
  1808. # #############################################################################################################
  1809. self.al_toolbar = FCDetachableTab(protect=True, parent=self)
  1810. self.al_toolbar.setTabsClosable(False)
  1811. self.al_toolbar.useOldIndex(True)
  1812. self.al_toolbar.set_detachable(val=False)
  1813. self.grbl_box.addWidget(self.al_toolbar)
  1814. # GRBL Connect TAB
  1815. self.gr_conn_tab = QtWidgets.QWidget()
  1816. self.gr_conn_tab.setObjectName("connect_tab")
  1817. self.gr_conn_tab_layout = QtWidgets.QVBoxLayout(self.gr_conn_tab)
  1818. self.gr_conn_tab_layout.setContentsMargins(2, 2, 2, 2)
  1819. # self.gr_conn_scroll_area = VerticalScrollArea()
  1820. # self.gr_conn_tab_layout.addWidget(self.gr_conn_scroll_area)
  1821. self.al_toolbar.addTab(self.gr_conn_tab, _("Connect"))
  1822. # GRBL Control TAB
  1823. self.gr_ctrl_tab = QtWidgets.QWidget()
  1824. self.gr_ctrl_tab.setObjectName("connect_tab")
  1825. self.gr_ctrl_tab_layout = QtWidgets.QVBoxLayout(self.gr_ctrl_tab)
  1826. self.gr_ctrl_tab_layout.setContentsMargins(2, 2, 2, 2)
  1827. # self.gr_ctrl_scroll_area = VerticalScrollArea()
  1828. # self.gr_ctrl_tab_layout.addWidget(self.gr_ctrl_scroll_area)
  1829. self.al_toolbar.addTab(self.gr_ctrl_tab, _("Control"))
  1830. # GRBL Sender TAB
  1831. self.gr_send_tab = QtWidgets.QWidget()
  1832. self.gr_send_tab.setObjectName("connect_tab")
  1833. self.gr_send_tab_layout = QtWidgets.QVBoxLayout(self.gr_send_tab)
  1834. self.gr_send_tab_layout.setContentsMargins(2, 2, 2, 2)
  1835. # self.gr_send_scroll_area = VerticalScrollArea()
  1836. # self.gr_send_tab_layout.addWidget(self.gr_send_scroll_area)
  1837. self.al_toolbar.addTab(self.gr_send_tab, _("Sender"))
  1838. for idx in range(self.al_toolbar.count()):
  1839. if self.al_toolbar.tabText(idx) == _("Connect"):
  1840. self.al_toolbar.tabBar.setTabTextColor(idx, QtGui.QColor('red'))
  1841. if self.al_toolbar.tabText(idx) == _("Control"):
  1842. self.al_toolbar.tabBar.setTabEnabled(idx, False)
  1843. if self.al_toolbar.tabText(idx) == _("Sender"):
  1844. self.al_toolbar.tabBar.setTabEnabled(idx, False)
  1845. # #############################################################################################################
  1846. # #############################################################################################################
  1847. # GRBL CONNECT
  1848. # #############################################################################################################
  1849. grbl_conn_grid = QtWidgets.QGridLayout()
  1850. grbl_conn_grid.setColumnStretch(0, 0)
  1851. grbl_conn_grid.setColumnStretch(1, 1)
  1852. grbl_conn_grid.setColumnStretch(2, 0)
  1853. self.gr_conn_tab_layout.addLayout(grbl_conn_grid)
  1854. # COM list
  1855. self.com_list_label = FCLabel('%s:' % _("COM list"))
  1856. self.com_list_label.setToolTip(
  1857. _("Lists the available serial ports.")
  1858. )
  1859. self.com_list_combo = FCComboBox()
  1860. self.com_search_button = FCButton(_("Search"))
  1861. self.com_search_button.setToolTip(
  1862. _("Search for the available serial ports.")
  1863. )
  1864. grbl_conn_grid.addWidget(self.com_list_label, 2, 0)
  1865. grbl_conn_grid.addWidget(self.com_list_combo, 2, 1)
  1866. grbl_conn_grid.addWidget(self.com_search_button, 2, 2)
  1867. # BAUDRATES list
  1868. self.baudrates_list_label = FCLabel('%s:' % _("Baud rates"))
  1869. self.baudrates_list_label.setToolTip(
  1870. _("Lists the available serial ports.")
  1871. )
  1872. self.baudrates_list_combo = FCComboBox()
  1873. cbmodel = QtCore.QStringListModel()
  1874. self.baudrates_list_combo.setModel(cbmodel)
  1875. self.baudrates_list_combo.addItems(
  1876. ['9600', '19200', '38400', '57600', '115200', '230400', '460800', '500000', '576000', '921600', '1000000',
  1877. '1152000', '1500000', '2000000'])
  1878. self.baudrates_list_combo.setCurrentText('115200')
  1879. grbl_conn_grid.addWidget(self.baudrates_list_label, 4, 0)
  1880. grbl_conn_grid.addWidget(self.baudrates_list_combo, 4, 1)
  1881. # New baudrate
  1882. self.new_bd_label = FCLabel('%s:' % _("New"))
  1883. self.new_bd_label.setToolTip(
  1884. _("New, custom baudrate.")
  1885. )
  1886. self.new_baudrate_entry = FCSpinner()
  1887. self.new_baudrate_entry.set_range(40, 9999999)
  1888. self.add_bd_button = FCButton(_("Add"))
  1889. self.add_bd_button.setToolTip(
  1890. _("Add the specified custom baudrate to the list.")
  1891. )
  1892. grbl_conn_grid.addWidget(self.new_bd_label, 6, 0)
  1893. grbl_conn_grid.addWidget(self.new_baudrate_entry, 6, 1)
  1894. grbl_conn_grid.addWidget(self.add_bd_button, 6, 2)
  1895. self.del_bd_button = FCButton(_("Delete selected baudrate"))
  1896. grbl_conn_grid.addWidget(self.del_bd_button, 8, 0, 1, 3)
  1897. ctrl_hlay = QtWidgets.QHBoxLayout()
  1898. self.controller_reset_button = FCButton(_("Reset"))
  1899. self.controller_reset_button.setToolTip(
  1900. _("Software reset of the controller.")
  1901. )
  1902. self.controller_reset_button.setDisabled(True)
  1903. ctrl_hlay.addWidget(self.controller_reset_button)
  1904. self.com_connect_button = FCButton()
  1905. self.com_connect_button.setText(_("Disconnected"))
  1906. self.com_connect_button.setToolTip(
  1907. _("Connect to the selected port with the selected baud rate.")
  1908. )
  1909. self.com_connect_button.setStyleSheet("QPushButton {background-color: red;}")
  1910. ctrl_hlay.addWidget(self.com_connect_button)
  1911. grbl_conn_grid.addWidget(FCLabel(""), 9, 0, 1, 3)
  1912. grbl_conn_grid.setRowStretch(9, 1)
  1913. grbl_conn_grid.addLayout(ctrl_hlay, 10, 0, 1, 3)
  1914. # #############################################################################################################
  1915. # GRBL CONTROL
  1916. # #############################################################################################################
  1917. grbl_ctrl_grid = QtWidgets.QGridLayout()
  1918. grbl_ctrl_grid.setColumnStretch(0, 0)
  1919. grbl_ctrl_grid.setColumnStretch(1, 1)
  1920. grbl_ctrl_grid.setColumnStretch(2, 0)
  1921. self.gr_ctrl_tab_layout.addLayout(grbl_ctrl_grid)
  1922. grbl_ctrl2_grid = QtWidgets.QGridLayout()
  1923. grbl_ctrl2_grid.setColumnStretch(0, 0)
  1924. grbl_ctrl2_grid.setColumnStretch(1, 1)
  1925. self.gr_ctrl_tab_layout.addLayout(grbl_ctrl2_grid)
  1926. self.gr_ctrl_tab_layout.addStretch(1)
  1927. jog_title_label = FCLabel(_("Jog"))
  1928. jog_title_label.setStyleSheet("""
  1929. FCLabel
  1930. {
  1931. font-weight: bold;
  1932. }
  1933. """)
  1934. zero_title_label = FCLabel(_("Zero Axes"))
  1935. zero_title_label.setStyleSheet("""
  1936. FCLabel
  1937. {
  1938. font-weight: bold;
  1939. }
  1940. """)
  1941. grbl_ctrl_grid.addWidget(jog_title_label, 0, 0)
  1942. grbl_ctrl_grid.addWidget(zero_title_label, 0, 2)
  1943. self.jog_wdg = FCJog(self.app)
  1944. self.jog_wdg.setStyleSheet("""
  1945. FCJog
  1946. {
  1947. border: 1px solid lightgray;
  1948. border-radius: 5px;
  1949. }
  1950. """)
  1951. self.zero_axs_wdg = FCZeroAxes(self.app)
  1952. self.zero_axs_wdg.setStyleSheet("""
  1953. FCZeroAxes
  1954. {
  1955. border: 1px solid lightgray;
  1956. border-radius: 5px
  1957. }
  1958. """)
  1959. grbl_ctrl_grid.addWidget(self.jog_wdg, 2, 0)
  1960. grbl_ctrl_grid.addWidget(self.zero_axs_wdg, 2, 2)
  1961. self.pause_resume_button = RotatedToolButton()
  1962. self.pause_resume_button.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
  1963. self.pause_resume_button.setText(_("Pause/Resume"))
  1964. self.pause_resume_button.setCheckable(True)
  1965. self.pause_resume_button.setStyleSheet("""
  1966. RotatedToolButton:checked
  1967. {
  1968. background-color: red;
  1969. color: white;
  1970. border: none;
  1971. }
  1972. """)
  1973. pause_frame = QtWidgets.QFrame()
  1974. pause_frame.setContentsMargins(0, 0, 0, 0)
  1975. pause_frame.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Expanding)
  1976. pause_hlay = QtWidgets.QHBoxLayout()
  1977. pause_hlay.setContentsMargins(0, 0, 0, 0)
  1978. pause_hlay.addWidget(self.pause_resume_button)
  1979. pause_frame.setLayout(pause_hlay)
  1980. grbl_ctrl_grid.addWidget(pause_frame, 2, 1)
  1981. # JOG Step
  1982. self.jog_step_label = FCLabel('%s:' % _("Step"))
  1983. self.jog_step_label.setToolTip(
  1984. _("Each jog action will move the axes with this value.")
  1985. )
  1986. self.jog_step_entry = FCSliderWithDoubleSpinner()
  1987. self.jog_step_entry.set_precision(self.decimals)
  1988. self.jog_step_entry.setSingleStep(0.1)
  1989. self.jog_step_entry.set_range(0, 500)
  1990. grbl_ctrl2_grid.addWidget(self.jog_step_label, 0, 0)
  1991. grbl_ctrl2_grid.addWidget(self.jog_step_entry, 0, 1)
  1992. # JOG Feedrate
  1993. self.jog_fr_label = FCLabel('%s:' % _("Feedrate"))
  1994. self.jog_fr_label.setToolTip(
  1995. _("Feedrate when jogging.")
  1996. )
  1997. self.jog_fr_entry = FCSliderWithDoubleSpinner()
  1998. self.jog_fr_entry.set_precision(self.decimals)
  1999. self.jog_fr_entry.setSingleStep(10)
  2000. self.jog_fr_entry.set_range(0, 10000)
  2001. grbl_ctrl2_grid.addWidget(self.jog_fr_label, 1, 0)
  2002. grbl_ctrl2_grid.addWidget(self.jog_fr_entry, 1, 1)
  2003. # #############################################################################################################
  2004. # GRBL SENDER
  2005. # #############################################################################################################
  2006. grbl_send_grid = QtWidgets.QGridLayout()
  2007. grbl_send_grid.setColumnStretch(0, 1)
  2008. grbl_send_grid.setColumnStretch(1, 0)
  2009. self.gr_send_tab_layout.addLayout(grbl_send_grid)
  2010. # Send CUSTOM COMMAND
  2011. self.grbl_command_label = FCLabel('%s:' % _("Send Command"))
  2012. self.grbl_command_label.setToolTip(
  2013. _("Send a custom command to GRBL.")
  2014. )
  2015. grbl_send_grid.addWidget(self.grbl_command_label, 2, 0, 1, 2)
  2016. self.grbl_command_entry = FCEntry()
  2017. self.grbl_command_entry.setPlaceholderText(_("Type GRBL command ..."))
  2018. self.grbl_send_button = QtWidgets.QToolButton()
  2019. self.grbl_send_button.setText(_("Send"))
  2020. self.grbl_send_button.setToolTip(
  2021. _("Send a custom command to GRBL.")
  2022. )
  2023. grbl_send_grid.addWidget(self.grbl_command_entry, 4, 0)
  2024. grbl_send_grid.addWidget(self.grbl_send_button, 4, 1)
  2025. # Get Parameter
  2026. self.grbl_get_param_label = FCLabel('%s:' % _("Get Config parameter"))
  2027. self.grbl_get_param_label.setToolTip(
  2028. _("A GRBL configuration parameter.")
  2029. )
  2030. grbl_send_grid.addWidget(self.grbl_get_param_label, 6, 0, 1, 2)
  2031. self.grbl_parameter_entry = FCEntry()
  2032. self.grbl_parameter_entry.setPlaceholderText(_("Type GRBL parameter ..."))
  2033. self.grbl_get_param_button = QtWidgets.QToolButton()
  2034. self.grbl_get_param_button.setText(_("Get"))
  2035. self.grbl_get_param_button.setToolTip(
  2036. _("Get the value of a specified GRBL parameter.")
  2037. )
  2038. grbl_send_grid.addWidget(self.grbl_parameter_entry, 8, 0)
  2039. grbl_send_grid.addWidget(self.grbl_get_param_button, 8, 1)
  2040. grbl_send_grid.setRowStretch(9, 1)
  2041. # GET Report
  2042. self.grbl_report_button = FCButton(_("Get Report"))
  2043. self.grbl_report_button.setToolTip(
  2044. _("Print in shell the GRBL report.")
  2045. )
  2046. grbl_send_grid.addWidget(self.grbl_report_button, 10, 0, 1, 2)
  2047. hm_lay = QtWidgets.QHBoxLayout()
  2048. # GET HEIGHT MAP
  2049. self.grbl_get_heightmap_button = FCButton(_("Apply AutoLevelling"))
  2050. self.grbl_get_heightmap_button.setToolTip(
  2051. _("Will send the probing GCode to the GRBL controller,\n"
  2052. "wait for the Z probing data and then apply this data\n"
  2053. "over the original GCode therefore doing autolevelling.")
  2054. )
  2055. hm_lay.addWidget(self.grbl_get_heightmap_button, stretch=1)
  2056. self.grbl_save_height_map_button = QtWidgets.QToolButton()
  2057. self.grbl_save_height_map_button.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png'))
  2058. self.grbl_save_height_map_button.setToolTip(
  2059. _("Will save the GRBL height map.")
  2060. )
  2061. hm_lay.addWidget(self.grbl_save_height_map_button, stretch=0, alignment=Qt.AlignRight)
  2062. grbl_send_grid.addLayout(hm_lay, 12, 0, 1, 2)
  2063. self.grbl_frame.hide()
  2064. # #############################################################################################################
  2065. height_lay = QtWidgets.QHBoxLayout()
  2066. self.h_gcode_button = FCButton(_("Save Probing GCode"))
  2067. self.h_gcode_button.setToolTip(
  2068. _("Will save the probing GCode.")
  2069. )
  2070. self.h_gcode_button.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.MinimumExpanding)
  2071. height_lay.addWidget(self.h_gcode_button)
  2072. self.view_h_gcode_button = QtWidgets.QToolButton()
  2073. self.view_h_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
  2074. # self.view_h_gcode_button.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
  2075. self.view_h_gcode_button.setToolTip(
  2076. _("View/Edit the probing GCode.")
  2077. )
  2078. # height_lay.addStretch()
  2079. height_lay.addWidget(self.view_h_gcode_button)
  2080. grid0.addLayout(height_lay, 31, 0, 1, 2)
  2081. self.import_heights_button = FCButton(_("Import Height Map"))
  2082. self.import_heights_button.setToolTip(
  2083. _("Import the file that has the Z heights\n"
  2084. "obtained through probing and then apply this data\n"
  2085. "over the original GCode therefore\n"
  2086. "doing autolevelling.")
  2087. )
  2088. grid0.addWidget(self.import_heights_button, 33, 0, 1, 2)
  2089. self.h_gcode_button.hide()
  2090. self.import_heights_button.hide()
  2091. separator_line = QtWidgets.QFrame()
  2092. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  2093. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  2094. grid0.addWidget(separator_line, 35, 0, 1, 2)
  2095. # #############################################################################################################
  2096. # ## Export G-Code ##
  2097. # #############################################################################################################
  2098. self.export_gcode_label = QtWidgets.QLabel("<b>%s:</b>" % _("Export CNC Code"))
  2099. self.export_gcode_label.setToolTip(
  2100. _("Export and save G-Code to\n"
  2101. "make this object to a file.")
  2102. )
  2103. self.custom_box.addWidget(self.export_gcode_label)
  2104. g_export_lay = QtWidgets.QHBoxLayout()
  2105. self.custom_box.addLayout(g_export_lay)
  2106. # Save Button
  2107. self.export_gcode_button = FCButton(_('Save CNC Code'))
  2108. self.export_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png'))
  2109. self.export_gcode_button.setToolTip(
  2110. _("Opens dialog to save G-Code\n"
  2111. "file.")
  2112. )
  2113. self.export_gcode_button.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
  2114. g_export_lay.addWidget(self.export_gcode_button)
  2115. self.review_gcode_button = QtWidgets.QToolButton()
  2116. self.review_gcode_button.setToolTip(_("Review CNC Code."))
  2117. self.review_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/find32.png'))
  2118. g_export_lay.addWidget(self.review_gcode_button)
  2119. self.custom_box.addStretch()
  2120. self.al_probe_points_table.setRowCount(0)
  2121. self.al_probe_points_table.resizeColumnsToContents()
  2122. self.al_probe_points_table.resizeRowsToContents()
  2123. v_header = self.al_probe_points_table.verticalHeader()
  2124. v_header.hide()
  2125. self.al_probe_points_table.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
  2126. h_header = self.al_probe_points_table.horizontalHeader()
  2127. h_header.setMinimumSectionSize(10)
  2128. h_header.setDefaultSectionSize(70)
  2129. h_header.setSectionResizeMode(0, QtWidgets.QHeaderView.Fixed)
  2130. h_header.resizeSection(0, 20)
  2131. h_header.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
  2132. h_header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents)
  2133. self.al_probe_points_table.setMinimumHeight(self.al_probe_points_table.getHeight())
  2134. self.al_probe_points_table.setMaximumHeight(self.al_probe_points_table.getHeight())
  2135. # Set initial UI
  2136. self.al_frame.hide()
  2137. self.al_rows_entry.setDisabled(True)
  2138. self.al_rows_label.setDisabled(True)
  2139. self.al_columns_entry.setDisabled(True)
  2140. self.al_columns_label.setDisabled(True)
  2141. self.al_method_lbl.setDisabled(True)
  2142. self.al_method_radio.setDisabled(True)
  2143. self.al_method_radio.set_value('v')
  2144. # self.on_mode_radio(val='grid')
  2145. class ScriptObjectUI(ObjectUI):
  2146. """
  2147. User interface for Script objects.
  2148. """
  2149. def __init__(self, app, parent=None):
  2150. """
  2151. Creates the user interface for Script objects. GUI elements should
  2152. be placed in ``self.custom_box`` to preserve the layout.
  2153. """
  2154. self.decimals = app.decimals
  2155. self.app = app
  2156. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  2157. if theme_settings.contains("theme"):
  2158. theme = theme_settings.value('theme', type=str)
  2159. else:
  2160. theme = 'white'
  2161. if theme == 'white':
  2162. self.resource_loc = 'assets/resources'
  2163. else:
  2164. self.resource_loc = 'assets/resources'
  2165. ObjectUI.__init__(self, title=_('Script Object'),
  2166. icon_file=self.resource_loc + '/script_new24.png',
  2167. parent=parent,
  2168. common=False,
  2169. app=self.app)
  2170. # ## Object name
  2171. self.name_hlay = QtWidgets.QHBoxLayout()
  2172. self.custom_box.addLayout(self.name_hlay)
  2173. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  2174. self.name_entry = FCEntry()
  2175. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  2176. self.name_hlay.addWidget(name_label)
  2177. self.name_hlay.addWidget(self.name_entry)
  2178. h_lay = QtWidgets.QHBoxLayout()
  2179. h_lay.setAlignment(QtCore.Qt.AlignVCenter)
  2180. self.custom_box.addLayout(h_lay)
  2181. self.autocomplete_cb = FCCheckBox("%s" % _("Auto Completer"))
  2182. self.autocomplete_cb.setToolTip(
  2183. _("This selects if the auto completer is enabled in the Script Editor.")
  2184. )
  2185. self.autocomplete_cb.setStyleSheet(
  2186. """
  2187. QCheckBox {font-weight: bold; color: black}
  2188. """
  2189. )
  2190. h_lay.addWidget(self.autocomplete_cb)
  2191. h_lay.addStretch()
  2192. # Plot CB - this is added only for compatibility; other FlatCAM objects expect it and the mechanism is already
  2193. # established and I don't want to changed it right now
  2194. self.plot_cb = FCCheckBox()
  2195. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  2196. self.custom_box.addWidget(self.plot_cb)
  2197. self.plot_cb.hide()
  2198. self.custom_box.addStretch()
  2199. class DocumentObjectUI(ObjectUI):
  2200. """
  2201. User interface for Notes objects.
  2202. """
  2203. def __init__(self, app, parent=None):
  2204. """
  2205. Creates the user interface for Notes objects. GUI elements should
  2206. be placed in ``self.custom_box`` to preserve the layout.
  2207. """
  2208. self.decimals = app.decimals
  2209. self.app = app
  2210. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  2211. if theme_settings.contains("theme"):
  2212. theme = theme_settings.value('theme', type=str)
  2213. else:
  2214. theme = 'white'
  2215. if theme == 'white':
  2216. self.resource_loc = 'assets/resources'
  2217. else:
  2218. self.resource_loc = 'assets/resources'
  2219. ObjectUI.__init__(self, title=_('Document Object'),
  2220. icon_file=self.resource_loc + '/notes16_1.png',
  2221. parent=parent,
  2222. common=False,
  2223. app=self.app)
  2224. # ## Object name
  2225. self.name_hlay = QtWidgets.QHBoxLayout()
  2226. self.custom_box.addLayout(self.name_hlay)
  2227. name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
  2228. self.name_entry = FCEntry()
  2229. self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus)
  2230. self.name_hlay.addWidget(name_label)
  2231. self.name_hlay.addWidget(self.name_entry)
  2232. # Plot CB - this is added only for compatibility; other FlatCAM objects expect it and the mechanism is already
  2233. # established and I don't want to changed it right now
  2234. self.plot_cb = FCCheckBox()
  2235. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  2236. self.custom_box.addWidget(self.plot_cb)
  2237. self.plot_cb.hide()
  2238. h_lay = QtWidgets.QHBoxLayout()
  2239. h_lay.setAlignment(QtCore.Qt.AlignVCenter)
  2240. self.custom_box.addLayout(h_lay)
  2241. self.autocomplete_cb = FCCheckBox("%s" % _("Auto Completer"))
  2242. self.autocomplete_cb.setToolTip(
  2243. _("This selects if the auto completer is enabled in the Document Editor.")
  2244. )
  2245. self.autocomplete_cb.setStyleSheet(
  2246. """
  2247. QCheckBox {font-weight: bold; color: black}
  2248. """
  2249. )
  2250. h_lay.addWidget(self.autocomplete_cb)
  2251. h_lay.addStretch()
  2252. # ##############################################################
  2253. # ############ FORM LAYOUT #####################################
  2254. # ##############################################################
  2255. self.form_box = QtWidgets.QFormLayout()
  2256. self.custom_box.addLayout(self.form_box)
  2257. # Font
  2258. self.font_type_label = QtWidgets.QLabel('%s:' % _("Font Type"))
  2259. if sys.platform == "win32":
  2260. f_current = QtGui.QFont("Arial")
  2261. elif sys.platform == "linux":
  2262. f_current = QtGui.QFont("FreeMono")
  2263. else:
  2264. f_current = QtGui.QFont("Helvetica Neue")
  2265. self.font_name = f_current.family()
  2266. self.font_type_cb = QtWidgets.QFontComboBox(self)
  2267. self.font_type_cb.setCurrentFont(f_current)
  2268. self.form_box.addRow(self.font_type_label, self.font_type_cb)
  2269. # Font Size
  2270. self.font_size_label = QtWidgets.QLabel('%s:' % _("Font Size"))
  2271. self.font_size_cb = FCComboBox()
  2272. self.font_size_cb.setEditable(True)
  2273. self.font_size_cb.setMinimumContentsLength(3)
  2274. self.font_size_cb.setMaximumWidth(70)
  2275. font_sizes = ['6', '7', '8', '9', '10', '11', '12', '13', '14',
  2276. '15', '16', '18', '20', '22', '24', '26', '28',
  2277. '32', '36', '40', '44', '48', '54', '60', '66',
  2278. '72', '80', '88', '96']
  2279. for i in font_sizes:
  2280. self.font_size_cb.addItem(i)
  2281. size_hlay = QtWidgets.QHBoxLayout()
  2282. size_hlay.addWidget(self.font_size_cb)
  2283. size_hlay.addStretch()
  2284. self.font_bold_tb = QtWidgets.QToolButton()
  2285. self.font_bold_tb.setCheckable(True)
  2286. self.font_bold_tb.setIcon(QtGui.QIcon(self.resource_loc + '/bold32.png'))
  2287. size_hlay.addWidget(self.font_bold_tb)
  2288. self.font_italic_tb = QtWidgets.QToolButton()
  2289. self.font_italic_tb.setCheckable(True)
  2290. self.font_italic_tb.setIcon(QtGui.QIcon(self.resource_loc + '/italic32.png'))
  2291. size_hlay.addWidget(self.font_italic_tb)
  2292. self.font_under_tb = QtWidgets.QToolButton()
  2293. self.font_under_tb.setCheckable(True)
  2294. self.font_under_tb.setIcon(QtGui.QIcon(self.resource_loc + '/underline32.png'))
  2295. size_hlay.addWidget(self.font_under_tb)
  2296. self.form_box.addRow(self.font_size_label, size_hlay)
  2297. # Alignment Choices
  2298. self.alignment_label = QtWidgets.QLabel('%s:' % _("Alignment"))
  2299. al_hlay = QtWidgets.QHBoxLayout()
  2300. self.al_left_tb = QtWidgets.QToolButton()
  2301. self.al_left_tb.setToolTip(_("Align Left"))
  2302. self.al_left_tb.setIcon(QtGui.QIcon(self.resource_loc + '/align_left32.png'))
  2303. al_hlay.addWidget(self.al_left_tb)
  2304. self.al_center_tb = QtWidgets.QToolButton()
  2305. self.al_center_tb.setToolTip(_("Center"))
  2306. self.al_center_tb.setIcon(QtGui.QIcon(self.resource_loc + '/align_center32.png'))
  2307. al_hlay.addWidget(self.al_center_tb)
  2308. self.al_right_tb = QtWidgets.QToolButton()
  2309. self.al_right_tb.setToolTip(_("Align Right"))
  2310. self.al_right_tb.setIcon(QtGui.QIcon(self.resource_loc + '/align_right32.png'))
  2311. al_hlay.addWidget(self.al_right_tb)
  2312. self.al_justify_tb = QtWidgets.QToolButton()
  2313. self.al_justify_tb.setToolTip(_("Justify"))
  2314. self.al_justify_tb.setIcon(QtGui.QIcon(self.resource_loc + '/align_justify32.png'))
  2315. al_hlay.addWidget(self.al_justify_tb)
  2316. self.form_box.addRow(self.alignment_label, al_hlay)
  2317. # Font Color
  2318. self.font_color_label = QtWidgets.QLabel('%s:' % _('Font Color'))
  2319. self.font_color_label.setToolTip(
  2320. _("Set the font color for the selected text")
  2321. )
  2322. self.font_color_entry = FCEntry()
  2323. self.font_color_button = QtWidgets.QPushButton()
  2324. self.font_color_button.setFixedSize(15, 15)
  2325. self.form_box_child_1 = QtWidgets.QHBoxLayout()
  2326. self.form_box_child_1.addWidget(self.font_color_entry)
  2327. self.form_box_child_1.addWidget(self.font_color_button)
  2328. self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2329. self.form_box.addRow(self.font_color_label, self.form_box_child_1)
  2330. # Selection Color
  2331. self.sel_color_label = QtWidgets.QLabel('%s:' % _('Selection Color'))
  2332. self.sel_color_label.setToolTip(
  2333. _("Set the selection color when doing text selection.")
  2334. )
  2335. self.sel_color_entry = FCEntry()
  2336. self.sel_color_button = QtWidgets.QPushButton()
  2337. self.sel_color_button.setFixedSize(15, 15)
  2338. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  2339. self.form_box_child_2.addWidget(self.sel_color_entry)
  2340. self.form_box_child_2.addWidget(self.sel_color_button)
  2341. self.form_box_child_2.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2342. self.form_box.addRow(self.sel_color_label, self.form_box_child_2)
  2343. # Tab size
  2344. self.tab_size_label = QtWidgets.QLabel('%s:' % _('Tab Size'))
  2345. self.tab_size_label.setToolTip(
  2346. _("Set the tab size. In pixels. Default value is 80 pixels.")
  2347. )
  2348. self.tab_size_spinner = FCSpinner(callback=self.confirmation_message_int)
  2349. self.tab_size_spinner.set_range(0, 1000)
  2350. self.form_box.addRow(self.tab_size_label, self.tab_size_spinner)
  2351. self.custom_box.addStretch()
  2352. # end of file