Rerun C++ SDK
Loading...
Searching...
No Matches
series_line.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_line.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/aggregation_policy.hpp"
10#include "../components/color.hpp"
11#include "../components/name.hpp"
12#include "../components/stroke_width.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 line 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 /// ### Line series
31 /// ![image](https://static.rerun.io/series_line_style/d2616d98b1e46bdb85849b8669154fdf058e3453/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_line_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 lines series under a shared root so that they show in the same plot by default.
47 /// rec.log_static(
48 /// "trig/sin",
49 /// rerun::SeriesLine().with_color({255, 0, 0}).with_name("sin(0.01t)").with_width(2)
50 /// );
51 /// rec.log_static(
52 /// "trig/cos",
53 /// rerun::SeriesLine().with_color({0, 255, 0}).with_name("cos(0.01t)").with_width(4)
54 /// );
55 ///
56 /// // Log the data on a timeline called "step".
57 /// for (int t = 0; t <static_cast<int>(TAU * 2.0 * 100.0); ++t) {
58 /// rec.set_time_sequence("step", t);
59 ///
60 /// rec.log("trig/sin", rerun::Scalar(sin(static_cast<double>(t) / 100.0)));
61 /// rec.log("trig/cos", rerun::Scalar(cos(static_cast<double>(t) / 100.0)));
62 /// }
63 /// }
64 /// ```
65 struct SeriesLine {
66 /// Color for the corresponding series.
67 std::optional<ComponentBatch> color;
68
69 /// Stroke width for the corresponding series.
70 std::optional<ComponentBatch> width;
71
72 /// Display name of the series.
73 ///
74 /// Used in the legend.
75 std::optional<ComponentBatch> name;
76
77 /// Configures the zoom-dependent scalar aggregation.
78 ///
79 /// This is done only if steps on the X axis go below a single pixel,
80 /// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
81 /// (and readability) in such situations as it prevents overdraw.
82 std::optional<ComponentBatch> aggregation_policy;
83
84 public:
85 static constexpr const char IndicatorComponentName[] =
86 "rerun.components.SeriesLineIndicator";
87
88 /// Indicator component, used to identify the archetype when converting to a list of components.
90 /// The name of the archetype as used in `ComponentDescriptor`s.
91 static constexpr const char ArchetypeName[] = "rerun.archetypes.SeriesLine";
92
93 /// `ComponentDescriptor` for the `color` field.
94 static constexpr auto Descriptor_color = ComponentDescriptor(
96 );
97 /// `ComponentDescriptor` for the `width` field.
98 static constexpr auto Descriptor_width = ComponentDescriptor(
99 ArchetypeName, "width",
101 );
102 /// `ComponentDescriptor` for the `name` field.
103 static constexpr auto Descriptor_name = ComponentDescriptor(
105 );
106 /// `ComponentDescriptor` for the `aggregation_policy` field.
108 ArchetypeName, "aggregation_policy",
110 );
111
112 public:
113 SeriesLine() = default;
114 SeriesLine(SeriesLine&& other) = default;
115 SeriesLine(const SeriesLine& other) = default;
116 SeriesLine& operator=(const SeriesLine& other) = default;
117 SeriesLine& operator=(SeriesLine&& other) = default;
118
119 /// Update only some specific fields of a `SeriesLine`.
121 return SeriesLine();
122 }
123
124 /// Clear all the fields of a `SeriesLine`.
126
127 /// Color for the corresponding series.
129 color = ComponentBatch::from_loggable(_color, Descriptor_color).value_or_throw();
130 return std::move(*this);
131 }
132
133 /// This method makes it possible to pack multiple `color` in a single component batch.
134 ///
135 /// This only makes sense when used in conjunction with `columns`. `with_color` should
136 /// be used when logging a single row's worth of data.
138 color = ComponentBatch::from_loggable(_color, Descriptor_color).value_or_throw();
139 return std::move(*this);
140 }
141
142 /// Stroke width for the corresponding series.
144 width = ComponentBatch::from_loggable(_width, Descriptor_width).value_or_throw();
145 return std::move(*this);
146 }
147
148 /// This method makes it possible to pack multiple `width` in a single component batch.
149 ///
150 /// This only makes sense when used in conjunction with `columns`. `with_width` should
151 /// be used when logging a single row's worth of data.
153 width = ComponentBatch::from_loggable(_width, Descriptor_width).value_or_throw();
154 return std::move(*this);
155 }
156
157 /// Display name of the series.
158 ///
159 /// Used in the legend.
161 name = ComponentBatch::from_loggable(_name, Descriptor_name).value_or_throw();
162 return std::move(*this);
163 }
164
165 /// This method makes it possible to pack multiple `name` in a single component batch.
166 ///
167 /// This only makes sense when used in conjunction with `columns`. `with_name` should
168 /// be used when logging a single row's worth of data.
170 name = ComponentBatch::from_loggable(_name, Descriptor_name).value_or_throw();
171 return std::move(*this);
172 }
173
174 /// Configures the zoom-dependent scalar aggregation.
175 ///
176 /// This is done only if steps on the X axis go below a single pixel,
177 /// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
178 /// (and readability) in such situations as it prevents overdraw.
180 const rerun::components::AggregationPolicy& _aggregation_policy
181 ) && {
184 .value_or_throw();
185 return std::move(*this);
186 }
187
188 /// This method makes it possible to pack multiple `aggregation_policy` in a single component batch.
189 ///
190 /// This only makes sense when used in conjunction with `columns`. `with_aggregation_policy` should
191 /// be used when logging a single row's worth of data.
193 const Collection<rerun::components::AggregationPolicy>& _aggregation_policy
194 ) && {
197 .value_or_throw();
198 return std::move(*this);
199 }
200
201 /// Partitions the component data into multiple sub-batches.
202 ///
203 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
204 /// instead, via `ComponentBatch::partitioned`.
205 ///
206 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
207 ///
208 /// The specified `lengths` must sum to the total length of the component batch.
210
211 /// Partitions the component data into unit-length sub-batches.
212 ///
213 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
214 /// where `n` is automatically guessed.
216 };
217
218} // namespace rerun::archetypes
219
220namespace rerun {
221 /// \private
222 template <typename T>
223 struct AsComponents;
224
225 /// \private
226 template <>
227 struct AsComponents<archetypes::SeriesLine> {
228 /// Serialize all set component batches.
229 static Result<Collection<ComponentBatch>> as_batches(const archetypes::SeriesLine& archetype
230 );
231 };
232} // 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
AggregationPolicy
Component: Policy for aggregation of multiple scalar plot values.
Definition aggregation_policy.hpp:29
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 line series in a chart.
Definition series_line.hpp:65
SeriesLine with_width(const rerun::components::StrokeWidth &_width) &&
Stroke width for the corresponding series.
Definition series_line.hpp:143
static SeriesLine update_fields()
Update only some specific fields of a SeriesLine.
Definition series_line.hpp:120
std::optional< ComponentBatch > name
Display name of the series.
Definition series_line.hpp:75
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition series_line.hpp:91
std::optional< ComponentBatch > width
Stroke width for the corresponding series.
Definition series_line.hpp:70
std::optional< ComponentBatch > color
Color for the corresponding series.
Definition series_line.hpp:67
static constexpr auto Descriptor_name
ComponentDescriptor for the name field.
Definition series_line.hpp:103
SeriesLine with_aggregation_policy(const rerun::components::AggregationPolicy &_aggregation_policy) &&
Configures the zoom-dependent scalar aggregation.
Definition series_line.hpp:179
static SeriesLine clear_fields()
Clear all the fields of a SeriesLine.
static constexpr auto Descriptor_aggregation_policy
ComponentDescriptor for the aggregation_policy field.
Definition series_line.hpp:107
static constexpr auto Descriptor_color
ComponentDescriptor for the color field.
Definition series_line.hpp:94
SeriesLine with_name(const rerun::components::Name &_name) &&
Display name of the series.
Definition series_line.hpp:160
SeriesLine with_many_aggregation_policy(const Collection< rerun::components::AggregationPolicy > &_aggregation_policy) &&
This method makes it possible to pack multiple aggregation_policy in a single component batch.
Definition series_line.hpp:192
static constexpr auto Descriptor_width
ComponentDescriptor for the width field.
Definition series_line.hpp:98
SeriesLine 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_line.hpp:137
SeriesLine with_color(const rerun::components::Color &_color) &&
Color for the corresponding series.
Definition series_line.hpp:128
std::optional< ComponentBatch > aggregation_policy
Configures the zoom-dependent scalar aggregation.
Definition series_line.hpp:82
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
SeriesLine with_many_width(const Collection< rerun::components::StrokeWidth > &_width) &&
This method makes it possible to pack multiple width in a single component batch.
Definition series_line.hpp:152
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
SeriesLine 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_line.hpp:169
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: A display name, typically for an entity or a item like a plot series.
Definition name.hpp:17
Component: The width of a stroke specified in UI points.
Definition stroke_width.hpp:15