![]() |
latest version v1.9 - last update 10 Apr 2010 |
![]() |
00001 /* 00002 * Copyright (C) 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /* ----------------------------------------------------------------------- 00025 * project ....: LTI Digitale Bild/Signal Verarbeitungsbibliothek 00026 * file .......: ltiPatternDraw.h 00027 * authors ....: Jochen Wickel 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 05.2.2003 00030 * revisions ..: $Id: ltiPatternDraw.h,v 1.4 2006/02/08 11:37:15 ltilib Exp $ 00031 */ 00032 #ifndef _LTI_PATTERNDRAW_H 00033 #define _LTI_PATTERNDRAW_H 00034 00035 #include "ltiDraw.h" 00036 00037 namespace lti { 00038 00039 /** 00040 * Object for drawing lines and points in a lti::matrix with support 00041 * for line and fill patterns. This means that drawing lines and 00042 * filled areas is a little slower than the methods of the 00043 * draw class. 00044 */ 00045 template<class T> 00046 class patternDraw : public draw<T> { 00047 public: 00048 00049 /** 00050 * default constructor 00051 */ 00052 patternDraw(); 00053 /** 00054 * destructor 00055 */ 00056 ~patternDraw(); 00057 00058 /** 00059 * get name of this type 00060 */ 00061 const char* getTypeName() const; 00062 00063 00064 /** 00065 * Draw a line from the point (fx,fy) to point (tx,ty). 00066 * The "last point" will be defined with the last "set", "line" or 00067 * "lineTo" method. 00068 */ 00069 void line(const int fx, const int fy, 00070 const int tx, const int ty); 00071 00072 /** 00073 * Draws a vertical line from (x1,y) to (x2,y). 00074 */ 00075 void verticalLine(const int x, const int y1, const int y2); 00076 00077 /** 00078 * Draws a horizontal line from (x1,y) to (x2,y). 00079 */ 00080 void horizontalLine(const int x1, const int x2, const int y); 00081 00082 /** 00083 * draw a circle with circle center 'p1' and radius 'r' 00084 */ 00085 void circle(const point& p1,const int r, const bool& filled=false); 00086 00087 /** 00088 * draw an ellipse with center 'p1' and main axes 'aX' and 'aY' 00089 */ 00090 void ellipse(const point& p1,const int aX, const int aY, 00091 const bool& filled=false); 00092 00093 /** 00094 * draw an ellipse with center 'p1' and main axes 'aX' and 'aY' 00095 */ 00096 void ellipse(const point& p1,const int aX, const int aY, 00097 const float& angle, const bool& filled=false); 00098 00099 /** 00100 * Draws a box. 00101 */ 00102 void box(const int x1, const int y1, const int x2, const int y2, 00103 const bool& filled=false); 00104 00105 00106 /** 00107 * Sets the pattern for drawing lines. All subsequent lines 00108 * will be drawn in the given pattern. The default is the 00109 * continuous line. 00110 * @param pat pattern for drawing lines. 00111 */ 00112 virtual void setLinePattern(const linePattern& pat); 00113 00114 /** 00115 * Sets the pattern for filling areas. All subsequenly filled 00116 * areas will be filled with the given pattern. The default 00117 * pattern is a homogenouos fill. 00118 * @param pat pattern for filling areas. 00119 */ 00120 virtual void setFillPattern(const fillPattern& pat); 00121 00122 void resetPixelCount() { 00123 pixcount=0; 00124 } 00125 00126 protected: 00127 /** 00128 * The pixel count for drawing lines. 00129 */ 00130 int pixcount; 00131 00132 /** 00133 * Flag which tells us if we are currently filling an area 00134 * using 2D drawing primitives. 00135 */ 00136 bool filling; 00137 00138 /** 00139 * Set pixel at x,y in the color set by setColor; also 00140 * considers the current line pattern. 00141 * @param x x-coordinate of the pixel to be set. 00142 * @param y y-coordinate of the pixel to be set. 00143 */ 00144 inline void setLineElement(const int x, const int y); 00145 00146 /** 00147 * Set pixel at x,y in the color set by setColor; also 00148 * considers the current fill pattern. 00149 * @param x x-coordinate of the pixel to be set. 00150 * @param y y-coordinate of the pixel to be set. 00151 */ 00152 inline void setFillElement(const int x, const int y); 00153 00154 /** 00155 * Sets a pixel accordings to the current fill or line pattern, 00156 * depending on the value of filling 00157 */ 00158 inline void setElement(const int x, const int y); 00159 00160 }; 00161 00162 00163 } 00164 00165 #endif