movable_text.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 // Adapted from: http://www.ogre3d.org/wiki/index.php/MovableText
31 // now: http://www.ogre3d.org/tikiwiki/tiki-index.php?page=MovableText
32 // Original authors:
33 /*
34  * File: MovableText.h
35  *
36  * description: This create create a billboarding object that display a text.
37  *
38  * @author 2003 by cTh see gavocanov@rambler.ru
39  * @update 2006 by barraq see nospam@barraquand.com
40  */
41 
42 #ifndef OGRE_TOOLS_MOVABLE_TEXT_H
43 #define OGRE_TOOLS_MOVABLE_TEXT_H
44 
46 #include <OgrePrerequisites.h>
47 #include <OgreMovableObject.h>
48 #include <OgreRenderable.h>
49 
50 namespace Ogre
51 {
52 class RenderQueue;
53 class Camera;
54 class Font;
55 } // namespace Ogre
56 
57 namespace rviz
58 {
59 class MovableText : public Ogre::MovableObject, public Ogre::Renderable
60 {
61  /******************************** MovableText data ****************************/
62 public:
64  {
67  };
69  {
73  };
74 
75 protected:
76  Ogre::String mFontName;
77  Ogre::String mType;
78  Ogre::String mName;
79  Ogre::String mCaption;
82 
83  Ogre::ColourValue mColor;
84  Ogre::RenderOperation mRenderOp;
85  Ogre::AxisAlignedBox mAABB;
86  Ogre::AxisAlignedBox mCamFacingAABB;
87  Ogre::LightList mLList;
88 
89  Ogre::Real mCharHeight;
90  Ogre::Real mLineSpacing;
91  Ogre::Real mSpaceWidth;
92 
95  bool mOnTop;
96 
98  Ogre::Real mRadius;
99 
100  Ogre::Vector3 mGlobalTranslation;
101  Ogre::Vector3 mLocalTranslation;
102 
103  Ogre::Camera* mpCam;
104  Ogre::RenderWindow* mpWin;
105  Ogre::Font* mpFont;
106  Ogre::MaterialPtr mpMaterial;
107  Ogre::MaterialPtr mpBackgroundMaterial;
108 
109  /******************************** public methods ******************************/
110 public:
111  MovableText(const Ogre::String& caption,
112  const Ogre::String& fontName = "Liberation Sans",
113  Ogre::Real charHeight = 1.0,
114  const Ogre::ColourValue& color = Ogre::ColourValue::White);
115  ~MovableText() override;
116 
117  void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false) override;
118 
119  // Set settings
120  void setFontName(const Ogre::String& fontName);
121  void setCaption(const Ogre::String& caption);
122  void setColor(const Ogre::ColourValue& color);
123  void setCharacterHeight(Ogre::Real height);
124  void setLineSpacing(Ogre::Real height);
125  void setSpaceWidth(Ogre::Real width);
126  void setTextAlignment(const HorizontalAlignment& horizontalAlignment,
127  const VerticalAlignment& verticalAlignment);
128  void setGlobalTranslation(Ogre::Vector3 trans);
129  void setLocalTranslation(Ogre::Vector3 trans);
130  void showOnTop(bool show = true);
131 
132  // Get settings
133  const Ogre::String& getFontName() const
134  {
135  return mFontName;
136  }
137  const Ogre::String& getCaption() const
138  {
139  return mCaption;
140  }
141  const Ogre::ColourValue& getColor() const
142  {
143  return mColor;
144  }
145 
146  Ogre::Real getCharacterHeight() const
147  {
148  return mCharHeight;
149  }
150  Ogre::Real getSpaceWidth() const
151  {
152  return mSpaceWidth;
153  }
154  Ogre::Vector3 getGlobalTranslation() const
155  {
156  return mGlobalTranslation;
157  }
158  Ogre::Vector3 getLocalTranslation() const
159  {
160  return mLocalTranslation;
161  }
162  bool getShowOnTop() const
163  {
164  return mOnTop;
165  }
166  Ogre::AxisAlignedBox GetAABB()
167  {
168  return mAABB;
169  }
170 
171  const Ogre::MaterialPtr& getMaterial() const override
172  {
173  assert(!mpMaterial.isNull());
174  return mpMaterial;
175  }
176 
177 
178  /******************************** protected methods and overload **************/
179 protected:
180  // from MovableText, create the object
181  void _setupGeometry();
182  void _updateColors();
183 
184  // from Ogre::MovableObject
185  void getWorldTransforms(Ogre::Matrix4* xform) const override;
186  Ogre::Real getBoundingRadius() const override
187  {
188  return mRadius;
189  }
190 
191  Ogre::Real getSquaredViewDepth(const Ogre::Camera* /*cam*/) const override
192  {
193  return 0;
194  }
195 
196  const Ogre::Quaternion& getWorldOrientation() const;
197  const Ogre::Vector3& getWorldPosition() const;
198  const Ogre::AxisAlignedBox& getBoundingBox() const override
199  {
200  return mCamFacingAABB;
201  }
202 
203 #if OGRE_VERSION >= OGRE_VERSION_CHECK(1, 10, 4)
204  const Ogre::String& getName() const
205 #else
206  const Ogre::String& getName() const override
207 #endif
208  {
209  return mName;
210  }
211 
212  const Ogre::String& getMovableType() const override
213  {
214  static Ogre::String movType = "MovableText";
215  return movType;
216  }
217 
218  void _notifyCurrentCamera(Ogre::Camera* cam) override;
219  void _updateRenderQueue(Ogre::RenderQueue* queue) override;
220 
221  // from renderable
222  void getRenderOperation(Ogre::RenderOperation& op) override;
223  const Ogre::LightList& getLights() const override
224  {
225  return mLList;
226  }
227 };
228 
229 } // namespace rviz
230 
231 #endif
rviz::MovableText::V_CENTER
@ V_CENTER
Definition: movable_text.h:72
rviz::MovableText::setTextAlignment
void setTextAlignment(const HorizontalAlignment &horizontalAlignment, const VerticalAlignment &verticalAlignment)
Definition: movable_text.cpp:182
rviz::MovableText::_updateColors
void _updateColors()
Definition: movable_text.cpp:467
rviz::MovableText::getSpaceWidth
Ogre::Real getSpaceWidth() const
Definition: movable_text.h:150
rviz::MovableText::mpFont
Ogre::Font * mpFont
Definition: movable_text.h:105
rviz::MovableText::mLineSpacing
Ogre::Real mLineSpacing
Definition: movable_text.h:90
Ogre
Definition: axes_display.h:35
rviz::MovableText::setFontName
void setFontName(const Ogre::String &fontName)
Definition: movable_text.cpp:106
rviz::MovableText::mSpaceWidth
Ogre::Real mSpaceWidth
Definition: movable_text.h:91
rviz::MovableText::getRenderOperation
void getRenderOperation(Ogre::RenderOperation &op) override
Definition: movable_text.cpp:526
rviz::MovableText::getColor
const Ogre::ColourValue & getColor() const
Definition: movable_text.h:141
rviz::MovableText::mNeedUpdate
bool mNeedUpdate
Definition: movable_text.h:93
version_check.h
rviz::MovableText::getName
const Ogre::String & getName() const
Definition: movable_text.h:204
rviz::MovableText::setCaption
void setCaption(const Ogre::String &caption)
Definition: movable_text.cpp:137
rviz::MovableText::getLights
const Ogre::LightList & getLights() const override
Definition: movable_text.h:223
rviz::MovableText::~MovableText
~MovableText() override
Definition: movable_text.cpp:99
rviz::MovableText::setCharacterHeight
void setCharacterHeight(Ogre::Real height)
Definition: movable_text.cpp:155
rviz::MovableText
Definition: movable_text.h:59
rviz::MovableText::getWorldTransforms
void getWorldTransforms(Ogre::Matrix4 *xform) const override
Definition: movable_text.cpp:502
rviz::MovableText::mLocalTranslation
Ogre::Vector3 mLocalTranslation
Definition: movable_text.h:101
rviz::MovableText::showOnTop
void showOnTop(bool show=true)
Definition: movable_text.cpp:207
rviz::MovableText::V_BELOW
@ V_BELOW
Definition: movable_text.h:70
rviz::MovableText::getMovableType
const Ogre::String & getMovableType() const override
Definition: movable_text.h:212
rviz::MovableText::H_CENTER
@ H_CENTER
Definition: movable_text.h:66
rviz::MovableText::MovableText
MovableText(const Ogre::String &caption, const Ogre::String &fontName="Liberation Sans", Ogre::Real charHeight=1.0, const Ogre::ColourValue &color=Ogre::ColourValue::White)
Definition: movable_text.cpp:67
rviz::MovableText::getGlobalTranslation
Ogre::Vector3 getGlobalTranslation() const
Definition: movable_text.h:154
rviz::MovableText::getWorldOrientation
const Ogre::Quaternion & getWorldOrientation() const
Definition: movable_text.cpp:485
rviz::MovableText::mType
Ogre::String mType
Definition: movable_text.h:77
rviz::MovableText::_updateRenderQueue
void _updateRenderQueue(Ogre::RenderQueue *queue) override
Definition: movable_text.cpp:555
rviz::MovableText::setLineSpacing
void setLineSpacing(Ogre::Real height)
Definition: movable_text.cpp:164
rviz::MovableText::getSquaredViewDepth
Ogre::Real getSquaredViewDepth(const Ogre::Camera *) const override
Definition: movable_text.h:191
rviz::MovableText::getLocalTranslation
Ogre::Vector3 getLocalTranslation() const
Definition: movable_text.h:158
rviz::MovableText::mRenderOp
Ogre::RenderOperation mRenderOp
Definition: movable_text.h:84
rviz::MovableText::mName
Ogre::String mName
Definition: movable_text.h:78
rviz::MovableText::mpWin
Ogre::RenderWindow * mpWin
Definition: movable_text.h:104
rviz
Definition: add_display_dialog.cpp:54
rviz::MovableText::mCamFacingAABB
Ogre::AxisAlignedBox mCamFacingAABB
Definition: movable_text.h:86
rviz::MovableText::getMaterial
const Ogre::MaterialPtr & getMaterial() const override
Definition: movable_text.h:171
rviz::MovableText::getShowOnTop
bool getShowOnTop() const
Definition: movable_text.h:162
rviz::MovableText::mTimeUntilNextToggle
Ogre::Real mTimeUntilNextToggle
Definition: movable_text.h:97
rviz::MovableText::mColor
Ogre::ColourValue mColor
Definition: movable_text.h:83
rviz::MovableText::_setupGeometry
void _setupGeometry()
Definition: movable_text.cpp:218
rviz::MovableText::setGlobalTranslation
void setGlobalTranslation(Ogre::Vector3 trans)
Definition: movable_text.cpp:197
rviz::MovableText::_notifyCurrentCamera
void _notifyCurrentCamera(Ogre::Camera *cam) override
Definition: movable_text.cpp:538
rviz::MovableText::getBoundingRadius
Ogre::Real getBoundingRadius() const override
Definition: movable_text.h:186
rviz::MovableText::mHorizontalAlignment
HorizontalAlignment mHorizontalAlignment
Definition: movable_text.h:80
rviz::MovableText::mLList
Ogre::LightList mLList
Definition: movable_text.h:87
rviz::MovableText::mAABB
Ogre::AxisAlignedBox mAABB
Definition: movable_text.h:85
rviz::MovableText::visitRenderables
void visitRenderables(Ogre::Renderable::Visitor *visitor, bool debugRenderables=false) override
Definition: movable_text.cpp:491
rviz::MovableText::getCharacterHeight
Ogre::Real getCharacterHeight() const
Definition: movable_text.h:146
rviz::MovableText::mRadius
Ogre::Real mRadius
Definition: movable_text.h:98
rviz::MovableText::mOnTop
bool mOnTop
Definition: movable_text.h:95
rviz::MovableText::mCharHeight
Ogre::Real mCharHeight
Definition: movable_text.h:89
rviz::MovableText::GetAABB
Ogre::AxisAlignedBox GetAABB()
Definition: movable_text.h:166
rviz::MovableText::VerticalAlignment
VerticalAlignment
Definition: movable_text.h:68
rviz::MovableText::getCaption
const Ogre::String & getCaption() const
Definition: movable_text.h:137
rviz::MovableText::setLocalTranslation
void setLocalTranslation(Ogre::Vector3 trans)
Definition: movable_text.cpp:202
rviz::MovableText::mpBackgroundMaterial
Ogre::MaterialPtr mpBackgroundMaterial
Definition: movable_text.h:107
rviz::MovableText::mpCam
Ogre::Camera * mpCam
Definition: movable_text.h:103
rviz::MovableText::mFontName
Ogre::String mFontName
Definition: movable_text.h:76
rviz::MovableText::getFontName
const Ogre::String & getFontName() const
Definition: movable_text.h:133
rviz::MovableText::getBoundingBox
const Ogre::AxisAlignedBox & getBoundingBox() const override
Definition: movable_text.h:198
rviz::MovableText::setSpaceWidth
void setSpaceWidth(Ogre::Real width)
Definition: movable_text.cpp:173
rviz::MovableText::mpMaterial
Ogre::MaterialPtr mpMaterial
Definition: movable_text.h:106
rviz::MovableText::HorizontalAlignment
HorizontalAlignment
Definition: movable_text.h:63
rviz::MovableText::setColor
void setColor(const Ogre::ColourValue &color)
Definition: movable_text.cpp:146
rviz::MovableText::mVerticalAlignment
VerticalAlignment mVerticalAlignment
Definition: movable_text.h:81
rviz::MovableText::H_LEFT
@ H_LEFT
Definition: movable_text.h:65
rviz::MovableText::mUpdateColors
bool mUpdateColors
Definition: movable_text.h:94
rviz::MovableText::V_ABOVE
@ V_ABOVE
Definition: movable_text.h:71
rviz::MovableText::mGlobalTranslation
Ogre::Vector3 mGlobalTranslation
Definition: movable_text.h:100
rviz::MovableText::mCaption
Ogre::String mCaption
Definition: movable_text.h:79
rviz::MovableText::getWorldPosition
const Ogre::Vector3 & getWorldPosition() const
Definition: movable_text.cpp:496


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:09