Rerun C++ SDK
Loading...
Searching...
No Matches
points2d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/archetypes/points2d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../components/class_id.hpp"
9#include "../components/color.hpp"
10#include "../components/draw_order.hpp"
11#include "../components/keypoint_id.hpp"
12#include "../components/position2d.hpp"
13#include "../components/radius.hpp"
14#include "../components/text.hpp"
15#include "../data_cell.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**: A 2D point cloud with positions and optional colors, radii, labels, etc.
26 ///
27 /// ## Example
28 ///
29 /// ### Randomly distributed 2D points with varying color and radius
30 /// ![image](https://static.rerun.io/point2d_random/8e8ac75373677bd72bd3f56a15e44fcab309a168/full.png)
31 ///
32 /// ```cpp
33 /// #include <rerun.hpp>
34 ///
35 /// #include <algorithm>
36 /// #include <random>
37 /// #include <vector>
38 ///
39 /// int main() {
40 /// const auto rec = rerun::RecordingStream("rerun_example_points2d_random");
41 /// rec.spawn().exit_on_failure();
42 ///
43 /// std::default_random_engine gen;
44 /// std::uniform_real_distribution<float> dist_pos(-3.0f, 3.0f);
45 /// std::uniform_real_distribution<float> dist_radius(0.1f, 1.0f);
46 /// // On MSVC uint8_t distributions are not supported.
47 /// std::uniform_int_distribution<int> dist_color(0, 255);
48 ///
49 /// std::vector<rerun::Position2D> points2d(10);
50 /// std::generate(points2d.begin(), points2d.end(), [&] {
51 /// return rerun::Position2D(dist_pos(gen), dist_pos(gen));
52 /// });
53 /// std::vector<rerun::Color> colors(10);
54 /// std::generate(colors.begin(), colors.end(), [&] {
55 /// return rerun::Color(
56 /// static_cast<uint8_t>(dist_color(gen)),
57 /// static_cast<uint8_t>(dist_color(gen)),
58 /// static_cast<uint8_t>(dist_color(gen))
59 /// );
60 /// });
61 /// std::vector<rerun::Radius> radii(10);
62 /// std::generate(radii.begin(), radii.end(), [&] { return dist_radius(gen); });
63 ///
64 /// rec.log("random", rerun::Points2D(points2d).with_colors(colors).with_radii(radii));
65 ///
66 /// // TODO(#5520): log VisualBounds2D
67 /// }
68 /// ```
69 struct Points2D {
70 /// All the 2D positions at which the point cloud shows points.
72
73 /// Optional radii for the points, effectively turning them into circles.
74 std::optional<Collection<rerun::components::Radius>> radii;
75
76 /// Optional colors for the points.
77 std::optional<Collection<rerun::components::Color>> colors;
78
79 /// Optional text labels for the points.
80 std::optional<Collection<rerun::components::Text>> labels;
81
82 /// An optional floating point value that specifies the 2D drawing order.
83 ///
84 /// Objects with higher values are drawn on top of those with lower values.
85 std::optional<rerun::components::DrawOrder> draw_order;
86
87 /// Optional class Ids for the points.
88 ///
89 /// The class ID provides colors and labels if not specified explicitly.
90 std::optional<Collection<rerun::components::ClassId>> class_ids;
91
92 /// Optional keypoint IDs for the points, identifying them within a class.
93 ///
94 /// If keypoint IDs are passed in but no class IDs were specified, the class ID will
95 /// default to 0.
96 /// This is useful to identify points within a single classification (which is identified
97 /// with `class_id`).
98 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
99 /// detected skeleton.
100 std::optional<Collection<rerun::components::KeypointId>> keypoint_ids;
101
102 public:
103 static constexpr const char IndicatorComponentName[] = "rerun.components.Points2DIndicator";
104
105 /// Indicator component, used to identify the archetype when converting to a list of components.
107
108 public:
109 Points2D() = default;
110 Points2D(Points2D&& other) = default;
111
113 : positions(std::move(_positions)) {}
114
115 /// Optional radii for the points, effectively turning them into circles.
117 radii = std::move(_radii);
118 // See: https://github.com/rerun-io/rerun/issues/4027
119 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
120 }
121
122 /// Optional colors for the points.
124 colors = std::move(_colors);
125 // See: https://github.com/rerun-io/rerun/issues/4027
126 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
127 }
128
129 /// Optional text labels for the points.
131 labels = std::move(_labels);
132 // See: https://github.com/rerun-io/rerun/issues/4027
133 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
134 }
135
136 /// An optional floating point value that specifies the 2D drawing order.
137 ///
138 /// Objects with higher values are drawn on top of those with lower values.
140 draw_order = std::move(_draw_order);
141 // See: https://github.com/rerun-io/rerun/issues/4027
142 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
143 }
144
145 /// Optional class Ids for the points.
146 ///
147 /// The class ID provides colors and labels if not specified explicitly.
149 class_ids = std::move(_class_ids);
150 // See: https://github.com/rerun-io/rerun/issues/4027
151 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
152 }
153
154 /// Optional keypoint IDs for the points, identifying them within a class.
155 ///
156 /// If keypoint IDs are passed in but no class IDs were specified, the class ID will
157 /// default to 0.
158 /// This is useful to identify points within a single classification (which is identified
159 /// with `class_id`).
160 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
161 /// detected skeleton.
163 keypoint_ids = std::move(_keypoint_ids);
164 // See: https://github.com/rerun-io/rerun/issues/4027
165 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
166 }
167 };
168
169} // namespace rerun::archetypes
170
171namespace rerun {
172 /// \private
173 template <typename T>
174 struct AsComponents;
175
176 /// \private
177 template <>
178 struct AsComponents<archetypes::Points2D> {
179 /// Serialize all set component batches.
180 static Result<std::vector<DataCell>> serialize(const archetypes::Points2D& archetype);
181 };
182} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:46
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:72
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:21
Archetype: A 2D point cloud with positions and optional colors, radii, labels, etc.
Definition points2d.hpp:69
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the points, effectively turning them into circles.
Definition points2d.hpp:74
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the points.
Definition points2d.hpp:77
Points2D with_keypoint_ids(Collection< rerun::components::KeypointId > _keypoint_ids) &&
Optional keypoint IDs for the points, identifying them within a class.
Definition points2d.hpp:162
Collection< rerun::components::Position2D > positions
All the 2D positions at which the point cloud shows points.
Definition points2d.hpp:71
Points2D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional class Ids for the points.
Definition points2d.hpp:148
Points2D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the points.
Definition points2d.hpp:130
std::optional< Collection< rerun::components::KeypointId > > keypoint_ids
Optional keypoint IDs for the points, identifying them within a class.
Definition points2d.hpp:100
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the points.
Definition points2d.hpp:90
Points2D with_draw_order(rerun::components::DrawOrder _draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition points2d.hpp:139
std::optional< rerun::components::DrawOrder > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition points2d.hpp:85
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the points.
Definition points2d.hpp:80
Points2D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the points, effectively turning them into circles.
Definition points2d.hpp:116
Points2D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the points.
Definition points2d.hpp:123
Component: Draw order used for the display order of 2D elements.
Definition draw_order.hpp:30
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23