Rerun C++ SDK
Loading...
Searching...
No Matches
boxes2d.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/boxes2d.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/half_size2d.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**: 2D boxes with half-extents and optional center, colors etc.
27 ///
28 /// ## Example
29 ///
30 /// ### Simple 2D boxes
31 /// ![image](https://static.rerun.io/box2d_simple/ac4424f3cf747382867649610cbd749c45b2020b/full.png)
32 ///
33 /// ```cpp
34 /// #include <rerun.hpp>
35 ///
36 /// int main() {
37 /// const auto rec = rerun::RecordingStream("rerun_example_box2d");
38 /// rec.spawn().exit_on_failure();
39 ///
40 /// rec.log("simple", rerun::Boxes2D::from_mins_and_sizes({{-1.f, -1.f}}, {{2.f, 2.f}}));
41 /// }
42 /// ```
43 struct Boxes2D {
44 /// All half-extents that make up the batch of boxes.
46
47 /// Optional center positions of the boxes.
48 std::optional<Collection<rerun::components::Position2D>> centers;
49
50 /// Optional colors for the boxes.
51 std::optional<Collection<rerun::components::Color>> colors;
52
53 /// Optional radii for the lines that make up the boxes.
54 std::optional<Collection<rerun::components::Radius>> radii;
55
56 /// Optional text labels for the boxes.
57 ///
58 /// If there's a single label present, it will be placed at the center of the entity.
59 /// Otherwise, each instance will have its own label.
60 std::optional<Collection<rerun::components::Text>> labels;
61
62 /// Optional choice of whether the text labels should be shown by default.
63 std::optional<rerun::components::ShowLabels> show_labels;
64
65 /// An optional floating point value that specifies the 2D drawing order.
66 ///
67 /// Objects with higher values are drawn on top of those with lower values.
68 ///
69 /// The default for 2D boxes is 10.0.
70 std::optional<rerun::components::DrawOrder> draw_order;
71
72 /// Optional `components::ClassId`s for the boxes.
73 ///
74 /// The `components::ClassId` provides colors and labels if not specified explicitly.
75 std::optional<Collection<rerun::components::ClassId>> class_ids;
76
77 public:
78 static constexpr const char IndicatorComponentName[] = "rerun.components.Boxes2DIndicator";
79
80 /// Indicator component, used to identify the archetype when converting to a list of components.
82
83 public: // START of extensions from boxes2d_ext.cpp:
84 /// Creates new `Boxes2D` with `half_sizes` centered around the local origin.
86 Boxes2D boxes;
87 boxes.half_sizes = std::move(half_sizes);
88 return boxes;
89 }
90
91 /// Creates new `Boxes2D` with `centers` and `half_sizes`.
95 ) {
96 Boxes2D boxes;
97 boxes.half_sizes = std::move(half_sizes);
98 boxes.centers = std::move(centers);
99 return boxes;
100 }
101
102 /// Creates new `Boxes2D` with `half_sizes` created from (full) sizes.
103 ///
104 /// TODO(#3285): Does *not* preserve data as-is and instead creates half-sizes from the
105 /// input data.
106 static Boxes2D from_sizes(const std::vector<datatypes::Vec2D>& sizes);
107
108 /// Creates new `Boxes2D` with `centers` and `half_sizes` created from centers and (full)
109 /// sizes.
110 ///
111 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
112 /// from the input data.
114 Collection<components::Position2D> centers, const std::vector<datatypes::Vec2D>& sizes
115 ) {
116 Boxes2D boxes = from_sizes(std::move(sizes));
117 boxes.centers = std::move(centers);
118 return boxes;
119 }
120
121 /// Creates new `Boxes2D` with `half_sizes` and `centers` created from minimums and (full)
122 /// sizes.
123 ///
124 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
125 /// from the input data.
127 const std::vector<datatypes::Vec2D>& mins, const std::vector<datatypes::Vec2D>& sizes
128 );
129
130 // END of extensions from boxes2d_ext.cpp, start of generated code:
131
132 public:
133 Boxes2D() = default;
134 Boxes2D(Boxes2D&& other) = default;
135
136 /// Optional center positions of the boxes.
138 centers = std::move(_centers);
139 // See: https://github.com/rerun-io/rerun/issues/4027
140 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
141 }
142
143 /// Optional colors for the boxes.
145 colors = std::move(_colors);
146 // See: https://github.com/rerun-io/rerun/issues/4027
147 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
148 }
149
150 /// Optional radii for the lines that make up the boxes.
152 radii = std::move(_radii);
153 // See: https://github.com/rerun-io/rerun/issues/4027
154 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
155 }
156
157 /// Optional text labels for the boxes.
158 ///
159 /// If there's a single label present, it will be placed at the center of the entity.
160 /// Otherwise, each instance will have its own label.
162 labels = std::move(_labels);
163 // See: https://github.com/rerun-io/rerun/issues/4027
164 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
165 }
166
167 /// Optional choice of whether the text labels should be shown by default.
169 show_labels = std::move(_show_labels);
170 // See: https://github.com/rerun-io/rerun/issues/4027
171 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
172 }
173
174 /// An optional floating point value that specifies the 2D drawing order.
175 ///
176 /// Objects with higher values are drawn on top of those with lower values.
177 ///
178 /// The default for 2D boxes is 10.0.
180 draw_order = std::move(_draw_order);
181 // See: https://github.com/rerun-io/rerun/issues/4027
182 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
183 }
184
185 /// Optional `components::ClassId`s for the boxes.
186 ///
187 /// The `components::ClassId` provides colors and labels if not specified explicitly.
189 class_ids = std::move(_class_ids);
190 // See: https://github.com/rerun-io/rerun/issues/4027
191 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
192 }
193 };
194
195} // namespace rerun::archetypes
196
197namespace rerun {
198 /// \private
199 template <typename T>
200 struct AsComponents;
201
202 /// \private
203 template <>
204 struct AsComponents<archetypes::Boxes2D> {
205 /// Serialize all set component batches.
206 static Result<std::vector<ComponentBatch>> serialize(const archetypes::Boxes2D& archetype);
207 };
208} // 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: 2D boxes with half-extents and optional center, colors etc.
Definition boxes2d.hpp:43
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the boxes.
Definition boxes2d.hpp:60
Boxes2D with_radii(Collection< rerun::components::Radius > _radii) &&
Optional radii for the lines that make up the boxes.
Definition boxes2d.hpp:151
std::optional< Collection< rerun::components::Color > > colors
Optional colors for the boxes.
Definition boxes2d.hpp:51
Boxes2D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the boxes.
Definition boxes2d.hpp:144
Collection< rerun::components::HalfSize2D > half_sizes
All half-extents that make up the batch of boxes.
Definition boxes2d.hpp:45
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the lines that make up the boxes.
Definition boxes2d.hpp:54
Boxes2D with_show_labels(rerun::components::ShowLabels _show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition boxes2d.hpp:168
Boxes2D with_draw_order(rerun::components::DrawOrder _draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition boxes2d.hpp:179
std::optional< rerun::components::ShowLabels > show_labels
Optional choice of whether the text labels should be shown by default.
Definition boxes2d.hpp:63
static Boxes2D from_centers_and_sizes(Collection< components::Position2D > centers, const std::vector< datatypes::Vec2D > &sizes)
Creates new Boxes2D with centers and half_sizes created from centers and (full) sizes.
Definition boxes2d.hpp:113
Boxes2D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional components::ClassIds for the boxes.
Definition boxes2d.hpp:188
static Boxes2D from_sizes(const std::vector< datatypes::Vec2D > &sizes)
Creates new Boxes2D with half_sizes created from (full) sizes.
static Boxes2D from_centers_and_half_sizes(Collection< components::Position2D > centers, Collection< components::HalfSize2D > half_sizes)
Creates new Boxes2D with centers and half_sizes.
Definition boxes2d.hpp:92
std::optional< Collection< rerun::components::Position2D > > centers
Optional center positions of the boxes.
Definition boxes2d.hpp:48
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional components::ClassIds for the boxes.
Definition boxes2d.hpp:75
Boxes2D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the boxes.
Definition boxes2d.hpp:161
Boxes2D with_centers(Collection< rerun::components::Position2D > _centers) &&
Optional center positions of the boxes.
Definition boxes2d.hpp:137
std::optional< rerun::components::DrawOrder > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition boxes2d.hpp:70
static Boxes2D from_half_sizes(Collection< components::HalfSize2D > half_sizes)
Creates new Boxes2D with half_sizes centered around the local origin.
Definition boxes2d.hpp:85
static Boxes2D from_mins_and_sizes(const std::vector< datatypes::Vec2D > &mins, const std::vector< datatypes::Vec2D > &sizes)
Creates new Boxes2D with half_sizes and centers created from minimums and (full) sizes.
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