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 <vector>
00034 #include <set>
00035
00036 #ifndef Q_MOC_RUN
00037 #include <boost/shared_ptr.hpp>
00038 #include <boost/unordered_map.hpp>
00039
00040 #include <OgreMovableObject.h>
00041 #endif
00042
00043 #include "rviz/selection/forwards.h"
00044 #include "rviz/selection/selection_handler.h"
00045 #include "rviz/viewport_mouse_event.h"
00046 #include "rviz/interactive_object.h"
00047
00048 namespace Ogre
00049 {
00050 class WireBoundingBox;
00051 class SceneNode;
00052 class MovableObject;
00053 }
00054
00055 namespace rviz
00056 {
00057
00058 class DisplayContext;
00059 class Property;
00060 class ViewportMouseEvent;
00061
00062 typedef std::vector<Ogre::AxisAlignedBox> V_AABB;
00063
00064 class SelectionHandler
00065 {
00066 public:
00067 SelectionHandler( DisplayContext* context );
00068 virtual ~SelectionHandler();
00069
00070 void addTrackedObjects( Ogre::SceneNode* node );
00071 void addTrackedObject(Ogre::MovableObject* object);
00072 void removeTrackedObject(Ogre::MovableObject* object);
00073
00074 virtual void updateTrackedBoxes();
00075
00083 virtual void createProperties( const Picked& obj, Property* parent_property ) {}
00084
00092 virtual void destroyProperties( const Picked& obj, Property* parent_property );
00093
00103 virtual void updateProperties() {}
00104
00105 virtual bool needsAdditionalRenderPass(uint32_t pass)
00106 {
00107 return false;
00108 }
00109
00110 virtual void preRenderPass(uint32_t pass);
00111 virtual void postRenderPass(uint32_t pass);
00112
00113 virtual void getAABBs(const Picked& obj, V_AABB& aabbs);
00114
00115 virtual void onSelect(const Picked& obj);
00116 virtual void onDeselect(const Picked& obj);
00117
00120 virtual void setInteractiveObject( InteractiveObjectWPtr object );
00121
00129 virtual InteractiveObjectWPtr getInteractiveObject();
00130
00131 CollObjectHandle getHandle() const { return pick_handle_; }
00132
00133 protected:
00135 void createBox(const std::pair<CollObjectHandle, uint64_t>& handles, const Ogre::AxisAlignedBox& aabb, const std::string& material_name);
00136
00138 void destroyBox(const std::pair<CollObjectHandle, uint64_t>& handles);
00139
00140 QList<Property*> properties_;
00141
00142 typedef std::map<std::pair<CollObjectHandle, uint64_t>, std::pair<Ogre::SceneNode*, Ogre::WireBoundingBox*> > M_HandleToBox;
00143 M_HandleToBox boxes_;
00144
00145 DisplayContext* context_;
00146
00147 typedef std::set<Ogre::MovableObject*> S_Movable;
00148 S_Movable tracked_objects_;
00149
00150 class Listener : public Ogre::MovableObject::Listener
00151 {
00152 public:
00153 Listener(SelectionHandler* handler)
00154 : handler_(handler)
00155 {}
00156 virtual void objectMoved(Ogre::MovableObject* object)
00157 {
00158 handler_->updateTrackedBoxes();
00159 }
00160
00161 virtual void objectDestroyed(Ogre::MovableObject* object)
00162 {
00163 handler_->removeTrackedObject(object);
00164 }
00165
00166 SelectionHandler* handler_;
00167 };
00168 typedef boost::shared_ptr<Listener> ListenerPtr;
00169 ListenerPtr listener_;
00170
00171 InteractiveObjectWPtr interactive_object_;
00172
00173 private:
00174
00175
00176
00177 CollObjectHandle pick_handle_;
00178
00179 friend class SelectionManager;
00180 };
00181
00182 typedef boost::shared_ptr<SelectionHandler> SelectionHandlerPtr;
00183 typedef std::vector<SelectionHandlerPtr> V_SelectionHandler;
00184 typedef std::set<SelectionHandlerPtr> S_SelectionHandler;
00185
00186 }
00187
00188 #endif