FlatCAMGUI.py 244 KB

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