Package: tcllib, Version: CVS HEAD

NAME

Diagrams -
User documentation of the Diagrams package

SYNOPSIS

package require Tcl 8.4
package require Tk 8.4
package require Diagrams 0.3
::Diagrams::drawin canvas
::Diagrams::saveps filename
::Diagrams::direction newdir
::Diagrams::currentpos pos
::Diagrams::getpos anchor obj
::Diagrams::position xcoord ycoord
::Diagrams::box text width height
::Diagrams::plaintext text width height
::Diagrams::circle text radius
::Diagrams::slanted text width height angle
::Diagrams::diamond text width height
::Diagrams::drum text width height
::Diagrams::arrow text length heads
::Diagrams::line args
::Diagrams::bracket dir dist begin end
::Diagrams::attach anchor
::Diagrams::color name
::Diagrams::fillcolor name
::Diagrams::textcolor name
::Diagrams::usegap use
::Diagrams::xgap value
::Diagrams::ygap value
::Diagrams::textfont name
::Diagrams::linewidth pixels
::Diagrams::linestyle style
::Diagrams::pushstate 
::Diagrams::popstate 
::Diagrams::computepos 
::Diagrams::boxcoords x1 y1 x2 y2
::Diagrams::moveobject obj

DESCRIPTION

The Diagrams package is meant to help drawing diagrams, like flowcharts. The philosophy is that you should be concentrating on the contents of the diagram, rather than the exact positioning and sizing of all items within it. The Diagrams package uses a few simple rules to layout the items:

The commands within this package can be split up in several categories. Each category is described in a separate section.

GENERAL COMMANDS FOR POSITIONING AND SETUP

::Diagrams::drawin canvas
Set the canvas widget in which to draw
TypeNameMode
widgetcanvas
  Widget to draw in

::Diagrams::saveps filename
Save the drawing in a PostScript file
TypeNameMode
filenamestring
  Name of the file to save the drawing in

::Diagrams::direction newdir
Set the direction for moving the current position. The direction is one of: north northeast east southeast south southwest west northwest N NE E SE S SW W NW up up-right left down-right down down-left left up-left centre center C
TypeNameMode
newdirstring
  New direction

::Diagrams::currentpos pos
Set the current position explicitly (argument must be a position "object")
TypeNameMode
poslist
  New position (retrieve via getpos for instance)

