Rerun C++ SDK
Loading...
Searching...
No Matches
series_lines.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_sdk_types/definitions/rerun/archetypes/series_lines.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/interpolation_mode.hpp"
12#include "../components/name.hpp"
13#include "../components/stroke_width.hpp"
14#include "../components/visible.hpp"
15#include "../result.hpp"
16
17#include <cstdint>
18#include <optional>
19#include <utility>
20#include <vector>
21
22namespace rerun::archetypes {
23 /// **Archetype**: Define the style properties for one or more line series in a chart.
24 ///
25 /// This archetype only provides styling information.
26 /// Changes over time are supported for most but not all its fields (see respective fields for details),
27 /// it's generally recommended to log this type as static.
28 ///
29 /// The underlying data needs to be logged to the same entity-path using `archetypes::Scalars`.
30 /// Dimensionality of the scalar arrays logged at each time point is assumed to be the same over time.
31 ///
32 /// ## Example
33 ///
34 /// ### Line series
35 /// ![image](https://static.rerun.io/series_line_style/d2616d98b1e46bdb85849b8669154fdf058e3453/full.png)
36 ///
37 /// ```cpp
38 /// #include <rerun.hpp>
39 ///
40 /// #include <cmath>
41 ///
42 /// constexpr float TAU = 6.28318530717958647692528676655900577f;
43 ///
44 /// int main(int argc, char* argv[]) {
45 /// const auto rec = rerun::RecordingStream("rerun_example_series_line_style");
46 /// rec.spawn().exit_on_failure();
47 ///
48 /// // Set up plot styling:
49 /// // They are logged static as they don't change over time and apply to all timelines.
50 /// // Log two lines series under a shared root so that they show in the same plot by default.
51 /// rec.log_static(
52 /// "trig/sin",
53 /// rerun::SeriesLines()
54 /// .with_colors(rerun::Rgba32{255, 0, 0})
55 /// .with_names("sin(0.01t)")
56 /// .with_widths(2.0f)
57 /// );
58 /// rec.log_static(
59 /// "trig/cos",
60 /// rerun::SeriesLines()
61 /// .with_colors(rerun::Rgba32{0, 255, 0})
62 /// .with_names("cos(0.01t)")
63 /// .with_widths(4.0f)
64 /// );
65 ///
66 /// // Log the data on a timeline called "step".
67 /// for (int t = 0; t <static_cast<int>(TAU * 2.0 * 100.0); ++t) {
68 /// rec.set_time_sequence("step", t);
69 ///
70 /// rec.log("trig/sin", rerun::Scalars(sin(static_cast<double>(t) / 100.0)));
71 /// rec.log("trig/cos", rerun::Scalars(cos(static_cast<double>(t) / 100.0)));
72 /// }
73 /// }
74 /// ```
75 struct SeriesLines {
76 /// Color for the corresponding series.
77 ///
78 /// May change over time, but can cause discontinuities in the line.
79 std::optional<ComponentBatch> colors;
80
81 /// Stroke width for the corresponding series.
82 ///
83 /// May change over time, but can cause discontinuities in the line.
84 std::optional<ComponentBatch> widths;
85
86 /// Display name of the series.
87 ///
88 /// Used in the legend. Expected to be unchanging over time.
89 std::optional<ComponentBatch> names;
90
91 /// Which lines are visible.
92 ///
93 /// If not set, all line series on this entity are visible.
94 /// Unlike with the regular visibility property of the entire entity, any series that is hidden
95 /// via this property will still be visible in the legend.
96 ///
97 /// May change over time, but can cause discontinuities in the line.
98 std::optional<ComponentBatch> visible_series;
99
100 /// Configures the zoom-dependent scalar aggregation.
101 ///
102 /// This is done only if steps on the X axis go below a single pixel,
103 /// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
104 /// (and readability) in such situations as it prevents overdraw.
105 ///
106 /// Expected to be unchanging over time.
107 std::optional<ComponentBatch> aggregation_policy;
108
109 /// Specifies how values between data points are interpolated.
110 ///
111 /// Defaults to linear interpolation. Use one of the `Step*` variants for a stepped (staircase) line.
112 ///
113 /// Expected to be unchanging over time.
114 std::optional<ComponentBatch> interpolation_mode;
115
116 public:
117 /// The name of the archetype as used in `ComponentDescriptor`s.
118 static constexpr const char ArchetypeName[] = "rerun.archetypes.SeriesLines";
119
120 /// `ComponentDescriptor` for the `colors` field.
121 static constexpr auto Descriptor_colors = ComponentDescriptor(
123 );
124 /// `ComponentDescriptor` for the `widths` field.
125 static constexpr auto Descriptor_widths = ComponentDescriptor(
126 ArchetypeName, "SeriesLines:widths",
128 );
129 /// `ComponentDescriptor` for the `names` field.
130 static constexpr auto Descriptor_names = ComponentDescriptor(
132 );
133 /// `ComponentDescriptor` for the `visible_series` field.
135 ArchetypeName, "SeriesLines:visible_series",
137 );
138 /// `ComponentDescriptor` for the `aggregation_policy` field.
140 ArchetypeName, "SeriesLines:aggregation_policy",
142 );
143 /// `ComponentDescriptor` for the `interpolation_mode` field.
145 ArchetypeName, "SeriesLines:interpolation_mode",
147 );
148
149 public: // START of extensions from series_lines_ext.cpp:
150 // Overload needed to avoid confusion with passing single strings.
151 /// Display name of the series.
152 ///
153 /// Used in the legend. Expected to be unchanging over time.
154 SeriesLines with_names(const char* _name) && {
156 .value_or_throw();
157 return std::move(*this);
158 }
159
160 // END of extensions from series_lines_ext.cpp, start of generated code:
161
162 public:
163 SeriesLines() = default;
164 SeriesLines(SeriesLines&& other) = default;
165 SeriesLines(const SeriesLines& other) = default;
166 SeriesLines& operator=(const SeriesLines& other) = default;
167 SeriesLines& operator=(SeriesLines&& other) = default;
168
169 /// Update only some specific fields of a `SeriesLines`.
171 return SeriesLines();
172 }
173
174 /// Clear all the fields of a `SeriesLines`.
176
177 /// Color for the corresponding series.
178 ///
179 /// May change over time, but can cause discontinuities in the line.
181 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
182 return std::move(*this);
183 }
184
185 /// Stroke width for the corresponding series.
186 ///
187 /// May change over time, but can cause discontinuities in the line.
189 widths = ComponentBatch::from_loggable(_widths, Descriptor_widths).value_or_throw();
190 return std::move(*this);
191 }
192
193 /// Display name of the series.
194 ///
195 /// Used in the legend. Expected to be unchanging over time.
197 names = ComponentBatch::from_loggable(_names, Descriptor_names).value_or_throw();
198 return std::move(*this);
199 }
200
201 /// Which lines are visible.
202 ///
203 /// If not set, all line series on this entity are visible.
204 /// Unlike with the regular visibility property of the entire entity, any series that is hidden
205 /// via this property will still be visible in the legend.
206 ///
207 /// May change over time, but can cause discontinuities in the line.
209 const Collection<rerun::components::Visible>& _visible_series
210 ) && {
213 .value_or_throw();
214 return std::move(*this);
215 }
216
217 /// Configures the zoom-dependent scalar aggregation.
218 ///
219 /// This is done only if steps on the X axis go below a single pixel,
220 /// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
221 /// (and readability) in such situations as it prevents overdraw.
222 ///
223 /// Expected to be unchanging over time.
225 const rerun::components::AggregationPolicy& _aggregation_policy
226 ) && {
229 .value_or_throw();
230 return std::move(*this);
231 }
232
233 /// This method makes it possible to pack multiple `aggregation_policy` in a single component batch.
234 ///
235 /// This only makes sense when used in conjunction with `columns`. `with_aggregation_policy` should
236 /// be used when logging a single row's worth of data.
238 const Collection<rerun::components::AggregationPolicy>& _aggregation_policy
239 ) && {
242 .value_or_throw();
243 return std::move(*this);
244 }
245
246 /// Specifies how values between data points are interpolated.
247 ///
248 /// Defaults to linear interpolation. Use one of the `Step*` variants for a stepped (staircase) line.
249 ///
250 /// Expected to be unchanging over time.
252 const rerun::components::InterpolationMode& _interpolation_mode
253 ) && {
256 .value_or_throw();
257 return std::move(*this);
258 }
259
260 /// This method makes it possible to pack multiple `interpolation_mode` in a single component batch.
261 ///
262 /// This only makes sense when used in conjunction with `columns`. `with_interpolation_mode` should
263 /// be used when logging a single row's worth of data.
265 const Collection<rerun::components::InterpolationMode>& _interpolation_mode
266 ) && {
269 .value_or_throw();
270 return std::move(*this);
271 }
272
273 /// Partitions the component data into multiple sub-batches.
274 ///
275 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
276 /// instead, via `ComponentBatch::partitioned`.
277 ///
278 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
279 ///
280 /// The specified `lengths` must sum to the total length of the component batch.
282
283 /// Partitions the component data into unit-length sub-batches.
284 ///
285 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
286 /// where `n` is automatically guessed.
288 };
289
290} // namespace rerun::archetypes
291
292namespace rerun {
293 /// \private
294 template <typename T>
295 struct AsComponents;
296
297 /// \private
298 template <>
299 struct AsComponents<archetypes::SeriesLines> {
300 /// Serialize all set component batches.
301 static Result<Collection<ComponentBatch>> as_batches(
302 const archetypes::SeriesLines& archetype
303 );
304 };
305} // 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:28
InterpolationMode
Component: Specifies how values between data points are interpolated in time series.
Definition interpolation_mode.hpp:24
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)
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: Define the style properties for one or more line series in a chart.
Definition series_lines.hpp:75
SeriesLines with_aggregation_policy(const rerun::components::AggregationPolicy &_aggregation_policy) &&
Configures the zoom-dependent scalar aggregation.
Definition series_lines.hpp:224
SeriesLines with_many_interpolation_mode(const Collection< rerun::components::InterpolationMode > &_interpolation_mode) &&
This method makes it possible to pack multiple interpolation_mode in a single component batch.
Definition series_lines.hpp:264
static constexpr auto Descriptor_widths
ComponentDescriptor for the widths field.
Definition series_lines.hpp:125
SeriesLines with_interpolation_mode(const rerun::components::InterpolationMode &_interpolation_mode) &&
Specifies how values between data points are interpolated.
Definition series_lines.hpp:251
SeriesLines 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_lines.hpp:237
static constexpr auto Descriptor_names
ComponentDescriptor for the names field.
Definition series_lines.hpp:130
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition series_lines.hpp:121
static SeriesLines update_fields()
Update only some specific fields of a SeriesLines.
Definition series_lines.hpp:170
SeriesLines with_names(const Collection< rerun::components::Name > &_names) &&
Display name of the series.
Definition series_lines.hpp:196
std::optional< ComponentBatch > interpolation_mode
Specifies how values between data points are interpolated.
Definition series_lines.hpp:114
SeriesLines with_names(const char *_name) &&
Display name of the series.
Definition series_lines.hpp:154
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition series_lines.hpp:118
static constexpr auto Descriptor_interpolation_mode
ComponentDescriptor for the interpolation_mode field.
Definition series_lines.hpp:144
static constexpr auto Descriptor_visible_series
ComponentDescriptor for the visible_series field.
Definition series_lines.hpp:134
SeriesLines with_visible_series(const Collection< rerun::components::Visible > &_visible_series) &&
Which lines are visible.
Definition series_lines.hpp:208
std::optional< ComponentBatch > widths
Stroke width for the corresponding series.
Definition series_lines.hpp:84
SeriesLines with_widths(const Collection< rerun::components::StrokeWidth > &_widths) &&
Stroke width for the corresponding series.
Definition series_lines.hpp:188
static constexpr auto Descriptor_aggregation_policy
ComponentDescriptor for the aggregation_policy field.
Definition series_lines.hpp:139
std::optional< ComponentBatch > visible_series
Which lines are visible.
Definition series_lines.hpp:98
std::optional< ComponentBatch > aggregation_policy
Configures the zoom-dependent scalar aggregation.
Definition series_lines.hpp:107
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
std::optional< ComponentBatch > colors
Color for the corresponding series.
Definition series_lines.hpp:79
SeriesLines with_colors(const Collection< rerun::components::Color > &_colors) &&
Color for the corresponding series.
Definition series_lines.hpp:180
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static SeriesLines clear_fields()
Clear all the fields of a SeriesLines.
std::optional< ComponentBatch > names
Display name of the series.
Definition series_lines.hpp:89
Component: A display name, typically for an entity or a item like a plot series.
Definition name.hpp:16