Gazebo Rendering

API Reference

7.4.2
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"
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: virtual ~BaseText();
41 
42  // Documentation inherited.
43  public: virtual void PreRender() override;
44 
45  // Documentation inherited.
46  public: virtual 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: virtual void SetTextString(const std::string &_text) override;
56 
57  // Documentation inherited.
58  public: virtual std::string TextString() const override;
59 
60  // Documentation inherited.
61  public: virtual void SetColor(const gz::math::Color &_color)
62  override;
63 
64  // Documentation inherited.
65  public: virtual gz::math::Color Color() const override;
66 
67  // Documentation inherited.
68  public: virtual void SetCharHeight(const float _height) override;
69 
70  // Documentation inherited.
71  public: virtual float CharHeight() const override;
72 
73  // Documentation inherited.
74  public: virtual void SetSpaceWidth(const float _width) override;
75 
76  // Documentation inherited.
77  public: virtual float SpaceWidth() const override;
78 
79  // Documentation inherited.
80  public: virtual void SetTextAlignment(const TextHorizontalAlign &_hAlign,
81  const TextVerticalAlign &_vAlign) override;
82  // Documentation inherited.
83  public: virtual TextHorizontalAlign HorizontalAlignment() const override;
84 
85  // Documentation inherited.
86  public: virtual TextVerticalAlign VerticalAlignment() const override;
87 
88  // Documentation inherited.
89  public: virtual void SetBaseline(const float _baseline) override;
90 
91  // Documentation inherited.
92  public: virtual float Baseline() const override;
93 
94  // Documentation inherited.
95  public: void SetShowOnTop(const bool _onTop) override;
96 
97  // Documentation inherited.
98  public: virtual bool ShowOnTop() const override;
99 
100  // Documentation inherited.
101  public: virtual gz::math::AxisAlignedBox AABB() const override;
102 
104  protected: std::string fontName = "Liberation Sans";
105 
107  protected: std::string text;
108 
111 
113  protected: float charHeight = 1.0;
114 
116  protected: float spaceWidth = 0;
117 
119  protected: TextHorizontalAlign horizontalAlign =
121 
123  protected: TextVerticalAlign verticalAlign = TextVerticalAlign::BOTTOM;
124 
126  protected: float baseline = 0;
127 
130  protected: bool onTop = false;
131 
133  protected: bool textDirty = false;
134  };
135 
137  // BaseText
139  template <class T>
141  {
142  }
143 
145  template <class T>
147  {
148  }
149 
151  template <class T>
153  {
154  return this->fontName;
155  }
156 
158  template <class T>
160  {
161  this->fontName = _font;
162  this->textDirty = true;
163  }
164 
166  template <class T>
168  {
169  return this->text;
170  }
171 
173  template <class T>
175  {
176  this->text = _text;
177  this->textDirty = true;
178  }
179 
181  template <class T>
183  {
184  return this->color;
185  }
186 
188  template <class T>
190  {
191  this->color = _color;
192  this->textDirty = true;
193  }
194 
196  template <class T>
198  {
199  return this->charHeight;
200  }
201 
203  template <class T>
204  void BaseText<T>::SetCharHeight(const float _height)
205  {
206  this->charHeight = _height;
207  this->textDirty = true;
208  }
209 
211  template <class T>
213  {
214  return this->spaceWidth;
215  }
216 
218  template <class T>
219  void BaseText<T>::SetSpaceWidth(const float _width)
220  {
221  this->spaceWidth = _width;
222  this->textDirty = true;
223  }
224 
226  template <class T>
228  {
229  return this->horizontalAlign;
230  }
231 
233  template <class T>
235  {
236  return this->verticalAlign;
237  }
238 
240  template <class T>
242  const TextVerticalAlign &_vertAlign)
243  {
244  this->horizontalAlign = _horzAlign;
245  this->verticalAlign = _vertAlign;
246  this->textDirty = true;
247  }
248 
250  template <class T>
251  float BaseText<T>::Baseline() const
252  {
253  return this->baseline;
254  }
255 
257  template <class T>
258  void BaseText<T>::SetBaseline(const float _baseline)
259  {
260  this->baseline = _baseline;
261  this->textDirty = true;
262  }
263 
265  template <class T>
267  {
268  return this->onTop;
269  }
270 
272  template <class T>
273  void BaseText<T>::SetShowOnTop(const bool _onTop)
274  {
275  this->onTop = _onTop;
276  this->textDirty = true;
277  }
278 
280  template <class T>
282  {
284  return box;
285  }
286 
288  template <class T>
290  {
291  T::PreRender();
292  }
293 
295  template <class T>
297  {
298  T::Destroy();
299  }
300  }
301  }
302 }
303 #endif