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