1Diagrams(n)                       Tk Diagrams                      Diagrams(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       Diagrams - User documentation of the Diagrams package
9

SYNOPSIS

11       package require Tcl  8.4
12
13       package require Tk  8.4
14
15       package require Diagrams  0.2
16
17       ::Diagrams::drawin canvas
18
19       ::Diagrams::saveps filename
20
21       ::Diagrams::direction newdir
22
23       ::Diagrams::currentpos pos
24
25       ::Diagrams::getpos anchor obj
26
27       ::Diagrams::position xcoord ycoord
28
29       ::Diagrams::box text width height
30
31       ::Diagrams::plaintext text width height
32
33       ::Diagrams::circle text radius
34
35       ::Diagrams::slanted text width height angle
36
37       ::Diagrams::diamond text width height
38
39       ::Diagrams::drum text width height
40
41       ::Diagrams::arrow text length heads
42
43       ::Diagrams::line args
44
45       ::Diagrams::attach anchor
46
47       ::Diagrams::color name
48
49       ::Diagrams::fillcolor name
50
51       ::Diagrams::textcolor name
52
53       ::Diagrams::usegap use
54
55       ::Diagrams::xgap value
56
57       ::Diagrams::ygap value
58
59       ::Diagrams::textfont name
60
61       ::Diagrams::linewidth pixels
62
63       ::Diagrams::linestyle style
64
65       ::Diagrams::pushstate
66
67       ::Diagrams::popstate
68
69       ::Diagrams::computepos
70
71       ::Diagrams::boxcoords x1 y1 x2 y2
72
73       ::Diagrams::moveobject obj
74
75______________________________________________________________________________
76

DESCRIPTION

78       The  Diagrams  package  is  meant  to help drawing diagrams, like flow‐
79       charts. The philosophy is that you should be concentrating on the  con‐
80       tents  of  the diagram, rather than the exact positioning and sizing of
81       all items within it. The Diagrams package uses a few  simple  rules  to
82       layout the items:
83
84       •      Each item (or object) in the diagram has a number of "anchors" -
85              places where arrows and lines can be connected to.
86
87       •      You can draw an arrow or a line from an object in a  preset  di‐
88              rection
89
90       •      Sizing  and positioning should be done as automatic as possible:
91              this is achieved for instance by drawing boxes and circles  with
92              text, rather than first drawing a rectangle and then drawing the
93              text inside it or vice versa.
94
95       The commands within this package can be split up in several categories.
96       Each category is described in a separate section.
97

GENERAL COMMANDS FOR POSITIONING AND SETUP

99       ::Diagrams::drawin canvas
100              Set the canvas widget in which to draw
101
102              widget canvas
103                     Widget to draw in
104
105
106       ::Diagrams::saveps filename
107              Save the drawing in a PostScript file
108
109              filename string
110                     Name of the file to save the drawing in
111
112
113       ::Diagrams::direction newdir
114              Set  the  direction for moving the current position.  The direc‐
115              tion is one of: north  northeast  east southeast   south  south‐
116              west  west  northwest N      NE         E    SE         S     SW
117              W    NW up     up-right   left down-right down   down-left  left
118              up-left centre center     C
119
120              newdir string
121                     New direction
122
123
124       ::Diagrams::currentpos pos
125              Set the current position explicitly (argument must be a position
126              "object")
127
128              pos list
129                     New position (retrieve via getpos for instance)
130
131
132       ::Diagrams::getpos anchor obj
133              Get the position of a particular "anchor" point of an object an‐
134              chor should be one of the direction strings
135
136              anchor string
137                     Name  of  the anchor (one of the directions - see the di‐
138                     rection command
139
140              obj list
141                     The object in question
142
143
144       ::Diagrams::position xcoord ycoord
145              Create a position "object"
146
147              xcoord float
148                     X-coordinate of the position
149
150              ycoord float
151                     Y-coordinate of the position
152

DRAWING OBJECTS

154       ::Diagrams::box text width height
155              Draw a box from the current position (width and height are  both
156              optional;  if  not  given,  the  text  determines  the width and
157              height)
158
159              string text
160                     Text to be shown inside the box
161
162              float width
163                     Width (if any) of the box in pixels
164
165              float height
166                     Height (if any) of the box in pixels
167
168
169       ::Diagrams::plaintext text width height
170              Draw plain text from the current position (width and height  are
171              both  optional;  if not given, the text determines the width and
172              height)
173
174              string text
175                     Text to be shown
176
177              float width
178                     Width (if any) of the (invisible) box in which  to  posi‐
179                     tion the text
180
181              float height
182                     Height (if any) of the box
183
184
185       ::Diagrams::circle text radius
186              Draw a circle from the current position (the radius is optional)
187
188              string text
189                     Text to be shown inside the circle
190
191              float radius
192                     Radius (if any) of the circle in pixels
193
194
195       ::Diagrams::slanted text width height angle
196              Draw  a slanted box from the current position (width, height and
197              angle are optional)
198
199              string text
200                     Text to be shown inside the box
201
202              float width
203                     Width (if any) of the box in pixels
204
205              float height
206                     Height (if any) of the box in pixels
207
208              float angle
209                     Angle of the slanted box
210
211
212       ::Diagrams::diamond text width height
213              Draw a diamond-shaped box from the current position  (width  and
214              height  are both optional; if not given, the text determines the
215              width and height)
216
217              string text
218                     Text to be shown inside the diamond
219
220              float width
221                     Width (if any) of the diamond in pixels
222
223              float height
224                     Height (if any) of the diamond in pixels
225
226
227       ::Diagrams::drum text width height
228              Draw a drumshaped item from  th  ecurrent  position  (width  and
229              height  are both optional; if not given, the text determines the
230              width and height)
231
232              string text
233                     Text to be shown inside the drum
234
235              float width
236                     Width (if any) of the drum in pixels
237
238              float height
239                     Height (if any) of the drum in pixels
240
241
242       ::Diagrams::arrow text length heads
243              Draw an arrow from the current position to the next.   The  text
244              is  drawn next to the arrow, the length (in pixels) is optional.
245              If not given the gap parameters are used.
246
247              string text
248                     Text to be shown along the arrow
249
250              float length
251                     Length of the arrow in pixels
252
253              float heads
254                     Which arrow heads to draw (first, last or both - defaults
255                     to last)
256
257
258       ::Diagrams::line args
259              Draw a line specified via positions or via line segments The ar‐
260              guments are either position or length-angle pairs
261
262              list args
263                     List of positions or of length-angle pairs
264
265

ATTRIBUTES

267       (Note: attributes are persistent)
268
269       ::Diagrams::attach anchor
270              Set the anchor point for attaching arrows to
271
272              string anchor
273                     Any one of the valid anchor (e.g. N or North)
274
275
276       ::Diagrams::color name
277              Set the color for the outline of a box etc.
278
279              color name
280                     Name of the colour to be used
281
282
283       ::Diagrams::fillcolor name
284              Set the color to fill the objects
285
286              color name
287                     Name of the colour to be used
288
289
290       ::Diagrams::textcolor name
291              Set the color to draw the text in
292
293              color name
294                     Name of the colour to be used
295
296
297       ::Diagrams::usegap use
298              Turn the gap on (1) or off (0). Note: usually  a  small  gap  is
299              used when positioning objects.
300
301              boolean use
302                     Use the gap to compute the position of the next object or
303                     not
304
305
306       ::Diagrams::xgap value
307              Size of the gap in horizontal direction (in pixels)
308
309              integer value
310                     Gap width in pixels
311
312
313       ::Diagrams::ygap value
314              Size of the gap in vertical direction (in pixels)
315
316              integer value
317                     Gap height in pixels
318
319
320       ::Diagrams::textfont name
321              Set the name of the font to use
322
323              string name
324                     Name of a text font
325
326
327       ::Diagrams::linewidth pixels
328              Set the width of the lines (in line objects and arrows  and  the
329              outline of boxes and other objects)
330
331              integer pixels
332                     Number of pixels the lines are wide
333
334
335       ::Diagrams::linestyle style
336              Set  the  style  of  the  lines and arrows and of the outline of
337              boxes and other objects. The predefined line styles are:  solid,
338              dot, dash, dash-dot, dash-dot-dot (these are the distinguishable
339              line styles on Windows). You can also  use  the  style  patterns
340              from the canvas directly.
341
342              string style
343                     Name of a valid line style
344
345

COMMANDS FOR IMPLEMENTING NEW OBJECTS

347       Note:  it is best to study how for instance box objects are implemented
348       first.
349
350       ::Diagrams::pushstate
351              Save the current global settings Used when  defining  an  object
352              that is composed of other objects
353
354       ::Diagrams::popstate
355              Restore the previously saved global settings
356
357       ::Diagrams::computepos
358              Compute the current position
359
360       ::Diagrams::boxcoords x1 y1 x2 y2
361              Compute  the  anchor  coordinates for a box-like object (this is
362              merely a convenience routine. In general, you will have to  com‐
363              pute the list of coordinates yourself - see for instance the di‐
364              amond object)
365
366              float x1
367                     X coordinate of upper-left corner
368
369              float y1
370                     Y coordinate of upper-left corner
371
372              float x2
373                     X coordinate of lower-right corner
374
375              float y2
376                     Y coordinate of lower-right corner
377
378
379       ::Diagrams::moveobject obj
380              Move the object to the right position and return the new  infor‐
381              mation
382
383              list obj
384                     List of data representing the object
385
386

KEYWORDS

388       diagrams, drawing
389
390
391
392diagrams                              0.2                          Diagrams(n)
Impressum