ObjectUI.py 103 KB

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