Rerun C++ SDK
Loading...
Searching...
No Matches
series_line.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_line.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.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/name.hpp"
13#include "../components/series_visible.hpp"
14#include "../components/stroke_width.hpp"
15#include "../indicator_component.hpp"
16#include "../result.hpp"
17
18#include <cstdint>
19#include <optional>
20#include <utility>
21#include <vector>
22
23RR_PUSH_WARNINGS
24RR_DISABLE_DEPRECATION_WARNING
25
26namespace rerun::archetypes {
27 /// **Archetype**: Define the style properties for a line series in a chart.
28 ///
29 /// This archetype only provides styling information and should be logged as static
30 /// when possible. The underlying data needs to be logged to the same entity-path using
31 /// `archetypes::Scalars`.
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() {
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("trig/sin", rerun::Scalars(sin(static_cast<double>(t) / 100.0)));
72 /// rec.log("trig/cos", rerun::Scalars(cos(static_cast<double>(t) / 100.0)));
73 /// }
74 /// }
75 /// ```
76 ///
77 /// ⚠ **Deprecated since 0.23.0**: Use `SeriesLines` instead.
78 ///
79 struct [[deprecated("since 0.23.0: Use `SeriesLines` instead.")]] SeriesLine {
80 /// Color for the corresponding series.
81 std::optional<ComponentBatch> color;
82
83 /// Stroke width for the corresponding series.
84 std::optional<ComponentBatch> width;
85
86 /// Display name of the series.
87 ///
88 /// Used in the legend.
89 std::optional<ComponentBatch> name;
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 std::optional<ComponentBatch> visible_series;
97
98 /// Configures the zoom-dependent scalar aggregation.
99 ///
100 /// This is done only if steps on the X axis go below a single pixel,
101 /// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
102 /// (and readability) in such situations as it prevents overdraw.
103 std::optional<ComponentBatch> aggregation_policy;
104
105 public:
106 static constexpr const char IndicatorComponentName[] =
107 "rerun.components.SeriesLineIndicator";
108
109 /// Indicator component, used to identify the archetype when converting to a list of components.
111 /// The name of the archetype as used in `ComponentDescriptor`s.
112 static constexpr const char ArchetypeName[] = "rerun.archetypes.SeriesLine";
113
114 /// `ComponentDescriptor` for the `color` field.
115 static constexpr auto Descriptor_color = ComponentDescriptor(
116 ArchetypeName, "color", Loggable<rerun::components::Color>::Descriptor.component_name
117 );
118 /// `ComponentDescriptor` for the `width` field.
119 static constexpr auto Descriptor_width = ComponentDescriptor(
120 ArchetypeName, "width",
122 );
123 /// `ComponentDescriptor` for the `name` field.
124 static constexpr auto Descriptor_name = ComponentDescriptor(
125 ArchetypeName, "name", Loggable<rerun::components::Name>::Descriptor.component_name
126 );
127 /// `ComponentDescriptor` for the `visible_series` field.
128 static constexpr auto Descriptor_visible_series = ComponentDescriptor(
129 ArchetypeName, "visible_series",
131 );
132 /// `ComponentDescriptor` for the `aggregation_policy` field.
133 static constexpr auto Descriptor_aggregation_policy = ComponentDescriptor(
134 ArchetypeName, "aggregation_policy",
136 );
137
138 public:
139 SeriesLine() = default;
140 SeriesLine(SeriesLine&& other) = default;
141 SeriesLine(const SeriesLine& other) = default;
142 SeriesLine& operator=(const SeriesLine& other) = default;
143 SeriesLine& operator=(SeriesLine&& other) = default;
144
145 /// Update only some specific fields of a `SeriesLine`.
147 return SeriesLine();
148 }
149
150 /// Clear all the fields of a `SeriesLine`.
152
153 /// Color for the corresponding series.
155 color = ComponentBatch::from_loggable(_color, Descriptor_color).value_or_throw();
156 return std::move(*this);
157 }
158
159 /// This method makes it possible to pack multiple `color` in a single component batch.
160 ///
161 /// This only makes sense when used in conjunction with `columns`. `with_color` should
162 /// be used when logging a single row's worth of data.
164 color = ComponentBatch::from_loggable(_color, Descriptor_color).value_or_throw();
165 return std::move(*this);
166 }
167
168 /// Stroke width for the corresponding series.
170 width = ComponentBatch::from_loggable(_width, Descriptor_width).value_or_throw();
171 return std::move(*this);
172 }
173
174 /// This method makes it possible to pack multiple `width` in a single component batch.
175 ///
176 /// This only makes sense when used in conjunction with `columns`. `with_width` should
177 /// be used when logging a single row's worth of data.
179 width = ComponentBatch::from_loggable(_width, Descriptor_width).value_or_throw();
180 return std::move(*this);
181 }
182
183 /// Display name of the series.
184 ///
185 /// Used in the legend.
187 name = ComponentBatch::from_loggable(_name, Descriptor_name).value_or_throw();
188 return std::move(*this);
189 }
190
191 /// This method makes it possible to pack multiple `name` in a single component batch.
192 ///
193 /// This only makes sense when used in conjunction with `columns`. `with_name` should
194 /// be used when logging a single row's worth of data.
196 name = ComponentBatch::from_loggable(_name, Descriptor_name).value_or_throw();
197 return std::move(*this);
198 }
199
200 /// Which lines are visible.
201 ///
202 /// If not set, all line series on this entity are visible.
203 /// Unlike with the regular visibility property of the entire entity, any series that is hidden
204 /// via this property will still be visible in the legend.
207 ) && {
208 visible_series =
209 ComponentBatch::from_loggable(_visible_series, Descriptor_visible_series)
210 .value_or_throw();
211 return std::move(*this);
212 }
213
214 /// Configures the zoom-dependent scalar aggregation.
215 ///
216 /// This is done only if steps on the X axis go below a single pixel,
217 /// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
218 /// (and readability) in such situations as it prevents overdraw.
220 const rerun::components::AggregationPolicy& _aggregation_policy
221 ) && {
222 aggregation_policy =
223 ComponentBatch::from_loggable(_aggregation_policy, Descriptor_aggregation_policy)
224 .value_or_throw();
225 return std::move(*this);
226 }
227
228 /// This method makes it possible to pack multiple `aggregation_policy` in a single component batch.
229 ///
230 /// This only makes sense when used in conjunction with `columns`. `with_aggregation_policy` should
231 /// be used when logging a single row's worth of data.
233 const Collection<rerun::components::AggregationPolicy>& _aggregation_policy
234 ) && {
235 aggregation_policy =
236 ComponentBatch::from_loggable(_aggregation_policy, Descriptor_aggregation_policy)
237 .value_or_throw();
238 return std::move(*this);
239 }
240
241 /// Partitions the component data into multiple sub-batches.
242 ///
243 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
244 /// instead, via `ComponentBatch::partitioned`.
245 ///
246 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
247 ///
248 /// The specified `lengths` must sum to the total length of the component batch.
250
251 /// Partitions the component data into unit-length sub-batches.
252 ///
253 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
254 /// where `n` is automatically guessed.
256 };
257
258} // namespace rerun::archetypes
259
260namespace rerun {
261 /// \private
262 template <typename T>
263 struct AsComponents;
264 RR_PUSH_WARNINGS
265 RR_DISABLE_DEPRECATION_WARNING
266
267 /// \private
268 template <>
269 struct AsComponents<archetypes::SeriesLine> {
270 /// Serialize all set component batches.
271 static Result<Collection<ComponentBatch>> as_batches(const archetypes::SeriesLine& archetype
272 );
273 };
274} // namespace rerun
275
276RR_POP_WARNINGS
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
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 a line series in a chart.
Definition series_line.hpp:79
SeriesLine with_width(const rerun::components::StrokeWidth &_width) &&
Stroke width for the corresponding series.
Definition series_line.hpp:169
static SeriesLine update_fields()
Update only some specific fields of a SeriesLine.
Definition series_line.hpp:146
std::optional< ComponentBatch > name
Display name of the series.
Definition series_line.hpp:89
std::optional< ComponentBatch > width
Stroke width for the corresponding series.
Definition series_line.hpp:84
std::optional< ComponentBatch > color
Color for the corresponding series.
Definition series_line.hpp:81
SeriesLine with_visible_series(const Collection< rerun::components::SeriesVisible > &_visible_series) &&
Which lines are visible.
Definition series_line.hpp:205
SeriesLine with_aggregation_policy(const rerun::components::AggregationPolicy &_aggregation_policy) &&
Configures the zoom-dependent scalar aggregation.
Definition series_line.hpp:219
static SeriesLine clear_fields()
Clear all the fields of a SeriesLine.
SeriesLine with_name(const rerun::components::Name &_name) &&
Display name of the series.
Definition series_line.hpp:186
SeriesLine 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_line.hpp:232
SeriesLine with_many_color(const Collection< rerun::components::Color > &_color) &&
This method makes it possible to pack multiple color in a single component batch.
Definition series_line.hpp:163
SeriesLine with_color(const rerun::components::Color &_color) &&
Color for the corresponding series.
Definition series_line.hpp:154
std::optional< ComponentBatch > aggregation_policy
Configures the zoom-dependent scalar aggregation.
Definition series_line.hpp:103
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
SeriesLine with_many_width(const Collection< rerun::components::StrokeWidth > &_width) &&
This method makes it possible to pack multiple width in a single component batch.
Definition series_line.hpp:178
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
std::optional< ComponentBatch > visible_series
Which lines are visible.
Definition series_line.hpp:96
SeriesLine with_many_name(const Collection< rerun::components::Name > &_name) &&
This method makes it possible to pack multiple name in a single component batch.
Definition series_line.hpp:195
Component: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition color.hpp:18
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
Component: The width of a stroke specified in UI points.
Definition stroke_width.hpp:15