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 #include <rviz/rviz_export.h>
48 
49 namespace Ogre
50 {
51 class WireBoundingBox;
52 class SceneNode;
53 class MovableObject;
54 } // namespace Ogre
55 
56 namespace rviz
57 {
58 class DisplayContext;
59 class Property;
61 
62 typedef std::vector<Ogre::AxisAlignedBox> V_AABB;
63 
64 class RVIZ_EXPORT SelectionHandler
65 {
66 public:
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  {
85  }
86 
94  virtual void destroyProperties(const Picked& obj, Property* parent_property);
95 
105  virtual void updateProperties()
106  {
107  }
108 
109  virtual bool needsAdditionalRenderPass(uint32_t /*pass*/)
110  {
111  return false;
112  }
113 
114  virtual void preRenderPass(uint32_t pass);
115  virtual void postRenderPass(uint32_t pass);
116 
117  virtual void getAABBs(const Picked& obj, V_AABB& aabbs);
118 
119  virtual void onSelect(const Picked& obj);
120  virtual void onDeselect(const Picked& obj);
121 
124  virtual void setInteractiveObject(InteractiveObjectWPtr object);
125 
133  virtual InteractiveObjectWPtr getInteractiveObject();
134 
136  {
137  return pick_handle_;
138  }
139 
140 protected:
142  void createBox(const std::pair<CollObjectHandle, uint64_t>& handles,
143  const Ogre::AxisAlignedBox& aabb,
144  const std::string& material_name);
145 
147  void destroyBox(const std::pair<CollObjectHandle, uint64_t>& handles);
148 
149  QList<Property*> properties_;
150 
151  typedef std::map<std::pair<CollObjectHandle, uint64_t>,
152  std::pair<Ogre::SceneNode*, Ogre::WireBoundingBox*> >
155 
157 
158  typedef std::set<Ogre::MovableObject*> S_Movable;
160 
161  class Listener : public Ogre::MovableObject::Listener
162  {
163  public:
164  Listener(SelectionHandler* handler) : handler_(handler)
165  {
166  }
167  void objectMoved(Ogre::MovableObject* /*object*/) override
168  {
169  handler_->updateTrackedBoxes();
170  }
171 
172  void objectDestroyed(Ogre::MovableObject* object) override
173  {
174  handler_->removeTrackedObject(object);
175  }
176 
178  };
181 
183 
184 private:
185  // pick_handle_ must never be changed, otherwise the destructor will
186  // call removeObject() with the wrong handle. Use getHandle() to
187  // access the value.
189 
190  friend class SelectionManager;
191 };
192 
194 typedef std::vector<SelectionHandlerPtr> V_SelectionHandler;
195 typedef std::set<SelectionHandlerPtr> S_SelectionHandler;
196 
197 } // namespace rviz
198 
199 #endif
rviz::SelectionHandler::Listener::objectDestroyed
void objectDestroyed(Ogre::MovableObject *object) override
Definition: selection_handler.h:172
Ogre
Definition: axes_display.h:35
rviz::SelectionHandler::M_HandleToBox
std::map< std::pair< CollObjectHandle, uint64_t >, std::pair< Ogre::SceneNode *, Ogre::WireBoundingBox * > > M_HandleToBox
Definition: selection_handler.h:153
boost::shared_ptr< Listener >
rviz::SelectionHandler::Listener::objectMoved
void objectMoved(Ogre::MovableObject *) override
Definition: selection_handler.h:167
rviz::SelectionHandler::ListenerPtr
boost::shared_ptr< Listener > ListenerPtr
Definition: selection_handler.h:179
forwards.h
rviz::SelectionHandlerPtr
boost::shared_ptr< SelectionHandler > SelectionHandlerPtr
Definition: selection_handler.h:193
rviz::SelectionHandler::getHandle
CollObjectHandle getHandle() const
Definition: selection_handler.h:135
interactive_object.h
rviz::ViewportMouseEvent
Definition: viewport_mouse_event.h:45
viewport_mouse_event.h
rviz::SelectionHandler::S_Movable
std::set< Ogre::MovableObject * > S_Movable
Definition: selection_handler.h:158
rviz::SelectionHandler::tracked_objects_
S_Movable tracked_objects_
Definition: selection_handler.h:159
rviz::CollObjectHandle
uint32_t CollObjectHandle
Definition: forwards.h:45
rviz::Picked
Definition: forwards.h:53
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
selection_handler.h
rviz::SelectionHandler::pick_handle_
CollObjectHandle pick_handle_
Definition: selection_handler.h:188
rviz
Definition: add_display_dialog.cpp:54
rviz::SelectionHandler::context_
DisplayContext * context_
Definition: selection_handler.h:156
rviz::SelectionHandler::createProperties
virtual void createProperties(const Picked &, Property *)
Override to create properties of the given picked object(s).
Definition: selection_handler.h:83
rviz::SelectionHandler::Listener
Definition: selection_handler.h:161
rviz::SelectionHandler::updateProperties
virtual void updateProperties()
Override to update property values.
Definition: selection_handler.h:105
rviz::SelectionHandler::boxes_
M_HandleToBox boxes_
Definition: selection_handler.h:154
rviz::DisplayContext
Pure-virtual base class for objects which give Display subclasses context in which to work.
Definition: display_context.h:81
rviz::SelectionHandler::interactive_object_
InteractiveObjectWPtr interactive_object_
Definition: selection_handler.h:182
rviz::SelectionHandler::needsAdditionalRenderPass
virtual bool needsAdditionalRenderPass(uint32_t)
Definition: selection_handler.h:109
rviz::SelectionHandler::Listener::Listener
Listener(SelectionHandler *handler)
Definition: selection_handler.h:164
rviz::S_SelectionHandler
std::set< SelectionHandlerPtr > S_SelectionHandler
Definition: selection_handler.h:195
rviz::V_AABB
std::vector< Ogre::AxisAlignedBox > V_AABB
Definition: selection_handler.h:60
rviz::SelectionManager
Definition: selection_manager.h:81
rviz::SelectionHandler
Definition: selection_handler.h:64
rviz::SelectionHandler::properties_
QList< Property * > properties_
Definition: selection_handler.h:149
rviz::V_SelectionHandler
std::vector< SelectionHandlerPtr > V_SelectionHandler
Definition: selection_handler.h:194
rviz::SelectionHandler::Listener::handler_
SelectionHandler * handler_
Definition: selection_handler.h:177
rviz::InteractiveObjectWPtr
boost::weak_ptr< InteractiveObject > InteractiveObjectWPtr
Definition: interactive_object.h:59
rviz::SelectionHandler::listener_
ListenerPtr listener_
Definition: selection_handler.h:180


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:10