Rerun C++ SDK
Loading...
Searching...
No Matches
arrows2d.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_types/definitions/rerun/archetypes/arrows2d.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/position2d.hpp"
13#include "../components/radius.hpp"
14#include "../components/show_labels.hpp"
15#include "../components/text.hpp"
16#include "../components/vector2d.hpp"
17#include "../indicator_component.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 arrows with optional colors, radii, labels, etc.
27 ///
28 /// ## Example
29 ///
30 /// ### Simple batch of 2D arrows
31 /// ![image](https://static.rerun.io/arrow2d_simple/59f044ccc03f7bc66ee802288f75706618b29a6e/full.png)
32 ///
33 /// ```cpp
34 /// #include <rerun.hpp>
35 ///
36 /// int main() {
37 /// const auto rec = rerun::RecordingStream("rerun_example_arrow2d");
38 /// rec.spawn().exit_on_failure();
39 ///
40 /// rec.log(
41 /// "arrows",
42 /// rerun::Arrows2D::from_vectors({{1.0f, 0.0f}, {0.0f, -1.0f}, {-0.7f, 0.7f}})
43 /// .with_radii(0.025f)
44 /// .with_origins({{0.25f, 0.0f}, {0.25f, 0.0f}, {-0.1f, -0.1f}})
45 /// .with_colors({{255, 0, 0}, {0, 255, 0}, {127, 0, 255}})
46 /// .with_labels({"right", "up", "left-down"})
47 /// );
48 /// }
49 /// ```
50 struct Arrows2D {
51 /// All the vectors for each arrow in the batch.
52 std::optional<ComponentBatch> vectors;
53
54 /// All the origin (base) positions for each arrow in the batch.
55 ///
56 /// If no origins are set, (0, 0) is used as the origin for each arrow.
57 std::optional<ComponentBatch> origins;
58
59 /// Optional radii for the arrows.
60 ///
61 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
62 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
63 std::optional<ComponentBatch> radii;
64
65 /// Optional colors for the points.
66 std::optional<ComponentBatch> colors;
67
68 /// Optional text labels for the arrows.
69 ///
70 /// If there's a single label present, it will be placed at the center of the entity.
71 /// Otherwise, each instance will have its own label.
72 std::optional<ComponentBatch> labels;
73
74 /// Whether the text labels should be shown.
75 ///
76 /// If not set, labels will automatically appear when there is exactly one label for this entity
77 /// or the number of instances on this entity is under a certain threshold.
78 std::optional<ComponentBatch> show_labels;
79
80 /// An optional floating point value that specifies the 2D drawing order.
81 ///
82 /// Objects with higher values are drawn on top of those with lower values.
83 std::optional<ComponentBatch> draw_order;
84
85 /// Optional class Ids for the points.
86 ///
87 /// The `components::ClassId` provides colors and labels if not specified explicitly.
88 std::optional<ComponentBatch> class_ids;
89
90 public:
91 static constexpr const char IndicatorComponentName[] = "rerun.components.Arrows2DIndicator";
92
93 /// Indicator component, used to identify the archetype when converting to a list of components.
95 /// The name of the archetype as used in `ComponentDescriptor`s.
96 static constexpr const char ArchetypeName[] = "rerun.archetypes.Arrows2D";
97
98 /// `ComponentDescriptor` for the `vectors` field.
99 static constexpr auto Descriptor_vectors = ComponentDescriptor(
100 ArchetypeName, "vectors",
102 );
103 /// `ComponentDescriptor` for the `origins` field.
105 ArchetypeName, "origins",
107 );
108 /// `ComponentDescriptor` for the `radii` field.
109 static constexpr auto Descriptor_radii = ComponentDescriptor(
111 );
112 /// `ComponentDescriptor` for the `colors` field.
113 static constexpr auto Descriptor_colors = ComponentDescriptor(
115 );
116 /// `ComponentDescriptor` for the `labels` field.
117 static constexpr auto Descriptor_labels = ComponentDescriptor(
119 );
120 /// `ComponentDescriptor` for the `show_labels` field.
122 ArchetypeName, "show_labels",
124 );
125 /// `ComponentDescriptor` for the `draw_order` field.
127 ArchetypeName, "draw_order",
129 );
130 /// `ComponentDescriptor` for the `class_ids` field.
132 ArchetypeName, "class_ids",
134 );
135
136 public: // START of extensions from arrows2d_ext.cpp:
137 /// Creates new 2D arrows pointing in the given directions, with a base at the origin (0, 0).
139 return Arrows2D().with_vectors(vectors_);
140 }
141
142 // END of extensions from arrows2d_ext.cpp, start of generated code:
143
144 public:
145 Arrows2D() = default;
146 Arrows2D(Arrows2D&& other) = default;
147 Arrows2D(const Arrows2D& other) = default;
148 Arrows2D& operator=(const Arrows2D& other) = default;
149 Arrows2D& operator=(Arrows2D&& other) = default;
150
151 /// Update only some specific fields of a `Arrows2D`.
153 return Arrows2D();
154 }
155
156 /// Clear all the fields of a `Arrows2D`.
158
159 /// All the vectors for each arrow in the batch.
161 vectors = ComponentBatch::from_loggable(_vectors, Descriptor_vectors).value_or_throw();
162 return std::move(*this);
163 }
164
165 /// All the origin (base) positions for each arrow in the batch.
166 ///
167 /// If no origins are set, (0, 0) is used as the origin for each arrow.
169 origins = ComponentBatch::from_loggable(_origins, Descriptor_origins).value_or_throw();
170 return std::move(*this);
171 }
172
173 /// Optional radii for the arrows.
174 ///
175 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
176 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
178 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
179 return std::move(*this);
180 }
181
182 /// Optional colors for the points.
184 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
185 return std::move(*this);
186 }
187
188 /// Optional text labels for the arrows.
189 ///
190 /// If there's a single label present, it will be placed at the center of the entity.
191 /// Otherwise, each instance will have its own label.
193 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
194 return std::move(*this);
195 }
196
197 /// Whether the text labels should be shown.
198 ///
199 /// If not set, labels will automatically appear when there is exactly one label for this entity
200 /// or the number of instances on this entity is under a certain threshold.
203 .value_or_throw();
204 return std::move(*this);
205 }
206
207 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
208 ///
209 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
210 /// be used when logging a single row's worth of data.
212 ) && {
214 .value_or_throw();
215 return std::move(*this);
216 }
217
218 /// An optional floating point value that specifies the 2D drawing order.
219 ///
220 /// Objects with higher values are drawn on top of those with lower values.
222 draw_order =
223 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
224 return std::move(*this);
225 }
226
227 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
228 ///
229 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
230 /// be used when logging a single row's worth of data.
232 ) && {
233 draw_order =
234 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
235 return std::move(*this);
236 }
237
238 /// Optional class Ids for the points.
239 ///
240 /// The `components::ClassId` provides colors and labels if not specified explicitly.
242 class_ids =
243 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
244 return std::move(*this);
245 }
246
247 /// Partitions the component data into multiple sub-batches.
248 ///
249 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
250 /// instead, via `ComponentBatch::partitioned`.
251 ///
252 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
253 ///
254 /// The specified `lengths` must sum to the total length of the component batch.
256
257 /// Partitions the component data into unit-length sub-batches.
258 ///
259 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
260 /// where `n` is automatically guessed.
262 };
263
264} // namespace rerun::archetypes
265
266namespace rerun {
267 /// \private
268 template <typename T>
269 struct AsComponents;
270
271 /// \private
272 template <>
273 struct AsComponents<archetypes::Arrows2D> {
274 /// Serialize all set component batches.
275 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Arrows2D& archetype);
276 };
277} // 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:76
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:14
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: 2D arrows with optional colors, radii, labels, etc.
Definition arrows2d.hpp:50
Arrows2D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the points.
Definition arrows2d.hpp:183
static Arrows2D clear_fields()
Clear all the fields of a Arrows2D.
Arrows2D with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition arrows2d.hpp:221
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition arrows2d.hpp:109
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition arrows2d.hpp:96
static constexpr auto Descriptor_vectors
ComponentDescriptor for the vectors field.
Definition arrows2d.hpp:99
std::optional< ComponentBatch > labels
Optional text labels for the arrows.
Definition arrows2d.hpp:72
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition arrows2d.hpp:121
static Arrows2D from_vectors(Collection< components::Vector2D > vectors_)
Creates new 2D arrows pointing in the given directions, with a base at the origin (0,...
Definition arrows2d.hpp:138
Arrows2D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition arrows2d.hpp:201
Arrows2D with_vectors(const Collection< rerun::components::Vector2D > &_vectors) &&
All the vectors for each arrow in the batch.
Definition arrows2d.hpp:160
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition arrows2d.hpp:117
static constexpr auto Descriptor_origins
ComponentDescriptor for the origins field.
Definition arrows2d.hpp:104
std::optional< ComponentBatch > radii
Optional radii for the arrows.
Definition arrows2d.hpp:63
static Arrows2D update_fields()
Update only some specific fields of a Arrows2D.
Definition arrows2d.hpp:152
std::optional< ComponentBatch > class_ids
Optional class Ids for the points.
Definition arrows2d.hpp:88
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition arrows2d.hpp:113
std::optional< ComponentBatch > origins
All the origin (base) positions for each arrow in the batch.
Definition arrows2d.hpp:57
Arrows2D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional class Ids for the points.
Definition arrows2d.hpp:241
Arrows2D 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 arrows2d.hpp:211
std::optional< ComponentBatch > colors
Optional colors for the points.
Definition arrows2d.hpp:66
std::optional< ComponentBatch > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition arrows2d.hpp:83
Arrows2D 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 arrows2d.hpp:231
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Arrows2D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the arrows.
Definition arrows2d.hpp:192
std::optional< ComponentBatch > vectors
All the vectors for each arrow in the batch.
Definition arrows2d.hpp:52
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition arrows2d.hpp:126
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition arrows2d.hpp:131
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition arrows2d.hpp:78
Arrows2D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the arrows.
Definition arrows2d.hpp:177
Arrows2D with_origins(const Collection< rerun::components::Position2D > &_origins) &&
All the origin (base) positions for each arrow in the batch.
Definition arrows2d.hpp:168
Component: Draw order of 2D elements.
Definition draw_order.hpp:20
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32
Component: Whether the entity's components::Text label is shown.
Definition show_labels.hpp:19