Skip to content

Commit

Permalink
zoombox now works with ROIs, small changes made
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSullivan7 committed May 8, 2024
1 parent 209bfa5 commit 843a0d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 2 additions & 8 deletions mantidimaging/gui/widgets/mi_mini_image_view/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,12 @@ def __init__(self,
name: str = "MIMiniImageView",
parent: QWidget | None = None,
recon_mode: bool = False,
view_box: ViewBox | None = None):
view_box_type: type[ViewBox] = ViewBox):
super().__init__()

self.name = name.title()
self.im = ImageItem()
if view_box is None:
self.vb = ViewBox(invertY=True, lockAspect=True, name=name)
else:
self.vb = view_box
self.vb.invertY(True)
self.vb.setAspectLocked(True)
self.vb.register(name)
self.vb = view_box_type(invertY=True, lockAspect=True, name=name)
self.vb.addItem(self.im)
self.hist = HistogramLUTItem(self.im)
graveyard.append(self.vb)
Expand Down
8 changes: 5 additions & 3 deletions mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ def keyPressEvent(self, event):
for child in self.allChildren():
if isinstance(child, LinearRegionItem):
child.setMovable(False)
elif isinstance(child, SpectrumROI):
child.translatable = False

def keyReleaseEvent(self, event):
if event.key() == Qt.Key_Control:
Expand All @@ -279,6 +281,8 @@ def keyReleaseEvent(self, event):
for child in self.allChildren():
if isinstance(child, LinearRegionItem):
child.setMovable(True)
elif isinstance(child, SpectrumROI):
child.translatable = True

## reimplement right-click to zoom out
def mouseClickEvent(self, ev):
Expand Down Expand Up @@ -315,7 +319,6 @@ def __init__(self) -> None:
self.nextRow()
self._image_index_range_label = self.addLabel()
self.range_control = LinearRegionItem()
self.range_control.setMovable(False)
self.range_control.sigRegionChangeFinished.connect(self._handle_tof_range_changed)
self.ci.layout.setRowStretchFactor(0, 1)

Expand Down Expand Up @@ -350,7 +353,6 @@ class SpectrumProjectionWidget(GraphicsLayoutWidget):

def __init__(self) -> None:
super().__init__()
self.spectrum_projection_viewbox = CustomViewBox(enableMenu=True)
self.image = MIMiniImageView(name="Projection", view_box=self.spectrum_projection_viewbox)
self.image = MIMiniImageView(name="Projection", view_box_type=CustomViewBox)
self.addItem(self.image, 0, 0)
self.ci.layout.setRowStretchFactor(0, 3)

0 comments on commit 843a0d1

Please sign in to comment.