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(
71 /// "trig/sin",
72 /// rerun::Scalars(sin(static_cast<double>(t) / 100.0))
73 /// );
74 /// rec.log(
75 /// "trig/cos",
76 /// rerun::Scalars(cos(static_cast<double>(t) / 100.0))
77 /// );
78 /// }
79 /// }
80 /// ```
81 struct SeriesLines {
82 /// Color for the corresponding series.
83 ///
84 /// May change over time, but can cause discontinuities in the line.
85 std::optional<ComponentBatch> colors;
86
87 /// Stroke width for the corresponding series.
88 ///
89 /// May change over time, but can cause discontinuities in the line.
90 std::optional<ComponentBatch> widths;
91
92 /// Display name of the series.
93 ///
94 /// Used in the legend. Expected to be unchanging over time.
95 std::optional<ComponentBatch> names;
96
97 /// Which lines are visible.
98 ///
99 /// If not set, all line series on this entity are visible.
100 /// Unlike with the regular visibility property of the entire entity, any series that is hidden
101 /// via this property will still be visible in the legend.
102 ///
103 /// May change over time, but can cause discontinuities in the line.
104 std::optional<ComponentBatch> visible_series;
105
106 /// Configures the zoom-dependent scalar aggregation.
107 ///
108 /// This is done only if steps on the X axis go below a single pixel,
109 /// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
110 /// (and readability) in such situations as it prevents overdraw.
111 ///
112 /// Expected to be unchanging over time.
113 std::optional<ComponentBatch> aggregation_policy;
114
115 /// Specifies how values between data points are interpolated.
116 ///
117 /// Defaults to linear interpolation. Use one of the `Step*` variants for a stepped (staircase) line.
118 ///
119 /// Expected to be unchanging over time.
120 std::optional<ComponentBatch> interpolation_mode;
121
122 public:
123 /// The name of the archetype as used in `ComponentDescriptor`s.
124 static constexpr const char ArchetypeName[] = "rerun.archetypes.SeriesLines";
125
126 /// `ComponentDescriptor` for the `colors` field.
127 static constexpr auto Descriptor_colors = ComponentDescriptor(
129 );
130 /// `ComponentDescriptor` for the `widths` field.
131 static constexpr auto Descriptor_widths = ComponentDescriptor(
132 ArchetypeName, "SeriesLines:widths",
134 );
135 /// `ComponentDescriptor` for the `names` field.
136 static constexpr auto Descriptor_names = ComponentDescriptor(
138 );
139 /// `ComponentDescriptor` for the `visible_series` field.
141 ArchetypeName, "SeriesLines:visible_series",
143 );
144 /// `ComponentDescriptor` for the `aggregation_policy` field.
146 ArchetypeName, "SeriesLines:aggregation_policy",
148 );
149 /// `ComponentDescriptor` for the `interpolation_mode` field.
151 ArchetypeName, "SeriesLines:interpolation_mode",
153 );
154
155 public: // START of extensions from series_lines_ext.cpp:
156 // Overload needed to avoid confusion with passing single strings.
157 /// Display name of the series.
158 ///
159 /// Used in the legend. Expected to be unchanging over time.
160 SeriesLines with_names(const char* _name) && {
162 .value_or_throw();
163 return std::move(*this);
164 }
165
166 // END of extensions from series_lines_ext.cpp, start of generated code:
167
168 public:
169 SeriesLines() = default;
170 SeriesLines(SeriesLines&& other) = default;
171 SeriesLines(const SeriesLines& other) = default;
172 SeriesLines& operator=(const SeriesLines& other) = default;
173 SeriesLines& operator=(SeriesLines&& other) = default;
174
175 /// Update only some specific fields of a `SeriesLines`.
177 return SeriesLines();
178 }
179
180 /// Clear all the fields of a `SeriesLines`.
182
183 /// Color for the corresponding series.
184 ///
185 /// May change over time, but can cause discontinuities in the line.
187 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
188 return std::move(*this);
189 }
190
191 /// Stroke width for the corresponding series.
192 ///
193 /// May change over time, but can cause discontinuities in the line.
195 widths = ComponentBatch::from_loggable(_widths, Descriptor_widths).value_or_throw();
196 return std::move(*this);
197 }
198
199 /// Display name of the series.
200 ///
201 /// Used in the legend. Expected to be unchanging over time.
203 names = ComponentBatch::from_loggable(_names, Descriptor_names).value_or_throw();
204 return std::move(*this);
205 }
206
207 /// Which lines are visible.
208 ///
209 /// If not set, all line series on this entity are visible.
210 /// Unlike with the regular visibility property of the entire entity, any series that is hidden
211 /// via this property will still be visible in the legend.
212 ///
213 /// May change over time, but can cause discontinuities in the line.
215 const Collection<rerun::components::Visible>& _visible_series
216 ) && {
219 .value_or_throw();
220 return std::move(*this);
221 }
222
223 /// Configures the zoom-dependent scalar aggregation.
224 ///
225 /// This is done only if steps on the X axis go below a single pixel,
226 /// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
227 /// (and readability) in such situations as it prevents overdraw.
228 ///
229 /// Expected to be unchanging over time.
231 const rerun::components::AggregationPolicy& _aggregation_policy
232 ) && {
235 .value_or_throw();
236 return std::move(*this);
237 }
238
239 /// This method makes it possible to pack multiple `aggregation_policy` in a single component batch.
240 ///
241 /// This only makes sense when used in conjunction with `columns`. `with_aggregation_policy` should
242 /// be used when logging a single row's worth of data.
244 const Collection<rerun::components::AggregationPolicy>& _aggregation_policy
245 ) && {
248 .value_or_throw();
249 return std::move(*this);
250 }
251
252 /// Specifies how values between data points are interpolated.
253 ///
254 /// Defaults to linear interpolation. Use one of the `Step*` variants for a stepped (staircase) line.
255 ///
256 /// Expected to be unchanging over time.
258 const rerun::components::InterpolationMode& _interpolation_mode
259 ) && {
262 .value_or_throw();
263 return std::move(*this);
264 }
265
266 /// This method makes it possible to pack multiple `interpolation_mode` in a single component batch.
267 ///
268 /// This only makes sense when used in conjunction with `columns`. `with_interpolation_mode` should
269 /// be used when logging a single row's worth of data.
271 const Collection<rerun::components::InterpolationMode>& _interpolation_mode
272 ) && {
275 .value_or_throw();
276 return std::move(*this);
277 }
278
279 /// Partitions the component data into multiple sub-batches.
280 ///
281 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
282 /// instead, via `ComponentBatch::partitioned`.
283 ///
284 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
285 ///
286 /// The specified `lengths` must sum to the total length of the component batch.
288
289 /// Partitions the component data into unit-length sub-batches.
290 ///
291 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
292 /// where `n` is automatically guessed.
294 };
295
296} // namespace rerun::archetypes
297
298namespace rerun {
299 /// \private
300 template <typename T>
301 struct AsComponents;
302
303 /// \private
304 template <>
305 struct AsComponents<archetypes::SeriesLines> {
306 /// Serialize all set component batches.
307 static Result<Collection<ComponentBatch>> as_batches(
308 const archetypes::SeriesLines& archetype
309 );
310 };
311} // 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:87
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:81
SeriesLines with_aggregation_policy(const rerun::components::AggregationPolicy &_aggregation_policy) &&
Configures the zoom-dependent scalar aggregation.
Definition series_lines.hpp:230
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:270
static constexpr auto Descriptor_widths
ComponentDescriptor for the widths field.
Definition series_lines.hpp:131
SeriesLines with_interpolation_mode(const rerun::components::InterpolationMode &_interpolation_mode) &&
Specifies how values between data points are interpolated.
Definition series_lines.hpp:257
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:243
static constexpr auto Descriptor_names
ComponentDescriptor for the names field.
Definition series_lines.hpp:136
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition series_lines.hpp:127
static SeriesLines update_fields()
Update only some specific fields of a SeriesLines.
Definition series_lines.hpp:176
SeriesLines with_names(const Collection< rerun::components::Name > &_names) &&
Display name of the series.
Definition series_lines.hpp:202
std::optional< ComponentBatch > interpolation_mode
Specifies how values between data points are interpolated.
Definition series_lines.hpp:120
SeriesLines with_names(const char *_name) &&
Display name of the series.
Definition series_lines.hpp:160
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition series_lines.hpp:124
static constexpr auto Descriptor_interpolation_mode
ComponentDescriptor for the interpolation_mode field.
Definition series_lines.hpp:150
static constexpr auto Descriptor_visible_series
ComponentDescriptor for the visible_series field.
Definition series_lines.hpp:140
SeriesLines with_visible_series(const Collection< rerun::components::Visible > &_visible_series) &&
Which lines are visible.
Definition series_lines.hpp:214
std::optional< ComponentBatch > widths
Stroke width for the corresponding series.
Definition series_lines.hpp:90
SeriesLines with_widths(const Collection< rerun::components::StrokeWidth > &_widths) &&
Stroke width for the corresponding series.
Definition series_lines.hpp:194
static constexpr auto Descriptor_aggregation_policy
ComponentDescriptor for the aggregation_policy field.
Definition series_lines.hpp:145
std::optional< ComponentBatch > visible_series
Which lines are visible.
Definition series_lines.hpp:104
std::optional< ComponentBatch > aggregation_policy
Configures the zoom-dependent scalar aggregation.
Definition series_lines.hpp:113
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:85
SeriesLines with_colors(const Collection< rerun::components::Color > &_colors) &&
Color for the corresponding series.
Definition series_lines.hpp:186
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:95
Component: A display name, typically for an entity or a item like a plot series.
Definition name.hpp:16