FlatCAMGUI.py 197 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152
  1. # ##########################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # http://flatcam.org #
  4. # Author: Juan Pablo Caram (c) #
  5. # Date: 2/5/2014 #
  6. # MIT Licence #
  7. # ##########################################################
  8. # ##########################################################
  9. # File Modified (major mod): Marius Adrian Stanciu #
  10. # Date: 3/10/2019 #
  11. # ##########################################################
  12. from flatcamGUI.PreferencesUI import *
  13. from flatcamEditors.FlatCAMGeoEditor import FCShapeTool
  14. from matplotlib.backend_bases import KeyEvent as mpl_key_event
  15. import webbrowser
  16. from copy import deepcopy
  17. from datetime import datetime
  18. import gettext
  19. import FlatCAMTranslation as fcTranslate
  20. import builtins
  21. fcTranslate.apply_language('strings')
  22. if '_' not in builtins.__dict__:
  23. _ = gettext.gettext
  24. class FlatCAMGUI(QtWidgets.QMainWindow):
  25. # Emitted when persistent window geometry needs to be retained
  26. geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
  27. final_save = QtCore.pyqtSignal(name='saveBeforeExit')
  28. def __init__(self, app):
  29. super(FlatCAMGUI, self).__init__()
  30. self.app = app
  31. self.decimals = self.app.decimals
  32. # Divine icon pack by Ipapun @ finicons.com
  33. # ################################## ##
  34. # ## BUILDING THE GUI IS DONE HERE # ##
  35. # ################################## ##
  36. # ######### ##
  37. # ## Menu # ##
  38. # ######### ##
  39. self.menu = self.menuBar()
  40. self.menu_toggle_nb = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/notebook32.png'), _("Toggle Panel"))
  41. self.menu_toggle_nb.setToolTip(
  42. _("Toggle Panel")
  43. )
  44. # self.menu_toggle_nb = QtWidgets.QAction("NB")
  45. self.menu_toggle_nb.setCheckable(True)
  46. self.menu.addAction(self.menu_toggle_nb)
  47. # ########################################################################
  48. # ########################## File # ######################################
  49. # ########################################################################
  50. self.menufile = self.menu.addMenu(_('File'))
  51. self.menufile.setToolTipsVisible(True)
  52. # New Project
  53. self.menufilenewproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/file16.png'),
  54. _('&New Project ...\tCTRL+N'), self)
  55. self.menufilenewproject.setToolTip(
  56. _("Will create a new, blank project")
  57. )
  58. self.menufile.addAction(self.menufilenewproject)
  59. # New Category (Excellon, Geometry)
  60. self.menufilenew = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/file16.png'), _('&New'))
  61. self.menufilenew.setToolTipsVisible(True)
  62. self.menufilenewgeo = self.menufilenew.addAction(
  63. QtGui.QIcon(self.app.resource_location + '/new_file_geo16.png'), _('Geometry\tN'))
  64. self.menufilenewgeo.setToolTip(
  65. _("Will create a new, empty Geometry Object.")
  66. )
  67. self.menufilenewgrb = self.menufilenew.addAction(QtGui.QIcon(self.app.resource_location + '/new_file_grb16.png'), _('Gerber\tB'))
  68. self.menufilenewgrb.setToolTip(
  69. _("Will create a new, empty Gerber Object.")
  70. )
  71. self.menufilenewexc = self.menufilenew.addAction(QtGui.QIcon(self.app.resource_location + '/new_file_exc16.png'), _('Excellon\tL'))
  72. self.menufilenewexc.setToolTip(
  73. _("Will create a new, empty Excellon Object.")
  74. )
  75. self.menufilenew.addSeparator()
  76. self.menufilenewdoc = self.menufilenew.addAction(QtGui.QIcon(self.app.resource_location + '/notes16_1.png'), _('Document\tD'))
  77. self.menufilenewdoc.setToolTip(
  78. _("Will create a new, empty Document Object.")
  79. )
  80. self.menufile_open = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'), _('Open'))
  81. self.menufile_open.setToolTipsVisible(True)
  82. # Open Project ...
  83. self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open &Project ...'), self)
  84. self.menufile_open.addAction(self.menufileopenproject)
  85. self.menufile_open.addSeparator()
  86. # Open Gerber ...
  87. self.menufileopengerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/flatcam_icon24.png'),
  88. _('Open &Gerber ...\tCTRL+G'), self)
  89. self.menufile_open.addAction(self.menufileopengerber)
  90. # Open Excellon ...
  91. self.menufileopenexcellon = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'),
  92. _('Open &Excellon ...\tCTRL+E'), self)
  93. self.menufile_open.addAction(self.menufileopenexcellon)
  94. # Open G-Code ...
  95. self.menufileopengcode = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/code.png'), _('Open G-&Code ...'), self)
  96. self.menufile_open.addAction(self.menufileopengcode)
  97. self.menufile_open.addSeparator()
  98. # Open Config File...
  99. self.menufileopenconfig = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open Config ...'), self)
  100. self.menufile_open.addAction(self.menufileopenconfig)
  101. # Recent
  102. self.recent_projects = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent projects"))
  103. self.recent = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent files"))
  104. # Separator
  105. self.menufile.addSeparator()
  106. # Scripting
  107. self.menufile_scripting = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Scripting'))
  108. self.menufile_scripting.setToolTipsVisible(True)
  109. self.menufilenewscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/script_new16.png'), _('New Script ...'), self)
  110. self.menufileopenscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'), self)
  111. self.menufilerunscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/script16.png'),
  112. '%s\tSHIFT+S' % _('Run Script ...'), self)
  113. self.menufilerunscript.setToolTip(
  114. _("Will run the opened Tcl Script thus\n"
  115. "enabling the automation of certain\n"
  116. "functions of FlatCAM.")
  117. )
  118. self.menufile_scripting.addAction(self.menufilenewscript)
  119. self.menufile_scripting.addAction(self.menufileopenscript)
  120. self.menufile_scripting.addSeparator()
  121. self.menufile_scripting.addAction(self.menufilerunscript)
  122. # Separator
  123. self.menufile.addSeparator()
  124. # Import ...
  125. self.menufileimport = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/import.png'), _('Import'))
  126. self.menufileimportsvg = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/svg16.png'),
  127. _('&SVG as Geometry Object ...'), self)
  128. self.menufileimport.addAction(self.menufileimportsvg)
  129. self.menufileimportsvg_as_gerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/svg16.png'),
  130. _('&SVG as Gerber Object ...'), self)
  131. self.menufileimport.addAction(self.menufileimportsvg_as_gerber)
  132. self.menufileimport.addSeparator()
  133. self.menufileimportdxf = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/dxf16.png'),
  134. _('&DXF as Geometry Object ...'), self)
  135. self.menufileimport.addAction(self.menufileimportdxf)
  136. self.menufileimportdxf_as_gerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/dxf16.png'),
  137. _('&DXF as Gerber Object ...'), self)
  138. self.menufileimport.addAction(self.menufileimportdxf_as_gerber)
  139. self.menufileimport.addSeparator()
  140. self.menufileimport_hpgl2_as_geo = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/dxf16.png'),
  141. _('HPGL2 as Geometry Object ...'), self)
  142. self.menufileimport.addAction(self.menufileimport_hpgl2_as_geo)
  143. self.menufileimport.addSeparator()
  144. # Export ...
  145. self.menufileexport = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export'))
  146. self.menufileexport.setToolTipsVisible(True)
  147. self.menufileexportsvg = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export &SVG ...'), self)
  148. self.menufileexport.addAction(self.menufileexportsvg)
  149. self.menufileexportdxf = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export DXF ...'), self)
  150. self.menufileexport.addAction(self.menufileexportdxf)
  151. self.menufileexport.addSeparator()
  152. self.menufileexportpng = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/export_png32.png'), _('Export &PNG ...'), self)
  153. self.menufileexportpng.setToolTip(
  154. _("Will export an image in PNG format,\n"
  155. "the saved image will contain the visual \n"
  156. "information currently in FlatCAM Plot Area.")
  157. )
  158. self.menufileexport.addAction(self.menufileexportpng)
  159. self.menufileexport.addSeparator()
  160. self.menufileexportexcellon = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/drill32.png'),
  161. _('Export &Excellon ...'), self)
  162. self.menufileexportexcellon.setToolTip(
  163. _("Will export an Excellon Object as Excellon file,\n"
  164. "the coordinates format, the file units and zeros\n"
  165. "are set in Preferences -> Excellon Export.")
  166. )
  167. self.menufileexport.addAction(self.menufileexportexcellon)
  168. self.menufileexportgerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'),
  169. _('Export &Gerber ...'), self)
  170. self.menufileexportgerber.setToolTip(
  171. _("Will export an Gerber Object as Gerber file,\n"
  172. "the coordinates format, the file units and zeros\n"
  173. "are set in Preferences -> Gerber Export.")
  174. )
  175. self.menufileexport.addAction(self.menufileexportgerber)
  176. # Separator
  177. self.menufile.addSeparator()
  178. # Save Defaults
  179. self.menufilesavedefaults = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/defaults.png'),
  180. _('Save Preferences'), self)
  181. self.menufile.addAction(self.menufilesavedefaults)
  182. # Separator
  183. self.menufile.addSeparator()
  184. self.menufile_backup = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/backup24.png'),
  185. _('Backup'))
  186. # Import Preferences
  187. self.menufileimportpref = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/backup_import24.png'),
  188. _('Import Preferences from file ...'), self)
  189. self.menufile_backup.addAction(self.menufileimportpref)
  190. # Export Preferences
  191. self.menufileexportpref = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/backup_export24.png'),
  192. _('Export Preferences to file ...'), self)
  193. self.menufile_backup.addAction(self.menufileexportpref)
  194. # Separator
  195. self.menufile.addSeparator()
  196. self.menufile_print = QtWidgets.QAction(
  197. QtGui.QIcon(self.app.resource_location + '/printer32.png'), '%s\tCTRL+P' % _('Print (PDF)'))
  198. self.menufile.addAction(self.menufile_print)
  199. self.menufile_save = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/save_as.png'), _('Save'))
  200. # Save Project
  201. self.menufilesaveproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/floppy16.png'),
  202. _('&Save Project ...'), self)
  203. self.menufile_save.addAction(self.menufilesaveproject)
  204. # Save Project As ...
  205. self.menufilesaveprojectas = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/save_as.png'),
  206. _('Save Project &As ...\tCTRL+S'), self)
  207. self.menufile_save.addAction(self.menufilesaveprojectas)
  208. # Save Project Copy ...
  209. self.menufilesaveprojectcopy = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/floppy16.png'),
  210. _('Save Project C&opy ...'), self)
  211. self.menufile_save.addAction(self.menufilesaveprojectcopy)
  212. self.menufile_save.addSeparator()
  213. # Separator
  214. self.menufile.addSeparator()
  215. # Quit
  216. self.menufile_exit = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/power16.png'),
  217. _('E&xit'), self)
  218. # exitAction.setShortcut('Ctrl+Q')
  219. # exitAction.setStatusTip('Exit application')
  220. self.menufile.addAction(self.menufile_exit)
  221. # ########################################################################
  222. # ########################## Edit # ######################################
  223. # ########################################################################
  224. self.menuedit = self.menu.addMenu(_('Edit'))
  225. # Separator
  226. self.menuedit.addSeparator()
  227. self.menueditedit = self.menuedit.addAction(QtGui.QIcon(self.app.resource_location + '/edit16.png'),
  228. _('Edit Object\tE'))
  229. self.menueditok = self.menuedit.addAction(QtGui.QIcon(self.app.resource_location + '/edit_ok16.png'),
  230. _('Close Editor\tCTRL+S'))
  231. # adjust the initial state of the menu entries related to the editor
  232. self.menueditedit.setDisabled(False)
  233. self.menueditok.setDisabled(True)
  234. # Separator
  235. self.menuedit.addSeparator()
  236. self.menuedit_convert = self.menuedit.addMenu(QtGui.QIcon(self.app.resource_location + '/convert24.png'),
  237. _('Conversion'))
  238. self.menuedit_convertjoin = self.menuedit_convert.addAction(
  239. QtGui.QIcon(self.app.resource_location + '/join16.png'), _('&Join Geo/Gerber/Exc -> Geo'))
  240. self.menuedit_convertjoin.setToolTip(
  241. _("Merge a selection of objects, which can be of type:\n"
  242. "- Gerber\n"
  243. "- Excellon\n"
  244. "- Geometry\n"
  245. "into a new combo Geometry object.")
  246. )
  247. self.menuedit_convertjoinexc = self.menuedit_convert.addAction(
  248. QtGui.QIcon(self.app.resource_location + '/join16.png'), _('Join Excellon(s) -> Excellon'))
  249. self.menuedit_convertjoinexc.setToolTip(
  250. _("Merge a selection of Excellon objects into a new combo Excellon object.")
  251. )
  252. self.menuedit_convertjoingrb = self.menuedit_convert.addAction(
  253. QtGui.QIcon(self.app.resource_location + '/join16.png'), _('Join Gerber(s) -> Gerber'))
  254. self.menuedit_convertjoingrb.setToolTip(
  255. _("Merge a selection of Gerber objects into a new combo Gerber object.")
  256. )
  257. # Separator
  258. self.menuedit_convert.addSeparator()
  259. self.menuedit_convert_sg2mg = self.menuedit_convert.addAction(
  260. QtGui.QIcon(self.app.resource_location + '/convert24.png'), _('Convert Single to MultiGeo'))
  261. self.menuedit_convert_sg2mg.setToolTip(
  262. _("Will convert a Geometry object from single_geometry type\n"
  263. "to a multi_geometry type.")
  264. )
  265. self.menuedit_convert_mg2sg = self.menuedit_convert.addAction(
  266. QtGui.QIcon(self.app.resource_location + '/convert24.png'), _('Convert Multi to SingleGeo'))
  267. self.menuedit_convert_mg2sg.setToolTip(
  268. _("Will convert a Geometry object from multi_geometry type\n"
  269. "to a single_geometry type.")
  270. )
  271. # Separator
  272. self.menuedit_convert.addSeparator()
  273. self.menueditconvert_any2geo = self.menuedit_convert.addAction(
  274. QtGui.QIcon(self.app.resource_location + '/copy_geo.png'),
  275. _('Convert Any to Geo'))
  276. self.menueditconvert_any2gerber = self.menuedit_convert.addAction(
  277. QtGui.QIcon(self.app.resource_location + '/copy_geo.png'),
  278. _('Convert Any to Gerber'))
  279. self.menuedit_convert.setToolTipsVisible(True)
  280. # Separator
  281. self.menuedit.addSeparator()
  282. self.menueditcopyobject = self.menuedit.addAction(
  283. QtGui.QIcon(self.app.resource_location + '/copy.png'), _('&Copy\tCTRL+C'))
  284. # Separator
  285. self.menuedit.addSeparator()
  286. self.menueditdelete = self.menuedit.addAction(
  287. QtGui.QIcon(self.app.resource_location + '/trash16.png'), _('&Delete\tDEL'))
  288. # Separator
  289. self.menuedit.addSeparator()
  290. self.menueditorigin = self.menuedit.addAction(
  291. QtGui.QIcon(self.app.resource_location + '/origin16.png'), _('Se&t Origin\tO'))
  292. self.menueditjump = self.menuedit.addAction(
  293. QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location\tJ'))
  294. # Separator
  295. self.menuedit.addSeparator()
  296. self.menuedittoggleunits = self.menuedit.addAction(
  297. QtGui.QIcon(self.app.resource_location + '/toggle_units16.png'), _('Toggle Units\tQ'))
  298. self.menueditselectall = self.menuedit.addAction(
  299. QtGui.QIcon(self.app.resource_location + '/select_all.png'), _('&Select All\tCTRL+A'))
  300. # Separator
  301. self.menuedit.addSeparator()
  302. self.menueditpreferences = self.menuedit.addAction(
  303. QtGui.QIcon(self.app.resource_location + '/pref.png'), _('&Preferences\tSHIFT+P'))
  304. # ########################################################################
  305. # ########################## OPTIONS # ###################################
  306. # ########################################################################
  307. self.menuoptions = self.menu.addMenu(_('Options'))
  308. self.menuoptions_transform_rotate = self.menuoptions.addAction(
  309. QtGui.QIcon(self.app.resource_location + '/rotate.png'), _("&Rotate Selection\tSHIFT+(R)"))
  310. # Separator
  311. self.menuoptions.addSeparator()
  312. self.menuoptions_transform_skewx = self.menuoptions.addAction(
  313. QtGui.QIcon(self.app.resource_location + '/skewX.png'), _("&Skew on X axis\tSHIFT+X"))
  314. self.menuoptions_transform_skewy = self.menuoptions.addAction(
  315. QtGui.QIcon(self.app.resource_location + '/skewY.png'), _("S&kew on Y axis\tSHIFT+Y"))
  316. # Separator
  317. self.menuoptions.addSeparator()
  318. self.menuoptions_transform_flipx = self.menuoptions.addAction(
  319. QtGui.QIcon(self.app.resource_location + '/flipx.png'), _("Flip on &X axis\tX"))
  320. self.menuoptions_transform_flipy = self.menuoptions.addAction(
  321. QtGui.QIcon(self.app.resource_location + '/flipy.png'), _("Flip on &Y axis\tY"))
  322. # Separator
  323. self.menuoptions.addSeparator()
  324. self.menuoptions_view_source = self.menuoptions.addAction(
  325. QtGui.QIcon(self.app.resource_location + '/source32.png'), _("View source\tALT+S"))
  326. self.menuoptions_tools_db = self.menuoptions.addAction(
  327. QtGui.QIcon(self.app.resource_location + '/database32.png'), _("Tools DataBase\tCTRL+D"))
  328. # Separator
  329. self.menuoptions.addSeparator()
  330. # ########################################################################
  331. # ########################## View # ######################################
  332. # ########################################################################
  333. self.menuview = self.menu.addMenu(_('View'))
  334. self.menuviewenable = self.menuview.addAction(
  335. QtGui.QIcon(self.app.resource_location + '/replot16.png'), _('Enable all plots\tALT+1'))
  336. self.menuviewdisableall = self.menuview.addAction(
  337. QtGui.QIcon(self.app.resource_location + '/clear_plot16.png'), _('Disable all plots\tALT+2'))
  338. self.menuviewdisableother = self.menuview.addAction(
  339. QtGui.QIcon(self.app.resource_location + '/clear_plot16.png'), _('Disable non-selected\tALT+3'))
  340. # Separator
  341. self.menuview.addSeparator()
  342. self.menuview_zoom_fit = self.menuview.addAction(
  343. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("&Zoom Fit\tV"))
  344. self.menuview_zoom_in = self.menuview.addAction(
  345. QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("&Zoom In\t="))
  346. self.menuview_zoom_out = self.menuview.addAction(
  347. QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("&Zoom Out\t-"))
  348. self.menuview.addSeparator()
  349. # Replot all
  350. self.menuview_replot = self.menuview.addAction(
  351. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("Redraw All\tF5"))
  352. self.menuview.addSeparator()
  353. self.menuview_toggle_code_editor = self.menuview.addAction(
  354. QtGui.QIcon(self.app.resource_location + '/code_editor32.png'), _('Toggle Code Editor\tSHIFT+E'))
  355. self.menuview.addSeparator()
  356. self.menuview_toggle_fscreen = self.menuview.addAction(
  357. QtGui.QIcon(self.app.resource_location + '/fscreen32.png'), _("&Toggle FullScreen\tALT+F10"))
  358. self.menuview_toggle_parea = self.menuview.addAction(
  359. QtGui.QIcon(self.app.resource_location + '/plot32.png'), _("&Toggle Plot Area\tCTRL+F10"))
  360. self.menuview_toggle_notebook = self.menuview.addAction(
  361. QtGui.QIcon(self.app.resource_location + '/notebook32.png'), _("&Toggle Project/Sel/Tool\t`"))
  362. self.menuview.addSeparator()
  363. self.menuview_toggle_grid = self.menuview.addAction(
  364. QtGui.QIcon(self.app.resource_location + '/grid32.png'), _("&Toggle Grid Snap\tG"))
  365. self.menuview_toggle_grid_lines = self.menuview.addAction(
  366. QtGui.QIcon(self.app.resource_location + '/grid32.png'), _("&Toggle Grid Lines\tALT+G"))
  367. self.menuview_toggle_axis = self.menuview.addAction(
  368. QtGui.QIcon(self.app.resource_location + '/axis32.png'), _("&Toggle Axis\tSHIFT+G"))
  369. self.menuview_toggle_workspace = self.menuview.addAction(
  370. QtGui.QIcon(self.app.resource_location + '/workspace24.png'), _("Toggle Workspace\tSHIFT+W"))
  371. # ########################################################################
  372. # ########################## Objects # ###################################
  373. # ########################################################################
  374. self.menuobjects = self.menu.addMenu(_('Objects'))
  375. self.menuobjects.addSeparator()
  376. self.menuobjects_selall = self.menuobjects.addAction(
  377. QtGui.QIcon(self.app.resource_location + '/select_all.png'), _('Select All'))
  378. self.menuobjects_unselall = self.menuobjects.addAction(
  379. QtGui.QIcon(self.app.resource_location + '/deselect_all32.png'), _('Deselect All')
  380. )
  381. # ########################################################################
  382. # ########################## Tool # ######################################
  383. # ########################################################################
  384. self.menutool = QtWidgets.QMenu(_('Tool'))
  385. self.menutoolaction = self.menu.addMenu(self.menutool)
  386. self.menutoolshell = self.menutool.addAction(
  387. QtGui.QIcon(self.app.resource_location + '/shell16.png'), _('&Command Line\tS'))
  388. # ########################################################################
  389. # ########################## Help # ######################################
  390. # ########################################################################
  391. self.menuhelp = self.menu.addMenu(_('Help'))
  392. self.menuhelp_manual = self.menuhelp.addAction(
  393. QtGui.QIcon(self.app.resource_location + '/globe16.png'), _('Online Help\tF1'))
  394. self.menuhelp_bookmarks = self.menuhelp.addMenu(
  395. QtGui.QIcon(self.app.resource_location + '/bookmarks16.png'), _('Bookmarks'))
  396. self.menuhelp_bookmarks.addSeparator()
  397. self.menuhelp_bookmarks_manager = self.menuhelp_bookmarks.addAction(
  398. QtGui.QIcon(self.app.resource_location + '/bookmarks16.png'), _('Bookmarks Manager'))
  399. self.menuhelp.addSeparator()
  400. self.menuhelp_report_bug = self.menuhelp.addAction(
  401. QtGui.QIcon(self.app.resource_location + '/bug16.png'), _('Report a bug'))
  402. self.menuhelp.addSeparator()
  403. self.menuhelp_exc_spec = self.menuhelp.addAction(
  404. QtGui.QIcon(self.app.resource_location + '/pdf_link16.png'), _('Excellon Specification'))
  405. self.menuhelp_gerber_spec = self.menuhelp.addAction(
  406. QtGui.QIcon(self.app.resource_location + '/pdf_link16.png'), _('Gerber Specification'))
  407. self.menuhelp.addSeparator()
  408. self.menuhelp_shortcut_list = self.menuhelp.addAction(
  409. QtGui.QIcon(self.app.resource_location + '/shortcuts24.png'), _('Shortcuts List\tF3'))
  410. self.menuhelp_videohelp = self.menuhelp.addAction(
  411. QtGui.QIcon(self.app.resource_location + '/youtube32.png'), _('YouTube Channel\tF4'))
  412. self.menuhelp_about = self.menuhelp.addAction(
  413. QtGui.QIcon(self.app.resource_location + '/about32.png'), _('About FlatCAM'))
  414. # ########################################################################
  415. # ########################## GEOMETRY EDITOR # ###########################
  416. # ########################################################################
  417. self.geo_editor_menu = QtWidgets.QMenu(">Geo Editor<")
  418. self.menu.addMenu(self.geo_editor_menu)
  419. self.geo_add_circle_menuitem = self.geo_editor_menu.addAction(
  420. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle\tO')
  421. )
  422. self.geo_add_arc_menuitem = self.geo_editor_menu.addAction(
  423. QtGui.QIcon(self.app.resource_location + '/arc16.png'), _('Add Arc\tA'))
  424. self.geo_editor_menu.addSeparator()
  425. self.geo_add_rectangle_menuitem = self.geo_editor_menu.addAction(
  426. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle\tR')
  427. )
  428. self.geo_add_polygon_menuitem = self.geo_editor_menu.addAction(
  429. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon\tN')
  430. )
  431. self.geo_add_path_menuitem = self.geo_editor_menu.addAction(
  432. QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path\tP'))
  433. self.geo_editor_menu.addSeparator()
  434. self.geo_add_text_menuitem = self.geo_editor_menu.addAction(
  435. QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text\tT'))
  436. self.geo_editor_menu.addSeparator()
  437. self.geo_union_menuitem = self.geo_editor_menu.addAction(
  438. QtGui.QIcon(self.app.resource_location + '/union16.png'),_('Polygon Union\tU'))
  439. self.geo_intersection_menuitem = self.geo_editor_menu.addAction(
  440. QtGui.QIcon(self.app.resource_location + '/intersection16.png'), _('Polygon Intersection\tE'))
  441. self.geo_subtract_menuitem = self.geo_editor_menu.addAction(
  442. QtGui.QIcon(self.app.resource_location + '/subtract16.png'), _('Polygon Subtraction\tS')
  443. )
  444. self.geo_editor_menu.addSeparator()
  445. self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(
  446. QtGui.QIcon(self.app.resource_location + '/cutpath16.png'), _('Cut Path\tX'))
  447. # self.move_menuitem = self.menu.addAction(QtGui.QIcon(self.app.resource_location + '/move16.png'), "Move Objects 'm'")
  448. self.geo_copy_menuitem = self.geo_editor_menu.addAction(
  449. QtGui.QIcon(self.app.resource_location + '/copy16.png'), _("Copy Geom\tC"))
  450. self.geo_delete_menuitem = self.geo_editor_menu.addAction(
  451. QtGui.QIcon(self.app.resource_location + '/deleteshape16.png'), _("Delete Shape\tDEL")
  452. )
  453. self.geo_editor_menu.addSeparator()
  454. self.geo_move_menuitem = self.geo_editor_menu.addAction(
  455. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move\tM"))
  456. self.geo_buffer_menuitem = self.geo_editor_menu.addAction(
  457. QtGui.QIcon(self.app.resource_location + '/buffer16.png'), _("Buffer Tool\tB")
  458. )
  459. self.geo_paint_menuitem = self.geo_editor_menu.addAction(
  460. QtGui.QIcon(self.app.resource_location + '/paint16.png'), _("Paint Tool\tI")
  461. )
  462. self.geo_transform_menuitem = self.geo_editor_menu.addAction(
  463. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool\tALT+R")
  464. )
  465. self.geo_editor_menu.addSeparator()
  466. self.geo_cornersnap_menuitem = self.geo_editor_menu.addAction(
  467. QtGui.QIcon(self.app.resource_location + '/corner32.png'), _("Toggle Corner Snap\tK")
  468. )
  469. # ########################################################################
  470. # ########################## EXCELLON Editor # ###########################
  471. # ########################################################################
  472. self.exc_editor_menu = QtWidgets.QMenu(_(">Excellon Editor<"))
  473. self.menu.addMenu(self.exc_editor_menu)
  474. self.exc_add_array_drill_menuitem = self.exc_editor_menu.addAction(
  475. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Drill Array\tA'))
  476. self.exc_add_drill_menuitem = self.exc_editor_menu.addAction(
  477. QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill\tD'))
  478. self.exc_editor_menu.addSeparator()
  479. self.exc_add_array_slot_menuitem = self.exc_editor_menu.addAction(
  480. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array\tQ'))
  481. self.exc_add_slot_menuitem = self.exc_editor_menu.addAction(
  482. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot\tW'))
  483. self.exc_editor_menu.addSeparator()
  484. self.exc_resize_drill_menuitem = self.exc_editor_menu.addAction(
  485. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill(S)\tR')
  486. )
  487. self.exc_copy_drill_menuitem = self.exc_editor_menu.addAction(
  488. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy\tC'))
  489. self.exc_delete_drill_menuitem = self.exc_editor_menu.addAction(
  490. QtGui.QIcon(self.app.resource_location + '/deleteshape32.png'), _('Delete\tDEL')
  491. )
  492. self.exc_editor_menu.addSeparator()
  493. self.exc_move_drill_menuitem = self.exc_editor_menu.addAction(
  494. QtGui.QIcon(self.app.resource_location + '/move32.png'), _('Move Drill(s)\tM'))
  495. # ########################################################################
  496. # ########################## GERBER Editor # #############################
  497. # ########################################################################
  498. self.grb_editor_menu = QtWidgets.QMenu(_(">Gerber Editor<"))
  499. self.menu.addMenu(self.grb_editor_menu)
  500. self.grb_add_pad_menuitem = self.grb_editor_menu.addAction(
  501. QtGui.QIcon(self.app.resource_location + '/aperture16.png'), _('Add Pad\tP'))
  502. self.grb_add_pad_array_menuitem = self.grb_editor_menu.addAction(
  503. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array\tA'))
  504. self.grb_add_track_menuitem = self.grb_editor_menu.addAction(
  505. QtGui.QIcon(self.app.resource_location + '/track32.png'), _('Add Track\tT'))
  506. self.grb_add_region_menuitem = self.grb_editor_menu.addAction(
  507. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Region\tN'))
  508. self.grb_editor_menu.addSeparator()
  509. self.grb_convert_poly_menuitem = self.grb_editor_menu.addAction(
  510. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize\tALT+N"))
  511. self.grb_add_semidisc_menuitem = self.grb_editor_menu.addAction(
  512. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("Add SemiDisc\tE"))
  513. self.grb_add_disc_menuitem = self.grb_editor_menu.addAction(
  514. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Add Disc\tD"))
  515. self.grb_add_buffer_menuitem = self.grb_editor_menu.addAction(
  516. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer\tB'))
  517. self.grb_add_scale_menuitem = self.grb_editor_menu.addAction(
  518. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale\tS'))
  519. self.grb_add_markarea_menuitem = self.grb_editor_menu.addAction(
  520. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area\tALT+A'))
  521. self.grb_add_eraser_menuitem = self.grb_editor_menu.addAction(
  522. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser\tCTRL+E'))
  523. self.grb_transform_menuitem = self.grb_editor_menu.addAction(
  524. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform\tALT+R"))
  525. self.grb_editor_menu.addSeparator()
  526. self.grb_copy_menuitem = self.grb_editor_menu.addAction(
  527. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy\tC'))
  528. self.grb_delete_menuitem = self.grb_editor_menu.addAction(
  529. QtGui.QIcon(self.app.resource_location + '/deleteshape32.png'), _('Delete\tDEL'))
  530. self.grb_editor_menu.addSeparator()
  531. self.grb_move_menuitem = self.grb_editor_menu.addAction(
  532. QtGui.QIcon(self.app.resource_location + '/move32.png'), _('Move\tM'))
  533. self.grb_editor_menu.menuAction().setVisible(False)
  534. self.grb_editor_menu.setDisabled(True)
  535. self.geo_editor_menu.menuAction().setVisible(False)
  536. self.geo_editor_menu.setDisabled(True)
  537. self.exc_editor_menu.menuAction().setVisible(False)
  538. self.exc_editor_menu.setDisabled(True)
  539. # ########################################################################
  540. # ########################## Project Tab Context Menu # ##################
  541. # ########################################################################
  542. self.menuproject = QtWidgets.QMenu()
  543. self.menuprojectenable = self.menuproject.addAction(
  544. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _('Enable Plot'))
  545. self.menuprojectdisable = self.menuproject.addAction(
  546. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _('Disable Plot'))
  547. self.menuproject.addSeparator()
  548. self.menuprojectcolor = self.menuproject.addMenu(
  549. QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Set Color'))
  550. self.menuproject_red = self.menuprojectcolor.addAction(
  551. QtGui.QIcon(self.app.resource_location + '/red32.png'), _('Red'))
  552. self.menuproject_blue = self.menuprojectcolor.addAction(
  553. QtGui.QIcon(self.app.resource_location + '/blue32.png'), _('Blue'))
  554. self.menuproject_yellow = self.menuprojectcolor.addAction(
  555. QtGui.QIcon(self.app.resource_location + '/yellow32.png'), _('Yellow'))
  556. self.menuproject_green = self.menuprojectcolor.addAction(
  557. QtGui.QIcon(self.app.resource_location + '/green32.png'), _('Green'))
  558. self.menuproject_purple = self.menuprojectcolor.addAction(
  559. QtGui.QIcon(self.app.resource_location + '/violet32.png'), _('Purple'))
  560. self.menuproject_brown = self.menuprojectcolor.addAction(
  561. QtGui.QIcon(self.app.resource_location + '/brown32.png'), _('Brown'))
  562. self.menuproject_custom = self.menuprojectcolor.addAction(
  563. QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Custom'))
  564. self.menuproject.addSeparator()
  565. self.menuprojectgeneratecnc = self.menuproject.addAction(
  566. QtGui.QIcon(self.app.resource_location + '/cnc32.png'), _('Generate CNC'))
  567. self.menuprojectviewsource = self.menuproject.addAction(
  568. QtGui.QIcon(self.app.resource_location + '/source32.png'), _('View Source'))
  569. self.menuprojectedit = self.menuproject.addAction(
  570. QtGui.QIcon(self.app.resource_location + '/edit_ok32.png'), _('Edit'))
  571. self.menuprojectcopy = self.menuproject.addAction(
  572. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy'))
  573. self.menuprojectdelete = self.menuproject.addAction(
  574. QtGui.QIcon(self.app.resource_location + '/delete32.png'), _('Delete'))
  575. self.menuprojectsave = self.menuproject.addAction(
  576. QtGui.QIcon(self.app.resource_location + '/save_as.png'), _('Save'))
  577. self.menuproject.addSeparator()
  578. self.menuprojectproperties = self.menuproject.addAction(
  579. QtGui.QIcon(self.app.resource_location + '/properties32.png'), _('Properties'))
  580. # ########################################################################
  581. # ####################### Central Widget -> Splitter # ##################
  582. # ########################################################################
  583. # IMPORTANT #
  584. # The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
  585. # desired.
  586. self.splitter = QtWidgets.QSplitter()
  587. self.setCentralWidget(self.splitter)
  588. # self.notebook = QtWidgets.QTabWidget()
  589. self.notebook = FCDetachableTab(protect=True)
  590. self.notebook.setTabsClosable(False)
  591. self.notebook.useOldIndex(True)
  592. self.splitter.addWidget(self.notebook)
  593. self.splitter_left = QtWidgets.QSplitter(Qt.Vertical)
  594. self.splitter.addWidget(self.splitter_left)
  595. self.splitter_left.addWidget(self.notebook)
  596. self.splitter_left.setHandleWidth(0)
  597. # ########################################################################
  598. # ########################## ToolBAR # ###################################
  599. # ########################################################################
  600. # ## TOOLBAR INSTALLATION ###
  601. self.toolbarfile = QtWidgets.QToolBar(_('File Toolbar'))
  602. self.toolbarfile.setObjectName('File_TB')
  603. self.addToolBar(self.toolbarfile)
  604. self.toolbargeo = QtWidgets.QToolBar(_('Edit Toolbar'))
  605. self.toolbargeo.setObjectName('Edit_TB')
  606. self.addToolBar(self.toolbargeo)
  607. self.toolbarview = QtWidgets.QToolBar(_('View Toolbar'))
  608. self.toolbarview.setObjectName('View_TB')
  609. self.addToolBar(self.toolbarview)
  610. self.toolbarshell = QtWidgets.QToolBar(_('Shell Toolbar'))
  611. self.toolbarshell.setObjectName('Shell_TB')
  612. self.addToolBar(self.toolbarshell)
  613. self.toolbartools = QtWidgets.QToolBar(_('Tools Toolbar'))
  614. self.toolbartools.setObjectName('Tools_TB')
  615. self.addToolBar(self.toolbartools)
  616. self.exc_edit_toolbar = QtWidgets.QToolBar(_('Excellon Editor Toolbar'))
  617. self.exc_edit_toolbar.setObjectName('ExcEditor_TB')
  618. self.addToolBar(self.exc_edit_toolbar)
  619. self.addToolBarBreak()
  620. self.geo_edit_toolbar = QtWidgets.QToolBar(_('Geometry Editor Toolbar'))
  621. self.geo_edit_toolbar.setObjectName('GeoEditor_TB')
  622. self.addToolBar(self.geo_edit_toolbar)
  623. self.grb_edit_toolbar = QtWidgets.QToolBar(_('Gerber Editor Toolbar'))
  624. self.grb_edit_toolbar.setObjectName('GrbEditor_TB')
  625. self.addToolBar(self.grb_edit_toolbar)
  626. self.snap_toolbar = QtWidgets.QToolBar(_('Grid Toolbar'))
  627. self.snap_toolbar.setObjectName('Snap_TB')
  628. self.addToolBar(self.snap_toolbar)
  629. settings = QSettings("Open Source", "FlatCAM")
  630. if settings.contains("layout"):
  631. layout = settings.value('layout', type=str)
  632. if layout == 'standard':
  633. pass
  634. elif layout == 'compact':
  635. self.removeToolBar(self.snap_toolbar)
  636. self.snap_toolbar.setMaximumHeight(30)
  637. self.splitter_left.addWidget(self.snap_toolbar)
  638. # ########################################################################
  639. # ########################## File Toolbar# ###############################
  640. # ########################################################################
  641. self.file_open_gerber_btn = self.toolbarfile.addAction(
  642. QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _("Open Gerber"))
  643. self.file_open_excellon_btn = self.toolbarfile.addAction(
  644. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Open Excellon"))
  645. self.toolbarfile.addSeparator()
  646. self.file_open_btn = self.toolbarfile.addAction(
  647. QtGui.QIcon(self.app.resource_location + '/folder32.png'), _("Open project"))
  648. self.file_save_btn = self.toolbarfile.addAction(
  649. QtGui.QIcon(self.app.resource_location + '/project_save32.png'), _("Save project"))
  650. # ########################################################################
  651. # ########################## Edit Toolbar# ###############################
  652. # ########################################################################
  653. self.newgeo_btn = self.toolbargeo.addAction(
  654. QtGui.QIcon(self.app.resource_location + '/new_file_geo32.png'), _("New Blank Geometry"))
  655. self.newgrb_btn = self.toolbargeo.addAction(
  656. QtGui.QIcon(self.app.resource_location + '/new_file_grb32.png'), _("New Blank Gerber"))
  657. self.newexc_btn = self.toolbargeo.addAction(
  658. QtGui.QIcon(self.app.resource_location + '/new_file_exc32.png'), _("New Blank Excellon"))
  659. self.toolbargeo.addSeparator()
  660. self.editgeo_btn = self.toolbargeo.addAction(
  661. QtGui.QIcon(self.app.resource_location + '/edit_file32.png'), _("Editor"))
  662. self.update_obj_btn = self.toolbargeo.addAction(
  663. QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'), _("Save Object and close the Editor")
  664. )
  665. self.toolbargeo.addSeparator()
  666. self.copy_btn = self.toolbargeo.addAction(
  667. QtGui.QIcon(self.app.resource_location + '/copy_file32.png'), _("Copy"))
  668. self.delete_btn = self.toolbargeo.addAction(
  669. QtGui.QIcon(self.app.resource_location + '/delete_file32.png'), _("&Delete"))
  670. self.toolbargeo.addSeparator()
  671. self.distance_btn = self.toolbargeo.addAction(
  672. QtGui.QIcon(self.app.resource_location + '/distance32.png'), _("Distance Tool"))
  673. self.distance_min_btn = self.toolbargeo.addAction(
  674. QtGui.QIcon(self.app.resource_location + '/distance_min32.png'), _("Distance Min Tool"))
  675. self.origin_btn = self.toolbargeo.addAction(
  676. QtGui.QIcon(self.app.resource_location + '/origin32.png'), _('Set Origin'))
  677. self.jmp_btn = self.toolbargeo.addAction(
  678. QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location'))
  679. # ########################################################################
  680. # ########################## View Toolbar# ###############################
  681. # ########################################################################
  682. self.replot_btn = self.toolbarview.addAction(
  683. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("&Replot"))
  684. self.clear_plot_btn = self.toolbarview.addAction(
  685. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("&Clear plot"))
  686. self.zoom_in_btn = self.toolbarview.addAction(
  687. QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("Zoom In"))
  688. self.zoom_out_btn = self.toolbarview.addAction(
  689. QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("Zoom Out"))
  690. self.zoom_fit_btn = self.toolbarview.addAction(
  691. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
  692. # self.toolbarview.setVisible(False)
  693. # ########################################################################
  694. # ########################## Shell Toolbar# ##############################
  695. # ########################################################################
  696. self.shell_btn = self.toolbarshell.addAction(
  697. QtGui.QIcon(self.app.resource_location + '/shell32.png'), _("&Command Line"))
  698. self.new_script_btn = self.toolbarshell.addAction(
  699. QtGui.QIcon(self.app.resource_location + '/script_new24.png'), _('New Script ...'))
  700. self.open_script_btn = self.toolbarshell.addAction(
  701. QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'))
  702. self.run_script_btn = self.toolbarshell.addAction(
  703. QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Run Script ...'))
  704. # ########################################################################
  705. # ########################## Tools Toolbar# ##############################
  706. # ########################################################################
  707. self.dblsided_btn = self.toolbartools.addAction(
  708. QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2Sided Tool"))
  709. self.cutout_btn = self.toolbartools.addAction(
  710. QtGui.QIcon(self.app.resource_location + '/cut16_bis.png'), _("Cutout Tool"))
  711. self.ncc_btn = self.toolbartools.addAction(
  712. QtGui.QIcon(self.app.resource_location + '/ncc16.png'), _("NCC Tool"))
  713. self.paint_btn = self.toolbartools.addAction(
  714. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool"))
  715. self.toolbartools.addSeparator()
  716. self.panelize_btn = self.toolbartools.addAction(
  717. QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool"))
  718. self.film_btn = self.toolbartools.addAction(
  719. QtGui.QIcon(self.app.resource_location + '/film16.png'), _("Film Tool"))
  720. self.solder_btn = self.toolbartools.addAction(
  721. QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste Tool"))
  722. self.sub_btn = self.toolbartools.addAction(
  723. QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool"))
  724. self.rules_btn = self.toolbartools.addAction(
  725. QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules Tool"))
  726. self.optimal_btn = self.toolbartools.addAction(
  727. QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal Tool"))
  728. self.toolbartools.addSeparator()
  729. self.calculators_btn = self.toolbartools.addAction(
  730. QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool"))
  731. self.transform_btn = self.toolbartools.addAction(
  732. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool"))
  733. self.qrcode_btn = self.toolbartools.addAction(
  734. QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool"))
  735. self.copperfill_btn = self.toolbartools.addAction(
  736. QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool"))
  737. self.fiducials_btn = self.toolbartools.addAction(
  738. QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool"))
  739. self.cal_btn = self.toolbartools.addAction(
  740. QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool"))
  741. # ########################################################################
  742. # ########################## Excellon Editor Toolbar# ####################
  743. # ########################################################################
  744. self.select_drill_btn = self.exc_edit_toolbar.addAction(
  745. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  746. self.add_drill_btn = self.exc_edit_toolbar.addAction(
  747. QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill Hole'))
  748. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  749. QtGui.QIcon(self.app.resource_location + '/addarray16.png'), _('Add Drill Hole Array'))
  750. self.add_slot_btn = self.exc_edit_toolbar.addAction(
  751. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot'))
  752. self.add_slot_array_btn = self.exc_edit_toolbar.addAction(
  753. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array'))
  754. self.resize_drill_btn = self.exc_edit_toolbar.addAction(
  755. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill'))
  756. self.exc_edit_toolbar.addSeparator()
  757. self.copy_drill_btn = self.exc_edit_toolbar.addAction(
  758. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy Drill'))
  759. self.delete_drill_btn = self.exc_edit_toolbar.addAction(
  760. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Drill"))
  761. self.exc_edit_toolbar.addSeparator()
  762. self.move_drill_btn = self.exc_edit_toolbar.addAction(
  763. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Drill"))
  764. # ########################################################################
  765. # ########################## Geometry Editor Toolbar# ####################
  766. # ########################################################################
  767. self.geo_select_btn = self.geo_edit_toolbar.addAction(
  768. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  769. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(
  770. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle'))
  771. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(
  772. QtGui.QIcon(self.app.resource_location + '/arc32.png'), _('Add Arc'))
  773. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(
  774. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle'))
  775. self.geo_edit_toolbar.addSeparator()
  776. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(
  777. QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path'))
  778. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(
  779. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon'))
  780. self.geo_edit_toolbar.addSeparator()
  781. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(
  782. QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text'))
  783. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(
  784. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Add Buffer'))
  785. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(
  786. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _('Paint Shape'))
  787. self.geo_eraser_btn = self.geo_edit_toolbar.addAction(
  788. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  789. self.geo_edit_toolbar.addSeparator()
  790. self.geo_union_btn = self.geo_edit_toolbar.addAction(
  791. QtGui.QIcon(self.app.resource_location + '/union32.png'), _('Polygon Union'))
  792. self.geo_explode_btn = self.geo_edit_toolbar.addAction(
  793. QtGui.QIcon(self.app.resource_location + '/explode32.png'), _('Polygon Explode'))
  794. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(
  795. QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _('Polygon Intersection'))
  796. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(
  797. QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _('Polygon Subtraction'))
  798. self.geo_edit_toolbar.addSeparator()
  799. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(
  800. QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _('Cut Path'))
  801. self.geo_copy_btn = self.geo_edit_toolbar.addAction(
  802. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy Shape(s)"))
  803. self.geo_delete_btn = self.geo_edit_toolbar.addAction(
  804. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Shape '-'"))
  805. self.geo_transform_btn = self.geo_edit_toolbar.addAction(
  806. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  807. self.geo_edit_toolbar.addSeparator()
  808. self.geo_move_btn = self.geo_edit_toolbar.addAction(
  809. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Objects "))
  810. # ########################################################################
  811. # ########################## Gerber Editor Toolbar# ######################
  812. # ########################################################################
  813. self.grb_select_btn = self.grb_edit_toolbar.addAction(
  814. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  815. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(
  816. QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Add Pad"))
  817. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(
  818. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array'))
  819. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(
  820. QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Add Track"))
  821. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(
  822. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Add Region"))
  823. self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(
  824. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
  825. self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(
  826. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
  827. self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(
  828. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
  829. self.grb_edit_toolbar.addSeparator()
  830. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(
  831. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer'))
  832. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(
  833. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale'))
  834. self.aperture_markarea_btn = self.grb_edit_toolbar.addAction(
  835. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area'))
  836. self.aperture_eraser_btn = self.grb_edit_toolbar.addAction(
  837. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  838. self.grb_edit_toolbar.addSeparator()
  839. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(
  840. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
  841. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(
  842. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete"))
  843. self.grb_transform_btn = self.grb_edit_toolbar.addAction(
  844. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  845. self.grb_edit_toolbar.addSeparator()
  846. self.aperture_move_btn = self.grb_edit_toolbar.addAction(
  847. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  848. # ########################################################################
  849. # ########################## Snap Toolbar# ###############################
  850. # ########################################################################
  851. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  852. self.grid_snap_btn = self.snap_toolbar.addAction(
  853. QtGui.QIcon(self.app.resource_location + '/grid32.png'), _('Snap to grid'))
  854. self.grid_gap_x_entry = FCEntry2()
  855. self.grid_gap_x_entry.setMaximumWidth(70)
  856. self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
  857. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  858. self.grid_gap_y_entry = FCEntry2()
  859. self.grid_gap_y_entry.setMaximumWidth(70)
  860. self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
  861. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  862. self.grid_space_label = QtWidgets.QLabel(" ")
  863. self.snap_toolbar.addWidget(self.grid_space_label)
  864. self.grid_gap_link_cb = FCCheckBox()
  865. self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
  866. "is copied to the Grid_Y value."))
  867. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  868. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  869. self.corner_snap_btn = self.snap_toolbar.addAction(
  870. QtGui.QIcon(self.app.resource_location + '/corner32.png'), _('Snap to corner'))
  871. self.snap_max_dist_entry = FCEntry()
  872. self.snap_max_dist_entry.setMaximumWidth(70)
  873. self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
  874. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  875. # ########################################################################
  876. # ########################## Notebook # ##################################
  877. # ########################################################################
  878. # ########################################################################
  879. # ########################## PROJECT Tab # ###############################
  880. # ########################################################################
  881. self.project_tab = QtWidgets.QWidget()
  882. self.project_tab.setObjectName("project_tab")
  883. self.project_frame_lay = QtWidgets.QVBoxLayout(self.project_tab)
  884. self.project_frame_lay.setContentsMargins(0, 0, 0, 0)
  885. self.project_frame = QtWidgets.QFrame()
  886. self.project_frame.setContentsMargins(0, 0, 0, 0)
  887. self.project_frame_lay.addWidget(self.project_frame)
  888. self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_frame)
  889. self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
  890. self.notebook.addTab(self.project_tab, _("Project"))
  891. self.project_frame.setDisabled(False)
  892. # ########################################################################
  893. # ########################## SELECTED Tab # ##############################
  894. # ########################################################################
  895. self.selected_tab = QtWidgets.QWidget()
  896. self.selected_tab.setObjectName("selected_tab")
  897. self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
  898. self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
  899. self.selected_scroll_area = VerticalScrollArea()
  900. self.selected_tab_layout.addWidget(self.selected_scroll_area)
  901. self.notebook.addTab(self.selected_tab, _("Selected"))
  902. # ########################################################################
  903. # ########################## TOOL Tab # ##################################
  904. # ########################################################################
  905. self.tool_tab = QtWidgets.QWidget()
  906. self.tool_tab.setObjectName("tool_tab")
  907. self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
  908. self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
  909. self.notebook.addTab(self.tool_tab, _("Tool"))
  910. self.tool_scroll_area = VerticalScrollArea()
  911. self.tool_tab_layout.addWidget(self.tool_scroll_area)
  912. # ########################################################################
  913. # ########################## RIGHT Widget # ##############################
  914. # ########################################################################
  915. self.right_widget = QtWidgets.QWidget()
  916. self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
  917. self.splitter.addWidget(self.right_widget)
  918. self.right_lay = QtWidgets.QVBoxLayout()
  919. self.right_lay.setContentsMargins(0, 0, 0, 0)
  920. self.right_widget.setLayout(self.right_lay)
  921. # ########################################################################
  922. # ########################## PLOT AREA Tab # #############################
  923. # ########################################################################
  924. self.plot_tab_area = FCDetachableTab2(protect=False, protect_by_name=[_('Plot Area')])
  925. self.plot_tab_area.useOldIndex(True)
  926. self.right_lay.addWidget(self.plot_tab_area)
  927. self.plot_tab_area.setTabsClosable(True)
  928. self.plot_tab = QtWidgets.QWidget()
  929. self.plot_tab.setObjectName("plotarea")
  930. self.plot_tab_area.addTab(self.plot_tab, _("Plot Area"))
  931. self.right_layout = QtWidgets.QVBoxLayout()
  932. self.right_layout.setObjectName("right_layout")
  933. self.right_layout.setContentsMargins(2, 2, 2, 2)
  934. self.plot_tab.setLayout(self.right_layout)
  935. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  936. self.plot_tab_area.protectTab(0)
  937. # ########################################################################
  938. # ########################## PREFERENCES AREA Tab # ######################
  939. # ########################################################################
  940. self.preferences_tab = QtWidgets.QWidget()
  941. self.preferences_tab.setObjectName("preferences_tab")
  942. self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
  943. self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
  944. self.pref_tab_area = FCTab()
  945. self.pref_tab_area.setTabsClosable(False)
  946. self.pref_tab_area_tabBar = self.pref_tab_area.tabBar()
  947. self.pref_tab_area_tabBar.setStyleSheet("QTabBar::tab{min-width:90px;}")
  948. self.pref_tab_area_tabBar.setExpanding(True)
  949. self.pref_tab_layout.addWidget(self.pref_tab_area)
  950. self.general_tab = QtWidgets.QWidget()
  951. self.general_tab.setObjectName("general_tab")
  952. self.pref_tab_area.addTab(self.general_tab, _("General"))
  953. self.general_tab_lay = QtWidgets.QVBoxLayout()
  954. self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
  955. self.general_tab.setLayout(self.general_tab_lay)
  956. self.hlay1 = QtWidgets.QHBoxLayout()
  957. self.general_tab_lay.addLayout(self.hlay1)
  958. self.hlay1.addStretch()
  959. self.general_scroll_area = QtWidgets.QScrollArea()
  960. self.general_tab_lay.addWidget(self.general_scroll_area)
  961. self.gerber_tab = QtWidgets.QWidget()
  962. self.gerber_tab.setObjectName("gerber_tab")
  963. self.pref_tab_area.addTab(self.gerber_tab, _("GERBER"))
  964. self.gerber_tab_lay = QtWidgets.QVBoxLayout()
  965. self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
  966. self.gerber_tab.setLayout(self.gerber_tab_lay)
  967. self.gerber_scroll_area = QtWidgets.QScrollArea()
  968. self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
  969. self.excellon_tab = QtWidgets.QWidget()
  970. self.excellon_tab.setObjectName("excellon_tab")
  971. self.pref_tab_area.addTab(self.excellon_tab, _("EXCELLON"))
  972. self.excellon_tab_lay = QtWidgets.QVBoxLayout()
  973. self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
  974. self.excellon_tab.setLayout(self.excellon_tab_lay)
  975. self.excellon_scroll_area = QtWidgets.QScrollArea()
  976. self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
  977. self.geometry_tab = QtWidgets.QWidget()
  978. self.geometry_tab.setObjectName("geometry_tab")
  979. self.pref_tab_area.addTab(self.geometry_tab, _("GEOMETRY"))
  980. self.geometry_tab_lay = QtWidgets.QVBoxLayout()
  981. self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
  982. self.geometry_tab.setLayout(self.geometry_tab_lay)
  983. self.geometry_scroll_area = QtWidgets.QScrollArea()
  984. self.geometry_tab_lay.addWidget(self.geometry_scroll_area)
  985. self.text_editor_tab = QtWidgets.QWidget()
  986. self.text_editor_tab.setObjectName("text_editor_tab")
  987. self.pref_tab_area.addTab(self.text_editor_tab, _("CNC-JOB"))
  988. self.cncjob_tab_lay = QtWidgets.QVBoxLayout()
  989. self.cncjob_tab_lay.setContentsMargins(2, 2, 2, 2)
  990. self.text_editor_tab.setLayout(self.cncjob_tab_lay)
  991. self.cncjob_scroll_area = QtWidgets.QScrollArea()
  992. self.cncjob_tab_lay.addWidget(self.cncjob_scroll_area)
  993. self.tools_tab = QtWidgets.QWidget()
  994. self.pref_tab_area.addTab(self.tools_tab, _("TOOLS"))
  995. self.tools_tab_lay = QtWidgets.QVBoxLayout()
  996. self.tools_tab_lay.setContentsMargins(2, 2, 2, 2)
  997. self.tools_tab.setLayout(self.tools_tab_lay)
  998. self.tools_scroll_area = QtWidgets.QScrollArea()
  999. self.tools_tab_lay.addWidget(self.tools_scroll_area)
  1000. self.tools2_tab = QtWidgets.QWidget()
  1001. self.pref_tab_area.addTab(self.tools2_tab, _("TOOLS 2"))
  1002. self.tools2_tab_lay = QtWidgets.QVBoxLayout()
  1003. self.tools2_tab_lay.setContentsMargins(2, 2, 2, 2)
  1004. self.tools2_tab.setLayout(self.tools2_tab_lay)
  1005. self.tools2_scroll_area = QtWidgets.QScrollArea()
  1006. self.tools2_tab_lay.addWidget(self.tools2_scroll_area)
  1007. self.fa_tab = QtWidgets.QWidget()
  1008. self.fa_tab.setObjectName("fa_tab")
  1009. self.pref_tab_area.addTab(self.fa_tab, _("UTILITIES"))
  1010. self.fa_tab_lay = QtWidgets.QVBoxLayout()
  1011. self.fa_tab_lay.setContentsMargins(2, 2, 2, 2)
  1012. self.fa_tab.setLayout(self.fa_tab_lay)
  1013. self.fa_scroll_area = QtWidgets.QScrollArea()
  1014. self.fa_tab_lay.addWidget(self.fa_scroll_area)
  1015. self.pref_tab_bottom_layout = QtWidgets.QHBoxLayout()
  1016. self.pref_tab_bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
  1017. self.pref_tab_layout.addLayout(self.pref_tab_bottom_layout)
  1018. self.pref_tab_bottom_layout_1 = QtWidgets.QHBoxLayout()
  1019. self.pref_tab_bottom_layout_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1020. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_1)
  1021. self.pref_import_button = QtWidgets.QPushButton()
  1022. self.pref_import_button.setText(_("Import Preferences"))
  1023. self.pref_import_button.setMinimumWidth(130)
  1024. self.pref_import_button.setToolTip(
  1025. _("Import a full set of FlatCAM settings from a file\n"
  1026. "previously saved on HDD.\n\n"
  1027. "FlatCAM automatically save a 'factory_defaults' file\n"
  1028. "on the first start. Do not delete that file."))
  1029. self.pref_tab_bottom_layout_1.addWidget(self.pref_import_button)
  1030. self.pref_export_button = QtWidgets.QPushButton()
  1031. self.pref_export_button.setText(_("Export Preferences"))
  1032. self.pref_export_button.setMinimumWidth(130)
  1033. self.pref_export_button.setToolTip(
  1034. _("Export a full set of FlatCAM settings in a file\n"
  1035. "that is saved on HDD."))
  1036. self.pref_tab_bottom_layout_1.addWidget(self.pref_export_button)
  1037. self.pref_open_button = QtWidgets.QPushButton()
  1038. self.pref_open_button.setText(_("Open Pref Folder"))
  1039. self.pref_open_button.setMinimumWidth(130)
  1040. self.pref_open_button.setToolTip(
  1041. _("Open the folder where FlatCAM save the preferences files."))
  1042. self.pref_tab_bottom_layout_1.addWidget(self.pref_open_button)
  1043. self.pref_tab_bottom_layout_2 = QtWidgets.QHBoxLayout()
  1044. self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  1045. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2)
  1046. self.pref_apply_button = FCButton()
  1047. self.pref_apply_button.setText(_("Apply"))
  1048. self.pref_apply_button.setMinimumWidth(130)
  1049. self.pref_apply_button.setToolTip(
  1050. _("Apply the current preferences without saving to a file."))
  1051. self.pref_tab_bottom_layout_2.addWidget(self.pref_apply_button)
  1052. self.pref_save_button = QtWidgets.QPushButton()
  1053. self.pref_save_button.setText(_("Save"))
  1054. self.pref_save_button.setMinimumWidth(130)
  1055. self.pref_save_button.setToolTip(
  1056. _("Save the current settings in the 'current_defaults' file\n"
  1057. "which is the file storing the working default preferences."))
  1058. self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
  1059. self.pref_close_button = QtWidgets.QPushButton()
  1060. self.pref_close_button.setText(_("Cancel"))
  1061. self.pref_close_button.setMinimumWidth(130)
  1062. self.pref_close_button.setToolTip(
  1063. _("Will not save the changes and will close the preferences window."))
  1064. self.pref_tab_bottom_layout_2.addWidget(self.pref_close_button)
  1065. # ########################################################################
  1066. # #################### SHORTCUT LIST AREA Tab # ##########################
  1067. # ########################################################################
  1068. self.shortcuts_tab = QtWidgets.QWidget()
  1069. self.sh_tab_layout = QtWidgets.QVBoxLayout()
  1070. self.sh_tab_layout.setContentsMargins(2, 2, 2, 2)
  1071. self.shortcuts_tab.setLayout(self.sh_tab_layout)
  1072. self.sh_hlay = QtWidgets.QHBoxLayout()
  1073. self.sh_title = QtWidgets.QTextEdit(
  1074. _('<b>Shortcut Key List</b>'))
  1075. self.sh_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1076. self.sh_title.setFrameStyle(QtWidgets.QFrame.NoFrame)
  1077. self.sh_title.setMaximumHeight(30)
  1078. font = self.sh_title.font()
  1079. font.setPointSize(12)
  1080. self.sh_title.setFont(font)
  1081. self.sh_tab_layout.addWidget(self.sh_title)
  1082. self.sh_tab_layout.addLayout(self.sh_hlay)
  1083. self.app_sh_msg = (
  1084. '''<b>General Shortcut list</b><br>
  1085. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1086. <tbody>
  1087. <tr height="20">
  1088. <td height="20" width="89"><strong>F3</strong></td>
  1089. <td width="194"><span style="color:#006400"><strong>&nbsp;%s</strong></span></td>
  1090. </tr>
  1091. <tr height="20">
  1092. <td height="20">&nbsp;</td>
  1093. <td>&nbsp;</td>
  1094. </tr>
  1095. <tr height="20">
  1096. <td height="20"><strong>1</strong></td>
  1097. <td>&nbsp;%s</td>
  1098. </tr>
  1099. <tr height="20">
  1100. <td height="20"><strong>2</strong></td>
  1101. <td>&nbsp;%s</td>
  1102. </tr>
  1103. <tr height="20">
  1104. <td height="20"><strong>3</strong></td>
  1105. <td>&nbsp;%s</td>
  1106. </tr>
  1107. <tr height="20">
  1108. <td height="20">&nbsp;</td>
  1109. <td>&nbsp;</td>
  1110. </tr>
  1111. <tr height="20">
  1112. <td height="20"><strong>B</strong></td>
  1113. <td>&nbsp;%s</td>
  1114. </tr>
  1115. <tr height="20">
  1116. <td height="20"><strong>E</strong></td>
  1117. <td>&nbsp;%s</td>
  1118. </tr>
  1119. <tr height="20">
  1120. <td height="20"><strong>G</strong></td>
  1121. <td>&nbsp;%s</td>
  1122. </tr>
  1123. <tr height="20">
  1124. <td height="20"><strong>J</strong></td>
  1125. <td>&nbsp;%s</td>
  1126. </tr>
  1127. <tr height="20">
  1128. <td height="20"><strong>L</strong></td>
  1129. <td>&nbsp;%s</td>
  1130. </tr>
  1131. <tr height="20">
  1132. <td height="20"><strong>M</strong></td>
  1133. <td>&nbsp;%s</td>
  1134. </tr>
  1135. <tr height="20">
  1136. <td height="20"><strong>N</strong></td>
  1137. <td>&nbsp;%s</td>
  1138. </tr>
  1139. <tr height="20">
  1140. <td height="20"><strong>O</strong></td>
  1141. <td>&nbsp;%s</td>
  1142. </tr>
  1143. <tr height="20">
  1144. <td height="20"><strong>Q</strong></td>
  1145. <td>&nbsp;%s</td>
  1146. </tr>
  1147. <tr height="20">
  1148. <td height="20"><strong>P</strong></td>
  1149. <td>&nbsp;%s</td>
  1150. </tr>
  1151. <tr height="20">
  1152. <td height="20"><strong>R</strong></td>
  1153. <td>&nbsp;%s</td>
  1154. </tr>
  1155. <tr height="20">
  1156. <td height="20"><strong>S</strong></td>
  1157. <td>&nbsp;%s</td>
  1158. </tr>
  1159. <tr height="20">
  1160. <td height="20"><strong>T</strong></td>
  1161. <td>&nbsp;%s</td>
  1162. </tr>
  1163. <tr height="20">
  1164. <td height="20"><strong>V</strong></td>
  1165. <td>&nbsp;%s</td>
  1166. </tr>
  1167. <tr height="20">
  1168. <td height="20"><strong>X</strong></td>
  1169. <td>&nbsp;%s</td>
  1170. </tr>
  1171. <tr height="20">
  1172. <td height="20"><strong>Y</strong></td>
  1173. <td>&nbsp;%s</td>
  1174. </tr>
  1175. <tr height="20">
  1176. <td height="20"><strong>&#39;-&#39;</strong></td>
  1177. <td>&nbsp;%s</td>
  1178. </tr>
  1179. <tr height="20">
  1180. <td height="20"><strong>&#39;=&#39;</strong></td>
  1181. <td>&nbsp;%s</td>
  1182. </tr>
  1183. <tr height="20">
  1184. <td height="20">&nbsp;</td>
  1185. <td>&nbsp;</td>
  1186. </tr>
  1187. <tr height="20">
  1188. <td height="20"><strong>CTRL+A</strong></td>
  1189. <td>&nbsp;%s</td>
  1190. </tr>
  1191. <tr height="20">
  1192. <td height="20"><strong>CTRL+C</strong></td>
  1193. <td>&nbsp;%s</td>
  1194. </tr>
  1195. <tr height="20">
  1196. <td height="20"><strong>CTRL+D</strong></td>
  1197. <td>&nbsp;%s</td>
  1198. </tr>
  1199. <tr height="20">
  1200. <td height="20"><strong>CTRL+E</strong></td>
  1201. <td>&nbsp;%s</td>
  1202. </tr>
  1203. <tr height="20">
  1204. <td height="20"><strong>CTRL+G</strong></td>
  1205. <td>&nbsp;%s</td>
  1206. </tr>
  1207. <tr height="20">
  1208. <td height="20"><strong>CTRL+M</strong></td>
  1209. <td>&nbsp;%s</td>
  1210. </tr>
  1211. <tr height="20">
  1212. <td height="20"><strong>CTRL+N</strong></td>
  1213. <td>&nbsp;%s</td>
  1214. </tr>
  1215. <tr height="20">
  1216. <td height="20"><strong>CTRL+O</strong></td>
  1217. <td>&nbsp;%s</td>
  1218. </tr>
  1219. <tr height="20">
  1220. <td height="20"><strong>CTRL+P</strong></td>
  1221. <td>&nbsp;%s</td>
  1222. </tr>
  1223. <tr height="20">
  1224. <td height="20"><strong>CTRL+Q</strong></td>
  1225. <td>&nbsp;%s</td>
  1226. </tr>
  1227. <tr height="20">
  1228. <td height="20"><strong>CTRL+S</strong></td>
  1229. <td>&nbsp;%s</td>
  1230. </tr>
  1231. <tr height="20">
  1232. <td height="20"><strong>CTRL+F10</strong></td>
  1233. <td>&nbsp;%s</td>
  1234. </tr>
  1235. <tr height="20">
  1236. <td height="20">&nbsp;</td>
  1237. <td>&nbsp;</td>
  1238. </tr>
  1239. <tr height="20">
  1240. <td height="20"><strong>SHIFT+C</strong></td>
  1241. <td>&nbsp;%s</td>
  1242. </tr>
  1243. <tr height="20">
  1244. <td height="20"><strong>SHIFT+E</strong></td>
  1245. <td>&nbsp;%s</td>
  1246. </tr>
  1247. <tr height="20">
  1248. <td height="20"><strong>SHIFT+G</strong></td>
  1249. <td>&nbsp;%s</td>
  1250. </tr>
  1251. <tr height="20">
  1252. <td height="20"><strong>SHIFT+M</strong></td>
  1253. <td>&nbsp;%s</td>
  1254. </tr>
  1255. <tr height="20">
  1256. <td height="20"><strong>SHIFT+P</strong></td>
  1257. <td>&nbsp;%s</td>
  1258. </tr>
  1259. <tr height="20">
  1260. <td height="20"><strong>SHIFT+R</strong></td>
  1261. <td>&nbsp;%s</td>
  1262. </tr>
  1263. <tr height="20">
  1264. <td height="20"><strong>SHIFT+S</strong></td>
  1265. <td>&nbsp;%s</td>
  1266. </tr>
  1267. <tr height="20">
  1268. <td height="20"><strong>SHIFT+W</strong></td>
  1269. <td>&nbsp;%s</td>
  1270. </tr>
  1271. <tr height="20">
  1272. <td height="20"><strong>SHIFT+X</strong></td>
  1273. <td>&nbsp;%s</td>
  1274. </tr>
  1275. <tr height="20">
  1276. <td height="20"><strong>SHIFT+Y</strong></td>
  1277. <td>&nbsp;%s</td>
  1278. </tr>
  1279. <tr height="20">
  1280. <td height="20">&nbsp;</td>
  1281. <td>&nbsp;</td>
  1282. </tr>
  1283. <tr height="20">
  1284. <td height="20"><strong>ALT+C</strong></td>
  1285. <td>&nbsp;%s</td>
  1286. </tr>
  1287. <tr height="20">
  1288. <td height="20"><strong>ALT+D</strong></td>
  1289. <td>&nbsp;%s</td>
  1290. </tr>
  1291. <tr height="20">
  1292. <td height="20"><strong>ALT+E</strong></td>
  1293. <td>&nbsp;%s</td>
  1294. </tr>
  1295. <tr height="20">
  1296. <td height="20"><strong>ALT+J</strong></td>
  1297. <td>&nbsp;%s</td>
  1298. </tr>
  1299. <tr height="20">
  1300. <td height="20"><strong>ALT+K</strong></td>
  1301. <td>&nbsp;%s</td>
  1302. </tr>
  1303. <tr height="20">
  1304. <td height="20"><strong>ALT+L</strong></td>
  1305. <td>&nbsp;%s</td>
  1306. </tr>
  1307. <tr height="20">
  1308. <td height="20"><strong>ALT+N</strong></td>
  1309. <td>&nbsp;%s</td>
  1310. </tr>
  1311. <tr height="20">
  1312. <td height="20"><strong>ALT+O</strong></td>
  1313. <td>&nbsp;%s</td>
  1314. </tr>
  1315. <tr height="20">
  1316. <td height="20"><strong>ALT+P</strong></td>
  1317. <td>&nbsp;%s</td>
  1318. </tr>
  1319. <tr height="20">
  1320. <td height="20"><strong>ALT+Q</strong></td>
  1321. <td>&nbsp;%s</td>
  1322. </tr>
  1323. <tr height="20">
  1324. <td height="20"><strong>ALT+R</strong></td>
  1325. <td>&nbsp;%s</td>
  1326. </tr>
  1327. <tr height="20">
  1328. <td height="20"><strong>ALT+S</strong></td>
  1329. <td>&nbsp;%s</td>
  1330. </tr>
  1331. <tr height="20">
  1332. <td height="20"><strong>ALT+U</strong></td>
  1333. <td>&nbsp;%s</td>
  1334. </tr>
  1335. <tr height="20">
  1336. <td height="20"><strong>ALT+1</strong></td>
  1337. <td>&nbsp;%s</td>
  1338. </tr>
  1339. <tr height="20">
  1340. <td height="20"><strong>ALT+2</strong></td>
  1341. <td>&nbsp;%s</td>
  1342. </tr>
  1343. <tr height="20">
  1344. <td height="20"><strong>ALT+3</strong></td>
  1345. <td>&nbsp;%s</td>
  1346. </tr>
  1347. <tr height="20">
  1348. <td height="20"><strong>ALT+F10</strong></td>
  1349. <td>&nbsp;%s</td>
  1350. </tr>
  1351. <tr height="20">
  1352. <td height="20">&nbsp;</td>
  1353. <td>&nbsp;</td>
  1354. </tr>
  1355. <tr height="20">
  1356. <td height="20"><strong>CTRL+ALT+X</strong></td>
  1357. <td>&nbsp;%s</td>
  1358. </tr>
  1359. <tr height="20">
  1360. <td height="20">&nbsp;</td>
  1361. <td>&nbsp;</td>
  1362. </tr>
  1363. <tr height="20">
  1364. <td height="20"><strong>F1</strong></td>
  1365. <td>&nbsp;%s</td>
  1366. </tr>
  1367. <tr height="20">
  1368. <td height="20"><strong>F4</strong></td>
  1369. <td>&nbsp;%s</td>
  1370. </tr>
  1371. <tr height="20">
  1372. <td height="20"><strong>F5</strong></td>
  1373. <td>&nbsp;%s</td>
  1374. </tr>
  1375. <tr height="20">
  1376. <td height="20"><strong>Del</strong></td>
  1377. <td>&nbsp;%s</td>
  1378. </tr>
  1379. <tr height="20">
  1380. <td height="20"><strong>Del</strong></td>
  1381. <td>&nbsp;%s</td>
  1382. </tr>
  1383. <tr height="20">
  1384. <td height="20"><strong>'`'</strong></td>
  1385. <td>&nbsp;%s</td>
  1386. </tr>
  1387. <tr height="20">
  1388. <td height="20"><strong>SPACE</strong></td>
  1389. <td>&nbsp;%s</td>
  1390. </tr>
  1391. <tr height="20">
  1392. <td height="20"><strong>Escape</strong></td>
  1393. <td>&nbsp;%s</td>
  1394. </tr>
  1395. </tbody>
  1396. </table>
  1397. ''' %
  1398. (
  1399. _("SHOW SHORTCUT LIST"), _("Switch to Project Tab"), _("Switch to Selected Tab"),
  1400. _("Switch to Tool Tab"),
  1401. _("New Gerber"), _("Edit Object (if selected)"), _("Grid On/Off"), _("Jump to Coordinates"),
  1402. _("New Excellon"), _("Move Obj"), _("New Geometry"), _("Set Origin"), _("Change Units"),
  1403. _("Open Properties Tool"), _("Rotate by 90 degree CW"), _("Shell Toggle"),
  1404. _("Add a Tool (when in Geometry Selected Tab or in Tools NCC or Tools Paint)"), _("Zoom Fit"),
  1405. _("Flip on X_axis"), _("Flip on Y_axis"), _("Zoom Out"), _("Zoom In"),
  1406. # CTRL section
  1407. _("Select All"), _("Copy Obj"), _("Open Tools Database"),
  1408. _("Open Excellon File"), _("Open Gerber File"), _("Distance Tool"), _("New Project"),
  1409. _("Open Project"), _("Print (PDF)"), _("PDF Import Tool"), _("Save Project As"), _("Toggle Plot Area"),
  1410. # SHIFT section
  1411. _("Copy Obj_Name"),
  1412. _("Toggle Code Editor"), _("Toggle the axis"), _("Distance Minimum Tool"), _("Open Preferences Window"),
  1413. _("Rotate by 90 degree CCW"), _("Run a Script"), _("Toggle the workspace"), _("Skew on X axis"),
  1414. _("Skew on Y axis"),
  1415. # ALT section
  1416. _("Calculators Tool"), _("2-Sided PCB Tool"), _("Transformations Tool"), _("Fiducials Tool"),
  1417. _("Solder Paste Dispensing Tool"),
  1418. _("Film PCB Tool"), _("Non-Copper Clearing Tool"), _("Optimal Tool"),
  1419. _("Paint Area Tool"), _("QRCode Tool"), _("Rules Check Tool"),
  1420. _("View File Source"),
  1421. _("Cutout PCB Tool"), _("Enable all Plots"), _("Disable all Plots"), _("Disable Non-selected Plots"),
  1422. _("Toggle Full Screen"),
  1423. # CTRL + ALT section
  1424. _("Abort current task (gracefully)"),
  1425. # F keys section
  1426. _("Open Online Manual"),
  1427. _("Open Online Tutorials"), _("Refresh Plots"), _("Delete Object"), _("Alternate: Delete Tool"),
  1428. _("(left to Key_1)Toogle Notebook Area (Left Side)"), _("En(Dis)able Obj Plot"),
  1429. _("Deselects all objects")
  1430. )
  1431. )
  1432. self.sh_app = QtWidgets.QTextEdit()
  1433. self.sh_app.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1434. self.sh_app.setText(self.app_sh_msg)
  1435. self.sh_app.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  1436. self.sh_hlay.addWidget(self.sh_app)
  1437. editor_title = """
  1438. <b>%s</b><br>
  1439. <br>
  1440. """ % _("Editor Shortcut list")
  1441. geo_sh_messages = """
  1442. <strong><span style="color:#0000ff">%s</span></strong><br>
  1443. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1444. <tbody>
  1445. <tr height="20">
  1446. <td height="20" width="89"><strong>A</strong></td>
  1447. <td width="194">&nbsp;%s</td>
  1448. </tr>
  1449. <tr height="20">
  1450. <td height="20"><strong>B</strong></td>
  1451. <td>&nbsp;%s</td>
  1452. </tr>
  1453. <tr height="20">
  1454. <td height="20"><strong>C</strong></td>
  1455. <td>&nbsp;%s</td>
  1456. </tr>
  1457. <tr height="20">
  1458. <td height="20"><strong>D</strong></td>
  1459. <td>&nbsp;%s</td>
  1460. </tr>
  1461. <tr height="20">
  1462. <td height="20"><strong>E</strong></td>
  1463. <td>&nbsp;%s</td>
  1464. </tr>
  1465. <tr height="20">
  1466. <td height="20"><strong>I</strong></td>
  1467. <td>&nbsp;%s</td>
  1468. </tr>
  1469. <tr height="20">
  1470. <td height="20"><strong>J</strong></td>
  1471. <td>&nbsp;%s</td>
  1472. </tr>
  1473. <tr height="20">
  1474. <td height="20"><strong>K</strong></td>
  1475. <td>&nbsp;%s</td>
  1476. </tr>
  1477. <tr height="20">
  1478. <td height="20"><strong>M</strong></td>
  1479. <td>&nbsp;%s</td>
  1480. </tr>
  1481. <tr height="20">
  1482. <td height="20"><strong>M</strong></td>
  1483. <td>&nbsp;%s</td>
  1484. </tr>
  1485. <tr height="20">
  1486. <td height="20"><strong>N</strong></td>
  1487. <td>&nbsp;%s</td>
  1488. </tr>
  1489. <tr height="20">
  1490. <td height="20"><strong>O</strong></td>
  1491. <td>&nbsp;%s</td>
  1492. </tr>
  1493. <tr height="20">
  1494. <td height="20"><strong>P</strong></td>
  1495. <td>&nbsp;%s</td>
  1496. </tr>
  1497. <tr height="20">
  1498. <td height="20"><strong>R</strong></td>
  1499. <td>&nbsp;%s</td>
  1500. </tr>
  1501. <tr height="20">
  1502. <td height="20"><strong>S</strong></td>
  1503. <td>&nbsp;%s</td>
  1504. </tr>
  1505. <tr height="20">
  1506. <td height="20"><strong>T</strong></td>
  1507. <td>&nbsp;%s</td>
  1508. </tr>
  1509. <tr height="20">
  1510. <td height="20"><strong>U</strong></td>
  1511. <td>&nbsp;%s</td>
  1512. </tr>
  1513. <tr height="20">
  1514. <td height="20"><strong>X</strong></td>
  1515. <td>&nbsp;%s</td>
  1516. </tr>
  1517. <tr height="20">
  1518. <td height="20"><strong>Y</strong></td>
  1519. <td>&nbsp;%s</td>
  1520. </tr>
  1521. <tr height="20">
  1522. <td height="20">&nbsp;</td>
  1523. <td>&nbsp;</td>
  1524. </tr>
  1525. <tr height="20">
  1526. <td height="20"><strong>SHIFT+M</strong></td>
  1527. <td>&nbsp;%s</td>
  1528. </tr>
  1529. <tr height="20">
  1530. <td height="20"><strong>SHIFT+X</strong></td>
  1531. <td>&nbsp;%s</td>
  1532. </tr>
  1533. <tr height="20">
  1534. <td height="20"><strong>SHIFT+Y</strong></td>
  1535. <td>&nbsp;%s</td>
  1536. </tr>
  1537. <tr height="20">
  1538. <td height="20">&nbsp;</td>
  1539. <td>&nbsp;</td>
  1540. </tr>
  1541. <tr height="20">
  1542. <td height="20"><strong>ALT+R</strong></td>
  1543. <td>&nbsp;%s</td>
  1544. </tr>
  1545. <tr height="20">
  1546. <td height="20"><strong>ALT+X</strong></td>
  1547. <td>&nbsp;%s</td>
  1548. </tr>
  1549. <tr height="20">
  1550. <td height="20"><strong>ALT+Y</strong></td>
  1551. <td>&nbsp;%s</td>
  1552. </tr>
  1553. <tr height="20">
  1554. <td height="20">&nbsp;</td>
  1555. <td>&nbsp;</td>
  1556. </tr>
  1557. <tr height="20">
  1558. <td height="20"><strong>CTRL+M</strong></td>
  1559. <td>&nbsp;%s</td>
  1560. </tr>
  1561. <tr height="20">
  1562. <td height="20"><strong>CTRL+S</strong></td>
  1563. <td>&nbsp;%s</td>
  1564. </tr>
  1565. <tr height="20">
  1566. <td height="20"><strong>CTRL+X</strong></td>
  1567. <td>&nbsp;%s</td>
  1568. </tr>
  1569. <tr height="20">
  1570. <td height="20">&nbsp;</td>
  1571. <td>&nbsp;</td>
  1572. </tr>
  1573. <tr height="20">
  1574. <td height="20"><strong>Space</strong></td>
  1575. <td>&nbsp;%s</td>
  1576. </tr>
  1577. <tr height="20">
  1578. <td height="20"><strong>ENTER</strong></td>
  1579. <td>&nbsp;%s</td>
  1580. </tr>
  1581. <tr height="20">
  1582. <td height="20"><strong>ESC</strong></td>
  1583. <td>&nbsp;%s</td>
  1584. </tr>
  1585. <tr height="20">
  1586. <td height="20"><strong>Del</strong></td>
  1587. <td>&nbsp;%s</td>
  1588. </tr>
  1589. </tbody>
  1590. </table>
  1591. <br>
  1592. """ % (
  1593. _("GEOMETRY EDITOR"), _("Draw an Arc"), _("Buffer Tool"), _("Copy Geo Item"),
  1594. _("Within Add Arc will toogle the ARC direction: CW or CCW"), _("Polygon Intersection Tool"),
  1595. _("Geo Paint Tool"), _("Jump to Location (x, y)"), _("Toggle Corner Snap"), _("Move Geo Item"),
  1596. _("Within Add Arc will cycle through the ARC modes"), _("Draw a Polygon"), _("Draw a Circle"),
  1597. _("Draw a Path"), _("Draw Rectangle"), _("Polygon Subtraction Tool"), _("Add Text Tool"),
  1598. _("Polygon Union Tool"), _("Flip shape on X axis"), _("Flip shape on Y axis"), _("Distance Minimum Tool"),
  1599. _("Skew shape on X axis"), _("Skew shape on Y axis"), _("Editor Transformation Tool"),
  1600. _("Offset shape on X axis"), _("Offset shape on Y axis"), _("Distance Tool"),
  1601. _("Save Object and Exit Editor"), _("Polygon Cut Tool"),
  1602. _("Rotate Geometry"), _("Finish drawing for certain tools"), _("Abort and return to Select"),
  1603. _("Delete Shape")
  1604. )
  1605. exc_sh_messages = """
  1606. <br>
  1607. <strong><span style="color:#ff0000">%s</span></strong><br>
  1608. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1609. <tbody>
  1610. <tr height="20">
  1611. <td height="20" width="89"><strong>A</strong></td>
  1612. <td width="194">&nbsp;%s</td>
  1613. </tr>
  1614. <tr height="20">
  1615. <td height="20"><strong>C</strong></td>
  1616. <td>&nbsp;%s</td>
  1617. </tr>
  1618. <tr height="20">
  1619. <td height="20"><strong>D</strong></td>
  1620. <td>&nbsp;%s</td>
  1621. </tr>
  1622. <tr height="20">
  1623. <td height="20"><strong>J</strong></td>
  1624. <td>&nbsp;%s</td>
  1625. </tr>
  1626. <tr height="20">
  1627. <td height="20"><strong>M</strong></td>
  1628. <td>&nbsp;%s</td>
  1629. </tr>
  1630. <tr height="20">
  1631. <td height="20" width="89"><strong>Q</strong></td>
  1632. <td width="194">&nbsp;%s</td>
  1633. </tr>
  1634. <tr height="20">
  1635. <td height="20"><strong>R</strong></td>
  1636. <td>&nbsp;%s</td>
  1637. </tr>
  1638. <tr height="20">
  1639. <td height="20"><strong>T</strong></td>
  1640. <td>&nbsp;%s</td>
  1641. </tr>
  1642. <tr height="20">
  1643. <td height="20" width="89"><strong>W</strong></td>
  1644. <td width="194">&nbsp;%s</td>
  1645. </tr>
  1646. <tr height="20">
  1647. <td height="20">&nbsp;</td>
  1648. <td>&nbsp;</td>
  1649. </tr>
  1650. <tr height="20">
  1651. <td height="20"><strong>SHIFT+M</strong></td>
  1652. <td>&nbsp;%s</td>
  1653. </tr>
  1654. <tr height="20">
  1655. <td height="20">&nbsp;</td>
  1656. <td>&nbsp;</td>
  1657. </tr>
  1658. <tr height="20">
  1659. <td height="20"><strong>Del</strong></td>
  1660. <td>&nbsp;%s</td>
  1661. </tr>
  1662. <tr height="20">
  1663. <td height="20"><strong>Del</strong></td>
  1664. <td>&nbsp;%s</td>
  1665. </tr>
  1666. <tr height="20">
  1667. <td height="20">&nbsp;</td>
  1668. <td>&nbsp;</td>
  1669. </tr>
  1670. <tr height="20">
  1671. <td height="20"><strong>ESC</strong></td>
  1672. <td>&nbsp;%s</td>
  1673. </tr>
  1674. <tr height="20">
  1675. <td height="20"><strong>CTRL+S</strong></td>
  1676. <td>&nbsp;%s</td>
  1677. </tr>
  1678. </tbody>
  1679. </table>
  1680. <br>
  1681. """ % (
  1682. _("EXCELLON EDITOR"), _("Add Drill Array"), _("Copy Drill(s)"), _("Add Drill"),
  1683. _("Jump to Location (x, y)"), _("Move Drill(s)"), _("Add Slot Array"), _("Resize Drill(s)"),
  1684. _("Add a new Tool"), _("Add Slot"), _("Distance Minimum Tool"),
  1685. _("Delete Drill(s)"), _("Alternate: Delete Tool(s)"),
  1686. _("Abort and return to Select"), _("Save Object and Exit Editor")
  1687. )
  1688. grb_sh_messages = """
  1689. <br>
  1690. <strong><span style="color:#00ff00">%s</span></strong><br>
  1691. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1692. <tbody>
  1693. <tr height="20">
  1694. <td height="20" width="89"><strong>A</strong></td>
  1695. <td width="194">&nbsp;%s</td>
  1696. </tr>
  1697. <tr height="20">
  1698. <td height="20"><strong>B</strong></td>
  1699. <td>&nbsp;%s</td>
  1700. </tr>
  1701. <tr height="20">
  1702. <td height="20"><strong>C</strong></td>
  1703. <td>&nbsp;%s</td>
  1704. </tr>
  1705. <tr height="20">
  1706. <td height="20"><strong>D</strong></td>
  1707. <td>&nbsp;%s</td>
  1708. </tr>
  1709. <tr height="20">
  1710. <td height="20"><strong>E</strong></td>
  1711. <td>&nbsp;%s</td>
  1712. </tr>
  1713. <tr height="20">
  1714. <td height="20"><strong>J</strong></td>
  1715. <td>&nbsp;%s</td>
  1716. </tr>
  1717. <tr height="20">
  1718. <td height="20"><strong>M</strong></td>
  1719. <td>&nbsp;%s</td>
  1720. </tr>
  1721. <tr height="20">
  1722. <td height="20"><strong>N</strong></td>
  1723. <td>&nbsp;%s</td>
  1724. </tr>
  1725. <tr height="20">
  1726. <td height="20"><strong>P</strong></td>
  1727. <td>&nbsp;%s</td>
  1728. </tr>
  1729. <tr height="20">
  1730. <td height="20"><strong>R</strong></td>
  1731. <td>&nbsp;%s</td>
  1732. </tr>
  1733. <tr height="20">
  1734. <td height="20"><strong>S</strong></td>
  1735. <td>&nbsp;%s</td>
  1736. </tr>
  1737. <tr height="20">
  1738. <td height="20"><strong>T</strong></td>
  1739. <td>&nbsp;%s</td>
  1740. </tr>
  1741. <tr height="20">
  1742. <td height="20"><strong>T</strong></td>
  1743. <td>&nbsp;%s</td>
  1744. </tr>
  1745. <tr height="20">
  1746. <td height="20">&nbsp;</td>
  1747. <td>&nbsp;</td>
  1748. </tr>
  1749. <tr height="20">
  1750. <td height="20"><strong>Del</strong></td>
  1751. <td>&nbsp;%s</td>
  1752. </tr>
  1753. <tr height="20">
  1754. <td height="20"><strong>Del</strong></td>
  1755. <td>&nbsp;%s</td>
  1756. </tr>
  1757. <tr height="20">
  1758. <td height="20"><strong>ESC</strong></td>
  1759. <td>&nbsp;%s</td>
  1760. </tr>
  1761. <tr height="20">
  1762. <td height="20">&nbsp;</td>
  1763. <td>&nbsp;</td>
  1764. </tr>
  1765. <tr height="20">
  1766. <td height="20"><strong>SHIFT+M</strong></td>
  1767. <td>&nbsp;%s</td>
  1768. </tr>
  1769. <tr height="20">
  1770. <td height="20">&nbsp;</td>
  1771. <td>&nbsp;</td>
  1772. </tr>
  1773. <tr height="20">
  1774. <td height="20"><strong>CTRL+E</strong></td>
  1775. <td>&nbsp;%s</td>
  1776. </tr>
  1777. <tr height="20">
  1778. <td height="20"><strong>CTRL+S</strong></td>
  1779. <td>&nbsp;%s</td>
  1780. </tr>
  1781. <tr height="20">
  1782. <td height="20">&nbsp;</td>
  1783. <td>&nbsp;</td>
  1784. </tr>
  1785. <tr height="20">
  1786. <td height="20"><strong>ALT+A</strong></td>
  1787. <td>&nbsp;%s</td>
  1788. </tr>
  1789. <tr height="20">
  1790. <td height="20"><strong>ALT+N</strong></td>
  1791. <td>&nbsp;%s</td>
  1792. </tr>
  1793. <tr height="20">
  1794. <td height="20"><strong>ALT+R</strong></td>
  1795. <td>&nbsp;%s</td>
  1796. </tr>
  1797. </tbody>
  1798. </table>
  1799. <br>
  1800. """ % (
  1801. _("GERBER EDITOR"), _("Add Pad Array"), _("Buffer"), _("Copy"), _("Add Disc"), _("Add SemiDisc"),
  1802. _("Jump to Location (x, y)"), _("Move"), _("Add Region"), _("Add Pad"),
  1803. _("Within Track & Region Tools will cycle in REVERSE the bend modes"), _("Scale"), _("Add Track"),
  1804. _("Within Track & Region Tools will cycle FORWARD the bend modes"), _("Delete"),
  1805. _("Alternate: Delete Apertures"), _("Abort and return to Select"), _("Distance Minimum Tool"),
  1806. _("Eraser Tool"),
  1807. _("Save Object and Exit Editor"), _("Mark Area Tool"), _("Poligonize Tool"), _("Transformation Tool")
  1808. )
  1809. self.editor_sh_msg = editor_title + geo_sh_messages + grb_sh_messages + exc_sh_messages
  1810. self.sh_editor = QtWidgets.QTextEdit()
  1811. self.sh_editor.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1812. self.sh_editor.setText(self.editor_sh_msg)
  1813. self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  1814. self.sh_hlay.addWidget(self.sh_editor)
  1815. # ########################################################################
  1816. # ########################## PLOT AREA CONTEXT MENU # ###################
  1817. # ########################################################################
  1818. self.popMenu = FCMenu()
  1819. self.popmenu_disable = self.popMenu.addAction(
  1820. QtGui.QIcon(self.app.resource_location + '/disable32.png'), _("Toggle Visibility"))
  1821. self.popmenu_panel_toggle = self.popMenu.addAction(
  1822. QtGui.QIcon(self.app.resource_location + '/notebook16.png'), _("Toggle Panel"))
  1823. self.popMenu.addSeparator()
  1824. self.cmenu_newmenu = self.popMenu.addMenu(
  1825. QtGui.QIcon(self.app.resource_location + '/file32.png'), _("New"))
  1826. self.popmenu_new_geo = self.cmenu_newmenu.addAction(
  1827. QtGui.QIcon(self.app.resource_location + '/new_geo32_bis.png'), _("Geometry"))
  1828. self.popmenu_new_grb = self.cmenu_newmenu.addAction(
  1829. QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), "Gerber")
  1830. self.popmenu_new_exc = self.cmenu_newmenu.addAction(
  1831. QtGui.QIcon(self.app.resource_location + '/new_exc32.png'), _("Excellon"))
  1832. self.cmenu_newmenu.addSeparator()
  1833. self.popmenu_new_prj = self.cmenu_newmenu.addAction(
  1834. QtGui.QIcon(self.app.resource_location + '/file16.png'), _("Project"))
  1835. self.popMenu.addSeparator()
  1836. self.cmenu_gridmenu = self.popMenu.addMenu(
  1837. QtGui.QIcon(self.app.resource_location + '/grid32_menu.png'), _("Grids"))
  1838. self.cmenu_viewmenu = self.popMenu.addMenu(
  1839. QtGui.QIcon(self.app.resource_location + '/view64.png'), _("View"))
  1840. self.zoomfit = self.cmenu_viewmenu.addAction(
  1841. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
  1842. self.clearplot = self.cmenu_viewmenu.addAction(
  1843. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("Clear Plot"))
  1844. self.replot = self.cmenu_viewmenu.addAction(
  1845. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("Replot"))
  1846. self.popMenu.addSeparator()
  1847. self.g_editor_cmenu = self.popMenu.addMenu(
  1848. QtGui.QIcon(self.app.resource_location + '/draw32.png'), _("Geo Editor"))
  1849. self.draw_line = self.g_editor_cmenu.addAction(
  1850. QtGui.QIcon(self.app.resource_location + '/path32.png'), _("Path"))
  1851. self.draw_rect = self.g_editor_cmenu.addAction(
  1852. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _("Rectangle"))
  1853. self.g_editor_cmenu.addSeparator()
  1854. self.draw_circle = self.g_editor_cmenu.addAction(
  1855. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _("Circle"))
  1856. self.draw_poly = self.g_editor_cmenu.addAction(
  1857. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Polygon"))
  1858. self.draw_arc = self.g_editor_cmenu.addAction(
  1859. QtGui.QIcon(self.app.resource_location + '/arc32.png'), _("Arc"))
  1860. self.g_editor_cmenu.addSeparator()
  1861. self.draw_text = self.g_editor_cmenu.addAction(
  1862. QtGui.QIcon(self.app.resource_location + '/text32.png'), _("Text"))
  1863. self.draw_buffer = self.g_editor_cmenu.addAction(
  1864. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _("Buffer"))
  1865. self.draw_paint = self.g_editor_cmenu.addAction(
  1866. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint"))
  1867. self.draw_eraser = self.g_editor_cmenu.addAction(
  1868. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _("Eraser"))
  1869. self.g_editor_cmenu.addSeparator()
  1870. self.draw_union = self.g_editor_cmenu.addAction(
  1871. QtGui.QIcon(self.app.resource_location + '/union32.png'), _("Union"))
  1872. self.draw_intersect = self.g_editor_cmenu.addAction(
  1873. QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _("Intersection"))
  1874. self.draw_substract = self.g_editor_cmenu.addAction(
  1875. QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _("Subtraction"))
  1876. self.draw_cut = self.g_editor_cmenu.addAction(
  1877. QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _("Cut"))
  1878. self.draw_transform = self.g_editor_cmenu.addAction(
  1879. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  1880. self.g_editor_cmenu.addSeparator()
  1881. self.draw_move = self.g_editor_cmenu.addAction(
  1882. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  1883. self.grb_editor_cmenu = self.popMenu.addMenu(
  1884. QtGui.QIcon(self.app.resource_location + '/draw32.png'), _("Gerber Editor"))
  1885. self.grb_draw_pad = self.grb_editor_cmenu.addAction(
  1886. QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Pad"))
  1887. self.grb_draw_pad_array = self.grb_editor_cmenu.addAction(
  1888. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _("Pad Array"))
  1889. self.grb_editor_cmenu.addSeparator()
  1890. self.grb_draw_track = self.grb_editor_cmenu.addAction(
  1891. QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Track"))
  1892. self.grb_draw_region = self.grb_editor_cmenu.addAction(
  1893. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Region"))
  1894. self.grb_draw_poligonize = self.grb_editor_cmenu.addAction(
  1895. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
  1896. self.grb_draw_semidisc = self.grb_editor_cmenu.addAction(
  1897. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
  1898. self.grb_draw_disc = self.grb_editor_cmenu.addAction(
  1899. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
  1900. self.grb_editor_cmenu.addSeparator()
  1901. self.grb_draw_buffer = self.grb_editor_cmenu.addAction(
  1902. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _("Buffer"))
  1903. self.grb_draw_scale = self.grb_editor_cmenu.addAction(
  1904. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _("Scale"))
  1905. self.grb_draw_markarea = self.grb_editor_cmenu.addAction(
  1906. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _("Mark Area"))
  1907. self.grb_draw_eraser = self.grb_editor_cmenu.addAction(
  1908. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _("Eraser"))
  1909. self.grb_editor_cmenu.addSeparator()
  1910. self.grb_draw_transformations = self.grb_editor_cmenu.addAction(
  1911. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  1912. self.e_editor_cmenu = self.popMenu.addMenu(
  1913. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Exc Editor"))
  1914. self.drill = self.e_editor_cmenu.addAction(
  1915. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Add Drill"))
  1916. self.drill_array = self.e_editor_cmenu.addAction(
  1917. QtGui.QIcon(self.app.resource_location + '/addarray32.png'), _("Add Drill Array"))
  1918. self.e_editor_cmenu.addSeparator()
  1919. self.slot = self.e_editor_cmenu.addAction(
  1920. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _("Add Slot"))
  1921. self.slot_array = self.e_editor_cmenu.addAction(
  1922. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _("Add Slot Array"))
  1923. self.e_editor_cmenu.addSeparator()
  1924. self.drill_resize = self.e_editor_cmenu.addAction(
  1925. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _("Resize Drill"))
  1926. self.popMenu.addSeparator()
  1927. self.popmenu_copy = self.popMenu.addAction(
  1928. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
  1929. self.popmenu_delete = self.popMenu.addAction(
  1930. QtGui.QIcon(self.app.resource_location + '/delete32.png'), _("Delete"))
  1931. self.popmenu_edit = self.popMenu.addAction(
  1932. QtGui.QIcon(self.app.resource_location + '/edit32.png'), _("Edit"))
  1933. self.popmenu_save = self.popMenu.addAction(
  1934. QtGui.QIcon(self.app.resource_location + '/floppy32.png'), _("Close Editor"))
  1935. self.popmenu_save.setVisible(False)
  1936. self.popMenu.addSeparator()
  1937. self.popmenu_move = self.popMenu.addAction(
  1938. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  1939. self.popmenu_properties = self.popMenu.addAction(
  1940. QtGui.QIcon(self.app.resource_location + '/properties32.png'), _("Properties"))
  1941. # ########################################################################
  1942. # ########################## INFO BAR # ##################################
  1943. # ########################################################################
  1944. self.infobar = self.statusBar()
  1945. self.fcinfo = FlatCAMInfoBar(app=self.app)
  1946. self.infobar.addWidget(self.fcinfo, stretch=1)
  1947. self.snap_infobar_label = QtWidgets.QLabel()
  1948. self.snap_infobar_label.setPixmap(QtGui.QPixmap(self.app.resource_location + '/snap_16.png'))
  1949. self.infobar.addWidget(self.snap_infobar_label)
  1950. self.rel_position_label = QtWidgets.QLabel(
  1951. "<b>Dx</b>: 0.0000&nbsp;&nbsp; <b>Dy</b>: 0.0000&nbsp;&nbsp;&nbsp;&nbsp;")
  1952. self.rel_position_label.setMinimumWidth(110)
  1953. self.rel_position_label.setToolTip(_("Relative neasurement.\nReference is last click position"))
  1954. self.infobar.addWidget(self.rel_position_label)
  1955. self.position_label = QtWidgets.QLabel(
  1956. "&nbsp;&nbsp;&nbsp;&nbsp;<b>X</b>: 0.0000&nbsp;&nbsp; <b>Y</b>: 0.0000")
  1957. self.position_label.setMinimumWidth(110)
  1958. self.position_label.setToolTip(_("Absolute neasurement.\nReference is (X=0, Y= 0) position"))
  1959. self.infobar.addWidget(self.position_label)
  1960. self.units_label = QtWidgets.QLabel("[in]")
  1961. self.units_label.setMargin(2)
  1962. self.infobar.addWidget(self.units_label)
  1963. # disabled
  1964. self.progress_bar = QtWidgets.QProgressBar()
  1965. self.progress_bar.setMinimum(0)
  1966. self.progress_bar.setMaximum(100)
  1967. # infobar.addWidget(self.progress_bar)
  1968. # ########################################################################
  1969. # ########################## SET GUI Elements # ##########################
  1970. # ########################################################################
  1971. self.app_icon = QtGui.QIcon()
  1972. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon16.png', QtCore.QSize(16, 16))
  1973. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon24.png', QtCore.QSize(24, 24))
  1974. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon32.png', QtCore.QSize(32, 32))
  1975. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon48.png', QtCore.QSize(48, 48))
  1976. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon128.png', QtCore.QSize(128, 128))
  1977. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon256.png', QtCore.QSize(256, 256))
  1978. self.setWindowIcon(self.app_icon)
  1979. self.setGeometry(100, 100, 1024, 650)
  1980. self.setWindowTitle('FlatCAM %s %s - %s' %
  1981. (self.app.version,
  1982. ('BETA' if self.app.beta else ''),
  1983. platform.architecture()[0])
  1984. )
  1985. self.filename = ""
  1986. self.units = ""
  1987. self.setAcceptDrops(True)
  1988. # ########################################################################
  1989. # ########################## Build GUI # #################################
  1990. # ########################################################################
  1991. self.grid_snap_btn.setCheckable(True)
  1992. self.corner_snap_btn.setCheckable(True)
  1993. self.update_obj_btn.setEnabled(False)
  1994. # start with GRID activated
  1995. self.grid_snap_btn.trigger()
  1996. self.g_editor_cmenu.menuAction().setVisible(False)
  1997. self.grb_editor_cmenu.menuAction().setVisible(False)
  1998. self.e_editor_cmenu.menuAction().setVisible(False)
  1999. self.general_defaults_form = GeneralPreferencesUI(decimals=self.decimals)
  2000. self.gerber_defaults_form = GerberPreferencesUI(decimals=self.decimals)
  2001. self.excellon_defaults_form = ExcellonPreferencesUI(decimals=self.decimals)
  2002. self.geometry_defaults_form = GeometryPreferencesUI(decimals=self.decimals)
  2003. self.cncjob_defaults_form = CNCJobPreferencesUI(decimals=self.decimals)
  2004. self.tools_defaults_form = ToolsPreferencesUI(decimals=self.decimals)
  2005. self.tools2_defaults_form = Tools2PreferencesUI(decimals=self.decimals)
  2006. self.util_defaults_form = UtilPreferencesUI(decimals=self.decimals)
  2007. QtWidgets.qApp.installEventFilter(self)
  2008. # restore the Toolbar State from file
  2009. settings = QSettings("Open Source", "FlatCAM")
  2010. if settings.contains("saved_gui_state"):
  2011. saved_gui_state = settings.value('saved_gui_state')
  2012. self.restoreState(saved_gui_state)
  2013. log.debug("FlatCAMGUI.__init__() --> UI state restored.")
  2014. if settings.contains("layout"):
  2015. layout = settings.value('layout', type=str)
  2016. if layout == 'standard':
  2017. # self.exc_edit_toolbar.setVisible(False)
  2018. self.exc_edit_toolbar.setDisabled(True)
  2019. # self.geo_edit_toolbar.setVisible(False)
  2020. self.geo_edit_toolbar.setDisabled(True)
  2021. # self.grb_edit_toolbar.setVisible(False)
  2022. self.grb_edit_toolbar.setDisabled(True)
  2023. self.corner_snap_btn.setVisible(False)
  2024. self.snap_magnet.setVisible(False)
  2025. elif layout == 'compact':
  2026. self.exc_edit_toolbar.setDisabled(True)
  2027. self.geo_edit_toolbar.setDisabled(True)
  2028. self.grb_edit_toolbar.setDisabled(True)
  2029. self.snap_magnet.setVisible(True)
  2030. self.corner_snap_btn.setVisible(True)
  2031. self.snap_magnet.setDisabled(True)
  2032. self.corner_snap_btn.setDisabled(True)
  2033. log.debug("FlatCAMGUI.__init__() --> UI layout restored from QSettings.")
  2034. else:
  2035. # self.exc_edit_toolbar.setVisible(False)
  2036. self.exc_edit_toolbar.setDisabled(True)
  2037. # self.geo_edit_toolbar.setVisible(False)
  2038. self.geo_edit_toolbar.setDisabled(True)
  2039. # self.grb_edit_toolbar.setVisible(False)
  2040. self.grb_edit_toolbar.setDisabled(True)
  2041. self.corner_snap_btn.setVisible(False)
  2042. self.snap_magnet.setVisible(False)
  2043. settings.setValue('layout', "standard")
  2044. # This will write the setting to the platform specific storage.
  2045. del settings
  2046. log.debug("FlatCAMGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'")
  2047. # construct the Toolbar Lock menu entry to the context menu of the QMainWindow
  2048. self.lock_action = QtWidgets.QAction()
  2049. self.lock_action.setText(_("Lock Toolbars"))
  2050. self.lock_action.setCheckable(True)
  2051. settings = QSettings("Open Source", "FlatCAM")
  2052. if settings.contains("toolbar_lock"):
  2053. lock_val = settings.value('toolbar_lock')
  2054. if lock_val == 'true':
  2055. lock_state = True
  2056. self.lock_action.setChecked(True)
  2057. else:
  2058. lock_state = False
  2059. self.lock_action.setChecked(False)
  2060. else:
  2061. lock_state = False
  2062. settings.setValue('toolbar_lock', lock_state)
  2063. # This will write the setting to the platform specific storage.
  2064. del settings
  2065. self.lock_toolbar(lock=lock_state)
  2066. self.lock_action.triggered[bool].connect(self.lock_toolbar)
  2067. # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2068. # %%%%%%%%%%%%%%%%% GUI Building FINISHED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2069. # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2070. def eventFilter(self, obj, event):
  2071. """
  2072. Filter the ToolTips display based on a Preferences setting
  2073. :param obj:
  2074. :param event: QT event to filter
  2075. :return:
  2076. """
  2077. if self.general_defaults_form.general_gui_set_group.toggle_tooltips_cb.get_value() is False:
  2078. if event.type() == QtCore.QEvent.ToolTip:
  2079. return True
  2080. else:
  2081. return False
  2082. return False
  2083. def populate_toolbars(self):
  2084. """
  2085. Will populate the App Toolbars with theie actions
  2086. :return: None
  2087. """
  2088. # ## File Toolbar # ##
  2089. self.file_open_gerber_btn = self.toolbarfile.addAction(
  2090. QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _("Open Gerber"))
  2091. self.file_open_excellon_btn = self.toolbarfile.addAction(
  2092. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Open Excellon"))
  2093. self.toolbarfile.addSeparator()
  2094. self.file_open_btn = self.toolbarfile.addAction(
  2095. QtGui.QIcon(self.app.resource_location + '/folder32.png'), _("Open project"))
  2096. self.file_save_btn = self.toolbarfile.addAction(
  2097. QtGui.QIcon(self.app.resource_location + '/project_save32.png'), _("Save project"))
  2098. # ## Edit Toolbar # ##
  2099. self.newgeo_btn = self.toolbargeo.addAction(
  2100. QtGui.QIcon(self.app.resource_location + '/new_file_geo32.png'), _("New Blank Geometry"))
  2101. self.newgrb_btn = self.toolbargeo.addAction(
  2102. QtGui.QIcon(self.app.resource_location + '/new_file_grb32.png'), _("New Blank Gerber"))
  2103. self.newexc_btn = self.toolbargeo.addAction(
  2104. QtGui.QIcon(self.app.resource_location + '/new_file_exc32.png'), _("New Blank Excellon"))
  2105. self.toolbargeo.addSeparator()
  2106. self.editgeo_btn = self.toolbargeo.addAction(
  2107. QtGui.QIcon(self.app.resource_location + '/edit32.png'), _("Editor"))
  2108. self.update_obj_btn = self.toolbargeo.addAction(
  2109. QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'),
  2110. _("Save Object and close the Editor")
  2111. )
  2112. self.toolbargeo.addSeparator()
  2113. self.copy_btn = self.toolbargeo.addAction(
  2114. QtGui.QIcon(self.app.resource_location + '/copy_file32.png'), _("Copy"))
  2115. self.delete_btn = self.toolbargeo.addAction(
  2116. QtGui.QIcon(self.app.resource_location + '/delete_file32.png'), _("&Delete"))
  2117. self.toolbargeo.addSeparator()
  2118. self.distance_btn = self.toolbargeo.addAction(
  2119. QtGui.QIcon(self.app.resource_location + '/distance32.png'), _("Distance Tool"))
  2120. self.distance_min_btn = self.toolbargeo.addAction(
  2121. QtGui.QIcon(self.app.resource_location + '/distance_min32.png'), _("Distance Min Tool"))
  2122. self.origin_btn = self.toolbargeo.addAction(
  2123. QtGui.QIcon(self.app.resource_location + '/origin32.png'), _('Set Origin'))
  2124. self.jmp_btn = self.toolbargeo.addAction(
  2125. QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location'))
  2126. # ## View Toolbar # ##
  2127. self.replot_btn = self.toolbarview.addAction(
  2128. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("&Replot"))
  2129. self.clear_plot_btn = self.toolbarview.addAction(
  2130. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("&Clear plot"))
  2131. self.zoom_in_btn = self.toolbarview.addAction(
  2132. QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("Zoom In"))
  2133. self.zoom_out_btn = self.toolbarview.addAction(
  2134. QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("Zoom Out"))
  2135. self.zoom_fit_btn = self.toolbarview.addAction(
  2136. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
  2137. # self.toolbarview.setVisible(False)
  2138. # ## Shell Toolbar # ##
  2139. self.shell_btn = self.toolbarshell.addAction(
  2140. QtGui.QIcon(self.app.resource_location + '/shell32.png'), _("&Command Line"))
  2141. self.new_script_btn = self.toolbarshell.addAction(
  2142. QtGui.QIcon(self.app.resource_location + '/script_new24.png'), _('New Script ...'))
  2143. self.open_script_btn = self.toolbarshell.addAction(
  2144. QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'))
  2145. self.run_script_btn = self.toolbarshell.addAction(
  2146. QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Run Script ...'))
  2147. # ## Tools Toolbar # ##
  2148. self.dblsided_btn = self.toolbartools.addAction(
  2149. QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2Sided Tool"))
  2150. self.cutout_btn = self.toolbartools.addAction(
  2151. QtGui.QIcon(self.app.resource_location + '/cut16_bis.png'), _("&Cutout Tool"))
  2152. self.ncc_btn = self.toolbartools.addAction(
  2153. QtGui.QIcon(self.app.resource_location + '/ncc16.png'), _("NCC Tool"))
  2154. self.paint_btn = self.toolbartools.addAction(
  2155. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool"))
  2156. self.toolbartools.addSeparator()
  2157. self.panelize_btn = self.toolbartools.addAction(
  2158. QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool"))
  2159. self.film_btn = self.toolbartools.addAction(
  2160. QtGui.QIcon(self.app.resource_location + '/film16.png'), _("Film Tool"))
  2161. self.solder_btn = self.toolbartools.addAction(
  2162. QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'),
  2163. _("SolderPaste Tool"))
  2164. self.sub_btn = self.toolbartools.addAction(
  2165. QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool"))
  2166. self.toolbartools.addSeparator()
  2167. self.calculators_btn = self.toolbartools.addAction(
  2168. QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool"))
  2169. self.transform_btn = self.toolbartools.addAction(
  2170. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool"))
  2171. self.qrcode_btn = self.toolbartools.addAction(
  2172. QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool"))
  2173. self.copperfill_btn = self.toolbartools.addAction(
  2174. QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool"))
  2175. self.fiducials_btn = self.toolbartools.addAction(
  2176. QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool"))
  2177. self.cal_btn = self.toolbartools.addAction(
  2178. QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool"))
  2179. # ## Excellon Editor Toolbar # ##
  2180. self.select_drill_btn = self.exc_edit_toolbar.addAction(
  2181. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  2182. self.add_drill_btn = self.exc_edit_toolbar.addAction(
  2183. QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill Hole'))
  2184. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  2185. QtGui.QIcon(self.app.resource_location + '/addarray16.png'), _('Add Drill Hole Array'))
  2186. self.resize_drill_btn = self.exc_edit_toolbar.addAction(
  2187. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill'))
  2188. self.add_slot_btn = self.exc_edit_toolbar.addAction(
  2189. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot'))
  2190. self.add_slot_array_btn = self.exc_edit_toolbar.addAction(
  2191. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array'))
  2192. self.exc_edit_toolbar.addSeparator()
  2193. self.copy_drill_btn = self.exc_edit_toolbar.addAction(
  2194. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy Drill'))
  2195. self.delete_drill_btn = self.exc_edit_toolbar.addAction(
  2196. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Drill"))
  2197. self.exc_edit_toolbar.addSeparator()
  2198. self.move_drill_btn = self.exc_edit_toolbar.addAction(
  2199. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Drill"))
  2200. # ## Geometry Editor Toolbar # ##
  2201. self.geo_select_btn = self.geo_edit_toolbar.addAction(
  2202. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select 'Esc'"))
  2203. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(
  2204. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle'))
  2205. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(
  2206. QtGui.QIcon(self.app.resource_location + '/arc32.png'), _('Add Arc'))
  2207. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(
  2208. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle'))
  2209. self.geo_edit_toolbar.addSeparator()
  2210. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(
  2211. QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path'))
  2212. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(
  2213. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon'))
  2214. self.geo_edit_toolbar.addSeparator()
  2215. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(
  2216. QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text'))
  2217. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(
  2218. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Add Buffer'))
  2219. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(
  2220. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _('Paint Shape'))
  2221. self.geo_eraser_btn = self.geo_edit_toolbar.addAction(
  2222. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  2223. self.geo_edit_toolbar.addSeparator()
  2224. self.geo_union_btn = self.geo_edit_toolbar.addAction(
  2225. QtGui.QIcon(self.app.resource_location + '/union32.png'), _('Polygon Union'))
  2226. self.geo_explode_btn = self.geo_edit_toolbar.addAction(
  2227. QtGui.QIcon(self.app.resource_location + '/explode32.png'), _('Polygon Explode'))
  2228. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(
  2229. QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _('Polygon Intersection'))
  2230. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(
  2231. QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _('Polygon Subtraction'))
  2232. self.geo_edit_toolbar.addSeparator()
  2233. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(
  2234. QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _('Cut Path'))
  2235. self.geo_copy_btn = self.geo_edit_toolbar.addAction(
  2236. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy Objects"))
  2237. self.geo_delete_btn = self.geo_edit_toolbar.addAction(
  2238. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Shape"))
  2239. self.geo_transform_btn = self.geo_edit_toolbar.addAction(
  2240. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  2241. self.geo_edit_toolbar.addSeparator()
  2242. self.geo_move_btn = self.geo_edit_toolbar.addAction(
  2243. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Objects"))
  2244. # ## Gerber Editor Toolbar # ##
  2245. self.grb_select_btn = self.grb_edit_toolbar.addAction(
  2246. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  2247. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(
  2248. QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Add Pad"))
  2249. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(
  2250. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array'))
  2251. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(
  2252. QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Add Track"))
  2253. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(
  2254. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Add Region"))
  2255. self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(
  2256. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
  2257. self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(
  2258. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
  2259. self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(
  2260. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
  2261. self.grb_edit_toolbar.addSeparator()
  2262. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(
  2263. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer'))
  2264. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(
  2265. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale'))
  2266. self.aperture_markarea_btn = self.grb_edit_toolbar.addAction(
  2267. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area'))
  2268. self.aperture_eraser_btn = self.grb_edit_toolbar.addAction(
  2269. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  2270. self.grb_edit_toolbar.addSeparator()
  2271. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(
  2272. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
  2273. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(
  2274. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete"))
  2275. self.grb_transform_btn = self.grb_edit_toolbar.addAction(
  2276. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  2277. self.grb_edit_toolbar.addSeparator()
  2278. self.aperture_move_btn = self.grb_edit_toolbar.addAction(
  2279. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  2280. # ## Snap Toolbar # ##
  2281. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  2282. # self.addToolBar(self.snap_toolbar)
  2283. self.grid_snap_btn = self.snap_toolbar.addAction(
  2284. QtGui.QIcon(self.app.resource_location + '/grid32.png'), _('Snap to grid'))
  2285. self.grid_gap_x_entry = FCEntry2()
  2286. self.grid_gap_x_entry.setMaximumWidth(70)
  2287. self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
  2288. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  2289. self.grid_gap_y_entry = FCEntry2()
  2290. self.grid_gap_y_entry.setMaximumWidth(70)
  2291. self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
  2292. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  2293. self.grid_space_label = QtWidgets.QLabel(" ")
  2294. self.snap_toolbar.addWidget(self.grid_space_label)
  2295. self.grid_gap_link_cb = FCCheckBox()
  2296. self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
  2297. "is copied to the Grid_Y value."))
  2298. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  2299. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  2300. self.corner_snap_btn = self.snap_toolbar.addAction(
  2301. QtGui.QIcon(self.app.resource_location + '/corner32.png'), _('Snap to corner'))
  2302. self.snap_max_dist_entry = FCEntry()
  2303. self.snap_max_dist_entry.setMaximumWidth(70)
  2304. self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
  2305. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  2306. self.grid_snap_btn.setCheckable(True)
  2307. self.corner_snap_btn.setCheckable(True)
  2308. self.update_obj_btn.setEnabled(False)
  2309. # start with GRID activated
  2310. self.grid_snap_btn.trigger()
  2311. settings = QSettings("Open Source", "FlatCAM")
  2312. if settings.contains("layout"):
  2313. layout = settings.value('layout', type=str)
  2314. if layout == 'standard':
  2315. self.exc_edit_toolbar.setVisible(True)
  2316. self.exc_edit_toolbar.setDisabled(True)
  2317. self.geo_edit_toolbar.setVisible(True)
  2318. self.geo_edit_toolbar.setDisabled(True)
  2319. self.grb_edit_toolbar.setVisible(True)
  2320. self.grb_edit_toolbar.setDisabled(True)
  2321. self.corner_snap_btn.setVisible(False)
  2322. self.snap_magnet.setVisible(False)
  2323. elif layout == 'compact':
  2324. self.exc_edit_toolbar.setVisible(True)
  2325. self.exc_edit_toolbar.setDisabled(True)
  2326. self.geo_edit_toolbar.setVisible(True)
  2327. self.geo_edit_toolbar.setDisabled(True)
  2328. self.grb_edit_toolbar.setVisible(True)
  2329. self.grb_edit_toolbar.setDisabled(True)
  2330. self.corner_snap_btn.setVisible(True)
  2331. self.snap_magnet.setVisible(True)
  2332. self.corner_snap_btn.setDisabled(True)
  2333. self.snap_magnet.setDisabled(True)
  2334. def keyPressEvent(self, event):
  2335. """
  2336. Key event handler for the entire app.
  2337. Some of the key events are also treated locally in the FlatCAM editors
  2338. :param event: QT event
  2339. :return:
  2340. """
  2341. modifiers = QtWidgets.QApplication.keyboardModifiers()
  2342. active = self.app.collection.get_active()
  2343. selected = self.app.collection.get_selected()
  2344. matplotlib_key_flag = False
  2345. # events out of the self.app.collection view (it's about Project Tab) are of type int
  2346. if type(event) is int:
  2347. key = event
  2348. # events from the GUI are of type QKeyEvent
  2349. elif type(event) == QtGui.QKeyEvent:
  2350. key = event.key()
  2351. elif isinstance(event, mpl_key_event): # MatPlotLib key events are trickier to interpret than the rest
  2352. matplotlib_key_flag = True
  2353. key = event.key
  2354. key = QtGui.QKeySequence(key)
  2355. # check for modifiers
  2356. key_string = key.toString().lower()
  2357. if '+' in key_string:
  2358. mod, __, key_text = key_string.rpartition('+')
  2359. if mod.lower() == 'ctrl':
  2360. modifiers = QtCore.Qt.ControlModifier
  2361. elif mod.lower() == 'alt':
  2362. modifiers = QtCore.Qt.AltModifier
  2363. elif mod.lower() == 'shift':
  2364. modifiers = QtCore.Qt.ShiftModifier
  2365. else:
  2366. modifiers = QtCore.Qt.NoModifier
  2367. key = QtGui.QKeySequence(key_text)
  2368. # events from Vispy are of type KeyEvent
  2369. else:
  2370. key = event.key
  2371. if self.app.call_source == 'app':
  2372. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  2373. if key == QtCore.Qt.Key_X:
  2374. self.app.abort_all_tasks()
  2375. return
  2376. elif modifiers == QtCore.Qt.ControlModifier:
  2377. # Select All
  2378. if key == QtCore.Qt.Key_A:
  2379. self.app.on_selectall()
  2380. # Copy an FlatCAM object
  2381. if key == QtCore.Qt.Key_C:
  2382. widget_name = self.plot_tab_area.currentWidget().objectName()
  2383. if widget_name == 'database_tab':
  2384. # Tools DB saved, update flag
  2385. self.app.tools_db_changed_flag = True
  2386. self.app.tools_db_tab.on_tool_copy()
  2387. return
  2388. self.app.on_copy_object()
  2389. # Copy an FlatCAM object
  2390. if key == QtCore.Qt.Key_D:
  2391. self.app.on_tools_database()
  2392. # Open Excellon file
  2393. if key == QtCore.Qt.Key_E:
  2394. self.app.on_fileopenexcellon()
  2395. # Open Gerber file
  2396. if key == QtCore.Qt.Key_G:
  2397. self.app.on_fileopengerber()
  2398. # Distance Tool
  2399. if key == QtCore.Qt.Key_M:
  2400. self.app.distance_tool.run()
  2401. # Create New Project
  2402. if key == QtCore.Qt.Key_N:
  2403. self.app.on_file_new_click()
  2404. # Open Project
  2405. if key == QtCore.Qt.Key_O:
  2406. self.app.on_file_openproject()
  2407. # Open Project
  2408. if key == QtCore.Qt.Key_P:
  2409. self.app.on_file_save_objects_pdf(use_thread=True)
  2410. # PDF Import
  2411. if key == QtCore.Qt.Key_Q:
  2412. self.app.pdf_tool.run()
  2413. # Save Project
  2414. if key == QtCore.Qt.Key_S:
  2415. widget_name = self.plot_tab_area.currentWidget().objectName()
  2416. if widget_name == 'preferences_tab':
  2417. self.app.on_save_button(save_to_file=False)
  2418. return
  2419. if widget_name == 'database_tab':
  2420. # Tools DB saved, update flag
  2421. self.app.tools_db_changed_flag = False
  2422. self.app.tools_db_tab.on_save_tools_db()
  2423. return
  2424. self.app.on_file_saveproject()
  2425. # Toggle Plot Area
  2426. if key == QtCore.Qt.Key_F10 or key == 'F10':
  2427. self.app.on_toggle_plotarea()
  2428. return
  2429. elif modifiers == QtCore.Qt.ShiftModifier:
  2430. # Copy Object Name
  2431. if key == QtCore.Qt.Key_C:
  2432. self.app.on_copy_name()
  2433. # Toggle Code Editor
  2434. if key == QtCore.Qt.Key_E:
  2435. self.app.on_toggle_code_editor()
  2436. # Toggle axis
  2437. if key == QtCore.Qt.Key_G:
  2438. self.app.on_toggle_axis()
  2439. # Run Distance Minimum Tool
  2440. if key == QtCore.Qt.Key_M:
  2441. self.app.distance_min_tool.run()
  2442. return
  2443. # Open Preferences Window
  2444. if key == QtCore.Qt.Key_P:
  2445. self.app.on_preferences()
  2446. return
  2447. # Rotate Object by 90 degree CCW
  2448. if key == QtCore.Qt.Key_R:
  2449. self.app.on_rotate(silent=True, preset=-float(self.app.defaults['tools_transform_rotate']))
  2450. return
  2451. # Run a Script
  2452. if key == QtCore.Qt.Key_S:
  2453. self.app.on_filerunscript()
  2454. return
  2455. # Toggle Workspace
  2456. if key == QtCore.Qt.Key_W:
  2457. self.app.on_workspace_toggle()
  2458. return
  2459. # Skew on X axis
  2460. if key == QtCore.Qt.Key_X:
  2461. self.app.on_skewx()
  2462. return
  2463. # Skew on Y axis
  2464. if key == QtCore.Qt.Key_Y:
  2465. self.app.on_skewy()
  2466. return
  2467. elif modifiers == QtCore.Qt.AltModifier:
  2468. # Eanble all plots
  2469. if key == Qt.Key_1:
  2470. self.app.enable_all_plots()
  2471. # Disable all plots
  2472. if key == Qt.Key_2:
  2473. self.app.disable_all_plots()
  2474. # Disable all other plots
  2475. if key == Qt.Key_3:
  2476. self.app.disable_other_plots()
  2477. # Calculator Tool
  2478. if key == QtCore.Qt.Key_C:
  2479. self.app.calculator_tool.run(toggle=True)
  2480. # 2-Sided PCB Tool
  2481. if key == QtCore.Qt.Key_D:
  2482. self.app.dblsidedtool.run(toggle=True)
  2483. return
  2484. # Calibration Tool
  2485. if key == QtCore.Qt.Key_E:
  2486. self.app.cal_exc_tool.run(toggle=True)
  2487. return
  2488. # Copper Thieving Tool
  2489. if key == QtCore.Qt.Key_F:
  2490. self.app.copper_thieving_tool.run(toggle=True)
  2491. return
  2492. # Toggle Grid lines
  2493. if key == QtCore.Qt.Key_G:
  2494. self.app.on_toggle_grid_lines()
  2495. return
  2496. # Fiducials Tool
  2497. if key == QtCore.Qt.Key_J:
  2498. self.app.fiducial_tool.run(toggle=True)
  2499. return
  2500. # Solder Paste Dispensing Tool
  2501. if key == QtCore.Qt.Key_K:
  2502. self.app.paste_tool.run(toggle=True)
  2503. return
  2504. # Film Tool
  2505. if key == QtCore.Qt.Key_L:
  2506. self.app.film_tool.run(toggle=True)
  2507. return
  2508. # Non-Copper Clear Tool
  2509. if key == QtCore.Qt.Key_N:
  2510. self.app.ncclear_tool.run(toggle=True)
  2511. return
  2512. # Optimal Tool
  2513. if key == QtCore.Qt.Key_O:
  2514. self.app.optimal_tool.run(toggle=True)
  2515. return
  2516. # Paint Tool
  2517. if key == QtCore.Qt.Key_P:
  2518. self.app.paint_tool.run(toggle=True)
  2519. return
  2520. # QRCode Tool
  2521. if key == QtCore.Qt.Key_Q:
  2522. self.app.qrcode_tool.run()
  2523. return
  2524. # Rules Tool
  2525. if key == QtCore.Qt.Key_R:
  2526. self.app.rules_tool.run(toggle=True)
  2527. return
  2528. # View Source Object Content
  2529. if key == QtCore.Qt.Key_S:
  2530. self.app.on_view_source()
  2531. return
  2532. # Transformation Tool
  2533. if key == QtCore.Qt.Key_T:
  2534. self.app.transform_tool.run(toggle=True)
  2535. return
  2536. # Substract Tool
  2537. if key == QtCore.Qt.Key_W:
  2538. self.app.sub_tool.run(toggle=True)
  2539. return
  2540. # Cutout Tool
  2541. if key == QtCore.Qt.Key_X:
  2542. self.app.cutout_tool.run(toggle=True)
  2543. return
  2544. # Panelize Tool
  2545. if key == QtCore.Qt.Key_Z:
  2546. self.app.panelize_tool.run(toggle=True)
  2547. return
  2548. # Toggle Fullscreen
  2549. if key == QtCore.Qt.Key_F10 or key == 'F10':
  2550. self.app.on_fullscreen()
  2551. return
  2552. elif modifiers == QtCore.Qt.NoModifier:
  2553. # Open Manual
  2554. if key == QtCore.Qt.Key_F1 or key == 'F1':
  2555. webbrowser.open(self.app.manual_url)
  2556. # Show shortcut list
  2557. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2558. self.app.on_shortcut_list()
  2559. # Open Video Help
  2560. if key == QtCore.Qt.Key_F4 or key == 'F4':
  2561. webbrowser.open(self.app.video_url)
  2562. # Open Video Help
  2563. if key == QtCore.Qt.Key_F5 or key == 'F5':
  2564. self.app.plot_all()
  2565. # Switch to Project Tab
  2566. if key == QtCore.Qt.Key_1:
  2567. self.app.on_select_tab('project')
  2568. # Switch to Selected Tab
  2569. if key == QtCore.Qt.Key_2:
  2570. self.app.on_select_tab('selected')
  2571. # Switch to Tool Tab
  2572. if key == QtCore.Qt.Key_3:
  2573. self.app.on_select_tab('tool')
  2574. # Delete from PyQt
  2575. # It's meant to make a difference between delete objects and delete tools in
  2576. # Geometry Selected tool table
  2577. if key == QtCore.Qt.Key_Delete and matplotlib_key_flag is False:
  2578. widget_name = self.plot_tab_area.currentWidget().objectName()
  2579. if widget_name == 'database_tab':
  2580. # Tools DB saved, update flag
  2581. self.app.tools_db_changed_flag = True
  2582. self.app.tools_db_tab.on_tool_delete()
  2583. return
  2584. self.app.on_delete_keypress()
  2585. # Delete from canvas
  2586. if key == 'Delete':
  2587. # Delete via the application to
  2588. # ensure cleanup of the GUI
  2589. if active:
  2590. active.app.on_delete()
  2591. # Escape = Deselect All
  2592. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2593. self.app.on_deselect_all()
  2594. # if in full screen, exit to normal view
  2595. if self.app.toggle_fscreen is True:
  2596. self.app.on_fullscreen(disable=True)
  2597. # try to disconnect the slot from Set Origin
  2598. try:
  2599. self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_set_zero_click)
  2600. except TypeError:
  2601. pass
  2602. self.app.inform.emit("")
  2603. # Space = Toggle Active/Inactive
  2604. if key == QtCore.Qt.Key_Space:
  2605. for select in selected:
  2606. select.ui.plot_cb.toggle()
  2607. self.app.collection.update_view()
  2608. self.app.delete_selection_shape()
  2609. # New Geometry
  2610. if key == QtCore.Qt.Key_B:
  2611. self.app.new_gerber_object()
  2612. # New Geometry
  2613. if key == QtCore.Qt.Key_D:
  2614. self.app.new_document_object()
  2615. # Copy Object Name
  2616. if key == QtCore.Qt.Key_E:
  2617. self.app.object2editor()
  2618. # Grid toggle
  2619. if key == QtCore.Qt.Key_G:
  2620. self.app.ui.grid_snap_btn.trigger()
  2621. # Jump to coords
  2622. if key == QtCore.Qt.Key_J:
  2623. self.app.on_jump_to()
  2624. # New Excellon
  2625. if key == QtCore.Qt.Key_L:
  2626. self.app.new_excellon_object()
  2627. # Move tool toggle
  2628. if key == QtCore.Qt.Key_M:
  2629. self.app.move_tool.toggle()
  2630. # New Geometry
  2631. if key == QtCore.Qt.Key_N:
  2632. self.app.new_geometry_object()
  2633. # Set Origin
  2634. if key == QtCore.Qt.Key_O:
  2635. self.app.on_set_origin()
  2636. return
  2637. # Properties Tool
  2638. if key == QtCore.Qt.Key_P:
  2639. self.app.properties_tool.run()
  2640. return
  2641. # Change Units
  2642. if key == QtCore.Qt.Key_Q:
  2643. # if self.app.defaults["units"] == 'MM':
  2644. # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
  2645. # else:
  2646. # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
  2647. # self.app.on_toggle_units(no_pref=True)
  2648. self.app.on_toggle_units_click()
  2649. # Rotate Object by 90 degree CW
  2650. if key == QtCore.Qt.Key_R:
  2651. self.app.on_rotate(silent=True, preset=self.app.defaults['tools_transform_rotate'])
  2652. # Shell toggle
  2653. if key == QtCore.Qt.Key_S:
  2654. self.app.on_toggle_shell()
  2655. # Add a Tool from shortcut
  2656. if key == QtCore.Qt.Key_T:
  2657. widget_name = self.plot_tab_area.currentWidget().objectName()
  2658. if widget_name == 'database_tab':
  2659. # Tools DB saved, update flag
  2660. self.app.tools_db_changed_flag = True
  2661. self.app.tools_db_tab.on_tool_add()
  2662. return
  2663. self.app.on_tool_add_keypress()
  2664. # Zoom Fit
  2665. if key == QtCore.Qt.Key_V:
  2666. self.app.on_zoom_fit(None)
  2667. # Mirror on X the selected object(s)
  2668. if key == QtCore.Qt.Key_X:
  2669. self.app.on_flipx()
  2670. # Mirror on Y the selected object(s)
  2671. if key == QtCore.Qt.Key_Y:
  2672. self.app.on_flipy()
  2673. # Zoom In
  2674. if key == QtCore.Qt.Key_Equal:
  2675. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], self.app.mouse)
  2676. # Zoom Out
  2677. if key == QtCore.Qt.Key_Minus:
  2678. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], self.app.mouse)
  2679. # toggle display of Notebook area
  2680. if key == QtCore.Qt.Key_QuoteLeft:
  2681. self.app.on_toggle_notebook()
  2682. return
  2683. elif self.app.call_source == 'geo_editor':
  2684. if modifiers == QtCore.Qt.ControlModifier:
  2685. # save (update) the current geometry and return to the App
  2686. if key == QtCore.Qt.Key_S or key == 'S':
  2687. self.app.editor2object()
  2688. return
  2689. # toggle the measurement tool
  2690. if key == QtCore.Qt.Key_M or key == 'M':
  2691. self.app.distance_tool.run()
  2692. return
  2693. # Cut Action Tool
  2694. if key == QtCore.Qt.Key_X or key == 'X':
  2695. if self.app.geo_editor.get_selected() is not None:
  2696. self.app.geo_editor.cutpath()
  2697. else:
  2698. msg = _('Please first select a geometry item to be cutted\n'
  2699. 'then select the geometry item that will be cutted\n'
  2700. 'out of the first item. In the end press ~X~ key or\n'
  2701. 'the toolbar button.')
  2702. messagebox = QtWidgets.QMessageBox()
  2703. messagebox.setText(msg)
  2704. messagebox.setWindowTitle(_("Warning"))
  2705. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2706. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2707. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2708. messagebox.exec_()
  2709. return
  2710. elif modifiers == QtCore.Qt.ShiftModifier:
  2711. # Run Distance Minimum Tool
  2712. if key == QtCore.Qt.Key_M or key == 'M':
  2713. self.app.distance_min_tool.run()
  2714. return
  2715. # Skew on X axis
  2716. if key == QtCore.Qt.Key_X or key == 'X':
  2717. self.app.geo_editor.transform_tool.on_skewx_key()
  2718. return
  2719. # Skew on Y axis
  2720. if key == QtCore.Qt.Key_Y or key == 'Y':
  2721. self.app.geo_editor.transform_tool.on_skewy_key()
  2722. return
  2723. elif modifiers == QtCore.Qt.AltModifier:
  2724. # Transformation Tool
  2725. if key == QtCore.Qt.Key_R or key == 'R':
  2726. self.app.geo_editor.select_tool('transform')
  2727. return
  2728. # Offset on X axis
  2729. if key == QtCore.Qt.Key_X or key == 'X':
  2730. self.app.geo_editor.transform_tool.on_offx_key()
  2731. return
  2732. # Offset on Y axis
  2733. if key == QtCore.Qt.Key_Y or key == 'Y':
  2734. self.app.geo_editor.transform_tool.on_offy_key()
  2735. return
  2736. elif modifiers == QtCore.Qt.NoModifier:
  2737. # toggle display of Notebook area
  2738. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2739. self.app.on_toggle_notebook()
  2740. # Finish the current action. Use with tools that do not
  2741. # complete automatically, like a polygon or path.
  2742. if key == QtCore.Qt.Key_Enter or key == 'Enter':
  2743. if isinstance(self.app.geo_editor.active_tool, FCShapeTool):
  2744. if self.app.geo_editor.active_tool.name == 'rotate':
  2745. self.app.geo_editor.active_tool.make()
  2746. if self.app.geo_editor.active_tool.complete:
  2747. self.app.geo_editor.on_shape_complete()
  2748. self.app.inform.emit('[success] %s' % _("Done."))
  2749. # automatically make the selection tool active after completing current action
  2750. self.app.geo_editor.select_tool('select')
  2751. return
  2752. else:
  2753. self.app.geo_editor.active_tool.click(
  2754. self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
  2755. self.app.geo_editor.active_tool.make()
  2756. if self.app.geo_editor.active_tool.complete:
  2757. self.app.geo_editor.on_shape_complete()
  2758. self.app.inform.emit('[success] %s' % _("Done."))
  2759. # automatically make the selection tool active after completing current action
  2760. self.app.geo_editor.select_tool('select')
  2761. # Abort the current action
  2762. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2763. # TODO: ...?
  2764. # self.on_tool_select("select")
  2765. self.app.inform.emit('[WARNING_NOTCL] %s' %
  2766. _("Cancelled."))
  2767. self.app.geo_editor.delete_utility_geometry()
  2768. # deselect any shape that might be selected
  2769. self.app.geo_editor.selected = []
  2770. self.app.geo_editor.replot()
  2771. self.app.geo_editor.select_tool('select')
  2772. # hide the notebook
  2773. self.app.ui.splitter.setSizes([0, 1])
  2774. return
  2775. # Delete selected object
  2776. if key == QtCore.Qt.Key_Delete or key == 'Delete':
  2777. self.app.geo_editor.delete_selected()
  2778. self.app.geo_editor.replot()
  2779. # Rotate
  2780. if key == QtCore.Qt.Key_Space or key == 'Space':
  2781. self.app.geo_editor.transform_tool.on_rotate_key()
  2782. # Zoom Out
  2783. if key == QtCore.Qt.Key_Minus or key == '-':
  2784. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2785. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2786. # Zoom In
  2787. if key == QtCore.Qt.Key_Equal or key == '=':
  2788. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2789. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2790. # Switch to Project Tab
  2791. if key == QtCore.Qt.Key_1 or key == '1':
  2792. self.app.on_select_tab('project')
  2793. # Switch to Selected Tab
  2794. if key == QtCore.Qt.Key_2 or key == '2':
  2795. self.app.on_select_tab('selected')
  2796. # Switch to Tool Tab
  2797. if key == QtCore.Qt.Key_3 or key == '3':
  2798. self.app.on_select_tab('tool')
  2799. if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() is False:
  2800. response = self.app.geo_editor.active_tool.on_key(key=key)
  2801. if response is not None:
  2802. self.app.inform.emit(response)
  2803. else:
  2804. # Arc Tool
  2805. if key == QtCore.Qt.Key_A or key == 'A':
  2806. self.app.geo_editor.select_tool('arc')
  2807. # Buffer
  2808. if key == QtCore.Qt.Key_B or key == 'B':
  2809. self.app.geo_editor.select_tool('buffer')
  2810. # Copy
  2811. if key == QtCore.Qt.Key_C or key == 'C':
  2812. self.app.geo_editor.on_copy_click()
  2813. # Substract Tool
  2814. if key == QtCore.Qt.Key_E or key == 'E':
  2815. if self.app.geo_editor.get_selected() is not None:
  2816. self.app.geo_editor.intersection()
  2817. else:
  2818. msg = _("Please select geometry items \n"
  2819. "on which to perform Intersection Tool.")
  2820. messagebox = QtWidgets.QMessageBox()
  2821. messagebox.setText(msg)
  2822. messagebox.setWindowTitle(_("Warning"))
  2823. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2824. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2825. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2826. messagebox.exec_()
  2827. # Grid Snap
  2828. if key == QtCore.Qt.Key_G or key == 'G':
  2829. self.app.ui.grid_snap_btn.trigger()
  2830. # make sure that the cursor shape is enabled/disabled, too
  2831. if self.app.geo_editor.options['grid_snap'] is True:
  2832. self.app.app_cursor.enabled = True
  2833. else:
  2834. self.app.app_cursor.enabled = False
  2835. # Paint
  2836. if key == QtCore.Qt.Key_I or key == 'I':
  2837. self.app.geo_editor.select_tool('paint')
  2838. # Jump to coords
  2839. if key == QtCore.Qt.Key_J or key == 'J':
  2840. self.app.on_jump_to()
  2841. # Corner Snap
  2842. if key == QtCore.Qt.Key_K or key == 'K':
  2843. self.app.geo_editor.on_corner_snap()
  2844. # Move
  2845. if key == QtCore.Qt.Key_M or key == 'M':
  2846. self.app.geo_editor.on_move_click()
  2847. # Polygon Tool
  2848. if key == QtCore.Qt.Key_N or key == 'N':
  2849. self.app.geo_editor.select_tool('polygon')
  2850. # Circle Tool
  2851. if key == QtCore.Qt.Key_O or key == 'O':
  2852. self.app.geo_editor.select_tool('circle')
  2853. # Path Tool
  2854. if key == QtCore.Qt.Key_P or key == 'P':
  2855. self.app.geo_editor.select_tool('path')
  2856. # Rectangle Tool
  2857. if key == QtCore.Qt.Key_R or key == 'R':
  2858. self.app.geo_editor.select_tool('rectangle')
  2859. # Substract Tool
  2860. if key == QtCore.Qt.Key_S or key == 'S':
  2861. if self.app.geo_editor.get_selected() is not None:
  2862. self.app.geo_editor.subtract()
  2863. else:
  2864. msg = _(
  2865. "Please select geometry items \n"
  2866. "on which to perform Substraction Tool.")
  2867. messagebox = QtWidgets.QMessageBox()
  2868. messagebox.setText(msg)
  2869. messagebox.setWindowTitle(_("Warning"))
  2870. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2871. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2872. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2873. messagebox.exec_()
  2874. # Add Text Tool
  2875. if key == QtCore.Qt.Key_T or key == 'T':
  2876. self.app.geo_editor.select_tool('text')
  2877. # Substract Tool
  2878. if key == QtCore.Qt.Key_U or key == 'U':
  2879. if self.app.geo_editor.get_selected() is not None:
  2880. self.app.geo_editor.union()
  2881. else:
  2882. msg = _("Please select geometry items \n"
  2883. "on which to perform union.")
  2884. messagebox = QtWidgets.QMessageBox()
  2885. messagebox.setText(msg)
  2886. messagebox.setWindowTitle(_("Warning"))
  2887. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2888. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2889. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2890. messagebox.exec_()
  2891. if key == QtCore.Qt.Key_V or key == 'V':
  2892. self.app.on_zoom_fit(None)
  2893. # Flip on X axis
  2894. if key == QtCore.Qt.Key_X or key == 'X':
  2895. self.app.geo_editor.transform_tool.on_flipx()
  2896. return
  2897. # Flip on Y axis
  2898. if key == QtCore.Qt.Key_Y or key == 'Y':
  2899. self.app.geo_editor.transform_tool.on_flipy()
  2900. return
  2901. # Show Shortcut list
  2902. if key == 'F3':
  2903. self.app.on_shortcut_list()
  2904. elif self.app.call_source == 'grb_editor':
  2905. if modifiers == QtCore.Qt.ControlModifier:
  2906. # Eraser Tool
  2907. if key == QtCore.Qt.Key_E or key == 'E':
  2908. self.app.grb_editor.on_eraser()
  2909. return
  2910. # save (update) the current geometry and return to the App
  2911. if key == QtCore.Qt.Key_S or key == 'S':
  2912. self.app.editor2object()
  2913. return
  2914. # toggle the measurement tool
  2915. if key == QtCore.Qt.Key_M or key == 'M':
  2916. self.app.distance_tool.run()
  2917. return
  2918. elif modifiers == QtCore.Qt.ShiftModifier:
  2919. # Run Distance Minimum Tool
  2920. if key == QtCore.Qt.Key_M or key == 'M':
  2921. self.app.distance_min_tool.run()
  2922. return
  2923. elif modifiers == QtCore.Qt.AltModifier:
  2924. # Mark Area Tool
  2925. if key == QtCore.Qt.Key_A or key == 'A':
  2926. self.app.grb_editor.on_markarea()
  2927. return
  2928. # Poligonize Tool
  2929. if key == QtCore.Qt.Key_N or key == 'N':
  2930. self.app.grb_editor.on_poligonize()
  2931. return
  2932. # Transformation Tool
  2933. if key == QtCore.Qt.Key_R or key == 'R':
  2934. self.app.grb_editor.on_transform()
  2935. return
  2936. elif modifiers == QtCore.Qt.NoModifier:
  2937. # Abort the current action
  2938. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2939. # self.on_tool_select("select")
  2940. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  2941. self.app.grb_editor.delete_utility_geometry()
  2942. # self.app.grb_editor.plot_all()
  2943. self.app.grb_editor.active_tool.clean_up()
  2944. self.app.grb_editor.select_tool('select')
  2945. return
  2946. # Delete selected object if delete key event comes out of canvas
  2947. if key == 'Delete':
  2948. self.app.grb_editor.launched_from_shortcuts = True
  2949. if self.app.grb_editor.selected:
  2950. self.app.grb_editor.delete_selected()
  2951. self.app.grb_editor.plot_all()
  2952. else:
  2953. self.app.inform.emit('[WARNING_NOTCL] %s' %
  2954. _("Cancelled. Nothing selected to delete."))
  2955. return
  2956. # Delete aperture in apertures table if delete key event comes from the Selected Tab
  2957. if key == QtCore.Qt.Key_Delete:
  2958. self.app.grb_editor.launched_from_shortcuts = True
  2959. self.app.grb_editor.on_aperture_delete()
  2960. return
  2961. if key == QtCore.Qt.Key_Minus or key == '-':
  2962. self.app.grb_editor.launched_from_shortcuts = True
  2963. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2964. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2965. return
  2966. if key == QtCore.Qt.Key_Equal or key == '=':
  2967. self.app.grb_editor.launched_from_shortcuts = True
  2968. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2969. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2970. return
  2971. # toggle display of Notebook area
  2972. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2973. self.app.grb_editor.launched_from_shortcuts = True
  2974. self.app.on_toggle_notebook()
  2975. return
  2976. # Rotate
  2977. if key == QtCore.Qt.Key_Space or key == 'Space':
  2978. self.app.grb_editor.transform_tool.on_rotate_key()
  2979. # Switch to Project Tab
  2980. if key == QtCore.Qt.Key_1 or key == '1':
  2981. self.app.grb_editor.launched_from_shortcuts = True
  2982. self.app.on_select_tab('project')
  2983. return
  2984. # Switch to Selected Tab
  2985. if key == QtCore.Qt.Key_2 or key == '2':
  2986. self.app.grb_editor.launched_from_shortcuts = True
  2987. self.app.on_select_tab('selected')
  2988. return
  2989. # Switch to Tool Tab
  2990. if key == QtCore.Qt.Key_3 or key == '3':
  2991. self.app.grb_editor.launched_from_shortcuts = True
  2992. self.app.on_select_tab('tool')
  2993. return
  2994. # we do this so we can reuse the following keys while inside a Tool
  2995. # the above keys are general enough so were left outside
  2996. if self.app.grb_editor.active_tool is not None and self.grb_select_btn.isChecked() is False:
  2997. response = self.app.grb_editor.active_tool.on_key(key=key)
  2998. if response is not None:
  2999. self.app.inform.emit(response)
  3000. else:
  3001. # Add Array of pads
  3002. if key == QtCore.Qt.Key_A or key == 'A':
  3003. self.app.grb_editor.launched_from_shortcuts = True
  3004. self.app.inform.emit("Click on target point.")
  3005. self.app.ui.add_pad_ar_btn.setChecked(True)
  3006. self.app.grb_editor.x = self.app.mouse[0]
  3007. self.app.grb_editor.y = self.app.mouse[1]
  3008. self.app.grb_editor.select_tool('array')
  3009. return
  3010. # Scale Tool
  3011. if key == QtCore.Qt.Key_B or key == 'B':
  3012. self.app.grb_editor.launched_from_shortcuts = True
  3013. self.app.grb_editor.select_tool('buffer')
  3014. return
  3015. # Copy
  3016. if key == QtCore.Qt.Key_C or key == 'C':
  3017. self.app.grb_editor.launched_from_shortcuts = True
  3018. if self.app.grb_editor.selected:
  3019. self.app.inform.emit(_("Click on target point."))
  3020. self.app.ui.aperture_copy_btn.setChecked(True)
  3021. self.app.grb_editor.on_tool_select('copy')
  3022. self.app.grb_editor.active_tool.set_origin(
  3023. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  3024. else:
  3025. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3026. _("Cancelled. Nothing selected to copy."))
  3027. return
  3028. # Add Disc Tool
  3029. if key == QtCore.Qt.Key_D or key == 'D':
  3030. self.app.grb_editor.launched_from_shortcuts = True
  3031. self.app.grb_editor.select_tool('disc')
  3032. return
  3033. # Add SemiDisc Tool
  3034. if key == QtCore.Qt.Key_E or key == 'E':
  3035. self.app.grb_editor.launched_from_shortcuts = True
  3036. self.app.grb_editor.select_tool('semidisc')
  3037. return
  3038. # Grid Snap
  3039. if key == QtCore.Qt.Key_G or key == 'G':
  3040. self.app.grb_editor.launched_from_shortcuts = True
  3041. # make sure that the cursor shape is enabled/disabled, too
  3042. if self.app.grb_editor.options['grid_snap'] is True:
  3043. self.app.app_cursor.enabled = False
  3044. else:
  3045. self.app.app_cursor.enabled = True
  3046. self.app.ui.grid_snap_btn.trigger()
  3047. return
  3048. # Jump to coords
  3049. if key == QtCore.Qt.Key_J or key == 'J':
  3050. self.app.on_jump_to()
  3051. # Corner Snap
  3052. if key == QtCore.Qt.Key_K or key == 'K':
  3053. self.app.grb_editor.launched_from_shortcuts = True
  3054. self.app.ui.corner_snap_btn.trigger()
  3055. return
  3056. # Move
  3057. if key == QtCore.Qt.Key_M or key == 'M':
  3058. self.app.grb_editor.launched_from_shortcuts = True
  3059. if self.app.grb_editor.selected:
  3060. self.app.inform.emit(_("Click on target point."))
  3061. self.app.ui.aperture_move_btn.setChecked(True)
  3062. self.app.grb_editor.on_tool_select('move')
  3063. self.app.grb_editor.active_tool.set_origin(
  3064. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  3065. else:
  3066. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3067. _("Cancelled. Nothing selected to move."))
  3068. return
  3069. # Add Region Tool
  3070. if key == QtCore.Qt.Key_N or key == 'N':
  3071. self.app.grb_editor.launched_from_shortcuts = True
  3072. self.app.grb_editor.select_tool('region')
  3073. return
  3074. # Add Pad Tool
  3075. if key == QtCore.Qt.Key_P or key == 'P':
  3076. self.app.grb_editor.launched_from_shortcuts = True
  3077. self.app.inform.emit(_("Click on target point."))
  3078. self.app.ui.add_pad_ar_btn.setChecked(True)
  3079. self.app.grb_editor.x = self.app.mouse[0]
  3080. self.app.grb_editor.y = self.app.mouse[1]
  3081. self.app.grb_editor.select_tool('pad')
  3082. return
  3083. # Scale Tool
  3084. if key == QtCore.Qt.Key_S or key == 'S':
  3085. self.app.grb_editor.launched_from_shortcuts = True
  3086. self.app.grb_editor.select_tool('scale')
  3087. return
  3088. # Add Track
  3089. if key == QtCore.Qt.Key_T or key == 'T':
  3090. self.app.grb_editor.launched_from_shortcuts = True
  3091. # ## Current application units in Upper Case
  3092. self.app.grb_editor.select_tool('track')
  3093. return
  3094. # Zoom Fit
  3095. if key == QtCore.Qt.Key_V or key == 'V':
  3096. self.app.grb_editor.launched_from_shortcuts = True
  3097. self.app.on_zoom_fit(None)
  3098. return
  3099. # Show Shortcut list
  3100. if key == QtCore.Qt.Key_F3 or key == 'F3':
  3101. self.app.on_shortcut_list()
  3102. return
  3103. elif self.app.call_source == 'exc_editor':
  3104. if modifiers == QtCore.Qt.ControlModifier:
  3105. # save (update) the current geometry and return to the App
  3106. if key == QtCore.Qt.Key_S or key == 'S':
  3107. self.app.editor2object()
  3108. return
  3109. # toggle the measurement tool
  3110. if key == QtCore.Qt.Key_M or key == 'M':
  3111. self.app.distance_tool.run()
  3112. return
  3113. elif modifiers == QtCore.Qt.ShiftModifier:
  3114. # Run Distance Minimum Tool
  3115. if key == QtCore.Qt.Key_M or key == 'M':
  3116. self.app.distance_min_tool.run()
  3117. return
  3118. elif modifiers == QtCore.Qt.AltModifier:
  3119. pass
  3120. elif modifiers == QtCore.Qt.NoModifier:
  3121. # Abort the current action
  3122. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3123. # TODO: ...?
  3124. # self.on_tool_select("select")
  3125. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  3126. self.app.exc_editor.delete_utility_geometry()
  3127. self.app.exc_editor.replot()
  3128. # self.select_btn.setChecked(True)
  3129. # self.on_tool_select('select')
  3130. self.app.exc_editor.select_tool('drill_select')
  3131. return
  3132. # Delete selected object if delete key event comes out of canvas
  3133. if key == 'Delete':
  3134. self.app.exc_editor.launched_from_shortcuts = True
  3135. if self.app.exc_editor.selected:
  3136. self.app.exc_editor.delete_selected()
  3137. self.app.exc_editor.replot()
  3138. else:
  3139. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3140. _("Cancelled. Nothing selected to delete."))
  3141. return
  3142. # Delete tools in tools table if delete key event comes from the Selected Tab
  3143. if key == QtCore.Qt.Key_Delete:
  3144. self.app.exc_editor.launched_from_shortcuts = True
  3145. self.app.exc_editor.on_tool_delete()
  3146. return
  3147. if key == QtCore.Qt.Key_Minus or key == '-':
  3148. self.app.exc_editor.launched_from_shortcuts = True
  3149. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  3150. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  3151. return
  3152. if key == QtCore.Qt.Key_Equal or key == '=':
  3153. self.app.exc_editor.launched_from_shortcuts = True
  3154. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  3155. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  3156. return
  3157. # toggle display of Notebook area
  3158. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  3159. self.app.exc_editor.launched_from_shortcuts = True
  3160. self.app.on_toggle_notebook()
  3161. return
  3162. # Switch to Project Tab
  3163. if key == QtCore.Qt.Key_1 or key == '1':
  3164. self.app.exc_editor.launched_from_shortcuts = True
  3165. self.app.on_select_tab('project')
  3166. return
  3167. # Switch to Selected Tab
  3168. if key == QtCore.Qt.Key_2 or key == '2':
  3169. self.app.exc_editor.launched_from_shortcuts = True
  3170. self.app.on_select_tab('selected')
  3171. return
  3172. # Switch to Tool Tab
  3173. if key == QtCore.Qt.Key_3 or key == '3':
  3174. self.app.exc_editor.launched_from_shortcuts = True
  3175. self.app.on_select_tab('tool')
  3176. return
  3177. # Add Array of Drill Hole Tool
  3178. if key == QtCore.Qt.Key_A or key == 'A':
  3179. self.app.exc_editor.launched_from_shortcuts = True
  3180. self.app.inform.emit("Click on target point.")
  3181. self.app.ui.add_drill_array_btn.setChecked(True)
  3182. self.app.exc_editor.x = self.app.mouse[0]
  3183. self.app.exc_editor.y = self.app.mouse[1]
  3184. self.app.exc_editor.select_tool('drill_array')
  3185. return
  3186. # Copy
  3187. if key == QtCore.Qt.Key_C or key == 'C':
  3188. self.app.exc_editor.launched_from_shortcuts = True
  3189. if self.app.exc_editor.selected:
  3190. self.app.inform.emit(_("Click on target point."))
  3191. self.app.ui.copy_drill_btn.setChecked(True)
  3192. self.app.exc_editor.on_tool_select('drill_copy')
  3193. self.app.exc_editor.active_tool.set_origin(
  3194. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  3195. else:
  3196. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3197. _("Cancelled. Nothing selected to copy."))
  3198. return
  3199. # Add Drill Hole Tool
  3200. if key == QtCore.Qt.Key_D or key == 'D':
  3201. self.app.exc_editor.launched_from_shortcuts = True
  3202. self.app.inform.emit(_("Click on target point."))
  3203. self.app.ui.add_drill_btn.setChecked(True)
  3204. self.app.exc_editor.x = self.app.mouse[0]
  3205. self.app.exc_editor.y = self.app.mouse[1]
  3206. self.app.exc_editor.select_tool('drill_add')
  3207. return
  3208. # Grid Snap
  3209. if key == QtCore.Qt.Key_G or key == 'G':
  3210. self.app.exc_editor.launched_from_shortcuts = True
  3211. # make sure that the cursor shape is enabled/disabled, too
  3212. if self.app.exc_editor.options['grid_snap'] is True:
  3213. self.app.app_cursor.enabled = False
  3214. else:
  3215. self.app.app_cursor.enabled = True
  3216. self.app.ui.grid_snap_btn.trigger()
  3217. return
  3218. # Jump to coords
  3219. if key == QtCore.Qt.Key_J or key == 'J':
  3220. self.app.on_jump_to()
  3221. # Corner Snap
  3222. if key == QtCore.Qt.Key_K or key == 'K':
  3223. self.app.exc_editor.launched_from_shortcuts = True
  3224. self.app.ui.corner_snap_btn.trigger()
  3225. return
  3226. # Move
  3227. if key == QtCore.Qt.Key_M or key == 'M':
  3228. self.app.exc_editor.launched_from_shortcuts = True
  3229. if self.app.exc_editor.selected:
  3230. self.app.inform.emit(_("Click on target point."))
  3231. self.app.ui.move_drill_btn.setChecked(True)
  3232. self.app.exc_editor.on_tool_select('drill_move')
  3233. self.app.exc_editor.active_tool.set_origin(
  3234. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  3235. else:
  3236. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3237. _("Cancelled. Nothing selected to move."))
  3238. return
  3239. # Add Array of Slote Hole Tool
  3240. if key == QtCore.Qt.Key_Q or key == 'Q':
  3241. self.app.exc_editor.launched_from_shortcuts = True
  3242. self.app.inform.emit("Click on target point.")
  3243. self.app.ui.add_slot_array_btn.setChecked(True)
  3244. self.app.exc_editor.x = self.app.mouse[0]
  3245. self.app.exc_editor.y = self.app.mouse[1]
  3246. self.app.exc_editor.select_tool('slot_array')
  3247. return
  3248. # Resize Tool
  3249. if key == QtCore.Qt.Key_R or key == 'R':
  3250. self.app.exc_editor.launched_from_shortcuts = True
  3251. self.app.exc_editor.select_tool('drill_resize')
  3252. return
  3253. # Add Tool
  3254. if key == QtCore.Qt.Key_T or key == 'T':
  3255. self.app.exc_editor.launched_from_shortcuts = True
  3256. # ## Current application units in Upper Case
  3257. self.units = self.general_defaults_form.general_app_group.units_radio.get_value().upper()
  3258. tool_add_popup = FCInputDialog(title=_("New Tool ..."),
  3259. text='%s:' % _('Enter a Tool Diameter'),
  3260. min=0.0000, max=99.9999, decimals=4)
  3261. tool_add_popup.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/letter_t_32.png'))
  3262. val, ok = tool_add_popup.get_value()
  3263. if ok:
  3264. self.app.exc_editor.on_tool_add(tooldia=val)
  3265. formated_val = '%.*f' % (self.decimals, float(val))
  3266. self.app.inform.emit(
  3267. '[success] %s: %s %s' % (_("Added new tool with dia"), formated_val, str(self.units))
  3268. )
  3269. else:
  3270. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Adding Tool cancelled ..."))
  3271. return
  3272. # Zoom Fit
  3273. if key == QtCore.Qt.Key_V or key == 'V':
  3274. self.app.exc_editor.launched_from_shortcuts = True
  3275. self.app.on_zoom_fit(None)
  3276. return
  3277. # Add Slot Hole Tool
  3278. if key == QtCore.Qt.Key_W or key == 'W':
  3279. self.app.exc_editor.launched_from_shortcuts = True
  3280. self.app.inform.emit(_("Click on target point."))
  3281. self.app.ui.add_slot_btn.setChecked(True)
  3282. self.app.exc_editor.x = self.app.mouse[0]
  3283. self.app.exc_editor.y = self.app.mouse[1]
  3284. self.app.exc_editor.select_tool('slot_add')
  3285. return
  3286. # Propagate to tool
  3287. response = None
  3288. if self.app.exc_editor.active_tool is not None:
  3289. response = self.app.exc_editor.active_tool.on_key(key=key)
  3290. if response is not None:
  3291. self.app.inform.emit(response)
  3292. # Show Shortcut list
  3293. if key == QtCore.Qt.Key_F3 or key == 'F3':
  3294. self.app.on_shortcut_list()
  3295. return
  3296. elif self.app.call_source == 'measurement':
  3297. if modifiers == QtCore.Qt.ControlModifier:
  3298. pass
  3299. elif modifiers == QtCore.Qt.AltModifier:
  3300. pass
  3301. elif modifiers == QtCore.Qt.ShiftModifier:
  3302. pass
  3303. elif modifiers == QtCore.Qt.NoModifier:
  3304. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3305. # abort the measurement action
  3306. self.app.distance_tool.deactivate_measure_tool()
  3307. self.app.inform.emit(_("Distance Tool exit..."))
  3308. return
  3309. if key == QtCore.Qt.Key_G or key == 'G':
  3310. self.app.ui.grid_snap_btn.trigger()
  3311. return
  3312. # Jump to coords
  3313. if key == QtCore.Qt.Key_J or key == 'J':
  3314. self.app.on_jump_to()
  3315. elif self.app.call_source == 'qrcode_tool':
  3316. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  3317. if key == QtCore.Qt.Key_X:
  3318. self.app.abort_all_tasks()
  3319. return
  3320. elif modifiers == QtCore.Qt.ControlModifier:
  3321. pass
  3322. elif modifiers == QtCore.Qt.ShiftModifier:
  3323. pass
  3324. elif modifiers == QtCore.Qt.AltModifier:
  3325. pass
  3326. elif modifiers == QtCore.Qt.NoModifier:
  3327. # Escape = Deselect All
  3328. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3329. self.app.qrcode_tool.on_exit()
  3330. # Grid toggle
  3331. if key == QtCore.Qt.Key_G:
  3332. self.app.ui.grid_snap_btn.trigger()
  3333. # Jump to coords
  3334. if key == QtCore.Qt.Key_J:
  3335. self.app.on_jump_to()
  3336. elif self.app.call_source == 'copper_thieving_tool':
  3337. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  3338. if key == QtCore.Qt.Key_X:
  3339. self.app.abort_all_tasks()
  3340. return
  3341. elif modifiers == QtCore.Qt.ControlModifier:
  3342. pass
  3343. elif modifiers == QtCore.Qt.ShiftModifier:
  3344. pass
  3345. elif modifiers == QtCore.Qt.AltModifier:
  3346. pass
  3347. elif modifiers == QtCore.Qt.NoModifier:
  3348. # Escape = Deselect All
  3349. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3350. self.app.copperfill_tool.on_exit()
  3351. # Grid toggle
  3352. if key == QtCore.Qt.Key_G:
  3353. self.app.ui.grid_snap_btn.trigger()
  3354. # Jump to coords
  3355. if key == QtCore.Qt.Key_J:
  3356. self.app.on_jump_to()
  3357. def createPopupMenu(self):
  3358. menu = super().createPopupMenu()
  3359. menu.addSeparator()
  3360. menu.addAction(self.lock_action)
  3361. return menu
  3362. def lock_toolbar(self, lock=False):
  3363. """
  3364. Used to (un)lock the toolbars of the app.
  3365. :param lock: boolean, will lock all toolbars in place when set True
  3366. :return: None
  3367. """
  3368. if lock:
  3369. for widget in self.children():
  3370. if isinstance(widget, QtWidgets.QToolBar):
  3371. widget.setMovable(False)
  3372. else:
  3373. for widget in self.children():
  3374. if isinstance(widget, QtWidgets.QToolBar):
  3375. widget.setMovable(True)
  3376. def dragEnterEvent(self, event):
  3377. if event.mimeData().hasUrls:
  3378. event.accept()
  3379. else:
  3380. event.ignore()
  3381. def dragMoveEvent(self, event):
  3382. if event.mimeData().hasUrls:
  3383. event.accept()
  3384. else:
  3385. event.ignore()
  3386. def dropEvent(self, event):
  3387. if event.mimeData().hasUrls:
  3388. event.setDropAction(QtCore.Qt.CopyAction)
  3389. event.accept()
  3390. for url in event.mimeData().urls():
  3391. self.filename = str(url.toLocalFile())
  3392. if self.filename == "":
  3393. self.app.inform.emit("Open cancelled.")
  3394. else:
  3395. extension = self.filename.lower().rpartition('.')[-1]
  3396. if extension in self.app.grb_list:
  3397. self.app.worker_task.emit({'fcn': self.app.open_gerber,
  3398. 'params': [self.filename]})
  3399. else:
  3400. event.ignore()
  3401. if extension in self.app.exc_list:
  3402. self.app.worker_task.emit({'fcn': self.app.open_excellon,
  3403. 'params': [self.filename]})
  3404. else:
  3405. event.ignore()
  3406. if extension in self.app.gcode_list:
  3407. self.app.worker_task.emit({'fcn': self.app.open_gcode,
  3408. 'params': [self.filename]})
  3409. else:
  3410. event.ignore()
  3411. if extension in self.app.svg_list:
  3412. object_type = 'geometry'
  3413. self.app.worker_task.emit({'fcn': self.app.import_svg,
  3414. 'params': [self.filename, object_type, None]})
  3415. if extension in self.app.dxf_list:
  3416. object_type = 'geometry'
  3417. self.app.worker_task.emit({'fcn': self.app.import_dxf,
  3418. 'params': [self.filename, object_type, None]})
  3419. if extension in self.app.pdf_list:
  3420. self.app.pdf_tool.periodic_check(1000)
  3421. self.app.worker_task.emit({'fcn': self.app.pdf_tool.open_pdf,
  3422. 'params': [self.filename]})
  3423. if extension in self.app.prj_list:
  3424. # self.app.open_project() is not Thread Safe
  3425. self.app.open_project(self.filename)
  3426. if extension in self.app.conf_list:
  3427. self.app.open_config_file(self.filename)
  3428. else:
  3429. event.ignore()
  3430. else:
  3431. event.ignore()
  3432. def closeEvent(self, event):
  3433. if self.app.save_in_progress:
  3434. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3435. _("Application is saving the project. Please wait ..."))
  3436. else:
  3437. grect = self.geometry()
  3438. # self.splitter.sizes()[0] is actually the size of the "notebook"
  3439. if not self.isMaximized():
  3440. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  3441. self.final_save.emit()
  3442. event.ignore()
  3443. class FlatCAMActivityView(QtWidgets.QWidget):
  3444. """
  3445. This class create and control the activity icon displayed in the App status bar
  3446. """
  3447. def __init__(self, app, parent=None):
  3448. super().__init__(parent=parent)
  3449. self.app = app
  3450. if self.app.defaults["global_activity_icon"] == "Ball green":
  3451. icon = self.app.resource_location + '/active_2_static.png'
  3452. movie = self.app.resource_location + "/active_2.gif"
  3453. elif self.app.defaults["global_activity_icon"] == "Ball black":
  3454. icon = self.app.resource_location + '/active_static.png'
  3455. movie = self.app.resource_location + "/active.gif"
  3456. elif self.app.defaults["global_activity_icon"] == "Arrow green":
  3457. icon = self.app.resource_location + '/active_3_static.png'
  3458. movie = self.app.resource_location + "/active_3.gif"
  3459. elif self.app.defaults["global_activity_icon"] == "Eclipse green":
  3460. icon = self.app.resource_location + '/active_4_static.png'
  3461. movie = self.app.resource_location + "/active_4.gif"
  3462. else:
  3463. icon = self.app.resource_location + '/active_static.png'
  3464. movie = self.app.resource_location + "/active.gif"
  3465. self.setMinimumWidth(200)
  3466. self.movie_path = movie
  3467. self.icon_path = icon
  3468. self.icon = QtWidgets.QLabel(self)
  3469. self.icon.setGeometry(0, 0, 16, 12)
  3470. self.movie = QtGui.QMovie(self.movie_path)
  3471. self.icon.setMovie(self.movie)
  3472. # self.movie.start()
  3473. layout = QtWidgets.QHBoxLayout()
  3474. layout.setContentsMargins(5, 0, 5, 0)
  3475. layout.setAlignment(QtCore.Qt.AlignLeft)
  3476. self.setLayout(layout)
  3477. layout.addWidget(self.icon)
  3478. self.text = QtWidgets.QLabel(self)
  3479. self.text.setText(_("Idle."))
  3480. self.icon.setPixmap(QtGui.QPixmap(self.icon_path))
  3481. layout.addWidget(self.text)
  3482. def set_idle(self):
  3483. self.movie.stop()
  3484. self.text.setText(_("Idle."))
  3485. def set_busy(self, msg, no_movie=None):
  3486. if no_movie is not True:
  3487. self.icon.setMovie(self.movie)
  3488. self.movie.start()
  3489. self.text.setText(msg)
  3490. class FlatCAMInfoBar(QtWidgets.QWidget):
  3491. """
  3492. This class create a place to display the App messages in the Status Bar
  3493. """
  3494. def __init__(self, parent=None, app=None):
  3495. super(FlatCAMInfoBar, self).__init__(parent=parent)
  3496. self.app = app
  3497. self.icon = QtWidgets.QLabel(self)
  3498. self.icon.setGeometry(0, 0, 12, 12)
  3499. self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png')
  3500. self.icon.setPixmap(self.pmap)
  3501. layout = QtWidgets.QHBoxLayout()
  3502. layout.setContentsMargins(5, 0, 5, 0)
  3503. self.setLayout(layout)
  3504. layout.addWidget(self.icon)
  3505. self.text = QtWidgets.QLabel(self)
  3506. self.text.setText(_("Application started ..."))
  3507. self.text.setToolTip(_("Hello!"))
  3508. layout.addWidget(self.text)
  3509. layout.addStretch()
  3510. def set_text_(self, text, color=None):
  3511. self.text.setText(text)
  3512. self.text.setToolTip(text)
  3513. if color:
  3514. self.text.setStyleSheet('color: %s' % str(color))
  3515. def set_status(self, text, level="info"):
  3516. level = str(level)
  3517. self.pmap.fill()
  3518. if level == "ERROR" or level == "ERROR_NOTCL":
  3519. self.pmap = QtGui.QPixmap(self.app.resource_location + '/redlight12.png')
  3520. elif level == "success" or level == "SUCCESS":
  3521. self.pmap = QtGui.QPixmap(self.app.resource_location + '/greenlight12.png')
  3522. elif level == "WARNING" or level == "WARNING_NOTCL":
  3523. self.pmap = QtGui.QPixmap(self.app.resource_location + '/yellowlight12.png')
  3524. elif level == "selected" or level == "SELECTED":
  3525. self.pmap = QtGui.QPixmap(self.app.resource_location + '/bluelight12.png')
  3526. else:
  3527. self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png')
  3528. self.set_text_(text)
  3529. self.icon.setPixmap(self.pmap)
  3530. class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon):
  3531. """
  3532. This class create the Sys Tray icon for the app
  3533. """
  3534. def __init__(self, app, icon, headless=None, parent=None):
  3535. # QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
  3536. super().__init__(icon, parent=parent)
  3537. self.app = app
  3538. menu = QtWidgets.QMenu(parent)
  3539. menu_runscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/script14.png'),
  3540. '%s' % _('Run Script ...'), self)
  3541. menu_runscript.setToolTip(
  3542. _("Will run the opened Tcl Script thus\n"
  3543. "enabling the automation of certain\n"
  3544. "functions of FlatCAM.")
  3545. )
  3546. menu.addAction(menu_runscript)
  3547. menu.addSeparator()
  3548. if headless is None:
  3549. self.menu_open = menu.addMenu(QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'), _('Open'))
  3550. # Open Project ...
  3551. menu_openproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/folder16.png'),
  3552. _('Open Project ...'), self)
  3553. self.menu_open.addAction(menu_openproject)
  3554. self.menu_open.addSeparator()
  3555. # Open Gerber ...
  3556. menu_opengerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/flatcam_icon24.png'),
  3557. _('Open &Gerber ...\tCTRL+G'), self)
  3558. self.menu_open.addAction(menu_opengerber)
  3559. # Open Excellon ...
  3560. menu_openexcellon = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'),
  3561. _('Open &Excellon ...\tCTRL+E'), self)
  3562. self.menu_open.addAction(menu_openexcellon)
  3563. # Open G-Code ...
  3564. menu_opengcode = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/code.png'),
  3565. _('Open G-&Code ...'), self)
  3566. self.menu_open.addAction(menu_opengcode)
  3567. self.menu_open.addSeparator()
  3568. menu_openproject.triggered.connect(self.app.on_file_openproject)
  3569. menu_opengerber.triggered.connect(self.app.on_fileopengerber)
  3570. menu_openexcellon.triggered.connect(self.app.on_fileopenexcellon)
  3571. menu_opengcode.triggered.connect(self.app.on_fileopengcode)
  3572. exitAction = menu.addAction(_("Exit"))
  3573. exitAction.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png'))
  3574. self.setContextMenu(menu)
  3575. menu_runscript.triggered.connect(lambda: self.app.on_filerunscript(
  3576. silent=True if self.app.cmd_line_headless == 1 else False))
  3577. exitAction.triggered.connect(self.app.final_save)
  3578. # end of file