text_output.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * \file
00003  *
00004  * $Id:
00005  *
00006  * Copyright (C) Brno University of Technology
00007  *
00008  * This file is part of software developed by dcgm-robotics@FIT group.
00009  *
00010  * Author: Tomas Lokaj (xlokaj03@stud.fit.vutbr.cz)
00011  * Supervised by: Michal Spanel (spanel@fit.vutbr.cz)
00012  * Date: 26/10/2012
00013  *
00014  * This file is free software: you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as published by
00016  * the Free Software Foundation, either version 3 of the License, or
00017  * (at your option) any later version.
00018  *
00019  * This file is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU Lesser General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this file.  If not, see <http://www.gnu.org/licenses/>.
00026  */
00027 
00028 #pragma once
00029 #include <Ogre.h>
00030 
00031 #ifndef TEXT_OUTPUT_H_
00032 #define TEXT_OUTPUT_H_
00033 
00034 namespace ogre_tools
00035 {
00039 class TextOutput
00040 {
00041 
00042 public:
00052   TextOutput(const std::string& id, Ogre::Real pos_x, Ogre::Real pos_y, Ogre::Real width, Ogre::Real height) :
00053       id_(id)
00054   {
00055     overlayManager_ = Ogre::OverlayManager::getSingletonPtr();
00056 
00057     panel_ = static_cast<Ogre::OverlayContainer*>(overlayManager_->createOverlayElement("Panel", "text_container"));
00058     panel_->setDimensions(1, 1);
00059     panel_->setPosition(0, 0);
00060 
00061     overlay_ = overlayManager_->create("text_overlay");
00062     overlay_->add2D(panel_);
00063     overlay_->show();
00064 
00065     textBox_ = overlayManager_->createOverlayElement("TextArea", id_);
00066     textBox_->setPosition(pos_x, pos_y);
00067     textBox_->setDimensions(width, height);
00068     textBox_->setWidth(width);
00069     textBox_->setHeight(height);
00070     textBox_->setMetricsMode(Ogre::GMM_PIXELS);
00071     textBox_->setParameter("font_name", "Arial");
00072 
00073     panel_->addChild(textBox_);
00074   }
00075 
00079   ~TextOutput();
00080 
00085   void setText(const std::string& Text)
00086   {
00087     textBox_->setCaption(Text);
00088   }
00089 
00094   void setColor(const Ogre::ColourValue& color)
00095   {
00096     textBox_->setColour(color);
00097   }
00098 
00103   void setFontSize(const int& size)
00104   {
00105     std::stringstream char_height;
00106     char_height << size;
00107     textBox_->setParameter("char_height", char_height.str());
00108   }
00109 
00110 private:
00111   Ogre::OverlayElement* textBox_;
00112   Ogre::OverlayManager* overlayManager_;
00113   Ogre::Overlay* overlay_;
00114   Ogre::OverlayContainer* panel_;
00115   std::string id_;
00116 };
00117 }
00118 
00119 #endif /* TEXT_OUTPUT_H_ */


srs_ui_but
Author(s): Vit Stancl (stancl@fit.vutbr.cz), Michal Spanel (spanel@fit.vutbr.cz), Tomas Lokaj
autogenerated on Mon Oct 6 2014 08:49:30