Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::Points2D Struct Reference

Archetype: A 2D point cloud with positions and optional colors, radii, labels, etc. More...

#include <rerun/archetypes/points2d.hpp>

Public Member Functions

 Points2D (Points2D &&other)=default
 
 Points2D (const Points2D &other)=default
 
Points2Doperator= (const Points2D &other)=default
 
Points2Doperator= (Points2D &&other)=default
 
 Points2D (Collection< rerun::components::Position2D > _positions)
 
Points2D with_positions (const Collection< rerun::components::Position2D > &_positions) &&
 All the 2D positions at which the point cloud shows points.
 
Points2D with_radii (const Collection< rerun::components::Radius > &_radii) &&
 Optional radii for the points, effectively turning them into circles.
 
Points2D with_colors (const Collection< rerun::components::Color > &_colors) &&
 Optional colors for the points.
 
Points2D with_labels (const Collection< rerun::components::Text > &_labels) &&
 Optional text labels for the points.
 
Points2D with_show_labels (const rerun::components::ShowLabels &_show_labels) &&
 Whether the text labels should be shown.
 
Points2D with_many_show_labels (const Collection< rerun::components::ShowLabels > &_show_labels) &&
 This method makes it possible to pack multiple show_labels in a single component batch.
 
Points2D with_draw_order (const rerun::components::DrawOrder &_draw_order) &&
 An optional floating point value that specifies the 2D drawing order.
 
Points2D with_many_draw_order (const Collection< rerun::components::DrawOrder > &_draw_order) &&
 This method makes it possible to pack multiple draw_order in a single component batch.
 
Points2D with_class_ids (const Collection< rerun::components::ClassId > &_class_ids) &&
 Optional class Ids for the points.
 
Points2D with_keypoint_ids (const Collection< rerun::components::KeypointId > &_keypoint_ids) &&
 Optional keypoint IDs for the points, identifying them within a class.
 
Collection< ComponentColumncolumns (const Collection< uint32_t > &lengths_)
 Partitions the component data into multiple sub-batches.
 
Collection< ComponentColumncolumns ()
 Partitions the component data into unit-length sub-batches.
 

Static Public Member Functions

static Points2D update_fields ()
 Update only some specific fields of a Points2D.
 
static Points2D clear_fields ()
 Clear all the fields of a Points2D.
 

Public Attributes

std::optional< ComponentBatchpositions
 All the 2D positions at which the point cloud shows points.
 
std::optional< ComponentBatchradii
 Optional radii for the points, effectively turning them into circles.
 
std::optional< ComponentBatchcolors
 Optional colors for the points.
 
std::optional< ComponentBatchlabels
 Optional text labels for the points.
 
std::optional< ComponentBatchshow_labels
 Whether the text labels should be shown.
 
std::optional< ComponentBatchdraw_order
 An optional floating point value that specifies the 2D drawing order.
 
std::optional< ComponentBatchclass_ids
 Optional class Ids for the points.
 
std::optional< ComponentBatchkeypoint_ids
 Optional keypoint IDs for the points, identifying them within a class.
 

Static Public Attributes

static constexpr const char ArchetypeName [] = "rerun.archetypes.Points2D"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_positions
 ComponentDescriptor for the positions field.
 
static constexpr auto Descriptor_radii
 ComponentDescriptor for the radii field.
 
static constexpr auto Descriptor_colors
 ComponentDescriptor for the colors field.
 
static constexpr auto Descriptor_labels
 ComponentDescriptor for the labels field.
 
static constexpr auto Descriptor_show_labels
 ComponentDescriptor for the show_labels field.
 
static constexpr auto Descriptor_draw_order
 ComponentDescriptor for the draw_order field.
 
static constexpr auto Descriptor_class_ids
 ComponentDescriptor for the class_ids field.
 
static constexpr auto Descriptor_keypoint_ids
 ComponentDescriptor for the keypoint_ids field.
 

Detailed Description

Archetype: A 2D point cloud with positions and optional colors, radii, labels, etc.

Examples

Randomly distributed 2D points with varying color and radius

image

