Skip to content

Commit 61b0c01

Browse files
kushalkolarclewis7
andauthored
VectorsGraphic (#929)
* start vector fields * basics of vector field works * add vector field to api docs * update event tables * add vector field to subsection_order * update vector field, almost there * vector field done and working * cleanup * update docstring * update * black * black * update * update .gitignore * restore stuff in .gitignore * test examples * update min pygfx version * ome zarr being annoying * remove multi-channel from screenshot tests, only show code in nb * don't run multi channel example * rename to VectorsGraphic since we will use field for something else * interactive electric field example * update name * black * update name * wrong sign, now correct * update api docs * Apply suggestion from @clewis7 Co-authored-by: Caitlin Lewis <caitlin9165@gmail.com> * fix render order and blending, add comment * rename * docstrings, comments * checks * clarify example * cleanup --------- Co-authored-by: Caitlin Lewis <caitlin9165@gmail.com>
1 parent 262c68a commit 61b0c01

24 files changed

+1192
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ instance/
7070

7171
# Sphinx documentation
7272
docs/_build/
73+
docs/source/sg_execution_times.rst
7374

7475
# PyBuilder
7576
target/
@@ -134,5 +135,6 @@ dmypy.json
134135
# vs code
135136
.vscode/
136137

138+
# diffs from visual regression tests
137139
examples/desktop/diffs/*.png
138140
docs/source/_gallery/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.. _api.VectorDirections:
2+
3+
VectorDirections
4+
****************
5+
6+
================
7+
VectorDirections
8+
================
9+
.. currentmodule:: fastplotlib.graphics.features
10+
11+
Constructor
12+
~~~~~~~~~~~
13+
.. autosummary::
14+
:toctree: VectorDirections_api
15+
16+
VectorDirections
17+
18+
Properties
19+
~~~~~~~~~~
20+
.. autosummary::
21+
:toctree: VectorDirections_api
22+
23+
VectorDirections.value
24+
25+
Methods
26+
~~~~~~~
27+
.. autosummary::
28+
:toctree: VectorDirections_api
29+
30+
VectorDirections.add_event_handler
31+
VectorDirections.block_events
32+
VectorDirections.clear_event_handlers
33+
VectorDirections.remove_event_handler
34+
VectorDirections.set_value
35+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.. _api.VectorPositions:
2+
3+
VectorPositions
4+
***************
5+
6+
===============
7+
VectorPositions
8+
===============
9+
.. currentmodule:: fastplotlib.graphics.features
10+
11+
Constructor
12+
~~~~~~~~~~~
13+
.. autosummary::
14+
:toctree: VectorPositions_api
15+
16+
VectorPositions
17+
18+
Properties
19+
~~~~~~~~~~
20+
.. autosummary::
21+
:toctree: VectorPositions_api
22+
23+
VectorPositions.value
24+
25+
Methods
26+
~~~~~~~
27+
.. autosummary::
28+
:toctree: VectorPositions_api
29+
30+
VectorPositions.add_event_handler
31+
VectorPositions.block_events
32+
VectorPositions.clear_event_handlers
33+
VectorPositions.remove_event_handler
34+
VectorPositions.set_value
35+

docs/source/api/graphic_features/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Graphic Features
3232
VolumeIsoEmissive
3333
VolumeIsoShininess
3434
VolumeSlicePlane
35+
VectorPositions
36+
VectorDirections
3537
TextData
3638
FontSize
3739
TextFaceColor
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.. _api.VectorsGraphic:
2+
3+
VectorsGraphic
4+
**************
5+
6+
==============
7+
VectorsGraphic
8+
==============
9+
.. currentmodule:: fastplotlib
10+
11+
Constructor
12+
~~~~~~~~~~~
13+
.. autosummary::
14+
:toctree: VectorsGraphic_api
15+
16+
VectorsGraphic
17+
18+
Properties
19+
~~~~~~~~~~
20+
.. autosummary::
21+
:toctree: VectorsGraphic_api
22+
23+
VectorsGraphic.alpha
24+
VectorsGraphic.alpha_mode
25+
VectorsGraphic.axes
26+
VectorsGraphic.block_events
27+
VectorsGraphic.deleted
28+
VectorsGraphic.directions
29+
VectorsGraphic.event_handlers
30+
VectorsGraphic.name
31+
VectorsGraphic.offset
32+
VectorsGraphic.positions
33+
VectorsGraphic.right_click_menu
34+
VectorsGraphic.rotation
35+
VectorsGraphic.supported_events
36+
VectorsGraphic.visible
37+
VectorsGraphic.world_object
38+
39+
Methods
40+
~~~~~~~
41+
.. autosummary::
42+
:toctree: VectorsGraphic_api
43+
44+
VectorsGraphic.add_axes
45+
VectorsGraphic.add_event_handler
46+
VectorsGraphic.clear_event_handlers
47+
VectorsGraphic.remove_event_handler
48+
VectorsGraphic.rotate
49+

docs/source/api/graphics/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Graphics
99
ScatterGraphic
1010
ImageGraphic
1111
ImageVolumeGraphic
12+
VectorsGraphic
1213
TextGraphic
1314
LineCollection
1415
LineStack

docs/source/api/layouts/subplot.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Methods
5454
Subplot.add_line_stack
5555
Subplot.add_scatter
5656
Subplot.add_text
57+
Subplot.add_vectors
5758
Subplot.auto_scale
5859
Subplot.center_graphic
5960
Subplot.center_scene

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"../../examples/line",
6767
"../../examples/line_collection",
6868
"../../examples/scatter",
69+
"../../examples/vectors",
6970
"../../examples/text",
7071
"../../examples/events",
7172
"../../examples/selection_tools",

docs/source/user_guide/event_tables.rst

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,108 @@ deleted
795795
| value | bool | True when graphic was deleted |
796796
+----------+------+-------------------------------+
797797

798+
VectorsGraphic
799+
--------------
800+
801+
positions
802+
^^^^^^^^^
803+
804+
**event info dict**
805+
806+
+----------+------------+----------------------+
807+
| dict key | type | description |
808+
+==========+============+======================+
809+
| value | np.ndarray | new vector positions |
810+
+----------+------------+----------------------+
811+
812+
directions
813+
^^^^^^^^^^
814+
815+
**event info dict**
816+
817+
+----------+------------+-----------------------+
818+
| dict key | type | description |
819+
+==========+============+=======================+
820+
| value | np.ndarray | new vector directions |
821+
+----------+------------+-----------------------+
822+
823+
name
824+
^^^^
825+
826+
**event info dict**
827+
828+
+----------+------+--------------------+
829+
| dict key | type | description |
830+
+==========+======+====================+
831+
| value | str | user provided name |
832+
+----------+------+--------------------+
833+
834+
offset
835+
^^^^^^
836+
837+
**event info dict**
838+
839+
+----------+---------------------------------+----------------------+
840+
| dict key | type | description |
841+
+==========+=================================+======================+
842+
| value | np.ndarray[float, float, float] | new offset (x, y, z) |
843+
+----------+---------------------------------+----------------------+
844+
845+
rotation
846+
^^^^^^^^
847+
848+
**event info dict**
849+
850+
+----------+----------------------------------------+-------------------------+
851+
| dict key | type | description |
852+
+==========+========================================+=========================+
853+
| value | np.ndarray[float, float, float, float] | new rotation quaternion |
854+
+----------+----------------------------------------+-------------------------+
855+
856+
alpha
857+
^^^^^
858+
859+
**event info dict**
860+
861+
+----------+-------+-----------------+
862+
| dict key | type | description |
863+
+==========+=======+=================+
864+
| value | float | new alpha value |
865+
+----------+-------+-----------------+
866+
867+
alpha_mode
868+
^^^^^^^^^^
869+
870+
**event info dict**
871+
872+
+----------+------+----------------+
873+
| dict key | type | description |
874+
+==========+======+================+
875+
| value | str | new alpha mode |
876+
+----------+------+----------------+
877+
878+
visible
879+
^^^^^^^
880+
881+
**event info dict**
882+
883+
+----------+------+---------------------+
884+
| dict key | type | description |
885+
+==========+======+=====================+
886+
| value | bool | new visibility bool |
887+
+----------+------+---------------------+
888+
889+
deleted
890+
^^^^^^^
891+
892+
**event info dict**
893+
894+
+----------+------+-------------------------------+
895+
| dict key | type | description |
896+
+==========+======+===============================+
897+
| value | bool | True when graphic was deleted |
898+
+----------+------+-------------------------------+
899+
798900
TextGraphic
799901
-----------
800902

examples/image_volume/image_volume_multi_channel.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
Example with multi-channel volume images. Use alpha_mode "add" for additive blending.
66
"""
77

8-
# test_example = true
9-
# sphinx_gallery_pygfx_docs = 'screenshot'
8+
# test_example = false
9+
# run_example = false
10+
# sphinx_gallery_pygfx_docs = 'code'
1011

1112
import fastplotlib as fpl
1213
from ome_zarr.io import parse_url
@@ -18,10 +19,8 @@
1819

1920
# read the image data
2021
reader = Reader(parse_url(url))
21-
# nodes may include images, labels etc
22-
nodes = list(reader())
23-
# first node will be the image pixel data
24-
image_node = nodes[0]
22+
# first node is image data
23+
image_node = next(reader())
2524

2625
dask_data = image_node.data
2726

0 commit comments

Comments
 (0)