Rerun C++ SDK
Loading...
Searching...
No Matches
plot_legend.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/blueprint/archetypes/plot_legend.def.rs".
3
4#pragma once
5
6#include "../../archetype_utils.hpp"
7#include "../../blueprint/components/corner2d.hpp"
8#include "../../collection.hpp"
9#include "../../component_batch.hpp"
10#include "../../component_column.hpp"
11#include "../../components/visible.hpp"
12#include "../../result.hpp"
13
14#include <cstdint>
15#include <optional>
16#include <utility>
17#include <vector>
18
19namespace rerun::blueprint::archetypes {
20 /// **Archetype**: Configuration for the legend of a plot.
21 ///
22 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
23 ///
24 struct PlotLegend {
25 /// To what corner the legend is aligned.
26 ///
27 /// Defaults to the right bottom corner.
28 std::optional<ComponentBatch> corner;
29
30 /// Whether the legend is shown at all.
31 ///
32 /// True by default.
33 std::optional<ComponentBatch> visible;
34
35 public:
36 /// The name of the archetype as used in `ComponentDescriptor`s.
37 static constexpr const char ArchetypeName[] = "rerun.blueprint.archetypes.PlotLegend";
38
39 /// `ComponentDescriptor` for the `corner` field.
40 static constexpr auto Descriptor_corner = ComponentDescriptor(
41 ArchetypeName, "PlotLegend:corner",
43 );
44 /// `ComponentDescriptor` for the `visible` field.
45 static constexpr auto Descriptor_visible = ComponentDescriptor(
47 );
48
49 public:
50 PlotLegend() = default;
51 PlotLegend(PlotLegend&& other) = default;
52 PlotLegend(const PlotLegend& other) = default;
53 PlotLegend& operator=(const PlotLegend& other) = default;
54 PlotLegend& operator=(PlotLegend&& other) = default;
55
56 /// Update only some specific fields of a `PlotLegend`.
58 return PlotLegend();
59 }
60
61 /// Clear all the fields of a `PlotLegend`.
63
64 /// To what corner the legend is aligned.
65 ///
66 /// Defaults to the right bottom corner.
67 PlotLegend with_corner(const rerun::blueprint::components::Corner2D& _corner) && {
68 corner = ComponentBatch::from_loggable(_corner, Descriptor_corner).value_or_throw();
69 return std::move(*this);
70 }
71
72 /// Whether the legend is shown at all.
73 ///
74 /// True by default.
76 visible = ComponentBatch::from_loggable(_visible, Descriptor_visible).value_or_throw();
77 return std::move(*this);
78 }
79
80 /// Partitions the component data into multiple sub-batches.
81 ///
82 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
83 /// instead, via `ComponentBatch::partitioned`.
84 ///
85 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
86 ///
87 /// The specified `lengths` must sum to the total length of the component batch.
89 return detail::partition_batches({&corner, &visible}, lengths_).value_or_throw();
90 }
91
92 /// Partitions the component data into unit-length sub-batches.
93 ///
94 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
95 /// where `n` is automatically guessed.
97 return detail::partition_batches_of_unit_length({&corner, &visible}).value_or_throw();
98 }
99 };
100
101} // namespace rerun::blueprint::archetypes
102
103namespace rerun {
104 /// \private
105 template <typename T>
106 struct AsComponents;
107
108 /// \private
109 template <>
110 struct AsComponents<blueprint::archetypes::PlotLegend> {
111 /// Serialize all set component batches.
112 static Result<Collection<ComponentBatch>> as_batches(
113 const blueprint::archetypes::PlotLegend& archetype
114 ) {
115 return detail::collect_batches({&archetype.corner, &archetype.visible});
116 }
117 };
118} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
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: Configuration for the legend of a plot.
Definition plot_legend.hpp:24
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition plot_legend.hpp:37
static PlotLegend update_fields()
Update only some specific fields of a PlotLegend.
Definition plot_legend.hpp:57
PlotLegend with_visible(const rerun::components::Visible &_visible) &&
Whether the legend is shown at all.
Definition plot_legend.hpp:75
static constexpr auto Descriptor_visible
ComponentDescriptor for the visible field.
Definition plot_legend.hpp:45
std::optional< ComponentBatch > corner
To what corner the legend is aligned.
Definition plot_legend.hpp:28
std::optional< ComponentBatch > visible
Whether the legend is shown at all.
Definition plot_legend.hpp:33
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition plot_legend.hpp:88
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition plot_legend.hpp:96
static constexpr auto Descriptor_corner
ComponentDescriptor for the corner field.
Definition plot_legend.hpp:40
static PlotLegend clear_fields()
Clear all the fields of a PlotLegend.
PlotLegend with_corner(const rerun::blueprint::components::Corner2D &_corner) &&
To what corner the legend is aligned.
Definition plot_legend.hpp:67
Component: Whether the container, view, entity or instance is currently visible.
Definition visible.hpp:14