FlatCAMGUI.py 266 KB

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