Rerun C++ SDK
Loading...
Searching...
No Matches
ellipses2d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/build/re_type_definitions/rerun/archetypes/ellipses2d.def.rs".
3
4#pragma once
5
6#include "../archetype_utils.hpp"
7#include "../collection.hpp"
8#include "../component_batch.hpp"
9#include "../component_column.hpp"
10#include "../components/class_id.hpp"
11#include "../components/color.hpp"
12#include "../components/draw_order.hpp"
13#include "../components/half_size2d.hpp"
14#include "../components/position2d.hpp"
15#include "../components/radius.hpp"
16#include "../components/show_labels.hpp"
17#include "../components/text.hpp"
18#include "../result.hpp"
19
20#include <cstdint>
21#include <optional>
22#include <utility>
23#include <vector>
24
25namespace rerun::archetypes {
26 /// **Archetype**: 2D ellipses with half-extents (semi-axes) and optional center, colors etc.
27 ///
28 /// The half-sizes specify the lengths of the ellipse's two axes along the local x and y directions.
29 /// If both half-sizes are equal, the ellipse is a circle.
30 ///
31 /// ## Examples
32 ///
33 /// ### Simple 2D ellipses
34 /// ```cpp
35 /// #include <rerun.hpp>
36 ///
37 /// int main(int argc, char* argv[]) {
38 /// const auto rec = rerun::RecordingStream("rerun_example_ellipses2d");
39 /// rec.spawn().exit_on_failure();
40 ///
41 /// rec.log(
42 /// "simple",
43 /// rerun::Ellipses2D::from_centers_and_half_sizes(
44 /// {{0.0f, 0.0f}},
45 /// {{2.0f, 1.0f}}
46 /// )
47 /// );
48 /// }
49 /// ```
50 ///
51 /// ### Batch of 2D ellipses
52 /// ```cpp
53 /// #include <rerun.hpp>
54 ///
55 /// int main(int argc, char* argv[]) {
56 /// const auto rec = rerun::RecordingStream("rerun_example_ellipses2d_batch");
57 /// rec.spawn().exit_on_failure();
58 ///
59 /// rec.log(
60 /// "batch",
61 /// rerun::Ellipses2D::from_centers_and_half_sizes(
62 /// {{-2.0f, 0.0f}, {0.0f, 0.0f}, {2.5f, 0.0f}},
63 /// {{1.5f, 0.75f}, {0.5f, 0.5f}, {0.75f, 1.5f}}
64 /// )
65 /// .with_line_radii({0.025f, 0.05f, 0.025f})
66 /// .with_colors({
67 /// rerun::Rgba32(255, 0, 0),
68 /// rerun::Rgba32(0, 255, 0),
69 /// rerun::Rgba32(0, 0, 255),
70 /// })
71 /// .with_labels({"wide", "circle", "tall"})
72 /// );
73 /// }
74 /// ```
75 struct Ellipses2D {
76 /// All half-extents (semi-axes) that make up the batch of ellipses.
77 std::optional<ComponentBatch> half_sizes;
78
79 /// Optional center positions of the ellipses.
80 std::optional<ComponentBatch> centers;
81
82 /// Optional colors for the ellipses.
83 std::optional<ComponentBatch> colors;
84
85 /// Optional radii for the lines that make up the ellipses.
86 std::optional<ComponentBatch> line_radii;
87
88 /// Optional text labels for the ellipses.
89 ///
90 /// If there's a single label present, it will be placed at the center of the entity.
91 /// Otherwise, each instance will have its own label.
92 std::optional<ComponentBatch> labels;
93
94 /// Whether the text labels should be shown.
95 ///
96 /// If not set, labels will automatically appear when there is exactly one label for this entity
97 /// or the number of instances on this entity is under a certain threshold.
98 std::optional<ComponentBatch> show_labels;
99
100 /// An optional floating point value that specifies the 2D drawing order.
101 ///
102 /// Objects with higher values are drawn on top of those with lower values.
103 /// Defaults to `10.0`.
104 std::optional<ComponentBatch> draw_order;
105
106 /// Optional `components::ClassId`s for the ellipses.
107 ///
108 /// The `components::ClassId` provides colors and labels if not specified explicitly.
109 std::optional<ComponentBatch> class_ids;
110
111 public:
112 /// The name of the archetype as used in `ComponentDescriptor`s.
113 static constexpr const char ArchetypeName[] = "rerun.archetypes.Ellipses2D";
114
115 /// `ComponentDescriptor` for the `half_sizes` field.
117 ArchetypeName, "Ellipses2D:half_sizes",
119 );
120 /// `ComponentDescriptor` for the `centers` field.
122 ArchetypeName, "Ellipses2D:centers",
124 );
125 /// `ComponentDescriptor` for the `colors` field.
126 static constexpr auto Descriptor_colors = ComponentDescriptor(
128 );
129 /// `ComponentDescriptor` for the `line_radii` field.
131 ArchetypeName, "Ellipses2D:line_radii",
133 );
134 /// `ComponentDescriptor` for the `labels` field.
135 static constexpr auto Descriptor_labels = ComponentDescriptor(
137 );
138 /// `ComponentDescriptor` for the `show_labels` field.
140 ArchetypeName, "Ellipses2D:show_labels",
142 );
143 /// `ComponentDescriptor` for the `draw_order` field.
145 ArchetypeName, "Ellipses2D:draw_order",
147 );
148 /// `ComponentDescriptor` for the `class_ids` field.
150 ArchetypeName, "Ellipses2D:class_ids",
152 );
153
154 public: // START of extensions from ellipses2d_ext.cpp:
155 /// Creates new `Ellipses2D` with `half_sizes` centered around the local origin.
157 return Ellipses2D().with_half_sizes(std::move(half_sizes));
158 }
159
160 /// Creates new `Ellipses2D` with `centers` and `half_sizes`.
164 ) {
165 return Ellipses2D()
166 .with_half_sizes(std::move(half_sizes))
167 .with_centers(std::move(centers));
168 }
169
170 // END of extensions from ellipses2d_ext.cpp, start of generated code:
171
172 public:
173 Ellipses2D() = default;
174 Ellipses2D(Ellipses2D&& other) = default;
175 Ellipses2D(const Ellipses2D& other) = default;
176 Ellipses2D& operator=(const Ellipses2D& other) = default;
177 Ellipses2D& operator=(Ellipses2D&& other) = default;
178
179 /// Update only some specific fields of a `Ellipses2D`.
181 return Ellipses2D();
182 }
183
184 /// Clear all the fields of a `Ellipses2D`.
186
187 /// All half-extents (semi-axes) that make up the batch of ellipses.
189 ) && {
190 half_sizes =
191 ComponentBatch::from_loggable(_half_sizes, Descriptor_half_sizes).value_or_throw();
192 return std::move(*this);
193 }
194
195 /// Optional center positions of the ellipses.
197 centers = ComponentBatch::from_loggable(_centers, Descriptor_centers).value_or_throw();
198 return std::move(*this);
199 }
200
201 /// Optional colors for the ellipses.
203 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
204 return std::move(*this);
205 }
206
207 /// Optional radii for the lines that make up the ellipses.
209 line_radii =
210 ComponentBatch::from_loggable(_line_radii, Descriptor_line_radii).value_or_throw();
211 return std::move(*this);
212 }
213
214 /// Optional text labels for the ellipses.
215 ///
216 /// If there's a single label present, it will be placed at the center of the entity.
217 /// Otherwise, each instance will have its own label.
219 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
220 return std::move(*this);
221 }
222
223 /// Whether the text labels should be shown.
224 ///
225 /// If not set, labels will automatically appear when there is exactly one label for this entity
226 /// or the number of instances on this entity is under a certain threshold.
229 .value_or_throw();
230 return std::move(*this);
231 }
232
233 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
234 ///
235 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
236 /// be used when logging a single row's worth of data.
239 ) && {
241 .value_or_throw();
242 return std::move(*this);
243 }
244
245 /// An optional floating point value that specifies the 2D drawing order.
246 ///
247 /// Objects with higher values are drawn on top of those with lower values.
248 /// Defaults to `10.0`.
250 draw_order =
251 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
252 return std::move(*this);
253 }
254
255 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
256 ///
257 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
258 /// be used when logging a single row's worth of data.
260 ) && {
261 draw_order =
262 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
263 return std::move(*this);
264 }
265
266 /// Optional `components::ClassId`s for the ellipses.
267 ///
268 /// The `components::ClassId` provides colors and labels if not specified explicitly.
270 class_ids =
271 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
272 return std::move(*this);
273 }
274
275 /// Partitions the component data into multiple sub-batches.
276 ///
277 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
278 /// instead, via `ComponentBatch::partitioned`.
279 ///
280 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
281 ///
282 /// The specified `lengths` must sum to the total length of the component batch.
284 return detail::partition_batches(
285 {&half_sizes,
286 &centers,
287 &colors,
288 &line_radii,
289 &labels,
291 &draw_order,
292 &class_ids},
293 lengths_
294 )
295 .value_or_throw();
296 }
297
298 /// Partitions the component data into unit-length sub-batches.
299 ///
300 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
301 /// where `n` is automatically guessed.
303 return detail::partition_batches_of_unit_length({&half_sizes,
304 &centers,
305 &colors,
306 &line_radii,
307 &labels,
309 &draw_order,
310 &class_ids})
311 .value_or_throw();
312 }
313 };
314
315} // namespace rerun::archetypes
316
317namespace rerun {
318 /// \private
319 template <typename T>
320 struct AsComponents;
321
322 /// \private
323 template <>
324 struct AsComponents<archetypes::Ellipses2D> {
325 /// Serialize all set component batches.
326 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Ellipses2D& archetype
327 ) {
328 return detail::collect_batches(
329 {&archetype.half_sizes,
330 &archetype.centers,
331 &archetype.colors,
332 &archetype.line_radii,
333 &archetype.labels,
334 &archetype.show_labels,
335 &archetype.draw_order,
336 &archetype.class_ids}
337 );
338 }
339 };
340} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:90
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: 2D ellipses with half-extents (semi-axes) and optional center, colors etc.
Definition ellipses2d.hpp:75
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition ellipses2d.hpp:144
static constexpr auto Descriptor_half_sizes
ComponentDescriptor for the half_sizes field.
Definition ellipses2d.hpp:116
Ellipses2D with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition ellipses2d.hpp:249
Ellipses2D with_half_sizes(const Collection< rerun::components::HalfSize2D > &_half_sizes) &&
All half-extents (semi-axes) that make up the batch of ellipses.
Definition ellipses2d.hpp:188
std::optional< ComponentBatch > line_radii
Optional radii for the lines that make up the ellipses.
Definition ellipses2d.hpp:86
Ellipses2D with_many_draw_order(const Collection< rerun::components::DrawOrder > &_draw_order) &&
This method makes it possible to pack multiple draw_order in a single component batch.
Definition ellipses2d.hpp:259
static Ellipses2D from_centers_and_half_sizes(Collection< components::Position2D > centers, Collection< components::HalfSize2D > half_sizes)
Creates new Ellipses2D with centers and half_sizes.
Definition ellipses2d.hpp:161
std::optional< ComponentBatch > class_ids
Optional components::ClassIds for the ellipses.
Definition ellipses2d.hpp:109
Ellipses2D with_centers(const Collection< rerun::components::Position2D > &_centers) &&
Optional center positions of the ellipses.
Definition ellipses2d.hpp:196
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition ellipses2d.hpp:283
Ellipses2D with_line_radii(const Collection< rerun::components::Radius > &_line_radii) &&
Optional radii for the lines that make up the ellipses.
Definition ellipses2d.hpp:208
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition ellipses2d.hpp:135
std::optional< ComponentBatch > labels
Optional text labels for the ellipses.
Definition ellipses2d.hpp:92
static Ellipses2D from_half_sizes(Collection< components::HalfSize2D > half_sizes)
Creates new Ellipses2D with half_sizes centered around the local origin.
Definition ellipses2d.hpp:156
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition ellipses2d.hpp:98
static Ellipses2D update_fields()
Update only some specific fields of a Ellipses2D.
Definition ellipses2d.hpp:180
std::optional< ComponentBatch > centers
Optional center positions of the ellipses.
Definition ellipses2d.hpp:80
Ellipses2D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the ellipses.
Definition ellipses2d.hpp:202
std::optional< ComponentBatch > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition ellipses2d.hpp:104
std::optional< ComponentBatch > half_sizes
All half-extents (semi-axes) that make up the batch of ellipses.
Definition ellipses2d.hpp:77
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition ellipses2d.hpp:149
Ellipses2D with_many_show_labels(const Collection< rerun::components::ShowLabels > &_show_labels) &&
This method makes it possible to pack multiple show_labels in a single component batch.
Definition ellipses2d.hpp:237
std::optional< ComponentBatch > colors
Optional colors for the ellipses.
Definition ellipses2d.hpp:83
Ellipses2D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the ellipses.
Definition ellipses2d.hpp:218
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition ellipses2d.hpp:302
static constexpr auto Descriptor_centers
ComponentDescriptor for the centers field.
Definition ellipses2d.hpp:121
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition ellipses2d.hpp:113
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition ellipses2d.hpp:126
static Ellipses2D clear_fields()
Clear all the fields of a Ellipses2D.
Ellipses2D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition ellipses2d.hpp:227
Ellipses2D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional components::ClassIds for the ellipses.
Definition ellipses2d.hpp:269
static constexpr auto Descriptor_line_radii
ComponentDescriptor for the line_radii field.
Definition ellipses2d.hpp:130
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition ellipses2d.hpp:139
Component: Draw order of 2D elements.
Definition draw_order.hpp:30
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:18