PageRenderTime 51ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Program_Files/replicatorg-0025/skein_engines/skeinforge-35/skeinforge_application/skeinforge.py

https://github.com/sialan/autonomous-sprayer
Python | 582 lines | 522 code | 26 blank | 34 comment | 24 complexity | bc66bda995c32da60bd44d79161ecc62 MD5 | raw file
  1. #!/usr/bin/python
  2. """
  3. This page is in the table of contents.
  4. ==Overview==
  5. ===Introduction===
  6. Skeinforge is a GPL tool chain to forge a gcode skein for a model.
  7. The tool chain starts with carve, which carves the model into layers, then the layers are modified by other tools in turn like fill, comb, tower, raft, stretch, hop, wipe, fillet & export. Each tool automatically gets the gcode from the previous tool. So if you want a carved & filled gcode, call the fill tool and it will call carve, then it will fill and output the gcode. If you want to use all the tools, call export and it will call in turn all the other tools down the chain to produce the gcode file.
  8. If you do not want a tool after preface to modify the output, deselect the Activate checkbox for that tool. When the Activate checkbox is off, the tool will just hand off the gcode to the next tool without modifying it.
  9. The skeinforge module provides a single place to call up all the setting dialogs. When the 'Skeinforge' button is clicked, skeinforge calls export, since that is the end of the chain.
  10. The plugin buttons which are commonly used are bolded and the ones which are rarely used have normal font weight.
  11. There are also tools which handle settings for the chain, like polyfile.
  12. The analyze tool calls plugins in the analyze_plugins folder, which will analyze the gcode in some way when it is generated if their Activate checkbox is selected.
  13. The interpret tool accesses and displays the import plugins.
  14. The default settings are similar to those on Nophead's machine. A setting which is often different is the 'Layer Thickness' in carve.
  15. ===Alternative===
  16. Another way to make gcode for a model is to use the Java RepRap host program, described at:
  17. http://reprap.org/wiki/Installing_RepRap_on_your_computer
  18. ===Contribute===
  19. You can contribute by helping develop the manual at:
  20. http://www.bitsfrombytes.com/wiki/index.php?title=Skeinforge
  21. There is also a forum thread about how to contribute to skeinforge development at:
  22. http://dev.forums.reprap.org/read.php?12,27562
  23. I will only reply to emails from contributors or to complete bug reports.
  24. ===Documentation===
  25. There is a manual at:
  26. http://www.bitsfrombytes.com/wiki/index.php?title=Skeinforge
  27. There is also documentation is in the documentation folder, in the doc strings for each module and it can be called from the '?' button or the menu or by clicking F1 in each setting dialog.
  28. A list of other tutorials is at:
  29. http://www.bitsfrombytes.com/wiki/index.php?title=Skeinforge#Tutorials
  30. ===Fabrication===
  31. To fabricate a model with gcode and the Arduino you can use the send.py in the fabricate folder. The documentation for it is in the folder as send.html and at:
  32. http://reprap.org/bin/view/Main/ArduinoSend
  33. Another way is to use an EMC2 or similar computer controlled milling machine, as described in the "ECM2 based repstrap" forum thread at:
  34. http://forums.reprap.org/read.php?1,12143
  35. using the M-Apps package, which is at:
  36. http://forums.reprap.org/file.php?1,file=772
  37. Another way is to use Zach's ReplicatorG at:
  38. http://replicat.org/
  39. There is also an older Processing script at:
  40. http://reprap.svn.sourceforge.net/viewvc/reprap/trunk/users/hoeken/arduino/GCode_Host/
  41. Yet another way is to use the reprap host, written in Java, to load and print gcode:
  42. http://dev.www.reprap.org/bin/view/Main/DriverSoftware#Load_GCode
  43. For jogging, the Metalab group wrote their own exerciser, also in Processing:
  44. http://reprap.svn.sourceforge.net/viewvc/reprap/trunk/users/metalab/processing/GCode_Exerciser/
  45. The Metalab group has descriptions of skeinforge in action and their adventures are described at:
  46. http://reprap.soup.io/
  47. There is a board about printing issues at:
  48. http://www.bitsfrombytes.com/fora/user/index.php?board=5.0
  49. You can buy the Rapman (an improved Darwin) from Bits from Bytes at:
  50. http://www.bitsfrombytes.com/
  51. You can buy the Makerbot from Makerbot Industries at:
  52. http://www.makerbot.com/
  53. ===File Formats===
  54. An explanation of the gcodes is at:
  55. http://reprap.org/bin/view/Main/Arduino_GCode_Interpreter
  56. and at:
  57. http://reprap.org/bin/view/Main/MCodeReference
  58. A gode example is at:
  59. http://forums.reprap.org/file.php?12,file=565
  60. The settings are saved as tab separated .csv files in the .skeinforge folder in your home directory. The settings can be set in the tool dialogs. The .csv files can also be edited with a text editor or a spreadsheet program set to separate tabs.
  61. The Scalable Vector Graphics file produced by vectorwrite can be opened by an SVG viewer or an SVG capable browser like Mozilla:
  62. http://www.mozilla.com/firefox/
  63. A good triangle surface format is the GNU Triangulated Surface format, which is supported by Mesh Viewer and described at:
  64. http://gts.sourceforge.net/reference/gts-surfaces.html#GTS-SURFACE-WRITE
  65. You can export GTS files from Art of Illusion with the Export GNU Triangulated Surface.bsh script in the Art of Illusion Scripts folder.
  66. STL is an inferior triangle surface format, described at:
  67. http://en.wikipedia.org/wiki/STL_(file_format)
  68. If you're using an STL file and you can't even carve it, try converting it to a GNU Triangulated Surface file in Art of Illusion. If it still doesn't carve, then follow the advice in the troubleshooting section.
  69. ===Getting Skeinforge===
  70. The latest version is at:
  71. http://members.axion.net/~enrique/reprap_python_beanshell.zip
  72. a sometimes out of date version is in the last reprap_python_beanshell.zip attachment in the last post of the Fabmetheus blog at:
  73. http://fabmetheus.blogspot.com/
  74. another sometimes out of date version is at:
  75. https://reprap.svn.sourceforge.net/svnroot/reprap/trunk/reprap/miscellaneous/python-beanshell-scripts/
  76. ===Getting Started===
  77. For skeinforge to run, install python 2.x on your machine, which is available from:
  78. http://www.python.org/download/
  79. To use the settings dialog you'll also need Tkinter, which probably came with the python installation. If it did not, look for it at:
  80. http://www.tcl.tk/software/tcltk/
  81. If you want python and Tkinter together on MacOS, you can try:
  82. http://www.astro.washington.edu/users/rowen/ROPackage/Overview.html
  83. If you want python and Tkinter together on all platforms and don't mind filling out forms, you can try the ActivePython package from Active State at:
  84. http://www.activestate.com/Products/activepython/feature_list.mhtml
  85. The computation intensive python modules will use psyco if it is available and run about twice as fast. Psyco is described at:
  86. http://psyco.sourceforge.net/index.html
  87. The psyco download page is:
  88. http://psyco.sourceforge.net/download.html
  89. Skeinforge imports Stereolithography (.stl) files or GNU Triangulated Surface (.gts) files. If importing an STL file directly doesn't work, an indirect way to import an STL file is by turning it into a GTS file is by using the Export GNU Triangulated Surface script at:
  90. http://members.axion.net/~enrique/Export%20GNU%20Triangulated%20Surface.bsh
  91. The Export GNU Triangulated Surface script is also in the Art of Illusion folder, which is in the same folder as skeinforge.py. To bring the script into Art of Illusion, drop it into the folder ArtOfIllusion/Scripts/Tools/. Then import the STL file using the STL import plugin in the import submenu of the Art of Illusion file menu. Then from the Scripts submenu in the Tools menu, choose 'Export GNU Triangulated Surface' and select the imported STL shape. Click the 'Export Selected' checkbox and click OK. Once you've created the GTS file, you can turn it into gcode by typing in a shell in the same folder as skeinforge:
  92. > python skeinforge.py
  93. When the skeinforge dialog pops up, click 'Skeinforge', choose the file which you exported in 'Export GNU Triangulated Surface' and the gcode file will be saved with the suffix '_export.gcode'.
  94. Or you can turn files into gcode by adding the file name, for example:
  95. > python skeinforge.py Screw Holder Bottom.stl
  96. ===Motto===
  97. I may be slow, but I get there in the end.
  98. ===Troubleshooting===
  99. If there's a bug, try downloading the very latest version because skeinforge is often updated without an announcement.
  100. If there is still a bug, then first prepare the following files:
  101. 1. stl file
  102. 2. pictures explaining the problem
  103. 3. your settings (pack the whole .skeinforge directory with all your settings)
  104. Then zip all the files.
  105. Second, write a description of the error, send the description and the archive to the developer, enrique ( perez_enrique AT yahoo.com.removethispart ). After a bug fix is released, test the new version and report the results to enrique, whether the fix was successful or not.
  106. If the dialog window is too big for the screen, on most Linux window managers you can move a window by holding down the Alt key and then drag the window with the left mouse button to get to the off screen widgets.
  107. If you can't use the graphical interface, you can change the settings for skeinforge by using a text editor or spreadsheet to change the settings in the profiles folder in the .skeinforge folder in your home directory.
  108. Comments and suggestions are welcome, however, I won't reply unless you are a contributor because developing takes all my time and as of the time of this writing I have at least three years of features to implement.
  109. I will only answer your questions if you contribute to skeinforge in some way. Some ways of contributing to skeinforge are in the contributions thread at:
  110. http://dev.forums.reprap.org/read.php?12,27562
  111. I reserve the right to make any correspondence public. Do not send me any correspondence marked confidential. If you do I will delete it.
  112. ==Examples==
  113. The following examples forge the STL file Screw Holder.stl. The examples are run in a terminal in the folder which contains Screw Holder.gts and skeinforge.py.
  114. > python skeinforge.py
  115. This brings up the dialog, after clicking 'Skeinforge', the following is printed:
  116. The exported file is saved as Screw Holder_export.gcode
  117. > python skeinforge.py Screw Holder.stl
  118. The exported file is saved as Screw Holder_export.gcode
  119. > python
  120. Python 2.5.1 (r251:54863, Sep 22 2007, 01:43:31)
  121. [GCC 4.2.1 (SUSE Linux)] on linux2
  122. Type "help", "copyright", "credits" or "license" for more information.
  123. >>> import skeinforge
  124. >>> skeinforge.writeOutput('Screw Holder.stl')
  125. The exported file is saved as Screw Holder_export.gcode
  126. >>> skeinforge.main()
  127. This brings up the skeinforge dialog.
  128. To run only fill for example, type in the skeinforge_plugins folder which fill is in:
  129. > python fill.py
  130. """
  131. from __future__ import absolute_import
  132. import __init__
  133. from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret
  134. from fabmetheus_utilities import archive
  135. from fabmetheus_utilities import euclidean
  136. from fabmetheus_utilities import gcodec
  137. from fabmetheus_utilities import settings
  138. from fabmetheus_utilities import archive
  139. from skeinforge_application.skeinforge_utilities import skeinforge_craft
  140. from skeinforge_application.skeinforge_utilities import skeinforge_polyfile
  141. from skeinforge_application.skeinforge_utilities import skeinforge_profile
  142. from optparse import OptionParser
  143. import os
  144. import sys
  145. # scale xy z
  146. # iso svg
  147. # set derivations to lathe form
  148. # gear separated diagonally, center distance
  149. # linear bearing
  150. # mirror axis center & origin, concatenate
  151. # matrixTetragrid to tetragrid, matrix.transform, target
  152. # maybe matrix array form a00 a01.. also
  153. # matrix rotate around axis http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations
  154. # lathe, transform normal in getRemaining, getConnection
  155. # grate separate
  156. # xml_creation
  157. # class, pymethe
  158. # fill rename shortenedSegmentList gridSegmentList and delete comments
  159. # array paths, follow paths, later maybe targetequation radius xyz give index
  160. # writeTagged, tags, creationTags, writeMatrix='true'
  161. # connectionfrom, to, connect, xaxis
  162. # add overview link to crnsdoo index and svg page
  163. # bound.bottom to cube, sphere, cylinder input, maybe mesh., bound.bottom & left & right & top for xy plane
  164. # look over copy module, make copy solid like copy lineation
  165. # document gear script
  166. # stretch add back addAlong
  167. #
  168. # maybe in svgReader if loop intersection with previous union else add
  169. #
  170. # unimportant
  171. # minor outline problem when an end path goes through a path, like in the letter A
  172. # view profile 1 mm thickness
  173. # svg inskcape layer label, import into inskscape in general
  174. # only parse svg once, do not parse again if yAxisPointingUpward="true"
  175. #
  176. # close, getPillarByLoopLists, addConcave, polymorph original graph section, loop, add step object, add continuous object
  177. # del previous, add begin & end if far get actual path
  178. # polling
  179. # getNormal, getIsFlat?
  180. # write svg for visible paths???
  181. # combine xmlelement with csvelement using example.csv & geometry.csv, csv _format, _column, _row, _text
  182. # getConnection of some kind like getConnectionVertexes, getConnection
  183. # import module, overwriteRoot
  184. # pixel, voxel, surfaxel/boxel, lattice, mesh
  185. # probably not replace getOverlapRatio with getOverlap if getOverlapRatio is never small, always 0.0
  186. # probably not speed up CircleIntersection by performing isWithinCircles before creation
  187. # equation for vertexes if not already
  188. # mesh. for cube, then cyliner, then sphere after lathe
  189. # probably not move alterations and profiles
  190. # tube
  191. # rotor
  192. # test translate
  193. # lathe
  194. # think about setActualMinimumZ in boolean_geometry
  195. # pyramid
  196. # round extrusion ?, fillet
  197. # manipulate solid, maybe manipulate around elements
  198. # hollow top
  199. # boolean loop corner outset
  200. # dovetail
  201. # creationID, addObject, getTarget, copyXMLElement?
  202. # maybe not getNewObject, getNew, addToBoolean
  203. # work out close and radius
  204. # maybe try to get rid of comment if possible
  205. # voronoi average location intersection looped inset intercircles
  206. # maybe move and give geometryOutput to cube, cylinder, sphere
  207. #
  208. # comb -> maybe add back running jump look at outside loops only for jump, find closest points, find slightly away inside points, link
  209. # global simplify pathBetween
  210. # comb documentation
  211. #
  212. # maybe move widen before bottom
  213. # maybe save all generated_files option
  214. # maybe meta overhang
  215. # convert global repository settings to local settings
  216. # table to dictionary
  217. # check for last existing then remove unneeded fill code (getLastExistingFillLoops) from euclidean
  218. # remove cool set at end of layer
  219. # add fan on when hot in chamber
  220. # maybe measuring rod
  221. # remove comments from clip, bend
  222. # winding into coiling, coil into wind & weave
  223. # later, precision
  224. # documentation
  225. # http://wiki.makerbot.com/configuring-skeinforge
  226. #
  227. #
  228. # add hook _extrusion
  229. # implement acceleration & collinear removal in penultimate viewers _extrusion
  230. # integral thin width _extrusion
  231. # layer color, for multilayer start http://reprap.org/pub/Main/MultipleMaterialsFiles/legend.xml _extrusion
  232. # maybe double height shells option _extrusion
  233. # raft triple layer base, middle interface with hot loop or ties
  234. # somehow, add pattern to outside, http://blog.makerbot.com/2010/09/03/lampshades/
  235. #
  236. # arch, ceiling
  237. # add polish, has perimeter, has cut first layer (False)
  238. # probably not set addedLocation in distanceFeedRate after arc move
  239. # maybe horizontal bridging and/or check to see if the ends are standing on anything
  240. # thin self? check when removing intersecting paths in inset
  241. # maybe later remove isPerimeterPathInSurroundLoops, once there are no weird fill bugs, also change getHorizontalSegmentListsFromLoopLists
  242. # save all analyze viewers of the same name except itself, update help menu self.wikiManualPrimary.setUpdateFunction
  243. # check alterations folder first, if there is something copy it to the home directory, if not check the home directory
  244. # set temperature in temperature
  245. # move alterations and profiles to top level
  246. #
  247. #
  248. #
  249. # help primary menu item refresh
  250. # add plugin help menu, add craft below menu
  251. # give option of saving when switching profiles
  252. # xml & svg more forgiving, svg make defaults for layerThickness, maxZ, minZ, add layer z to svg_template, make the slider on the template track even when mouse is outside
  253. # option of surrounding lines in display
  254. # maybe add connecting line in display line
  255. # maybe check inset loops to see if they are smaller, but this would be slow
  256. # maybe status bar
  257. # maybe measurement ruler mouse tool
  258. # search rss from blogs, add search links for common materials, combine created on or progress bar with searchable help
  259. # boundaries, center radius z bottom top, circular or rectangular, polygon, put cool minimum radius orbits within boundaries
  260. # move & rotate model
  261. # possible jitter bug http://cpwebste.blogspot.com/2010/04/hydras-first-print.html
  262. # trial, meta in a grid settings
  263. # maybe svg slice format
  264. # maybe interpret svg_convex_mesh
  265. #laminate tool head
  266. #maybe use 5x5 radius search in circle node
  267. #maybe add layer updates in behold, skeinlayer and maybe others
  268. #lathe winding, extrusion and cutting; synonym for rotation or turning, loop angle
  269. # maybe split into source code and documentation sections
  270. # transform plugins, start with sarrus http://www.thingiverse.com/thing:1425
  271. # maybe make setting backups
  272. # maybe settings in gcode or saved versions
  273. # move skeinforge_utilities to fabmetheus_utilities
  274. # maybe lathe cutting
  275. # maybe lathe extrusion
  276. # maybe lathe millng
  277. # maybe lathe winding & weaving
  278. #
  279. #
  280. #
  281. # pick and place
  282. # search items, search links, choice entry field
  283. # svg triangle mesh, svg polygon mesh
  284. # simulate
  285. #transform
  286. #extrude loops I guess make circles? and/or run along sparse infill
  287. #custom inclined plane, inclined plane from model, screw, fillet travel as well maybe
  288. # probably not stretch single isLoop
  289. #maybe much afterwards make congajure multistep view
  290. #maybe stripe although model colors alone can handle it
  291. #stretch fiber around shape, maybe modify winding for asymmetric shapes
  292. #multiple heads around edge
  293. #maybe add full underscored date name for version
  294. #maybe add rarely used tool option
  295. #angle shape for overhang extrusions
  296. #maybe m111? countdown
  297. #common tool
  298. #first time tool tip
  299. #individual tool tip to place in text
  300. # maybe try to simplify raft layer start
  301. # maybe make temp directory
  302. # maybe carve aoi xml testing and check xml gcode
  303. # maybe cross hatch support polishing???
  304. # maybe print svg view from current layer or zero layer in single view
  305. # maybe check if tower is picking the nearest island
  306. # maybe combine skein classes in fillet
  307. # maybe isometric svg option
  308. #Manual
  309. #10,990
  310. #11,1776,786
  311. #12,3304,1528
  312. #1,4960,1656
  313. #2, 7077,2117
  314. #3, 9598,2521
  315. #4 12014,2305
  316. #5 14319,2536
  317. #6 16855,3226
  318. #7 20081, 2189
  319. #8 22270, 2625
  320. #9 24895, 2967, 98
  321. #10 27862, 3433, 110
  322. #11 31295
  323. #85 jan7, 86jan11, 87 jan13, 88 jan15, 91 jan21, 92 jan23, 95 jan30, 98 feb6
  324. #make one piece electromagnet spool
  325. #stepper rotor with ceramic disk magnet in middle, electromagnet with long thin spool line?
  326. #stepper motor
  327. #make plastic coated thread in vat with pulley
  328. #tensile stuart platform
  329. #kayak
  330. #gear vacuum pump
  331. #gear turbine
  332. #heat engine
  333. #solar power
  334. #sailboat
  335. #yacht
  336. #house
  337. #condo with reflected gardens in between buildings
  338. #medical equipment
  339. #cell counter, etc..
  340. #pipe clamp lathe
  341. # square tube driller & cutter
  342. # archihedrongagglevoteindexium
  343. # outline images
  344. # look from top of intersection circle plane to look for next, add a node; tree out until all are stepped on then connect, when more than three intersections are close
  345. # when loading a file, we should have a preview of the part and orientation in space
  346. # second (and most important in my opinion) would be the ability to rotate the part on X/Y/Z axis to chose it's orientation
  347. # third, a routine to detect the largest face and orient the part accordingly. Mat http://reprap.kumy.net/
  348. # concept, three perpendicular slices to get display spheres
  349. # extend lines around short segment after cross hatched boolean
  350. # concept, teslocracy or citizendium; donation, postponement, rotate ad network, cached search options
  351. # concept, local ad server, every time the program runs it changes the iamge which all the documentation points to from a pool of ads
  352. # concept, join cross slices, go from vertex to two orthogonal edges, then from edges to each other, if not to a common point, then simplify polygons by removing points which do not change the area much
  353. # concept, each node is fourfold, use sorted intersectionindexes to find close, connect each double sided edge, don't overlap more than two triangles on an edge
  354. # concept, diamond cross section loops
  355. # concept, in file, store polygon mesh and centers
  356. # concept, display spheres or polygons would have original triangle for work plane
  357. # .. then again no point with slices
  358. # concept, filled slices, about 2 mm thick
  359. # concept, rgb color triangle switch to get inside color, color golden ratio on 5:11 slope with a modulo 3 face
  360. # concept, interlaced bricks at corners ( length proportional to corner angle )
  361. # concept, new links to archi, import links to archi and adds skeinforge tool menu item, back on skeinforge named execute tool is added
  362. # concept, trnsnt
  363. # concept, indexium expand condense remove, single text, pymetheus
  364. # concept, inscribed key silencer
  365. # concept, spreadsheet to python and/or javascript
  366. # concept, blog, frequent updates, mix associated news
  367. # concept, range voting for posters, informative, complainer, funny, insightful, rude, spammer, literacy, troll?
  368. # concept, intermittent cloud with multiple hash functions
  369. # concept, demodiu xml articles
  370. __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
  371. __credits__ = """
  372. Adrian Bowyer <http://forums.reprap.org/profile.php?12,13>
  373. Brendan Erwin <http://forums.reprap.org/profile.php?12,217>
  374. Greenarrow <http://forums.reprap.org/profile.php?12,81>
  375. Ian England <http://forums.reprap.org/profile.php?12,192>
  376. John Gilmore <http://forums.reprap.org/profile.php?12,364>
  377. Jonwise <http://forums.reprap.org/profile.php?12,716>
  378. Kyle Corbitt <http://forums.reprap.org/profile.php?12,90>
  379. Michael Duffin <http://forums.reprap.org/profile.php?12,930>
  380. Marius Kintel <http://reprap.soup.io/>
  381. Nophead <http://www.blogger.com/profile/12801535866788103677>
  382. PJR <http://forums.reprap.org/profile.php?12,757>
  383. Reece.Arnott <http://forums.reprap.org/profile.php?12,152>
  384. Wade <http://forums.reprap.org/profile.php?12,489>
  385. Xsainnz <http://forums.reprap.org/profile.php?12,563>
  386. Zach Hoeken <http://blog.zachhoeken.com/>
  387. Organizations:
  388. Art of Illusion <http://www.artofillusion.org/>"""
  389. __date__ = "$Date: 2008/21/11 $"
  390. __license__ = 'GPL 3.0'
  391. def addToProfileMenu( profileSelection, profileType, repository ):
  392. "Add a profile menu."
  393. pluginFileNames = skeinforge_profile.getPluginFileNames()
  394. craftTypeName = skeinforge_profile.getCraftTypeName()
  395. pluginModule = skeinforge_profile.getCraftTypePluginModule()
  396. profilePluginSettings = settings.getReadRepository( pluginModule.getNewRepository() )
  397. for pluginFileName in pluginFileNames:
  398. skeinforge_profile.ProfileTypeMenuRadio().getFromMenuButtonDisplay( profileType, pluginFileName, repository, craftTypeName == pluginFileName )
  399. for profileName in profilePluginSettings.profileList.value:
  400. skeinforge_profile.ProfileSelectionMenuRadio().getFromMenuButtonDisplay( profileSelection, profileName, repository, profileName == profilePluginSettings.profileListbox.value )
  401. def getPluginsDirectoryPath():
  402. "Get the plugins directory path."
  403. return archive.getAbsoluteFrozenFolderPath( __file__, 'skeinforge_plugins')
  404. def getPluginFileNames():
  405. "Get analyze plugin fileNames."
  406. return archive.getPluginFileNamesFromDirectoryPath( getPluginsDirectoryPath() )
  407. def getNewRepository():
  408. "Get the repository constructor."
  409. return SkeinforgeRepository()
  410. def getRadioPluginsAddPluginGroupFrame( directoryPath, importantFileNames, names, repository ):
  411. "Get the radio plugins and add the plugin frame."
  412. repository.pluginGroupFrame = settings.PluginGroupFrame()
  413. radioPlugins = []
  414. for name in names:
  415. radioPlugin = settings.RadioPlugin().getFromRadio( name in importantFileNames, repository.pluginGroupFrame.latentStringVar, name, repository, name == importantFileNames[0] )
  416. radioPlugin.updateFunction = repository.pluginGroupFrame.update
  417. radioPlugins.append( radioPlugin )
  418. defaultRadioButton = settings.getSelectedRadioPlugin( importantFileNames + [ radioPlugins[0].name ], radioPlugins )
  419. repository.pluginGroupFrame.getFromPath( defaultRadioButton, directoryPath, repository )
  420. return radioPlugins
  421. def writeOutput(fileName):
  422. "Craft a gcode file."
  423. skeinforge_craft.writeOutput(fileName)
  424. class SkeinforgeRepository:
  425. "A class to handle the skeinforge settings."
  426. def __init__(self):
  427. "Set the default settings, execute title & settings fileName."
  428. settings.addListsToRepository('skeinforge_application.skeinforge.html', None, self )
  429. self.fileNameInput = settings.FileNameInput().getFromFileName( fabmetheus_interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File for Skeinforge', self, '')
  430. self.profileType = settings.MenuButtonDisplay().getFromName('Profile Type: ', self )
  431. self.profileSelection = settings.MenuButtonDisplay().getFromName('Profile Selection: ', self )
  432. addToProfileMenu( self.profileSelection, self.profileType, self )
  433. settings.LabelDisplay().getFromName('Search:', self )
  434. reprapSearch = settings.HelpPage().getFromNameAfterHTTP('members.axion.net/~enrique/search_reprap.html', 'Reprap', self )
  435. skeinforgeSearch = settings.HelpPage().getFromNameAfterHTTP('members.axion.net/~enrique/search_skeinforge.html', 'Skeinforge', self )
  436. skeinforgeSearch.column += 2
  437. webSearch = settings.HelpPage().getFromNameAfterHTTP('members.axion.net/~enrique/search_web.html', 'Web', self )
  438. webSearch.column += 4
  439. versionText = archive.getFileText( archive.getVersionFileName() )
  440. self.version = settings.LabelDisplay().getFromName('Version: ' + versionText, self )
  441. settings.LabelDisplay().getFromName('', self )
  442. importantFileNames = ['craft', 'profile']
  443. getRadioPluginsAddPluginGroupFrame( getPluginsDirectoryPath(), importantFileNames, getPluginFileNames(), self )
  444. self.executeTitle = 'Skeinforge'
  445. def execute(self):
  446. "Skeinforge button has been clicked."
  447. fileNames = skeinforge_polyfile.getFileOrDirectoryTypesUnmodifiedGcode(self.fileNameInput.value, fabmetheus_interpret.getImportPluginFileNames(), self.fileNameInput.wasCancelled)
  448. for fileName in fileNames:
  449. writeOutput(fileName)
  450. def save(self):
  451. "Profile has been saved and profile menu should be updated."
  452. self.profileType.removeMenus()
  453. self.profileSelection.removeMenus()
  454. addToProfileMenu( self.profileSelection, self.profileType, self )
  455. self.profileType.addRadiosToDialog( self.repositoryDialog )
  456. self.profileSelection.addRadiosToDialog( self.repositoryDialog )
  457. def main():
  458. "Display the skeinforge dialog."
  459. parser = OptionParser()
  460. parser.add_option("-p", "--prefdir", help="set path to preference directory",
  461. action="store", type="string", dest="preferencesDirectory")
  462. parser.add_option("-s", "--start", help="set start file to use",
  463. action="store", type="string", dest="startFile")
  464. parser.add_option("-e", "--end", help="set end file to use",
  465. action="store", type="string", dest="endFile")
  466. parser.add_option("-o", "--option",
  467. help='set an individual option in the format "module:preference=value"',
  468. action="append", type="string", dest="preferences")
  469. (options, args) = parser.parse_args()
  470. defaultStart = 'start.txt'
  471. defaultEnd = 'end.txt'
  472. if options.preferencesDirectory:
  473. pdir = options.preferencesDirectory;
  474. archive.setSettingsPath(pdir)
  475. if options.preferences:
  476. for prefSpec in options.preferences:
  477. (moduleName,prefSpec) = prefSpec.split(":",1)
  478. (prefName,valueName) = prefSpec.split("=",1)
  479. settings.addPreferenceOverride(moduleName,prefName,valueName)
  480. sys.argv = [sys.argv[0]] + args
  481. if len( args ) > 0:
  482. writeOutput( ' '.join(args) )
  483. else:
  484. settings.startMainLoopFromConstructor( getNewRepository() )
  485. if __name__ == "__main__":
  486. main()