ndv.views.bases #
Abstract base classes for views and viewable objects.
Classes:
-
ArrayCanvas
–ABC for canvases that show array data.
-
ArrayView
–ABC for ND Array viewers widget.
-
CanvasElement
–Protocol defining an interactive element on the Canvas.
-
HistogramCanvas
–A histogram-based view for LookUp Table (LUT) adjustment.
-
LutView
–Manages LUT properties (contrast, colormap, etc...) in a view object.
-
Mouseable
–Mixin class for objects that can be interacted with using the mouse.
-
NDVApp
–Base class for application wrappers.
-
RectangularROIHandle
–An axis-aligned rectanglular ROI.
-
Viewable
–ABC representing anything that can be viewed on screen.
ArrayCanvas #
ArrayCanvas(viewer_model: ArrayViewerModel | None = ...)
Bases: GraphicsCanvas
ABC for canvases that show array data.
Methods:
-
canvas_to_world
–Map XY canvas position (pixels) to XYZ coordinate in world space.
-
close
–Close the view/widget.
-
frontend_widget
–Return the native object backing the viewable objects.
-
set_range
–Sets the bounds of the camera.
-
set_visible
–Sets the visibility of the view/widget itself.
Source code in src/ndv/views/bases/_graphics/_canvas.py
53 54 |
|
canvas_to_world abstractmethod
#
Map XY canvas position (pixels) to XYZ coordinate in world space.
Source code in src/ndv/views/bases/_graphics/_canvas.py
37 38 39 40 41 |
|
close abstractmethod
#
close() -> None
Close the view/widget.
Source code in src/ndv/views/bases/_view_base.py
19 20 21 |
|
frontend_widget abstractmethod
#
frontend_widget() -> Any
Return the native object backing the viewable objects.
Source code in src/ndv/views/bases/_view_base.py
11 12 13 |
|
set_range abstractmethod
#
set_range(
x: tuple[float, float] | None = None,
y: tuple[float, float] | None = None,
z: tuple[float, float] | None = None,
margin: float = ...,
) -> None
Sets the bounds of the camera.
Source code in src/ndv/views/bases/_graphics/_canvas.py
26 27 28 29 30 31 32 33 34 35 |
|
ArrayView #
ArrayView(
canvas_widget: Any,
viewer_model: ArrayViewerModel,
**kwargs: Any,
)
Bases: Viewable
ABC for ND Array viewers widget.
Currently, this is the "main" widget that contains the array display and all the controls for interacting with the array, including sliders, LUTs, and histograms.
Methods:
-
close
–Close the view/widget.
-
frontend_widget
–Return the native object backing the viewable objects.
-
set_visible
–Sets the visibility of the view/widget itself.
Source code in src/ndv/views/bases/_array_view.py
36 37 38 39 40 41 42 |
|
close abstractmethod
#
close() -> None
Close the view/widget.
Source code in src/ndv/views/bases/_view_base.py
19 20 21 |
|
CanvasElement #
Bases: Mouseable
Protocol defining an interactive element on the Canvas.
Methods:
-
can_select
–Defines whether the element can be selected.
-
remove
–Removes the element from the canvas.
-
selected
–Returns element selection status.
-
set_selected
–Sets element selection status.
-
set_visible
–Sets element visibility.
-
visible
–Defines whether the element is visible on the canvas.
can_select abstractmethod
#
can_select() -> bool
Defines whether the element can be selected.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
33 34 35 |
|
remove #
remove() -> None
Removes the element from the canvas.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
45 46 |
|
selected abstractmethod
#
selected() -> bool
Returns element selection status.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
37 38 39 |
|
set_selected abstractmethod
#
set_selected(selected: bool) -> None
Sets element selection status.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
41 42 43 |
|
HistogramCanvas #
Bases: GraphicsCanvas
, LutView
A histogram-based view for LookUp Table (LUT) adjustment.
Methods:
-
canvas_to_world
–Map XY canvas position (pixels) to XYZ coordinate in world space.
-
close
–Close the view/widget.
-
frontend_widget
–Return the native object backing the viewable objects.
-
highlight
–Highlights a domain value on the histogram.
-
set_channel_name
–Set the name of the channel to
name
. -
set_channel_visible
–Check or uncheck the visibility indicator of the LUT.
-
set_clim_bounds
–Defines the minimum and maximum possible values for the clims.
-
set_clim_policy
–Set the clim policy to
policy
. -
set_clims
–Set the (low, high) contrast limits to
clims
. -
set_colormap
–Set the colormap to
cmap
. -
set_data
–Sets the histogram data.
-
set_gamma
–Set the gamma value of the LUT.
-
set_log_base
–Sets the axis scale of the range.
-
set_range
–Sets the bounds of the camera.
-
set_vertical
–If True, orient axes vertically (x-axis on left).
-
set_visible
–Sets the visibility of the view/widget itself.
-
synchronize
–Aligns the view against the backing model.
canvas_to_world abstractmethod
#
Map XY canvas position (pixels) to XYZ coordinate in world space.
Source code in src/ndv/views/bases/_graphics/_canvas.py
37 38 39 40 41 |
|
close abstractmethod
#
close() -> None
Close the view/widget.
Source code in src/ndv/views/bases/_view_base.py
19 20 21 |
|
frontend_widget abstractmethod
#
frontend_widget() -> Any
Return the native object backing the viewable objects.
Source code in src/ndv/views/bases/_view_base.py
11 12 13 |
|
highlight #
highlight(value: float | None) -> None
Highlights a domain value on the histogram.
Source code in src/ndv/views/bases/_graphics/_canvas.py
93 94 |
|
set_channel_name abstractmethod
#
set_channel_name(name: str) -> None
Set the name of the channel to name
.
Source code in src/ndv/views/bases/_lut_view.py
19 20 21 |
|
set_channel_visible abstractmethod
#
set_channel_visible(visible: bool) -> None
Check or uncheck the visibility indicator of the LUT.
Usually corresponds to a checkbox.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
56 57 58 59 60 61 62 63 |
|
set_clim_bounds #
Defines the minimum and maximum possible values for the clims.
Source code in src/ndv/views/bases/_lut_view.py
50 51 52 53 54 |
|
set_clim_policy abstractmethod
#
set_clim_policy(policy: ClimPolicy) -> None
Set the clim policy to policy
.
Usually corresponds to an "autoscale" checkbox.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
23 24 25 26 27 28 29 30 |
|
set_clims abstractmethod
#
Set the (low, high) contrast limits to clims
.
Usually this will be a range slider or two text boxes.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
41 42 43 44 45 46 47 48 |
|
set_colormap abstractmethod
#
set_colormap(cmap: Colormap) -> None
Set the colormap to cmap
.
Usually corresponds to a dropdown menu.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
32 33 34 35 36 37 38 39 |
|
set_data #
Sets the histogram data.
Properties
values : np.ndarray The histogram values. bin_edges : np.ndarray The bin edges of the histogram.
Source code in src/ndv/views/bases/_graphics/_canvas.py
82 83 84 85 86 87 88 89 90 91 |
|
set_gamma #
set_gamma(gamma: float) -> None
Set the gamma value of the LUT.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
65 66 67 68 69 70 |
|
set_log_base #
set_log_base(base: float | None) -> None
Sets the axis scale of the range.
Properties
enabled : bool If true, the range will be displayed with a logarithmic (base 10) scale. If false, the range will be displayed with a linear scale.
Source code in src/ndv/views/bases/_graphics/_canvas.py
72 73 74 75 76 77 78 79 80 |
|
set_range abstractmethod
#
set_range(
x: tuple[float, float] | None = None,
y: tuple[float, float] | None = None,
z: tuple[float, float] | None = None,
margin: float = ...,
) -> None
Sets the bounds of the camera.
Source code in src/ndv/views/bases/_graphics/_canvas.py
26 27 28 29 30 31 32 33 34 35 |
|
set_vertical #
set_vertical(vertical: bool) -> None
If True, orient axes vertically (x-axis on left).
Source code in src/ndv/views/bases/_graphics/_canvas.py
69 70 |
|
set_visible abstractmethod
#
set_visible(visible: bool) -> None
Sets the visibility of the view/widget itself.
Source code in src/ndv/views/bases/_view_base.py
15 16 17 |
|
synchronize #
synchronize() -> None
Aligns the view against the backing model.
Source code in src/ndv/views/bases/_lut_view.py
97 98 99 100 101 102 103 104 |
|
LutView #
Bases: Viewable
Manages LUT properties (contrast, colormap, etc...) in a view object.
Methods:
-
close
–Close the view/widget.
-
frontend_widget
–Return the native object backing the viewable objects.
-
set_channel_name
–Set the name of the channel to
name
. -
set_channel_visible
–Check or uncheck the visibility indicator of the LUT.
-
set_clim_bounds
–Defines the minimum and maximum possible values for the clims.
-
set_clim_policy
–Set the clim policy to
policy
. -
set_clims
–Set the (low, high) contrast limits to
clims
. -
set_colormap
–Set the colormap to
cmap
. -
set_gamma
–Set the gamma value of the LUT.
-
set_visible
–Sets the visibility of the view/widget itself.
-
synchronize
–Aligns the view against the backing model.
close abstractmethod
#
close() -> None
Close the view/widget.
Source code in src/ndv/views/bases/_view_base.py
19 20 21 |
|
frontend_widget abstractmethod
#
frontend_widget() -> Any
Return the native object backing the viewable objects.
Source code in src/ndv/views/bases/_view_base.py
11 12 13 |
|
set_channel_name abstractmethod
#
set_channel_name(name: str) -> None
Set the name of the channel to name
.
Source code in src/ndv/views/bases/_lut_view.py
19 20 21 |
|
set_channel_visible abstractmethod
#
set_channel_visible(visible: bool) -> None
Check or uncheck the visibility indicator of the LUT.
Usually corresponds to a checkbox.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
56 57 58 59 60 61 62 63 |
|
set_clim_bounds #
Defines the minimum and maximum possible values for the clims.
Source code in src/ndv/views/bases/_lut_view.py
50 51 52 53 54 |
|
set_clim_policy abstractmethod
#
set_clim_policy(policy: ClimPolicy) -> None
Set the clim policy to policy
.
Usually corresponds to an "autoscale" checkbox.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
23 24 25 26 27 28 29 30 |
|
set_clims abstractmethod
#
Set the (low, high) contrast limits to clims
.
Usually this will be a range slider or two text boxes.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
41 42 43 44 45 46 47 48 |
|
set_colormap abstractmethod
#
set_colormap(cmap: Colormap) -> None
Set the colormap to cmap
.
Usually corresponds to a dropdown menu.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
32 33 34 35 36 37 38 39 |
|
set_gamma #
set_gamma(gamma: float) -> None
Set the gamma value of the LUT.
Note that this method must not modify the backing LUTModel.
Source code in src/ndv/views/bases/_lut_view.py
65 66 67 68 69 70 |
|
set_visible abstractmethod
#
set_visible(visible: bool) -> None
Sets the visibility of the view/widget itself.
Source code in src/ndv/views/bases/_view_base.py
15 16 17 |
|
synchronize #
synchronize() -> None
Aligns the view against the backing model.
Source code in src/ndv/views/bases/_lut_view.py
97 98 99 100 101 102 103 104 |
|
Mouseable #
Mixin class for objects that can be interacted with using the mouse.
The signals here are to be emitted by the view object that inherits this class; usually by intercepting native mouse events with filter_mouse_events
.
The methods allow the object to handle its own mouse events before emitting the signals. If the method returns True
, the event is considered handled and should not be passed to the next receiver in the chain.
NDVApp #
Base class for application wrappers.
Methods:
-
call_in_main_thread
–Call
func
in the main gui thread. -
call_later
–Call
func
aftermsec
milliseconds. -
create_app
–Create the application instance, if not already created.
-
filter_mouse_events
–Install mouse event filter on
canvas
, redirecting events toreceiver
. -
get_executor
–Return an executor for running tasks in the background.
-
process_events
–Process events for the application.
-
run
–Run the application.
call_in_main_thread #
Call func
in the main gui thread.
Source code in src/ndv/views/bases/_app.py
51 52 53 54 55 56 57 |
|
call_later #
Call func
after msec
milliseconds.
Source code in src/ndv/views/bases/_app.py
96 97 98 99 100 101 102 |
|
create_app #
create_app() -> Any
Create the application instance, if not already created.
Source code in src/ndv/views/bases/_app.py
34 35 36 |
|
filter_mouse_events #
Install mouse event filter on canvas
, redirecting events to receiver
.
Source code in src/ndv/views/bases/_app.py
45 46 47 48 49 |
|
get_executor #
get_executor() -> Executor
Return an executor for running tasks in the background.
Source code in src/ndv/views/bases/_app.py
59 60 61 |
|
process_events #
process_events() -> None
Process events for the application.
Source code in src/ndv/views/bases/_app.py
92 93 94 |
|
run #
run() -> None
Run the application.
Source code in src/ndv/views/bases/_app.py
41 42 43 |
|
RectangularROIHandle #
Bases: CanvasElement
An axis-aligned rectanglular ROI.
Methods:
-
can_select
–Defines whether the element can be selected.
-
remove
–Removes the element from the canvas.
-
selected
–Returns element selection status.
-
set_border
–Sets the border color.
-
set_bounding_box
–Sets the bounding box.
-
set_fill
–Sets the fill color.
-
set_handles
–Sets the handle face color.
-
set_selected
–Sets element selection status.
-
set_visible
–Sets element visibility.
-
visible
–Defines whether the element is visible on the canvas.
can_select abstractmethod
#
can_select() -> bool
Defines whether the element can be selected.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
33 34 35 |
|
remove #
remove() -> None
Removes the element from the canvas.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
45 46 |
|
selected abstractmethod
#
selected() -> bool
Returns element selection status.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
37 38 39 |
|
set_border #
set_border(color: Color) -> None
Sets the border color.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
104 105 |
|
set_bounding_box #
Sets the bounding box.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
96 97 98 99 |
|
set_fill #
set_fill(color: Color) -> None
Sets the fill color.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
101 102 |
|
set_handles #
set_handles(color: Color) -> None
Sets the handle face color.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
107 108 |
|
set_selected abstractmethod
#
set_selected(selected: bool) -> None
Sets element selection status.
Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
41 42 43 |
|
Viewable #
Bases: ABC
ABC representing anything that can be viewed on screen.
For example, a widget, a window, a frame, canvas, etc.
Methods:
-
close
–Close the view/widget.
-
frontend_widget
–Return the native object backing the viewable objects.
-
set_visible
–Sets the visibility of the view/widget itself.
close abstractmethod
#
close() -> None
Close the view/widget.
Source code in src/ndv/views/bases/_view_base.py
19 20 21 |
|