ObjectUI.py 94 KB

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