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/OgrePanelOverlayElement.h>
54  #include <OGRE/Overlay/OgreOverlayElement.h>
55  #include <OGRE/Overlay/OgreOverlayContainer.h>
56  #include <OGRE/Overlay/OgreOverlayManager.h>
57 #endif
58 
59 #include <QImage>
60 #include <QColor>
61 
62 #include <ros/ros.h>
63 
64 namespace jsk_rviz_plugins
65 {
66  class OverlayObject;
67 
68  class ScopedPixelBuffer
69  {
70  public:
71  ScopedPixelBuffer(Ogre::HardwarePixelBufferSharedPtr pixel_buffer);
72  virtual ~ScopedPixelBuffer();
73  virtual Ogre::HardwarePixelBufferSharedPtr getPixelBuffer();
74  virtual QImage getQImage(unsigned int width, unsigned int height);
75  virtual QImage getQImage(OverlayObject& overlay);
76  virtual QImage getQImage(unsigned int width, unsigned int height, QColor& bg_color);
77  virtual QImage getQImage(OverlayObject& overlay, QColor& bg_color);
78  protected:
79  Ogre::HardwarePixelBufferSharedPtr pixel_buffer_;
80  private:
81 
82  };
83 
84 
85  // this is a class for put overlay object on rviz 3D panel.
86  // This class suppose to be instantiated in onInitialize method
87  // of rviz::Display class.
88  class OverlayObject
89  {
90  public:
91 #if ROS_VERSION_MINIMUM(1,12,0)
92  typedef std::shared_ptr<OverlayObject> Ptr;
93 #else
95 #endif
96 
97  OverlayObject(const std::string& name);
98  virtual ~OverlayObject();
99 
100  virtual std::string getName();
101  virtual void hide();
102  virtual void show();
103  virtual bool isTextureReady();
104  virtual void updateTextureSize(unsigned int width, unsigned int height);
105  virtual ScopedPixelBuffer getBuffer();
106  virtual void setPosition(double left, double top);
107  virtual void setDimensions(double width, double height);
108  virtual bool isVisible();
109  virtual unsigned int getTextureWidth();
110  virtual unsigned int getTextureHeight();
111  protected:
112  const std::string name_;
113  Ogre::Overlay* overlay_;
114  Ogre::PanelOverlayElement* panel_;
115  Ogre::MaterialPtr panel_material_;
116  Ogre::TexturePtr texture_;
117 
118  private:
119 
120  };
121 
122  // Ogre::Overlay* createOverlay(std::string name);
123  // Ogre::PanelOverlayElement* createOverlayPanel(Ogre::Overlay* overlay);
124  // Ogre::MaterialPtr createOverlayMaterial(Ogre::Overlay* overlay);
125 }
126 
127 #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:100
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:144
jsk_rviz_plugins::OverlayObject::overlay_
Ogre::Overlay * overlay_
Definition: overlay_utils.h:145
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:146
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:147
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:148
jsk_rviz_plugins::ScopedPixelBuffer::pixel_buffer_
Ogre::HardwarePixelBufferSharedPtr pixel_buffer_
Definition: overlay_utils.h:111
jsk_rviz_plugins
Definition: __init__.py:1
jsk_rviz_plugins::OverlayObject::Ptr
boost::shared_ptr< OverlayObject > Ptr
Definition: overlay_utils.h:126
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 Aug 2 2024 08:50:14