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 {
00068 return CDisplayWindowPtr(new CDisplayWindow(windowCaption));
00069 }
00070
00071
00072
00073 virtual ~CDisplayWindow();
00074
00075
00076
00077
00078 void showImageAndPoints( const CImage &img, const vector_float &x, const vector_float &y, const TColor &color = TColor::red );
00079
00080
00081
00082
00083
00084 template <class FEATURELIST>
00085 void showImageAndPoints( const CImage &img, const FEATURELIST &list, const TColor &color = TColor::red, const bool &showIDs = false )
00086 {
00087 MRPT_START
00088 CImage imgColor(1,1,CH_RGB);
00089 img.colorImage( imgColor );
00090 imgColor.drawFeatures(list,color,showIDs);
00091 showImage(imgColor);
00092 MRPT_END
00093 }
00094
00095
00096
00097
00098
00099 template <class FEATURELIST>
00100 void showTiledImageAndPoints( const CImage &img, const FEATURELIST &list, const TColor &color = TColor::red )
00101 {
00102 MRPT_START
00103
00104 CImage imgColor(1,1,3);
00105 img.colorImage( imgColor );
00106
00107
00108 unsigned int w = imgColor.getWidth();
00109 unsigned int h = imgColor.getHeight();
00110 imgColor.line( 0, h/2, w-1, h/2, TColor::green );
00111 imgColor.line( w/4, 0, w/4, h, TColor::green );
00112 imgColor.line( w/2, 0, w/2, h, TColor::green );
00113 imgColor.line( 3*w/4, 0, 3*w/4, h, TColor::green );
00114
00115 showImageAndPoints( imgColor, list, color );
00116
00117 MRPT_END
00118 }
00119
00120
00121
00122
00123
00124 template <class MATCHEDLIST>
00125 void showImagesAndMatchedPoints( const CImage &img1, const CImage &img2, const MATCHEDLIST &mList, const TColor &color = TColor::red )
00126 {
00127 MRPT_START
00128
00129 CImage imgColor;
00130
00131
00132 imgColor.joinImagesHorz( img1, img2 );
00133
00134 unsigned int w = img1.getWidth();
00135
00136 for( typename MATCHEDLIST::const_iterator i = mList.begin(); i != mList.end(); ++i )
00137 {
00138 imgColor.drawCircle( round( i->first->x ), round( i->first->y ), 4, color );
00139 imgColor.drawCircle( round( i->second->x + w ), round( i->second->y ), 4, color );
00140 imgColor.line( round( i->first->x ), round( i->first->y ), round( i->second->x + w ), round( i->second->y ), color );
00141 }
00142 showImage(imgColor);
00143
00144 MRPT_END
00145 }
00146
00147
00148
00149
00150
00151 template <class FEATURELIST>
00152 void showImagesAndMatchedPoints( const CImage &img1, const CImage &img2, const FEATURELIST &leftList, const FEATURELIST &rightList, const TColor &color = TColor::red )
00153 {
00154 MRPT_START
00155
00156 CImage imgColor;
00157
00158
00159 ASSERT_( leftList.size() == rightList.size() );
00160 imgColor.joinImagesHorz( img1, img2 );
00161
00162 unsigned int w = img1.getWidth();
00163
00164 for( typename FEATURELIST::const_iterator iL = leftList.begin(), iR = rightList.begin(); iL != leftList.end(); ++iL, ++iR )
00165 {
00166 imgColor.drawCircle( round( (*iL)->x ), round( (*iL)->y ), 4, color );
00167 imgColor.drawCircle( round( (*iR)->x + w ), round( (*iR)->y ), 4, color );
00168 imgColor.line( round( (*iL)->x ), round( (*iL)->y ), round( (*iR)->x + w ), round( (*iR)->y ), color );
00169 }
00170 showImage(imgColor);
00171
00172 MRPT_END
00173 }
00174
00175
00176
00177
00178 void showImage( const CImage &img );
00179
00180
00181
00182 void plot( const vector_float &x, const vector_float &y );
00183
00184
00185
00186 void plot( const vector_float &y );
00187
00188
00189
00190 void resize( unsigned int width, unsigned int height );
00191
00192
00193
00194 void setPos( int x, int y );
00195
00196
00197
00198 inline void enableCursorCoordinatesVisualization(bool enable)
00199 {
00200 m_enableCursorCoordinates = enable;
00201 }
00202
00203
00204
00205 void setWindowTitle( const std::string &str );
00206
00207 };
00208
00209 }
00210
00211 }
00212
00213 #endif