FlatCAMGUI.py 162 KB

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