skeinforge_tools.analyze_plugins.behold ($Date: 2008/21/04 $)
index
/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/analyze_plugins/behold.py

Behold is an analysis script to display a gcode file in an isometric view.

The default 'Activate Behold' checkbox is on. When it is on, the functions described below will work when called from the skeinforge toolchain, when it is off, the functions will not be called from the toolchain. The functions will still be called, whether or not the 'Activate Behold' checkbox is on, when behold is run directly. Behold can not separate the layers when it reads gcode without comments.

The viewer is simple, the viewpoint can only be moved in a sphere around the center of the model by changing the viewpoint latitude and longitude. Different regions of the model can be hidden by setting the width of the thread to zero. The alternating bands act as contour bands and their brightness and width can be changed. The layers will be displayed starting at the "Layer From" index up until the "Layer To" index. All of the preferences can be set in the initial "Behold Preferences" window and some can be changed after the viewer is running in the "Behold Dynamic Preferences" window. In the viewer, dragging the mouse will change the viewpoint.

The "Band Height" is height of the band in layers, with the default of five, a pair of bands is ten layers high. The "Bottom Band Brightness" is the ratio of the brightness of the bottom band over the brightness of the top band, the default is 0.7. The "Bottom Layer Brightness" is the ratio of the brightness of the bottom layer over the brightness of the top layer, the default is 1.0. With a low bottom layer brightness ratio the bottom of the model will be darker than the top of the model, as if it was being illuminated by a light just above the top. The "Bright Band Start" button group determines where the bright band starts from. If the "From the Bottom" choice is selected, the bright bands will start from the bottom. If the default "From the Top" choice is selected, the bright bands will start from the top.

If "Draw Arrows" is selected, arrows will be drawn at the end of each line segment, the default is on. If "Go Around Extruder Off Travel" is selected, the display will include the travel when the extruder is off, which means it will include the nozzle wipe path if any.

When the export menu item in the file menu is clicked, the canvas will be saved as a postscript file. If the 'Export Postscript Program' is set to a program name, the postscript file will be sent to that program to be opened. The default is gimp, the Gnu Image Manipulation Program (Gimp), which is open source, can open postscript and save in a variety of formats. It is available at:
http://www.gimp.org/

If the 'Export File Extension' is set to a file extension, the postscript file will be sent to the program, along with the file extension for the converted output. The default is blank because some systems do not have an image conversion program; if you have or will install an image conversion program, a common 'Export File Extension' is png. A good open source conversion program is Image Magick, which is available at:
http://www.imagemagick.org/script/index.php

The "Layer From" is the index of the bottom layer that will be displayed. If the layer from is the default zero, the display will start from the lowest layer. If the the layer from index is negative, then the display will start from the layer from index below the top layer. The "Layer To" is the index of the top layer that will be displayed. If the layer to index is a huge number like the default 999999999, the display will go to the top of the model, at least until we model habitats:) If the layer to index is negative, then the display will go to the layer to index below the top layer. The layer from until layer to index is a python slice.

The "Number of Fill Bottom Layers" is the number of layers at the bottom which will be colored olive. The "Number of Fill Bottom Layers" is the number of layers at the top which will be colored blue.

The "Pixels over Extrusion Width" preference is the scale of the image, the higher the number, the greater the size of the display. The "Screen Horizontal Inset" determines how much the display will be inset in the horizontal direction from the edge of screen, the higher the number the more it will be inset and the smaller it will be, the default is one hundred. The "Screen Vertical Inset" determines how much the display will be inset in the vertical direction from the edge of screen, the default is fifty.

The "Viewpoint Latitude" is the latitude of the viewpoint, the default is 15 degrees. The "Viewpoint Longitude" is the longitude of the viewpoint, the default is 210 degrees. The viewpoint can also be moved by dragging the mouse. The viewpoint latitude will be increased when the mouse is dragged from the center towards the edge. The viewpoint longitude will be changed by the amount around the center the mouse is dragged. This is not very intuitive, but I don't know how to do this the intuitive way and I have other stuff to develop. If the shift key is pressed; if the latitude is changed more than the longitude, only the latitude will be changed, if the longitude is changed more only the longitude will be changed.

