MovableText.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef GAZEBO_RENDERING_MOVABLETEXT_HH_
18#define GAZEBO_RENDERING_MOVABLETEXT_HH_
19
20#include <memory>
21#include <string>
22
23#include <ignition/math/Box.hh>
24#include <ignition/math/Color.hh>
25
26// TODO: remove this line
28
29#include "gazebo/util/system.hh"
30
31namespace gazebo
32{
33 namespace rendering
34 {
35 class MovableTextPrivate;
36
39
42 class GZ_RENDERING_VISIBLE MovableText
43 : public Ogre::MovableObject, public Ogre::Renderable
44 {
47 public: enum HorizAlign {
51 H_CENTER
52 };
53
56 public: enum VertAlign {
60 V_ABOVE
61 };
62
64 public: MovableText();
65
67 public: virtual ~MovableText();
68
75 public: void Load(const std::string &_name,
76 const std::string &_text,
77 const std::string &_fontName = "Arial",
78 float _charHeight = 1.0,
79 const ignition::math::Color &_color =
80 ignition::math::Color::White);
81
86 public: void SetFontName(const std::string &_font);
87
91 public: const std::string &FontName() const;
92
96 public: void SetText(const std::string &_text);
97
101 public: const std::string &Text() const;
102
106 public: void SetColor(const ignition::math::Color &_color);
107
111 public: const ignition::math::Color &Color() const;
112
116 public: void SetCharHeight(const float _height);
117
121 public: float CharHeight() const;
122
126 public: void SetSpaceWidth(const float _width);
127
131 public: float SpaceWidth() const;
132
136 public: void SetTextAlignment(const HorizAlign &_hAlign,
137 const VertAlign &_vAlign);
138
142 public: void SetBaseline(const float _height);
143
147 public: float Baseline() const;
148
153 public: void SetShowOnTop(const bool _show);
154
158 public: bool ShowOnTop() const;
159
162 public: ignition::math::Box AABB();
163
165 public: void Update();
166
172 public: virtual void visitRenderables(Ogre::Renderable::Visitor *_visitor,
173 bool _debug = false) override;
174
176 protected: void SetupGeometry();
177
179 protected: void UpdateColors();
180
183 protected: void getWorldTransforms(Ogre::Matrix4 *_xform) const override;
184
187 protected: float getBoundingRadius() const override;
188
191 protected: float getSquaredViewDepth(const Ogre::Camera *_cam) const
192 override;
193
196 protected: void getRenderOperation(Ogre::RenderOperation &_op) override;
197
200 protected: const Ogre::MaterialPtr &getMaterial() const override;
201
204 protected: const Ogre::LightList &getLights() const override;
205
207 private: const Ogre::AxisAlignedBox &getBoundingBox() const override;
208
210 private: const Ogre::String &getMovableType() const override;
211
213 private: void _notifyCurrentCamera(Ogre::Camera *_cam) override;
214
216 private: void _updateRenderQueue(Ogre::RenderQueue *_queue) override;
217
220 private: std::unique_ptr<MovableTextPrivate> dataPtr;
221 };
223 }
224}
225#endif
rendering
Definition RenderEngine.hh:31
Movable text.
Definition MovableText.hh:44
void SetupGeometry()
Setup the geometry.
void Load(const std::string &_name, const std::string &_text, const std::string &_fontName="Arial", float _charHeight=1.0, const ignition::math::Color &_color=ignition::math::Color::White)
Loads text and font info.
void SetTextAlignment(const HorizAlign &_hAlign, const VertAlign &_vAlign)
Set the alignment of the text.
const std::string & FontName() const
Get the font name.
void SetCharHeight(const float _height)
Set the height of the character in meters.
void UpdateColors()
Update colors.
float CharHeight() const
Get the height of the characters in meters return Height of the characters.
void SetBaseline(const float _height)
Set the baseline height of the text.
float getSquaredViewDepth(const Ogre::Camera *_cam) const override
const ignition::math::Color & Color() const
Get the text color.
void getRenderOperation(Ogre::RenderOperation &_op) override
const std::string & Text() const
Get the displayed text.
const Ogre::MaterialPtr & getMaterial() const override
float SpaceWidth() const
Get the width of spaces between words.
void getWorldTransforms(Ogre::Matrix4 *_xform) const override
void SetText(const std::string &_text)
Set the text to display.
void SetColor(const ignition::math::Color &_color)
Set the text color.
virtual ~MovableText()
Destructor.
HorizAlign
Horizontal alignment.
Definition MovableText.hh:47
@ H_CENTER
Center alignment.
Definition MovableText.hh:51
@ H_LEFT
Left alignment.
Definition MovableText.hh:49
ignition::math::Box AABB()
Get the axis aligned bounding box of the text.
void SetShowOnTop(const bool _show)
True = text always is displayed ontop.
void SetFontName(const std::string &_font)
Set the font.
bool ShowOnTop() const
Get whether the is displayed above other objects.
VertAlign
vertical alignment
Definition MovableText.hh:56
@ V_BELOW
Align below.
Definition MovableText.hh:58
@ V_ABOVE
Align above.
Definition MovableText.hh:60
float getBoundingRadius() const override
float Baseline() const
Get the baseline height in meters.
const Ogre::LightList & getLights() const override
virtual void visitRenderables(Ogre::Renderable::Visitor *_visitor, bool _debug=false) override
void SetSpaceWidth(const float _width)
Set the width of spaces between words.
void Update()
Update the text.
Forward declarations for the common classes.
Definition Animation.hh:27