CVR-Lib last update 20 Sep 2009

cvrDraw.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1998
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  *
00006  * This file is part of the Computer Vision and Robotics Library (CVR-Lib)
00007  *
00008  * The CVR-Lib is free software; you can redistribute it and/or
00009  * modify it under the terms of the BSD License.
00010  *
00011  * All rights reserved.
00012  *
00013  * Redistribution and use in source and binary forms, with or without
00014  * modification, are permitted provided that the following conditions are met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright notice,
00017  *    this list of conditions and the following disclaimer.
00018  *
00019  * 2. Redistributions in binary form must reproduce the above copyright notice,
00020  *    this list of conditions and the following disclaimer in the documentation
00021  *    and/or other materials provided with the distribution.
00022  *
00023  * 3. Neither the name of the authors nor the names of its contributors may be
00024  *    used to endorse or promote products derived from this software without
00025  *    specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00037  * POSSIBILITY OF SUCH DAMAGE.
00038  */
00039 
00040 
00041 
00042 /**
00043  * \file   cvrDraw.h
00044  * \author Pablo Alvarado
00045  * \date   25.5.1998
00046  *
00047  * $Id: cvrDraw.h,v 1.14 2007/11/11 19:40:30 alvarado Exp $
00048  */
00049 
00050 #ifndef _CVR_DRAW_H_
00051 #define _CVR_DRAW_H_
00052 
00053 
00054 #include <vector>
00055 
00056 #include "cvrTypes.h"
00057 // #include "cvrHTypes.h"
00058 #include "cvrGenericMatrix.h"
00059 #include "cvrImage.h"
00060 #include "cvrIoPoints.h"
00061 #include "cvrBorderPoints.h"
00062 #include "cvrAreaPoints.h"
00063 #include "cvrPolygonPoints.h"
00064 #include "cvrIoHandler.h"
00065 #include "cvrPoint.h"
00066 #include "cvrLine.h"
00067 #include "cvrRectangle.h"
00068 #include "cvrLocation.h"
00069 #include "cvrAffineLocation.h"
00070 //#include "cvrKernel1D.h"
00071 //#include "cvrKernel2D.h"
00072 //#include "cvrSeparableKernel.h"
00073 #include "cvrRound.h"
00074 
00075 #include "cvrDrawBase.h"
00076 
00077 namespace cvr {
00078 
00079   /**
00080    * Object for drawing a number of geometric figures and lists
00081    * thereof, simple texts and a few other types with graphic
00082    * representation in a cvr::matrix. There are also methods to draw
00083    * Matlab-style markers instead of single pixels for points (see
00084    * marker()).
00085    *
00086    * The type T of this template class corresponds to the type T of the matrix.
00087    *
00088    * Example:
00089    *
00090    * if you want to draw on a channel, you can create an instance of
00091    * the draw-object this way:
00092    *
00093    * \code
00094    * cvr::draw<cvr::channel::value_type> drawer;  // drawer for channels
00095    * cvr::channel canvas(256,256,0.0f);   // a channel to draw on
00096    *
00097    * drawer.use(canvas);                  // draw on canvas
00098    * drawer.setColor(0.5f);               // use gray
00099    * drawer.line(0,0,255,255);            // draw a line from to upper-left
00100    *                                      // to the bottom-right corner.
00101    * \endcode
00102    *
00103    */
00104   template<class T>
00105   class draw : public drawBase<T> {
00106   public:
00107 
00108     /**
00109      * default constructor
00110      */
00111     draw();
00112 
00113     /**
00114      * copy constructor
00115      */
00116     draw(const draw<T>& other);
00117 
00118     /**
00119      * destructor
00120      */
00121     ~draw();
00122 
00123     /**
00124      * Gets the name of this object's class.
00125      */
00126     const std::string& name() const;
00127 
00128     /**
00129      * Creates a copy of this object
00130      */
00131     virtual draw<T>* clone() const;
00132 
00133     /**
00134      * Creates a new instance of the object's class
00135      */
00136     virtual draw<T>* newInstance() const;
00137 
00138     /**
00139      * Indicates in which image will be drawn
00140      */
00141     virtual void use(matrix<T>& img);
00142 
00143     /**
00144      * get a reference to the image currently being used.
00145      * \warning if you haven't set any image yet (see use()), an cvr::exception
00146      *          will be thrown
00147      */
00148     virtual matrix<T>& getCanvas();
00149 
00150     /**
00151      * get a read-only reference to the image currently being used.
00152      * \warning if you haven't set any image yet (see use()), an cvr::exception
00153      *          will be thrown
00154      */
00155     virtual const matrix<T>& getCanvas() const;
00156 
00157     /**
00158      * returns the size of the canvas
00159      */
00160     ipoint getCanvasSize();
00161 
00162     /**
00163      * Specifies color to be used. If the template type is rgbPixel
00164      * this means an actual color. For other template types, this sets
00165      * a gray-level.
00166      */
00167     void setColor(const T& px);
00168 
00169     /**
00170      * Specifies color to be used. If the template type is rgbPixel
00171      * this means an actual color. For other template types, this sets
00172      * a gray-level. Here, MATLAB style specifiers are used. See
00173      * setStyle(const char*) for details.
00174      */
00175     void setColor(const char* color);
00176 
00177     /**
00178      * Specifies gray-level to be used.
00179      */
00180     void setGray(const float k);
00181 
00182     /**
00183      * Get color being used
00184      */
00185     const T& getColor() const;
00186 
00187     /**
00188      * scale each pixel value with the given constant
00189      */
00190     void scale(const double factor);
00191 
00192     /**
00193      * fills the canvas with the actual color
00194      */
00195     void clear();
00196 
00197     /**
00198      * fill the canvas with the current color, starting at the given
00199      * seed until a color different to the original one at the seed is
00200      * found.  This is similar to the fill tools usually found in
00201      * paint programs.
00202      */
00203     void fill(const ipoint& seed);
00204 
00205     /**
00206      * fill the canvas with the current color, starting at the given
00207      * seed until a color different to the original one at the seed is
00208      * found.  This is similar to the fill tools usually found in
00209      * paint programs.
00210      */
00211     inline void fill(int x, int y);
00212 
00213     /**
00214      * fillUntil fills the canvas with the current color,
00215      * starting at the given seed until the stop color is reached.
00216      */
00217     void fillUntil(const ipoint& seed, const T& stopColor);
00218 
00219     /**
00220      * fillUntil fill the canvas with the current color,
00221      * starting at the given seed until the stop color is reached.
00222      */
00223     inline void fillUntil(int x, int y, const T& stopColor);
00224 
00225     /**
00226      * Set pixel at x, y in the color set by setColor().
00227      * @param x x-coordinate of the pixel to be set.
00228      * @param y y-coordinate of the pixel to be set.
00229      */
00230     void set(int x, int y);
00231 
00232     /**
00233      * Set pixel at p in the color set by setColor().
00234      * @param p coordinates of the pixel to be set
00235      */
00236     inline void set(const ipoint& p);
00237 
00238     /*
00239      * Set pixel at p in the color set by setColor().
00240      * @param p coordinates of the pixel to be set
00241      */
00242     /* TODO
00243     template<class U>
00244     inline void set(const hPoint2D<U>& p);
00245     */
00246 
00247     /**
00248      * Draw a line from the point (fx, fy) to point (tx, ty).
00249      * The "last point" will be defined with the last "set", "line" or
00250      * "lineTo" method.
00251      *
00252      * @param fx x coordinate of initial point.
00253      * @param fy y coordinate of initial point.
00254      * @param tx x coordinate of final point.
00255      * @param ty y coordinate of final point.
00256      */
00257     void line(int fx, int fy,
00258               int tx, int ty);
00259 
00260     /**
00261      * Draw a line from the point p to point p2.
00262      *
00263      * @param p1 initial point
00264      * @param p2 final point
00265      *
00266      * @see line(int, int, int, int)
00267      */
00268     inline void line(const ipoint& p1, const ipoint& p2);
00269 
00270     /**
00271      * Draw a line
00272      * @see line(int, int, int, int)
00273      */
00274     inline void line(const cvr::line<int>& l);
00275 
00276     /**
00277      * the homogeneus point p represents also a line, which equation is
00278      * given by p.x*x + p.y*y + p.h*1 = 0.  This line is drawn with this
00279      * member
00280      */
00281     /* TODO
00282     template <class U>
00283     inline void line(const hPoint2D<U>& p);
00284     */
00285 
00286     /**
00287      * Draw a line from the last point to (x, y).
00288      * The "last point" will be defined with the last "set", "point", "line" or
00289      * "lineTo" method.
00290      */
00291     void lineTo(int x, int y);
00292 
00293     /**
00294      * Draw a line from the last point to the point p.
00295      * The "last point" will be defined with the last "set", "point", "line" or
00296      * "lineTo" method.
00297      */
00298     inline void lineTo(const ipoint& p);
00299 
00300     /**
00301      * Doesn't draw anything, only sets the last position to the given
00302      * coordinates. This can be useful before using lineTo()
00303      */
00304     virtual void moveTo(int x, int y);
00305 
00306     /// make other base member functions lineTo available
00307     using drawBase<T>::lineTo;
00308 
00309     /**
00310      * Draws a vertical line from (x, y1) to (x, y2).
00311      */
00312     void verticalLine(int x, int y1, int y2);
00313 
00314     /**
00315      * Draws a vertical line from (p1.x, p1.y) to (p1.x, p2.y).
00316      */
00317     void verticalLine(const ipoint& p1, const ipoint& p2);
00318 
00319     /**
00320      * Draws a horizontal line from (x1, y) to (x2, y).
00321      */
00322     void horizontalLine(int x1, int x2, int y);
00323 
00324     /**
00325      * Draws a horizontal line from (p1.x, p1.y) to (p2.x, p1.y).
00326      */
00327     void horizontalLine(const ipoint& p1, const ipoint& p2);
00328 
00329     /**
00330      * draw an arrow. arrow tip will be at (tx, ty).
00331      * If size<1.0 then tipsize will be the relative portion of arrow length.
00332      * If size>1.0 then tipsize will be (int)size, independent of arrow length.
00333      */
00334     void arrow(int fx, int fy,
00335                int tx, int ty,
00336                const float& size=0.2f);
00337 
00338 
00339     /**
00340      * draw an arrow from point p1 to point p2
00341      */
00342     inline void arrow(const ipoint& p1, const ipoint& p2,
00343                       const float& size=0.2f);
00344 
00345     /**
00346      * draw a rectangle
00347      * @param r rectangle (with orientation 0)
00348      * @param filled true if the rectangle must be filled, false if only the
00349      *               border needs to be drawn.
00350      */
00351     inline void rectangle(const cvr::rectangle<int>& r, bool filled = false);
00352 
00353     /**
00354      * draw a rotated rectangle
00355      * @param r rectangle (with orientation 0)
00356      * @param angle rotation angle at the middle point of the rectangle
00357      * @param filled true if the rectangle must be filled, false if only the
00358      *               border needs to be drawn.
00359      */
00360     inline void rectangle(const cvr::rectangle<int>& r, const float angle,
00361                           bool filled);
00362 
00363     /**
00364      * draw a rectangle
00365      * @param upperLeft upper left corner of the rectangle with orientation 0
00366      * @param bottomRight bottom right corner of the rectangle with orientation
00367      *                    0
00368      * @param filled true if the rectangle must be filled, false if only the
00369      *               border needs to be drawn.
00370      * @see rectangle(int, int, int, int, bool)
00371      */
00372     inline void rectangle(const ipoint& upperLeft, const ipoint& bottomRight,
00373                           bool filled = false);
00374 
00375     /**
00376      * draw a rectangle
00377      * @param upperLeft upper left corner of the rectangle with orientation 0
00378      * @param bottomRight bottom right corner of the rectangle with orientation
00379      *                    0
00380      * @param angle rotation angle at the middle point of the rectangle
00381      * @param filled true if the rectangle must be filled, false if only the
00382      *               border needs to be drawn.
00383      * @see rectangle(int, int, int, int, bool)
00384      */
00385     inline void rectangle(const ipoint& upperLeft, const ipoint& bottomRight,
00386                           const float angle,
00387                           bool filled = false);
00388 
00389     /**
00390      * draw a rectangle.
00391      * @param xl left x-coordinate.
00392      * @param yu upper y-coordinate.
00393      * @param xr right x-coordinate.
00394      * @param yb bottom y-coordinate.
00395      * @param filled if true rectangle is filled
00396      */
00397     void rectangle(int xl, const  int yu,
00398                    int xr, int yb, bool filled = false);
00399 
00400     /**
00401      * draw a rectangle.
00402      * @param xl left x-coordinate.
00403      * @param yu upper y-coordinate.
00404      * @param xr right x-coordinate.
00405      * @param yb bottom y-coordinate.
00406      * @param angle rotation angle at the middle point of the rectangle
00407      * @param filled if true rectangle is filled
00408      */
00409     void rectangle(int xl, const  int yu,
00410                    int xr, int yb,
00411                    const float angle,
00412                    bool filled = false);
00413 
00414     /**
00415      * draw a polygon represented by the given polygonPoints list
00416      * optionally, it can be rotated by the given angle and shifted
00417      * @param poly the polygon vertices
00418      * @param filled true if the polygon must be filled, false otherwise
00419      * @param angle rotation angle on the mean point of the vertices
00420      * @param shift shift amount to the polygon points.
00421      */
00422     void polygon(const ipolygonPoints& poly,
00423                  bool filled = false,
00424                  const float angle=0.0f,
00425                  const ipoint& shift=ipoint(0,0));
00426 
00427     /**
00428      * draw a circle with circle center 'p1' and radius 'r'
00429      */
00430     void circle(const ipoint& p1, int r, bool filled = false);
00431 
00432     /**
00433      * draw a circle with circle center (x, y) and radius 'r'
00434      */
00435     inline void circle(int x, int y,
00436                        int r,
00437                        bool filled = false);
00438 
00439     /**
00440      * draw an ellipse with center 'p1' and main axes 'aX' and 'aY'
00441      */
00442     void ellipse(const ipoint& p1, int aX, int aY,
00443                  bool filled = false);
00444 
00445     /**
00446      * draw an ellipse with center 'p1' and main axes 'aX' and 'aY'
00447      */
00448     void ellipse(const ipoint& p1, int aX, int aY,
00449                  const float& angle, bool filled = false);
00450 
00451     /**
00452      * draw an arc from 'pA' to 'pB', clockwise around center 'p1'.
00453      */
00454     void arc(const ipoint& p1, const ipoint& pA, const ipoint& pB);
00455 
00456     /**
00457      * Sets pixels at all points in c, moved by he given offset.
00458      */
00459     inline void set(const ipointList& c, const ipoint& offset=ipoint(0,0));
00460 
00461     /**
00462      * draw a location.
00463      *
00464      * @param loc location with position, angle and radius
00465      * @param showAngleLine if true, a line from the middle point of the
00466      *        location (given by loc.position) with the angle given by
00467      *        loc.angle will be drawn.
00468      */
00469     inline void set(const location& loc, bool showAngleLine = false);
00470 
00471     /**
00472      * draw a rectLocation
00473      *
00474      * @param loc location with position, angle and radius
00475      * @param showAngleLine if true, a line from the middle point of the
00476      *        location (given by loc.position) with the angle given by
00477      *        loc.angle will be drawn.
00478      */
00479     inline void set(const rectLocation& loc, bool showAngleLine = false);
00480 
00481     /**
00482      * draw an affineLocation.
00483      *
00484      * @param loc affineLocation
00485      * @param approximateEllipse if true, an ellipse is drawn, otherwise the
00486      *        transformed square
00487      * @param showAngleLine if true, a line from the middle point of the
00488      *        location (given by loc.position) with the angle given by
00489      *        loc.angle will be drawn.
00490      */
00491     inline void set(const affineLocation& loc,
00492                     bool approximateEllipse = false,
00493                     bool showAngleLine = false);
00494 
00495     /**
00496      * draw a list of locations
00497      */
00498     inline void set(const list<location>& locs,
00499                     bool showAngleLine = false);
00500 
00501     /**
00502      * draw a list of locations
00503      */
00504     inline void set(const list<affineLocation>& locs,
00505                     bool approximateEllipse = false,
00506                     bool showAngleLine = false);
00507 
00508     /**
00509      * draw the contents of the vector using the whole image
00510      * @param vct the vector to be shown
00511      * @param axisColor color for the axis.  The vector will be drawn in the
00512      *                  default color (see setColor())
00513      * @param forceAxis0 if true, both axis will be shown, i.e. the value 0 for
00514      *                  the vector will be always shown.  If false, only the
00515      *                  required value-range will be shown
00516      */
00517     void set(const dvector& vct,
00518              const T& axisColor,
00519              bool forceAxis0 = true);
00520 
00521     /**
00522      * draw the contents of the vector using the whole image
00523      * @param vct the vector to be shown
00524      * @param axisColor color for the axis.  The vector will be drawn in the
00525      *                  default color (see setColor())
00526      * @param forceAxis0 if true, both axis will be shown, i.e. the value 0 for
00527      *                  the vector will be always shown.  If false, only the
00528      *                  required value-range will be shown
00529      */
00530     void set(const fvector& vct,
00531              const T& axisColor,
00532              bool forceAxis0 = true);
00533 
00534     /**
00535      * draw the contents of the vector using the whole image
00536      * @param vct the vector to be shown
00537      * @param axisColor color for the axis.  The vector will be drawn in the
00538      *                  default color (see setColor())
00539      * @param forceAxis0 if true, both axis will be shown, i.e. the value 0 for
00540      *                  the vector will be always shown.  If false, only the
00541      *                  required value-range will be shown
00542      */
00543     void set(const ivector& vct,
00544              const T& axisColor,
00545              bool forceAxis0 = true);
00546 
00547     /**
00548      * Draws a grid in the image.
00549      * The interpretation of delta depends on the value of interval.
00550      * if interval is true, the values are taken as number of pixels
00551      * between two grid lines in x and y direction. Otherwise, it
00552      * is used as number of grid lines.
00553      */
00554     void grid(const ipoint& delta, bool interval=true);
00555 
00556     /**
00557      * overlay the given channel using the actual color
00558      * The new pixel color is calculated as (1-c)*old_pixel_color+c*used_color,
00559      * where c is the channel color and used_color is the color set with
00560      * setColor().
00561      * The given channel will be overlayed at the given position
00562      * (default 0,0)
00563      * @param overlay channel to be overlayed
00564      * @param x position at x (the column)
00565      * @param y position at y (the row)
00566      */
00567     void overlay(const channel& overlay, int x = 0, int y = 0);
00568 
00569     /**
00570      * overlay the given channel using the actual color
00571      * The new pixel color is calculated as (1-c)*old_pixel_color+c*used_color,
00572      * where c is the channel color and used_color is the color set with
00573      * setColor().
00574      * The given channel will be overlayed at the given position
00575      * (default 0,0)
00576      * @param overlay channel to be overlayed
00577      * @param p position where <code>overlay</code> will be placed
00578      */
00579     void overlay(const channel& overlay, const ipoint& p);
00580 
00581     /**
00582      * overlay the given channel8 using the actual color
00583      * The new pixel color is calculated as
00584      * ((255-c)*old_pixel_color+c*used_color)/255,
00585      * where c is the channel color and used_color is the color set with
00586      * setColor()
00587      * @param overlay channel8 to be overlayed
00588      * @param x position at x (the column)
00589      * @param y position at y (the row)
00590      */
00591     void overlay(const channel8& overlay, int x = 0, int y = 0);
00592 
00593     /**
00594      * overlay the given channel8 using the actual color
00595      * The new pixel color is calculated as
00596      * ((255-c)*old_pixel_color+c*used_color)/255,
00597      * where c is the channel color and used_color is the color set with
00598      * setColor()
00599      * @param overlay channel to be overlayed
00600      * @param p position where <code>overlay</code> will be placed
00601      */
00602     void overlay(const channel8& overlay, const ipoint& p);
00603 
00604     /**
00605      * draw an integer <code>num</code> at position 'p1' with size 's'.
00606      * 's' must be given as quota of image height (0.0 to 1.0).
00607      *
00608      * @see text()
00609      *
00610      * @param num the number to be written
00611      * @param p1 the position where the number will be drawn
00612      * @param s scale factor as quota of image height
00613      */
00614     void number(int num,
00615                 const ipoint& p1 = ipoint(0,0),
00616                 const float& s = 0.03125f);
00617 
00618     /**
00619      * draw an integer <code>num</code> at position 'x'/'y' with size 's'.
00620      * 's' must be given as quota of image height (0.0 to 1.0).
00621      * @see text()
00622      * @param num the number to be written
00623      * @param x the column where the number will be drawn
00624      * @param y the row where the number will be drawn
00625      * @param s scale factor as quota of image height
00626      */
00627     void number(int num,
00628                 int x,
00629                 int y,
00630                 const float& s);
00631 
00632     /**
00633      * draw an integer <code>num</code> at position 'x'/'y' with size 's'.
00634      * 's' must be given as quota of image height (0.0 to 1.0).
00635      * @see text()
00636      * @param num the number to be written
00637      * @param x the column where the number will be drawn
00638      * @param y the row where the number will be drawn
00639      */
00640     inline void number(int num,
00641                        int x,
00642                        int y);
00643 
00644     /**
00645      * Draw the given text at the position <code>upperleft</code> with
00646      * a specified scale.
00647      * scale.x and scale.y must have values greater than zero.
00648      * The original size of one character is 8x8.
00649      * With the parameter opaqueness you can make transparent text.
00650      * Opaqueness = 1.0f means no transparency.
00651      * If <code>horizontal</code> is true the text is writen from left
00652      * to right.
00653      * @param txt the output text
00654      * @param upperleft the coordinates in the image where the text will be
00655      *                  written
00656      * @param scale a point with the (integer) scaling factor greater or equal
00657      *              one for each coordinate.  Note that you can use different
00658      *              scales for the width and height of the caracters
00659      * @param opaqueness value in percent (between 0.0f and 1.0f)
00660      * @param horizontal true left to rigth, false top to bottom
00661      */
00662     void text(const std::string txt,
00663               const ipoint& upperleft = ipoint(0,0),
00664               const ipoint& scale = ipoint(1,1),
00665               const float opaqueness = 1.0f,
00666               bool horizontal = true);
00667 
00668 
00669     /**
00670      * Draw the given text at the position <code>upperleft</code> with
00671      * a specified scale.
00672      * scale.x and scale.y must have values greater than zero.
00673      * The original size of one character is 8x8.
00674      * With the parameter opaqueness you can make transparent text.
00675      * Opaqueness = 1.0f means no transparency.
00676      * If <code>horizontal</code> is true the text is writen from left
00677      * to right.
00678      * @param txt the output text
00679      * @param x the x coordinate in the image where the text will be
00680      *                written
00681      * @param y the y coordinate in the image where the text will be
00682      *                written
00683      * @param scale a point with the (integer) scaling factor greater or equal
00684      *              one for each coordinate.  Note that you can use different
00685      *              scales for the width and height of the caracters
00686      * @param opaqueness value in percent (between 0.0f and 1.0f)
00687      * @param horizontal true left to rigth, false top to bottom
00688      */
00689     void text(const std::string txt,
00690               int x,
00691               int y,
00692               const ipoint& scale,
00693               const float opaqueness,
00694               bool horizontal);
00695 
00696     /**
00697      * Draw the text string txt at position x, y.
00698      * @see text(const std::string, int, int, const point&,
00699      *           const float, bool)
00700      */
00701     inline void text(const std::string txt, int x, int y);
00702 
00703   protected:
00704     /**
00705      * the "actual" image
00706      */
00707     matrix<T>* img_;
00708 
00709     /**
00710      * Color in use
00711      */
00712     T actColor_;
00713 
00714     /**
00715      * Returns "true" if the point is within the image
00716      */
00717     inline bool inCanvas(const ipoint& p) const;
00718 
00719     /**
00720      * Returns "true" if the point is within the image
00721      */
00722     inline bool inCanvas(int x, int y) const;
00723 
00724     /**
00725      * Checks if the line-segment between (x, y) and (x2, y2) lies
00726      * within the image.  If (x, y) lays out of the image boudaries
00727      * it will be "transformed" to a point in the image
00728      */
00729     bool correctLine (int &x, int &y, int x2, int y2);
00730 
00731     /**
00732      * This is need for drawing filled rotated ellipses
00733      */
00734     inline static ipoint turnPoint(const float x, const float y, float angle);
00735 
00736     /**
00737      * This is need for drawing filled rotated ellipses
00738      * this enters a point into the point list, the first one into x1
00739      * the second one into x2
00740      * if any more come, they are merged into the closest one.
00741      *
00742      * The vectors x1 and x2 can be seen as input- or output point lists, while
00743      * miny and maxy contain the range of y values used until now.
00744      *
00745      * You must ensure that the x1 and x2 arrays are bigger than the
00746      * value contained in p.y.
00747      */
00748     inline void enterPX(const ipoint& p,
00749                         int* x1, int* x2, int& miny, int& maxy);
00750 
00751     /**
00752      * Draws a symbol set with the method setStyle() at the given
00753      * position. Used by the marker() methods.
00754      */
00755     void drawSymbol(int x, int y);
00756 
00757     /**
00758      * Draws a symbol at the given location.  Used by the marker()
00759      * methods.
00760      */
00761     void drawSymbol(int x, int y, int w,
00762                     typename drawBase<T>::eMarkerType t);
00763 
00764     /**
00765      * Draws a symbol at the given location.  Used by the marker() methods.
00766      */
00767     void drawSymbol(int x, int y, int w, const char* style);
00768 
00769   };
00770 
00771 }
00772 
00773 #include "cvrDraw_inline.h"
00774 
00775 #endif
00776 

Generated on Sun Sep 20 22:07:59 2009 for CVR-Lib by Doxygen 1.5.8