Rerun C++ SDK
Loading...
Searching...
No Matches
tensor_scalar_mapping.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/blueprint/archetypes/tensor_scalar_mapping.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/colormap.hpp"
11#include "../../components/gamma_correction.hpp"
12#include "../../components/magnification_filter.hpp"
13#include "../../result.hpp"
14
15#include <cstdint>
16#include <optional>
17#include <utility>
18#include <vector>
19
20namespace rerun::blueprint::archetypes {
21 /// **Archetype**: Configures how tensor scalars are mapped to color.
22 ///
23 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
24 ///
26 /// Filter used when zooming in on the tensor.
27 ///
28 /// Note that the filter is applied to the scalar values *before* they are mapped to color.
29 std::optional<ComponentBatch> mag_filter;
30
31 /// How scalar values map to colors.
32 std::optional<ComponentBatch> colormap;
33
34 /// Gamma exponent applied to normalized values before mapping to color.
35 ///
36 /// Raises the normalized values to the power of this value before mapping to color.
37 /// Acts like an inverse brightness. Defaults to 1.0.
38 ///
39 /// The final value for display is set as:
40 /// `colormap( ((value - data_display_range.min) / (data_display_range.max - data_display_range.min)) ** gamma )`
41 std::optional<ComponentBatch> gamma;
42
43 public:
44 /// The name of the archetype as used in `ComponentDescriptor`s.
45 static constexpr const char ArchetypeName[] =
46 "rerun.blueprint.archetypes.TensorScalarMapping";
47
48 /// `ComponentDescriptor` for the `mag_filter` field.
50 ArchetypeName, "TensorScalarMapping:mag_filter",
52 );
53 /// `ComponentDescriptor` for the `colormap` field.
55 ArchetypeName, "TensorScalarMapping:colormap",
57 );
58 /// `ComponentDescriptor` for the `gamma` field.
59 static constexpr auto Descriptor_gamma = ComponentDescriptor(
60 ArchetypeName, "TensorScalarMapping:gamma",
62 );
63
64 public:
65 TensorScalarMapping() = default;
67 TensorScalarMapping(const TensorScalarMapping& other) = default;
68 TensorScalarMapping& operator=(const TensorScalarMapping& other) = default;
69 TensorScalarMapping& operator=(TensorScalarMapping&& other) = default;
70
71 /// Update only some specific fields of a `TensorScalarMapping`.
73 return TensorScalarMapping();
74 }
75
76 /// Clear all the fields of a `TensorScalarMapping`.
78
79 /// Filter used when zooming in on the tensor.
80 ///
81 /// Note that the filter is applied to the scalar values *before* they are mapped to color.
84 ) && {
86 ComponentBatch::from_loggable(_mag_filter, Descriptor_mag_filter).value_or_throw();
87 return std::move(*this);
88 }
89
90 /// How scalar values map to colors.
92 colormap =
93 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
94 return std::move(*this);
95 }
96
97 /// Gamma exponent applied to normalized values before mapping to color.
98 ///
99 /// Raises the normalized values to the power of this value before mapping to color.
100 /// Acts like an inverse brightness. Defaults to 1.0.
101 ///
102 /// The final value for display is set as:
103 /// `colormap( ((value - data_display_range.min) / (data_display_range.max - data_display_range.min)) ** gamma )`
105 gamma = ComponentBatch::from_loggable(_gamma, Descriptor_gamma).value_or_throw();
106 return std::move(*this);
107 }
108
109 /// Partitions the component data into multiple sub-batches.
110 ///
111 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
112 /// instead, via `ComponentBatch::partitioned`.
113 ///
114 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
115 ///
116 /// The specified `lengths` must sum to the total length of the component batch.
118 return detail::partition_batches({&mag_filter, &colormap, &gamma}, lengths_)
119 .value_or_throw();
120 }
121
122 /// Partitions the component data into unit-length sub-batches.
123 ///
124 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
125 /// where `n` is automatically guessed.
127 return detail::partition_batches_of_unit_length({&mag_filter, &colormap, &gamma})
128 .value_or_throw();
129 }
130 };
131
132} // namespace rerun::blueprint::archetypes
133
134namespace rerun {
135 /// \private
136 template <typename T>
137 struct AsComponents;
138
139 /// \private
140 template <>
141 struct AsComponents<blueprint::archetypes::TensorScalarMapping> {
142 /// Serialize all set component batches.
143 static Result<Collection<ComponentBatch>> as_batches(
145 ) {
146 return detail::collect_batches(
147 {&archetype.mag_filter, &archetype.colormap, &archetype.gamma}
148 );
149 }
150 };
151} // 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
Colormap
Component: Colormap for mapping scalar values within a given range to a color.
Definition colormap.hpp:28
MagnificationFilter
Component: Filter used when a single texel/pixel of an image is displayed larger than a single screen...
Definition magnification_filter.hpp:27
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: Configures how tensor scalars are mapped to color.
Definition tensor_scalar_mapping.hpp:25
TensorScalarMapping with_colormap(const rerun::components::Colormap &_colormap) &&
How scalar values map to colors.
Definition tensor_scalar_mapping.hpp:91
TensorScalarMapping with_gamma(const rerun::components::GammaCorrection &_gamma) &&
Gamma exponent applied to normalized values before mapping to color.
Definition tensor_scalar_mapping.hpp:104
std::optional< ComponentBatch > gamma
Gamma exponent applied to normalized values before mapping to color.
Definition tensor_scalar_mapping.hpp:41
TensorScalarMapping with_mag_filter(const rerun::components::MagnificationFilter &_mag_filter) &&
Filter used when zooming in on the tensor.
Definition tensor_scalar_mapping.hpp:82
static constexpr auto Descriptor_colormap
ComponentDescriptor for the colormap field.
Definition tensor_scalar_mapping.hpp:54
static constexpr auto Descriptor_gamma
ComponentDescriptor for the gamma field.
Definition tensor_scalar_mapping.hpp:59
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition tensor_scalar_mapping.hpp:45
static constexpr auto Descriptor_mag_filter
ComponentDescriptor for the mag_filter field.
Definition tensor_scalar_mapping.hpp:49
static TensorScalarMapping update_fields()
Update only some specific fields of a TensorScalarMapping.
Definition tensor_scalar_mapping.hpp:72
std::optional< ComponentBatch > mag_filter
Filter used when zooming in on the tensor.
Definition tensor_scalar_mapping.hpp:29
static TensorScalarMapping clear_fields()
Clear all the fields of a TensorScalarMapping.
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Definition tensor_scalar_mapping.hpp:117
std::optional< ComponentBatch > colormap
How scalar values map to colors.
Definition tensor_scalar_mapping.hpp:32
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Definition tensor_scalar_mapping.hpp:126
Component: A gamma correction value to be used with a scalar value or color.
Definition gamma_correction.hpp:20