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({{0.0f, 0.0f}}, {{2.0f, 1.0f}})
43 /// );
44 /// }
45 /// ```
46 ///
47 /// ### Batch of 2D ellipses
48 /// ```cpp
49 /// #include <rerun.hpp>
50 ///
51 /// int main(int argc, char* argv[]) {
52 /// const auto rec = rerun::RecordingStream("rerun_example_ellipses2d_batch");
53 /// rec.spawn().exit_on_failure();
54 ///
55 /// rec.log(
56 /// "batch",
57 /// rerun::Ellipses2D::from_centers_and_half_sizes(
58 /// {{-2.0f, 0.0f}, {0.0f, 0.0f}, {2.5f, 0.0f}},
59 /// {{1.5f, 0.75f}, {0.5f, 0.5f}, {0.75f, 1.5f}}
60 /// )
61 /// .with_line_radii({0.025f, 0.05f, 0.025f})
62 /// .with_colors({
63 /// rerun::Rgba32(255, 0, 0),
64 /// rerun::Rgba32(0, 255, 0),
65 /// rerun::Rgba32(0, 0, 255),
66 /// })
67 /// .with_labels({"wide", "circle", "tall"})
68 /// );
69 /// }
70 /// ```
71 struct Ellipses2D {
72 /// All half-extents (semi-axes) that make up the batch of ellipses.
73 std::optional<ComponentBatch> half_sizes;
74
75 /// Optional center positions of the ellipses.
76 std::optional<ComponentBatch> centers;
77
78 /// Optional colors for the ellipses.
79 std::optional<ComponentBatch> colors;
80
81 /// Optional radii for the lines that make up the ellipses.
82 std::optional<ComponentBatch> line_radii;
83
84 /// Optional text labels for the ellipses.
85 ///
86 /// If there's a single label present, it will be placed at the center of the entity.
87 /// Otherwise, each instance will have its own label.
88 std::optional<ComponentBatch> labels;
89
90 /// Whether the text labels should be shown.
91 ///
92 /// If not set, labels will automatically appear when there is exactly one label for this entity
93 /// or the number of instances on this entity is under a certain threshold.
94 std::optional<ComponentBatch> show_labels;
95
96 /// An optional floating point value that specifies the 2D drawing order.
97 ///
98 /// Objects with higher values are drawn on top of those with lower values.
99 /// Defaults to `10.0`.
100 std::optional<ComponentBatch> draw_order;
101
102 /// Optional `components::ClassId`s for the ellipses.
103 ///
104 /// The `components::ClassId` provides colors and labels if not specified explicitly.
105 std::optional<ComponentBatch> class_ids;
106
107 public:
108 /// The name of the archetype as used in `ComponentDescriptor`s.
109 static constexpr const char ArchetypeName[] = "rerun.archetypes.Ellipses2D";
110
111 /// `ComponentDescriptor` for the `half_sizes` field.
113 ArchetypeName, "Ellipses2D:half_sizes",
115 );
116 /// `ComponentDescriptor` for the `centers` field.
118 ArchetypeName, "Ellipses2D:centers",
120 );
121 /// `ComponentDescriptor` for the `colors` field.
122 static constexpr auto Descriptor_colors = ComponentDescriptor(
124 );
125 /// `ComponentDescriptor` for the `line_radii` field.
127 ArchetypeName, "Ellipses2D:line_radii",
129 );
130 /// `ComponentDescriptor` for the `labels` field.
131 static constexpr auto Descriptor_labels = ComponentDescriptor(
133 );
134 /// `ComponentDescriptor` for the `show_labels` field.
136 ArchetypeName, "Ellipses2D:show_labels",
138 );
139 /// `ComponentDescriptor` for the `draw_order` field.
141 ArchetypeName, "Ellipses2D:draw_order",
143 );
144 /// `ComponentDescriptor` for the `class_ids` field.
146 ArchetypeName, "Ellipses2D:class_ids",
148 );
149
150 public: // START of extensions from ellipses2d_ext.cpp:
151 /// Creates new `Ellipses2D` with `half_sizes` centered around the local origin.
153 return Ellipses2D().with_half_sizes(std::move(half_sizes));
154 }
155
156 /// Creates new `Ellipses2D` with `centers` and `half_sizes`.
160 ) {
161 return Ellipses2D()
162 .with_half_sizes(std::move(half_sizes))
163 .with_centers(std::move(centers));
164 }
165
166 // END of extensions from ellipses2d_ext.cpp, start of generated code:
167
168 public:
169 Ellipses2D() = default;
170 Ellipses2D(Ellipses2D&& other) = default;
171 Ellipses2D(const Ellipses2D& other) = default;
172 Ellipses2D& operator=(const Ellipses2D& other) = default;
173 Ellipses2D& operator=(Ellipses2D&& other) = default;
174
175 /// Update only some specific fields of a `Ellipses2D`.
177 return Ellipses2D();
178 }
179
180 /// Clear all the fields of a `Ellipses2D`.
182
183 /// All half-extents (semi-axes) that make up the batch of ellipses.
185 ) && {
186 half_sizes =
187 ComponentBatch::from_loggable(_half_sizes, Descriptor_half_sizes).value_or_throw();
188 return std::move(*this);
189 }
190
191 /// Optional center positions of the ellipses.
193 centers = ComponentBatch::from_loggable(_centers, Descriptor_centers).value_or_throw();
194 return std::move(*this);
195 }
196
197 /// Optional colors for the ellipses.
199 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
200 return std::move(*this);
201 }
202
203 /// Optional radii for the lines that make up the ellipses.
205 line_radii =
206 ComponentBatch::from_loggable(_line_radii, Descriptor_line_radii).value_or_throw();
207 return std::move(*this);
208 }
209
210 /// Optional text labels for the ellipses.
211 ///
212 /// If there's a single label present, it will be placed at the center of the entity.
213 /// Otherwise, each instance will have its own label.
215 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
216 return std::move(*this);
217 }
218
219 /// Whether the text labels should be shown.
220 ///
221 /// If not set, labels will automatically appear when there is exactly one label for this entity
222 /// or the number of instances on this entity is under a certain threshold.
225 .value_or_throw();
226 return std::move(*this);
227 }
228
229 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
230 ///
231 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
232 /// be used when logging a single row's worth of data.
235 ) && {
237 .value_or_throw();
238 return std::move(*this);
239 }
240
241 /// An optional floating point value that specifies the 2D drawing order.
242 ///
243 /// Objects with higher values are drawn on top of those with lower values.
244 /// Defaults to `10.0`.
246 draw_order =
247 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
248 return std::move(*this);
249 }
250
251 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
252 ///
253 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
254 /// be used when logging a single row's worth of data.
256 ) && {
257 draw_order =
258 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
259 return std::move(*this);
260 }
261
262 /// Optional `components::ClassId`s for the ellipses.
263 ///
264 /// The `components::ClassId` provides colors and labels if not specified explicitly.
266 class_ids =
267 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
268 return std::move(*this);
269 }
270
271 /// Partitions the component data into multiple sub-batches.
272 ///
273 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
274 /// instead, via `ComponentBatch::partitioned`.
275 ///
276 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
277 ///
278 /// The specified `lengths` must sum to the total length of the component batch.
280
281 /// Partitions the component data into unit-length sub-batches.
282 ///
283 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
284 /// where `n` is automatically guessed.
286 };
287
288} // namespace rerun::archetypes
289
290namespace rerun {
291 /// \private
292 template <typename T>
293 struct AsComponents;
294
295 /// \private
296 template <>
297 struct AsComponents<archetypes::Ellipses2D> {
298 /// Serialize all set component batches.
299 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Ellipses2D& archetype
300 );
301 };
302} // 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:81
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:71
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition ellipses2d.hpp:140
static constexpr auto Descriptor_half_sizes
ComponentDescriptor for the half_sizes field.
Definition ellipses2d.hpp:112
Ellipses2D with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition ellipses2d.hpp:245
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:184
std::optional< ComponentBatch > line_radii
Optional radii for the lines that make up the ellipses.
Definition ellipses2d.hpp:82
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:255
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:157
std::optional< ComponentBatch > class_ids
Optional components::ClassIds for the ellipses.
Definition ellipses2d.hpp:105
Ellipses2D with_centers(const Collection< rerun::components::Position2D > &_centers) &&
Optional center positions of the ellipses.
Definition ellipses2d.hpp:192
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:204
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition ellipses2d.hpp:131
std::optional< ComponentBatch > labels
Optional text labels for the ellipses.
Definition ellipses2d.hpp:88
static Ellipses2D from_half_sizes(Collection< components::HalfSize2D > half_sizes)
Creates new Ellipses2D with half_sizes centered around the local origin.
Definition ellipses2d.hpp:152
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition ellipses2d.hpp:94
static Ellipses2D update_fields()
Update only some specific fields of a Ellipses2D.
Definition ellipses2d.hpp:176
std::optional< ComponentBatch > centers
Optional center positions of the ellipses.
Definition ellipses2d.hpp:76
Ellipses2D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the ellipses.
Definition ellipses2d.hpp:198
std::optional< ComponentBatch > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition ellipses2d.hpp:100
std::optional< ComponentBatch > half_sizes
All half-extents (semi-axes) that make up the batch of ellipses.
Definition ellipses2d.hpp:73
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition ellipses2d.hpp:145
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:233
std::optional< ComponentBatch > colors
Optional colors for the ellipses.
Definition ellipses2d.hpp:79
Ellipses2D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the ellipses.
Definition ellipses2d.hpp:214
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:117
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition ellipses2d.hpp:109
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition ellipses2d.hpp:122
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:223
Ellipses2D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional components::ClassIds for the ellipses.
Definition ellipses2d.hpp:265
static constexpr auto Descriptor_line_radii
ComponentDescriptor for the line_radii field.
Definition ellipses2d.hpp:126
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition ellipses2d.hpp:135
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