FlatCAMGUI.py 262 KB

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