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 /// Optional choice of whether the text labels should be shown by default.
75 std::optional<ComponentBatch> show_labels;
76
77 /// An optional floating point value that specifies the 2D drawing order.
78 ///
79 /// Objects with higher values are drawn on top of those with lower values.
80 std::optional<ComponentBatch> draw_order;
81
82 /// Optional class Ids for the points.
83 ///
84 /// The `components::ClassId` provides colors and labels if not specified explicitly.
85 std::optional<ComponentBatch> class_ids;
86
87 public:
88 static constexpr const char IndicatorComponentName[] = "rerun.components.Arrows2DIndicator";
89
90 /// Indicator component, used to identify the archetype when converting to a list of components.
92 /// The name of the archetype as used in `ComponentDescriptor`s.
93 static constexpr const char ArchetypeName[] = "rerun.archetypes.Arrows2D";
94
95 /// `ComponentDescriptor` for the `vectors` field.
96 static constexpr auto Descriptor_vectors = ComponentDescriptor(
97 ArchetypeName, "vectors",
99 );
100 /// `ComponentDescriptor` for the `origins` field.
102 ArchetypeName, "origins",
104 );
105 /// `ComponentDescriptor` for the `radii` field.
106 static constexpr auto Descriptor_radii = ComponentDescriptor(
108 );
109 /// `ComponentDescriptor` for the `colors` field.
110 static constexpr auto Descriptor_colors = ComponentDescriptor(
112 );
113 /// `ComponentDescriptor` for the `labels` field.
114 static constexpr auto Descriptor_labels = ComponentDescriptor(
116 );
117 /// `ComponentDescriptor` for the `show_labels` field.
119 ArchetypeName, "show_labels",
121 );
122 /// `ComponentDescriptor` for the `draw_order` field.
124 ArchetypeName, "draw_order",
126 );
127 /// `ComponentDescriptor` for the `class_ids` field.
129 ArchetypeName, "class_ids",
131 );
132
133 public: // START of extensions from arrows2d_ext.cpp:
134 /// Creates new 2D arrows pointing in the given directions, with a base at the origin (0, 0).
136 return Arrows2D().with_vectors(vectors_);
137 }
138
139 // END of extensions from arrows2d_ext.cpp, start of generated code:
140
141 public:
142 Arrows2D() = default;
143 Arrows2D(Arrows2D&& other) = default;
144 Arrows2D(const Arrows2D& other) = default;
145 Arrows2D& operator=(const Arrows2D& other) = default;
146 Arrows2D& operator=(Arrows2D&& other) = default;
147
148 /// Update only some specific fields of a `Arrows2D`.
150 return Arrows2D();
151 }
152
153 /// Clear all the fields of a `Arrows2D`.
155
156 /// All the vectors for each arrow in the batch.
158 vectors = ComponentBatch::from_loggable(_vectors, Descriptor_vectors).value_or_throw();
159 return std::move(*this);
160 }
161
162 /// All the origin (base) positions for each arrow in the batch.
163 ///
164 /// If no origins are set, (0, 0) is used as the origin for each arrow.
166 origins = ComponentBatch::from_loggable(_origins, Descriptor_origins).value_or_throw();
167 return std::move(*this);
168 }
169
170 /// Optional radii for the arrows.
171 ///
172 /// The shaft is rendered as a line with `radius = 0.5 * radius`.
173 /// The tip is rendered with `height = 2.0 * radius` and `radius = 1.0 * radius`.
175 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
176 return std::move(*this);
177 }
178
179 /// Optional colors for the points.
181 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
182 return std::move(*this);
183 }
184
185 /// Optional text labels for the arrows.
186 ///
187 /// If there's a single label present, it will be placed at the center of the entity.
188 /// Otherwise, each instance will have its own label.
190 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
191 return std::move(*this);
192 }
193
194 /// Optional choice of whether the text labels should be shown by default.
197 .value_or_throw();
198 return std::move(*this);
199 }
200
201 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
202 ///
203 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
204 /// be used when logging a single row's worth of data.
206 ) && {
208 .value_or_throw();
209 return std::move(*this);
210 }
211
212 /// An optional floating point value that specifies the 2D drawing order.
213 ///
214 /// Objects with higher values are drawn on top of those with lower values.
216 draw_order =
217 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
218 return std::move(*this);
219 }
220
221 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
222 ///
223 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
224 /// be used when logging a single row's worth of data.
226 ) && {
227 draw_order =
228 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
229 return std::move(*this);
230 }
231
232 /// Optional class Ids for the points.
233 ///
234 /// The `components::ClassId` provides colors and labels if not specified explicitly.
236 class_ids =
237 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
238 return std::move(*this);
239 }
240
241 /// Partitions the component data into multiple sub-batches.
242 ///
243 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
244 /// instead, via `ComponentBatch::partitioned`.
245 ///
246 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
247 ///
248 /// The specified `lengths` must sum to the total length of the component batch.
250
251 /// Partitions the component data into unit-length sub-batches.
252 ///
253 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
254 /// where `n` is automatically guessed.
256 };
257
258} // namespace rerun::archetypes
259
260namespace rerun {
261 /// \private
262 template <typename T>
263 struct AsComponents;
264
265 /// \private
266 template <>
267 struct AsComponents<archetypes::Arrows2D> {
268 /// Serialize all set component batches.
269 static Result<Collection<ComponentBatch>> as_batches(const archetypes::Arrows2D& archetype);
270 };
271} // 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=rerun::Loggable< T >::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:180
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:215
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition arrows2d.hpp:106
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition arrows2d.hpp:93
static constexpr auto Descriptor_vectors
ComponentDescriptor for the vectors field.
Definition arrows2d.hpp:96
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:118
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:135
Arrows2D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition arrows2d.hpp:195
Arrows2D with_vectors(const Collection< rerun::components::Vector2D > &_vectors) &&
All the vectors for each arrow in the batch.
Definition arrows2d.hpp:157
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:114
static constexpr auto Descriptor_origins
ComponentDescriptor for the origins field.
Definition arrows2d.hpp:101
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:149
std::optional< ComponentBatch > class_ids
Optional class Ids for the points.
Definition arrows2d.hpp:85
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition arrows2d.hpp:110
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:235
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:205
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:80
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:225
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:189
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:123
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition arrows2d.hpp:128
std::optional< ComponentBatch > show_labels
Optional choice of whether the text labels should be shown by default.
Definition arrows2d.hpp:75
Arrows2D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the arrows.
Definition arrows2d.hpp:174
Arrows2D with_origins(const Collection< rerun::components::Position2D > &_origins) &&
All the origin (base) positions for each arrow in the batch.
Definition arrows2d.hpp:165
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