Rerun C++ SDK
Loading...
Searching...
No Matches
graph_nodes.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/graph_nodes.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/color.hpp"
10#include "../components/graph_node.hpp"
11#include "../components/position2d.hpp"
12#include "../components/radius.hpp"
13#include "../components/show_labels.hpp"
14#include "../components/text.hpp"
15#include "../indicator_component.hpp"
16#include "../result.hpp"
17
18#include <cstdint>
19#include <optional>
20#include <utility>
21#include <vector>
22
23namespace rerun::archetypes {
24 /// **Archetype**: A list of nodes in a graph with optional labels, colors, etc.
25 ///
26 /// ## Example
27 ///
28 /// ### Simple directed graph
29 /// ![image](https://static.rerun.io/graph_directed/ca29a37b65e1e0b6482251dce401982a0bc568fa/full.png)
30 ///
31 /// ```cpp
32 /// #include <rerun.hpp>
33 ///
34 /// int main() {
35 /// const auto rec = rerun::RecordingStream("rerun_example_graph_directed");
36 /// rec.spawn().exit_on_failure();
37 ///
38 /// rec.log(
39 /// "simple",
40 /// rerun::GraphNodes({"a", "b", "c"})
41 /// .with_positions({{0.0, 100.0}, {-100.0, 0.0}, {100.0, 0.0}})
42 /// .with_labels({"A", "B", "C"}),
43 /// rerun::GraphEdges({{"a", "b"}, {"b", "c"}, {"c", "a"}})
44 /// // Graphs are undirected by default.
45 /// .with_graph_type(rerun::components::GraphType::Directed)
46 /// );
47 /// }
48 /// ```
49 struct GraphNodes {
50 /// A list of node IDs.
51 std::optional<ComponentBatch> node_ids;
52
53 /// Optional center positions of the nodes.
54 std::optional<ComponentBatch> positions;
55
56 /// Optional colors for the boxes.
57 std::optional<ComponentBatch> colors;
58
59 /// Optional text labels for the node.
60 std::optional<ComponentBatch> labels;
61
62 /// Optional choice of whether the text labels should be shown by default.
63 std::optional<ComponentBatch> show_labels;
64
65 /// Optional radii for nodes.
66 std::optional<ComponentBatch> radii;
67
68 public:
69 static constexpr const char IndicatorComponentName[] =
70 "rerun.components.GraphNodesIndicator";
71
72 /// Indicator component, used to identify the archetype when converting to a list of components.
74 /// The name of the archetype as used in `ComponentDescriptor`s.
75 static constexpr const char ArchetypeName[] = "rerun.archetypes.GraphNodes";
76
77 /// `ComponentDescriptor` for the `node_ids` field.
79 ArchetypeName, "node_ids",
81 );
82 /// `ComponentDescriptor` for the `positions` field.
84 ArchetypeName, "positions",
86 );
87 /// `ComponentDescriptor` for the `colors` field.
88 static constexpr auto Descriptor_colors = ComponentDescriptor(
90 );
91 /// `ComponentDescriptor` for the `labels` field.
92 static constexpr auto Descriptor_labels = ComponentDescriptor(
94 );
95 /// `ComponentDescriptor` for the `show_labels` field.
97 ArchetypeName, "show_labels",
99 );
100 /// `ComponentDescriptor` for the `radii` field.
101 static constexpr auto Descriptor_radii = ComponentDescriptor(
103 );
104
105 public:
106 GraphNodes() = default;
107 GraphNodes(GraphNodes&& other) = default;
108 GraphNodes(const GraphNodes& other) = default;
109 GraphNodes& operator=(const GraphNodes& other) = default;
110 GraphNodes& operator=(GraphNodes&& other) = default;
111
113 : node_ids(ComponentBatch::from_loggable(std::move(_node_ids), Descriptor_node_ids)
114 .value_or_throw()) {}
115
116 /// Update only some specific fields of a `GraphNodes`.
118 return GraphNodes();
119 }
120
121 /// Clear all the fields of a `GraphNodes`.
123
124 /// A list of node IDs.
126 node_ids =
127 ComponentBatch::from_loggable(_node_ids, Descriptor_node_ids).value_or_throw();
128 return std::move(*this);
129 }
130
131 /// Optional center positions of the nodes.
133 positions =
134 ComponentBatch::from_loggable(_positions, Descriptor_positions).value_or_throw();
135 return std::move(*this);
136 }
137
138 /// Optional colors for the boxes.
140 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
141 return std::move(*this);
142 }
143
144 /// Optional text labels for the node.
146 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
147 return std::move(*this);
148 }
149
150 /// Optional choice of whether the text labels should be shown by default.
153 .value_or_throw();
154 return std::move(*this);
155 }
156
157 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
158 ///
159 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
160 /// be used when logging a single row's worth of data.
163 ) && {
165 .value_or_throw();
166 return std::move(*this);
167 }
168
169 /// Optional radii for nodes.
171 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
172 return std::move(*this);
173 }
174
175 /// Partitions the component data into multiple sub-batches.
176 ///
177 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
178 /// instead, via `ComponentBatch::partitioned`.
179 ///
180 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
181 ///
182 /// The specified `lengths` must sum to the total length of the component batch.
184
185 /// Partitions the component data into unit-length sub-batches.
186 ///
187 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
188 /// where `n` is automatically guessed.
190 };
191
192} // namespace rerun::archetypes
193
194namespace rerun {
195 /// \private
196 template <typename T>
197 struct AsComponents;
198
199 /// \private
200 template <>
201 struct AsComponents<archetypes::GraphNodes> {
202 /// Serialize all set component batches.
203 static Result<Collection<ComponentBatch>> as_batches(const archetypes::GraphNodes& archetype
204 );
205 };
206} // 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 built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor=rerun::Loggable< T >::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:14
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: A list of nodes in a graph with optional labels, colors, etc.
Definition graph_nodes.hpp:49
static constexpr auto Descriptor_labels
ComponentDescriptor for the labels field.
Definition graph_nodes.hpp:92
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition graph_nodes.hpp:88
std::optional< ComponentBatch > labels
Optional text labels for the node.
Definition graph_nodes.hpp:60
static GraphNodes clear_fields()
Clear all the fields of a GraphNodes.
static constexpr auto Descriptor_show_labels
ComponentDescriptor for the show_labels field.
Definition graph_nodes.hpp:96
GraphNodes with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Optional choice of whether the text labels should be shown by default.
Definition graph_nodes.hpp:151
static GraphNodes update_fields()
Update only some specific fields of a GraphNodes.
Definition graph_nodes.hpp:117
static constexpr auto Descriptor_positions
ComponentDescriptor for the positions field.
Definition graph_nodes.hpp:83
static constexpr auto Descriptor_node_ids
ComponentDescriptor for the node_ids field.
Definition graph_nodes.hpp:78
std::optional< ComponentBatch > radii
Optional radii for nodes.
Definition graph_nodes.hpp:66
std::optional< ComponentBatch > colors
Optional colors for the boxes.
Definition graph_nodes.hpp:57
std::optional< ComponentBatch > show_labels
Optional choice of whether the text labels should be shown by default.
Definition graph_nodes.hpp:63
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
GraphNodes with_labels(const Collection< rerun::components::Text > &_labels) &&
Optional text labels for the node.
Definition graph_nodes.hpp:145
GraphNodes with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the boxes.
Definition graph_nodes.hpp:139
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition graph_nodes.hpp:101
GraphNodes with_positions(const Collection< rerun::components::Position2D > &_positions) &&
Optional center positions of the nodes.
Definition graph_nodes.hpp:132
std::optional< ComponentBatch > node_ids
A list of node IDs.
Definition graph_nodes.hpp:51
GraphNodes with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for nodes.
Definition graph_nodes.hpp:170
GraphNodes with_many_show_labels(const Collection< rerun::components::ShowLabels > &_show_labels) &&
This method makes it possible to pack multiple show_labels in a single component batch.
Definition graph_nodes.hpp:161
GraphNodes with_node_ids(const Collection< rerun::components::GraphNode > &_node_ids) &&
A list of node IDs.
Definition graph_nodes.hpp:125
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition graph_nodes.hpp:75
std::optional< ComponentBatch > positions
Optional center positions of the nodes.
Definition graph_nodes.hpp:54
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