#include <rerun.hpp>
#include <algorithm>
#include <random>
#include <vector>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_points2d_random");
rec.spawn().exit_on_failure();
std::default_random_engine gen;
std::uniform_real_distribution<float> dist_pos(-3.0f, 3.0f);
std::uniform_real_distribution<float> dist_radius(0.1f, 1.0f);
// On MSVC uint8_t distributions are not supported.
std::uniform_int_distribution<int> dist_color(0, 255);
std::vector<rerun::Position2D> points2d(10);
std::generate(points2d.begin(), points2d.end(), [&] {
return rerun::Position2D(dist_pos(gen), dist_pos(gen));
});
std::vector<rerun::Color> colors(10);
std::generate(colors.begin(), colors.end(), [&] {
return rerun::Color(
static_cast<uint8_t>(dist_color(gen)),
static_cast<uint8_t>(dist_color(gen)),
static_cast<uint8_t>(dist_color(gen))
);
});
std::vector<rerun::Radius> radii(10);
std::generate(radii.begin(), radii.end(), [&] { return dist_radius(gen); });
rec.log("random", rerun::Points2D(points2d).with_colors(colors).with_radii(radii));
// TODO(#5520): log VisualBounds2D
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:61
Archetype: A 2D point cloud with positions and optional colors, radii, labels, etc.
Definition points2d.hpp:106
std::optional< ComponentBatch > colors
Optional colors for the points.
Definition points2d.hpp:114
Points2D with_colors(const Collection< rerun::components::Color > &_colors) &&
Optional colors for the points.
Definition points2d.hpp:223
Points2D with_radii(const Collection< rerun::components::Radius > &_radii) &&
Optional radii for the points, effectively turning them into circles.
Definition points2d.hpp:217
std::optional< ComponentBatch > radii
Optional radii for the points, effectively turning them into circles.
Definition points2d.hpp:111

Log points with radii given in UI points

image

#include <rerun.hpp>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_points2d_ui_radius");
rec.spawn().exit_on_failure();
// Two blue points with scene unit radii of 0.1 and 0.3.
rec.log(
"scene_units",
rerun::Points2D({{0.0f, 0.0f}, {0.0f, 1.0f}})
// By default, radii are interpreted as world-space units.
.with_radii({0.1f, 0.3f})
);
// Two red points with ui point radii of 40 and 60.
// UI points are independent of zooming in Views, but are sensitive to the application UI scaling.
// For 100% ui scaling, UI points are equal to pixels.
rec.log(
"ui_points",
rerun::Points2D({{1.0f, 0.0f}, {1.0f, 1.0f}})
// rerun::Radius::ui_points produces radii that the viewer interprets as given in ui points.
})
);
// TODO(#5521): log VisualBounds2D
}
Component: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition color.hpp:17
static Radius ui_points(float radius_in_ui_points)
Creates a new radius in ui points.
Definition radius.hpp:35

Member Function Documentation

◆ with_labels()

Points2D rerun::archetypes::Points2D::with_labels ( const Collection< rerun::components::Text > &  _labels) &&
inline

Optional text labels for the points.

If there's a single label present, it will be placed at the center of the entity. Otherwise, each instance will have its own label.

◆ with_show_labels()

Points2D rerun::archetypes::Points2D::with_show_labels ( const rerun::components::ShowLabels _show_labels) &&
inline

Whether the text labels should be shown.

If not set, labels will automatically appear when there is exactly one label for this entity or the number of instances on this entity is under a certain threshold.

◆ with_many_show_labels()

Points2D rerun::archetypes::Points2D::with_many_show_labels ( const Collection< rerun::components::ShowLabels > &  _show_labels) &&
inline

This method makes it possible to pack multiple show_labels in a single component batch.

This only makes sense when used in conjunction with columns. with_show_labels should be used when logging a single row's worth of data.

◆ with_draw_order()

Points2D rerun::archetypes::Points2D::with_draw_order ( const rerun::components::DrawOrder _draw_order) &&
inline

An optional floating point value that specifies the 2D drawing order.

Objects with higher values are drawn on top of those with lower values. Defaults to 30.0.

◆ with_many_draw_order()

Points2D rerun::archetypes::Points2D::with_many_draw_order ( const Collection< rerun::components::DrawOrder > &  _draw_order) &&
inline

This method makes it possible to pack multiple draw_order in a single component batch.

This only makes sense when used in conjunction with columns. with_draw_order should be used when logging a single row's worth of data.

◆ with_class_ids()

Points2D rerun::archetypes::Points2D::with_class_ids ( const Collection< rerun::components::ClassId > &  _class_ids) &&
inline

Optional class Ids for the points.

The components::ClassId provides colors and labels if not specified explicitly.

◆ with_keypoint_ids()

Points2D rerun::archetypes::Points2D::with_keypoint_ids ( const Collection< rerun::components::KeypointId > &  _keypoint_ids) &&
inline

