FlatCAMGUI.py 286 KB

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