FlatCAMGUI.py 274 KB

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