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 CDisplayWindow_H
00029 #define CDisplayWindow_H
00030
00031 #include <mrpt/gui/CBaseGUIWindow.h>
00032 #include <mrpt/utils/CImage.h>
00033
00034 namespace mrpt
00035 {
00036
00037 namespace gui
00038 {
00039 using namespace mrpt::utils;
00040
00041 DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE(CDisplayWindow, mrpt::gui::CBaseGUIWindow, GUI_IMPEXP)
00042
00043
00044
00045
00046
00047
00048 class GUI_IMPEXP CDisplayWindow : public mrpt::gui::CBaseGUIWindow
00049 {
00050
00051 DEFINE_MRPT_OBJECT( CDisplayWindow )
00052
00053 protected:
00054
00055
00056
00057 bool m_enableCursorCoordinates;
00058
00059 public:
00060
00061
00062 CDisplayWindow( const std::string &windowCaption = std::string(), unsigned int initWidth = 400, unsigned int initHeight = 400 );
00063
00064
00065 static CDisplayWindowPtr Create(
00066 const std::string &windowCaption = std::string(),
00067 unsigned int initWidth = 400,
00068 unsigned int initHeight = 400 )
00069 {
00070 return CDisplayWindowPtr(new CDisplayWindow(windowCaption,initWidth,initHeight));
00071 }
00072
00073
00074
00075 virtual ~CDisplayWindow();
00076
00077
00078 virtual bool getLastMousePosition(int &x, int &y) const;
00079
00080
00081 virtual void setCursorCross(bool cursorIsCross);
00082
00083
00084
00085
00086 void showImageAndPoints( const CImage &img, const vector_float &x, const vector_float &y, const TColor &color = TColor::red, const bool &showNumbers = false );
00087
00088
00089
00090
00091
00092 template <class FEATURELIST>
00093 void showImageAndPoints( const CImage &img, const FEATURELIST &list, const TColor &color = TColor::red, const bool &showIDs = false )
00094 {
00095 MRPT_START
00096 CImage imgColor(1,1,CH_RGB);
00097 img.colorImage( imgColor );
00098 imgColor.drawFeatures(list,color,showIDs);
00099 showImage(imgColor);
00100 MRPT_END
00101 }
00102
00103
00104
00105
00106
00107 template <class FEATURELIST>
00108 void showTiledImageAndPoints( const CImage &img, const FEATURELIST &list, const TColor &color = TColor::red )
00109 {
00110 MRPT_START
00111
00112 CImage imgColor(1,1,3);
00113 img.colorImage( imgColor );
00114
00115
00116 unsigned int w = imgColor.getWidth();
00117 unsigned int h = imgColor.getHeight();
00118 imgColor.line( 0, h/2, w-1, h/2, TColor::green );
00119 imgColor.line( w/4, 0, w/4, h, TColor::green );
00120 imgColor.line( w/2, 0, w/2, h, TColor::green );
00121 imgColor.line( 3*w/4, 0, 3*w/4, h, TColor::green );
00122
00123 showImageAndPoints( imgColor, list, color );
00124
00125 MRPT_END
00126 }
00127
00128
00129
00130
00131
00132 template <class MATCHEDLIST>
00133 void showImagesAndMatchedPoints( const CImage &img1, const CImage &img2, const MATCHEDLIST &mList, const TColor &color = TColor::red, bool showNumbers = false )
00134 {
00135 MRPT_START
00136
00137 CImage imgColor;
00138
00139
00140 imgColor.joinImagesHorz( img1, img2 );
00141
00142 unsigned int w = img1.getWidth();
00143 unsigned int nf = 0;
00144
00145 for( typename MATCHEDLIST::const_iterator i = mList.begin(); i != mList.end(); ++i, ++nf )
00146 {
00147 imgColor.drawCircle( round( i->first->x ), round( i->first->y ), 4, color );
00148 imgColor.drawCircle( round( i->second->x + w ), round( i->second->y ), 4, color );
00149
00150 if( showNumbers )
00151 {
00152 char buf[15];
00153 mrpt::system::os::sprintf( buf, 15, "%d[%u]", nf, (unsigned int)i->first->ID );
00154 imgColor.textOut( round( i->first->x ) - 10, round( i->first->y ), buf, color );
00155 mrpt::system::os::sprintf( buf, 15, "%d[%u]", nf, (unsigned int)i->second->ID );
00156 imgColor.textOut( round( i->second->x + w ) + 10, round( i->second->y ), buf, color );
00157 }
00158 }
00159 showImage(imgColor);
00160
00161 MRPT_END
00162 }
00163
00164
00165
00166
00167
00168 template <class FEATURELIST>
00169 void showImagesAndMatchedPoints( const CImage &img1, const CImage &img2, const FEATURELIST &leftList, const FEATURELIST &rightList, const TColor &color = TColor::red )
00170 {
00171 MRPT_START
00172
00173 CImage imgColor;
00174
00175
00176 ASSERT_( leftList.size() == rightList.size() );
00177 imgColor.joinImagesHorz( img1, img2 );
00178
00179 unsigned int w = img1.getWidth();
00180
00181 for( typename FEATURELIST::const_iterator iL = leftList.begin(), iR = rightList.begin(); iL != leftList.end(); ++iL, ++iR )
00182 {
00183 imgColor.drawCircle( round( (*iL)->x ), round( (*iL)->y ), 4, color );
00184 imgColor.drawCircle( round( (*iR)->x + w ), round( (*iR)->y ), 4, color );
00185 imgColor.line( round( (*iL)->x ), round( (*iL)->y ), round( (*iR)->x + w ), round( (*iR)->y ), color );
00186 }
00187 showImage(imgColor);
00188
00189 MRPT_END
00190 }
00191
00192
00193
00194
00195 void showImage( const CImage &img );
00196
00197
00198
00199 void plot( const vector_float &x, const vector_float &y );
00200
00201
00202
00203 void plot( const vector_float &y );
00204
00205
00206
00207 void resize( unsigned int width, unsigned int height );
00208
00209
00210
00211 void setPos( int x, int y );
00212
00213
00214
00215 inline void enableCursorCoordinatesVisualization(bool enable)
00216 {
00217 m_enableCursorCoordinates = enable;
00218 }
00219
00220
00221
00222 void setWindowTitle( const std::string &str );
00223
00224 };
00225
00226 }
00227
00228 }
00229
00230 #endif