ObjectUI.py 119 KB

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