The "Width of Extrusion Thread" sets the width of the green extrusion threads, those threads which are not loops and not part of the raft. The default is one, if the width is zero the extrusion threads will be invisible. The "Width of Fill Bottom Thread" sets the width of the olive extrusion threads at the bottom of the model, the default is three. The "Width of Fill Top Thread" sets the width of the blue extrusion threads at the top of the model, the default is three. The "Width of Loop Thread" sets the width of the yellow loop threads, which are not perimeters, the default is three. The "Width of Perimeter Inside Thread" sets the width of the orange inside perimeter threads, the default is three. The "Width of Perimeter Outside Thread" sets the width of the red outside perimeter threads, the default is three. The "Width of Raft Thread" sets the width of the brown raft threads, the default is one. The "Width of Travel Thread" sets the width of the gray extruder off travel threads, the default is zero.

The "Width of X Axis" preference sets the width of the dark orange X Axis, the default is five pixels. The "Width of Y Axis" sets the width of the gold Y Axis, the default is five. The "Width of Z Axis" sets the width of the sky blue Z Axis, the default is five.

To run behold, in a shell in the folder which behold is in type:
> python behold.py

An explanation of the gcodes is at:
http://reprap.org/bin/view/Main/Arduino_GCode_Interpreter

and at:
http://reprap.org/bin/view/Main/MCodeReference

A gode example is at:
http://forums.reprap.org/file.php?12,file=565

This example lets the viewer behold the gcode file Screw Holder.gcode. This example is run in a terminal in the folder which contains Screw Holder.gcode and behold.py.


> python behold.py
This brings up the behold dialog.


> python behold.py Screw Holder.gcode
This brings up the behold dialog to view the gcode file.


