overlay_utils.h
Go to the documentation of this file.
00001 // -*- mode: c++ -*-
00002 /*********************************************************************
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2014, JSK Lab
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/o2r other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of the JSK Lab nor the names of its
00019  *     contributors may be used to endorse or promote products derived
00020  *     from this software without specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
00034  *********************************************************************/
00035 
00036 #ifndef JSK_RVIZ_PLUGIN_OVERLAY_UTIL_H_
00037 #define JSK_RVIZ_PLUGIN_OVERLAY_UTIL_H_
00038 
00039 #include <OGRE/OgreOverlayManager.h>
00040 #include <OGRE/OgreMaterialManager.h>
00041 #include <OGRE/OgreTextureManager.h>
00042 #include <OGRE/OgreTexture.h>
00043 #include <OGRE/OgreTechnique.h>
00044 #include <OGRE/OgreHardwarePixelBuffer.h>
00045 #include <OGRE/OgrePanelOverlayElement.h>
00046 #include <OGRE/OgreOverlayElement.h>
00047 #include <OGRE/OgreOverlayContainer.h>
00048 
00049 #include <QImage>
00050 #include <QColor>
00051 
00052 namespace jsk_rviz_plugins
00053 {
00054   class OverlayObject;
00055   
00056   class ScopedPixelBuffer
00057   {
00058   public:
00059     ScopedPixelBuffer(Ogre::HardwarePixelBufferSharedPtr pixel_buffer);
00060     virtual ~ScopedPixelBuffer();
00061     virtual Ogre::HardwarePixelBufferSharedPtr getPixelBuffer();
00062     virtual QImage getQImage(unsigned int width, unsigned int height);
00063     virtual QImage getQImage(OverlayObject& overlay);
00064     virtual QImage getQImage(unsigned int width, unsigned int height, QColor& bg_color);
00065     virtual QImage getQImage(OverlayObject& overlay, QColor& bg_color);
00066   protected:
00067     Ogre::HardwarePixelBufferSharedPtr pixel_buffer_;
00068   private:
00069     
00070   };
00071 
00072   
00073   // this is a class for put overlay object on rviz 3D panel.
00074   // This class suppose to be instantiated in onInitialize method
00075   // of rviz::Display class.
00076   class OverlayObject
00077   {
00078   public:
00079     typedef boost::shared_ptr<OverlayObject> Ptr;
00080     
00081     OverlayObject(const std::string& name);
00082     virtual ~OverlayObject();
00083     
00084     virtual std::string getName();
00085     virtual void hide();
00086     virtual void show();
00087     virtual bool isTextureReady();
00088     virtual bool updateTextureSize(unsigned int width, unsigned int height);
00089     virtual ScopedPixelBuffer getBuffer();
00090     virtual void setPosition(double left, double top);
00091     virtual void setDimensions(double width, double height);
00092     virtual bool isVisible();
00093     virtual unsigned int getTextureWidth();
00094     virtual unsigned int getTextureHeight();
00095   protected:
00096     const std::string name_;
00097     Ogre::Overlay* overlay_;
00098     Ogre::PanelOverlayElement* panel_;
00099     Ogre::MaterialPtr panel_material_;
00100     Ogre::TexturePtr texture_;
00101 
00102   private:
00103     
00104   };
00105   
00106   // Ogre::Overlay* createOverlay(std::string name);
00107   // Ogre::PanelOverlayElement* createOverlayPanel(Ogre::Overlay* overlay);
00108   // Ogre::MaterialPtr createOverlayMaterial(Ogre::Overlay* overlay);
00109 }
00110 
00111 #endif


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Sun Sep 13 2015 22:29:03