FlatCAMGUI.py 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739
  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. from PyQt5 import QtGui, QtCore, QtWidgets
  9. from PyQt5.QtCore import Qt
  10. from GUIElements import *
  11. import platform
  12. class FlatCAMGUI(QtWidgets.QMainWindow):
  13. # Emitted when persistent window geometry needs to be retained
  14. geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
  15. final_save = QtCore.pyqtSignal(name='saveBeforeExit')
  16. def __init__(self, version, beta, app):
  17. super(FlatCAMGUI, self).__init__()
  18. self.app = app
  19. # Divine icon pack by Ipapun @ finicons.com
  20. #####################################
  21. ### BUILDING THE GUI IS DONE HERE ###
  22. #####################################
  23. ############
  24. ### Menu ###
  25. ############
  26. self.menu = self.menuBar()
  27. ### File ###
  28. self.menufile = self.menu.addMenu('&File')
  29. # New
  30. self.menufilenew = QtWidgets.QAction(QtGui.QIcon('share/file16.png'), '&New Project ...\tCTRL+N', self)
  31. self.menufile.addAction(self.menufilenew)
  32. self.menufile_open = self.menufile.addMenu(QtGui.QIcon('share/folder32_bis.png'), 'Open')
  33. # Open gerber ...
  34. self.menufileopengerber = QtWidgets.QAction(QtGui.QIcon('share/flatcam_icon24.png'),
  35. 'Open &Gerber ...\tCTRL+G', self)
  36. self.menufile_open.addAction(self.menufileopengerber)
  37. # Open gerber with follow...
  38. self.menufileopengerber_follow = QtWidgets.QAction(QtGui.QIcon('share/flatcam_icon24.png'),
  39. 'Open &Gerber (w/ Follow) ...', self)
  40. self.menufile_open.addAction(self.menufileopengerber_follow)
  41. self.menufile_open.addSeparator()
  42. # Open Excellon ...
  43. self.menufileopenexcellon = QtWidgets.QAction(QtGui.QIcon('share/open_excellon32.png'),
  44. 'Open &Excellon ...\tCTRL+E',
  45. self)
  46. self.menufile_open.addAction(self.menufileopenexcellon)
  47. # Open G-Code ...
  48. self.menufileopengcode = QtWidgets.QAction(QtGui.QIcon('share/code.png'), 'Open G-&Code ...', self)
  49. self.menufile_open.addAction(self.menufileopengcode)
  50. # Open Project ...
  51. self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Project ...', self)
  52. self.menufile_open.addAction(self.menufileopenproject)
  53. # Recent
  54. self.recent = self.menufile.addMenu(QtGui.QIcon('share/recent_files.png'), "Recent files")
  55. # Separator
  56. self.menufile.addSeparator()
  57. # Run Scripts
  58. self.menufilerunscript = QtWidgets.QAction(QtGui.QIcon('share/script16.png'), 'Run Script ...\tSHIFT+S', self)
  59. self.menufile.addAction(self.menufilerunscript)
  60. # Separator
  61. self.menufile.addSeparator()
  62. # Import ...
  63. self.menufileimport = self.menufile.addMenu(QtGui.QIcon('share/import.png'), 'Import')
  64. self.menufileimportsvg = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  65. '&SVG as Geometry Object ...', self)
  66. self.menufileimport.addAction(self.menufileimportsvg)
  67. self.menufileimportsvg_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  68. '&SVG as Gerber Object ...', self)
  69. self.menufileimport.addAction(self.menufileimportsvg_as_gerber)
  70. self.menufileimport.addSeparator()
  71. self.menufileimportdxf = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  72. '&DXF as Geometry Object ...', self)
  73. self.menufileimport.addAction(self.menufileimportdxf)
  74. self.menufileimportdxf_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  75. '&DXF as Gerber Object ...', self)
  76. self.menufileimport.addAction(self.menufileimportdxf_as_gerber)
  77. self.menufileimport.addSeparator()
  78. # Export ...
  79. self.menufileexport = self.menufile.addMenu(QtGui.QIcon('share/export.png'), 'Export')
  80. self.menufileexportsvg = QtWidgets.QAction(QtGui.QIcon('share/export.png'), 'Export &SVG ...', self)
  81. self.menufileexport.addAction(self.menufileexportsvg)
  82. self.menufileexportdxf = QtWidgets.QAction(QtGui.QIcon('share/export.png'), 'Export DXF ...', self)
  83. self.menufileexport.addAction(self.menufileexportdxf)
  84. self.menufileexport.addSeparator()
  85. self.menufileexportpng = QtWidgets.QAction(QtGui.QIcon('share/export_png32.png'), 'Export &PNG ...', self)
  86. self.menufileexport.addAction(self.menufileexportpng)
  87. self.menufileexport.addSeparator()
  88. self.menufileexportexcellon = QtWidgets.QAction(QtGui.QIcon('share/drill32.png'), 'Export &Excellon ...', self)
  89. self.menufileexport.addAction(self.menufileexportexcellon)
  90. self.menufileexportexcellon_altium = QtWidgets.QAction(QtGui.QIcon('share/drill32.png'),
  91. 'Export Excellon 2:4 LZ INCH ...', self)
  92. self.menufileexport.addAction(self.menufileexportexcellon_altium)
  93. # Separator
  94. self.menufile.addSeparator()
  95. # Save Defaults
  96. self.menufilesavedefaults = QtWidgets.QAction(QtGui.QIcon('share/defaults.png'), 'Save &Defaults', self)
  97. self.menufile.addAction(self.menufilesavedefaults)
  98. # Separator
  99. self.menufile.addSeparator()
  100. self.menufile_save = self.menufile.addMenu(QtGui.QIcon('share/save_as.png'), 'Save')
  101. # Save Project
  102. self.menufilesaveproject = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), '&Save Project ...', self)
  103. self.menufile_save.addAction(self.menufilesaveproject)
  104. # Save Project As ...
  105. self.menufilesaveprojectas = QtWidgets.QAction(QtGui.QIcon('share/save_as.png'),
  106. 'Save Project &As ...\tCTRL+S', self)
  107. self.menufile_save.addAction(self.menufilesaveprojectas)
  108. # Save Project Copy ...
  109. self.menufilesaveprojectcopy = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), 'Save Project C&opy ...',
  110. self)
  111. self.menufile_save.addAction(self.menufilesaveprojectcopy)
  112. # Separator
  113. self.menufile.addSeparator()
  114. # Quit
  115. self.menufile_exit = QtWidgets.QAction(QtGui.QIcon('share/power16.png'), 'E&xit', self)
  116. # exitAction.setShortcut('Ctrl+Q')
  117. # exitAction.setStatusTip('Exit application')
  118. self.menufile.addAction(self.menufile_exit)
  119. ### Edit ###
  120. self.menuedit = self.menu.addMenu('&Edit')
  121. self.menueditnew = self.menuedit.addAction(QtGui.QIcon('share/new_geo16.png'), '&New Geometry\tN')
  122. self.menueditnewexc = self.menuedit.addAction(QtGui.QIcon('share/new_geo16.png'), 'New Excellon\tL')
  123. # Separator
  124. self.menuedit.addSeparator()
  125. self.menueditedit = self.menuedit.addAction(QtGui.QIcon('share/edit16.png'), 'Edit Object\tE')
  126. self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), 'Save && Close Editor\tCTRL+S')
  127. # Separator
  128. self.menuedit.addSeparator()
  129. self.menuedit_convert = self.menuedit.addMenu(QtGui.QIcon('share/convert24.png'), 'Conversion')
  130. self.menuedit_convertjoin = self.menuedit_convert.addAction(
  131. QtGui.QIcon('share/join16.png'), '&Join Geo/Gerber/Exc -> Geo')
  132. self.menuedit_convertjoin.setToolTip(
  133. "Merge a selection of objects, which can be of type:\n"
  134. "- Gerber\n"
  135. "- Excellon\n"
  136. "- Geometry\n"
  137. "into a new combo Geometry object.")
  138. self.menuedit_convertjoinexc = self.menuedit_convert.addAction(
  139. QtGui.QIcon('share/join16.png'), 'Join Excellon(s) -> Excellon')
  140. self.menuedit_convertjoinexc.setToolTip(
  141. "Merge a selection of Excellon objects into a new combo Excellon object.")
  142. self.menuedit_convertjoingrb = self.menuedit_convert.addAction(
  143. QtGui.QIcon('share/join16.png'), 'Join Gerber(s) -> Gerber')
  144. self.menuedit_convertjoingrb.setToolTip(
  145. "Merge a selection of Gerber objects into a new combo Gerber object.")
  146. # Separator
  147. self.menuedit_convert.addSeparator()
  148. self.menuedit_convert_sg2mg = self.menuedit_convert.addAction(
  149. QtGui.QIcon('share/convert24.png'), 'Convert Single to MultiGeo')
  150. self.menuedit_convert_sg2mg.setToolTip(
  151. "Will convert a Geometry object from single_geometry type\n"
  152. "to a multi_geometry type.")
  153. self.menuedit_convert_mg2sg = self.menuedit_convert.addAction(
  154. QtGui.QIcon('share/convert24.png'), 'Convert Multi to SingleGeo')
  155. self.menuedit_convert_mg2sg.setToolTip(
  156. "Will convert a Geometry object from multi_geometry type\n"
  157. "to a single_geometry type.")
  158. self.menuedit_convert.setToolTipsVisible(True)
  159. # Separator
  160. self.menuedit.addSeparator()
  161. self.menueditcopyobject = self.menuedit.addAction(QtGui.QIcon('share/copy.png'), '&Copy Object\tCTRL+C')
  162. self.menueditcopyobjectasgeom = self.menuedit.addAction(QtGui.QIcon('share/copy_geo.png'),
  163. 'Copy as &Geom')
  164. # Separator
  165. self.menuedit.addSeparator()
  166. self.menueditdelete = self.menuedit.addAction(QtGui.QIcon('share/trash16.png'), '&Delete\tDEL')
  167. # Separator
  168. self.menuedit.addSeparator()
  169. self.menueditorigin = self.menuedit.addAction(QtGui.QIcon('share/origin.png'), 'Se&t Origin\tO')
  170. self.menueditjump = self.menuedit.addAction(QtGui.QIcon('share/jump_to16.png'), 'Jump to Location\tJ')
  171. # Separator
  172. self.menuedit.addSeparator()
  173. self.menuedittoggleunits= self.menuedit.addAction(QtGui.QIcon('share/toggle_units16.png'),
  174. 'Toggle Units\tQ')
  175. self.menueditselectall = self.menuedit.addAction(QtGui.QIcon('share/select_all.png'),
  176. '&Select All\tCTRL+A')
  177. # Separator
  178. self.menuedit.addSeparator()
  179. self.menueditpreferences = self.menuedit.addAction(QtGui.QIcon('share/pref.png'), '&Preferences\tSHIFT+P')
  180. ### Options ###
  181. self.menuoptions = self.menu.addMenu('&Options')
  182. # self.menuoptions_transfer = self.menuoptions.addMenu(QtGui.QIcon('share/transfer.png'), 'Transfer options')
  183. # self.menuoptions_transfer_a2p = self.menuoptions_transfer.addAction("Application to Project")
  184. # self.menuoptions_transfer_p2a = self.menuoptions_transfer.addAction("Project to Application")
  185. # self.menuoptions_transfer_p2o = self.menuoptions_transfer.addAction("Project to Object")
  186. # self.menuoptions_transfer_o2p = self.menuoptions_transfer.addAction("Object to Project")
  187. # self.menuoptions_transfer_a2o = self.menuoptions_transfer.addAction("Application to Object")
  188. # self.menuoptions_transfer_o2a = self.menuoptions_transfer.addAction("Object to Application")
  189. # Separator
  190. # self.menuoptions.addSeparator()
  191. # self.menuoptions_transform = self.menuoptions.addMenu(QtGui.QIcon('share/transform.png'),
  192. # '&Transform Object')
  193. self.menuoptions_transform_rotate = self.menuoptions.addAction(QtGui.QIcon('share/rotate.png'),
  194. "&Rotate Selection\tSHIFT+(R)")
  195. # Separator
  196. self.menuoptions.addSeparator()
  197. self.menuoptions_transform_skewx = self.menuoptions.addAction(QtGui.QIcon('share/skewX.png'),
  198. "&Skew on X axis\tSHIFT+X")
  199. self.menuoptions_transform_skewy = self.menuoptions.addAction(QtGui.QIcon('share/skewY.png'),
  200. "S&kew on Y axis\tSHIFT+Y")
  201. # Separator
  202. self.menuoptions.addSeparator()
  203. self.menuoptions_transform_flipx = self.menuoptions.addAction(QtGui.QIcon('share/flipx.png'),
  204. "Flip on &X axis\tX")
  205. self.menuoptions_transform_flipy = self.menuoptions.addAction(QtGui.QIcon('share/flipy.png'),
  206. "Flip on &Y axis\tY")
  207. # Separator
  208. self.menuoptions.addSeparator()
  209. ### View ###
  210. self.menuview = self.menu.addMenu('&View')
  211. self.menuviewenable = self.menuview.addAction(QtGui.QIcon('share/replot16.png'), 'Enable all plots')
  212. self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  213. 'Disable all plots')
  214. self.menuviewdisableother = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  215. 'Disable non-selected')
  216. # Separator
  217. self.menuview.addSeparator()
  218. self.menuview_zoom_fit = self.menuview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "&Zoom Fit\t1")
  219. self.menuview_zoom_in = self.menuview.addAction(QtGui.QIcon('share/zoom_in32.png'), "&Zoom In\t2")
  220. self.menuview_zoom_out = self.menuview.addAction(QtGui.QIcon('share/zoom_out32.png'), "&Zoom Out\t3")
  221. self.menuview.addSeparator()
  222. self.menuview_toggle_grid = self.menuview.addAction(QtGui.QIcon('share/grid32.png'), "&Toggle Grid\tG")
  223. self.menuview_toggle_axis = self.menuview.addAction(QtGui.QIcon('share/axis32.png'), "&Toggle Axis\tSHIFT+G")
  224. self.menuview_toggle_workspace = self.menuview.addAction(QtGui.QIcon('share/workspace24.png'),
  225. "Toggle Workspace\tSHIFT+W")
  226. ### FlatCAM Editor menu ###
  227. # self.editor_menu = QtWidgets.QMenu("Editor")
  228. # self.menu.addMenu(self.editor_menu)
  229. self.geo_editor_menu = QtWidgets.QMenu("Geo Editor")
  230. self.menu.addMenu(self.geo_editor_menu)
  231. # self.select_menuitem = self.menu.addAction(QtGui.QIcon('share/pointer16.png'), "Select 'Esc'")
  232. self.geo_add_circle_menuitem = self.geo_editor_menu.addAction(
  233. QtGui.QIcon('share/circle32.png'), 'Add Circle\tO'
  234. )
  235. self.geo_add_arc_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/arc16.png'), 'Add Arc\tA')
  236. self.geo_editor_menu.addSeparator()
  237. self.geo_add_rectangle_menuitem = self.geo_editor_menu.addAction(
  238. QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle\tR'
  239. )
  240. self.geo_add_polygon_menuitem = self.geo_editor_menu.addAction(
  241. QtGui.QIcon('share/polygon32.png'), 'Add Polygon\tN'
  242. )
  243. self.geo_add_path_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/path32.png'), 'Add Path\tP')
  244. self.geo_editor_menu.addSeparator()
  245. self.geo_add_text_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/text32.png'), 'Add Text\tT')
  246. self.geo_editor_menu.addSeparator()
  247. self.geo_union_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/union16.png'), 'Polygon Union\tU')
  248. self.geo_intersection_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/intersection16.png'),
  249. 'Polygon Intersection\tE')
  250. self.geo_subtract_menuitem = self.geo_editor_menu.addAction(
  251. QtGui.QIcon('share/subtract16.png'), 'Polygon Subtraction\tS'
  252. )
  253. self.geo_editor_menu.addSeparator()
  254. self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/cutpath16.png'), 'Cut Path\tX')
  255. # self.move_menuitem = self.menu.addAction(QtGui.QIcon('share/move16.png'), "Move Objects 'm'")
  256. self.geo_copy_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/copy16.png'), "Copy Geom\tC")
  257. self.geo_delete_menuitem = self.geo_editor_menu.addAction(
  258. QtGui.QIcon('share/deleteshape16.png'), "Delete Shape\tDEL"
  259. )
  260. self.geo_editor_menu.addSeparator()
  261. self.geo_move_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/move32.png'), "Move\tM")
  262. self.geo_buffer_menuitem = self.geo_editor_menu.addAction(
  263. QtGui.QIcon('share/buffer16.png'), "Buffer Selection\tB"
  264. )
  265. self.geo_paint_menuitem = self.geo_editor_menu.addAction(
  266. QtGui.QIcon('share/paint16.png'), "Paint Selection\tI"
  267. )
  268. self.geo_editor_menu.addSeparator()
  269. self.geo_cornersnap_menuitem = self.geo_editor_menu.addAction(
  270. QtGui.QIcon('share/corner32.png'), "Toggle Corner Snap\tK"
  271. )
  272. # self.exc_editor_menu = QtWidgets.QMenu("Excellon Editor")
  273. # self.menu.addMenu(self.exc_editor_menu)
  274. self.geo_editor_menu.setDisabled(True)
  275. # self.exc_editor_menu.setDisabled(True)
  276. ### Tool ###
  277. # self.menutool = self.menu.addMenu('&Tool')
  278. self.menutool = QtWidgets.QMenu('&Tool')
  279. self.menutoolaction = self.menu.addMenu(self.menutool)
  280. self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), '&Command Line\tS')
  281. ### Help ###
  282. self.menuhelp = self.menu.addMenu('&Help')
  283. self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/tv16.png'), 'About FlatCAM')
  284. self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), 'Home')
  285. self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), 'Manual\tF1')
  286. self.menuhelp.addSeparator()
  287. self.menuhelp_shortcut_list = self.menuhelp.addAction(QtGui.QIcon('share/shortcuts24.png'), 'Shortcuts List\t`')
  288. self.menuhelp_videohelp = self.menuhelp.addAction(QtGui.QIcon('share/videohelp24.png'), 'See on YouTube\tF2')
  289. ################################
  290. ### Project Tab Context menu ###
  291. ################################
  292. self.menuproject = QtWidgets.QMenu()
  293. self.menuprojectenable = self.menuproject.addAction(QtGui.QIcon('share/replot32.png'), 'Enable Plot')
  294. self.menuprojectdisable = self.menuproject.addAction(QtGui.QIcon('share/clear_plot32.png'), 'Disable Plot')
  295. self.menuproject.addSeparator()
  296. self.menuprojectgeneratecnc = self.menuproject.addAction(QtGui.QIcon('share/cnc32.png'), 'Generate CNC')
  297. self.menuproject.addSeparator()
  298. self.menuprojectcopy = self.menuproject.addAction(QtGui.QIcon('share/copy32.png'), 'Copy')
  299. self.menuprojectdelete = self.menuproject.addAction(QtGui.QIcon('share/delete32.png'), 'Delete')
  300. self.menuprojectedit = self.menuproject.addAction(QtGui.QIcon('share/edit_ok32.png'), 'Edit')
  301. self.menuproject.addSeparator()
  302. self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), 'Properties')
  303. ###############
  304. ### Toolbar ###
  305. ###############
  306. self.toolbarfile = QtWidgets.QToolBar('File Toolbar')
  307. self.addToolBar(self.toolbarfile)
  308. self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
  309. "Open GERBER")
  310. self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), "Open EXCELLON")
  311. self.toolbarfile.addSeparator()
  312. self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), "Open project")
  313. self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), "Save project")
  314. self.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
  315. self.addToolBar(self.toolbargeo)
  316. self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "New Blank Geometry")
  317. self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), "New Blank Excellon")
  318. self.toolbargeo.addSeparator()
  319. self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), "Editor")
  320. self.update_obj_btn = self.toolbargeo.addAction(
  321. QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object and close the Editor"
  322. )
  323. self.update_obj_btn.setEnabled(False)
  324. self.toolbargeo.addSeparator()
  325. self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), "&Delete")
  326. self.toolbarview = QtWidgets.QToolBar('View Toolbar')
  327. self.addToolBar(self.toolbarview)
  328. self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
  329. self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear plot")
  330. self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), "Zoom In")
  331. self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), "Zoom Out")
  332. self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
  333. # self.toolbarview.setVisible(False)
  334. self.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
  335. self.addToolBar(self.toolbartools)
  336. self.shell_btn = self.toolbartools.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
  337. ### Drill Editor Toolbar ###
  338. self.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
  339. self.addToolBar(self.exc_edit_toolbar)
  340. self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  341. self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), 'Add Drill Hole')
  342. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  343. QtGui.QIcon('share/addarray16.png'), 'Add Drill Hole Array')
  344. self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), 'Resize Drill')
  345. self.exc_edit_toolbar.addSeparator()
  346. self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), 'Copy Drill')
  347. self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Drill")
  348. self.exc_edit_toolbar.addSeparator()
  349. self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Drill")
  350. self.exc_edit_toolbar.setDisabled(True)
  351. self.exc_edit_toolbar.setVisible(False)
  352. ### Geometry Editor Toolbar ###
  353. self.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
  354. self.geo_edit_toolbar.setVisible(False)
  355. self.addToolBar(self.geo_edit_toolbar)
  356. self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  357. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), 'Add Circle')
  358. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), 'Add Arc')
  359. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle')
  360. self.geo_edit_toolbar.addSeparator()
  361. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
  362. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
  363. self.geo_edit_toolbar.addSeparator()
  364. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), 'Add Text')
  365. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), 'Add Buffer')
  366. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), 'Paint Shape')
  367. self.geo_edit_toolbar.addSeparator()
  368. self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), 'Polygon Union')
  369. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
  370. 'Polygon Intersection')
  371. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'), 'Polygon Subtraction')
  372. self.geo_edit_toolbar.addSeparator()
  373. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), 'Cut Path')
  374. self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), "Copy Objects 'c'")
  375. self.geo_rotate_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rotate.png'), "Rotate Objects 'Space'")
  376. self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Shape '-'")
  377. self.geo_edit_toolbar.addSeparator()
  378. self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Objects 'm'")
  379. ### Snap Toolbar ###
  380. self.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
  381. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  382. self.addToolBar(self.snap_toolbar)
  383. self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), 'Snap to grid')
  384. self.grid_gap_x_entry = FCEntry2()
  385. self.grid_gap_x_entry.setMaximumWidth(70)
  386. self.grid_gap_x_entry.setToolTip("Grid X distance")
  387. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  388. self.grid_gap_y_entry = FCEntry2()
  389. self.grid_gap_y_entry.setMaximumWidth(70)
  390. self.grid_gap_y_entry.setToolTip("Grid Y distance")
  391. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  392. self.grid_space_label = QtWidgets.QLabel(" ")
  393. self.snap_toolbar.addWidget(self.grid_space_label)
  394. self.grid_gap_link_cb = FCCheckBox()
  395. self.grid_gap_link_cb.setToolTip("When active, value on Grid_X\n"
  396. "is copied to the Grid_Y value.")
  397. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  398. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  399. self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), 'Snap to corner')
  400. self.snap_max_dist_entry = QtWidgets.QLineEdit()
  401. self.snap_max_dist_entry.setMaximumWidth(70)
  402. self.snap_max_dist_entry.setToolTip("Max. magnet distance")
  403. self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  404. self.grid_snap_btn.setCheckable(True)
  405. self.corner_snap_btn.setCheckable(True)
  406. ################
  407. ### Splitter ###
  408. ################
  409. self.splitter = QtWidgets.QSplitter()
  410. self.setCentralWidget(self.splitter)
  411. ################
  412. ### Notebook ###
  413. ################
  414. self.notebook = QtWidgets.QTabWidget()
  415. self.splitter.addWidget(self.notebook)
  416. ### Project ###
  417. self.project_tab = QtWidgets.QWidget()
  418. # project_tab.setMinimumWidth(250) # Hack
  419. self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_tab)
  420. self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
  421. self.notebook.addTab(self.project_tab, "Project")
  422. ### Selected ###
  423. self.selected_tab = QtWidgets.QWidget()
  424. self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
  425. self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
  426. self.selected_scroll_area = VerticalScrollArea()
  427. self.selected_tab_layout.addWidget(self.selected_scroll_area)
  428. self.notebook.addTab(self.selected_tab, "Selected")
  429. ### Tool ###
  430. self.tool_tab = QtWidgets.QWidget()
  431. self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
  432. self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
  433. self.notebook.addTab(self.tool_tab, "Tool")
  434. self.tool_scroll_area = VerticalScrollArea()
  435. self.tool_tab_layout.addWidget(self.tool_scroll_area)
  436. self.right_widget = QtWidgets.QWidget()
  437. self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
  438. self.splitter.addWidget(self.right_widget)
  439. self.right_lay = QtWidgets.QVBoxLayout()
  440. self.right_lay.setContentsMargins(0, 0, 0, 0)
  441. self.right_widget.setLayout(self.right_lay)
  442. self.plot_tab_area = FCTab()
  443. self.right_lay.addWidget(self.plot_tab_area)
  444. self.plot_tab_area.setTabsClosable(True)
  445. plot_tab = QtWidgets.QWidget()
  446. self.plot_tab_area.addTab(plot_tab, "Plot Area")
  447. self.right_layout = QtWidgets.QVBoxLayout()
  448. self.right_layout.setContentsMargins(2, 2, 2, 2)
  449. plot_tab.setLayout(self.right_layout)
  450. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  451. self.plot_tab_area.protectTab(0)
  452. ########################################
  453. ### HERE WE BUILD THE PREF. TAB AREA ###
  454. ########################################
  455. self.preferences_tab = QtWidgets.QWidget()
  456. self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
  457. self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
  458. self.pref_tab_area = FCTab()
  459. self.pref_tab_area.setTabsClosable(False)
  460. self.pref_tab_area_tabBar = self.pref_tab_area.tabBar()
  461. self.pref_tab_area_tabBar.setStyleSheet("QTabBar::tab{width:80px;}")
  462. self.pref_tab_area_tabBar.setExpanding(True)
  463. self.pref_tab_layout.addWidget(self.pref_tab_area)
  464. self.general_tab = QtWidgets.QWidget()
  465. self.pref_tab_area.addTab(self.general_tab, "General")
  466. self.general_tab_lay = QtWidgets.QVBoxLayout()
  467. self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
  468. self.general_tab.setLayout(self.general_tab_lay)
  469. self.hlay1 = QtWidgets.QHBoxLayout()
  470. self.general_tab_lay.addLayout(self.hlay1)
  471. self.options_combo = QtWidgets.QComboBox()
  472. self.options_combo.addItem("APP. DEFAULTS")
  473. self.options_combo.addItem("PROJ. OPTIONS ")
  474. self.hlay1.addWidget(self.options_combo)
  475. # disable this button as it may no longer be useful
  476. self.options_combo.setVisible(False)
  477. self.hlay1.addStretch()
  478. self.general_scroll_area = VerticalScrollArea()
  479. self.general_tab_lay.addWidget(self.general_scroll_area)
  480. self.gerber_tab = QtWidgets.QWidget()
  481. self.pref_tab_area.addTab(self.gerber_tab, "GERBER")
  482. self.gerber_tab_lay = QtWidgets.QVBoxLayout()
  483. self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
  484. self.gerber_tab.setLayout(self.gerber_tab_lay)
  485. self.gerber_scroll_area = VerticalScrollArea()
  486. self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
  487. self.excellon_tab = QtWidgets.QWidget()
  488. self.pref_tab_area.addTab(self.excellon_tab, "EXCELLON")
  489. self.excellon_tab_lay = QtWidgets.QVBoxLayout()
  490. self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
  491. self.excellon_tab.setLayout(self.excellon_tab_lay)
  492. self.excellon_scroll_area = VerticalScrollArea()
  493. self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
  494. self.geometry_tab = QtWidgets.QWidget()
  495. self.pref_tab_area.addTab(self.geometry_tab, "GEOMETRY")
  496. self.geometry_tab_lay = QtWidgets.QVBoxLayout()
  497. self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
  498. self.geometry_tab.setLayout(self.geometry_tab_lay)
  499. self.geometry_scroll_area = VerticalScrollArea()
  500. self.geometry_tab_lay.addWidget(self.geometry_scroll_area)
  501. self.cncjob_tab = QtWidgets.QWidget()
  502. self.pref_tab_area.addTab(self.cncjob_tab, "CNC-JOB")
  503. self.cncjob_tab_lay = QtWidgets.QVBoxLayout()
  504. self.cncjob_tab_lay.setContentsMargins(2, 2, 2, 2)
  505. self.cncjob_tab.setLayout(self.cncjob_tab_lay)
  506. self.cncjob_scroll_area = VerticalScrollArea()
  507. self.cncjob_tab_lay.addWidget(self.cncjob_scroll_area)
  508. self.tools_tab = QtWidgets.QWidget()
  509. self.pref_tab_area.addTab(self.tools_tab, "TOOLS")
  510. self.tools_tab_lay = QtWidgets.QVBoxLayout()
  511. self.tools_tab_lay.setContentsMargins(2, 2, 2, 2)
  512. self.tools_tab.setLayout(self.tools_tab_lay)
  513. self.tools_scroll_area = VerticalScrollArea()
  514. self.tools_tab_lay.addWidget(self.tools_scroll_area)
  515. self.pref_tab_bottom_layout = QtWidgets.QHBoxLayout()
  516. self.pref_tab_bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
  517. self.pref_tab_layout.addLayout(self.pref_tab_bottom_layout)
  518. self.pref_tab_bottom_layout_1 = QtWidgets.QHBoxLayout()
  519. self.pref_tab_bottom_layout_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  520. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_1)
  521. self.pref_import_button = QtWidgets.QPushButton()
  522. self.pref_import_button.setText("Import Preferences")
  523. self.pref_import_button.setFixedWidth(130)
  524. self.pref_import_button.setToolTip(
  525. "Import a full set of FlatCAM settings from a file\n"
  526. "previously saved on HDD.\n\n"
  527. "FlatCAM automatically save a 'factory_defaults' file\n"
  528. "on the first start. Do not delete that file.")
  529. self.pref_tab_bottom_layout_1.addWidget(self.pref_import_button)
  530. self.pref_export_button = QtWidgets.QPushButton()
  531. self.pref_export_button.setText("Export Preferences")
  532. self.pref_export_button.setFixedWidth(130)
  533. self.pref_export_button.setToolTip(
  534. "Export a full set of FlatCAM settings in a file\n"
  535. "that is saved on HDD.")
  536. self.pref_tab_bottom_layout_1.addWidget(self.pref_export_button)
  537. self.pref_open_button = QtWidgets.QPushButton()
  538. self.pref_open_button.setText("Open Pref Folder")
  539. self.pref_open_button.setFixedWidth(130)
  540. self.pref_open_button.setToolTip(
  541. "Open the folder where FlatCAM save the preferences files.")
  542. self.pref_tab_bottom_layout_1.addWidget(self.pref_open_button)
  543. self.pref_tab_bottom_layout_2 = QtWidgets.QHBoxLayout()
  544. self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  545. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2)
  546. self.pref_save_button = QtWidgets.QPushButton()
  547. self.pref_save_button.setText("Save Preferences")
  548. self.pref_save_button.setFixedWidth(130)
  549. self.pref_save_button.setToolTip(
  550. "Save the current settings in the 'current_defaults' file\n"
  551. "which is the file storing the working default preferences.")
  552. self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
  553. ##############################################################
  554. ### HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS ###
  555. ##############################################################
  556. self.popMenu = QtWidgets.QMenu()
  557. self.cmenu_newmenu = self.popMenu.addMenu(QtGui.QIcon('share/file32.png'), "New")
  558. self.popmenu_new_geo = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "Geo Obj")
  559. self.popmenu_new_exc = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_exc32.png'), "Exc. Obj")
  560. self.cmenu_newmenu.addSeparator()
  561. self.popmenu_new_prj = self.cmenu_newmenu.addAction(QtGui.QIcon('share/file16.png'), "Project")
  562. self.popMenu.addSeparator()
  563. self.cmenu_gridmenu = self.popMenu.addMenu(QtGui.QIcon('share/grid32_menu.png'), "Grids")
  564. self.gridmenu_1 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.05")
  565. self.gridmenu_2 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.10")
  566. self.gridmenu_3 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.20")
  567. self.gridmenu_4 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.50")
  568. self.gridmenu_5 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "1.00")
  569. self.cmenu_viewmenu = self.popMenu.addMenu(QtGui.QIcon('share/view64.png'), "View")
  570. self.zoomfit = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
  571. self.clearplot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/clear_plot32.png'), "Clear Plot")
  572. self.replot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/replot32.png'), "Replot")
  573. self.popMenu.addSeparator()
  574. self.g_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/draw32.png'), "Geo Editor")
  575. self.draw_line = self.g_editor_cmenu.addAction(QtGui.QIcon('share/path32.png'), "Line")
  576. self.draw_rect = self.g_editor_cmenu.addAction(QtGui.QIcon('share/rectangle32.png'), "Rectangle")
  577. self.draw_cut = self.g_editor_cmenu.addAction(QtGui.QIcon('share/cutpath32.png'), "Cut")
  578. self.g_editor_cmenu.addSeparator()
  579. self.draw_move = self.g_editor_cmenu.addAction(QtGui.QIcon('share/move32.png'), "Move")
  580. self.e_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/drill32.png'), "Exc Editor")
  581. self.drill = self.e_editor_cmenu.addAction(QtGui.QIcon('share/drill32.png'), "Add Drill")
  582. self.drill_array = self.e_editor_cmenu.addAction(QtGui.QIcon('share/addarray32.png'), "Add Drill Array")
  583. self.drill_copy = self.e_editor_cmenu.addAction(QtGui.QIcon('share/copy32.png'), "Copy Drill(s)")
  584. self.popMenu.addSeparator()
  585. self.popmenu_copy = self.popMenu.addAction(QtGui.QIcon('share/copy32.png'), "Copy")
  586. self.popmenu_delete = self.popMenu.addAction(QtGui.QIcon('share/delete32.png'), "Delete")
  587. self.popmenu_edit = self.popMenu.addAction(QtGui.QIcon('share/edit32.png'), "Edit")
  588. self.popmenu_save = self.popMenu.addAction(QtGui.QIcon('share/floppy32.png'), "Save && Close Edit")
  589. self.popmenu_save.setVisible(False)
  590. self.popMenu.addSeparator()
  591. self.popmenu_move = self.popMenu.addAction(QtGui.QIcon('share/move32.png'), "Move")
  592. self.popmenu_properties = self.popMenu.addAction(QtGui.QIcon('share/properties32.png'), "Properties")
  593. ####################################
  594. ### Here we build the CNCJob Tab ###
  595. ####################################
  596. self.cncjob_tab = QtWidgets.QWidget()
  597. self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_tab)
  598. self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
  599. self.cncjob_tab.setLayout(self.cncjob_tab_layout)
  600. self.code_editor = QtWidgets.QTextEdit()
  601. stylesheet = """
  602. QTextEdit { selection-background-color:yellow;
  603. selection-color:black;
  604. }
  605. """
  606. self.code_editor.setStyleSheet(stylesheet)
  607. self.buttonPreview = QtWidgets.QPushButton('Print Preview')
  608. self.buttonPrint = QtWidgets.QPushButton('Print CNC Code')
  609. self.buttonFind = QtWidgets.QPushButton('Find in CNC Code')
  610. self.buttonFind.setFixedWidth(100)
  611. self.buttonPreview.setFixedWidth(100)
  612. self.entryFind = FCEntry()
  613. self.entryFind.setMaximumWidth(200)
  614. self.buttonReplace = QtWidgets.QPushButton('Replace With')
  615. self.buttonReplace.setFixedWidth(100)
  616. self.entryReplace = FCEntry()
  617. self.entryReplace.setMaximumWidth(200)
  618. self.sel_all_cb = QtWidgets.QCheckBox('All')
  619. self.sel_all_cb.setToolTip(
  620. "When checked it will replace all instances in the 'Find' box\n"
  621. "with the text in the 'Replace' box.."
  622. )
  623. self.buttonOpen = QtWidgets.QPushButton('Open CNC Code')
  624. self.buttonSave = QtWidgets.QPushButton('Save CNC Code')
  625. self.cncjob_tab_layout.addWidget(self.code_editor, 0, 0, 1, 5)
  626. cnc_tab_lay_1 = QtWidgets.QHBoxLayout()
  627. cnc_tab_lay_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  628. cnc_tab_lay_1.addWidget(self.buttonFind)
  629. cnc_tab_lay_1.addWidget(self.entryFind)
  630. cnc_tab_lay_1.addWidget(self.buttonReplace)
  631. cnc_tab_lay_1.addWidget(self.entryReplace)
  632. cnc_tab_lay_1.addWidget(self.sel_all_cb)
  633. self.cncjob_tab_layout.addLayout(cnc_tab_lay_1, 1, 0, 1, 1, QtCore.Qt.AlignLeft)
  634. cnc_tab_lay_3 = QtWidgets.QHBoxLayout()
  635. cnc_tab_lay_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  636. cnc_tab_lay_3.addWidget(self.buttonPreview)
  637. cnc_tab_lay_3.addWidget(self.buttonPrint)
  638. self.cncjob_tab_layout.addLayout(cnc_tab_lay_3, 2, 0, 1, 1, QtCore.Qt.AlignLeft)
  639. cnc_tab_lay_4 = QtWidgets.QHBoxLayout()
  640. cnc_tab_lay_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  641. cnc_tab_lay_4.addWidget(self.buttonOpen)
  642. cnc_tab_lay_4.addWidget(self.buttonSave)
  643. self.cncjob_tab_layout.addLayout(cnc_tab_lay_4, 2, 4, 1, 1)
  644. ##################################
  645. ### Build InfoBar is done here ###
  646. ##################################
  647. self.infobar = self.statusBar()
  648. self.fcinfo = FlatCAMInfoBar()
  649. self.infobar.addWidget(self.fcinfo, stretch=1)
  650. self.rel_position_label = QtWidgets.QLabel(
  651. "<b>Dx</b>: 0.0000&nbsp;&nbsp; <b>Dy</b>: 0.0000&nbsp;&nbsp;&nbsp;&nbsp;")
  652. self.rel_position_label.setMinimumWidth(110)
  653. self.rel_position_label.setToolTip("Relative neasurement.\nReference is last click position")
  654. self.infobar.addWidget(self.rel_position_label)
  655. self.position_label = QtWidgets.QLabel(
  656. "&nbsp;&nbsp;&nbsp;&nbsp;<b>X</b>: 0.0000&nbsp;&nbsp; <b>Y</b>: 0.0000")
  657. self.position_label.setMinimumWidth(110)
  658. self.position_label.setToolTip("Absolute neasurement.\nReference is (X=0, Y= 0) position")
  659. self.infobar.addWidget(self.position_label)
  660. self.units_label = QtWidgets.QLabel("[in]")
  661. self.units_label.setMargin(2)
  662. self.infobar.addWidget(self.units_label)
  663. # disabled
  664. self.progress_bar = QtWidgets.QProgressBar()
  665. self.progress_bar.setMinimum(0)
  666. self.progress_bar.setMaximum(100)
  667. # infobar.addWidget(self.progress_bar)
  668. self.activity_view = FlatCAMActivityView()
  669. self.infobar.addWidget(self.activity_view)
  670. self.app_icon = QtGui.QIcon()
  671. self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
  672. self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
  673. self.app_icon.addFile('share/flatcam_icon32.png', QtCore.QSize(32, 32))
  674. self.app_icon.addFile('share/flatcam_icon48.png', QtCore.QSize(48, 48))
  675. self.app_icon.addFile('share/flatcam_icon128.png', QtCore.QSize(128, 128))
  676. self.app_icon.addFile('share/flatcam_icon256.png', QtCore.QSize(256, 256))
  677. self.setWindowIcon(self.app_icon)
  678. self.setGeometry(100, 100, 1024, 650)
  679. self.setWindowTitle('FlatCAM %s %s - %s' % (version, ('BETA' if beta else ''), platform.architecture()[0]))
  680. self.show()
  681. self.filename = ""
  682. self.setAcceptDrops(True)
  683. def dragEnterEvent(self, event):
  684. if event.mimeData().hasUrls:
  685. event.accept()
  686. else:
  687. event.ignore()
  688. def dragMoveEvent(self, event):
  689. if event.mimeData().hasUrls:
  690. event.accept()
  691. else:
  692. event.ignore()
  693. def dropEvent(self, event):
  694. if event.mimeData().hasUrls:
  695. event.setDropAction(QtCore.Qt.CopyAction)
  696. event.accept()
  697. for url in event.mimeData().urls():
  698. self.filename = str(url.toLocalFile())
  699. if self.filename == "":
  700. self.app.inform.emit("Open cancelled.")
  701. else:
  702. if self.filename.lower().rpartition('.')[-1] in self.app.grb_list:
  703. self.app.worker_task.emit({'fcn': self.app.open_gerber,
  704. 'params': [self.filename]})
  705. else:
  706. event.ignore()
  707. if self.filename.lower().rpartition('.')[-1] in self.app.exc_list:
  708. self.app.worker_task.emit({'fcn': self.app.open_excellon,
  709. 'params': [self.filename]})
  710. else:
  711. event.ignore()
  712. if self.filename.lower().rpartition('.')[-1] in self.app.gcode_list:
  713. self.app.worker_task.emit({'fcn': self.app.open_gcode,
  714. 'params': [self.filename]})
  715. else:
  716. event.ignore()
  717. if self.filename.lower().rpartition('.')[-1] in self.app.svg_list:
  718. object_type = 'geometry'
  719. self.app.worker_task.emit({'fcn': self.app.import_svg,
  720. 'params': [self.filename, object_type, None]})
  721. if self.filename.lower().rpartition('.')[-1] in self.app.dxf_list:
  722. object_type = 'geometry'
  723. self.app.worker_task.emit({'fcn': self.app.import_dxf,
  724. 'params': [self.filename, object_type, None]})
  725. if self.filename.lower().rpartition('.')[-1] in self.app.prj_list:
  726. # self.app.open_project() is not Thread Safe
  727. self.app.open_project(self.filename)
  728. else:
  729. event.ignore()
  730. else:
  731. event.ignore()
  732. def closeEvent(self, event):
  733. grect = self.geometry()
  734. # self.splitter.sizes()[0] is actually the size of the "notebook"
  735. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  736. self.final_save.emit()
  737. if self.app.should_we_quit is True:
  738. QtWidgets.qApp.quit()
  739. else:
  740. self.app.should_we_quit = True
  741. event.ignore()
  742. class GeneralPreferencesUI(QtWidgets.QWidget):
  743. def __init__(self, parent=None):
  744. QtWidgets.QWidget.__init__(self, parent=parent)
  745. self.layout = QtWidgets.QHBoxLayout()
  746. self.setLayout(self.layout)
  747. self.general_app_group = GeneralAppPrefGroupUI()
  748. self.general_app_group.setFixedWidth(260)
  749. self.general_gui_group = GeneralGUIPrefGroupUI()
  750. self.general_gui_group.setFixedWidth(260)
  751. self.layout.addWidget(self.general_app_group)
  752. self.layout.addWidget(self.general_gui_group)
  753. self.layout.addStretch()
  754. class GerberPreferencesUI(QtWidgets.QWidget):
  755. def __init__(self, parent=None):
  756. QtWidgets.QWidget.__init__(self, parent=parent)
  757. self.layout = QtWidgets.QHBoxLayout()
  758. self.setLayout(self.layout)
  759. self.gerber_gen_group = GerberGenPrefGroupUI()
  760. self.gerber_gen_group.setFixedWidth(260)
  761. self.gerber_opt_group = GerberOptPrefGroupUI()
  762. self.gerber_opt_group.setFixedWidth(260)
  763. self.layout.addWidget(self.gerber_gen_group)
  764. self.layout.addWidget(self.gerber_opt_group)
  765. self.layout.addStretch()
  766. class ExcellonPreferencesUI(QtWidgets.QWidget):
  767. def __init__(self, parent=None):
  768. QtWidgets.QWidget.__init__(self, parent=parent)
  769. self.layout = QtWidgets.QHBoxLayout()
  770. self.setLayout(self.layout)
  771. self.excellon_gen_group = ExcellonGenPrefGroupUI()
  772. self.excellon_gen_group.setFixedWidth(260)
  773. self.excellon_opt_group = ExcellonOptPrefGroupUI()
  774. self.excellon_opt_group.setFixedWidth(260)
  775. self.layout.addWidget(self.excellon_gen_group)
  776. self.layout.addWidget(self.excellon_opt_group)
  777. self.layout.addStretch()
  778. class GeometryPreferencesUI(QtWidgets.QWidget):
  779. def __init__(self, parent=None):
  780. QtWidgets.QWidget.__init__(self, parent=parent)
  781. self.layout = QtWidgets.QHBoxLayout()
  782. self.setLayout(self.layout)
  783. self.geometry_gen_group = GeometryGenPrefGroupUI()
  784. self.geometry_gen_group.setFixedWidth(260)
  785. self.geometry_opt_group = GeometryOptPrefGroupUI()
  786. self.geometry_opt_group.setFixedWidth(260)
  787. self.layout.addWidget(self.geometry_gen_group)
  788. self.layout.addWidget(self.geometry_opt_group)
  789. self.layout.addStretch()
  790. class ToolsPreferencesUI(QtWidgets.QWidget):
  791. def __init__(self, parent=None):
  792. QtWidgets.QWidget.__init__(self, parent=parent)
  793. self.layout = QtWidgets.QHBoxLayout()
  794. self.setLayout(self.layout)
  795. self.tools_ncc_group = ToolsNCCPrefGroupUI()
  796. self.tools_ncc_group.setFixedWidth(260)
  797. self.tools_paint_group = ToolsPaintPrefGroupUI()
  798. self.tools_paint_group.setFixedWidth(260)
  799. self.tools_cutout_group = ToolsCutoutPrefGroupUI()
  800. self.tools_cutout_group.setFixedWidth(260)
  801. self.vlay = QtWidgets.QVBoxLayout()
  802. self.vlay.addWidget(self.tools_ncc_group)
  803. self.vlay.addWidget(self.tools_paint_group)
  804. self.layout.addLayout(self.vlay)
  805. self.layout.addWidget(self.tools_cutout_group)
  806. self.layout.addStretch()
  807. class CNCJobPreferencesUI(QtWidgets.QWidget):
  808. def __init__(self, parent=None):
  809. QtWidgets.QWidget.__init__(self, parent=parent)
  810. self.layout = QtWidgets.QHBoxLayout()
  811. self.setLayout(self.layout)
  812. self.cncjob_gen_group = CNCJobGenPrefGroupUI()
  813. self.cncjob_gen_group.setFixedWidth(260)
  814. self.cncjob_opt_group = CNCJobOptPrefGroupUI()
  815. self.cncjob_opt_group.setFixedWidth(260)
  816. self.layout.addWidget(self.cncjob_gen_group)
  817. self.layout.addWidget(self.cncjob_opt_group)
  818. self.layout.addStretch()
  819. class OptionsGroupUI(QtWidgets.QGroupBox):
  820. def __init__(self, title, parent=None):
  821. # QtGui.QGroupBox.__init__(self, title, parent=parent)
  822. super(OptionsGroupUI, self).__init__()
  823. self.setStyleSheet("""
  824. QGroupBox
  825. {
  826. font-size: 16px;
  827. font-weight: bold;
  828. }
  829. """)
  830. self.layout = QtWidgets.QVBoxLayout()
  831. self.setLayout(self.layout)
  832. class GeneralGUIPrefGroupUI(OptionsGroupUI):
  833. def __init__(self, parent=None):
  834. super(GeneralGUIPrefGroupUI, self).__init__(self)
  835. self.setTitle(str("GUI Preferences"))
  836. # Create a form layout for the Application general settings
  837. self.form_box = QtWidgets.QFormLayout()
  838. # Grid X Entry
  839. self.gridx_label = QtWidgets.QLabel('Grid X value:')
  840. self.gridx_label.setToolTip(
  841. "This is the Grid value on X axis\n"
  842. )
  843. self.gridx_entry = LengthEntry()
  844. # Grid Y Entry
  845. self.gridy_label = QtWidgets.QLabel('Grid Y value:')
  846. self.gridy_label.setToolTip(
  847. "This is the Grid value on Y axis\n"
  848. )
  849. self.gridy_entry = LengthEntry()
  850. # Workspace
  851. self.workspace_lbl = QtWidgets.QLabel('Workspace:')
  852. self.workspace_lbl.setToolTip(
  853. "Draw a delimiting rectangle on canvas.\n"
  854. "The purpose is to illustrate the limits for our work."
  855. )
  856. self.workspace_type_lbl = QtWidgets.QLabel('Wk. format:')
  857. self.workspace_type_lbl.setToolTip(
  858. "Select the type of rectangle to be used on canvas,\n"
  859. "as valid workspace."
  860. )
  861. self.workspace_cb = FCCheckBox()
  862. self.wk_cb = FCComboBox()
  863. self.wk_cb.addItem('A4P')
  864. self.wk_cb.addItem('A4L')
  865. self.wk_cb.addItem('A3P')
  866. self.wk_cb.addItem('A3L')
  867. self.wks = OptionalInputSection(self.workspace_cb, [self.workspace_type_lbl, self.wk_cb])
  868. # Plot Fill Color
  869. self.pf_color_label = QtWidgets.QLabel('Plot Fill:')
  870. self.pf_color_label.setToolTip(
  871. "Set the fill color for plotted objects.\n"
  872. "First 6 digits are the color and the last 2\n"
  873. "digits are for alpha (transparency) level."
  874. )
  875. self.pf_color_entry = FCEntry()
  876. self.pf_color_button = QtWidgets.QPushButton()
  877. self.pf_color_button.setFixedSize(15, 15)
  878. self.form_box_child_1 = QtWidgets.QHBoxLayout()
  879. self.form_box_child_1.addWidget(self.pf_color_entry)
  880. self.form_box_child_1.addWidget(self.pf_color_button)
  881. self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  882. # Plot Fill Transparency Level
  883. self.pf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  884. self.pf_alpha_label.setToolTip(
  885. "Set the fill transparency for plotted objects."
  886. )
  887. self.pf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  888. self.pf_color_alpha_slider.setMinimum(0)
  889. self.pf_color_alpha_slider.setMaximum(255)
  890. self.pf_color_alpha_slider.setSingleStep(1)
  891. self.pf_color_alpha_spinner = FCSpinner()
  892. self.pf_color_alpha_spinner.setFixedWidth(70)
  893. self.pf_color_alpha_spinner.setMinimum(0)
  894. self.pf_color_alpha_spinner.setMaximum(255)
  895. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  896. self.form_box_child_2.addWidget(self.pf_color_alpha_slider)
  897. self.form_box_child_2.addWidget(self.pf_color_alpha_spinner)
  898. # Plot Line Color
  899. self.pl_color_label = QtWidgets.QLabel('Plot Line:')
  900. self.pl_color_label.setToolTip(
  901. "Set the line color for plotted objects."
  902. )
  903. self.pl_color_entry = FCEntry()
  904. self.pl_color_button = QtWidgets.QPushButton()
  905. self.pl_color_button.setFixedSize(15, 15)
  906. self.form_box_child_3 = QtWidgets.QHBoxLayout()
  907. self.form_box_child_3.addWidget(self.pl_color_entry)
  908. self.form_box_child_3.addWidget(self.pl_color_button)
  909. self.form_box_child_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  910. # Plot Selection (left - right) Fill Color
  911. self.sf_color_label = QtWidgets.QLabel('Sel. Fill:')
  912. self.sf_color_label.setToolTip(
  913. "Set the fill color for the selection box\n"
  914. "in case that the selection is done from left to right.\n"
  915. "First 6 digits are the color and the last 2\n"
  916. "digits are for alpha (transparency) level."
  917. )
  918. self.sf_color_entry = FCEntry()
  919. self.sf_color_button = QtWidgets.QPushButton()
  920. self.sf_color_button.setFixedSize(15, 15)
  921. self.form_box_child_4 = QtWidgets.QHBoxLayout()
  922. self.form_box_child_4.addWidget(self.sf_color_entry)
  923. self.form_box_child_4.addWidget(self.sf_color_button)
  924. self.form_box_child_4.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  925. # Plot Selection (left - right) Fill Transparency Level
  926. self.sf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  927. self.sf_alpha_label.setToolTip(
  928. "Set the fill transparency for the 'left to right' selection box."
  929. )
  930. self.sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  931. self.sf_color_alpha_slider.setMinimum(0)
  932. self.sf_color_alpha_slider.setMaximum(255)
  933. self.sf_color_alpha_slider.setSingleStep(1)
  934. self.sf_color_alpha_spinner = FCSpinner()
  935. self.sf_color_alpha_spinner.setFixedWidth(70)
  936. self.sf_color_alpha_spinner.setMinimum(0)
  937. self.sf_color_alpha_spinner.setMaximum(255)
  938. self.form_box_child_5 = QtWidgets.QHBoxLayout()
  939. self.form_box_child_5.addWidget(self.sf_color_alpha_slider)
  940. self.form_box_child_5.addWidget(self.sf_color_alpha_spinner)
  941. # Plot Selection (left - right) Line Color
  942. self.sl_color_label = QtWidgets.QLabel('Sel. Line:')
  943. self.sl_color_label.setToolTip(
  944. "Set the line color for the 'left to right' selection box."
  945. )
  946. self.sl_color_entry = FCEntry()
  947. self.sl_color_button = QtWidgets.QPushButton()
  948. self.sl_color_button.setFixedSize(15, 15)
  949. self.form_box_child_6 = QtWidgets.QHBoxLayout()
  950. self.form_box_child_6.addWidget(self.sl_color_entry)
  951. self.form_box_child_6.addWidget(self.sl_color_button)
  952. self.form_box_child_6.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  953. # Plot Selection (right - left) Fill Color
  954. self.alt_sf_color_label = QtWidgets.QLabel('Sel2. Fill:')
  955. self.alt_sf_color_label.setToolTip(
  956. "Set the fill color for the selection box\n"
  957. "in case that the selection is done from right to left.\n"
  958. "First 6 digits are the color and the last 2\n"
  959. "digits are for alpha (transparency) level."
  960. )
  961. self.alt_sf_color_entry = FCEntry()
  962. self.alt_sf_color_button = QtWidgets.QPushButton()
  963. self.alt_sf_color_button.setFixedSize(15, 15)
  964. self.form_box_child_7 = QtWidgets.QHBoxLayout()
  965. self.form_box_child_7.addWidget(self.alt_sf_color_entry)
  966. self.form_box_child_7.addWidget(self.alt_sf_color_button)
  967. self.form_box_child_7.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  968. # Plot Selection (right - left) Fill Transparency Level
  969. self.alt_sf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  970. self.alt_sf_alpha_label.setToolTip(
  971. "Set the fill transparency for selection 'right to left' box."
  972. )
  973. self.alt_sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  974. self.alt_sf_color_alpha_slider.setMinimum(0)
  975. self.alt_sf_color_alpha_slider.setMaximum(255)
  976. self.alt_sf_color_alpha_slider.setSingleStep(1)
  977. self.alt_sf_color_alpha_spinner = FCSpinner()
  978. self.alt_sf_color_alpha_spinner.setFixedWidth(70)
  979. self.alt_sf_color_alpha_spinner.setMinimum(0)
  980. self.alt_sf_color_alpha_spinner.setMaximum(255)
  981. self.form_box_child_8 = QtWidgets.QHBoxLayout()
  982. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_slider)
  983. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_spinner)
  984. # Plot Selection (right - left) Line Color
  985. self.alt_sl_color_label = QtWidgets.QLabel('Sel2. Line:')
  986. self.alt_sl_color_label.setToolTip(
  987. "Set the line color for the 'right to left' selection box."
  988. )
  989. self.alt_sl_color_entry = FCEntry()
  990. self.alt_sl_color_button = QtWidgets.QPushButton()
  991. self.alt_sl_color_button.setFixedSize(15, 15)
  992. self.form_box_child_9 = QtWidgets.QHBoxLayout()
  993. self.form_box_child_9.addWidget(self.alt_sl_color_entry)
  994. self.form_box_child_9.addWidget(self.alt_sl_color_button)
  995. self.form_box_child_9.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  996. # Editor Draw Color
  997. self.draw_color_label = QtWidgets.QLabel('Editor Draw:')
  998. self.alt_sf_color_label.setToolTip(
  999. "Set the color for the shape."
  1000. )
  1001. self.draw_color_entry = FCEntry()
  1002. self.draw_color_button = QtWidgets.QPushButton()
  1003. self.draw_color_button.setFixedSize(15, 15)
  1004. self.form_box_child_10 = QtWidgets.QHBoxLayout()
  1005. self.form_box_child_10.addWidget(self.draw_color_entry)
  1006. self.form_box_child_10.addWidget(self.draw_color_button)
  1007. self.form_box_child_10.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1008. # Editor Draw Selection Color
  1009. self.sel_draw_color_label = QtWidgets.QLabel('Editor Draw Sel.:')
  1010. self.sel_draw_color_label.setToolTip(
  1011. "Set the color of the shape when selected."
  1012. )
  1013. self.sel_draw_color_entry = FCEntry()
  1014. self.sel_draw_color_button = QtWidgets.QPushButton()
  1015. self.sel_draw_color_button.setFixedSize(15, 15)
  1016. self.form_box_child_11 = QtWidgets.QHBoxLayout()
  1017. self.form_box_child_11.addWidget(self.sel_draw_color_entry)
  1018. self.form_box_child_11.addWidget(self.sel_draw_color_button)
  1019. self.form_box_child_11.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1020. # Just to add empty rows
  1021. self.spacelabel = QtWidgets.QLabel('')
  1022. # Add (label - input field) pair to the QFormLayout
  1023. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1024. self.form_box.addRow(self.gridx_label, self.gridx_entry)
  1025. self.form_box.addRow(self.gridy_label, self.gridy_entry)
  1026. self.form_box.addRow(self.workspace_lbl, self.workspace_cb)
  1027. self.form_box.addRow(self.workspace_type_lbl, self.wk_cb)
  1028. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1029. self.form_box.addRow(self.pf_color_label, self.form_box_child_1)
  1030. self.form_box.addRow(self.pf_alpha_label, self.form_box_child_2)
  1031. self.form_box.addRow(self.pl_color_label, self.form_box_child_3)
  1032. self.form_box.addRow(self.sf_color_label, self.form_box_child_4)
  1033. self.form_box.addRow(self.sf_alpha_label, self.form_box_child_5)
  1034. self.form_box.addRow(self.sl_color_label, self.form_box_child_6)
  1035. self.form_box.addRow(self.alt_sf_color_label, self.form_box_child_7)
  1036. self.form_box.addRow(self.alt_sf_alpha_label, self.form_box_child_8)
  1037. self.form_box.addRow(self.alt_sl_color_label, self.form_box_child_9)
  1038. self.form_box.addRow(self.draw_color_label, self.form_box_child_10)
  1039. self.form_box.addRow(self.sel_draw_color_label, self.form_box_child_11)
  1040. # Add the QFormLayout that holds the Application general defaults
  1041. # to the main layout of this TAB
  1042. self.layout.addLayout(self.form_box)
  1043. class GeneralAppPrefGroupUI(OptionsGroupUI):
  1044. def __init__(self, parent=None):
  1045. super(GeneralAppPrefGroupUI, self).__init__(self)
  1046. self.setTitle(str("App Preferences"))
  1047. # Create a form layout for the Application general settings
  1048. self.form_box = QtWidgets.QFormLayout()
  1049. # Units for FlatCAM
  1050. self.unitslabel = QtWidgets.QLabel('<b>Units:</b>')
  1051. self.unitslabel.setToolTip("The default value for FlatCAM units.\n"
  1052. "Whatever is selected here is set every time\n"
  1053. "FLatCAM is started.")
  1054. self.units_radio = RadioSet([{'label': 'IN', 'value': 'IN'},
  1055. {'label': 'MM', 'value': 'MM'}])
  1056. # Languages for FlatCAM
  1057. self.languagelabel = QtWidgets.QLabel('<b>Languages:</b>')
  1058. self.languagelabel.setToolTip("Set the language used throughout FlatCAM.")
  1059. self.language_cb = FCComboBox()
  1060. self.languagespace = QtWidgets.QLabel('')
  1061. self.language_apply_btn = FCButton("Apply Language")
  1062. # Shell StartUp CB
  1063. self.shell_startup_label = QtWidgets.QLabel('Shell at StartUp:')
  1064. self.shell_startup_label.setToolTip(
  1065. "Check this box if you want the shell to\n"
  1066. "start automatically at startup."
  1067. )
  1068. self.shell_startup_cb = FCCheckBox(label='')
  1069. self.shell_startup_cb.setToolTip(
  1070. "Check this box if you want the shell to\n"
  1071. "start automatically at startup."
  1072. )
  1073. # Version Check CB
  1074. self.version_check_label = QtWidgets.QLabel('Version Check:')
  1075. self.version_check_label.setToolTip(
  1076. "Check this box if you want to check\n"
  1077. "for a new version automatically at startup."
  1078. )
  1079. self.version_check_cb = FCCheckBox(label='')
  1080. self.version_check_cb.setToolTip(
  1081. "Check this box if you want to check\n"
  1082. "for a new version automatically at startup."
  1083. )
  1084. # Send Stats CB
  1085. self.send_stats_label = QtWidgets.QLabel('Send Stats:')
  1086. self.send_stats_label.setToolTip(
  1087. "Check this box if you agree to send anonymous\n"
  1088. "stats automatically at startup, to help improve FlatCAM."
  1089. )
  1090. self.send_stats_cb= FCCheckBox(label='')
  1091. self.send_stats_cb.setToolTip(
  1092. "Check this box if you agree to send anonymous\n"
  1093. "stats automatically at startup, to help improve FlatCAM."
  1094. )
  1095. self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
  1096. # Select mouse pan button
  1097. self.panbuttonlabel = QtWidgets.QLabel('<b>Pan Button:</b>')
  1098. self.panbuttonlabel.setToolTip("Select the mouse button to use for panning:\n"
  1099. "- MMB --> Middle Mouse Button\n"
  1100. "- RMB --> Middle Mouse Button")
  1101. self.pan_button_radio = RadioSet([{'label': 'MMB', 'value': '3'},
  1102. {'label': 'RMB', 'value': '2'}])
  1103. # Multiple Selection Modifier Key
  1104. self.mselectlabel = QtWidgets.QLabel('<b>Multiple Sel:</b>')
  1105. self.mselectlabel.setToolTip("Select the key used for multiple selection.")
  1106. self.mselect_radio = RadioSet([{'label': 'CTRL', 'value': 'Control'},
  1107. {'label': 'SHIFT', 'value': 'Shift'}])
  1108. # # Mouse panning with "Space" key, CB
  1109. # self.pan_with_space_label = QtWidgets.QLabel('Pan w/ Space:')
  1110. # self.pan_with_space_label.setToolTip(
  1111. # "Check this box if you want to pan when mouse is moved,\n"
  1112. # "and key 'Space' is pressed."
  1113. # )
  1114. # self.pan_with_space_cb = FCCheckBox(label='')
  1115. # self.pan_with_space_cb.setToolTip(
  1116. # "Check this box if you want to pan when mouse is moved,\n"
  1117. # "and key 'Space' is pressed."
  1118. # )
  1119. # Just to add empty rows
  1120. self.spacelabel = QtWidgets.QLabel('')
  1121. # Add (label - input field) pair to the QFormLayout
  1122. self.form_box.addRow(self.unitslabel, self.units_radio)
  1123. self.form_box.addRow(self.languagelabel, self.language_cb)
  1124. self.form_box.addRow(self.languagespace, self.language_apply_btn)
  1125. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1126. self.form_box.addRow(self.shell_startup_label, self.shell_startup_cb)
  1127. self.form_box.addRow(self.version_check_label, self.version_check_cb)
  1128. self.form_box.addRow(self.send_stats_label, self.send_stats_cb)
  1129. self.form_box.addRow(self.panbuttonlabel, self.pan_button_radio)
  1130. self.form_box.addRow(self.mselectlabel, self.mselect_radio)
  1131. # self.form_box.addRow(self.pan_with_space_label, self.pan_with_space_cb)
  1132. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1133. # Add the QFormLayout that holds the Application general defaults
  1134. # to the main layout of this TAB
  1135. self.layout.addLayout(self.form_box)
  1136. class GerberGenPrefGroupUI(OptionsGroupUI):
  1137. def __init__(self, parent=None):
  1138. # OptionsGroupUI.__init__(self, "Gerber General Preferences", parent=parent)
  1139. super(GerberGenPrefGroupUI, self).__init__(self)
  1140. self.setTitle(str("Gerber General"))
  1141. ## Plot options
  1142. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1143. self.layout.addWidget(self.plot_options_label)
  1144. grid0 = QtWidgets.QGridLayout()
  1145. self.layout.addLayout(grid0)
  1146. # Plot CB
  1147. self.plot_cb = FCCheckBox(label='Plot')
  1148. self.plot_options_label.setToolTip(
  1149. "Plot (show) this object."
  1150. )
  1151. grid0.addWidget(self.plot_cb, 0, 0)
  1152. # Solid CB
  1153. self.solid_cb = FCCheckBox(label='Solid')
  1154. self.solid_cb.setToolTip(
  1155. "Solid color polygons."
  1156. )
  1157. grid0.addWidget(self.solid_cb, 0, 1)
  1158. # Multicolored CB
  1159. self.multicolored_cb = FCCheckBox(label='M-Color')
  1160. self.multicolored_cb.setToolTip(
  1161. "Draw polygons in different colors."
  1162. )
  1163. grid0.addWidget(self.multicolored_cb, 0, 2)
  1164. # Number of circle steps for circular aperture linear approximation
  1165. self.circle_steps_label = QtWidgets.QLabel("Circle Steps:")
  1166. self.circle_steps_label.setToolTip(
  1167. "The number of circle steps for Gerber \n"
  1168. "circular aperture linear approximation."
  1169. )
  1170. grid0.addWidget(self.circle_steps_label, 1, 0)
  1171. self.circle_steps_entry = IntEntry()
  1172. grid0.addWidget(self.circle_steps_entry, 1, 1)
  1173. self.layout.addStretch()
  1174. class GerberOptPrefGroupUI(OptionsGroupUI):
  1175. def __init__(self, parent=None):
  1176. # OptionsGroupUI.__init__(self, "Gerber Options Preferences", parent=parent)
  1177. super(GerberOptPrefGroupUI, self).__init__(self)
  1178. self.setTitle(str("Gerber Options"))
  1179. ## Isolation Routing
  1180. self.isolation_routing_label = QtWidgets.QLabel("<b>Isolation Routing:</b>")
  1181. self.isolation_routing_label.setToolTip(
  1182. "Create a Geometry object with\n"
  1183. "toolpaths to cut outside polygons."
  1184. )
  1185. self.layout.addWidget(self.isolation_routing_label)
  1186. # Cutting Tool Diameter
  1187. grid0 = QtWidgets.QGridLayout()
  1188. self.layout.addLayout(grid0)
  1189. tdlabel = QtWidgets.QLabel('Tool dia:')
  1190. tdlabel.setToolTip(
  1191. "Diameter of the cutting tool."
  1192. )
  1193. grid0.addWidget(tdlabel, 0, 0)
  1194. self.iso_tool_dia_entry = LengthEntry()
  1195. grid0.addWidget(self.iso_tool_dia_entry, 0, 1)
  1196. # Nr of passes
  1197. passlabel = QtWidgets.QLabel('Width (# passes):')
  1198. passlabel.setToolTip(
  1199. "Width of the isolation gap in\n"
  1200. "number (integer) of tool widths."
  1201. )
  1202. grid0.addWidget(passlabel, 1, 0)
  1203. self.iso_width_entry = IntEntry()
  1204. grid0.addWidget(self.iso_width_entry, 1, 1)
  1205. # Pass overlap
  1206. overlabel = QtWidgets.QLabel('Pass overlap:')
  1207. overlabel.setToolTip(
  1208. "How much (fraction) of the tool width to overlap each tool pass.\n"
  1209. "Example:\n"
  1210. "A value here of 0.25 means an overlap of 25% from the tool diameter found above."
  1211. )
  1212. grid0.addWidget(overlabel, 2, 0)
  1213. self.iso_overlap_entry = FloatEntry()
  1214. grid0.addWidget(self.iso_overlap_entry, 2, 1)
  1215. milling_type_label = QtWidgets.QLabel('Milling Type:')
  1216. milling_type_label.setToolTip(
  1217. "Milling type:\n"
  1218. "- climb / best for precision milling and to reduce tool usage\n"
  1219. "- conventional / useful when there is no backlash compensation"
  1220. )
  1221. grid0.addWidget(milling_type_label, 3, 0)
  1222. self.milling_type_radio = RadioSet([{'label': 'Climb', 'value': 'cl'},
  1223. {'label': 'Conv.', 'value': 'cv'}])
  1224. grid0.addWidget(self.milling_type_radio, 3, 1)
  1225. # Combine passes
  1226. self.combine_passes_cb = FCCheckBox(label='Combine Passes')
  1227. self.combine_passes_cb.setToolTip(
  1228. "Combine all passes into one object"
  1229. )
  1230. grid0.addWidget(self.combine_passes_cb, 4, 0)
  1231. ## Clear non-copper regions
  1232. self.clearcopper_label = QtWidgets.QLabel("<b>Clear non-copper:</b>")
  1233. self.clearcopper_label.setToolTip(
  1234. "Create a Geometry object with\n"
  1235. "toolpaths to cut all non-copper regions."
  1236. )
  1237. self.layout.addWidget(self.clearcopper_label)
  1238. grid1 = QtWidgets.QGridLayout()
  1239. self.layout.addLayout(grid1)
  1240. # Margin
  1241. bmlabel = QtWidgets.QLabel('Boundary Margin:')
  1242. bmlabel.setToolTip(
  1243. "Specify the edge of the PCB\n"
  1244. "by drawing a box around all\n"
  1245. "objects with this minimum\n"
  1246. "distance."
  1247. )
  1248. grid1.addWidget(bmlabel, 0, 0)
  1249. self.noncopper_margin_entry = LengthEntry()
  1250. grid1.addWidget(self.noncopper_margin_entry, 0, 1)
  1251. # Rounded corners
  1252. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  1253. self.noncopper_rounded_cb.setToolTip(
  1254. "Creates a Geometry objects with polygons\n"
  1255. "covering the copper-free areas of the PCB."
  1256. )
  1257. grid1.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  1258. ## Bounding box
  1259. self.boundingbox_label = QtWidgets.QLabel('<b>Bounding Box:</b>')
  1260. self.layout.addWidget(self.boundingbox_label)
  1261. grid2 = QtWidgets.QGridLayout()
  1262. self.layout.addLayout(grid2)
  1263. bbmargin = QtWidgets.QLabel('Boundary Margin:')
  1264. bbmargin.setToolTip(
  1265. "Distance of the edges of the box\n"
  1266. "to the nearest polygon."
  1267. )
  1268. grid2.addWidget(bbmargin, 0, 0)
  1269. self.bbmargin_entry = LengthEntry()
  1270. grid2.addWidget(self.bbmargin_entry, 0, 1)
  1271. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  1272. self.bbrounded_cb.setToolTip(
  1273. "If the bounding box is \n"
  1274. "to have rounded corners\n"
  1275. "their radius is equal to\n"
  1276. "the margin."
  1277. )
  1278. grid2.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  1279. self.layout.addStretch()
  1280. class ExcellonGenPrefGroupUI(OptionsGroupUI):
  1281. def __init__(self, parent=None):
  1282. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  1283. super(ExcellonGenPrefGroupUI, self).__init__(self)
  1284. self.setTitle(str("Excellon General"))
  1285. # Plot options
  1286. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1287. self.layout.addWidget(self.plot_options_label)
  1288. grid1 = QtWidgets.QGridLayout()
  1289. self.layout.addLayout(grid1)
  1290. self.plot_cb = FCCheckBox(label='Plot')
  1291. self.plot_cb.setToolTip(
  1292. "Plot (show) this object."
  1293. )
  1294. grid1.addWidget(self.plot_cb, 0, 0)
  1295. self.solid_cb = FCCheckBox(label='Solid')
  1296. self.solid_cb.setToolTip(
  1297. "Plot as solid circles."
  1298. )
  1299. grid1.addWidget(self.solid_cb, 0, 1)
  1300. # Excellon format
  1301. self.excellon_format_label = QtWidgets.QLabel("<b>Excellon Format:</b>")
  1302. self.excellon_format_label.setToolTip(
  1303. "The NC drill files, usually named Excellon files\n"
  1304. "are files that can be found in different formats.\n"
  1305. "Here we set the format used when the provided\n"
  1306. "coordinates are not using period.\n"
  1307. "\n"
  1308. "Possible presets:\n"
  1309. "\n"
  1310. "PROTEUS 3:3 MM LZ\n"
  1311. "DipTrace 5:2 MM TZ\n"
  1312. "DipTrace 4:3 MM LZ\n"
  1313. "\n"
  1314. "EAGLE 3:3 MM TZ\n"
  1315. "EAGLE 4:3 MM TZ\n"
  1316. "EAGLE 2:5 INCH TZ\n"
  1317. "EAGLE 3:5 INCH TZ\n"
  1318. "\n"
  1319. "ALTIUM 2:4 INCH LZ\n"
  1320. "Sprint Layout 2:4 INCH LZ"
  1321. "\n"
  1322. "KiCAD 3:5 INCH TZ"
  1323. )
  1324. self.layout.addWidget(self.excellon_format_label)
  1325. hlay1 = QtWidgets.QHBoxLayout()
  1326. self.layout.addLayout(hlay1)
  1327. self.excellon_format_in_label = QtWidgets.QLabel("INCH:")
  1328. self.excellon_format_in_label.setAlignment(QtCore.Qt.AlignLeft)
  1329. self.excellon_format_in_label.setToolTip(
  1330. "Default values for INCH are 2:4")
  1331. hlay1.addWidget(self.excellon_format_in_label, QtCore.Qt.AlignLeft)
  1332. self.excellon_format_upper_in_entry = IntEntry()
  1333. self.excellon_format_upper_in_entry.setMaxLength(1)
  1334. self.excellon_format_upper_in_entry.setAlignment(QtCore.Qt.AlignRight)
  1335. self.excellon_format_upper_in_entry.setFixedWidth(30)
  1336. self.excellon_format_upper_in_entry.setToolTip(
  1337. "This numbers signify the number of digits in\n"
  1338. "the whole part of Excellon coordinates."
  1339. )
  1340. hlay1.addWidget(self.excellon_format_upper_in_entry, QtCore.Qt.AlignLeft)
  1341. excellon_separator_in_label= QtWidgets.QLabel(':')
  1342. excellon_separator_in_label.setFixedWidth(5)
  1343. hlay1.addWidget(excellon_separator_in_label, QtCore.Qt.AlignLeft)
  1344. self.excellon_format_lower_in_entry = IntEntry()
  1345. self.excellon_format_lower_in_entry.setMaxLength(1)
  1346. self.excellon_format_lower_in_entry.setAlignment(QtCore.Qt.AlignRight)
  1347. self.excellon_format_lower_in_entry.setFixedWidth(30)
  1348. self.excellon_format_lower_in_entry.setToolTip(
  1349. "This numbers signify the number of digits in\n"
  1350. "the decimal part of Excellon coordinates."
  1351. )
  1352. hlay1.addWidget(self.excellon_format_lower_in_entry, QtCore.Qt.AlignLeft)
  1353. hlay1.addStretch()
  1354. hlay2 = QtWidgets.QHBoxLayout()
  1355. self.layout.addLayout(hlay2)
  1356. self.excellon_format_mm_label = QtWidgets.QLabel("METRIC:")
  1357. self.excellon_format_mm_label.setAlignment(QtCore.Qt.AlignLeft)
  1358. self.excellon_format_mm_label.setToolTip(
  1359. "Default values for METRIC are 3:3")
  1360. hlay2.addWidget(self.excellon_format_mm_label, QtCore.Qt.AlignLeft)
  1361. self.excellon_format_upper_mm_entry = IntEntry()
  1362. self.excellon_format_upper_mm_entry.setMaxLength(1)
  1363. self.excellon_format_upper_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  1364. self.excellon_format_upper_mm_entry.setFixedWidth(30)
  1365. self.excellon_format_upper_mm_entry.setToolTip(
  1366. "This numbers signify the number of digits in\n"
  1367. "the whole part of Excellon coordinates."
  1368. )
  1369. hlay2.addWidget(self.excellon_format_upper_mm_entry, QtCore.Qt.AlignLeft)
  1370. excellon_separator_mm_label= QtWidgets.QLabel(':')
  1371. excellon_separator_mm_label.setFixedWidth(5)
  1372. hlay2.addWidget(excellon_separator_mm_label, QtCore.Qt.AlignLeft)
  1373. self.excellon_format_lower_mm_entry = IntEntry()
  1374. self.excellon_format_lower_mm_entry.setMaxLength(1)
  1375. self.excellon_format_lower_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  1376. self.excellon_format_lower_mm_entry.setFixedWidth(30)
  1377. self.excellon_format_lower_mm_entry.setToolTip(
  1378. "This numbers signify the number of digits in\n"
  1379. "the decimal part of Excellon coordinates."
  1380. )
  1381. hlay2.addWidget(self.excellon_format_lower_mm_entry, QtCore.Qt.AlignLeft)
  1382. hlay2.addStretch()
  1383. hlay3 = QtWidgets.QHBoxLayout()
  1384. self.layout.addLayout(hlay3)
  1385. self.excellon_zeros_label = QtWidgets.QLabel('Default <b>Zeros</b>:')
  1386. self.excellon_zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  1387. self.excellon_zeros_label.setToolTip(
  1388. "This sets the type of Excellon zeros.\n"
  1389. "If LZ then Leading Zeros are kept and\n"
  1390. "Trailing Zeros are removed.\n"
  1391. "If TZ is checked then Trailing Zeros are kept\n"
  1392. "and Leading Zeros are removed."
  1393. )
  1394. hlay3.addWidget(self.excellon_zeros_label)
  1395. self.excellon_zeros_radio = RadioSet([{'label': 'LZ', 'value': 'L'},
  1396. {'label': 'TZ', 'value': 'T'}])
  1397. self.excellon_zeros_radio.setToolTip(
  1398. "This sets the default type of Excellon zeros.\n"
  1399. "If it is not detected in the parsed file the value here\n"
  1400. "will be used."
  1401. "If LZ then Leading Zeros are kept and\n"
  1402. "Trailing Zeros are removed.\n"
  1403. "If TZ is checked then Trailing Zeros are kept\n"
  1404. "and Leading Zeros are removed."
  1405. )
  1406. hlay3.addStretch()
  1407. hlay3.addWidget(self.excellon_zeros_radio, QtCore.Qt.AlignRight)
  1408. hlay4 = QtWidgets.QHBoxLayout()
  1409. self.layout.addLayout(hlay4)
  1410. self.excellon_units_label = QtWidgets.QLabel('Default <b>Units</b>:')
  1411. self.excellon_units_label.setAlignment(QtCore.Qt.AlignLeft)
  1412. self.excellon_units_label.setToolTip(
  1413. "This sets the default units of Excellon files.\n"
  1414. "If it is not detected in the parsed file the value here\n"
  1415. "will be used."
  1416. "Some Excellon files don't have an header\n"
  1417. "therefore this parameter will be used.\n"
  1418. )
  1419. hlay4.addWidget(self.excellon_units_label)
  1420. self.excellon_units_radio = RadioSet([{'label': 'INCH', 'value': 'INCH'},
  1421. {'label': 'MM', 'value': 'METRIC'}])
  1422. self.excellon_units_radio.setToolTip(
  1423. "This sets the units of Excellon files.\n"
  1424. "Some Excellon files don't have an header\n"
  1425. "therefore this parameter will be used.\n"
  1426. )
  1427. hlay4.addStretch()
  1428. hlay4.addWidget(self.excellon_units_radio, QtCore.Qt.AlignRight)
  1429. hlay5 = QtWidgets.QVBoxLayout()
  1430. self.layout.addLayout(hlay5)
  1431. self.empty_label = QtWidgets.QLabel("")
  1432. hlay5.addWidget(self.empty_label)
  1433. hlay6 = QtWidgets.QVBoxLayout()
  1434. self.layout.addLayout(hlay6)
  1435. self.excellon_general_label = QtWidgets.QLabel("<b>Excellon Optimization:</b>")
  1436. hlay6.addWidget(self.excellon_general_label)
  1437. # Create a form layout for the Excellon general settings
  1438. form_box_excellon = QtWidgets.QFormLayout()
  1439. hlay6.addLayout(form_box_excellon)
  1440. self.excellon_optimization_label = QtWidgets.QLabel('Path Optimization: ')
  1441. self.excellon_optimization_label.setAlignment(QtCore.Qt.AlignLeft)
  1442. self.excellon_optimization_label.setToolTip(
  1443. "This sets the optimization type for the Excellon drill path.\n"
  1444. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  1445. "Guided Local Path is used. Default search time is 3sec.\n"
  1446. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  1447. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  1448. "\n"
  1449. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  1450. "Travelling Salesman algorithm for path optimization."
  1451. )
  1452. self.excellon_optimization_radio = RadioSet([{'label': 'MH', 'value': 'M'},
  1453. {'label': 'Basic', 'value': 'B'}])
  1454. self.excellon_optimization_radio.setToolTip(
  1455. "This sets the optimization type for the Excellon drill path.\n"
  1456. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  1457. "Guided Local Path is used. Default search time is 3sec.\n"
  1458. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  1459. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  1460. "\n"
  1461. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  1462. "Travelling Salesman algorithm for path optimization."
  1463. )
  1464. form_box_excellon.addRow(self.excellon_optimization_label, self.excellon_optimization_radio)
  1465. self.optimization_time_label = QtWidgets.QLabel('Optimization Time: ')
  1466. self.optimization_time_label.setAlignment(QtCore.Qt.AlignLeft)
  1467. self.optimization_time_label.setToolTip(
  1468. "When OR-Tools Metaheuristic (MH) is enabled there is a\n"
  1469. "maximum threshold for how much time is spent doing the\n"
  1470. "path optimization. This max duration is set here."
  1471. )
  1472. self.optimization_time_entry = LengthEntry()
  1473. form_box_excellon.addRow(self.optimization_time_label, self.optimization_time_entry)
  1474. current_platform = platform.architecture()[0]
  1475. if current_platform == '64bit':
  1476. self.excellon_optimization_label.setDisabled(False)
  1477. self.excellon_optimization_radio.setDisabled(False)
  1478. self.optimization_time_label.setDisabled(False)
  1479. self.optimization_time_entry.setDisabled(False)
  1480. self.excellon_optimization_radio.activated_custom.connect(self.optimization_selection)
  1481. else:
  1482. self.excellon_optimization_label.setDisabled(True)
  1483. self.excellon_optimization_radio.setDisabled(True)
  1484. self.optimization_time_label.setDisabled(True)
  1485. self.optimization_time_entry.setDisabled(True)
  1486. self.layout.addStretch()
  1487. def optimization_selection(self):
  1488. if self.excellon_optimization_radio.get_value() == 'M':
  1489. self.optimization_time_label.setDisabled(False)
  1490. self.optimization_time_entry.setDisabled(False)
  1491. else:
  1492. self.optimization_time_label.setDisabled(True)
  1493. self.optimization_time_entry.setDisabled(True)
  1494. class ExcellonOptPrefGroupUI(OptionsGroupUI):
  1495. def __init__(self, parent=None):
  1496. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  1497. super(ExcellonOptPrefGroupUI, self).__init__(self)
  1498. self.setTitle(str("Excellon Options"))
  1499. ## Create CNC Job
  1500. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job</b>')
  1501. self.cncjob_label.setToolTip(
  1502. "Create a CNC Job object\n"
  1503. "for this drill object."
  1504. )
  1505. self.layout.addWidget(self.cncjob_label)
  1506. grid2 = QtWidgets.QGridLayout()
  1507. self.layout.addLayout(grid2)
  1508. cutzlabel = QtWidgets.QLabel('Cut Z:')
  1509. cutzlabel.setToolTip(
  1510. "Drill depth (negative)\n"
  1511. "below the copper surface."
  1512. )
  1513. grid2.addWidget(cutzlabel, 0, 0)
  1514. self.cutz_entry = LengthEntry()
  1515. grid2.addWidget(self.cutz_entry, 0, 1)
  1516. travelzlabel = QtWidgets.QLabel('Travel Z:')
  1517. travelzlabel.setToolTip(
  1518. "Tool height when travelling\n"
  1519. "across the XY plane."
  1520. )
  1521. grid2.addWidget(travelzlabel, 1, 0)
  1522. self.travelz_entry = LengthEntry()
  1523. grid2.addWidget(self.travelz_entry, 1, 1)
  1524. # Tool change:
  1525. toolchlabel = QtWidgets.QLabel("Tool change:")
  1526. toolchlabel.setToolTip(
  1527. "Include tool-change sequence\n"
  1528. "in G-Code (Pause for tool change)."
  1529. )
  1530. self.toolchange_cb = FCCheckBox()
  1531. grid2.addWidget(toolchlabel, 2, 0)
  1532. grid2.addWidget(self.toolchange_cb, 2, 1)
  1533. toolchangezlabel = QtWidgets.QLabel('Toolchange Z:')
  1534. toolchangezlabel.setToolTip(
  1535. "Toolchange Z position."
  1536. )
  1537. grid2.addWidget(toolchangezlabel, 3, 0)
  1538. self.toolchangez_entry = LengthEntry()
  1539. grid2.addWidget(self.toolchangez_entry, 3, 1)
  1540. toolchange_xy_label = QtWidgets.QLabel('Toolchange X,Y:')
  1541. toolchange_xy_label.setToolTip(
  1542. "Toolchange X,Y position."
  1543. )
  1544. grid2.addWidget(toolchange_xy_label, 4, 0)
  1545. self.toolchangexy_entry = FCEntry()
  1546. grid2.addWidget(self.toolchangexy_entry, 4, 1)
  1547. startzlabel = QtWidgets.QLabel('Start move Z:')
  1548. startzlabel.setToolTip(
  1549. "Height of the tool just after start.\n"
  1550. "Delete the value if you don't need this feature."
  1551. )
  1552. grid2.addWidget(startzlabel, 5, 0)
  1553. self.estartz_entry = FloatEntry()
  1554. grid2.addWidget(self.estartz_entry, 5, 1)
  1555. endzlabel = QtWidgets.QLabel('End move Z:')
  1556. endzlabel.setToolTip(
  1557. "Height of the tool after\n"
  1558. "the last move at the end of the job."
  1559. )
  1560. grid2.addWidget(endzlabel, 6, 0)
  1561. self.eendz_entry = LengthEntry()
  1562. grid2.addWidget(self.eendz_entry, 6, 1)
  1563. frlabel = QtWidgets.QLabel('Feedrate:')
  1564. frlabel.setToolTip(
  1565. "Tool speed while drilling\n"
  1566. "(in units per minute)."
  1567. )
  1568. grid2.addWidget(frlabel, 7, 0)
  1569. self.feedrate_entry = LengthEntry()
  1570. grid2.addWidget(self.feedrate_entry, 7, 1)
  1571. fr_rapid_label = QtWidgets.QLabel('Feedrate Rapids:')
  1572. fr_rapid_label.setToolTip(
  1573. "Tool speed while drilling\n"
  1574. "with rapid move\n"
  1575. "(in units per minute)."
  1576. )
  1577. grid2.addWidget(fr_rapid_label, 8, 0)
  1578. self.feedrate_rapid_entry = LengthEntry()
  1579. grid2.addWidget(self.feedrate_rapid_entry, 8, 1)
  1580. # Spindle speed
  1581. spdlabel = QtWidgets.QLabel('Spindle speed:')
  1582. spdlabel.setToolTip(
  1583. "Speed of the spindle\n"
  1584. "in RPM (optional)"
  1585. )
  1586. grid2.addWidget(spdlabel, 9, 0)
  1587. self.spindlespeed_entry = IntEntry(allow_empty=True)
  1588. grid2.addWidget(self.spindlespeed_entry, 9, 1)
  1589. # Dwell
  1590. dwelllabel = QtWidgets.QLabel('Dwell:')
  1591. dwelllabel.setToolTip(
  1592. "Pause to allow the spindle to reach its\n"
  1593. "speed before cutting."
  1594. )
  1595. dwelltime = QtWidgets.QLabel('Duration [m-sec.]:')
  1596. dwelltime.setToolTip(
  1597. "Number of milliseconds for spindle to dwell."
  1598. )
  1599. self.dwell_cb = FCCheckBox()
  1600. self.dwelltime_entry = FCEntry()
  1601. grid2.addWidget(dwelllabel, 10, 0)
  1602. grid2.addWidget(self.dwell_cb, 10, 1)
  1603. grid2.addWidget(dwelltime, 11, 0)
  1604. grid2.addWidget(self.dwelltime_entry, 11, 1)
  1605. self.ois_dwell_exc = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  1606. # postprocessor selection
  1607. pp_excellon_label = QtWidgets.QLabel("Postprocessor:")
  1608. pp_excellon_label.setToolTip(
  1609. "The postprocessor file that dictates\n"
  1610. "gcode output."
  1611. )
  1612. grid2.addWidget(pp_excellon_label, 12, 0)
  1613. self.pp_excellon_name_cb = FCComboBox()
  1614. self.pp_excellon_name_cb.setFocusPolicy(Qt.StrongFocus)
  1615. grid2.addWidget(self.pp_excellon_name_cb, 12, 1)
  1616. #### Choose what to use for Gcode creation: Drills, Slots or Both
  1617. excellon_gcode_type_label = QtWidgets.QLabel('<b>Gcode: </b>')
  1618. excellon_gcode_type_label.setToolTip(
  1619. "Choose what to use for GCode generation:\n"
  1620. "'Drills', 'Slots' or 'Both'.\n"
  1621. "When choosing 'Slots' or 'Both', slots will be\n"
  1622. "converted to drills."
  1623. )
  1624. self.excellon_gcode_type_radio = RadioSet([{'label': 'Drills', 'value': 'drills'},
  1625. {'label': 'Slots', 'value': 'slots'},
  1626. {'label': 'Both', 'value': 'both'}])
  1627. grid2.addWidget(excellon_gcode_type_label, 13, 0)
  1628. grid2.addWidget(self.excellon_gcode_type_radio, 13, 1)
  1629. # until I decide to implement this feature those remain disabled
  1630. excellon_gcode_type_label.setDisabled(True)
  1631. self.excellon_gcode_type_radio.setDisabled(True)
  1632. #### Milling Holes ####
  1633. self.mill_hole_label = QtWidgets.QLabel('<b>Mill Holes</b>')
  1634. self.mill_hole_label.setToolTip(
  1635. "Create Geometry for milling holes."
  1636. )
  1637. self.layout.addWidget(self.mill_hole_label)
  1638. grid3 = QtWidgets.QGridLayout()
  1639. self.layout.addLayout(grid3)
  1640. tdlabel = QtWidgets.QLabel('Drill Tool dia:')
  1641. tdlabel.setToolTip(
  1642. "Diameter of the cutting tool."
  1643. )
  1644. grid3.addWidget(tdlabel, 0, 0)
  1645. self.tooldia_entry = LengthEntry()
  1646. grid3.addWidget(self.tooldia_entry, 0, 1)
  1647. stdlabel = QtWidgets.QLabel('Slot Tool dia:')
  1648. stdlabel.setToolTip(
  1649. "Diameter of the cutting tool\n"
  1650. "when milling slots."
  1651. )
  1652. grid3.addWidget(stdlabel, 1, 0)
  1653. self.slot_tooldia_entry = LengthEntry()
  1654. grid3.addWidget(self.slot_tooldia_entry, 1, 1)
  1655. grid4 = QtWidgets.QGridLayout()
  1656. self.layout.addLayout(grid4)
  1657. # Adding the Excellon Format Defaults Button
  1658. self.excellon_defaults_button = QtWidgets.QPushButton()
  1659. self.excellon_defaults_button.setText(str("Defaults"))
  1660. self.excellon_defaults_button.setFixedWidth(80)
  1661. grid4.addWidget(self.excellon_defaults_button, 0, 0, QtCore.Qt.AlignRight)
  1662. self.layout.addStretch()
  1663. class GeometryGenPrefGroupUI(OptionsGroupUI):
  1664. def __init__(self, parent=None):
  1665. # OptionsGroupUI.__init__(self, "Geometry General Preferences", parent=parent)
  1666. super(GeometryGenPrefGroupUI, self).__init__(self)
  1667. self.setTitle(str("Geometry General"))
  1668. ## Plot options
  1669. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1670. self.layout.addWidget(self.plot_options_label)
  1671. # Plot CB
  1672. self.plot_cb = FCCheckBox(label='Plot')
  1673. self.plot_cb.setToolTip(
  1674. "Plot (show) this object."
  1675. )
  1676. self.layout.addWidget(self.plot_cb)
  1677. grid0 = QtWidgets.QGridLayout()
  1678. self.layout.addLayout(grid0)
  1679. # Number of circle steps for circular aperture linear approximation
  1680. self.circle_steps_label = QtWidgets.QLabel("Circle Steps:")
  1681. self.circle_steps_label.setToolTip(
  1682. "The number of circle steps for <b>Geometry</b> \n"
  1683. "circle and arc shapes linear approximation."
  1684. )
  1685. grid0.addWidget(self.circle_steps_label, 1, 0)
  1686. self.circle_steps_entry = IntEntry()
  1687. grid0.addWidget(self.circle_steps_entry, 1, 1)
  1688. # Tools
  1689. self.tools_label = QtWidgets.QLabel("<b>Tools</b>")
  1690. self.layout.addWidget(self.tools_label)
  1691. grid1 = QtWidgets.QGridLayout()
  1692. self.layout.addLayout(grid1)
  1693. # Tooldia
  1694. tdlabel = QtWidgets.QLabel('Tool dia: ')
  1695. tdlabel.setToolTip(
  1696. "The diameter of the cutting\n"
  1697. "tool (just for display)."
  1698. )
  1699. grid1.addWidget(tdlabel, 0, 0)
  1700. self.cnctooldia_entry = LengthEntry()
  1701. grid1.addWidget(self.cnctooldia_entry, 0, 1)
  1702. self.layout.addStretch()
  1703. class GeometryOptPrefGroupUI(OptionsGroupUI):
  1704. def __init__(self, parent=None):
  1705. # OptionsGroupUI.__init__(self, "Geometry Options Preferences", parent=parent)
  1706. super(GeometryOptPrefGroupUI, self).__init__(self)
  1707. self.setTitle(str("Geometry Options"))
  1708. # ------------------------------
  1709. ## Create CNC Job
  1710. # ------------------------------
  1711. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job:</b>')
  1712. self.cncjob_label.setToolTip(
  1713. "Create a CNC Job object\n"
  1714. "tracing the contours of this\n"
  1715. "Geometry object."
  1716. )
  1717. self.layout.addWidget(self.cncjob_label)
  1718. grid1 = QtWidgets.QGridLayout()
  1719. self.layout.addLayout(grid1)
  1720. # Cut Z
  1721. cutzlabel = QtWidgets.QLabel('Cut Z:')
  1722. cutzlabel.setToolTip(
  1723. "Cutting depth (negative)\n"
  1724. "below the copper surface."
  1725. )
  1726. grid1.addWidget(cutzlabel, 0, 0)
  1727. self.cutz_entry = LengthEntry()
  1728. grid1.addWidget(self.cutz_entry, 0, 1)
  1729. # Multidepth CheckBox
  1730. self.multidepth_cb = FCCheckBox(label='Multidepth')
  1731. self.multidepth_cb.setToolTip(
  1732. "Multidepth usage: True or False."
  1733. )
  1734. grid1.addWidget(self.multidepth_cb, 1, 0)
  1735. # Depth/pass
  1736. dplabel = QtWidgets.QLabel('Depth/Pass:')
  1737. dplabel.setToolTip(
  1738. "The depth to cut on each pass,\n"
  1739. "when multidepth is enabled.\n"
  1740. "It has positive value although\n"
  1741. "it is a fraction from the depth\n"
  1742. "which has negative value."
  1743. )
  1744. grid1.addWidget(dplabel, 2, 0)
  1745. self.depthperpass_entry = LengthEntry()
  1746. grid1.addWidget(self.depthperpass_entry, 2, 1)
  1747. self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry])
  1748. # Travel Z
  1749. travelzlabel = QtWidgets.QLabel('Travel Z:')
  1750. travelzlabel.setToolTip(
  1751. "Height of the tool when\n"
  1752. "moving without cutting."
  1753. )
  1754. grid1.addWidget(travelzlabel, 3, 0)
  1755. self.travelz_entry = LengthEntry()
  1756. grid1.addWidget(self.travelz_entry, 3, 1)
  1757. # Tool change:
  1758. toolchlabel = QtWidgets.QLabel("Tool change:")
  1759. toolchlabel.setToolTip(
  1760. "Include tool-change sequence\n"
  1761. "in G-Code (Pause for tool change)."
  1762. )
  1763. self.toolchange_cb = FCCheckBox()
  1764. grid1.addWidget(toolchlabel, 4, 0)
  1765. grid1.addWidget(self.toolchange_cb, 4, 1)
  1766. # Toolchange Z
  1767. toolchangezlabel = QtWidgets.QLabel('Toolchange Z:')
  1768. toolchangezlabel.setToolTip(
  1769. "Toolchange Z position."
  1770. )
  1771. grid1.addWidget(toolchangezlabel, 5, 0)
  1772. self.toolchangez_entry = LengthEntry()
  1773. grid1.addWidget(self.toolchangez_entry, 5, 1)
  1774. # Toolchange X,Y
  1775. toolchange_xy_label = QtWidgets.QLabel('Toolchange X,Y:')
  1776. toolchange_xy_label.setToolTip(
  1777. "Toolchange X,Y position."
  1778. )
  1779. grid1.addWidget(toolchange_xy_label, 6, 0)
  1780. self.toolchangexy_entry = FCEntry()
  1781. grid1.addWidget(self.toolchangexy_entry, 6, 1)
  1782. # Start move Z
  1783. startzlabel = QtWidgets.QLabel('Start move Z:')
  1784. startzlabel.setToolTip(
  1785. "Height of the tool just after starting the work.\n"
  1786. "Delete the value if you don't need this feature."
  1787. )
  1788. grid1.addWidget(startzlabel, 7, 0)
  1789. self.gstartz_entry = FloatEntry()
  1790. grid1.addWidget(self.gstartz_entry, 7, 1)
  1791. # End move Z
  1792. endzlabel = QtWidgets.QLabel('End move Z:')
  1793. endzlabel.setToolTip(
  1794. "Height of the tool after\n"
  1795. "the last move at the end of the job."
  1796. )
  1797. grid1.addWidget(endzlabel, 8, 0)
  1798. self.gendz_entry = LengthEntry()
  1799. grid1.addWidget(self.gendz_entry, 8, 1)
  1800. # Feedrate X-Y
  1801. frlabel = QtWidgets.QLabel('Feed Rate X-Y:')
  1802. frlabel.setToolTip(
  1803. "Cutting speed in the XY\n"
  1804. "plane in units per minute"
  1805. )
  1806. grid1.addWidget(frlabel, 9, 0)
  1807. self.cncfeedrate_entry = LengthEntry()
  1808. grid1.addWidget(self.cncfeedrate_entry, 9, 1)
  1809. # Feedrate Z (Plunge)
  1810. frz_label = QtWidgets.QLabel('Feed Rate Z:')
  1811. frz_label.setToolTip(
  1812. "Cutting speed in the XY\n"
  1813. "plane in units per minute.\n"
  1814. "It is called also Plunge."
  1815. )
  1816. grid1.addWidget(frz_label, 10, 0)
  1817. self.cncplunge_entry = LengthEntry()
  1818. grid1.addWidget(self.cncplunge_entry, 10, 1)
  1819. # Feedrate rapids
  1820. fr_rapid_label = QtWidgets.QLabel('Feed Rate Rapids:')
  1821. fr_rapid_label.setToolTip(
  1822. "Cutting speed in the XY\n"
  1823. "plane in units per minute"
  1824. )
  1825. grid1.addWidget(fr_rapid_label, 11, 0)
  1826. self.cncfeedrate_rapid_entry = LengthEntry()
  1827. grid1.addWidget(self.cncfeedrate_rapid_entry, 11, 1)
  1828. # End move extra cut
  1829. self.extracut_cb = FCCheckBox(label='Cut over 1st pt.')
  1830. self.extracut_cb.setToolTip(
  1831. "In order to remove possible\n"
  1832. "copper leftovers where first cut\n"
  1833. "meet with last cut, we generate an\n"
  1834. "extended cut over the first cut section."
  1835. )
  1836. grid1.addWidget(self.extracut_cb, 12, 0)
  1837. # Spindle Speed
  1838. spdlabel = QtWidgets.QLabel('Spindle speed:')
  1839. spdlabel.setToolTip(
  1840. "Speed of the spindle\n"
  1841. "in RPM (optional)"
  1842. )
  1843. grid1.addWidget(spdlabel, 13, 0)
  1844. self.cncspindlespeed_entry = IntEntry(allow_empty=True)
  1845. grid1.addWidget(self.cncspindlespeed_entry, 13, 1)
  1846. # Dwell
  1847. self.dwell_cb = FCCheckBox(label='Dwell:')
  1848. self.dwell_cb.setToolTip(
  1849. "Pause to allow the spindle to reach its\n"
  1850. "speed before cutting."
  1851. )
  1852. dwelltime = QtWidgets.QLabel('Duration [m-sec.]:')
  1853. dwelltime.setToolTip(
  1854. "Number of milliseconds for spindle to dwell."
  1855. )
  1856. self.dwelltime_entry = FCEntry()
  1857. grid1.addWidget(self.dwell_cb, 14, 0)
  1858. grid1.addWidget(dwelltime, 15, 0)
  1859. grid1.addWidget(self.dwelltime_entry, 15, 1)
  1860. self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  1861. # postprocessor selection
  1862. pp_label = QtWidgets.QLabel("Postprocessor:")
  1863. pp_label.setToolTip(
  1864. "The postprocessor file that dictates\n"
  1865. "Machine Code output."
  1866. )
  1867. grid1.addWidget(pp_label, 16, 0)
  1868. self.pp_geometry_name_cb = FCComboBox()
  1869. self.pp_geometry_name_cb.setFocusPolicy(Qt.StrongFocus)
  1870. grid1.addWidget(self.pp_geometry_name_cb, 16, 1)
  1871. # Size of trace segment on X axis
  1872. segx_label = QtWidgets.QLabel("Seg. X size:")
  1873. segx_label.setToolTip(
  1874. "The size of the trace segment on the X axis.\n"
  1875. "Useful for auto-leveling.\n"
  1876. "A value of 0 means no segmentation on the X axis."
  1877. )
  1878. grid1.addWidget(segx_label, 17, 0)
  1879. self.segx_entry = FCEntry()
  1880. grid1.addWidget(self.segx_entry, 17, 1)
  1881. # Size of trace segment on Y axis
  1882. segy_label = QtWidgets.QLabel("Seg. Y size:")
  1883. segy_label.setToolTip(
  1884. "The size of the trace segment on the Y axis.\n"
  1885. "Useful for auto-leveling.\n"
  1886. "A value of 0 means no segmentation on the Y axis."
  1887. )
  1888. grid1.addWidget(segy_label, 18, 0)
  1889. self.segy_entry = FCEntry()
  1890. grid1.addWidget(self.segy_entry, 18, 1)
  1891. self.layout.addStretch()
  1892. class CNCJobGenPrefGroupUI(OptionsGroupUI):
  1893. def __init__(self, parent=None):
  1894. # OptionsGroupUI.__init__(self, "CNC Job General Preferences", parent=None)
  1895. super(CNCJobGenPrefGroupUI, self).__init__(self)
  1896. self.setTitle(str("CNC Job General"))
  1897. ## Plot options
  1898. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1899. self.layout.addWidget(self.plot_options_label)
  1900. grid0 = QtWidgets.QGridLayout()
  1901. self.layout.addLayout(grid0)
  1902. # Plot CB
  1903. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  1904. self.plot_cb = FCCheckBox('Plot')
  1905. self.plot_cb.setToolTip(
  1906. "Plot (show) this object."
  1907. )
  1908. grid0.addWidget(self.plot_cb, 0, 0)
  1909. # Number of circle steps for circular aperture linear approximation
  1910. self.steps_per_circle_label = QtWidgets.QLabel("Circle Steps:")
  1911. self.steps_per_circle_label.setToolTip(
  1912. "The number of circle steps for <b>GCode</b> \n"
  1913. "circle and arc shapes linear approximation."
  1914. )
  1915. grid0.addWidget(self.steps_per_circle_label, 1, 0)
  1916. self.steps_per_circle_entry = IntEntry()
  1917. grid0.addWidget(self.steps_per_circle_entry, 1, 1)
  1918. # Tool dia for plot
  1919. tdlabel = QtWidgets.QLabel('Tool dia:')
  1920. tdlabel.setToolTip(
  1921. "Diameter of the tool to be\n"
  1922. "rendered in the plot."
  1923. )
  1924. grid0.addWidget(tdlabel, 2, 0)
  1925. self.tooldia_entry = LengthEntry()
  1926. grid0.addWidget(self.tooldia_entry, 2, 1)
  1927. # Number of decimals to use in GCODE coordinates
  1928. cdeclabel = QtWidgets.QLabel('Coords decimals:')
  1929. cdeclabel.setToolTip(
  1930. "The number of decimals to be used for \n"
  1931. "the X, Y, Z coordinates in CNC code (GCODE, etc.)"
  1932. )
  1933. grid0.addWidget(cdeclabel, 3, 0)
  1934. self.coords_dec_entry = IntEntry()
  1935. grid0.addWidget(self.coords_dec_entry, 3, 1)
  1936. # Number of decimals to use in GCODE feedrate
  1937. frdeclabel = QtWidgets.QLabel('Feedrate decimals:')
  1938. frdeclabel.setToolTip(
  1939. "The number of decimals to be used for \n"
  1940. "the feedrate in CNC code (GCODE, etc.)"
  1941. )
  1942. grid0.addWidget(frdeclabel, 4, 0)
  1943. self.fr_dec_entry = IntEntry()
  1944. grid0.addWidget(self.fr_dec_entry, 4, 1)
  1945. self.layout.addStretch()
  1946. class CNCJobOptPrefGroupUI(OptionsGroupUI):
  1947. def __init__(self, parent=None):
  1948. # OptionsGroupUI.__init__(self, "CNC Job Options Preferences", parent=None)
  1949. super(CNCJobOptPrefGroupUI, self).__init__(self)
  1950. self.setTitle(str("CNC Job Options"))
  1951. ## Export G-Code
  1952. self.export_gcode_label = QtWidgets.QLabel("<b>Export G-Code:</b>")
  1953. self.export_gcode_label.setToolTip(
  1954. "Export and save G-Code to\n"
  1955. "make this object to a file."
  1956. )
  1957. self.layout.addWidget(self.export_gcode_label)
  1958. # Prepend to G-Code
  1959. prependlabel = QtWidgets.QLabel('Prepend to G-Code:')
  1960. prependlabel.setToolTip(
  1961. "Type here any G-Code commands you would\n"
  1962. "like to add at the beginning of the G-Code file."
  1963. )
  1964. self.layout.addWidget(prependlabel)
  1965. self.prepend_text = FCTextArea()
  1966. self.layout.addWidget(self.prepend_text)
  1967. # Append text to G-Code
  1968. appendlabel = QtWidgets.QLabel('Append to G-Code:')
  1969. appendlabel.setToolTip(
  1970. "Type here any G-Code commands you would\n"
  1971. "like to append to the generated file.\n"
  1972. "I.e.: M2 (End of program)"
  1973. )
  1974. self.layout.addWidget(appendlabel)
  1975. self.append_text = FCTextArea()
  1976. self.layout.addWidget(self.append_text)
  1977. self.layout.addStretch()
  1978. class ToolsNCCPrefGroupUI(OptionsGroupUI):
  1979. def __init__(self, parent=None):
  1980. # OptionsGroupUI.__init__(self, "NCC Tool Options", parent=parent)
  1981. super(ToolsNCCPrefGroupUI, self).__init__(self)
  1982. self.setTitle(str("NCC Tool Options"))
  1983. ## Clear non-copper regions
  1984. self.clearcopper_label = QtWidgets.QLabel("<b>Clear non-copper:</b>")
  1985. self.clearcopper_label.setToolTip(
  1986. "Create a Geometry object with\n"
  1987. "toolpaths to cut all non-copper regions."
  1988. )
  1989. self.layout.addWidget(self.clearcopper_label)
  1990. grid0 = QtWidgets.QGridLayout()
  1991. self.layout.addLayout(grid0)
  1992. ncctdlabel = QtWidgets.QLabel('Tools dia:')
  1993. ncctdlabel.setToolTip(
  1994. "Diameters of the cutting tools, separated by ','"
  1995. )
  1996. grid0.addWidget(ncctdlabel, 0, 0)
  1997. self.ncc_tool_dia_entry = FCEntry()
  1998. grid0.addWidget(self.ncc_tool_dia_entry, 0, 1)
  1999. nccoverlabel = QtWidgets.QLabel('Overlap:')
  2000. nccoverlabel.setToolTip(
  2001. "How much (fraction) of the tool width to overlap each tool pass.\n"
  2002. "Example:\n"
  2003. "A value here of 0.25 means 25% from the tool diameter found above.\n\n"
  2004. "Adjust the value starting with lower values\n"
  2005. "and increasing it if areas that should be cleared are still \n"
  2006. "not cleared.\n"
  2007. "Lower values = faster processing, faster execution on PCB.\n"
  2008. "Higher values = slow processing and slow execution on CNC\n"
  2009. "due of too many paths."
  2010. )
  2011. grid0.addWidget(nccoverlabel, 1, 0)
  2012. self.ncc_overlap_entry = FloatEntry()
  2013. grid0.addWidget(self.ncc_overlap_entry, 1, 1)
  2014. nccmarginlabel = QtWidgets.QLabel('Margin:')
  2015. nccmarginlabel.setToolTip(
  2016. "Bounding box margin."
  2017. )
  2018. grid0.addWidget(nccmarginlabel, 2, 0)
  2019. self.ncc_margin_entry = FloatEntry()
  2020. grid0.addWidget(self.ncc_margin_entry, 2, 1)
  2021. # Method
  2022. methodlabel = QtWidgets.QLabel('Method:')
  2023. methodlabel.setToolTip(
  2024. "Algorithm for non-copper clearing:<BR>"
  2025. "<B>Standard</B>: Fixed step inwards.<BR>"
  2026. "<B>Seed-based</B>: Outwards from seed.<BR>"
  2027. "<B>Line-based</B>: Parallel lines."
  2028. )
  2029. grid0.addWidget(methodlabel, 3, 0)
  2030. self.ncc_method_radio = RadioSet([
  2031. {"label": "Standard", "value": "standard"},
  2032. {"label": "Seed-based", "value": "seed"},
  2033. {"label": "Straight lines", "value": "lines"}
  2034. ], orientation='vertical', stretch=False)
  2035. grid0.addWidget(self.ncc_method_radio, 3, 1)
  2036. # Connect lines
  2037. pathconnectlabel = QtWidgets.QLabel("Connect:")
  2038. pathconnectlabel.setToolTip(
  2039. "Draw lines between resulting\n"
  2040. "segments to minimize tool lifts."
  2041. )
  2042. grid0.addWidget(pathconnectlabel, 4, 0)
  2043. self.ncc_connect_cb = FCCheckBox()
  2044. grid0.addWidget(self.ncc_connect_cb, 4, 1)
  2045. contourlabel = QtWidgets.QLabel("Contour:")
  2046. contourlabel.setToolTip(
  2047. "Cut around the perimeter of the polygon\n"
  2048. "to trim rough edges."
  2049. )
  2050. grid0.addWidget(contourlabel, 5, 0)
  2051. self.ncc_contour_cb = FCCheckBox()
  2052. grid0.addWidget(self.ncc_contour_cb, 5, 1)
  2053. restlabel = QtWidgets.QLabel("Rest M.:")
  2054. restlabel.setToolTip(
  2055. "If checked, use 'rest machining'.\n"
  2056. "Basically it will clear copper outside PCB features,\n"
  2057. "using the biggest tool and continue with the next tools,\n"
  2058. "from bigger to smaller, to clear areas of copper that\n"
  2059. "could not be cleared by previous tool.\n"
  2060. "If not checked, use the standard algorithm."
  2061. )
  2062. grid0.addWidget(restlabel, 6, 0)
  2063. self.ncc_rest_cb = FCCheckBox()
  2064. grid0.addWidget(self.ncc_rest_cb, 6, 1)
  2065. self.layout.addStretch()
  2066. class ToolsCutoutPrefGroupUI(OptionsGroupUI):
  2067. def __init__(self, parent=None):
  2068. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  2069. super(ToolsCutoutPrefGroupUI, self).__init__(self)
  2070. self.setTitle(str("Cutout Tool Options"))
  2071. ## Board cuttout
  2072. self.board_cutout_label = QtWidgets.QLabel("<b>Board cutout:</b>")
  2073. self.board_cutout_label.setToolTip(
  2074. "Create toolpaths to cut around\n"
  2075. "the PCB and separate it from\n"
  2076. "the original board."
  2077. )
  2078. self.layout.addWidget(self.board_cutout_label)
  2079. grid0 = QtWidgets.QGridLayout()
  2080. self.layout.addLayout(grid0)
  2081. tdclabel = QtWidgets.QLabel('Tool dia:')
  2082. tdclabel.setToolTip(
  2083. "Diameter of the cutting tool."
  2084. )
  2085. grid0.addWidget(tdclabel, 0, 0)
  2086. self.cutout_tooldia_entry = LengthEntry()
  2087. grid0.addWidget(self.cutout_tooldia_entry, 0, 1)
  2088. marginlabel = QtWidgets.QLabel('Margin:')
  2089. marginlabel.setToolTip(
  2090. "Distance from objects at which\n"
  2091. "to draw the cutout."
  2092. )
  2093. grid0.addWidget(marginlabel, 1, 0)
  2094. self.cutout_margin_entry = LengthEntry()
  2095. grid0.addWidget(self.cutout_margin_entry, 1, 1)
  2096. gaplabel = QtWidgets.QLabel('Gap size:')
  2097. gaplabel.setToolTip(
  2098. "Size of the gaps in the toolpath\n"
  2099. "that will remain to hold the\n"
  2100. "board in place."
  2101. )
  2102. grid0.addWidget(gaplabel, 2, 0)
  2103. self.cutout_gap_entry = LengthEntry()
  2104. grid0.addWidget(self.cutout_gap_entry, 2, 1)
  2105. gapslabel = QtWidgets.QLabel('Gaps Rect:')
  2106. gapslabel.setToolTip(
  2107. "Where to place the gaps when doing a Rectangular Cutout:\n"
  2108. " - 2 (T/B) --> Top/Bottom\n"
  2109. " - 2 (L/R) --> Left/Rigt\n"
  2110. " - 4 --> on each of all 4 sides."
  2111. )
  2112. grid0.addWidget(gapslabel, 3, 0)
  2113. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  2114. {'label': '2 (L/R)', 'value': 'lr'},
  2115. {'label': '4', 'value': '4'}])
  2116. grid0.addWidget(self.gaps_radio, 3, 1)
  2117. gaps_ff_label = QtWidgets.QLabel('Gaps FF:')
  2118. gaps_ff_label.setToolTip(
  2119. "Number of gaps used for the FreeForm cutout.\n"
  2120. "There can be maximum 8 bridges/gaps.\n"
  2121. "The choices are:\n"
  2122. "- lr - left + right\n"
  2123. "- tb - top + bottom\n"
  2124. "- 4 - left + right +top + bottom\n"
  2125. "- 2lr - 2*left + 2*right\n"
  2126. "- 2tb - 2*top + 2*bottom\n"
  2127. "- 8 - 2*left + 2*right +2*top + 2*bottom"
  2128. )
  2129. grid0.addWidget(gaps_ff_label, 4, 0)
  2130. self.gaps_combo = FCComboBox()
  2131. grid0.addWidget(self.gaps_combo, 4, 1)
  2132. gaps_items = ['LR', 'TB', '4', '2LR', '2TB', '8']
  2133. for it in gaps_items:
  2134. self.gaps_combo.addItem(it)
  2135. self.gaps_combo.setStyleSheet('background-color: rgb(255,255,255)')
  2136. self.layout.addStretch()
  2137. class ToolsPaintPrefGroupUI(OptionsGroupUI):
  2138. def __init__(self, parent=None):
  2139. # OptionsGroupUI.__init__(self, "Paint Area Tool Options", parent=parent)
  2140. super(ToolsPaintPrefGroupUI, self).__init__(self)
  2141. self.setTitle(str("Paint Area Tool Options"))
  2142. # ------------------------------
  2143. ## Paint area
  2144. # ------------------------------
  2145. self.paint_label = QtWidgets.QLabel('<b>Paint Area:</b>')
  2146. self.paint_label.setToolTip(
  2147. "Creates tool paths to cover the\n"
  2148. "whole area of a polygon (remove\n"
  2149. "all copper). You will be asked\n"
  2150. "to click on the desired polygon."
  2151. )
  2152. self.layout.addWidget(self.paint_label)
  2153. grid0 = QtWidgets.QGridLayout()
  2154. self.layout.addLayout(grid0)
  2155. # Tool dia
  2156. ptdlabel = QtWidgets.QLabel('Tool dia:')
  2157. ptdlabel.setToolTip(
  2158. "Diameter of the tool to\n"
  2159. "be used in the operation."
  2160. )
  2161. grid0.addWidget(ptdlabel, 0, 0)
  2162. self.painttooldia_entry = LengthEntry()
  2163. grid0.addWidget(self.painttooldia_entry, 0, 1)
  2164. # Overlap
  2165. ovlabel = QtWidgets.QLabel('Overlap:')
  2166. ovlabel.setToolTip(
  2167. "How much (fraction) of the tool\n"
  2168. "width to overlap each tool pass."
  2169. )
  2170. grid0.addWidget(ovlabel, 1, 0)
  2171. self.paintoverlap_entry = LengthEntry()
  2172. grid0.addWidget(self.paintoverlap_entry, 1, 1)
  2173. # Margin
  2174. marginlabel = QtWidgets.QLabel('Margin:')
  2175. marginlabel.setToolTip(
  2176. "Distance by which to avoid\n"
  2177. "the edges of the polygon to\n"
  2178. "be painted."
  2179. )
  2180. grid0.addWidget(marginlabel, 2, 0)
  2181. self.paintmargin_entry = LengthEntry()
  2182. grid0.addWidget(self.paintmargin_entry, 2, 1)
  2183. # Method
  2184. methodlabel = QtWidgets.QLabel('Method:')
  2185. methodlabel.setToolTip(
  2186. "Algorithm to paint the polygon:<BR>"
  2187. "<B>Standard</B>: Fixed step inwards.<BR>"
  2188. "<B>Seed-based</B>: Outwards from seed."
  2189. )
  2190. grid0.addWidget(methodlabel, 3, 0)
  2191. self.paintmethod_combo = RadioSet([
  2192. {"label": "Standard", "value": "standard"},
  2193. {"label": "Seed-based", "value": "seed"},
  2194. {"label": "Straight lines", "value": "lines"}
  2195. ], orientation='vertical', stretch=False)
  2196. grid0.addWidget(self.paintmethod_combo, 3, 1)
  2197. # Connect lines
  2198. pathconnectlabel = QtWidgets.QLabel("Connect:")
  2199. pathconnectlabel.setToolTip(
  2200. "Draw lines between resulting\n"
  2201. "segments to minimize tool lifts."
  2202. )
  2203. grid0.addWidget(pathconnectlabel, 4, 0)
  2204. self.pathconnect_cb = FCCheckBox()
  2205. grid0.addWidget(self.pathconnect_cb, 4, 1)
  2206. # Paint contour
  2207. contourlabel = QtWidgets.QLabel("Contour:")
  2208. contourlabel.setToolTip(
  2209. "Cut around the perimeter of the polygon\n"
  2210. "to trim rough edges."
  2211. )
  2212. grid0.addWidget(contourlabel, 5, 0)
  2213. self.contour_cb = FCCheckBox()
  2214. grid0.addWidget(self.contour_cb, 5, 1)
  2215. # Polygon selection
  2216. selectlabel = QtWidgets.QLabel('Selection:')
  2217. selectlabel.setToolTip(
  2218. "How to select the polygons to paint."
  2219. )
  2220. grid0.addWidget(selectlabel, 6, 0)
  2221. self.selectmethod_combo = RadioSet([
  2222. {"label": "Single", "value": "single"},
  2223. {"label": "All", "value": "all"},
  2224. # {"label": "Rectangle", "value": "rectangle"}
  2225. ])
  2226. grid0.addWidget(self.selectmethod_combo, 6, 1)
  2227. self.layout.addStretch()
  2228. class FlatCAMActivityView(QtWidgets.QWidget):
  2229. def __init__(self, parent=None):
  2230. super().__init__(parent=parent)
  2231. self.setMinimumWidth(200)
  2232. self.icon = QtWidgets.QLabel(self)
  2233. self.icon.setGeometry(0, 0, 16, 12)
  2234. self.movie = QtGui.QMovie("share/active.gif")
  2235. self.icon.setMovie(self.movie)
  2236. # self.movie.start()
  2237. layout = QtWidgets.QHBoxLayout()
  2238. layout.setContentsMargins(5, 0, 5, 0)
  2239. layout.setAlignment(QtCore.Qt.AlignLeft)
  2240. self.setLayout(layout)
  2241. layout.addWidget(self.icon)
  2242. self.text = QtWidgets.QLabel(self)
  2243. self.text.setText("Idle.")
  2244. layout.addWidget(self.text)
  2245. def set_idle(self):
  2246. self.movie.stop()
  2247. self.text.setText("Idle.")
  2248. def set_busy(self, msg):
  2249. self.movie.start()
  2250. self.text.setText(msg)
  2251. class FlatCAMInfoBar(QtWidgets.QWidget):
  2252. def __init__(self, parent=None):
  2253. super(FlatCAMInfoBar, self).__init__(parent=parent)
  2254. self.icon = QtWidgets.QLabel(self)
  2255. self.icon.setGeometry(0, 0, 12, 12)
  2256. self.pmap = QtGui.QPixmap('share/graylight12.png')
  2257. self.icon.setPixmap(self.pmap)
  2258. layout = QtWidgets.QHBoxLayout()
  2259. layout.setContentsMargins(5, 0, 5, 0)
  2260. self.setLayout(layout)
  2261. layout.addWidget(self.icon)
  2262. self.text = QtWidgets.QLabel(self)
  2263. self.text.setText("Hello!")
  2264. self.text.setToolTip("Hello!")
  2265. layout.addWidget(self.text)
  2266. layout.addStretch()
  2267. def set_text_(self, text):
  2268. self.text.setText(text)
  2269. self.text.setToolTip(text)
  2270. def set_status(self, text, level="info"):
  2271. level = str(level)
  2272. self.pmap.fill()
  2273. if level == "error" or level == "error_notcl":
  2274. self.pmap = QtGui.QPixmap('share/redlight12.png')
  2275. elif level == "success":
  2276. self.pmap = QtGui.QPixmap('share/greenlight12.png')
  2277. elif level == "warning" or level == "warning_notcl":
  2278. self.pmap = QtGui.QPixmap('share/yellowlight12.png')
  2279. else:
  2280. self.pmap = QtGui.QPixmap('share/graylight12.png')
  2281. self.icon.setPixmap(self.pmap)
  2282. self.set_text_(text)
  2283. # end of file