MIRA
TextObject.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
51 #ifndef _MIRA_TEXTOBJECT_H_
52 #define _MIRA_TEXTOBJECT_H_
53 
54 #ifndef Q_MOC_RUN
55 #include <OGRE/OgreMovableObject.h>
56 #include <OGRE/OgreRenderable.h>
57 #include <OGRE/OgreVector3.h>
58 #include <OGRE/OgreQuaternion.h>
59 #endif
60 
61 #if (OGRE_VERSION >= 0x010900)
62 #include <OGRE/Overlay/OgreFont.h>
63 #endif
64 
66 
67 namespace Ogre
68 {
69  class RenderQueue;
70  class Camera;
71 }
72 
73 namespace mira {
74 
76 
77 class TextObject: public Ogre::MovableObject, public Ogre::Renderable, public VisualizationObject
78 {
79  /******************************** TextObject data ****************************/
80 public:
82  {
86  };
88  {
92  };
93 
94 protected:
95  Ogre::String mFontName;
96  Ogre::String mType;
97  Ogre::String mName;
98  Ogre::String mCaption;
101 
102  Ogre::ColourValue mColor;
103  Ogre::RenderOperation mRenderOp;
104  Ogre::AxisAlignedBox mAABB;
105  Ogre::LightList mLList;
106 
107  Ogre::Real mCharHeight;
108  Ogre::Real mSpaceWidth;
109 
112  bool mOnTop;
113 
115  Ogre::Real mRadius;
116 
117  Ogre::Vector3 mGlobalTranslation;
118  Ogre::Vector3 mLocalTranslation;
119 
120  Ogre::Camera *mCam;
121  Ogre::RenderWindow *mWin;
122  Ogre::Font *mFont;
123  Ogre::MaterialPtr mMaterial;
124  Ogre::MaterialPtr mBackgroundMaterial;
125 
126  /******************************** public methods ******************************/
127 public:
128 
129  TextObject(const Ogre::String &caption,
130  Ogre::SceneManager* sceneManager,
131  Ogre::SceneNode* parent=NULL);
132 
133  TextObject(const Ogre::String &caption,
134  const Ogre::String &fontName,
135  Ogre::SceneManager* sceneManager,
136  Ogre::SceneNode* parent=NULL);
137 
138  virtual ~TextObject();
139 
140  virtual void visitRenderables(Ogre::Renderable::Visitor* visitor,
141  bool debugRenderables = false);
142 
143  virtual void setColor(const Ogre::ColourValue &color);
144  virtual void setVisible(bool visible, bool cascade = true);
145 
146  // Set settings
147  void setFontName(const Ogre::String &fontName);
148  void setCaption(const Ogre::String &caption);
149  void setCharacterHeight(Ogre::Real height);
150  void setSpaceWidth(Ogre::Real width);
151  void setTextAlignment(const HorizontalAlignment& horizontalAlignment,
152  const VerticalAlignment& verticalAlignment);
153  void setGlobalTranslation(Ogre::Vector3 trans);
154  void setLocalTranslation(Ogre::Vector3 trans);
155  void showOnTop(bool show = true);
156 
157  // Get settings
158  const Ogre::String& getFontName() const
159  {
160  return mFontName;
161  }
162  const Ogre::String& getCaption() const
163  {
164  return mCaption;
165  }
166  const Ogre::ColourValue& getColor() const
167  {
168  return mColor;
169  }
170 
171  Ogre::Real getCharacterHeight() const
172  {
173  return mCharHeight;
174  }
175  Ogre::Real getSpaceWidth() const
176  {
177  return mSpaceWidth;
178  }
179  Ogre::Vector3 getGlobalTranslation() const
180  {
181  return mGlobalTranslation;
182  }
183  Ogre::Vector3 getLocalTranslation() const
184  {
185  return mLocalTranslation;
186  }
187  bool getShowOnTop() const
188  {
189  return mOnTop;
190  }
191  Ogre::AxisAlignedBox GetAABB(void)
192  {
193  return mAABB;
194  }
195 
196  /******************************** protected methods and overload **************/
197 protected:
198 
199  // from TextObject, create the object
200  void _setupGeometry();
201  void _updateColors();
202 
203  // from MovableObject
204  void getWorldTransforms(Ogre::Matrix4 *xform) const;
205  Ogre::Real getBoundingRadius(void) const
206  {
207  return mRadius;
208  }
209 
210  Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
211  {
212  return 0;
213  }
214 
215  const Ogre::Quaternion& getWorldOrientation(void) const;
216  const Ogre::Vector3& getWorldPosition(void) const;
217  const Ogre::AxisAlignedBox& getBoundingBox(void) const
218  {
219  return mAABB;
220  }
221 
222  const Ogre::String& getName(void) const
223  {
224  return mName;
225  }
226 
227  const Ogre::String& getMovableType(void) const
228  {
229  static Ogre::String movType = "TextObject";
230  return movType;
231  }
232 
233  void _notifyCurrentCamera(Ogre::Camera *cam);
234  void _updateRenderQueue(Ogre::RenderQueue* queue);
235 
236  // from renderable
237  void getRenderOperation(Ogre::RenderOperation &op);
238  const Ogre::MaterialPtr& getMaterial(void) const
239  {
240  assert(!mMaterial.isNull());
241  return mMaterial;
242  }
243 
244  const Ogre::LightList& getLights(void) const
245  {
246  return mLList;
247  }
248 
249 };
250 
252 
253 }
254 
255 #endif
HorizontalAlignment mHorizontalAlignment
Definition: TextObject.h:99
Definition: TextObject.h:90
const Ogre::ColourValue & getColor() const
Definition: TextObject.h:166
Ogre::Real mCharHeight
Definition: TextObject.h:107
Definition: TextObject.h:91
Definition: TextObject.h:85
Ogre::ColourValue mColor
Definition: TextObject.h:102
Ogre::Camera * mCam
Definition: TextObject.h:120
Ogre::Real getBoundingRadius(void) const
Definition: TextObject.h:205
Declaration of VisualizationObject.
const Ogre::String & getMovableType(void) const
Definition: TextObject.h:227
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
const Ogre::String & getCaption() const
Definition: TextObject.h:162
const Ogre::LightList & getLights(void) const
Definition: TextObject.h:244
Definition: VisualizationObject.h:70
Definition: TextObject.h:77
TextObject(const Ogre::String &caption, Ogre::SceneManager *sceneManager, Ogre::SceneNode *parent=NULL)
VerticalAlignment mVerticalAlignment
Definition: TextObject.h:100
Ogre::MaterialPtr mMaterial
Definition: TextObject.h:123
bool getShowOnTop() const
Definition: TextObject.h:187
Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
Definition: TextObject.h:210
const Ogre::Quaternion & getWorldOrientation(void) const
virtual void setColor(const Ogre::ColourValue &color)
bool mOnTop
Definition: TextObject.h:112
void setTextAlignment(const HorizontalAlignment &horizontalAlignment, const VerticalAlignment &verticalAlignment)
Ogre::Vector3 getGlobalTranslation() const
Definition: TextObject.h:179
void setCharacterHeight(Ogre::Real height)
void _updateRenderQueue(Ogre::RenderQueue *queue)
Ogre::AxisAlignedBox mAABB
Definition: TextObject.h:104
const Ogre::AxisAlignedBox & getBoundingBox(void) const
Definition: TextObject.h:217
Ogre::String mCaption
Definition: TextObject.h:98
Ogre::Real mRadius
Definition: TextObject.h:115
Ogre::AxisAlignedBox GetAABB(void)
Definition: TextObject.h:191
virtual ~TextObject()
void setCaption(const Ogre::String &caption)
void setSpaceWidth(Ogre::Real width)
const Ogre::String & getName(void) const
Definition: TextObject.h:222
Ogre::Vector3 mGlobalTranslation
Definition: TextObject.h:117
Ogre::Real getCharacterHeight() const
Definition: TextObject.h:171
Ogre::String mName
Definition: TextObject.h:97
Ogre::Vector3 getLocalTranslation() const
Definition: TextObject.h:183
virtual void setVisible(bool visible, bool cascade=true)
Definition: TextObject.h:89
void setFontName(const Ogre::String &fontName)
void getRenderOperation(Ogre::RenderOperation &op)
const Ogre::MaterialPtr & getMaterial(void) const
Definition: TextObject.h:238
Ogre::LightList mLList
Definition: TextObject.h:105
Ogre::String mFontName
Definition: TextObject.h:95
bool mNeedUpdate
Definition: TextObject.h:110
Ogre::RenderOperation mRenderOp
Definition: TextObject.h:103
Definition: ImageObject.h:60
void getWorldTransforms(Ogre::Matrix4 *xform) const
HorizontalAlignment
Definition: TextObject.h:81
void showOnTop(bool show=true)
void setGlobalTranslation(Ogre::Vector3 trans)
virtual void visitRenderables(Ogre::Renderable::Visitor *visitor, bool debugRenderables=false)
bool mUpdateColors
Definition: TextObject.h:111
Ogre::Font * mFont
Definition: TextObject.h:122
Definition: TextObject.h:84
Ogre::MaterialPtr mBackgroundMaterial
Definition: TextObject.h:124
Definition: TextObject.h:83
Ogre::Vector3 mLocalTranslation
Definition: TextObject.h:118
Ogre::Real getSpaceWidth() const
Definition: TextObject.h:175
void _notifyCurrentCamera(Ogre::Camera *cam)
Ogre::RenderWindow * mWin
Definition: TextObject.h:121
void setLocalTranslation(Ogre::Vector3 trans)
Ogre::Real mTimeUntilNextToggle
Definition: TextObject.h:114
Ogre::String mType
Definition: TextObject.h:96
Ogre::Real mSpaceWidth
Definition: TextObject.h:108
VerticalAlignment
Definition: TextObject.h:87
const Ogre::String & getFontName() const
Definition: TextObject.h:158
const Ogre::Vector3 & getWorldPosition(void) const