Rerun C++ SDK
Loading...
Searching...
No Matches
line_strips2d.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/line_strips2d.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/line_strip2d.hpp"
13#include "../components/radius.hpp"
14#include "../components/show_labels.hpp"
15#include "../components/text.hpp"
16#include "../result.hpp"
17
18#include <cstdint>
19#include <optional>
20#include <utility>
21#include <vector>
22
23namespace rerun::archetypes {
24 /// **Archetype**: 2D line strips with positions and optional colors, radii, labels, etc.
25 ///
26 /// ## Examples
27 ///
28 /// ### line_strips2d_batch:
29 /// ![image](https://static.rerun.io/line_strip2d_batch/c6f4062bcf510462d298a5dfe9fdbe87c754acee/full.png)
30 ///
31 /// ```cpp
32 /// #include <rerun.hpp>
33 ///
34 /// #include <vector>
35 ///
36 /// int main(int argc, char* argv[]) {
37 /// const auto rec = rerun::RecordingStream("rerun_example_line_strip2d_batch");
38 /// rec.spawn().exit_on_failure();
39 ///
40 /// rerun::Collection<rerun::Vec2D> strip1 = {
41 /// {0.f, 0.f},
42 /// {2.f, 1.f},
43 /// {4.f, -1.f},
44 /// {6.f, 0.f}};
45 /// rerun::Collection<rerun::Vec2D> strip2 = {
46 /// {0.f, 3.f},
47 /// {1.f, 4.f},
48 /// {2.f, 2.f},
49 /// {3.f, 4.f},
50 /// {4.f, 2.f},
51 /// {5.f, 4.f},
52 /// {6.f, 3.f}};
53 /// rec.log(
54 /// "strips",
55 /// rerun::LineStrips2D({strip1, strip2})
56 /// .with_colors({0xFF0000FF, 0x00FF00FF})
57 /// .with_radii({0.025f, 0.005f})
58 /// .with_labels({"one strip here", "and one strip there"})
59 /// );
60 ///
61 /// // TODO(#5520): log VisualBounds2D
62 /// }
63 /// ```
64 ///
65 /// ### Lines with scene & UI radius each
66 /// ```cpp
67 /// #include <rerun.hpp>
68 ///
69 /// int main(int argc, char* argv[]) {
70 /// const auto rec =
71 /// rerun::RecordingStream("rerun_example_line_strip2d_ui_radius");
72 /// rec.spawn().exit_on_failure();
73 ///
74 /// // A blue line with a scene unit radii of 0.01.
75 /// rerun::LineStrip2D linestrip_blue(
76 /// {{0.f, 0.f}, {0.f, 1.f}, {1.f, 0.f}, {1.f, 1.f}}
77 /// );
78 /// rec.log(
79 /// "scene_unit_line",
80 /// rerun::LineStrips2D(linestrip_blue)
81 /// // By default, radii are interpreted as world-space units.
82 /// .with_radii(0.01f)
83 /// .with_colors(rerun::Color(0, 0, 255))
84 /// );
85 ///
86 /// // A red line with a ui point radii of 5.
87 /// // UI points are independent of zooming in Views, but are sensitive to the application UI scaling.
88 /// // For 100 % ui scaling, UI points are equal to pixels.
89 /// rerun::LineStrip2D linestrip_red(
90 /// {{3.f, 0.f}, {3.f, 1.f}, {4.f, 0.f}, {4.f, 1.f}}
91 /// );
92 /// rec.log(
93 /// "ui_points_line",
94 /// rerun::LineStrips2D(linestrip_red)
95 /// // By default, radii are interpreted as world-space units.
96 /// .with_radii(rerun::Radius::ui_points(5.0f))
97 /// .with_colors(rerun::Color(255, 0, 0))
98 /// );
99 ///
100 /// // TODO(#5520): log VisualBounds2D
101 /// }
102 /// ```
104 /// All the actual 2D line strips that make up the batch.
105 std::optional<ComponentBatch> strips;
106
107 /// Optional radii for the line strips.
108 std::optional<ComponentBatch> radii;
109
110 /// Optional colors for the line strips.
111 std::optional<ComponentBatch> colors;
112
113 /// Optional text labels for the line strips.
114 ///
115 /// If there's a single label present, it will be placed at the center of the entity.
116 /// Otherwise, each instance will have its own label.
117 std::optional<ComponentBatch> labels;
118
119 /// Whether the text labels should be shown.
120 ///
121 /// If not set, labels will automatically appear when there is exactly one label for this entity
122 /// or the number of instances on this entity is under a certain threshold.
123 std::optional<ComponentBatch> show_labels;
124
125 /// An optional floating point value that specifies the 2D drawing order of each line strip.
126 ///
127 /// Objects with higher values are drawn on top of those with lower values.
128 /// Defaults to `20.0`.
129 std::optional<ComponentBatch> draw_order;
130
131 /// Optional `components::ClassId`s for the lines.
132 ///
133 /// The `components::ClassId` provides colors and labels if not specified explicitly.
134 std::optional<ComponentBatch> class_ids;
135
136 public:
137 /// The name of the archetype as used in `ComponentDescriptor`s.
138 static constexpr const char ArchetypeName[] = "rerun.archetypes.LineStrips2D";
139
140 /// `ComponentDescriptor` for the `strips` field.
141 static constexpr auto Descriptor_strips = ComponentDescriptor(
142 ArchetypeName, "LineStrips2D:strips",
144 );
145 /// `ComponentDescriptor` for the `radii` field.
146 static constexpr auto Descriptor_radii = ComponentDescriptor(
148 );
149 /// `ComponentDescriptor` for the `colors` field.
150 static constexpr auto Descriptor_colors = ComponentDescriptor(
152 );
153 /// `ComponentDescriptor` for the `labels` field.
154 static constexpr auto Descriptor_labels = ComponentDescriptor(
156 );
157 /// `ComponentDescriptor` for the `show_labels` field.
159 ArchetypeName, "LineStrips2D:show_labels",
161 );
162 /// `ComponentDescriptor` for the `draw_order` field.
164 ArchetypeName, "LineStrips2D:draw_order",
166 );
167 /// `ComponentDescriptor` for the `class_ids` field.
169 ArchetypeName, "LineStrips2D:class_ids",
171 );
172
173 public:
174 LineStrips2D() = default;
175 LineStrips2D(LineStrips2D&& other) = default;
176 LineStrips2D(const LineStrips2D& other) = default;
177 LineStrips2D& operator=(const LineStrips2D& other) = default;
178 LineStrips2D& operator=(LineStrips2D&& other) = default;
179
181 : strips(ComponentBatch::from_loggable(std::move(_strips), Descriptor_strips)
182 .value_or_throw()) {}
183
184 /// Update only some specific fields of a `LineStrips2D`.
186 return LineStrips2D();
187 }
188
189 /// Clear all the fields of a `LineStrips2D`.
191
192 /// All the actual 2D line strips that make up the batch.
194 strips = ComponentBatch::from_loggable(_strips, Descriptor_strips).value_or_throw();
195 return std::move(*this);
196 }
197
198 /// Optional radii for the line strips.
200 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
201 return std::move(*this);
202 }
203
204 /// Optional colors for the line strips.
206 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
207 return std::move(*this);
208 }
209
210 /// Optional text labels for the line strips.
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 of each line strip.
242 ///
243 /// Objects with higher values are drawn on top of those with lower values.
244 /// Defaults to `20.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.
257 ) && {
258 draw_order =
259 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
260 return std::move(*this);
261 }
262
263 /// Optional `components::ClassId`s for the lines.
264 ///
265 /// The `components::ClassId` provides colors and labels if not specified explicitly.
267 class_ids =
268 ComponentBatch::from_loggable(_class_ids, Descriptor_class_ids).value_or_throw();
269 return std::move(*this);
270 }
271
272 /// Partitions the component data into multiple sub-batches.
273 ///
274 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
275 /// instead, via `ComponentBatch::partitioned`.
276 ///
277 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
278 ///
279 /// The specified `lengths` must sum to the total length of the component batch.
281
282 /// Partitions the component data into unit-length sub-batches.
283 ///
284 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
285 /// where `n` is automatically guessed.
287 };
288
289} // namespace rerun::archetypes
290
291namespace rerun {
292 /// \private
293 template <typename T>
294 struct AsComponents;
295
296 /// \private
297 template <>
298 struct AsComponents<archetypes::LineStrips2D> {
299 /// Serialize all set component batches.
300 static Result<Collection<ComponentBatch>> as_batches(
301 const archetypes::LineStrips2D& archetype
302 );
303 };
304} // 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
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
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 line strips with positions and optional colors, radii, labels, etc.
Definition line_strips2d.hpp:103
static LineStrips2D update_fields()
Update only some specific fields of a LineStrips2D.
Definition line_strips2d.hpp:185
LineStrips2D with_strips(const Collection< rerun::components::LineStrip2D > &_strips) &&
All the actual 2D line strips that make up the batch.
Definition line_strips2d.hpp:193
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
LineStrips2D with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the line strips.
Definition line_strips2d.hpp:214
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition line_strips2d.hpp:158
std::optional< ComponentBatch > labels
Optional text labels for the line strips.
Definition line_strips2d.hpp:117
std::optional< ComponentBatch > strips
All the actual 2D line strips that make up the batch.
Definition line_strips2d.hpp:105
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition line_strips2d.hpp:150
std::optional< ComponentBatch > draw_order
An optional floating point value that specifies the 2D drawing order of each line strip.
Definition line_strips2d.hpp:129
static constexpr auto Descriptor_class_ids
ComponentDescriptor for the class_ids field.
Definition line_strips2d.hpp:168
LineStrips2D with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
An optional floating point value that specifies the 2D drawing order of each line strip.
Definition line_strips2d.hpp:245
static constexpr auto Descriptor_strips
ComponentDescriptor for the strips field.
Definition line_strips2d.hpp:141
LineStrips2D with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition line_strips2d.hpp:223
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition line_strips2d.hpp:163
LineStrips2D with_class_ids(const Collection< rerun::components::ClassId > &_class_ids) &&
Optional components::ClassIds for the lines.
Definition line_strips2d.hpp:266
LineStrips2D 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 line_strips2d.hpp:233
std::optional< ComponentBatch > class_ids
Optional components::ClassIds for the lines.
Definition line_strips2d.hpp:134
LineStrips2D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the line strips.
Definition line_strips2d.hpp:199
std::optional< ComponentBatch > colors
Optional colors for the line strips.
Definition line_strips2d.hpp:111
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition line_strips2d.hpp:146
static LineStrips2D clear_fields()
Clear all the fields of a LineStrips2D.
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition line_strips2d.hpp:154
LineStrips2D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the line strips.
Definition line_strips2d.hpp:205
LineStrips2D 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 line_strips2d.hpp:255
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition line_strips2d.hpp:138
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
std::optional< ComponentBatch > radii
Optional radii for the line strips.
Definition line_strips2d.hpp:108
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition line_strips2d.hpp:123
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