Go to the documentation of this file.00001
00063 #ifndef COB_3D_MAPPING_TOOLS_GUI_VIEW_H_
00064 #define COB_3D_MAPPING_TOOLS_GUI_VIEW_H_
00065
00066 #include <string>
00067 #include <iostream>
00068 #include <boost/shared_ptr.hpp>
00069 #include <boost/make_shared.hpp>
00070 #include <boost/signals.hpp>
00071
00072 #include <wx/wx.h>
00073 #include <wx/rawbmp.h>
00074
00075 #include "cob_3d_mapping_tools/gui/tools.h"
00076
00077 namespace Gui
00078 {
00079
00080
00081 class ResourceBase;
00082 template<typename RT> class Resource;
00083
00084 class ViewBase
00085 {
00086 public:
00087 virtual void show()=0;
00088 virtual void onDataChanged()=0;
00089
00090 ResourceBase* r_base_ptr;
00091
00092 protected:
00093 ViewBase(const std::string& name) : name_(name) { }
00094 ~ViewBase();
00095
00096 std::string name_;
00097 friend class WindowManager;
00098 };
00099
00100
00101
00102 template<typename RT, typename VT>
00103 class View : public ViewBase
00104 {
00105 public:
00106 View(const std::string& name, Resource<RT>* r) : ViewBase(name), r_ptr(r) { this->r_base_ptr = r; }
00107
00108 void show() { reloadData(RT(),VT()); show(VT()); }
00109 void onDataChanged() { reloadData(RT(),VT()); refresh(VT()); }
00110 boost::signals::connection registerMouseCallback(boost::function<void (wxMouseEvent&, Resource<RT>*)>);
00111 boost::signals::connection registerKeyCallback(boost::function<void (wxKeyEvent&, Resource<RT>*)>);
00112
00113 protected:
00114 ~View() { std::cout << "View destroyed" << std::endl; }
00115
00116 void show(ViewTypes::View2D);
00117 void refresh(ViewTypes::View2D);
00118
00119 void reloadData(ResourceTypes::Image, ViewTypes::Color);
00120 template<typename PT> void reloadData(ResourceTypes::OrganizedPointCloud<PT>, ViewTypes::Color);
00121 template<typename PT> void reloadData(ResourceTypes::OrganizedPointCloud<PT>, ViewTypes::Depth_Z);
00122 template<typename PT, size_t Channel> void reloadData(ResourceTypes::OrganizedPointCloud<PT>, ViewTypes::Normal<Channel>);
00123
00124 Resource<RT>* r_ptr;
00125 boost::signal<void (wxMouseEvent&, Resource<RT>*)> mouse_sig_;
00126 boost::signal<void (wxKeyEvent&, Resource<RT>*)> key_sig_;
00127
00128 friend class WindowManager;
00129 };
00130
00131
00132
00133 template<typename RT, typename VT>
00134 class ImageView : public View<RT,VT> , public wxPanel
00135 {
00136 public:
00137 ImageView(const std::string& name, Resource<RT>* r) : View<RT,VT>(name,r) { }
00138 ~ImageView() { }
00139 void render();
00140
00141 wxBitmapPtr bmp_;
00142
00143 private:
00144 void render(wxDC& dc);
00145 void paintEvent(wxPaintEvent& event);
00146 void mouseEvent(wxMouseEvent& event);
00147 void keyEvent(wxKeyEvent& event);
00148
00149 friend class WindowManager;
00150 DECLARE_EVENT_TABLE()
00151 };
00152
00153
00154
00155 template<typename RT, typename VT>
00156 class TextView : public View<RT,VT>
00157 {
00158 public:
00159 TextView(const std::string& name, Resource<RT>* r) : View<RT,VT>(name,r) { }
00160 ~TextView() { }
00161
00162 friend class WindowManager;
00163 };
00164
00165 }
00166
00167 #endif