Skip to content

Commit d77e025

Browse files
authored
Add the remaining space views and name them consistently (#5498)
### What Just lots of boiler plate with some name changes. Also split the apy.py file into a few sub-modules because it was getting large. All SpaceViews now end in View. - Spatial2DView - Spatial3DView - BarChartView - TensorView - TextDocumentView - TextLogView - TimeSeriesView Testing it out on the plots example: ![image](https://github.com/rerun-io/rerun/assets/3312232/97890949-de50-464e-b640-014f151177b5) ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using newly built examples: [app.rerun.io](https://app.rerun.io/pr/5498/index.html) * Using examples from latest `main` build: [app.rerun.io](https://app.rerun.io/pr/5498/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [app.rerun.io](https://app.rerun.io/pr/5498/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/5498) - [Docs preview](https://rerun.io/preview/bcbce7510db61092c96237a2668518ba564f0227/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/bcbce7510db61092c96237a2668518ba564f0227/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
1 parent fad5244 commit d77e025

File tree

6 files changed

+317
-161
lines changed

6 files changed

+317
-161
lines changed

examples/python/blueprint/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88
import rerun as rr # pip install rerun-sdk
9-
from rerun.blueprint.api import Blueprint, BlueprintPanel, Grid, SelectionPanel, Spatial2D, TimePanel, Viewport
9+
from rerun.blueprint import Blueprint, BlueprintPanel, Grid, SelectionPanel, Spatial2DView, TimePanel, Viewport
1010

1111

1212
def main() -> None:
@@ -28,8 +28,8 @@ def main() -> None:
2828
blueprint = Blueprint(
2929
Viewport(
3030
Grid(
31-
Spatial2D(name="Rect 0", origin="/", contents=["image", "rect/0"]),
32-
Spatial2D(name="Rect 1", origin="/", contents=["image", "rect/1"]),
31+
Spatial2DView(name="Rect 0", origin="/", contents=["image", "rect/0"]),
32+
Spatial2DView(name="Rect 1", origin="/", contents=["image", "rect/1"]),
3333
),
3434
auto_space_views=args.auto_space_views,
3535
),

rerun_py/rerun_sdk/rerun/blueprint/__init__.py

Lines changed: 17 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rerun_py/rerun_sdk/rerun/blueprint/api.py

Lines changed: 3 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ..recording_stream import RecordingStream
1212
from .archetypes import ContainerBlueprint, PanelBlueprint, SpaceViewBlueprint, SpaceViewContents, ViewportBlueprint
1313
from .components import ColumnShareArrayLike, RowShareArrayLike
14-
from .components.container_kind import ContainerKind, ContainerKindLike
14+
from .components.container_kind import ContainerKindLike
1515

1616
SpaceViewContentsLike = Union[str, Sequence[str], Utf8Like, SpaceViewContents]
1717

@@ -70,6 +70,8 @@ def blueprint_path(self) -> str:
7070

7171
def to_viewport(self) -> Viewport:
7272
"""Convert this space view to a viewport."""
73+
from .containers import Grid
74+
7375
return Viewport(Grid(self))
7476

7577
def to_blueprint(self) -> Blueprint:
@@ -112,56 +114,6 @@ def _iter_space_views(self) -> Iterable[bytes]:
112114
return [self.id.bytes]
113115

114116

115-
class Spatial3D(SpaceView):
116-
"""A Spatial 3D space view."""
117-
118-
def __init__(
119-
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None
120-
):
121-
"""
122-
Construct a blueprint for a new 3D space view.
123-
124-
Parameters
125-
----------
126-
origin
127-
The `EntityPath` to use as the origin of this space view. All other entities will be transformed
128-
to be displayed relative to this origin.
129-
contents
130-
The contents of the space view. Most commonly specified as a query expression. The individual
131-
sub-expressions must either be newline separate, or provided as a list of strings.
132-
See: [rerun.blueprint.components.QueryExpression][].
133-
name
134-
The name of the space view.
135-
136-
"""
137-
super().__init__(class_identifier="3D", origin=origin, contents=contents, name=name)
138-
139-
140-
class Spatial2D(SpaceView):
141-
"""A Spatial 2D space view."""
142-
143-
def __init__(
144-
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None
145-
):
146-
"""
147-
Construct a blueprint for a new 2D space view.
148-
149-
Parameters
150-
----------
151-
origin
152-
The `EntityPath` to use as the origin of this space view. All other entities will be transformed
153-
to be displayed relative to this origin.
154-
contents
155-
The contents of the space view. Most commonly specified as a query expression. The individual
156-
sub-expressions must either be newline separate, or provided as a list of strings.
157-
See: [rerun.blueprint.components.QueryExpression][].
158-
name
159-
The name of the space view.
160-
161-
"""
162-
super().__init__(class_identifier="2D", origin=origin, contents=contents, name=name)
163-
164-
165117
class Container:
166118
"""
167119
Base class for all container types.
@@ -252,96 +204,6 @@ def _iter_space_views(self) -> Iterable[bytes]:
252204
return itertools.chain.from_iterable(sub._iter_space_views() for sub in self.contents)
253205

254206

255-
class Horizontal(Container):
256-
"""A horizontal container."""
257-
258-
def __init__(self, *contents: Container | SpaceView, column_shares: Optional[ColumnShareArrayLike] = None):
259-
"""
260-
Construct a new horizontal container.
261-
262-
Parameters
263-
----------
264-
*contents:
265-
All positional arguments are the contents of the container, which may be either other containers or space views.
266-
column_shares
267-
The layout shares of the columns in the container. The share is used to determine what fraction of the total width each
268-
column should take up. The column with index `i` will take up the fraction `shares[i] / total_shares`.
269-
270-
"""
271-
super().__init__(*contents, kind=ContainerKind.Horizontal, column_shares=column_shares)
272-
273-
274-
class Vertical(Container):
275-
"""A vertical container."""
276-
277-
def __init__(self, *contents: Container | SpaceView, row_shares: Optional[RowShareArrayLike] = None):
278-
"""
279-
Construct a new vertical container.
280-
281-
Parameters
282-
----------
283-
*contents:
284-
All positional arguments are the contents of the container, which may be either other containers or space views.
285-
row_shares
286-
The layout shares of the rows in the container. The share is used to determine what fraction of the total height each
287-
row should take up. The ros with index `i` will take up the fraction `shares[i] / total_shares`.
288-
289-
"""
290-
super().__init__(*contents, kind=ContainerKind.Vertical, row_shares=row_shares)
291-
292-
293-
class Grid(Container):
294-
"""A grid container."""
295-
296-
def __init__(
297-
self,
298-
*contents: Container | SpaceView,
299-
column_shares: Optional[ColumnShareArrayLike] = None,
300-
row_shares: Optional[RowShareArrayLike] = None,
301-
grid_columns: Optional[int] = None,
302-
):
303-
"""
304-
Construct a new grid container.
305-
306-
Parameters
307-
----------
308-
*contents:
309-
All positional arguments are the contents of the container, which may be either other containers or space views.
310-
column_shares
311-
The layout shares of the columns in the container. The share is used to determine what fraction of the total width each
312-
column should take up. The column with index `i` will take up the fraction `shares[i] / total_shares`.
313-
row_shares
314-
The layout shares of the rows in the container. The share is used to determine what fraction of the total height each
315-
row should take up. The ros with index `i` will take up the fraction `shares[i] / total_shares`.
316-
grid_columns
317-
The number of columns in the grid.
318-
319-
"""
320-
super().__init__(
321-
*contents,
322-
kind=ContainerKind.Grid,
323-
column_shares=column_shares,
324-
row_shares=row_shares,
325-
grid_columns=grid_columns,
326-
)
327-
328-
329-
class Tabs(Container):
330-
"""A tab container."""
331-
332-
def __init__(self, *contents: Container | SpaceView):
333-
"""
334-
Construct a new tab container.
335-
336-
Parameters
337-
----------
338-
*contents:
339-
All positional arguments are the contents of the container, which may be either other containers or space views.
340-
341-
"""
342-
super().__init__(*contents, kind=ContainerKind.Tabs)
343-
344-
345207
class Viewport:
346208
"""
347209
The top-level description of the Viewport.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
from __future__ import annotations
2+
3+
from typing import Optional
4+
5+
from .api import Container, SpaceView
6+
from .components import ColumnShareArrayLike, RowShareArrayLike
7+
from .components.container_kind import ContainerKind
8+
9+
10+
class Horizontal(Container):
11+
"""A horizontal container."""
12+
13+
def __init__(self, *contents: Container | SpaceView, column_shares: Optional[ColumnShareArrayLike] = None):
14+
"""
15+
Construct a new horizontal container.
16+
17+
Parameters
18+
----------
19+
*contents:
20+
All positional arguments are the contents of the container, which may be either other containers or space views.
21+
column_shares
22+
The layout shares of the columns in the container. The share is used to determine what fraction of the total width each
23+
column should take up. The column with index `i` will take up the fraction `shares[i] / total_shares`.
24+
25+
"""
26+
super().__init__(*contents, kind=ContainerKind.Horizontal, column_shares=column_shares)
27+
28+
29+
class Vertical(Container):
30+
"""A vertical container."""
31+
32+
def __init__(self, *contents: Container | SpaceView, row_shares: Optional[RowShareArrayLike] = None):
33+
"""
34+
Construct a new vertical container.
35+
36+
Parameters
37+
----------
38+
*contents:
39+
All positional arguments are the contents of the container, which may be either other containers or space views.
40+
row_shares
41+
The layout shares of the rows in the container. The share is used to determine what fraction of the total height each
42+
row should take up. The ros with index `i` will take up the fraction `shares[i] / total_shares`.
43+
44+
"""
45+
super().__init__(*contents, kind=ContainerKind.Vertical, row_shares=row_shares)
46+
47+
48+
class Grid(Container):
49+
"""A grid container."""
50+
51+
def __init__(
52+
self,
53+
*contents: Container | SpaceView,
54+
column_shares: Optional[ColumnShareArrayLike] = None,
55+
row_shares: Optional[RowShareArrayLike] = None,
56+
grid_columns: Optional[int] = None,
57+
):
58+
"""
59+
Construct a new grid container.
60+
61+
Parameters
62+
----------
63+
*contents:
64+
All positional arguments are the contents of the container, which may be either other containers or space views.
65+
column_shares
66+
The layout shares of the columns in the container. The share is used to determine what fraction of the total width each
67+
column should take up. The column with index `i` will take up the fraction `shares[i] / total_shares`.
68+
row_shares
69+
The layout shares of the rows in the container. The share is used to determine what fraction of the total height each
70+
row should take up. The ros with index `i` will take up the fraction `shares[i] / total_shares`.
71+
grid_columns
72+
The number of columns in the grid.
73+
74+
"""
75+
super().__init__(
76+
*contents,
77+
kind=ContainerKind.Grid,
78+
column_shares=column_shares,
79+
row_shares=row_shares,
80+
grid_columns=grid_columns,
81+
)
82+
83+
84+
class Tabs(Container):
85+
"""A tab container."""
86+
87+
def __init__(self, *contents: Container | SpaceView):
88+
"""
89+
Construct a new tab container.
90+
91+
Parameters
92+
----------
93+
*contents:
94+
All positional arguments are the contents of the container, which may be either other containers or space views.
95+
96+
"""
97+
super().__init__(*contents, kind=ContainerKind.Tabs)

0 commit comments

Comments
 (0)