ObjectUI.py 90 KB

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