SYNOPSIS:

This library provides the following classes draw_sym draw_str draw_pix mouse that make the operations of NST units of the same available inside prog_units.

CLASS draw_sym:

Constructors:

draw_sym(char *windowname)
draw_sym3d(char *windowname, char *options=NULL)
draw_sym(char *windowname, char *options)
Here, *options is an option string consisting of zero or more option directives. The most important option directives are
%a
autoscaling
%nB
buffer recently drawn symbols in internal buffer to allow redraw (also needed to obtain postscript output via NST unit window_to_eps). Parameter n sets the maximal size of the buffer. To fit num points into the buffer, n=num+numcalls is the minimal required value, where numcalls is the number of calls used to insert the num points. The buffer itself will grow as needed (up to a maximal limit of approx. 24n bytes). To clear the buffer, use method init() below. If n is not specified, the current default is n=30000.
%I
draw in inverse color (for simple undraw). %I and %B are mutually exclusive.
%a and %B are the defaults used with the first two constructors. Further options are as documented for the NST draw_sym unit. The %C option is without effect here.

Further methods:

color(int color)
symbol(int symbol)
size(float size)
linewidth(float linewidth)
draw(float x, float y, float z_or_color=0)
draw(float *x, float *y)
draw(float *x, float *y, float *z)
draw(float *x, float *y, int *colors)
draw(float *xy[z], int *colors)
draw(float *x, float *y, float *z, int *colors)
draw(float *coords)
line(float x1, float y1, float x2, float y2)
line(float x1, float y1, float x2, float y2, int color)
line(float *coords)
rect(float xmi, float ymi, float xma, float yma):
rect(float xmi, float ymi, float xma, float yma, int color):
circle(float x, float y, float radius, int color):
circle(float x, float y, float radius):
ellipse(float x, float y, float dx1, float dy1, float a2, int color):
ellipse(float x, float y, float dx1, float dy1, float a2):
ellipse(float x, float y, float a1, float a2):
mark(float x, float y, float z_or_color=0)
mark(float *x, float *y)
mark(float *x, float *y, float *z)
mark(float *xy[z], int *colors)
mark(float *x, float *y, int *colors)
mark(float *x, float *y, float *z, int *colors)
mark(float *coords)
clear()
clear buffer, when in %B mode
redraw()
redraw buffer (only useful in %B mode)
redraw(char *window)
redraw buffer into window with name window (only useful in %B mode)
rescale(int ax=2)
rescale x- (for ax=0) or y-axis (for ax=1) or both (for ax=2) (only when drawing into a plot_xy, plot_vec or plot_series window)
restore()
restore original scaling
labels(char *xlabel, char *ylabel)
set axis labels (use NULL to omit a label)
All these methods are of return type void. Draw and mark differ only in that draw will connect the drawn markers by lines. For the ellipse, x,y are the ellipse center and dx1 and dy1 the components of the distance vector from the center to the first apex. a2 is the length of the orthogonal ellipse axes. The ellipse and circle methods can only be used in 2D. When the draw/mark(x,y,z_or_color) functions are used for a 2D window, a nonzero integer value for the last argument is interpreted as a color specification. When the target window is a plot3d window, the function calls with additional z-arguments should be used. Coords is expected to contain the to-be-plotted points as consecutive xy-pairs or xyz triples (depending on whether the target window is in 2d or 3d mode). Color and symbol are integers, for which the exported constants listed below can be used. The remaining arguments should be self-explanatory.

Exported color constants:

WHITE, RED, GREEN, BLUE, YELLOW, MAGENTA, CYAN, BLACK

Exported symbol type constants:

POINT, CROSS, SQUARE, TRIANGLE, PLUS, STAR, CIRCLE,
-.FILLED_SQUARE, FILLED_TRIANGLE, FILLED_CIRCLE,
ARROW, MIDARROW, FILLED_ARROW, FILLED_MIDARROW
(all the constants above are nonzero and of type int).

DRAWING ARROWS:

Symbol type ARROW or FILLED_ARROW will cause method draw() to draw lines with arrow ends. Symbol type MIDARROW or FILLED_MIDARROW will cause method draw() to draw lines with arrows centered on their shafts. Method mark() will just move to a new location without drawing anything.

CLASS draw_str:

Constructors:

