Skip to content

Commit

Permalink
Merge branch 'master' into 673_compare_window_show_stack_name
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitar Tasev committed Nov 27, 2020
2 parents b3d45ce + 73dc5c4 commit fb66b6a
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 247 deletions.
73 changes: 68 additions & 5 deletions mantidimaging/gui/widgets/mi_image_view/view.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Copyright (C) 2020 ISIS Rutherford Appleton Laboratory UKRI
# SPDX - License - Identifier: GPL-3.0-or-later

from typing import Optional, Tuple, Callable
from time import sleep
from typing import Callable, Optional, Tuple

from PyQt5 import QtCore
from PyQt5.QtWidgets import QLabel
from pyqtgraph import ImageView, ROI, ImageItem
from PyQt5.QtWidgets import QApplication, QHBoxLayout, QLabel, QPushButton, QSizePolicy
from pyqtgraph import ROI, ImageItem, ImageView
from pyqtgraph.GraphicsScene.mouseEvents import HoverEvent

from mantidimaging.core.utility.close_enough_point import CloseEnoughPoint
Expand All @@ -29,12 +30,50 @@ class MIImageView(ImageView):

roi_changed_callback: Optional[Callable[[SensibleROI], None]] = None

def __init__(self, parent=None, name="ImageView", view=None, imageItem=None, levelMode='mono', *args):
def __init__(self,
parent=None,
name="ImageView",
view=None,
imageItem=None,
levelMode='mono',
detailsSpanAllCols=False,
*args):
super().__init__(parent, name, view, imageItem, levelMode, *args)
self.presenter = MIImagePresenter()
self.details = QLabel("", self.ui.layoutWidget)
self.details.setStyleSheet("QLabel { color : white; background-color: black}")
self.ui.gridLayout.addWidget(self.details, 1, 0, 1, 1)
if detailsSpanAllCols:
self.ui.gridLayout.addWidget(self.details, 1, 0, 1, 3)
self.ui.gridLayout.setColumnStretch(0, 8)
self.ui.gridLayout.setColumnStretch(1, 1)
self.ui.gridLayout.setColumnStretch(2, 1)
else:
self.ui.gridLayout.addWidget(self.details, 1, 0, 1, 1)

# Hide the norm button as it allows for manual data changes and we don't want users to do that unrecorded.
self.ui.menuBtn.hide()

# Construct and add the left and right buttons for the stack
self.shifting_through_images = False

self.button_stack_left = QPushButton()
self.button_stack_left.setText("<")
self.button_stack_left.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
self.button_stack_left.setMaximumSize(40, 40)
self.button_stack_left.pressed.connect(lambda: self.toggle_jumping_frame(-1))
self.button_stack_left.released.connect(lambda: self.toggle_jumping_frame())

self.button_stack_right = QPushButton()
self.button_stack_right.setText(">")
self.button_stack_right.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
self.button_stack_right.setMaximumSize(40, 40)
self.button_stack_right.pressed.connect(lambda: self.toggle_jumping_frame(1))
self.button_stack_right.released.connect(lambda: self.toggle_jumping_frame())

self.vertical_layout = QHBoxLayout()
self.vertical_layout.addWidget(self.button_stack_left)
self.vertical_layout.addWidget(self.button_stack_right)
self.ui.gridLayout.addLayout(self.vertical_layout, 1, 2, 1, 1)

