ObjectUI.py 106 KB

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