| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373 |
- # ##########################################################
- # FlatCAM: 2D Post-processing for Manufacturing #
- # http://flatcam.org #
- # Author: Juan Pablo Caram (c) #
- # Date: 2/5/2014 #
- # MIT Licence #
- # ##########################################################
- # ##########################################################
- # File Modified (major mod): Marius Adrian Stanciu #
- # Date: 3/10/2019 #
- # ##########################################################
- from flatcamGUI.PreferencesUI import *
- from flatcamEditors.FlatCAMGeoEditor import FCShapeTool
- from matplotlib.backend_bases import KeyEvent as mpl_key_event
- import webbrowser
- from flatcamObjects.ObjectCollection import KeySensitiveListView
- import subprocess
- import os
- import gettext
- import FlatCAMTranslation as fcTranslate
- import builtins
- fcTranslate.apply_language('strings')
- if '_' not in builtins.__dict__:
- _ = gettext.gettext
- class FlatCAMGUI(QtWidgets.QMainWindow):
- # Emitted when persistent window geometry needs to be retained
- geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
- final_save = QtCore.pyqtSignal(name='saveBeforeExit')
- def __init__(self, app):
- super(FlatCAMGUI, self).__init__()
- self.app = app
- self.decimals = self.app.decimals
- # Divine icon pack by Ipapun @ finicons.com
- # #######################################################################
- # ############ BUILDING THE GUI IS EXECUTED HERE ########################
- # #######################################################################
- # #######################################################################
- # ####################### TCL Shell DOCK ################################
- # #######################################################################
- self.shell_dock = QtWidgets.QDockWidget("FlatCAM TCL Shell")
- self.shell_dock.setObjectName('Shell_DockWidget')
- self.shell_dock.setAllowedAreas(QtCore.Qt.AllDockWidgetAreas)
- self.shell_dock.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
- QtWidgets.QDockWidget.DockWidgetFloatable |
- QtWidgets.QDockWidget.DockWidgetClosable)
- self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.shell_dock)
- # #######################################################################
- # ###################### Menu BUILDING ##################################
- # #######################################################################
- self.menu = self.menuBar()
- self.menu_toggle_nb = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/notebook32.png'), _("Toggle Panel"))
- self.menu_toggle_nb.setToolTip(
- _("Toggle Panel")
- )
- # self.menu_toggle_nb = QtWidgets.QAction("NB")
- self.menu_toggle_nb.setCheckable(True)
- self.menu.addAction(self.menu_toggle_nb)
- # ########################################################################
- # ########################## File # ######################################
- # ########################################################################
- self.menufile = self.menu.addMenu(_('File'))
- self.menufile.setToolTipsVisible(True)
- # New Project
- self.menufilenewproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/file16.png'),
- _('&New Project ...\tCtrl+N'), self)
- self.menufilenewproject.setToolTip(
- _("Will create a new, blank project")
- )
- self.menufile.addAction(self.menufilenewproject)
- # New Category (Excellon, Geometry)
- self.menufilenew = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/file16.png'), _('&New'))
- self.menufilenew.setToolTipsVisible(True)
- self.menufilenewgeo = self.menufilenew.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_file_geo16.png'), _('Geometry\tN'))
- self.menufilenewgeo.setToolTip(
- _("Will create a new, empty Geometry Object.")
- )
- self.menufilenewgrb = self.menufilenew.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_file_grb16.png'), _('Gerber\tB'))
- self.menufilenewgrb.setToolTip(
- _("Will create a new, empty Gerber Object.")
- )
- self.menufilenewexc = self.menufilenew.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_file_exc16.png'), _('Excellon\tL'))
- self.menufilenewexc.setToolTip(
- _("Will create a new, empty Excellon Object.")
- )
- self.menufilenew.addSeparator()
- self.menufilenewdoc = self.menufilenew.addAction(
- QtGui.QIcon(self.app.resource_location + '/notes16_1.png'), _('Document\tD'))
- self.menufilenewdoc.setToolTip(
- _("Will create a new, empty Document Object.")
- )
- self.menufile_open = self.menufile.addMenu(
- QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'), _('Open'))
- self.menufile_open.setToolTipsVisible(True)
- # Open Project ...
- self.menufileopenproject = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open &Project ...'), self)
- self.menufile_open.addAction(self.menufileopenproject)
- self.menufile_open.addSeparator()
- # Open Gerber ...
- self.menufileopengerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/flatcam_icon24.png'),
- _('Open &Gerber ...\tCtrl+G'), self)
- self.menufile_open.addAction(self.menufileopengerber)
- # Open Excellon ...
- self.menufileopenexcellon = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'),
- _('Open &Excellon ...\tCtrl+E'), self)
- self.menufile_open.addAction(self.menufileopenexcellon)
- # Open G-Code ...
- self.menufileopengcode = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/code.png'), _('Open G-&Code ...'), self)
- self.menufile_open.addAction(self.menufileopengcode)
- self.menufile_open.addSeparator()
- # Open Config File...
- self.menufileopenconfig = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open Config ...'), self)
- self.menufile_open.addAction(self.menufileopenconfig)
- # Recent
- self.recent_projects = self.menufile.addMenu(
- QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent projects"))
- self.recent = self.menufile.addMenu(
- QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent files"))
- # SAVE category
- self.menufile_save = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/save_as.png'), _('Save'))
- # Save Project
- self.menufilesaveproject = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/floppy16.png'), _('&Save Project ...\tCtrl+S'), self)
- self.menufile_save.addAction(self.menufilesaveproject)
- # Save Project As ...
- self.menufilesaveprojectas = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/floppy16.png'), _('Save Project &As ...\tCtrl+Shift+S'), self)
- self.menufile_save.addAction(self.menufilesaveprojectas)
- # Save Project Copy ...
- # self.menufilesaveprojectcopy = QtWidgets.QAction(
- # QtGui.QIcon(self.app.resource_location + '/floppy16.png'), _('Save Project C&opy ...'), self)
- # self.menufile_save.addAction(self.menufilesaveprojectcopy)
- self.menufile_save.addSeparator()
- # Separator
- self.menufile.addSeparator()
- # Scripting
- self.menufile_scripting = self.menufile.addMenu(
- QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Scripting'))
- self.menufile_scripting.setToolTipsVisible(True)
- self.menufilenewscript = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/script_new16.png'), _('New Script ...'), self)
- self.menufileopenscript = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'), self)
- self.menufileopenscriptexample = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Example ...'), self)
- self.menufilerunscript = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/script16.png'), '%s\tShift+S' % _('Run Script ...'), self)
- self.menufilerunscript.setToolTip(
- _("Will run the opened Tcl Script thus\n"
- "enabling the automation of certain\n"
- "functions of FlatCAM.")
- )
- self.menufile_scripting.addAction(self.menufilenewscript)
- self.menufile_scripting.addAction(self.menufileopenscript)
- self.menufile_scripting.addAction(self.menufileopenscriptexample)
- self.menufile_scripting.addSeparator()
- self.menufile_scripting.addAction(self.menufilerunscript)
- # Separator
- self.menufile.addSeparator()
- # Import ...
- self.menufileimport = self.menufile.addMenu(
- QtGui.QIcon(self.app.resource_location + '/import.png'), _('Import'))
- self.menufileimportsvg = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/svg16.png'), _('&SVG as Geometry Object ...'), self)
- self.menufileimport.addAction(self.menufileimportsvg)
- self.menufileimportsvg_as_gerber = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/svg16.png'), _('&SVG as Gerber Object ...'), self)
- self.menufileimport.addAction(self.menufileimportsvg_as_gerber)
- self.menufileimport.addSeparator()
- self.menufileimportdxf = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/dxf16.png'), _('&DXF as Geometry Object ...'), self)
- self.menufileimport.addAction(self.menufileimportdxf)
- self.menufileimportdxf_as_gerber = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/dxf16.png'), _('&DXF as Gerber Object ...'), self)
- self.menufileimport.addAction(self.menufileimportdxf_as_gerber)
- self.menufileimport.addSeparator()
- self.menufileimport_hpgl2_as_geo = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/dxf16.png'), _('HPGL2 as Geometry Object ...'), self)
- self.menufileimport.addAction(self.menufileimport_hpgl2_as_geo)
- self.menufileimport.addSeparator()
- # Export ...
- self.menufileexport = self.menufile.addMenu(
- QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export'))
- self.menufileexport.setToolTipsVisible(True)
- self.menufileexportsvg = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export &SVG ...'), self)
- self.menufileexport.addAction(self.menufileexportsvg)
- self.menufileexportdxf = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export DXF ...'), self)
- self.menufileexport.addAction(self.menufileexportdxf)
- self.menufileexport.addSeparator()
- self.menufileexportpng = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/export_png32.png'), _('Export &PNG ...'), self)
- self.menufileexportpng.setToolTip(
- _("Will export an image in PNG format,\n"
- "the saved image will contain the visual \n"
- "information currently in FlatCAM Plot Area.")
- )
- self.menufileexport.addAction(self.menufileexportpng)
- self.menufileexport.addSeparator()
- self.menufileexportexcellon = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/drill32.png'), _('Export &Excellon ...'), self)
- self.menufileexportexcellon.setToolTip(
- _("Will export an Excellon Object as Excellon file,\n"
- "the coordinates format, the file units and zeros\n"
- "are set in Preferences -> Excellon Export.")
- )
- self.menufileexport.addAction(self.menufileexportexcellon)
- self.menufileexportgerber = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _('Export &Gerber ...'), self)
- self.menufileexportgerber.setToolTip(
- _("Will export an Gerber Object as Gerber file,\n"
- "the coordinates format, the file units and zeros\n"
- "are set in Preferences -> Gerber Export.")
- )
- self.menufileexport.addAction(self.menufileexportgerber)
- # Separator
- self.menufile.addSeparator()
- self.menufile_backup = self.menufile.addMenu(
- QtGui.QIcon(self.app.resource_location + '/backup24.png'), _('Backup'))
- # Import Preferences
- self.menufileimportpref = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/backup_import24.png'),
- _('Import Preferences from file ...'), self
- )
- self.menufile_backup.addAction(self.menufileimportpref)
- # Export Preferences
- self.menufileexportpref = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/backup_export24.png'), _('Export Preferences to file ...'), self)
- self.menufile_backup.addAction(self.menufileexportpref)
- # Separator
- self.menufile_backup.addSeparator()
- # Save Defaults
- self.menufilesavedefaults = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/defaults.png'), _('Save Preferences'), self)
- self.menufile_backup.addAction(self.menufilesavedefaults)
- # Separator
- self.menufile.addSeparator()
- self.menufile_print = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/printer32.png'), '%s\tCtrl+P' % _('Print (PDF)'))
- self.menufile.addAction(self.menufile_print)
- # Separator
- self.menufile.addSeparator()
- # Quit
- self.menufile_exit = QtWidgets.QAction(
- QtGui.QIcon(self.app.resource_location + '/power16.png'), _('E&xit'), self)
- # exitAction.setShortcut('Ctrl+Q')
- # exitAction.setStatusTip('Exit application')
- self.menufile.addAction(self.menufile_exit)
- # ########################################################################
- # ########################## Edit # ######################################
- # ########################################################################
- self.menuedit = self.menu.addMenu(_('Edit'))
- # Separator
- self.menuedit.addSeparator()
- self.menueditedit = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/edit16.png'), _('Edit Object\tE'))
- self.menueditok = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/edit_ok16.png'), _('Close Editor\tCtrl+S'))
- # adjust the initial state of the menu entries related to the editor
- self.menueditedit.setDisabled(False)
- self.menueditok.setDisabled(True)
- # Separator
- self.menuedit.addSeparator()
- self.menuedit_convert = self.menuedit.addMenu(
- QtGui.QIcon(self.app.resource_location + '/convert24.png'), _('Conversion'))
- self.menuedit_convertjoin = self.menuedit_convert.addAction(
- QtGui.QIcon(self.app.resource_location + '/join16.png'), _('&Join Geo/Gerber/Exc -> Geo'))
- self.menuedit_convertjoin.setToolTip(
- _("Merge a selection of objects, which can be of type:\n"
- "- Gerber\n"
- "- Excellon\n"
- "- Geometry\n"
- "into a new combo Geometry object.")
- )
- self.menuedit_convertjoinexc = self.menuedit_convert.addAction(
- QtGui.QIcon(self.app.resource_location + '/join16.png'), _('Join Excellon(s) -> Excellon'))
- self.menuedit_convertjoinexc.setToolTip(
- _("Merge a selection of Excellon objects into a new combo Excellon object.")
- )
- self.menuedit_convertjoingrb = self.menuedit_convert.addAction(
- QtGui.QIcon(self.app.resource_location + '/join16.png'), _('Join Gerber(s) -> Gerber'))
- self.menuedit_convertjoingrb.setToolTip(
- _("Merge a selection of Gerber objects into a new combo Gerber object.")
- )
- # Separator
- self.menuedit_convert.addSeparator()
- self.menuedit_convert_sg2mg = self.menuedit_convert.addAction(
- QtGui.QIcon(self.app.resource_location + '/convert24.png'), _('Convert Single to MultiGeo'))
- self.menuedit_convert_sg2mg.setToolTip(
- _("Will convert a Geometry object from single_geometry type\n"
- "to a multi_geometry type.")
- )
- self.menuedit_convert_mg2sg = self.menuedit_convert.addAction(
- QtGui.QIcon(self.app.resource_location + '/convert24.png'), _('Convert Multi to SingleGeo'))
- self.menuedit_convert_mg2sg.setToolTip(
- _("Will convert a Geometry object from multi_geometry type\n"
- "to a single_geometry type.")
- )
- # Separator
- self.menuedit_convert.addSeparator()
- self.menueditconvert_any2geo = self.menuedit_convert.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy_geo.png'),
- _('Convert Any to Geo'))
- self.menueditconvert_any2gerber = self.menuedit_convert.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy_geo.png'),
- _('Convert Any to Gerber'))
- self.menuedit_convert.setToolTipsVisible(True)
- # Separator
- self.menuedit.addSeparator()
- self.menueditcopyobject = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy.png'), _('&Copy\tCtrl+C'))
- # Separator
- self.menuedit.addSeparator()
- self.menueditdelete = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/trash16.png'), _('&Delete\tDEL'))
- # Separator
- self.menuedit.addSeparator()
- self.menueditorigin = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/origin16.png'), _('Se&t Origin\tO'))
- self.menuedit_move2origin = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/origin2_16.png'), _('Move to Origin\tShift+O'))
- self.menueditjump = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location\tJ'))
- self.menueditlocate = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/locate16.png'), _('Locate in Object\tShift+J'))
- # Separator
- self.menuedit.addSeparator()
- self.menuedittoggleunits = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/toggle_units16.png'), _('Toggle Units\tQ'))
- self.menueditselectall = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/select_all.png'), _('&Select All\tCtrl+A'))
- # Separator
- self.menuedit.addSeparator()
- self.menueditpreferences = self.menuedit.addAction(
- QtGui.QIcon(self.app.resource_location + '/pref.png'), _('&Preferences\tShift+P'))
- # ########################################################################
- # ########################## OPTIONS # ###################################
- # ########################################################################
- self.menuoptions = self.menu.addMenu(_('Options'))
- self.menuoptions_transform_rotate = self.menuoptions.addAction(
- QtGui.QIcon(self.app.resource_location + '/rotate.png'), _("&Rotate Selection\tShift+(R)"))
- # Separator
- self.menuoptions.addSeparator()
- self.menuoptions_transform_skewx = self.menuoptions.addAction(
- QtGui.QIcon(self.app.resource_location + '/skewX.png'), _("&Skew on X axis\tShift+X"))
- self.menuoptions_transform_skewy = self.menuoptions.addAction(
- QtGui.QIcon(self.app.resource_location + '/skewY.png'), _("S&kew on Y axis\tShift+Y"))
- # Separator
- self.menuoptions.addSeparator()
- self.menuoptions_transform_flipx = self.menuoptions.addAction(
- QtGui.QIcon(self.app.resource_location + '/flipx.png'), _("Flip on &X axis\tX"))
- self.menuoptions_transform_flipy = self.menuoptions.addAction(
- QtGui.QIcon(self.app.resource_location + '/flipy.png'), _("Flip on &Y axis\tY"))
- # Separator
- self.menuoptions.addSeparator()
- self.menuoptions_view_source = self.menuoptions.addAction(
- QtGui.QIcon(self.app.resource_location + '/source32.png'), _("View source\tAlt+S"))
- self.menuoptions_tools_db = self.menuoptions.addAction(
- QtGui.QIcon(self.app.resource_location + '/database32.png'), _("Tools DataBase\tCtrl+D"))
- # Separator
- self.menuoptions.addSeparator()
- # ########################################################################
- # ########################## View # ######################################
- # ########################################################################
- self.menuview = self.menu.addMenu(_('View'))
- self.menuviewenable = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/replot16.png'), _('Enable all plots\tAlt+1'))
- self.menuviewdisableall = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/clear_plot16.png'), _('Disable all plots\tAlt+2'))
- self.menuviewdisableother = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/clear_plot16.png'), _('Disable non-selected\tAlt+3'))
- # Separator
- self.menuview.addSeparator()
- self.menuview_zoom_fit = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("&Zoom Fit\tV"))
- self.menuview_zoom_in = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("&Zoom In\t="))
- self.menuview_zoom_out = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("&Zoom Out\t-"))
- self.menuview.addSeparator()
- # Replot all
- self.menuview_replot = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("Redraw All\tF5"))
- self.menuview.addSeparator()
- self.menuview_toggle_code_editor = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/code_editor32.png'), _('Toggle Code Editor\tShift+E'))
- self.menuview.addSeparator()
- self.menuview_toggle_fscreen = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/fscreen32.png'), _("&Toggle FullScreen\tAlt+F10"))
- self.menuview_toggle_parea = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/plot32.png'), _("&Toggle Plot Area\tCtrl+F10"))
- self.menuview_toggle_notebook = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/notebook32.png'), _("&Toggle Project/Sel/Tool\t`"))
- self.menuview.addSeparator()
- self.menuview_toggle_grid = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/grid32.png'), _("&Toggle Grid Snap\tG"))
- self.menuview_toggle_grid_lines = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/grid32.png'), _("&Toggle Grid Lines\tAlt+G"))
- self.menuview_toggle_axis = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/axis32.png'), _("&Toggle Axis\tShift+G"))
- self.menuview_toggle_workspace = self.menuview.addAction(
- QtGui.QIcon(self.app.resource_location + '/workspace24.png'), _("Toggle Workspace\tShift+W"))
- # ########################################################################
- # ########################## Objects # ###################################
- # ########################################################################
- self.menuobjects = self.menu.addMenu(_('Objects'))
- self.menuobjects.addSeparator()
- self.menuobjects_selall = self.menuobjects.addAction(
- QtGui.QIcon(self.app.resource_location + '/select_all.png'), _('Select All'))
- self.menuobjects_unselall = self.menuobjects.addAction(
- QtGui.QIcon(self.app.resource_location + '/deselect_all32.png'), _('Deselect All')
- )
- # ########################################################################
- # ########################## Tool # ######################################
- # ########################################################################
- self.menutool = QtWidgets.QMenu(_('Tool'))
- self.menutoolaction = self.menu.addMenu(self.menutool)
- self.menutoolshell = self.menutool.addAction(
- QtGui.QIcon(self.app.resource_location + '/shell16.png'), _('&Command Line\tS'))
- # ########################################################################
- # ########################## Help # ######################################
- # ########################################################################
- self.menuhelp = self.menu.addMenu(_('Help'))
- self.menuhelp_manual = self.menuhelp.addAction(
- QtGui.QIcon(self.app.resource_location + '/globe16.png'), _('Online Help\tF1'))
- self.menuhelp_bookmarks = self.menuhelp.addMenu(
- QtGui.QIcon(self.app.resource_location + '/bookmarks16.png'), _('Bookmarks'))
- self.menuhelp_bookmarks.addSeparator()
- self.menuhelp_bookmarks_manager = self.menuhelp_bookmarks.addAction(
- QtGui.QIcon(self.app.resource_location + '/bookmarks16.png'), _('Bookmarks Manager'))
- self.menuhelp.addSeparator()
- self.menuhelp_report_bug = self.menuhelp.addAction(
- QtGui.QIcon(self.app.resource_location + '/bug16.png'), _('Report a bug'))
- self.menuhelp.addSeparator()
- self.menuhelp_exc_spec = self.menuhelp.addAction(
- QtGui.QIcon(self.app.resource_location + '/pdf_link16.png'), _('Excellon Specification'))
- self.menuhelp_gerber_spec = self.menuhelp.addAction(
- QtGui.QIcon(self.app.resource_location + '/pdf_link16.png'), _('Gerber Specification'))
- self.menuhelp.addSeparator()
- self.menuhelp_shortcut_list = self.menuhelp.addAction(
- QtGui.QIcon(self.app.resource_location + '/shortcuts24.png'), _('Shortcuts List\tF3'))
- self.menuhelp_videohelp = self.menuhelp.addAction(
- QtGui.QIcon(self.app.resource_location + '/youtube32.png'), _('YouTube Channel\tF4'))
- self.menuhelp_about = self.menuhelp.addAction(
- QtGui.QIcon(self.app.resource_location + '/about32.png'), _('About FlatCAM'))
- # ########################################################################
- # ########################## GEOMETRY EDITOR # ###########################
- # ########################################################################
- self.geo_editor_menu = QtWidgets.QMenu(">Geo Editor<")
- self.menu.addMenu(self.geo_editor_menu)
- self.geo_add_circle_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle\tO')
- )
- self.geo_add_arc_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/arc16.png'), _('Add Arc\tA'))
- self.geo_editor_menu.addSeparator()
- self.geo_add_rectangle_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle\tR')
- )
- self.geo_add_polygon_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon\tN')
- )
- self.geo_add_path_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path\tP'))
- self.geo_editor_menu.addSeparator()
- self.geo_add_text_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text\tT'))
- self.geo_editor_menu.addSeparator()
- self.geo_union_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/union16.png'), _('Polygon Union\tU'))
- self.geo_intersection_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/intersection16.png'), _('Polygon Intersection\tE'))
- self.geo_subtract_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/subtract16.png'), _('Polygon Subtraction\tS')
- )
- self.geo_editor_menu.addSeparator()
- self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/cutpath16.png'), _('Cut Path\tX'))
- # self.move_menuitem = self.menu.addAction(
- # QtGui.QIcon(self.app.resource_location + '/move16.png'), "Move Objects 'm'")
- self.geo_copy_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy16.png'), _("Copy Geom\tC"))
- self.geo_delete_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/deleteshape16.png'), _("Delete Shape\tDEL")
- )
- self.geo_editor_menu.addSeparator()
- self.geo_move_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move\tM"))
- self.geo_buffer_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/buffer16.png'), _("Buffer Tool\tB")
- )
- self.geo_paint_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/paint16.png'), _("Paint Tool\tI")
- )
- self.geo_transform_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool\tAlt+R")
- )
- self.geo_editor_menu.addSeparator()
- self.geo_cornersnap_menuitem = self.geo_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/corner32.png'), _("Toggle Corner Snap\tK")
- )
- # ########################################################################
- # ########################## EXCELLON Editor # ###########################
- # ########################################################################
- self.exc_editor_menu = QtWidgets.QMenu(_(">Excellon Editor<"))
- self.menu.addMenu(self.exc_editor_menu)
- self.exc_add_array_drill_menuitem = self.exc_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Drill Array\tA'))
- self.exc_add_drill_menuitem = self.exc_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill\tD'))
- self.exc_editor_menu.addSeparator()
- self.exc_add_array_slot_menuitem = self.exc_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array\tQ'))
- self.exc_add_slot_menuitem = self.exc_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot\tW'))
- self.exc_editor_menu.addSeparator()
- self.exc_resize_drill_menuitem = self.exc_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill(S)\tR')
- )
- self.exc_copy_drill_menuitem = self.exc_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy\tC'))
- self.exc_delete_drill_menuitem = self.exc_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/deleteshape32.png'), _('Delete\tDEL')
- )
- self.exc_editor_menu.addSeparator()
- self.exc_move_drill_menuitem = self.exc_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _('Move Drill(s)\tM'))
- # ########################################################################
- # ########################## GERBER Editor # #############################
- # ########################################################################
- self.grb_editor_menu = QtWidgets.QMenu(_(">Gerber Editor<"))
- self.menu.addMenu(self.grb_editor_menu)
- self.grb_add_pad_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/aperture16.png'), _('Add Pad\tP'))
- self.grb_add_pad_array_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array\tA'))
- self.grb_add_track_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/track32.png'), _('Add Track\tT'))
- self.grb_add_region_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Region\tN'))
- self.grb_editor_menu.addSeparator()
- self.grb_convert_poly_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize\tAlt+N"))
- self.grb_add_semidisc_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("Add SemiDisc\tE"))
- self.grb_add_disc_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Add Disc\tD"))
- self.grb_add_buffer_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer\tB'))
- self.grb_add_scale_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale\tS'))
- self.grb_add_markarea_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area\tAlt+A'))
- self.grb_add_eraser_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser\tCtrl+E'))
- self.grb_transform_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform\tAlt+R"))
- self.grb_editor_menu.addSeparator()
- self.grb_copy_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy\tC'))
- self.grb_delete_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/deleteshape32.png'), _('Delete\tDEL'))
- self.grb_editor_menu.addSeparator()
- self.grb_move_menuitem = self.grb_editor_menu.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _('Move\tM'))
- self.grb_editor_menu.menuAction().setVisible(False)
- self.grb_editor_menu.setDisabled(True)
- self.geo_editor_menu.menuAction().setVisible(False)
- self.geo_editor_menu.setDisabled(True)
- self.exc_editor_menu.menuAction().setVisible(False)
- self.exc_editor_menu.setDisabled(True)
- # ########################################################################
- # ########################## Project Tab Context Menu # ##################
- # ########################################################################
- self.menuproject = QtWidgets.QMenu()
- self.menuprojectenable = self.menuproject.addAction(
- QtGui.QIcon(self.app.resource_location + '/replot32.png'), _('Enable Plot'))
- self.menuprojectdisable = self.menuproject.addAction(
- QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _('Disable Plot'))
- self.menuproject.addSeparator()
- self.menuprojectcolor = self.menuproject.addMenu(
- QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Set Color'))
- self.menuproject_red = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/red32.png'), _('Red'))
- self.menuproject_blue = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/blue32.png'), _('Blue'))
- self.menuproject_yellow = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/yellow32.png'), _('Yellow'))
- self.menuproject_green = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/green32.png'), _('Green'))
- self.menuproject_purple = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/violet32.png'), _('Purple'))
- self.menuproject_brown = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/brown32.png'), _('Brown'))
- self.menuproject_brown = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/white32.png'), _('White'))
- self.menuproject_brown = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/black32.png'), _('Black'))
- self.menuprojectcolor.addSeparator()
- self.menuproject_custom = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Custom'))
- self.menuprojectcolor.addSeparator()
- self.menuproject_custom = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Opacity'))
- self.menuproject_custom = self.menuprojectcolor.addAction(
- QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Default'))
- self.menuproject.addSeparator()
- self.menuprojectgeneratecnc = self.menuproject.addAction(
- QtGui.QIcon(self.app.resource_location + '/cnc32.png'), _('Generate CNC'))
- self.menuprojectviewsource = self.menuproject.addAction(
- QtGui.QIcon(self.app.resource_location + '/source32.png'), _('View Source'))
- self.menuprojectedit = self.menuproject.addAction(
- QtGui.QIcon(self.app.resource_location + '/edit_ok32.png'), _('Edit'))
- self.menuprojectcopy = self.menuproject.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy'))
- self.menuprojectdelete = self.menuproject.addAction(
- QtGui.QIcon(self.app.resource_location + '/delete32.png'), _('Delete'))
- self.menuprojectsave = self.menuproject.addAction(
- QtGui.QIcon(self.app.resource_location + '/save_as.png'), _('Save'))
- self.menuproject.addSeparator()
- self.menuprojectproperties = self.menuproject.addAction(
- QtGui.QIcon(self.app.resource_location + '/properties32.png'), _('Properties'))
- # ########################################################################
- # ####################### Central Widget -> Splitter # ##################
- # ########################################################################
- # IMPORTANT #
- # The order: SPLITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
- # desired.
- self.splitter = QtWidgets.QSplitter()
- self.setCentralWidget(self.splitter)
- # self.notebook = QtWidgets.QTabWidget()
- self.notebook = FCDetachableTab(protect=True)
- self.notebook.setTabsClosable(False)
- self.notebook.useOldIndex(True)
- self.splitter.addWidget(self.notebook)
- self.splitter_left = QtWidgets.QSplitter(Qt.Vertical)
- self.splitter.addWidget(self.splitter_left)
- self.splitter_left.addWidget(self.notebook)
- self.splitter_left.setHandleWidth(0)
- # ########################################################################
- # ########################## ToolBAR # ###################################
- # ########################################################################
- # ## TOOLBAR INSTALLATION ###
- self.toolbarfile = QtWidgets.QToolBar(_('File Toolbar'))
- self.toolbarfile.setObjectName('File_TB')
- self.addToolBar(self.toolbarfile)
- self.toolbargeo = QtWidgets.QToolBar(_('Edit Toolbar'))
- self.toolbargeo.setObjectName('Edit_TB')
- self.addToolBar(self.toolbargeo)
- self.toolbarview = QtWidgets.QToolBar(_('View Toolbar'))
- self.toolbarview.setObjectName('View_TB')
- self.addToolBar(self.toolbarview)
- self.toolbarshell = QtWidgets.QToolBar(_('Shell Toolbar'))
- self.toolbarshell.setObjectName('Shell_TB')
- self.addToolBar(self.toolbarshell)
- self.toolbartools = QtWidgets.QToolBar(_('Tools Toolbar'))
- self.toolbartools.setObjectName('Tools_TB')
- self.addToolBar(self.toolbartools)
- self.exc_edit_toolbar = QtWidgets.QToolBar(_('Excellon Editor Toolbar'))
- self.exc_edit_toolbar.setObjectName('ExcEditor_TB')
- self.addToolBar(self.exc_edit_toolbar)
- self.addToolBarBreak()
- self.geo_edit_toolbar = QtWidgets.QToolBar(_('Geometry Editor Toolbar'))
- self.geo_edit_toolbar.setObjectName('GeoEditor_TB')
- self.addToolBar(self.geo_edit_toolbar)
- self.grb_edit_toolbar = QtWidgets.QToolBar(_('Gerber Editor Toolbar'))
- self.grb_edit_toolbar.setObjectName('GrbEditor_TB')
- self.addToolBar(self.grb_edit_toolbar)
- self.snap_toolbar = QtWidgets.QToolBar(_('Grid Toolbar'))
- self.snap_toolbar.setObjectName('Snap_TB')
- self.addToolBar(self.snap_toolbar)
- flat_settings = QSettings("Open Source", "FlatCAM")
- if flat_settings.contains("layout"):
- layout = flat_settings.value('layout', type=str)
- if layout == 'compact':
- self.removeToolBar(self.snap_toolbar)
- self.snap_toolbar.setMaximumHeight(30)
- self.splitter_left.addWidget(self.snap_toolbar)
- # ########################################################################
- # ########################## File Toolbar# ###############################
- # ########################################################################
- self.file_open_gerber_btn = self.toolbarfile.addAction(
- QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _("Open Gerber"))
- self.file_open_excellon_btn = self.toolbarfile.addAction(
- QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Open Excellon"))
- self.toolbarfile.addSeparator()
- self.file_open_btn = self.toolbarfile.addAction(
- QtGui.QIcon(self.app.resource_location + '/folder32.png'), _("Open project"))
- self.file_save_btn = self.toolbarfile.addAction(
- QtGui.QIcon(self.app.resource_location + '/project_save32.png'), _("Save project"))
- # ########################################################################
- # ########################## Edit Toolbar# ###############################
- # ########################################################################
- self.newgeo_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_file_geo32.png'), _("New Blank Geometry"))
- self.newgrb_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_file_grb32.png'), _("New Blank Gerber"))
- self.newexc_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_file_exc32.png'), _("New Blank Excellon"))
- self.toolbargeo.addSeparator()
- self.editgeo_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/edit_file32.png'), _("Editor"))
- self.update_obj_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'), _("Save Object and close the Editor")
- )
- self.toolbargeo.addSeparator()
- self.copy_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy_file32.png'), _("Copy"))
- self.delete_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/delete_file32.png'), _("&Delete"))
- self.toolbargeo.addSeparator()
- self.distance_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/distance32.png'), _("Distance Tool"))
- self.distance_min_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/distance_min32.png'), _("Distance Min Tool"))
- self.origin_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/origin32.png'), _('Set Origin'))
- self.move2origin_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/origin2_32.png'), _('Move to Origin'))
- self.jmp_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location'))
- self.locate_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/locate32.png'), _('Locate in Object'))
- # ########################################################################
- # ########################## View Toolbar# ###############################
- # ########################################################################
- self.replot_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("&Replot"))
- self.clear_plot_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("&Clear plot"))
- self.zoom_in_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("Zoom In"))
- self.zoom_out_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("Zoom Out"))
- self.zoom_fit_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
- # self.toolbarview.setVisible(False)
- # ########################################################################
- # ########################## Shell Toolbar# ##############################
- # ########################################################################
- self.shell_btn = self.toolbarshell.addAction(
- QtGui.QIcon(self.app.resource_location + '/shell32.png'), _("&Command Line"))
- self.new_script_btn = self.toolbarshell.addAction(
- QtGui.QIcon(self.app.resource_location + '/script_new24.png'), _('New Script ...'))
- self.open_script_btn = self.toolbarshell.addAction(
- QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'))
- self.run_script_btn = self.toolbarshell.addAction(
- QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Run Script ...'))
- # ########################################################################
- # ########################## Tools Toolbar# ##############################
- # ########################################################################
- self.dblsided_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2Sided Tool"))
- self.align_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects Tool"))
- self.extract_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/extract_drill32.png'), _("Extract Drills Tool"))
- self.cutout_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/cut16_bis.png'), _("Cutout Tool"))
- self.ncc_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/ncc16.png'), _("NCC Tool"))
- self.paint_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool"))
- self.toolbartools.addSeparator()
- self.panelize_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool"))
- self.film_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/film16.png'), _("Film Tool"))
- self.solder_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste Tool"))
- self.sub_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool"))
- self.rules_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules Tool"))
- self.optimal_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal Tool"))
- self.toolbartools.addSeparator()
- self.calculators_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool"))
- self.transform_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool"))
- self.qrcode_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool"))
- self.copperfill_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool"))
- self.fiducials_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool"))
- self.cal_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool"))
- self.punch_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/punch32.png'), _("Punch Gerber Tool"))
- self.invert_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/invert32.png'), _("Invert Gerber Tool"))
- # ########################################################################
- # ########################## Excellon Editor Toolbar# ####################
- # ########################################################################
- self.select_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
- self.add_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill Hole'))
- self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/addarray16.png'), _('Add Drill Hole Array'))
- self.add_slot_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot'))
- self.add_slot_array_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array'))
- self.resize_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill'))
- self.exc_edit_toolbar.addSeparator()
- self.copy_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy Drill'))
- self.delete_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Drill"))
- self.exc_edit_toolbar.addSeparator()
- self.move_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Drill"))
- # ########################################################################
- # ########################## Geometry Editor Toolbar# ####################
- # ########################################################################
- self.geo_select_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
- self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle'))
- self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/arc32.png'), _('Add Arc'))
- self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle'))
- self.geo_edit_toolbar.addSeparator()
- self.geo_add_path_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path'))
- self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon'))
- self.geo_edit_toolbar.addSeparator()
- self.geo_add_text_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text'))
- self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Add Buffer'))
- self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _('Paint Shape'))
- self.geo_eraser_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
- self.geo_edit_toolbar.addSeparator()
- self.geo_union_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/union32.png'), _('Polygon Union'))
- self.geo_explode_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/explode32.png'), _('Polygon Explode'))
- self.geo_intersection_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _('Polygon Intersection'))
- self.geo_subtract_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _('Polygon Subtraction'))
- self.geo_edit_toolbar.addSeparator()
- self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _('Cut Path'))
- self.geo_copy_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy Shape(s)"))
- self.geo_delete_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Shape '-'"))
- self.geo_transform_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
- self.geo_edit_toolbar.addSeparator()
- self.geo_move_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Objects "))
- # ########################################################################
- # ########################## Gerber Editor Toolbar# ######################
- # ########################################################################
- self.grb_select_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
- self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Add Pad"))
- self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array'))
- self.grb_add_track_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Add Track"))
- self.grb_add_region_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Add Region"))
- self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
- self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
- self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
- self.grb_edit_toolbar.addSeparator()
- self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer'))
- self.aperture_scale_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale'))
- self.aperture_markarea_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area'))
- self.aperture_eraser_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
- self.grb_edit_toolbar.addSeparator()
- self.aperture_copy_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
- self.aperture_delete_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete"))
- self.grb_transform_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
- self.grb_edit_toolbar.addSeparator()
- self.aperture_move_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
- # ########################################################################
- # ########################## Snap Toolbar# ###############################
- # ########################################################################
- # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
- self.grid_snap_btn = self.snap_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/grid32.png'), _('Snap to grid'))
- self.grid_gap_x_entry = FCEntry2()
- self.grid_gap_x_entry.setMaximumWidth(70)
- self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
- self.snap_toolbar.addWidget(self.grid_gap_x_entry)
- self.grid_gap_y_entry = FCEntry2()
- self.grid_gap_y_entry.setMaximumWidth(70)
- self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
- self.snap_toolbar.addWidget(self.grid_gap_y_entry)
- self.grid_space_label = QtWidgets.QLabel(" ")
- self.snap_toolbar.addWidget(self.grid_space_label)
- self.grid_gap_link_cb = FCCheckBox()
- self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
- "is copied to the Grid_Y value."))
- self.snap_toolbar.addWidget(self.grid_gap_link_cb)
- self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
- self.corner_snap_btn = self.snap_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/corner32.png'), _('Snap to corner'))
- self.snap_max_dist_entry = FCEntry()
- self.snap_max_dist_entry.setMaximumWidth(70)
- self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
- self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
- # ########################################################################
- # ########################## Notebook # ##################################
- # ########################################################################
- # ########################################################################
- # ########################## PROJECT Tab # ###############################
- # ########################################################################
- self.project_tab = QtWidgets.QWidget()
- self.project_tab.setObjectName("project_tab")
- self.project_frame_lay = QtWidgets.QVBoxLayout(self.project_tab)
- self.project_frame_lay.setContentsMargins(0, 0, 0, 0)
- self.project_frame = QtWidgets.QFrame()
- self.project_frame.setContentsMargins(0, 0, 0, 0)
- self.project_frame_lay.addWidget(self.project_frame)
- self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_frame)
- self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
- self.notebook.addTab(self.project_tab, _("Project"))
- self.project_frame.setDisabled(False)
- # ########################################################################
- # ########################## SELECTED Tab # ##############################
- # ########################################################################
- self.selected_tab = QtWidgets.QWidget()
- # self.selected_tab.setMinimumWidth(270)
- self.selected_tab.setObjectName("selected_tab")
- self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
- self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
- self.selected_scroll_area = VerticalScrollArea()
- # self.selected_scroll_area.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
- self.selected_tab_layout.addWidget(self.selected_scroll_area)
- self.notebook.addTab(self.selected_tab, _("Selected"))
- # ########################################################################
- # ########################## TOOL Tab # ##################################
- # ########################################################################
- self.tool_tab = QtWidgets.QWidget()
- self.tool_tab.setObjectName("tool_tab")
- self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
- self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
- self.notebook.addTab(self.tool_tab, _("Tool"))
- self.tool_scroll_area = VerticalScrollArea()
- # self.tool_scroll_area.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
- self.tool_tab_layout.addWidget(self.tool_scroll_area)
- # ########################################################################
- # ########################## RIGHT Widget # ##############################
- # ########################################################################
- self.right_widget = QtWidgets.QWidget()
- self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
- self.splitter.addWidget(self.right_widget)
- self.right_lay = QtWidgets.QVBoxLayout()
- self.right_lay.setContentsMargins(0, 0, 0, 0)
- self.right_widget.setLayout(self.right_lay)
- # ########################################################################
- # ########################## PLOT AREA Tab # #############################
- # ########################################################################
- self.plot_tab_area = FCDetachableTab2(protect=False, protect_by_name=[_('Plot Area')])
- self.plot_tab_area.useOldIndex(True)
- self.right_lay.addWidget(self.plot_tab_area)
- self.plot_tab_area.setTabsClosable(True)
- self.plot_tab = QtWidgets.QWidget()
- self.plot_tab.setObjectName("plotarea")
- self.plot_tab_area.addTab(self.plot_tab, _("Plot Area"))
- self.right_layout = QtWidgets.QVBoxLayout()
- self.right_layout.setObjectName("right_layout")
- self.right_layout.setContentsMargins(2, 2, 2, 2)
- self.plot_tab.setLayout(self.right_layout)
- # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
- self.plot_tab_area.protectTab(0)
- # ########################################################################
- # ########################## PREFERENCES AREA Tab # ######################
- # ########################################################################
- self.preferences_tab = QtWidgets.QWidget()
- self.preferences_tab.setObjectName("preferences_tab")
- self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
- self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
- self.pref_tab_area = FCTab()
- self.pref_tab_area.setTabsClosable(False)
- self.pref_tab_area_tabBar = self.pref_tab_area.tabBar()
- self.pref_tab_area_tabBar.setStyleSheet("QTabBar::tab{min-width:90px;}")
- self.pref_tab_area_tabBar.setExpanding(True)
- self.pref_tab_layout.addWidget(self.pref_tab_area)
- self.general_tab = QtWidgets.QWidget()
- self.general_tab.setObjectName("general_tab")
- self.pref_tab_area.addTab(self.general_tab, _("General"))
- self.general_tab_lay = QtWidgets.QVBoxLayout()
- self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
- self.general_tab.setLayout(self.general_tab_lay)
- self.hlay1 = QtWidgets.QHBoxLayout()
- self.general_tab_lay.addLayout(self.hlay1)
- self.hlay1.addStretch()
- self.general_scroll_area = QtWidgets.QScrollArea()
- self.general_tab_lay.addWidget(self.general_scroll_area)
- self.gerber_tab = QtWidgets.QWidget()
- self.gerber_tab.setObjectName("gerber_tab")
- self.pref_tab_area.addTab(self.gerber_tab, _("GERBER"))
- self.gerber_tab_lay = QtWidgets.QVBoxLayout()
- self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
- self.gerber_tab.setLayout(self.gerber_tab_lay)
- self.gerber_scroll_area = QtWidgets.QScrollArea()
- self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
- self.excellon_tab = QtWidgets.QWidget()
- self.excellon_tab.setObjectName("excellon_tab")
- self.pref_tab_area.addTab(self.excellon_tab, _("EXCELLON"))
- self.excellon_tab_lay = QtWidgets.QVBoxLayout()
- self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
- self.excellon_tab.setLayout(self.excellon_tab_lay)
- self.excellon_scroll_area = QtWidgets.QScrollArea()
- self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
- self.geometry_tab = QtWidgets.QWidget()
- self.geometry_tab.setObjectName("geometry_tab")
- self.pref_tab_area.addTab(self.geometry_tab, _("GEOMETRY"))
- self.geometry_tab_lay = QtWidgets.QVBoxLayout()
- self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
- self.geometry_tab.setLayout(self.geometry_tab_lay)
- self.geometry_scroll_area = QtWidgets.QScrollArea()
- self.geometry_tab_lay.addWidget(self.geometry_scroll_area)
- self.text_editor_tab = QtWidgets.QWidget()
- self.text_editor_tab.setObjectName("text_editor_tab")
- self.pref_tab_area.addTab(self.text_editor_tab, _("CNC-JOB"))
- self.cncjob_tab_lay = QtWidgets.QVBoxLayout()
- self.cncjob_tab_lay.setContentsMargins(2, 2, 2, 2)
- self.text_editor_tab.setLayout(self.cncjob_tab_lay)
- self.cncjob_scroll_area = QtWidgets.QScrollArea()
- self.cncjob_tab_lay.addWidget(self.cncjob_scroll_area)
- self.tools_tab = QtWidgets.QWidget()
- self.pref_tab_area.addTab(self.tools_tab, _("TOOLS"))
- self.tools_tab_lay = QtWidgets.QVBoxLayout()
- self.tools_tab_lay.setContentsMargins(2, 2, 2, 2)
- self.tools_tab.setLayout(self.tools_tab_lay)
- self.tools_scroll_area = QtWidgets.QScrollArea()
- self.tools_tab_lay.addWidget(self.tools_scroll_area)
- self.tools2_tab = QtWidgets.QWidget()
- self.pref_tab_area.addTab(self.tools2_tab, _("TOOLS 2"))
- self.tools2_tab_lay = QtWidgets.QVBoxLayout()
- self.tools2_tab_lay.setContentsMargins(2, 2, 2, 2)
- self.tools2_tab.setLayout(self.tools2_tab_lay)
- self.tools2_scroll_area = QtWidgets.QScrollArea()
- self.tools2_tab_lay.addWidget(self.tools2_scroll_area)
- self.fa_tab = QtWidgets.QWidget()
- self.fa_tab.setObjectName("fa_tab")
- self.pref_tab_area.addTab(self.fa_tab, _("UTILITIES"))
- self.fa_tab_lay = QtWidgets.QVBoxLayout()
- self.fa_tab_lay.setContentsMargins(2, 2, 2, 2)
- self.fa_tab.setLayout(self.fa_tab_lay)
- self.fa_scroll_area = QtWidgets.QScrollArea()
- self.fa_tab_lay.addWidget(self.fa_scroll_area)
- self.pref_tab_bottom_layout = QtWidgets.QHBoxLayout()
- self.pref_tab_bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
- self.pref_tab_layout.addLayout(self.pref_tab_bottom_layout)
- self.pref_tab_bottom_layout_1 = QtWidgets.QHBoxLayout()
- self.pref_tab_bottom_layout_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
- self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_1)
- self.pref_defaults_button = QtWidgets.QPushButton()
- self.pref_defaults_button.setText(_("Restore Defaults"))
- self.pref_defaults_button.setMinimumWidth(130)
- self.pref_defaults_button.setToolTip(
- _("Restore the entire set of default values\n"
- "to the initial values loaded after first launch."))
- self.pref_tab_bottom_layout_1.addWidget(self.pref_defaults_button)
- self.pref_open_button = QtWidgets.QPushButton()
- self.pref_open_button.setText(_("Open Pref Folder"))
- self.pref_open_button.setMinimumWidth(130)
- self.pref_open_button.setToolTip(
- _("Open the folder where FlatCAM save the preferences files."))
- self.pref_tab_bottom_layout_1.addWidget(self.pref_open_button)
- # Clear Settings
- self.clear_btn = FCButton('%s' % _('Clear GUI Settings'))
- self.clear_btn.setMinimumWidth(130)
- self.clear_btn.setToolTip(
- _("Clear the GUI settings for FlatCAM,\n"
- "such as: layout, gui state, style, hdpi support etc.")
- )
- self.pref_tab_bottom_layout_1.addWidget(self.clear_btn)
- self.pref_tab_bottom_layout_2 = QtWidgets.QHBoxLayout()
- self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
- self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2)
- self.pref_apply_button = FCButton()
- self.pref_apply_button.setText(_("Apply"))
- self.pref_apply_button.setMinimumWidth(130)
- self.pref_apply_button.setToolTip(
- _("Apply the current preferences without saving to a file."))
- self.pref_tab_bottom_layout_2.addWidget(self.pref_apply_button)
- self.pref_save_button = QtWidgets.QPushButton()
- self.pref_save_button.setText(_("Save"))
- self.pref_save_button.setMinimumWidth(130)
- self.pref_save_button.setToolTip(
- _("Save the current settings in the 'current_defaults' file\n"
- "which is the file storing the working default preferences."))
- self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
- self.pref_close_button = QtWidgets.QPushButton()
- self.pref_close_button.setText(_("Cancel"))
- self.pref_close_button.setMinimumWidth(130)
- self.pref_close_button.setToolTip(
- _("Will not save the changes and will close the preferences window."))
- self.pref_tab_bottom_layout_2.addWidget(self.pref_close_button)
- # ########################################################################
- # #################### SHORTCUT LIST AREA Tab # ##########################
- # ########################################################################
- self.shortcuts_tab = QtWidgets.QWidget()
- self.sh_tab_layout = QtWidgets.QVBoxLayout()
- self.sh_tab_layout.setContentsMargins(2, 2, 2, 2)
- self.shortcuts_tab.setLayout(self.sh_tab_layout)
- self.sh_hlay = QtWidgets.QHBoxLayout()
- self.sh_title = QtWidgets.QTextEdit(
- _('<b>Shortcut Key List</b>'))
- self.sh_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
- self.sh_title.setFrameStyle(QtWidgets.QFrame.NoFrame)
- self.sh_title.setMaximumHeight(30)
- font = self.sh_title.font()
- font.setPointSize(12)
- self.sh_title.setFont(font)
- self.sh_tab_layout.addWidget(self.sh_title)
- self.sh_tab_layout.addLayout(self.sh_hlay)
- self.app_sh_msg = (
- '''<b>General Shortcut list</b><br>
- <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
- <tbody>
- <tr height="20">
- <td height="20" width="89"><strong>F3</strong></td>
- <td width="194"><span style="color:#006400"><strong> %s</strong></span></td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>1</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>2</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>3</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>B</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>E</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>G</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>J</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>L</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>N</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>O</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Q</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>P</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>R</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>S</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>T</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>V</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>X</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Y</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>'-'</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>'='</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+A</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+C</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+D</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+E</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+G</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+N</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+O</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+P</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+Q</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+S</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+F10</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+C</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+E</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+G</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+J</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+P</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+R</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+S</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+W</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+X</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+Y</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+A</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+C</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+D</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+E</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+H</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+I</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+J</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+K</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+L</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+N</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+O</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+P</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+Q</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+R</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+S</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+U</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+1</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+2</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+3</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+F10</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+Alt+X</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+Shift+S</strong></td>
- <td> %s</td>
- </tr>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+Shift+V</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>F1</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>F4</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>F5</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Del</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Del</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>'`'</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>SPACE</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Escape</strong></td>
- <td> %s</td>
- </tr>
- </tbody>
- </table>
- ''' %
- (
- _("SHOW SHORTCUT LIST"), _("Switch to Project Tab"), _("Switch to Selected Tab"),
- _("Switch to Tool Tab"),
- _("New Gerber"), _("Edit Object (if selected)"), _("Grid On/Off"), _("Jump to Coordinates"),
- _("New Excellon"), _("Move Obj"), _("New Geometry"), _("Set Origin"), _("Change Units"),
- _("Open Properties Tool"), _("Rotate by 90 degree CW"), _("Shell Toggle"),
- _("Add a Tool (when in Geometry Selected Tab or in Tools NCC or Tools Paint)"), _("Zoom Fit"),
- _("Flip on X_axis"), _("Flip on Y_axis"), _("Zoom Out"), _("Zoom In"),
- # CTRL section
- _("Select All"), _("Copy Obj"), _("Open Tools Database"),
- _("Open Excellon File"), _("Open Gerber File"), _("Distance Tool"), _("New Project"),
- _("Open Project"), _("Print (PDF)"), _("PDF Import Tool"), _("Save Project"), _("Toggle Plot Area"),
- # SHIFT section
- _("Copy Obj_Name"),
- _("Toggle Code Editor"), _("Toggle the axis"), _("Locate in Object"), _("Distance Minimum Tool"),
- _("Open Preferences Window"),
- _("Rotate by 90 degree CCW"), _("Run a Script"), _("Toggle the workspace"), _("Skew on X axis"),
- _("Skew on Y axis"),
- # ALT section
- _("Align Objects Tool"), _("Calculators Tool"), _("2-Sided PCB Tool"), _("Transformations Tool"),
- _("Punch Gerber Tool"), _("Extract Drills Tool"), _("Fiducials Tool"),
- _("Solder Paste Dispensing Tool"),
- _("Film PCB Tool"), _("Non-Copper Clearing Tool"), _("Optimal Tool"),
- _("Paint Area Tool"), _("QRCode Tool"), _("Rules Check Tool"),
- _("View File Source"),
- _("Cutout PCB Tool"), _("Enable all Plots"), _("Disable all Plots"), _("Disable Non-selected Plots"),
- _("Toggle Full Screen"),
- # CTRL + ALT section
- _("Abort current task (gracefully)"),
- # CTRL + SHIFT section
- _("Save Project As"),
- _("Paste Special. Will convert a Windows path style to the one required in Tcl Shell"),
- # F keys section
- _("Open Online Manual"),
- _("Open Online Tutorials"), _("Refresh Plots"), _("Delete Object"), _("Alternate: Delete Tool"),
- _("(left to Key_1)Toogle Notebook Area (Left Side)"), _("En(Dis)able Obj Plot"),
- _("Deselects all objects")
- )
- )
- self.sh_app = QtWidgets.QTextEdit()
- self.sh_app.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
- self.sh_app.setText(self.app_sh_msg)
- self.sh_app.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
- self.sh_hlay.addWidget(self.sh_app)
- editor_title = """
- <b>%s</b><br>
- <br>
- """ % _("Editor Shortcut list")
- geo_sh_messages = """
- <strong><span style="color:#0000ff">%s</span></strong><br>
- <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
- <tbody>
- <tr height="20">
- <td height="20" width="89"><strong>A</strong></td>
- <td width="194"> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>B</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>C</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>D</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>E</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>I</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>J</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>K</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>N</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>O</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>P</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>R</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>S</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>T</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>U</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>X</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Y</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+X</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+Y</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+R</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+X</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+Y</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+S</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+X</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Space</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>ENTER</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>ESC</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Del</strong></td>
- <td> %s</td>
- </tr>
- </tbody>
- </table>
- <br>
- """ % (
- _("GEOMETRY EDITOR"), _("Draw an Arc"), _("Buffer Tool"), _("Copy Geo Item"),
- _("Within Add Arc will toogle the ARC direction: CW or CCW"), _("Polygon Intersection Tool"),
- _("Geo Paint Tool"), _("Jump to Location (x, y)"), _("Toggle Corner Snap"), _("Move Geo Item"),
- _("Within Add Arc will cycle through the ARC modes"), _("Draw a Polygon"), _("Draw a Circle"),
- _("Draw a Path"), _("Draw Rectangle"), _("Polygon Subtraction Tool"), _("Add Text Tool"),
- _("Polygon Union Tool"), _("Flip shape on X axis"), _("Flip shape on Y axis"), _("Distance Minimum Tool"),
- _("Skew shape on X axis"), _("Skew shape on Y axis"), _("Editor Transformation Tool"),
- _("Offset shape on X axis"), _("Offset shape on Y axis"), _("Distance Tool"),
- _("Save Object and Exit Editor"), _("Polygon Cut Tool"),
- _("Rotate Geometry"), _("Finish drawing for certain tools"), _("Abort and return to Select"),
- _("Delete Shape")
- )
- exc_sh_messages = """
- <br>
- <strong><span style="color:#ff0000">%s</span></strong><br>
- <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
- <tbody>
- <tr height="20">
- <td height="20" width="89"><strong>A</strong></td>
- <td width="194"> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>C</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>D</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>J</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20" width="89"><strong>Q</strong></td>
- <td width="194"> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>R</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>T</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20" width="89"><strong>W</strong></td>
- <td width="194"> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Del</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Del</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>ESC</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+S</strong></td>
- <td> %s</td>
- </tr>
- </tbody>
- </table>
- <br>
- """ % (
- _("EXCELLON EDITOR"), _("Add Drill Array"), _("Copy Drill(s)"), _("Add Drill"),
- _("Jump to Location (x, y)"), _("Move Drill(s)"), _("Add Slot Array"), _("Resize Drill(s)"),
- _("Add a new Tool"), _("Add Slot"), _("Distance Minimum Tool"),
- _("Delete Drill(s)"), _("Alternate: Delete Tool(s)"),
- _("Abort and return to Select"), _("Save Object and Exit Editor")
- )
- grb_sh_messages = """
- <br>
- <strong><span style="color:#00ff00">%s</span></strong><br>
- <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
- <tbody>
- <tr height="20">
- <td height="20" width="89"><strong>A</strong></td>
- <td width="194"> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>B</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>C</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>D</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>E</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>J</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>N</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>P</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>R</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>S</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>T</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>T</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Del</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Del</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>ESC</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Shift+M</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+E</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Ctrl+S</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"> </td>
- <td> </td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+A</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+N</strong></td>
- <td> %s</td>
- </tr>
- <tr height="20">
- <td height="20"><strong>Alt+R</strong></td>
- <td> %s</td>
- </tr>
- </tbody>
- </table>
- <br>
- """ % (
- _("GERBER EDITOR"), _("Add Pad Array"), _("Buffer"), _("Copy"), _("Add Disc"), _("Add SemiDisc"),
- _("Jump to Location (x, y)"), _("Move"), _("Add Region"), _("Add Pad"),
- _("Within Track & Region Tools will cycle in REVERSE the bend modes"), _("Scale"), _("Add Track"),
- _("Within Track & Region Tools will cycle FORWARD the bend modes"), _("Delete"),
- _("Alternate: Delete Apertures"), _("Abort and return to Select"), _("Distance Minimum Tool"),
- _("Eraser Tool"),
- _("Save Object and Exit Editor"), _("Mark Area Tool"), _("Poligonize Tool"), _("Transformation Tool")
- )
- self.editor_sh_msg = editor_title + geo_sh_messages + grb_sh_messages + exc_sh_messages
- self.sh_editor = QtWidgets.QTextEdit()
- self.sh_editor.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
- self.sh_editor.setText(self.editor_sh_msg)
- self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
- self.sh_hlay.addWidget(self.sh_editor)
- # ########################################################################
- # ########################## PLOT AREA CONTEXT MENU # ###################
- # ########################################################################
- self.popMenu = FCMenu()
- self.popmenu_disable = self.popMenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/disable32.png'), _("Toggle Visibility"))
- self.popmenu_panel_toggle = self.popMenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/notebook16.png'), _("Toggle Panel"))
- self.popMenu.addSeparator()
- self.cmenu_newmenu = self.popMenu.addMenu(
- QtGui.QIcon(self.app.resource_location + '/file32.png'), _("New"))
- self.popmenu_new_geo = self.cmenu_newmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_geo32_bis.png'), _("Geometry"))
- self.popmenu_new_grb = self.cmenu_newmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), "Gerber")
- self.popmenu_new_exc = self.cmenu_newmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_exc32.png'), _("Excellon"))
- self.cmenu_newmenu.addSeparator()
- self.popmenu_new_prj = self.cmenu_newmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/file16.png'), _("Project"))
- self.popMenu.addSeparator()
- self.cmenu_gridmenu = self.popMenu.addMenu(
- QtGui.QIcon(self.app.resource_location + '/grid32_menu.png'), _("Grids"))
- self.cmenu_viewmenu = self.popMenu.addMenu(
- QtGui.QIcon(self.app.resource_location + '/view64.png'), _("View"))
- self.zoomfit = self.cmenu_viewmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
- self.clearplot = self.cmenu_viewmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("Clear Plot"))
- self.replot = self.cmenu_viewmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("Replot"))
- self.popMenu.addSeparator()
- self.g_editor_cmenu = self.popMenu.addMenu(
- QtGui.QIcon(self.app.resource_location + '/draw32.png'), _("Geo Editor"))
- self.draw_line = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/path32.png'), _("Path"))
- self.draw_rect = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _("Rectangle"))
- self.g_editor_cmenu.addSeparator()
- self.draw_circle = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/circle32.png'), _("Circle"))
- self.draw_poly = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Polygon"))
- self.draw_arc = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/arc32.png'), _("Arc"))
- self.g_editor_cmenu.addSeparator()
- self.draw_text = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/text32.png'), _("Text"))
- self.draw_buffer = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _("Buffer"))
- self.draw_paint = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint"))
- self.draw_eraser = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _("Eraser"))
- self.g_editor_cmenu.addSeparator()
- self.draw_union = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/union32.png'), _("Union"))
- self.draw_intersect = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _("Intersection"))
- self.draw_substract = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _("Subtraction"))
- self.draw_cut = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _("Cut"))
- self.draw_transform = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
- self.g_editor_cmenu.addSeparator()
- self.draw_move = self.g_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
- self.grb_editor_cmenu = self.popMenu.addMenu(
- QtGui.QIcon(self.app.resource_location + '/draw32.png'), _("Gerber Editor"))
- self.grb_draw_pad = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Pad"))
- self.grb_draw_pad_array = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _("Pad Array"))
- self.grb_editor_cmenu.addSeparator()
- self.grb_draw_track = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Track"))
- self.grb_draw_region = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Region"))
- self.grb_draw_poligonize = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
- self.grb_draw_semidisc = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
- self.grb_draw_disc = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
- self.grb_editor_cmenu.addSeparator()
- self.grb_draw_buffer = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _("Buffer"))
- self.grb_draw_scale = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/scale32.png'), _("Scale"))
- self.grb_draw_markarea = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _("Mark Area"))
- self.grb_draw_eraser = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _("Eraser"))
- self.grb_editor_cmenu.addSeparator()
- self.grb_draw_transformations = self.grb_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
- self.e_editor_cmenu = self.popMenu.addMenu(
- QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Exc Editor"))
- self.drill = self.e_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Add Drill"))
- self.drill_array = self.e_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/addarray32.png'), _("Add Drill Array"))
- self.e_editor_cmenu.addSeparator()
- self.slot = self.e_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/slot26.png'), _("Add Slot"))
- self.slot_array = self.e_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _("Add Slot Array"))
- self.e_editor_cmenu.addSeparator()
- self.drill_resize = self.e_editor_cmenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/resize16.png'), _("Resize Drill"))
- self.popMenu.addSeparator()
- self.popmenu_copy = self.popMenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
- self.popmenu_delete = self.popMenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/delete32.png'), _("Delete"))
- self.popmenu_edit = self.popMenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/edit32.png'), _("Edit"))
- self.popmenu_save = self.popMenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/floppy32.png'), _("Close Editor"))
- self.popmenu_save.setVisible(False)
- self.popMenu.addSeparator()
- self.popmenu_move = self.popMenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
- self.popmenu_properties = self.popMenu.addAction(
- QtGui.QIcon(self.app.resource_location + '/properties32.png'), _("Properties"))
- # ########################################################################
- # ########################## INFO BAR # ##################################
- # ########################################################################
- self.infobar = self.statusBar()
- self.fcinfo = FlatCAMInfoBar(app=self.app)
- self.infobar.addWidget(self.fcinfo, stretch=1)
- self.snap_infobar_label = FCLabel()
- self.snap_infobar_label.setPixmap(QtGui.QPixmap(self.app.resource_location + '/snap_16.png'))
- self.infobar.addWidget(self.snap_infobar_label)
- self.rel_position_label = QtWidgets.QLabel(
- "<b>Dx</b>: 0.0000 <b>Dy</b>: 0.0000 ")
- self.rel_position_label.setMinimumWidth(110)
- self.rel_position_label.setToolTip(_("Relative neasurement.\nReference is last click position"))
- self.infobar.addWidget(self.rel_position_label)
- self.position_label = QtWidgets.QLabel(
- " <b>X</b>: 0.0000 <b>Y</b>: 0.0000")
- self.position_label.setMinimumWidth(110)
- self.position_label.setToolTip(_("Absolute neasurement.\nReference is (X=0, Y= 0) position"))
- self.infobar.addWidget(self.position_label)
- self.units_label = QtWidgets.QLabel("[in]")
- self.units_label.setMargin(2)
- self.infobar.addWidget(self.units_label)
- # disabled
- # self.progress_bar = QtWidgets.QProgressBar()
- # self.progress_bar.setMinimum(0)
- # self.progress_bar.setMaximum(100)
- # infobar.addWidget(self.progress_bar)
- # ########################################################################
- # ########################## SET GUI Elements # ##########################
- # ########################################################################
- self.app_icon = QtGui.QIcon()
- self.app_icon.addFile(self.app.resource_location + '/flatcam_icon16.png', QtCore.QSize(16, 16))
- self.app_icon.addFile(self.app.resource_location + '/flatcam_icon24.png', QtCore.QSize(24, 24))
- self.app_icon.addFile(self.app.resource_location + '/flatcam_icon32.png', QtCore.QSize(32, 32))
- self.app_icon.addFile(self.app.resource_location + '/flatcam_icon48.png', QtCore.QSize(48, 48))
- self.app_icon.addFile(self.app.resource_location + '/flatcam_icon128.png', QtCore.QSize(128, 128))
- self.app_icon.addFile(self.app.resource_location + '/flatcam_icon256.png', QtCore.QSize(256, 256))
- self.setWindowIcon(self.app_icon)
- self.setGeometry(100, 100, 1024, 650)
- self.setWindowTitle('FlatCAM %s %s - %s' %
- (self.app.version,
- ('BETA' if self.app.beta else ''),
- platform.architecture()[0])
- )
- self.filename = ""
- self.units = ""
- self.setAcceptDrops(True)
- # ########################################################################
- # ########################## Build GUI # #################################
- # ########################################################################
- self.grid_snap_btn.setCheckable(True)
- self.corner_snap_btn.setCheckable(True)
- self.update_obj_btn.setEnabled(False)
- # start with GRID activated
- self.grid_snap_btn.trigger()
- self.g_editor_cmenu.menuAction().setVisible(False)
- self.grb_editor_cmenu.menuAction().setVisible(False)
- self.e_editor_cmenu.menuAction().setVisible(False)
- # ########################################################################
- # ######################## BUILD PREFERENCES #############################
- # ########################################################################
- self.general_defaults_form = GeneralPreferencesUI(decimals=self.decimals)
- self.gerber_defaults_form = GerberPreferencesUI(decimals=self.decimals)
- self.excellon_defaults_form = ExcellonPreferencesUI(decimals=self.decimals)
- self.geometry_defaults_form = GeometryPreferencesUI(decimals=self.decimals)
- self.cncjob_defaults_form = CNCJobPreferencesUI(decimals=self.decimals)
- self.tools_defaults_form = ToolsPreferencesUI(decimals=self.decimals)
- self.tools2_defaults_form = Tools2PreferencesUI(decimals=self.decimals)
- self.util_defaults_form = UtilPreferencesUI(decimals=self.decimals)
- QtWidgets.qApp.installEventFilter(self)
- # ########################################################################
- # ################## RESTORE THE TOOLBAR STATE from file #################
- # ########################################################################
- flat_settings = QSettings("Open Source", "FlatCAM")
- if flat_settings.contains("saved_gui_state"):
- saved_gui_state = flat_settings.value('saved_gui_state')
- self.restoreState(saved_gui_state)
- log.debug("FlatCAMGUI.__init__() --> UI state restored from QSettings.")
- if flat_settings.contains("layout"):
- layout = flat_settings.value('layout', type=str)
- self.exc_edit_toolbar.setDisabled(True)
- self.geo_edit_toolbar.setDisabled(True)
- self.grb_edit_toolbar.setDisabled(True)
- if layout == 'standard':
- self.corner_snap_btn.setVisible(False)
- self.snap_magnet.setVisible(False)
- else:
- self.snap_magnet.setVisible(True)
- self.corner_snap_btn.setVisible(True)
- self.snap_magnet.setDisabled(True)
- self.corner_snap_btn.setDisabled(True)
- log.debug("FlatCAMGUI.__init__() --> UI layout restored from QSettings. Layout = %s" % str(layout))
- else:
- self.exc_edit_toolbar.setDisabled(True)
- self.geo_edit_toolbar.setDisabled(True)
- self.grb_edit_toolbar.setDisabled(True)
- self.corner_snap_btn.setVisible(False)
- self.snap_magnet.setVisible(False)
- flat_settings.setValue('layout', "standard")
- # This will write the setting to the platform specific storage.
- del flat_settings
- log.debug("FlatCAMGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'")
- # construct the Toolbar Lock menu entry to the context menu of the QMainWindow
- self.lock_action = QtWidgets.QAction()
- self.lock_action.setText(_("Lock Toolbars"))
- self.lock_action.setCheckable(True)
- qsettings = QSettings("Open Source", "FlatCAM")
- if qsettings.contains("toolbar_lock"):
- lock_val = settings.value('toolbar_lock')
- if lock_val == 'true':
- lock_state = True
- self.lock_action.setChecked(True)
- else:
- lock_state = False
- self.lock_action.setChecked(False)
- else:
- lock_state = False
- qsettings.setValue('toolbar_lock', lock_state)
- # This will write the setting to the platform specific storage.
- del qsettings
- self.lock_toolbar(lock=lock_state)
- self.lock_action.triggered[bool].connect(self.lock_toolbar)
- self.pref_open_button.clicked.connect(self.on_preferences_open_folder)
- self.clear_btn.clicked.connect(self.on_gui_clear)
- # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- # %%%%%%%%%%%%%%%%% GUI Building FINISHED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- def eventFilter(self, obj, event):
- """
- Filter the ToolTips display based on a Preferences setting
- :param obj:
- :param event: QT event to filter
- :return:
- """
- if self.app.defaults["global_toggle_tooltips"] is False:
- if event.type() == QtCore.QEvent.ToolTip:
- return True
- else:
- return False
- return False
- def on_preferences_open_folder(self):
- """
- Will open an Explorer window set to the folder path where the FlatCAM preferences files are usually saved.
- :return: None
- """
- if sys.platform == 'win32':
- subprocess.Popen('explorer %s' % self.app.data_path)
- elif sys.platform == 'darwin':
- os.system('open "%s"' % self.app.data_path)
- else:
- subprocess.Popen(['xdg-open', self.app.data_path])
- self.app.inform.emit('[success] %s' % _("FlatCAM Preferences Folder opened."))
- def on_gui_clear(self):
- theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
- theme_settings.setValue('theme', 'white')
- del theme_settings
- resource_loc = self.app.resource_location
- msgbox = QtWidgets.QMessageBox()
- msgbox.setText(_("Are you sure you want to delete the GUI Settings? \n"))
- msgbox.setWindowTitle(_("Clear GUI Settings"))
- msgbox.setWindowIcon(QtGui.QIcon(resource_loc + '/trash32.png'))
- bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
- bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
- msgbox.setDefaultButton(bt_no)
- msgbox.exec_()
- response = msgbox.clickedButton()
- if response == bt_yes:
- qsettings = QSettings("Open Source", "FlatCAM")
- for key in qsettings.allKeys():
- qsettings.remove(key)
- # This will write the setting to the platform specific storage.
- del qsettings
- def populate_toolbars(self):
- """
- Will populate the App Toolbars with their actions
- :return: None
- """
- # ########################################################################
- # ## File Toolbar # ##
- # ########################################################################
- self.file_open_gerber_btn = self.toolbarfile.addAction(
- QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _("Open Gerber"))
- self.file_open_excellon_btn = self.toolbarfile.addAction(
- QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Open Excellon"))
- self.toolbarfile.addSeparator()
- self.file_open_btn = self.toolbarfile.addAction(
- QtGui.QIcon(self.app.resource_location + '/folder32.png'), _("Open project"))
- self.file_save_btn = self.toolbarfile.addAction(
- QtGui.QIcon(self.app.resource_location + '/project_save32.png'), _("Save project"))
- # ########################################################################
- # ## Edit Toolbar # ##
- # ########################################################################
- self.newgeo_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_file_geo32.png'), _("New Blank Geometry"))
- self.newgrb_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_file_grb32.png'), _("New Blank Gerber"))
- self.newexc_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/new_file_exc32.png'), _("New Blank Excellon"))
- self.toolbargeo.addSeparator()
- self.editgeo_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/edit32.png'), _("Editor"))
- self.update_obj_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'),
- _("Save Object and close the Editor")
- )
- self.toolbargeo.addSeparator()
- self.copy_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy_file32.png'), _("Copy"))
- self.delete_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/delete_file32.png'), _("&Delete"))
- self.toolbargeo.addSeparator()
- self.distance_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/distance32.png'), _("Distance Tool"))
- self.distance_min_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/distance_min32.png'), _("Distance Min Tool"))
- self.origin_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/origin32.png'), _('Set Origin'))
- self.jmp_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location'))
- self.locate_btn = self.toolbargeo.addAction(
- QtGui.QIcon(self.app.resource_location + '/locate32.png'), _('Locate in Object'))
- # ########################################################################
- # ########################## View Toolbar# ###############################
- # ########################################################################
- self.replot_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("&Replot"))
- self.clear_plot_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("&Clear plot"))
- self.zoom_in_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("Zoom In"))
- self.zoom_out_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("Zoom Out"))
- self.zoom_fit_btn = self.toolbarview.addAction(
- QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
- # ########################################################################
- # ########################## Shell Toolbar# ##############################
- # ########################################################################
- self.shell_btn = self.toolbarshell.addAction(
- QtGui.QIcon(self.app.resource_location + '/shell32.png'), _("&Command Line"))
- self.new_script_btn = self.toolbarshell.addAction(
- QtGui.QIcon(self.app.resource_location + '/script_new24.png'), _('New Script ...'))
- self.open_script_btn = self.toolbarshell.addAction(
- QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'))
- self.run_script_btn = self.toolbarshell.addAction(
- QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Run Script ...'))
- # ########################################################################
- # ## Tools Toolbar # ##
- # ########################################################################
- self.dblsided_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2Sided Tool"))
- self.align_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects Tool"))
- self.extract_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/extract_drill32.png'), _("Extract Drills Tool"))
- self.cutout_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/cut16_bis.png'), _("&Cutout Tool"))
- self.ncc_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/ncc16.png'), _("NCC Tool"))
- self.paint_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool"))
- self.toolbartools.addSeparator()
- self.panelize_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool"))
- self.film_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/film16.png'), _("Film Tool"))
- self.solder_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste Tool"))
- self.sub_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool"))
- self.rules_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules Tool"))
- self.optimal_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal Tool"))
- self.toolbartools.addSeparator()
- self.calculators_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool"))
- self.transform_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool"))
- self.qrcode_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool"))
- self.copperfill_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool"))
- self.fiducials_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool"))
- self.cal_btn = self.toolbartools.addAction(
- QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool"))
- # ########################################################################
- # ## Excellon Editor Toolbar # ##
- # ########################################################################
- self.select_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
- self.add_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill Hole'))
- self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/addarray16.png'), _('Add Drill Hole Array'))
- self.resize_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill'))
- self.add_slot_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot'))
- self.add_slot_array_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array'))
- self.exc_edit_toolbar.addSeparator()
- self.copy_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy Drill'))
- self.delete_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Drill"))
- self.exc_edit_toolbar.addSeparator()
- self.move_drill_btn = self.exc_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Drill"))
- # ########################################################################
- # ## Geometry Editor Toolbar # ##
- # ########################################################################
- self.geo_select_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select 'Esc'"))
- self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle'))
- self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/arc32.png'), _('Add Arc'))
- self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle'))
- self.geo_edit_toolbar.addSeparator()
- self.geo_add_path_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path'))
- self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon'))
- self.geo_edit_toolbar.addSeparator()
- self.geo_add_text_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text'))
- self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Add Buffer'))
- self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _('Paint Shape'))
- self.geo_eraser_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
- self.geo_edit_toolbar.addSeparator()
- self.geo_union_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/union32.png'), _('Polygon Union'))
- self.geo_explode_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/explode32.png'), _('Polygon Explode'))
- self.geo_intersection_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _('Polygon Intersection'))
- self.geo_subtract_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _('Polygon Subtraction'))
- self.geo_edit_toolbar.addSeparator()
- self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _('Cut Path'))
- self.geo_copy_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy Objects"))
- self.geo_delete_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Shape"))
- self.geo_transform_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
- self.geo_edit_toolbar.addSeparator()
- self.geo_move_btn = self.geo_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Objects"))
- # ########################################################################
- # ## Gerber Editor Toolbar # ##
- # ########################################################################
- self.grb_select_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
- self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Add Pad"))
- self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array'))
- self.grb_add_track_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Add Track"))
- self.grb_add_region_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Add Region"))
- self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
- self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
- self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
- self.grb_edit_toolbar.addSeparator()
- self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer'))
- self.aperture_scale_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale'))
- self.aperture_markarea_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area'))
- self.aperture_eraser_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
- self.grb_edit_toolbar.addSeparator()
- self.aperture_copy_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
- self.aperture_delete_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete"))
- self.grb_transform_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
- self.grb_edit_toolbar.addSeparator()
- self.aperture_move_btn = self.grb_edit_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
- # ########################################################################
- # ## Snap Toolbar # ##
- # ########################################################################
- # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
- # self.addToolBar(self.snap_toolbar)
- self.grid_snap_btn = self.snap_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/grid32.png'), _('Snap to grid'))
- self.grid_gap_x_entry = FCEntry2()
- self.grid_gap_x_entry.setMaximumWidth(70)
- self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
- self.snap_toolbar.addWidget(self.grid_gap_x_entry)
- self.grid_gap_y_entry = FCEntry2()
- self.grid_gap_y_entry.setMaximumWidth(70)
- self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
- self.snap_toolbar.addWidget(self.grid_gap_y_entry)
- self.grid_space_label = QtWidgets.QLabel(" ")
- self.snap_toolbar.addWidget(self.grid_space_label)
- self.grid_gap_link_cb = FCCheckBox()
- self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
- "is copied to the Grid_Y value."))
- self.snap_toolbar.addWidget(self.grid_gap_link_cb)
- self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
- self.corner_snap_btn = self.snap_toolbar.addAction(
- QtGui.QIcon(self.app.resource_location + '/corner32.png'), _('Snap to corner'))
- self.snap_max_dist_entry = FCEntry()
- self.snap_max_dist_entry.setMaximumWidth(70)
- self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
- self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
- self.grid_snap_btn.setCheckable(True)
- self.corner_snap_btn.setCheckable(True)
- self.update_obj_btn.setEnabled(False)
- # start with GRID activated
- self.grid_snap_btn.trigger()
- qsettings = QSettings("Open Source", "FlatCAM")
- if qsettings.contains("layout"):
- layout = qsettings.value('layout', type=str)
- if layout == 'standard':
- self.corner_snap_btn.setVisible(False)
- self.snap_magnet.setVisible(False)
- else:
- self.corner_snap_btn.setVisible(True)
- self.snap_magnet.setVisible(True)
- self.corner_snap_btn.setDisabled(True)
- self.snap_magnet.setDisabled(True)
- # on 'minimal' layout only some toolbars are active
- if layout != 'minimal':
- self.exc_edit_toolbar.setVisible(True)
- self.exc_edit_toolbar.setDisabled(True)
- self.geo_edit_toolbar.setVisible(True)
- self.geo_edit_toolbar.setDisabled(True)
- self.grb_edit_toolbar.setVisible(True)
- self.grb_edit_toolbar.setDisabled(True)
- def keyPressEvent(self, event):
- """
- Key event handler for the entire app.
- Some of the key events are also treated locally in the FlatCAM editors
- :param event: QT event
- :return:
- """
- modifiers = QtWidgets.QApplication.keyboardModifiers()
- active = self.app.collection.get_active()
- selected = self.app.collection.get_selected()
- names_list = self.app.collection.get_names()
- matplotlib_key_flag = False
- # events out of the self.app.collection view (it's about Project Tab) are of type int
- if type(event) is int:
- key = event
- # events from the GUI are of type QKeyEvent
- elif type(event) == QtGui.QKeyEvent:
- key = event.key()
- elif isinstance(event, mpl_key_event): # MatPlotLib key events are trickier to interpret than the rest
- matplotlib_key_flag = True
- key = event.key
- key = QtGui.QKeySequence(key)
- # check for modifiers
- key_string = key.toString().lower()
- if '+' in key_string:
- mod, __, key_text = key_string.rpartition('+')
- if mod.lower() == 'ctrl':
- modifiers = QtCore.Qt.ControlModifier
- elif mod.lower() == 'alt':
- modifiers = QtCore.Qt.AltModifier
- elif mod.lower() == 'shift':
- modifiers = QtCore.Qt.ShiftModifier
- else:
- modifiers = QtCore.Qt.NoModifier
- key = QtGui.QKeySequence(key_text)
- # events from Vispy are of type KeyEvent
- else:
- key = event.key
- if self.app.call_source == 'app':
- if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
- if key == QtCore.Qt.Key_X:
- self.app.abort_all_tasks()
- return
- if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier:
- if key == QtCore.Qt.Key_S:
- self.app.on_file_saveprojectas()
- return
- elif modifiers == QtCore.Qt.ControlModifier:
- # Select All
- if key == QtCore.Qt.Key_A:
- self.app.on_selectall()
- # Copy an FlatCAM object
- if key == QtCore.Qt.Key_C:
- widget_name = self.plot_tab_area.currentWidget().objectName()
- if widget_name == 'database_tab':
- # Tools DB saved, update flag
- self.app.tools_db_changed_flag = True
- self.app.tools_db_tab.on_tool_copy()
- return
- self.app.on_copy_command()
- # Copy an FlatCAM object
- if key == QtCore.Qt.Key_D:
- self.app.on_tools_database()
- # Open Excellon file
- if key == QtCore.Qt.Key_E:
- self.app.on_fileopenexcellon(signal=None)
- # Open Gerber file
- if key == QtCore.Qt.Key_G:
- widget_name = self.plot_tab_area.currentWidget().objectName()
- if 'editor' in widget_name.lower():
- self.app.goto_text_line()
- else:
- self.app.on_fileopengerber(signal=None)
- # Distance Tool
- if key == QtCore.Qt.Key_M:
- self.app.distance_tool.run()
- # Create New Project
- if key == QtCore.Qt.Key_N:
- self.app.on_file_new_click()
- # Open Project
- if key == QtCore.Qt.Key_O:
- self.app.on_file_openproject()
- # Open Project
- if key == QtCore.Qt.Key_P:
- self.app.on_file_save_objects_pdf(use_thread=True)
- # PDF Import
- if key == QtCore.Qt.Key_Q:
- self.app.pdf_tool.run()
- # Save Project
- if key == QtCore.Qt.Key_S:
- widget_name = self.plot_tab_area.currentWidget().objectName()
- if widget_name == 'preferences_tab':
- self.app.on_save_button(save_to_file=False)
- return
- if widget_name == 'database_tab':
- # Tools DB saved, update flag
- self.app.tools_db_changed_flag = False
- self.app.tools_db_tab.on_save_tools_db()
- return
- self.app.on_file_saveproject()
- # Toggle Plot Area
- if key == QtCore.Qt.Key_F10 or key == 'F10':
- self.app.on_toggle_plotarea()
- return
- elif modifiers == QtCore.Qt.ShiftModifier:
- # Copy Object Name
- if key == QtCore.Qt.Key_C:
- self.app.on_copy_name()
- # Toggle Code Editor
- if key == QtCore.Qt.Key_E:
- self.app.on_toggle_code_editor()
- # Toggle axis
- if key == QtCore.Qt.Key_G:
- self.app.on_toggle_axis()
- # Locate in Object
- if key == QtCore.Qt.Key_J:
- self.app.on_locate(obj=self.app.collection.get_active())
- # Run Distance Minimum Tool
- if key == QtCore.Qt.Key_M:
- self.app.distance_min_tool.run()
- return
- # Open Preferences Window
- if key == QtCore.Qt.Key_P:
- self.app.on_preferences()
- return
- # Rotate Object by 90 degree CCW
- if key == QtCore.Qt.Key_R:
- self.app.on_rotate(silent=True, preset=-float(self.app.defaults['tools_transform_rotate']))
- return
- # Run a Script
- if key == QtCore.Qt.Key_S:
- self.app.on_filerunscript()
- return
- # Toggle Workspace
- if key == QtCore.Qt.Key_W:
- self.app.on_workspace_toggle()
- return
- # Skew on X axis
- if key == QtCore.Qt.Key_X:
- self.app.on_skewx()
- return
- # Skew on Y axis
- if key == QtCore.Qt.Key_Y:
- self.app.on_skewy()
- return
- elif modifiers == QtCore.Qt.AltModifier:
- # Eanble all plots
- if key == Qt.Key_1:
- self.app.enable_all_plots()
- # Disable all plots
- if key == Qt.Key_2:
- self.app.disable_all_plots()
- # Disable all other plots
- if key == Qt.Key_3:
- self.app.disable_other_plots()
- # Align in Object Tool
- if key == QtCore.Qt.Key_A:
- self.app.align_objects_tool.run(toggle=True)
- # Calculator Tool
- if key == QtCore.Qt.Key_C:
- self.app.calculator_tool.run(toggle=True)
- # 2-Sided PCB Tool
- if key == QtCore.Qt.Key_D:
- self.app.dblsidedtool.run(toggle=True)
- return
- # Calibration Tool
- if key == QtCore.Qt.Key_E:
- self.app.cal_exc_tool.run(toggle=True)
- return
- # Copper Thieving Tool
- if key == QtCore.Qt.Key_F:
- self.app.copper_thieving_tool.run(toggle=True)
- return
- # Toggle Grid lines
- if key == QtCore.Qt.Key_G:
- self.app.on_toggle_grid_lines()
- return
- # Align in Object Tool
- if key == QtCore.Qt.Key_H:
- self.app.punch_tool.run(toggle=True)
- # Extract Drills Tool
- if key == QtCore.Qt.Key_I:
- self.app.edrills_tool.run(toggle=True)
- # Fiducials Tool
- if key == QtCore.Qt.Key_J:
- self.app.fiducial_tool.run(toggle=True)
- return
- # Solder Paste Dispensing Tool
- if key == QtCore.Qt.Key_K:
- self.app.paste_tool.run(toggle=True)
- return
- # Film Tool
- if key == QtCore.Qt.Key_L:
- self.app.film_tool.run(toggle=True)
- return
- # Non-Copper Clear Tool
- if key == QtCore.Qt.Key_N:
- self.app.ncclear_tool.run(toggle=True)
- return
- # Optimal Tool
- if key == QtCore.Qt.Key_O:
- self.app.optimal_tool.run(toggle=True)
- return
- # Paint Tool
- if key == QtCore.Qt.Key_P:
- self.app.paint_tool.run(toggle=True)
- return
- # QRCode Tool
- if key == QtCore.Qt.Key_Q:
- self.app.qrcode_tool.run()
- return
- # Rules Tool
- if key == QtCore.Qt.Key_R:
- self.app.rules_tool.run(toggle=True)
- return
- # View Source Object Content
- if key == QtCore.Qt.Key_S:
- self.app.on_view_source()
- return
- # Transformation Tool
- if key == QtCore.Qt.Key_T:
- self.app.transform_tool.run(toggle=True)
- return
- # Substract Tool
- if key == QtCore.Qt.Key_W:
- self.app.sub_tool.run(toggle=True)
- return
- # Cutout Tool
- if key == QtCore.Qt.Key_X:
- self.app.cutout_tool.run(toggle=True)
- return
- # Panelize Tool
- if key == QtCore.Qt.Key_Z:
- self.app.panelize_tool.run(toggle=True)
- return
- # Toggle Fullscreen
- if key == QtCore.Qt.Key_F10 or key == 'F10':
- self.app.on_fullscreen()
- return
- elif modifiers == QtCore.Qt.NoModifier:
- # Open Manual
- if key == QtCore.Qt.Key_F1 or key == 'F1':
- webbrowser.open(self.app.manual_url)
- # Show shortcut list
- if key == QtCore.Qt.Key_F3 or key == 'F3':
- self.app.on_shortcut_list()
- # Open Video Help
- if key == QtCore.Qt.Key_F4 or key == 'F4':
- webbrowser.open(self.app.video_url)
- # Open Video Help
- if key == QtCore.Qt.Key_F5 or key == 'F5':
- self.app.plot_all()
- # Switch to Project Tab
- if key == QtCore.Qt.Key_1:
- self.app.on_select_tab('project')
- # Switch to Selected Tab
- if key == QtCore.Qt.Key_2:
- self.app.on_select_tab('selected')
- # Switch to Tool Tab
- if key == QtCore.Qt.Key_3:
- self.app.on_select_tab('tool')
- # Delete from PyQt
- # It's meant to make a difference between delete objects and delete tools in
- # Geometry Selected tool table
- if key == QtCore.Qt.Key_Delete and matplotlib_key_flag is False:
- widget_name = self.plot_tab_area.currentWidget().objectName()
- if widget_name == 'database_tab':
- # Tools DB saved, update flag
- self.app.tools_db_changed_flag = True
- self.app.tools_db_tab.on_tool_delete()
- return
- self.app.on_delete_keypress()
- # Delete from canvas
- if key == 'Delete':
- # Delete via the application to
- # ensure cleanup of the GUI
- if active:
- active.app.on_delete()
- # Escape = Deselect All
- if key == QtCore.Qt.Key_Escape or key == 'Escape':
- self.app.on_deselect_all()
- # if in full screen, exit to normal view
- if self.app.toggle_fscreen is True:
- self.app.on_fullscreen(disable=True)
- # try to disconnect the slot from Set Origin
- try:
- self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_set_zero_click)
- except TypeError:
- pass
- self.app.inform.emit("")
- # Space = Toggle Active/Inactive
- if key == QtCore.Qt.Key_Space:
- for select in selected:
- select.ui.plot_cb.toggle()
- self.app.collection.update_view()
- self.app.delete_selection_shape()
- # Select the object in the Tree above the current one
- if key == QtCore.Qt.Key_Up:
- # make sure it works only for the Project Tab who is an instance of KeySensitiveListView
- focused_wdg = QtWidgets.QApplication.focusWidget()
- if isinstance(focused_wdg, KeySensitiveListView):
- self.app.collection.set_all_inactive()
- if active is None:
- return
- active_name = active.options['name']
- active_index = names_list.index(active_name)
- if active_index == 0:
- self.app.collection.set_active(names_list[-1])
- else:
- self.app.collection.set_active(names_list[active_index-1])
- # Select the object in the Tree bellow the current one
- if key == QtCore.Qt.Key_Down:
- # make sure it works only for the Project Tab who is an instance of KeySensitiveListView
- focused_wdg = QtWidgets.QApplication.focusWidget()
- if isinstance(focused_wdg, KeySensitiveListView):
- self.app.collection.set_all_inactive()
- if active is None:
- return
- active_name = active.options['name']
- active_index = names_list.index(active_name)
- if active_index == len(names_list) - 1:
- self.app.collection.set_active(names_list[0])
- else:
- self.app.collection.set_active(names_list[active_index+1])
- # New Geometry
- if key == QtCore.Qt.Key_B:
- self.app.new_gerber_object()
- # New Geometry
- if key == QtCore.Qt.Key_D:
- self.app.new_document_object()
- # Copy Object Name
- if key == QtCore.Qt.Key_E:
- self.app.object2editor()
- # Grid toggle
- if key == QtCore.Qt.Key_G:
- self.app.ui.grid_snap_btn.trigger()
- # Jump to coords
- if key == QtCore.Qt.Key_J:
- self.app.on_jump_to()
- # New Excellon
- if key == QtCore.Qt.Key_L:
- self.app.new_excellon_object()
- # Move tool toggle
- if key == QtCore.Qt.Key_M:
- self.app.move_tool.toggle()
- # New Geometry
- if key == QtCore.Qt.Key_N:
- self.app.new_geometry_object()
- # Set Origin
- if key == QtCore.Qt.Key_O:
- self.app.on_set_origin()
- return
- # Properties Tool
- if key == QtCore.Qt.Key_P:
- self.app.properties_tool.run()
- return
- # Change Units
- if key == QtCore.Qt.Key_Q:
- # if self.app.defaults["units"] == 'MM':
- # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
- # else:
- # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
- # self.app.on_toggle_units(no_pref=True)
- self.app.on_toggle_units_click()
- # Rotate Object by 90 degree CW
- if key == QtCore.Qt.Key_R:
- self.app.on_rotate(silent=True, preset=self.app.defaults['tools_transform_rotate'])
- # Shell toggle
- if key == QtCore.Qt.Key_S:
- self.app.toggle_shell()
- # Add a Tool from shortcut
- if key == QtCore.Qt.Key_T:
- widget_name = self.plot_tab_area.currentWidget().objectName()
- if widget_name == 'database_tab':
- # Tools DB saved, update flag
- self.app.tools_db_changed_flag = True
- self.app.tools_db_tab.on_tool_add()
- return
- self.app.on_tool_add_keypress()
- # Zoom Fit
- if key == QtCore.Qt.Key_V:
- self.app.on_zoom_fit(None)
- # Mirror on X the selected object(s)
- if key == QtCore.Qt.Key_X:
- self.app.on_flipx()
- # Mirror on Y the selected object(s)
- if key == QtCore.Qt.Key_Y:
- self.app.on_flipy()
- # Zoom In
- if key == QtCore.Qt.Key_Equal:
- self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], self.app.mouse)
- # Zoom Out
- if key == QtCore.Qt.Key_Minus:
- self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], self.app.mouse)
- # toggle display of Notebook area
- if key == QtCore.Qt.Key_QuoteLeft:
- self.app.on_toggle_notebook()
- return
- elif self.app.call_source == 'geo_editor':
- if modifiers == QtCore.Qt.ControlModifier:
- # save (update) the current geometry and return to the App
- if key == QtCore.Qt.Key_S or key == 'S':
- self.app.editor2object()
- return
- # toggle the measurement tool
- if key == QtCore.Qt.Key_M or key == 'M':
- self.app.distance_tool.run()
- return
- # Cut Action Tool
- if key == QtCore.Qt.Key_X or key == 'X':
- if self.app.geo_editor.get_selected() is not None:
- self.app.geo_editor.cutpath()
- else:
- msg = _('Please first select a geometry item to be cutted\n'
- 'then select the geometry item that will be cutted\n'
- 'out of the first item. In the end press ~X~ key or\n'
- 'the toolbar button.')
- messagebox = QtWidgets.QMessageBox()
- messagebox.setText(msg)
- messagebox.setWindowTitle(_("Warning"))
- messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
- messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
- messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
- messagebox.exec_()
- return
- elif modifiers == QtCore.Qt.ShiftModifier:
- # Run Distance Minimum Tool
- if key == QtCore.Qt.Key_M or key == 'M':
- self.app.distance_min_tool.run()
- return
- # Skew on X axis
- if key == QtCore.Qt.Key_X or key == 'X':
- self.app.geo_editor.transform_tool.on_skewx_key()
- return
- # Skew on Y axis
- if key == QtCore.Qt.Key_Y or key == 'Y':
- self.app.geo_editor.transform_tool.on_skewy_key()
- return
- elif modifiers == QtCore.Qt.AltModifier:
- # Transformation Tool
- if key == QtCore.Qt.Key_R or key == 'R':
- self.app.geo_editor.select_tool('transform')
- return
- # Offset on X axis
- if key == QtCore.Qt.Key_X or key == 'X':
- self.app.geo_editor.transform_tool.on_offx_key()
- return
- # Offset on Y axis
- if key == QtCore.Qt.Key_Y or key == 'Y':
- self.app.geo_editor.transform_tool.on_offy_key()
- return
- elif modifiers == QtCore.Qt.NoModifier:
- # toggle display of Notebook area
- if key == QtCore.Qt.Key_QuoteLeft or key == '`':
- self.app.on_toggle_notebook()
- # Finish the current action. Use with tools that do not
- # complete automatically, like a polygon or path.
- if key == QtCore.Qt.Key_Enter or key == 'Enter':
- if isinstance(self.app.geo_editor.active_tool, FCShapeTool):
- if self.app.geo_editor.active_tool.name == 'rotate':
- self.app.geo_editor.active_tool.make()
- if self.app.geo_editor.active_tool.complete:
- self.app.geo_editor.on_shape_complete()
- self.app.inform.emit('[success] %s' % _("Done."))
- # automatically make the selection tool active after completing current action
- self.app.geo_editor.select_tool('select')
- return
- else:
- self.app.geo_editor.active_tool.click(
- self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
- self.app.geo_editor.active_tool.make()
- if self.app.geo_editor.active_tool.complete:
- self.app.geo_editor.on_shape_complete()
- self.app.inform.emit('[success] %s' % _("Done."))
- # automatically make the selection tool active after completing current action
- self.app.geo_editor.select_tool('select')
- # Abort the current action
- if key == QtCore.Qt.Key_Escape or key == 'Escape':
- # self.on_tool_select("select")
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
- self.app.geo_editor.delete_utility_geometry()
- self.app.geo_editor.active_tool.clean_up()
- self.app.geo_editor.select_tool('select')
- # hide the notebook
- self.app.ui.splitter.setSizes([0, 1])
- return
- # Delete selected object
- if key == QtCore.Qt.Key_Delete or key == 'Delete':
- self.app.geo_editor.delete_selected()
- self.app.geo_editor.replot()
- # Rotate
- if key == QtCore.Qt.Key_Space or key == 'Space':
- self.app.geo_editor.transform_tool.on_rotate_key()
- # Zoom Out
- if key == QtCore.Qt.Key_Minus or key == '-':
- self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
- [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
- # Zoom In
- if key == QtCore.Qt.Key_Equal or key == '=':
- self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
- [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
- # Switch to Project Tab
- if key == QtCore.Qt.Key_1 or key == '1':
- self.app.on_select_tab('project')
- # Switch to Selected Tab
- if key == QtCore.Qt.Key_2 or key == '2':
- self.app.on_select_tab('selected')
- # Switch to Tool Tab
- if key == QtCore.Qt.Key_3 or key == '3':
- self.app.on_select_tab('tool')
- # Grid Snap
- if key == QtCore.Qt.Key_G or key == 'G':
- self.app.ui.grid_snap_btn.trigger()
- # make sure that the cursor shape is enabled/disabled, too
- if self.app.geo_editor.options['grid_snap'] is True:
- self.app.app_cursor.enabled = True
- else:
- self.app.app_cursor.enabled = False
- # Corner Snap
- if key == QtCore.Qt.Key_K or key == 'K':
- self.app.geo_editor.on_corner_snap()
- if key == QtCore.Qt.Key_V or key == 'V':
- self.app.on_zoom_fit(None)
- # we do this so we can reuse the following keys while inside a Tool
- # the above keys are general enough so were left outside
- if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() is False:
- response = self.app.geo_editor.active_tool.on_key(key=key)
- if response is not None:
- self.app.inform.emit(response)
- else:
- # Arc Tool
- if key == QtCore.Qt.Key_A or key == 'A':
- self.app.geo_editor.select_tool('arc')
- # Buffer
- if key == QtCore.Qt.Key_B or key == 'B':
- self.app.geo_editor.select_tool('buffer')
- # Copy
- if key == QtCore.Qt.Key_C or key == 'C':
- self.app.geo_editor.on_copy_click()
- # Substract Tool
- if key == QtCore.Qt.Key_E or key == 'E':
- if self.app.geo_editor.get_selected() is not None:
- self.app.geo_editor.intersection()
- else:
- msg = _("Please select geometry items \n"
- "on which to perform Intersection Tool.")
- messagebox = QtWidgets.QMessageBox()
- messagebox.setText(msg)
- messagebox.setWindowTitle(_("Warning"))
- messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
- messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
- messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
- messagebox.exec_()
- # Paint
- if key == QtCore.Qt.Key_I or key == 'I':
- self.app.geo_editor.select_tool('paint')
- # Jump to coords
- if key == QtCore.Qt.Key_J or key == 'J':
- self.app.on_jump_to()
- # Move
- if key == QtCore.Qt.Key_M or key == 'M':
- self.app.geo_editor.on_move_click()
- # Polygon Tool
- if key == QtCore.Qt.Key_N or key == 'N':
- self.app.geo_editor.select_tool('polygon')
- # Circle Tool
- if key == QtCore.Qt.Key_O or key == 'O':
- self.app.geo_editor.select_tool('circle')
- # Path Tool
- if key == QtCore.Qt.Key_P or key == 'P':
- self.app.geo_editor.select_tool('path')
- # Rectangle Tool
- if key == QtCore.Qt.Key_R or key == 'R':
- self.app.geo_editor.select_tool('rectangle')
- # Substract Tool
- if key == QtCore.Qt.Key_S or key == 'S':
- if self.app.geo_editor.get_selected() is not None:
- self.app.geo_editor.subtract()
- else:
- msg = _(
- "Please select geometry items \n"
- "on which to perform Substraction Tool.")
- messagebox = QtWidgets.QMessageBox()
- messagebox.setText(msg)
- messagebox.setWindowTitle(_("Warning"))
- messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
- messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
- messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
- messagebox.exec_()
- # Add Text Tool
- if key == QtCore.Qt.Key_T or key == 'T':
- self.app.geo_editor.select_tool('text')
- # Substract Tool
- if key == QtCore.Qt.Key_U or key == 'U':
- if self.app.geo_editor.get_selected() is not None:
- self.app.geo_editor.union()
- else:
- msg = _("Please select geometry items \n"
- "on which to perform union.")
- messagebox = QtWidgets.QMessageBox()
- messagebox.setText(msg)
- messagebox.setWindowTitle(_("Warning"))
- messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
- messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
- messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
- messagebox.exec_()
- # Flip on X axis
- if key == QtCore.Qt.Key_X or key == 'X':
- self.app.geo_editor.transform_tool.on_flipx()
- return
- # Flip on Y axis
- if key == QtCore.Qt.Key_Y or key == 'Y':
- self.app.geo_editor.transform_tool.on_flipy()
- return
- # Show Shortcut list
- if key == 'F3':
- self.app.on_shortcut_list()
- elif self.app.call_source == 'grb_editor':
- if modifiers == QtCore.Qt.ControlModifier:
- # Eraser Tool
- if key == QtCore.Qt.Key_E or key == 'E':
- self.app.grb_editor.on_eraser()
- return
- # save (update) the current geometry and return to the App
- if key == QtCore.Qt.Key_S or key == 'S':
- self.app.editor2object()
- return
- # toggle the measurement tool
- if key == QtCore.Qt.Key_M or key == 'M':
- self.app.distance_tool.run()
- return
- elif modifiers == QtCore.Qt.ShiftModifier:
- # Run Distance Minimum Tool
- if key == QtCore.Qt.Key_M or key == 'M':
- self.app.distance_min_tool.run()
- return
- elif modifiers == QtCore.Qt.AltModifier:
- # Mark Area Tool
- if key == QtCore.Qt.Key_A or key == 'A':
- self.app.grb_editor.on_markarea()
- return
- # Poligonize Tool
- if key == QtCore.Qt.Key_N or key == 'N':
- self.app.grb_editor.on_poligonize()
- return
- # Transformation Tool
- if key == QtCore.Qt.Key_R or key == 'R':
- self.app.grb_editor.on_transform()
- return
- elif modifiers == QtCore.Qt.NoModifier:
- # Abort the current action
- if key == QtCore.Qt.Key_Escape or key == 'Escape':
- # self.on_tool_select("select")
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
- self.app.grb_editor.delete_utility_geometry()
- # self.app.grb_editor.plot_all()
- self.app.grb_editor.active_tool.clean_up()
- self.app.grb_editor.select_tool('select')
- return
- # Delete selected object if delete key event comes out of canvas
- if key == 'Delete':
- self.app.grb_editor.launched_from_shortcuts = True
- if self.app.grb_editor.selected:
- self.app.grb_editor.delete_selected()
- self.app.grb_editor.plot_all()
- else:
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to delete."))
- return
- # Delete aperture in apertures table if delete key event comes from the Selected Tab
- if key == QtCore.Qt.Key_Delete:
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.grb_editor.on_aperture_delete()
- return
- if key == QtCore.Qt.Key_Minus or key == '-':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
- [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
- return
- if key == QtCore.Qt.Key_Equal or key == '=':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
- [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
- return
- # toggle display of Notebook area
- if key == QtCore.Qt.Key_QuoteLeft or key == '`':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.on_toggle_notebook()
- return
- # Rotate
- if key == QtCore.Qt.Key_Space or key == 'Space':
- self.app.grb_editor.transform_tool.on_rotate_key()
- # Switch to Project Tab
- if key == QtCore.Qt.Key_1 or key == '1':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.on_select_tab('project')
- return
- # Switch to Selected Tab
- if key == QtCore.Qt.Key_2 or key == '2':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.on_select_tab('selected')
- return
- # Switch to Tool Tab
- if key == QtCore.Qt.Key_3 or key == '3':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.on_select_tab('tool')
- return
- # we do this so we can reuse the following keys while inside a Tool
- # the above keys are general enough so were left outside
- if self.app.grb_editor.active_tool is not None and self.grb_select_btn.isChecked() is False:
- response = self.app.grb_editor.active_tool.on_key(key=key)
- if response is not None:
- self.app.inform.emit(response)
- else:
- # Add Array of pads
- if key == QtCore.Qt.Key_A or key == 'A':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.inform.emit("Click on target point.")
- self.app.ui.add_pad_ar_btn.setChecked(True)
- self.app.grb_editor.x = self.app.mouse[0]
- self.app.grb_editor.y = self.app.mouse[1]
- self.app.grb_editor.select_tool('array')
- return
- # Scale Tool
- if key == QtCore.Qt.Key_B or key == 'B':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.grb_editor.select_tool('buffer')
- return
- # Copy
- if key == QtCore.Qt.Key_C or key == 'C':
- self.app.grb_editor.launched_from_shortcuts = True
- if self.app.grb_editor.selected:
- self.app.inform.emit(_("Click on target point."))
- self.app.ui.aperture_copy_btn.setChecked(True)
- self.app.grb_editor.on_tool_select('copy')
- self.app.grb_editor.active_tool.set_origin(
- (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
- else:
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to copy."))
- return
- # Add Disc Tool
- if key == QtCore.Qt.Key_D or key == 'D':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.grb_editor.select_tool('disc')
- return
- # Add SemiDisc Tool
- if key == QtCore.Qt.Key_E or key == 'E':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.grb_editor.select_tool('semidisc')
- return
- # Grid Snap
- if key == QtCore.Qt.Key_G or key == 'G':
- self.app.grb_editor.launched_from_shortcuts = True
- # make sure that the cursor shape is enabled/disabled, too
- if self.app.grb_editor.options['grid_snap'] is True:
- self.app.app_cursor.enabled = False
- else:
- self.app.app_cursor.enabled = True
- self.app.ui.grid_snap_btn.trigger()
- return
- # Jump to coords
- if key == QtCore.Qt.Key_J or key == 'J':
- self.app.on_jump_to()
- # Corner Snap
- if key == QtCore.Qt.Key_K or key == 'K':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.ui.corner_snap_btn.trigger()
- return
- # Move
- if key == QtCore.Qt.Key_M or key == 'M':
- self.app.grb_editor.launched_from_shortcuts = True
- if self.app.grb_editor.selected:
- self.app.inform.emit(_("Click on target point."))
- self.app.ui.aperture_move_btn.setChecked(True)
- self.app.grb_editor.on_tool_select('move')
- self.app.grb_editor.active_tool.set_origin(
- (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
- else:
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to move."))
- return
- # Add Region Tool
- if key == QtCore.Qt.Key_N or key == 'N':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.grb_editor.select_tool('region')
- return
- # Add Pad Tool
- if key == QtCore.Qt.Key_P or key == 'P':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.inform.emit(_("Click on target point."))
- self.app.ui.add_pad_ar_btn.setChecked(True)
- self.app.grb_editor.x = self.app.mouse[0]
- self.app.grb_editor.y = self.app.mouse[1]
- self.app.grb_editor.select_tool('pad')
- return
- # Scale Tool
- if key == QtCore.Qt.Key_S or key == 'S':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.grb_editor.select_tool('scale')
- return
- # Add Track
- if key == QtCore.Qt.Key_T or key == 'T':
- self.app.grb_editor.launched_from_shortcuts = True
- # ## Current application units in Upper Case
- self.app.grb_editor.select_tool('track')
- return
- # Zoom Fit
- if key == QtCore.Qt.Key_V or key == 'V':
- self.app.grb_editor.launched_from_shortcuts = True
- self.app.on_zoom_fit(None)
- return
- # Show Shortcut list
- if key == QtCore.Qt.Key_F3 or key == 'F3':
- self.app.on_shortcut_list()
- return
- elif self.app.call_source == 'exc_editor':
- if modifiers == QtCore.Qt.ControlModifier:
- # save (update) the current geometry and return to the App
- if key == QtCore.Qt.Key_S or key == 'S':
- self.app.editor2object()
- return
- # toggle the measurement tool
- if key == QtCore.Qt.Key_M or key == 'M':
- self.app.distance_tool.run()
- return
- elif modifiers == QtCore.Qt.ShiftModifier:
- # Run Distance Minimum Tool
- if key == QtCore.Qt.Key_M or key == 'M':
- self.app.distance_min_tool.run()
- return
- elif modifiers == QtCore.Qt.AltModifier:
- pass
- elif modifiers == QtCore.Qt.NoModifier:
- # Abort the current action
- if key == QtCore.Qt.Key_Escape or key == 'Escape':
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
- self.app.exc_editor.delete_utility_geometry()
- self.app.exc_editor.active_tool.clean_up()
- self.app.exc_editor.select_tool('drill_select')
- return
- # Delete selected object if delete key event comes out of canvas
- if key == 'Delete':
- self.app.exc_editor.launched_from_shortcuts = True
- if self.app.exc_editor.selected:
- self.app.exc_editor.delete_selected()
- self.app.exc_editor.replot()
- else:
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to delete."))
- return
- # Delete tools in tools table if delete key event comes from the Selected Tab
- if key == QtCore.Qt.Key_Delete:
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.exc_editor.on_tool_delete()
- return
- if key == QtCore.Qt.Key_Minus or key == '-':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
- [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
- return
- if key == QtCore.Qt.Key_Equal or key == '=':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
- [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
- return
- # toggle display of Notebook area
- if key == QtCore.Qt.Key_QuoteLeft or key == '`':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.on_toggle_notebook()
- return
- # Switch to Project Tab
- if key == QtCore.Qt.Key_1 or key == '1':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.on_select_tab('project')
- return
- # Switch to Selected Tab
- if key == QtCore.Qt.Key_2 or key == '2':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.on_select_tab('selected')
- return
- # Switch to Tool Tab
- if key == QtCore.Qt.Key_3 or key == '3':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.on_select_tab('tool')
- return
- # Grid Snap
- if key == QtCore.Qt.Key_G or key == 'G':
- self.app.exc_editor.launched_from_shortcuts = True
- # make sure that the cursor shape is enabled/disabled, too
- if self.app.exc_editor.options['grid_snap'] is True:
- self.app.app_cursor.enabled = False
- else:
- self.app.app_cursor.enabled = True
- self.app.ui.grid_snap_btn.trigger()
- return
- # Corner Snap
- if key == QtCore.Qt.Key_K or key == 'K':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.ui.corner_snap_btn.trigger()
- return
- # Zoom Fit
- if key == QtCore.Qt.Key_V or key == 'V':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.on_zoom_fit(None)
- return
- # Add Slot Hole Tool
- if key == QtCore.Qt.Key_W or key == 'W':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.inform.emit(_("Click on target point."))
- self.app.ui.add_slot_btn.setChecked(True)
- self.app.exc_editor.x = self.app.mouse[0]
- self.app.exc_editor.y = self.app.mouse[1]
- self.app.exc_editor.select_tool('slot_add')
- return
- # Propagate to tool
- # Show Shortcut list
- if key == QtCore.Qt.Key_F3 or key == 'F3':
- self.app.on_shortcut_list()
- return
- # we do this so we can reuse the following keys while inside a Tool
- # the above keys are general enough so were left outside
- if self.app.exc_editor.active_tool is not None and self.select_drill_btn.isChecked() is False:
- response = self.app.exc_editor.active_tool.on_key(key=key)
- if response is not None:
- self.app.inform.emit(response)
- else:
- # Add Array of Drill Hole Tool
- if key == QtCore.Qt.Key_A or key == 'A':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.inform.emit("Click on target point.")
- self.app.ui.add_drill_array_btn.setChecked(True)
- self.app.exc_editor.x = self.app.mouse[0]
- self.app.exc_editor.y = self.app.mouse[1]
- self.app.exc_editor.select_tool('drill_array')
- return
- # Copy
- if key == QtCore.Qt.Key_C or key == 'C':
- self.app.exc_editor.launched_from_shortcuts = True
- if self.app.exc_editor.selected:
- self.app.inform.emit(_("Click on target point."))
- self.app.ui.copy_drill_btn.setChecked(True)
- self.app.exc_editor.on_tool_select('drill_copy')
- self.app.exc_editor.active_tool.set_origin(
- (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
- else:
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to copy."))
- return
- # Add Drill Hole Tool
- if key == QtCore.Qt.Key_D or key == 'D':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.inform.emit(_("Click on target point."))
- self.app.ui.add_drill_btn.setChecked(True)
- self.app.exc_editor.x = self.app.mouse[0]
- self.app.exc_editor.y = self.app.mouse[1]
- self.app.exc_editor.select_tool('drill_add')
- return
- # Jump to coords
- if key == QtCore.Qt.Key_J or key == 'J':
- self.app.on_jump_to()
- # Move
- if key == QtCore.Qt.Key_M or key == 'M':
- self.app.exc_editor.launched_from_shortcuts = True
- if self.app.exc_editor.selected:
- self.app.inform.emit(_("Click on target point."))
- self.app.ui.move_drill_btn.setChecked(True)
- self.app.exc_editor.on_tool_select('drill_move')
- self.app.exc_editor.active_tool.set_origin(
- (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
- else:
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to move."))
- return
- # Add Array of Slots Hole Tool
- if key == QtCore.Qt.Key_Q or key == 'Q':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.inform.emit("Click on target point.")
- self.app.ui.add_slot_array_btn.setChecked(True)
- self.app.exc_editor.x = self.app.mouse[0]
- self.app.exc_editor.y = self.app.mouse[1]
- self.app.exc_editor.select_tool('slot_array')
- return
- # Resize Tool
- if key == QtCore.Qt.Key_R or key == 'R':
- self.app.exc_editor.launched_from_shortcuts = True
- self.app.exc_editor.select_tool('drill_resize')
- return
- # Add Tool
- if key == QtCore.Qt.Key_T or key == 'T':
- self.app.exc_editor.launched_from_shortcuts = True
- # ## Current application units in Upper Case
- self.units = self.general_defaults_form.general_app_group.units_radio.get_value().upper()
- tool_add_popup = FCInputDialog(title=_("New Tool ..."),
- text='%s:' % _('Enter a Tool Diameter'),
- min=0.0000, max=99.9999, decimals=4)
- tool_add_popup.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/letter_t_32.png'))
- val, ok = tool_add_popup.get_value()
- if ok:
- self.app.exc_editor.on_tool_add(tooldia=val)
- formated_val = '%.*f' % (self.decimals, float(val))
- self.app.inform.emit(
- '[success] %s: %s %s' % (_("Added new tool with dia"), formated_val, str(self.units))
- )
- else:
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Adding Tool cancelled ..."))
- return
- elif self.app.call_source == 'measurement':
- if modifiers == QtCore.Qt.ControlModifier:
- pass
- elif modifiers == QtCore.Qt.AltModifier:
- pass
- elif modifiers == QtCore.Qt.ShiftModifier:
- pass
- elif modifiers == QtCore.Qt.NoModifier:
- if key == QtCore.Qt.Key_Escape or key == 'Escape':
- # abort the measurement action
- self.app.distance_tool.deactivate_measure_tool()
- self.app.inform.emit(_("Distance Tool exit..."))
- return
- if key == QtCore.Qt.Key_G or key == 'G':
- self.app.ui.grid_snap_btn.trigger()
- return
- # Jump to coords
- if key == QtCore.Qt.Key_J or key == 'J':
- self.app.on_jump_to()
- elif self.app.call_source == 'qrcode_tool':
- if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
- if key == QtCore.Qt.Key_X:
- self.app.abort_all_tasks()
- return
- elif modifiers == QtCore.Qt.ControlModifier:
- pass
- elif modifiers == QtCore.Qt.ShiftModifier:
- pass
- elif modifiers == QtCore.Qt.AltModifier:
- pass
- elif modifiers == QtCore.Qt.NoModifier:
- # Escape = Deselect All
- if key == QtCore.Qt.Key_Escape or key == 'Escape':
- self.app.qrcode_tool.on_exit()
- # Grid toggle
- if key == QtCore.Qt.Key_G:
- self.app.ui.grid_snap_btn.trigger()
- # Jump to coords
- if key == QtCore.Qt.Key_J:
- self.app.on_jump_to()
- elif self.app.call_source == 'copper_thieving_tool':
- if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
- if key == QtCore.Qt.Key_X:
- self.app.abort_all_tasks()
- return
- elif modifiers == QtCore.Qt.ControlModifier:
- pass
- elif modifiers == QtCore.Qt.ShiftModifier:
- pass
- elif modifiers == QtCore.Qt.AltModifier:
- pass
- elif modifiers == QtCore.Qt.NoModifier:
- # Escape = Deselect All
- if key == QtCore.Qt.Key_Escape or key == 'Escape':
- self.app.copperfill_tool.on_exit()
- # Grid toggle
- if key == QtCore.Qt.Key_G:
- self.app.ui.grid_snap_btn.trigger()
- # Jump to coords
- if key == QtCore.Qt.Key_J:
- self.app.on_jump_to()
- def createPopupMenu(self):
- menu = super().createPopupMenu()
- menu.addSeparator()
- menu.addAction(self.lock_action)
- return menu
- def lock_toolbar(self, lock=False):
- """
- Used to (un)lock the toolbars of the app.
- :param lock: boolean, will lock all toolbars in place when set True
- :return: None
- """
- if lock:
- for widget in self.children():
- if isinstance(widget, QtWidgets.QToolBar):
- widget.setMovable(False)
- else:
- for widget in self.children():
- if isinstance(widget, QtWidgets.QToolBar):
- widget.setMovable(True)
- def dragEnterEvent(self, event):
- if event.mimeData().hasUrls:
- event.accept()
- else:
- event.ignore()
- def dragMoveEvent(self, event):
- if event.mimeData().hasUrls:
- event.accept()
- else:
- event.ignore()
- def dropEvent(self, event):
- if event.mimeData().hasUrls:
- event.setDropAction(QtCore.Qt.CopyAction)
- event.accept()
- for url in event.mimeData().urls():
- self.filename = str(url.toLocalFile())
- if self.filename == "":
- self.app.inform.emit("Cancelled.")
- else:
- extension = self.filename.lower().rpartition('.')[-1]
- if extension in self.app.grb_list:
- self.app.worker_task.emit({'fcn': self.app.open_gerber,
- 'params': [self.filename]})
- else:
- event.ignore()
- if extension in self.app.exc_list:
- self.app.worker_task.emit({'fcn': self.app.open_excellon,
- 'params': [self.filename]})
- else:
- event.ignore()
- if extension in self.app.gcode_list:
- self.app.worker_task.emit({'fcn': self.app.open_gcode,
- 'params': [self.filename]})
- else:
- event.ignore()
- if extension in self.app.svg_list:
- object_type = 'geometry'
- self.app.worker_task.emit({'fcn': self.app.import_svg,
- 'params': [self.filename, object_type, None]})
- if extension in self.app.dxf_list:
- object_type = 'geometry'
- self.app.worker_task.emit({'fcn': self.app.import_dxf,
- 'params': [self.filename, object_type, None]})
- if extension in self.app.pdf_list:
- self.app.pdf_tool.periodic_check(1000)
- self.app.worker_task.emit({'fcn': self.app.pdf_tool.open_pdf,
- 'params': [self.filename]})
- if extension in self.app.prj_list:
- # self.app.open_project() is not Thread Safe
- self.app.open_project(self.filename)
- if extension in self.app.conf_list:
- self.app.open_config_file(self.filename)
- else:
- event.ignore()
- else:
- event.ignore()
- def closeEvent(self, event):
- if self.app.save_in_progress:
- self.app.inform.emit('[WARNING_NOTCL] %s' % _("Application is saving the project. Please wait ..."))
- else:
- grect = self.geometry()
- # self.splitter.sizes()[0] is actually the size of the "notebook"
- if not self.isMaximized():
- self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
- self.final_save.emit()
- event.ignore()
- class FlatCAMActivityView(QtWidgets.QWidget):
- """
- This class create and control the activity icon displayed in the App status bar
- """
- def __init__(self, app, parent=None):
- super().__init__(parent=parent)
- self.app = app
- if self.app.defaults["global_activity_icon"] == "Ball green":
- icon = self.app.resource_location + '/active_2_static.png'
- movie = self.app.resource_location + "/active_2.gif"
- elif self.app.defaults["global_activity_icon"] == "Ball black":
- icon = self.app.resource_location + '/active_static.png'
- movie = self.app.resource_location + "/active.gif"
- elif self.app.defaults["global_activity_icon"] == "Arrow green":
- icon = self.app.resource_location + '/active_3_static.png'
- movie = self.app.resource_location + "/active_3.gif"
- elif self.app.defaults["global_activity_icon"] == "Eclipse green":
- icon = self.app.resource_location + '/active_4_static.png'
- movie = self.app.resource_location + "/active_4.gif"
- else:
- icon = self.app.resource_location + '/active_static.png'
- movie = self.app.resource_location + "/active.gif"
- self.setMinimumWidth(200)
- self.movie_path = movie
- self.icon_path = icon
- self.icon = QtWidgets.QLabel(self)
- self.icon.setGeometry(0, 0, 16, 12)
- self.movie = QtGui.QMovie(self.movie_path)
- self.icon.setMovie(self.movie)
- # self.movie.start()
- layout = QtWidgets.QHBoxLayout()
- layout.setContentsMargins(5, 0, 5, 0)
- layout.setAlignment(QtCore.Qt.AlignLeft)
- self.setLayout(layout)
- layout.addWidget(self.icon)
- self.text = QtWidgets.QLabel(self)
- self.text.setText(_("Idle."))
- self.icon.setPixmap(QtGui.QPixmap(self.icon_path))
- layout.addWidget(self.text)
- def set_idle(self):
- self.movie.stop()
- self.text.setText(_("Idle."))
- def set_busy(self, msg, no_movie=None):
- if no_movie is not True:
- self.icon.setMovie(self.movie)
- self.movie.start()
- self.text.setText(msg)
- class FlatCAMInfoBar(QtWidgets.QWidget):
- """
- This class create a place to display the App messages in the Status Bar
- """
- def __init__(self, parent=None, app=None):
- super(FlatCAMInfoBar, self).__init__(parent=parent)
- self.app = app
- self.icon = QtWidgets.QLabel(self)
- self.icon.setGeometry(0, 0, 12, 12)
- self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png')
- self.icon.setPixmap(self.pmap)
- layout = QtWidgets.QHBoxLayout()
- layout.setContentsMargins(5, 0, 5, 0)
- self.setLayout(layout)
- layout.addWidget(self.icon)
- self.text = QtWidgets.QLabel(self)
- self.text.setText(_("Application started ..."))
- self.text.setToolTip(_("Hello!"))
- layout.addWidget(self.text)
- layout.addStretch()
- def set_text_(self, text, color=None):
- self.text.setText(text)
- self.text.setToolTip(text)
- if color:
- self.text.setStyleSheet('color: %s' % str(color))
- def set_status(self, text, level="info"):
- level = str(level)
- self.pmap.fill()
- if level == "ERROR" or level == "ERROR_NOTCL":
- self.pmap = QtGui.QPixmap(self.app.resource_location + '/redlight12.png')
- elif level.lower() == "success":
- self.pmap = QtGui.QPixmap(self.app.resource_location + '/greenlight12.png')
- elif level == "WARNING" or level == "WARNING_NOTCL":
- self.pmap = QtGui.QPixmap(self.app.resource_location + '/yellowlight12.png')
- elif level.lower() == "selected":
- self.pmap = QtGui.QPixmap(self.app.resource_location + '/bluelight12.png')
- else:
- self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png')
- try:
- self.set_text_(text)
- self.icon.setPixmap(self.pmap)
- except Exception as e:
- log.debug("FlatCAMInfoBar.set_status() --> %s" % str(e))
- class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon):
- """
- This class create the Sys Tray icon for the app
- """
- def __init__(self, app, icon, headless=None, parent=None):
- # QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
- super().__init__(icon, parent=parent)
- self.app = app
- menu = QtWidgets.QMenu(parent)
- menu_runscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/script14.png'),
- '%s' % _('Run Script ...'), self)
- menu_runscript.setToolTip(
- _("Will run the opened Tcl Script thus\n"
- "enabling the automation of certain\n"
- "functions of FlatCAM.")
- )
- menu.addAction(menu_runscript)
- menu.addSeparator()
- if headless is None:
- self.menu_open = menu.addMenu(QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'), _('Open'))
- # Open Project ...
- menu_openproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/folder16.png'),
- _('Open Project ...'), self)
- self.menu_open.addAction(menu_openproject)
- self.menu_open.addSeparator()
- # Open Gerber ...
- menu_opengerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/flatcam_icon24.png'),
- _('Open &Gerber ...\tCtrl+G'), self)
- self.menu_open.addAction(menu_opengerber)
- # Open Excellon ...
- menu_openexcellon = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'),
- _('Open &Excellon ...\tCtrl+E'), self)
- self.menu_open.addAction(menu_openexcellon)
- # Open G-Code ...
- menu_opengcode = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/code.png'),
- _('Open G-&Code ...'), self)
- self.menu_open.addAction(menu_opengcode)
- self.menu_open.addSeparator()
- menu_openproject.triggered.connect(self.app.on_file_openproject)
- menu_opengerber.triggered.connect(self.app.on_fileopengerber)
- menu_openexcellon.triggered.connect(self.app.on_fileopenexcellon)
- menu_opengcode.triggered.connect(self.app.on_fileopengcode)
- exitAction = menu.addAction(_("Exit"))
- exitAction.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png'))
- self.setContextMenu(menu)
- menu_runscript.triggered.connect(lambda: self.app.on_filerunscript(
- silent=True if self.app.cmd_line_headless == 1 else False))
- exitAction.triggered.connect(self.app.final_save)
- # end of file
|