Rerun C++ SDK
Loading...
Searching...
No Matches
points2d.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/points2d.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../component_batch.hpp"
9#include "../components/class_id.hpp"
10#include "../components/color.hpp"
11#include "../components/draw_order.hpp"
12#include "../components/keypoint_id.hpp"
13#include "../components/position2d.hpp"
14#include "../components/radius.hpp"
15#include "../components/show_labels.hpp"
16#include "../components/text.hpp"
17#include "../indicator_component.hpp"
18#include "../result.hpp"
19
20#include <cstdint>
21#include <optional>
22#include <utility>
23#include <vector>
24
25namespace rerun::archetypes {
26 /// **Archetype**: A 2D point cloud with positions and optional colors, radii, labels, etc.
27 ///
28 /// ## Examples
29 ///
30 /// ### Randomly distributed 2D points with varying color and radius
31 /// ![image](https://static.rerun.io/point2d_random/8e8ac75373677bd72bd3f56a15e44fcab309a168/full.png)
32 ///
33 /// ```cpp
34 /// #include <rerun.hpp>
35 ///
36 /// #include <algorithm>
37 /// #include <random>
38 /// #include <vector>
39 ///
40 /// int main() {
41 /// const auto rec = rerun::RecordingStream("rerun_example_points2d_random");
42 /// rec.spawn().exit_on_failure();
43 ///
44 /// std::default_random_engine gen;
45 /// std::uniform_real_distribution<float> dist_pos(-3.0f, 3.0f);
46 /// std::uniform_real_distribution<float> dist_radius(0.1f, 1.0f);
47 /// // On MSVC uint8_t distributions are not supported.
48 /// std::uniform_int_distribution<int> dist_color(0, 255);
49 ///
50 /// std::vector<rerun::Position2D> points2d(10);
51 /// std::generate(points2d.begin(), points2d.end(), [&] {
52 /// return rerun::Position2D(dist_pos(gen), dist_pos(gen));
53 /// });
54 /// std::vector<rerun::Color> colors(10);
55 /// std::generate(colors.begin(), colors.end(), [&] {
56 /// return rerun::Color(
57 /// static_cast<uint8_t>(dist_color(gen)),
58 /// static_cast<uint8_t>(dist_color(gen)),
59 /// static_cast<uint8_t>(dist_color(gen))
60 /// );
61 /// });
62 /// std::vector<rerun::Radius> radii(10);
63 /// std::generate(radii.begin(), radii.end(), [&] { return dist_radius(gen); });
64 ///
65 /// rec.log("random", rerun::Points2D(points2d).with_colors(colors).with_radii(radii));
66 ///
67 /// // TODO(#5520): log VisualBounds2D
68 /// }
69 /// ```
70 ///
71 /// ### Log points with radii given in UI points
72 /// ![image](https://static.rerun.io/point2d_ui_radius/ce804fc77300d89c348b4ab5960395171497b7ac/full.png)
73 ///
74 /// ```cpp
75 /// #include <rerun.hpp>
76 ///
77 /// int main() {
78 /// const auto rec = rerun::RecordingStream("rerun_example_points2d_ui_radius");
79 /// rec.spawn().exit_on_failure();
80 ///
81 /// // Two blue points with scene unit radii of 0.1 and 0.3.
82 /// rec.log(
83 /// "scene_units",
84 /// rerun::Points2D({{0.0f, 0.0f}, {0.0f, 1.0f}})
85 /// // By default, radii are interpreted as world-space units.
86 /// .with_radii({0.1f, 0.3f})
87 /// .with_colors(rerun::Color(0, 0, 255))
88 /// );
89 ///
90 /// // Two red points with ui point radii of 40 and 60.
91 /// // UI points are independent of zooming in Views, but are sensitive to the application UI scaling.
92 /// // For 100% ui scaling, UI points are equal to pixels.
93 /// rec.log(
94 /// "ui_points",
95 /// rerun::Points2D({{1.0f, 0.0f}, {1.0f, 1.0f}})
96 /// // rerun::Radius::ui_points produces radii that the viewer interprets as given in ui points.
97 /// .with_radii({
98 /// rerun::Radius::ui_points(40.0f),
99 /// rerun::Radius::ui_points(60.0f),
100 /// })
101 /// .with_colors(rerun::Color(255, 0, 0))
102 /// );
103 ///
104 /// // TODO(#5521): log VisualBounds2D
105 /// }
106 /// ```
107 struct Points2D {
108 /// All the 2D positions at which the point cloud shows points.
110
111 /// Optional radii for the points, effectively turning them into circles.
112 std::optional<Collection<rerun::components::Radius>> radii;
113
114 /// Optional colors for the points.
115 std::optional<Collection<rerun::components::Color>> colors;
116
117 /// Optional text labels for the points.
118 ///
119 /// If there's a single label present, it will be placed at the center of the entity.
120 /// Otherwise, each instance will have its own label.
121 std::optional<Collection<rerun::components::Text>> labels;
122
123 /// Optional choice of whether the text labels should be shown by default.
124 std::optional<rerun::components::ShowLabels> show_labels;
125
126 /// An optional floating point value that specifies the 2D drawing order.
127 ///
128 /// Objects with higher values are drawn on top of those with lower values.
129 std::optional<rerun::components::DrawOrder> draw_order;
130
131 /// Optional class Ids for the points.
132 ///
133 /// The `components::ClassId` provides colors and labels if not specified explicitly.
134 std::optional<Collection<rerun::components::ClassId>> class_ids;
135
136 /// Optional keypoint IDs for the points, identifying them within a class.
137 ///
138 /// If keypoint IDs are passed in but no `components::ClassId`s were specified, the `components::ClassId` will
139 /// default to 0.
140 /// This is useful to identify points within a single classification (which is identified
141 /// with `class_id`).
142 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
143 /// detected skeleton.
144 std::optional<Collection<rerun::components::KeypointId>> keypoint_ids;
145
146 public:
147 static constexpr const char IndicatorComponentName[] = "rerun.components.Points2DIndicator";
148
149 /// Indicator component, used to identify the archetype when converting to a list of components.
151
152 public:
153 Points2D() = default;
154 Points2D(Points2D&& other) = default;
155
157 : positions(std::move(_positions)) {}
158
159 /// Optional radii for the points, effectively turning them into circles.
161 radii = std::move(_radii);
162 // See: https://github.com/rerun-io/rerun/issues/4027
163 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
164 }
165
166 /// Optional colors for the points.
168 colors = std::move(_colors);
169 // See: https://github.com/rerun-io/rerun/issues/4027
170 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
171 }
172
173 /// Optional text labels for the points.
174 ///
175 /// If there's a single label present, it will be placed at the center of the entity.
176 /// Otherwise, each instance will have its own label.
178 labels = std::move(_labels);
179 // See: https://github.com/rerun-io/rerun/issues/4027
180 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
181 }
182
183 /// Optional choice of whether the text labels should be shown by default.
185 show_labels = std::move(_show_labels);
186 // See: https://github.com/rerun-io/rerun/issues/4027
187 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
188 }
189
190 /// An optional floating point value that specifies the 2D drawing order.
191 ///
192 /// Objects with higher values are drawn on top of those with lower values.
194 draw_order = std::move(_draw_order);
195 // See: https://github.com/rerun-io/rerun/issues/4027
196 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
197 }
198
199 /// Optional class Ids for the points.
200 ///
201 /// The `components::ClassId` provides colors and labels if not specified explicitly.
203 class_ids = std::move(_class_ids);
204 // See: https://github.com/rerun-io/rerun/issues/4027
205 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
206 }
207
208 /// Optional keypoint IDs for the points, identifying them within a class.
209 ///
210 /// If keypoint IDs are passed in but no `components::ClassId`s were specified, the `components::ClassId` will
211 /// default to 0.
212 /// This is useful to identify points within a single classification (which is identified
213 /// with `class_id`).
214 /// E.g. the classification might be 'Person' and the keypoints refer to joints on a
215 /// detected skeleton.
217 keypoint_ids = std::move(_keypoint_ids);
218 // See: https://github.com/rerun-io/rerun/issues/4027
219 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
220 }
221 };
222
223} // namespace rerun::archetypes
224
225namespace rerun {
226 /// \private
227 template <typename T>
228 struct AsComponents;
229
230 /// \private
231 template <>
232 struct AsComponents<archetypes::Points2D> {
233 /// Serialize all set component batches.
234 static Result<std::vector<ComponentBatch>> serialize(const archetypes::Points2D& archetype);
235 };
236} // 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:77
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Archetype: A 2D point cloud with positions and optional colors, radii, labels, etc.
Definition points2d.hpp:107
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the points, effectively turning them into circles.
Definition points2d.hpp:112
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the points.
Definition points2d.hpp:115
Points2D with_show_labels(rerun::components::ShowLabels _show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition points2d.hpp:184
Points2D with_keypoint_ids(Collection< rerun::components::KeypointId > _keypoint_ids) &&
Optional keypoint IDs for the points, identifying them within a class.
Definition points2d.hpp:216
Collection< rerun::components::Position2D > positions
All the 2D positions at which the point cloud shows points.
Definition points2d.hpp:109
Points2D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional class Ids for the points.
Definition points2d.hpp:202
Points2D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the points.
Definition points2d.hpp:177
std::optional< Collection< rerun::components::KeypointId > > keypoint_ids
Optional keypoint IDs for the points, identifying them within a class.
Definition points2d.hpp:144
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional class Ids for the points.
Definition points2d.hpp:134
std::optional< rerun::components::ShowLabels > show_labels
Optional choice of whether the text labels should be shown by default.
Definition points2d.hpp:124
Points2D with_draw_order(rerun::components::DrawOrder _draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition points2d.hpp:193
std::optional< rerun::components::DrawOrder > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition points2d.hpp:129
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the points.
Definition points2d.hpp:121
Points2D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the points, effectively turning them into circles.
Definition points2d.hpp:160
Points2D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the points.
Definition points2d.hpp:167
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