Skip to content

Commit

Permalink
Set ROI Max Bounds to Size of Image
Browse files Browse the repository at this point in the history
  • Loading branch information
JackEAllen committed Aug 5, 2024
1 parent 378a35e commit 19013dc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mantidimaging/gui/widgets/mi_image_view/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import TYPE_CHECKING
from collections.abc import Callable

from PyQt5.QtCore import Qt
from PyQt5.QtCore import Qt, QRectF
from PyQt5.QtWidgets import QApplication, QHBoxLayout, QLabel, QPushButton, QSizePolicy
from pyqtgraph import ROI, ImageItem, ImageView, ViewBox
from pyqtgraph.GraphicsScene.mouseEvents import HoverEvent
Expand Down Expand Up @@ -148,6 +148,9 @@ def angles(self, angles: ProjectionAngles | None) -> None:
self._angles = angles
self._update_message(self._last_mouse_hover_location)

def _set_roi_max_bounds(self):
self.roi.maxBounds = QRectF(0, 0, self.image_data.shape[2], self.image_data.shape[1])

def setImage(self, image: np.ndarray, *args, **kwargs):
dimensions_changed = self.image_data is None or self.image_data.shape != image.shape
if image.ndim == 3:
Expand Down Expand Up @@ -195,6 +198,7 @@ def roiChanged(self) -> None:
roi = self._update_roi_region_avg()
if self.roi_changed_callback and roi is not None:
self.roi_changed_callback(roi)
self._set_roi_max_bounds()
self._refresh_message()

def _update_roi_region_avg(self) -> SensibleROI | None:
Expand Down

0 comments on commit 19013dc

Please sign in to comment.