Skip to content
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
4 changes: 2 additions & 2 deletions docs/_scripts/homepage_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def build_viewer(*, show: bool) -> napari.Viewer:
layer.rendering = RENDERING
layer.attenuation = ATTENUATION
layer.colormap = COLORMAP
viewer.scale_bar.visible = True
viewer.axes.visible = True
viewer.canvas.scale_bar.visible = True
viewer.scene.axes.visible = True
viewer.dims.axis_labels = ('T', 'Z', 'Y', 'X')
viewer.window._qt_window.resize(*WINDOW_SIZE)
viewer.fit_to_view()
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/open_images.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ file_path_ply = pooch.retrieve(
viewer = napari.Viewer()
viewer.open(file_path_ply, plugin='napari-meshio')
viewer.dims.ndisplay = 3
viewer.camera.angles = (92, -24, 15)
viewer.scene.camera.angles = (92, -24, 15)
nbscreenshot(viewer, alt_text="napari viewer showing a 3D mesh of an airplane opened via napari-meshio.")
```

Expand Down
35 changes: 26 additions & 9 deletions docs/getting_started/viewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ The **canvas** is in the center of the viewer and contains the visual display of

+++

```{seealso}
The canvas model can be accessed via `viewer.canvas`; several things are exposed here, such as the [grid mode](grid-mode), [canvas overlays](viewer-overlays) and the overlay tiling settings.
```

(layer-list)=

### Layer list
Expand Down Expand Up @@ -510,8 +514,8 @@ tags: [hide-input]
---
# programmatically adjust the camera angle
viewer.dims.ndisplay = 3
viewer.camera.zoom = 2
viewer.camera.angles = (3, 38, 53)
viewer.scene.camera.zoom = 2
viewer.scene.camera.angles = (3, 38, 53)
nbscreenshot(viewer, alt_text="A rotated 3D view")
```

Expand All @@ -536,13 +540,17 @@ Note that if you want to drag the canvas/rendering itself, instead of rotating t
The camera perspective can also be altered programmatically:

```python
viewer.camera.perspective = 45
viewer.scene.camera.perspective = 45
```

By default, camera center and zoom persist when switching between 2D and 3D
views (synced mode). You can change this behavior via the camera popup, the
**View** menu (**Toggle Synced Camera**, {kbd}`Ctrl+U`), or programmatically
through `viewer.camera.synced`. See the [camera guide](camera-guide) for details.
through `viewer.scene.camera.synced`. See the [camera guide](camera-guide) for details.

```{note}
The scene model also gives you access to [scene overlays](viewer-overlays)!
```

### Roll dimensions

Expand Down Expand Up @@ -589,6 +597,8 @@ Note that this has no effect on the order of `viewer.dims.current_step`. The fir

The fourth button transposes the displayed dimensions.

(grid-mode)=

### Grid button

The fifth button, the grid button, toggles between the default layer mode and grid mode. When clicked, it distributes the layers in a grid of cells. Each cell is a small interactive canvas whose camera is linked with all the others.
Expand All @@ -606,7 +616,7 @@ The fifth button, the grid button, toggles between the default layer mode and gr
</figure>
```

The distribution of the layers in the grid can be altered according to the settings below, accessible by right-clicking the button (or programmatically through `viewer.grid`). The question icons can be hovered for more information about each setting.
The distribution of the layers in the grid can be altered according to the settings below, accessible by right-clicking the button (or programmatically through `viewer.canvas.grid`). The question icons can be hovered for more information about each setting.

1. Grid stride: By default, 1, placing one layer in each view. The value determines the number of layers overlaid in each view. Negative values reverse the order in which layers are displayed in the grid.
1. Grid width/height: By default, -1, which automatically determines the grid layout.
Expand Down Expand Up @@ -635,15 +645,22 @@ The right side of the status bar contains some helpful tips depending on which l
Overlays provide additional information about the render state and the data, displayed on the canvas itself.
In napari there are two main types: canvas overlays - which are locked in position on the screen and hover over the rendered canvas - and scene overlays - which are located somewhere in world coordinates and follow the camera and dims just like layers. Canvas overlays can be positioned in various locations on the canvas (e.g: `top_left`, `bottom_center`), and will automatically tile if multiple are present at the same location.

The viewer gives access to a few such overlays:
Canvas overlays can be accessed via `viewer.canvas.overlays`:

- Scale bar (canvas overlay, accessible via `viewer.canvas.overlays.scale_bar`): it displays distances in world coordinates for the displayed scene. The scale bar usually inherits layer units when they are set. If inference fails it can fall back to a dimensionless label, and if displayed axes mix dimensionalities it uses the last displayed axis unit with a warning. You can control its appearance and fixed length from the viewer. See the [units guide](units-guide) for more information.
- Canvas Axes (canvas overlay, accessible via `viewer.canvas.overlays.axes`): displays basic axes in a corner of the canvas, linked to the viewer's camera.
- Text (canvas overlay, accessible via `viewer.canvas.overlays.text`): displays arbitrary text on the canvas.

- Scale bar (canvas overlay, accessible via `viewer.scale_bar`): it displays distances in world coordinates for the displayed scene. The scale bar usually inherits layer units when they are set. If inference fails it can fall back to a dimensionless label, and if displayed axes mix dimensionalities it uses the last displayed axis unit with a warning. You can control its appearance and fixed length from the viewer. See the [units guide](units-guide) for more information.
- Axes (scene overlay, accessible via `viewer.axes`): displays basis axes at the origin.
- Text Overlay (canvas overlay, accessible via `viewer.text_overlay`): displays arbitrary text on the canvas.
Scene overlays live on `viewer.scene.overlays`:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you comment about layer-scene overlays / cross-link to them (like the bounding box)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a comment just below here in line 664!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh the problem with reading only the changed diff 🤦 sorry for the noise. Hopefully it's noticeable enough there :)

- Scene Axes (scene overlay, accessible via `viewer.scene.axes`): displays basis axes at the origin in the scene.

These overlays can also be accessed via graphical interface through the **View** menu and their respective submenus.

```{tip}
`canvas.overlays` and `scene.overlays` are smart dictionaries that allows access via attributes, instead of only via keys. So a shorthand for `viewer.canvas.overlays['text'] is `viewer.canvas.overlays.text`!
```

```{seealso}
Similarly to the viewer, layers [also have some overlays](layer-overlays) that can be used to display layer-specific information!
```

Expand Down
16 changes: 8 additions & 8 deletions docs/guides/camera.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ state independently.
The current mode is controlled by {attr}`~napari.components.Camera.synced`:

```python
viewer.camera.synced = True # synced mode (default)
viewer.camera.synced = False # separate mode
viewer.scene.camera.synced = True # synced mode (default)
viewer.scene.camera.synced = False # separate mode
```

(camera-synced-mode)=
Expand Down Expand Up @@ -105,10 +105,10 @@ From the **View** menu, select **Toggle Synced Camera**

```python
# Switch to separate mode
viewer.camera.synced = False
viewer.scene.camera.synced = False

# Switch back to default synced mode
viewer.camera.synced = True
viewer.scene.camera.synced = True
```

### Settings — Persistent preference
Expand All @@ -135,16 +135,16 @@ programmatically:

```python
# Center of the view (in world coordinates)
viewer.camera.center = (0, 100, 200)
viewer.scene.camera.center = (0, 100, 200)

# Zoom level (pixels per world unit)
viewer.camera.zoom = 4.0
viewer.scene.camera.zoom = 4.0

# Euler angles for 3D rotation (only used in 3D mode)
viewer.camera.angles = (30, 45, 0)
viewer.scene.camera.angles = (30, 45, 0)

# Perspective (field of view) in 3D mode
viewer.camera.perspective = 30
viewer.scene.camera.perspective = 30
```

For more on axis orientation and handedness, see {ref}`handedness-guide`.
Expand Down
12 changes: 6 additions & 6 deletions docs/guides/handedness.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ viewer, sst_layer = napari.imshow(
colormap='magma',
)
viewer.dims.axis_labels = sst.sst.dims
viewer.axes.visible = True
viewer.scene.overlays.axes.visible = True
```

```{code-cell} python
Expand All @@ -86,7 +86,7 @@ down (incorrectly [since Ptolemy](https://en.wikipedia.org/wiki/History_of_carto
Instead, we can flip the *axis orientation* so that the vertical axis (latitude) points up:

```{code-cell} python
viewer.camera.orientation2d = ('up', 'right')
viewer.scene.camera.orientation2d = ('up', 'right')
```

```{code-cell} python
Expand Down Expand Up @@ -142,9 +142,9 @@ layer = viewer.add_surface((vertices, faces), name='1BNA', shading='smooth')
---
tags: [remove-input]
---
viewer.camera.angles = (90, 0, 0)
viewer.camera.zoom = 16
viewer.axes.visible = True
viewer.scene.camera.angles = (90, 0, 0)
viewer.scene.camera.zoom = 16
viewer.scene.overlays.axes.visible = True

nbscreenshot(viewer)
```
Expand All @@ -154,7 +154,7 @@ a right-handed helix. However, if we flip one of the axes (as they were in napar
we will get the mirror image of the DNA, which will be physically inaccurate:

```{code-cell} python
viewer.camera.orientation = ('away', 'down', 'right')
viewer.scene.camera.orientation = ('away', 'down', 'right')
```

```{code-cell} python
Expand Down
4 changes: 2 additions & 2 deletions docs/howtos/layers/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ viewer.dims.ndisplay = 3
tags: [hide-input]
---
# programmatically adjust the camera angle
viewer.camera.zoom = 2
viewer.camera.angles = (3, 38, 53)
viewer.scene.camera.zoom = 2
viewer.scene.camera.angles = (3, 38, 53)
nbscreenshot(viewer, alt_text="A 3D view of a labels layer on top of 3D blobs")
```

Expand Down
Loading