::Diagrams::getpos anchor obj
Get the position of a particular "anchor" point of an object anchor should be one of the direction strings
TypeNameMode
anchorstring
  Name of the anchor (one of the directions - see the direction command
objlist
  The object in question

::Diagrams::position xcoord ycoord
Create a position "object"
TypeNameMode
xcoordfloat
  X-coordinate of the position
ycoordfloat
  Y-coordinate of the position

DRAWING OBJECTS

::Diagrams::box text width height
Draw a box from the current position (width and height are both optional; if not given, the text determines the width and height)
TypeNameMode
stringtext
  Text to be shown inside the box
floatwidth
  Width (if any) of the box in pixels
floatheight
  Height (if any) of the box in pixels

::Diagrams::plaintext text width height
Draw plain text from the current position (width and height are both optional; if not given, the text determines the width and height)
TypeNameMode
stringtext
  Text to be shown
floatwidth
  Width (if any) of the (invisible) box in which to position the text
floatheight
  Height (if any) of the box

::Diagrams::circle text radius
Draw a circle from the current position (the radius is optional)
TypeNameMode
stringtext
  Text to be shown inside the circle
floatradius
  Radius (if any) of the circle in pixels

::Diagrams::slanted text width height angle
Draw a slanted box from the current position (width, height and angle are optional)
TypeNameMode
stringtext
  Text to be shown inside the box
floatwidth
  Width (if any) of the box in pixels
floatheight
  Height (if any) of the box in pixels
floatangle
  Angle of the slanted box

::Diagrams::diamond text width height
Draw a diamond-shaped box from the current position (width and height are both optional; if not given, the text determines the width and height)
TypeNameMode
stringtext
  Text to be shown inside the diamond
floatwidth
  Width (if any) of the diamond in pixels
floatheight
  Height (if any) of the diamond in pixels

::Diagrams::drum text width height
Draw a drumshaped item from th ecurrent position (width and height are both optional; if not given, the text determines the width and height)
TypeNameMode
stringtext
  Text to be shown inside the drum
floatwidth
  Width (if any) of the drum in pixels
floatheight
  Height (if any) of the drum in pixels

::Diagrams::arrow text length heads
Draw an arrow from the current position to the next. The text is drawn next to the arrow, the length (in pixels) is optional. If not given the gap parameters are used.
TypeNameMode
stringtext
  Text to be shown along the arrow
floatlength
  Length of the arrow in pixels
floatheads
  Which arrow heads to draw (first, last or both - defaults to last)

::Diagrams::line args
Draw a line specified via positions or via line segments The arguments are either position or length-angle pairs
TypeNameMode
listargs
  List of positions or of length-angle pairs

::Diagrams::bracket dir dist begin end
Draw an arrow consisting of three lines from one item to another. The first argument gives the direction in which the arrow "bulges" away from the items, the second argument gives the distance over which it bulges.
TypeNameMode
stringdir
  Direction of "bulging" - one of north, south, east or west.
floatdist
  Length of the two end pieces of the arrow
listbegin
  Description of the item where the arrow begins as (returned by one of the item creation procedures, box, circle ...)
listend
  Ditto for the item where the arrow points to

ATTRIBUTES

(Note: attributes are persistent)
::Diagrams::attach anchor
Set the anchor point for attaching arrows to
TypeNameMode
stringanchor
  Any one of the valid anchor (e.g. N or North)

::Diagrams::color name
Set the color for the outline of a box etc.
TypeNameMode
colorname
  Name of the colour to be used

::Diagrams::fillcolor name
Set the color to fill the objects
TypeNameMode
colorname
  Name of the colour to be used

::Diagrams::textcolor name
Set the color to draw the text in
TypeNameMode
colorname
  Name of the colour to be used

::Diagrams::usegap use
Turn the gap on (1) or off (0). Note: usually a small gap is used when positioning objects.
TypeNameMode
booleanuse
  Use the gap to compute the position of the next object or not

::Diagrams::xgap value
Size of the gap in horizontal direction (in pixels)
TypeNameMode
integervalue
  Gap width in pixels

::Diagrams::ygap value
Size of the gap in vertical direction (in pixels)
TypeNameMode
integervalue
  Gap height in pixels

::Diagrams::textfont name
Set the name of the font to use
TypeNameMode
stringname
  Name of a text font

::Diagrams::linewidth pixels
Set the width of the lines (in line objects and arrows and the outline of boxes and other objects)
TypeNameMode
integerpixels
  Number of pixels the lines are wide

::Diagrams::linestyle style
Set the style of the lines and arrows and of the outline of boxes and other objects. The predefined line styles are: solid, dot, dash, dash-dot, dash-dot-dot (these are the distinguishable line styles on Windows). You can also use the style patterns from the canvas directly.
TypeNameMode
stringstyle
  Name of a valid line style

COMMANDS FOR IMPLEMENTING NEW OBJECTS

Note: it is best to study how for instance box objects are implemented first.
::Diagrams::pushstate
Save the current global settings Used when defining an object that is composed of other objects
::Diagrams::popstate
Restore the previously saved global settings
::Diagrams::computepos
Compute the current position
::Diagrams::boxcoords x1 y1 x2 y2
Compute the anchor coordinates for a box-like object (this is merely a convenience routine. In general, you will have to compute the list of coordinates yourself - see for instance the diamond object)
TypeNameMode
floatx1
  X coordinate of upper-left corner
floaty1
  Y coordinate of upper-left corner
floatx2
  X coordinate of lower-right corner
floaty2
  Y coordinate of lower-right corner

::Diagrams::moveobject obj
Move the object to the right position and return the new information
TypeNameMode
listobj
  List of data representing the object

KEYWORDS

diagrams, drawing