예제 #1
0
def execute():
    # all data will be row-major, so this needs to be specified as the default is col-major
    pyqtgraph.setConfigOptions(imageAxisOrder="row-major")

    # create the GUI event loop
    q_application = QApplication(sys.argv)
    q_application.setApplicationName("Mantid Imaging")
    application_window = MainWindowView()

    sys.excepthook = lambda exc_type, exc_value, exc_traceback: application_window.uncaught_exception(
        "".join(traceback.format_exception_only(exc_type, exc_value)), "".join(
            traceback.format_exception(exc_type, exc_value, exc_traceback)))

    def dont_let_qt_shutdown_while_debugging(type, value, tback):
        # log the exception here
        logging.getLogger(__name__).error(
            f"Exception {type} encountered:\n{traceback.format_exception(type, value, tback)}"
        )
        # then call the default handler
        sys.__excepthook__(type, value, tback)

    if os.environ.get("PYDEVD_LOAD_VALUES_ASYNC", False):
        sys.excepthook = dont_let_qt_shutdown_while_debugging
    application_window.show()

    return sys.exit(q_application.exec_())
예제 #2
0
 def test_command_line_dont_show_recon_window(self, recon_window,
                                              welcome_screen_presenter,
                                              command_line_args):
     command_line_args.return_value.path.return_value = ""
     command_line_args.return_value.recon.return_value = False
     command_line_args.return_value.operation.return_value = ""
     MainWindowView()
     recon_window.assert_not_called()
예제 #3
0
 def test_command_line_show_recon_window(self, recon_window,
                                         welcome_screen_presenter,
                                         command_line_args):
     command_line_args.return_value.path.return_value = ""
     command_line_args.return_value.recon.return_value = True
     command_line_args.return_value.operation.return_value = ""
     view = MainWindowView()
     recon_window.assert_called_once_with(view)
예제 #4
0
 def setUp(self):
     # mock the view so it has the same methods
     with mock.patch(
             'mantidimaging.gui.windows.main.view.check_version_and_label'
     ) as mock_find_latest_version:
         self.window = MainWindowView()
         mock_find_latest_version.assert_called_once()
     self.window.remove_stack = mock.Mock()
     self.dock, self.view, self.test_data = self._add_stack_visualiser()
예제 #5
0
 def test_command_line_no_path_argument_set(self, main_window_presenter,
                                            welcome_screen_presenter,
                                            command_line_args):
     command_line_args.return_value.path.return_value = ""
     command_line_args.return_value.recon.return_value = False
     command_line_args.return_value.operation.return_value = ""
     MainWindowView()
     main_window_presenter.return_value.load_stacks_from_folder.assert_not_called(
     )
예제 #6
0
 def test_load_path_from_command_line(self, main_window_presenter,
                                      welcome_screen_presenter,
                                      command_line_args):
     command_line_args.return_value.path.return_value = test_path = "./"
     command_line_args.return_value.recon.return_value = False
     command_line_args.return_value.operation.return_value = ""
     MainWindowView()
     main_window_presenter.return_value.load_stacks_from_folder.assert_called_once_with(
         test_path)
예제 #7
0
    def test_command_line_show_filters_window(self, main_window_presenter,
                                              welcome_screen_presenter,
                                              command_line_args):
        command_line_args.return_value.path.return_value = ""
        command_line_args.return_value.recon.return_value = False
        command_line_args.return_value.operation.return_value = command_line_filter = "Median"

        MainWindowView()
        main_window_presenter.return_value.show_operation.assert_called_once_with(
            command_line_filter)
예제 #8
0
 def setUp(self) -> None:
     with mock.patch(
             "mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
         with mock.patch(
                 "mantidimaging.gui.windows.main.view.CommandLineArguments"
         ) as command_line_args:
             command_line_args.return_value.path.return_value = ""
             command_line_args.return_value.operation.return_value = ""
             command_line_args.return_value.recon.return_value = False
             self.view = MainWindowView()
     self.presenter = mock.MagicMock()
     self.view.presenter = self.presenter
예제 #9
0
    def setUp(self):
        # mock the view so it has the same methods
        with mock.patch(
                'mantidimaging.gui.windows.main.view.find_if_latest_version'
        ) as mock_find_latest_version:
            self.window = MainWindowView()
            mock_find_latest_version.assert_called_once()
        self.window.remove_stack = mock.Mock()

        self.dock = QDockWidget()
        self.dock.setWindowTitle("Potatoes")

        self.test_data = th.generate_images(automatic_free=False)
        self.view = StackVisualiserView(self.window, self.dock, self.test_data)
        self.dock.setWidget(self.view)
        self.window.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.dock)
예제 #10
0
 def setUp(self) -> None:
     with mock.patch("mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
         self.main_window = MainWindowView()
     self.view = ReconstructWindowView(self.main_window)
     self.view.presenter = self.presenter = mock.Mock()
     self.view.image_view = self.image_view = mock.Mock()
     self.view.tableView = self.tableView = mock.Mock()
     self.view.resultCor = self.resultCor = mock.Mock()
     self.view.resultTilt = self.resultTilt = mock.Mock()
     self.view.resultSlope = self.resultSlope = mock.Mock()
     self.view.numIter = self.numIter = mock.Mock()
     self.view.pixelSize = self.pixelSize = mock.Mock()
     self.view.alphaSpinbox = self.alpha = mock.Mock()
     self.view.algorithmName = self.algorithmName = mock.Mock()
     self.view.filterName = self.filterName = mock.Mock()
     self.view.maxProjAngle = self.maxProjAngle = mock.Mock()
     self.view.autoFindMethod = self.autoFindMethod = mock.Mock()
예제 #11
0
 def setUp(self):
     # mock the view so it has the same methods
     with mock.patch('mantidimaging.gui.windows.main.view.check_version_and_label'):
         self.main_window = MainWindowView()
     self.window = FiltersWindowView(self.main_window)
예제 #12
0
 def setUp(self) -> None:
     with mock.patch("mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
         self.main_window = MainWindowView()
     self.view = WizardView(self.main_window, mock.Mock())
예제 #13
0
 def setUp(self):
     with mock.patch("mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
         self.window = MainWindowView()
     self.view, self.test_data = self._add_stack_visualiser()
예제 #14
0
 def setUp(self) -> None:
     with mock.patch("mantidimaging.gui.windows.main.view.check_version_and_label") as check_version_and_label:
         self.view = MainWindowView()
         self.presenter = mock.MagicMock()
         self.view.presenter = self.presenter
         self.check_version_and_label = check_version_and_label
예제 #15
0
 def setUp(self) -> None:
     with mock.patch(
             "mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
         self.view = MainWindowView()
     self.presenter = mock.MagicMock()
     self.view.presenter = self.presenter
예제 #16
0
 def setUp(self):
     # mock the view so it has the same methods
     with mock.patch(
             "mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
         self.main_window = MainWindowView()
     self.window = FiltersWindowView(self.main_window)
예제 #17
0
 def setUp(self) -> None:
     self.main_window = MainWindowView()
     self.main_window.show()
     QTest.qWait(SHORT_DELAY)
예제 #18
0
 def start_imaging(self):
     self.imaging = MainWindowView(open_dialogs=False)
     self.imaging.ask_to_use_closest_to_180 = mock.Mock(return_value=False)
     self.imaging.show()
     QApplication.processEvents()
예제 #19
0
def setup_application():
    q_application = QApplication(sys.argv)
    q_application.setApplicationName("Mantid Imaging")
    q_application.setOrganizationName("mantidproject")
    q_application.setOrganizationDomain("mantidproject.org")
    return q_application, MainWindowView()