draw_str(char *windowname)
draw_str3d(char *windowname, char *options=NULL)
draw_str(char *windowname, char *options)
Options are as explained for draw_sym.

Further methods:

color(int color)
size(float size)
hotspot(int pos)
float fontwidth(void)
returns font width in data coord
float fontheight(void)
returns font height in data coord
draw(float x, float y, char *text)
draw(float x, float y, float z, char *text)
draw(float *x, float *y, char *tokens, int maxlen=0)
draw(float *x, float *y, float *z, char *tokens, int maxlen=0)
draw(float *coords, char *tokens, int maxlen=0)
printf(float x, float y, char *fmt, ...)
printf(float x, float y, float z, char *fmt, ...)
clear()
clear buffer, when in %B mode
redraw()
redraw buffer (only useful in %B mode)
Hotspot selects which point of the text will be centered at the given position (.pos can be one of the exported position constants listed below). When the target window is a plot3d window, the function calls with additional z-arguments should be used. Coords is expected to contain the to-be-plotted points as consecutive xy-pairs or xyz triples (depending on whether the target window is in 2d or 3d mode). Tokens is an array of space-separated text tokens that will be plotted at the coord positions. If maxlen>0, each token will in addition be truncated to its maxlen first characters. The printf methods work like the familiar C printf function with an additional coordinate specification before the format parameter. Currently, the printed text must not exceed 10000 chars. Exported hotspot position constants (all int):
CENTER, NORTH, SOUTH, EAST, WEST, N_WEST, N_EAST, S_WEST, S_EAST

CLASS draw_pix:

draw_pix(char *windowname, char *pcOptions, int dx, int dy)
draw(float x, float y, float *pix=NULL, int zoom=1)
move pixel area so that hot spot becomes located at (x,y) and apply zoom factor zoom. If pix is non-NULL, also draw pixel data.
draw(float *pix, int zoom=1)
just draw pixel data and apply zoom factor.
clear()
clear
redraw()

Further methods:

CLASS mouse:

Constructors:

mouse(char *windowlist)
windowlist is a string containing one or several names of NST windows (separated by white space) to which the mouse unit can attach

Further methods:

Below, button is one of LEFT_BUTTON, MIDDLE_BUTTON or RIGHT_BUTTON, while buttons is a int[3] array specifying with its nonzero positions a button set. The int return value of the routines indicates which from the windows in windowlist was selected (1=first window in windowlist etc.).
int poll(float *x, float *y)
int poll(float *x, float *y, int *buttons)
when pointer is in one of the windows of windowlist : return nr of list position (1,2,..) and updated values of .*x,*y (and buttons in the second case). Otherwise return 0 with arguments unchanged. No wait.
int wait(float *x, float *y, int button)
immediately returns 0 with arguments unchanged when pointer is not in one of the windows of windowlist. Otherwise, waits until one of the specified button is pressed (return value is nr>0 of list position of current window) or pointer leaves the current window (return value is 0).
int wait(float *x, float *y, int *buttons)
as before, but for nonzero return value overwrites array buttons so that an element of 1 indicates which button was pressed (if any), while the remaining array elements are 0. NOTE: if the return value was 0, buttons will be unchanged.
int track(float *x, float *y, float *x2, float *y2, int button)
int track(float *x, float *y, float *x2, float *y2, *buttons)
analogous to poll(), but start tracking if pointer is in k-th window from windowlist AND one of the specified buttons is down (otherwise immediately return 0). After tracking return start and end point of tracking in *x1,*y1 and *x2,*y2 and return k>0. The second routine also sets in buttons the element at the position of the trigger button to 1, all other elements to 0.
void shape(int which)
choose rubber shape to use for tracking (one of RECTANGLE, CENTERED_RECTANGLE, LINE or NONE).
void color(int color)
choose color of rubber shape
The returned coordinates are the data coordinates of the window from which the event is reported, the return value is the position (starting with 1) of that window in windowlist.

Exported constants:

int LEFT_BUTTON, MIDDLE_BUTTON, RIGHT_BUTTON
identify buttons (values are 1,2 and 4)
int RECTANGLE, CENTERED_RECTANGLE, LINE, NONE
identify rubber shape for tracking

FILE

/local/homes/rhaschke/nst7/man/../o.linx86//../nstsrc/nst_draw.c