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