Skip to content

Commit ab5de2c

Browse files
committed
Rename RectangularROI views
1 parent b0020e6 commit ab5de2c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/ndv/views/_pygfx/_array_canvas.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_cursor(self, mme: MouseMoveEvent) -> CursorType | None:
110110
return None
111111

112112

113-
class PyGFXBoundingBox(RectangularROI):
113+
class PyGFXRectangularROI(RectangularROI):
114114
def __init__(
115115
self,
116116
render: Callable,
@@ -407,8 +407,8 @@ def __init__(self, viewer_model: ArrayViewerModel) -> None:
407407

408408
self._elements = WeakKeyDictionary[pygfx.WorldObject, CanvasElement]()
409409
self._selection: CanvasElement | None = None
410-
# TODO: Weak Reference?
411-
self._last_roi_created: ReferenceType[PyGFXBoundingBox] | None = None
410+
# Maintain a weak reference to the last ROI created.
411+
self._last_roi_created: ReferenceType[PyGFXRectangularROI] | None = None
412412

413413
def frontend_widget(self) -> Any:
414414
return self._canvas
@@ -504,9 +504,9 @@ def add_volume(self, data: np.ndarray | None = None) -> PyGFXImageHandle:
504504
self._elements[vol] = handle
505505
return handle
506506

507-
def add_bounding_box(self) -> PyGFXBoundingBox:
507+
def add_bounding_box(self) -> PyGFXRectangularROI:
508508
"""Add a new Rectangular ROI node to the scene."""
509-
roi = PyGFXBoundingBox(
509+
roi = PyGFXRectangularROI(
510510
render=self.refresh,
511511
canvas_to_world=self.canvas_to_world,
512512
parent=self._scene,

src/ndv/views/_vispy/_array_canvas.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def get_cursor(self, mme: MouseMoveEvent) -> CursorType | None:
116116
return None
117117

118118

119-
class VispyBoundingBox(RectangularROI):
119+
class VispyRectangularROI(RectangularROI):
120120
def __init__(self, parent: Any) -> None:
121121
self._selected = False
122122
self._move_mode: ROIMoveMode | None = None
@@ -307,8 +307,8 @@ def __init__(self, viewer_model: ArrayViewerModel) -> None:
307307

308308
self._elements: WeakKeyDictionary = WeakKeyDictionary()
309309
self._selection: CanvasElement | None = None
310-
# TODO: Weak Reference?
311-
self._last_roi_created: ReferenceType[VispyBoundingBox] | None = None
310+
# Maintain weak reference to last ROI created
311+
self._last_roi_created: ReferenceType[VispyRectangularROI] | None = None
312312

313313
@property
314314
def _camera(self) -> vispy.scene.cameras.BaseCamera:
@@ -389,9 +389,9 @@ def add_volume(self, data: np.ndarray | None = None) -> VispyImageHandle:
389389
self.set_range()
390390
return handle
391391

392-
def add_bounding_box(self) -> VispyBoundingBox:
392+
def add_bounding_box(self) -> VispyRectangularROI:
393393
"""Add a new Rectangular ROI node to the scene."""
394-
roi = VispyBoundingBox(parent=self._view.scene)
394+
roi = VispyRectangularROI(parent=self._view.scene)
395395
roi.set_visible(False)
396396
self._elements[roi._handles] = roi
397397
self._elements[roi._rect] = roi
@@ -423,7 +423,7 @@ def set_range(
423423
_y[1] = max(_y[1], shape[1])
424424
if len(shape) > 2:
425425
_z[1] = max(_z[1], shape[2])
426-
elif isinstance(handle, VispyBoundingBox):
426+
elif isinstance(handle, VispyRectangularROI):
427427
for v in handle.vertices:
428428
_x[0] = min(_x[0], v[0])
429429
_x[1] = max(_x[1], v[0])

0 commit comments

Comments
 (0)