Gazebo Rendering

API Reference

9.5.0
BaseText.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 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 GZ_RENDERING_BASE_BASETEXT_HH_
18#define GZ_RENDERING_BASE_BASETEXT_HH_
19
20#include <string>
21#include "gz/rendering/Text.hh"
23
24namespace gz
25{
26 namespace rendering
27 {
28 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
29 //
31 template <class T>
32 class BaseText :
33 public virtual Text,
34 public virtual T
35 {
37 protected: BaseText();
38
40 public: ~BaseText() override;
41
42 // Documentation inherited.
43 public: void PreRender() override;
44
45 // Documentation inherited.
46 public: void Destroy() override;
47
48 // Documentation inherited.
49 public: void SetFontName(const std::string &_font) override;
50
51 // Documentation inherited.
52 public: std::string FontName() const override;
53
54 // Documentation inherited.
55 public: void SetTextString(const std::string &_text) override;
56
57 // Documentation inherited.
58 public: std::string TextString() const override;
59
60 // Documentation inherited.
61 public: void SetColor(const gz::math::Color &_color) override;
62
63 // Documentation inherited.
64 public: gz::math::Color Color() const override;
65
66 // Documentation inherited.
67 public: void SetCharHeight(const float _height) override;
68
69 // Documentation inherited.
70 public: float CharHeight() const override;
71
72 // Documentation inherited.
73 public: void SetSpaceWidth(const float _width) override;
74
75 // Documentation inherited.
76 public: float SpaceWidth() const override;
77
78 // Documentation inherited.
79 public: void SetTextAlignment(
80 const TextHorizontalAlign &_hAlign,
81 const TextVerticalAlign &_vAlign) override;
82
83 // Documentation inherited.
84 public: TextHorizontalAlign HorizontalAlignment() const override;
85
86 // Documentation inherited.
87 public: TextVerticalAlign VerticalAlignment() const override;
88
89 // Documentation inherited.
90 public: void SetBaseline(const float _baseline) override;
91
92 // Documentation inherited.
93 public: float Baseline() const override;
94
95 // Documentation inherited.
96 public: void SetShowOnTop(const bool _onTop) override;
97
98 // Documentation inherited.
99 public: bool ShowOnTop() const override;
100
101 // Documentation inherited.
102 public: gz::math::AxisAlignedBox AABB() const override;
103
105 protected: std::string fontName = "Liberation Sans";
106
108 protected: std::string text;
109
112
114 protected: float charHeight = 1.0;
115
117 protected: float spaceWidth = 0;
118
120 protected: TextHorizontalAlign horizontalAlign =
121 TextHorizontalAlign::LEFT;
122
124 protected: TextVerticalAlign verticalAlign = TextVerticalAlign::BOTTOM;
125
127 protected: float baseline = 0;
128
131 protected: bool onTop = false;
132
134 protected: bool textDirty = false;
135 };
136
138 // BaseText
140 template <class T>
144
146 template <class T>
150
152 template <class T>
154 {
155 return this->fontName;
156 }
157
159 template <class T>
161 {
162 this->fontName = _font;
163 this->textDirty = true;
164 }
165
167 template <class T>
169 {
170 return this->text;
171 }
172
174 template <class T>
176 {
177 this->text = _text;
178 this->textDirty = true;
179 }
180
182 template <class T>
184 {
185 return this->color;
186 }
187
189 template <class T>
191 {
192 this->color = _color;
193 this->textDirty = true;
194 }
195
197 template <class T>
199 {
200 return this->charHeight;
201 }
202
204 template <class T>
205 void BaseText<T>::SetCharHeight(const float _height)
206 {
207 this->charHeight = _height;
208 this->textDirty = true;
209 }
210
212 template <class T>
214 {
215 return this->spaceWidth;
216 }
217
219 template <class T>
220 void BaseText<T>::SetSpaceWidth(const float _width)
221 {
222 this->spaceWidth = _width;
223 this->textDirty = true;
224 }
225
227 template <class T>
229 {
230 return this->horizontalAlign;
231 }
232
234 template <class T>
236 {
237 return this->verticalAlign;
238 }
239
241 template <class T>
243 const TextVerticalAlign &_vAlign)
244 {
245 this->horizontalAlign = _hAlign;
246 this->verticalAlign = _vAlign;
247 this->textDirty = true;
248 }
249
251 template <class T>
253 {
254 return this->baseline;
255 }
256
258 template <class T>
259 void BaseText<T>::SetBaseline(const float _baseline)
260 {
261 this->baseline = _baseline;
262 this->textDirty = true;
263 }
264
266 template <class T>
268 {
269 return this->onTop;
270 }
271
273 template <class T>
274 void BaseText<T>::SetShowOnTop(const bool _onTop)
275 {
276 this->onTop = _onTop;
277 this->textDirty = true;
278 }
279
281 template <class T>
283 {
285 return box;
286 }
287
289 template <class T>
291 {
292 T::PreRender();
293 }
294
296 template <class T>
298 {
299 T::Destroy();
300 }
301 }
302 }
303}
304#endif