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 "../indicator_component.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() {
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 public:
110 static constexpr const char IndicatorComponentName[] =
111 "rerun.components.SeriesLinesIndicator";
112
113 /// Indicator component, used to identify the archetype when converting to a list of components.
115 /// The name of the archetype as used in `ComponentDescriptor`s.
116 static constexpr const char ArchetypeName[] = "rerun.archetypes.SeriesLines";
117
118 /// `ComponentDescriptor` for the `colors` field.
119 static constexpr auto Descriptor_colors = ComponentDescriptor(
121 );
122 /// `ComponentDescriptor` for the `widths` field.
123 static constexpr auto Descriptor_widths = ComponentDescriptor(
124 ArchetypeName, "widths",
126 );
127 /// `ComponentDescriptor` for the `names` field.
128 static constexpr auto Descriptor_names = ComponentDescriptor(
130 );
131 /// `ComponentDescriptor` for the `visible_series` field.
133 ArchetypeName, "visible_series",
135 );
136 /// `ComponentDescriptor` for the `aggregation_policy` field.
138 ArchetypeName, "aggregation_policy",
140 );
141
142 public: // START of extensions from series_lines_ext.cpp:
143 // Overload needed to avoid confusion with passing single strings.
144 /// Display name of the series.
145 ///
146 /// Used in the legend. Expected to be unchanging over time.
147 SeriesLines with_names(const char* _name) && {
149 .value_or_throw();
150 return std::move(*this);
151 }
152
153 // END of extensions from series_lines_ext.cpp, start of generated code:
154
155 public:
156 SeriesLines() = default;
157 SeriesLines(SeriesLines&& other) = default;
158 SeriesLines(const SeriesLines& other) = default;
159 SeriesLines& operator=(const SeriesLines& other) = default;
160 SeriesLines& operator=(SeriesLines&& other) = default;
161
162 /// Update only some specific fields of a `SeriesLines`.
164 return SeriesLines();
165 }
166
167 /// Clear all the fields of a `SeriesLines`.
169
170 /// Color for the corresponding series.
171 ///
172 /// May change over time, but can cause discontinuities in the line.
174 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
175 return std::move(*this);
176 }
177
178 /// Stroke width for the corresponding series.
179 ///
180 /// May change over time, but can cause discontinuities in the line.
182 widths = ComponentBatch::from_loggable(_widths, Descriptor_widths).value_or_throw();
183 return std::move(*this);
184 }
185
186 /// Display name of the series.
187 ///
188 /// Used in the legend. Expected to be unchanging over time.
190 names = ComponentBatch::from_loggable(_names, Descriptor_names).value_or_throw();
191 return std::move(*this);
192 }
193
194 /// Which lines are visible.
195 ///
196 /// If not set, all line series on this entity are visible.
197 /// Unlike with the regular visibility property of the entire entity, any series that is hidden
198 /// via this property will still be visible in the legend.
199 ///
200 /// May change over time, but can cause discontinuities in the line.
203 ) && {
206 .value_or_throw();
207 return std::move(*this);
208 }
209
210 /// Configures the zoom-dependent scalar aggregation.
211 ///
212 /// This is done only if steps on the X axis go below a single pixel,
213 /// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
214 /// (and readability) in such situations as it prevents overdraw.
215 ///
216 /// Expected to be unchanging over time.
218 const rerun::components::AggregationPolicy& _aggregation_policy
219 ) && {
222 .value_or_throw();
223 return std::move(*this);
224 }
225
226 /// This method makes it possible to pack multiple `aggregation_policy` in a single component batch.
227 ///
228 /// This only makes sense when used in conjunction with `columns`. `with_aggregation_policy` should
229 /// be used when logging a single row's worth of data.
231 const Collection<rerun::components::AggregationPolicy>& _aggregation_policy
232 ) && {
235 .value_or_throw();
236 return std::move(*this);
237 }
238
239 /// Partitions the component data into multiple sub-batches.
240 ///
241 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
242 /// instead, via `ComponentBatch::partitioned`.
243 ///
244 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
245 ///
246 /// The specified `lengths` must sum to the total length of the component batch.
248
249 /// Partitions the component data into unit-length sub-batches.
250 ///
251 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
252 /// where `n` is automatically guessed.
254 };
255
256} // namespace rerun::archetypes
257
258namespace rerun {
259 /// \private
260 template <typename T>
261 struct AsComponents;
262
263 /// \private
264 template <>
265 struct AsComponents<archetypes::SeriesLines> {
266 /// Serialize all set component batches.
267 static Result<Collection<ComponentBatch>> as_batches(
268 const archetypes::SeriesLines& archetype
269 );
270 };
271} // 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 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:217
static constexpr auto Descriptor_widths
ComponentDescriptor for the widths field.
Definition series_lines.hpp:123
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:230
static constexpr auto Descriptor_names
ComponentDescriptor for the names field.
Definition series_lines.hpp:128
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition series_lines.hpp:119
static SeriesLines update_fields()
Update only some specific fields of a SeriesLines.
Definition series_lines.hpp:163
SeriesLines with_names(const Collection< rerun::components::Name > &_names) &&
Display name of the series.
Definition series_lines.hpp:189
SeriesLines with_names(const char *_name) &&
Display name of the series.
Definition series_lines.hpp:147
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition series_lines.hpp:116
static constexpr auto Descriptor_visible_series
ComponentDescriptor for the visible_series field.
Definition series_lines.hpp:132
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:181
static constexpr auto Descriptor_aggregation_policy
ComponentDescriptor for the aggregation_policy field.
Definition series_lines.hpp:137
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:173
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:201
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
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