FlatCAMGUI.py 231 KB

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