ObjectUI.py 109 KB

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