FlatCAMGUI.py 183 KB

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