Draw Class Reference
A very simple drawing environment, originally to visualize planner stuff.
More...
#include <Draw.h>
Detailed Description
A very simple drawing environment, originally to visualize planner stuff.
Default origin is in the lower left corner, positive x and y to the right and up
Definition at line 12 of file Draw.h.
List of all members.
Public Types |
enum | Colors {
BLACK,
DK_GRAY,
GRAY,
LT_GRAY,
WHITE,
RED,
YELLOW,
GREEN,
CYAN,
BLUE,
MAGENTA
} |
| Convenient color constants.
More...
|
enum | PointStyles { CIRCLE,
SQUARE,
DIAMOND
} |
| Provides different point() styles.
More...
|
Public Member Functions |
| Draw () |
| Default constructor, must still call setFile() before any drawing commands.
|
| Draw (const std::string &file, double width, double height) |
| Constructor, sets up output.
|
| ~Draw () |
| Destructor.
|
Draw & | setFile (const std::string &file, double width, double height) |
| This must be called to setup output destination before calling any drawing commands.
|
Draw & | flushPage () |
| Writes the current page and starts a new one.
|
Draw & | setOrigin (const fmat::Column< 2 > &p) |
| Moves the origin (lower left corner).
|
Draw & | setOrigin (double x, double y) |
| Moves the origin (lower left corner).
|
Draw & | centerView (const fmat::Column< 2 > &p) |
| Moves the origin in order to center the viewport on the specified point.
|
Draw & | centerView (double x, double y) |
| Moves the origin in order to center the viewport on the specified point.
|
Draw & | setClip () |
| Clips further drawing to the current path area.
|
Draw & | clearClip () |
| Clears the clipping region.
|
Draw & | setScale (double x, bool scaleStroke=false) |
| Changes the scaling factor, to display more or less within the bounds given to setFile().
|
double | displayToScaled (double x) const |
| Converts from display units to scaled coordinates.
|
double | scaledToDisplay (double x) const |
| Converts from scaled coordinates to display units.
|
Draw & | setRegion (const BoundingBox2D ®ion, bool scaleStroke=false) |
| Changes scale and origin to fit the specified drawing region to the output.
|
Draw & | drawGrid (double xRes, double yRes, double xOff=0, double yOff=0) |
| Draws a grid of the specified horizontal and vertical resolution across the visible region (doesn't stroke).
|
Draw & | drawAxes () |
| Draws the axes across the visible region (doesn't stroke).
|
Draw & | setStrokeWidth (double x) |
| Sets the stroke width using output dimension units, i.e. scale factor invariant.
|
Draw & | setScaledStrokeWidth (double x) |
| Sets the stroke width using coordinate-space units, i.e. relative to scale factor.
|
double | getStrokeWidth () const |
| Returns the stroke width in output dimension units.
|
double | getScaledStrokeWidth () const |
| Returns the stroke width in coordinate-space units.
|
Draw & | setColorRGB (double red, double green, double blue, double alpha=1) |
| Sets the color for future drawing operations.
|
Draw & | setColorGray (double x, double alpha=1) |
| Sets the color for future drawing operations.
|
Draw & | setColor (Colors c, double alpha=1) |
| Sets the color for future drawing operations.
|
Draw & | stroke () |
| Outline the current path.
|
Draw & | stroke (Colors c, double alpha=1) |
| Outline the current path with specified color.
|
Draw & | stroke (double red, double green, double blue, double alpha=1) |
| Outline the current path with specified color.
|
Draw & | strokeLine (const fmat::Column< 2 > &p1, const fmat::Column< 2 > &p2) |
| Stroke a single line; if drawing a polygon, better to use lineTo and stroke as a batch.
|
Draw & | strokeLine (double x1, double y1, double x2, double y2) |
| Stroke a single line; if drawing a polygon, better to use lineTo and stroke as a batch.
|
Draw & | fill () |
| Paint the current path.
|
Draw & | fill (Colors c, double alpha=1) |
| Paint the current path with specified color.
|
Draw & | fill (double red, double green, double blue, double alpha=1) |
| Paint the current path with specified color.
|
Draw & | point (const fmat::Column< 2 > &p, double size, PointStyles style=CIRCLE) |
| Produces a output-dimension (i.e. unscaled) symbol at the specified point (follow up with fill() and/or stroke()).
|
Draw & | point (double x, double y, double size, PointStyles style=CIRCLE) |
| Produces a output-dimension (i.e. unscaled) symbol at the specified point (follow up with fill() and/or stroke()).
|
Draw & | arc (const fmat::Column< 2 > &p, double r, double begin, double end) |
| Produces an arc of the specified range.
|
Draw & | arc (double x, double y, double r, double begin, double end) |
| Produces an arc of the specified range.
|
Draw & | circle (const fmat::Column< 2 > &c, double r) |
| Produces a closed path for a circle at the specified point.
|
Draw & | circle (double x, double y, double r) |
| Produces a closed path for a circle at the specified point.
|
Draw & | ellipse (const fmat::Column< 2 > &c, double width, double height, double orientation=0) |
| Produces an ellipse, note width and height, not major/minor.
|
Draw & | rect (const BoundingBox2D &r) |
| Produces a closed path for an axis-aligned rectangle.
|
Draw & | rect (const fmat::Column< 2 > &p1, const fmat::Column< 2 > &p2) |
| Produces a closed path for an axis-aligned rectangle between the specified points.
|
Draw & | arrow (const fmat::Column< 2 > &p1, const fmat::Column< 2 > &p2, double headWidth=2, double headLength=5) |
| Draws a line between points with an arrowhead at p2, the headWidth and headLength are multiples of the stroke width.
|
Draw & | draw (const PlannerObstacle2D &o) |
| Produces a closed path for a planner obstacle.
|
Draw & | draw (const RectangularObstacle &o) |
| Produces a closed path for a planner obstacle.
|
Draw & | draw (const CircularObstacle &o) |
| Produces a closed path for a planner obstacle.
|
Draw & | draw (const EllipticalObstacle &o) |
| Produces a closed path for a planner obstacle.
|
Draw & | draw (const ConvexPolyObstacle &o) |
| Produces a closed path for a planner obstacle.
|
Draw & | draw (const HierarchicalObstacle &o) |
| Produces a closed path for a planner obstacle.
|
Draw & | moveTo (const fmat::Column< 2 > &p) |
| Set the pen location without adding a line segment to the current path.
|
Draw & | moveTo (double x, double y) |
| Set the pen location without adding a line segment to the current path.
|
Draw & | lineTo (const fmat::Column< 2 > &p) |
| Add a line segment to the current path.
|
Draw & | lineTo (double x, double y) |
| Add a line segment to the current path.
|
Draw & | arcTo (const fmat::Column< 2 > &p, double r, double begin, double end) |
| Produces an arc of the specified range (continuing the current path).
|
Draw & | arcTo (double x, double y, double r, double begin, double end) |
| Produces an arc of the specified range (continuing the current path).
|
Draw & | closePath () |
| Add a line segment back to the last moveTo location.
|
Draw & | holdPath (bool continuePath=false) |
| Clears path unless continuePath is set, additional paths will be collected together until releasePath() is called.
|
Draw & | releasePath () |
| Clears the hold flag from holdPath(), but does not actually clear the path.
|
bool | getHoldMode () const |
| Returns current hold setting.
|
Draw & | clearPath () |
| Erase current path, but does not reset holdPath() mode.
|
Protected Member Functions |
void | teardown () |
| Flush pending output and release resources.
|
void | resetTransform () |
| Recomputes and applies the surface transform.
|
void | checkSurfaceStatus (const std::string &msg) |
| Throws an exception if surface status is not success.
|
void | checkStatus (const std::string &msg) |
| Throws an exception if either cairo or surface status is not success.
|
Protected Attributes |
cairo_t * | cr |
cairo_surface_t * | surface |
std::string | filename |
fmat::Column< 2 > | origin |
double | scale |
double | surfaceWidth |
double | surfaceHeight |
bool | addPath |
| Indicates state of holdPath()/releasePath(), if true the path isn't cleared between draw calls.
|
Private Member Functions |
| Draw (const Draw &o) |
| Do not call.
|
Draw & | operator= (const Draw &o) |
| Do not call.
|
Member Enumeration Documentation
Convenient color constants.
- Enumerator:
BLACK |
|
DK_GRAY |
|
GRAY |
|
LT_GRAY |
|
WHITE |
|
RED |
|
YELLOW |
|
GREEN |
|
CYAN |
|
BLUE |
|
MAGENTA |
|
Definition at line 70 of file Draw.h.
Provides different point() styles.
- Enumerator:
-
Definition at line 102 of file Draw.h.
Constructor & Destructor Documentation
Default constructor, must still call setFile() before any drawing commands.
Definition at line 15 of file Draw.h.
Draw::Draw |
( |
const std::string & |
file, |
|
|
double |
width, |
|
|
double |
height | |
|
) |
| | |
Constructor, sets up output.
Definition at line 19 of file Draw.h.
Destructor.
Definition at line 23 of file Draw.h.
Draw::Draw |
( |
const Draw & |
o |
) |
[private] |
Member Function Documentation
Draw & Draw::arc |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
r, |
|
|
double |
begin, |
|
|
double |
end | |
|
) |
| | |
Produces an arc of the specified range.
Definition at line 78 of file Draw.cc.
Draw& Draw::arc |
( |
const fmat::Column< 2 > & |
p, |
|
|
double |
r, |
|
|
double |
begin, |
|
|
double |
end | |
|
) |
| | |
Produces an arc of the specified range.
Definition at line 112 of file Draw.h.
Referenced by arc(), and circle().
Draw & Draw::arcTo |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
r, |
|
|
double |
begin, |
|
|
double |
end | |
|
) |
| | |
Produces an arc of the specified range (continuing the current path).
Definition at line 90 of file Draw.cc.
Draw& Draw::arcTo |
( |
const fmat::Column< 2 > & |
p, |
|
|
double |
r, |
|
|
double |
begin, |
|
|
double |
end | |
|
) |
| | |
Produces an arc of the specified range (continuing the current path).
Definition at line 159 of file Draw.h.
Referenced by arcTo().
Draws a line between points with an arrowhead at p2, the headWidth and headLength are multiples of the stroke width.
You can stroke to get a barbed head, or fill to get a little triangle. For a really perfect filled arrowhead, call closePath() first to avoid a little bit of mitred corners sticking out.
Definition at line 81 of file Draw.cc.
Draw & Draw::centerView |
( |
double |
x, |
|
|
double |
y | |
|
) |
| | |
Moves the origin in order to center the viewport on the specified point.
Definition at line 70 of file Draw.cc.
Moves the origin in order to center the viewport on the specified point.
Definition at line 36 of file Draw.h.
Referenced by centerView(), and setRegion().
void Draw::checkStatus |
( |
const std::string & |
msg |
) |
[protected] |
Throws an exception if either cairo or surface status is not success.
Definition at line 95 of file Draw.cc.
void Draw::checkSurfaceStatus |
( |
const std::string & |
msg |
) |
[protected] |
Throws an exception if surface status is not success.
Definition at line 94 of file Draw.cc.
Draw& Draw::circle |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
r | |
|
) |
| | |
Produces a closed path for a circle at the specified point.
Definition at line 119 of file Draw.h.
Produces a closed path for a circle at the specified point.
Definition at line 117 of file Draw.h.
Draw & Draw::clearClip |
( |
|
) |
|
Clears the clipping region.
Definition at line 72 of file Draw.cc.
Draw & Draw::clearPath |
( |
|
) |
|
Draw & Draw::closePath |
( |
|
) |
|
Add a line segment back to the last moveTo location.
Definition at line 91 of file Draw.cc.
double Draw::displayToScaled |
( |
double |
x |
) |
const |
Converts from display units to scaled coordinates.
Definition at line 49 of file Draw.h.
Produces a closed path for a planner obstacle.
Definition at line 87 of file Draw.cc.
Produces a closed path for a planner obstacle.
Definition at line 86 of file Draw.cc.
Produces a closed path for a planner obstacle.
Definition at line 85 of file Draw.cc.
Produces a closed path for a planner obstacle.
Definition at line 84 of file Draw.cc.
Produces a closed path for a planner obstacle.
Definition at line 83 of file Draw.cc.
Produces a closed path for a planner obstacle.
Definition at line 82 of file Draw.cc.
Draw & Draw::drawAxes |
( |
|
) |
|
Draws the axes across the visible region (doesn't stroke).
Definition at line 63 of file Draw.cc.
Draw & Draw::drawGrid |
( |
double |
xRes, |
|
|
double |
yRes, |
|
|
double |
xOff = 0 , |
|
|
double |
yOff = 0 | |
|
) |
| | |
Draws a grid of the specified horizontal and vertical resolution across the visible region (doesn't stroke).
Definition at line 62 of file Draw.cc.
Draw & Draw::ellipse |
( |
const fmat::Column< 2 > & |
c, |
|
|
double |
width, |
|
|
double |
height, |
|
|
double |
orientation = 0 | |
|
) |
| | |
Produces an ellipse, note width and height, not major/minor.
Definition at line 79 of file Draw.cc.
Draw& Draw::fill |
( |
double |
red, |
|
|
double |
green, |
|
|
double |
blue, |
|
|
double |
alpha = 1 | |
|
) |
| | |
Paint the current path with specified color.
Definition at line 98 of file Draw.h.
Paint the current path with specified color.
Definition at line 96 of file Draw.h.
Paint the current path.
Definition at line 76 of file Draw.cc.
Referenced by fill().
Draw & Draw::flushPage |
( |
|
) |
|
Writes the current page and starts a new one.
Definition at line 69 of file Draw.cc.
bool Draw::getHoldMode |
( |
|
) |
const |
Returns current hold setting.
Definition at line 171 of file Draw.h.
double Draw::getScaledStrokeWidth |
( |
|
) |
const |
double Draw::getStrokeWidth |
( |
|
) |
const |
Returns the stroke width in output dimension units.
Definition at line 65 of file Draw.h.
Draw& Draw::holdPath |
( |
bool |
continuePath = false |
) |
|
Clears path unless continuePath is set, additional paths will be collected together until releasePath() is called.
Definition at line 167 of file Draw.h.
Draw & Draw::lineTo |
( |
double |
x, |
|
|
double |
y | |
|
) |
| | |
Add a line segment to the current path.
Definition at line 89 of file Draw.cc.
Add a line segment to the current path.
Definition at line 154 of file Draw.h.
Referenced by lineTo().
Draw & Draw::moveTo |
( |
double |
x, |
|
|
double |
y | |
|
) |
| | |
Set the pen location without adding a line segment to the current path.
Clears previous path unless holdPath() has been called.
Definition at line 88 of file Draw.cc.
Set the pen location without adding a line segment to the current path.
Definition at line 148 of file Draw.h.
Referenced by moveTo().
Draw& Draw::operator= |
( |
const Draw & |
o |
) |
[private] |
Draw & Draw::point |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
size, |
|
|
PointStyles |
style = CIRCLE | |
|
) |
| | |
Produces a output-dimension (i.e. unscaled) symbol at the specified point (follow up with fill() and/or stroke()).
Definition at line 77 of file Draw.cc.
Produces a output-dimension (i.e. unscaled) symbol at the specified point (follow up with fill() and/or stroke()).
Definition at line 107 of file Draw.h.
Referenced by point().
Produces a closed path for an axis-aligned rectangle between the specified points.
Definition at line 80 of file Draw.cc.
Produces a closed path for an axis-aligned rectangle.
Definition at line 125 of file Draw.h.
Referenced by rect().
Draw& Draw::releasePath |
( |
|
) |
|
Clears the hold flag from holdPath(), but does not actually clear the path.
Definition at line 169 of file Draw.h.
void Draw::resetTransform |
( |
|
) |
[protected] |
Recomputes and applies the surface transform.
Definition at line 93 of file Draw.cc.
Referenced by setOrigin().
double Draw::scaledToDisplay |
( |
double |
x |
) |
const |
Converts from scaled coordinates to display units.
Definition at line 51 of file Draw.h.
Clips further drawing to the current path area.
Definition at line 71 of file Draw.cc.
Draw & Draw::setColor |
( |
Colors |
c, |
|
|
double |
alpha = 1 | |
|
) |
| | |
Sets the color for future drawing operations.
Definition at line 3 of file Draw.cc.
Referenced by fill(), and stroke().
Draw& Draw::setColorGray |
( |
double |
x, |
|
|
double |
alpha = 1 | |
|
) |
| | |
Sets the color for future drawing operations.
Definition at line 77 of file Draw.h.
Draw & Draw::setColorRGB |
( |
double |
red, |
|
|
double |
green, |
|
|
double |
blue, |
|
|
double |
alpha = 1 | |
|
) |
| | |
Draw & Draw::setFile |
( |
const std::string & |
file, |
|
|
double |
width, |
|
|
double |
height | |
|
) |
| | |
This must be called to setup output destination before calling any drawing commands.
Definition at line 38 of file Draw.cc.
Referenced by Draw().
Draw& Draw::setOrigin |
( |
double |
x, |
|
|
double |
y | |
|
) |
| | |
Moves the origin (lower left corner).
Definition at line 34 of file Draw.h.
Moves the origin (lower left corner).
Definition at line 32 of file Draw.h.
Changes scale and origin to fit the specified drawing region to the output.
Definition at line 51 of file Draw.cc.
Draw & Draw::setScale |
( |
double |
x, |
|
|
bool |
scaleStroke = false | |
|
) |
| | |
Changes the scaling factor, to display more or less within the bounds given to setFile().
The apparent stroke width is unchanged unless you set scaleStroke
Definition at line 45 of file Draw.cc.
Referenced by setRegion().
Draw & Draw::setScaledStrokeWidth |
( |
double |
x |
) |
|
Sets the stroke width using coordinate-space units, i.e. relative to scale factor.
Definition at line 65 of file Draw.cc.
Draw & Draw::setStrokeWidth |
( |
double |
x |
) |
|
Sets the stroke width using output dimension units, i.e. scale factor invariant.
Definition at line 64 of file Draw.cc.
Draw& Draw::stroke |
( |
double |
red, |
|
|
double |
green, |
|
|
double |
blue, |
|
|
double |
alpha = 1 | |
|
) |
| | |
Outline the current path with specified color.
Definition at line 86 of file Draw.h.
Outline the current path with specified color.
Definition at line 84 of file Draw.h.
Outline the current path.
Definition at line 74 of file Draw.cc.
Referenced by stroke().
Draw & Draw::strokeLine |
( |
double |
x1, |
|
|
double |
y1, |
|
|
double |
x2, |
|
|
double |
y2 | |
|
) |
| | |
Stroke a single line; if drawing a polygon, better to use lineTo and stroke as a batch.
Definition at line 75 of file Draw.cc.
Stroke a single line; if drawing a polygon, better to use lineTo and stroke as a batch.
Definition at line 88 of file Draw.h.
Referenced by strokeLine().
void Draw::teardown |
( |
|
) |
[protected] |
Member Data Documentation
The documentation for this class was generated from the following files:
|