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