FlatCAMGUI.py 212 KB

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