FlatCAMGUI.py 145 KB

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