Go to the documentation of this file.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
00029
00030 #ifndef RVIZ_SELECTION_HANDLER_H
00031 #define RVIZ_SELECTION_HANDLER_H
00032
00033 #include "forwards.h"
00034 #include "selection_handler.h"
00035 #include "rviz/properties/forwards.h"
00036 #include "rviz/viewport_mouse_event.h"
00037 #include "rviz/interactive_object.h"
00038
00039 #include <boost/shared_ptr.hpp>
00040 #include <boost/unordered_map.hpp>
00041
00042 #include <OGRE/OgreMovableObject.h>
00043
00044 #include <vector>
00045 #include <set>
00046
00047 namespace Ogre
00048 {
00049 class WireBoundingBox;
00050 class SceneNode;
00051 class MovableObject;
00052 }
00053
00054 namespace rviz
00055 {
00056
00057 class ViewportMouseEvent;
00058 class VisualizationManager;
00059 class PropertyManager;
00060
00061 typedef std::vector<Ogre::AxisAlignedBox> V_AABB;
00062
00063
00064
00065 class SelectionHandler
00066 {
00067 public:
00068 typedef std::vector<PropertyBaseWPtr> V_Property;
00069
00070 SelectionHandler();
00071 virtual ~SelectionHandler();
00072
00073 void initialize(VisualizationManager* manager);
00074 void addTrackedObject(Ogre::MovableObject* object);
00075 void removeTrackedObject(Ogre::MovableObject* object);
00076
00077 virtual void updateTrackedBoxes();
00078
00079 virtual void createProperties(const Picked& obj, PropertyManager* property_manager) {}
00080 virtual void destroyProperties(const Picked& obj, PropertyManager* property_manager);
00081 virtual void updateProperties();
00082
00083 virtual bool needsAdditionalRenderPass(uint32_t pass)
00084 {
00085 return false;
00086 }
00087
00088 virtual void preRenderPass(uint32_t pass);
00089 virtual void postRenderPass(uint32_t pass);
00090
00091 virtual void getAABBs(const Picked& obj, V_AABB& aabbs);
00092
00093 virtual void onSelect(const Picked& obj);
00094 virtual void onDeselect(const Picked& obj);
00095
00098 virtual void setInteractiveObject( InteractiveObjectWPtr object );
00099
00107 virtual InteractiveObjectWPtr getInteractiveObject();
00108
00109 protected:
00110 void createBox(const std::pair<CollObjectHandle, uint64_t>& handles, const Ogre::AxisAlignedBox& aabb, const std::string& material_name);
00111 void destroyBox(const std::pair<CollObjectHandle, uint64_t>& handles);
00112
00113 V_Property properties_;
00114
00115 typedef std::map<std::pair<CollObjectHandle, uint64_t>, std::pair<Ogre::SceneNode*, Ogre::WireBoundingBox*> > M_HandleToBox;
00116 M_HandleToBox boxes_;
00117
00118 VisualizationManager* manager_;
00119
00120 typedef std::set<Ogre::MovableObject*> S_Movable;
00121 S_Movable tracked_objects_;
00122
00123 class Listener : public Ogre::MovableObject::Listener
00124 {
00125 public:
00126 Listener(SelectionHandler* handler)
00127 : handler_(handler)
00128 {}
00129 virtual void objectMoved(Ogre::MovableObject* object)
00130 {
00131 handler_->updateTrackedBoxes();
00132 }
00133
00134 virtual void objectDestroyed(Ogre::MovableObject* object)
00135 {
00136 handler_->removeTrackedObject(object);
00137 }
00138
00139 SelectionHandler* handler_;
00140 };
00141 typedef boost::shared_ptr<Listener> ListenerPtr;
00142 ListenerPtr listener_;
00143
00144 InteractiveObjectWPtr interactive_object_;
00145
00146 friend class SelectionManager;
00147 };
00148
00149 typedef boost::shared_ptr<SelectionHandler> SelectionHandlerPtr;
00150 typedef std::vector<SelectionHandlerPtr> V_SelectionHandler;
00151 typedef std::set<SelectionHandlerPtr> S_SelectionHandler;
00152
00153 }
00154
00155 #endif