Gazebo Rendering
API Reference
9.5.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-rendering
include
gz
rendering
base
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
"
22
#include "
gz/rendering/base/BaseObject.hh
"
23
24
namespace
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
111
protected
:
gz::math::Color
color =
gz::math::Color::White
;
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>
141
BaseText<T>::BaseText
()
142
{
143
}
144
146
template
<
class
T>
147
BaseText<T>::~BaseText
()
148
{
149
}
150
152
template
<
class
T>
153
std::string
BaseText<T>::FontName
()
const
154
{
155
return
this->fontName;
156
}
157
159
template
<
class
T>
160
void
BaseText<T>::SetFontName
(
const
std::string
&_font)
161
{
162
this->fontName = _font;
163
this->textDirty =
true
;
164
}
165
167
template
<
class
T>
168
std::string
BaseText<T>::TextString
()
const
169
{
170
return
this->text;
171
}
172
174
template
<
class
T>
175
void
BaseText<T>::SetTextString
(
const
std::string
&_text)
176
{
177
this->text = _text;
178
this->textDirty =
true
;
179
}
180
182
template
<
class
T>
183
gz::math::Color
BaseText<T>::Color
()
const
184
{
185
return
this->color;
186
}
187
189
template
<
class
T>
190
void
BaseText<T>::SetColor
(
const
gz::math::Color
&_color)
191
{
192
this->color = _color;
193
this->textDirty =
true
;
194
}
195
197
template
<
class
T>
198
float
BaseText<T>::CharHeight
()
const
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>
213
float
BaseText<T>::SpaceWidth
()
const
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>
228
TextHorizontalAlign
BaseText<T>::HorizontalAlignment
()
const
229
{
230
return
this->horizontalAlign;
231
}
232
234
template
<
class
T>
235
TextVerticalAlign
BaseText<T>::VerticalAlignment
()
const
236
{
237
return
this->verticalAlign;
238
}
239
241
template
<
class
T>
242
void
BaseText<T>::SetTextAlignment
(
const
TextHorizontalAlign
&_hAlign,
243
const
TextVerticalAlign
&_vAlign)
244
{
245
this->horizontalAlign = _hAlign;
246
this->verticalAlign = _vAlign;
247
this->textDirty =
true
;
248
}
249
251
template
<
class
T>
252
float
BaseText<T>::Baseline
()
const
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>
267
bool
BaseText<T>::ShowOnTop
()
const
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>
282
gz::math::AxisAlignedBox
BaseText<T>::AABB
()
const
283
{
284
math::AxisAlignedBox
box;
285
return
box;
286
}
287
289
template
<
class
T>
290
void
BaseText<T>::PreRender
()
291
{
292
T::PreRender();
293
}
294
296
template
<
class
T>
297
void
BaseText<T>::Destroy
()
298
{
299
T::Destroy();
300
}
301
}
302
}
303
}
304
#endif