ObjectUI.py 72 KB

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