last update 20 Sep 2009 |
#include <cvrDraw.h>
Public Member Functions | |
draw () | |
draw (const draw< T > &other) | |
~draw () | |
const std::string & | name () const |
virtual draw< T > * | clone () const |
virtual draw< T > * | newInstance () const |
virtual void | use (matrix< T > &img) |
virtual matrix< T > & | getCanvas () |
virtual const matrix< T > & | getCanvas () const |
ipoint | getCanvasSize () |
void | setColor (const T &px) |
void | setColor (const char *color) |
void | setGray (const float k) |
const T & | getColor () const |
void | scale (const double factor) |
void | clear () |
void | fill (const ipoint &seed) |
void | fill (int x, int y) |
void | fillUntil (const ipoint &seed, const T &stopColor) |
void | fillUntil (int x, int y, const T &stopColor) |
void | set (int x, int y) |
void | set (const ipoint &p) |
void | line (int fx, int fy, int tx, int ty) |
void | line (const ipoint &p1, const ipoint &p2) |
void | line (const cvr::line< int > &l) |
void | lineTo (int x, int y) |
void | lineTo (const ipoint &p) |
virtual void | moveTo (int x, int y) |
void | verticalLine (int x, int y1, int y2) |
void | verticalLine (const ipoint &p1, const ipoint &p2) |
void | horizontalLine (int x1, int x2, int y) |
void | horizontalLine (const ipoint &p1, const ipoint &p2) |
void | arrow (int fx, int fy, int tx, int ty, const float &size=0.2f) |
void | arrow (const ipoint &p1, const ipoint &p2, const float &size=0.2f) |
void | rectangle (const cvr::rectangle< int > &r, bool filled=false) |
void | rectangle (const cvr::rectangle< int > &r, const float angle, bool filled) |
void | rectangle (const ipoint &upperLeft, const ipoint &bottomRight, bool filled=false) |
void | rectangle (const ipoint &upperLeft, const ipoint &bottomRight, const float angle, bool filled=false) |
void | rectangle (int xl, const int yu, int xr, int yb, bool filled=false) |
void | rectangle (int xl, const int yu, int xr, int yb, const float angle, bool filled=false) |
void | polygon (const ipolygonPoints &poly, bool filled=false, const float angle=0.0f, const ipoint &shift=ipoint(0, 0)) |
void | circle (const ipoint &p1, int r, bool filled=false) |
void | circle (int x, int y, int r, bool filled=false) |
void | ellipse (const ipoint &p1, int aX, int aY, bool filled=false) |
void | ellipse (const ipoint &p1, int aX, int aY, const float &angle, bool filled=false) |
void | arc (const ipoint &p1, const ipoint &pA, const ipoint &pB) |
void | set (const ipointList &c, const ipoint &offset=ipoint(0, 0)) |
void | set (const location &loc, bool showAngleLine=false) |
void | set (const rectLocation &loc, bool showAngleLine=false) |
void | set (const affineLocation &loc, bool approximateEllipse=false, bool showAngleLine=false) |
void | set (const list< location > &locs, bool showAngleLine=false) |
void | set (const list< affineLocation > &locs, bool approximateEllipse=false, bool showAngleLine=false) |
void | set (const dvector &vct, const T &axisColor, bool forceAxis0=true) |
void | set (const fvector &vct, const T &axisColor, bool forceAxis0=true) |
void | set (const ivector &vct, const T &axisColor, bool forceAxis0=true) |
void | grid (const ipoint &delta, bool interval=true) |
void | overlay (const channel &overlay, int x=0, int y=0) |
void | overlay (const channel &overlay, const ipoint &p) |
void | overlay (const channel8 &overlay, int x=0, int y=0) |
void | overlay (const channel8 &overlay, const ipoint &p) |
void | number (int num, const ipoint &p1=ipoint(0, 0), const float &s=0.03125f) |
void | number (int num, int x, int y, const float &s) |
void | number (int num, int x, int y) |
void | text (const std::string txt, const ipoint &upperleft=ipoint(0, 0), const ipoint &scale=ipoint(1, 1), const float opaqueness=1.0f, bool horizontal=true) |
void | text (const std::string txt, int x, int y, const ipoint &scale, const float opaqueness, bool horizontal) |
void | text (const std::string txt, int x, int y) |
Protected Member Functions | |
bool | inCanvas (const ipoint &p) const |
bool | inCanvas (int x, int y) const |
bool | correctLine (int &x, int &y, int x2, int y2) |
void | enterPX (const ipoint &p, int *x1, int *x2, int &miny, int &maxy) |
void | drawSymbol (int x, int y) |
void | drawSymbol (int x, int y, int w, typename drawBase< T >::eMarkerType t) |
void | drawSymbol (int x, int y, int w, const char *style) |
Static Protected Member Functions | |
static ipoint | turnPoint (const float x, const float y, float angle) |
Protected Attributes | |
matrix< T > * | img_ |
T | actColor_ |
There are also methods to draw Matlab-style markers instead of single pixels for points (see marker()).
The type T of this template class corresponds to the type T of the matrix.
Example:
if you want to draw on a channel, you can create an instance of the draw-object this way:
cvr::draw<cvr::channel::value_type> drawer; // drawer for channels cvr::channel canvas(256,256,0.0f); // a channel to draw on drawer.use(canvas); // draw on canvas drawer.setColor(0.5f); // use gray drawer.line(0,0,255,255); // draw a line from to upper-left // to the bottom-right corner.
void cvr::draw< T >::arrow | ( | int | fx, | |
int | fy, | |||
int | tx, | |||
int | ty, | |||
const float & | size = 0.2f | |||
) | [virtual] |
draw an arrow.
arrow tip will be at (tx, ty). If size<1.0 then tipsize will be the relative portion of arrow length. If size>1.0 then tipsize will be (int)size, independent of arrow length.
Implements cvr::drawBase< T >.
void cvr::draw< T >::circle | ( | int | x, | |
int | y, | |||
int | r, | |||
bool | filled = false | |||
) | [inline] |
draw a circle with circle center (x, y) and radius 'r'
void cvr::draw< T >::clear | ( | ) |
fills the canvas with the actual color
bool cvr::draw< T >::correctLine | ( | int & | x, | |
int & | y, | |||
int | x2, | |||
int | y2 | |||
) | [protected] |
void cvr::draw< T >::drawSymbol | ( | int | x, | |
int | y, | |||
int | w, | |||
const char * | style | |||
) | [protected, virtual] |
void cvr::draw< T >::drawSymbol | ( | int | x, | |
int | y, | |||
int | w, | |||
typename drawBase< T >::eMarkerType | t | |||
) | [protected] |
void cvr::draw< T >::drawSymbol | ( | int | x, | |
int | y | |||
) | [protected] |
Draws a symbol set with the method setStyle() at the given position.
Used by the marker() methods.
void cvr::draw< T >::enterPX | ( | const ipoint & | p, | |
int * | x1, | |||
int * | x2, | |||
int & | miny, | |||
int & | maxy | |||
) | [inline, protected] |
This is need for drawing filled rotated ellipses this enters a point into the point list, the first one into x1 the second one into x2 if any more come, they are merged into the closest one.
The vectors x1 and x2 can be seen as input- or output point lists, while miny and maxy contain the range of y values used until now.
You must ensure that the x1 and x2 arrays are bigger than the value contained in p.y.
void cvr::draw< T >::fill | ( | int | x, | |
int | y | |||
) | [inline] |
fill the canvas with the current color, starting at the given seed until a color different to the original one at the seed is found.
This is similar to the fill tools usually found in paint programs.
fill the canvas with the current color, starting at the given seed until a color different to the original one at the seed is found.
This is similar to the fill tools usually found in paint programs.
void cvr::draw< T >::fillUntil | ( | int | x, | |
int | y, | |||
const T & | stopColor | |||
) | [inline] |
fillUntil fill the canvas with the current color, starting at the given seed until the stop color is reached.
fillUntil fills the canvas with the current color, starting at the given seed until the stop color is reached.
get a read-only reference to the image currently being used.
get a reference to the image currently being used.
const T& cvr::draw< T >::getColor | ( | ) | const |
Get color being used.
void cvr::draw< T >::grid | ( | const ipoint & | delta, | |
bool | interval = true | |||
) | [virtual] |
Draws a grid in the image.
The interpretation of delta depends on the value of interval. if interval is true, the values are taken as number of pixels between two grid lines in x and y direction. Otherwise, it is used as number of grid lines.
Implements cvr::drawBase< T >.
void cvr::draw< T >::horizontalLine | ( | int | x1, | |
int | x2, | |||
int | y | |||
) | [virtual] |
bool cvr::draw< T >::inCanvas | ( | int | x, | |
int | y | |||
) | const [inline, protected] |
void cvr::draw< T >::line | ( | const ipoint & | p1, | |
const ipoint & | p2 | |||
) | [inline, virtual] |
Draw a line from the point p to point p2.
Reimplemented from cvr::drawBase< T >.
Draw a line from the point (fx, fy) to point (tx, ty).
The "last point" will be defined with the last "set", "line" or "lineTo" method.
fx | x coordinate of initial point. | |
fy | y coordinate of initial point. | |
tx | x coordinate of final point. | |
ty | y coordinate of final point. |
Implements cvr::drawBase< T >.
Draw a line from the last point to the point p.
The "last point" will be defined with the last "set", "point", "line" or "lineTo" method.
Reimplemented from cvr::drawBase< T >.
void cvr::draw< T >::lineTo | ( | int | x, | |
int | y | |||
) | [virtual] |
the homogeneus point p represents also a line, which equation is given by p.x*x + p.y*y + p.h*1 = 0.
This line is drawn with this member Draw a line from the last point to (x, y). The "last point" will be defined with the last "set", "point", "line" or "lineTo" method.
Implements cvr::drawBase< T >.
virtual void cvr::draw< T >::moveTo | ( | int | x, | |
int | y | |||
) | [virtual] |
Doesn't draw anything, only sets the last position to the given coordinates.
This can be useful before using lineTo()
Implements cvr::drawBase< T >.
const std::string& cvr::draw< T >::name | ( | ) | const [virtual] |
void cvr::draw< T >::number | ( | int | num, | |
int | x, | |||
int | y | |||
) | [inline, virtual] |
draw an integer num
at position 'x'/'y' with size 's'.
's' must be given as quota of image height (0.0 to 1.0).
num | the number to be written | |
x | the column where the number will be drawn | |
y | the row where the number will be drawn |
Implements cvr::drawBase< T >.
void cvr::draw< T >::number | ( | int | num, | |
int | x, | |||
int | y, | |||
const float & | s | |||
) |
overlay the given channel8 using the actual color The new pixel color is calculated as ((255-c)*old_pixel_color+c*used_color)/255, where c is the channel color and used_color is the color set with setColor()
overlay | channel to be overlayed | |
p | position where overlay will be placed |
overlay the given channel8 using the actual color The new pixel color is calculated as ((255-c)*old_pixel_color+c*used_color)/255, where c is the channel color and used_color is the color set with setColor()
overlay | channel8 to be overlayed | |
x | position at x (the column) | |
y | position at y (the row) |
overlay the given channel using the actual color The new pixel color is calculated as (1-c)*old_pixel_color+c*used_color, where c is the channel color and used_color is the color set with setColor().
The given channel will be overlayed at the given position (default 0,0)
overlay | channel to be overlayed | |
p | position where overlay will be placed |
overlay the given channel using the actual color The new pixel color is calculated as (1-c)*old_pixel_color+c*used_color, where c is the channel color and used_color is the color set with setColor().
The given channel will be overlayed at the given position (default 0,0)
overlay | channel to be overlayed | |
x | position at x (the column) | |
y | position at y (the row) |
void cvr::draw< T >::polygon | ( | const ipolygonPoints & | poly, | |
bool | filled = false , |
|||
const float | angle = 0.0f , |
|||
const ipoint & | shift = ipoint(0, 0) | |||
) | [virtual] |
draw a polygon represented by the given polygonPoints list optionally, it can be rotated by the given angle and shifted
poly | the polygon vertices | |
filled | true if the polygon must be filled, false otherwise | |
angle | rotation angle on the mean point of the vertices | |
shift | shift amount to the polygon points. |
Implements cvr::drawBase< T >.
void cvr::draw< T >::rectangle | ( | int | xl, | |
const int | yu, | |||
int | xr, | |||
int | yb, | |||
bool | filled = false | |||
) | [virtual] |
xl | left x-coordinate. | |
yu | upper y-coordinate. | |
xr | right x-coordinate. | |
yb | bottom y-coordinate. | |
filled | if true rectangle is filled |
Implements cvr::drawBase< T >.
void cvr::draw< T >::rectangle | ( | const ipoint & | upperLeft, | |
const ipoint & | bottomRight, | |||
const float | angle, | |||
bool | filled = false | |||
) | [inline] |
upperLeft | upper left corner of the rectangle with orientation 0 | |
bottomRight | bottom right corner of the rectangle with orientation 0 | |
angle | rotation angle at the middle point of the rectangle | |
filled | true if the rectangle must be filled, false if only the border needs to be drawn. |
void cvr::draw< T >::rectangle | ( | const ipoint & | upperLeft, | |
const ipoint & | bottomRight, | |||
bool | filled = false | |||
) | [inline, virtual] |
upperLeft | upper left corner of the rectangle with orientation 0 | |
bottomRight | bottom right corner of the rectangle with orientation 0 | |
filled | true if the rectangle must be filled, false if only the border needs to be drawn. |
Reimplemented from cvr::drawBase< T >.
void cvr::draw< T >::rectangle | ( | const cvr::rectangle< int > & | r, | |
const float | angle, | |||
bool | filled | |||
) | [inline] |
void cvr::draw< T >::rectangle | ( | const cvr::rectangle< int > & | r, | |
bool | filled = false | |||
) | [inline, virtual] |
r | rectangle (with orientation 0) | |
filled | true if the rectangle must be filled, false if only the border needs to be drawn. |
Reimplemented from cvr::drawBase< T >.
void cvr::draw< T >::scale | ( | const double | factor | ) |
scale each pixel value with the given constant
void cvr::draw< T >::set | ( | const ivector & | vct, | |
const T & | axisColor, | |||
bool | forceAxis0 = true | |||
) |
draw the contents of the vector using the whole image
vct | the vector to be shown | |
axisColor | color for the axis. The vector will be drawn in the default color (see setColor()) | |
forceAxis0 | if true, both axis will be shown, i.e. the value 0 for the vector will be always shown. If false, only the required value-range will be shown |
void cvr::draw< T >::set | ( | const fvector & | vct, | |
const T & | axisColor, | |||
bool | forceAxis0 = true | |||
) |
draw the contents of the vector using the whole image
vct | the vector to be shown | |
axisColor | color for the axis. The vector will be drawn in the default color (see setColor()) | |
forceAxis0 | if true, both axis will be shown, i.e. the value 0 for the vector will be always shown. If false, only the required value-range will be shown |
void cvr::draw< T >::set | ( | const dvector & | vct, | |
const T & | axisColor, | |||
bool | forceAxis0 = true | |||
) |
draw the contents of the vector using the whole image
vct | the vector to be shown | |
axisColor | color for the axis. The vector will be drawn in the default color (see setColor()) | |
forceAxis0 | if true, both axis will be shown, i.e. the value 0 for the vector will be always shown. If false, only the required value-range will be shown |
void cvr::draw< T >::set | ( | const list< affineLocation > & | locs, | |
bool | approximateEllipse = false , |
|||
bool | showAngleLine = false | |||
) | [inline, virtual] |
void cvr::draw< T >::set | ( | const affineLocation & | loc, | |
bool | approximateEllipse = false , |
|||
bool | showAngleLine = false | |||
) | [inline, virtual] |
draw an affineLocation.
loc | affineLocation | |
approximateEllipse | if true, an ellipse is drawn, otherwise the transformed square | |
showAngleLine | if true, a line from the middle point of the location (given by loc.position) with the angle given by loc.angle will be drawn. |
Reimplemented from cvr::drawBase< T >.
void cvr::draw< T >::set | ( | const rectLocation & | loc, | |
bool | showAngleLine = false | |||
) | [inline, virtual] |
loc | location with position, angle and radius | |
showAngleLine | if true, a line from the middle point of the location (given by loc.position) with the angle given by loc.angle will be drawn. |
Reimplemented from cvr::drawBase< T >.
void cvr::draw< T >::set | ( | const ipointList & | c, | |
const ipoint & | offset = ipoint(0, 0) | |||
) | [inline, virtual] |
Set pixel at p in the color set by setColor().
p | coordinates of the pixel to be set |
Reimplemented from cvr::drawBase< T >.
void cvr::draw< T >::set | ( | int | x, | |
int | y | |||
) | [virtual] |
Set pixel at x, y in the color set by setColor().
x | x-coordinate of the pixel to be set. | |
y | y-coordinate of the pixel to be set. |
Implements cvr::drawBase< T >.
void cvr::draw< T >::setColor | ( | const char * | color | ) | [virtual] |
Specifies color to be used.
If the template type is rgbPixel this means an actual color. For other template types, this sets a gray-level. Here, MATLAB style specifiers are used. See setStyle(const char*) for details.
Implements cvr::drawBase< T >.
void cvr::draw< T >::setColor | ( | const T & | px | ) | [virtual] |
Specifies color to be used.
If the template type is rgbPixel this means an actual color. For other template types, this sets a gray-level.
Implements cvr::drawBase< T >.
void cvr::draw< T >::setGray | ( | const float | k | ) | [virtual] |
void cvr::draw< T >::text | ( | const std::string | txt, | |
int | x, | |||
int | y | |||
) | [inline, virtual] |
void cvr::draw< T >::text | ( | const std::string | txt, | |
int | x, | |||
int | y, | |||
const ipoint & | scale, | |||
const float | opaqueness, | |||
bool | horizontal | |||
) |
Draw the given text at the position upperleft
with a specified scale.
scale.x and scale.y must have values greater than zero. The original size of one character is 8x8. With the parameter opaqueness you can make transparent text. Opaqueness = 1.0f means no transparency. If horizontal
is true the text is writen from left to right.
txt | the output text | |
x | the x coordinate in the image where the text will be written | |
y | the y coordinate in the image where the text will be written | |
scale | a point with the (integer) scaling factor greater or equal one for each coordinate. Note that you can use different scales for the width and height of the caracters | |
opaqueness | value in percent (between 0.0f and 1.0f) | |
horizontal | true left to rigth, false top to bottom |
void cvr::draw< T >::text | ( | const std::string | txt, | |
const ipoint & | upperleft = ipoint(0, 0) , |
|||
const ipoint & | scale = ipoint(1, 1) , |
|||
const float | opaqueness = 1.0f , |
|||
bool | horizontal = true | |||
) |
Draw the given text at the position upperleft
with a specified scale.
scale.x and scale.y must have values greater than zero. The original size of one character is 8x8. With the parameter opaqueness you can make transparent text. Opaqueness = 1.0f means no transparency. If horizontal
is true the text is writen from left to right.
txt | the output text | |
upperleft | the coordinates in the image where the text will be written | |
scale | a point with the (integer) scaling factor greater or equal one for each coordinate. Note that you can use different scales for the width and height of the caracters | |
opaqueness | value in percent (between 0.0f and 1.0f) | |
horizontal | true left to rigth, false top to bottom |
static ipoint cvr::draw< T >::turnPoint | ( | const float | x, | |
const float | y, | |||
float | angle | |||
) | [inline, static, protected] |
This is need for drawing filled rotated ellipses.
Indicates in which image will be drawn.
void cvr::draw< T >::verticalLine | ( | int | x, | |
int | y1, | |||
int | y2 | |||
) | [virtual] |