ObjectUI.py 110 KB

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