NAME¶
Grid - displays a grid in a viewer and constrains points to lie on it
SYNOPSIS¶
#include <Unidraw/grid.h>
DESCRIPTION¶
The Grid object performs two functions: it displays a grid in a viewer, and it
can constrain points to lie on the grid. The base class draws the grid as a
simple array of dots; subclasses can draw arbitrarily complex grids.
PUBLIC OPERATIONS¶
- Grid(float w, float h, float xincr, float
yincr)
- The constructor parameters correspond to a width, a height,
and independent units of graduation for the horizontal and vertical axes,
all in pixels. The Grid base class employs a special-purpose graphic to
render itself, one that draws an array of dots based on the information
supplied in this constructor.
- virtual Graphic* GetGraphic()
- Return the graphic used to render the grid.
- virtual void Constrain(Coord&, Coord&)
- Constrain the given coordinate pair to fall on the grid.
The pair is changed to fall on the nearest grid point by default.
- virtual void Visiblity(boolean)
- Make the grid visible (specify true) or invisible
(specify false).
- virtual boolean IsVisible()
- Return whether the grid is visible or not.
- virtual void SetSpacing(float xincr, float
yincr)
- Reset the grid's units of graduation.
PROTECTED OPERATIONS¶
- Grid(Graphic*)
- The protected constructor allows subclasses to specify an
arbitrary graphic for rendering the grid. Subclasses that use this
constructor must also redefine the Constrain operation.
SEE ALSO¶
Graphic(3U), Viewer(3U)