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 
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.
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
virtual QImage getQImage(unsigned int width, unsigned int height)
ROSCONSOLE_CONSOLE_IMPL_DECL std::string getName(void *handle)
width
Ogre::HardwarePixelBufferSharedPtr pixel_buffer_
Definition: overlay_utils.h:79
Ogre::MaterialPtr panel_material_
ScopedPixelBuffer(Ogre::HardwarePixelBufferSharedPtr pixel_buffer)
bool isVisible(PanelDockWidget *widget)
height
virtual Ogre::HardwarePixelBufferSharedPtr getPixelBuffer()
Ogre::PanelOverlayElement * panel_
boost::shared_ptr< OverlayObject > Ptr
Definition: overlay_utils.h:94


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Thu Jun 1 2023 02:45:58