Skip to content

Commit

Permalink
Load images into live viewer on initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
JackEAllen committed Sep 12, 2023
1 parent d9f590e commit bf62aae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mantidimaging/gui/windows/live_viewer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def path(self, path: Path) -> None:
self._dataset_path = path
self.image_watcher = ImageWatcher(path)
self.image_watcher.image_changed.connect(self._handle_image_changed_in_list)
self.image_watcher.find_images()

def _handle_image_changed_in_list(self, image_files: list[Image_Data]) -> None:
"""
Expand All @@ -113,6 +112,15 @@ def _handle_image_changed_in_list(self, image_files: list[Image_Data]) -> None:
self.images = image_files
self.presenter.update_image_list(image_files)

def get_images(self) -> None:
"""
Trigger the image watcher to find images in the directory
in case images are already present.
"""
if self.image_watcher:
image_files = self.image_watcher.find_images()
self._handle_image_changed_in_list(image_files)


class ImageWatcher(QObject):
"""
Expand Down
5 changes: 5 additions & 0 deletions mantidimaging/gui/windows/live_viewer/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, main_window: 'MainWindowView', live_dir_path: Path) -> None:
self.move(self.main_window.x() + self.main_window.width(), self.main_window.y())

self.live_viewer.z_slider.valueChanged.connect(self.presenter.select_image)
self.presenter.model.get_images()

def show_most_recent_image(self, image: np.ndarray) -> None:
"""
Expand All @@ -49,6 +50,10 @@ def watch_directory(self) -> None:
"""Show the most recent image arrived in the selected directory"""
self.presenter.set_dataset_path(self.path)

def load_exisitng_images(self) -> None:
"""Load the existing images in the selected directory if present"""
self.presenter.model.get_images()

def remove_image(self) -> None:
"""Remove the image from the view."""
self.live_viewer.handle_deleted()
Expand Down

0 comments on commit bf62aae

Please sign in to comment.