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,3);
00089 img.colorImage( imgColor );
00090
00091 for(typename FEATURELIST::const_iterator i = list.begin(); i != list.end(); ++i )
00092 {
00093 imgColor.cross( round((*i)->x), round((*i)->y), color, '+' );
00094 if( showIDs )
00095 imgColor.textOut( round((*i)->x), round((*i)->y), format("%u", static_cast<unsigned int>((*i)->ID)), 0xFF0000 );
00096 if( ! (*i)->isPointFeature() )
00097 imgColor.drawCircle( round((*i)->x), round((*i)->y), (*i)->scale, TColor::red );
00098 }
00099
00100 showImage(imgColor);
00101 MRPT_END
00102 }
00103
00104
00105
00106
00107
00108 template <class FEATURELIST>
00109 void showTiledImageAndPoints( const CImage &img, const FEATURELIST &list, const TColor &color = TColor::red )
00110 {
00111 MRPT_START
00112
00113 CImage imgColor(1,1,3);
00114 img.colorImage( imgColor );
00115
00116
00117 unsigned int w = imgColor.getWidth();
00118 unsigned int h = imgColor.getHeight();
00119 imgColor.line( 0, h/2, w-1, h/2, TColor::green );
00120 imgColor.line( w/4, 0, w/4, h, TColor::green );
00121 imgColor.line( w/2, 0, w/2, h, TColor::green );
00122 imgColor.line( 3*w/4, 0, 3*w/4, h, TColor::green );
00123
00124 showImageAndPoints( imgColor, list, color );
00125
00126 MRPT_END
00127 }
00128
00129
00130
00131
00132
00133 template <class MATCHEDLIST>
00134 void showImagesAndMatchedPoints( const CImage &img1, const CImage &img2, const MATCHEDLIST &mList, const TColor &color = TColor::red )
00135 {
00136 MRPT_START
00137
00138 CImage imgColor;
00139
00140
00141 imgColor.joinImagesHorz( img1, img2 );
00142
00143 unsigned int w = img1.getWidth();
00144
00145 for( typename MATCHEDLIST::const_iterator i = mList.begin(); i != mList.end(); ++i )
00146 {
00147 imgColor.cross( round( i->first->x ), round( i->first->y ), color, '+' );
00148 imgColor.cross( round( i->second->x + w ), round( i->second->y ), color, '+' );
00149 }
00150 showImage(imgColor);
00151
00152 MRPT_END
00153 }
00154
00155
00156
00157
00158
00159 void showImage( const CImage &img );
00160
00161
00162
00163 void plot( const vector_float &x, const vector_float &y );
00164
00165
00166
00167 void plot( const vector_float &y );
00168
00169
00170
00171 void resize( unsigned int width, unsigned int height );
00172
00173
00174
00175 void setPos( int x, int y );
00176
00177
00178
00179 inline void enableCursorCoordinatesVisualization(bool enable)
00180 {
00181 m_enableCursorCoordinates = enable;
00182 }
00183
00184
00185
00186 void setWindowTitle( const std::string &str );
00187
00188 };
00189
00190 }
00191
00192 }
00193
00194 #endif