00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CEnhancedMetaFile_H
00029 #define CEnhancedMetaFile_H
00030
00031 #include <mrpt/utils/utils_defs.h>
00032 #include <mrpt/utils/CMRPTCanvas.h>
00033 #include <mrpt/utils/safe_pointers.h>
00034
00035
00036
00037
00038 namespace mrpt
00039 {
00040 namespace utils
00041 {
00045 class MRPTDLLIMPEXP CEnhancedMetaFile : public CMRPTCanvas
00046 {
00047 private:
00048 void_ptr_noncopy m_hdc;
00049 int m_scale;
00050 void_ptr_noncopy m_hFont;
00051 std::string m_targetFile;
00052
00053 public:
00054 static int LINUX_IMG_WIDTH;
00055 static int LINUX_IMG_HEIGHT;
00056
00057
00062 CEnhancedMetaFile(
00063 const std::string &targetFileName,
00064 int scaleFactor = 1);
00065
00068 virtual ~CEnhancedMetaFile( );
00069
00077 void setPixel( int x, int y, size_t color);
00078
00081 size_t getWidth() const { return 640; }
00082
00085 size_t getHeight() const {return 480;}
00086
00093 void drawImage(
00094 int x,
00095 int y,
00096 const utils::CMRPTImage &img );
00097
00107 void line(
00108 int x0,
00109 int y0,
00110 int x1,
00111 int y1,
00112 unsigned int color,
00113 unsigned int width = 1,
00114 TPenStyle penStyle = psSolid);
00115
00125 void textOut(
00126 int x0,
00127 int y0,
00128 const std::string &str,
00129 unsigned int color
00130 );
00131
00139 void selectTextFont(
00140 const std::string &fontName,
00141 int fontSize,
00142 bool bold = false,
00143 bool italic = false );
00144
00151 void drawImage(
00152 int x,
00153 int y,
00154 const utils::CMRPTImageFloat &img );
00155
00164 void drawImage(
00165 int x,
00166 int y,
00167 const utils::CMRPTImage &img,
00168 float rotation,
00169 float scale )
00170 {
00171 CMRPTCanvas::drawImage(x,y,img,rotation,scale);
00172 }
00173
00174
00184 void rectangle(
00185 int x0,
00186 int y0,
00187 int x1,
00188 int y1,
00189 unsigned int color,
00190 unsigned int width = 1 );
00191
00202 template <class T>
00203 void ellipseGaussian(
00204 math::CMatrixTemplateNumeric<T> *cov2D,
00205 T mean_x,
00206 T mean_y,
00207 float confIntervalStds = 2,
00208 unsigned int color = 0xFFFFFF,
00209 unsigned int width = 1,
00210 int nEllipsePoints = 20
00211 )
00212 {
00213 MRPT_TRY_START;
00214 int x1=0,y1=0,x2=0,y2=0;
00215 double ang;
00216 math::CMatrixTemplateNumeric<T> eigVal,eigVec;
00217 int i;
00218
00219
00220 cov2D->eigenVectors(eigVec,eigVal);
00221
00222 eigVal.Sqrt();
00223 math::CMatrixTemplateNumeric<T> M( eigVal * (~eigVec) );
00224
00225
00226 for (i=0,ang=0;i<nEllipsePoints;i++,ang+= (M_2PI/(nEllipsePoints-1)))
00227 {
00228 float ccos = cos(ang);
00229 float ssin = sin(ang);
00230
00231 x2 = round( mean_x + confIntervalStds * (ccos * M(0,0) + ssin * M(1,0)) );
00232 y2 = round( mean_y + confIntervalStds * (ccos * M(0,1) + ssin * M(1,1)) );
00233
00234 if (i>0)
00235 line( x1, y1,x2, y2,color,width );
00236
00237 x1 = x2;
00238 y1 = y2;
00239 }
00240
00241 MRPT_TRY_END_WITH_CLEAN_UP( \
00242 std::cout << "Covariance matrix leading to error is:" << std::endl << *cov2D << std::endl; \
00243 );
00244 }
00245
00246
00247
00248 };
00249
00250 }
00251 }
00252 #endif