FlatCAMGUI.py 268 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199
  1. ############################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # http://flatcam.org #
  4. # Author: Juan Pablo Caram (c) #
  5. # Date: 2/5/2014 #
  6. # MIT Licence #
  7. ############################################################
  8. ############################################################
  9. # File Modified (major mod): Marius Adrian Stanciu #
  10. # Date: 3/10/2019 #
  11. ############################################################
  12. from PyQt5.QtCore import QSettings
  13. from flatcamGUI.GUIElements import *
  14. import platform
  15. import webbrowser
  16. from flatcamEditors.FlatCAMGeoEditor import FCShapeTool
  17. import gettext
  18. import FlatCAMTranslation as fcTranslate
  19. fcTranslate.apply_language('strings')
  20. import builtins
  21. if '_' not in builtins.__dict__:
  22. _ = gettext.gettext
  23. class FlatCAMGUI(QtWidgets.QMainWindow):
  24. # Emitted when persistent window geometry needs to be retained
  25. geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
  26. final_save = QtCore.pyqtSignal(name='saveBeforeExit')
  27. def __init__(self, version, beta, app):
  28. super(FlatCAMGUI, self).__init__()
  29. self.app = app
  30. # Divine icon pack by Ipapun @ finicons.com
  31. #####################################
  32. ### BUILDING THE GUI IS DONE HERE ###
  33. #####################################
  34. ############
  35. ### Menu ###
  36. ############
  37. self.menu = self.menuBar()
  38. ### File ###
  39. self.menufile = self.menu.addMenu(_('&File'))
  40. self.menufile.setToolTipsVisible(True)
  41. # New Project
  42. self.menufilenewproject = QtWidgets.QAction(QtGui.QIcon('share/file16.png'),
  43. _('&New Project ...\tCTRL+N'), self)
  44. self.menufilenewproject.setToolTip(
  45. _("Will create a new, blank project")
  46. )
  47. self.menufile.addAction(self.menufilenewproject)
  48. # New Category (Excellon, Geometry)
  49. self.menufilenew = self.menufile.addMenu(QtGui.QIcon('share/file16.png'), _('&New'))
  50. self.menufilenew.setToolTipsVisible(True)
  51. self.menufilenewgeo = self.menufilenew.addAction(QtGui.QIcon('share/geometry16.png'), _('Geometry\tN'))
  52. self.menufilenewgeo.setToolTip(
  53. _("Will create a new, empty Geometry Object.")
  54. )
  55. self.menufilenewgrb = self.menufilenew.addAction(QtGui.QIcon('share/flatcam_icon32.png'), _('Gerber\tB'))
  56. self.menufilenewgrb.setToolTip(
  57. _("Will create a new, empty Gerber Object.")
  58. )
  59. self.menufilenewexc = self.menufilenew.addAction(QtGui.QIcon('share/drill16.png'), _('Excellon\tL'))
  60. self.menufilenewexc.setToolTip(
  61. _("Will create a new, empty Excellon Object.")
  62. )
  63. self.menufile_open = self.menufile.addMenu(QtGui.QIcon('share/folder32_bis.png'), _('Open'))
  64. self.menufile_open.setToolTipsVisible(True)
  65. # Open gerber ...
  66. self.menufileopengerber = QtWidgets.QAction(QtGui.QIcon('share/flatcam_icon24.png'),
  67. _('Open &Gerber ...\tCTRL+G'), self)
  68. self.menufile_open.addAction(self.menufileopengerber)
  69. self.menufile_open.addSeparator()
  70. # Open Excellon ...
  71. self.menufileopenexcellon = QtWidgets.QAction(QtGui.QIcon('share/open_excellon32.png'),
  72. _('Open &Excellon ...\tCTRL+E'),
  73. self)
  74. self.menufile_open.addAction(self.menufileopenexcellon)
  75. # Open G-Code ...
  76. self.menufileopengcode = QtWidgets.QAction(QtGui.QIcon('share/code.png'), _('Open G-&Code ...'), self)
  77. self.menufile_open.addAction(self.menufileopengcode)
  78. # Open Project ...
  79. self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon('share/folder16.png'), _('Open &Project ...'), self)
  80. self.menufile_open.addAction(self.menufileopenproject)
  81. self.menufile_open.addSeparator()
  82. # Open Config File...
  83. self.menufileopenconfig = QtWidgets.QAction(QtGui.QIcon('share/folder16.png'), _('Open Config ...'), self)
  84. self.menufile_open.addAction(self.menufileopenconfig)
  85. # Recent
  86. self.recent = self.menufile.addMenu(QtGui.QIcon('share/recent_files.png'), _("Recent files"))
  87. # Separator
  88. self.menufile.addSeparator()
  89. # Scripting
  90. self.menufile_scripting = self.menufile.addMenu(QtGui.QIcon('share/script16.png'), _('Scripting'))
  91. self.menufile_scripting.setToolTipsVisible(True)
  92. self.menufilenewscript = QtWidgets.QAction(QtGui.QIcon('share/script_new16.png'), _('New Script ...'),
  93. self)
  94. self.menufileopenscript = QtWidgets.QAction(QtGui.QIcon('share/script_open16.png'), _('Open Script ...'),
  95. self)
  96. self.menufilerunscript = QtWidgets.QAction(QtGui.QIcon('share/script16.png'), _('Run Script ...\tSHIFT+S'),
  97. self)
  98. self.menufilerunscript.setToolTip(
  99. _( "Will run the opened Tcl Script thus\n"
  100. "enabling the automation of certain\n"
  101. "functions of FlatCAM.")
  102. )
  103. self.menufile_scripting.addAction(self.menufilenewscript)
  104. self.menufile_scripting.addAction(self.menufileopenscript)
  105. self.menufile_scripting.addSeparator()
  106. self.menufile_scripting.addAction(self.menufilerunscript)
  107. # Separator
  108. self.menufile.addSeparator()
  109. # Import ...
  110. self.menufileimport = self.menufile.addMenu(QtGui.QIcon('share/import.png'), _('Import'))
  111. self.menufileimportsvg = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  112. _('&SVG as Geometry Object ...'), self)
  113. self.menufileimport.addAction(self.menufileimportsvg)
  114. self.menufileimportsvg_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  115. _('&SVG as Gerber Object ...'), self)
  116. self.menufileimport.addAction(self.menufileimportsvg_as_gerber)
  117. self.menufileimport.addSeparator()
  118. self.menufileimportdxf = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  119. _('&DXF as Geometry Object ...'), self)
  120. self.menufileimport.addAction(self.menufileimportdxf)
  121. self.menufileimportdxf_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  122. _('&DXF as Gerber Object ...'), self)
  123. self.menufileimport.addAction(self.menufileimportdxf_as_gerber)
  124. self.menufileimport.addSeparator()
  125. # Export ...
  126. self.menufileexport = self.menufile.addMenu(QtGui.QIcon('share/export.png'), _('Export'))
  127. self.menufileexport.setToolTipsVisible(True)
  128. self.menufileexportsvg = QtWidgets.QAction(QtGui.QIcon('share/export.png'), _('Export &SVG ...'), self)
  129. self.menufileexport.addAction(self.menufileexportsvg)
  130. self.menufileexportdxf = QtWidgets.QAction(QtGui.QIcon('share/export.png'), _('Export DXF ...'), self)
  131. self.menufileexport.addAction(self.menufileexportdxf)
  132. self.menufileexport.addSeparator()
  133. self.menufileexportpng = QtWidgets.QAction(QtGui.QIcon('share/export_png32.png'), _('Export &PNG ...'), self)
  134. self.menufileexportpng.setToolTip(
  135. _("Will export an image in PNG format,\n"
  136. "the saved image will contain the visual \n"
  137. "information currently in FlatCAM Plot Area.")
  138. )
  139. self.menufileexport.addAction(self.menufileexportpng)
  140. self.menufileexport.addSeparator()
  141. self.menufileexportexcellon = QtWidgets.QAction(QtGui.QIcon('share/drill32.png'), _('Export &Excellon ...'),
  142. self)
  143. self.menufileexportexcellon.setToolTip(
  144. _( "Will export an Excellon Object as Excellon file,\n"
  145. "the coordinates format, the file units and zeros\n"
  146. "are set in Preferences -> Excellon Export.")
  147. )
  148. self.menufileexport.addAction(self.menufileexportexcellon)
  149. # Separator
  150. self.menufile.addSeparator()
  151. # Save Defaults
  152. self.menufilesavedefaults = QtWidgets.QAction(QtGui.QIcon('share/defaults.png'), _('Save &Defaults'), self)
  153. self.menufile.addAction(self.menufilesavedefaults)
  154. # Separator
  155. self.menufile.addSeparator()
  156. self.menufile_save = self.menufile.addMenu(QtGui.QIcon('share/save_as.png'), _('Save'))
  157. # Save Project
  158. self.menufilesaveproject = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), _('&Save Project ...'), self)
  159. self.menufile_save.addAction(self.menufilesaveproject)
  160. # Save Project As ...
  161. self.menufilesaveprojectas = QtWidgets.QAction(QtGui.QIcon('share/save_as.png'),
  162. _('Save Project &As ...\tCTRL+S'), self)
  163. self.menufile_save.addAction(self.menufilesaveprojectas)
  164. # Save Project Copy ...
  165. self.menufilesaveprojectcopy = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), _('Save Project C&opy ...'),
  166. self)
  167. self.menufile_save.addAction(self.menufilesaveprojectcopy)
  168. # Separator
  169. self.menufile.addSeparator()
  170. # Quit
  171. self.menufile_exit = QtWidgets.QAction(QtGui.QIcon('share/power16.png'), _('E&xit'), self)
  172. # exitAction.setShortcut('Ctrl+Q')
  173. # exitAction.setStatusTip('Exit application')
  174. self.menufile.addAction(self.menufile_exit)
  175. ### Edit ###
  176. self.menuedit = self.menu.addMenu(_('&Edit'))
  177. # Separator
  178. self.menuedit.addSeparator()
  179. self.menueditedit = self.menuedit.addAction(QtGui.QIcon('share/edit16.png'), _('Edit Object\tE'))
  180. self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), _('Close Editor\tCTRL+S'))
  181. # adjust the initial state of the menu entries related to the editor
  182. self.menueditedit.setDisabled(False)
  183. self.menueditok.setDisabled(True)
  184. # Separator
  185. self.menuedit.addSeparator()
  186. self.menuedit_convert = self.menuedit.addMenu(QtGui.QIcon('share/convert24.png'), _('Conversion'))
  187. self.menuedit_convertjoin = self.menuedit_convert.addAction(
  188. QtGui.QIcon('share/join16.png'), _('&Join Geo/Gerber/Exc -> Geo'))
  189. self.menuedit_convertjoin.setToolTip(
  190. _( "Merge a selection of objects, which can be of type:\n"
  191. "- Gerber\n"
  192. "- Excellon\n"
  193. "- Geometry\n"
  194. "into a new combo Geometry object.")
  195. )
  196. self.menuedit_convertjoinexc = self.menuedit_convert.addAction(
  197. QtGui.QIcon('share/join16.png'), _('Join Excellon(s) -> Excellon'))
  198. self.menuedit_convertjoinexc.setToolTip(
  199. _( "Merge a selection of Excellon objects into a new combo Excellon object.")
  200. )
  201. self.menuedit_convertjoingrb = self.menuedit_convert.addAction(
  202. QtGui.QIcon('share/join16.png'), _('Join Gerber(s) -> Gerber'))
  203. self.menuedit_convertjoingrb.setToolTip(
  204. _("Merge a selection of Gerber objects into a new combo Gerber object.")
  205. )
  206. # Separator
  207. self.menuedit_convert.addSeparator()
  208. self.menuedit_convert_sg2mg = self.menuedit_convert.addAction(
  209. QtGui.QIcon('share/convert24.png'), _('Convert Single to MultiGeo'))
  210. self.menuedit_convert_sg2mg.setToolTip(
  211. _( "Will convert a Geometry object from single_geometry type\n"
  212. "to a multi_geometry type.")
  213. )
  214. self.menuedit_convert_mg2sg = self.menuedit_convert.addAction(
  215. QtGui.QIcon('share/convert24.png'), _('Convert Multi to SingleGeo'))
  216. self.menuedit_convert_mg2sg.setToolTip(
  217. _( "Will convert a Geometry object from multi_geometry type\n"
  218. "to a single_geometry type.")
  219. )
  220. self.menuedit_convert.setToolTipsVisible(True)
  221. # Separator
  222. self.menuedit.addSeparator()
  223. self.menueditcopyobject = self.menuedit.addAction(QtGui.QIcon('share/copy.png'), _('&Copy Object\tCTRL+C'))
  224. self.menueditcopyobjectasgeom = self.menuedit.addAction(QtGui.QIcon('share/copy_geo.png'),
  225. _('Copy as &Geom'))
  226. # Separator
  227. self.menuedit.addSeparator()
  228. self.menueditdelete = self.menuedit.addAction(QtGui.QIcon('share/trash16.png'), _('&Delete\tDEL'))
  229. # Separator
  230. self.menuedit.addSeparator()
  231. self.menueditorigin = self.menuedit.addAction(QtGui.QIcon('share/origin.png'), _('Se&t Origin\tO'))
  232. self.menueditjump = self.menuedit.addAction(QtGui.QIcon('share/jump_to16.png'), _('Jump to Location\tJ'))
  233. # Separator
  234. self.menuedit.addSeparator()
  235. self.menuedittoggleunits= self.menuedit.addAction(QtGui.QIcon('share/toggle_units16.png'),
  236. _('Toggle Units\tQ'))
  237. self.menueditselectall = self.menuedit.addAction(QtGui.QIcon('share/select_all.png'),
  238. _('&Select All\tCTRL+A'))
  239. # Separator
  240. self.menuedit.addSeparator()
  241. self.menueditpreferences = self.menuedit.addAction(QtGui.QIcon('share/pref.png'), _('&Preferences\tSHIFT+P'))
  242. ### Options ###
  243. self.menuoptions = self.menu.addMenu(_('&Options'))
  244. # self.menuoptions_transfer = self.menuoptions.addMenu(QtGui.QIcon('share/transfer.png'), 'Transfer options')
  245. # self.menuoptions_transfer_a2p = self.menuoptions_transfer.addAction("Application to Project")
  246. # self.menuoptions_transfer_p2a = self.menuoptions_transfer.addAction("Project to Application")
  247. # self.menuoptions_transfer_p2o = self.menuoptions_transfer.addAction("Project to Object")
  248. # self.menuoptions_transfer_o2p = self.menuoptions_transfer.addAction("Object to Project")
  249. # self.menuoptions_transfer_a2o = self.menuoptions_transfer.addAction("Application to Object")
  250. # self.menuoptions_transfer_o2a = self.menuoptions_transfer.addAction("Object to Application")
  251. # Separator
  252. # self.menuoptions.addSeparator()
  253. # self.menuoptions_transform = self.menuoptions.addMenu(QtGui.QIcon('share/transform.png'),
  254. # '&Transform Object')
  255. self.menuoptions_transform_rotate = self.menuoptions.addAction(QtGui.QIcon('share/rotate.png'),
  256. _("&Rotate Selection\tSHIFT+(R)"))
  257. # Separator
  258. self.menuoptions.addSeparator()
  259. self.menuoptions_transform_skewx = self.menuoptions.addAction(QtGui.QIcon('share/skewX.png'),
  260. _("&Skew on X axis\tSHIFT+X"))
  261. self.menuoptions_transform_skewy = self.menuoptions.addAction(QtGui.QIcon('share/skewY.png'),
  262. _( "S&kew on Y axis\tSHIFT+Y"))
  263. # Separator
  264. self.menuoptions.addSeparator()
  265. self.menuoptions_transform_flipx = self.menuoptions.addAction(QtGui.QIcon('share/flipx.png'),
  266. _("Flip on &X axis\tX"))
  267. self.menuoptions_transform_flipy = self.menuoptions.addAction(QtGui.QIcon('share/flipy.png'),
  268. _("Flip on &Y axis\tY"))
  269. # Separator
  270. self.menuoptions.addSeparator()
  271. self.menuoptions_view_source = self.menuoptions.addAction(QtGui.QIcon('share/source32.png'),
  272. _("View source\tALT+S"))
  273. # Separator
  274. self.menuoptions.addSeparator()
  275. ### View ###
  276. self.menuview = self.menu.addMenu(_('&View'))
  277. self.menuviewenable = self.menuview.addAction(QtGui.QIcon('share/replot16.png'), _('Enable all plots\tALT+1'))
  278. self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  279. _('Disable all plots\tALT+2'))
  280. self.menuviewdisableother = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  281. _('Disable non-selected\tALT+3'))
  282. # Separator
  283. self.menuview.addSeparator()
  284. self.menuview_zoom_fit = self.menuview.addAction(QtGui.QIcon('share/zoom_fit32.png'), _("&Zoom Fit\tV"))
  285. self.menuview_zoom_in = self.menuview.addAction(QtGui.QIcon('share/zoom_in32.png'), _("&Zoom In\t-"))
  286. self.menuview_zoom_out = self.menuview.addAction(QtGui.QIcon('share/zoom_out32.png'), _("&Zoom Out\t="))
  287. self.menuview.addSeparator()
  288. self.menuview_toggle_code_editor = self.menuview.addAction(QtGui.QIcon('share/code_editor32.png'),
  289. _('Toggle Code Editor\tCTRL+E'))
  290. self.menuview.addSeparator()
  291. self.menuview_toggle_fscreen = self.menuview.addAction(
  292. QtGui.QIcon('share/fscreen32.png'), _("&Toggle FullScreen\tALT+F10"))
  293. self.menuview_toggle_parea = self.menuview.addAction(
  294. QtGui.QIcon('share/plot32.png'), _("&Toggle Plot Area\tCTRL+F10"))
  295. self.menuview_toggle_notebook = self.menuview.addAction(
  296. QtGui.QIcon('share/notebook32.png'), _("&Toggle Project/Sel/Tool\t`"))
  297. self.menuview.addSeparator()
  298. self.menuview_toggle_grid = self.menuview.addAction(QtGui.QIcon('share/grid32.png'), _("&Toggle Grid Snap\tG")
  299. )
  300. self.menuview_toggle_axis = self.menuview.addAction(QtGui.QIcon('share/axis32.png'), _("&Toggle Axis\tSHIFT+G")
  301. )
  302. self.menuview_toggle_workspace = self.menuview.addAction(QtGui.QIcon('share/workspace24.png'),
  303. _("Toggle Workspace\tSHIFT+W"))
  304. ### Tool ###
  305. # self.menutool = self.menu.addMenu('&Tool')
  306. self.menutool = QtWidgets.QMenu(_('&Tool'))
  307. self.menutoolaction = self.menu.addMenu(self.menutool)
  308. self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), _('&Command Line\tS'))
  309. ### Help ###
  310. self.menuhelp = self.menu.addMenu(_('&Help'))
  311. self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), _('Help\tF1'))
  312. self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), _('FlatCAM.org'))
  313. self.menuhelp.addSeparator()
  314. self.menuhelp_shortcut_list = self.menuhelp.addAction(QtGui.QIcon('share/shortcuts24.png'),
  315. _('Shortcuts List\tF3'))
  316. self.menuhelp_videohelp = self.menuhelp.addAction(QtGui.QIcon('share/youtube32.png'), _('YouTube Channel\tF4')
  317. )
  318. self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/about32.png'), _('About'))
  319. ### FlatCAM Editor menu ###
  320. # self.editor_menu = QtWidgets.QMenu("Editor")
  321. # self.menu.addMenu(self.editor_menu)
  322. self.geo_editor_menu = QtWidgets.QMenu(">Geo Editor<")
  323. self.menu.addMenu(self.geo_editor_menu)
  324. # self.select_menuitem = self.menu.addAction(QtGui.QIcon('share/pointer16.png'), "Select 'Esc'")
  325. self.geo_add_circle_menuitem = self.geo_editor_menu.addAction(
  326. QtGui.QIcon('share/circle32.png'), _('Add Circle\tO')
  327. )
  328. self.geo_add_arc_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/arc16.png'), _('Add Arc\tA'))
  329. self.geo_editor_menu.addSeparator()
  330. self.geo_add_rectangle_menuitem = self.geo_editor_menu.addAction(
  331. QtGui.QIcon('share/rectangle32.png'), _('Add Rectangle\tR')
  332. )
  333. self.geo_add_polygon_menuitem = self.geo_editor_menu.addAction(
  334. QtGui.QIcon('share/polygon32.png'), _('Add Polygon\tN')
  335. )
  336. self.geo_add_path_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/path32.png'), _('Add Path\tP'))
  337. self.geo_editor_menu.addSeparator()
  338. self.geo_add_text_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/text32.png'), _('Add Text\tT'))
  339. self.geo_editor_menu.addSeparator()
  340. self.geo_union_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/union16.png'),
  341. _('Polygon Union\tU'))
  342. self.geo_intersection_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/intersection16.png'),
  343. _('Polygon Intersection\tE'))
  344. self.geo_subtract_menuitem = self.geo_editor_menu.addAction(
  345. QtGui.QIcon('share/subtract16.png'), _('Polygon Subtraction\tS')
  346. )
  347. self.geo_editor_menu.addSeparator()
  348. self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/cutpath16.png'),
  349. _('Cut Path\tX'))
  350. # self.move_menuitem = self.menu.addAction(QtGui.QIcon('share/move16.png'), "Move Objects 'm'")
  351. self.geo_copy_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/copy16.png'), _("Copy Geom\tC"))
  352. self.geo_delete_menuitem = self.geo_editor_menu.addAction(
  353. QtGui.QIcon('share/deleteshape16.png'), _("Delete Shape\tDEL")
  354. )
  355. self.geo_editor_menu.addSeparator()
  356. self.geo_move_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/move32.png'), _("Move\tM"))
  357. self.geo_buffer_menuitem = self.geo_editor_menu.addAction(
  358. QtGui.QIcon('share/buffer16.png'),_( "Buffer Tool\tB")
  359. )
  360. self.geo_paint_menuitem = self.geo_editor_menu.addAction(
  361. QtGui.QIcon('share/paint16.png'), _("Paint Tool\tI")
  362. )
  363. self.geo_transform_menuitem = self.geo_editor_menu.addAction(
  364. QtGui.QIcon('share/transform.png'),_( "Transform Tool\tALT+R")
  365. )
  366. self.geo_editor_menu.addSeparator()
  367. self.geo_cornersnap_menuitem = self.geo_editor_menu.addAction(
  368. QtGui.QIcon('share/corner32.png'), _("Toggle Corner Snap\tK")
  369. )
  370. self.exc_editor_menu = QtWidgets.QMenu(_(">Excellon Editor<"))
  371. self.menu.addMenu(self.exc_editor_menu)
  372. self.exc_add_array_drill_menuitem = self.exc_editor_menu.addAction(
  373. QtGui.QIcon('share/rectangle32.png'), _('Add Drill Array\tA'))
  374. self.exc_add_drill_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/plus16.png'),
  375. _('Add Drill\tD'))
  376. self.exc_editor_menu.addSeparator()
  377. self.exc_resize_drill_menuitem = self.exc_editor_menu.addAction(
  378. QtGui.QIcon('share/resize16.png'), _('Resize Drill(S)\tR')
  379. )
  380. self.exc_copy_drill_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/copy32.png'), _('Copy\tC'))
  381. self.exc_delete_drill_menuitem = self.exc_editor_menu.addAction(
  382. QtGui.QIcon('share/deleteshape32.png'), _('Delete\tDEL')
  383. )
  384. self.exc_editor_menu.addSeparator()
  385. self.exc_move_drill_menuitem = self.exc_editor_menu.addAction(
  386. QtGui.QIcon('share/move32.png'),_( 'Move Drill(s)\tM'))
  387. ### APPLICATION GERBER EDITOR MENU ###
  388. self.grb_editor_menu = QtWidgets.QMenu(_(">Gerber Editor<"))
  389. self.menu.addMenu(self.grb_editor_menu)
  390. self.grb_add_pad_menuitem = self.grb_editor_menu.addAction(
  391. QtGui.QIcon('share/aperture16.png'), _('Add Pad\tP'))
  392. self.grb_add_pad_array_menuitem = self.grb_editor_menu.addAction(
  393. QtGui.QIcon('share/padarray32.png'), _('Add Pad Array\tA'))
  394. self.grb_add_track_menuitem = self.grb_editor_menu.addAction(
  395. QtGui.QIcon('share/track32.png'), _('Add Track\tT'))
  396. self.grb_add_region_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/rectangle32.png'),
  397. _('Add Region\tN'))
  398. self.grb_editor_menu.addSeparator()
  399. self.grb_add_buffer_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/buffer16-2.png'),
  400. _('Buffer\tB'))
  401. self.grb_add_scale_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/scale32.png'),
  402. _('Scale\tS'))
  403. self.grb_transform_menuitem = self.grb_editor_menu.addAction(
  404. QtGui.QIcon('share/transform.png'),_( "Transform\tALT+R")
  405. )
  406. self.grb_editor_menu.addSeparator()
  407. self.grb_copy_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/copy32.png'), _('Copy\tC'))
  408. self.grb_delete_menuitem = self.grb_editor_menu.addAction(
  409. QtGui.QIcon('share/deleteshape32.png'), _('Delete\tDEL')
  410. )
  411. self.grb_editor_menu.addSeparator()
  412. self.grb_move_menuitem = self.grb_editor_menu.addAction(
  413. QtGui.QIcon('share/move32.png'),_( 'Move\tM'))
  414. self.grb_editor_menu.menuAction().setVisible(False)
  415. self.grb_editor_menu.setDisabled(True)
  416. self.geo_editor_menu.menuAction().setVisible(False)
  417. self.geo_editor_menu.setDisabled(True)
  418. self.exc_editor_menu.menuAction().setVisible(False)
  419. self.exc_editor_menu.setDisabled(True)
  420. ################################
  421. ### Project Tab Context menu ###
  422. ################################
  423. self.menuproject = QtWidgets.QMenu()
  424. self.menuprojectenable = self.menuproject.addAction(QtGui.QIcon('share/replot32.png'), _('Enable Plot'))
  425. self.menuprojectdisable = self.menuproject.addAction(QtGui.QIcon('share/clear_plot32.png'), _('Disable Plot'))
  426. self.menuproject.addSeparator()
  427. self.menuprojectgeneratecnc = self.menuproject.addAction(QtGui.QIcon('share/cnc32.png'), _('Generate CNC'))
  428. self.menuprojectviewsource = self.menuproject.addAction(QtGui.QIcon('share/source32.png'), _('View Source'))
  429. self.menuprojectedit = self.menuproject.addAction(QtGui.QIcon('share/edit_ok32.png'), _('Edit'))
  430. self.menuprojectcopy = self.menuproject.addAction(QtGui.QIcon('share/copy32.png'), _('Copy'))
  431. self.menuprojectdelete = self.menuproject.addAction(QtGui.QIcon('share/delete32.png'), _('Delete'))
  432. self.menuprojectsave= self.menuproject.addAction(QtGui.QIcon('share/save_as.png'), _('Save'))
  433. self.menuproject.addSeparator()
  434. self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), _('Properties'))
  435. ################
  436. ### Splitter ###
  437. ################
  438. # IMPORTANT #
  439. # The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
  440. # desired.
  441. self.splitter = QtWidgets.QSplitter()
  442. self.setCentralWidget(self.splitter)
  443. # self.notebook = QtWidgets.QTabWidget()
  444. self.notebook = FCDetachableTab(protect=True)
  445. self.notebook.setTabsClosable(False)
  446. self.notebook.useOldIndex(True)
  447. self.splitter.addWidget(self.notebook)
  448. self.splitter_left = QtWidgets.QSplitter(Qt.Vertical)
  449. self.splitter.addWidget(self.splitter_left)
  450. self.splitter_left.addWidget(self.notebook)
  451. self.splitter_left.setHandleWidth(0)
  452. ###############
  453. ### Toolbar ###
  454. ###############
  455. ### TOOLBAR INSTALLATION ###
  456. self.toolbarfile = QtWidgets.QToolBar(_('File Toolbar'))
  457. self.toolbarfile.setObjectName('File_TB')
  458. self.addToolBar(self.toolbarfile)
  459. self.toolbargeo = QtWidgets.QToolBar(_('Edit Toolbar'))
  460. self.toolbargeo.setObjectName('Edit_TB')
  461. self.addToolBar(self.toolbargeo)
  462. self.toolbarview = QtWidgets.QToolBar(_('View Toolbar'))
  463. self.toolbarview.setObjectName('View_TB')
  464. self.addToolBar(self.toolbarview)
  465. self.toolbarshell = QtWidgets.QToolBar(_('Shell Toolbar'))
  466. self.toolbarshell.setObjectName('Shell_TB')
  467. self.addToolBar(self.toolbarshell)
  468. self.toolbartools = QtWidgets.QToolBar(_('Tools Toolbar'))
  469. self.toolbartools.setObjectName('Tools_TB')
  470. self.addToolBar(self.toolbartools)
  471. self.exc_edit_toolbar = QtWidgets.QToolBar(_('Excellon Editor Toolbar'))
  472. self.exc_edit_toolbar.setObjectName('ExcEditor_TB')
  473. self.addToolBar(self.exc_edit_toolbar)
  474. self.geo_edit_toolbar = QtWidgets.QToolBar(_('Geometry Editor Toolbar'))
  475. self.geo_edit_toolbar.setObjectName('GeoEditor_TB')
  476. self.addToolBar(self.geo_edit_toolbar)
  477. self.grb_edit_toolbar = QtWidgets.QToolBar(_('Gerber Editor Toolbar'))
  478. self.grb_edit_toolbar.setObjectName('GrbEditor_TB')
  479. self.addToolBar(self.grb_edit_toolbar)
  480. self.snap_toolbar = QtWidgets.QToolBar(_('Grid Toolbar'))
  481. self.snap_toolbar.setObjectName('Snap_TB')
  482. self.addToolBar(self.snap_toolbar)
  483. settings = QSettings("Open Source", "FlatCAM")
  484. if settings.contains("layout"):
  485. layout = settings.value('layout', type=str)
  486. if layout == 'standard':
  487. pass
  488. elif layout == 'compact':
  489. self.removeToolBar(self.snap_toolbar)
  490. self.snap_toolbar.setMaximumHeight(30)
  491. self.splitter_left.addWidget(self.snap_toolbar)
  492. ### File Toolbar ###
  493. self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
  494. _("Open Gerber"))
  495. self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), _("Open Excellon"))
  496. self.toolbarfile.addSeparator()
  497. self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), _("Open project"))
  498. self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), _("Save project"))
  499. ### Edit Toolbar ###
  500. self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), _("New Blank Geometry"))
  501. self.newgrb_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32.png'), _("New Blank Gerber"))
  502. self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), _("New Blank Excellon"))
  503. self.toolbargeo.addSeparator()
  504. self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), _("Editor"))
  505. self.update_obj_btn = self.toolbargeo.addAction(
  506. QtGui.QIcon('share/edit_ok32_bis.png'), _("Save Object and close the Editor")
  507. )
  508. self.toolbargeo.addSeparator()
  509. self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), _("&Delete"))
  510. ### View Toolbar ###
  511. self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), _("&Replot"))
  512. self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), _("&Clear plot"))
  513. self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), _("Zoom In"))
  514. self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), _("Zoom Out"))
  515. self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), _("Zoom Fit"))
  516. # self.toolbarview.setVisible(False)
  517. ### Shell Toolbar ###
  518. self.shell_btn = self.toolbarshell.addAction(QtGui.QIcon('share/shell32.png'), _("&Command Line"))
  519. ### Tools Toolbar ###
  520. self.dblsided_btn = self.toolbartools.addAction(QtGui.QIcon('share/doubleside32.png'), _("2Sided Tool"))
  521. self.cutout_btn = self.toolbartools.addAction(QtGui.QIcon('share/cut16_bis.png'), _("&Cutout Tool"))
  522. self.ncc_btn = self.toolbartools.addAction(QtGui.QIcon('share/ncc16.png'), _("NCC Tool"))
  523. self.paint_btn = self.toolbartools.addAction(QtGui.QIcon('share/paint20_1.png'), _("Paint Tool"))
  524. self.toolbartools.addSeparator()
  525. self.panelize_btn = self.toolbartools.addAction(QtGui.QIcon('share/panel16.png'), _("Panel Tool"))
  526. self.film_btn = self.toolbartools.addAction(QtGui.QIcon('share/film16.png'),_( "Film Tool"))
  527. self.solder_btn = self.toolbartools.addAction(QtGui.QIcon('share/solderpastebis32.png'), _("SolderPaste Tool"))
  528. self.toolbartools.addSeparator()
  529. self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'), _("Calculators Tool"))
  530. self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool"))
  531. ### Drill Editor Toolbar ###
  532. self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  533. self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), _('Add Drill Hole'))
  534. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  535. QtGui.QIcon('share/addarray16.png'), _('Add Drill Hole Array'))
  536. self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), _('Resize Drill'))
  537. self.exc_edit_toolbar.addSeparator()
  538. self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _('Copy Drill'))
  539. self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'), _("Delete Drill"))
  540. self.exc_edit_toolbar.addSeparator()
  541. self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Drill"))
  542. ### Geometry Editor Toolbar ###
  543. self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  544. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), _('Add Circle'))
  545. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), _('Add Arc'))
  546. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'),
  547. _('Add Rectangle'))
  548. self.geo_edit_toolbar.addSeparator()
  549. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), _('Add Path'))
  550. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), _('Add Polygon'))
  551. self.geo_edit_toolbar.addSeparator()
  552. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), _('Add Text'))
  553. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), _('Add Buffer'))
  554. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), _('Paint Shape'))
  555. self.geo_edit_toolbar.addSeparator()
  556. self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), _('Polygon Union'))
  557. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
  558. _('Polygon Intersection'))
  559. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'),
  560. _('Polygon Subtraction'))
  561. self.geo_edit_toolbar.addSeparator()
  562. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), _('Cut Path'))
  563. self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _("Copy Shape(s)"))
  564. self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  565. _("Delete Shape '-'"))
  566. self.geo_transform_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/transform.png'),
  567. _("Transformations"))
  568. self.geo_edit_toolbar.addSeparator()
  569. self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Objects "))
  570. ### Gerber Editor Toolbar ###
  571. self.grb_select_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  572. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/aperture32.png'), _("Add Pad"))
  573. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/padarray32.png'), _('Add Pad Array'))
  574. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/track32.png'), _("Add Track"))
  575. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), _("Add Region"))
  576. self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), _("Poligonize"))
  577. self.grb_edit_toolbar.addSeparator()
  578. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), _('Buffer'))
  579. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/scale32.png'), _('Scale'))
  580. self.grb_edit_toolbar.addSeparator()
  581. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _("Copy"))
  582. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  583. _("Delete"))
  584. self.grb_transform_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/transform.png'),
  585. _("Transformations"))
  586. self.grb_edit_toolbar.addSeparator()
  587. self.aperture_move_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  588. ### Snap Toolbar ###
  589. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  590. # self.addToolBar(self.snap_toolbar)
  591. self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), _('Snap to grid'))
  592. self.grid_gap_x_entry = FCEntry2()
  593. self.grid_gap_x_entry.setMaximumWidth(70)
  594. self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
  595. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  596. self.grid_gap_y_entry = FCEntry2()
  597. self.grid_gap_y_entry.setMaximumWidth(70)
  598. self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
  599. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  600. self.grid_space_label = QtWidgets.QLabel(" ")
  601. self.snap_toolbar.addWidget(self.grid_space_label)
  602. self.grid_gap_link_cb = FCCheckBox()
  603. self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
  604. "is copied to the Grid_Y value."))
  605. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  606. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  607. self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), _('Snap to corner'))
  608. self.snap_max_dist_entry = FCEntry()
  609. self.snap_max_dist_entry.setMaximumWidth(70)
  610. self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
  611. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  612. ################
  613. ### Notebook ###
  614. ################
  615. ### Project ###
  616. self.project_tab = QtWidgets.QWidget()
  617. self.project_tab.setObjectName("project_tab")
  618. # project_tab.setMinimumWidth(250) # Hack
  619. self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_tab)
  620. self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
  621. self.notebook.addTab(self.project_tab,_( "Project"))
  622. ### Selected ###
  623. self.selected_tab = QtWidgets.QWidget()
  624. self.selected_tab.setObjectName("selected_tab")
  625. self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
  626. self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
  627. self.selected_scroll_area = VerticalScrollArea()
  628. self.selected_tab_layout.addWidget(self.selected_scroll_area)
  629. self.notebook.addTab(self.selected_tab, _("Selected"))
  630. ### Tool ###
  631. self.tool_tab = QtWidgets.QWidget()
  632. self.tool_tab.setObjectName("tool_tab")
  633. self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
  634. self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
  635. self.notebook.addTab(self.tool_tab, _("Tool"))
  636. self.tool_scroll_area = VerticalScrollArea()
  637. self.tool_tab_layout.addWidget(self.tool_scroll_area)
  638. self.right_widget = QtWidgets.QWidget()
  639. self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
  640. self.splitter.addWidget(self.right_widget)
  641. self.right_lay = QtWidgets.QVBoxLayout()
  642. self.right_lay.setContentsMargins(0, 0, 0, 0)
  643. self.right_widget.setLayout(self.right_lay)
  644. # self.plot_tab_area = FCTab()
  645. self.plot_tab_area = FCDetachableTab(protect=False, protect_by_name=[_('Plot Area')])
  646. self.plot_tab_area.useOldIndex(True)
  647. self.right_lay.addWidget(self.plot_tab_area)
  648. self.plot_tab_area.setTabsClosable(True)
  649. self.plot_tab = QtWidgets.QWidget()
  650. self.plot_tab.setObjectName("plotarea")
  651. self.plot_tab_area.addTab(self.plot_tab, _("Plot Area"))
  652. self.right_layout = QtWidgets.QVBoxLayout()
  653. self.right_layout.setContentsMargins(2, 2, 2, 2)
  654. self.plot_tab.setLayout(self.right_layout)
  655. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  656. self.plot_tab_area.protectTab(0)
  657. ########################################
  658. ### HERE WE BUILD THE PREF. TAB AREA ###
  659. ########################################
  660. self.preferences_tab = QtWidgets.QWidget()
  661. self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
  662. self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
  663. self.pref_tab_area = FCTab()
  664. self.pref_tab_area.setTabsClosable(False)
  665. self.pref_tab_area_tabBar = self.pref_tab_area.tabBar()
  666. self.pref_tab_area_tabBar.setStyleSheet("QTabBar::tab{width:90px;}")
  667. self.pref_tab_area_tabBar.setExpanding(True)
  668. self.pref_tab_layout.addWidget(self.pref_tab_area)
  669. self.general_tab = QtWidgets.QWidget()
  670. self.pref_tab_area.addTab(self.general_tab, _("General"))
  671. self.general_tab_lay = QtWidgets.QVBoxLayout()
  672. self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
  673. self.general_tab.setLayout(self.general_tab_lay)
  674. self.hlay1 = QtWidgets.QHBoxLayout()
  675. self.general_tab_lay.addLayout(self.hlay1)
  676. self.options_combo = QtWidgets.QComboBox()
  677. self.options_combo.addItem(_("APP. DEFAULTS"))
  678. self.options_combo.addItem(_("PROJ. OPTIONS "))
  679. self.hlay1.addWidget(self.options_combo)
  680. # disable this button as it may no longer be useful
  681. self.options_combo.setVisible(False)
  682. self.hlay1.addStretch()
  683. self.general_scroll_area = QtWidgets.QScrollArea()
  684. self.general_tab_lay.addWidget(self.general_scroll_area)
  685. self.gerber_tab = QtWidgets.QWidget()
  686. self.pref_tab_area.addTab(self.gerber_tab, _("GERBER"))
  687. self.gerber_tab_lay = QtWidgets.QVBoxLayout()
  688. self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
  689. self.gerber_tab.setLayout(self.gerber_tab_lay)
  690. self.gerber_scroll_area = QtWidgets.QScrollArea()
  691. self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
  692. self.excellon_tab = QtWidgets.QWidget()
  693. self.pref_tab_area.addTab(self.excellon_tab, _("EXCELLON"))
  694. self.excellon_tab_lay = QtWidgets.QVBoxLayout()
  695. self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
  696. self.excellon_tab.setLayout(self.excellon_tab_lay)
  697. self.excellon_scroll_area = QtWidgets.QScrollArea()
  698. self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
  699. self.geometry_tab = QtWidgets.QWidget()
  700. self.pref_tab_area.addTab(self.geometry_tab, _("GEOMETRY"))
  701. self.geometry_tab_lay = QtWidgets.QVBoxLayout()
  702. self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
  703. self.geometry_tab.setLayout(self.geometry_tab_lay)
  704. self.geometry_scroll_area = QtWidgets.QScrollArea()
  705. self.geometry_tab_lay.addWidget(self.geometry_scroll_area)
  706. self.cncjob_tab = QtWidgets.QWidget()
  707. self.cncjob_tab.setObjectName("cncjob_tab")
  708. self.pref_tab_area.addTab(self.cncjob_tab, _("CNC-JOB"))
  709. self.cncjob_tab_lay = QtWidgets.QVBoxLayout()
  710. self.cncjob_tab_lay.setContentsMargins(2, 2, 2, 2)
  711. self.cncjob_tab.setLayout(self.cncjob_tab_lay)
  712. self.cncjob_scroll_area = QtWidgets.QScrollArea()
  713. self.cncjob_tab_lay.addWidget(self.cncjob_scroll_area)
  714. self.tools_tab = QtWidgets.QWidget()
  715. self.pref_tab_area.addTab(self.tools_tab, _("TOOLS"))
  716. self.tools_tab_lay = QtWidgets.QVBoxLayout()
  717. self.tools_tab_lay.setContentsMargins(2, 2, 2, 2)
  718. self.tools_tab.setLayout(self.tools_tab_lay)
  719. self.tools_scroll_area = QtWidgets.QScrollArea()
  720. self.tools_tab_lay.addWidget(self.tools_scroll_area)
  721. self.pref_tab_bottom_layout = QtWidgets.QHBoxLayout()
  722. self.pref_tab_bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
  723. self.pref_tab_layout.addLayout(self.pref_tab_bottom_layout)
  724. self.pref_tab_bottom_layout_1 = QtWidgets.QHBoxLayout()
  725. self.pref_tab_bottom_layout_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  726. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_1)
  727. self.pref_import_button = QtWidgets.QPushButton()
  728. self.pref_import_button.setText(_("Import Preferences"))
  729. self.pref_import_button.setFixedWidth(130)
  730. self.pref_import_button.setToolTip(
  731. _("Import a full set of FlatCAM settings from a file\n"
  732. "previously saved on HDD.\n\n"
  733. "FlatCAM automatically save a 'factory_defaults' file\n"
  734. "on the first start. Do not delete that file."))
  735. self.pref_tab_bottom_layout_1.addWidget(self.pref_import_button)
  736. self.pref_export_button = QtWidgets.QPushButton()
  737. self.pref_export_button.setText(_("Export Preferences"))
  738. self.pref_export_button.setFixedWidth(130)
  739. self.pref_export_button.setToolTip(
  740. _( "Export a full set of FlatCAM settings in a file\n"
  741. "that is saved on HDD."))
  742. self.pref_tab_bottom_layout_1.addWidget(self.pref_export_button)
  743. self.pref_open_button = QtWidgets.QPushButton()
  744. self.pref_open_button.setText(_("Open Pref Folder"))
  745. self.pref_open_button.setFixedWidth(130)
  746. self.pref_open_button.setToolTip(
  747. _("Open the folder where FlatCAM save the preferences files."))
  748. self.pref_tab_bottom_layout_1.addWidget(self.pref_open_button)
  749. self.pref_tab_bottom_layout_2 = QtWidgets.QHBoxLayout()
  750. self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  751. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2)
  752. self.pref_save_button = QtWidgets.QPushButton()
  753. self.pref_save_button.setText(_("Save Preferences"))
  754. self.pref_save_button.setFixedWidth(130)
  755. self.pref_save_button.setToolTip(
  756. _("Save the current settings in the 'current_defaults' file\n"
  757. "which is the file storing the working default preferences."))
  758. self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
  759. ########################################
  760. ### HERE WE BUILD THE SHORTCUTS LIST. TAB AREA ###
  761. ########################################
  762. self.shortcuts_tab = QtWidgets.QWidget()
  763. self.sh_tab_layout = QtWidgets.QVBoxLayout()
  764. self.sh_tab_layout.setContentsMargins(2, 2, 2, 2)
  765. self.shortcuts_tab.setLayout(self.sh_tab_layout)
  766. self.sh_hlay = QtWidgets.QHBoxLayout()
  767. self.sh_title = QtWidgets.QTextEdit(
  768. _('<b>Shortcut Key List</b>'))
  769. self.sh_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  770. self.sh_title.setFrameStyle(QtWidgets.QFrame.NoFrame)
  771. self.sh_title.setMaximumHeight(30)
  772. font = self.sh_title.font()
  773. font.setPointSize(12)
  774. self.sh_title.setFont(font)
  775. self.sh_tab_layout.addWidget(self.sh_title)
  776. self.sh_tab_layout.addLayout(self.sh_hlay)
  777. self.app_sh_msg = _(
  778. '''<b>General Shortcut list</b><br>
  779. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  780. <tbody>
  781. <tr height="20">
  782. <td height="20" width="89"><strong>F3</strong></td>
  783. <td width="194"><span style="color:#006400"><strong>&nbsp;SHOW SHORTCUT LIST</strong></span></td>
  784. </tr>
  785. <tr height="20">
  786. <td height="20">&nbsp;</td>
  787. <td>&nbsp;</td>
  788. </tr>
  789. <tr height="20">
  790. <td height="20"><strong>1</strong></td>
  791. <td>&nbsp;Switch to Project Tab</td>
  792. </tr>
  793. <tr height="20">
  794. <td height="20"><strong>2</strong></td>
  795. <td>&nbsp;Switch to Selected Tab</td>
  796. </tr>
  797. <tr height="20">
  798. <td height="20"><strong>3</strong></td>
  799. <td>&nbsp;Switch to Tool Tab</td>
  800. </tr>
  801. <tr height="20">
  802. <td height="20">&nbsp;</td>
  803. <td>&nbsp;</td>
  804. </tr>
  805. <tr height="20">
  806. <td height="20"><strong>E</strong></td>
  807. <td>&nbsp;Edit Object (if selected)</td>
  808. </tr>
  809. <tr height="20">
  810. <td height="20"><strong>G</strong></td>
  811. <td>&nbsp;Grid On/Off</td>
  812. </tr>
  813. <tr height="20">
  814. <td height="20"><strong>J</strong></td>
  815. <td>&nbsp;Jump to Coordinates</td>
  816. </tr>
  817. <tr height="20">
  818. <td height="20"><strong>L</strong></td>
  819. <td>&nbsp;New Excellon</td>
  820. </tr>
  821. <tr height="20">
  822. <td height="20"><strong>M</strong></td>
  823. <td>&nbsp;Move Obj</td>
  824. </tr>
  825. <tr height="20">
  826. <td height="20"><strong>N</strong></td>
  827. <td>&nbsp;New Geometry</td>
  828. </tr>
  829. <tr height="20">
  830. <td height="20"><strong>O</strong></td>
  831. <td>&nbsp;Set Origin</td>
  832. </tr>
  833. <tr height="20">
  834. <td height="20"><strong>Q</strong></td>
  835. <td>&nbsp;Change Units</td>
  836. </tr>
  837. <tr height="20">
  838. <td height="20"><strong>P</strong></td>
  839. <td>&nbsp;Open Properties Tool</td>
  840. </tr>
  841. <tr height="20">
  842. <td height="20"><strong>R</strong></td>
  843. <td>&nbsp;Rotate by 90 degree CW</td>
  844. </tr>
  845. <tr height="20">
  846. <td height="20"><strong>S</strong></td>
  847. <td>&nbsp;Shell Toggle</td>
  848. </tr>
  849. <tr height="20">
  850. <td height="20"><strong>T</strong></td>
  851. <td>&nbsp;Add a Tool (when in Geometry Selected Tab or in Tools NCC or Tools Paint)</td>
  852. </tr>
  853. <tr height="20">
  854. <td height="20"><strong>V</strong></td>
  855. <td>&nbsp;Zoom Fit</td>
  856. </tr>
  857. <tr height="20">
  858. <td height="20"><strong>X</strong></td>
  859. <td>&nbsp;Flip on X_axis</td>
  860. </tr>
  861. <tr height="20">
  862. <td height="20"><strong>Y</strong></td>
  863. <td>&nbsp;Flip on Y_axis</td>
  864. </tr>
  865. <tr height="20">
  866. <td height="20"><strong>&#39;=&#39;</strong></td>
  867. <td>&nbsp;Zoom Out</td>
  868. </tr>
  869. <tr height="20">
  870. <td height="20"><strong>&#39;-&#39;</strong></td>
  871. <td>&nbsp;Zoom In</td>
  872. </tr>
  873. <tr height="20">
  874. <td height="20">&nbsp;</td>
  875. <td>&nbsp;</td>
  876. </tr>
  877. <tr height="20">
  878. <td height="20"><strong>CTRL+A</strong></td>
  879. <td>&nbsp;Select All</td>
  880. </tr>
  881. <tr height="20">
  882. <td height="20"><strong>CTRL+C</strong></td>
  883. <td>&nbsp;Copy Obj</td>
  884. </tr>
  885. <tr height="20">
  886. <td height="20"><strong>CTRL+E</strong></td>
  887. <td>&nbsp;Open Excellon File</td>
  888. </tr>
  889. <tr height="20">
  890. <td height="20"><strong>CTRL+G</strong></td>
  891. <td>&nbsp;Open Gerber File</td>
  892. </tr>
  893. <tr height="20">
  894. <td height="20"><strong>CTRL+N</strong></td>
  895. <td>&nbsp;New Project</td>
  896. </tr>
  897. <tr height="20">
  898. <td height="20"><strong>CTRL+M</strong></td>
  899. <td>&nbsp;Measurement Tool</td>
  900. </tr>
  901. <tr height="20">
  902. <td height="20"><strong>CTRL+O</strong></td>
  903. <td>&nbsp;Open Project</td>
  904. </tr>
  905. <tr height="20">
  906. <td height="20"><strong>CTRL+S</strong></td>
  907. <td>&nbsp;Save Project As</td>
  908. </tr>
  909. <tr height="20">
  910. <td height="20"><strong>CTRL+F10</strong></td>
  911. <td>&nbsp;Toggle Plot Area</td>
  912. </tr>
  913. <tr height="20">
  914. <td height="20">&nbsp;</td>
  915. <td>&nbsp;</td>
  916. </tr>
  917. <tr height="20">
  918. <td height="20"><strong>SHIFT+C</strong></td>
  919. <td>&nbsp;Copy Obj_Name</td>
  920. </tr>
  921. <tr height="20">
  922. <td height="20"><strong>SHIFT+E</strong></td>
  923. <td>&nbsp;Toggle Code Editor</td>
  924. </tr>
  925. <tr height="20">
  926. <td height="20"><strong>SHIFT+G</strong></td>
  927. <td>&nbsp;Toggle the axis</td>
  928. </tr>
  929. <tr height="20">
  930. <td height="20"><strong>SHIFT+P</strong></td>
  931. <td>&nbsp;Open Preferences Window</td>
  932. </tr>
  933. <tr height="20">
  934. <td height="20"><strong>SHIFT+R</strong></td>
  935. <td>&nbsp;Rotate by 90 degree CCW</td>
  936. </tr>
  937. <tr height="20">
  938. <td height="20"><strong>SHIFT+S</strong></td>
  939. <td>&nbsp;Run a Script</td>
  940. </tr>
  941. <tr height="20">
  942. <td height="20"><strong>SHIFT+W</strong></td>
  943. <td>&nbsp;Toggle the workspace</td>
  944. </tr>
  945. <tr height="20">
  946. <td height="20"><strong>SHIFT+X</strong></td>
  947. <td>&nbsp;Skew on X axis</td>
  948. </tr>
  949. <tr height="20">
  950. <td height="20"><strong>SHIFT+Y</strong></td>
  951. <td>&nbsp;Skew on Y axis</td>
  952. </tr>
  953. <tr height="20">
  954. <td height="20">&nbsp;</td>
  955. <td>&nbsp;</td>
  956. </tr>
  957. <tr height="20">
  958. <td height="20"><strong>ALT+C</strong></td>
  959. <td>&nbsp;Calculators Tool</td>
  960. </tr>
  961. <tr height="20">
  962. <td height="20"><strong>ALT+D</strong></td>
  963. <td>&nbsp;2-Sided PCB Tool</td>
  964. </tr>
  965. <tr height="20">
  966. <td height="20"><strong>ALT+K</strong></td>
  967. <td>&nbsp;Solder Paste Dispensing Tool</td>
  968. </tr>
  969. <tr height="20">
  970. <td height="20"><strong>ALT+L</strong></td>
  971. <td>&nbsp;Film PCB Tool</td>
  972. </tr>
  973. <tr height="20">
  974. <td height="20"><strong>ALT+N</strong></td>
  975. <td>&nbsp;Non-Copper Clearing Tool</td>
  976. </tr>
  977. <tr height="20">
  978. <td height="20"><strong>ALT+P</strong></td>
  979. <td>&nbsp;Paint Area Tool</td>
  980. </tr>
  981. <tr height="20">
  982. <td height="20"><strong>ALT+R</strong></td>
  983. <td>&nbsp;Transformations Tool</td>
  984. </tr>
  985. <tr height="20">
  986. <td height="20"><strong>ALT+S</strong></td>
  987. <td>&nbsp;View File Source</td>
  988. </tr>
  989. <tr height="20">
  990. <td height="20"><strong>ALT+U</strong></td>
  991. <td>&nbsp;Cutout PCB Tool</td>
  992. </tr>
  993. <tr height="20">
  994. <td height="20"><strong>ALT+1</strong></td>
  995. <td>&nbsp;Enable all Plots</td>
  996. </tr>
  997. <tr height="20">
  998. <td height="20"><strong>ALT+2</strong></td>
  999. <td>&nbsp;Disable all Plots</td>
  1000. </tr>
  1001. <tr height="20">
  1002. <td height="20"><strong>ALT+3</strong></td>
  1003. <td>&nbsp;Disable Non-selected Plots</td>
  1004. </tr>
  1005. <tr height="20">
  1006. <td height="20"><strong>ALT+F10</strong></td>
  1007. <td>&nbsp;Toggle Full Screen</td>
  1008. </tr>
  1009. <tr height="20">
  1010. <td height="20">&nbsp;</td>
  1011. <td>&nbsp;</td>
  1012. </tr>
  1013. <tr height="20">
  1014. <td height="20"><strong>F1</strong></td>
  1015. <td>&nbsp;Open Online Manual</td>
  1016. </tr>
  1017. <tr height="20">
  1018. <td height="20"><strong>F4</strong></td>
  1019. <td>&nbsp;Open Online Tutorials</td>
  1020. </tr>
  1021. <tr height="20">
  1022. <td height="20"><strong>Del</strong></td>
  1023. <td>&nbsp;Delete Object</td>
  1024. </tr>
  1025. <tr height="20">
  1026. <td height="20"><strong>Del</strong></td>
  1027. <td>&nbsp;Alternate: Delete Tool</td>
  1028. </tr>
  1029. <tr height="20">
  1030. <td height="20"><strong>'`'</strong></td>
  1031. <td>&nbsp;(left to Key_1)Toogle Notebook Area (Left Side)</td>
  1032. </tr>
  1033. <tr height="20">
  1034. <td height="20"><strong>SPACE</strong></td>
  1035. <td>&nbsp;En(Dis)able Obj Plot</td>
  1036. </tr>
  1037. <tr height="20">
  1038. <td height="20"><strong>Escape</strong></td>
  1039. <td>&nbsp;Deselects all objects</td>
  1040. </tr>
  1041. </tbody>
  1042. </table>
  1043. '''
  1044. )
  1045. self.sh_app = QtWidgets.QTextEdit()
  1046. self.sh_app.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1047. self.sh_app.setText(self.app_sh_msg)
  1048. self.sh_app.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  1049. self.sh_hlay.addWidget(self.sh_app)
  1050. self.editor_sh_msg = _(
  1051. '''<b>Editor Shortcut list</b><br>
  1052. <br>
  1053. <strong><span style="color:#0000ff">GEOMETRY EDITOR</span></strong><br>
  1054. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1055. <tbody>
  1056. <tr height="20">
  1057. <td height="20" width="89"><strong>A</strong></td>
  1058. <td width="194">&nbsp;Draw an Arc</td>
  1059. </tr>
  1060. <tr height="20">
  1061. <td height="20"><strong>B</strong></td>
  1062. <td>&nbsp;Buffer Tool</td>
  1063. </tr>
  1064. <tr height="20">
  1065. <td height="20"><strong>C</strong></td>
  1066. <td>&nbsp;Copy Geo Item</td>
  1067. </tr>
  1068. <tr height="20">
  1069. <td height="20"><strong>E</strong></td>
  1070. <td>&nbsp;Polygon Intersection Tool</td>
  1071. </tr>
  1072. <tr height="20">
  1073. <td height="20"><strong>I</strong></td>
  1074. <td>&nbsp;Paint Tool</td>
  1075. </tr>
  1076. <tr height="20">
  1077. <td height="20"><strong>J</strong></td>
  1078. <td>&nbsp;Jump to Location (x, y)</td>
  1079. </tr>
  1080. <tr height="20">
  1081. <td height="20"><strong>K</strong></td>
  1082. <td>&nbsp;Toggle Corner Snap</td>
  1083. </tr>
  1084. <tr height="20">
  1085. <td height="20"><strong>M</strong></td>
  1086. <td>&nbsp;Move Geo Item</td>
  1087. </tr>
  1088. <tr height="20">
  1089. <td height="20"><strong>N</strong></td>
  1090. <td>&nbsp;Draw a Polygon</td>
  1091. </tr>
  1092. <tr height="20">
  1093. <td height="20"><strong>O</strong></td>
  1094. <td>&nbsp;Draw a Circle</td>
  1095. </tr>
  1096. <tr height="20">
  1097. <td height="20"><strong>P</strong></td>
  1098. <td>&nbsp;Draw a Path</td>
  1099. </tr>
  1100. <tr height="20">
  1101. <td height="20"><strong>R</strong></td>
  1102. <td>&nbsp;Draw Rectangle</td>
  1103. </tr>
  1104. <tr height="20">
  1105. <td height="20"><strong>S</strong></td>
  1106. <td>&nbsp;Polygon Substraction Tool</td>
  1107. </tr>
  1108. <tr height="20">
  1109. <td height="20"><strong>T</strong></td>
  1110. <td>&nbsp;Add Text Tool</td>
  1111. </tr>
  1112. <tr height="20">
  1113. <td height="20"><strong>U</strong></td>
  1114. <td>&nbsp;Polygon Union Tool</td>
  1115. </tr>
  1116. <tr height="20">
  1117. <td height="20"><strong>X</strong></td>
  1118. <td>&nbsp;Flip shape on X axis</td>
  1119. </tr>
  1120. <tr height="20">
  1121. <td height="20"><strong>Y</strong></td>
  1122. <td>&nbsp;Flip shape on Y axis</td>
  1123. </tr>
  1124. <tr height="20">
  1125. <td height="20">&nbsp;</td>
  1126. <td>&nbsp;</td>
  1127. </tr>
  1128. <tr height="20">
  1129. <td height="20"><strong>SHIFT+X</strong></td>
  1130. <td>&nbsp;Skew shape on X axis</td>
  1131. </tr>
  1132. <tr height="20">
  1133. <td height="20"><strong>SHIFT+Y</strong></td>
  1134. <td>&nbsp;Skew shape on Y axis</td>
  1135. </tr>
  1136. <tr height="20">
  1137. <td height="20">&nbsp;</td>
  1138. <td>&nbsp;</td>
  1139. </tr>
  1140. <tr height="20">
  1141. <td height="20"><strong>ALT+R</strong></td>
  1142. <td>&nbsp;Editor Transformation Tool</td>
  1143. </tr>
  1144. <tr height="20">
  1145. <td height="20"><strong>ALT+X</strong></td>
  1146. <td>&nbsp;Offset shape on X axis</td>
  1147. </tr>
  1148. <tr height="20">
  1149. <td height="20"><strong>ALT+Y</strong></td>
  1150. <td>&nbsp;Offset shape on Y axis</td>
  1151. </tr>
  1152. <tr height="20">
  1153. <td height="20">&nbsp;</td>
  1154. <td>&nbsp;</td>
  1155. </tr>
  1156. <tr height="20">
  1157. <td height="20"><strong>CTRL+M</strong></td>
  1158. <td>&nbsp;Measurement Tool</td>
  1159. </tr>
  1160. <tr height="20">
  1161. <td height="20"><strong>CTRL+S</strong></td>
  1162. <td>&nbsp;Save Object and Exit Editor</td>
  1163. </tr>
  1164. <tr height="20">
  1165. <td height="20"><strong>CTRL+X</strong></td>
  1166. <td>&nbsp;Polygon Cut Tool</td>
  1167. </tr>
  1168. <tr height="20">
  1169. <td height="20">&nbsp;</td>
  1170. <td>&nbsp;</td>
  1171. </tr>
  1172. <tr height="20">
  1173. <td height="20"><strong>Space</strong></td>
  1174. <td>&nbsp;Rotate Geometry</td>
  1175. </tr>
  1176. <tr height="20">
  1177. <td height="20"><strong>ENTER</strong></td>
  1178. <td>&nbsp;Finish drawing for certain tools</td>
  1179. </tr>
  1180. <tr height="20">
  1181. <td height="20"><strong>ESC</strong></td>
  1182. <td>&nbsp;Abort and return to Select</td>
  1183. </tr>
  1184. <tr height="20">
  1185. <td height="20"><strong>Del</strong></td>
  1186. <td>&nbsp;Delete Shape</td>
  1187. </tr>
  1188. </tbody>
  1189. </table>
  1190. <br>
  1191. <br>
  1192. <strong><span style="color:#ff0000">EXCELLON EDITOR</span></strong><br>
  1193. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1194. <tbody>
  1195. <tr height="20">
  1196. <td height="20" width="89"><strong>A</strong></td>
  1197. <td width="194">&nbsp;Add Drill Array</td>
  1198. </tr>
  1199. <tr height="20">
  1200. <td height="20"><strong>C</strong></td>
  1201. <td>&nbsp;Copy Drill(s)</td>
  1202. </tr>
  1203. <tr height="20">
  1204. <td height="20"><strong>D</strong></td>
  1205. <td>&nbsp;Add Drill</td>
  1206. </tr>
  1207. <tr height="20">
  1208. <td height="20"><strong>J</strong></td>
  1209. <td>&nbsp;Jump to Location (x, y)</td>
  1210. </tr>
  1211. <tr height="20">
  1212. <td height="20"><strong>M</strong></td>
  1213. <td>&nbsp;Move Drill(s)</td>
  1214. </tr>
  1215. <tr height="20">
  1216. <td height="20"><strong>R</strong></td>
  1217. <td>&nbsp;Resize Drill(s)</td>
  1218. </tr>
  1219. <tr height="20">
  1220. <td height="20"><strong>T</strong></td>
  1221. <td>&nbsp;Add a new Tool</td>
  1222. </tr>
  1223. <tr height="20">
  1224. <td height="20">&nbsp;</td>
  1225. <td>&nbsp;</td>
  1226. </tr>
  1227. <tr height="20">
  1228. <td height="20"><strong>Del</strong></td>
  1229. <td>&nbsp;Delete Drill(s)</td>
  1230. </tr>
  1231. <tr height="20">
  1232. <td height="20"><strong>Del</strong></td>
  1233. <td>&nbsp;Alternate: Delete Tool(s)</td>
  1234. </tr>
  1235. <tr height="20">
  1236. <td height="20">&nbsp;</td>
  1237. <td>&nbsp;</td>
  1238. </tr>
  1239. <tr height="20">
  1240. <td height="20"><strong>ESC</strong></td>
  1241. <td>&nbsp;Abort and return to Select</td>
  1242. </tr>
  1243. <tr height="20">
  1244. <td height="20"><strong>CTRL+S</strong></td>
  1245. <td>&nbsp;Save Object and Exit Editor</td>
  1246. </tr>
  1247. </tbody>
  1248. </table>
  1249. <br>
  1250. <br>
  1251. <strong><span style="color:#00ff00">GERBER EDITOR</span></strong><br>
  1252. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1253. <tbody>
  1254. <tr height="20">
  1255. <td height="20" width="89"><strong>A</strong></td>
  1256. <td width="194">&nbsp;Add Pad Array</td>
  1257. </tr>
  1258. <tr height="20">
  1259. <td height="20"><strong>B</strong></td>
  1260. <td>&nbsp;Buffer</td>
  1261. </tr>
  1262. <tr height="20">
  1263. <td height="20"><strong>C</strong></td>
  1264. <td>&nbsp;Copy</td>
  1265. </tr>
  1266. <tr height="20">
  1267. <td height="20"><strong>J</strong></td>
  1268. <td>&nbsp;Jump to Location (x, y)</td>
  1269. </tr>
  1270. <tr height="20">
  1271. <td height="20"><strong>M</strong></td>
  1272. <td>&nbsp;Move</td>
  1273. </tr>
  1274. <tr height="20">
  1275. <td height="20"><strong>N</strong></td>
  1276. <td>&nbsp;Add Region</td>
  1277. </tr>
  1278. <tr height="20">
  1279. <td height="20"><strong>P</strong></td>
  1280. <td>&nbsp;Add Pad</td>
  1281. </tr>
  1282. <tr height="20">
  1283. <td height="20"><strong>S</strong></td>
  1284. <td>&nbsp;Scale</td>
  1285. </tr>
  1286. <tr height="20">
  1287. <td height="20"><strong>T</strong></td>
  1288. <td>&nbsp;Add Track</td>
  1289. </tr>
  1290. <tr height="20">
  1291. <td height="20">&nbsp;</td>
  1292. <td>&nbsp;</td>
  1293. </tr>
  1294. <tr height="20">
  1295. <td height="20"><strong>Del</strong></td>
  1296. <td>&nbsp;Delete</td>
  1297. </tr>
  1298. <tr height="20">
  1299. <td height="20"><strong>Del</strong></td>
  1300. <td>&nbsp;Alternate: Delete Apertures</td>
  1301. </tr>
  1302. <tr height="20">
  1303. <td height="20">&nbsp;</td>
  1304. <td>&nbsp;</td>
  1305. </tr>
  1306. <tr height="20">
  1307. <td height="20"><strong>ESC</strong></td>
  1308. <td>&nbsp;Abort and return to Select</td>
  1309. </tr>
  1310. <tr height="20">
  1311. <td height="20"><strong>CTRL+S</strong></td>
  1312. <td>&nbsp;Save Object and Exit Editor</td>
  1313. </tr>
  1314. <tr height="20">
  1315. <td height="20">&nbsp;</td>
  1316. <td>&nbsp;</td>
  1317. </tr>
  1318. <tr height="20">
  1319. <td height="20"><strong>ALT+R</strong></td>
  1320. <td>&nbsp;Transformation Tool</td>
  1321. </tr>
  1322. </tbody>
  1323. </table>
  1324. '''
  1325. )
  1326. self.sh_editor = QtWidgets.QTextEdit()
  1327. self.sh_editor.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1328. self.sh_editor.setText(self.editor_sh_msg)
  1329. self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  1330. self.sh_hlay.addWidget(self.sh_editor)
  1331. ##############################################################
  1332. ### HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS ###
  1333. ##############################################################
  1334. self.popMenu = QtWidgets.QMenu()
  1335. self.popmenu_disable = self.popMenu.addAction(QtGui.QIcon('share/clear_plot32.png'), _("Disable"))
  1336. self.popMenu.addSeparator()
  1337. self.cmenu_newmenu = self.popMenu.addMenu(QtGui.QIcon('share/file32.png'), _("New"))
  1338. self.popmenu_new_geo = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_geo32_bis.png'), _("Geometry"))
  1339. self.popmenu_new_exc = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_exc32.png'), _("Excellon"))
  1340. self.cmenu_newmenu.addSeparator()
  1341. self.popmenu_new_prj = self.cmenu_newmenu.addAction(QtGui.QIcon('share/file16.png'), _("Project"))
  1342. self.popMenu.addSeparator()
  1343. self.cmenu_gridmenu = self.popMenu.addMenu(QtGui.QIcon('share/grid32_menu.png'), _("Grids"))
  1344. self.cmenu_viewmenu = self.popMenu.addMenu(QtGui.QIcon('share/view64.png'), _("View"))
  1345. self.zoomfit = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/zoom_fit32.png'), _("Zoom Fit"))
  1346. self.clearplot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/clear_plot32.png'), _("Clear Plot"))
  1347. self.replot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/replot32.png'), _("Replot"))
  1348. self.popMenu.addSeparator()
  1349. self.g_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/draw32.png'), _("Geo Editor"))
  1350. self.draw_line = self.g_editor_cmenu.addAction(QtGui.QIcon('share/path32.png'), _("Line"))
  1351. self.draw_rect = self.g_editor_cmenu.addAction(QtGui.QIcon('share/rectangle32.png'), _("Rectangle"))
  1352. self.draw_cut = self.g_editor_cmenu.addAction(QtGui.QIcon('share/cutpath32.png'), _("Cut"))
  1353. self.g_editor_cmenu.addSeparator()
  1354. self.draw_move = self.g_editor_cmenu.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  1355. self.grb_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/draw32.png'), _("Gerber Editor"))
  1356. self.grb_draw_pad = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/aperture32.png'), _("Pad"))
  1357. self.grb_draw_pad_array = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/padarray32.png'), _("Pad Array"))
  1358. self.grb_draw_track = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/track32.png'), _("Track"))
  1359. self.grb_draw_region = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/polygon32.png'), _("Region"))
  1360. self.grb_editor_cmenu.addSeparator()
  1361. self.grb_copy = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/copy.png'), _("Copy"))
  1362. self.grb_delete = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/trash32.png'), _("Delete"))
  1363. self.grb_move = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  1364. self.e_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/drill32.png'), _("Exc Editor"))
  1365. self.drill = self.e_editor_cmenu.addAction(QtGui.QIcon('share/drill32.png'), _("Add Drill"))
  1366. self.drill_array = self.e_editor_cmenu.addAction(QtGui.QIcon('share/addarray32.png'), _("Add Drill Array"))
  1367. self.drill_copy = self.e_editor_cmenu.addAction(QtGui.QIcon('share/copy32.png'), _("Copy Drill(s)"))
  1368. self.popMenu.addSeparator()
  1369. self.popmenu_copy = self.popMenu.addAction(QtGui.QIcon('share/copy32.png'), _("Copy"))
  1370. self.popmenu_delete = self.popMenu.addAction(QtGui.QIcon('share/delete32.png'), _("Delete"))
  1371. self.popmenu_edit = self.popMenu.addAction(QtGui.QIcon('share/edit32.png'), _("Edit"))
  1372. self.popmenu_save = self.popMenu.addAction(QtGui.QIcon('share/floppy32.png'), _("Close Editor"))
  1373. self.popmenu_save.setVisible(False)
  1374. self.popMenu.addSeparator()
  1375. self.popmenu_move = self.popMenu.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  1376. self.popmenu_properties = self.popMenu.addAction(QtGui.QIcon('share/properties32.png'), _("Properties"))
  1377. ####################################
  1378. ### Here we build the CNCJob Tab ###
  1379. ####################################
  1380. self.cncjob_tab = QtWidgets.QWidget()
  1381. self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_tab)
  1382. self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
  1383. self.cncjob_tab.setLayout(self.cncjob_tab_layout)
  1384. self.code_editor = FCTextAreaExtended()
  1385. stylesheet = """
  1386. QTextEdit { selection-background-color:yellow;
  1387. selection-color:black;
  1388. }
  1389. """
  1390. self.code_editor.setStyleSheet(stylesheet)
  1391. self.buttonPreview = QtWidgets.QPushButton(_('Print Preview'))
  1392. self.buttonPrint = QtWidgets.QPushButton(_('Print Code'))
  1393. self.buttonFind = QtWidgets.QPushButton(_('Find in Code'))
  1394. self.buttonFind.setFixedWidth(100)
  1395. self.buttonPreview.setFixedWidth(100)
  1396. self.entryFind = FCEntry()
  1397. self.entryFind.setMaximumWidth(200)
  1398. self.buttonReplace = QtWidgets.QPushButton(_('Replace With'))
  1399. self.buttonReplace.setFixedWidth(100)
  1400. self.entryReplace = FCEntry()
  1401. self.entryReplace.setMaximumWidth(200)
  1402. self.sel_all_cb = QtWidgets.QCheckBox(_('All'))
  1403. self.sel_all_cb.setToolTip(
  1404. _("When checked it will replace all instances in the 'Find' box\n"
  1405. "with the text in the 'Replace' box..")
  1406. )
  1407. self.buttonOpen = QtWidgets.QPushButton(_('Open Code'))
  1408. self.buttonSave = QtWidgets.QPushButton(_('Save Code'))
  1409. self.cncjob_tab_layout.addWidget(self.code_editor, 0, 0, 1, 5)
  1410. cnc_tab_lay_1 = QtWidgets.QHBoxLayout()
  1411. cnc_tab_lay_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1412. cnc_tab_lay_1.addWidget(self.buttonFind)
  1413. cnc_tab_lay_1.addWidget(self.entryFind)
  1414. cnc_tab_lay_1.addWidget(self.buttonReplace)
  1415. cnc_tab_lay_1.addWidget(self.entryReplace)
  1416. cnc_tab_lay_1.addWidget(self.sel_all_cb)
  1417. self.cncjob_tab_layout.addLayout(cnc_tab_lay_1, 1, 0, 1, 1, QtCore.Qt.AlignLeft)
  1418. cnc_tab_lay_3 = QtWidgets.QHBoxLayout()
  1419. cnc_tab_lay_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1420. cnc_tab_lay_3.addWidget(self.buttonPreview)
  1421. cnc_tab_lay_3.addWidget(self.buttonPrint)
  1422. self.cncjob_tab_layout.addLayout(cnc_tab_lay_3, 2, 0, 1, 1, QtCore.Qt.AlignLeft)
  1423. cnc_tab_lay_4 = QtWidgets.QHBoxLayout()
  1424. cnc_tab_lay_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  1425. cnc_tab_lay_4.addWidget(self.buttonOpen)
  1426. cnc_tab_lay_4.addWidget(self.buttonSave)
  1427. self.cncjob_tab_layout.addLayout(cnc_tab_lay_4, 2, 4, 1, 1)
  1428. ##################################
  1429. ### Build InfoBar is done here ###
  1430. ##################################
  1431. self.infobar = self.statusBar()
  1432. self.fcinfo = FlatCAMInfoBar()
  1433. self.infobar.addWidget(self.fcinfo, stretch=1)
  1434. self.rel_position_label = QtWidgets.QLabel(
  1435. "<b>Dx</b>: 0.0000&nbsp;&nbsp; <b>Dy</b>: 0.0000&nbsp;&nbsp;&nbsp;&nbsp;")
  1436. self.rel_position_label.setMinimumWidth(110)
  1437. self.rel_position_label.setToolTip(_("Relative neasurement.\nReference is last click position"))
  1438. self.infobar.addWidget(self.rel_position_label)
  1439. self.position_label = QtWidgets.QLabel(
  1440. "&nbsp;&nbsp;&nbsp;&nbsp;<b>X</b>: 0.0000&nbsp;&nbsp; <b>Y</b>: 0.0000")
  1441. self.position_label.setMinimumWidth(110)
  1442. self.position_label.setToolTip(_("Absolute neasurement.\nReference is (X=0, Y= 0) position"))
  1443. self.infobar.addWidget(self.position_label)
  1444. self.units_label = QtWidgets.QLabel("[in]")
  1445. self.units_label.setMargin(2)
  1446. self.infobar.addWidget(self.units_label)
  1447. # disabled
  1448. self.progress_bar = QtWidgets.QProgressBar()
  1449. self.progress_bar.setMinimum(0)
  1450. self.progress_bar.setMaximum(100)
  1451. # infobar.addWidget(self.progress_bar)
  1452. self.activity_view = FlatCAMActivityView()
  1453. self.infobar.addWidget(self.activity_view)
  1454. self.app_icon = QtGui.QIcon()
  1455. self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
  1456. self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
  1457. self.app_icon.addFile('share/flatcam_icon32.png', QtCore.QSize(32, 32))
  1458. self.app_icon.addFile('share/flatcam_icon48.png', QtCore.QSize(48, 48))
  1459. self.app_icon.addFile('share/flatcam_icon128.png', QtCore.QSize(128, 128))
  1460. self.app_icon.addFile('share/flatcam_icon256.png', QtCore.QSize(256, 256))
  1461. self.setWindowIcon(self.app_icon)
  1462. self.setGeometry(100, 100, 1024, 650)
  1463. self.setWindowTitle('FlatCAM %s %s - %s' % (version, ('BETA' if beta else ''), platform.architecture()[0]))
  1464. self.show()
  1465. self.filename = ""
  1466. self.setAcceptDrops(True)
  1467. # # restore the Toolbar State from file
  1468. # try:
  1469. # with open(self.app.data_path + '\gui_state.config', 'rb') as stream:
  1470. # self.restoreState(QtCore.QByteArray(stream.read()))
  1471. # log.debug("FlatCAMGUI.__init__() --> UI state restored.")
  1472. # except IOError:
  1473. # log.debug("FlatCAMGUI.__init__() --> UI state not restored. IOError")
  1474. # pass
  1475. ######################
  1476. ### INITIALIZE GUI ###
  1477. ######################
  1478. self.grid_snap_btn.setCheckable(True)
  1479. self.corner_snap_btn.setCheckable(True)
  1480. self.update_obj_btn.setEnabled(False)
  1481. # start with GRID activated
  1482. self.grid_snap_btn.trigger()
  1483. self.g_editor_cmenu.setEnabled(False)
  1484. self.grb_editor_cmenu.setEnabled(False)
  1485. self.e_editor_cmenu.setEnabled(False)
  1486. self.general_defaults_form = GeneralPreferencesUI()
  1487. self.gerber_defaults_form = GerberPreferencesUI()
  1488. self.excellon_defaults_form = ExcellonPreferencesUI()
  1489. self.geometry_defaults_form = GeometryPreferencesUI()
  1490. self.cncjob_defaults_form = CNCJobPreferencesUI()
  1491. self.tools_defaults_form = ToolsPreferencesUI()
  1492. self.general_options_form = GeneralPreferencesUI()
  1493. self.gerber_options_form = GerberPreferencesUI()
  1494. self.excellon_options_form = ExcellonPreferencesUI()
  1495. self.geometry_options_form = GeometryPreferencesUI()
  1496. self.cncjob_options_form = CNCJobPreferencesUI()
  1497. self.tools_options_form = ToolsPreferencesUI()
  1498. QtWidgets.qApp.installEventFilter(self)
  1499. # restore the Toolbar State from file
  1500. settings = QSettings("Open Source", "FlatCAM")
  1501. if settings.contains("saved_gui_state"):
  1502. saved_gui_state = settings.value('saved_gui_state')
  1503. self.restoreState(saved_gui_state)
  1504. log.debug("FlatCAMGUI.__init__() --> UI state restored.")
  1505. settings = QSettings("Open Source", "FlatCAM")
  1506. if settings.contains("layout"):
  1507. layout = settings.value('layout', type=str)
  1508. if layout == 'standard':
  1509. self.exc_edit_toolbar.setVisible(False)
  1510. self.exc_edit_toolbar.setDisabled(True)
  1511. self.geo_edit_toolbar.setVisible(False)
  1512. self.geo_edit_toolbar.setDisabled(True)
  1513. self.grb_edit_toolbar.setVisible(False)
  1514. self.grb_edit_toolbar.setDisabled(True)
  1515. self.corner_snap_btn.setVisible(False)
  1516. self.snap_magnet.setVisible(False)
  1517. elif layout == 'compact':
  1518. self.exc_edit_toolbar.setDisabled(True)
  1519. self.geo_edit_toolbar.setDisabled(True)
  1520. self.grb_edit_toolbar.setDisabled(True)
  1521. self.snap_magnet.setVisible(True)
  1522. self.corner_snap_btn.setVisible(True)
  1523. self.snap_magnet.setDisabled(True)
  1524. self.corner_snap_btn.setDisabled(True)
  1525. log.debug("FlatCAMGUI.__init__() --> UI layout restored from QSettings.")
  1526. else:
  1527. self.exc_edit_toolbar.setVisible(False)
  1528. self.exc_edit_toolbar.setDisabled(True)
  1529. self.geo_edit_toolbar.setVisible(False)
  1530. self.geo_edit_toolbar.setDisabled(True)
  1531. self.grb_edit_toolbar.setVisible(False)
  1532. self.grb_edit_toolbar.setDisabled(True)
  1533. self.corner_snap_btn.setVisible(False)
  1534. self.snap_magnet.setVisible(False)
  1535. settings.setValue('layout', "standard")
  1536. # This will write the setting to the platform specific storage.
  1537. del settings
  1538. log.debug("FlatCAMGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'")
  1539. def eventFilter(self, obj, event):
  1540. if self.general_defaults_form.general_app_group.toggle_tooltips_cb.get_value() is False:
  1541. if event.type() == QtCore.QEvent.ToolTip:
  1542. return True
  1543. else:
  1544. return False
  1545. return False
  1546. def populate_toolbars(self):
  1547. ### File Toolbar ###
  1548. self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
  1549. _("Open Gerber"))
  1550. self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), _("Open Excellon"))
  1551. self.toolbarfile.addSeparator()
  1552. self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), _("Open project"))
  1553. self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), _("Save project"))
  1554. ### Edit Toolbar ###
  1555. self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), _("New Blank Geometry"))
  1556. self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), _("New Blank Excellon"))
  1557. self.toolbargeo.addSeparator()
  1558. self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), _("Editor"))
  1559. self.update_obj_btn = self.toolbargeo.addAction(
  1560. QtGui.QIcon('share/edit_ok32_bis.png'), _("Save Object and close the Editor")
  1561. )
  1562. self.toolbargeo.addSeparator()
  1563. self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), _("&Delete"))
  1564. ### View Toolbar ###
  1565. self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), _("&Replot"))
  1566. self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), _("&Clear plot"))
  1567. self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), _("Zoom In"))
  1568. self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), _("Zoom Out"))
  1569. self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), _("Zoom Fit"))
  1570. # self.toolbarview.setVisible(False)
  1571. ### Shell Toolbar ###
  1572. self.shell_btn = self.toolbarshell.addAction(QtGui.QIcon('share/shell32.png'), _("&Command Line"))
  1573. ### Tools Toolbar ###
  1574. self.dblsided_btn = self.toolbartools.addAction(QtGui.QIcon('share/doubleside32.png'), _("2Sided Tool"))
  1575. self.cutout_btn = self.toolbartools.addAction(QtGui.QIcon('share/cut16_bis.png'), _("&Cutout Tool"))
  1576. self.ncc_btn = self.toolbartools.addAction(QtGui.QIcon('share/ncc16.png'), _("NCC Tool"))
  1577. self.paint_btn = self.toolbartools.addAction(QtGui.QIcon('share/paint20_1.png'), _("Paint Tool"))
  1578. self.toolbartools.addSeparator()
  1579. self.panelize_btn = self.toolbartools.addAction(QtGui.QIcon('share/panel16.png'), _("Panel Tool"))
  1580. self.film_btn = self.toolbartools.addAction(QtGui.QIcon('share/film16.png'), _("Film Tool"))
  1581. self.solder_btn = self.toolbartools.addAction(QtGui.QIcon('share/solderpastebis32.png'),
  1582. _("SolderPaste Tool"))
  1583. self.toolbartools.addSeparator()
  1584. self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'),
  1585. _("Calculators Tool"))
  1586. self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool"))
  1587. ### Drill Editor Toolbar ###
  1588. self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  1589. self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), _('Add Drill Hole'))
  1590. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  1591. QtGui.QIcon('share/addarray16.png'), _('Add Drill Hole Array'))
  1592. self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), _('Resize Drill'))
  1593. self.exc_edit_toolbar.addSeparator()
  1594. self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _('Copy Drill'))
  1595. self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  1596. _("Delete Drill"))
  1597. self.exc_edit_toolbar.addSeparator()
  1598. self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Drill"))
  1599. ### Geometry Editor Toolbar ###
  1600. self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select 'Esc'"))
  1601. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), _('Add Circle'))
  1602. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), _('Add Arc'))
  1603. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'),
  1604. _('Add Rectangle'))
  1605. self.geo_edit_toolbar.addSeparator()
  1606. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), _('Add Path'))
  1607. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'),
  1608. _('Add Polygon'))
  1609. self.geo_edit_toolbar.addSeparator()
  1610. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), _('Add Text'))
  1611. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'),
  1612. _('Add Buffer'))
  1613. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), _('Paint Shape'))
  1614. self.geo_edit_toolbar.addSeparator()
  1615. self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), _('Polygon Union'))
  1616. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
  1617. _('Polygon Intersection'))
  1618. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'),
  1619. _('Polygon Subtraction'))
  1620. self.geo_edit_toolbar.addSeparator()
  1621. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), _('Cut Path'))
  1622. self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _("Copy Objects"))
  1623. self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  1624. _("Delete Shape"))
  1625. self.geo_transform_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/transform.png'),
  1626. _("Transformations"))
  1627. self.geo_edit_toolbar.addSeparator()
  1628. self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Objects"))
  1629. ### Gerber Editor Toolbar ###
  1630. self.grb_select_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  1631. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/aperture32.png'), _("Add Pad"))
  1632. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/padarray32.png'), _('Add Pad Array'))
  1633. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/track32.png'), _("Add Track"))
  1634. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), _("Add Region"))
  1635. self.grb_edit_toolbar.addSeparator()
  1636. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), _('Buffer'))
  1637. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/scale32.png'), _('Scale'))
  1638. self.grb_edit_toolbar.addSeparator()
  1639. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _("Copy"))
  1640. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  1641. _("Delete"))
  1642. self.grb_transform_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/transform.png'),
  1643. _("Transformations"))
  1644. self.grb_edit_toolbar.addSeparator()
  1645. self.aperture_move_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  1646. ### Snap Toolbar ###
  1647. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  1648. # self.addToolBar(self.snap_toolbar)
  1649. self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), _('Snap to grid'))
  1650. self.grid_gap_x_entry = FCEntry2()
  1651. self.grid_gap_x_entry.setMaximumWidth(70)
  1652. self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
  1653. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  1654. self.grid_gap_y_entry = FCEntry2()
  1655. self.grid_gap_y_entry.setMaximumWidth(70)
  1656. self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
  1657. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  1658. self.grid_space_label = QtWidgets.QLabel(" ")
  1659. self.snap_toolbar.addWidget(self.grid_space_label)
  1660. self.grid_gap_link_cb = FCCheckBox()
  1661. self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
  1662. "is copied to the Grid_Y value."))
  1663. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  1664. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  1665. self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), _('Snap to corner'))
  1666. self.snap_max_dist_entry = FCEntry()
  1667. self.snap_max_dist_entry.setMaximumWidth(70)
  1668. self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
  1669. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  1670. self.grid_snap_btn.setCheckable(True)
  1671. self.corner_snap_btn.setCheckable(True)
  1672. self.update_obj_btn.setEnabled(False)
  1673. # start with GRID activated
  1674. self.grid_snap_btn.trigger()
  1675. settings = QSettings("Open Source", "FlatCAM")
  1676. if settings.contains("layout"):
  1677. layout = settings.value('layout', type=str)
  1678. if layout == 'standard':
  1679. self.exc_edit_toolbar.setVisible(False)
  1680. self.exc_edit_toolbar.setDisabled(True)
  1681. self.geo_edit_toolbar.setVisible(False)
  1682. self.geo_edit_toolbar.setDisabled(True)
  1683. self.grb_edit_toolbar.setVisible(False)
  1684. self.grb_edit_toolbar.setDisabled(True)
  1685. self.corner_snap_btn.setVisible(False)
  1686. self.snap_magnet.setVisible(False)
  1687. elif layout == 'compact':
  1688. self.exc_edit_toolbar.setVisible(True)
  1689. self.exc_edit_toolbar.setDisabled(True)
  1690. self.geo_edit_toolbar.setVisible(True)
  1691. self.geo_edit_toolbar.setDisabled(True)
  1692. self.grb_edit_toolbar.setVisible(False)
  1693. self.grb_edit_toolbar.setDisabled(True)
  1694. self.corner_snap_btn.setVisible(True)
  1695. self.snap_magnet.setVisible(True)
  1696. self.corner_snap_btn.setDisabled(True)
  1697. self.snap_magnet.setDisabled(True)
  1698. def keyPressEvent(self, event):
  1699. modifiers = QtWidgets.QApplication.keyboardModifiers()
  1700. active = self.app.collection.get_active()
  1701. selected = self.app.collection.get_selected()
  1702. # events out of the self.app.collection view (it's about Project Tab) are of type int
  1703. if type(event) is int:
  1704. key = event
  1705. # events from the GUI are of type QKeyEvent
  1706. elif type(event) == QtGui.QKeyEvent:
  1707. key = event.key()
  1708. # events from Vispy are of type KeyEvent
  1709. else:
  1710. key = event.key
  1711. # Propagate to tool
  1712. response = None
  1713. if self.app.call_source == 'app':
  1714. if modifiers == QtCore.Qt.ControlModifier:
  1715. if key == QtCore.Qt.Key_A:
  1716. self.app.on_selectall()
  1717. if key == QtCore.Qt.Key_C:
  1718. self.app.on_copy_object()
  1719. if key == QtCore.Qt.Key_E:
  1720. self.app.on_fileopenexcellon()
  1721. if key == QtCore.Qt.Key_G:
  1722. self.app.on_fileopengerber()
  1723. if key == QtCore.Qt.Key_N:
  1724. self.app.on_file_new_click()
  1725. if key == QtCore.Qt.Key_M:
  1726. self.app.measurement_tool.run()
  1727. if key == QtCore.Qt.Key_O:
  1728. self.app.on_file_openproject()
  1729. if key == QtCore.Qt.Key_S:
  1730. self.app.on_file_saveproject()
  1731. # Toggle Plot Area
  1732. if key == QtCore.Qt.Key_F10 or key == 'F10':
  1733. self.app.on_toggle_plotarea()
  1734. return
  1735. elif modifiers == QtCore.Qt.ShiftModifier:
  1736. # Copy Object Name
  1737. if key == QtCore.Qt.Key_C:
  1738. self.app.on_copy_name()
  1739. # Toggle Code Editor
  1740. if key == QtCore.Qt.Key_E:
  1741. self.app.on_toggle_code_editor()
  1742. # Toggle axis
  1743. if key == QtCore.Qt.Key_G:
  1744. if self.app.toggle_axis is False:
  1745. self.app.plotcanvas.v_line.set_data(color=(0.70, 0.3, 0.3, 1.0))
  1746. self.app.plotcanvas.h_line.set_data(color=(0.70, 0.3, 0.3, 1.0))
  1747. self.app.plotcanvas.redraw()
  1748. self.app.toggle_axis = True
  1749. else:
  1750. self.app.plotcanvas.v_line.set_data(color=(0.0, 0.0, 0.0, 0.0))
  1751. self.app.plotcanvas.h_line.set_data(color=(0.0, 0.0, 0.0, 0.0))
  1752. self.app.plotcanvas.redraw()
  1753. self.app.toggle_axis = False
  1754. # Open Preferences Window
  1755. if key == QtCore.Qt.Key_P:
  1756. self.app.on_preferences()
  1757. return
  1758. # Rotate Object by 90 degree CCW
  1759. if key == QtCore.Qt.Key_R:
  1760. self.app.on_rotate(silent=True, preset=-float(self.app.defaults['tools_transform_rotate']))
  1761. return
  1762. # Run a Script
  1763. if key == QtCore.Qt.Key_S:
  1764. self.app.on_filerunscript()
  1765. return
  1766. # Toggle Workspace
  1767. if key == QtCore.Qt.Key_W:
  1768. self.app.on_workspace_menu()
  1769. return
  1770. # Skew on X axis
  1771. if key == QtCore.Qt.Key_X:
  1772. self.app.on_skewx()
  1773. return
  1774. # Skew on Y axis
  1775. if key == QtCore.Qt.Key_Y:
  1776. self.app.on_skewy()
  1777. return
  1778. elif modifiers == QtCore.Qt.AltModifier:
  1779. # Eanble all plots
  1780. if key == Qt.Key_1:
  1781. self.app.enable_all_plots()
  1782. # Disable all plots
  1783. if key == Qt.Key_2:
  1784. self.app.disable_all_plots()
  1785. # Disable all other plots
  1786. if key == Qt.Key_3:
  1787. self.app.disable_other_plots()
  1788. # Calculator Tool
  1789. if key == QtCore.Qt.Key_C:
  1790. self.app.calculator_tool.run(toggle=True)
  1791. # 2-Sided PCB Tool
  1792. if key == QtCore.Qt.Key_D:
  1793. self.app.dblsidedtool.run(toggle=True)
  1794. return
  1795. # Solder Paste Dispensing Tool
  1796. if key == QtCore.Qt.Key_K:
  1797. self.app.paste_tool.run(toggle=True)
  1798. return
  1799. # Film Tool
  1800. if key == QtCore.Qt.Key_L:
  1801. self.app.film_tool.run(toggle=True)
  1802. return
  1803. # Non-Copper Clear Tool
  1804. if key == QtCore.Qt.Key_N:
  1805. self.app.ncclear_tool.run(toggle=True)
  1806. return
  1807. # Paint Tool
  1808. if key == QtCore.Qt.Key_P:
  1809. self.app.paint_tool.run(toggle=True)
  1810. return
  1811. # Transformation Tool
  1812. if key == QtCore.Qt.Key_R:
  1813. self.app.transform_tool.run(toggle=True)
  1814. return
  1815. # View Source Object Content
  1816. if key == QtCore.Qt.Key_S:
  1817. self.app.on_view_source()
  1818. return
  1819. # Cutout Tool
  1820. if key == QtCore.Qt.Key_U:
  1821. self.app.cutout_tool.run(toggle=True)
  1822. return
  1823. # Panelize Tool
  1824. if key == QtCore.Qt.Key_Z:
  1825. self.app.panelize_tool.run(toggle=True)
  1826. return
  1827. # Toggle Fullscreen
  1828. if key == QtCore.Qt.Key_F10 or key == 'F10':
  1829. self.app.on_fullscreen()
  1830. return
  1831. elif modifiers == QtCore.Qt.NoModifier:
  1832. # Open Manual
  1833. if key == QtCore.Qt.Key_F1 or key == 'F1':
  1834. webbrowser.open(self.app.manual_url)
  1835. # Show shortcut list
  1836. if key == QtCore.Qt.Key_F3 or key == 'F3':
  1837. self.app.on_shortcut_list()
  1838. # Open Video Help
  1839. if key == QtCore.Qt.Key_F4 or key == 'F4':
  1840. webbrowser.open(self.app.video_url)
  1841. # Switch to Project Tab
  1842. if key == QtCore.Qt.Key_1:
  1843. self.app.on_select_tab('project')
  1844. # Switch to Selected Tab
  1845. if key == QtCore.Qt.Key_2:
  1846. self.app.on_select_tab('selected')
  1847. # Switch to Tool Tab
  1848. if key == QtCore.Qt.Key_3:
  1849. self.app.on_select_tab('tool')
  1850. # Delete from PyQt
  1851. # It's meant to make a difference between delete objects and delete tools in
  1852. # Geometry Selected tool table
  1853. if key == QtCore.Qt.Key_Delete:
  1854. self.app.on_delete_keypress()
  1855. # Delete from canvas
  1856. if key == 'Delete':
  1857. # Delete via the application to
  1858. # ensure cleanup of the GUI
  1859. if active:
  1860. active.app.on_delete()
  1861. # Escape = Deselect All
  1862. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  1863. self.app.on_deselect_all()
  1864. # if in full screen, exit to normal view
  1865. self.showNormal()
  1866. self.app.restore_toolbar_view()
  1867. self.splitter_left.setVisible(True)
  1868. self.app.toggle_fscreen = False
  1869. # try to disconnect the slot from Set Origin
  1870. try:
  1871. self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_set_zero_click)
  1872. except:
  1873. pass
  1874. self.app.inform.emit("")
  1875. # Space = Toggle Active/Inactive
  1876. if key == QtCore.Qt.Key_Space:
  1877. for select in selected:
  1878. select.ui.plot_cb.toggle()
  1879. self.app.delete_selection_shape()
  1880. # New Geometry
  1881. if key == QtCore.Qt.Key_B:
  1882. self.app.new_gerber_object()
  1883. # Copy Object Name
  1884. if key == QtCore.Qt.Key_E:
  1885. self.app.object2editor()
  1886. # Grid toggle
  1887. if key == QtCore.Qt.Key_G:
  1888. self.app.ui.grid_snap_btn.trigger()
  1889. # Jump to coords
  1890. if key == QtCore.Qt.Key_J:
  1891. self.app.on_jump_to()
  1892. # New Excellon
  1893. if key == QtCore.Qt.Key_L:
  1894. self.app.new_excellon_object()
  1895. # Move tool toggle
  1896. if key == QtCore.Qt.Key_M:
  1897. self.app.move_tool.toggle()
  1898. # New Geometry
  1899. if key == QtCore.Qt.Key_N:
  1900. self.app.new_geometry_object()
  1901. # Set Origin
  1902. if key == QtCore.Qt.Key_O:
  1903. self.app.on_set_origin()
  1904. return
  1905. # Set Origin
  1906. if key == QtCore.Qt.Key_P:
  1907. self.app.properties_tool.run()
  1908. return
  1909. # Change Units
  1910. if key == QtCore.Qt.Key_Q:
  1911. if self.app.defaults["units"] == 'MM':
  1912. self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
  1913. else:
  1914. self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
  1915. self.app.on_toggle_units()
  1916. # Rotate Object by 90 degree CW
  1917. if key == QtCore.Qt.Key_R:
  1918. self.app.on_rotate(silent=True, preset=self.app.defaults['tools_transform_rotate'])
  1919. # Shell toggle
  1920. if key == QtCore.Qt.Key_S:
  1921. self.app.on_toggle_shell()
  1922. # Add a Tool from shortcut
  1923. if key == QtCore.Qt.Key_T:
  1924. self.app.on_tool_add_keypress()
  1925. # Zoom Fit
  1926. if key == QtCore.Qt.Key_V:
  1927. self.app.on_zoom_fit(None)
  1928. # Mirror on X the selected object(s)
  1929. if key == QtCore.Qt.Key_X:
  1930. self.app.on_flipx()
  1931. # Mirror on Y the selected object(s)
  1932. if key == QtCore.Qt.Key_Y:
  1933. self.app.on_flipy()
  1934. # Zoom In
  1935. if key == QtCore.Qt.Key_Equal:
  1936. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'], self.app.mouse)
  1937. # Zoom Out
  1938. if key == QtCore.Qt.Key_Minus:
  1939. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'], self.app.mouse)
  1940. # toggle display of Notebook area
  1941. if key == QtCore.Qt.Key_QuoteLeft:
  1942. self.app.on_toggle_notebook()
  1943. return
  1944. elif self.app.call_source == 'geo_editor':
  1945. if modifiers == QtCore.Qt.ControlModifier:
  1946. # save (update) the current geometry and return to the App
  1947. if key == QtCore.Qt.Key_S or key == 'S':
  1948. self.app.editor2object()
  1949. return
  1950. # toggle the measurement tool
  1951. if key == QtCore.Qt.Key_M or key == 'M':
  1952. self.app.measurement_tool.run()
  1953. return
  1954. # Cut Action Tool
  1955. if key == QtCore.Qt.Key_X or key == 'X':
  1956. if self.app.geo_editor.get_selected() is not None:
  1957. self.app.geo_editor.cutpath()
  1958. else:
  1959. msg = _('Please first select a geometry item to be cutted\n' \
  1960. 'then select the geometry item that will be cutted\n' \
  1961. 'out of the first item. In the end press ~X~ key or\n' \
  1962. 'the toolbar button.')
  1963. messagebox = QtWidgets.QMessageBox()
  1964. messagebox.setText(msg)
  1965. messagebox.setWindowTitle(_("Warning"))
  1966. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  1967. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  1968. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  1969. messagebox.exec_()
  1970. return
  1971. elif modifiers == QtCore.Qt.ShiftModifier:
  1972. # Skew on X axis
  1973. if key == QtCore.Qt.Key_X or key == 'X':
  1974. self.app.geo_editor.transform_tool.on_skewx_key()
  1975. return
  1976. # Skew on Y axis
  1977. if key == QtCore.Qt.Key_Y or key == 'Y':
  1978. self.app.geo_editor.transform_tool.on_skewy_key()
  1979. return
  1980. elif modifiers == QtCore.Qt.AltModifier:
  1981. # Transformation Tool
  1982. if key == QtCore.Qt.Key_R or key == 'R':
  1983. self.app.geo_editor.select_tool('transform')
  1984. return
  1985. # Offset on X axis
  1986. if key == QtCore.Qt.Key_X or key == 'X':
  1987. self.app.geo_editor.transform_tool.on_offx_key()
  1988. return
  1989. # Offset on Y axis
  1990. if key == QtCore.Qt.Key_Y or key == 'Y':
  1991. self.app.geo_editor.transform_tool.on_offy_key()
  1992. return
  1993. elif modifiers == QtCore.Qt.NoModifier:
  1994. # toggle display of Notebook area
  1995. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  1996. self.app.on_toggle_notebook()
  1997. # Finish the current action. Use with tools that do not
  1998. # complete automatically, like a polygon or path.
  1999. if key == QtCore.Qt.Key_Enter or key == 'Enter':
  2000. if isinstance(self.app.geo_editor.active_tool, FCShapeTool):
  2001. if self.app.geo_editor.active_tool.name == 'rotate':
  2002. self.app.geo_editor.active_tool.make()
  2003. if self.app.geo_editor.active_tool.complete:
  2004. self.app.geo_editor.on_shape_complete()
  2005. self.app.inform.emit(_("[success] Done."))
  2006. # automatically make the selection tool active after completing current action
  2007. self.app.geo_editor.select_tool('select')
  2008. return
  2009. else:
  2010. self.app.geo_editor.active_tool.click(
  2011. self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
  2012. self.app.geo_editor.active_tool.make()
  2013. if self.app.geo_editor.active_tool.complete:
  2014. self.app.geo_editor.on_shape_complete()
  2015. self.app.inform.emit(_("[success] Done."))
  2016. # automatically make the selection tool active after completing current action
  2017. self.app.geo_editor.select_tool('select')
  2018. # Abort the current action
  2019. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2020. # TODO: ...?
  2021. # self.on_tool_select("select")
  2022. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled."))
  2023. self.app.geo_editor.delete_utility_geometry()
  2024. # deselect any shape that might be selected
  2025. self.app.geo_editor.selected = []
  2026. self.app.geo_editor.replot()
  2027. self.app.geo_editor.select_tool('select')
  2028. # hide the notebook
  2029. self.app.ui.splitter.setSizes([0, 1])
  2030. return
  2031. # Delete selected object
  2032. if key == QtCore.Qt.Key_Delete or key == 'Delete':
  2033. self.app.geo_editor.delete_selected()
  2034. self.app.geo_editor.replot()
  2035. # Rotate
  2036. if key == QtCore.Qt.Key_Space or key == 'Space':
  2037. self.app.geo_editor.transform_tool.on_rotate_key()
  2038. if key == QtCore.Qt.Key_Minus or key == '-':
  2039. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'],
  2040. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2041. if key == QtCore.Qt.Key_Equal or key == '=':
  2042. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'],
  2043. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2044. # Switch to Project Tab
  2045. if key == QtCore.Qt.Key_1 or key == '1':
  2046. self.app.on_select_tab('project')
  2047. # Switch to Selected Tab
  2048. if key == QtCore.Qt.Key_2 or key == '2':
  2049. self.app.on_select_tab('selected')
  2050. # Switch to Tool Tab
  2051. if key == QtCore.Qt.Key_3 or key == '3':
  2052. self.app.on_select_tab('tool')
  2053. if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() == False:
  2054. response = self.app.geo_editor.active_tool.on_key(key=key)
  2055. if response is not None:
  2056. self.app.inform.emit(response)
  2057. else:
  2058. # Arc Tool
  2059. if key == QtCore.Qt.Key_A or key == 'A':
  2060. self.app.geo_editor.select_tool('arc')
  2061. # Buffer
  2062. if key == QtCore.Qt.Key_B or key == 'B':
  2063. self.app.geo_editor.select_tool('buffer')
  2064. # Copy
  2065. if key == QtCore.Qt.Key_C or key == 'C':
  2066. self.app.geo_editor.on_copy_click()
  2067. # Substract Tool
  2068. if key == QtCore.Qt.Key_E or key == 'E':
  2069. if self.app.geo_editor.get_selected() is not None:
  2070. self.app.geo_editor.intersection()
  2071. else:
  2072. msg = _("Please select geometry items \n" \
  2073. "on which to perform Intersection Tool.")
  2074. messagebox = QtWidgets.QMessageBox()
  2075. messagebox.setText(msg)
  2076. messagebox.setWindowTitle(_("Warning"))
  2077. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  2078. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2079. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2080. messagebox.exec_()
  2081. # Grid Snap
  2082. if key == QtCore.Qt.Key_G or key == 'G':
  2083. self.app.ui.grid_snap_btn.trigger()
  2084. # make sure that the cursor shape is enabled/disabled, too
  2085. if self.app.geo_editor.options['grid_snap'] is True:
  2086. self.app.app_cursor.enabled = True
  2087. else:
  2088. self.app.app_cursor.enabled = False
  2089. # Paint
  2090. if key == QtCore.Qt.Key_I or key == 'I':
  2091. self.app.geo_editor.select_tool('paint')
  2092. # Jump to coords
  2093. if key == QtCore.Qt.Key_J or key == 'J':
  2094. self.app.on_jump_to()
  2095. # Corner Snap
  2096. if key == QtCore.Qt.Key_K or key == 'K':
  2097. self.app.geo_editor.on_corner_snap()
  2098. # Move
  2099. if key == QtCore.Qt.Key_M or key == 'M':
  2100. self.app.geo_editor.on_move_click()
  2101. # Polygon Tool
  2102. if key == QtCore.Qt.Key_N or key == 'N':
  2103. self.app.geo_editor.select_tool('polygon')
  2104. # Circle Tool
  2105. if key == QtCore.Qt.Key_O or key == 'O':
  2106. self.app.geo_editor.select_tool('circle')
  2107. # Path Tool
  2108. if key == QtCore.Qt.Key_P or key == 'P':
  2109. self.app.geo_editor.select_tool('path')
  2110. # Rectangle Tool
  2111. if key == QtCore.Qt.Key_R or key == 'R':
  2112. self.app.geo_editor.select_tool('rectangle')
  2113. # Substract Tool
  2114. if key == QtCore.Qt.Key_S or key == 'S':
  2115. if self.app.geo_editor.get_selected() is not None:
  2116. self.app.geo_editor.subtract()
  2117. else:
  2118. msg = _(
  2119. "Please select geometry items \n"
  2120. "on which to perform Substraction Tool.")
  2121. messagebox = QtWidgets.QMessageBox()
  2122. messagebox.setText(msg)
  2123. messagebox.setWindowTitle(_("Warning"))
  2124. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  2125. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2126. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2127. messagebox.exec_()
  2128. # Add Text Tool
  2129. if key == QtCore.Qt.Key_T or key == 'T':
  2130. self.app.geo_editor.select_tool('text')
  2131. # Substract Tool
  2132. if key == QtCore.Qt.Key_U or key == 'U':
  2133. if self.app.geo_editor.get_selected() is not None:
  2134. self.app.geo_editor.union()
  2135. else:
  2136. msg = _("Please select geometry items \n"
  2137. "on which to perform union.")
  2138. messagebox = QtWidgets.QMessageBox()
  2139. messagebox.setText(msg)
  2140. messagebox.setWindowTitle(_("Warning"))
  2141. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  2142. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2143. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2144. messagebox.exec_()
  2145. if key == QtCore.Qt.Key_V or key == 'V':
  2146. self.app.on_zoom_fit(None)
  2147. # Flip on X axis
  2148. if key == QtCore.Qt.Key_X or key == 'X':
  2149. self.app.geo_editor.transform_tool.on_flipx()
  2150. return
  2151. # Flip on Y axis
  2152. if key == QtCore.Qt.Key_Y or key == 'Y':
  2153. self.app.geo_editor.transform_tool.on_flipy()
  2154. return
  2155. # Show Shortcut list
  2156. if key == 'F3':
  2157. self.app.on_shortcut_list()
  2158. elif self.app.call_source == 'grb_editor':
  2159. if modifiers == QtCore.Qt.ControlModifier:
  2160. # save (update) the current geometry and return to the App
  2161. if key == QtCore.Qt.Key_S or key == 'S':
  2162. self.app.editor2object()
  2163. return
  2164. # toggle the measurement tool
  2165. if key == QtCore.Qt.Key_M or key == 'M':
  2166. self.app.measurement_tool.run()
  2167. return
  2168. elif modifiers == QtCore.Qt.ShiftModifier:
  2169. pass
  2170. elif modifiers == QtCore.Qt.AltModifier:
  2171. # Transformation Tool
  2172. if key == QtCore.Qt.Key_R or key == 'R':
  2173. self.app.grb_editor.on_transform()
  2174. return
  2175. elif modifiers == QtCore.Qt.NoModifier:
  2176. # Abort the current action
  2177. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2178. # self.on_tool_select("select")
  2179. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled."))
  2180. self.app.grb_editor.delete_utility_geometry()
  2181. # self.app.grb_editor.plot_all()
  2182. self.app.grb_editor.active_tool.clean_up()
  2183. self.app.grb_editor.select_tool('select')
  2184. return
  2185. # Delete selected object if delete key event comes out of canvas
  2186. if key == 'Delete':
  2187. self.app.grb_editor.launched_from_shortcuts = True
  2188. if self.app.grb_editor.selected:
  2189. self.app.grb_editor.delete_selected()
  2190. self.app.grb_editor.plot_all()
  2191. else:
  2192. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to delete."))
  2193. return
  2194. # Delete aperture in apertures table if delete key event comes from the Selected Tab
  2195. if key == QtCore.Qt.Key_Delete:
  2196. self.app.grb_editor.launched_from_shortcuts = True
  2197. self.app.grb_editor.on_aperture_delete()
  2198. return
  2199. if key == QtCore.Qt.Key_Minus or key == '-':
  2200. self.app.grb_editor.launched_from_shortcuts = True
  2201. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'],
  2202. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2203. return
  2204. if key == QtCore.Qt.Key_Equal or key == '=':
  2205. self.app.grb_editor.launched_from_shortcuts = True
  2206. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'],
  2207. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2208. return
  2209. # toggle display of Notebook area
  2210. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2211. self.app.grb_editor.launched_from_shortcuts = True
  2212. self.app.on_toggle_notebook()
  2213. return
  2214. # Rotate
  2215. if key == QtCore.Qt.Key_Space or key == 'Space':
  2216. self.app.grb_editor.transform_tool.on_rotate_key()
  2217. # Switch to Project Tab
  2218. if key == QtCore.Qt.Key_1 or key == '1':
  2219. self.app.grb_editor.launched_from_shortcuts = True
  2220. self.app.on_select_tab('project')
  2221. return
  2222. # Switch to Selected Tab
  2223. if key == QtCore.Qt.Key_2 or key == '2':
  2224. self.app.grb_editor.launched_from_shortcuts = True
  2225. self.app.on_select_tab('selected')
  2226. return
  2227. # Switch to Tool Tab
  2228. if key == QtCore.Qt.Key_3 or key == '3':
  2229. self.app.grb_editor.launched_from_shortcuts = True
  2230. self.app.on_select_tab('tool')
  2231. return
  2232. # we do this so we can reuse the following keys while inside a Tool
  2233. # the above keys are general enough so were left outside
  2234. if self.app.grb_editor.active_tool is not None and self.grb_select_btn.isChecked() == False:
  2235. response = self.app.grb_editor.active_tool.on_key(key=key)
  2236. if response is not None:
  2237. self.app.inform.emit(response)
  2238. else:
  2239. # Add Array of pads
  2240. if key == QtCore.Qt.Key_A or key == 'A':
  2241. self.app.grb_editor.launched_from_shortcuts = True
  2242. self.app.inform.emit("Click on target point.")
  2243. self.app.ui.add_pad_ar_btn.setChecked(True)
  2244. self.app.grb_editor.x = self.app.mouse[0]
  2245. self.app.grb_editor.y = self.app.mouse[1]
  2246. self.app.grb_editor.select_tool('array')
  2247. return
  2248. # Scale Tool
  2249. if key == QtCore.Qt.Key_B or key == 'B':
  2250. self.app.grb_editor.launched_from_shortcuts = True
  2251. self.app.grb_editor.select_tool('buffer')
  2252. return
  2253. # Copy
  2254. if key == QtCore.Qt.Key_C or key == 'C':
  2255. self.app.grb_editor.launched_from_shortcuts = True
  2256. if self.app.grb_editor.selected:
  2257. self.app.inform.emit(_("Click on target point."))
  2258. self.app.ui.aperture_copy_btn.setChecked(True)
  2259. self.app.grb_editor.on_tool_select('copy')
  2260. self.app.grb_editor.active_tool.set_origin(
  2261. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  2262. else:
  2263. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to copy."))
  2264. return
  2265. # Grid Snap
  2266. if key == QtCore.Qt.Key_G or key == 'G':
  2267. self.app.grb_editor.launched_from_shortcuts = True
  2268. # make sure that the cursor shape is enabled/disabled, too
  2269. if self.app.grb_editor.options['grid_snap'] is True:
  2270. self.app.app_cursor.enabled = False
  2271. else:
  2272. self.app.app_cursor.enabled = True
  2273. self.app.ui.grid_snap_btn.trigger()
  2274. return
  2275. # Jump to coords
  2276. if key == QtCore.Qt.Key_J or key == 'J':
  2277. self.app.on_jump_to()
  2278. # Corner Snap
  2279. if key == QtCore.Qt.Key_K or key == 'K':
  2280. self.app.grb_editor.launched_from_shortcuts = True
  2281. self.app.ui.corner_snap_btn.trigger()
  2282. return
  2283. # Move
  2284. if key == QtCore.Qt.Key_M or key == 'M':
  2285. self.app.grb_editor.launched_from_shortcuts = True
  2286. if self.app.grb_editor.selected:
  2287. self.app.inform.emit(_("Click on target point."))
  2288. self.app.ui.aperture_move_btn.setChecked(True)
  2289. self.app.grb_editor.on_tool_select('move')
  2290. self.app.grb_editor.active_tool.set_origin(
  2291. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  2292. else:
  2293. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to move."))
  2294. return
  2295. # Add Region Tool
  2296. if key == QtCore.Qt.Key_N or key == 'N':
  2297. self.app.grb_editor.launched_from_shortcuts = True
  2298. self.app.grb_editor.select_tool('region')
  2299. return
  2300. # Add Pad Tool
  2301. if key == QtCore.Qt.Key_P or key == 'P':
  2302. self.app.grb_editor.launched_from_shortcuts = True
  2303. self.app.inform.emit(_("Click on target point."))
  2304. self.app.ui.add_pad_ar_btn.setChecked(True)
  2305. self.app.grb_editor.x = self.app.mouse[0]
  2306. self.app.grb_editor.y = self.app.mouse[1]
  2307. self.app.grb_editor.select_tool('pad')
  2308. return
  2309. # Scale Tool
  2310. if key == QtCore.Qt.Key_S or key == 'S':
  2311. self.app.grb_editor.launched_from_shortcuts = True
  2312. self.app.grb_editor.select_tool('scale')
  2313. return
  2314. # Add Track
  2315. if key == QtCore.Qt.Key_T or key == 'T':
  2316. self.app.grb_editor.launched_from_shortcuts = True
  2317. ## Current application units in Upper Case
  2318. self.app.grb_editor.select_tool('track')
  2319. return
  2320. # Zoom Fit
  2321. if key == QtCore.Qt.Key_V or key == 'V':
  2322. self.app.grb_editor.launched_from_shortcuts = True
  2323. self.app.on_zoom_fit(None)
  2324. return
  2325. # Show Shortcut list
  2326. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2327. self.app.on_shortcut_list()
  2328. return
  2329. elif self.app.call_source == 'exc_editor':
  2330. if modifiers == QtCore.Qt.ControlModifier:
  2331. # save (update) the current geometry and return to the App
  2332. if key == QtCore.Qt.Key_S or key == 'S':
  2333. self.app.editor2object()
  2334. return
  2335. # toggle the measurement tool
  2336. if key == QtCore.Qt.Key_M or key == 'M':
  2337. self.app.measurement_tool.run()
  2338. return
  2339. elif modifiers == QtCore.Qt.ShiftModifier:
  2340. pass
  2341. elif modifiers == QtCore.Qt.AltModifier:
  2342. pass
  2343. elif modifiers == QtCore.Qt.NoModifier:
  2344. # Abort the current action
  2345. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2346. # TODO: ...?
  2347. # self.on_tool_select("select")
  2348. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled."))
  2349. self.app.exc_editor.delete_utility_geometry()
  2350. self.app.exc_editor.replot()
  2351. # self.select_btn.setChecked(True)
  2352. # self.on_tool_select('select')
  2353. self.app.exc_editor.select_tool('select')
  2354. return
  2355. # Delete selected object if delete key event comes out of canvas
  2356. if key == 'Delete':
  2357. self.app.exc_editor.launched_from_shortcuts = True
  2358. if self.app.exc_editor.selected:
  2359. self.app.exc_editor.delete_selected()
  2360. self.app.exc_editor.replot()
  2361. else:
  2362. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to delete."))
  2363. return
  2364. # Delete tools in tools table if delete key event comes from the Selected Tab
  2365. if key == QtCore.Qt.Key_Delete:
  2366. self.app.exc_editor.launched_from_shortcuts = True
  2367. self.app.exc_editor.on_tool_delete()
  2368. return
  2369. if key == QtCore.Qt.Key_Minus or key == '-':
  2370. self.app.exc_editor.launched_from_shortcuts = True
  2371. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'],
  2372. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  2373. return
  2374. if key == QtCore.Qt.Key_Equal or key == '=':
  2375. self.app.exc_editor.launched_from_shortcuts = True
  2376. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'],
  2377. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  2378. return
  2379. # toggle display of Notebook area
  2380. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2381. self.app.exc_editor.launched_from_shortcuts = True
  2382. self.app.on_toggle_notebook()
  2383. return
  2384. # Switch to Project Tab
  2385. if key == QtCore.Qt.Key_1 or key == '1':
  2386. self.app.exc_editor.launched_from_shortcuts = True
  2387. self.app.on_select_tab('project')
  2388. return
  2389. # Switch to Selected Tab
  2390. if key == QtCore.Qt.Key_2 or key == '2':
  2391. self.app.exc_editor.launched_from_shortcuts = True
  2392. self.app.on_select_tab('selected')
  2393. return
  2394. # Switch to Tool Tab
  2395. if key == QtCore.Qt.Key_3 or key == '3':
  2396. self.app.exc_editor.launched_from_shortcuts = True
  2397. self.app.on_select_tab('tool')
  2398. return
  2399. # Add Array of Drill Hole Tool
  2400. if key == QtCore.Qt.Key_A or key == 'A':
  2401. self.app.exc_editor.launched_from_shortcuts = True
  2402. self.app.inform.emit("Click on target point.")
  2403. self.app.ui.add_drill_array_btn.setChecked(True)
  2404. self.app.exc_editor.x = self.app.mouse[0]
  2405. self.app.exc_editor.y = self.app.mouse[1]
  2406. self.app.exc_editor.select_tool('drill_array')
  2407. return
  2408. # Copy
  2409. if key == QtCore.Qt.Key_C or key == 'C':
  2410. self.app.exc_editor.launched_from_shortcuts = True
  2411. if self.app.exc_editor.selected:
  2412. self.app.inform.emit(_("Click on target point."))
  2413. self.app.ui.copy_drill_btn.setChecked(True)
  2414. self.app.exc_editor.on_tool_select('drill_copy')
  2415. self.app.exc_editor.active_tool.set_origin(
  2416. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  2417. else:
  2418. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to copy."))
  2419. return
  2420. # Add Drill Hole Tool
  2421. if key == QtCore.Qt.Key_D or key == 'D':
  2422. self.app.exc_editor.launched_from_shortcuts = True
  2423. self.app.inform.emit(_("Click on target point."))
  2424. self.app.ui.add_drill_btn.setChecked(True)
  2425. self.app.exc_editor.x = self.app.mouse[0]
  2426. self.app.exc_editor.y = self.app.mouse[1]
  2427. self.app.exc_editor.select_tool('drill_add')
  2428. return
  2429. # Grid Snap
  2430. if key == QtCore.Qt.Key_G or key == 'G':
  2431. self.app.exc_editor.launched_from_shortcuts = True
  2432. # make sure that the cursor shape is enabled/disabled, too
  2433. if self.app.exc_editor.options['grid_snap'] is True:
  2434. self.app.app_cursor.enabled = False
  2435. else:
  2436. self.app.app_cursor.enabled = True
  2437. self.app.ui.grid_snap_btn.trigger()
  2438. return
  2439. # Jump to coords
  2440. if key == QtCore.Qt.Key_J or key == 'J':
  2441. self.app.on_jump_to()
  2442. # Corner Snap
  2443. if key == QtCore.Qt.Key_K or key == 'K':
  2444. self.app.exc_editor.launched_from_shortcuts = True
  2445. self.app.ui.corner_snap_btn.trigger()
  2446. return
  2447. # Move
  2448. if key == QtCore.Qt.Key_M or key == 'M':
  2449. self.app.exc_editor.launched_from_shortcuts = True
  2450. if self.app.exc_editor.selected:
  2451. self.app.inform.emit(_("Click on target point."))
  2452. self.app.ui.move_drill_btn.setChecked(True)
  2453. self.app.exc_editor.on_tool_select('drill_move')
  2454. self.app.exc_editor.active_tool.set_origin(
  2455. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  2456. else:
  2457. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to move."))
  2458. return
  2459. # Resize Tool
  2460. if key == QtCore.Qt.Key_R or key == 'R':
  2461. self.app.exc_editor.launched_from_shortcuts = True
  2462. self.app.exc_editor.select_tool('drill_resize')
  2463. return
  2464. # Add Tool
  2465. if key == QtCore.Qt.Key_T or key == 'T':
  2466. self.app.exc_editor.launched_from_shortcuts = True
  2467. ## Current application units in Upper Case
  2468. self.units = self.general_defaults_group.general_app_group.units_radio.get_value().upper()
  2469. tool_add_popup = FCInputDialog(title=_("New Tool ..."),
  2470. text=_('Enter a Tool Diameter:'),
  2471. min=0.0000, max=99.9999, decimals=4)
  2472. tool_add_popup.setWindowIcon(QtGui.QIcon('share/letter_t_32.png'))
  2473. val, ok = tool_add_popup.get_value()
  2474. if ok:
  2475. self.app.exc_editor.on_tool_add(tooldia=val)
  2476. self.app.inform.emit(
  2477. _("[success] Added new tool with dia: {dia} {units}").format(dia='%.4f' % float(val), units=str(self.units)))
  2478. else:
  2479. self.app.inform.emit(
  2480. _("[WARNING_NOTCL] Adding Tool cancelled ..."))
  2481. return
  2482. # Zoom Fit
  2483. if key == QtCore.Qt.Key_V or key == 'V':
  2484. self.app.exc_editor.launched_from_shortcuts = True
  2485. self.app.on_zoom_fit(None)
  2486. return
  2487. # Propagate to tool
  2488. response = None
  2489. if self.app.exc_editor.active_tool is not None:
  2490. response = self.app.exc_editor.active_tool.on_key(key=key)
  2491. if response is not None:
  2492. self.app.inform.emit(response)
  2493. # Show Shortcut list
  2494. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2495. self.app.on_shortcut_list()
  2496. return
  2497. elif self.app.call_source == 'measurement':
  2498. if modifiers == QtCore.Qt.ControlModifier:
  2499. pass
  2500. elif modifiers == QtCore.Qt.AltModifier:
  2501. pass
  2502. elif modifiers == QtCore.Qt.ShiftModifier:
  2503. pass
  2504. elif modifiers == QtCore.Qt.NoModifier:
  2505. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2506. # abort the measurement action
  2507. self.app.measurement_tool.on_measure(activate=False)
  2508. self.app.measurement_tool.deactivate_measure_tool()
  2509. self.app.inform.emit(_("Measurement Tool exit..."))
  2510. return
  2511. if key == QtCore.Qt.Key_G or key == 'G':
  2512. self.app.ui.grid_snap_btn.trigger()
  2513. return
  2514. def dragEnterEvent(self, event):
  2515. if event.mimeData().hasUrls:
  2516. event.accept()
  2517. else:
  2518. event.ignore()
  2519. def dragMoveEvent(self, event):
  2520. if event.mimeData().hasUrls:
  2521. event.accept()
  2522. else:
  2523. event.ignore()
  2524. def dropEvent(self, event):
  2525. if event.mimeData().hasUrls:
  2526. event.setDropAction(QtCore.Qt.CopyAction)
  2527. event.accept()
  2528. for url in event.mimeData().urls():
  2529. self.filename = str(url.toLocalFile())
  2530. if self.filename == "":
  2531. self.app.inform.emit("Open cancelled.")
  2532. else:
  2533. extension = self.filename.lower().rpartition('.')[-1]
  2534. if extension in self.app.grb_list:
  2535. self.app.worker_task.emit({'fcn': self.app.open_gerber,
  2536. 'params': [self.filename]})
  2537. else:
  2538. event.ignore()
  2539. if extension in self.app.exc_list:
  2540. self.app.worker_task.emit({'fcn': self.app.open_excellon,
  2541. 'params': [self.filename]})
  2542. else:
  2543. event.ignore()
  2544. if extension in self.app.gcode_list:
  2545. self.app.worker_task.emit({'fcn': self.app.open_gcode,
  2546. 'params': [self.filename]})
  2547. else:
  2548. event.ignore()
  2549. if extension in self.app.svg_list:
  2550. object_type = 'geometry'
  2551. self.app.worker_task.emit({'fcn': self.app.import_svg,
  2552. 'params': [self.filename, object_type, None]})
  2553. if extension in self.app.dxf_list:
  2554. object_type = 'geometry'
  2555. self.app.worker_task.emit({'fcn': self.app.import_dxf,
  2556. 'params': [self.filename, object_type, None]})
  2557. if extension in self.app.prj_list:
  2558. # self.app.open_project() is not Thread Safe
  2559. self.app.open_project(self.filename)
  2560. else:
  2561. event.ignore()
  2562. else:
  2563. event.ignore()
  2564. def closeEvent(self, event):
  2565. if self.app.save_in_progress:
  2566. self.app.inform.emit(_("[WARNING_NOTCL] Application is saving the project. Please wait ..."))
  2567. else:
  2568. grect = self.geometry()
  2569. # self.splitter.sizes()[0] is actually the size of the "notebook"
  2570. if not self.isMaximized():
  2571. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  2572. self.final_save.emit()
  2573. event.ignore()
  2574. class GeneralPreferencesUI(QtWidgets.QWidget):
  2575. def __init__(self, parent=None):
  2576. QtWidgets.QWidget.__init__(self, parent=parent)
  2577. self.layout = QtWidgets.QHBoxLayout()
  2578. self.setLayout(self.layout)
  2579. self.general_app_group = GeneralAppPrefGroupUI()
  2580. self.general_app_group.setFixedWidth(250)
  2581. self.general_gui_group = GeneralGUIPrefGroupUI()
  2582. self.general_gui_group.setFixedWidth(250)
  2583. self.general_gui_set_group = GeneralGUISetGroupUI()
  2584. self.general_gui_set_group.setFixedWidth(250)
  2585. self.layout.addWidget(self.general_app_group)
  2586. self.layout.addWidget(self.general_gui_group)
  2587. self.layout.addWidget(self.general_gui_set_group)
  2588. self.layout.addStretch()
  2589. class GerberPreferencesUI(QtWidgets.QWidget):
  2590. def __init__(self, parent=None):
  2591. QtWidgets.QWidget.__init__(self, parent=parent)
  2592. self.layout = QtWidgets.QHBoxLayout()
  2593. self.setLayout(self.layout)
  2594. self.gerber_gen_group = GerberGenPrefGroupUI()
  2595. self.gerber_gen_group.setFixedWidth(250)
  2596. self.gerber_opt_group = GerberOptPrefGroupUI()
  2597. self.gerber_opt_group.setFixedWidth(230)
  2598. self.gerber_adv_opt_group = GerberAdvOptPrefGroupUI()
  2599. self.gerber_adv_opt_group.setFixedWidth(200)
  2600. self.layout.addWidget(self.gerber_gen_group)
  2601. self.layout.addWidget(self.gerber_opt_group)
  2602. self.layout.addWidget(self.gerber_adv_opt_group)
  2603. self.layout.addStretch()
  2604. class ExcellonPreferencesUI(QtWidgets.QWidget):
  2605. def __init__(self, parent=None):
  2606. QtWidgets.QWidget.__init__(self, parent=parent)
  2607. self.layout = QtWidgets.QHBoxLayout()
  2608. self.setLayout(self.layout)
  2609. self.excellon_gen_group = ExcellonGenPrefGroupUI()
  2610. self.excellon_gen_group.setFixedWidth(220)
  2611. self.excellon_opt_group = ExcellonOptPrefGroupUI()
  2612. self.excellon_opt_group.setFixedWidth(250)
  2613. self.excellon_exp_group = ExcellonExpPrefGroupUI()
  2614. self.excellon_exp_group.setFixedWidth(250)
  2615. self.excellon_adv_opt_group = ExcellonAdvOptPrefGroupUI()
  2616. self.excellon_adv_opt_group.setFixedWidth(250)
  2617. self.vlay = QtWidgets.QVBoxLayout()
  2618. self.vlay.addWidget(self.excellon_opt_group)
  2619. self.vlay.addWidget(self.excellon_exp_group)
  2620. self.layout.addWidget(self.excellon_gen_group)
  2621. self.layout.addLayout(self.vlay)
  2622. self.layout.addWidget(self.excellon_adv_opt_group)
  2623. self.layout.addStretch()
  2624. class GeometryPreferencesUI(QtWidgets.QWidget):
  2625. def __init__(self, parent=None):
  2626. QtWidgets.QWidget.__init__(self, parent=parent)
  2627. self.layout = QtWidgets.QHBoxLayout()
  2628. self.setLayout(self.layout)
  2629. self.geometry_gen_group = GeometryGenPrefGroupUI()
  2630. self.geometry_gen_group.setFixedWidth(220)
  2631. self.geometry_opt_group = GeometryOptPrefGroupUI()
  2632. self.geometry_opt_group.setFixedWidth(250)
  2633. self.geometry_adv_opt_group = GeometryAdvOptPrefGroupUI()
  2634. self.geometry_adv_opt_group.setFixedWidth(250)
  2635. self.layout.addWidget(self.geometry_gen_group)
  2636. self.layout.addWidget(self.geometry_opt_group)
  2637. self.layout.addWidget(self.geometry_adv_opt_group)
  2638. self.layout.addStretch()
  2639. class ToolsPreferencesUI(QtWidgets.QWidget):
  2640. def __init__(self, parent=None):
  2641. QtWidgets.QWidget.__init__(self, parent=parent)
  2642. self.layout = QtWidgets.QHBoxLayout()
  2643. self.setLayout(self.layout)
  2644. self.tools_ncc_group = ToolsNCCPrefGroupUI()
  2645. self.tools_ncc_group.setMinimumWidth(200)
  2646. self.tools_paint_group = ToolsPaintPrefGroupUI()
  2647. self.tools_paint_group.setMinimumWidth(200)
  2648. self.tools_cutout_group = ToolsCutoutPrefGroupUI()
  2649. self.tools_cutout_group.setMinimumWidth(220)
  2650. self.tools_2sided_group = Tools2sidedPrefGroupUI()
  2651. self.tools_2sided_group.setMinimumWidth(220)
  2652. self.tools_film_group = ToolsFilmPrefGroupUI()
  2653. self.tools_film_group.setMinimumWidth(220)
  2654. self.tools_panelize_group = ToolsPanelizePrefGroupUI()
  2655. self.tools_panelize_group.setMinimumWidth(220)
  2656. self.tools_calculators_group = ToolsCalculatorsPrefGroupUI()
  2657. self.tools_calculators_group.setMinimumWidth(220)
  2658. self.tools_transform_group = ToolsTransformPrefGroupUI()
  2659. self.tools_transform_group.setMinimumWidth(200)
  2660. self.tools_solderpaste_group = ToolsSolderpastePrefGroupUI()
  2661. self.tools_solderpaste_group.setMinimumWidth(200)
  2662. self.vlay = QtWidgets.QVBoxLayout()
  2663. self.vlay.addWidget(self.tools_ncc_group)
  2664. self.vlay.addWidget(self.tools_paint_group)
  2665. self.vlay.addWidget(self.tools_film_group)
  2666. self.vlay1 = QtWidgets.QVBoxLayout()
  2667. self.vlay1.addWidget(self.tools_cutout_group)
  2668. self.vlay1.addWidget(self.tools_transform_group)
  2669. self.vlay1.addWidget(self.tools_2sided_group)
  2670. self.vlay2 = QtWidgets.QVBoxLayout()
  2671. self.vlay2.addWidget(self.tools_panelize_group)
  2672. self.vlay2.addWidget(self.tools_calculators_group)
  2673. self.vlay3 = QtWidgets.QVBoxLayout()
  2674. self.vlay3.addWidget(self.tools_solderpaste_group)
  2675. self.layout.addLayout(self.vlay)
  2676. self.layout.addLayout(self.vlay1)
  2677. self.layout.addLayout(self.vlay2)
  2678. self.layout.addLayout(self.vlay3)
  2679. self.layout.addStretch()
  2680. class CNCJobPreferencesUI(QtWidgets.QWidget):
  2681. def __init__(self, parent=None):
  2682. QtWidgets.QWidget.__init__(self, parent=parent)
  2683. self.layout = QtWidgets.QHBoxLayout()
  2684. self.setLayout(self.layout)
  2685. self.cncjob_gen_group = CNCJobGenPrefGroupUI()
  2686. self.cncjob_gen_group.setFixedWidth(270)
  2687. self.cncjob_opt_group = CNCJobOptPrefGroupUI()
  2688. self.cncjob_opt_group.setFixedWidth(260)
  2689. self.cncjob_adv_opt_group = CNCJobAdvOptPrefGroupUI()
  2690. self.cncjob_adv_opt_group.setFixedWidth(260)
  2691. self.layout.addWidget(self.cncjob_gen_group)
  2692. self.layout.addWidget(self.cncjob_opt_group)
  2693. self.layout.addWidget(self.cncjob_adv_opt_group)
  2694. self.layout.addStretch()
  2695. class OptionsGroupUI(QtWidgets.QGroupBox):
  2696. def __init__(self, title, parent=None):
  2697. # QtGui.QGroupBox.__init__(self, title, parent=parent)
  2698. super(OptionsGroupUI, self).__init__()
  2699. self.setStyleSheet("""
  2700. QGroupBox
  2701. {
  2702. font-size: 16px;
  2703. font-weight: bold;
  2704. }
  2705. """)
  2706. self.layout = QtWidgets.QVBoxLayout()
  2707. self.setLayout(self.layout)
  2708. class GeneralGUIPrefGroupUI(OptionsGroupUI):
  2709. def __init__(self, parent=None):
  2710. super(GeneralGUIPrefGroupUI, self).__init__(self)
  2711. self.setTitle(str("GUI Preferences"))
  2712. # Create a form layout for the Application general settings
  2713. self.form_box = QtWidgets.QFormLayout()
  2714. # Grid X Entry
  2715. self.gridx_label = QtWidgets.QLabel(_('Grid X value:'))
  2716. self.gridx_label.setToolTip(
  2717. _( "This is the Grid snap value on X axis.")
  2718. )
  2719. self.gridx_entry = LengthEntry()
  2720. # Grid Y Entry
  2721. self.gridy_label = QtWidgets.QLabel(_('Grid Y value:'))
  2722. self.gridy_label.setToolTip(
  2723. _("This is the Grid snap value on Y axis.")
  2724. )
  2725. self.gridy_entry = LengthEntry()
  2726. # Snap Max Entry
  2727. self.snap_max_label = QtWidgets.QLabel(_('Snap Max:'))
  2728. self.snap_max_label.setToolTip(_("Max. magnet distance"))
  2729. self.snap_max_dist_entry = FCEntry()
  2730. # Workspace
  2731. self.workspace_lbl = QtWidgets.QLabel(_('Workspace:'))
  2732. self.workspace_lbl.setToolTip(
  2733. _( "Draw a delimiting rectangle on canvas.\n"
  2734. "The purpose is to illustrate the limits for our work.")
  2735. )
  2736. self.workspace_type_lbl = QtWidgets.QLabel(_('Wk. format:'))
  2737. self.workspace_type_lbl.setToolTip(
  2738. _( "Select the type of rectangle to be used on canvas,\n"
  2739. "as valid workspace.")
  2740. )
  2741. self.workspace_cb = FCCheckBox()
  2742. self.wk_cb = FCComboBox()
  2743. self.wk_cb.addItem('A4P')
  2744. self.wk_cb.addItem('A4L')
  2745. self.wk_cb.addItem('A3P')
  2746. self.wk_cb.addItem('A3L')
  2747. self.wks = OptionalInputSection(self.workspace_cb, [self.workspace_type_lbl, self.wk_cb])
  2748. # Plot Fill Color
  2749. self.pf_color_label = QtWidgets.QLabel(_('Plot Fill:'))
  2750. self.pf_color_label.setToolTip(
  2751. _( "Set the fill color for plotted objects.\n"
  2752. "First 6 digits are the color and the last 2\n"
  2753. "digits are for alpha (transparency) level.")
  2754. )
  2755. self.pf_color_entry = FCEntry()
  2756. self.pf_color_button = QtWidgets.QPushButton()
  2757. self.pf_color_button.setFixedSize(15, 15)
  2758. self.form_box_child_1 = QtWidgets.QHBoxLayout()
  2759. self.form_box_child_1.addWidget(self.pf_color_entry)
  2760. self.form_box_child_1.addWidget(self.pf_color_button)
  2761. self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2762. # Plot Fill Transparency Level
  2763. self.pf_alpha_label = QtWidgets.QLabel(_('Alpha Level:'))
  2764. self.pf_alpha_label.setToolTip(
  2765. _( "Set the fill transparency for plotted objects.")
  2766. )
  2767. self.pf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  2768. self.pf_color_alpha_slider.setMinimum(0)
  2769. self.pf_color_alpha_slider.setMaximum(255)
  2770. self.pf_color_alpha_slider.setSingleStep(1)
  2771. self.pf_color_alpha_spinner = FCSpinner()
  2772. self.pf_color_alpha_spinner.setFixedWidth(70)
  2773. self.pf_color_alpha_spinner.setMinimum(0)
  2774. self.pf_color_alpha_spinner.setMaximum(255)
  2775. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  2776. self.form_box_child_2.addWidget(self.pf_color_alpha_slider)
  2777. self.form_box_child_2.addWidget(self.pf_color_alpha_spinner)
  2778. # Plot Line Color
  2779. self.pl_color_label = QtWidgets.QLabel(_('Plot Line:'))
  2780. self.pl_color_label.setToolTip(
  2781. _( "Set the line color for plotted objects.")
  2782. )
  2783. self.pl_color_entry = FCEntry()
  2784. self.pl_color_button = QtWidgets.QPushButton()
  2785. self.pl_color_button.setFixedSize(15, 15)
  2786. self.form_box_child_3 = QtWidgets.QHBoxLayout()
  2787. self.form_box_child_3.addWidget(self.pl_color_entry)
  2788. self.form_box_child_3.addWidget(self.pl_color_button)
  2789. self.form_box_child_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2790. # Plot Selection (left - right) Fill Color
  2791. self.sf_color_label = QtWidgets.QLabel(_('Sel. Fill:'))
  2792. self.sf_color_label.setToolTip(
  2793. _("Set the fill color for the selection box\n"
  2794. "in case that the selection is done from left to right.\n"
  2795. "First 6 digits are the color and the last 2\n"
  2796. "digits are for alpha (transparency) level.")
  2797. )
  2798. self.sf_color_entry = FCEntry()
  2799. self.sf_color_button = QtWidgets.QPushButton()
  2800. self.sf_color_button.setFixedSize(15, 15)
  2801. self.form_box_child_4 = QtWidgets.QHBoxLayout()
  2802. self.form_box_child_4.addWidget(self.sf_color_entry)
  2803. self.form_box_child_4.addWidget(self.sf_color_button)
  2804. self.form_box_child_4.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2805. # Plot Selection (left - right) Fill Transparency Level
  2806. self.sf_alpha_label = QtWidgets.QLabel(_('Alpha Level:'))
  2807. self.sf_alpha_label.setToolTip(
  2808. _("Set the fill transparency for the 'left to right' selection box.")
  2809. )
  2810. self.sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  2811. self.sf_color_alpha_slider.setMinimum(0)
  2812. self.sf_color_alpha_slider.setMaximum(255)
  2813. self.sf_color_alpha_slider.setSingleStep(1)
  2814. self.sf_color_alpha_spinner = FCSpinner()
  2815. self.sf_color_alpha_spinner.setFixedWidth(70)
  2816. self.sf_color_alpha_spinner.setMinimum(0)
  2817. self.sf_color_alpha_spinner.setMaximum(255)
  2818. self.form_box_child_5 = QtWidgets.QHBoxLayout()
  2819. self.form_box_child_5.addWidget(self.sf_color_alpha_slider)
  2820. self.form_box_child_5.addWidget(self.sf_color_alpha_spinner)
  2821. # Plot Selection (left - right) Line Color
  2822. self.sl_color_label = QtWidgets.QLabel(_('Sel. Line:'))
  2823. self.sl_color_label.setToolTip(
  2824. _("Set the line color for the 'left to right' selection box.")
  2825. )
  2826. self.sl_color_entry = FCEntry()
  2827. self.sl_color_button = QtWidgets.QPushButton()
  2828. self.sl_color_button.setFixedSize(15, 15)
  2829. self.form_box_child_6 = QtWidgets.QHBoxLayout()
  2830. self.form_box_child_6.addWidget(self.sl_color_entry)
  2831. self.form_box_child_6.addWidget(self.sl_color_button)
  2832. self.form_box_child_6.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2833. # Plot Selection (right - left) Fill Color
  2834. self.alt_sf_color_label = QtWidgets.QLabel(_('Sel2. Fill:'))
  2835. self.alt_sf_color_label.setToolTip(
  2836. _("Set the fill color for the selection box\n"
  2837. "in case that the selection is done from right to left.\n"
  2838. "First 6 digits are the color and the last 2\n"
  2839. "digits are for alpha (transparency) level.")
  2840. )
  2841. self.alt_sf_color_entry = FCEntry()
  2842. self.alt_sf_color_button = QtWidgets.QPushButton()
  2843. self.alt_sf_color_button.setFixedSize(15, 15)
  2844. self.form_box_child_7 = QtWidgets.QHBoxLayout()
  2845. self.form_box_child_7.addWidget(self.alt_sf_color_entry)
  2846. self.form_box_child_7.addWidget(self.alt_sf_color_button)
  2847. self.form_box_child_7.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2848. # Plot Selection (right - left) Fill Transparency Level
  2849. self.alt_sf_alpha_label = QtWidgets.QLabel(_('Alpha Level:'))
  2850. self.alt_sf_alpha_label.setToolTip(
  2851. _("Set the fill transparency for selection 'right to left' box.")
  2852. )
  2853. self.alt_sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  2854. self.alt_sf_color_alpha_slider.setMinimum(0)
  2855. self.alt_sf_color_alpha_slider.setMaximum(255)
  2856. self.alt_sf_color_alpha_slider.setSingleStep(1)
  2857. self.alt_sf_color_alpha_spinner = FCSpinner()
  2858. self.alt_sf_color_alpha_spinner.setFixedWidth(70)
  2859. self.alt_sf_color_alpha_spinner.setMinimum(0)
  2860. self.alt_sf_color_alpha_spinner.setMaximum(255)
  2861. self.form_box_child_8 = QtWidgets.QHBoxLayout()
  2862. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_slider)
  2863. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_spinner)
  2864. # Plot Selection (right - left) Line Color
  2865. self.alt_sl_color_label = QtWidgets.QLabel(_('Sel2. Line:'))
  2866. self.alt_sl_color_label.setToolTip(
  2867. _("Set the line color for the 'right to left' selection box.")
  2868. )
  2869. self.alt_sl_color_entry = FCEntry()
  2870. self.alt_sl_color_button = QtWidgets.QPushButton()
  2871. self.alt_sl_color_button.setFixedSize(15, 15)
  2872. self.form_box_child_9 = QtWidgets.QHBoxLayout()
  2873. self.form_box_child_9.addWidget(self.alt_sl_color_entry)
  2874. self.form_box_child_9.addWidget(self.alt_sl_color_button)
  2875. self.form_box_child_9.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2876. # Editor Draw Color
  2877. self.draw_color_label = QtWidgets.QLabel(_('Editor Draw:'))
  2878. self.alt_sf_color_label.setToolTip(
  2879. _("Set the color for the shape.")
  2880. )
  2881. self.draw_color_entry = FCEntry()
  2882. self.draw_color_button = QtWidgets.QPushButton()
  2883. self.draw_color_button.setFixedSize(15, 15)
  2884. self.form_box_child_10 = QtWidgets.QHBoxLayout()
  2885. self.form_box_child_10.addWidget(self.draw_color_entry)
  2886. self.form_box_child_10.addWidget(self.draw_color_button)
  2887. self.form_box_child_10.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2888. # Editor Draw Selection Color
  2889. self.sel_draw_color_label = QtWidgets.QLabel(_('Editor Draw Sel.:'))
  2890. self.sel_draw_color_label.setToolTip(
  2891. _("Set the color of the shape when selected.")
  2892. )
  2893. self.sel_draw_color_entry = FCEntry()
  2894. self.sel_draw_color_button = QtWidgets.QPushButton()
  2895. self.sel_draw_color_button.setFixedSize(15, 15)
  2896. self.form_box_child_11 = QtWidgets.QHBoxLayout()
  2897. self.form_box_child_11.addWidget(self.sel_draw_color_entry)
  2898. self.form_box_child_11.addWidget(self.sel_draw_color_button)
  2899. self.form_box_child_11.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2900. # Just to add empty rows
  2901. self.spacelabel = QtWidgets.QLabel('')
  2902. # Add (label - input field) pair to the QFormLayout
  2903. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2904. self.form_box.addRow(self.gridx_label, self.gridx_entry)
  2905. self.form_box.addRow(self.gridy_label, self.gridy_entry)
  2906. self.form_box.addRow(self.snap_max_label, self.snap_max_dist_entry)
  2907. self.form_box.addRow(self.workspace_lbl, self.workspace_cb)
  2908. self.form_box.addRow(self.workspace_type_lbl, self.wk_cb)
  2909. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2910. self.form_box.addRow(self.pf_color_label, self.form_box_child_1)
  2911. self.form_box.addRow(self.pf_alpha_label, self.form_box_child_2)
  2912. self.form_box.addRow(self.pl_color_label, self.form_box_child_3)
  2913. self.form_box.addRow(self.sf_color_label, self.form_box_child_4)
  2914. self.form_box.addRow(self.sf_alpha_label, self.form_box_child_5)
  2915. self.form_box.addRow(self.sl_color_label, self.form_box_child_6)
  2916. self.form_box.addRow(self.alt_sf_color_label, self.form_box_child_7)
  2917. self.form_box.addRow(self.alt_sf_alpha_label, self.form_box_child_8)
  2918. self.form_box.addRow(self.alt_sl_color_label, self.form_box_child_9)
  2919. self.form_box.addRow(self.draw_color_label, self.form_box_child_10)
  2920. self.form_box.addRow(self.sel_draw_color_label, self.form_box_child_11)
  2921. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2922. # Add the QFormLayout that holds the Application general defaults
  2923. # to the main layout of this TAB
  2924. self.layout.addLayout(self.form_box)
  2925. class GeneralGUISetGroupUI(OptionsGroupUI):
  2926. def __init__(self, parent=None):
  2927. super(GeneralGUISetGroupUI, self).__init__(self)
  2928. self.setTitle(str(_("GUI Settings")))
  2929. # Create a form layout for the Application general settings
  2930. self.form_box = QtWidgets.QFormLayout()
  2931. # Layout selection
  2932. self.layout_label = QtWidgets.QLabel(_('Layout:'))
  2933. self.layout_label.setToolTip(
  2934. _("Select an layout for FlatCAM.\n"
  2935. "It is applied immediately.")
  2936. )
  2937. self.layout_combo = FCComboBox()
  2938. # don't translate the QCombo items as they are used in QSettings and identified by name
  2939. self.layout_combo.addItem("standard")
  2940. self.layout_combo.addItem("compact")
  2941. # Set the current index for layout_combo
  2942. settings = QSettings("Open Source", "FlatCAM")
  2943. if settings.contains("layout"):
  2944. layout = settings.value('layout', type=str)
  2945. idx = self.layout_combo.findText(layout.capitalize())
  2946. self.layout_combo.setCurrentIndex(idx)
  2947. # Style selection
  2948. self.style_label = QtWidgets.QLabel(_('Style:'))
  2949. self.style_label.setToolTip(
  2950. _("Select an style for FlatCAM.\n"
  2951. "It will be applied at the next app start.")
  2952. )
  2953. self.style_combo = FCComboBox()
  2954. self.style_combo.addItems(QtWidgets.QStyleFactory.keys())
  2955. # find current style
  2956. index = self.style_combo.findText(QtWidgets.qApp.style().objectName(), QtCore.Qt.MatchFixedString)
  2957. self.style_combo.setCurrentIndex(index)
  2958. self.style_combo.activated[str].connect(self.handle_style)
  2959. # Enable High DPI Support
  2960. self.hdpi_label = QtWidgets.QLabel(_('HDPI Support:'))
  2961. self.hdpi_label.setToolTip(
  2962. _("Enable High DPI support for FlatCAM.\n"
  2963. "It will be applied at the next app start.")
  2964. )
  2965. self.hdpi_cb = FCCheckBox()
  2966. settings = QSettings("Open Source", "FlatCAM")
  2967. if settings.contains("hdpi"):
  2968. self.hdpi_cb.set_value(settings.value('hdpi', type=int))
  2969. else:
  2970. self.hdpi_cb.set_value(False)
  2971. self.hdpi_cb.stateChanged.connect(self.handle_hdpi)
  2972. # Clear Settings
  2973. self.clear_label = QtWidgets.QLabel(_('Clear GUI Settings:'))
  2974. self.clear_label.setToolTip(
  2975. _("Clear the GUI settings for FlatCAM,\n"
  2976. "such as: layout, gui state, style, hdpi support etc.")
  2977. )
  2978. self.clear_btn = FCButton(_("Clear"))
  2979. self.clear_btn.clicked.connect(self.handle_clear)
  2980. # Enable Hover box
  2981. self.hover_label = QtWidgets.QLabel(_('Hover Shape:'))
  2982. self.hover_label.setToolTip(
  2983. _("Enable display of a hover shape for FlatCAM objects.\n"
  2984. "It is displayed whenever the mouse cursor is hovering\n"
  2985. "over any kind of not-selected object.")
  2986. )
  2987. self.hover_cb = FCCheckBox()
  2988. # Just to add empty rows
  2989. self.spacelabel = QtWidgets.QLabel('')
  2990. # Add (label - input field) pair to the QFormLayout
  2991. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2992. self.form_box.addRow(self.layout_label, self.layout_combo)
  2993. self.form_box.addRow(self.style_label, self.style_combo)
  2994. self.form_box.addRow(self.hdpi_label, self.hdpi_cb)
  2995. self.form_box.addRow(self.clear_label, self.clear_btn)
  2996. self.form_box.addRow(self.hover_label, self.hover_cb)
  2997. # Add the QFormLayout that holds the Application general defaults
  2998. # to the main layout of this TAB
  2999. self.layout.addLayout(self.form_box)
  3000. def handle_style(self, style):
  3001. # set current style
  3002. settings = QSettings("Open Source", "FlatCAM")
  3003. settings.setValue('style', style)
  3004. # This will write the setting to the platform specific storage.
  3005. del settings
  3006. def handle_hdpi(self, state):
  3007. # set current HDPI
  3008. settings = QSettings("Open Source", "FlatCAM")
  3009. settings.setValue('hdpi', state)
  3010. # This will write the setting to the platform specific storage.
  3011. del settings
  3012. def handle_clear(self):
  3013. msgbox = QtWidgets.QMessageBox()
  3014. msgbox.setText(_("Are you sure you want to delete the GUI Settings? "
  3015. "\n")
  3016. )
  3017. msgbox.setWindowTitle(_("Clear GUI Settings"))
  3018. msgbox.setWindowIcon(QtGui.QIcon('share/trash32.png'))
  3019. bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
  3020. bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
  3021. msgbox.setDefaultButton(bt_no)
  3022. msgbox.exec_()
  3023. response = msgbox.clickedButton()
  3024. if response == bt_yes:
  3025. settings = QSettings("Open Source", "FlatCAM")
  3026. for key in settings.allKeys():
  3027. settings.remove(key)
  3028. # This will write the setting to the platform specific storage.
  3029. del settings
  3030. class GeneralAppPrefGroupUI(OptionsGroupUI):
  3031. def __init__(self, parent=None):
  3032. super(GeneralAppPrefGroupUI, self).__init__(self)
  3033. self.setTitle(str(_("App Preferences")))
  3034. # Create a form layout for the Application general settings
  3035. self.form_box = QtWidgets.QFormLayout()
  3036. # Units for FlatCAM
  3037. self.unitslabel = QtWidgets.QLabel(_('<b>Units:</b>'))
  3038. self.unitslabel.setToolTip(_("The default value for FlatCAM units.\n"
  3039. "Whatever is selected here is set every time\n"
  3040. "FLatCAM is started."))
  3041. self.units_radio = RadioSet([{'label': 'IN', 'value': 'IN'},
  3042. {'label': 'MM', 'value': 'MM'}])
  3043. # Application Level for FlatCAM
  3044. self.app_level_label = QtWidgets.QLabel(_('<b>APP. LEVEL:</b>'))
  3045. self.app_level_label.setToolTip(_("Choose the default level of usage for FlatCAM.\n"
  3046. "BASIC level -> reduced functionality, best for beginner's.\n"
  3047. "ADVANCED level -> full functionality.\n\n"
  3048. "The choice here will influence the parameters in\n"
  3049. "the Selected Tab for all kinds of FlatCAM objects."))
  3050. self.app_level_radio = RadioSet([{'label': _('Basic'), 'value': 'b'},
  3051. {'label': _('Advanced'), 'value': 'a'}])
  3052. # Languages for FlatCAM
  3053. self.languagelabel = QtWidgets.QLabel(_('<b>Languages:</b>'))
  3054. self.languagelabel.setToolTip(_("Set the language used throughout FlatCAM."))
  3055. self.language_cb = FCComboBox()
  3056. self.languagespace = QtWidgets.QLabel('')
  3057. self.language_apply_btn = FCButton(_("Apply Language"))
  3058. # Shell StartUp CB
  3059. self.shell_startup_label = QtWidgets.QLabel(_('Shell at StartUp:'))
  3060. self.shell_startup_label.setToolTip(
  3061. _("Check this box if you want the shell to\n"
  3062. "start automatically at startup.")
  3063. )
  3064. self.shell_startup_cb = FCCheckBox(label='')
  3065. self.shell_startup_cb.setToolTip(
  3066. _("Check this box if you want the shell to\n"
  3067. "start automatically at startup.")
  3068. )
  3069. # Version Check CB
  3070. self.version_check_label = QtWidgets.QLabel(_('Version Check:'))
  3071. self.version_check_label.setToolTip(
  3072. _("Check this box if you want to check\n"
  3073. "for a new version automatically at startup.")
  3074. )
  3075. self.version_check_cb = FCCheckBox(label='')
  3076. self.version_check_cb.setToolTip(
  3077. _("Check this box if you want to check\n"
  3078. "for a new version automatically at startup.")
  3079. )
  3080. # Send Stats CB
  3081. self.send_stats_label = QtWidgets.QLabel(_('Send Stats:'))
  3082. self.send_stats_label.setToolTip(
  3083. _("Check this box if you agree to send anonymous\n"
  3084. "stats automatically at startup, to help improve FlatCAM.")
  3085. )
  3086. self.send_stats_cb= FCCheckBox(label='')
  3087. self.send_stats_cb.setToolTip(
  3088. _("Check this box if you agree to send anonymous\n"
  3089. "stats automatically at startup, to help improve FlatCAM.")
  3090. )
  3091. self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
  3092. # Select mouse pan button
  3093. self.panbuttonlabel = QtWidgets.QLabel(_('<b>Pan Button:</b>'))
  3094. self.panbuttonlabel.setToolTip(_("Select the mouse button to use for panning:\n"
  3095. "- MMB --> Middle Mouse Button\n"
  3096. "- RMB --> Right Mouse Button"))
  3097. self.pan_button_radio = RadioSet([{'label': _('MMB'), 'value': '3'},
  3098. {'label': _('RMB'), 'value': '2'}])
  3099. # Multiple Selection Modifier Key
  3100. self.mselectlabel = QtWidgets.QLabel(_('<b>Multiple Sel:</b>'))
  3101. self.mselectlabel.setToolTip(_("Select the key used for multiple selection."))
  3102. self.mselect_radio = RadioSet([{'label': _('CTRL'), 'value': 'Control'},
  3103. {'label': _('SHIFT'), 'value': 'Shift'}])
  3104. # Project at StartUp CB
  3105. self.project_startup_label = QtWidgets.QLabel(_('Project at StartUp:'))
  3106. self.project_startup_label.setToolTip(
  3107. _("Check this box if you want the project/selected/tool tab area to\n"
  3108. "to be shown automatically at startup.")
  3109. )
  3110. self.project_startup_cb = FCCheckBox(label='')
  3111. self.project_startup_cb.setToolTip(
  3112. _("Check this box if you want the project/selected/tool tab area to\n"
  3113. "to be shown automatically at startup.")
  3114. )
  3115. # Project autohide CB
  3116. self.project_autohide_label = QtWidgets.QLabel(_('Project AutoHide:'))
  3117. self.project_autohide_label.setToolTip(
  3118. _( "Check this box if you want the project/selected/tool tab area to\n"
  3119. "hide automatically when there are no objects loaded and\n"
  3120. "to show whenever a new object is created.")
  3121. )
  3122. self.project_autohide_cb = FCCheckBox(label='')
  3123. self.project_autohide_cb.setToolTip(
  3124. _("Check this box if you want the project/selected/tool tab area to\n"
  3125. "hide automatically when there are no objects loaded and\n"
  3126. "to show whenever a new object is created.")
  3127. )
  3128. # Enable/Disable ToolTips globally
  3129. self.toggle_tooltips_label = QtWidgets.QLabel(_('<b>Enable ToolTips:</b>'))
  3130. self.toggle_tooltips_label.setToolTip(
  3131. _( "Check this box if you want to have toolTips displayed\n"
  3132. "when hovering with mouse over items throughout the App.")
  3133. )
  3134. self.toggle_tooltips_cb = FCCheckBox(label='')
  3135. self.toggle_tooltips_cb.setToolTip(
  3136. _( "Check this box if you want to have toolTips displayed\n"
  3137. "when hovering with mouse over items throughout the App.")
  3138. )
  3139. self.worker_number_label = QtWidgets.QLabel(_('Workers number:'))
  3140. self.worker_number_label.setToolTip(
  3141. _("The number of Qthreads made available to the App.\n"
  3142. "A bigger number may finish the jobs more quickly but\n"
  3143. "depending on your computer speed, may make the App\n"
  3144. "unresponsive. Can have a value between 2 and 16.\n"
  3145. "Default value is 2.\n"
  3146. "After change, it will be applied at next App start.")
  3147. )
  3148. self.worker_number_sb = FCSpinner()
  3149. self.worker_number_sb.setToolTip(
  3150. _("The number of Qthreads made available to the App.\n"
  3151. "A bigger number may finish the jobs more quickly but\n"
  3152. "depending on your computer speed, may make the App\n"
  3153. "unresponsive. Can have a value between 2 and 16.\n"
  3154. "Default value is 2.\n"
  3155. "After change, it will be applied at next App start.")
  3156. )
  3157. self.worker_number_sb.set_range(2, 16)
  3158. # Just to add empty rows
  3159. self.spacelabel = QtWidgets.QLabel('')
  3160. # Add (label - input field) pair to the QFormLayout
  3161. self.form_box.addRow(self.unitslabel, self.units_radio)
  3162. self.form_box.addRow(self.app_level_label, self.app_level_radio)
  3163. self.form_box.addRow(self.languagelabel, self.language_cb)
  3164. self.form_box.addRow(self.languagespace, self.language_apply_btn)
  3165. self.form_box.addRow(self.spacelabel, self.spacelabel)
  3166. self.form_box.addRow(self.shell_startup_label, self.shell_startup_cb)
  3167. self.form_box.addRow(self.version_check_label, self.version_check_cb)
  3168. self.form_box.addRow(self.send_stats_label, self.send_stats_cb)
  3169. self.form_box.addRow(self.panbuttonlabel, self.pan_button_radio)
  3170. self.form_box.addRow(self.mselectlabel, self.mselect_radio)
  3171. self.form_box.addRow(self.project_startup_label, self.project_startup_cb)
  3172. self.form_box.addRow(self.project_autohide_label, self.project_autohide_cb)
  3173. self.form_box.addRow(self.toggle_tooltips_label, self.toggle_tooltips_cb)
  3174. self.form_box.addRow(self.worker_number_label, self.worker_number_sb)
  3175. self.form_box.addRow(self.spacelabel, self.spacelabel)
  3176. # Add the QFormLayout that holds the Application general defaults
  3177. # to the main layout of this TAB
  3178. self.layout.addLayout(self.form_box)
  3179. # hlay = QtWidgets.QHBoxLayout()
  3180. # self.layout.addLayout(hlay)
  3181. # hlay.addStretch()
  3182. # Save compressed project CB
  3183. self.save_type_cb = FCCheckBox(_('Save Compressed Project'))
  3184. self.save_type_cb.setToolTip(
  3185. _("Whether to save a compressed or uncompressed project.\n"
  3186. "When checked it will save a compressed FlatCAM project.")
  3187. )
  3188. # self.advanced_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  3189. self.layout.addWidget(self.save_type_cb)
  3190. hlay1 = QtWidgets.QHBoxLayout()
  3191. self.layout.addLayout(hlay1)
  3192. # Project LZMA Comppression Level
  3193. self.compress_combo = FCComboBox()
  3194. self.compress_label = QtWidgets.QLabel(_('Compression Level:'))
  3195. self.compress_label.setToolTip(
  3196. _("The level of compression used when saving\n"
  3197. "a FlatCAM project. Higher value means better compression\n"
  3198. "but require more RAM usage and more processing time.")
  3199. )
  3200. # self.advanced_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  3201. self.compress_combo.addItems([str(i) for i in range(10)])
  3202. hlay1.addWidget(self.compress_label)
  3203. hlay1.addWidget(self.compress_combo)
  3204. self.proj_ois = OptionalInputSection(self.save_type_cb, [self.compress_label, self.compress_combo], True)
  3205. self.form_box_2 = QtWidgets.QFormLayout()
  3206. self.layout.addLayout(self.form_box_2)
  3207. self.layout.addStretch()
  3208. class GerberGenPrefGroupUI(OptionsGroupUI):
  3209. def __init__(self, parent=None):
  3210. # OptionsGroupUI.__init__(self, "Gerber General Preferences", parent=parent)
  3211. super(GerberGenPrefGroupUI, self).__init__(self)
  3212. self.setTitle(str("Gerber General"))
  3213. ## Plot options
  3214. self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
  3215. self.layout.addWidget(self.plot_options_label)
  3216. grid0 = QtWidgets.QGridLayout()
  3217. self.layout.addLayout(grid0)
  3218. # Solid CB
  3219. self.solid_cb = FCCheckBox(label=_('Solid'))
  3220. self.solid_cb.setToolTip(
  3221. _("Solid color polygons.")
  3222. )
  3223. grid0.addWidget(self.solid_cb, 0, 0)
  3224. # Multicolored CB
  3225. self.multicolored_cb = FCCheckBox(label=_('M-Color'))
  3226. self.multicolored_cb.setToolTip(
  3227. _("Draw polygons in different colors.")
  3228. )
  3229. grid0.addWidget(self.multicolored_cb, 0, 1)
  3230. # Plot CB
  3231. self.plot_cb = FCCheckBox(label=_('Plot'))
  3232. self.plot_options_label.setToolTip(
  3233. _("Plot (show) this object.")
  3234. )
  3235. grid0.addWidget(self.plot_cb, 0, 2)
  3236. # Number of circle steps for circular aperture linear approximation
  3237. self.circle_steps_label = QtWidgets.QLabel(_("Circle Steps:"))
  3238. self.circle_steps_label.setToolTip(
  3239. _("The number of circle steps for Gerber \n"
  3240. "circular aperture linear approximation.")
  3241. )
  3242. grid0.addWidget(self.circle_steps_label, 1, 0)
  3243. self.circle_steps_entry = IntEntry()
  3244. grid0.addWidget(self.circle_steps_entry, 1, 1)
  3245. self.layout.addStretch()
  3246. class GerberOptPrefGroupUI(OptionsGroupUI):
  3247. def __init__(self, parent=None):
  3248. # OptionsGroupUI.__init__(self, "Gerber Options Preferences", parent=parent)
  3249. super(GerberOptPrefGroupUI, self).__init__(self)
  3250. self.setTitle(str(_("Gerber Options")))
  3251. ## Isolation Routing
  3252. self.isolation_routing_label = QtWidgets.QLabel(_("<b>Isolation Routing:</b>"))
  3253. self.isolation_routing_label.setToolTip(
  3254. _("Create a Geometry object with\n"
  3255. "toolpaths to cut outside polygons.")
  3256. )
  3257. self.layout.addWidget(self.isolation_routing_label)
  3258. # Cutting Tool Diameter
  3259. grid0 = QtWidgets.QGridLayout()
  3260. self.layout.addLayout(grid0)
  3261. tdlabel = QtWidgets.QLabel(_('Tool dia:'))
  3262. tdlabel.setToolTip(
  3263. _("Diameter of the cutting tool.")
  3264. )
  3265. grid0.addWidget(tdlabel, 0, 0)
  3266. self.iso_tool_dia_entry = LengthEntry()
  3267. grid0.addWidget(self.iso_tool_dia_entry, 0, 1)
  3268. # Nr of passes
  3269. passlabel = QtWidgets.QLabel(_('Width (# passes):'))
  3270. passlabel.setToolTip(
  3271. _("Width of the isolation gap in\n"
  3272. "number (integer) of tool widths.")
  3273. )
  3274. grid0.addWidget(passlabel, 1, 0)
  3275. self.iso_width_entry = IntEntry()
  3276. grid0.addWidget(self.iso_width_entry, 1, 1)
  3277. # Pass overlap
  3278. overlabel = QtWidgets.QLabel(_('Pass overlap:'))
  3279. overlabel.setToolTip(
  3280. _("How much (fraction) of the tool width to overlap each tool pass.\n"
  3281. "Example:\n"
  3282. "A value here of 0.25 means an overlap of 25%% from the tool diameter found above.")
  3283. )
  3284. grid0.addWidget(overlabel, 2, 0)
  3285. self.iso_overlap_entry = FloatEntry()
  3286. grid0.addWidget(self.iso_overlap_entry, 2, 1)
  3287. milling_type_label = QtWidgets.QLabel(_('Milling Type:'))
  3288. milling_type_label.setToolTip(
  3289. _("Milling type:\n"
  3290. "- climb / best for precision milling and to reduce tool usage\n"
  3291. "- conventional / useful when there is no backlash compensation")
  3292. )
  3293. grid0.addWidget(milling_type_label, 3, 0)
  3294. self.milling_type_radio = RadioSet([{'label': _('Climb'), 'value': 'cl'},
  3295. {'label': _('Conv.'), 'value': 'cv'}])
  3296. grid0.addWidget(self.milling_type_radio, 3, 1)
  3297. # Combine passes
  3298. self.combine_passes_cb = FCCheckBox(label=_('Combine Passes'))
  3299. self.combine_passes_cb.setToolTip(
  3300. _("Combine all passes into one object")
  3301. )
  3302. grid0.addWidget(self.combine_passes_cb, 4, 0)
  3303. ## Clear non-copper regions
  3304. self.clearcopper_label = QtWidgets.QLabel(_("<b>Clear non-copper:</b>"))
  3305. self.clearcopper_label.setToolTip(
  3306. _("Create a Geometry object with\n"
  3307. "toolpaths to cut all non-copper regions.")
  3308. )
  3309. self.layout.addWidget(self.clearcopper_label)
  3310. grid1 = QtWidgets.QGridLayout()
  3311. self.layout.addLayout(grid1)
  3312. # Margin
  3313. bmlabel = QtWidgets.QLabel(_('Boundary Margin:'))
  3314. bmlabel.setToolTip(
  3315. _("Specify the edge of the PCB\n"
  3316. "by drawing a box around all\n"
  3317. "objects with this minimum\n"
  3318. "distance.")
  3319. )
  3320. grid1.addWidget(bmlabel, 0, 0)
  3321. self.noncopper_margin_entry = LengthEntry()
  3322. grid1.addWidget(self.noncopper_margin_entry, 0, 1)
  3323. # Rounded corners
  3324. self.noncopper_rounded_cb = FCCheckBox(label=_("Rounded corners"))
  3325. self.noncopper_rounded_cb.setToolTip(
  3326. _("Creates a Geometry objects with polygons\n"
  3327. "covering the copper-free areas of the PCB.")
  3328. )
  3329. grid1.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  3330. ## Bounding box
  3331. self.boundingbox_label = QtWidgets.QLabel(_('<b>Bounding Box:</b>'))
  3332. self.layout.addWidget(self.boundingbox_label)
  3333. grid2 = QtWidgets.QGridLayout()
  3334. self.layout.addLayout(grid2)
  3335. bbmargin = QtWidgets.QLabel(_('Boundary Margin:'))
  3336. bbmargin.setToolTip(
  3337. _("Distance of the edges of the box\n"
  3338. "to the nearest polygon.")
  3339. )
  3340. grid2.addWidget(bbmargin, 0, 0)
  3341. self.bbmargin_entry = LengthEntry()
  3342. grid2.addWidget(self.bbmargin_entry, 0, 1)
  3343. self.bbrounded_cb = FCCheckBox(label=_("Rounded corners"))
  3344. self.bbrounded_cb.setToolTip(
  3345. _("If the bounding box is \n"
  3346. "to have rounded corners\n"
  3347. "their radius is equal to\n"
  3348. "the margin.")
  3349. )
  3350. grid2.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  3351. self.layout.addStretch()
  3352. class GerberAdvOptPrefGroupUI(OptionsGroupUI):
  3353. def __init__(self, parent=None):
  3354. # OptionsGroupUI.__init__(self, "Gerber Adv. Options Preferences", parent=parent)
  3355. super(GerberAdvOptPrefGroupUI, self).__init__(self)
  3356. self.setTitle(str(_("Gerber Adv. Options")))
  3357. ## Advanced Gerber Parameters
  3358. self.adv_param_label = QtWidgets.QLabel(_("<b>Advanced Param.:</b>"))
  3359. self.adv_param_label.setToolTip(
  3360. _("A list of Gerber advanced parameters.\n"
  3361. "Those parameters are available only for\n"
  3362. "Advanced App. Level.")
  3363. )
  3364. self.layout.addWidget(self.adv_param_label)
  3365. grid0 = QtWidgets.QGridLayout()
  3366. self.layout.addLayout(grid0)
  3367. # Follow Attribute
  3368. self.follow_cb = FCCheckBox(label=_('"Follow"'))
  3369. self.follow_cb.setToolTip(
  3370. _("Generate a 'Follow' geometry.\n"
  3371. "This means that it will cut through\n"
  3372. "the middle of the trace.")
  3373. )
  3374. grid0.addWidget(self.follow_cb, 0, 0)
  3375. # Aperture Table Visibility CB
  3376. self.aperture_table_visibility_cb = FCCheckBox(label=_('Table Show/Hide'))
  3377. self.aperture_table_visibility_cb.setToolTip(
  3378. _("Toggle the display of the Gerber Apertures Table.\n"
  3379. "Also, on hide, it will delete all mark shapes\n"
  3380. "that are drawn on canvas.")
  3381. )
  3382. grid0.addWidget(self.aperture_table_visibility_cb, 1, 0)
  3383. # Scale Aperture Factor
  3384. self.scale_aperture_label = QtWidgets.QLabel(_('Ap. Scale Factor:'))
  3385. self.scale_aperture_label.setToolTip(
  3386. _("Change the size of the selected apertures.\n"
  3387. "Factor by which to multiply\n"
  3388. "geometric features of this object.")
  3389. )
  3390. grid0.addWidget(self.scale_aperture_label, 2, 0)
  3391. self.scale_aperture_entry = FloatEntry2()
  3392. grid0.addWidget(self.scale_aperture_entry, 2, 1)
  3393. # Buffer Aperture Factor
  3394. self.buffer_aperture_label = QtWidgets.QLabel(_('Ap. Buffer Factor:'))
  3395. self.buffer_aperture_label.setToolTip(
  3396. _("Change the size of the selected apertures.\n"
  3397. "Factor by which to expand/shrink\n"
  3398. "geometric features of this object.")
  3399. )
  3400. grid0.addWidget(self.buffer_aperture_label, 3, 0)
  3401. self.buffer_aperture_entry = FloatEntry2()
  3402. grid0.addWidget(self.buffer_aperture_entry, 3, 1)
  3403. self.layout.addStretch()
  3404. class ExcellonGenPrefGroupUI(OptionsGroupUI):
  3405. def __init__(self, parent=None):
  3406. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  3407. super(ExcellonGenPrefGroupUI, self).__init__(self)
  3408. self.setTitle(str(_("Excellon General")))
  3409. # Plot options
  3410. self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
  3411. self.layout.addWidget(self.plot_options_label)
  3412. grid1 = QtWidgets.QGridLayout()
  3413. self.layout.addLayout(grid1)
  3414. self.plot_cb = FCCheckBox(label=_('Plot'))
  3415. self.plot_cb.setToolTip(
  3416. "Plot (show) this object."
  3417. )
  3418. grid1.addWidget(self.plot_cb, 0, 0)
  3419. self.solid_cb = FCCheckBox(label=_('Solid'))
  3420. self.solid_cb.setToolTip(
  3421. "Plot as solid circles."
  3422. )
  3423. grid1.addWidget(self.solid_cb, 0, 1)
  3424. # Excellon format
  3425. self.excellon_format_label = QtWidgets.QLabel(_("<b>Excellon Format:</b>"))
  3426. self.excellon_format_label.setToolTip(
  3427. _("The NC drill files, usually named Excellon files\n"
  3428. "are files that can be found in different formats.\n"
  3429. "Here we set the format used when the provided\n"
  3430. "coordinates are not using period.\n"
  3431. "\n"
  3432. "Possible presets:\n"
  3433. "\n"
  3434. "PROTEUS 3:3 MM LZ\n"
  3435. "DipTrace 5:2 MM TZ\n"
  3436. "DipTrace 4:3 MM LZ\n"
  3437. "\n"
  3438. "EAGLE 3:3 MM TZ\n"
  3439. "EAGLE 4:3 MM TZ\n"
  3440. "EAGLE 2:5 INCH TZ\n"
  3441. "EAGLE 3:5 INCH TZ\n"
  3442. "\n"
  3443. "ALTIUM 2:4 INCH LZ\n"
  3444. "Sprint Layout 2:4 INCH LZ"
  3445. "\n"
  3446. "KiCAD 3:5 INCH TZ")
  3447. )
  3448. self.layout.addWidget(self.excellon_format_label)
  3449. hlay1 = QtWidgets.QHBoxLayout()
  3450. self.layout.addLayout(hlay1)
  3451. self.excellon_format_in_label = QtWidgets.QLabel(_("INCH:"))
  3452. self.excellon_format_in_label.setAlignment(QtCore.Qt.AlignLeft)
  3453. self.excellon_format_in_label.setToolTip(
  3454. _("Default values for INCH are 2:4"))
  3455. hlay1.addWidget(self.excellon_format_in_label, QtCore.Qt.AlignLeft)
  3456. self.excellon_format_upper_in_entry = IntEntry()
  3457. self.excellon_format_upper_in_entry.setMaxLength(1)
  3458. self.excellon_format_upper_in_entry.setAlignment(QtCore.Qt.AlignRight)
  3459. self.excellon_format_upper_in_entry.setFixedWidth(30)
  3460. self.excellon_format_upper_in_entry.setToolTip(
  3461. _( "This numbers signify the number of digits in\n"
  3462. "the whole part of Excellon coordinates.")
  3463. )
  3464. hlay1.addWidget(self.excellon_format_upper_in_entry, QtCore.Qt.AlignLeft)
  3465. excellon_separator_in_label= QtWidgets.QLabel(':')
  3466. excellon_separator_in_label.setFixedWidth(5)
  3467. hlay1.addWidget(excellon_separator_in_label, QtCore.Qt.AlignLeft)
  3468. self.excellon_format_lower_in_entry = IntEntry()
  3469. self.excellon_format_lower_in_entry.setMaxLength(1)
  3470. self.excellon_format_lower_in_entry.setAlignment(QtCore.Qt.AlignRight)
  3471. self.excellon_format_lower_in_entry.setFixedWidth(30)
  3472. self.excellon_format_lower_in_entry.setToolTip(
  3473. _("This numbers signify the number of digits in\n"
  3474. "the decimal part of Excellon coordinates.")
  3475. )
  3476. hlay1.addWidget(self.excellon_format_lower_in_entry, QtCore.Qt.AlignLeft)
  3477. hlay1.addStretch()
  3478. hlay2 = QtWidgets.QHBoxLayout()
  3479. self.layout.addLayout(hlay2)
  3480. self.excellon_format_mm_label = QtWidgets.QLabel(_("METRIC:"))
  3481. self.excellon_format_mm_label.setAlignment(QtCore.Qt.AlignLeft)
  3482. self.excellon_format_mm_label.setToolTip(
  3483. _("Default values for METRIC are 3:3"))
  3484. hlay2.addWidget(self.excellon_format_mm_label, QtCore.Qt.AlignLeft)
  3485. self.excellon_format_upper_mm_entry = IntEntry()
  3486. self.excellon_format_upper_mm_entry.setMaxLength(1)
  3487. self.excellon_format_upper_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  3488. self.excellon_format_upper_mm_entry.setFixedWidth(30)
  3489. self.excellon_format_upper_mm_entry.setToolTip(
  3490. _("This numbers signify the number of digits in\n"
  3491. "the whole part of Excellon coordinates.")
  3492. )
  3493. hlay2.addWidget(self.excellon_format_upper_mm_entry, QtCore.Qt.AlignLeft)
  3494. excellon_separator_mm_label= QtWidgets.QLabel(':')
  3495. excellon_separator_mm_label.setFixedWidth(5)
  3496. hlay2.addWidget(excellon_separator_mm_label, QtCore.Qt.AlignLeft)
  3497. self.excellon_format_lower_mm_entry = IntEntry()
  3498. self.excellon_format_lower_mm_entry.setMaxLength(1)
  3499. self.excellon_format_lower_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  3500. self.excellon_format_lower_mm_entry.setFixedWidth(30)
  3501. self.excellon_format_lower_mm_entry.setToolTip(
  3502. _("This numbers signify the number of digits in\n"
  3503. "the decimal part of Excellon coordinates.")
  3504. )
  3505. hlay2.addWidget(self.excellon_format_lower_mm_entry, QtCore.Qt.AlignLeft)
  3506. hlay2.addStretch()
  3507. hlay3 = QtWidgets.QHBoxLayout()
  3508. self.layout.addLayout(hlay3)
  3509. self.excellon_zeros_label = QtWidgets.QLabel(_('Default <b>Zeros</b>:'))
  3510. self.excellon_zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  3511. self.excellon_zeros_label.setToolTip(
  3512. _("This sets the type of Excellon zeros.\n"
  3513. "If LZ then Leading Zeros are kept and\n"
  3514. "Trailing Zeros are removed.\n"
  3515. "If TZ is checked then Trailing Zeros are kept\n"
  3516. "and Leading Zeros are removed.")
  3517. )
  3518. hlay3.addWidget(self.excellon_zeros_label)
  3519. self.excellon_zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'L'},
  3520. {'label': _('TZ'), 'value': 'T'}])
  3521. self.excellon_zeros_radio.setToolTip(
  3522. _("This sets the default type of Excellon zeros.\n"
  3523. "If it is not detected in the parsed file the value here\n"
  3524. "will be used."
  3525. "If LZ then Leading Zeros are kept and\n"
  3526. "Trailing Zeros are removed.\n"
  3527. "If TZ is checked then Trailing Zeros are kept\n"
  3528. "and Leading Zeros are removed.")
  3529. )
  3530. hlay3.addStretch()
  3531. hlay3.addWidget(self.excellon_zeros_radio, QtCore.Qt.AlignRight)
  3532. hlay4 = QtWidgets.QHBoxLayout()
  3533. self.layout.addLayout(hlay4)
  3534. self.excellon_units_label = QtWidgets.QLabel(_('Default <b>Units</b>:'))
  3535. self.excellon_units_label.setAlignment(QtCore.Qt.AlignLeft)
  3536. self.excellon_units_label.setToolTip(
  3537. _("This sets the default units of Excellon files.\n"
  3538. "If it is not detected in the parsed file the value here\n"
  3539. "will be used."
  3540. "Some Excellon files don't have an header\n"
  3541. "therefore this parameter will be used.")
  3542. )
  3543. hlay4.addWidget(self.excellon_units_label)
  3544. self.excellon_units_radio = RadioSet([{'label': _('INCH'), 'value': 'INCH'},
  3545. {'label': _('MM'), 'value': 'METRIC'}])
  3546. self.excellon_units_radio.setToolTip(
  3547. _("This sets the units of Excellon files.\n"
  3548. "Some Excellon files don't have an header\n"
  3549. "therefore this parameter will be used.")
  3550. )
  3551. hlay4.addStretch()
  3552. hlay4.addWidget(self.excellon_units_radio, QtCore.Qt.AlignRight)
  3553. hlay5 = QtWidgets.QVBoxLayout()
  3554. self.layout.addLayout(hlay5)
  3555. self.empty_label = QtWidgets.QLabel("")
  3556. hlay5.addWidget(self.empty_label)
  3557. hlay6 = QtWidgets.QVBoxLayout()
  3558. self.layout.addLayout(hlay6)
  3559. self.excellon_general_label = QtWidgets.QLabel(_("<b>Excellon Optimization:</b>"))
  3560. hlay6.addWidget(self.excellon_general_label)
  3561. # Create a form layout for the Excellon general settings
  3562. form_box_excellon = QtWidgets.QFormLayout()
  3563. hlay6.addLayout(form_box_excellon)
  3564. self.excellon_optimization_label = QtWidgets.QLabel(_('Algorithm: '))
  3565. self.excellon_optimization_label.setAlignment(QtCore.Qt.AlignLeft)
  3566. self.excellon_optimization_label.setToolTip(
  3567. _("This sets the optimization type for the Excellon drill path.\n"
  3568. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  3569. "Guided Local Path is used. Default search time is 3sec.\n"
  3570. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  3571. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  3572. "\n"
  3573. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  3574. "Travelling Salesman algorithm for path optimization.")
  3575. )
  3576. self.excellon_optimization_radio = RadioSet([{'label': _('MH'), 'value': 'M'},
  3577. {'label': _('Basic'), 'value': 'B'}])
  3578. self.excellon_optimization_radio.setToolTip(
  3579. _("This sets the optimization type for the Excellon drill path.\n"
  3580. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  3581. "Guided Local Path is used. Default search time is 3sec.\n"
  3582. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  3583. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  3584. "\n"
  3585. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  3586. "Travelling Salesman algorithm for path optimization.")
  3587. )
  3588. form_box_excellon.addRow(self.excellon_optimization_label, self.excellon_optimization_radio)
  3589. self.optimization_time_label = QtWidgets.QLabel(_('Optimization Time: '))
  3590. self.optimization_time_label.setAlignment(QtCore.Qt.AlignLeft)
  3591. self.optimization_time_label.setToolTip(
  3592. _("When OR-Tools Metaheuristic (MH) is enabled there is a\n"
  3593. "maximum threshold for how much time is spent doing the\n"
  3594. "path optimization. This max duration is set here.\n"
  3595. "In seconds.")
  3596. )
  3597. self.optimization_time_entry = LengthEntry()
  3598. form_box_excellon.addRow(self.optimization_time_label, self.optimization_time_entry)
  3599. current_platform = platform.architecture()[0]
  3600. if current_platform == '64bit':
  3601. self.excellon_optimization_label.setDisabled(False)
  3602. self.excellon_optimization_radio.setDisabled(False)
  3603. self.optimization_time_label.setDisabled(False)
  3604. self.optimization_time_entry.setDisabled(False)
  3605. self.excellon_optimization_radio.activated_custom.connect(self.optimization_selection)
  3606. else:
  3607. self.excellon_optimization_label.setDisabled(True)
  3608. self.excellon_optimization_radio.setDisabled(True)
  3609. self.optimization_time_label.setDisabled(True)
  3610. self.optimization_time_entry.setDisabled(True)
  3611. self.layout.addStretch()
  3612. def optimization_selection(self):
  3613. if self.excellon_optimization_radio.get_value() == 'M':
  3614. self.optimization_time_label.setDisabled(False)
  3615. self.optimization_time_entry.setDisabled(False)
  3616. else:
  3617. self.optimization_time_label.setDisabled(True)
  3618. self.optimization_time_entry.setDisabled(True)
  3619. class ExcellonOptPrefGroupUI(OptionsGroupUI):
  3620. def __init__(self, parent=None):
  3621. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  3622. super(ExcellonOptPrefGroupUI, self).__init__(self)
  3623. self.setTitle(str(_("Excellon Options")))
  3624. ## Create CNC Job
  3625. self.cncjob_label = QtWidgets.QLabel(_('<b>Create CNC Job</b>'))
  3626. self.cncjob_label.setToolTip(
  3627. _("Parameters used to create a CNC Job object\n"
  3628. "for this drill object.")
  3629. )
  3630. self.layout.addWidget(self.cncjob_label)
  3631. grid2 = QtWidgets.QGridLayout()
  3632. self.layout.addLayout(grid2)
  3633. cutzlabel = QtWidgets.QLabel(_('Cut Z:'))
  3634. cutzlabel.setToolTip(
  3635. _("Drill depth (negative)\n"
  3636. "below the copper surface.")
  3637. )
  3638. grid2.addWidget(cutzlabel, 0, 0)
  3639. self.cutz_entry = LengthEntry()
  3640. grid2.addWidget(self.cutz_entry, 0, 1)
  3641. travelzlabel = QtWidgets.QLabel(_('Travel Z:'))
  3642. travelzlabel.setToolTip(
  3643. _("Tool height when travelling\n"
  3644. "across the XY plane.")
  3645. )
  3646. grid2.addWidget(travelzlabel, 1, 0)
  3647. self.travelz_entry = LengthEntry()
  3648. grid2.addWidget(self.travelz_entry, 1, 1)
  3649. # Tool change:
  3650. toolchlabel = QtWidgets.QLabel(_("Tool change:"))
  3651. toolchlabel.setToolTip(
  3652. _("Include tool-change sequence\n"
  3653. "in G-Code (Pause for tool change).")
  3654. )
  3655. self.toolchange_cb = FCCheckBox()
  3656. grid2.addWidget(toolchlabel, 2, 0)
  3657. grid2.addWidget(self.toolchange_cb, 2, 1)
  3658. toolchangezlabel = QtWidgets.QLabel(_('Toolchange Z:'))
  3659. toolchangezlabel.setToolTip(
  3660. _("Toolchange Z position.")
  3661. )
  3662. grid2.addWidget(toolchangezlabel, 3, 0)
  3663. self.toolchangez_entry = LengthEntry()
  3664. grid2.addWidget(self.toolchangez_entry, 3, 1)
  3665. frlabel = QtWidgets.QLabel(_('Feedrate:'))
  3666. frlabel.setToolTip(
  3667. _("Tool speed while drilling\n"
  3668. "(in units per minute).")
  3669. )
  3670. grid2.addWidget(frlabel, 4, 0)
  3671. self.feedrate_entry = LengthEntry()
  3672. grid2.addWidget(self.feedrate_entry, 4, 1)
  3673. # Spindle speed
  3674. spdlabel = QtWidgets.QLabel(_('Spindle Speed:'))
  3675. spdlabel.setToolTip(
  3676. _("Speed of the spindle\n"
  3677. "in RPM (optional)")
  3678. )
  3679. grid2.addWidget(spdlabel, 5, 0)
  3680. self.spindlespeed_entry = IntEntry(allow_empty=True)
  3681. grid2.addWidget(self.spindlespeed_entry, 5, 1)
  3682. # Dwell
  3683. dwelllabel = QtWidgets.QLabel(_('Dwell:'))
  3684. dwelllabel.setToolTip(
  3685. _("Pause to allow the spindle to reach its\n"
  3686. "speed before cutting.")
  3687. )
  3688. dwelltime = QtWidgets.QLabel(_('Duration:'))
  3689. dwelltime.setToolTip(
  3690. _("Number of milliseconds for spindle to dwell.")
  3691. )
  3692. self.dwell_cb = FCCheckBox()
  3693. self.dwelltime_entry = FCEntry()
  3694. grid2.addWidget(dwelllabel, 6, 0)
  3695. grid2.addWidget(self.dwell_cb, 6, 1)
  3696. grid2.addWidget(dwelltime, 7, 0)
  3697. grid2.addWidget(self.dwelltime_entry, 7, 1)
  3698. self.ois_dwell_exc = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  3699. # postprocessor selection
  3700. pp_excellon_label = QtWidgets.QLabel(_("Postprocessor:"))
  3701. pp_excellon_label.setToolTip(
  3702. _("The postprocessor file that dictates\n"
  3703. "gcode output.")
  3704. )
  3705. grid2.addWidget(pp_excellon_label, 8, 0)
  3706. self.pp_excellon_name_cb = FCComboBox()
  3707. self.pp_excellon_name_cb.setFocusPolicy(Qt.StrongFocus)
  3708. grid2.addWidget(self.pp_excellon_name_cb, 8, 1)
  3709. #### Choose what to use for Gcode creation: Drills, Slots or Both
  3710. excellon_gcode_type_label = QtWidgets.QLabel(_('<b>Gcode: </b>'))
  3711. excellon_gcode_type_label.setToolTip(
  3712. _("Choose what to use for GCode generation:\n"
  3713. "'Drills', 'Slots' or 'Both'.\n"
  3714. "When choosing 'Slots' or 'Both', slots will be\n"
  3715. "converted to drills.")
  3716. )
  3717. self.excellon_gcode_type_radio = RadioSet([{'label': _('Drills'), 'value': 'drills'},
  3718. {'label': _('Slots'), 'value': 'slots'},
  3719. {'label': _('Both'), 'value': 'both'}])
  3720. grid2.addWidget(excellon_gcode_type_label, 9, 0)
  3721. grid2.addWidget(self.excellon_gcode_type_radio, 9, 1)
  3722. # until I decide to implement this feature those remain disabled
  3723. excellon_gcode_type_label.hide()
  3724. self.excellon_gcode_type_radio.setVisible(False)
  3725. #### Milling Holes ####
  3726. self.mill_hole_label = QtWidgets.QLabel(_('<b>Mill Holes</b>'))
  3727. self.mill_hole_label.setToolTip(
  3728. _("Create Geometry for milling holes.")
  3729. )
  3730. self.layout.addWidget(self.mill_hole_label)
  3731. grid3 = QtWidgets.QGridLayout()
  3732. self.layout.addLayout(grid3)
  3733. tdlabel = QtWidgets.QLabel(_('Drill Tool dia:'))
  3734. tdlabel.setToolTip(
  3735. _("Diameter of the cutting tool.")
  3736. )
  3737. grid3.addWidget(tdlabel, 0, 0)
  3738. self.tooldia_entry = LengthEntry()
  3739. grid3.addWidget(self.tooldia_entry, 0, 1)
  3740. stdlabel = QtWidgets.QLabel(_('Slot Tool dia:'))
  3741. stdlabel.setToolTip(
  3742. _("Diameter of the cutting tool\n"
  3743. "when milling slots.")
  3744. )
  3745. grid3.addWidget(stdlabel, 1, 0)
  3746. self.slot_tooldia_entry = LengthEntry()
  3747. grid3.addWidget(self.slot_tooldia_entry, 1, 1)
  3748. grid4 = QtWidgets.QGridLayout()
  3749. self.layout.addLayout(grid4)
  3750. # Adding the Excellon Format Defaults Button
  3751. self.excellon_defaults_button = QtWidgets.QPushButton()
  3752. self.excellon_defaults_button.setText(str(_("Defaults")))
  3753. self.excellon_defaults_button.setFixedWidth(80)
  3754. grid4.addWidget(self.excellon_defaults_button, 0, 0, QtCore.Qt.AlignRight)
  3755. self.layout.addStretch()
  3756. class ExcellonAdvOptPrefGroupUI(OptionsGroupUI):
  3757. def __init__(self, parent=None):
  3758. # OptionsGroupUI.__init__(self, "Excellon Advanced Options", parent=parent)
  3759. super(ExcellonAdvOptPrefGroupUI, self).__init__(self)
  3760. self.setTitle(str(_("Excellon Adv. Options")))
  3761. ######################
  3762. ## ADVANCED OPTIONS ##
  3763. ######################
  3764. self.cncjob_label = QtWidgets.QLabel(_('<b>Advanced Options:</b>'))
  3765. self.cncjob_label.setToolTip(
  3766. _("Parameters used to create a CNC Job object\n"
  3767. "for this drill object that are shown when App Level is Advanced.")
  3768. )
  3769. self.layout.addWidget(self.cncjob_label)
  3770. grid1 = QtWidgets.QGridLayout()
  3771. self.layout.addLayout(grid1)
  3772. offsetlabel = QtWidgets.QLabel(_('Offset Z:'))
  3773. offsetlabel.setToolTip(
  3774. _("Some drill bits (the larger ones) need to drill deeper\n"
  3775. "to create the desired exit hole diameter due of the tip shape.\n"
  3776. "The value here can compensate the Cut Z parameter."))
  3777. grid1.addWidget(offsetlabel, 0, 0)
  3778. self.offset_entry = LengthEntry()
  3779. grid1.addWidget(self.offset_entry, 0, 1)
  3780. toolchange_xy_label = QtWidgets.QLabel(_('Toolchange X,Y:'))
  3781. toolchange_xy_label.setToolTip(
  3782. _("Toolchange X,Y position.")
  3783. )
  3784. grid1.addWidget(toolchange_xy_label, 1, 0)
  3785. self.toolchangexy_entry = FCEntry()
  3786. grid1.addWidget(self.toolchangexy_entry, 1, 1)
  3787. startzlabel = QtWidgets.QLabel(_('Start move Z:'))
  3788. startzlabel.setToolTip(
  3789. _("Height of the tool just after start.\n"
  3790. "Delete the value if you don't need this feature.")
  3791. )
  3792. grid1.addWidget(startzlabel, 2, 0)
  3793. self.estartz_entry = FloatEntry()
  3794. grid1.addWidget(self.estartz_entry, 2, 1)
  3795. endzlabel = QtWidgets.QLabel(_('End move Z:'))
  3796. endzlabel.setToolTip(
  3797. _("Height of the tool after\n"
  3798. "the last move at the end of the job.")
  3799. )
  3800. grid1.addWidget(endzlabel, 3, 0)
  3801. self.eendz_entry = LengthEntry()
  3802. grid1.addWidget(self.eendz_entry, 3, 1)
  3803. fr_rapid_label = QtWidgets.QLabel(_('Feedrate Rapids:'))
  3804. fr_rapid_label.setToolTip(
  3805. _("Tool speed while drilling\n"
  3806. "(in units per minute).\n"
  3807. "This is for the rapid move G00.\n"
  3808. "It is useful only for Marlin,\n"
  3809. "ignore for any other cases.")
  3810. )
  3811. grid1.addWidget(fr_rapid_label, 4, 0)
  3812. self.feedrate_rapid_entry = LengthEntry()
  3813. grid1.addWidget(self.feedrate_rapid_entry, 4, 1)
  3814. # Probe depth
  3815. self.pdepth_label = QtWidgets.QLabel(_("Probe Z depth:"))
  3816. self.pdepth_label.setToolTip(
  3817. _("The maximum depth that the probe is allowed\n"
  3818. "to probe. Negative value, in current units.")
  3819. )
  3820. grid1.addWidget(self.pdepth_label, 5, 0)
  3821. self.pdepth_entry = FCEntry()
  3822. grid1.addWidget(self.pdepth_entry, 5, 1)
  3823. # Probe feedrate
  3824. self.feedrate_probe_label = QtWidgets.QLabel(_("Feedrate Probe:"))
  3825. self.feedrate_probe_label.setToolTip(
  3826. _( "The feedrate used while the probe is probing.")
  3827. )
  3828. grid1.addWidget(self.feedrate_probe_label, 6, 0)
  3829. self.feedrate_probe_entry = FCEntry()
  3830. grid1.addWidget(self.feedrate_probe_entry, 6, 1)
  3831. fplungelabel = QtWidgets.QLabel(_('Fast Plunge:'))
  3832. fplungelabel.setToolTip(
  3833. _("By checking this, the vertical move from\n"
  3834. "Z_Toolchange to Z_move is done with G0,\n"
  3835. "meaning the fastest speed available.\n"
  3836. "WARNING: the move is done at Toolchange X,Y coords.")
  3837. )
  3838. self.fplunge_cb = FCCheckBox()
  3839. grid1.addWidget(fplungelabel, 7, 0)
  3840. grid1.addWidget(self.fplunge_cb, 7, 1)
  3841. fretractlabel = QtWidgets.QLabel(_('Fast Retract:'))
  3842. fretractlabel.setToolTip(
  3843. _("Exit hole strategy.\n"
  3844. " - When uncheked, while exiting the drilled hole the drill bit\n"
  3845. "will travel slow, with set feedrate (G1), up to zero depth and then\n"
  3846. "travel as fast as possible (G0) to the Z Move (travel height).\n"
  3847. " - When checked the travel from Z cut (cut depth) to Z_move\n"
  3848. "(travel height) is done as fast as possible (G0) in one move.")
  3849. )
  3850. self.fretract_cb = FCCheckBox()
  3851. grid1.addWidget(fretractlabel, 8, 0)
  3852. grid1.addWidget(self.fretract_cb, 8, 1)
  3853. self.layout.addStretch()
  3854. class ExcellonExpPrefGroupUI(OptionsGroupUI):
  3855. def __init__(self, parent=None):
  3856. super(ExcellonExpPrefGroupUI, self).__init__(self)
  3857. self.setTitle(str(_("Excellon Export")))
  3858. # Plot options
  3859. self.export_options_label = QtWidgets.QLabel(_("<b>Export Options:</b>"))
  3860. self.export_options_label.setToolTip(
  3861. _("The parameters set here are used in the file exported\n"
  3862. "when using the File -> Export -> Export Excellon menu entry.")
  3863. )
  3864. self.layout.addWidget(self.export_options_label)
  3865. form = QtWidgets.QFormLayout()
  3866. self.layout.addLayout(form)
  3867. # Excellon Units
  3868. self.excellon_units_label = QtWidgets.QLabel(_('<b>Units</b>:'))
  3869. self.excellon_units_label.setToolTip(
  3870. _("The units used in the Excellon file.")
  3871. )
  3872. self.excellon_units_radio = RadioSet([{'label': _('INCH'), 'value': 'INCH'},
  3873. {'label': _('MM'), 'value': 'METRIC'}])
  3874. self.excellon_units_radio.setToolTip(
  3875. _("The units used in the Excellon file.")
  3876. )
  3877. form.addRow(self.excellon_units_label, self.excellon_units_radio)
  3878. # Excellon non-decimal format
  3879. self.digits_label = QtWidgets.QLabel(_("<b>Int/Decimals:</b>"))
  3880. self.digits_label.setToolTip(
  3881. _("The NC drill files, usually named Excellon files\n"
  3882. "are files that can be found in different formats.\n"
  3883. "Here we set the format used when the provided\n"
  3884. "coordinates are not using period.")
  3885. )
  3886. hlay1 = QtWidgets.QHBoxLayout()
  3887. self.format_whole_entry = IntEntry()
  3888. self.format_whole_entry.setMaxLength(1)
  3889. self.format_whole_entry.setAlignment(QtCore.Qt.AlignRight)
  3890. self.format_whole_entry.setFixedWidth(30)
  3891. self.format_whole_entry.setToolTip(
  3892. _("This numbers signify the number of digits in\n"
  3893. "the whole part of Excellon coordinates.")
  3894. )
  3895. hlay1.addWidget(self.format_whole_entry, QtCore.Qt.AlignLeft)
  3896. excellon_separator_label= QtWidgets.QLabel(':')
  3897. excellon_separator_label.setFixedWidth(5)
  3898. hlay1.addWidget(excellon_separator_label, QtCore.Qt.AlignLeft)
  3899. self.format_dec_entry = IntEntry()
  3900. self.format_dec_entry.setMaxLength(1)
  3901. self.format_dec_entry.setAlignment(QtCore.Qt.AlignRight)
  3902. self.format_dec_entry.setFixedWidth(30)
  3903. self.format_dec_entry.setToolTip(
  3904. _("This numbers signify the number of digits in\n"
  3905. "the decimal part of Excellon coordinates.")
  3906. )
  3907. hlay1.addWidget(self.format_dec_entry, QtCore.Qt.AlignLeft)
  3908. hlay1.addStretch()
  3909. form.addRow(self.digits_label, hlay1)
  3910. # Select the Excellon Format
  3911. self.format_label = QtWidgets.QLabel(_("<b>Format:</b>"))
  3912. self.format_label.setToolTip(
  3913. _("Select the kind of coordinates format used.\n"
  3914. "Coordinates can be saved with decimal point or without.\n"
  3915. "When there is no decimal point, it is required to specify\n"
  3916. "the number of digits for integer part and the number of decimals.\n"
  3917. "Also it will have to be specified if LZ = leading zeros are kept\n"
  3918. "or TZ = trailing zeros are kept.")
  3919. )
  3920. self.format_radio = RadioSet([{'label': _('Decimal'), 'value': 'dec'},
  3921. {'label': _('No-Decimal'), 'value': 'ndec'}])
  3922. self.format_radio.setToolTip(
  3923. _("Select the kind of coordinates format used.\n"
  3924. "Coordinates can be saved with decimal point or without.\n"
  3925. "When there is no decimal point, it is required to specify\n"
  3926. "the number of digits for integer part and the number of decimals.\n"
  3927. "Also it will have to be specified if LZ = leading zeros are kept\n"
  3928. "or TZ = trailing zeros are kept.")
  3929. )
  3930. form.addRow(self.format_label, self.format_radio)
  3931. # Excellon Zeros
  3932. self.zeros_label = QtWidgets.QLabel(_('<b>Zeros</b>:'))
  3933. self.zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  3934. self.zeros_label.setToolTip(
  3935. _("This sets the type of Excellon zeros.\n"
  3936. "If LZ then Leading Zeros are kept and\n"
  3937. "Trailing Zeros are removed.\n"
  3938. "If TZ is checked then Trailing Zeros are kept\n"
  3939. "and Leading Zeros are removed.")
  3940. )
  3941. self.zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'LZ'},
  3942. {'label': _('TZ'), 'value': 'TZ'}])
  3943. self.zeros_radio.setToolTip(
  3944. _("This sets the default type of Excellon zeros.\n"
  3945. "If LZ then Leading Zeros are kept and\n"
  3946. "Trailing Zeros are removed.\n"
  3947. "If TZ is checked then Trailing Zeros are kept\n"
  3948. "and Leading Zeros are removed.")
  3949. )
  3950. form.addRow(self.zeros_label, self.zeros_radio)
  3951. self.layout.addStretch()
  3952. self.format_radio.activated_custom.connect(self.optimization_selection)
  3953. def optimization_selection(self):
  3954. if self.format_radio.get_value() == 'dec':
  3955. self.zeros_label.setDisabled(True)
  3956. self.zeros_radio.setDisabled(True)
  3957. else:
  3958. self.zeros_label.setDisabled(False)
  3959. self.zeros_radio.setDisabled(False)
  3960. class GeometryGenPrefGroupUI(OptionsGroupUI):
  3961. def __init__(self, parent=None):
  3962. # OptionsGroupUI.__init__(self, "Geometry General Preferences", parent=parent)
  3963. super(GeometryGenPrefGroupUI, self).__init__(self)
  3964. self.setTitle(str(_("Geometry General")))
  3965. ## Plot options
  3966. self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
  3967. self.layout.addWidget(self.plot_options_label)
  3968. # Plot CB
  3969. self.plot_cb = FCCheckBox(label=_('Plot'))
  3970. self.plot_cb.setToolTip(
  3971. _("Plot (show) this object.")
  3972. )
  3973. self.layout.addWidget(self.plot_cb)
  3974. grid0 = QtWidgets.QGridLayout()
  3975. self.layout.addLayout(grid0)
  3976. # Number of circle steps for circular aperture linear approximation
  3977. self.circle_steps_label = QtWidgets.QLabel(_("Circle Steps:"))
  3978. self.circle_steps_label.setToolTip(
  3979. _("The number of circle steps for <b>Geometry</b> \n"
  3980. "circle and arc shapes linear approximation.")
  3981. )
  3982. grid0.addWidget(self.circle_steps_label, 1, 0)
  3983. self.circle_steps_entry = IntEntry()
  3984. grid0.addWidget(self.circle_steps_entry, 1, 1)
  3985. # Tools
  3986. self.tools_label = QtWidgets.QLabel(_("<b>Tools</b>"))
  3987. self.layout.addWidget(self.tools_label)
  3988. grid0_b = QtWidgets.QGridLayout()
  3989. self.layout.addLayout(grid0_b)
  3990. # Tooldia
  3991. tdlabel = QtWidgets.QLabel(_('Tool dia: '))
  3992. tdlabel.setToolTip(
  3993. _("The diameter of the cutting\n"
  3994. "tool..")
  3995. )
  3996. grid0_b.addWidget(tdlabel, 0, 0)
  3997. self.cnctooldia_entry = LengthEntry()
  3998. grid0_b.addWidget(self.cnctooldia_entry, 0, 1)
  3999. self.layout.addStretch()
  4000. class GeometryOptPrefGroupUI(OptionsGroupUI):
  4001. def __init__(self, parent=None):
  4002. # OptionsGroupUI.__init__(self, "Geometry Options Preferences", parent=parent)
  4003. super(GeometryOptPrefGroupUI, self).__init__(self)
  4004. self.setTitle(str(_("Geometry Options")))
  4005. # ------------------------------
  4006. ## Create CNC Job
  4007. # ------------------------------
  4008. self.cncjob_label = QtWidgets.QLabel(_('<b>Create CNC Job:</b>'))
  4009. self.cncjob_label.setToolTip(
  4010. _("Create a CNC Job object\n"
  4011. "tracing the contours of this\n"
  4012. "Geometry object.")
  4013. )
  4014. self.layout.addWidget(self.cncjob_label)
  4015. grid1 = QtWidgets.QGridLayout()
  4016. self.layout.addLayout(grid1)
  4017. # Cut Z
  4018. cutzlabel = QtWidgets.QLabel(_('Cut Z:'))
  4019. cutzlabel.setToolTip(
  4020. _("Cutting depth (negative)\n"
  4021. "below the copper surface.")
  4022. )
  4023. grid1.addWidget(cutzlabel, 0, 0)
  4024. self.cutz_entry = LengthEntry()
  4025. grid1.addWidget(self.cutz_entry, 0, 1)
  4026. # Multidepth CheckBox
  4027. self.multidepth_cb = FCCheckBox(label=_('Multidepth'))
  4028. self.multidepth_cb.setToolTip(
  4029. _("Multidepth usage: True or False.")
  4030. )
  4031. grid1.addWidget(self.multidepth_cb, 1, 0)
  4032. # Depth/pass
  4033. dplabel = QtWidgets.QLabel(_('Depth/Pass:'))
  4034. dplabel.setToolTip(
  4035. _("The depth to cut on each pass,\n"
  4036. "when multidepth is enabled.\n"
  4037. "It has positive value although\n"
  4038. "it is a fraction from the depth\n"
  4039. "which has negative value.")
  4040. )
  4041. grid1.addWidget(dplabel, 2, 0)
  4042. self.depthperpass_entry = LengthEntry()
  4043. grid1.addWidget(self.depthperpass_entry, 2, 1)
  4044. self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry])
  4045. # Travel Z
  4046. travelzlabel = QtWidgets.QLabel(_('Travel Z:'))
  4047. travelzlabel.setToolTip(
  4048. _("Height of the tool when\n"
  4049. "moving without cutting.")
  4050. )
  4051. grid1.addWidget(travelzlabel, 3, 0)
  4052. self.travelz_entry = LengthEntry()
  4053. grid1.addWidget(self.travelz_entry, 3, 1)
  4054. # Tool change:
  4055. toolchlabel = QtWidgets.QLabel(_("Tool change:"))
  4056. toolchlabel.setToolTip(
  4057. _("Include tool-change sequence\n"
  4058. "in G-Code (Pause for tool change).")
  4059. )
  4060. self.toolchange_cb = FCCheckBox()
  4061. grid1.addWidget(toolchlabel, 4, 0)
  4062. grid1.addWidget(self.toolchange_cb, 4, 1)
  4063. # Toolchange Z
  4064. toolchangezlabel = QtWidgets.QLabel(_('Toolchange Z:'))
  4065. toolchangezlabel.setToolTip(
  4066. _("Toolchange Z position.")
  4067. )
  4068. grid1.addWidget(toolchangezlabel, 5, 0)
  4069. self.toolchangez_entry = LengthEntry()
  4070. grid1.addWidget(self.toolchangez_entry, 5, 1)
  4071. # Feedrate X-Y
  4072. frlabel = QtWidgets.QLabel(_('Feed Rate X-Y:'))
  4073. frlabel.setToolTip(
  4074. _("Cutting speed in the XY\n"
  4075. "plane in units per minute")
  4076. )
  4077. grid1.addWidget(frlabel, 6, 0)
  4078. self.cncfeedrate_entry = LengthEntry()
  4079. grid1.addWidget(self.cncfeedrate_entry, 6, 1)
  4080. # Feedrate Z (Plunge)
  4081. frz_label = QtWidgets.QLabel(_('Feed Rate Z:'))
  4082. frz_label.setToolTip(
  4083. _("Cutting speed in the XY\n"
  4084. "plane in units per minute.\n"
  4085. "It is called also Plunge.")
  4086. )
  4087. grid1.addWidget(frz_label, 7, 0)
  4088. self.cncplunge_entry = LengthEntry()
  4089. grid1.addWidget(self.cncplunge_entry, 7, 1)
  4090. # Spindle Speed
  4091. spdlabel = QtWidgets.QLabel(_('Spindle speed:'))
  4092. spdlabel.setToolTip(
  4093. _("Speed of the spindle\n"
  4094. "in RPM (optional)")
  4095. )
  4096. grid1.addWidget(spdlabel, 8, 0)
  4097. self.cncspindlespeed_entry = IntEntry(allow_empty=True)
  4098. grid1.addWidget(self.cncspindlespeed_entry, 8, 1)
  4099. # Dwell
  4100. self.dwell_cb = FCCheckBox(label=_('Dwell:'))
  4101. self.dwell_cb.setToolTip(
  4102. _("Pause to allow the spindle to reach its\n"
  4103. "speed before cutting.")
  4104. )
  4105. dwelltime = QtWidgets.QLabel(_('Duration:'))
  4106. dwelltime.setToolTip(
  4107. _("Number of milliseconds for spindle to dwell.")
  4108. )
  4109. self.dwelltime_entry = FCEntry()
  4110. grid1.addWidget(self.dwell_cb, 9, 0)
  4111. grid1.addWidget(dwelltime, 10, 0)
  4112. grid1.addWidget(self.dwelltime_entry, 10, 1)
  4113. self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  4114. # postprocessor selection
  4115. pp_label = QtWidgets.QLabel(_("Postprocessor:"))
  4116. pp_label.setToolTip(
  4117. _("The postprocessor file that dictates\n"
  4118. "Machine Code output.")
  4119. )
  4120. grid1.addWidget(pp_label, 11, 0)
  4121. self.pp_geometry_name_cb = FCComboBox()
  4122. self.pp_geometry_name_cb.setFocusPolicy(Qt.StrongFocus)
  4123. grid1.addWidget(self.pp_geometry_name_cb, 11, 1)
  4124. self.layout.addStretch()
  4125. class GeometryAdvOptPrefGroupUI(OptionsGroupUI):
  4126. def __init__(self, parent=None):
  4127. # OptionsGroupUI.__init__(self, "Geometry Advanced Options Preferences", parent=parent)
  4128. super(GeometryAdvOptPrefGroupUI, self).__init__(self)
  4129. self.setTitle(str(_("Geometry Adv. Options")))
  4130. # ------------------------------
  4131. ## Advanced Options
  4132. # ------------------------------
  4133. self.cncjob_label = QtWidgets.QLabel(_('<b>Advanced Options:</b>'))
  4134. self.cncjob_label.setToolTip(
  4135. _("Parameters to create a CNC Job object\n"
  4136. "tracing the contours of a Geometry object.")
  4137. )
  4138. self.layout.addWidget(self.cncjob_label)
  4139. grid1 = QtWidgets.QGridLayout()
  4140. self.layout.addLayout(grid1)
  4141. # Toolchange X,Y
  4142. toolchange_xy_label = QtWidgets.QLabel(_('Toolchange X,Y:'))
  4143. toolchange_xy_label.setToolTip(
  4144. _("Toolchange X,Y position.")
  4145. )
  4146. grid1.addWidget(toolchange_xy_label, 1, 0)
  4147. self.toolchangexy_entry = FCEntry()
  4148. grid1.addWidget(self.toolchangexy_entry, 1, 1)
  4149. # Start move Z
  4150. startzlabel = QtWidgets.QLabel(_('Start move Z:'))
  4151. startzlabel.setToolTip(
  4152. _("Height of the tool just after starting the work.\n"
  4153. "Delete the value if you don't need this feature.")
  4154. )
  4155. grid1.addWidget(startzlabel, 2, 0)
  4156. self.gstartz_entry = FloatEntry()
  4157. grid1.addWidget(self.gstartz_entry, 2, 1)
  4158. # End move Z
  4159. endzlabel = QtWidgets.QLabel(_('End move Z:'))
  4160. endzlabel.setToolTip(
  4161. _("Height of the tool after\n"
  4162. "the last move at the end of the job.")
  4163. )
  4164. grid1.addWidget(endzlabel, 3, 0)
  4165. self.gendz_entry = LengthEntry()
  4166. grid1.addWidget(self.gendz_entry, 3, 1)
  4167. # Feedrate rapids
  4168. fr_rapid_label = QtWidgets.QLabel(_('Feedrate Rapids:'))
  4169. fr_rapid_label.setToolTip(
  4170. _("Cutting speed in the XY plane\n"
  4171. "(in units per minute).\n"
  4172. "This is for the rapid move G00.\n"
  4173. "It is useful only for Marlin,\n"
  4174. "ignore for any other cases."
  4175. )
  4176. )
  4177. grid1.addWidget(fr_rapid_label, 4, 0)
  4178. self.cncfeedrate_rapid_entry = LengthEntry()
  4179. grid1.addWidget(self.cncfeedrate_rapid_entry, 4, 1)
  4180. # End move extra cut
  4181. self.extracut_cb = FCCheckBox(label=_('Re-cut 1st pt.'))
  4182. self.extracut_cb.setToolTip(
  4183. _("In order to remove possible\n"
  4184. "copper leftovers where first cut\n"
  4185. "meet with last cut, we generate an\n"
  4186. "extended cut over the first cut section.")
  4187. )
  4188. grid1.addWidget(self.extracut_cb, 5, 0)
  4189. # Probe depth
  4190. self.pdepth_label = QtWidgets.QLabel(_("Probe Z depth:"))
  4191. self.pdepth_label.setToolTip(
  4192. _("The maximum depth that the probe is allowed\n"
  4193. "to probe. Negative value, in current units.")
  4194. )
  4195. grid1.addWidget(self.pdepth_label, 6, 0)
  4196. self.pdepth_entry = FCEntry()
  4197. grid1.addWidget(self.pdepth_entry, 6, 1)
  4198. # Probe feedrate
  4199. self.feedrate_probe_label = QtWidgets.QLabel(_("Feedrate Probe:"))
  4200. self.feedrate_probe_label.setToolTip(
  4201. _("The feedrate used while the probe is probing.")
  4202. )
  4203. grid1.addWidget(self.feedrate_probe_label, 7, 0)
  4204. self.feedrate_probe_entry = FCEntry()
  4205. grid1.addWidget(self.feedrate_probe_entry, 7, 1)
  4206. # Fast Move from Z Toolchange
  4207. fplungelabel = QtWidgets.QLabel(_('Fast Plunge:'))
  4208. fplungelabel.setToolTip(
  4209. _("By checking this, the vertical move from\n"
  4210. "Z_Toolchange to Z_move is done with G0,\n"
  4211. "meaning the fastest speed available.\n"
  4212. "WARNING: the move is done at Toolchange X,Y coords.")
  4213. )
  4214. self.fplunge_cb = FCCheckBox()
  4215. grid1.addWidget(fplungelabel, 8, 0)
  4216. grid1.addWidget(self.fplunge_cb, 8, 1)
  4217. # Size of trace segment on X axis
  4218. segx_label = QtWidgets.QLabel(_("Seg. X size:"))
  4219. segx_label.setToolTip(
  4220. _("The size of the trace segment on the X axis.\n"
  4221. "Useful for auto-leveling.\n"
  4222. "A value of 0 means no segmentation on the X axis.")
  4223. )
  4224. grid1.addWidget(segx_label, 9, 0)
  4225. self.segx_entry = FCEntry()
  4226. grid1.addWidget(self.segx_entry, 9, 1)
  4227. # Size of trace segment on Y axis
  4228. segy_label = QtWidgets.QLabel(_("Seg. Y size:"))
  4229. segy_label.setToolTip(
  4230. _("The size of the trace segment on the Y axis.\n"
  4231. "Useful for auto-leveling.\n"
  4232. "A value of 0 means no segmentation on the Y axis.")
  4233. )
  4234. grid1.addWidget(segy_label, 10, 0)
  4235. self.segy_entry = FCEntry()
  4236. grid1.addWidget(self.segy_entry, 10, 1)
  4237. self.layout.addStretch()
  4238. class CNCJobGenPrefGroupUI(OptionsGroupUI):
  4239. def __init__(self, parent=None):
  4240. # OptionsGroupUI.__init__(self, "CNC Job General Preferences", parent=None)
  4241. super(CNCJobGenPrefGroupUI, self).__init__(self)
  4242. self.setTitle(str(_("CNC Job General")))
  4243. ## Plot options
  4244. self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
  4245. self.layout.addWidget(self.plot_options_label)
  4246. grid0 = QtWidgets.QGridLayout()
  4247. self.layout.addLayout(grid0)
  4248. grid0.setColumnStretch(1, 1)
  4249. grid0.setColumnStretch(2, 1)
  4250. # Plot CB
  4251. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  4252. self.plot_cb = FCCheckBox(_('Plot Object'))
  4253. self.plot_cb.setToolTip(
  4254. "Plot (show) this object."
  4255. )
  4256. grid0.addWidget(self.plot_cb, 0, 0)
  4257. # Plot Kind
  4258. self.cncplot_method_label = QtWidgets.QLabel(_("Plot kind:"))
  4259. self.cncplot_method_label.setToolTip(
  4260. _("This selects the kind of geometries on the canvas to plot.\n"
  4261. "Those can be either of type 'Travel' which means the moves\n"
  4262. "above the work piece or it can be of type 'Cut',\n"
  4263. "which means the moves that cut into the material.")
  4264. )
  4265. self.cncplot_method_radio = RadioSet([
  4266. {"label": _("All"), "value": "all"},
  4267. {"label": _("Travel"), "value": "travel"},
  4268. {"label": _("Cut"), "value": "cut"}
  4269. ], stretch=False)
  4270. grid0.addWidget(self.cncplot_method_label, 1, 0)
  4271. grid0.addWidget(self.cncplot_method_radio, 1, 1)
  4272. grid0.addWidget(QtWidgets.QLabel(''), 1, 2)
  4273. # Number of circle steps for circular aperture linear approximation
  4274. self.steps_per_circle_label = QtWidgets.QLabel(_("Circle Steps:"))
  4275. self.steps_per_circle_label.setToolTip(
  4276. _("The number of circle steps for <b>GCode</b> \n"
  4277. "circle and arc shapes linear approximation.")
  4278. )
  4279. grid0.addWidget(self.steps_per_circle_label, 2, 0)
  4280. self.steps_per_circle_entry = IntEntry()
  4281. grid0.addWidget(self.steps_per_circle_entry, 2, 1)
  4282. # Tool dia for plot
  4283. tdlabel = QtWidgets.QLabel(_('Tool dia:'))
  4284. tdlabel.setToolTip(
  4285. _("Diameter of the tool to be\n"
  4286. "rendered in the plot.")
  4287. )
  4288. grid0.addWidget(tdlabel, 3, 0)
  4289. self.tooldia_entry = LengthEntry()
  4290. grid0.addWidget(self.tooldia_entry, 3, 1)
  4291. # Number of decimals to use in GCODE coordinates
  4292. cdeclabel = QtWidgets.QLabel(_('Coords dec.:'))
  4293. cdeclabel.setToolTip(
  4294. _("The number of decimals to be used for \n"
  4295. "the X, Y, Z coordinates in CNC code (GCODE, etc.)")
  4296. )
  4297. grid0.addWidget(cdeclabel, 4, 0)
  4298. self.coords_dec_entry = IntEntry()
  4299. grid0.addWidget(self.coords_dec_entry, 4, 1)
  4300. # Number of decimals to use in GCODE feedrate
  4301. frdeclabel = QtWidgets.QLabel(_('Feedrate dec.:'))
  4302. frdeclabel.setToolTip(
  4303. _("The number of decimals to be used for \n"
  4304. "the Feedrate parameter in CNC code (GCODE, etc.)")
  4305. )
  4306. grid0.addWidget(frdeclabel, 5, 0)
  4307. self.fr_dec_entry = IntEntry()
  4308. grid0.addWidget(self.fr_dec_entry, 5, 1)
  4309. self.layout.addStretch()
  4310. class CNCJobOptPrefGroupUI(OptionsGroupUI):
  4311. def __init__(self, parent=None):
  4312. # OptionsGroupUI.__init__(self, "CNC Job Options Preferences", parent=None)
  4313. super(CNCJobOptPrefGroupUI, self).__init__(self)
  4314. self.setTitle(str(_("CNC Job Options")))
  4315. ## Export G-Code
  4316. self.export_gcode_label = QtWidgets.QLabel(_("<b>Export G-Code:</b>"))
  4317. self.export_gcode_label.setToolTip(
  4318. _("Export and save G-Code to\n"
  4319. "make this object to a file.")
  4320. )
  4321. self.layout.addWidget(self.export_gcode_label)
  4322. # Prepend to G-Code
  4323. prependlabel = QtWidgets.QLabel(_('Prepend to G-Code:'))
  4324. prependlabel.setToolTip(
  4325. _("Type here any G-Code commands you would\n"
  4326. "like to add at the beginning of the G-Code file.")
  4327. )
  4328. self.layout.addWidget(prependlabel)
  4329. self.prepend_text = FCTextArea()
  4330. self.layout.addWidget(self.prepend_text)
  4331. # Append text to G-Code
  4332. appendlabel = QtWidgets.QLabel(_('Append to G-Code:'))
  4333. appendlabel.setToolTip(
  4334. _("Type here any G-Code commands you would\n"
  4335. "like to append to the generated file.\n"
  4336. "I.e.: M2 (End of program)")
  4337. )
  4338. self.layout.addWidget(appendlabel)
  4339. self.append_text = FCTextArea()
  4340. self.layout.addWidget(self.append_text)
  4341. self.layout.addStretch()
  4342. class CNCJobAdvOptPrefGroupUI(OptionsGroupUI):
  4343. def __init__(self, parent=None):
  4344. # OptionsGroupUI.__init__(self, "CNC Job Advanced Options Preferences", parent=None)
  4345. super(CNCJobAdvOptPrefGroupUI, self).__init__(self)
  4346. self.setTitle(str(_("CNC Job Adv. Options")))
  4347. ## Export G-Code
  4348. self.export_gcode_label = QtWidgets.QLabel(_("<b>Export G-Code:</b>"))
  4349. self.export_gcode_label.setToolTip(
  4350. _("Export and save G-Code to\n"
  4351. "make this object to a file.")
  4352. )
  4353. self.layout.addWidget(self.export_gcode_label)
  4354. # Prepend to G-Code
  4355. toolchangelabel = QtWidgets.QLabel(_('Toolchange G-Code:'))
  4356. toolchangelabel.setToolTip(
  4357. _("Type here any G-Code commands you would\n"
  4358. "like to be executed when Toolchange event is encountered.\n"
  4359. "This will constitute a Custom Toolchange GCode,\n"
  4360. "or a Toolchange Macro.")
  4361. )
  4362. self.layout.addWidget(toolchangelabel)
  4363. self.toolchange_text = FCTextArea()
  4364. self.layout.addWidget(self.toolchange_text)
  4365. hlay = QtWidgets.QHBoxLayout()
  4366. self.layout.addLayout(hlay)
  4367. # Toolchange Replacement GCode
  4368. self.toolchange_cb = FCCheckBox(label=_('Use Toolchange Macro'))
  4369. self.toolchange_cb.setToolTip(
  4370. _("Check this box if you want to use\n"
  4371. "a Custom Toolchange GCode (macro).")
  4372. )
  4373. hlay.addWidget(self.toolchange_cb)
  4374. hlay.addStretch()
  4375. hlay1 = QtWidgets.QHBoxLayout()
  4376. self.layout.addLayout(hlay1)
  4377. # Variable list
  4378. self.tc_variable_combo = FCComboBox()
  4379. self.tc_variable_combo.setToolTip(
  4380. _("A list of the FlatCAM variables that can be used\n"
  4381. "in the Toolchange event.\n"
  4382. "They have to be surrounded by the '%' symbol")
  4383. )
  4384. hlay1.addWidget(self.tc_variable_combo)
  4385. # Populate the Combo Box
  4386. variables = [_('Parameters'), 'tool', 'tooldia', 't_drills', 'x_toolchange', 'y_toolchange', 'z_toolchange',
  4387. 'z_cut', 'z_move', 'z_depthpercut', 'spindlespeed', 'dwelltime']
  4388. self.tc_variable_combo.addItems(variables)
  4389. self.tc_variable_combo.setItemData(0, _("FlatCAM CNC parameters"), Qt.ToolTipRole)
  4390. self.tc_variable_combo.setItemData(1, _("tool = tool number"), Qt.ToolTipRole)
  4391. self.tc_variable_combo.setItemData(2, _("tooldia = tool diameter"), Qt.ToolTipRole)
  4392. self.tc_variable_combo.setItemData(3, _("t_drills = for Excellon, total number of drills"), Qt.ToolTipRole)
  4393. self.tc_variable_combo.setItemData(4, _("x_toolchange = X coord for Toolchange"), Qt.ToolTipRole)
  4394. self.tc_variable_combo.setItemData(5, _("y_toolchange = Y coord for Toolchange"), Qt.ToolTipRole)
  4395. self.tc_variable_combo.setItemData(6, _("z_toolchange = Z coord for Toolchange"), Qt.ToolTipRole)
  4396. self.tc_variable_combo.setItemData(7, _("z_cut = Z depth for the cut"), Qt.ToolTipRole)
  4397. self.tc_variable_combo.setItemData(8, _("z_move = Z height for travel"), Qt.ToolTipRole)
  4398. self.tc_variable_combo.setItemData(9, _("z_depthpercut = the step value for multidepth cut"), Qt.ToolTipRole)
  4399. self.tc_variable_combo.setItemData(10, _("spindlesspeed = the value for the spindle speed"), Qt.ToolTipRole)
  4400. self.tc_variable_combo.setItemData(11, _("dwelltime = time to dwell to allow the spindle to reach it's set RPM"),
  4401. Qt.ToolTipRole)
  4402. hlay1.addStretch()
  4403. # Insert Variable into the Toolchange G-Code Text Box
  4404. # self.tc_insert_buton = FCButton("Insert")
  4405. # self.tc_insert_buton.setToolTip(
  4406. # "Insert the variable in the GCode Box\n"
  4407. # "surrounded by the '%' symbol."
  4408. # )
  4409. # hlay1.addWidget(self.tc_insert_buton)
  4410. self.layout.addStretch()
  4411. class ToolsNCCPrefGroupUI(OptionsGroupUI):
  4412. def __init__(self, parent=None):
  4413. # OptionsGroupUI.__init__(self, "NCC Tool Options", parent=parent)
  4414. super(ToolsNCCPrefGroupUI, self).__init__(self)
  4415. self.setTitle(str(_("NCC Tool Options")))
  4416. ## Clear non-copper regions
  4417. self.clearcopper_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4418. self.clearcopper_label.setToolTip(
  4419. _("Create a Geometry object with\n"
  4420. "toolpaths to cut all non-copper regions.")
  4421. )
  4422. self.layout.addWidget(self.clearcopper_label)
  4423. grid0 = QtWidgets.QGridLayout()
  4424. self.layout.addLayout(grid0)
  4425. ncctdlabel = QtWidgets.QLabel(_('Tools dia:'))
  4426. ncctdlabel.setToolTip(
  4427. _("Diameters of the cutting tools, separated by ','")
  4428. )
  4429. grid0.addWidget(ncctdlabel, 0, 0)
  4430. self.ncc_tool_dia_entry = FCEntry()
  4431. grid0.addWidget(self.ncc_tool_dia_entry, 0, 1)
  4432. nccoverlabel = QtWidgets.QLabel(_('Overlap Rate:'))
  4433. nccoverlabel.setToolTip(
  4434. _( "How much (fraction) of the tool width to overlap each tool pass.\n"
  4435. "Example:\n"
  4436. "A value here of 0.25 means 25% from the tool diameter found above.\n\n"
  4437. "Adjust the value starting with lower values\n"
  4438. "and increasing it if areas that should be cleared are still \n"
  4439. "not cleared.\n"
  4440. "Lower values = faster processing, faster execution on PCB.\n"
  4441. "Higher values = slow processing and slow execution on CNC\n"
  4442. "due of too many paths.")
  4443. )
  4444. grid0.addWidget(nccoverlabel, 1, 0)
  4445. self.ncc_overlap_entry = FloatEntry()
  4446. grid0.addWidget(self.ncc_overlap_entry, 1, 1)
  4447. nccmarginlabel = QtWidgets.QLabel(_('Margin:'))
  4448. nccmarginlabel.setToolTip(
  4449. _("Bounding box margin.")
  4450. )
  4451. grid0.addWidget(nccmarginlabel, 2, 0)
  4452. self.ncc_margin_entry = FloatEntry()
  4453. grid0.addWidget(self.ncc_margin_entry, 2, 1)
  4454. # Method
  4455. methodlabel = QtWidgets.QLabel(_('Method:'))
  4456. methodlabel.setToolTip(
  4457. _("Algorithm for non-copper clearing:<BR>"
  4458. "<B>Standard</B>: Fixed step inwards.<BR>"
  4459. "<B>Seed-based</B>: Outwards from seed.<BR>"
  4460. "<B>Line-based</B>: Parallel lines.")
  4461. )
  4462. grid0.addWidget(methodlabel, 3, 0)
  4463. self.ncc_method_radio = RadioSet([
  4464. {"label": _("Standard"), "value": "standard"},
  4465. {"label": _("Seed-based"), "value": "seed"},
  4466. {"label": _("Straight lines"), "value": "lines"}
  4467. ], orientation='vertical', stretch=False)
  4468. grid0.addWidget(self.ncc_method_radio, 3, 1)
  4469. # Connect lines
  4470. pathconnectlabel = QtWidgets.QLabel(_("Connect:"))
  4471. pathconnectlabel.setToolTip(
  4472. _("Draw lines between resulting\n"
  4473. "segments to minimize tool lifts.")
  4474. )
  4475. grid0.addWidget(pathconnectlabel, 4, 0)
  4476. self.ncc_connect_cb = FCCheckBox()
  4477. grid0.addWidget(self.ncc_connect_cb, 4, 1)
  4478. contourlabel = QtWidgets.QLabel(_("Contour:"))
  4479. contourlabel.setToolTip(
  4480. _( "Cut around the perimeter of the polygon\n"
  4481. "to trim rough edges.")
  4482. )
  4483. grid0.addWidget(contourlabel, 5, 0)
  4484. self.ncc_contour_cb = FCCheckBox()
  4485. grid0.addWidget(self.ncc_contour_cb, 5, 1)
  4486. restlabel = QtWidgets.QLabel(_("Rest M.:"))
  4487. restlabel.setToolTip(
  4488. _("If checked, use 'rest machining'.\n"
  4489. "Basically it will clear copper outside PCB features,\n"
  4490. "using the biggest tool and continue with the next tools,\n"
  4491. "from bigger to smaller, to clear areas of copper that\n"
  4492. "could not be cleared by previous tool.\n"
  4493. "If not checked, use the standard algorithm.")
  4494. )
  4495. grid0.addWidget(restlabel, 6, 0)
  4496. self.ncc_rest_cb = FCCheckBox()
  4497. grid0.addWidget(self.ncc_rest_cb, 6, 1)
  4498. self.layout.addStretch()
  4499. class ToolsCutoutPrefGroupUI(OptionsGroupUI):
  4500. def __init__(self, parent=None):
  4501. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  4502. super(ToolsCutoutPrefGroupUI, self).__init__(self)
  4503. self.setTitle(str(_("Cutout Tool Options")))
  4504. ## Board cuttout
  4505. self.board_cutout_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4506. self.board_cutout_label.setToolTip(
  4507. _("Create toolpaths to cut around\n"
  4508. "the PCB and separate it from\n"
  4509. "the original board.")
  4510. )
  4511. self.layout.addWidget(self.board_cutout_label)
  4512. grid0 = QtWidgets.QGridLayout()
  4513. self.layout.addLayout(grid0)
  4514. tdclabel = QtWidgets.QLabel(_('Tool dia:'))
  4515. tdclabel.setToolTip(
  4516. _( "Diameter of the cutting tool.")
  4517. )
  4518. grid0.addWidget(tdclabel, 0, 0)
  4519. self.cutout_tooldia_entry = LengthEntry()
  4520. grid0.addWidget(self.cutout_tooldia_entry, 0, 1)
  4521. marginlabel = QtWidgets.QLabel(_('Margin:'))
  4522. marginlabel.setToolTip(
  4523. _("Distance from objects at which\n"
  4524. "to draw the cutout.")
  4525. )
  4526. grid0.addWidget(marginlabel, 1, 0)
  4527. self.cutout_margin_entry = LengthEntry()
  4528. grid0.addWidget(self.cutout_margin_entry, 1, 1)
  4529. gaplabel = QtWidgets.QLabel(_('Gap size:'))
  4530. gaplabel.setToolTip(
  4531. _("Size of the gaps in the toolpath\n"
  4532. "that will remain to hold the\n"
  4533. "board in place.")
  4534. )
  4535. grid0.addWidget(gaplabel, 2, 0)
  4536. self.cutout_gap_entry = LengthEntry()
  4537. grid0.addWidget(self.cutout_gap_entry, 2, 1)
  4538. gaps_label = QtWidgets.QLabel(_('Gaps:'))
  4539. gaps_label.setToolTip(
  4540. _("Number of bridge gaps used for the cutout.\n"
  4541. "There can be maximum 8 bridges/gaps.\n"
  4542. "The choices are:\n"
  4543. "- lr - left + right\n"
  4544. "- tb - top + bottom\n"
  4545. "- 4 - left + right +top + bottom\n"
  4546. "- 2lr - 2*left + 2*right\n"
  4547. "- 2tb - 2*top + 2*bottom\n"
  4548. "- 8 - 2*left + 2*right +2*top + 2*bottom")
  4549. )
  4550. grid0.addWidget(gaps_label, 3, 0)
  4551. self.gaps_combo = FCComboBox()
  4552. grid0.addWidget(self.gaps_combo, 3, 1)
  4553. gaps_items = ['LR', 'TB', '4', '2LR', '2TB', '8']
  4554. for it in gaps_items:
  4555. self.gaps_combo.addItem(it)
  4556. self.gaps_combo.setStyleSheet('background-color: rgb(255,255,255)')
  4557. # Surrounding convex box shape
  4558. self.convex_box = FCCheckBox()
  4559. self.convex_box_label = QtWidgets.QLabel(_("Convex Sh.:"))
  4560. self.convex_box_label.setToolTip(
  4561. _("Create a convex shape surrounding the entire PCB.")
  4562. )
  4563. grid0.addWidget(self.convex_box_label, 4, 0)
  4564. grid0.addWidget(self.convex_box, 4, 1)
  4565. self.layout.addStretch()
  4566. class Tools2sidedPrefGroupUI(OptionsGroupUI):
  4567. def __init__(self, parent=None):
  4568. # OptionsGroupUI.__init__(self, "2sided Tool Options", parent=parent)
  4569. super(Tools2sidedPrefGroupUI, self).__init__(self)
  4570. self.setTitle(str(_("2Sided Tool Options")))
  4571. ## Board cuttout
  4572. self.dblsided_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4573. self.dblsided_label.setToolTip(
  4574. _("A tool to help in creating a double sided\n"
  4575. "PCB using alignment holes.")
  4576. )
  4577. self.layout.addWidget(self.dblsided_label)
  4578. grid0 = QtWidgets.QGridLayout()
  4579. self.layout.addLayout(grid0)
  4580. ## Drill diameter for alignment holes
  4581. self.drill_dia_entry = LengthEntry()
  4582. self.dd_label = QtWidgets.QLabel(_("Drill diam.:"))
  4583. self.dd_label.setToolTip(
  4584. _("Diameter of the drill for the "
  4585. "alignment holes.")
  4586. )
  4587. grid0.addWidget(self.dd_label, 0, 0)
  4588. grid0.addWidget(self.drill_dia_entry, 0, 1)
  4589. ## Axis
  4590. self.mirror_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
  4591. {'label': _('Y'), 'value': 'Y'}])
  4592. self.mirax_label = QtWidgets.QLabel(_("Mirror Axis:"))
  4593. self.mirax_label.setToolTip(
  4594. _("Mirror vertically (X) or horizontally (Y).")
  4595. )
  4596. # grid_lay.addRow("Mirror Axis:", self.mirror_axis)
  4597. self.empty_lb1 = QtWidgets.QLabel("")
  4598. grid0.addWidget(self.empty_lb1, 1, 0)
  4599. grid0.addWidget(self.mirax_label, 2, 0)
  4600. grid0.addWidget(self.mirror_axis_radio, 2, 1)
  4601. ## Axis Location
  4602. self.axis_location_radio = RadioSet([{'label': _('Point'), 'value': 'point'},
  4603. {'label': _('Box'), 'value': 'box'}])
  4604. self.axloc_label = QtWidgets.QLabel(_("Axis Ref:"))
  4605. self.axloc_label.setToolTip(
  4606. _("The axis should pass through a <b>point</b> or cut\n "
  4607. "a specified <b>box</b> (in a Geometry object) in \n"
  4608. "the middle.")
  4609. )
  4610. # grid_lay.addRow("Axis Location:", self.axis_location)
  4611. grid0.addWidget(self.axloc_label, 3, 0)
  4612. grid0.addWidget(self.axis_location_radio, 3, 1)
  4613. self.layout.addStretch()
  4614. class ToolsPaintPrefGroupUI(OptionsGroupUI):
  4615. def __init__(self, parent=None):
  4616. # OptionsGroupUI.__init__(self, "Paint Area Tool Options", parent=parent)
  4617. super(ToolsPaintPrefGroupUI, self).__init__(self)
  4618. self.setTitle(str(_("Paint Tool Options")))
  4619. # ------------------------------
  4620. ## Paint area
  4621. # ------------------------------
  4622. self.paint_label = QtWidgets.QLabel(_('<b>Parameters:</b>'))
  4623. self.paint_label.setToolTip(
  4624. _("Creates tool paths to cover the\n"
  4625. "whole area of a polygon (remove\n"
  4626. "all copper). You will be asked\n"
  4627. "to click on the desired polygon.")
  4628. )
  4629. self.layout.addWidget(self.paint_label)
  4630. grid0 = QtWidgets.QGridLayout()
  4631. self.layout.addLayout(grid0)
  4632. # Tool dia
  4633. ptdlabel = QtWidgets.QLabel(_('Tool dia:'))
  4634. ptdlabel.setToolTip(
  4635. _("Diameter of the tool to\n"
  4636. "be used in the operation.")
  4637. )
  4638. grid0.addWidget(ptdlabel, 0, 0)
  4639. self.painttooldia_entry = LengthEntry()
  4640. grid0.addWidget(self.painttooldia_entry, 0, 1)
  4641. # Overlap
  4642. ovlabel = QtWidgets.QLabel(_('Overlap Rate:'))
  4643. ovlabel.setToolTip(
  4644. _("How much (fraction) of the tool\n"
  4645. "width to overlap each tool pass.")
  4646. )
  4647. grid0.addWidget(ovlabel, 1, 0)
  4648. self.paintoverlap_entry = LengthEntry()
  4649. grid0.addWidget(self.paintoverlap_entry, 1, 1)
  4650. # Margin
  4651. marginlabel = QtWidgets.QLabel(_('Margin:'))
  4652. marginlabel.setToolTip(
  4653. _("Distance by which to avoid\n"
  4654. "the edges of the polygon to\n"
  4655. "be painted.")
  4656. )
  4657. grid0.addWidget(marginlabel, 2, 0)
  4658. self.paintmargin_entry = LengthEntry()
  4659. grid0.addWidget(self.paintmargin_entry, 2, 1)
  4660. # Method
  4661. methodlabel = QtWidgets.QLabel(_('Method:'))
  4662. methodlabel.setToolTip(
  4663. _("Algorithm to paint the polygon:<BR>"
  4664. "<B>Standard</B>: Fixed step inwards.<BR>"
  4665. "<B>Seed-based</B>: Outwards from seed.")
  4666. )
  4667. grid0.addWidget(methodlabel, 3, 0)
  4668. self.paintmethod_combo = RadioSet([
  4669. {"label": _("Standard"), "value": "standard"},
  4670. {"label": _("Seed-based"), "value": "seed"},
  4671. {"label": _("Straight lines"), "value": "lines"}
  4672. ], orientation='vertical', stretch=False)
  4673. grid0.addWidget(self.paintmethod_combo, 3, 1)
  4674. # Connect lines
  4675. pathconnectlabel = QtWidgets.QLabel(_("Connect:"))
  4676. pathconnectlabel.setToolTip(
  4677. _("Draw lines between resulting\n"
  4678. "segments to minimize tool lifts.")
  4679. )
  4680. grid0.addWidget(pathconnectlabel, 4, 0)
  4681. self.pathconnect_cb = FCCheckBox()
  4682. grid0.addWidget(self.pathconnect_cb, 4, 1)
  4683. # Paint contour
  4684. contourlabel = QtWidgets.QLabel(_("Contour:"))
  4685. contourlabel.setToolTip(
  4686. _("Cut around the perimeter of the polygon\n"
  4687. "to trim rough edges.")
  4688. )
  4689. grid0.addWidget(contourlabel, 5, 0)
  4690. self.contour_cb = FCCheckBox()
  4691. grid0.addWidget(self.contour_cb, 5, 1)
  4692. # Polygon selection
  4693. selectlabel = QtWidgets.QLabel(_('Selection:'))
  4694. selectlabel.setToolTip(
  4695. _("How to select the polygons to paint.")
  4696. )
  4697. grid0.addWidget(selectlabel, 6, 0)
  4698. self.selectmethod_combo = RadioSet([
  4699. {"label": _("Single"), "value": "single"},
  4700. {"label": _("All"), "value": "all"},
  4701. # {"label": "Rectangle", "value": "rectangle"}
  4702. ])
  4703. grid0.addWidget(self.selectmethod_combo, 6, 1)
  4704. self.layout.addStretch()
  4705. class ToolsFilmPrefGroupUI(OptionsGroupUI):
  4706. def __init__(self, parent=None):
  4707. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  4708. super(ToolsFilmPrefGroupUI, self).__init__(self)
  4709. self.setTitle(str(_("Film Tool Options")))
  4710. ## Board cuttout
  4711. self.film_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4712. self.film_label.setToolTip(
  4713. _("Create a PCB film from a Gerber or Geometry\n"
  4714. "FlatCAM object.\n"
  4715. "The file is saved in SVG format.")
  4716. )
  4717. self.layout.addWidget(self.film_label)
  4718. grid0 = QtWidgets.QGridLayout()
  4719. self.layout.addLayout(grid0)
  4720. self.film_type_radio = RadioSet([{'label': _('Pos'), 'value': 'pos'},
  4721. {'label': _('Neg'), 'value': 'neg'}])
  4722. ftypelbl = QtWidgets.QLabel(_('Film Type:'))
  4723. ftypelbl.setToolTip(
  4724. _("Generate a Positive black film or a Negative film.\n"
  4725. "Positive means that it will print the features\n"
  4726. "with black on a white canvas.\n"
  4727. "Negative means that it will print the features\n"
  4728. "with white on a black canvas.\n"
  4729. "The Film format is SVG.")
  4730. )
  4731. grid0.addWidget(ftypelbl, 0, 0)
  4732. grid0.addWidget(self.film_type_radio, 0, 1)
  4733. self.film_boundary_entry = FCEntry()
  4734. self.film_boundary_label = QtWidgets.QLabel(_("Border:"))
  4735. self.film_boundary_label.setToolTip(
  4736. _("Specify a border around the object.\n"
  4737. "Only for negative film.\n"
  4738. "It helps if we use as a Box Object the same \n"
  4739. "object as in Film Object. It will create a thick\n"
  4740. "black bar around the actual print allowing for a\n"
  4741. "better delimitation of the outline features which are of\n"
  4742. "white color like the rest and which may confound with the\n"
  4743. "surroundings if not for this border.")
  4744. )
  4745. grid0.addWidget(self.film_boundary_label, 1, 0)
  4746. grid0.addWidget(self.film_boundary_entry, 1, 1)
  4747. self.film_scale_entry = FCEntry()
  4748. self.film_scale_label = QtWidgets.QLabel(_("Scale Stroke:"))
  4749. self.film_scale_label.setToolTip(
  4750. _("Scale the line stroke thickness of each feature in the SVG file.\n"
  4751. "It means that the line that envelope each SVG feature will be thicker or thinner,\n"
  4752. "therefore the fine features may be more affected by this parameter.")
  4753. )
  4754. grid0.addWidget(self.film_scale_label, 2, 0)
  4755. grid0.addWidget(self.film_scale_entry, 2, 1)
  4756. self.layout.addStretch()
  4757. class ToolsPanelizePrefGroupUI(OptionsGroupUI):
  4758. def __init__(self, parent=None):
  4759. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  4760. super(ToolsPanelizePrefGroupUI, self).__init__(self)
  4761. self.setTitle(str(_("Panelize Tool Options")))
  4762. ## Board cuttout
  4763. self.panelize_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4764. self.panelize_label.setToolTip(
  4765. _("Create an object that contains an array of (x, y) elements,\n"
  4766. "each element is a copy of the source object spaced\n"
  4767. "at a X distance, Y distance of each other.")
  4768. )
  4769. self.layout.addWidget(self.panelize_label)
  4770. grid0 = QtWidgets.QGridLayout()
  4771. self.layout.addLayout(grid0)
  4772. ## Spacing Columns
  4773. self.pspacing_columns = FCEntry()
  4774. self.spacing_columns_label = QtWidgets.QLabel(_("Spacing cols:"))
  4775. self.spacing_columns_label.setToolTip(
  4776. _("Spacing between columns of the desired panel.\n"
  4777. "In current units.")
  4778. )
  4779. grid0.addWidget(self.spacing_columns_label, 0, 0)
  4780. grid0.addWidget(self.pspacing_columns, 0, 1)
  4781. ## Spacing Rows
  4782. self.pspacing_rows = FCEntry()
  4783. self.spacing_rows_label = QtWidgets.QLabel(_("Spacing rows:"))
  4784. self.spacing_rows_label.setToolTip(
  4785. _("Spacing between rows of the desired panel.\n"
  4786. "In current units.")
  4787. )
  4788. grid0.addWidget(self.spacing_rows_label, 1, 0)
  4789. grid0.addWidget(self.pspacing_rows, 1, 1)
  4790. ## Columns
  4791. self.pcolumns = FCEntry()
  4792. self.columns_label = QtWidgets.QLabel(_("Columns:"))
  4793. self.columns_label.setToolTip(
  4794. _("Number of columns of the desired panel")
  4795. )
  4796. grid0.addWidget(self.columns_label, 2, 0)
  4797. grid0.addWidget(self.pcolumns, 2, 1)
  4798. ## Rows
  4799. self.prows = FCEntry()
  4800. self.rows_label = QtWidgets.QLabel(_("Rows:"))
  4801. self.rows_label.setToolTip(
  4802. _("Number of rows of the desired panel")
  4803. )
  4804. grid0.addWidget(self.rows_label, 3, 0)
  4805. grid0.addWidget(self.prows, 3, 1)
  4806. ## Type of resulting Panel object
  4807. self.panel_type_radio = RadioSet([{'label': _('Gerber'), 'value': 'gerber'},
  4808. {'label': _('Geo'), 'value': 'geometry'}])
  4809. self.panel_type_label = QtWidgets.QLabel(_("Panel Type:"))
  4810. self.panel_type_label.setToolTip(
  4811. _( "Choose the type of object for the panel object:\n"
  4812. "- Gerber\n"
  4813. "- Geometry")
  4814. )
  4815. grid0.addWidget(self.panel_type_label, 4, 0)
  4816. grid0.addWidget(self.panel_type_radio, 4, 1)
  4817. ## Constrains
  4818. self.pconstrain_cb = FCCheckBox(_("Constrain within:"))
  4819. self.pconstrain_cb.setToolTip(
  4820. _("Area define by DX and DY within to constrain the panel.\n"
  4821. "DX and DY values are in current units.\n"
  4822. "Regardless of how many columns and rows are desired,\n"
  4823. "the final panel will have as many columns and rows as\n"
  4824. "they fit completely within selected area.")
  4825. )
  4826. grid0.addWidget(self.pconstrain_cb, 5, 0)
  4827. self.px_width_entry = FCEntry()
  4828. self.x_width_lbl = QtWidgets.QLabel(_("Width (DX):"))
  4829. self.x_width_lbl.setToolTip(
  4830. _("The width (DX) within which the panel must fit.\n"
  4831. "In current units.")
  4832. )
  4833. grid0.addWidget(self.x_width_lbl, 6, 0)
  4834. grid0.addWidget(self.px_width_entry, 6, 1)
  4835. self.py_height_entry = FCEntry()
  4836. self.y_height_lbl = QtWidgets.QLabel(_("Height (DY):"))
  4837. self.y_height_lbl.setToolTip(
  4838. _("The height (DY)within which the panel must fit.\n"
  4839. "In current units.")
  4840. )
  4841. grid0.addWidget(self.y_height_lbl, 7, 0)
  4842. grid0.addWidget(self.py_height_entry, 7, 1)
  4843. self.layout.addStretch()
  4844. class ToolsCalculatorsPrefGroupUI(OptionsGroupUI):
  4845. def __init__(self, parent=None):
  4846. # OptionsGroupUI.__init__(self, "Calculators Tool Options", parent=parent)
  4847. super(ToolsCalculatorsPrefGroupUI, self).__init__(self)
  4848. self.setTitle(str(_("Calculators Tool Options")))
  4849. ## V-shape Calculator Tool
  4850. self.vshape_tool_label = QtWidgets.QLabel(_("<b>V-Shape Tool Calculator:</b>"))
  4851. self.vshape_tool_label.setToolTip(
  4852. _("Calculate the tool diameter for a given V-shape tool,\n"
  4853. "having the tip diameter, tip angle and\n"
  4854. "depth-of-cut as parameters.")
  4855. )
  4856. self.layout.addWidget(self.vshape_tool_label)
  4857. grid0 = QtWidgets.QGridLayout()
  4858. self.layout.addLayout(grid0)
  4859. ## Tip Diameter
  4860. self.tip_dia_entry = FCEntry()
  4861. self.tip_dia_label = QtWidgets.QLabel(_("Tip Diameter:"))
  4862. self.tip_dia_label.setToolTip(
  4863. _("This is the tool tip diameter.\n"
  4864. "It is specified by manufacturer.")
  4865. )
  4866. grid0.addWidget(self.tip_dia_label, 0, 0)
  4867. grid0.addWidget(self.tip_dia_entry, 0, 1)
  4868. ## Tip angle
  4869. self.tip_angle_entry = FCEntry()
  4870. self.tip_angle_label = QtWidgets.QLabel(_("Tip angle:"))
  4871. self.tip_angle_label.setToolTip(
  4872. _("This is the angle on the tip of the tool.\n"
  4873. "It is specified by manufacturer.")
  4874. )
  4875. grid0.addWidget(self.tip_angle_label, 1, 0)
  4876. grid0.addWidget(self.tip_angle_entry, 1, 1)
  4877. ## Depth-of-cut Cut Z
  4878. self.cut_z_entry = FCEntry()
  4879. self.cut_z_label = QtWidgets.QLabel(_("Cut Z:"))
  4880. self.cut_z_label.setToolTip(
  4881. _("This is depth to cut into material.\n"
  4882. "In the CNCJob object it is the CutZ parameter.")
  4883. )
  4884. grid0.addWidget(self.cut_z_label, 2, 0)
  4885. grid0.addWidget(self.cut_z_entry, 2, 1)
  4886. ## Electroplating Calculator Tool
  4887. self.plate_title_label = QtWidgets.QLabel(_("<b>ElectroPlating Calculator:</b>"))
  4888. self.plate_title_label.setToolTip(
  4889. _("This calculator is useful for those who plate the via/pad/drill holes,\n"
  4890. "using a method like grahite ink or calcium hypophosphite ink or palladium chloride.")
  4891. )
  4892. self.layout.addWidget(self.plate_title_label)
  4893. grid1 = QtWidgets.QGridLayout()
  4894. self.layout.addLayout(grid1)
  4895. ## PCB Length
  4896. self.pcblength_entry = FCEntry()
  4897. self.pcblengthlabel = QtWidgets.QLabel(_("Board Length:"))
  4898. self.pcblengthlabel.setToolTip(_('This is the board length. In centimeters.'))
  4899. grid1.addWidget(self.pcblengthlabel, 0, 0)
  4900. grid1.addWidget(self.pcblength_entry, 0, 1)
  4901. ## PCB Width
  4902. self.pcbwidth_entry = FCEntry()
  4903. self.pcbwidthlabel = QtWidgets.QLabel(_("Board Width:"))
  4904. self.pcbwidthlabel.setToolTip(_('This is the board width.In centimeters.'))
  4905. grid1.addWidget(self.pcbwidthlabel, 1, 0)
  4906. grid1.addWidget(self.pcbwidth_entry, 1, 1)
  4907. ## Current Density
  4908. self.cdensity_label = QtWidgets.QLabel(_("Current Density:"))
  4909. self.cdensity_entry = FCEntry()
  4910. self.cdensity_label.setToolTip(_("Current density to pass through the board. \n"
  4911. "In Amps per Square Feet ASF."))
  4912. grid1.addWidget(self.cdensity_label, 2, 0)
  4913. grid1.addWidget(self.cdensity_entry, 2, 1)
  4914. ## PCB Copper Growth
  4915. self.growth_label = QtWidgets.QLabel(_("Copper Growth:"))
  4916. self.growth_entry = FCEntry()
  4917. self.growth_label.setToolTip(_("How thick the copper growth is intended to be.\n"
  4918. "In microns."))
  4919. grid1.addWidget(self.growth_label, 3, 0)
  4920. grid1.addWidget(self.growth_entry, 3, 1)
  4921. self.layout.addStretch()
  4922. class ToolsTransformPrefGroupUI(OptionsGroupUI):
  4923. def __init__(self, parent=None):
  4924. super(ToolsTransformPrefGroupUI, self).__init__(self)
  4925. self.setTitle(str(_("Transform Tool Options")))
  4926. ## Transformations
  4927. self.transform_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4928. self.transform_label.setToolTip(
  4929. _("Various transformations that can be applied\n"
  4930. "on a FlatCAM object.")
  4931. )
  4932. self.layout.addWidget(self.transform_label)
  4933. grid0 = QtWidgets.QGridLayout()
  4934. self.layout.addLayout(grid0)
  4935. ## Rotate Angle
  4936. self.rotate_entry = FCEntry()
  4937. self.rotate_label = QtWidgets.QLabel(_("Rotate Angle:"))
  4938. self.rotate_label.setToolTip(
  4939. _("Angle for rotation. In degrees.")
  4940. )
  4941. grid0.addWidget(self.rotate_label, 0, 0)
  4942. grid0.addWidget(self.rotate_entry, 0, 1)
  4943. ## Skew/Shear Angle on X axis
  4944. self.skewx_entry = FCEntry()
  4945. self.skewx_label = QtWidgets.QLabel(_("Skew_X angle:"))
  4946. self.skewx_label.setToolTip(
  4947. _("Angle for Skew/Shear on X axis. In degrees.")
  4948. )
  4949. grid0.addWidget(self.skewx_label, 1, 0)
  4950. grid0.addWidget(self.skewx_entry, 1, 1)
  4951. ## Skew/Shear Angle on Y axis
  4952. self.skewy_entry = FCEntry()
  4953. self.skewy_label = QtWidgets.QLabel(_("Skew_Y angle:"))
  4954. self.skewy_label.setToolTip(
  4955. _("Angle for Skew/Shear on Y axis. In degrees.")
  4956. )
  4957. grid0.addWidget(self.skewy_label, 2, 0)
  4958. grid0.addWidget(self.skewy_entry, 2, 1)
  4959. ## Scale factor on X axis
  4960. self.scalex_entry = FCEntry()
  4961. self.scalex_label = QtWidgets.QLabel(_("Scale_X factor:"))
  4962. self.scalex_label.setToolTip(
  4963. _("Factor for scaling on X axis.")
  4964. )
  4965. grid0.addWidget(self.scalex_label, 3, 0)
  4966. grid0.addWidget(self.scalex_entry, 3, 1)
  4967. ## Scale factor on X axis
  4968. self.scaley_entry = FCEntry()
  4969. self.scaley_label = QtWidgets.QLabel(_("Scale_Y factor:"))
  4970. self.scaley_label.setToolTip(
  4971. _("Factor for scaling on Y axis.")
  4972. )
  4973. grid0.addWidget(self.scaley_label, 4, 0)
  4974. grid0.addWidget(self.scaley_entry, 4, 1)
  4975. ## Link Scale factors
  4976. self.link_cb = FCCheckBox(_("Link"))
  4977. self.link_cb.setToolTip(
  4978. _("Scale the selected object(s)\n"
  4979. "using the Scale_X factor for both axis.")
  4980. )
  4981. grid0.addWidget(self.link_cb, 5, 0)
  4982. ## Scale Reference
  4983. self.reference_cb = FCCheckBox(_("Scale Reference"))
  4984. self.reference_cb.setToolTip(
  4985. _("Scale the selected object(s)\n"
  4986. "using the origin reference when checked,\n"
  4987. "and the center of the biggest bounding box\n"
  4988. "of the selected objects when unchecked.")
  4989. )
  4990. grid0.addWidget(self.reference_cb, 5, 1)
  4991. ## Offset distance on X axis
  4992. self.offx_entry = FCEntry()
  4993. self.offx_label = QtWidgets.QLabel(_("Offset_X val:"))
  4994. self.offx_label.setToolTip(
  4995. _( "Distance to offset on X axis. In current units.")
  4996. )
  4997. grid0.addWidget(self.offx_label, 6, 0)
  4998. grid0.addWidget(self.offx_entry, 6, 1)
  4999. ## Offset distance on Y axis
  5000. self.offy_entry = FCEntry()
  5001. self.offy_label = QtWidgets.QLabel(_("Offset_Y val:"))
  5002. self.offy_label.setToolTip(
  5003. _("Distance to offset on Y axis. In current units.")
  5004. )
  5005. grid0.addWidget(self.offy_label, 7, 0)
  5006. grid0.addWidget(self.offy_entry, 7, 1)
  5007. ## Mirror (Flip) Reference Point
  5008. self.mirror_reference_cb = FCCheckBox(_("Mirror Reference"))
  5009. self.mirror_reference_cb.setToolTip(
  5010. _("Flip the selected object(s)\n"
  5011. "around the point in Point Entry Field.\n"
  5012. "\n"
  5013. "The point coordinates can be captured by\n"
  5014. "left click on canvas together with pressing\n"
  5015. "SHIFT key. \n"
  5016. "Then click Add button to insert coordinates.\n"
  5017. "Or enter the coords in format (x, y) in the\n"
  5018. "Point Entry field and click Flip on X(Y)"))
  5019. grid0.addWidget(self.mirror_reference_cb, 8, 1)
  5020. self.flip_ref_label = QtWidgets.QLabel(_(" Mirror Ref. Point:"))
  5021. self.flip_ref_label.setToolTip(
  5022. _("Coordinates in format (x, y) used as reference for mirroring.\n"
  5023. "The 'x' in (x, y) will be used when using Flip on X and\n"
  5024. "the 'y' in (x, y) will be used when using Flip on Y and")
  5025. )
  5026. self.flip_ref_entry = EvalEntry2("(0, 0)")
  5027. grid0.addWidget(self.flip_ref_label, 9, 0)
  5028. grid0.addWidget(self.flip_ref_entry, 9, 1)
  5029. self.layout.addStretch()
  5030. class ToolsSolderpastePrefGroupUI(OptionsGroupUI):
  5031. def __init__(self, parent=None):
  5032. super(ToolsSolderpastePrefGroupUI, self).__init__(self)
  5033. self.setTitle(str(_("SolderPaste Tool Options")))
  5034. ## Solder Paste Dispensing
  5035. self.solderpastelabel = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  5036. self.solderpastelabel.setToolTip(
  5037. _("A tool to create GCode for dispensing\n"
  5038. "solder paste onto a PCB.")
  5039. )
  5040. self.layout.addWidget(self.solderpastelabel)
  5041. grid0 = QtWidgets.QGridLayout()
  5042. self.layout.addLayout(grid0)
  5043. # Nozzle Tool Diameters
  5044. nozzletdlabel = QtWidgets.QLabel(_('Tools dia:'))
  5045. nozzletdlabel.setToolTip(
  5046. _("Diameters of nozzle tools, separated by ','")
  5047. )
  5048. self.nozzle_tool_dia_entry = FCEntry()
  5049. grid0.addWidget(nozzletdlabel, 0, 0)
  5050. grid0.addWidget(self.nozzle_tool_dia_entry, 0, 1)
  5051. # New Nozzle Tool Dia
  5052. self.addtool_entry_lbl = QtWidgets.QLabel(_('<b>New Nozzle Dia:</b>'))
  5053. self.addtool_entry_lbl.setToolTip(
  5054. _("Diameter for the new Nozzle tool to add in the Tool Table")
  5055. )
  5056. self.addtool_entry = FCEntry()
  5057. grid0.addWidget(self.addtool_entry_lbl, 1, 0)
  5058. grid0.addWidget(self.addtool_entry, 1, 1)
  5059. # Z dispense start
  5060. self.z_start_entry = FCEntry()
  5061. self.z_start_label = QtWidgets.QLabel(_("Z Dispense Start:"))
  5062. self.z_start_label.setToolTip(
  5063. _("The height (Z) when solder paste dispensing starts.")
  5064. )
  5065. grid0.addWidget(self.z_start_label, 2, 0)
  5066. grid0.addWidget(self.z_start_entry, 2, 1)
  5067. # Z dispense
  5068. self.z_dispense_entry = FCEntry()
  5069. self.z_dispense_label = QtWidgets.QLabel(_("Z Dispense:"))
  5070. self.z_dispense_label.setToolTip(
  5071. _("The height (Z) when doing solder paste dispensing.")
  5072. )
  5073. grid0.addWidget(self.z_dispense_label, 3, 0)
  5074. grid0.addWidget(self.z_dispense_entry, 3, 1)
  5075. # Z dispense stop
  5076. self.z_stop_entry = FCEntry()
  5077. self.z_stop_label = QtWidgets.QLabel(_("Z Dispense Stop:"))
  5078. self.z_stop_label.setToolTip(
  5079. _("The height (Z) when solder paste dispensing stops.")
  5080. )
  5081. grid0.addWidget(self.z_stop_label, 4, 0)
  5082. grid0.addWidget(self.z_stop_entry, 4, 1)
  5083. # Z travel
  5084. self.z_travel_entry = FCEntry()
  5085. self.z_travel_label = QtWidgets.QLabel(_("Z Travel:"))
  5086. self.z_travel_label.setToolTip(
  5087. _("The height (Z) for travel between pads\n"
  5088. "(without dispensing solder paste).")
  5089. )
  5090. grid0.addWidget(self.z_travel_label, 5, 0)
  5091. grid0.addWidget(self.z_travel_entry, 5, 1)
  5092. # Z toolchange location
  5093. self.z_toolchange_entry = FCEntry()
  5094. self.z_toolchange_label = QtWidgets.QLabel(_("Z Toolchange:"))
  5095. self.z_toolchange_label.setToolTip(
  5096. _("The height (Z) for tool (nozzle) change.")
  5097. )
  5098. grid0.addWidget(self.z_toolchange_label, 6, 0)
  5099. grid0.addWidget(self.z_toolchange_entry, 6, 1)
  5100. # X,Y Toolchange location
  5101. self.xy_toolchange_entry = FCEntry()
  5102. self.xy_toolchange_label = QtWidgets.QLabel(_("XY Toolchange:"))
  5103. self.xy_toolchange_label.setToolTip(
  5104. _("The X,Y location for tool (nozzle) change.\n"
  5105. "The format is (x, y) where x and y are real numbers.")
  5106. )
  5107. grid0.addWidget(self.xy_toolchange_label, 7, 0)
  5108. grid0.addWidget(self.xy_toolchange_entry, 7, 1)
  5109. # Feedrate X-Y
  5110. self.frxy_entry = FCEntry()
  5111. self.frxy_label = QtWidgets.QLabel(_("Feedrate X-Y:"))
  5112. self.frxy_label.setToolTip(
  5113. _("Feedrate (speed) while moving on the X-Y plane.")
  5114. )
  5115. grid0.addWidget(self.frxy_label, 8, 0)
  5116. grid0.addWidget(self.frxy_entry, 8, 1)
  5117. # Feedrate Z
  5118. self.frz_entry = FCEntry()
  5119. self.frz_label = QtWidgets.QLabel(_("Feedrate Z:"))
  5120. self.frz_label.setToolTip(
  5121. _("Feedrate (speed) while moving vertically\n"
  5122. "(on Z plane).")
  5123. )
  5124. grid0.addWidget(self.frz_label, 9, 0)
  5125. grid0.addWidget(self.frz_entry, 9, 1)
  5126. # Feedrate Z Dispense
  5127. self.frz_dispense_entry = FCEntry()
  5128. self.frz_dispense_label = QtWidgets.QLabel(_("Feedrate Z Dispense:"))
  5129. self.frz_dispense_label.setToolTip(
  5130. _("Feedrate (speed) while moving up vertically\n"
  5131. " to Dispense position (on Z plane).")
  5132. )
  5133. grid0.addWidget(self.frz_dispense_label, 10, 0)
  5134. grid0.addWidget(self.frz_dispense_entry, 10, 1)
  5135. # Spindle Speed Forward
  5136. self.speedfwd_entry = FCEntry()
  5137. self.speedfwd_label = QtWidgets.QLabel(_("Spindle Speed FWD:"))
  5138. self.speedfwd_label.setToolTip(
  5139. _("The dispenser speed while pushing solder paste\n"
  5140. "through the dispenser nozzle.")
  5141. )
  5142. grid0.addWidget(self.speedfwd_label, 11, 0)
  5143. grid0.addWidget(self.speedfwd_entry, 11, 1)
  5144. # Dwell Forward
  5145. self.dwellfwd_entry = FCEntry()
  5146. self.dwellfwd_label = QtWidgets.QLabel(_("Dwell FWD:"))
  5147. self.dwellfwd_label.setToolTip(
  5148. _("Pause after solder dispensing.")
  5149. )
  5150. grid0.addWidget(self.dwellfwd_label, 12, 0)
  5151. grid0.addWidget(self.dwellfwd_entry, 12, 1)
  5152. # Spindle Speed Reverse
  5153. self.speedrev_entry = FCEntry()
  5154. self.speedrev_label = QtWidgets.QLabel(_("Spindle Speed REV:"))
  5155. self.speedrev_label.setToolTip(
  5156. _("The dispenser speed while retracting solder paste\n"
  5157. "through the dispenser nozzle.")
  5158. )
  5159. grid0.addWidget(self.speedrev_label, 13, 0)
  5160. grid0.addWidget(self.speedrev_entry, 13, 1)
  5161. # Dwell Reverse
  5162. self.dwellrev_entry = FCEntry()
  5163. self.dwellrev_label = QtWidgets.QLabel(_("Dwell REV:"))
  5164. self.dwellrev_label.setToolTip(
  5165. _("Pause after solder paste dispenser retracted,\n"
  5166. "to allow pressure equilibrium.")
  5167. )
  5168. grid0.addWidget(self.dwellrev_label, 14, 0)
  5169. grid0.addWidget(self.dwellrev_entry, 14, 1)
  5170. # Postprocessors
  5171. pp_label = QtWidgets.QLabel(_('PostProcessors:'))
  5172. pp_label.setToolTip(
  5173. _("Files that control the GCode generation.")
  5174. )
  5175. self.pp_combo = FCComboBox()
  5176. grid0.addWidget(pp_label, 15, 0)
  5177. grid0.addWidget(self.pp_combo, 15, 1)
  5178. self.layout.addStretch()
  5179. class FlatCAMActivityView(QtWidgets.QWidget):
  5180. def __init__(self, parent=None):
  5181. super().__init__(parent=parent)
  5182. self.setMinimumWidth(200)
  5183. self.icon = QtWidgets.QLabel(self)
  5184. self.icon.setGeometry(0, 0, 16, 12)
  5185. self.movie = QtGui.QMovie("share/active.gif")
  5186. self.icon.setMovie(self.movie)
  5187. # self.movie.start()
  5188. layout = QtWidgets.QHBoxLayout()
  5189. layout.setContentsMargins(5, 0, 5, 0)
  5190. layout.setAlignment(QtCore.Qt.AlignLeft)
  5191. self.setLayout(layout)
  5192. layout.addWidget(self.icon)
  5193. self.text = QtWidgets.QLabel(self)
  5194. self.text.setText(_("Idle."))
  5195. layout.addWidget(self.text)
  5196. def set_idle(self):
  5197. self.movie.stop()
  5198. self.text.setText(_("Idle."))
  5199. def set_busy(self, msg):
  5200. self.movie.start()
  5201. self.text.setText(msg)
  5202. class FlatCAMInfoBar(QtWidgets.QWidget):
  5203. def __init__(self, parent=None):
  5204. super(FlatCAMInfoBar, self).__init__(parent=parent)
  5205. self.icon = QtWidgets.QLabel(self)
  5206. self.icon.setGeometry(0, 0, 12, 12)
  5207. self.pmap = QtGui.QPixmap('share/graylight12.png')
  5208. self.icon.setPixmap(self.pmap)
  5209. layout = QtWidgets.QHBoxLayout()
  5210. layout.setContentsMargins(5, 0, 5, 0)
  5211. self.setLayout(layout)
  5212. layout.addWidget(self.icon)
  5213. self.text = QtWidgets.QLabel(self)
  5214. self.text.setText(_("Application started ..."))
  5215. self.text.setToolTip(_("Hello!"))
  5216. layout.addWidget(self.text)
  5217. layout.addStretch()
  5218. def set_text_(self, text, color=None):
  5219. self.text.setText(text)
  5220. self.text.setToolTip(text)
  5221. if color:
  5222. self.text.setStyleSheet('color: %s' % str(color))
  5223. def set_status(self, text, level="info"):
  5224. level = str(level)
  5225. self.pmap.fill()
  5226. if level == "ERROR" or level == "ERROR_NOTCL":
  5227. self.pmap = QtGui.QPixmap('share/redlight12.png')
  5228. elif level == "success" or level == "SUCCESS":
  5229. self.pmap = QtGui.QPixmap('share/greenlight12.png')
  5230. elif level == "WARNING" or level == "WARNING_NOTCL":
  5231. self.pmap = QtGui.QPixmap('share/yellowlight12.png')
  5232. elif level == "selected" or level == "SELECTED":
  5233. self.pmap = QtGui.QPixmap('share/bluelight12.png')
  5234. else:
  5235. self.pmap = QtGui.QPixmap('share/graylight12.png')
  5236. self.set_text_(text)
  5237. self.icon.setPixmap(self.pmap)
  5238. # end of file