Gazebo Rendering

API Reference

3.7.2
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 SetLayer(int32_t _layer) override;
65 
66  // Documentation inherited
67  public: virtual int32_t Layer() const override;
68 
69  // Documentation inherited
70  public: virtual void ClearPoints() override;
71 
72  // Documentation inherited
73  public: virtual void AddPoint(double _x,
74  double _y, double _z,
75  const gz::math::Color &_color) override;
76 
77  // Documentation inherited
78  public: virtual void AddPoint(const gz::math::Vector3d &_pt,
79  const gz::math::Color &_color) override;
80 
81  // Documentation inherited
82  public: virtual void SetPoint(unsigned int _index,
83  const gz::math::Vector3d &_value) override;
84 
87  protected: std::chrono::steady_clock::duration lifetime =
88  std::chrono::steady_clock::duration::zero();
90 
92  protected: int32_t layer = 0;
93 
95  protected: bool markerDirty = false;
96 
98  protected: MarkerType markerType =
100  };
101 
103  // BaseMarker
105  template <class T>
107  {
108  }
109 
111  template <class T>
113  {
114  }
115 
117  template <class T>
119  const std::chrono::steady_clock::duration &_lifetime)
120  {
121  this->lifetime = _lifetime;
122  this->markerDirty = true;
123  }
124 
126  template <class T>
127  std::chrono::steady_clock::duration BaseMarker<T>::Lifetime() const
128  {
129  return this->lifetime;
130  }
131 
133  template <class T>
134  void BaseMarker<T>::SetLayer(int32_t _layer)
135  {
136  this->layer = _layer;
137  this->markerDirty = true;
138  }
139 
141  template <class T>
142  int32_t BaseMarker<T>::Layer() const
143  {
144  return this->layer;
145  }
146 
148  template <class T>
149  void BaseMarker<T>::SetType(const MarkerType _markerType)
150  {
151  this->markerType = _markerType;
152  this->markerDirty = true;
153  }
154 
156  template <class T>
158  {
159  return this->markerType;
160  }
161 
163  template <class T>
165  {
166  T::PreRender();
167  }
168 
170  template <class T>
172  {
173  T::Destroy();
174  }
175 
177  template <class T>
179  {
180  // no op
181  }
182 
184  template <class T>
185  void BaseMarker<T>::AddPoint(const gz::math::Vector3d &,
186  const gz::math::Color &)
187  {
188  // no op
189  }
190 
192  template <class T>
193  void BaseMarker<T>::AddPoint(double _x, double _y, double _z,
194  const gz::math::Color &_color)
195  {
196  this->AddPoint(gz::math::Vector3d(_x, _y, _z), _color);
197  }
198 
200  template <class T>
201  void BaseMarker<T>::SetPoint(unsigned int,
202  const gz::math::Vector3d &)
203  {
204  // no op
205  }
206  }
207  }
208 }
209 #endif
virtual std::chrono::steady_clock::duration Lifetime() const override
Get the lifetime of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:127
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
@ MT_NONE
No type.
Definition: gz/rendering/Marker.hh:38
virtual void ClearPoints() override
Clear the points of the marker, if applicable.
Definition: gz/rendering/base/BaseMarker.hh:178
std::chrono::steady_clock::duration lifetime
Life time of a marker.
Definition: gz/rendering/base/BaseMarker.hh:87
int32_t layer
Layer at which the marker will reside.
Definition: gz/rendering/base/BaseMarker.hh:92
bool markerDirty
Flag to indicate if marker needs to be updated.
Definition: gz/rendering/base/BaseMarker.hh:95
virtual ~BaseMarker()
Destructor.
Definition: gz/rendering/base/BaseMarker.hh:112
virtual MarkerType Type() const override
Get the render type of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:157
virtual void Destroy() override
Destroy function.
Definition: gz/rendering/base/BaseMarker.hh:171
A marker geometry class. The marker's visual appearance is based on the marker type specified.
Definition: gz/rendering/Marker.hh:74
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:193
BaseMarker()
Constructor.
Definition: gz/rendering/base/BaseMarker.hh:106
virtual void SetPoint(unsigned int _index, const gz::math::Vector3d &_value) override
Set an existing point's vector.
Definition: gz/rendering/base/BaseMarker.hh:201
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:134
virtual void PreRender() override
PreRender function.
Definition: gz/rendering/base/BaseMarker.hh:164
virtual void SetLifetime(const std::chrono::steady_clock::duration &_lifetime) override
Set the lifetime of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:118
virtual void SetType(const MarkerType _markerType) override
Set the render type of this Marker.
Definition: gz/rendering/base/BaseMarker.hh:149
#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:142
MarkerType markerType
Marker type.
Definition: gz/rendering/base/BaseMarker.hh:98