Skip to content

Commit

Permalink
Add the remaining space views and name them consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Mar 13, 2024
1 parent 07d711d commit bcbce75
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 27 deletions.
6 changes: 3 additions & 3 deletions examples/python/blueprint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
import rerun as rr # pip install rerun-sdk
from rerun.blueprint import Blueprint, BlueprintPanel, Grid, SelectionPanel, Spatial2D, TimePanel, Viewport
from rerun.blueprint import Blueprint, BlueprintPanel, Grid, SelectionPanel, Spatial2DView, TimePanel, Viewport


def main() -> None:
Expand All @@ -28,8 +28,8 @@ def main() -> None:
blueprint = Blueprint(
Viewport(
Grid(
Spatial2D(name="Rect 0", origin="/", contents=["image", "rect/0"]),
Spatial2D(name="Rect 1", origin="/", contents=["image", "rect/1"]),
Spatial2DView(name="Rect 0", origin="/", contents=["image", "rect/0"]),
Spatial2DView(name="Rect 1", origin="/", contents=["image", "rect/1"]),
),
auto_space_views=args.auto_space_views,
),
Expand Down
19 changes: 16 additions & 3 deletions rerun_py/rerun_sdk/rerun/blueprint/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

151 changes: 138 additions & 13 deletions rerun_py/rerun_sdk/rerun/blueprint/space_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,176 @@
from .api import SpaceView, SpaceViewContentsLike


class Spatial3D(SpaceView):
"""A Spatial 3D space view."""
class BarChartView(SpaceView):
"""A bar chart view."""

def __init__(
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None
):
"""
Construct a blueprint for a new 3D space view.
Construct a blueprint for a new bar chart view.
Parameters
----------
origin
The `EntityPath` to use as the origin of this space view. All other entities will be transformed
The `EntityPath` to use as the origin of this view. All other entities will be transformed
to be displayed relative to this origin.
contents
The contents of the space view. Most commonly specified as a query expression. The individual
The contents of the view. Most commonly specified as a query expression. The individual
sub-expressions must either be newline separate, or provided as a list of strings.
See: [rerun.blueprint.components.QueryExpression][].
name
The name of the space view.
The name of the view.
"""
super().__init__(class_identifier="3D", origin=origin, contents=contents, name=name)
super().__init__(class_identifier="Bar Chart", origin=origin, contents=contents, name=name)


class Spatial2D(SpaceView):
"""A Spatial 2D space view."""
class Spatial2DView(SpaceView):
"""A Spatial 2D view."""

def __init__(
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None
):
"""
Construct a blueprint for a new 2D space view.
Construct a blueprint for a new spatial 2D view.
Parameters
----------
origin
The `EntityPath` to use as the origin of this space view. All other entities will be transformed
The `EntityPath` to use as the origin of this view. All other entities will be transformed
to be displayed relative to this origin.
contents
The contents of the space view. Most commonly specified as a query expression. The individual
The contents of the view. Most commonly specified as a query expression. The individual
sub-expressions must either be newline separate, or provided as a list of strings.
See: [rerun.blueprint.components.QueryExpression][].
name
The name of the space view.
The name of the view.
"""
super().__init__(class_identifier="2D", origin=origin, contents=contents, name=name)


class Spatial3DView(SpaceView):
"""A Spatial 3D view."""

def __init__(
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None
):
"""
Construct a blueprint for a new spatial 3D view.
Parameters
----------
origin
The `EntityPath` to use as the origin of this view. All other entities will be transformed
to be displayed relative to this origin.
contents
The contents of the view. Most commonly specified as a query expression. The individual
sub-expressions must either be newline separate, or provided as a list of strings.
See: [rerun.blueprint.components.QueryExpression][].
name
The name of the view.
"""
super().__init__(class_identifier="3D", origin=origin, contents=contents, name=name)


class TensorView(SpaceView):
"""A tensor view."""

def __init__(
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None
):
"""
Construct a blueprint for a new tensor view.
Parameters
----------
origin
The `EntityPath` to use as the origin of this view. All other entities will be transformed
to be displayed relative to this origin.
contents
The contents of the view. Most commonly specified as a query expression. The individual
sub-expressions must either be newline separate, or provided as a list of strings.
See: [rerun.blueprint.components.QueryExpression][].
name
The name of the view.
"""
super().__init__(class_identifier="Tensor", origin=origin, contents=contents, name=name)


class TextDocumentView(SpaceView):
"""A text document view."""

def __init__(
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None
):
"""
Construct a blueprint for a new text document view.
Parameters
----------
origin
The `EntityPath` to use as the origin of this view. All other entities will be transformed
to be displayed relative to this origin.
contents
The contents of the view. Most commonly specified as a query expression. The individual
sub-expressions must either be newline separate, or provided as a list of strings.
See: [rerun.blueprint.components.QueryExpression][].
name
The name of the view.
"""
super().__init__(class_identifier="Text Document", origin=origin, contents=contents, name=name)


class TextLogView(SpaceView):
"""A text log view."""

def __init__(
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None
):
"""
Construct a blueprint for a new text log view.
Parameters
----------
origin
The `EntityPath` to use as the origin of this view. All other entities will be transformed
to be displayed relative to this origin.
contents
The contents of the view. Most commonly specified as a query expression. The individual
sub-expressions must either be newline separate, or provided as a list of strings.
See: [rerun.blueprint.components.QueryExpression][].
name
The name of the view.
"""
super().__init__(class_identifier="TextLog", origin=origin, contents=contents, name=name)


class TimeSeriesView(SpaceView):
"""A time series view."""

def __init__(
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None
):
"""
Construct a blueprint for a new time series view.
Parameters
----------
origin
The `EntityPath` to use as the origin of this view. All other entities will be transformed
to be displayed relative to this origin.
contents
The contents of the view. Most commonly specified as a query expression. The individual
sub-expressions must either be newline separate, or provided as a list of strings.
See: [rerun.blueprint.components.QueryExpression][].
name
The name of the view.
"""
super().__init__(class_identifier="Time Series", origin=origin, contents=contents, name=name)
26 changes: 18 additions & 8 deletions tests/python/blueprint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@

import rerun as rr
from numpy.random import default_rng
from rerun.blueprint import Blueprint, Grid, Horizontal, Spatial2D, Spatial3D, Tabs, TimePanel, Vertical, Viewport
from rerun.blueprint import (
Blueprint,
Grid,
Horizontal,
Spatial2DView,
Spatial3DView,
Tabs,
TimePanel,
Vertical,
Viewport,
)

if __name__ == "__main__":
blueprint = Blueprint(
Viewport(
Vertical(
Spatial3D(origin="/test1"),
Spatial3DView(origin="/test1"),
Horizontal(
Tabs(
Spatial3D(origin="/test1"),
Spatial2D(origin="/test2"),
Spatial3DView(origin="/test1"),
Spatial2DView(origin="/test2"),
),
Grid(
Spatial3D(origin="/test1"),
Spatial2D(origin="/test2"),
Spatial3D(origin="/test1"),
Spatial2D(origin="/test2"),
Spatial3DView(origin="/test1"),
Spatial2DView(origin="/test2"),
Spatial3DView(origin="/test1"),
Spatial2DView(origin="/test2"),
grid_columns=3,
column_shares=[1, 1, 1],
),
Expand Down

0 comments on commit bcbce75

Please sign in to comment.