From 0fc2a9fad2616bb3580176df37c488fc76a9a2ca Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 3 Jul 2023 16:46:12 +0200 Subject: [PATCH] rerun codegen --- .../definitions/rerun/archetypes/points2d.fbs | 13 ++++++++ crates/re_types/source_hash.txt | 2 +- crates/re_types/src/archetypes/points2d.rs | 30 +++++++++++++++++++ .../rerun/_rerun2/archetypes/points2d.py | 17 ++++++++++- 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/crates/re_types/definitions/rerun/archetypes/points2d.fbs b/crates/re_types/definitions/rerun/archetypes/points2d.fbs index a483faa3aae5f..f520c953f41f6 100644 --- a/crates/re_types/definitions/rerun/archetypes/points2d.fbs +++ b/crates/re_types/definitions/rerun/archetypes/points2d.fbs @@ -14,6 +14,19 @@ namespace rerun.archetypes; // TODO(#2521): always derive debug & clone for rust backend /// A 2D point cloud with positions and optional colors, radii, labels, etc. +/// +/// \py Example +/// \py ------- +/// \py +/// \py ```python +/// \py include:../../../../../docs/code-examples/point2d_simple_v2.py +/// \py ``` +/// +/// \rs ## Example +/// \rs +/// \rs ```ignore +/// \rs include:../../../../../docs/code-examples/point2d_simple_v2.rs +/// \rs ``` table Points2D ( "attr.rust.derive": "Debug, Clone, PartialEq", order: 100 diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index 2edfdc1adebe3..764dcd2263c7c 100644 --- a/crates/re_types/source_hash.txt +++ b/crates/re_types/source_hash.txt @@ -1,4 +1,4 @@ # This is a sha256 hash for all direct and indirect dependencies of this crate's build script. # It can be safely removed at anytime to force the build script to run again. # Check out build.rs to see how it's computed. -2482cd3e136880416056a88c296bd419d5b01626d2db3914e5e375c614123bcc \ No newline at end of file +3635c632f3859d33d5b8ad124e652bc8d647d7bf94b05b35e42488558f603b3e \ No newline at end of file diff --git a/crates/re_types/src/archetypes/points2d.rs b/crates/re_types/src/archetypes/points2d.rs index e303af8b244e0..934c65b7c2ae6 100644 --- a/crates/re_types/src/archetypes/points2d.rs +++ b/crates/re_types/src/archetypes/points2d.rs @@ -9,6 +9,36 @@ #![allow(clippy::unnecessary_cast)] #[doc = "A 2D point cloud with positions and optional colors, radii, labels, etc."] +#[doc = ""] +#[doc = "## Example"] +#[doc = ""] +#[doc = "```ignore"] +#[doc = "//! Log some very simple points."] +#[doc = ""] +#[doc = "use rerun::{"] +#[doc = " components::{Rect2D, Vec4D},"] +#[doc = " experimental::archetypes::Points2D,"] +#[doc = " MsgSender, RecordingStreamBuilder,"] +#[doc = "};"] +#[doc = ""] +#[doc = "fn main() -> Result<(), Box> {"] +#[doc = " let (rec_stream, storage) = RecordingStreamBuilder::new(\"points\").memory()?;"] +#[doc = ""] +#[doc = " MsgSender::from_archetype(\"points\", &Points2D::new([(0.0, 0.0), (1.0, 1.0)]))?"] +#[doc = " .send(&rec_stream)?;"] +#[doc = ""] +#[doc = " // Log an extra rect to set the view bounds"] +#[doc = " MsgSender::new(\"bounds\")"] +#[doc = " .with_component(&[Rect2D::XCYCWH(Vec4D([0.0, 0.0, 4.0, 3.0]))])?"] +#[doc = " .send(&rec_stream)?;"] +#[doc = ""] +#[doc = " rec_stream.flush_blocking();"] +#[doc = ""] +#[doc = " rerun::native_viewer::show(storage.take())?;"] +#[doc = ""] +#[doc = " Ok(())"] +#[doc = "}"] +#[doc = "```"] #[derive(Debug, Clone, PartialEq)] pub struct Points2D { #[doc = "All the actual 2D points that make up the point cloud."] diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py index 137fefc78fd32..ae145ed950b24 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/points2d.py @@ -15,7 +15,22 @@ @dataclass class Points2D(Archetype): - """A 2D point cloud with positions and optional colors, radii, labels, etc.""" + """ + A 2D point cloud with positions and optional colors, radii, labels, etc. + + Example + ------- + ```python + import rerun as rr + + rr.init("points", spawn=True) + + rr.log_any("simple", rr.Points2D([[0, 0], [1, 1]])) + + # Log an extra rect to set the view bounds + rr.log_rect("bounds", [0, 0, 4, 3], rect_format=rr.RectFormat.XCYCWH) + ``` + """ points: components.Point2DArray = field(metadata={"component": "primary"}) """