> python
Python 2.5.1 (r251:54863, Sep 22 2007, 01:43:31)
[GCC 4.2.1 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import behold
>>> behold.main()
This brings up the behold dialog.


>>> behold.beholdFile()
This brings up the behold window to view the gcode file.

 
Modules
       
__init__
skeinforge_tools.analyze_plugins.analyze_utilities.display_line
skeinforge_tools.skeinforge_utilities.euclidean
skeinforge_tools.skeinforge_utilities.gcodec
math
skeinforge_tools.meta_plugins.polyfile
skeinforge_tools.skeinforge_utilities.preferences
sys
skeinforge_tools.analyze_plugins.analyze_utilities.tableau
skeinforge_tools.analyze_plugins.analyze_utilities.viewpoint_move
skeinforge_tools.analyze_plugins.analyze_utilities.viewpoint_rotate

 
Classes
       
skeinforge_tools.analyze_plugins.analyze_utilities.tableau.TableauRepository
BeholdPreferences
skeinforge_tools.analyze_plugins.analyze_utilities.tableau.TableauWindow
SkeinWindow
BeholdSkein
ColoredLine
SkeinPane

 
class BeholdPreferences(skeinforge_tools.analyze_plugins.analyze_utilities.tableau.TableauRepository)
    A class to handle the behold preferences.
 
  Methods defined here:
__init__(self)
Set the default preferences, execute title & preferences fileName.
execute(self)
Write button has been clicked.

Methods inherited from skeinforge_tools.analyze_plugins.analyze_utilities.tableau.TableauRepository:
setToDisplaySave(self, event=None)
Set the preference values to the display, save the new values.
setToDisplaySavePhoenixUpdate(self, event=None)
Set the preference values to the display, save the new values, then call the update function.
setToDisplaySaveUpdate(self, event=None)
Set the preference values to the display, save the new values, then call the update function.

 
class BeholdSkein
    A class to write a get a scalable vector graphics text for a gcode skein.
 
  Methods defined here:
__init__(self)
addToPath(self, line, location)
Add a point to travel and maybe extrusion.
getLayerTop(self)
Get the layer top.
getLayerZoneIndex(self, z)
Get the layer zone index.
initializeActiveLocation(self)
Set variables to default.
isLayerStart(self, firstWord, splitLine)
Parse a gcode line and add it to the vector output.
linearCorner(self, splitLine)
Update the bounding corners.
linearMove(self, line, splitLine)
Get statistics for a linear move.
moveColoredThreadToSkeinPane(self)
Move a colored thread to the skein pane.
parseCorner(self, line)
Parse a gcode line and use the location to update the bounding corners.
parseGcode(self, fileName, gcodeText, beholdPreferences)
Parse gcode text and store the vector output.
parseLine(self, line)
Parse a gcode line and add it to the vector output.
setColoredLineColor(self, coloredLine, colorTuple)
Set the color and stipple of the colored line.
setColoredThread(self, colorTuple, lineList)
Set the colored thread, then move it to the line list and stipple of the colored line.

 
class ColoredLine
    A colored line.
 
  Methods defined here:
__init__(self, begin, colorName, end, tagString)
Set the color name and corners.
__repr__(self)
Get the string representation of this colored line.

 
class SkeinPane
    A class to hold the colored lines for a layer.
 
  Methods defined here:
__init__(self, sequenceIndex)
Create empty line lists.

 
class SkeinWindow(skeinforge_tools.analyze_plugins.analyze_utilities.tableau.TableauWindow)
     Methods defined here:
__init__(self, tableauRepository, skein)
Initialize the skein window.
drawColoredLine(self, arrowType, coloredLine, viewVectors, width)
Draw colored line.
drawColoredLineMotion(self, coloredLine, viewVectors, width)
Draw colored line with motion stipple and tag.
drawColoredLines(self, coloredLines, viewVectors, width)
Draw colored lines.
drawSkeinPane(self, skeinPane, viewVectors)
Draw colored lines.
drawXYAxisLines(self, viewVectors)
Draw the x and y axis lines.
drawZAxisLine(self, viewVectors)
Draw the z axis line.
getCentered(self, coordinate)
Get the centered coordinate.
getCenteredScreened(self, coordinate)
Get the normalized centered coordinate.
getScreenComplex(self, pointComplex)
Get the point in screen perspective.
getViewComplex(self, point, viewVectors)
Get the point in view perspective.
phoenixUpdate(self)
Update, and deiconify a new window and destroy the old.
printHexadecimalColorName(self, name)
Print the color name in hexadecimal.
update(self)
Update the screen.

Methods inherited from skeinforge_tools.analyze_plugins.analyze_utilities.tableau.TableauWindow:
button1(self, event)
The button was clicked.
buttonRelease1(self, event)
The button was released.
centerUpdateSetWindowGeometryShowPreferences(self, center)
Center the scroll region, update, set the window geometry, and show the preferences.
destroyAllDialogWindows(self)
Destroy all the dialog windows.
export(self)
Export the canvas as a postscript file.
getScrollPaneCenter(self)
Get the center of the scroll pane.
motion(self, event)
The mouse moved.
relayXview(self, *args)
Relay xview changes.
relayYview(self, *args)
Relay yview changes.
save(self)
Set the preference values to the display, save the new values.
saveUpdate(self)
Save and update.
setMenuPanesPreferencesRootSkein(self, skein, suffix, tableauRepository)
Set the menu bar, skein panes, tableau preferences, root and skein.
setMouseTool(self)
Set the mouse tool.
setMouseToolBindButtonMotion(self)
Set the mouse tool and bind button one clicked, button one released and motion.
shiftButtonRelease1(self, event)
The button was released while the shift key was pressed.
shiftMotion(self, event)
The mouse moved.
updateDeiconify(self, center=(0.5+0.5j))
Update and deiconify the window.

 
Functions
       
beholdFile(fileName='')
Behold a gcode file.  If no fileName is specified, behold the first gcode file in this folder that is not modified.
compareLayerSequence(first, second)
Get comparison in order to sort skein panes in ascending order of layer zone index then sequence index.
displayFileGivenText(fileName, gcodeText, beholdPreferences=None)
Display a beholded gcode file for a gcode file.
getPolygonComplexFromColoredLines(coloredLines)
Get a complex polygon from the colored lines.
getRepositoryConstructor()
Get the repository constructor.
getTwoHex(number)
Get the first two hexadecimal digits.
getWindowGivenTextPreferences(fileName, gcodeText, beholdPreferences)
Display the gcode text in a behold viewer.
main()
Display the behold dialog.
writeOutput(fileName, gcodeText='')
Write a beholded gcode file for a skeinforge gcode file, if 'Activate Behold' is selected.

 
Data
        __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
__date__ = '$Date: 2008/21/04 $'
__license__ = 'GPL 3.0'
absolute_import = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)

 
Author
        Enrique Perez (perez_enrique@yahoo.com)