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-Lib: Image Processing and Computer Vision Library 00026 * file .......: ltiDraw3DDistribution.h 00027 * authors ....: Jens Paustenbach 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 21.1.2003 00030 * revisions ..: $Id: ltiDraw3DDistribution.h,v 1.7 2006/02/07 18:47:13 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_DRAW3_D_DISTRIBUTION_H_ 00034 #define _LTI_DRAW3_D_DISTRIBUTION_H_ 00035 00036 #include "ltiFunctor.h" 00037 #include "ltiScene3D.h" 00038 #include "ltiRGBPixel.h" 00039 #include <map> 00040 #include <vector> 00041 00042 namespace lti { 00043 /** 00044 * Draws a three dimensional distribution. 00045 * With this functor a three dimensional distribution is drawn. 00046 * If the functor gets an id vector that gives each point in the 00047 * distribution an id, all points with the same id get the same color and 00048 * all differnt ids get different color. By default there is a colorMap 00049 * with 15 different colors. If there are more than 15 different ids, 00050 * different markers will be used. 00051 * The apply methods, that haven't an id vector use the first not used 00052 * negativ id to save the color used for drawing this distribution. 00053 * With the hold option you can choose, if the old scene is erased before 00054 * the distribution is drawn or if it is drawn into the same scene. 00055 */ 00056 class draw3DDistribution : public functor { 00057 public: 00058 /** 00059 * the parameters for the class draw3DDistribution 00060 */ 00061 class parameters : public functor::parameters { 00062 public: 00063 /** 00064 * default constructor 00065 */ 00066 parameters(); 00067 00068 /** 00069 * copy constructor 00070 * @param other the parameters object to be copied 00071 */ 00072 parameters(const parameters& other); 00073 00074 /** 00075 * destructor 00076 */ 00077 ~parameters(); 00078 00079 /** 00080 * returns name of this type 00081 */ 00082 const char* getTypeName() const; 00083 00084 /** 00085 * copy the contents of a parameters object 00086 * @param other the parameters object to be copied 00087 * @return a reference to this parameters object 00088 */ 00089 parameters& copy(const parameters& other); 00090 00091 /** 00092 * copy the contents of a parameters object 00093 * @param other the parameters object to be copied 00094 * @return a reference to this parameters object 00095 */ 00096 parameters& operator=(const parameters& other); 00097 00098 00099 /** 00100 * returns a pointer to a clone of the parameters 00101 */ 00102 virtual functor::parameters* clone() const; 00103 00104 /** 00105 * write the parameters in the given ioHandler 00106 * @param handler the ioHandler to be used 00107 * @param complete if true (the default) the enclosing begin/end will 00108 * be also written, otherwise only the data block will be written. 00109 * @return true if write was successful 00110 */ 00111 virtual bool write(ioHandler& handler,const bool complete=true) const; 00112 00113 /** 00114 * read the parameters from the given ioHandler 00115 * @param handler the ioHandler to be used 00116 * @param complete if true (the default) the enclosing begin/end will 00117 * be also written, otherwise only the data block will be written. 00118 * @return true if write was successful 00119 */ 00120 virtual bool read(ioHandler& handler,const bool complete=true); 00121 00122 # ifdef _LTI_MSC_6 00123 /** 00124 * this function is required by MSVC only, as a workaround for a 00125 * very awful bug, which exists since MSVC V.4.0, and still by 00126 * V.6.0 with all bugfixes (so called "service packs") remains 00127 * there... This method is also public due to another bug, so please 00128 * NEVER EVER call this method directly: use read() instead 00129 */ 00130 bool readMS(ioHandler& handler,const bool complete=true); 00131 00132 /** 00133 * this function is required by MSVC only, as a workaround for a 00134 * very awful bug, which exists since MSVC V.4.0, and still by 00135 * V.6.0 with all bugfixes (so called "service packs") remains 00136 * there... This method is also public due to another bug, so please 00137 * NEVER EVER call this method directly: use write() instead 00138 */ 00139 bool writeMS(ioHandler& handler,const bool complete=true) const; 00140 # endif 00141 00142 // ------------------------------------------------ 00143 // the parameters 00144 // ------------------------------------------------ 00145 00146 /** 00147 * the palette that is used to draw distribution with differnt ids. 00148 */ 00149 std::vector<rgbPixel> colorMap; 00150 00151 /** 00152 * the markers that are used to draw distribution with differnt ids. 00153 */ 00154 std::vector<std::string> markerMap; 00155 00156 /** 00157 * if true, all three axis are scaled equal, otherwise each axis has 00158 * its own scaling factor. 00159 */ 00160 bool scaleEqual; 00161 00162 /** 00163 * Number of Ticks on each axis. 00164 */ 00165 int nbTicks; 00166 00167 /** 00168 * Color of the background grid. 00169 */ 00170 rgbPixel gridColor; 00171 00172 /** 00173 * If true a grid is drawn in the background of the distribution 00174 */ 00175 bool grid; 00176 00177 /** 00178 * If true the x-axis is red, the y-axis green and z-axis is yellow 00179 */ 00180 bool colouredAxes; 00181 00182 }; 00183 00184 /** 00185 * default constructor 00186 */ 00187 draw3DDistribution(); 00188 00189 /** 00190 * Construct a functor using the given parameters 00191 */ 00192 draw3DDistribution(const parameters& par); 00193 00194 /** 00195 * copy constructor 00196 * @param other the object to be copied 00197 */ 00198 draw3DDistribution(const draw3DDistribution& other); 00199 00200 /** 00201 * destructor 00202 */ 00203 virtual ~draw3DDistribution(); 00204 00205 /** 00206 * returns the name of this type ("draw3DDistribution") 00207 */ 00208 virtual const char* getTypeName() const; 00209 00210 /** 00211 * Draws a three dimensional distribution 00212 * @param drawer the scene that is used for drawing 00213 * @param dist the 3 dimensional distribution that is drawn. 00214 * @param ids the ids corresponding to the points in the distribution 00215 * @param hold if true the old scene is not erased. 00216 * @return true if apply successful or false otherwise. 00217 */ 00218 bool apply(scene3D<rgbPixel>& drawer,const dmatrix& dist, 00219 const ivector& ids, const bool& hold=false) const; 00220 00221 /** 00222 * Draws a three dimensional distribution. For the id the first free 00223 * negativ id is chosen. 00224 * @param drawer the scene that is used for drawing 00225 * @param dist the 3 dimensional distribution that is drawn. 00226 * @param hold if true the old scene is not erased. 00227 * @return true if apply successful or false otherwise. 00228 */ 00229 bool apply(scene3D<rgbPixel>& drawer,const dmatrix& dist, 00230 const bool& hold=false) const; 00231 00232 /** 00233 * Draws a three dimensions of a high dimensional distribution 00234 * @param drawer the scene that is used for drawing 00235 * @param dist the distribution 00236 * @param first the column in dist with the first dimension. 00237 * @param second the column in dist with the second dimension. 00238 * @param third the column in dist with the third dimension. 00239 * @param hold if true the old scene is not erased. 00240 * @return true if apply successful or false otherwise. 00241 */ 00242 bool apply(scene3D<rgbPixel>& drawer,const dmatrix& dist, 00243 int first, int second, int third, const bool& hold=false) const; 00244 00245 /** 00246 * Draws a three dimensions distribution. 00247 * @param drawer the scene that is used for drawing 00248 * @param x the first dimension. 00249 * @param y the second dimension. 00250 * @param z the third dimension. 00251 * @param hold if true the old scene is not erased. 00252 * @return true if apply successful or false otherwise. 00253 */ 00254 bool apply(scene3D<rgbPixel>& drawer,const dvector& x,const dvector& y, 00255 const dvector& z,const bool& hold=false) const; 00256 00257 /** 00258 * copy data of "other" functor. 00259 * @param other the functor to be copied 00260 * @return a reference to this functor object 00261 */ 00262 draw3DDistribution& copy(const draw3DDistribution& other); 00263 00264 /** 00265 * alias for copy member 00266 * @param other the functor to be copied 00267 * @return a reference to this functor object 00268 */ 00269 draw3DDistribution& operator=(const draw3DDistribution& other); 00270 00271 /** 00272 * returns a pointer to a clone of this functor. 00273 */ 00274 virtual functor* clone() const; 00275 00276 /** 00277 * returns used parameters 00278 */ 00279 const parameters& getParameters() const; 00280 00281 protected: 00282 /** 00283 * Saves the assignment of ids to colors. 00284 */ 00285 std::map<int,rgbPixel> *idsToColor; 00286 00287 /** 00288 * Saves the assignment of ids to marker types. 00289 */ 00290 std::map<int,std::string> *idsToMarker; 00291 00292 }; 00293 } 00294 00295 #endif