ObjectUI.py 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. import sys
  2. from PyQt5 import QtGui, QtCore, QtWidgets, QtWidgets
  3. from GUIElements import FCEntry, FloatEntry, EvalEntry, FCCheckBox, FCTable, \
  4. LengthEntry, FCTextArea, IntEntry, RadioSet, OptionalInputSection, FCComboBox, FloatEntry2, EvalEntry2
  5. from camlib import Excellon
  6. class ObjectUI(QtWidgets.QWidget):
  7. """
  8. Base class for the UI of FlatCAM objects. Deriving classes should
  9. put UI elements in ObjectUI.custom_box (QtWidgets.QLayout).
  10. """
  11. def __init__(self, icon_file='share/flatcam_icon32.png', title='FlatCAM Object', parent=None):
  12. QtWidgets.QWidget.__init__(self, parent=parent)
  13. layout = QtWidgets.QVBoxLayout()
  14. self.setLayout(layout)
  15. ## Page Title box (spacing between children)
  16. self.title_box = QtWidgets.QHBoxLayout()
  17. layout.addLayout(self.title_box)
  18. ## Page Title icon
  19. pixmap = QtGui.QPixmap(icon_file)
  20. self.icon = QtWidgets.QLabel()
  21. self.icon.setPixmap(pixmap)
  22. self.title_box.addWidget(self.icon, stretch=0)
  23. ## Title label
  24. self.title_label = QtWidgets.QLabel("<font size=5><b>" + title + "</b></font>")
  25. self.title_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  26. self.title_box.addWidget(self.title_label, stretch=1)
  27. ## Object name
  28. self.name_box = QtWidgets.QHBoxLayout()
  29. layout.addLayout(self.name_box)
  30. name_label = QtWidgets.QLabel("Name:")
  31. self.name_box.addWidget(name_label)
  32. self.name_entry = FCEntry()
  33. self.name_box.addWidget(self.name_entry)
  34. ## Box box for custom widgets
  35. # This gets populated in offspring implementations.
  36. self.custom_box = QtWidgets.QVBoxLayout()
  37. layout.addLayout(self.custom_box)
  38. ###########################
  39. ## Common to all objects ##
  40. ###########################
  41. #### Scale ####
  42. self.scale_label = QtWidgets.QLabel('<b>Scale:</b>')
  43. self.scale_label.setToolTip(
  44. "Change the size of the object."
  45. )
  46. layout.addWidget(self.scale_label)
  47. self.scale_grid = QtWidgets.QGridLayout()
  48. layout.addLayout(self.scale_grid)
  49. # Factor
  50. faclabel = QtWidgets.QLabel('Factor:')
  51. faclabel.setToolTip(
  52. "Factor by which to multiply\n"
  53. "geometric features of this object."
  54. )
  55. self.scale_grid.addWidget(faclabel, 0, 0)
  56. self.scale_entry = FloatEntry2()
  57. self.scale_entry.set_value(1.0)
  58. self.scale_grid.addWidget(self.scale_entry, 0, 1)
  59. # GO Button
  60. self.scale_button = QtWidgets.QPushButton('Scale')
  61. self.scale_button.setToolTip(
  62. "Perform scaling operation."
  63. )
  64. self.scale_button.setFixedWidth(40)
  65. self.scale_grid.addWidget(self.scale_button, 0, 2)
  66. #### Offset ####
  67. self.offset_label = QtWidgets.QLabel('<b>Offset:</b>')
  68. self.offset_label.setToolTip(
  69. "Change the position of this object."
  70. )
  71. layout.addWidget(self.offset_label)
  72. self.offset_grid = QtWidgets.QGridLayout()
  73. layout.addLayout(self.offset_grid)
  74. self.offset_vectorlabel = QtWidgets.QLabel('Vector:')
  75. self.offset_vectorlabel.setToolTip(
  76. "Amount by which to move the object\n"
  77. "in the x and y axes in (x, y) format."
  78. )
  79. self.offset_grid.addWidget(self.offset_vectorlabel, 0, 0)
  80. self.offsetvector_entry = EvalEntry2()
  81. self.offsetvector_entry.setText("(0.0, 0.0)")
  82. self.offset_grid.addWidget(self.offsetvector_entry, 0, 1)
  83. self.offset_button = QtWidgets.QPushButton('Offset')
  84. self.offset_button.setToolTip(
  85. "Perform the offset operation."
  86. )
  87. self.offset_button.setFixedWidth(40)
  88. self.offset_grid.addWidget(self.offset_button, 0, 2)
  89. layout.addStretch()
  90. class GerberObjectUI(ObjectUI):
  91. """
  92. User interface for Gerber objects.
  93. """
  94. def __init__(self, parent=None):
  95. ObjectUI.__init__(self, title='Gerber Object', parent=parent)
  96. # Plot options
  97. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  98. self.custom_box.addWidget(self.plot_options_label)
  99. grid0 = QtWidgets.QGridLayout()
  100. grid0.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  101. self.custom_box.addLayout(grid0)
  102. # Plot CB
  103. self.plot_cb = FCCheckBox(label='Plot ')
  104. self.plot_options_label.setToolTip(
  105. "Plot (show) this object."
  106. )
  107. self.plot_cb.setFixedWidth(50)
  108. grid0.addWidget(self.plot_cb, 0, 0)
  109. # Solid CB
  110. self.solid_cb = FCCheckBox(label='Solid ')
  111. self.solid_cb.setToolTip(
  112. "Solid color polygons."
  113. )
  114. self.solid_cb.setFixedWidth(50)
  115. grid0.addWidget(self.solid_cb, 0, 1)
  116. # Multicolored CB
  117. self.multicolored_cb = FCCheckBox(label='M-Color ')
  118. self.multicolored_cb.setToolTip(
  119. "Draw polygons in different colors."
  120. )
  121. self.multicolored_cb.setFixedWidth(55)
  122. grid0.addWidget(self.multicolored_cb, 0, 2)
  123. # Isolation Routing
  124. self.isolation_routing_label = QtWidgets.QLabel("<b>Isolation Routing:</b>")
  125. self.isolation_routing_label.setToolTip(
  126. "Create a Geometry object with\n"
  127. "toolpaths to cut outside polygons."
  128. )
  129. self.custom_box.addWidget(self.isolation_routing_label)
  130. grid1 = QtWidgets.QGridLayout()
  131. self.custom_box.addLayout(grid1)
  132. tdlabel = QtWidgets.QLabel('Tool dia:')
  133. tdlabel.setToolTip(
  134. "Diameter of the cutting tool.\n"
  135. "If you want to have an isolation path\n"
  136. "inside the actual shape of the Gerber\n"
  137. "feature, use a negative value for\n"
  138. "this parameter."
  139. )
  140. grid1.addWidget(tdlabel, 0, 0)
  141. self.iso_tool_dia_entry = LengthEntry()
  142. grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
  143. passlabel = QtWidgets.QLabel('Passes:')
  144. passlabel.setToolTip(
  145. "Width of the isolation gap in\n"
  146. "number (integer) of tool widths."
  147. )
  148. grid1.addWidget(passlabel, 1, 0)
  149. self.iso_width_entry = IntEntry()
  150. grid1.addWidget(self.iso_width_entry, 1, 1)
  151. overlabel = QtWidgets.QLabel('Pass overlap:')
  152. overlabel.setToolTip(
  153. "How much (fraction) of the tool width to overlap each tool pass.\n"
  154. "Example:\n"
  155. "A value here of 0.25 means an overlap of 25% from the tool diameter found above."
  156. )
  157. grid1.addWidget(overlabel, 2, 0)
  158. self.iso_overlap_entry = FloatEntry()
  159. grid1.addWidget(self.iso_overlap_entry, 2, 1)
  160. # Milling Type Radio Button
  161. milling_type_label = QtWidgets.QLabel('Milling Type:')
  162. milling_type_label.setToolTip(
  163. "Milling type:\n"
  164. "- climb / best for precision milling and to reduce tool usage\n"
  165. "- conventional / useful when there is no backlash compensation"
  166. )
  167. grid1.addWidget(milling_type_label, 3, 0)
  168. self.milling_type_radio = RadioSet([{'label': 'Climb', 'value': 'cl'},
  169. {'label': 'Conv.', 'value': 'cv'}])
  170. grid1.addWidget(self.milling_type_radio, 3, 1)
  171. # combine all passes CB
  172. self.combine_passes_cb = FCCheckBox(label='Combine')
  173. self.combine_passes_cb.setToolTip(
  174. "Combine all passes into one object"
  175. )
  176. grid1.addWidget(self.combine_passes_cb, 4, 0)
  177. # generate follow
  178. self.follow_cb = FCCheckBox(label='"Follow" Geo')
  179. self.follow_cb.setToolTip(
  180. "Generate a 'Follow' geometry.\n"
  181. "This means that it will cut through\n"
  182. "the middle of the trace.\n"
  183. "Requires that the Gerber file to be\n"
  184. "loaded with 'follow' parameter."
  185. )
  186. grid1.addWidget(self.follow_cb, 4, 1)
  187. self.gen_iso_label = QtWidgets.QLabel("<b>Generate Isolation Geometry:</b>")
  188. self.gen_iso_label.setToolTip(
  189. "Create a Geometry object with toolpaths to cut \n"
  190. "isolation outside, inside or on both sides of the\n"
  191. "object. For a Gerber object outside means outside\n"
  192. "of the Gerber feature and inside means inside of\n"
  193. "the Gerber feature, if possible at all. This means\n"
  194. "that only if the Gerber feature has openings inside, they\n"
  195. "will be isolated. If what is wanted is to cut isolation\n"
  196. "inside the actual Gerber feature, use a negative tool\n"
  197. "diameter above."
  198. )
  199. self.custom_box.addWidget(self.gen_iso_label)
  200. hlay_1 = QtWidgets.QHBoxLayout()
  201. self.custom_box.addLayout(hlay_1)
  202. hlay_1.addStretch()
  203. self.generate_ext_iso_button = QtWidgets.QPushButton('Ext Geo')
  204. self.generate_ext_iso_button.setToolTip(
  205. "Create the Geometry Object\n"
  206. "for isolation routing containing\n"
  207. "only the exteriors geometry."
  208. )
  209. self.generate_ext_iso_button.setFixedWidth(60)
  210. hlay_1.addWidget(self.generate_ext_iso_button)
  211. self.generate_int_iso_button = QtWidgets.QPushButton('Int Geo')
  212. self.generate_int_iso_button.setToolTip(
  213. "Create the Geometry Object\n"
  214. "for isolation routing containing\n"
  215. "only the interiors geometry."
  216. )
  217. self.generate_int_iso_button.setFixedWidth(60)
  218. hlay_1.addWidget(self.generate_int_iso_button)
  219. self.generate_iso_button = QtWidgets.QPushButton('FULL Geo')
  220. self.generate_iso_button.setToolTip(
  221. "Create the Geometry Object\n"
  222. "for isolation routing. It contains both\n"
  223. "the interiors and exteriors geometry."
  224. )
  225. self.generate_iso_button.setFixedWidth(80)
  226. hlay_1.addWidget(self.generate_iso_button)
  227. # when the follow checkbox is checked then the exteriors and interiors isolation generation buttons
  228. # are disabled as is doesn't make sense to have them enabled due of the nature of "follow"
  229. self.ois_iso = OptionalInputSection(self.follow_cb,
  230. [self.generate_int_iso_button, self.generate_ext_iso_button], logic=False)
  231. ## Clear non-copper regions
  232. self.clearcopper_label = QtWidgets.QLabel("<b>Clear non-copper:</b>")
  233. self.clearcopper_label.setToolTip(
  234. "Create a Geometry object with\n"
  235. "toolpaths to cut all non-copper regions."
  236. )
  237. self.custom_box.addWidget(self.clearcopper_label)
  238. self.generate_ncc_button = QtWidgets.QPushButton('Non-Copper Clear Tool')
  239. self.generate_ncc_button.setToolTip(
  240. "Create the Geometry Object\n"
  241. "for non-copper routing."
  242. )
  243. self.custom_box.addWidget(self.generate_ncc_button)
  244. ## Board cutout
  245. self.board_cutout_label = QtWidgets.QLabel("<b>Board cutout:</b>")
  246. self.board_cutout_label.setToolTip(
  247. "Create toolpaths to cut around\n"
  248. "the PCB and separate it from\n"
  249. "the original board."
  250. )
  251. self.custom_box.addWidget(self.board_cutout_label)
  252. self.generate_cutout_button = QtWidgets.QPushButton('Cutout Tool')
  253. self.generate_cutout_button.setToolTip(
  254. "Generate the geometry for\n"
  255. "the board cutout."
  256. )
  257. self.custom_box.addWidget(self.generate_cutout_button)
  258. ## Non-copper regions
  259. self.noncopper_label = QtWidgets.QLabel("<b>Non-copper regions:</b>")
  260. self.noncopper_label.setToolTip(
  261. "Create polygons covering the\n"
  262. "areas without copper on the PCB.\n"
  263. "Equivalent to the inverse of this\n"
  264. "object. Can be used to remove all\n"
  265. "copper from a specified region."
  266. )
  267. self.custom_box.addWidget(self.noncopper_label)
  268. grid4 = QtWidgets.QGridLayout()
  269. self.custom_box.addLayout(grid4)
  270. # Margin
  271. bmlabel = QtWidgets.QLabel('Boundary Margin:')
  272. bmlabel.setToolTip(
  273. "Specify the edge of the PCB\n"
  274. "by drawing a box around all\n"
  275. "objects with this minimum\n"
  276. "distance."
  277. )
  278. grid4.addWidget(bmlabel, 0, 0)
  279. self.noncopper_margin_entry = LengthEntry()
  280. grid4.addWidget(self.noncopper_margin_entry, 0, 1)
  281. # Rounded corners
  282. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  283. self.noncopper_rounded_cb.setToolTip(
  284. "Creates a Geometry objects with polygons\n"
  285. "covering the copper-free areas of the PCB."
  286. )
  287. grid4.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  288. self.generate_noncopper_button = QtWidgets.QPushButton('Generate Geometry')
  289. self.custom_box.addWidget(self.generate_noncopper_button)
  290. ## Bounding box
  291. self.boundingbox_label = QtWidgets.QLabel('<b>Bounding Box:</b>')
  292. self.custom_box.addWidget(self.boundingbox_label)
  293. grid5 = QtWidgets.QGridLayout()
  294. self.custom_box.addLayout(grid5)
  295. bbmargin = QtWidgets.QLabel('Boundary Margin:')
  296. bbmargin.setToolTip(
  297. "Distance of the edges of the box\n"
  298. "to the nearest polygon."
  299. )
  300. grid5.addWidget(bbmargin, 0, 0)
  301. self.bbmargin_entry = LengthEntry()
  302. grid5.addWidget(self.bbmargin_entry, 0, 1)
  303. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  304. self.bbrounded_cb.setToolTip(
  305. "If the bounding box is \n"
  306. "to have rounded corners\n"
  307. "their radius is equal to\n"
  308. "the margin."
  309. )
  310. grid5.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  311. self.generate_bb_button = QtWidgets.QPushButton('Generate Geometry')
  312. self.generate_bb_button.setToolTip(
  313. "Genrate the Geometry object."
  314. )
  315. self.custom_box.addWidget(self.generate_bb_button)
  316. class ExcellonObjectUI(ObjectUI):
  317. """
  318. User interface for Excellon objects.
  319. """
  320. def __init__(self, parent=None):
  321. ObjectUI.__init__(self, title='Excellon Object',
  322. icon_file='share/drill32.png',
  323. parent=parent)
  324. #### Plot options ####
  325. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  326. self.custom_box.addWidget(self.plot_options_label)
  327. grid0 = QtWidgets.QGridLayout()
  328. self.custom_box.addLayout(grid0)
  329. self.plot_cb = FCCheckBox(label='Plot')
  330. self.plot_cb.setToolTip(
  331. "Plot (show) this object."
  332. )
  333. grid0.addWidget(self.plot_cb, 0, 0)
  334. self.solid_cb = FCCheckBox(label='Solid')
  335. self.solid_cb.setToolTip(
  336. "Solid circles."
  337. )
  338. grid0.addWidget(self.solid_cb, 0, 1)
  339. # add a frame and inside add a vertical box layout. Inside this vbox layout I add all the Drills widgets
  340. # this way I can hide/show the frame
  341. self.drills_frame = QtWidgets.QFrame()
  342. self.drills_frame.setContentsMargins(0, 0, 0, 0)
  343. self.custom_box.addWidget(self.drills_frame)
  344. self.tools_box = QtWidgets.QVBoxLayout()
  345. self.tools_box.setContentsMargins(0, 0, 0, 0)
  346. self.drills_frame.setLayout(self.tools_box)
  347. #### Tools Drills ####
  348. self.tools_table_label = QtWidgets.QLabel('<b>Tools Table</b>')
  349. self.tools_table_label.setToolTip(
  350. "Tools in this Excellon object\n"
  351. "when are used for drilling."
  352. )
  353. self.tools_box.addWidget(self.tools_table_label)
  354. self.tools_table = FCTable()
  355. self.tools_box.addWidget(self.tools_table)
  356. self.tools_table.setColumnCount(4)
  357. self.tools_table.setHorizontalHeaderLabels(['#', 'Diameter', 'D', 'S'])
  358. self.tools_table.setSortingEnabled(False)
  359. self.empty_label = QtWidgets.QLabel('')
  360. self.tools_box.addWidget(self.empty_label)
  361. #### Create CNC Job ####
  362. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job</b>')
  363. self.cncjob_label.setToolTip(
  364. "Create a CNC Job object\n"
  365. "for this drill object."
  366. )
  367. self.tools_box.addWidget(self.cncjob_label)
  368. grid1 = QtWidgets.QGridLayout()
  369. self.tools_box.addLayout(grid1)
  370. # Cut Z
  371. cutzlabel = QtWidgets.QLabel('Cut Z:')
  372. cutzlabel.setToolTip(
  373. "Drill depth (negative)\n"
  374. "below the copper surface."
  375. )
  376. grid1.addWidget(cutzlabel, 0, 0)
  377. self.cutz_entry = LengthEntry()
  378. grid1.addWidget(self.cutz_entry, 0, 1)
  379. # Travel Z (z_move)
  380. travelzlabel = QtWidgets.QLabel('Travel Z:')
  381. travelzlabel.setToolTip(
  382. "Tool height when travelling\n"
  383. "across the XY plane."
  384. )
  385. grid1.addWidget(travelzlabel, 1, 0)
  386. self.travelz_entry = LengthEntry()
  387. grid1.addWidget(self.travelz_entry, 1, 1)
  388. # Tool change:
  389. self.toolchange_cb = FCCheckBox("Tool change")
  390. self.toolchange_cb.setToolTip(
  391. "Include tool-change sequence\n"
  392. "in G-Code (Pause for tool change)."
  393. )
  394. grid1.addWidget(self.toolchange_cb, 2, 0)
  395. # Tool change Z:
  396. toolchzlabel = QtWidgets.QLabel("Tool change Z:")
  397. toolchzlabel.setToolTip(
  398. "Z-axis position (height) for\n"
  399. "tool change."
  400. )
  401. grid1.addWidget(toolchzlabel, 3, 0)
  402. self.toolchangez_entry = LengthEntry()
  403. grid1.addWidget(self.toolchangez_entry, 3, 1)
  404. self.ois_tcz_e = OptionalInputSection(self.toolchange_cb, [self.toolchangez_entry])
  405. # Start move Z:
  406. startzlabel = QtWidgets.QLabel("Start move Z:")
  407. startzlabel.setToolTip(
  408. "Tool height just before starting the work.\n"
  409. "Delete the value if you don't need this feature."
  410. )
  411. grid1.addWidget(startzlabel, 4, 0)
  412. self.estartz_entry = FloatEntry()
  413. grid1.addWidget(self.estartz_entry, 4, 1)
  414. # End move Z:
  415. endzlabel = QtWidgets.QLabel("End move Z:")
  416. endzlabel.setToolTip(
  417. "Z-axis position (height) for\n"
  418. "the last move."
  419. )
  420. grid1.addWidget(endzlabel, 5, 0)
  421. self.eendz_entry = LengthEntry()
  422. grid1.addWidget(self.eendz_entry, 5, 1)
  423. # Excellon Feedrate
  424. frlabel = QtWidgets.QLabel('Feedrate (Plunge):')
  425. frlabel.setToolTip(
  426. "Tool speed while drilling\n"
  427. "(in units per minute).\n"
  428. "This is for linear move G01."
  429. )
  430. grid1.addWidget(frlabel, 6, 0)
  431. self.feedrate_entry = LengthEntry()
  432. grid1.addWidget(self.feedrate_entry, 6, 1)
  433. # Excellon Rapid Feedrate
  434. fr_rapid_label = QtWidgets.QLabel('Feedrate Rapids:')
  435. fr_rapid_label.setToolTip(
  436. "Tool speed while drilling\n"
  437. "(in units per minute).\n"
  438. "This is for the rapid move G00."
  439. )
  440. grid1.addWidget(fr_rapid_label, 7, 0)
  441. self.feedrate_rapid_entry = LengthEntry()
  442. grid1.addWidget(self.feedrate_rapid_entry, 7, 1)
  443. # Spindlespeed
  444. spdlabel = QtWidgets.QLabel('Spindle speed:')
  445. spdlabel.setToolTip(
  446. "Speed of the spindle\n"
  447. "in RPM (optional)"
  448. )
  449. grid1.addWidget(spdlabel, 8, 0)
  450. self.spindlespeed_entry = IntEntry(allow_empty=True)
  451. grid1.addWidget(self.spindlespeed_entry, 8, 1)
  452. # Dwell
  453. self.dwell_cb = FCCheckBox('Dwell:')
  454. self.dwell_cb.setToolTip(
  455. "Pause to allow the spindle to reach its\n"
  456. "speed before cutting."
  457. )
  458. self.dwelltime_entry = FCEntry()
  459. self.dwelltime_entry.setToolTip(
  460. "Number of milliseconds for spindle to dwell."
  461. )
  462. grid1.addWidget(self.dwell_cb, 9, 0)
  463. grid1.addWidget(self.dwelltime_entry, 9, 1)
  464. self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  465. # postprocessor selection
  466. pp_excellon_label = QtWidgets.QLabel("Postprocessor")
  467. pp_excellon_label.setToolTip(
  468. "The json file that dictates\n"
  469. "gcode output."
  470. )
  471. self.tools_box.addWidget(pp_excellon_label)
  472. self.pp_excellon_name_cb = FCComboBox()
  473. self.pp_excellon_name_cb.setFocusPolicy(QtCore.Qt.StrongFocus)
  474. self.tools_box.addWidget(self.pp_excellon_name_cb)
  475. choose_tools_label = QtWidgets.QLabel(
  476. "Select from the Tools Table above\n"
  477. "the tools you want to include."
  478. )
  479. self.tools_box.addWidget(choose_tools_label)
  480. #### Choose what to use for Gcode creation: Drills, Slots or Both
  481. gcode_box = QtWidgets.QFormLayout()
  482. gcode_type_label = QtWidgets.QLabel('<b>Type: </b>')
  483. gcode_type_label.setToolTip(
  484. "Choose what to use for GCode generation:\n"
  485. "'Drills', 'Slots' or 'Both'.\n"
  486. "When choosing 'Slots' or 'Both', slots will be\n"
  487. "converted to a series of drills."
  488. )
  489. self.excellon_gcode_type_radio = RadioSet([{'label': 'Drills', 'value': 'drills'},
  490. {'label': 'Slots', 'value': 'slots'},
  491. {'label': 'Both', 'value': 'both'}])
  492. gcode_box.addRow(gcode_type_label, self.excellon_gcode_type_radio)
  493. self.tools_box.addLayout(gcode_box)
  494. # temporary action until I finish the feature
  495. self.excellon_gcode_type_radio.setEnabled(False)
  496. self.generate_cnc_button = QtWidgets.QPushButton('Create GCode')
  497. self.generate_cnc_button.setToolTip(
  498. "Generate the CNC Job."
  499. )
  500. self.tools_box.addWidget(self.generate_cnc_button)
  501. #### Milling Holes Drills####
  502. self.mill_hole_label = QtWidgets.QLabel('<b>Mill Holes</b>')
  503. self.mill_hole_label.setToolTip(
  504. "Create Geometry for milling holes."
  505. )
  506. self.tools_box.addWidget(self.mill_hole_label)
  507. self.choose_tools_label2 = QtWidgets.QLabel(
  508. "Select from the Tools Table above\n"
  509. " the hole dias that are to be milled."
  510. )
  511. self.tools_box.addWidget(self.choose_tools_label2)
  512. grid2 = QtWidgets.QGridLayout()
  513. self.tools_box.addLayout(grid2)
  514. self.tdlabel = QtWidgets.QLabel('Drills Tool dia:')
  515. self.tdlabel.setToolTip(
  516. "Diameter of the cutting tool."
  517. )
  518. grid2.addWidget(self.tdlabel, 0, 0)
  519. self.tooldia_entry = LengthEntry()
  520. grid2.addWidget(self.tooldia_entry, 0, 1)
  521. self.generate_milling_button = QtWidgets.QPushButton('Mill Drills Geo')
  522. self.generate_milling_button.setToolTip(
  523. "Create the Geometry Object\n"
  524. "for milling DRILLS toolpaths."
  525. )
  526. grid2.addWidget(self.generate_milling_button, 0, 2)
  527. grid3 = QtWidgets.QGridLayout()
  528. self.custom_box.addLayout(grid3)
  529. self.stdlabel = QtWidgets.QLabel('Slots Tool dia:')
  530. self.stdlabel.setToolTip(
  531. "Diameter of the cutting tool."
  532. )
  533. grid3.addWidget(self.stdlabel, 0, 0)
  534. self.slot_tooldia_entry = LengthEntry()
  535. grid3.addWidget(self.slot_tooldia_entry, 0, 1)
  536. self.generate_milling_slots_button = QtWidgets.QPushButton('Mill Slots Geo')
  537. self.generate_milling_slots_button.setToolTip(
  538. "Create the Geometry Object\n"
  539. "for milling SLOTS toolpaths."
  540. )
  541. grid3.addWidget(self.generate_milling_slots_button, 0, 2)
  542. def hide_drills(self, state=True):
  543. if state is True:
  544. self.drills_frame.hide()
  545. else:
  546. self.drills_frame.show()
  547. class GeometryObjectUI(ObjectUI):
  548. """
  549. User interface for Geometry objects.
  550. """
  551. def __init__(self, parent=None):
  552. super(GeometryObjectUI, self).__init__(title='Geometry Object', icon_file='share/geometry32.png', parent=parent)
  553. # Plot options
  554. # self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  555. # self.custom_box.addWidget(self.plot_options_label)
  556. # add a frame and inside add a vertical box layout. Inside this vbox layout I add all the Tools widgets
  557. # this way I can hide/show the frame
  558. self.geo_tools_frame = QtWidgets.QFrame()
  559. self.geo_tools_frame.setContentsMargins(0, 0, 0, 0)
  560. self.custom_box.addWidget(self.geo_tools_frame)
  561. self.geo_tools_box = QtWidgets.QVBoxLayout()
  562. self.geo_tools_box.setContentsMargins(0, 0, 0, 0)
  563. self.geo_tools_frame.setLayout(self.geo_tools_box)
  564. hlay_plot = QtWidgets.QHBoxLayout()
  565. self.geo_tools_box.addLayout(hlay_plot)
  566. #### Tools ####
  567. self.tools_table_label = QtWidgets.QLabel('<b>Tools Table</b>')
  568. self.tools_table_label.setToolTip(
  569. "Tools in this Geometry object used for cutting.\n"
  570. "The 'Offset' entry will set an offset for the cut.\n"
  571. "'Offset' can be inside, outside, on path (none) and custom.\n"
  572. "'Type' entry is only informative and it allow to know the \n"
  573. "intent of using the current tool. \n"
  574. "It can be Rough(ing), Finish(ing) or Iso(lation).\n"
  575. "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n"
  576. "ball(B), or V-Shaped(V). \n"
  577. "When V-shaped is selected the 'Type' entry is automatically \n"
  578. "set to Isolation, the CutZ parameter in the UI form is\n"
  579. "grayed out and Cut Z is automatically calculated from the newly \n"
  580. "showed UI form entries named V-Tip Dia and V-Tip Angle."
  581. )
  582. hlay_plot.addWidget(self.tools_table_label)
  583. # Plot CB
  584. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  585. self.plot_cb = FCCheckBox('Plot Object')
  586. self.plot_cb.setToolTip(
  587. "Plot (show) this object."
  588. )
  589. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  590. hlay_plot.addStretch()
  591. hlay_plot.addWidget(self.plot_cb)
  592. self.geo_tools_table = FCTable()
  593. self.geo_tools_box.addWidget(self.geo_tools_table)
  594. self.geo_tools_table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
  595. self.geo_tools_table.setColumnCount(7)
  596. self.geo_tools_table.setColumnWidth(0, 20)
  597. self.geo_tools_table.setHorizontalHeaderLabels(['#', 'Dia', 'Offset', 'Type', 'TT', '', 'P'])
  598. self.geo_tools_table.setColumnHidden(5, True)
  599. self.geo_tools_table.horizontalHeaderItem(0).setToolTip(
  600. "This is the Tool Number.\n"
  601. "When ToolChange is checked, on toolchange event this value\n"
  602. "will be showed as a T1, T2 ... Tn")
  603. self.geo_tools_table.horizontalHeaderItem(1).setToolTip(
  604. "Tool Diameter. It's value (in current FlatCAM units) \n"
  605. "is the cut width into the material.")
  606. self.geo_tools_table.horizontalHeaderItem(2).setToolTip(
  607. "The value for the Offset can be:\n"
  608. "- Path -> There is no offset, the tool cut will be done through the geometry line.\n"
  609. "- In(side) -> The tool cut will follow the geometry inside. It will create a 'pocket'.\n"
  610. "- Out(side) -> The tool cut will follow the geometry line on the outside.")
  611. self.geo_tools_table.horizontalHeaderItem(3).setToolTip(
  612. "The (Operation) Type has only informative value. Usually the UI form values \n"
  613. "are choosed based on the operation type and this will serve as a reminder.\n"
  614. "Can be 'Roughing', 'Finishing' or 'Isolation'.\n"
  615. "For Roughing we may choose a lower Feedrate and multiDepth cut.\n"
  616. "For Finishing we may choose a higher Feedrate, without multiDepth.\n"
  617. "For Isolation we need a lower Feedrate as it use a milling bit with a fine tip.")
  618. self.geo_tools_table.horizontalHeaderItem(4).setToolTip(
  619. "The Tool Type (TT) can be:\n"
  620. "- Circular with 1 ... 4 teeth -> it is informative only. Being circular the cut width in material\n"
  621. "is exactly the tool diameter.\n"
  622. "- Ball -> informative only and make reference to the Ball type endmill.\n"
  623. "- V-Shape -> it will disable de Z-Cut parameter in the UI form and enable two additional UI form\n"
  624. "fields: V-Tip Dia and V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such\n"
  625. "as the cut width into material will be equal with the value in the Tool Diameter column of this table.\n"
  626. "Choosing the V-Shape Tool Type automatically will select the Operation Type as Isolation.")
  627. self.geo_tools_table.horizontalHeaderItem(6).setToolTip(
  628. "Plot column. It is visible only for MultiGeo geometries, meaning geometries that holds the geometry\n"
  629. "data into the tools. For those geometries, deleting the tool will delete the geometry data also,\n"
  630. "so be WARNED. From the checkboxes on each row it can be enabled/disabled the plot on canvas\n"
  631. "for the corresponding tool.")
  632. # self.geo_tools_table.setSortingEnabled(False)
  633. # self.geo_tools_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
  634. # Tool Offset
  635. self.grid1 = QtWidgets.QGridLayout()
  636. self.geo_tools_box.addLayout(self.grid1)
  637. self.tool_offset_lbl = QtWidgets.QLabel('Tool Offset:')
  638. self.tool_offset_lbl.setToolTip(
  639. "The value to offset the cut when \n"
  640. "the Offset type selected is 'Offset'.\n"
  641. "The value can be positive for 'outside'\n"
  642. "cut and negative for 'inside' cut."
  643. )
  644. self.grid1.addWidget(self.tool_offset_lbl, 0, 0)
  645. self.tool_offset_entry = FloatEntry()
  646. spacer_lbl = QtWidgets.QLabel(" ")
  647. spacer_lbl.setFixedWidth(80)
  648. self.grid1.addWidget(self.tool_offset_entry, 0, 1)
  649. self.grid1.addWidget(spacer_lbl, 0, 2)
  650. #### Add a new Tool ####
  651. hlay = QtWidgets.QHBoxLayout()
  652. self.geo_tools_box.addLayout(hlay)
  653. # self.addtool_label = QtWidgets.QLabel('<b>Tool</b>')
  654. # self.addtool_label.setToolTip(
  655. # "Add/Copy/Delete a tool to the tool list."
  656. # )
  657. self.addtool_entry_lbl = QtWidgets.QLabel('<b>Tool Dia:</b>')
  658. self.addtool_entry_lbl.setToolTip(
  659. "Diameter for the new tool"
  660. )
  661. self.addtool_entry = FloatEntry()
  662. # hlay.addWidget(self.addtool_label)
  663. # hlay.addStretch()
  664. hlay.addWidget(self.addtool_entry_lbl)
  665. hlay.addWidget(self.addtool_entry)
  666. grid2 = QtWidgets.QGridLayout()
  667. self.geo_tools_box.addLayout(grid2)
  668. self.addtool_btn = QtWidgets.QPushButton('Add')
  669. self.addtool_btn.setToolTip(
  670. "Add a new tool to the Tool Table\n"
  671. "with the diameter specified above."
  672. )
  673. self.copytool_btn = QtWidgets.QPushButton('Copy')
  674. self.copytool_btn.setToolTip(
  675. "Copy a selection of tools in the Tool Table\n"
  676. "by first selecting a row in the Tool Table."
  677. )
  678. self.deltool_btn = QtWidgets.QPushButton('Delete')
  679. self.deltool_btn.setToolTip(
  680. "Delete a selection of tools in the Tool Table\n"
  681. "by first selecting a row in the Tool Table."
  682. )
  683. grid2.addWidget(self.addtool_btn, 0, 0)
  684. grid2.addWidget(self.copytool_btn, 0, 1)
  685. grid2.addWidget(self.deltool_btn, 0,2)
  686. self.empty_label = QtWidgets.QLabel('')
  687. self.geo_tools_box.addWidget(self.empty_label)
  688. #-----------------------------------
  689. # Create CNC Job
  690. #-----------------------------------
  691. #### Tools Data ####
  692. self.tool_data_label = QtWidgets.QLabel('<b>Tool Data</b>')
  693. self.tool_data_label.setToolTip(
  694. "The data used for creating GCode.\n"
  695. "Each tool store it's own set of such data."
  696. )
  697. self.geo_tools_box.addWidget(self.tool_data_label)
  698. self.grid3 = QtWidgets.QGridLayout()
  699. self.geo_tools_box.addLayout(self.grid3)
  700. # Tip Dia
  701. self.tipdialabel = QtWidgets.QLabel('V-Tip Dia:')
  702. self.tipdialabel.setToolTip(
  703. "The tip diameter for V-Shape Tool"
  704. )
  705. self.grid3.addWidget(self.tipdialabel, 1, 0)
  706. self.tipdia_entry = LengthEntry()
  707. self.grid3.addWidget(self.tipdia_entry, 1, 1)
  708. # Tip Angle
  709. self.tipanglelabel = QtWidgets.QLabel('V-Tip Angle:')
  710. self.tipanglelabel.setToolTip(
  711. "The tip angle for V-Shape Tool.\n"
  712. "In degree."
  713. )
  714. self.grid3.addWidget(self.tipanglelabel, 2, 0)
  715. self.tipangle_entry = LengthEntry()
  716. self.grid3.addWidget(self.tipangle_entry, 2, 1)
  717. # Cut Z
  718. cutzlabel = QtWidgets.QLabel('Cut Z:')
  719. cutzlabel.setToolTip(
  720. "Cutting depth (negative)\n"
  721. "below the copper surface."
  722. )
  723. self.grid3.addWidget(cutzlabel, 3, 0)
  724. self.cutz_entry = LengthEntry()
  725. self.grid3.addWidget(self.cutz_entry, 3, 1)
  726. # Multi-pass
  727. self.mpass_cb = FCCheckBox("Multi-Depth:")
  728. self.mpass_cb.setToolTip(
  729. "Use multiple passes to limit\n"
  730. "the cut depth in each pass. Will\n"
  731. "cut multiple times until Cut Z is\n"
  732. "reached.\n"
  733. "To the right, input the depth of \n"
  734. "each pass (positive value)."
  735. )
  736. self.grid3.addWidget(self.mpass_cb, 4, 0)
  737. self.maxdepth_entry = LengthEntry()
  738. self.maxdepth_entry.setToolTip(
  739. "Depth of each pass (positive)."
  740. )
  741. self.grid3.addWidget(self.maxdepth_entry, 4, 1)
  742. self.ois_mpass_geo = OptionalInputSection(self.mpass_cb, [self.maxdepth_entry])
  743. # Travel Z
  744. travelzlabel = QtWidgets.QLabel('Travel Z:')
  745. travelzlabel.setToolTip(
  746. "Height of the tool when\n"
  747. "moving without cutting."
  748. )
  749. self.grid3.addWidget(travelzlabel, 5, 0)
  750. self.travelz_entry = LengthEntry()
  751. self.grid3.addWidget(self.travelz_entry, 5, 1)
  752. # Tool change:
  753. self.toolchzlabel = QtWidgets.QLabel("Tool change Z:")
  754. self.toolchzlabel.setToolTip(
  755. "Z-axis position (height) for\n"
  756. "tool change."
  757. )
  758. self.toolchangeg_cb = FCCheckBox("Tool change")
  759. self.toolchangeg_cb.setToolTip(
  760. "Include tool-change sequence\n"
  761. "in G-Code (Pause for tool change)."
  762. )
  763. self.toolchangez_entry = LengthEntry()
  764. self.grid3.addWidget(self.toolchangeg_cb, 6, 0)
  765. self.grid3.addWidget(self.toolchzlabel, 7, 0)
  766. self.grid3.addWidget(self.toolchangez_entry, 7, 1)
  767. self.ois_tcz_geo = OptionalInputSection(self.toolchangeg_cb, [self.toolchangez_entry])
  768. # The Z value for the start move
  769. # startzlabel = QtWidgets.QLabel('Start move Z:')
  770. # startzlabel.setToolTip(
  771. # "Tool height just before starting the work.\n"
  772. # "Delete the value if you don't need this feature."
  773. #
  774. # )
  775. # self.grid3.addWidget(startzlabel, 8, 0)
  776. # self.gstartz_entry = FloatEntry()
  777. # self.grid3.addWidget(self.gstartz_entry, 8, 1)
  778. # The Z value for the end move
  779. endzlabel = QtWidgets.QLabel('End move Z:')
  780. endzlabel.setToolTip(
  781. "This is the height (Z) at which the CNC\n"
  782. "will go as the last move."
  783. )
  784. self.grid3.addWidget(endzlabel, 9, 0)
  785. self.gendz_entry = LengthEntry()
  786. self.grid3.addWidget(self.gendz_entry, 9, 1)
  787. # Feedrate X-Y
  788. frlabel = QtWidgets.QLabel('Feed Rate X-Y:')
  789. frlabel.setToolTip(
  790. "Cutting speed in the XY\n"
  791. "plane in units per minute"
  792. )
  793. self.grid3.addWidget(frlabel, 10, 0)
  794. self.cncfeedrate_entry = LengthEntry()
  795. self.grid3.addWidget(self.cncfeedrate_entry, 10, 1)
  796. # Feedrate Z (Plunge)
  797. frzlabel = QtWidgets.QLabel('Feed Rate Z (Plunge):')
  798. frzlabel.setToolTip(
  799. "Cutting speed in the Z\n"
  800. "plane in units per minute"
  801. )
  802. self.grid3.addWidget(frzlabel, 11, 0)
  803. self.cncplunge_entry = LengthEntry()
  804. self.grid3.addWidget(self.cncplunge_entry, 11, 1)
  805. # Feedrate rapids
  806. fr_rapidlabel = QtWidgets.QLabel('Feed Rate Rapids:')
  807. fr_rapidlabel.setToolTip(
  808. "Cutting speed in the XY\n"
  809. "plane in units per minute\n"
  810. "for the rapid movements"
  811. )
  812. self.grid3.addWidget(fr_rapidlabel, 12, 0)
  813. self.cncfeedrate_rapid_entry = LengthEntry()
  814. self.grid3.addWidget(self.cncfeedrate_rapid_entry, 12, 1)
  815. # Cut over 1st point in path
  816. self.extracut_cb = FCCheckBox('Cut over 1st pt')
  817. self.extracut_cb.setToolTip(
  818. "In order to remove possible\n"
  819. "copper leftovers where first cut\n"
  820. "meet with last cut, we generate an\n"
  821. "extended cut over the first cut section."
  822. )
  823. self.grid3.addWidget(self.extracut_cb, 13, 0)
  824. # Spindlespeed
  825. spdlabel = QtWidgets.QLabel('Spindle speed:')
  826. spdlabel.setToolTip(
  827. "Speed of the spindle\n"
  828. "in RPM (optional)"
  829. )
  830. self.grid3.addWidget(spdlabel, 14, 0)
  831. self.cncspindlespeed_entry = IntEntry(allow_empty=True)
  832. self.grid3.addWidget(self.cncspindlespeed_entry, 14, 1)
  833. # Dwell
  834. self.dwell_cb = FCCheckBox('Dwell:')
  835. self.dwell_cb.setToolTip(
  836. "Pause to allow the spindle to reach its\n"
  837. "speed before cutting."
  838. )
  839. self.dwelltime_entry = FCEntry()
  840. self.dwelltime_entry.setToolTip(
  841. "Number of milliseconds for spindle to dwell."
  842. )
  843. self.grid3.addWidget(self.dwell_cb, 15, 0)
  844. self.grid3.addWidget(self.dwelltime_entry, 15, 1)
  845. self.ois_dwell_geo = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  846. # postprocessor selection
  847. pp_label = QtWidgets.QLabel("PostProcessor:")
  848. pp_label.setToolTip(
  849. "The Postprocessor file that dictates\n"
  850. "Gcode output."
  851. )
  852. self.grid3.addWidget(pp_label, 16, 0)
  853. self.pp_geometry_name_cb = FCComboBox()
  854. self.pp_geometry_name_cb.setFocusPolicy(QtCore.Qt.StrongFocus)
  855. self.grid3.addWidget(self.pp_geometry_name_cb, 16, 1)
  856. warning_lbl = QtWidgets.QLabel(
  857. "Add at least one tool in the tool-table.\n"
  858. "Click the header to select all, or Ctrl + LMB\n"
  859. "for custom selection of tools.")
  860. self.grid3.addWidget(warning_lbl, 17, 0, 1, 2)
  861. # Button
  862. self.generate_cnc_button = QtWidgets.QPushButton('Generate')
  863. self.generate_cnc_button.setToolTip(
  864. "Generate the CNC Job object."
  865. )
  866. self.geo_tools_box.addWidget(self.generate_cnc_button)
  867. #------------------------------
  868. # Paint area
  869. #------------------------------
  870. self.paint_label = QtWidgets.QLabel('<b>Paint Area:</b>')
  871. self.paint_label.setToolTip(
  872. "Creates tool paths to cover the\n"
  873. "whole area of a polygon (remove\n"
  874. "all copper). You will be asked\n"
  875. "to click on the desired polygon."
  876. )
  877. self.geo_tools_box.addWidget(self.paint_label)
  878. # GO Button
  879. self.paint_tool_button = QtWidgets.QPushButton('Paint Tool')
  880. self.paint_tool_button.setToolTip(
  881. "Launch Paint Tool in Tools Tab."
  882. )
  883. self.geo_tools_box.addWidget(self.paint_tool_button)
  884. class CNCObjectUI(ObjectUI):
  885. """
  886. User interface for CNCJob objects.
  887. """
  888. def __init__(self, parent=None):
  889. """
  890. Creates the user interface for CNCJob objects. GUI elements should
  891. be placed in ``self.custom_box`` to preserve the layout.
  892. """
  893. ObjectUI.__init__(self, title='CNC Job Object', icon_file='share/cnc32.png', parent=parent)
  894. # Scale and offset ans skew are not available for CNCJob objects.
  895. # Hiding from the GUI.
  896. for i in range(0, self.scale_grid.count()):
  897. self.scale_grid.itemAt(i).widget().hide()
  898. self.scale_label.hide()
  899. self.scale_button.hide()
  900. for i in range(0, self.offset_grid.count()):
  901. self.offset_grid.itemAt(i).widget().hide()
  902. self.offset_label.hide()
  903. self.offset_button.hide()
  904. ## Plot options
  905. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  906. self.custom_box.addWidget(self.plot_options_label)
  907. # # Tool dia for plot
  908. # tdlabel = QtWidgets.QLabel('Tool dia:')
  909. # tdlabel.setToolTip(
  910. # "Diameter of the tool to be\n"
  911. # "rendered in the plot."
  912. # )
  913. # grid0.addWidget(tdlabel, 1, 0)
  914. # self.tooldia_entry = LengthEntry()
  915. # grid0.addWidget(self.tooldia_entry, 1, 1)
  916. hlay = QtWidgets.QHBoxLayout()
  917. self.custom_box.addLayout(hlay)
  918. # CNC Tools Table for plot
  919. self.cnc_tools_table_label = QtWidgets.QLabel('<b>CNC Tools Table</b>')
  920. self.cnc_tools_table_label.setToolTip(
  921. "Tools in this CNCJob object used for cutting.\n"
  922. "The tool diameter is used for plotting on canvas.\n"
  923. "The 'Offset' entry will set an offset for the cut.\n"
  924. "'Offset' can be inside, outside, on path (none) and custom.\n"
  925. "'Type' entry is only informative and it allow to know the \n"
  926. "intent of using the current tool. \n"
  927. "It can be Rough(ing), Finish(ing) or Iso(lation).\n"
  928. "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n"
  929. "ball(B), or V-Shaped(V)."
  930. )
  931. hlay.addWidget(self.cnc_tools_table_label)
  932. # Plot CB
  933. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  934. self.plot_cb = FCCheckBox('Plot Object')
  935. self.plot_cb.setToolTip(
  936. "Plot (show) this object."
  937. )
  938. self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  939. hlay.addStretch()
  940. hlay.addWidget(self.plot_cb)
  941. self.cnc_tools_table = FCTable()
  942. self.custom_box.addWidget(self.cnc_tools_table)
  943. # self.cnc_tools_table.setColumnCount(4)
  944. # self.cnc_tools_table.setHorizontalHeaderLabels(['#', 'Dia', 'Plot', ''])
  945. # self.cnc_tools_table.setColumnHidden(3, True)
  946. self.cnc_tools_table.setColumnCount(7)
  947. self.cnc_tools_table.setColumnWidth(0, 20)
  948. self.cnc_tools_table.setHorizontalHeaderLabels(['#', 'Dia', 'Offset', 'Type', 'TT', '', 'P'])
  949. self.cnc_tools_table.setColumnHidden(5, True)
  950. # Update plot button
  951. self.updateplot_button = QtWidgets.QPushButton('Update Plot')
  952. self.updateplot_button.setToolTip(
  953. "Update the plot."
  954. )
  955. self.custom_box.addWidget(self.updateplot_button)
  956. ##################
  957. ## Export G-Code
  958. ##################
  959. self.export_gcode_label = QtWidgets.QLabel("<b>Export CNC Code:</b>")
  960. self.export_gcode_label.setToolTip(
  961. "Export and save G-Code to\n"
  962. "make this object to a file."
  963. )
  964. self.custom_box.addWidget(self.export_gcode_label)
  965. # Prepend text to Gerber
  966. prependlabel = QtWidgets.QLabel('Prepend to CNC Code:')
  967. prependlabel.setToolTip(
  968. "Type here any G-Code commands you would\n"
  969. "like to add to the beginning of the generated file."
  970. )
  971. self.custom_box.addWidget(prependlabel)
  972. self.prepend_text = FCTextArea()
  973. self.custom_box.addWidget(self.prepend_text)
  974. # Append text to Gerber
  975. appendlabel = QtWidgets.QLabel('Append to CNC Code')
  976. appendlabel.setToolTip(
  977. "Type here any G-Code commands you would\n"
  978. "like to append to the generated file.\n"
  979. "I.e.: M2 (End of program)"
  980. )
  981. self.custom_box.addWidget(appendlabel)
  982. self.append_text = FCTextArea()
  983. self.custom_box.addWidget(self.append_text)
  984. h_lay = QtWidgets.QHBoxLayout()
  985. h_lay.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  986. self.custom_box.addLayout(h_lay)
  987. # Edit GCode Button
  988. self.modify_gcode_button = QtWidgets.QPushButton('Edit CNC Code')
  989. self.modify_gcode_button.setToolTip(
  990. "Opens TAB to modify/print G-Code\n"
  991. "file."
  992. )
  993. # GO Button
  994. self.export_gcode_button = QtWidgets.QPushButton('Save CNC Code')
  995. self.export_gcode_button.setToolTip(
  996. "Opens dialog to save G-Code\n"
  997. "file."
  998. )
  999. h_lay.addWidget(self.modify_gcode_button)
  1000. h_lay.addWidget(self.export_gcode_button)
  1001. # self.custom_box.addWidget(self.export_gcode_button)
  1002. # end of file