ObjectUI.py 78 KB

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