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