Gazebo Rendering

API Reference

6.6.3
gz/rendering/base/BaseMarker.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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_BASEMARKER_HH_
18 #define GZ_RENDERING_BASEMARKER_HH_
19 
20 #include <gz/common/SuppressWarning.hh>
21 
22 #include "gz/rendering/Marker.hh"
25 
26 namespace ignition
27 {
28  namespace rendering
29  {
30  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
32  template <class T>
33  class BaseMarker :
34  public virtual Marker,
35  public virtual T
36  {
38  protected: BaseMarker();
39 
41  public: virtual ~BaseMarker();
42 
44  public: virtual void PreRender() override;
45 
47  public: virtual void Destroy() override;
48 
49  // Documentation inherited
50  public: virtual void SetLifetime(const
51  std::chrono::steady_clock::duration &_lifetime) override;
52 
53  // Documentation inherited
54  public: virtual std::chrono::steady_clock::duration Lifetime()
55  const override;
56 
57  // Documentation inherited
58  public: virtual void SetType(const MarkerType _markerType) override;
59 
60  // Documentation inherited
61  public: virtual MarkerType Type() const override;
62 
63  // Documentation inherited
64  public: virtual void SetSize(double _size) override;
65 
66  // Documentation inherited
67  public: virtual double Size() const override;
68 
69  // Documentation inherited
70  public: virtual void SetLayer(int32_t _layer) override;
71 
72  // Documentation inherited
73  public: virtual int32_t Layer() const override;
74 
75  // Documentation inherited
76  public: virtual void ClearPoints() override;
77 
78  // Documentation inherited
79  public: virtual void AddPoint(double _x,
80  double _y, double _z,
81  const gz::math::Color &_color) override;
82 
83  // Documentation inherited
84  public: virtual void AddPoint(const gz::math::Vector3d &_pt,
85  const gz::math::Color &_color) override;
86 
87  // Documentation inherited
88  public: virtual void SetPoint(unsigned int _index,
89  const gz::math::Vector3d &_value) override;
90 
93  protected: std::chrono::steady_clock::duration lifetime =
94  std::chrono::steady_clock::duration::zero();
96 
98  protected: int32_t layer = 0;
99 
101  protected: bool markerDirty = false;
102 
104  protected: MarkerType markerType =
106 
108  protected: double size = 1.0;
109  };
110 
112  // BaseMarker
114  template <class T>
116  {
117  }
118 
120  template <class T>
122  {
123  }
124 
126  template <class T>
128  const std::chrono::steady_clock::duration &_lifetime)
129  {
130  this->lifetime = _lifetime;
131  this->markerDirty = true;
132  }
133 
135  template <class T>
136  std::chrono::steady_clock::duration BaseMarker<T>::Lifetime() const
137  {
138  return this->lifetime;
139  }
140 
142  template <class T>
143  void BaseMarker<T>::SetLayer(int32_t _layer)
144  {
145  this->layer = _layer;
146  this->markerDirty = true;
147  }
148 
150  template <class T>
151  int32_t BaseMarker<T>::Layer() const
152  {
153  return this->layer;
154  }
155 
157  template <class T>
158  void BaseMarker<T>::SetType(const MarkerType _markerType)
159  {
160  this->markerType = _markerType;
161  this->markerDirty = true;
162  }
163 
165  template <class T>
167  {
168  return this->markerType;
169  }
170 
172  template <class T>
173  void BaseMarker<T>::SetSize(double _size)
174  {
175  this->size = _size;
176  this->markerDirty = true;
177  }
178 
180  template <class T>
181  double BaseMarker<T>::Size() const
182  {
183  return this->size;
184  }
185 
187  template <class T>
189  {
190  T::PreRender();
191  }
192 
194  template <class T>
196  {
197  T::Destroy();
198  }
199 
201  template <class T>
203  {
204  // no op
205  }
206 
208  template <class T>
209  void BaseMarker<T>::AddPoint(const gz::math::Vector3d &,
210  const gz::math::Color &)
211  {
212  // no op
213  }
214 
216  template <class T>
217  void BaseMarker<T>::AddPoint(double _x, double _y, double _z,
218  const gz::math::Color &_color)
219  {
220  this->AddPoint(gz::math::Vector3d(_x, _y, _z), _color);
221  }
222 
224  template <class T>
225  void BaseMarker<T>::SetPoint(unsigned int,
226  const gz::math::Vector3d &)
227  {
228  // no op
229  }
230  }
231  }
232 }
233 #endif
virtual std::chrono::steady_clock::duration Lifetime() const override
Get the lifetime of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:136
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
@ MT_NONE
No type.
Definition: gz/rendering/Marker.hh:38
virtual void SetSize(double _size) override
Set size of the marker. Only affects MT_POINTS. e.g. size of rasterized points in pixels.
Definition: gz/rendering/base/BaseMarker.hh:173
virtual void ClearPoints() override
Clear the points of the marker, if applicable.
Definition: gz/rendering/base/BaseMarker.hh:202
std::chrono::steady_clock::duration lifetime
Life time of a marker.
Definition: gz/rendering/base/BaseMarker.hh:93
int32_t layer
Layer at which the marker will reside.
Definition: gz/rendering/base/BaseMarker.hh:98
bool markerDirty
Flag to indicate if marker needs to be updated.
Definition: gz/rendering/base/BaseMarker.hh:101
virtual ~BaseMarker()
Destructor.
Definition: gz/rendering/base/BaseMarker.hh:121
double size
Marker size.
Definition: gz/rendering/base/BaseMarker.hh:108
virtual double Size() const override
Get the size of the marker.
Definition: gz/rendering/base/BaseMarker.hh:181
virtual MarkerType Type() const override
Get the render type of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:166
virtual void Destroy() override
Destroy function.
Definition: gz/rendering/base/BaseMarker.hh:195
A marker geometry class. The marker's visual appearance is based on the marker type specified.
Definition: gz/rendering/Marker.hh:77
virtual void AddPoint(double _x, double _y, double _z, const gz::math::Color &_color) override
Add a point with its respective color to the marker.
Definition: gz/rendering/base/BaseMarker.hh:217
BaseMarker()
Constructor.
Definition: gz/rendering/base/BaseMarker.hh:115
virtual void SetPoint(unsigned int _index, const gz::math::Vector3d &_value) override
Set an existing point's vector.
Definition: gz/rendering/base/BaseMarker.hh:225
Base implementation of a Marker geometry.
Definition: gz/rendering/base/BaseMarker.hh:33
MarkerType
Enum for marker types.
Definition: gz/rendering/Marker.hh:35
virtual void SetLayer(int32_t _layer) override
Set the layer of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:143
virtual void PreRender() override
PreRender function.
Definition: gz/rendering/base/BaseMarker.hh:188
virtual void SetLifetime(const std::chrono::steady_clock::duration &_lifetime) override
Set the lifetime of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:127
virtual void SetType(const MarkerType _markerType) override
Set the render type of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:158
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
virtual int32_t Layer() const override
Get the layer of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:151
MarkerType markerType
Marker type.
Definition: gz/rendering/base/BaseMarker.hh:104