ObjectUI.py 91 KB

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