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 CDisplayWindowPlots_H
00029 #define CDisplayWindowPlots_H
00030
00031 #include <mrpt/gui/CBaseGUIWindow.h>
00032 #include <mrpt/math/CMatrixTemplateNumeric.h>
00033 #include <mrpt/math/lightweight_geom_data.h>
00034 #include <mrpt/utils/CImage.h>
00035
00036
00037
00038
00039 namespace mrpt
00040 {
00041 namespace gui
00042 {
00043 using namespace mrpt::utils;
00044 using namespace mrpt::math;
00045
00046 class CWindowDialogPlots;
00047
00048 DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE(CDisplayWindowPlots, mrpt::gui::CBaseGUIWindow, GUI_IMPEXP)
00049
00050
00051
00052
00053
00054
00055
00056 class GUI_IMPEXP CDisplayWindowPlots : public mrpt::gui::CBaseGUIWindow
00057 {
00058
00059 DEFINE_MRPT_OBJECT( CDisplayWindowPlots )
00060
00061 public:
00062 typedef void (* TCallbackMenu) (int menuID,float cursor_x, float cursor_y, void* userParam);
00063
00064 protected:
00065 friend class CWindowDialogPlots;
00066
00067 bool m_holdon;
00068 bool m_holdon_just_disabled;
00069 uint32_t m_holdon_cnt;
00070 TCallbackMenu m_callback;
00071 void *m_callback_param;
00072
00073 void internal_plot(vector_float &x,vector_float &y,const std::string &lineFormat,const std::string &plotName);
00074 template <typename VECTOR1,typename VECTOR2>
00075 void internal_plot_interface(const VECTOR1 &x,const VECTOR2 &y,const std::string &lineFormat,const std::string &plotName)
00076 {
00077 vector_float x1(x.size()), y1(y.size());
00078 const size_t N1=size_t(x.size());
00079 for (size_t i=0;i<N1;i++) x1[i]=x[i];
00080 const size_t N2=size_t(y.size());
00081 for (size_t i=0;i<N2;i++) y1[i]=y[i];
00082 this->internal_plot(x1,y1,lineFormat,plotName);
00083 }
00084 template <typename VECTOR1>
00085 void internal_plot_interface(const VECTOR1 &y,const std::string &lineFormat,const std::string &plotName)
00086 {
00087 const size_t N=size_t(y.size());
00088 vector_float x1(N),y1(N);
00089 for (size_t i=0;i<N;i++) { x1[i]=i; y1[i]=y[i]; }
00090 this->internal_plot(x1,y1,lineFormat,plotName);
00091 }
00092
00093 public:
00094
00095
00096
00097 CDisplayWindowPlots(
00098 const std::string &windowCaption = std::string(),
00099 unsigned int initialWidth = 350,
00100 unsigned int initialHeight = 300 );
00101
00102
00103 static CDisplayWindowPlotsPtr Create(
00104 const std::string &windowCaption = std::string(),
00105 unsigned int initialWindowWidth = 400,
00106 unsigned int initialWindowHeight = 300 )
00107 {
00108 return CDisplayWindowPlotsPtr(new CDisplayWindowPlots(windowCaption,initialWindowWidth,initialWindowHeight));
00109 }
00110
00111
00112
00113 virtual ~CDisplayWindowPlots();
00114
00115
00116 virtual bool getLastMousePosition(int &x, int &y) const;
00117
00118
00119 virtual void setCursorCross(bool cursorIsCross);
00120
00121
00122
00123 void resize( unsigned int width, unsigned int height );
00124
00125
00126
00127 void setPos( int x, int y );
00128
00129
00130
00131 void setWindowTitle( const std::string &str );
00132
00133
00134
00135 void enableMousePanZoom( bool enabled );
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 template <typename T1,typename T2> inline void plot(const std::vector<T1> &x,const std::vector<T2> &y,const std::string &lineFormat = std::string("b-"),const std::string &plotName = std::string("plotXY") ) { this->internal_plot_interface(x,y,lineFormat,plotName); }
00164
00165 template <typename T1,typename Derived2> inline void plot(const std::vector<T1> &x,const Eigen::MatrixBase<Derived2> &y,const std::string &lineFormat = std::string("b-"),const std::string &plotName = std::string("plotXY") ) { this->internal_plot_interface(x,y,lineFormat,plotName); }
00166
00167 template <typename Derived1,typename T2> inline void plot(const Eigen::MatrixBase<Derived1> &x,const std::vector<T2> &y,const std::string &lineFormat = std::string("b-"),const std::string &plotName = std::string("plotXY") ) { this->internal_plot_interface(x,y,lineFormat,plotName); }
00168
00169 template <typename Derived1,typename Derived2> inline void plot(const Eigen::MatrixBase<Derived1> &x,const Eigen::MatrixBase<Derived2> &y,const std::string &lineFormat = std::string("b-"),const std::string &plotName = std::string("plotXY") ) { this->internal_plot_interface(x,y,lineFormat,plotName); }
00170
00171
00172 template <typename T> void plot(const std::vector<T> &y,const std::string &lineFormat = std::string("b-"),const std::string &plotName = std::string("plotXY") ) { this->internal_plot_interface(y,lineFormat,plotName); }
00173
00174 template <typename Derived> void plot(const Eigen::MatrixBase<Derived> &y,const std::string &lineFormat = std::string("b-"),const std::string &plotName = std::string("plotXY") ) { this->internal_plot_interface(y,lineFormat,plotName); }
00175
00176
00177 void axis( float x_min, float x_max, float y_min, float y_max, bool aspectRatioFix = false );
00178
00179
00180 void axis_equal(bool enable=true);
00181
00182
00183 void axis_fit(bool aspectRatioFix=false);
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 template <typename T>
00199 void GUI_IMPEXP plotEllipse(
00200 const T mean_x,
00201 const T mean_y,
00202 const CMatrixTemplateNumeric<T> &cov22,
00203 const float quantiles,
00204 const std::string &lineFormat = std::string("b-"),
00205 const std::string &plotName = std::string("plotEllipse"),
00206 bool showName = false);
00207
00208
00209 template <typename T>
00210 void GUI_IMPEXP plotEllipse(
00211 const T mean_x,
00212 const T mean_y,
00213 const CMatrixFixedNumeric<T,2,2> &cov22,
00214 const float quantiles,
00215 const std::string &lineFormat = std::string("b-"),
00216 const std::string &plotName = std::string("plotEllipse"),
00217 bool showName = false);
00218
00219
00220
00221
00222
00223
00224 void image(
00225 const utils::CImage &img,
00226 const float &x_left,
00227 const float &y_bottom,
00228 const float &x_width,
00229 const float &y_height,
00230 const std::string &plotName = std::string("image") );
00231
00232
00233
00234
00235
00236 void clear();
00237
00238
00239
00240
00241 inline void clf() {
00242 clear();
00243 }
00244
00245
00246
00247
00248 void hold_on();
00249
00250
00251
00252
00253 void hold_off();
00254
00255
00256
00257
00258
00259
00260 void addPopupMenuEntry( const std::string &label, int menuID );
00261
00262
00263
00264
00265
00266 void setMenuCallback(TCallbackMenu userFunction, void* userParam = NULL );
00267
00268
00269 };
00270 }
00271
00272 }
00273
00274 #endif