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