Skip to content

Commit b6b61df

Browse files
dalthvizmelissawmpsobolewskiPhDjni
authored
Add basic layer modes description, including transform button (#420)
# References and relevant issues Depends on napari/napari#6794 # Description Adds new content related with layers transform mode and base possible values (`pan_zoom` and `transform`) --------- Co-authored-by: Melissa Weber Mendonça <melissawm@gmail.com> Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com> Co-authored-by: Juan Nunez-Iglesias <jni@fastmail.com>
1 parent 105c102 commit b6b61df

File tree

10 files changed

+179
-81
lines changed

10 files changed

+179
-81
lines changed

docs/guides/layers.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ currently supported by napari, check out the
2828
introduction, check out the
2929
[Layer list section in the napari viewer tutorial](layer-list).
3030

31+
(layer_mode)=
32+
## Layer mode
33+
34+
All our layers support a `mode` property that changes the way you interact
35+
with the layer from the viewer. These modes are accessible via the layer controls
36+
widget top buttons and via keyboard shortcuts (these shortcuts will vary depending on the layer type). Currently, there are two base modes:
37+
38+
* Pan and zoom
39+
![image: Pan/zoom](../images/pan-zoom-tool.png)
40+
41+
The `pan_zoom` mode allows you to pan around and zoom in/out the layer. It's
42+
the default mode selected. Note: zooming with the mouse-wheel should essentially always work!
43+
44+
* Transform
45+
![image: Transform](../images/transform-tool.png)
46+
47+
The `transform` mode allows you to translate, rotate, and scale the layer
48+
graphically. Note: While you can transform 3D layers, at present this mode is only usable in 2D viewer display mode.
49+
To reset the transformation, you can Option/Alt-click the transform
50+
button over the layer controls (a confirmation dialog will open to confirm
51+
the reset).
52+
53+
For a more detailed description of layer modes available check each
54+
[layer how-to guide](using-layers).
55+
3156
## Layer visibility
3257

3358
All our layers support a visibility toggle that allows you to set the `visible`

docs/howtos/layers/image.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,38 @@ For more information about layers, refer to [Layers at a glance](../../guides/la
2525

2626
The GUI contains following tools in the `layer controls` panel for the `image`
2727
layer:
28-
* Opacity
29-
* Contrast Limits
30-
* Auto-contrast
31-
* Gamma
32-
* Colormap
33-
* Blending
34-
* Interpolation
28+
29+
* Buttons
30+
* Pan/zoom
31+
* Transform
32+
* Controls
33+
* Opacity
34+
* Contrast Limits
35+
* Auto-contrast
36+
* Gamma
37+
* Colormap
38+
* Blending
39+
* Interpolation
3540

3641
Before we can use any of the GUI `layer controls`, we must load an image.
3742
1. Start napari.
3843
2. Click `File` > `Open Sample` > `napari builtins` > `Cells (3D+2Ch)` or any
3944
sample image of your choice.
4045

46+
### Buttons
47+
48+
* `Pan/zoom` ![image: Pan/zoom tool](../../images/pan-zoom-tool.png) is the default mode
49+
of the layer and supports panning and zooming. Press the `1` key when the layer is selected
50+
to use this mode.
51+
52+
* `Transform` ![image: Transform](../../images/transform-tool.png) enables you to
53+
rotate, scale, or translate the layer. Note: at present this feature is limited to 2D viewer display mode.
54+
To reset the transformation,
55+
you can Option/Alt-click the transform button (a confirmation dialog will open to
56+
confirm the reset). Press the `2` key when the layer is selected to use this mode.
57+
58+
### Controls
59+
4160
The GUI controls may be adjusted as follows:
4261

4362
* `opacity` is adjusted by moving the circle along the slider until the image

docs/howtos/layers/labels.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ layer:
4646
* fill bucket
4747
* color picker
4848
* pan/zoom mode
49+
* transform mode
4950
* Controls
5051
* label
5152
* opacity
@@ -257,6 +258,15 @@ pan and zoom is selected, editing the layer is not possible. Once you click on
257258
one of the editing tools, pan and zoom is turned off. Return to pan and zoom
258259
mode by pressing the `6` key when the `labels layer` is selected.
259260

261+
### Transform mode
262+
263+
This mode is represented by ![image: Transform](../../images/transform-tool.png) in the
264+
`layer controls` panel. It enables you to rotate, scale, or translate the layer.
265+
Note: at present this feature is limited to 2D viewer display mode.
266+
To reset the transformation, you can Option/Alt-click the transform button (a
267+
confirmation dialog will open to confirm the reset). Enable this mode by pressing
268+
the `7` key when the `labels layer` is selected.
269+
260270
### Creating a new `labels layer`
261271

262272
Create a brand-new empty `labels layer` by clicking the `New labels layer`

docs/howtos/layers/points.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ layer:
5454
* Add points
5555
* Select points
5656
* Pan/zoom
57+
* Transform
5758
* Controls
5859
* Opacity
5960
* Point size
@@ -125,6 +126,15 @@ layer:
125126
options are supported only when viewing a layer using 2D rendering. Return to
126127
pan and zoom mode by pressing the `4` key when the points layer is selected.
127128

129+
* **Transform**
130+
![image: Transform](../../images/transform-tool.png)
131+
132+
Use this tool to rotate, scale, or translate the layer.
133+
Note: at present this feature is limited to 2D viewer display mode. To reset the transformation,
134+
you can Option/Alt-click the transform button (a confirmation dialog will open to
135+
confirm the reset). Enable this mode by pressing the `5` key when the points layer
136+
is selected.
137+
128138
### Controls
129139

130140
* Opacity

docs/howtos/layers/shapes.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ are used. i.e. You can't remove a vertex before you have created a shape.
118118
* Select vertices
119119
* Select shapes
120120
* Pan/zoom
121+
* Transform
121122
* Move to back
122123
* Move to front
123124
* Add ellipses
@@ -171,12 +172,20 @@ are used. i.e. You can't remove a vertex before you have created a shape.
171172
than one shape, select one, hold down the shift key and select the rest.
172173

173174
* **Pan/zoom**
174-
![image: Select shapes](../../images/pan-zoom-tool.png)
175+
![image: Pan/zoom](../../images/pan-zoom-tool.png)
175176

176-
Use this tool to pan around the image or zoom in. Pan and zoom functionality
177-
is disabled when using the adding and editing tools. Temporarily re-enable pan
178-
and zoom by pressing and holding the spacebar. This feature can be useful if
179-
you want to move around the shapes layer as you edit it.
177+
Use this tool to pan around the layer or zoom in. Pan functionality
178+
is disabled when using the adding and editing tools; however, zoom using the mouse-wheel will typically continue to work. To activate the tool,
179+
you can press `6`. Temporarily re-enable pan and zoom by pressing and holding
180+
the spacebar. This feature can be useful if you want to move around the shapes
181+
layer as you edit it.
182+
183+
* **Transform**
184+
![image: Transform](../../images/transform-tool.png)
185+
186+
Use this tool to rotate, scale, or translate the layer. Note: at present this feature is limited to 2D viewer display mode. To activate the tool,
187+
you can press `7`. To reset the transformation, you can Option/Alt-click the
188+
transform button (a confirmation dialog will open to confirm the reset).
180189

181190
* **Move to back**
182191
![image: Move to back](../../images/shape-move-to-back.png)

docs/howtos/layers/surface.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,29 @@ viewer.close()
7777
Once you have created a `surface` layer programmatically, the following GUI
7878
controls are available in the viewer:
7979

80-
* Opacity - use this slider control to assign opacity from 0 to 1.00 where 0 is
81-
transparent and 1.00 is completely opaque.
82-
* Contrast Limits - click and slide the dots on either end of the slider bar to
83-
adjust upper and lower contrast limits.
84-
* Auto-contrast - choose once or continuous.
85-
* Gamma - Click on the oval on the gamma slider bar and adjust it to any value
86-
between 0.20 and 2.00. Gamma correction or gamma is a nonlinear operation used
87-
to encode and decode luminance or tristimulus values in video or still image
88-
systems.
89-
* Colormap - select a value from the dropdown list.
90-
* Blending - Choose `opaque`, `translucent`, `translucent no depth`, or
91-
`additive` from the dropdown. Refer to the [Blending layers](blending-layers)
92-
section of _Layers at a glance_ for an explanation of each type of blending.
93-
* Shading - Choose `none`, `flat`, or `smooth` from the dropdown.
80+
* **Buttons**
81+
* Pan/zoom - ![image: Pan/zoom tool](../../images/pan-zoom-tool.png) is the default
82+
mode of the layer and supports panning and zooming. Press the `1` key when the
83+
layer is selected to use this mode.
84+
* Transform - ![image: Transform](../../images/transform-tool.png) enables you to
85+
rotate, scale, or translate the layer. Note: at present this feature is limited to 2D viewer display mode. To reset the transformation, you can
86+
Option/Alt-click the transform button (a confirmation dialog will open to
87+
confirm the reset). Press the `2` key when the layer is selected to use this mode.
88+
* **Controls**
89+
* Opacity - use this slider control to assign opacity from 0 to 1.00 where 0 is
90+
transparent and 1.00 is completely opaque.
91+
* Contrast Limits - click and slide the dots on either end of the slider bar to
92+
adjust upper and lower contrast limits.
93+
* Auto-contrast - choose once or continuous.
94+
* Gamma - Click on the oval on the gamma slider bar and adjust it to any value
95+
between 0.20 and 2.00. Gamma correction or gamma is a nonlinear operation used
96+
to encode and decode luminance or tristimulus values in video or still image
97+
systems.
98+
* Colormap - select a value from the dropdown list.
99+
* Blending - Choose `opaque`, `translucent`, `translucent no depth`, or
100+
`additive` from the dropdown. Refer to the [Blending layers](blending-layers)
101+
section of _Layers at a glance_ for an explanation of each type of blending.
102+
* Shading - Choose `none`, `flat`, or `smooth` from the dropdown.
94103

95104
## Arguments of `view_surface` and `add_surface`
96105

docs/howtos/layers/tracks.md

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -92,33 +92,42 @@ napari.run()
9292

9393
## GUI controls for the `tracks` layer
9494

95-
* Color by - there is a dropdown for this but at present the only choice is
96-
`track_id`.
97-
* Colormap - choose a colormap from the dropdown. These are explained in
98-
[the colormaps section](./surface.md#working-with-colormaps) of
99-
_Using the surface layer_.
100-
* Blending - choose `opaque`, `translucent`, `translucent no depth`, `minimum`
101-
or `additive` from the dropdown. Refer to the
102-
[Blending layers](blending-layers) section of _Layers at a glance_ for an
103-
explanation of each type of blending.
104-
* Opacity - click and hold the circle on the opacity slider bar and adjust it to
105-
any value between 0.00 (clear) and 1.00 (completely opaque).
106-
* Tail width - adjusting the tail width gives the track the appearance of being
107-
narrower or wider. At the minimum value, the track looks like a one-pixel
108-
line.
109-
* Tail length - adjusting the tail length gives the track the appearance of
110-
being shorter or longer. At the minimum value, it looks something like a
111-
dotted line, at the maximum value it almost looks like an unbroken line.
112-
* Head length - Adjusting the head length gives the track the appearance of
113-
being longer. If it is adjusted to the maximum value, the tracks look like
114-
stripes. At the minimum value, the tracks flash across the canvas and
115-
disappear before starting again.
116-
* Tail - check this box to see the tracks. If it is not checked, you will not be
117-
able to see the tracks at all.
118-
* Show ID - check this box to display a previously assigned `track_id` label for
119-
each track. Assigning values to `track_id` is explained in
120-
[Tracks data](#tracks-data) below.
121-
* Graph - check this box to display a previously created graph.
95+
* **Buttons**
96+
* Pan/zoom - ![image: Pan/zoom tool](../../images/pan-zoom-tool.png) is the default
97+
mode of the layer and supports panning and zooming. Press the `1` key when the
98+
layer is selected to use this mode.
99+
* Transform - ![image: Transform](../../images/transform-tool.png) enables you to
100+
rotate, scale, or translate the layer. Note: at present this feature is limited to 2D viewer display mode. To reset the transformation, you can
101+
Option/Alt-click the transform button (a confirmation dialog will open to
102+
confirm the reset). Press the `2` key when the layer is selected to use this mode.
103+
* **Controls**
104+
* Color by - there is a dropdown for this but at present the only choice is
105+
`track_id`.
106+
* Colormap - choose a colormap from the dropdown. These are explained in
107+
[the colormaps section](./surface.md#working-with-colormaps) of
108+
_Using the surface layer_.
109+
* Blending - choose `opaque`, `translucent`, `translucent no depth`, `minimum`
110+
or `additive` from the dropdown. Refer to the
111+
[Blending layers](blending-layers) section of _Layers at a glance_ for an
112+
explanation of each type of blending.
113+
* Opacity - click and hold the circle on the opacity slider bar and adjust it to
114+
any value between 0.00 (clear) and 1.00 (completely opaque).
115+
* Tail width - adjusting the tail width gives the track the appearance of being
116+
narrower or wider. At the minimum value, the track looks like a one-pixel
117+
line.
118+
* Tail length - adjusting the tail length gives the track the appearance of
119+
being shorter or longer. At the minimum value, it looks something like a
120+
dotted line, at the maximum value it almost looks like an unbroken line.
121+
* Head length - Adjusting the head length gives the track the appearance of
122+
being longer. If it is adjusted to the maximum value, the tracks look like
123+
stripes. At the minimum value, the tracks flash across the canvas and
124+
disappear before starting again.
125+
* Tail - check this box to see the tracks. If it is not checked, you will not be
126+
able to see the tracks at all.
127+
* Show ID - check this box to display a previously assigned `track_id` label for
128+
each track. Assigning values to `track_id` is explained in
129+
[Tracks data](#tracks-data) below.
130+
* Graph - check this box to display a previously created graph.
122131

123132
## Tracks data
124133

@@ -212,7 +221,7 @@ other high dimensional data.
212221
## Changing track width
213222

214223
We can specify the width of the tracks in pixels. The track width can be
215-
specified via the `tail_width` keyword argument in the `viewer.add_tracks()` and
224+
specified via the `tail_width` keyword argument in the {meth}`viewer.add_tracks<napari.Viewer.add_tracks>` and
216225
`napari.view_tracks()` methods. From a layer that has already been constructed,
217226
we can set the track width via the `layer.tail_width` property.
218227

@@ -245,7 +254,7 @@ Additionally, we can adjust the width of the track in the GUI using the
245254
We can specify the length of the tails of the tracks in time units. The tail is
246255
the portion of the track displayed from previous time steps. The track tail
247256
length can be specified via the `tail_length` keyword argument in the
248-
`viewer.add_tracks()` and `napari.view_tracks()` methods. From a layer that has
257+
{meth}`viewer.add_tracks<napari.Viewer.add_tracks>` and `napari.view_tracks()` methods. From a layer that has
249258
already been constructed, we can set the track width via the `tail_length`
250259
property.
251260

@@ -278,7 +287,7 @@ length" slider in the `tracks` layer controls.
278287

279288
We can color the tracks by mapping colors to the track features defined in
280289
`Tracks.features`. If we define features and pass them via the `features`
281-
keyword argument in the `viewer.add_tracks()` and `napari.view_tracks()`
290+
keyword argument in the {meth}`viewer.add_tracks<napari.Viewer.add_tracks>` and `napari.view_tracks()`
282291
methods, we can then select the feature we would like to color the tracks by in
283292
the "color by" dropdown menu in the `tracks` layer controls. We can additionally
284293
specify the colormap used to map the feature value to color via the "colormap"

docs/howtos/layers/vectors.md

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,29 +85,38 @@ Before you can use the GUI to manipulate vectors, you must load a vector layer.
8585
Please refer to [A simple example](#a-simple-example) to add a `vectors` layer
8686
first, then explore the editing options the GUI provides.
8787

88-
* Opacity - click and hold the circle on the opacity slider bar and adjust it to
89-
any value between 0.00 (clear) and 1.00 (completely opaque).
90-
* Width - adjusting the width makes the vectors appear thicker or thinner. Use
91-
the + and - buttons on either side of the width bar to adjust width or click
92-
on the number in the middle of the bar and enter a value. The minimum value is
93-
0.10.
94-
* Length - adjusting the length makes the vector longer or shorter. Use the +
95-
and - buttons on either side of the length bar to adjust length or click on
96-
the number in the middle of the bar and enter a value. The minimum value is
97-
0.10.
98-
* Blending - `blending` has the options of `opaque`, `translucent`,
99-
`translucent no depth`, `minimum`, or `additive` in the dropdown. Refer to the
100-
[Blending layers](blending-layers) section of _Layers at a glance_ for an
101-
explanation of each type of blending.
102-
* Edge color mode - select `direct`, `cycle`, or `colormap` from the dropdown.
103-
* Direct (default mode) allows each vector to be set arbitrarily.
104-
* Cycle allows the color to be set via a color cycle over an attribute.
105-
* Colormap allows the color to be set via a color map over an attribute.
106-
* Edge color - click the thumbnail next to `edge color:` to select or create a
107-
color from the pallette.
108-
* Out of slice - if this box is checked, `out of slice` is on or true. If this
109-
box is not checked, `out of slice` is off or false. If it is on or true,
110-
vectors slightly out of slice are rendered.
88+
* **Buttons**
89+
* Pan/zoom - ![image: Pan/zoom tool](../../images/pan-zoom-tool.png) is the default
90+
mode of the layer and supports panning and zooming. Press the `1` key when the
91+
layer is selected to use this mode.
92+
* Transform - ![image: Transform](../../images/transform-tool.png) enables you to
93+
rotate, scale, or translate the layer. Note: at present this feature is limited to 2D viewer display mode. To reset the transformation, you can
94+
Option/Alt-click the transform button (a confirmation dialog will open to
95+
confirm the reset). Press the `2` key when the layer is selected to use this mode.
96+
* **Controls**
97+
* Opacity - click and hold the circle on the opacity slider bar and adjust it to
98+
any value between 0.00 (clear) and 1.00 (completely opaque).
99+
* Width - adjusting the width makes the vectors appear thicker or thinner. Use
100+
the + and - buttons on either side of the width bar to adjust width or click
101+
on the number in the middle of the bar and enter a value. The minimum value is
102+
0.10.
103+
* Length - adjusting the length makes the vector longer or shorter. Use the +
104+
and - buttons on either side of the length bar to adjust length or click on
105+
the number in the middle of the bar and enter a value. The minimum value is
106+
0.10.
107+
* Blending - `blending` has the options of `opaque`, `translucent`,
108+
`translucent no depth`, `minimum`, or `additive` in the dropdown. Refer to the
109+
[Blending layers](blending-layers) section of _Layers at a glance_ for an
110+
explanation of each type of blending.
111+
* Edge color mode - select `direct`, `cycle`, or `colormap` from the dropdown.
112+
* Direct (default mode) allows each vector to be set arbitrarily.
113+
* Cycle allows the color to be set via a color cycle over an attribute.
114+
* Colormap allows the color to be set via a color map over an attribute.
115+
* Edge color - click the thumbnail next to `edge color:` to select or create a
116+
color from the pallette.
117+
* Out of slice - if this box is checked, `out of slice` is on or true. If this
118+
box is not checked, `out of slice` is off or false. If it is on or true,
119+
vectors slightly out of slice are rendered.
111120

112121
### Vector starting position
113122

@@ -159,8 +168,6 @@ Set the width of all the vectors in a layer using the `layer.width` property.
159168

160169
Set the color of all the vectors in a layer using the `layer.edge_color` property.
161170

162-
Pan and zoom are not available on the vectors layer.
163-
164171
## Vectors data
165172

166173
The input data to the `vectors` layer must be an `Nx2xD` NumPy array

docs/images/pan-zoom-tool.png

-876 Bytes
Loading

docs/images/transform-tool.png

854 Bytes
Loading

0 commit comments

Comments
 (0)