overlay_utils.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #ifndef JSK_RVIZ_PLUGIN_OVERLAY_UTIL_H_
37 #define JSK_RVIZ_PLUGIN_OVERLAY_UTIL_H_
38 
39 
40 #include <OGRE/OgreMaterialManager.h>
41 #include <OGRE/OgreTextureManager.h>
42 #include <OGRE/OgreTexture.h>
43 #include <OGRE/OgreTechnique.h>
44 #include <OGRE/OgreHardwarePixelBuffer.h>
45 // see OGRE/OgrePrerequisites.h
46 //#define OGRE_VERSION ((OGRE_VERSION_MAJOR << 16) | (OGRE_VERSION_MINOR << 8) | OGRE_VERSION_PATCH)
47 #if OGRE_VERSION < ((1 << 16) | (9 << 8) | 0)
48  #include <OGRE/OgrePanelOverlayElement.h>
49  #include <OGRE/OgreOverlayElement.h>
50  #include <OGRE/OgreOverlayContainer.h>
51  #include <OGRE/OgreOverlayManager.h>
52 #else
53  #include <OGRE/Overlay/OgreOverlay.h>
54  #include <OGRE/Overlay/OgrePanelOverlayElement.h>
55  #include <OGRE/Overlay/OgreOverlayElement.h>
56  #include <OGRE/Overlay/OgreOverlayContainer.h>
57  #include <OGRE/Overlay/OgreOverlayManager.h>
58 #endif
59 
60 #include <QImage>
61 #include <QColor>
62 
63 #include <ros/ros.h>
64 
65 namespace jsk_rviz_plugins
66 {
67  class OverlayObject;
68 
69  class ScopedPixelBuffer
70  {
71  public:
72  ScopedPixelBuffer(Ogre::HardwarePixelBufferSharedPtr pixel_buffer);
73  virtual ~ScopedPixelBuffer();
74  virtual Ogre::HardwarePixelBufferSharedPtr getPixelBuffer();
75  virtual QImage getQImage(unsigned int width, unsigned int height);
76  virtual QImage getQImage(OverlayObject& overlay);
77  virtual QImage getQImage(unsigned int width, unsigned int height, QColor& bg_color);
78  virtual QImage getQImage(OverlayObject& overlay, QColor& bg_color);
79  protected:
80  Ogre::HardwarePixelBufferSharedPtr pixel_buffer_;
81  private:
82 
83  };
84 
85 
86  // this is a class for put overlay object on rviz 3D panel.
87  // This class suppose to be instantiated in onInitialize method
88  // of rviz::Display class.
89  class OverlayObject
90  {
91  public:
92 #if ROS_VERSION_MINIMUM(1,12,0)
93  typedef std::shared_ptr<OverlayObject> Ptr;
94 #else
96 #endif
97 
98  OverlayObject(const std::string& name);
99  virtual ~OverlayObject();
100 
101  virtual std::string getName();
102  virtual void hide();
103  virtual void show();
104  virtual bool isTextureReady();
105  virtual void updateTextureSize(unsigned int width, unsigned int height);
106  virtual ScopedPixelBuffer getBuffer();
107  virtual void setPosition(double left, double top);
108  virtual void setDimensions(double width, double height);
109  virtual bool isVisible();
110  virtual unsigned int getTextureWidth();
111  virtual unsigned int getTextureHeight();
112  protected:
113  const std::string name_;
114  Ogre::Overlay* overlay_;
115  Ogre::PanelOverlayElement* panel_;
116  Ogre::MaterialPtr panel_material_;
117  Ogre::TexturePtr texture_;
118 
119  private:
120 
121  };
122 
123  // Ogre::Overlay* createOverlay(std::string name);
124  // Ogre::PanelOverlayElement* createOverlayPanel(Ogre::Overlay* overlay);
125  // Ogre::MaterialPtr createOverlayMaterial(Ogre::Overlay* overlay);
126 }
127 
128 #endif
boost::shared_ptr< OverlayObject >
jsk_rviz_plugins::OverlayObject::isTextureReady
virtual bool isTextureReady()
Definition: overlay_utils.cpp:169
jsk_rviz_plugins::OverlayObject::getTextureWidth
virtual unsigned int getTextureWidth()
Definition: overlay_utils.cpp:235
jsk_rviz_plugins::ScopedPixelBuffer::ScopedPixelBuffer
ScopedPixelBuffer(Ogre::HardwarePixelBufferSharedPtr pixel_buffer)
Definition: overlay_utils.cpp:73
jsk_rviz_plugins::ScopedPixelBuffer
Definition: overlay_utils.h:101
ros.h
jsk_rviz_plugins::OverlayObject::getTextureHeight
virtual unsigned int getTextureHeight()
Definition: overlay_utils.cpp:245
jsk_rviz_plugins::OverlayObject::isVisible
virtual bool isVisible()
Definition: overlay_utils.cpp:230
jsk_rviz_plugins::OverlayObject::OverlayObject
OverlayObject(const std::string &name)
Definition: overlay_utils.cpp:121
overlay_sample.left
left
Definition: overlay_sample.py:26
overlay_sample.bg_color
bg_color
Definition: overlay_sample.py:45
jsk_rviz_plugins::ScopedPixelBuffer::~ScopedPixelBuffer
virtual ~ScopedPixelBuffer()
Definition: overlay_utils.cpp:79
jsk_rviz_plugins::OverlayObject::show
virtual void show()
Definition: overlay_utils.cpp:162
jsk_rviz_plugins::OverlayObject::name_
const std::string name_
Definition: overlay_utils.h:145
jsk_rviz_plugins::OverlayObject::overlay_
Ogre::Overlay * overlay_
Definition: overlay_utils.h:146
jsk_rviz_plugins::OverlayObject::~OverlayObject
virtual ~OverlayObject()
Definition: overlay_utils.cpp:139
jsk_rviz_plugins::OverlayObject::getName
virtual std::string getName()
Definition: overlay_utils.cpp:150
jsk_rviz_plugins::OverlayObject::hide
virtual void hide()
Definition: overlay_utils.cpp:155
jsk_rviz_plugins::ScopedPixelBuffer::getPixelBuffer
virtual Ogre::HardwarePixelBufferSharedPtr getPixelBuffer()
Definition: overlay_utils.cpp:84
jsk_rviz_plugins::OverlayObject::setPosition
virtual void setPosition(double left, double top)
Definition: overlay_utils.cpp:220
jsk_rviz_plugins::OverlayObject::getBuffer
virtual ScopedPixelBuffer getBuffer()
Definition: overlay_utils.cpp:210
jsk_rviz_plugins::OverlayObject::panel_
Ogre::PanelOverlayElement * panel_
Definition: overlay_utils.h:147
jsk_rviz_plugins::OverlayObject::updateTextureSize
virtual void updateTextureSize(unsigned int width, unsigned int height)
Definition: overlay_utils.cpp:174
jsk_rviz_plugins::OverlayObject::panel_material_
Ogre::MaterialPtr panel_material_
Definition: overlay_utils.h:148
jsk_rviz_plugins::ScopedPixelBuffer::getQImage
virtual QImage getQImage(unsigned int width, unsigned int height)
Definition: overlay_utils.cpp:89
overlay_sample.top
top
Definition: overlay_sample.py:27
jsk_rviz_plugins::OverlayObject::texture_
Ogre::TexturePtr texture_
Definition: overlay_utils.h:149
jsk_rviz_plugins::ScopedPixelBuffer::pixel_buffer_
Ogre::HardwarePixelBufferSharedPtr pixel_buffer_
Definition: overlay_utils.h:112
jsk_rviz_plugins
Definition: __init__.py:1
jsk_rviz_plugins::OverlayObject::Ptr
boost::shared_ptr< OverlayObject > Ptr
Definition: overlay_utils.h:127
jsk_rviz_plugins::OverlayObject::setDimensions
virtual void setDimensions(double width, double height)
Definition: overlay_utils.cpp:225


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Fri Dec 13 2024 03:49:56