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 
55 
56 #ifndef Q_MOC_RUN
57 #include <OGRE/OgreMovableObject.h>
58 #include <OGRE/OgreRenderable.h>
59 #include <OGRE/OgreVector3.h>
60 #include <OGRE/OgreQuaternion.h>
61 #endif
62 
63 #if (OGRE_VERSION >= 0x010900)
64 #include <OGRE/Overlay/OgreFont.h>
65 #endif
66 
68 
69 namespace Ogre
70 {
71  class RenderQueue;
72  class Camera;
73 }
74 
75 namespace mira {
76 
78 
79 class MIRA_GUI_VISUALIZATION_EXPORT TextObject: public Ogre::MovableObject, public Ogre::Renderable, public VisualizationObject
80 {
81  /******************************** TextObject data ****************************/
82 public:
84  {
87  H_RIGHT
88  };
90  {
93  V_CENTER
94  };
95 
96 protected:
97  Ogre::String mFontName;
98  Ogre::String mType;
99  Ogre::String mName;
100  Ogre::String mCaption;
103 
104  Ogre::ColourValue mColor;
105  Ogre::RenderOperation mRenderOp;
106  Ogre::AxisAlignedBox mAABB;
107  Ogre::LightList mLList;
108 
109  Ogre::Real mCharHeight;
110  Ogre::Real mSpaceWidth;
111 
114  bool mOnTop;
115 
117  Ogre::Real mRadius;
118 
119  Ogre::Vector3 mGlobalTranslation;
120  Ogre::Vector3 mLocalTranslation;
121 
122  Ogre::Camera *mCam;
123  Ogre::RenderWindow *mWin;
124  Ogre::Font *mFont;
125  Ogre::MaterialPtr mMaterial;
126  Ogre::MaterialPtr mBackgroundMaterial;
127 
128  /******************************** public methods ******************************/
129 public:
130 
131  TextObject(const Ogre::String &caption,
132  Ogre::SceneManager* sceneManager,
133  Ogre::SceneNode* parent=NULL);
134 
135  TextObject(const Ogre::String &caption,
136  const Ogre::String &fontName,
137  Ogre::SceneManager* sceneManager,
138  Ogre::SceneNode* parent=NULL);
139 
140  virtual ~TextObject();
141 
142  virtual void visitRenderables(Ogre::Renderable::Visitor* visitor,
143  bool debugRenderables = false);
144 
145  virtual void setColor(const Ogre::ColourValue &color);
146  virtual void setVisible(bool visible, bool cascade = true);
147 
148  // Set settings
149  void setFontName(const Ogre::String &fontName);
150  void setCaption(const Ogre::String &caption);
151  void setCharacterHeight(Ogre::Real height);
152  void setSpaceWidth(Ogre::Real width);
153  void setTextAlignment(const HorizontalAlignment& horizontalAlignment,
154  const VerticalAlignment& verticalAlignment);
155  void setGlobalTranslation(Ogre::Vector3 trans);
156  void setLocalTranslation(Ogre::Vector3 trans);
157  void showOnTop(bool show = true);
158 
159  // Get settings
160  const Ogre::String& getFontName() const
161  {
162  return mFontName;
163  }
164  const Ogre::String& getCaption() const
165  {
166  return mCaption;
167  }
168  const Ogre::ColourValue& getColor() const
169  {
170  return mColor;
171  }
172 
173  Ogre::Real getCharacterHeight() const
174  {
175  return mCharHeight;
176  }
177  Ogre::Real getSpaceWidth() const
178  {
179  return mSpaceWidth;
180  }
181  Ogre::Vector3 getGlobalTranslation() const
182  {
183  return mGlobalTranslation;
184  }
185  Ogre::Vector3 getLocalTranslation() const
186  {
187  return mLocalTranslation;
188  }
189  bool getShowOnTop() const
190  {
191  return mOnTop;
192  }
193  Ogre::AxisAlignedBox GetAABB(void)
194  {
195  return mAABB;
196  }
197 
198  /******************************** protected methods and overload **************/
199 protected:
200 
201  // from TextObject, create the object
202  void _setupGeometry();
203  void _updateColors();
204 
205  // from MovableObject
206  void getWorldTransforms(Ogre::Matrix4 *xform) const;
207  Ogre::Real getBoundingRadius(void) const
208  {
209  return mRadius;
210  }
211 
212  Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
213  {
214  return 0;
215  }
216 
217  const Ogre::Quaternion& getWorldOrientation(void) const;
218  const Ogre::Vector3& getWorldPosition(void) const;
219  const Ogre::AxisAlignedBox& getBoundingBox(void) const
220  {
221  return mAABB;
222  }
223 
224  const Ogre::String& getName(void) const
225  {
226  return mName;
227  }
228 
229  const Ogre::String& getMovableType(void) const
230  {
231  static Ogre::String movType = "TextObject";
232  return movType;
233  }
234 
235  void _notifyCurrentCamera(Ogre::Camera *cam);
236  void _updateRenderQueue(Ogre::RenderQueue* queue);
237 
238  // from renderable
239  void getRenderOperation(Ogre::RenderOperation &op);
240  const Ogre::MaterialPtr& getMaterial(void) const
241  {
242  assert(!mMaterial.isNull());
243  return mMaterial;
244  }
245 
246  const Ogre::LightList& getLights(void) const
247  {
248  return mLList;
249  }
250 
251 };
252 
254 
255 }
256 
257 #endif
HorizontalAlignment mHorizontalAlignment
Definition: TextObject.h:101
Definition: TextObject.h:92
const Ogre::ColourValue & getColor() const
Definition: TextObject.h:168
Ogre::Real mCharHeight
Definition: TextObject.h:109
Ogre::ColourValue mColor
Definition: TextObject.h:104
Ogre::Camera * mCam
Definition: TextObject.h:122
Ogre::Real getBoundingRadius(void) const
Definition: TextObject.h:207
Declaration of VisualizationObject.
const Ogre::String & getMovableType(void) const
Definition: TextObject.h:229
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
const Ogre::String & getCaption() const
Definition: TextObject.h:164
const Ogre::LightList & getLights(void) const
Definition: TextObject.h:246
Definition: VisualizationObject.h:71
Definition: TextObject.h:79
VerticalAlignment mVerticalAlignment
Definition: TextObject.h:102
Ogre::MaterialPtr mMaterial
Definition: TextObject.h:125
bool getShowOnTop() const
Definition: TextObject.h:189
Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
Definition: TextObject.h:212
bool mOnTop
Definition: TextObject.h:114
Ogre::Vector3 getGlobalTranslation() const
Definition: TextObject.h:181
Ogre::AxisAlignedBox mAABB
Definition: TextObject.h:106
const Ogre::AxisAlignedBox & getBoundingBox(void) const
Definition: TextObject.h:219
Ogre::String mCaption
Definition: TextObject.h:100
Ogre::Real mRadius
Definition: TextObject.h:117
Ogre::AxisAlignedBox GetAABB(void)
Definition: TextObject.h:193
#define MIRA_GUI_VISUALIZATION_EXPORT
Definition: GuiVisualizationExports.h:61
const Ogre::String & getName(void) const
Definition: TextObject.h:224
Ogre::Vector3 mGlobalTranslation
Definition: TextObject.h:119
Ogre::Real getCharacterHeight() const
Definition: TextObject.h:173
Ogre::String mName
Definition: TextObject.h:99
Ogre::Vector3 getLocalTranslation() const
Definition: TextObject.h:185
Definition: TextObject.h:91
const Ogre::MaterialPtr & getMaterial(void) const
Definition: TextObject.h:240
Ogre::LightList mLList
Definition: TextObject.h:107
FrameworkVis export macro declaration.
Ogre::String mFontName
Definition: TextObject.h:97
bool mNeedUpdate
Definition: TextObject.h:112
Ogre::RenderOperation mRenderOp
Definition: TextObject.h:105
Definition: ImageObject.h:60
HorizontalAlignment
Definition: TextObject.h:83
bool mUpdateColors
Definition: TextObject.h:113
Ogre::Font * mFont
Definition: TextObject.h:124
Definition: TextObject.h:86
Ogre::MaterialPtr mBackgroundMaterial
Definition: TextObject.h:126
Definition: TextObject.h:85
Ogre::Vector3 mLocalTranslation
Definition: TextObject.h:120
Ogre::Real getSpaceWidth() const
Definition: TextObject.h:177
Ogre::RenderWindow * mWin
Definition: TextObject.h:123
Ogre::Real mTimeUntilNextToggle
Definition: TextObject.h:116
Ogre::String mType
Definition: TextObject.h:98
Ogre::Real mSpaceWidth
Definition: TextObject.h:110
VerticalAlignment
Definition: TextObject.h:89
const Ogre::String & getFontName() const
Definition: TextObject.h:160