30 #ifndef RVIZ_SELECTION_MANAGER_H 31 #define RVIZ_SELECTION_MANAGER_H 41 #include <boost/shared_ptr.hpp> 42 #include <boost/unordered_map.hpp> 43 #include <boost/thread/recursive_mutex.hpp> 45 #include <OgreTexture.h> 46 #include <OgreMaterial.h> 47 #include <OgreMaterialManager.h> 48 #include <OgreMovableObject.h> 49 #include <OgreRenderQueueListener.h> 50 #include <OgreSharedPtr.h> 65 class WireBoundingBox;
76 class PropertyTreeModel;
77 class ViewportMouseEvent;
78 class VisualizationManager;
80 class SelectionManager:
public QObject,
public Ogre::MaterialManager::Listener,
public Ogre::RenderQueueListener
97 void setDebugMode(
bool debug );
104 void highlight(Ogre::Viewport* viewport,
int x1,
int y1,
int x2,
int y2);
105 void removeHighlight();
108 void select(Ogre::Viewport* viewport,
int x1,
int y1,
int x2,
int y2,
SelectType type);
112 void pick(Ogre::Viewport* viewport,
int x1,
int y1,
int x2,
int y2,
M_Picked& results,
bool single_render_pass=
false );
117 void setSelection(
const M_Picked& objs);
118 void addSelection(
const M_Picked& objs);
119 void removeSelection(
const M_Picked& objs);
126 static void setPickColor(
const Ogre::ColourValue& color, Ogre::SceneNode* node ) { setPickData(
colorToHandle( color ), color, node ); }
127 static void setPickColor(
const Ogre::ColourValue& color, Ogre::MovableObject*
object ) { setPickData(
colorToHandle( color ), color,
object ); }
130 static void setPickData(
CollObjectHandle handle,
const Ogre::ColourValue& color, Ogre::SceneNode* node );
131 static void setPickData(
CollObjectHandle handle,
const Ogre::ColourValue& color, Ogre::MovableObject*
object );
134 virtual Ogre::Technique* handleSchemeNotFound(
unsigned short scheme_index,
135 const Ogre::String& scheme_name,
136 Ogre::Material* original_material,
137 unsigned short lod_index,
138 const Ogre::Renderable* rend);
144 void enableInteraction(
bool enable );
148 void focusOnSelection();
151 void setTextureSize(
unsigned size );
156 bool get3DPoint( Ogre::Viewport* viewport,
const int x,
const int y, Ogre::Vector3& result_point );
174 bool get3DPatch( Ogre::Viewport* viewport,
const int x,
const int y,
const unsigned width,
175 const unsigned height,
const bool skip_missing,
176 std::vector<Ogre::Vector3> &result_points );
194 bool getPatchDepthImage( Ogre::Viewport* viewport,
const int x,
const int y,
const unsigned width,
195 const unsigned height, std::vector<float> & depth_vector);
198 void renderQueueStarted( uint8_t queueGroupId,
199 const std::string& invocation,
200 bool& skipThisInvocation );
207 void updateProperties();
210 void selectionAdded(
const M_Picked& added );
211 void selectionRemoved(
const M_Picked& removed );
213 std::pair<Picked, bool> addSelectedObject(
const Picked& obj);
214 void removeSelectedObject(
const Picked& obj);
216 void setHighlightRect(Ogre::Viewport* viewport,
int x1,
int y1,
int x2,
int y2);
219 void renderAndUnpack(Ogre::Viewport* viewport, uint32_t pass,
int x1,
int y1,
int x2,
int y2,
V_CollObject& pixels);
222 bool render( Ogre::Viewport* viewport, Ogre::TexturePtr tex,
223 int x1,
int y1,
int x2,
int y2,
224 Ogre::PixelBox& dst_box, std::string material_scheme,
225 unsigned texture_width,
unsigned textured_height );
227 void unpackColors(
const Ogre::PixelBox& box,
V_CollObject& pixels);
229 void setDepthTextureSize(
unsigned width,
unsigned height);
231 void publishDebugImage(
const Ogre::PixelBox& pixel_box,
const std::string& label );
254 const static uint32_t s_num_render_textures_ = 2;
255 Ogre::TexturePtr render_textures_[s_num_render_textures_];
256 Ogre::PixelBox pixel_boxes_[s_num_render_textures_];
293 #endif // RVIZ_SELECTION_MANAGER_H
ROSCONSOLE_DECL void initialize()
boost::unordered_map< CollObjectHandle, Picked > M_Picked
TFSIMD_FORCE_INLINE const tfScalar & y() const
Ogre::Technique * fallback_black_cull_technique_
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
Ogre::Technique * fallback_pick_cull_technique_
static void setPickHandle(CollObjectHandle handle, Ogre::SceneNode *node)
uint32_t depth_texture_width_
PropertyTreeModel * property_model_
Ogre::Technique * fallback_pick_technique_
std::map< std::string, ros::Publisher > PublisherMap
const M_Picked & getSelection()
V_CollObject pixel_buffer_
Ogre::Technique * fallback_depth_cull_technique_
The VisualizationManager class is the central manager class of rviz, holding all the Displays...
static void setPickColor(const Ogre::ColourValue &color, Ogre::MovableObject *object)
std::vector< CollObjectHandle > V_CollObject
TFSIMD_FORCE_INLINE const tfScalar & x() const
PublisherMap debug_publishers_
boost::unordered_map< CollObjectHandle, SelectionHandler * > M_CollisionObjectToSelectionHandler
Ogre::TexturePtr depth_render_texture_
static void setPickHandle(CollObjectHandle handle, Ogre::MovableObject *object)
Ogre::Technique * fallback_depth_technique_
uint32_t colorToHandle(Ogre::PixelFormat fmt, uint32_t col)
Ogre::SceneNode * highlight_node_
Ogre::Viewport * viewport
VisualizationManager * vis_manager_
static void setPickColor(const Ogre::ColourValue &color, Ogre::SceneNode *node)
Ogre::Rectangle2D * highlight_rectangle_
bool getInteractionEnabled()
Ogre::MaterialPtr fallback_pick_material_
Ogre::Technique * fallback_black_technique_
PropertyTreeModel * getPropertyModel()
Ogre::PixelBox depth_pixel_box_
boost::recursive_mutex global_mutex_
bool interaction_enabled_
M_CollisionObjectToSelectionHandler objects_
uint32_t CollObjectHandle