DADiSP Worksheet Functions > Function Categories > Annotation > POLYGONDRAW

 

POLYGONDRAW

Purpose:

Draws a closed polygon at the specified coordinates.

Syntax:

POLYGONDRAW(

win, color, style, target, match, focus, width, fill, x1, y1, ..., xN, yN)

win

-

Optional. The target window. Defaults to the current window.

color

-

Optional. An integer or macro color name (e.g. RED) specifying the polygon border color. Defaults to color of primary series.

style

-

Optional. An integer specifying the polygon border style:

1:

Solid (default)

2:

Dashed

3:

Dotted

target

-

Optional. An integer specifying the spatial relationship of the polygon to the Window:

0:

PAPER (default). The polygon is located on the "graph paper" in the Window; within the coordinate system of the data. The polygon scrolls with the series.

1:

GLASS. The polygon is located within the plotting area of Window. The polygon remains fixed in place when the series scrolls.

2:

GLASS_WMARGIN. The polygon is located within the area of the entire Window. The polygon remains fixed in place when the series scrolls.

3:

GLASS_WPMARGIN. The polygon is located within the vertical dimensions of a Window, and within the horizontal dimensions of the plotting area. The polygon remains fixed in place when the series scrolls.

4:

GLASS_WSMARGIN. The polygon is located anywhere within the entire Worksheet area.

match

-

Optional. An integer that sets the polygon border color to match the color of the selected overplot. Defaults to 1 (primary series). –1 implies use color parameter.

focus

-

Optional. An integer specifying 1-based focus offset for PAPER annotations.

width

-

Optional. An integer specifying the polygon border width in pixels. Defaults to 1.

fill

-

Optional. An integer specifying the interior color. Defaults to –1, transparent.

x1, y1, xN, yN

-

Real number coordinates of the closed polygon.

Returns:

An integer object handle that can be used to set or adjust the polygon properties.

Example:

gtri(100,.01,2);polygondraw(purple, 2, 0, -1, 0.2, 0.4, 0.7, 1.0, .8, .2, .6, .4)

 

creates a purple dashed (2) polygon in "paper mode" (0). The color of the polygon border is purple, and is unrelated to any overplots (match == -1); the polygon contains the coordinates (0.2, 0.4), (0.7, 1.0), (0.8, 0.2), (0.6, 0.4).

Example:

Polygon annotations can be manipulated by setting the polygon properties of the returned object handle.

 

W1: gsin(100,.01)

h = polygondraw(purple,2,0,-1,0.2,0.4,0.7,1.0,.8,.2,.6,.4);

h.color = lred; h.width = 4;h.fill = yellow;

 

A polygon is placed in W1 at coordinates (0.2, 0.4), (0.7, 1.0), (0.8, 0.2), (0.6, 0.4). The border color is set to light red, the border width is set to 4 and the fill color is set to yellow.

Remarks:

Polygon properties can be manipulated with the object handle. The following properties are available:

 

Name

Type

Description

x

real

x coordinate

y

real

y coordinate

tag

string

object identifier

xor

integer

xor background flag

fill

integer

background color

lock

integer

lock interactive movement

type

string

type of object, "shape"

color

integer

border color

focus

integer

target overlay focus

match

integer

overplot number to match color

shape

string

readonly type of shape, "polygon"

style

integer

border line style

width

integer

border width

coords

series

diagonal coordinates as a series

handle

integer

polygon handle

onmove

string

move callback function

onsize

string

size callback function

tagnum

integer

same as handle, polygon

target

integer

polygon coordinate target, glass, paper, etc.

winnum

integer

readonly window number of polygon target

showtag

integer

show polygon string tag

visible

integer

polygon visibility

oncreate

string

creation callback function

ondelete

string

deletion callback function

onlclick

string

mouse left click callback function

onmotion

string

motion callback function

onrclick

string

mouse right click callback function

onsizing

string

sizing callback function

position

series

readonly bounding box coordinates of the polygon in window coordinates, lower left X coordinate, Y coordinate, height and width

devposition

series

readonly bounding box coordinates of the polygon in device coordinates

transparency

integer

interior transparency

 

Readonly properties can only be queried. All other properties can be set and queried using the handle.property dot syntax.

 

POLYGONDRAW can be used directly from the command line or as part of an SPL routine to draw lines in a Window that contains data. The result is identical to adding lines via the Drawing Toolbar and the polygon can subsequently be manipulated with the mouse.

 

Use -2 to specify the default value for any integer parameter.

 

The overplot index match associates a polygon annotation with a specific overplot by guaranteeing that the polygon border color will be the same as the overplot color.

 

When setting an index match, use 1 to refer to the color of the primary series; use 2 to refer to the color of the first overplot; 3 for the second overplot, etc.

 

The onmove, onsize, oncreate, ondelete, onlclick, onmotion, onrclick and onsizing callbacks specify functions to run when the associated event occurs. For example, consider the following callback function:

 

 

/* motion callback */

poly_onmotion(h)

{

    printf("xmin: %g  ymin: %g  xmax: %g  ymax: %g",

            min(h.x), min(h.y), max(h.x), max(h.y));

}

 

 

A callback function accepts the annotation handle as the sole input.

 

Now for the polygon:

 

h = polygondraw(0.0, 0.0, 1.0, 2.0, 2.0, 1.0);h.onmotion = "poly_onmotion";

 

The poly_onmotion function is invoked when the polygon moves via the mouse. In this case, the coordinate range of the polygon is displayed in the status line.

 

 

See ARROWDRAW to draw an arrow line.

 

See ELLIPSEDRAW to draw an ellipse.

 

See LINEDRAW to draw one or more line segments.

 

See RECTDRAW to draw a rectangle.

See Also:

ARROWDRAW

ELLIPSEDRAW

FINDHANDLE

FINDSHAPE

FINDTEXT

LINECOPY

LINECUR

LINEDEL

LINEDRAW

LINEMOVE

RECTDRAW

TEXT