FlatCAMGUI.py 197 KB

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