ObjectUI.py 93 KB

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