Rerun C++ SDK
Loading...
Searching...
No Matches
series_point.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/series_point.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/marker_shape.hpp"
11#include "../components/marker_size.hpp"
12#include "../components/name.hpp"
13#include "../indicator_component.hpp"
14#include "../result.hpp"
15
16#include <cstdint>
17#include <optional>
18#include <utility>
19#include <vector>
20
21namespace rerun::archetypes {
22 /// **Archetype**: Define the style properties for a point series in a chart.
23 ///
24 /// This archetype only provides styling information and should be logged as static
25 /// when possible. The underlying data needs to be logged to the same entity-path using
26 /// `archetypes::Scalar`.
27 ///
28 /// ## Example
29 ///
30 /// ### Point series
31 /// ![image](https://static.rerun.io/series_point_style/82207a705da6c086b28ce161db1db9e8b12258b7/full.png)
32 ///
33 /// ```cpp
34 /// #include <rerun.hpp>
35 ///
36 /// #include <cmath>
37 ///
38 /// constexpr float TAU = 6.28318530717958647692528676655900577f;
39 ///
40 /// int main() {
41 /// const auto rec = rerun::RecordingStream("rerun_example_series_point_style");
42 /// rec.spawn().exit_on_failure();
43 ///
44 /// // Set up plot styling:
45 /// // They are logged static as they don't change over time and apply to all timelines.
46 /// // Log two point series under a shared root so that they show in the same plot by default.
47 /// rec.log_static(
48 /// "trig/sin",
49 /// rerun::SeriesPoint()
50 /// .with_color({255, 0, 0})
51 /// .with_name("sin(0.01t)")
52 /// .with_marker(rerun::components::MarkerShape::Circle)
53 /// .with_marker_size(4)
54 /// );
55 /// rec.log_static(
56 /// "trig/cos",
57 /// rerun::SeriesPoint()
58 /// .with_color({0, 255, 0})
59 /// .with_name("cos(0.01t)")
60 /// .with_marker(rerun::components::MarkerShape::Cross)
61 /// .with_marker_size(2)
62 /// );
63 ///
64 /// // Log the data on a timeline called "step".
65 /// for (int t = 0; t <static_cast<int>(TAU * 2.0 * 10.0); ++t) {
66 /// rec.set_time_sequence("step", t);
67 ///
68 /// rec.log("trig/sin", rerun::Scalar(sin(static_cast<double>(t) / 10.0)));
69 /// rec.log("trig/cos", rerun::Scalar(cos(static_cast<double>(t) / 10.0)));
70 /// }
71 /// }
72 /// ```
73 struct SeriesPoint {
74 /// Color for the corresponding series.
75 std::optional<ComponentBatch> color;
76
77 /// What shape to use to represent the point
78 std::optional<ComponentBatch> marker;
79
80 /// Display name of the series.
81 ///
82 /// Used in the legend.
83 std::optional<ComponentBatch> name;
84
85 /// Size of the marker.
86 std::optional<ComponentBatch> marker_size;
87
88 public:
89 static constexpr const char IndicatorComponentName[] =
90 "rerun.components.SeriesPointIndicator";
91
92 /// Indicator component, used to identify the archetype when converting to a list of components.
94 /// The name of the archetype as used in `ComponentDescriptor`s.
95 static constexpr const char ArchetypeName[] = "rerun.archetypes.SeriesPoint";
96
97 /// `ComponentDescriptor` for the `color` field.
98 static constexpr auto Descriptor_color = ComponentDescriptor(
100 );
101 /// `ComponentDescriptor` for the `marker` field.
102 static constexpr auto Descriptor_marker = ComponentDescriptor(
103 ArchetypeName, "marker",
105 );
106 /// `ComponentDescriptor` for the `name` field.
107 static constexpr auto Descriptor_name = ComponentDescriptor(
109 );
110 /// `ComponentDescriptor` for the `marker_size` field.
112 ArchetypeName, "marker_size",
114 );
115
116 public:
117 SeriesPoint() = default;
118 SeriesPoint(SeriesPoint&& other) = default;
119 SeriesPoint(const SeriesPoint& other) = default;
120 SeriesPoint& operator=(const SeriesPoint& other) = default;
121 SeriesPoint& operator=(SeriesPoint&& other) = default;
122
123 /// Update only some specific fields of a `SeriesPoint`.
125 return SeriesPoint();
126 }
127
128 /// Clear all the fields of a `SeriesPoint`.
130
131 /// Color for the corresponding series.
133 color = ComponentBatch::from_loggable(_color, Descriptor_color).value_or_throw();
134 return std::move(*this);
135 }
136
137 /// This method makes it possible to pack multiple `color` in a single component batch.
138 ///
139 /// This only makes sense when used in conjunction with `columns`. `with_color` should
140 /// be used when logging a single row's worth of data.
142 color = ComponentBatch::from_loggable(_color, Descriptor_color).value_or_throw();
143 return std::move(*this);
144 }
145
146 /// What shape to use to represent the point
148 marker = ComponentBatch::from_loggable(_marker, Descriptor_marker).value_or_throw();
149 return std::move(*this);
150 }
151
152 /// This method makes it possible to pack multiple `marker` in a single component batch.
153 ///
154 /// This only makes sense when used in conjunction with `columns`. `with_marker` should
155 /// be used when logging a single row's worth of data.
157 marker = ComponentBatch::from_loggable(_marker, Descriptor_marker).value_or_throw();
158 return std::move(*this);
159 }
160
161 /// Display name of the series.
162 ///
163 /// Used in the legend.
165 name = ComponentBatch::from_loggable(_name, Descriptor_name).value_or_throw();
166 return std::move(*this);
167 }
168
169 /// This method makes it possible to pack multiple `name` in a single component batch.
170 ///
171 /// This only makes sense when used in conjunction with `columns`. `with_name` should
172 /// be used when logging a single row's worth of data.
174 name = ComponentBatch::from_loggable(_name, Descriptor_name).value_or_throw();
175 return std::move(*this);
176 }
177
178 /// Size of the marker.
181 .value_or_throw();
182 return std::move(*this);
183 }
184
185 /// This method makes it possible to pack multiple `marker_size` in a single component batch.
186 ///
187 /// This only makes sense when used in conjunction with `columns`. `with_marker_size` should
188 /// be used when logging a single row's worth of data.
191 ) && {
193 .value_or_throw();
194 return std::move(*this);
195 }
196
197 /// Partitions the component data into multiple sub-batches.
198 ///
199 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
200 /// instead, via `ComponentBatch::partitioned`.
201 ///
202 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
203 ///
204 /// The specified `lengths` must sum to the total length of the component batch.
206
207 /// Partitions the component data into unit-length sub-batches.
208 ///
209 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
210 /// where `n` is automatically guessed.
212 };
213
214} // namespace rerun::archetypes
215
216namespace rerun {
217 /// \private
218 template <typename T>
219 struct AsComponents;
220
221 /// \private
222 template <>
223 struct AsComponents<archetypes::SeriesPoint> {
224 /// Serialize all set component batches.
225 static Result<Collection<ComponentBatch>> as_batches(
226 const archetypes::SeriesPoint& archetype
227 );
228 };
229} // 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
MarkerShape
Component: The visual appearance of a point in e.g. a 2D plot.
Definition marker_shape.hpp:25
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
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: Define the style properties for a point series in a chart.
Definition series_point.hpp:73
static constexpr auto Descriptor_marker
ComponentDescriptor for the marker field.
Definition series_point.hpp:102
std::optional< ComponentBatch > name
Display name of the series.
Definition series_point.hpp:83
static SeriesPoint update_fields()
Update only some specific fields of a SeriesPoint.
Definition series_point.hpp:124
SeriesPoint with_marker_size(const rerun::components::MarkerSize &_marker_size) &&
Size of the marker.
Definition series_point.hpp:179
std::optional< ComponentBatch > marker_size
Size of the marker.
Definition series_point.hpp:86
std::optional< ComponentBatch > marker
What shape to use to represent the point.
Definition series_point.hpp:78
SeriesPoint with_many_marker(const Collection< rerun::components::MarkerShape > &_marker) &&
This method makes it possible to pack multiple marker in a single component batch.
Definition series_point.hpp:156
std::optional< ComponentBatch > color
Color for the corresponding series.
Definition series_point.hpp:75
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static constexpr auto Descriptor_name
ComponentDescriptor for the name field.
Definition series_point.hpp:107
SeriesPoint with_many_name(const Collection< rerun::components::Name > &_name) &&
This method makes it possible to pack multiple name in a single component batch.
Definition series_point.hpp:173
SeriesPoint with_color(const rerun::components::Color &_color) &&
Color for the corresponding series.
Definition series_point.hpp:132
static constexpr auto Descriptor_color
ComponentDescriptor for the color field.
Definition series_point.hpp:98
SeriesPoint with_many_color(const Collection< rerun::components::Color > &_color) &&
This method makes it possible to pack multiple color in a single component batch.
Definition series_point.hpp:141
static SeriesPoint clear_fields()
Clear all the fields of a SeriesPoint.
SeriesPoint with_name(const rerun::components::Name &_name) &&
Display name of the series.
Definition series_point.hpp:164
SeriesPoint with_marker(const rerun::components::MarkerShape &_marker) &&
What shape to use to represent the point.
Definition series_point.hpp:147
static constexpr auto Descriptor_marker_size
ComponentDescriptor for the marker_size field.
Definition series_point.hpp:111
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
SeriesPoint with_many_marker_size(const Collection< rerun::components::MarkerSize > &_marker_size) &&
This method makes it possible to pack multiple marker_size in a single component batch.
Definition series_point.hpp:189
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition series_point.hpp:95
Component: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition color.hpp:18
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32
Component: Radius of a marker of a point in e.g. a 2D plot, measured in UI points.
Definition marker_size.hpp:15
Component: A display name, typically for an entity or a item like a plot series.
Definition name.hpp:17