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