ObjectUI.py 104 KB

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