Optional keypoint IDs for the points, identifying them within a class.

If keypoint IDs are passed in but no components::ClassIds were specified, the components::ClassId will default to 0. This is useful to identify points within a single classification (which is identified with class_id). E.g. the classification might be 'Person' and the keypoints refer to joints on a detected skeleton.

◆ columns() [1/2]

Collection< ComponentColumn > rerun::archetypes::Points2D::columns ( const Collection< uint32_t > &  lengths_)

Partitions the component data into multiple sub-batches.

Specifically, this transforms the existing ComponentBatch data into ComponentColumns instead, via ComponentBatch::partitioned.

This makes it possible to use RecordingStream::send_columns to send columnar data directly into Rerun.

The specified lengths must sum to the total length of the component batch.

◆ columns() [2/2]

Collection< ComponentColumn > rerun::archetypes::Points2D::columns ( )

Partitions the component data into unit-length sub-batches.

This is semantically similar to calling columns with std::vector<uint32_t>(n, 1), where n is automatically guessed.

Member Data Documentation

◆ labels

std::optional<ComponentBatch> rerun::archetypes::Points2D::labels

Optional text labels for the points.

If there's a single label present, it will be placed at the center of the entity. Otherwise, each instance will have its own label.

◆ show_labels

std::optional<ComponentBatch> rerun::archetypes::Points2D::show_labels

Whether the text labels should be shown.

If not set, labels will automatically appear when there is exactly one label for this entity or the number of instances on this entity is under a certain threshold.

◆ draw_order

std::optional<ComponentBatch> rerun::archetypes::Points2D::draw_order

An optional floating point value that specifies the 2D drawing order.

Objects with higher values are drawn on top of those with lower values. Defaults to 30.0.

◆ class_ids

std::optional<ComponentBatch> rerun::archetypes::Points2D::class_ids

Optional class Ids for the points.

The components::ClassId provides colors and labels if not specified explicitly.

◆ keypoint_ids

std::optional<ComponentBatch> rerun::archetypes::Points2D::keypoint_ids

Optional keypoint IDs for the points, identifying them within a class.

If keypoint IDs are passed in but no components::ClassIds were specified, the components::ClassId will default to 0. This is useful to identify points within a single classification (which is identified with class_id). E.g. the classification might be 'Person' and the keypoints refer to joints on a detected skeleton.

◆ Descriptor_positions

constexpr auto rerun::archetypes::Points2D::Descriptor_positions
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "Points2D:positions",
Loggable<rerun::components::Position2D>::ComponentType
)
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition points2d.hpp:151

ComponentDescriptor for the positions field.

◆ Descriptor_radii

constexpr auto rerun::archetypes::Points2D::Descriptor_radii
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "Points2D:radii", Loggable<rerun::components::Radius>::ComponentType
)

ComponentDescriptor for the radii field.

◆ Descriptor_colors

constexpr auto rerun::archetypes::Points2D::Descriptor_colors
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "Points2D:colors", Loggable<rerun::components::Color>::ComponentType
)

ComponentDescriptor for the colors field.

◆ Descriptor_labels

constexpr auto rerun::archetypes::Points2D::Descriptor_labels
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "Points2D:labels", Loggable<rerun::components::Text>::ComponentType
)

ComponentDescriptor for the labels field.

◆ Descriptor_show_labels

constexpr auto rerun::archetypes::Points2D::Descriptor_show_labels
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "Points2D:show_labels",
Loggable<rerun::components::ShowLabels>::ComponentType
)

ComponentDescriptor for the show_labels field.

◆ Descriptor_draw_order

constexpr auto rerun::archetypes::Points2D::Descriptor_draw_order
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "Points2D:draw_order",
Loggable<rerun::components::DrawOrder>::ComponentType
)

ComponentDescriptor for the draw_order field.

◆ Descriptor_class_ids

constexpr auto rerun::archetypes::Points2D::Descriptor_class_ids
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "Points2D:class_ids", Loggable<rerun::components::ClassId>::ComponentType
)

ComponentDescriptor for the class_ids field.

◆ Descriptor_keypoint_ids

constexpr auto rerun::archetypes::Points2D::Descriptor_keypoint_ids
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "Points2D:keypoint_ids",
Loggable<rerun::components::KeypointId>::ComponentType
)

ComponentDescriptor for the keypoint_ids field.


The documentation for this struct was generated from the following file: