Rerun C++ SDK
Loading...
Searching...
No Matches
series_points.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_points.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/color.hpp"
10#include "../components/marker_shape.hpp"
11#include "../components/marker_size.hpp"
12#include "../components/name.hpp"
13#include "../components/series_visible.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 point series (scatter plot) 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 /// ### Point series
35 /// ![image](https://static.rerun.io/series_point_style/82207a705da6c086b28ce161db1db9e8b12258b7/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_point_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 point series under a shared root so that they show in the same plot by default.
51 /// rec.log_static(
52 /// "trig/sin",
53 /// rerun::SeriesPoints()
54 /// .with_colors(rerun::Rgba32{255, 0, 0})
55 /// .with_names("sin(0.01t)")
56 /// .with_markers(rerun::components::MarkerShape::Circle)
57 /// .with_marker_sizes(4.0f)
58 /// );
59 /// rec.log_static(
60 /// "trig/cos",
61 /// rerun::SeriesPoints()
62 /// .with_colors(rerun::Rgba32{0, 255, 0})
63 /// .with_names("cos(0.01t)")
64 /// .with_markers(rerun::components::MarkerShape::Cross)
65 /// .with_marker_sizes(2.0f)
66 /// );
67 ///
68 /// // Log the data on a timeline called "step".
69 /// for (int t = 0; t <static_cast<int>(TAU * 2.0 * 10.0); ++t) {
70 /// rec.set_time_sequence("step", t);
71 ///
72 /// rec.log("trig/sin", rerun::Scalars(sin(static_cast<double>(t) / 10.0)));
73 /// rec.log("trig/cos", rerun::Scalars(cos(static_cast<double>(t) / 10.0)));
74 /// }
75 /// }
76 /// ```
77 struct SeriesPoints {
78 /// Color for the corresponding series.
79 ///
80 /// May change over time, but can cause discontinuities in the line.
81 std::optional<ComponentBatch> colors;
82
83 /// What shape to use to represent the point
84 ///
85 /// May change over time.
86 std::optional<ComponentBatch> markers;
87
88 /// Display name of the series.
89 ///
90 /// Used in the legend. Expected to be unchanging over time.
91 std::optional<ComponentBatch> names;
92
93 /// Which lines are visible.
94 ///
95 /// If not set, all line series on this entity are visible.
96 /// Unlike with the regular visibility property of the entire entity, any series that is hidden
97 /// via this property will still be visible in the legend.
98 ///
99 /// May change over time.
100 std::optional<ComponentBatch> visible_series;
101
102 /// Sizes of the markers.
103 ///
104 /// May change over time.
105 std::optional<ComponentBatch> marker_sizes;
106
107 public:
108 static constexpr const char IndicatorComponentName[] =
109 "rerun.components.SeriesPointsIndicator";
110
111 /// Indicator component, used to identify the archetype when converting to a list of components.
113 /// The name of the archetype as used in `ComponentDescriptor`s.
114 static constexpr const char ArchetypeName[] = "rerun.archetypes.SeriesPoints";
115
116 /// `ComponentDescriptor` for the `colors` field.
117 static constexpr auto Descriptor_colors = ComponentDescriptor(
119 );
120 /// `ComponentDescriptor` for the `markers` field.
122 ArchetypeName, "markers",
124 );
125 /// `ComponentDescriptor` for the `names` field.
126 static constexpr auto Descriptor_names = ComponentDescriptor(
128 );
129 /// `ComponentDescriptor` for the `visible_series` field.
131 ArchetypeName, "visible_series",
133 );
134 /// `ComponentDescriptor` for the `marker_sizes` field.
136 ArchetypeName, "marker_sizes",
138 );
139
140 public: // START of extensions from series_points_ext.cpp:
141 // Overload needed to avoid confusion with passing single strings.
142 /// Display name of the series.
143 ///
144 /// Used in the legend. Expected to be unchanging over time.
145 SeriesPoints with_names(const char* _name) && {
147 .value_or_throw();
148 return std::move(*this);
149 }
150
151 // END of extensions from series_points_ext.cpp, start of generated code:
152
153 public:
154 SeriesPoints() = default;
155 SeriesPoints(SeriesPoints&& other) = default;
156 SeriesPoints(const SeriesPoints& other) = default;
157 SeriesPoints& operator=(const SeriesPoints& other) = default;
158 SeriesPoints& operator=(SeriesPoints&& other) = default;
159
160 /// Update only some specific fields of a `SeriesPoints`.
162 return SeriesPoints();
163 }
164
165 /// Clear all the fields of a `SeriesPoints`.
167
168 /// Color for the corresponding series.
169 ///
170 /// May change over time, but can cause discontinuities in the line.
172 colors = ComponentBatch::from_loggable(_colors, Descriptor_colors).value_or_throw();
173 return std::move(*this);
174 }
175
176 /// What shape to use to represent the point
177 ///
178 /// May change over time.
180 markers = ComponentBatch::from_loggable(_markers, Descriptor_markers).value_or_throw();
181 return std::move(*this);
182 }
183
184 /// Display name of the series.
185 ///
186 /// Used in the legend. Expected to be unchanging over time.
188 names = ComponentBatch::from_loggable(_names, Descriptor_names).value_or_throw();
189 return std::move(*this);
190 }
191
192 /// Which lines are visible.
193 ///
194 /// If not set, all line series on this entity are visible.
195 /// Unlike with the regular visibility property of the entire entity, any series that is hidden
196 /// via this property will still be visible in the legend.
197 ///
198 /// May change over time.
201 ) && {
204 .value_or_throw();
205 return std::move(*this);
206 }
207
208 /// Sizes of the markers.
209 ///
210 /// May change over time.
213 ) && {
215 .value_or_throw();
216 return std::move(*this);
217 }
218
219 /// Partitions the component data into multiple sub-batches.
220 ///
221 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
222 /// instead, via `ComponentBatch::partitioned`.
223 ///
224 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
225 ///
226 /// The specified `lengths` must sum to the total length of the component batch.
228
229 /// Partitions the component data into unit-length sub-batches.
230 ///
231 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
232 /// where `n` is automatically guessed.
234 };
235
236} // namespace rerun::archetypes
237
238namespace rerun {
239 /// \private
240 template <typename T>
241 struct AsComponents;
242
243 /// \private
244 template <>
245 struct AsComponents<archetypes::SeriesPoints> {
246 /// Serialize all set component batches.
247 static Result<Collection<ComponentBatch>> as_batches(
248 const archetypes::SeriesPoints& archetype
249 );
250 };
251} // 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
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 point series (scatter plot) in a chart.
Definition series_points.hpp:77
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
SeriesPoints with_visible_series(const Collection< rerun::components::SeriesVisible > &_visible_series) &&
Which lines are visible.
Definition series_points.hpp:199
static constexpr auto Descriptor_markers
ComponentDescriptor for the markers field.
Definition series_points.hpp:121
std::optional< ComponentBatch > visible_series
Which lines are visible.
Definition series_points.hpp:100
SeriesPoints with_marker_sizes(const Collection< rerun::components::MarkerSize > &_marker_sizes) &&
Sizes of the markers.
Definition series_points.hpp:211
static constexpr auto Descriptor_visible_series
ComponentDescriptor for the visible_series field.
Definition series_points.hpp:130
SeriesPoints with_names(const char *_name) &&
Display name of the series.
Definition series_points.hpp:145
static constexpr auto Descriptor_colors
ComponentDescriptor for the colors field.
Definition series_points.hpp:117
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static SeriesPoints update_fields()
Update only some specific fields of a SeriesPoints.
Definition series_points.hpp:161
SeriesPoints with_colors(const Collection< rerun::components::Color > &_colors) &&
Color for the corresponding series.
Definition series_points.hpp:171
SeriesPoints with_names(const Collection< rerun::components::Name > &_names) &&
Display name of the series.
Definition series_points.hpp:187
std::optional< ComponentBatch > markers
What shape to use to represent the point.
Definition series_points.hpp:86
std::optional< ComponentBatch > names
Display name of the series.
Definition series_points.hpp:91
static constexpr auto Descriptor_marker_sizes
ComponentDescriptor for the marker_sizes field.
Definition series_points.hpp:135
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition series_points.hpp:114
std::optional< ComponentBatch > colors
Color for the corresponding series.
Definition series_points.hpp:81
std::optional< ComponentBatch > marker_sizes
Sizes of the markers.
Definition series_points.hpp:105
static SeriesPoints clear_fields()
Clear all the fields of a SeriesPoints.
SeriesPoints with_markers(const Collection< rerun::components::MarkerShape > &_markers) &&
What shape to use to represent the point.
Definition series_points.hpp:179
static constexpr auto Descriptor_names
ComponentDescriptor for the names field.
Definition series_points.hpp:126
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