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/viewport_mouse_event.h"
00036 #include "rviz/interactive_object.h"
00037
00038 #include <boost/shared_ptr.hpp>
00039 #include <boost/unordered_map.hpp>
00040
00041 #include <OGRE/OgreMovableObject.h>
00042
00043 #include <vector>
00044 #include <set>
00045
00046 namespace Ogre
00047 {
00048 class WireBoundingBox;
00049 class SceneNode;
00050 class MovableObject;
00051 }
00052
00053 namespace rviz
00054 {
00055
00056 class Property;
00057 class ViewportMouseEvent;
00058 class VisualizationManager;
00059
00060 typedef std::vector<Ogre::AxisAlignedBox> V_AABB;
00061
00062 class SelectionHandler
00063 {
00064 public:
00065 SelectionHandler();
00066 virtual ~SelectionHandler();
00067
00068 void initialize(VisualizationManager* manager);
00069 void addTrackedObject(Ogre::MovableObject* object);
00070 void removeTrackedObject(Ogre::MovableObject* object);
00071
00072 virtual void updateTrackedBoxes();
00073
00081 virtual void createProperties( const Picked& obj, Property* parent_property ) {}
00082
00090 virtual void destroyProperties( const Picked& obj, Property* parent_property );
00091
00101 virtual void updateProperties() {}
00102
00103 virtual bool needsAdditionalRenderPass(uint32_t pass)
00104 {
00105 return false;
00106 }
00107
00108 virtual void preRenderPass(uint32_t pass);
00109 virtual void postRenderPass(uint32_t pass);
00110
00111 virtual void getAABBs(const Picked& obj, V_AABB& aabbs);
00112
00113 virtual void onSelect(const Picked& obj);
00114 virtual void onDeselect(const Picked& obj);
00115
00118 virtual void setInteractiveObject( InteractiveObjectWPtr object );
00119
00127 virtual InteractiveObjectWPtr getInteractiveObject();
00128
00129 protected:
00130 void createBox(const std::pair<CollObjectHandle, uint64_t>& handles, const Ogre::AxisAlignedBox& aabb, const std::string& material_name);
00131 void destroyBox(const std::pair<CollObjectHandle, uint64_t>& handles);
00132
00133 QList<Property*> properties_;
00134
00135 typedef std::map<std::pair<CollObjectHandle, uint64_t>, std::pair<Ogre::SceneNode*, Ogre::WireBoundingBox*> > M_HandleToBox;
00136 M_HandleToBox boxes_;
00137
00138 VisualizationManager* manager_;
00139
00140 typedef std::set<Ogre::MovableObject*> S_Movable;
00141 S_Movable tracked_objects_;
00142
00143 class Listener : public Ogre::MovableObject::Listener
00144 {
00145 public:
00146 Listener(SelectionHandler* handler)
00147 : handler_(handler)
00148 {}
00149 virtual void objectMoved(Ogre::MovableObject* object)
00150 {
00151 handler_->updateTrackedBoxes();
00152 }
00153
00154 virtual void objectDestroyed(Ogre::MovableObject* object)
00155 {
00156 handler_->removeTrackedObject(object);
00157 }
00158
00159 SelectionHandler* handler_;
00160 };
00161 typedef boost::shared_ptr<Listener> ListenerPtr;
00162 ListenerPtr listener_;
00163
00164 InteractiveObjectWPtr interactive_object_;
00165
00166 friend class SelectionManager;
00167 };
00168
00169 typedef boost::shared_ptr<SelectionHandler> SelectionHandlerPtr;
00170 typedef std::vector<SelectionHandlerPtr> V_SelectionHandler;
00171 typedef std::set<SelectionHandlerPtr> S_SelectionHandler;
00172
00173 }
00174
00175 #endif