Graphic, FullGraphic - structured graphic abstract base
class and subclass that stores a complete set of graphics
state attributes
SYNOPSIS
#include <Unidraw/Graphic/graphic.h>
DESCRIPTION
Graphic is an abstract base class for structured graphics
objects. Graphic objects maintain graphics state and geo-
metric information, which lets them draw themselves on
demand and support hit detection.
Graphic subclasses can implement graphical objects such as
lines, rectangles, ellipses, and polygons. Subclasses can
also support hierarchical composition of Graphic
instances, thus providing an object-oriented rendition of
traditional structured graphics functionality.
GRAPHIC PUBLIC OPERATIONS
virtual void Draw(Canvas*)
virtual void Draw(Canvas*, Coord, Coord, Coord, Coord)
virtual void DrawClipped(Canvas*, Coord, Coord, Coord,
Coord)
virtual void Erase(Canvas*)
virtual void Erase(Canvas*, Coord, Coord, Coord, Coord)
virtual void EraseClipped(Canvas*, Coord, Coord, Coord,
Coord)
Draw or erase the graphic on the given canvas. The
one-parameter Draw and Erase operations draw and
erase the graphic in its entirety. The five-param-
eter forms take four coordinates defining a rectan-
gular area with which to cull drawing. Composite
graphics in particular can use this information to
avoid drawing children falling entirely outside the
given area. DrawClipped and EraseClipped draw the
graphic strictly within a rectangular area. All
Coord parameters are in canvas coordinates.
virtual void FillBg(boolean)
virtual void SetBrush(PSBrush*)
virtual void SetColors(PSColor* fg, PSColor* bg)
virtual void SetFont(PSFont*)
virtual void SetPattern(PSPattern*)
virtual int BgFilled()
virtual PSBrush* GetBrush()
virtual PSColor* GetFgColor()
virtual PSColor* GetBgColor()
virtual PSFont* GetFont()
virtual PSPattern* GetPattern()
class implements the operations for setting and
getting the fill mode and colors; the other opera-
tions should be redefined in subclasses that need
them.
void Translate(float dx, float dy)
void Scale(float x, float y, float cx = 0.0, float cy =
0.0)
void Rotate(float angle, float cx = 0.0, float cy = 0.0)
void SetTransformer(Transformer*)
Transformer* GetTransformer()
void TotalTransformation(Transformer& t)
Coordinates passed to drawing operations are trans-
formed according to the current translation, rota-
tion, and scale factor. Optionally, scaling and
rotation can be performed relative to a point (cx,
cy). The base class stores a transformer _t that
can be directly set and accessed with SetTrans-
former and GetTransformer. The default transformer
is nil, meaning no transformations are performed.
TotalTransformation uses concatTransformer
(described below) to concatenate t (usually the
identity transformation) and the transformers of
the graphic's parents to obtain the graphic's total
transformation, which it then stores in t.
Unless otherwise noted, input and output coordi-
nates are affected by the concatentation of this's
transformer, its parent's transformer, its parent's
parent's, and so on up to the root of the graphic
instance hierarchy. Prior to transformation, coor-
dinates reflect the graphic's coordinate system.
Following transformation, the coordinates reflect
the canvas coordinate system (i.e., they are canvas
coordinates). The coordinates that Graphic sub-
class constructors require are normally in graphic
coordinates, while operations for returning a
graphic's bounding box (see below) are in canvas
coordinates.
void Align(Alignment, Graphic*, Alignment)
Position the given graphic relative to this, which
stays fixed, while the graphic supplied as the
argument is translated appropriately. The first
Alignment parameter specifies the alignment with
respect to this, while the second specifies the
alignment with respect to the given graphic.
virtual void GetBounds(
float& left, float&