Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code examples & screenshots for all blueprint view types #6304

Merged
merged 9 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include "rerun/attributes.fbs";
namespace rerun.blueprint.views;

/// A bar chart view.
///
/// \example views/bar_chart title="Use a blueprint to create a BarChartView." image="https://static.rerun.io/bar_chart_view/74fa45af3c7310b51cd283c37439ed8f8ca9356d/1200w.png"
table BarChartView (
"attr.rerun.view_identifier": "BarChart"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include "rerun/attributes.fbs";
namespace rerun.blueprint.views;

/// A Spatial 2D view.
///
/// \example views/spatial2d title="Use a blueprint to customize a Spatial2DView." image="https://static.rerun.io/spatial2d/074c0822870325d6502c9f51c165c1181a20e83f/1200w.png"
table Spatial2DView (
"attr.rerun.view_identifier": "2D"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace rerun.blueprint.views;

/// A Spatial 3D view.
///
/// \example views/spatial3dview title="Use a blueprint to customize a Spatial3DView"
/// \example views/spatial3d title="Use a blueprint to customize a Spatial3DView." image="https://static.rerun.io/spatial3d/4816694fc4176cc284ff30d9c8f06c936a625ac9/1200w.png"
table Spatial3DView (
"attr.rerun.view_identifier": "3D"
) {
Expand Down
2 changes: 2 additions & 0 deletions crates/re_types/definitions/rerun/blueprint/views/tensor.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include "rerun/attributes.fbs";
namespace rerun.blueprint.views;

/// A tensor view.
///
/// \example views/tensor title="Use a blueprint to create a TensorView." image="https://static.rerun.io/tensor_view/3b452ace3cdb29ada1a613eae8e8e8e165a1d396/1200w.png"
table TensorView (
"attr.rerun.view_identifier": "Tensor"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include "rerun/attributes.fbs";
namespace rerun.blueprint.views;

/// A text document view.
///
/// \example views/text_document title="Use a blueprint to show a text document." image="https://static.rerun.io/text_log/27f15235fe9639ff42b6ea0d2f0ce580685c021c/1200w.png"
table TextDocumentView (
"attr.rerun.view_identifier": "TextDocument"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include "rerun/attributes.fbs";
namespace rerun.blueprint.views;

/// A text log view.
///
/// \example views/text_log title="Use a blueprint to show a TextLogView." image="https://static.rerun.io/text_log/457ab91ec42a481bacae4146c0fc01eee397bb86/1200w.png"
table TextLogView (
"attr.rerun.view_identifier": "TextLog"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace rerun.blueprint.views;

/// A time series view.
///
/// \example views/timeseriesview title="Use a blueprint to customize a TimeSeriesView"
/// \example views/timeseries title="Use a blueprint to customize a TimeSeriesView." image="https://static.rerun.io/timeseries_view/c87150647feb413627fdb8563afe33b39d7dbf57/1200w.png"
table TimeSeriesView (
"attr.rerun.view_identifier": "TimeSeries"
) {
Expand Down
14 changes: 14 additions & 0 deletions docs/content/reference/types/views/bar_chart_view.md

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

14 changes: 14 additions & 0 deletions docs/content/reference/types/views/spatial2d_view.md

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

12 changes: 10 additions & 2 deletions docs/content/reference/types/views/spatial3d_view.md

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

14 changes: 14 additions & 0 deletions docs/content/reference/types/views/tensor_view.md

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

14 changes: 14 additions & 0 deletions docs/content/reference/types/views/text_document_view.md

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

14 changes: 14 additions & 0 deletions docs/content/reference/types/views/text_log_view.md

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

12 changes: 10 additions & 2 deletions docs/content/reference/types/views/time_series_view.md

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

14 changes: 14 additions & 0 deletions docs/snippets/all/views/bar_chart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Use a blueprint to show a bar chart."""

import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_bar_chart", spawn=True)
# It's recommended to log bar charts with the `rr.BarChart` archetype,
# but single dimensional tensors can also be used if a `BarChartView` is created explicitly.
rr.log("tensor", rr.Tensor([8, 4, 0, 9, 1, 4, 1, 6, 9, 0]))

# Create a bar chart view to display the chart.
blueprint = rrb.Blueprint(rrb.BarChartView(origin="tensor", name="Bar Chart"), collapse_panels=True)

rr.send_blueprint(blueprint)
32 changes: 32 additions & 0 deletions docs/snippets/all/views/spatial2d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Use a blueprint to customize a Spatial2DView."""

import numpy as np
import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_spatial_2d", spawn=True)

# Create a spiral of points:
theta = np.linspace(0, 10 * np.pi, 300)
radius = np.linspace(0, 10, 300)
positions = np.column_stack((np.cos(theta) * radius, np.sin(theta) * radius))
colors = np.random.randint(0, 255, size=(len(theta), 3))

rr.log("points", rr.Points2D(positions, colors=colors, radii=0.1))
rr.log("box", rr.Boxes2D(half_sizes=[3, 3], colors=0))

# Create a Spatial2D view to display the points.
blueprint = rrb.Blueprint(
rrb.Spatial2DView(
origin="/",
name="2D Scene",
# Set the background color to light blue.
background=[100, 149, 237],
# Note that this range is smaller than the range of the points,
# so some points will not be visible.
visual_bounds=rrb.VisualBounds(x_range=[-5, 5], y_range=[-5, 5]),
),
collapse_panels=True,
)

rr.send_blueprint(blueprint)
29 changes: 29 additions & 0 deletions docs/snippets/all/views/spatial3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Use a blueprint to customize a Spatial3DView."""

import rerun as rr
import rerun.blueprint as rrb
from numpy.random import default_rng

rr.init("rerun_example_spatial_3d", spawn=True)

# Create some random points.
rng = default_rng(12345)
positions = rng.uniform(-5, 5, size=[50, 3])
colors = rng.uniform(0, 255, size=[50, 3])
radii = rng.uniform(0.1, 0.5, size=[50])

rr.log("points", rr.Points3D(positions, colors=colors, radii=radii))
rr.log("box", rr.Boxes3D(half_sizes=[5, 5, 5], colors=0))

# Create a Spatial3D view to display the points.
blueprint = rrb.Blueprint(
rrb.Spatial3DView(
origin="/",
name="3D Scene",
# Set the background color to light blue.
background=[100, 149, 237],
),
collapse_panels=True,
)

rr.send_blueprint(blueprint)
25 changes: 0 additions & 25 deletions docs/snippets/all/views/spatial3dview.py

This file was deleted.

17 changes: 17 additions & 0 deletions docs/snippets/all/views/tensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Use a blueprint to show a tensor view."""

import numpy as np
import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_tensor", spawn=True)

tensor_one = np.random.randint(0, 256, (8, 6, 3, 5), dtype=np.uint8)
rr.log("tensors/one", rr.Tensor(tensor_one, dim_names=("width", "height", "channel", "batch")))
tensor_two = np.random.random_sample((10, 20, 30))
rr.log("tensors/two", rr.Tensor(tensor_two))

# Create a tensor view that displays both tensors (you can switch between them inside the view).
blueprint = rrb.Blueprint(rrb.TensorView(origin="/tensors", name="Tensors"), collapse_panels=True)

rr.send_blueprint(blueprint)
53 changes: 53 additions & 0 deletions docs/snippets/all/views/text_document.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Use a blueprint to show a text document."""

import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_text_document", spawn=True)

rr.log(
"markdown",
rr.TextDocument(
'''
# Hello Markdown!
[Click here to see the raw text](recording://markdown:Text).

Basic formatting:

| **Feature** | **Alternative** |
| ----------------- | --------------- |
| Plain | |
| *italics* | _italics_ |
| **bold** | __bold__ |
| ~~strikethrough~~ | |
| `inline code` | |

----------------------------------

## Support
- [x] [Commonmark](https://commonmark.org/help/) support
- [x] GitHub-style strikethrough, tables, and checkboxes
- Basic syntax highlighting for:
- [x] C and C++
- [x] Python
- [x] Rust
- [ ] Other languages

## Links
You can link to [an entity](recording://markdown),
a [specific instance of an entity](recording://markdown[#0]),
or a [specific component](recording://markdown:Text).

Of course you can also have [normal https links](https://github.com/rerun-io/rerun), e.g. <https://rerun.io>.

## Image
![A random image](https://picsum.photos/640/480)
'''.strip(),
media_type=rr.MediaType.MARKDOWN,
),
)

# Create a text view that displays the markdown.
blueprint = rrb.Blueprint(rrb.TextDocumentView(origin="markdown", name="Markdown example"), collapse_panels=True)

rr.send_blueprint(blueprint)
19 changes: 19 additions & 0 deletions docs/snippets/all/views/text_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Use a blueprint to show a text log."""

import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_text_log", spawn=True)

rr.set_time_sequence("time", 0)
rr.log("log/status", rr.TextLog("Application started.", level=rr.TextLogLevel.INFO))
rr.set_time_sequence("time", 5)
rr.log("log/other", rr.TextLog("A warning.", level=rr.TextLogLevel.WARN))
for i in range(10):
rr.set_time_sequence("time", i)
rr.log("log/status", rr.TextLog(f"Processing item {i}.", level=rr.TextLogLevel.INFO))

# Create a text view that displays all logs.
blueprint = rrb.Blueprint(rrb.TextLogView(origin="/log", name="Text Logs"), collapse_panels=True)

rr.send_blueprint(blueprint)
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
end=rrb.TimeRangeBoundary.infinite(),
),
],
)
),
collapse_panels=True,
)

rr.send_blueprint(blueprint)
Loading
Loading