selection_handler.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef RVIZ_SELECTION_HANDLER_H
31 #define RVIZ_SELECTION_HANDLER_H
32 
33 #include <vector>
34 #include <set>
35 
36 #ifndef Q_MOC_RUN
37 #include <boost/shared_ptr.hpp>
38 #include <boost/unordered_map.hpp>
39 
40 #include <OgreMovableObject.h>
41 #endif
42 
47 
48 namespace Ogre
49 {
50 class WireBoundingBox;
51 class SceneNode;
52 class MovableObject;
53 }
54 
55 namespace rviz
56 {
57 
58 class DisplayContext;
59 class Property;
61 
62 typedef std::vector<Ogre::AxisAlignedBox> V_AABB;
63 
65 {
66 public:
67  SelectionHandler( DisplayContext* context );
68  virtual ~SelectionHandler();
69 
70  void addTrackedObjects( Ogre::SceneNode* node );
71  void addTrackedObject(Ogre::MovableObject* object);
72  void removeTrackedObject(Ogre::MovableObject* object);
73 
74  virtual void updateTrackedBoxes();
75 
83  virtual void createProperties( const Picked& obj, Property* parent_property ) {}
84 
92  virtual void destroyProperties( const Picked& obj, Property* parent_property );
93 
103  virtual void updateProperties() {}
104 
105  virtual bool needsAdditionalRenderPass(uint32_t pass)
106  {
107  return false;
108  }
109 
110  virtual void preRenderPass(uint32_t pass);
111  virtual void postRenderPass(uint32_t pass);
112 
113  virtual void getAABBs(const Picked& obj, V_AABB& aabbs);
114 
115  virtual void onSelect(const Picked& obj);
116  virtual void onDeselect(const Picked& obj);
117 
120  virtual void setInteractiveObject( InteractiveObjectWPtr object );
121 
129  virtual InteractiveObjectWPtr getInteractiveObject();
130 
131  CollObjectHandle getHandle() const { return pick_handle_; }
132 
133 protected:
135  void createBox(const std::pair<CollObjectHandle, uint64_t>& handles, const Ogre::AxisAlignedBox& aabb, const std::string& material_name);
136 
138  void destroyBox(const std::pair<CollObjectHandle, uint64_t>& handles);
139 
140  QList<Property*> properties_;
141 
142  typedef std::map<std::pair<CollObjectHandle, uint64_t>, std::pair<Ogre::SceneNode*, Ogre::WireBoundingBox*> > M_HandleToBox;
143  M_HandleToBox boxes_;
144 
146 
147  typedef std::set<Ogre::MovableObject*> S_Movable;
148  S_Movable tracked_objects_;
149 
150  class Listener : public Ogre::MovableObject::Listener
151  {
152  public:
154  : handler_(handler)
155  {}
156  virtual void objectMoved(Ogre::MovableObject* object)
157  {
158  handler_->updateTrackedBoxes();
159  }
160 
161  virtual void objectDestroyed(Ogre::MovableObject* object)
162  {
163  handler_->removeTrackedObject(object);
164  }
165 
167  };
169  ListenerPtr listener_;
170 
172 
173 private:
174  // pick_handle_ must never be changed, otherwise the destructor will
175  // call removeObject() with the wrong handle. Use getHandle() to
176  // access the value.
178 
179  friend class SelectionManager;
180 };
181 
183 typedef std::vector<SelectionHandlerPtr> V_SelectionHandler;
184 typedef std::set<SelectionHandlerPtr> S_SelectionHandler;
185 
186 }
187 
188 #endif
boost::shared_ptr< Listener > ListenerPtr
std::set< SelectionHandlerPtr > S_SelectionHandler
virtual bool needsAdditionalRenderPass(uint32_t pass)
CollObjectHandle getHandle() const
virtual void updateProperties()
Override to update property values.
std::vector< SelectionHandlerPtr > V_SelectionHandler
A single element of a property tree, with a name, value, description, and possibly children...
Definition: property.h:100
std::set< Ogre::MovableObject * > S_Movable
virtual void objectMoved(Ogre::MovableObject *object)
Pure-virtual base class for objects which give Display subclasses context in which to work...
std::vector< Ogre::AxisAlignedBox > V_AABB
Listener(SelectionHandler *handler)
DisplayContext * context_
InteractiveObjectWPtr interactive_object_
boost::weak_ptr< InteractiveObject > InteractiveObjectWPtr
std::map< std::pair< CollObjectHandle, uint64_t >, std::pair< Ogre::SceneNode *, Ogre::WireBoundingBox * > > M_HandleToBox
CollObjectHandle pick_handle_
QList< Property * > properties_
virtual void createProperties(const Picked &obj, Property *parent_property)
Override to create properties of the given picked object(s).
virtual void objectDestroyed(Ogre::MovableObject *object)
boost::shared_ptr< SelectionHandler > SelectionHandlerPtr
uint32_t CollObjectHandle
Definition: forwards.h:46


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Wed Aug 28 2019 04:01:51