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