ogre_panel.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2020, Locus Robotics
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef ROBOT_NAV_RVIZ_PLUGINS_OGRE_PANEL_H
36 #define ROBOT_NAV_RVIZ_PLUGINS_OGRE_PANEL_H
37 
38 #include <OgreManualObject.h>
39 #include <OgreSceneManager.h>
41 #include <nav_core2/bounds.h>
42 #include <rviz/ogre_helpers/custom_parameter_indices.h> // ALPHA_PARAMETER
43 #include <rviz/frame_manager.h>
45 #include <map>
46 #include <memory>
47 #include <string>
48 #include <vector>
49 
50 namespace robot_nav_rviz_plugins
51 {
63 class OgrePanel
64 {
65 public:
67  Ogre::SceneManager& scene_manager, Ogre::SceneNode& scene_node);
68 
73  void updateInfo(const nav_grid::NavGridInfo& info);
74 
81  void updateData(const nav_core2::UIntBounds& updated_bounds);
82 
86  void addPalette(const NavGridPalette& palette);
87 
92  void setPalette(const std::string& palette_name);
93 
99  void updateAlpha(float alpha, bool draw_behind);
100 
104  void clear();
105 
112 
113  using Ptr = std::shared_ptr<OgrePanel>;
114 
115 protected:
120  {
121  public:
122  PartialOgrePanel(Ogre::SceneManager& scene_manager, Ogre::SceneNode& parent_scene_node,
123  const nav_core2::UIntBounds& bounds, float resolution);
125 
126  const nav_core2::UIntBounds& getBounds() const { return bounds_; }
127 
132  void updateData(std::vector<unsigned char>& pixels);
133  void clear();
134 
135  void setTexture(const std::string& texture_name, int index);
136  void updateAlphaRendering(Ogre::SceneBlendType scene_blending, bool depth_write, int group,
137  Ogre::Renderable::Visitor* alpha_setter);
138 
139 
140  using Ptr = std::shared_ptr<PartialOgrePanel>;
141 
142  protected:
143  Ogre::SceneManager& scene_manager_;
144  Ogre::ManualObject* manual_object_;
145  Ogre::TexturePtr texture_;
146  Ogre::MaterialPtr material_;
147  Ogre::SceneNode* scene_node_;
149  };
150 
151  nav_grid::VectorNavGrid<unsigned char>& data_; // VectorNavGrid is used for easy copying
152  Ogre::SceneManager& scene_manager_;
153  Ogre::SceneNode& scene_node_;
154  std::vector<PartialOgrePanel::Ptr> swatches_; // For some reason, code segfaults if this is changed to raw object
155 
156  std::map<std::string, Ogre::TexturePtr> palettes_;
157  std::map<std::string, bool> palette_transparency_;
158  std::string current_palette_;
159 };
160 } // namespace robot_nav_rviz_plugins
161 
162 #endif // ROBOT_NAV_RVIZ_PLUGINS_OGRE_PANEL_H
Portion of the larger OgrePanel....see above.
Definition: ogre_panel.h:119
std::map< std::string, bool > palette_transparency_
Definition: ogre_panel.h:157
void updateInfo(const nav_grid::NavGridInfo &info)
Update the location/shape of the grid.
Definition: ogre_panel.cpp:57
OgrePanel(nav_grid::VectorNavGrid< unsigned char > &data, Ogre::SceneManager &scene_manager, Ogre::SceneNode &scene_node)
Definition: ogre_panel.cpp:51
void updateAlphaRendering(Ogre::SceneBlendType scene_blending, bool depth_write, int group, Ogre::Renderable::Visitor *alpha_setter)
std::shared_ptr< PartialOgrePanel > Ptr
Definition: ogre_panel.h:140
std::shared_ptr< OgrePanel > Ptr
Definition: ogre_panel.h:113
PartialOgrePanel(Ogre::SceneManager &scene_manager, Ogre::SceneNode &parent_scene_node, const nav_core2::UIntBounds &bounds, float resolution)
Ogre::SceneManager & scene_manager_
Definition: ogre_panel.h:152
nav_grid::VectorNavGrid< unsigned char > & data_
Definition: ogre_panel.h:151
void setTexture(const std::string &texture_name, int index)
void updateData(std::vector< unsigned char > &pixels)
Update the data for this Partial Panel.
void clear()
Clear the panel from the visualization by making it invisible.
Definition: ogre_panel.cpp:215
Several reusable pieces for displaying polygons.
A collection of Ogre objects for rendering a two-dimensional rectangular plane (such as a map) in rvi...
Definition: ogre_panel.h:63
void addPalette(const NavGridPalette &palette)
Add a palette with the given name.
Definition: ogre_panel.cpp:131
const nav_core2::UIntBounds & getBounds() const
Definition: ogre_panel.h:126
std::map< std::string, Ogre::TexturePtr > palettes_
Definition: ogre_panel.h:156
bool transformMap(rviz::FrameManager &fm)
Move the map to its proper position and orientation.
Definition: ogre_panel.cpp:223
void updateData(const nav_core2::UIntBounds &updated_bounds)
Update the panel data within the given bounds.
Definition: ogre_panel.cpp:94
void updateAlpha(float alpha, bool draw_behind)
Sets the alpha/draw_behind properties.
Definition: ogre_panel.cpp:175
std::vector< PartialOgrePanel::Ptr > swatches_
Definition: ogre_panel.h:154
void setPalette(const std::string &palette_name)
Set the palette to use.
Definition: ogre_panel.cpp:165
A simple datastructure representing a palette of up to 256 24-bit colors.


robot_nav_rviz_plugins
Author(s):
autogenerated on Sun Jan 10 2021 04:08:58