Go to the documentation of this file.00001
00063 #ifndef COB_3D_MAPPING_TOOLS_GUI_CORE_HPP_
00064 #define COB_3D_MAPPING_TOOLS_GUI_CORE_HPP_
00065
00066 #include "cob_3d_mapping_tools/gui/core.h"
00067 #include "cob_3d_mapping_tools/gui/impl/view.hpp"
00068 #include "cob_3d_mapping_tools/gui/impl/resource.hpp"
00069 #include "cob_3d_mapping_tools/gui/impl/tools.hpp"
00070
00071
00072
00073
00074
00075 template<typename RT, typename VT>
00076 void Gui::WindowManager::create(ImageView<RT,VT>* object, const std::string& status_msg)
00077 {
00078 Window* w = new Window(object->name_);
00079 wxStatusBar* sb = new wxStatusBar(w);
00080 sb->SetStatusText(wxString(status_msg.c_str(), wxConvUTF8));
00081 object->Create(w, -1, wxDefaultPosition, wxSize(object->bmp_->GetWidth(), object->bmp_->GetHeight()));
00082 wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
00083 sizer->Add(object, 0, wxEXPAND);
00084 sizer->Add(sb, 0, 0, 0);
00085 sizer->SetSizeHints(w);
00086 w->SetSizer(sizer);
00087 w->SetAutoLayout(true);
00088 w->Show(true);
00089 }
00090
00091 template<typename RT, typename VT>
00092 void Gui::WindowManager::moveWindow(View<RT,VT>* window_ptr, int x, int y)
00093 {
00094 moveWindow(window_ptr,wxPoint(x,y),VT());
00095 }
00096
00097 template<typename RT, typename VT>
00098 void Gui::WindowManager::moveWindow(View<RT,VT>* w, const wxPoint& p, ViewTypes::View2D)
00099 {
00100 wxWindow* wxW = static_cast<ImageView<RT,VT>*>(w);
00101 while (!wxW->IsTopLevel())
00102 wxW = wxW->GetParent();
00103 wxW->SetPosition(p);
00104 }
00105
00106
00107
00108
00109
00110 template<typename RT>
00111 std::map<std::string, Gui::Resource<RT>* >* Gui::ResourceManager::get()
00112 {
00113 static std::map<std::string, Resource<RT>* > map; return ↦
00114 }
00115
00116
00117 template<typename RT>
00118 Gui::Resource<RT>* Gui::ResourceManager::create(const std::string& name, const typename RT::DataTypePtr& data)
00119 {
00120 Resource<RT>* r = new Resource<RT>(name,data);
00121 get<RT>()->insert(std::pair<std::string,Resource<RT>* >(name, r));
00122 return r;
00123 }
00124
00125 template<typename RT>
00126 Gui::Resource<RT>* Gui::ResourceManager::create(const std::string& name, const std::string& file, ResourceTypes::BaseCloud)
00127 {
00128 typename RT::DataTypePtr tmp_data(new typename RT::DataTypeRaw);
00129 if (pcl::io::loadPCDFile<typename RT::PointType>(file, *tmp_data) < 0) return NULL;
00130 return create<RT>(name,tmp_data);
00131 }
00132
00133 template<typename RT>
00134 Gui::Resource<RT>* Gui::ResourceManager::create(const std::string& name, const std::string& file, ResourceTypes::Image)
00135 {
00136 typename RT::DataTypePtr tmp_data(new typename RT::DataTypeRaw);
00137 *tmp_data = cv::imread(file);
00138 if (tmp_data->data==NULL) return NULL;
00139 return create<RT>(name,tmp_data);
00140 }
00141
00142
00143 template<typename RT>
00144 void Gui::ResourceManager::destroy(const std::string& name)
00145 {
00146 typedef typename std::map<std::string,Resource<RT>*>::iterator iterator;
00147 iterator it = get<RT>()->find(name);
00148 delete it->second;
00149 get<RT>()->erase(it);
00150 }
00151
00152 #endif