diff --git a/docs/_scripts/homepage_video.py b/docs/_scripts/homepage_video.py index 9c3e5270a..5cb973404 100644 --- a/docs/_scripts/homepage_video.py +++ b/docs/_scripts/homepage_video.py @@ -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() diff --git a/docs/getting_started/open_images.md b/docs/getting_started/open_images.md index 5352169ef..b77302495 100644 --- a/docs/getting_started/open_images.md +++ b/docs/getting_started/open_images.md @@ -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.") ``` diff --git a/docs/getting_started/viewer.md b/docs/getting_started/viewer.md index e224458fa..82f5d205e 100644 --- a/docs/getting_started/viewer.md +++ b/docs/getting_started/viewer.md @@ -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 @@ -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") ``` @@ -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 @@ -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. @@ -606,7 +616,7 @@ The fifth button, the grid button, toggles between the default layer mode and gr ``` -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. @@ -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`: +- 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! ``` diff --git a/docs/guides/camera.md b/docs/guides/camera.md index 3efc22af2..e48df9dc8 100644 --- a/docs/guides/camera.md +++ b/docs/guides/camera.md @@ -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)= @@ -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 @@ -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`. diff --git a/docs/guides/handedness.md b/docs/guides/handedness.md index d12d342de..c645383cf 100644 --- a/docs/guides/handedness.md +++ b/docs/guides/handedness.md @@ -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 @@ -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 @@ -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) ``` @@ -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 diff --git a/docs/howtos/layers/labels.md b/docs/howtos/layers/labels.md index d4eba9cb4..3a06a53aa 100644 --- a/docs/howtos/layers/labels.md +++ b/docs/howtos/layers/labels.md @@ -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") ```