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 /// Whether the text labels should be shown.
63 ///
64 /// If not set, labels will automatically appear when there is exactly one label for this entity
65 /// or the number of instances on this entity is under a certain threshold.
66 std::optional<ComponentBatch> show_labels;
67
68 /// Optional radii for nodes.
69 std::optional<ComponentBatch> radii;
70
71 public:
72 static constexpr const char IndicatorComponentName[] =
73 "rerun.components.GraphNodesIndicator";
74
75 /// Indicator component, used to identify the archetype when converting to a list of components.
77 /// The name of the archetype as used in `ComponentDescriptor`s.
78 static constexpr const char ArchetypeName[] = "rerun.archetypes.GraphNodes";
79
80 /// `ComponentDescriptor` for the `node_ids` field.
82 ArchetypeName, "node_ids",
84 );
85 /// `ComponentDescriptor` for the `positions` field.
87 ArchetypeName, "positions",
89 );
90 /// `ComponentDescriptor` for the `colors` field.
91 static constexpr auto Descriptor_colors = ComponentDescriptor(
93 );
94 /// `ComponentDescriptor` for the `labels` field.
95 static constexpr auto Descriptor_labels = ComponentDescriptor(
97 );
98 /// `ComponentDescriptor` for the `show_labels` field.
100 ArchetypeName, "show_labels",
102 );
103 /// `ComponentDescriptor` for the `radii` field.
104 static constexpr auto Descriptor_radii = ComponentDescriptor(
106 );
107
108 public:
109 GraphNodes() = default;
110 GraphNodes(GraphNodes&& other) = default;
111 GraphNodes(const GraphNodes& other) = default;
112 GraphNodes& operator=(const GraphNodes& other) = default;
113 GraphNodes& operator=(GraphNodes&& other) = default;
114
116 : node_ids(ComponentBatch::from_loggable(std::move(_node_ids), Descriptor_node_ids)
117 .value_or_throw()) {}
118
119 /// Update only some specific fields of a `GraphNodes`.
121 return GraphNodes();
122 }
123
124 /// Clear all the fields of a `GraphNodes`.
126
127 /// A list of node IDs.
129 node_ids =
130 ComponentBatch::from_loggable(_node_ids, Descriptor_node_ids).value_or_throw();
131 return std::move(*this);
132 }
133
134 /// Optional center positions of the nodes.
136 positions =
137 ComponentBatch::from_loggable(_positions, Descriptor_positions).value_or_throw();
138 return std::move(*this);
139 }
140
141 /// Optional colors for the boxes.
143 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
144 return std::move(*this);
145 }
146
147 /// Optional text labels for the node.
149 labels = ComponentBatch::from_loggable(_labels, Descriptor_labels).value_or_throw();
150 return std::move(*this);
151 }
152
153 /// Whether the text labels should be shown.
154 ///
155 /// If not set, labels will automatically appear when there is exactly one label for this entity
156 /// or the number of instances on this entity is under a certain threshold.
159 .value_or_throw();
160 return std::move(*this);
161 }
162
163 /// This method makes it possible to pack multiple `show_labels` in a single component batch.
164 ///
165 /// This only makes sense when used in conjunction with `columns`. `with_show_labels` should
166 /// be used when logging a single row's worth of data.
169 ) && {
171 .value_or_throw();
172 return std::move(*this);
173 }
174
175 /// Optional radii for nodes.
177 radii = ComponentBatch::from_loggable(_radii, Descriptor_radii).value_or_throw();
178 return std::move(*this);
179 }
180
181 /// Partitions the component data into multiple sub-batches.
182 ///
183 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
184 /// instead, via `ComponentBatch::partitioned`.
185 ///
186 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
187 ///
188 /// The specified `lengths` must sum to the total length of the component batch.
190
191 /// Partitions the component data into unit-length sub-batches.
192 ///
193 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
194 /// where `n` is automatically guessed.
196 };
197
198} // namespace rerun::archetypes
199
200namespace rerun {
201 /// \private
202 template <typename T>
203 struct AsComponents;
204
205 /// \private
206 template <>
207 struct AsComponents<archetypes::GraphNodes> {
208 /// Serialize all set component batches.
209 static Result<Collection<ComponentBatch>> as_batches(const archetypes::GraphNodes& archetype
210 );
211 };
212} // 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)
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:95
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:91
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:99
GraphNodes with_show_labels(const rerun::components::ShowLabels &_show_labels) &&
Whether the text labels should be shown.
Definition graph_nodes.hpp:157
static GraphNodes update_fields()
Update only some specific fields of a GraphNodes.
Definition graph_nodes.hpp:120
static constexpr auto Descriptor_positions
ComponentDescriptor for the positions field.
Definition graph_nodes.hpp:86
static constexpr auto Descriptor_node_ids
ComponentDescriptor for the node_ids field.
Definition graph_nodes.hpp:81
std::optional< ComponentBatch > radii
Optional radii for nodes.
Definition graph_nodes.hpp:69
std::optional< ComponentBatch > colors
Optional colors for the boxes.
Definition graph_nodes.hpp:57
std::optional< ComponentBatch > show_labels
Whether the text labels should be shown.
Definition graph_nodes.hpp:66
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:148
GraphNodes with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the boxes.
Definition graph_nodes.hpp:142
static constexpr auto Descriptor_radii
ComponentDescriptor for the radii field.
Definition graph_nodes.hpp:104
GraphNodes with_positions(const Collection< rerun::components::Position2D > &_positions) &&
Optional center positions of the nodes.
Definition graph_nodes.hpp:135
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:176
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:167
GraphNodes with_node_ids(const Collection< rerun::components::GraphNode > &_node_ids) &&
A list of node IDs.
Definition graph_nodes.hpp:128
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition graph_nodes.hpp:78
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