next up previous contents index
Next: Shell Commands Up: Functions with Side Effects Previous: Input and Output Routines

Plotting Functions

The functions in this section can be used for plotting data on an Xwindow display. The basic idea of these functions is that you create a window with the w_make_window command and then can add various features to the window. The most important features are boxes and buttons. A scale box can be used to create a virtual coordinate system on the window on which points, lines, rectangles and polygons can be drawn. A text box can be used to create a box in which text can be written. A button can be used along with the input functions to get information back from the window. In all the functions in this section colors are specified by one of w_black, w_white, w_red, w_blue, w_green, w_cyan, w_yellow, w_magenta, w_pink, w_light_green, w_light_blue, w_purple, w_gray, w_dark_gray, or w_orange.

display {[char]}
  The display variable inherited from your environment.

w_make_window((offset, size), title, background_color, display)
{(((int, int), int, int), [char], int, [char], stream) tex2html_wrap_inline10682 w_window}
  Makes an X window on the specified display with the given offset, size, title, and background color.

Note that windows get automatically closed when you return to top-level. This means that you cannot return a window to top-level and then use it--you must create it and use it within a single top-level call.

w_kill_window(win) {w_window tex2html_wrap_inline10684 bool}
  Kills a window created by w_make_window.

w_add_box((offset, size), (voffset, vsize), name, color, window)
{(((int, int), int, int), ((float, float), float, float), [char], int, w_window) tex2html_wrap_inline10686 (w_window, w_box)}
  Creates a scaled box on the specified window, which can be used to draw into using the various drawing commands. The position and size of the box within the window are specifed by offset and size. The virtual coordinates of the box are specified by the virtual offset (voffset) and the virtual size (vsize). The color specifies the background color. The function returns a pair whose first element in the modified window structure and whose second element is the newly created box. Technically this box is not necessary since it can be retrieved with w_get_named_box.

w_add_text_box((offset, size), name, color, window)
{(((int, int), int, int), [char], int, w_window) tex2html_wrap_inline10688 (w_window, w_box)}
  Create a text box on the specified window with the given offset, size and color. Such a box can be used in conjunction w_write_paragraph, w_write_text_centered or w_write_text_left. These will all write text into a text box.

w_add_button((offset, size), name, color, window)
{(((int, int), int, int), [char], int, w_window) tex2html_wrap_inline10690 w_window}
  Adds a button to a window. The name is printed across the button and is also the name that is returned by w_get_input and related functions if the button is pressed.

w_add_button_stack((offset, size, separation), names, color, window)
{(((int, int), (int, int), int, int), [[char]], int, w_window) tex2html_wrap_inline10692 w_window}
  Adds a stack of buttons. The separation is specified as an x and y distance (e.g. if the x distance is 0, then the buttons will vertical). names is an array of button names.

w_add_text(position, text, color, window)
{((int, int), [char], int, w_window) tex2html_wrap_inline10694 w_window}
  Adds a single text string to a window at the specified position. The function w_add_text_box is often more convenient.

w_get_named_box(name, window) {([char], w_window) tex2html_wrap_inline10696 w_box}
  Returns the box of the specified name from a window.

w_reset_box_size(boxname, (voffset, vsize), window)
{([char], ((float, float), float, float), w_window) tex2html_wrap_inline10698 (w_window, w_box)}
  Resets the virtual coordinates of a scaled box inside of a window. You need to pass this command the name of the box rather than the box itself. Like w_make_box, it returns both the new window structure and a new box. This command does not clear the current contents of the box.

w_clear_box(box) {w_box tex2html_wrap_inline10700 bool}
  Clears the contents of a box.

w_bounds_from_box(box) {w_box tex2html_wrap_inline10702 ((float, float), float, float)}
  Returns the virtual coordinates of a scale box.

w_box_scale(box) {w_box tex2html_wrap_inline10704 float}
  Returns the ratio of the size of a box in pixels to the size in the virtual coordinate system.

w_bounding_box(points) {[(a, a)] tex2html_wrap_inline10706 ((a, a), a, a) :: (a in number)}
  For a set of points this function returns a bounding box (the smallest box that contains them all). The bounding box is specified as a pair in which the first element is the (x,y) coordinate of the lower left corner and the second element is a pair with the width and height.