self.imageItem.hoverEvent = self.image_hover_event
# disconnect the ROI recalculation on every move
Expand All @@ -55,6 +94,16 @@ def __init__(self, parent=None, name="ImageView", view=None, imageItem=None, lev

self.imageItem.sigImageChanged.connect(self._refresh_message)

def toggle_jumping_frame(self, images_to_jump_by=None):
if not self.shifting_through_images and images_to_jump_by is not None:
self.shifting_through_images = True
else:
self.shifting_through_images = False
while self.shifting_through_images:
self.jumpFrames(images_to_jump_by)
sleep(0.02)
QApplication.processEvents()

def _refresh_message(self):
# updates the ROI average value
self._update_roi_region_avg()
Expand All @@ -81,6 +130,20 @@ def roiChanged(self):
if self.roi_changed_callback and roi is not None:
self.roi_changed_callback(roi)

def timeLineChanged(self):
"""
Re-implements timeLineChanged function, and the only change
is that now self.updateImage will NOT auto range the histogram
"""
if not self.ignorePlaying:
self.play(0)

(ind, time) = self.timeIndex(self.timeLine)
if ind != self.currentIndex:
self.currentIndex = ind
self.updateImage(autoHistogramRange=False)
self.sigTimeChanged.emit(ind, time)

def _update_roi_region_avg(self) -> Optional[SensibleROI]:
if self.image.ndim != 3:
return None
Expand Down
229 changes: 0 additions & 229 deletions mantidimaging/gui/widgets/pg_image_view.py

This file was deleted.

11 changes: 6 additions & 5 deletions mantidimaging/gui/windows/operations/view.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Copyright (C) 2020 ISIS Rutherford Appleton Laboratory UKRI
# SPDX - License - Identifier: GPL-3.0-or-later

from mantidimaging.core.net.help_pages import open_api_webpage
from typing import TYPE_CHECKING

import numpy as np
from PyQt5 import Qt
from PyQt5.QtWidgets import QMessageBox, QVBoxLayout, QCheckBox, QLabel, QApplication, QSplitter, QPushButton, \
QSizePolicy, QComboBox, QStyle, QMainWindow, QAction, QMenu
from PyQt5.QtWidgets import (QAction, QApplication, QCheckBox, QComboBox, QLabel, QMainWindow, QMenu, QMessageBox,
QPushButton, QSizePolicy, QSplitter, QStyle, QVBoxLayout)
from pyqtgraph import ImageItem

from mantidimaging.core.net.help_pages import open_api_webpage
from mantidimaging.gui.mvp_base import BaseMainWindowView
from mantidimaging.gui.utility import (delete_all_widgets_from_layout)
from mantidimaging.gui.widgets.pg_image_view import MIImageView
from mantidimaging.gui.utility import delete_all_widgets_from_layout
from mantidimaging.gui.widgets.mi_image_view.view import MIImageView
from mantidimaging.gui.widgets.stack_selector import StackSelectorWidgetView

from .filter_previews import FilterPreviews
from .presenter import FiltersWindowPresenter
from .presenter import Notification as PresNotification
Expand Down
2 changes: 1 addition & 1 deletion mantidimaging/gui/windows/recon/point_table_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from enum import Enum
from typing import List

from PyQt5.QtCore import Qt, QAbstractTableModel, QModelIndex
from PyQt5.QtCore import QAbstractTableModel, QModelIndex, Qt

from mantidimaging.core.rotation import CorTiltDataModel
from mantidimaging.core.rotation.data_model import Point
Expand Down
4 changes: 2 additions & 2 deletions mantidimaging/gui/windows/stack_choice/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX - License - Identifier: GPL-3.0-or-later

from enum import Enum, auto
from typing import Optional, TYPE_CHECKING, Union
from typing import TYPE_CHECKING, Optional, Union

from PyQt5 import QtCore
from PyQt5.QtCore import Qt
Expand All @@ -12,7 +12,7 @@

from mantidimaging.core.data.images import Images
from mantidimaging.gui.mvp_base import BaseMainWindowView
from mantidimaging.gui.widgets.pg_image_view import MIImageView
from mantidimaging.gui.widgets.mi_image_view.view import MIImageView

if TYPE_CHECKING:
from mantidimaging.gui.windows.stack_choice.compare_presenter import StackComparePresenter
Expand Down
Loading

0 comments on commit fb66b6a

Please sign in to comment.