man tkdraw

tkdraw - a simple drawing tool implemented as a wish script

contents

[usage] [file menu] [tcl button] [ed menu] [top button] [dup button] [mov button] [new menu] [apply button] [mouse actions] [files] [hints] [limitations]

usage

tkdraw [filename]
The tkdraw script is essentially an interface to the capabilities built in to tk canvas widgets, packaged as a drawing tool. The general method is to have two major windows, one a canvas, and one a text window showing the descripton of the canvas object currently being manipulated as a set of tcl commands.

Gestural commands on the canvas to locate objects, shape objects, select objets, or move them, make the appropriate text edits to the tcl commands in the text window.

Finally, a row of buttons supply miscelaneous menus and operations, such as interactions with the file system, access to objects by browsing the drawlist instead of the canvas, common edits such as duplication, movement, new object creation, and "apply" of changes.

file menu

file.options
Sets the edit text to the options for the drawing as a whole. The apply button must be used to commit changes made.
file.clear
Clears the edit text. Useful to do to avoid confusion, or to prepare to type in commands "by hand" to apply, eg, use file.clear, then type "exec lpr -Psome_printer << [c postscript]" and then the apply operation will print the current drawing to the some_printer postscript printer.
file.new
Clears the canvas, resets the draw list to empty.
file.read
Reads a file containing a drawing in tcl-list format, replacing the current drawing.
file.include
Reads a file containing a drawing in tcl-list format, adding it to the current drawing.
file.write
Writes the drawing to a file in tcl-list format.
file.write-ps
Writes the drawing to a file in postscript format. It choses the filename from the options settings, and replaces any extension with ".ps".
file.write-gif
Writes the drawing to a file in gif format. It chooses the filename from the options settings, and replaces any extension with ".gif". The PBM toolkit and xwd must be on your $PATH.
file.print
Pipes the canvas to lpr in postscript form.
file.quit
Terminates the tkdraw session. Note, there is no checking to ensure file write of any canvas changes.

tcl button

The tcl button executes the current X selection as a tcl script. This is useful for importint commands, customizations, or configuration options from other tools.

ed menu

ed.drawlist
Pops up a top-level window containing the current drawlist, so that one can access any of the items for edit without necessarily knowing where it is on the canvas.
ed.delete-item
Deletes the item currently in the edit buffer from the canvas and the draw list (but leaves it in the text buffer).
ed.scale-item
Prepares to scale all coordinates of item in the edit buffer by a given factor; pick an origin, x & y scale factors, and apply
ed.grid
Edits the item currently in the edit buffer, moving all coordinates in the coordinate list to the next lower multiple of 10. Useful for precision alignment of points in an object for regular shape, or for aligning multiple objects.
ed.mov-group
ed.dup-group
ed.del-group
ed.scale-group
sets up a command to perform a "mov", "dup" or "del" operation on a group of items within a region of the screen; use by
  1. [mov,dup,del]-group
  2. select screen area (then select a move vector if doing a mov or dup)
  3. apply

top button

Moves the item in the edit buffer to the end of the draw list.

dup button

Duplcates the item in the edit buffer to the end of the draw list.

mov button

Presumes that the last four entries in the coordinate line are movement endpoints, and edits the prior entries. Thus, to move an object, select it, drag from any point on the object to where you want that point to land, and do the mov operation.

new menu

The new menu allows choice of the standard tk canvas objects to create, namely line, rectangle, polygon, oval, arc, bitmap and text.

apply button

The apply button is used to commit changes to canvas. The top, dup, and mov buttons automatically apply, but other edits must be explicitly applied, or they will not take effect.

canvas mouse bindings

There are three gestural idioms supported on the canvas. Each of them updates the text display.
placement
A single leftclick will add an x,y coordinate pair to the current object's coordinate list. Thus, to place a bitmap or text object on the canvas, create it from the new menu, specifiy its bitmap file or text content, click on the canvas, and execute the apply button.
rubberbanding
A left drag on the canvas will add two x,y coordinate pairs to the current object's coordinate list, and during the drag, the current bounding box and its diagonal track mouse motions. Thus, to create a rectang, oval, or arc, simply creat it from the new menu, drag out its location on the canvas, and apply.

Note that this is also used for moving objects. Simply select the object (see below), drag from where it is to where you want it, and apply.

selection
A middleclick on the canvas will select the nearest object for editing. It is also useful if you need prompting for what options are available on particlar objects. For example, you can create a line with a plain style, then select the just-created line for editing, and the options for color, arrow style, edge rounding, spline curves, and so on, will all be presented.

files

The $HOME/.tkdrawrc file is executed if it exists at startup.

usage hints

re-use

Note that since there is an "include" option, different drawings can be combined. Simply selection file.options, choose a filename of an old drawing with some features you want to reuse, then choose file.include. Its drawing list will be added to that of the current drawing.

Sometimes, however, it would be easier to snip out only one object or two, rather than including a compelex drawing and then deleting most of it. In that case, other possibilities might be easier. One possibility is to bring up another copy of tkdraw on a file that has an element you wish to snip. Then, select it for editing and select its text as the X selection. Finally, go back to the original tkdraw, select file.clear, past in the text with either ctrl-V or right-click, and hit "top" to insert it into the local drawing's draw list. Another possibility is to read the first drawing, save the text into another X window (say, an editor), read the new drawing, and use clear/paste/top to insert it.

Finally, note that flipping to the drawing options, then applying, then chosing read or include, can be tedious. You can simply use file.clear, then type

read-drawing 1 foo
to read in file "foo". Note that "1" as the first argument includes the file; "0" can be used to overwrite the current drawing.

grouping

Tkdraw doesn't do groups. It's application domain is small overhead transparencies, HTML pages, and so on, so the draw list usually doesn't get complicated enough to make it worthwhile in practice in its user community. But if you've placed a group of objects, and want to move them all as a group elsewhere, you can save the two x,y coordinate pairs from a drag into another window, and make them the current X selection. Then, you can simply choose each of the objects you wish to move as a group in turn, paste the coordinates in with a rightclick or ctrl-V, and select move. They will all retain their precise relative placement on the screen, but moved to a new location.

Also, by storing a group of objects in a file, they can all be inserted into a drawing as a unit via file.include.

macros

If some arbitrary tcl commands need to be executed for some portion of a drawing, they could be stored in the "comments" field of the options, then simply selected and executed with the "tcl" button to expand them when the drawing is loaded. Eventually, adding a macro capability to the draw list will be a superior solution, and may also be a way to get grouping cleanly, but this is still tenative.

limitations

Weaknesses currently are lack of groups, the ability to provoke arbitrary tcl or tk errors by mistyping in the text window, and no point-and-click file browsing interface.