w_draw_point(point, color, box) {((float, float), int, w_box) tex2html_wrap_inline10708 bool}
  Draws a point in a box based on the virtual coordinates.

w_draw_big_point(point, size, color, box) {((float, float), int, int, w_box) tex2html_wrap_inline10710 bool}
  Draws a big point in a box based on the virtual coordinates. The point size is specified by an integer (pixels).

w_draw_points(points, color, box) {([(float, float)], int, w_box) tex2html_wrap_inline10712 [bool]}
  Draws a sequence of points in a box based on the virtual coordinates.

w_draw_segments(endpoints, width, color, box)
{([((float, float), float, float)], int, int, w_box) tex2html_wrap_inline10714 bool}
  Draws a sequence of line segments in a box based on virtual coordinates. Each line-segment is specified as a pair of points. The width argument specifies the width of the lines in pixels. All segments that go ouside of the box are clipped.

w_draw_string(point, string, color, box) {((float, float), [char], int, w_box) tex2html_wrap_inline10716 bool}
  Draws a text string in a box at the position specified by point in virtual coordinates.

w_draw_rectangle((offset, size), width, color, box)
{(((float, float), b, a), int, int, w_box) tex2html_wrap_inline10718 bool :: (a in number; b in number)}
  Draws a rectangle in a box based on the virtual coordinates. This function clips any part of the rectangle that goes outside the box. The width specified the width of the lines.

w_shade_rectangle((offset, size), color, box)
{(((float, float), b, a), int, w_box) tex2html_wrap_inline10720 bool :: (a in number; b in number)}
  Shades a rectangle in a box based on the virtual coordinates. This function clips any part of the rectangle that goes outside the box.

w_shade_polygon(points, color, box) {([(float, float)], int, w_box) tex2html_wrap_inline10722 bool}
  Shades a polygon in a box based on the virtual coordinates. The polygon is specified as a sequence of points. This function clips any part of the polygon that goes outside of the box.

w_write_text_centered(text, color, text_box) {([char], int, w_box) tex2html_wrap_inline10724 bool}
  Writes text into a text box such that the text is centered both horizontally and vertically.

w_write_text_left(text, color, text_box) {([char], int, w_box) tex2html_wrap_inline10726 bool}
  Writes text into a text box such that it is against the left end of the box and centered vertically.

w_write_paragraph(text, color, text_box) {([char], int, w_box) tex2html_wrap_inline10728 bool}
  Writes a paragraph into a text box starting at the top left hand corner of the box and does line wrapping so the text will not go outside of the right margin of the box. Line breaks are ignored although the @ character can be used to force a line break.

w_get_input(window) {w_window tex2html_wrap_inline10730 ([char], [char], (float, float), (int, int), char)}
  Gets input from a window. It returns a tuple of the form (event_type,name,position,flags,char). The event_type is one of "button","key","box", or "none" depending on the event. The "box" event in evoked if you click the mouse inside of a box. The name is the name of the box or button on which the event took place. The position specifies the the virtual coordinate on which a "box" event took place. The flags specify whether control and shift keys were pressed. The character specifies the key pressed in the case of a "key" event. This function blocks until an event takes place.

w_get_input_noblock(window)
{w_window tex2html_wrap_inline10732 (bool, [char], [char], (float, float), (int, int), char)}
  This is the same as w_get_input but does not block. It returns an additional flag at the begining, which specifies if an event was found.

w_get_button_input(window) {w_window tex2html_wrap_inline10734 [char]}
  This function only picks up button events and throws away all other events. It returns the button name.

w_get_zoom_box(pt, width, box)
{((float, float), a, w_box) tex2html_wrap_inline10736 ((float, float), float, float) :: (a in any)}
  This function allows to to use an elastic band to pick out a region of a box. It is typically used in conjunction with w_get_input. In particular, if the input returned by w_get_input is a mouse click on a particular box (down click) the position of the click and the box can be passed to this function which will then return the other corner (the corner on which the user lets go of the mouse). This function actually returns the lower left and upper right corners of the region. The width specifies the width in pixels of the elastic band.



next up previous contents index
Next: Shell Commands Up: Functions with Side Effects Previous: Input and Output Routines



Jonathan Hardwick
Tue Nov 28 13:57:00 EST 1995