CVR-Lib last update 20 Sep 2009

cvrDrawBase.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   cvrDrawBase.h
00044  * \author Jens Paustenbach
00045  * \date   19.11.2002
00046  *
00047  * $Id: cvrDrawBase.h,v 1.11 2007/11/11 19:40:29 alvarado Exp $
00048  */
00049 
00050 #ifndef _CVR_DRAW_BASE_H_
00051 #define _CVR_DRAW_BASE_H_
00052 
00053 #include "cvrObject.h"
00054 #include "cvrStatus.h"
00055 #include "cvrTypes.h"
00056 #include "cvrImage.h"
00057 #include "cvrIoPoints.h"
00058 #include "cvrBorderPoints.h"
00059 #include "cvrAreaPoints.h"
00060 #include "cvrIoHandler.h"
00061 #include "cvrLocation.h"
00062 #include "cvrAffineLocation.h"
00063 #include "cvrRectLocation.h"
00064 //#include "cvrKernel1D.h"
00065 //#include "cvrKernel2D.h"
00066 //#include "cvrSeparableKernel.h"
00067 #include "cvrPoint.h"
00068 #include "cvrPointList.h"
00069 #include "cvrRectangle.h"
00070 #include "cvrList.h"
00071 
00072 namespace cvr {
00073 
00074   /**
00075    *  Abstract parent class for draw and epsDraw.
00076    *  This class provides all methods that are implemented in cvrDraw and
00077    *  cvrEpsDraw. It makes a base class availabel with all generall drawing
00078    *  methods. Some special methods, are not implemented in this base class.
00079    *  The class is aiming at providing a base class, so that, according to
00080    *  the given parameter, a picture is drawn or an eps file written. <br>
00081    */
00082   template<class T>
00083   class drawBase : public object, public status {
00084   public:
00085 
00086     /**
00087      * Specifies different types of marker which can be defined for
00088      * the marker-method.
00089      *
00090      * @see setMarkerType, setStyle
00091      */
00092     enum eMarkerType {
00093       Pixel = 0,     /**< Pixel          ('.') */
00094       Circle,        /**< Circle         ('o') */
00095       Xmark,         /**< Xmark          ('x') */
00096       Plus,          /**< Plus           ('+') */
00097       Star,          /**< Star           ('*') */
00098       Square,        /**< Square         ('s') */
00099       Diamond,       /**< Diamond        ('d') */
00100       TriangleUp,    /**< Triangle up    ('^') */
00101       TriangleDown,  /**< Triangle down  ('v') */
00102       TriangleLeft,  /**< Triangle left  ('<') */
00103       TriangleRight, /**< Triangle right ('>') */
00104       Dot            /**< Dot            ('#') */
00105     };
00106 
00107     /**
00108      * default constructor
00109      */
00110     drawBase();
00111 
00112 
00113     /**
00114      * copy constructor
00115      * @param other the object to be copied
00116      */
00117     drawBase(const drawBase& other);
00118 
00119     /**
00120      * destructor
00121      */
00122     virtual ~drawBase();
00123 
00124     /**
00125      * copy data of "other" functor.
00126      * @param other the functor to be copied
00127      * @return a reference to this functor object
00128      */
00129     drawBase& copy(const drawBase& other);
00130 
00131     /**
00132      * returns the name of this type
00133      */
00134     virtual const std::string& name() const;
00135 
00136     /**
00137      * Specifies grayscale level to be used (range from 0 to 1) for
00138      * the next graphics objects.
00139      */
00140     virtual void setGray(const float k) = 0;
00141 
00142     /**
00143      * Specifies the size for the next markers.
00144      * Default is 5 in draw and 2 in epsDraw
00145      */
00146     virtual void setMarkerSize(int size);
00147 
00148     /**
00149      * Specifies color to be used.
00150      */
00151     virtual void setColor(const char* color) = 0;
00152 
00153     /**
00154      * Specifies color to be used.
00155      */
00156     virtual void setColor(const T& color) = 0;
00157 
00158     /**
00159      * Sets the style used for drawing points. This includes the color and
00160      * the symbols for the %point
00161      * @see point(int, int, const char*)
00162      *
00163      * The string characterizing consists of two parts: the first
00164      * definining color and the second defining the symbol. These are
00165      * as close to the MATLAB(TM) attributes as possible. If one of the
00166      * parts is missing, the corresponding value remains unchanged.
00167      *
00168      * <table>
00169      * <tr>
00170      * <th>Colors</th> <th width="10%" > <br></th> <th>Symbols</th>
00171      * </tr>
00172      * <tr> <td>
00173      * <table>
00174      * <tr><td>y</td><td>yellow</td></tr>
00175      * <tr><td>m</td><td>magenta</td></tr>
00176      * <tr><td>c</td><td>cyan</td></tr>
00177      * <tr><td>r</td><td>red</td></tr>
00178      * <tr><td>g</td><td>green</td></tr>
00179      * <tr><td>b</td><td>blue</td></tr>
00180      * <tr><td>w</td><td>white</td></tr>
00181      * <tr><td>k</td><td>black</td></tr>
00182      * </table>
00183      * </td> <td> <br> </td>
00184      * <td>
00185      * <table>
00186      * <tr><td>.</td><td>point/pixel</td></tr>
00187      * <tr><td>o</td><td>circle</td></tr>
00188      * <tr><td>x</td><td>x-mark</td></tr>
00189      * <tr><td>+</td><td>plus</td></tr>
00190      * <tr><td>*</td><td>star</td></tr>
00191      * <tr><td>s</td><td>square</td></tr>
00192      * <tr><td>d</td><td>diamond</td></tr>
00193      * <tr><td>^</td><td>triangle (up)</td></tr>
00194      * <tr><td>v</td><td>triangle (down)</td></tr>
00195      * <tr><td><</td><td>triangle (left)</td></tr>
00196      * <tr><td>></td><td>triangle (right)</td></tr>
00197      * <tr><td>#</td><td>dot</td></tr>
00198      * </table>
00199      * </td></tr>
00200      * </table>
00201      *
00202      * In addition all colors except for black can be darkened by a
00203      * number between 0 and 9 following the color letter. The default
00204      * is 0. The higher the number, the darker the color. Also the
00205      * closed symbols are available in a filled version. This is
00206      * activated by an 'f' following the symbol specifier.
00207      *
00208      * Colors only work properly if the canvas used is of type image,
00209      * ie using rgbPixel as template type. Otherwise, gray-levels are
00210      * used instead of the colors. Here, 'c', 'm', and 'y' result in
00211      * the same gray-level as do 'r', 'g' and 'b'. For better
00212      * predictability use white with different factors for getting
00213      * gray-levels.
00214      *
00215      * A change of the color using setColor(const char*) or
00216      * setColor(const T&) does not affect the type of symbol being
00217      * used.
00218      */
00219     virtual void setStyle(const char* style);
00220 
00221     /**
00222      * Specifies the marker type to be used for points
00223      */
00224     virtual void setMarkerType(eMarkerType m);
00225 
00226     /*
00227      * Sets the pattern for drawing lines. All subsequent lines
00228      * will be drawn in the given pattern. The default is the
00229      * continuous line.
00230      * @param pat pattern for drawing lines.
00231      */
00232     // virtual void setLinePattern(const linePattern& pat);
00233 
00234     /*
00235      * Sets the pattern for filling areas. All subsequenly filled
00236      * areas will be filled with the given pattern. The default
00237      * pattern is a homogenouos fill.
00238      * @param pat pattern for filling areas.
00239      */
00240     // virtual void setFillPattern(const fillPattern& pat);
00241 
00242     /**
00243      * returns the size of the drawing area.
00244      */
00245     virtual ipoint getCanvasSize() = 0;
00246 
00247     /**
00248      * sets a single pixel at point (x, y)
00249      * In epsDraw this pixel is a small square.
00250      */
00251     virtual void set(int x, int y) = 0;
00252 
00253     /**
00254      * sets a single pixel at p
00255      */
00256     virtual inline void set(const ipoint& p);
00257 
00258     /**
00259      * sets a single pixel at p
00260      */
00261     /*
00262     template<class U>
00263     inline void set(const hPoint2D<U>& p);
00264     */
00265 
00266     /**
00267      * sets pixels at all points in c, moved by the given offset
00268      */
00269     virtual void set(const ipointList& c,
00270                      const ipoint& offset = ipoint(0,0));
00271 
00272     /**
00273      * draw a location.
00274      *
00275      * @param loc location with position, angle and radius
00276      * @param showAngleLine if true, a line from the middle point of the
00277      *        location (given by loc.position) with the angle given by
00278      *        loc.angle will be drawn.
00279      */
00280     virtual void set(const location& loc, bool showAngleLine = false);
00281 
00282     /**
00283      * draw a rectLocation
00284      *
00285      * @param loc location with position, angle and radius
00286      * @param showAngleLine if true, a line from the middle point of the
00287      *        location (given by loc.position) with the angle given by
00288      *        loc.angle will be drawn.
00289      */
00290     virtual void set(const rectLocation& loc, bool showAngleLine = false);
00291 
00292     /**
00293      * draw an affineLocation. Depending on \p approximateEllipse an ellipse
00294      * is approximated from the transMatrix of \p loc or the transformed
00295      * square is drawn.
00296      *
00297      * @param loc affineLocation
00298      * @param approximateEllipse if true, an ellipse is drawn, otherwise the
00299      *        transformed square
00300      * @param showAngleLine if true, a line from the middle point of the
00301      *        location (given by loc.position) with the angle given by
00302      *        loc.angle will be drawn.
00303      */
00304     virtual void set(const affineLocation& loc,
00305                      bool approximateEllipse = false,
00306                      bool showAngleLine = false);
00307 
00308     /**
00309      * draws a list of locations
00310      *
00311      * @see set(const location&, bool);
00312      */
00313     virtual void set(const list<location>& locs,
00314                      bool showAngleLine = false);
00315 
00316     /**
00317      * Draws a list of affineLocation
00318      *
00319      * @see set(const affineLocation&, bool, bool);
00320      */
00321     virtual void set(const list<affineLocation>& locs,
00322                      bool approximateEllipse = false,
00323                      bool showAngleLine = false);
00324 
00325     /**
00326      * Set marker at point (x, y).
00327      * If there is no style, markerType or width is given, the value
00328      * set by the setStyle or setWidth is used.
00329      * @param x the x coordinate
00330      * @param y the y coordinate
00331      */
00332     virtual inline void marker(int x, int y);
00333 
00334     /**
00335      * Set marker at point (x, y).
00336      * If there is no style, markerType or width is given, the value
00337      * set by the setStyle or setWidth is used.
00338      * @param x the x coordinate
00339      * @param y the y coordinate
00340      * @param width the size of the marker symbol
00341      */
00342     virtual inline void marker(int x, int y, int width);
00343 
00344     /**
00345      * Set marker at point (x, y).
00346      * If there is no style, markerType or width is given, the value
00347      * set by the setStyle or setWidth is used.
00348      * @param x the x coordinate
00349      * @param y the y coordinate
00350      * @param style the style of the marker symbol.
00351      */
00352     virtual inline void marker(int x, int y, const char* style);
00353 
00354     /**
00355      * Set marker at point (x, y).
00356      * If there is no style, markerType or width is given, the value
00357      * set by the setStyle or setWidth is used.
00358      * @param x the x coordinate
00359      * @param y the y coordinate
00360      * @param t the type of the marker
00361      */
00362     virtual inline void marker(int x, int y, eMarkerType t);
00363 
00364     /**
00365      * Set marker at point (x, y).
00366      * If there is no style, markerType or width is given, the value
00367      * set by the setStyle or setWidth is used.
00368      * @param x the x coordinate
00369      * @param y the y coordinate
00370      * @param w the size of the marker symbol
00371      * @param style the style of the marker symbol.
00372      */
00373     virtual inline void marker(int x, int y, int w, const char* style);
00374 
00375     /**
00376      * Set marker at point (x, y).
00377      * If there is no style, markerType or width is given, the value
00378      * set by the setStyle or setWidth is used.
00379      * @param x the x coordinate
00380      * @param y the y coordinate
00381      * @param w the size of the marker symbol
00382      * @param t the type of the marker
00383      */
00384     virtual inline void marker(int x, int y, int w, eMarkerType t);
00385 
00386     /**
00387      * Set marker at p.
00388      * @see marker(int, int)
00389      */
00390     virtual inline void marker(const ipoint& p);
00391 
00392     /**
00393      * Set marker at p with given width.
00394      * @see marker(int, int)
00395      */
00396     virtual inline void marker(const ipoint& p, int width);
00397 
00398     /**
00399      * Set marker at p with given style
00400      * @see marker(int, int)
00401      */
00402     virtual inline void marker(const ipoint& p, const char* style);
00403 
00404     /**
00405      * Set given marker type at p.
00406      * @see marker(int, int)
00407      */
00408     virtual inline void marker(const ipoint& p, eMarkerType t);
00409 
00410     /**
00411      * Set given marker type at p with given width.
00412      * @see marker(int, int)
00413      */
00414     virtual inline void marker(const ipoint& p, int width, eMarkerType t);
00415 
00416     /**
00417      * Set marker at p with given width and style.
00418      * @see marker(int, int)
00419      */
00420     virtual inline void marker(const ipoint& p, int width, const char* style);
00421 
00422     /*
00423      * Set marker at p.
00424      * @param p coordinates of the pixel to be set
00425      * @see marker(int, int)
00426      */
00427     /* TODO
00428     template <class U>
00429     inline void marker(const hPoint2D<U>& p);
00430     */
00431 
00432     /*
00433      * Set marker at p width given width.
00434      * @see marker(int, int)
00435      */
00436     /* TODO
00437     template <class U>
00438     inline void marker(const hPoint2D<U>& p, int width);
00439     */
00440 
00441     /*
00442      * Set given marker type at p.
00443      * @see marker(int, int)
00444      */
00445     /* TODO
00446     template <class U>
00447     inline void marker(const hPoint2D<U>& p, eMarkerType t);
00448     */
00449 
00450     /*
00451      * Set marker at p width given style.
00452      * @see marker(int, int, const char*)
00453      */
00454     /* TODO
00455     template <class U>
00456     inline void marker(const hPoint2D<U>& p, const char* style);
00457     */
00458 
00459     /*
00460      * Set given marker type at p with given width.
00461      * @see marker(int, int)
00462      */
00463     /* TODO
00464     template <class U>
00465     inline void marker(const hPoint2D<U>& p, int width, eMarkerType t);
00466     */
00467 
00468     /*
00469      * Set marker at p with given width and style.
00470      * @see marker(int, int)
00471      */
00472     /* TODO
00473     template <class U>
00474     inline void marker(const hPoint2D<U>& p, int width, const char* style);
00475     */
00476 
00477     /**
00478      * Sets markers at all positions in c, moved by offset.
00479      * @see marker(int, int)
00480      *
00481      * @param c list of points to put markers on.
00482      * @param offset offset to be added to all points in the previous list.
00483      */
00484     virtual inline void marker(const ipointList& c,
00485                                const ipoint& offset=ipoint(0,0));
00486 
00487     /**
00488      * Sets markers at all positions in c, moved by offset, with given width.
00489      * @see marker(int, int)
00490      *
00491      * @param c list of points to put markers on.
00492      * @param width width for all markers.
00493      * @param offset offset to be added to all points in the previous list.
00494      */
00495     virtual inline void marker(const ipointList& c, int width,
00496                                const ipoint& offset=ipoint(0,0));
00497 
00498     /**
00499      * Sets markers at all positions in c, moved by offset, with given style.
00500      *
00501      * @param c list of points to put markers on.
00502      * @param style string with format for the markers.
00503      * @param offset offset to be added to all points in the previous list.
00504      *
00505      * @see marker(int, int)
00506      */
00507     virtual inline void marker(const ipointList& c, const char* style,
00508                                const ipoint& offset=ipoint(0,0));
00509 
00510     /**
00511      * Sets given marker types at all positions in c, moved by offset.
00512      *
00513      * @param c list of points to put markers on.
00514      * @param t type of the markers.
00515      * @param offset offset to be added to all points in the previous list.
00516      *
00517      * @see marker(int, int)
00518      */
00519     virtual inline void marker(const ipointList& c, eMarkerType t,
00520                                const ipoint& offset=ipoint(0,0));
00521 
00522     /**
00523      * Sets markers at all positions in the c, moved by offset, with given
00524      * width and style.
00525      *
00526      * @param c list of points to put markers on.
00527      * @param width width of the marker
00528      * @param style string denoting the marker type.
00529      * @param offset offset to be added to all points in the previous list.
00530      *
00531      * @see marker(int, int)
00532      */
00533     virtual void marker(const ipointList& c, int width, const char* style,
00534                         const ipoint& offset=ipoint(0,0));
00535 
00536     /**
00537      * Sets given marker types at all positions in the c, moved by offset,
00538      * with given width.
00539      *
00540      * @param c list of points to put markers on.
00541      * @param width width of the marker
00542      * @param t marker type
00543      * @param offset offset to be added to all points in the previous list.
00544      *
00545      * @see marker(int, int)
00546      */
00547     virtual void marker(const ipointList& c, int width, eMarkerType t,
00548                         const ipoint& offset=ipoint(0,0));
00549 
00550     /**
00551      * Draws a line from the point (fx, fy) to point (tx, ty).
00552      * The "last point" will be defined with the last "set", "line" or
00553      * "lineTo" method.
00554      *
00555      * @param fx x component of the initial point.
00556      * @param fy y component of the initial point.
00557      * @param tx x component of the initial point.
00558      * @param ty y component of the initial point.
00559      */
00560     virtual void line(int fx, int fy,
00561                       int tx, int ty) = 0;
00562 
00563 
00564     /**
00565      * Draws a line from the point p to point p2.
00566      *
00567      * @see line(int, int, int, int)
00568      *
00569      * @param p1 the initial point.
00570      * @param p2 the initial point.
00571      */
00572     virtual inline void line(const ipoint& p1, const ipoint& p2);
00573 
00574     /**
00575      * Draws a line from the last point to point (x, y).
00576      * The "last point" will be defined with the last "set", "point", "line" or
00577      * "lineTo" method.
00578      *
00579      * @param x x component of the initial point.
00580      * @param y y component of the initial point.
00581      */
00582     virtual void lineTo(int x, int y) = 0;
00583 
00584     /**
00585      * Draw a line from the last point to point p.
00586      * @see lineTo(int, int)
00587      *
00588      * @param p initial point.
00589      *
00590      */
00591     virtual inline void lineTo(const ipoint& p);
00592 
00593     /**
00594      * Doesn't draw anything, only sets the last position to the given
00595      * coordinates. This can be useful before using lineTo()
00596      *
00597      * @param x x component of the destination point.
00598      * @param y y component of the destination point.
00599      */
00600     virtual void moveTo(int x, int y) = 0;
00601 
00602     /**
00603      * Doesn't draw anything, only sets the last position to the given
00604      * coordinates. This can be useful before using lineTo()
00605      *
00606      * @param p destination point.
00607      */
00608     virtual inline void moveTo(const ipoint& p);
00609 
00610     /**
00611      * Draws a vertical line from (x, y1) to (x, y2).
00612      *
00613      * @param x x component of the line
00614      * @param y1 y component of the initial point.
00615      * @param y2 y component of the final point.
00616      */
00617     virtual void verticalLine(int x, int y1, int y2) = 0;
00618 
00619     /**
00620      * Draws a horizontal line from (x1, y) to (x2, y).
00621      *
00622      * @param x1 x component of the initial point.
00623      * @param x2 x component of the final point.
00624      * @param y y component of the line.
00625      */
00626     virtual void horizontalLine(int x1, int x2, int y) = 0;
00627 
00628     /**
00629      * Draws a vertical line from (p1.x, p1.y) to (p1.x, p2.y).
00630      *
00631      * @param p1 position of the initial point
00632      * @param p2 provides only the end y position of the line.
00633      */
00634     virtual inline void verticalLine(const ipoint& p1, const ipoint& p2);
00635 
00636     /**
00637      * Draws a horizontal line from (p1.x, p1.y) to (p2.x, p1.y).
00638      *
00639      * @param p1 position of the initial point
00640      * @param p2 provides only the end x position of the line.
00641      */
00642     virtual inline void horizontalLine(const ipoint& p1, const ipoint& p2);
00643 
00644     /**
00645      * Draw a line from the point p with the length "length" and the
00646      * angle "angle".  The angles should be a value between -2Pi and
00647      * 2Pi in radian.
00648      *
00649      * @param p initial position of the line.
00650      * @param length length of the line.
00651      * @param angle angle of the line.
00652      */
00653     virtual void polarLine(const ipoint& p,
00654                            const float& length,
00655                            const float& angle);
00656 
00657     /**
00658      * Draws a grid in the image.
00659      *
00660      * The interpretation of \a delta depends on the value of \a interval.
00661      *
00662      * If \a interval is \a true, the values are taken as number of
00663      * pixels between two grid lines in x and y direction.
00664      * Otherwise, it is used as number of grid lines.
00665      *
00666      * \warning This method is not yet implemented in epsDraw!
00667      *
00668      * @param delta Number of pixels between lines or number of lines in
00669      *              the image.
00670      * @param interval if \a true then \a delta means distance between lines,
00671      *                 otherwise it means number of lines.
00672      */
00673     virtual void grid(const ipoint& delta, bool interval) = 0;
00674 
00675     /**
00676      * Draw a rectangle.
00677      *
00678      * @param x1 left x-coordinate.
00679      * @param y1 upper y-coordinate.
00680      * @param x2 right x-coordinate.
00681      * @param y2 bottom y-coordinate.
00682      * @param filled if true rectangle is filled
00683      */
00684     virtual void rectangle(int x1, int y1,
00685                            int x2, int y2,
00686                            bool filled = false) = 0;
00687 
00688     /**
00689      * Draws a rectangle.
00690      *
00691      * @param upperLeft upper left corner of the rectangle
00692      * @param bottomRight bottom right corner of the rectangle
00693      * @param filled if true rectangle is filled
00694      */
00695     virtual inline void rectangle(const ipoint& upperLeft,
00696                                   const ipoint& bottomRight,
00697                                   bool filled = false);
00698 
00699     /**
00700      * Draw a rectangle.
00701      *
00702      * The rectangle must contain the upper left and the bottom right point.
00703      *
00704      * @param r rectangle to be drawn
00705      * @param filled if true rectangle is filled
00706      */
00707     virtual inline void rectangle(const cvr::rectangle<int>& r,
00708                                   bool filled = false);
00709 
00710     /**
00711      * Draw a polygon represented by the given polygonPoints list
00712      * optionally, it can be rotated by the given angle and shifted.
00713      *
00714      * @param poly the polygon vertices
00715      * @param filled true if the polygon must be filled, false otherwise
00716      * @param angle rotation angle on the mean point of the vertices
00717      * @param shift shift amount to the polygon points.
00718      */
00719     virtual void polygon(const ipolygonPoints& poly,
00720                          bool filled = false,
00721                          const float angle=0.0f,
00722                          const ipoint& shift=ipoint(0,0)) = 0;
00723 
00724     /**
00725      * Draw a circle with circle center 'p1' and radius 'r'.
00726      *
00727      * @param p1 center of the circle
00728      * @param r radius of the circle
00729      * @param filled if true circle is filled
00730      */
00731     virtual void circle(const ipoint& p1, int r,
00732                         bool filled = false) = 0;
00733 
00734 
00735     /**
00736      * Draw an ellipse with center 'p1' and main axes 'aX' and 'aY'.
00737      */
00738     virtual void ellipse(const ipoint& p1, int aX, int aY,
00739                          bool filled = false) = 0;
00740 
00741     /**
00742      * Draw an ellipse with center 'p1' and main axes 'aX' and 'aY'.
00743      *
00744      * The ellipse is turned by the given angle.
00745      *
00746      * @param p1 center of ellipse
00747      * @param aX radius of ellipse in the first main direction
00748      * @param aY radius of ellipse in the second main direction
00749      * @param angle angle between first main direction and x axis. Must be
00750      *              given in radians (rad=deg/180*Pi).
00751      * @param filled if true, the ellipse is filled
00752      */
00753     virtual void ellipse(const ipoint& p1, int aX, int aY,
00754                          const float& angle, bool filled = false) = 0;
00755 
00756     /**
00757      * Draw an arc from 'pA' to 'pB', clockwise around center 'p1'.
00758      *
00759      * @param p1 center of the arc.
00760      * @param pA initial point
00761      * @param pB final point
00762      */
00763     virtual void arc(const ipoint& p1, const ipoint& pA, const ipoint& pB) = 0;
00764 
00765 
00766     /**
00767      * Draw an arrow. arrow tip will be at (tx, ty).
00768      * If size<1.0 then tipsize will be the relative portion of arrow length.
00769      * If size>1.0 then tipsize will be (int)size, independent of arrow length.
00770      *
00771      * @param fx x coordinate of the initial point.
00772      * @param fy y coordinate of the initial point.
00773      * @param tx x coordinate of the final point.
00774      * @param ty y coordinate of the final point.
00775      * @param size size of the arrow
00776      */
00777     virtual void arrow(int fx, int fy,
00778                        int tx, int ty,
00779                        const float& size=0.2f) = 0;
00780 
00781     /**
00782      * Draw an arrow. arrow tip will be at p2.
00783      * If size<1.0 then tipsize will be the relative portion of arrow length.
00784      * If size>1.0 then tipsize will be (int)size, independent of arrow length.
00785      *
00786      * @param p1 initial point.
00787      * @param p2 coordinate of the initial point.
00788      * @param size size of the arrow
00789      */
00790     virtual inline void arrow(const ipoint& p1,
00791                               const ipoint& p2, const float& size=0.2f);
00792 
00793     /**
00794      * Draw the given text at the position x, y.
00795      * According to the typ of the subclass the position and the lenght of
00796      * the drawn text could differ
00797      * @param txt the output text
00798      * @param x the x coordinate in the image where the text will be
00799      *                written
00800      * @param y the y coordinate in the image where the text will be
00801      *                written
00802      */
00803     virtual void text(const std::string txt, int x, int y) = 0;
00804 
00805     /**
00806      * Draw the given text at the position p=(x, y).
00807      * @see test(std::string, int, int)
00808      *
00809      * @param txt the output text
00810      * @param p coordinate in the image where the text will be written.
00811      */
00812     virtual inline void text(const std::string txt, const ipoint& p);
00813 
00814     /**
00815      * Draw an integer <code>num</code> at position 'x'/'y'.
00816      * According to the typ of the subclass the position and the lenght of
00817      * the drawn text could differ
00818      * @param num the number to be written
00819      * @param x the column where the number will be drawn
00820      * @param y the row where the number will be drawn
00821      */
00822     virtual void number(int num, int x, int y) = 0;
00823 
00824     /**
00825      * Draw an integer <code>num</code> at position p='x'/'y'.
00826      *
00827      * @see number(int, int, int)
00828      *
00829      * @param num the number to be written
00830      * @param p the coordinates where the number will be drawn
00831      */
00832     virtual inline void number(int num, const ipoint& p);
00833 
00834 
00835   protected:
00836 
00837     /**
00838      * actual (last used) position X
00839      */
00840     int actX_;
00841 
00842     /**
00843      * actual (last used) position Y
00844      */
00845     int actY_;
00846 
00847     /**
00848      * the actual symbol that is used for markers
00849      */
00850     eMarkerType actSymbol_;
00851 
00852     /**
00853      * the actual size that is used for markers
00854      * for epsDraw the default is 1 and for draw the default is 5
00855      * because the elements are much smaller and with a size smaller than 5
00856      * they are indistinguishable.
00857      */
00858     int actSize_;
00859 
00860     /**
00861      * If true symbols are filled where possible.
00862      */
00863     bool filled_;
00864 
00865     /**
00866      * The pattern for drawing lines.
00867      */
00868     // TODO
00869     // linePattern linepat_;
00870 
00871     /**
00872      * The pattern for filling areas.
00873      */
00874     // TODO
00875     // fillPattern fillpat_;
00876 
00877     /**
00878      * Flag telling the drawing methods to use the pattern.
00879      */
00880     bool useLinePattern_;
00881 
00882     /**
00883      * Flag telling the drawing methods to use the pattern.
00884      */
00885     bool useFillPattern_;
00886 
00887   private:
00888     /**
00889      * Abstract drawing methods for markers. This methods are needed by the
00890      * marker methods
00891      */
00892     virtual void drawSymbol(int x, int y, int w, const char* style) = 0;
00893     /**
00894      * Abstract drawing methods for markers. This methods are needed by the
00895      * marker methods
00896      */
00897     virtual void drawSymbol(int x, int y, int w, eMarkerType t) = 0;
00898 
00899 
00900   };
00901 
00902 }
00903 
00904 #include "cvrDrawBase_inline.h"
00905 
00906 #endif
00907 

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