FlatCAMGUI.py 191 KB

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