FlatCAMGUI.py 220 KB

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