FlatCAMGUI.py 198 KB

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