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