FlatCAMGUI.py 190 KB

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