Rerun C++ SDK
Loading...
Searching...
No Matches
boxes2d.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/boxes2d.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/half_sizes2d.hpp"
12#include "../components/instance_key.hpp"
13#include "../components/position2d.hpp"
14#include "../components/radius.hpp"
15#include "../components/text.hpp"
16#include "../data_cell.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, rotations, rotations, 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 /// // Log an extra rect to set the view bounds
43 /// rec.log("bounds", rerun::Boxes2D::from_sizes({{4.f, 3.f}}));
44 /// }
45 /// ```
46 struct Boxes2D {
47 /// All half-extents that make up the batch of boxes.
49
50 /// Optional center positions of the boxes.
51 std::optional<Collection<rerun::components::Position2D>> centers;
52
53 /// Optional colors for the boxes.
54 std::optional<Collection<rerun::components::Color>> colors;
55
56 /// Optional radii for the lines that make up the boxes.
57 std::optional<Collection<rerun::components::Radius>> radii;
58
59 /// Optional text labels for the boxes.
60 std::optional<Collection<rerun::components::Text>> labels;
61
62 /// An optional floating point value that specifies the 2D drawing order.
63 ///
64 /// Objects with higher values are drawn on top of those with lower values.
65 ///
66 /// The default for 2D boxes is 10.0.
67 std::optional<rerun::components::DrawOrder> draw_order;
68
69 /// Optional `ClassId`s for the boxes.
70 ///
71 /// The class ID provides colors and labels if not specified explicitly.
72 std::optional<Collection<rerun::components::ClassId>> class_ids;
73
74 /// Unique identifiers for each individual boxes in the batch.
75 std::optional<Collection<rerun::components::InstanceKey>> instance_keys;
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:
84 // Extensions to generated type defined in 'boxes2d_ext.cpp'
85
86 /// Creates new `Boxes2D` with `half_sizes` centered around the local origin.
88 Boxes2D boxes;
89 boxes.half_sizes = std::move(half_sizes);
90 return boxes;
91 }
92
93 /// Creates new `Boxes2D` with `centers` and `half_sizes`.
97 ) {
98 Boxes2D boxes;
99 boxes.half_sizes = std::move(half_sizes);
100 boxes.centers = std::move(centers);
101 return boxes;
102 }
103
104 /// Creates new `Boxes2D` with `half_sizes` created from (full) sizes.
105 ///
106 /// TODO(#3285): Does *not* preserve data as-is and instead creates half-sizes from the
107 /// input data.
108 static Boxes2D from_sizes(const std::vector<datatypes::Vec2D>& sizes);
109
110 /// Creates new `Boxes2D` with `centers` and `half_sizes` created from centers and (full)
111 /// sizes.
112 ///
113 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
114 /// from the input data.
116 Collection<components::Position2D> centers, const std::vector<datatypes::Vec2D>& sizes
117 ) {
118 Boxes2D boxes = from_sizes(std::move(sizes));
119 boxes.centers = std::move(centers);
120 return boxes;
121 }
122
123 /// Creates new `Boxes2D` with `half_sizes` and `centers` created from minimums and (full)
124 /// sizes.
125 ///
126 /// TODO(#3285): Does *not* preserve data as-is and instead creates centers and half-sizes
127 /// from the input data.
129 const std::vector<datatypes::Vec2D>& mins, const std::vector<datatypes::Vec2D>& sizes
130 );
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 RERUN_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 RERUN_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 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
155 }
156
157 /// Optional text labels for the boxes.
159 labels = std::move(_labels);
160 // See: https://github.com/rerun-io/rerun/issues/4027
161 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
162 }
163
164 /// An optional floating point value that specifies the 2D drawing order.
165 ///
166 /// Objects with higher values are drawn on top of those with lower values.
167 ///
168 /// The default for 2D boxes is 10.0.
170 draw_order = std::move(_draw_order);
171 // See: https://github.com/rerun-io/rerun/issues/4027
172 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
173 }
174
175 /// Optional `ClassId`s for the boxes.
176 ///
177 /// The class ID provides colors and labels if not specified explicitly.
179 class_ids = std::move(_class_ids);
180 // See: https://github.com/rerun-io/rerun/issues/4027
181 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
182 }
183
184 /// Unique identifiers for each individual boxes in the batch.
186 instance_keys = std::move(_instance_keys);
187 // See: https://github.com/rerun-io/rerun/issues/4027
188 RERUN_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
189 }
190
191 /// Returns the number of primary instances of this archetype.
192 size_t num_instances() const {
193 return half_sizes.size();
194 }
195 };
196
197} // namespace rerun::archetypes
198
199namespace rerun {
200 /// \private
201 template <typename T>
202 struct AsComponents;
203
204 /// \private
205 template <>
206 struct AsComponents<archetypes::Boxes2D> {
207 /// Serialize all set component batches.
208 static Result<std::vector<DataCell>> serialize(const archetypes::Boxes2D& archetype);
209 };
210} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:47
size_t size() const
Returns the number of instances in this collection.
Definition collection.hpp:254
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:66
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Archetype: 2D boxes with half-extents and optional center, rotations, rotations, colors etc.
Definition boxes2d.hpp:46
Boxes2D with_instance_keys(Collection< rerun::components::InstanceKey > _instance_keys) &&
Unique identifiers for each individual boxes in the batch.
Definition boxes2d.hpp:185
Collection< rerun::components::HalfSizes2D > half_sizes
All half-extents that make up the batch of boxes.
Definition boxes2d.hpp:48
static Boxes2D from_half_sizes(Collection< components::HalfSizes2D > half_sizes)
Creates new Boxes2D with half_sizes centered around the local origin.
Definition boxes2d.hpp:87
std::optional< Collection< rerun::components::Text > > labels
Optional text labels for the boxes.
Definition boxes2d.hpp:60
std::optional< Collection< rerun::components::InstanceKey > > instance_keys
Unique identifiers for each individual boxes in the batch.
Definition boxes2d.hpp:75
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:54
Boxes2D with_colors(Collection< rerun::components::Color > _colors) &&
Optional colors for the boxes.
Definition boxes2d.hpp:144
size_t num_instances() const
Returns the number of primary instances of this archetype.
Definition boxes2d.hpp:192
std::optional< Collection< rerun::components::Radius > > radii
Optional radii for the lines that make up the boxes.
Definition boxes2d.hpp:57
Boxes2D with_draw_order(rerun::components::DrawOrder _draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition boxes2d.hpp:169
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:115
static Boxes2D from_centers_and_half_sizes(Collection< components::Position2D > centers, Collection< components::HalfSizes2D > half_sizes)
Creates new Boxes2D with centers and half_sizes.
Definition boxes2d.hpp:94
Boxes2D with_class_ids(Collection< rerun::components::ClassId > _class_ids) &&
Optional ClassIds for the boxes.
Definition boxes2d.hpp:178
static Boxes2D from_sizes(const std::vector< datatypes::Vec2D > &sizes)
Creates new Boxes2D with half_sizes created from (full) sizes.
std::optional< Collection< rerun::components::Position2D > > centers
Optional center positions of the boxes.
Definition boxes2d.hpp:51
std::optional< Collection< rerun::components::ClassId > > class_ids
Optional ClassIds for the boxes.
Definition boxes2d.hpp:72
Boxes2D with_labels(Collection< rerun::components::Text > _labels) &&
Optional text labels for the boxes.
Definition boxes2d.hpp:158
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:67
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 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