From eb8199811455ea397d6b5e3af57cc3ce77a7b3af Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Tue, 17 Nov 2020 18:26:05 +0000 Subject: [PATCH 01/31] Replace hard-coded main window with .ui design --- i19-gui/MainWindow.ui | 1382 +++++++++++++++++++++++ i19-gui/chemical_crystallography_gui.py | 888 ++++----------- 2 files changed, 1601 insertions(+), 669 deletions(-) create mode 100644 i19-gui/MainWindow.ui diff --git a/i19-gui/MainWindow.ui b/i19-gui/MainWindow.ui new file mode 100644 index 0000000..b2aa2dd --- /dev/null +++ b/i19-gui/MainWindow.ui @@ -0,0 +1,1382 @@ + + + MainWindow + + + + 0 + 0 + 730 + 737 + + + + false + + + Chemical Crystallography Xia2 GUI + + + + + + + 10 + + + 10 + + + 10 + + + 0 + + + + + + + Dataset + + + + + + + + 14 + 75 + true + + + + none + + + + + + + Dials Version + + + + + + + Images + + + + + + + + 14 + 75 + true + + + + 0 + + + + + + + Prefix + + + + + + + + 14 + 75 + true + + + + 0 + + + + + + + Runs + + + + + + + + 14 + 75 + true + + + + none + + + + + + + + 14 + 75 + true + + + + 0 + + + + + + + + + Qt::Horizontal + + + + + + + + + Processing path + + + + + + + + 10 + 75 + true + + + + none + + + + + + + + + Qt::Horizontal + + + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 85 + 170 + 255 + + + + + + + 213 + 234 + 255 + + + + + + + 149 + 202 + 255 + + + + + + + 42 + 85 + 127 + + + + + + + 56 + 113 + 170 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 170 + 212 + 255 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 85 + 170 + 255 + + + + + + + 213 + 234 + 255 + + + + + + + 149 + 202 + 255 + + + + + + + 42 + 85 + 127 + + + + + + + 56 + 113 + 170 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 170 + 212 + 255 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 42 + 85 + 127 + + + + + + + 85 + 170 + 255 + + + + + + + 213 + 234 + 255 + + + + + + + 149 + 202 + 255 + + + + + + + 42 + 85 + 127 + + + + + + + 56 + 113 + 170 + + + + + + + 42 + 85 + 127 + + + + + + + 255 + 255 + 255 + + + + + + + 42 + 85 + 127 + + + + + + + 85 + 170 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 85 + 170 + 255 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + Run xia2 + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 85 + 170 + 255 + + + + + + + 213 + 234 + 255 + + + + + + + 149 + 202 + 255 + + + + + + + 42 + 85 + 127 + + + + + + + 56 + 113 + 170 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 170 + 212 + 255 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 85 + 170 + 255 + + + + + + + 213 + 234 + 255 + + + + + + + 149 + 202 + 255 + + + + + + + 42 + 85 + 127 + + + + + + + 56 + 113 + 170 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 170 + 212 + 255 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 42 + 85 + 127 + + + + + + + 85 + 170 + 255 + + + + + + + 213 + 234 + 255 + + + + + + + 149 + 202 + 255 + + + + + + + 42 + 85 + 127 + + + + + + + 56 + 113 + 170 + + + + + + + 42 + 85 + 127 + + + + + + + 255 + 255 + 255 + + + + + + + 42 + 85 + 127 + + + + + + + 85 + 170 + 255 + + + + + + + 85 + 170 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 85 + 170 + 255 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + Run screen19 + + + + + + + + 10 + + + + xia2 options + + + + + + + + 10 + + + + Run Albula + + + + + + + + + Qt::Horizontal + + + + + + + + + xia2 command + + + + + + + + 10 + 75 + true + + + + true + + + xia2 small_molecule=true dataset_path + + + + + + + + + Qt::Horizontal + + + + + + + QTabWidget::North + + + QTabWidget::Rounded + + + 0 + + + true + + + false + + + + Main + + + + + + + + + + + + + + xia2output1 + + + + + + + + + + + 10 + + + + Image Viewer + + + + + + + + 10 + + + + Reciprocal Lattice + + + + + + + + 10 + + + + HTML + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 730 + 22 + + + + + File + + + + + + + + + Edit + + + + + + + + View + + + + + Settings + + + + + Version + + + + + + + + + + + + + + + + Open + + + Open the dataset - select dataset folder + + + Ctrl+O + + + + + Open Multiple + + + Open multiple datasets - selected multiple datasets uning the Ctrl button + + + + + Close GUI + + + This will close the GUI + + + + + Copy Command + + + + + Save Settings + + + Save all the GUI settings to a .txt file + + + + + Load Settings + + + Load previous save GUI settings + + + + + + + + dials_current + + + + + dials_latest + + + + + dials_now + + + + + dials_1.4 + + + + + + diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 90dc00c..9c1f7c0 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -13,18 +13,14 @@ import subprocess import sys from datetime import datetime +from pathlib import Path from time import sleep -from PyQt5 import QtCore, QtGui, QtWidgets - -######################################################################################## -######################################################################################## -######################################################################################## -######################################################################################## +from PyQt5 import QtCore, QtGui, QtWidgets, uic -class UIMainWindow(object): - def __init__(self, main_window): +class UIMainWindow(QtWidgets.QMainWindow): + def __init__(self): self.dials_version = "" self.opening_visit = "/dls/i19-2/data/2020/" self.visit = "" @@ -88,379 +84,36 @@ def __init__(self, main_window): ] self.tabs_num = 0 - self.font_size14_b = QtGui.QFont() - self.font_size14_b.setPointSize(14) - self.font_size14_b.setBold(True) - self.font_size14_b.setWeight(75) - - self.font_size12_b = QtGui.QFont() - self.font_size12_b.setPointSize(10) - self.font_size12_b.setBold(True) - self.font_size12_b.setWeight(75) - - self.font_size10_b = QtGui.QFont() - self.font_size10_b.setPointSize(10) - self.font_size10_b.setBold(True) - self.font_size10_b.setWeight(75) - - self.font_size10 = QtGui.QFont() - self.font_size10.setPointSize(10) - - main_window.setObjectName("main_window") - main_window.resize(764, 720) - - self.central_widget = QtWidgets.QWidget(main_window) - self.central_widget.setObjectName("central_widget") - main_window.setCentralWidget(self.central_widget) - # menu_bar - self.menu_bar = QtWidgets.QMenuBar(main_window) - self.menu_bar.setGeometry(QtCore.QRect(0, 0, 800, 26)) - self.menu_bar.setObjectName("menu_bar") - main_window.setMenuBar(self.menu_bar) - self.status_bar = QtWidgets.QStatusBar(main_window) - self.status_bar.setObjectName("status_bar") - main_window.setStatusBar(self.status_bar) - ################################################################################ - # menu File - self.menu_file = QtWidgets.QMenu(self.menu_bar) - self.menu_file.setObjectName("menu_file") - self.menu_bar.addAction(self.menu_file.menuAction()) - # - self.menu_file_open = QtWidgets.QAction(main_window) - self.menu_file_open.setObjectName("menu_file_open") - self.menu_file.addAction(self.menu_file_open) - self.menu_file_open.triggered.connect(self.select_dataset) - self.menu_file_open_multiple = QtWidgets.QAction(main_window) - self.menu_file_open_multiple.setObjectName("menu_file_open_multiple") - self.menu_file.addAction(self.menu_file_open_multiple) - self.menu_file_open_multiple.triggered.connect(self.open_multiple) - self.menu_file_close_gui = QtWidgets.QAction(main_window) - self.menu_file_close_gui.setObjectName("menu_file_close_gui") - self.menu_file.addAction(self.menu_file_close_gui) - self.menu_file_close_gui.triggered.connect(self.close_gui) - # menu Edit - self.menu_edit = QtWidgets.QMenu(self.menu_bar) - self.menu_edit.setObjectName("menu_edit") - self.menu_bar.addAction(self.menu_edit.menuAction()) - # - self.menu_edit_copy_command = QtWidgets.QAction(main_window) - self.menu_edit_copy_command.setObjectName("menu_edit_copy_command") - self.menu_edit.addAction(self.menu_edit_copy_command) - self.menu_edit_save_settings = QtWidgets.QAction(main_window) - self.menu_edit_save_settings.setObjectName("menu_edit_save_settings") - self.menu_edit.addAction(self.menu_edit_save_settings) - self.menu_edit_load_settings = QtWidgets.QAction(main_window) - self.menu_edit_load_settings.setObjectName("menu_edit_load_settings") - self.menu_edit.addAction(self.menu_edit_load_settings) - # menu View - self.menu_view = QtWidgets.QMenu(self.menu_bar) - self.menu_view.setObjectName("menu_view") - self.menu_bar.addAction(self.menu_view.menuAction()) - # menu Settings - self.menu_settings = QtWidgets.QMenu(self.menu_bar) - self.menu_settings.setObjectName("menu_settings") - self.menu_bar.addAction(self.menu_settings.menuAction()) - # menu Version - self.menu_version = QtWidgets.QMenu(self.menu_bar) - self.menu_version.setObjectName("menu_version") - self.menu_bar.addAction(self.menu_version.menuAction()) - # - self.menu_version_current = QtWidgets.QAction(main_window) - self.menu_version_current.setObjectName("menu_version_current") - self.menu_version.addAction(self.menu_version_current) - self.menu_version_current.triggered.connect(self.version_current) - self.menu_version_latest = QtWidgets.QAction(main_window) - self.menu_version_latest.setObjectName("menu_version_latest") - self.menu_version.addAction(self.menu_version_latest) - self.menu_version_latest.triggered.connect(self.version_latest) - self.menu_version_now = QtWidgets.QAction(main_window) - self.menu_version_now.setObjectName("menu_version_now") - self.menu_version.addAction(self.menu_version_now) - self.menu_version_now.triggered.connect(self.version_now) - self.menu_version_1_4 = QtWidgets.QAction(main_window) - self.menu_version_1_4.setObjectName("menu_version_1_4") - self.menu_version.addAction(self.menu_version_1_4) - self.menu_version_1_4.triggered.connect(self.version_1_4) - self.menu_version_2_1 = QtWidgets.QAction(main_window) - self.menu_version_2_1.setObjectName("menu_version_2_1") - self.menu_version.addAction(self.menu_version_2_1) - self.menu_version_2_1.triggered.connect(self.version_2_1) - - ################################################################################ - self.labels_dataset = QtWidgets.QLabel(self.central_widget) - self.labels_dataset.setGeometry(QtCore.QRect(0, 0, 55, 16)) - self.labels_dataset.setObjectName("labels_dataset") - self.labels_prefix = QtWidgets.QLabel(self.central_widget) - self.labels_prefix.setGeometry(QtCore.QRect(250, 0, 55, 16)) - self.labels_prefix.setObjectName("labels_prefix") - self.labels_images = QtWidgets.QLabel(self.central_widget) - self.labels_images.setGeometry(QtCore.QRect(500, 0, 100, 16)) - self.labels_images.setObjectName("labels_images") - self.labels_version = QtWidgets.QLabel(self.central_widget) - self.labels_version.setGeometry(QtCore.QRect(650, 0, 81, 16)) - self.labels_version.setObjectName("labels_version") - - self.dataset_info_dataset = QtWidgets.QLabel(self.central_widget) - self.dataset_info_dataset.setGeometry(QtCore.QRect(0, 17, 250, 28)) - self.dataset_info_dataset.setFont(self.font_size12_b) - self.dataset_info_dataset.setObjectName("dataset_info_dataset") - self.dataset_info_prefix = QtWidgets.QLabel(self.central_widget) - self.dataset_info_prefix.setGeometry(QtCore.QRect(250, 17, 151, 28)) - self.dataset_info_prefix.setFont(self.font_size12_b) - self.dataset_info_prefix.setObjectName("dataset_info_prefix") - self.dataset_info_images = QtWidgets.QLabel(self.central_widget) - self.dataset_info_images.setGeometry(QtCore.QRect(500, 17, 300, 28)) - self.dataset_info_images.setFont(self.font_size12_b) - self.dataset_info_images.setObjectName("dataset_info_images") - - self.dataset_info_line = QtWidgets.QFrame(self.central_widget) - self.dataset_info_line.setGeometry(QtCore.QRect(0, 43, 761, 16)) - self.dataset_info_line.setFrameShape(QtWidgets.QFrame.HLine) - self.dataset_info_line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.dataset_info_line.setObjectName("dataset_info_line") - - ################################################################################ - - palette = QtGui.QPalette() - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) - brush = QtGui.QBrush(QtGui.QColor(85, 170, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) - brush = QtGui.QBrush(QtGui.QColor(213, 234, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) - brush = QtGui.QBrush(QtGui.QColor(149, 202, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) - brush = QtGui.QBrush(QtGui.QColor(42, 85, 127)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) - brush = QtGui.QBrush(QtGui.QColor(56, 113, 170)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) - brush = QtGui.QBrush(QtGui.QColor(85, 170, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush) - brush = QtGui.QBrush(QtGui.QColor(170, 212, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.PlaceholderText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) - brush = QtGui.QBrush(QtGui.QColor(85, 170, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) - brush = QtGui.QBrush(QtGui.QColor(213, 234, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) - brush = QtGui.QBrush(QtGui.QColor(149, 202, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) - brush = QtGui.QBrush(QtGui.QColor(42, 85, 127)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) - brush = QtGui.QBrush(QtGui.QColor(56, 113, 170)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) - brush = QtGui.QBrush(QtGui.QColor(85, 170, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush) - brush = QtGui.QBrush(QtGui.QColor(170, 212, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.PlaceholderText, brush) - brush = QtGui.QBrush(QtGui.QColor(42, 85, 127)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) - brush = QtGui.QBrush(QtGui.QColor(85, 170, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) - brush = QtGui.QBrush(QtGui.QColor(213, 234, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) - brush = QtGui.QBrush(QtGui.QColor(149, 202, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) - brush = QtGui.QBrush(QtGui.QColor(42, 85, 127)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) - brush = QtGui.QBrush(QtGui.QColor(56, 113, 170)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) - brush = QtGui.QBrush(QtGui.QColor(42, 85, 127)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) - brush = QtGui.QBrush(QtGui.QColor(42, 85, 127)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) - brush = QtGui.QBrush(QtGui.QColor(85, 170, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) - brush = QtGui.QBrush(QtGui.QColor(85, 170, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush) - brush = QtGui.QBrush(QtGui.QColor(85, 170, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.PlaceholderText, brush) - - self.view_buttons_xia2 = QtWidgets.QPushButton(self.central_widget) - self.view_buttons_xia2.setGeometry(QtCore.QRect(5, 60, 151, 31)) - self.view_buttons_xia2.setPalette(palette) - self.view_buttons_xia2.setFont(self.font_size10_b) - self.view_buttons_xia2.setObjectName("view_buttons_xia2") - self.view_buttons_xia2.clicked.connect(self.run_xia2) - - self.view_buttons_screen19 = QtWidgets.QPushButton(self.central_widget) - self.view_buttons_screen19.setGeometry(QtCore.QRect(165, 60, 151, 31)) - self.view_buttons_screen19.setPalette(palette) - self.view_buttons_screen19.setFont(self.font_size10_b) - self.view_buttons_screen19.setObjectName("view_buttons_screen19") - self.view_buttons_screen19.clicked.connect(self.run_screen19) - - self.view_buttons_options = QtWidgets.QPushButton(self.central_widget) - self.view_buttons_options.setGeometry(QtCore.QRect(325, 60, 151, 31)) - self.view_buttons_options.setFont(self.font_size10) - self.view_buttons_options.setObjectName("view_buttons_options") - self.view_buttons_options.clicked.connect(self.open_options) - - self.view_buttons_albula = QtWidgets.QPushButton(self.central_widget) - self.view_buttons_albula.setGeometry(QtCore.QRect(485, 60, 151, 31)) - self.view_buttons_albula.setFont(self.font_size10) - self.view_buttons_albula.setObjectName("view_buttons_albula") - self.view_buttons_albula.clicked.connect(self.run_albula) - - self.view_buttons_line = QtWidgets.QFrame(self.central_widget) - self.view_buttons_line.setGeometry(QtCore.QRect(0, 93, 761, 16)) - self.view_buttons_line.setFrameShape(QtWidgets.QFrame.HLine) - self.view_buttons_line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.view_buttons_line.setObjectName("view_buttons_line") - - ################################################################################ - - self.processing_path_label = QtWidgets.QLabel(self.central_widget) - self.processing_path_label.setGeometry(QtCore.QRect(2, 101, 191, 16)) - self.processing_path_label.setObjectName("processing_path_label") - - self.processing_path_path = QtWidgets.QLabel(self.central_widget) - self.processing_path_path.setGeometry(QtCore.QRect(2, 115, 761, 21)) - self.processing_path_path.setFont(self.font_size10_b) - self.processing_path_path.setObjectName("processing_path_path") - - self.processing_path_line = QtWidgets.QFrame(self.central_widget) - self.processing_path_line.setGeometry(QtCore.QRect(-1, 132, 761, 16)) - self.processing_path_line.setFrameShape(QtWidgets.QFrame.HLine) - self.processing_path_line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.processing_path_line.setObjectName("processing_path_line") - - ################################################################################ - - self.command_label = QtWidgets.QLabel(self.central_widget) - self.command_label.setGeometry(QtCore.QRect(2, 142, 91, 16)) - self.command_label.setObjectName("command_label") - - self.command_command = QtWidgets.QPlainTextEdit(self.central_widget) - self.command_command.setGeometry(QtCore.QRect(0, 160, 761, 61)) - self.command_command.setFont(self.font_size10_b) - self.command_command.setObjectName("command_command") - - self.command_line = QtWidgets.QFrame(self.central_widget) - self.command_line.setGeometry(QtCore.QRect(0, 220, 761, 16)) - self.command_line.setFrameShape(QtWidgets.QFrame.HLine) - self.command_line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.command_line.setObjectName("command_line") - - ################################################################################ - # xia2 output tabs - - self.xia2_output = QtWidgets.QTabWidget(self.central_widget) - # self.xia2_output.setGeometry(QtCore.QRect(0, 180, 761, 331)) - self.xia2_output.setGeometry(QtCore.QRect(0, 230, 761, 441)) - self.xia2_output.setObjectName("xia2_output") - self.xia2_output.setTabsClosable(True) - self.xia2_output.tabCloseRequested.connect(self.close_handler) - - self.main_tab = QtWidgets.QWidget() - self.main_tab.setObjectName("main_tab") - self.main_tab_txt = QtWidgets.QPlainTextEdit(self.main_tab) - self.main_tab_txt.setGeometry(QtCore.QRect(0, 0, 756, 372)) - self.main_tab_txt.setObjectName("main_tab_txt") - self.xia2_output.addTab(self.main_tab, "") - self.xia2_output.setTabText(self.xia2_output.indexOf(self.main_tab), "Main") - - ################################################################################ - - self.retranslate_ui(main_window) - self.xia2_output.setCurrentIndex(1) - QtCore.QMetaObject.connectSlotsByName(main_window) - - #################################################### - - #################################################### - # functions + super().__init__() + uic.loadUi(Path(__file__).parent / "MainWindow.ui", self) + + self.menuFile_Open.triggered.connect(self.select_dataset) + self.menuFile_Open_Multiple.triggered.connect(self.open_multiple) + self.menuFile_Close_GUI.triggered.connect(self.close_gui) + self.versionCurrent.triggered.connect(self.version_current) + self.versionLatest.triggered.connect(self.version_latest) + self.versionNow.triggered.connect(self.version_now) + self.version1_4.triggered.connect(self.version_1_4) + self.viewButtons_xia2.clicked.connect(self.run_xia2) + self.viewButtons_screen19.clicked.connect(self.run_screen19) + # Connect the 'xia2 options' button to the method that opens the options pane. + self.viewButtons_options.clicked.connect(self.open_options) + self.viewButtons_albula.clicked.connect(self.run_albula) + + # Remove the close button from the main log output tab, leaving the close + # buttons on the other tabs active. + tab_bar = self.output_tabs.tabBar() + left_delete_button = tab_bar.tabButton(0, tab_bar.LeftSide) + if left_delete_button: + left_delete_button.deleteLater() + right_delete_button = tab_bar.tabButton(0, tab_bar.RightSide) + if right_delete_button: + right_delete_button.deleteLater() + tab_bar.setTabButton(0, tab_bar.LeftSide, None) + tab_bar.setTabButton(0, tab_bar.RightSide, None) + self.output_tabs.tabCloseRequested.connect(self.close_handler) + + self.show() @staticmethod def append_output(tab_name, new_lines_print): @@ -482,7 +135,7 @@ def select_dataset(self): if self.dataset_path: self.multiple_dataset = {} self.append_output( - self.main_tab_txt, "\n Dataset Path: " + self.dataset_path + self.log_output_txt, "\n Dataset Path: " + self.dataset_path ) self.dataset = self.dataset_path.split("/")[-1] # dataset name if "staging" in self.dataset_path.split("/"): @@ -492,13 +145,15 @@ def select_dataset(self): # /dls/i19-2/data/2020/cm26492-2/ self.visit = "/".join(self.dataset_path.split("/")[:6]) + "/" self.opening_visit = str(self.visit) - self.append_output(self.main_tab_txt, " Dataset: " + self.dataset) + self.append_output( + self.log_output_txt, " Dataset: " + self.dataset + ) for cbf_file in os.listdir(self.dataset_path): # prefix if cbf_file.endswith("_00001.cbf"): self.prefix = cbf_file[:-12] break - self.append_output(self.main_tab_txt, " Prefix: " + self.prefix) + self.append_output(self.log_output_txt, " Prefix: " + self.prefix) self.run_list = [] run_images_dict = {} for cbf_files in os.listdir(self.dataset_path): # runs in dataset @@ -509,7 +164,7 @@ def select_dataset(self): self.run_list.sort() self.append_output( - self.main_tab_txt, + self.log_output_txt, " Number of runs: " + " ".join(map(str, (len(self.run_list), self.run_list))), ) @@ -520,11 +175,11 @@ def select_dataset(self): ) run_images_dict[run] = num_cbf_run self.append_output( - self.main_tab_txt, " Images per run: " + str(run_images_dict) + self.log_output_txt, " Images per run: " + str(run_images_dict) ) total_num_images = sum(run_images_dict.values()) # total number of images self.append_output( - self.main_tab_txt, + self.log_output_txt, " Total number of images: " + str(total_num_images) + "\n", ) # update labels @@ -548,7 +203,8 @@ def open_multiple(self): if new_dataset_path: self.append_output( - self.main_tab_txt, "\n New Dataset Path: " + new_dataset_path + self.log_output_txt, + "\n New Dataset Path: " + new_dataset_path, ) dataset = new_dataset_path.split("/")[-1] # dataset name @@ -559,14 +215,16 @@ def open_multiple(self): # /dls/i19-2/data/2020/cm26492-2/ self.visit = "/".join(self.dataset_path.split("/")[:6]) + "/" self.opening_visit = str(self.visit) - self.append_output(self.main_tab_txt, " New Dataset: " + dataset) + self.append_output( + self.log_output_txt, " New Dataset: " + dataset + ) for cbf_file in os.listdir(new_dataset_path): # prefix if cbf_file.endswith("_00001.cbf"): prefix = cbf_file[:-12] break if prefix: - self.append_output(self.main_tab_txt, " New Prefix: " + prefix) + self.append_output(self.log_output_txt, " New Prefix: " + prefix) run_list = [] run_images_dict = {} for cbf_file in os.listdir(new_dataset_path): # runs in dataset @@ -577,7 +235,7 @@ def open_multiple(self): run_list.sort() self.append_output( - self.main_tab_txt, + self.log_output_txt, " New Number of runs: " + str(len(run_list)) + " " @@ -590,11 +248,12 @@ def open_multiple(self): ) run_images_dict[run] = num_cbf_run self.append_output( - self.main_tab_txt, " New Images per run: " + str(run_images_dict) + self.log_output_txt, + " New Images per run: " + str(run_images_dict), ) total_num_images = sum(run_images_dict.values()) # total number of images self.append_output( - self.main_tab_txt, + self.log_output_txt, " New Total number of images: " + str(total_num_images) + "\n", ) # update labels @@ -607,24 +266,24 @@ def open_multiple(self): self.multiple_dataset[dataset] = [new_dataset_path, prefix, run_list] self.append_output( - self.main_tab_txt, + self.log_output_txt, " Multiple runs:\n " + str(self.multiple_dataset), ) # file menu, close -> close GUI #### def close_gui(self): - self.append_output(self.main_tab_txt, "\n\nClosing GUI\n\n") + self.append_output(self.log_output_txt, "\n\nClosing GUI\n\n") QtCore.QCoreApplication.instance().quit() # open albula #### def run_albula(self): - self.append_output(self.main_tab_txt, self.dataset_path) + self.append_output(self.log_output_txt, self.dataset_path) if self.dataset_path == "": subprocess.Popen( ["sh", "/dls_sw/i19/scripts/MarkWarren/PyQT/1_basic/albula.sh"] ) else: - self.append_output(self.main_tab_txt, "opening albula with first image") + self.append_output(self.log_output_txt, "opening albula with first image") image = f"{self.dataset_path}/{self.prefix}{self.run_list[0]:02d}_00001.cbf" subprocess.Popen( ["sh", "/dls_sw/i19/scripts/MarkWarren/PyQT/1_basic/albula.sh", image] @@ -632,7 +291,7 @@ def run_albula(self): # open options window ########################################################### def open_options(self): - self.append_output(self.main_tab_txt, "Opening options window") + self.append_output(self.log_output_txt, "Opening options window") self.secondWindow = QtWidgets.QMainWindow() self.ui = UIXia2Options( self, @@ -641,7 +300,7 @@ def open_options(self): self.dataset_path, self.command_command, self.visit, - self.main_tab_txt, + self.log_output_txt, self.run_list, self.prefix, self.opening_visit, @@ -654,17 +313,17 @@ def update_options(self): ) def run_xia2(self): - self.append_output(self.main_tab_txt, "\nRunning xia2\n") + self.append_output(self.log_output_txt, "\nRunning xia2\n") # single datasets ########### if not self.dataset_path == "MULTIPLE": - self.append_output(self.main_tab_txt, "Single Dataset") + self.append_output(self.log_output_txt, "Single Dataset") if self.prefix == "": self.append_output( - self.main_tab_txt, + self.log_output_txt, "\n\n #########################################################", ) self.append_output( - self.main_tab_txt, + self.log_output_txt, " No cbf images found in directory, " "please select dataset directory", ) @@ -672,7 +331,7 @@ def run_xia2(self): self.run_xia2_dataset(self.dataset, self.dataset_path) # multiple datasets ########### if self.dataset_path == "MULTIPLE": # if multiple input has been utilised - self.append_output(self.main_tab_txt, "\n Multiple dataset processing\n") + self.append_output(self.log_output_txt, "\n Multiple dataset processing\n") # { # "01_Prot1_21": [ # "/dls/i19-2/data/2020/cy23401-1/01_Prot1_21", @@ -686,12 +345,12 @@ def run_xia2(self): dataset_path, prefix, _ = self.multiple_dataset[dataset_key] if not prefix: self.append_output( - self.main_tab_txt, + self.log_output_txt, "\n\n ############################" "############################b", ) self.append_output( - self.main_tab_txt, + self.log_output_txt, " No cbf images found in directory, " "please select dataset directory", ) @@ -705,12 +364,12 @@ def run_xia2(self): runs = self.multiple_dataset[dataset_key][2] if prefix == "": self.append_output( - self.main_tab_txt, + self.log_output_txt, "\n\n ############################" "############################c", ) self.append_output( - self.main_tab_txt, + self.log_output_txt, " No cbf images found in directory, " "please select dataset directory", ) @@ -759,11 +418,11 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas self.processing_path_path.setText(self.processing_path) self.tabs_processing_path[self.tabs_num] = self.processing_path - self.append_output(self.main_tab_txt, "Xia2 command:") + self.append_output(self.log_output_txt, "Xia2 command:") # this is the bit I think i need to change!!! # dataset and prefix I would guess is required input_xia2_command = self.xia2_command + xia2_input + self.xia2_options_list - self.append_output(self.main_tab_txt, " " + input_xia2_command) + self.append_output(self.log_output_txt, " " + input_xia2_command) # create job file @@ -814,9 +473,9 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas lambda: self.run_dials_html(tab_num) ) - self.xia2_output.addTab(self.tabs[self.tabs_num], "") - self.xia2_output.setTabText( - self.xia2_output.indexOf(self.tabs[self.tabs_num]), + self.output_tabs.addTab(self.tabs[self.tabs_num], "") + self.output_tabs.setTabText( + self.output_tabs.indexOf(self.tabs[self.tabs_num]), input_dataset + "_" + time_date, ) @@ -833,7 +492,7 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas dataset_error_statement = ( "\n\n No dataset has been selected (File>Open) \n\n" ) - self.append_output(self.main_tab_txt, dataset_error_statement) + self.append_output(self.log_output_txt, dataset_error_statement) self.append_output(tab_name, dataset_error_statement) else: if self.computing_location == "Local": @@ -865,7 +524,7 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas input_dataset, self.tabstxt, self.tabs_num, - self.main_tab_txt, + self.log_output_txt, "xia2.txt", ) @@ -881,14 +540,14 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas self.tabs_num = 0 def run_screen19(self): - self.append_output(self.main_tab_txt, "\nRunning screen19\n") + self.append_output(self.log_output_txt, "\nRunning screen19\n") if self.prefix == "": self.append_output( - self.main_tab_txt, + self.log_output_txt, "\n\n #########################################################", ) self.append_output( - self.main_tab_txt, + self.log_output_txt, " No cbf images found in directory, please select dataset directory", ) return @@ -911,7 +570,7 @@ def run_screen19(self): self.processing_path_path.setText(self.processing_path) self.tabs_processing_path[self.tabs_num] = self.processing_path - self.append_output(self.main_tab_txt, "screen19 command:") + self.append_output(self.log_output_txt, "screen19 command:") # remove unwanted xia2 commands screen19_options_list = "" @@ -924,7 +583,7 @@ def run_screen19(self): input_screen19_command = ( "screen19 " + self.dataset_path + screen19_options_list ) - self.append_output(self.main_tab_txt, " " + input_screen19_command) + self.append_output(self.log_output_txt, " " + input_screen19_command) # create job file job_file = self.processing_path + "job.sh" @@ -983,9 +642,9 @@ def run_screen19(self): lambda: self.run_dials_html(tab_num) ) - self.xia2_output.addTab(self.tabs[self.tabs_num], "") - self.xia2_output.setTabText( - self.xia2_output.indexOf(self.tabs[self.tabs_num]), + self.output_tabs.addTab(self.tabs[self.tabs_num], "") + self.output_tabs.setTabText( + self.output_tabs.indexOf(self.tabs[self.tabs_num]), self.dataset + "_s19_" + time_date, ) @@ -1004,7 +663,7 @@ def run_screen19(self): dataset_error_statement = ( "\n\n Dataset has not be selected (File>Open) \n\n" ) - self.append_output(self.main_tab_txt, dataset_error_statement) + self.append_output(self.log_output_txt, dataset_error_statement) self.append_output(tab_name, dataset_error_statement) else: if self.computing_location == "Local": @@ -1029,7 +688,7 @@ def run_screen19(self): self.dataset, self.tabstxt, self.tabs_num, - self.main_tab_txt, + self.log_output_txt, "screen19.log", ) @@ -1045,21 +704,24 @@ def run_screen19(self): self.tabs_num = 0 def thread_started(self): - self.append_output(self.main_tab_txt, "\n*** Thread Started ***\n") + self.append_output(self.log_output_txt, "\n*** Thread Started ***\n") def thread_finished(self): - self.append_output(self.main_tab_txt, "\n*** Thread Finished ***\n") + self.append_output(self.log_output_txt, "\n*** Thread Finished ***\n") def stop_thread(self): - self.append_output(self.main_tab_txt, "\n*** Stopping Thead ***\n") + self.append_output(self.log_output_txt, "\n*** Stopping Thead ***\n") # self.MyThread2.stop() # self.MyThread2.quit() # open run dials Reciprocal Lattice viewer #### def run_dials_reciprocal_lattice(self, tabs_num): - self.append_output(self.main_tab_txt, "Opening dials reciprocal lattice viewer") self.append_output( - self.main_tab_txt, "Processing path:" + self.tabs_processing_path[tabs_num] + self.log_output_txt, "Opening dials reciprocal lattice viewer" + ) + self.append_output( + self.log_output_txt, + "Processing path:" + self.tabs_processing_path[tabs_num], ) latest_expt = "" @@ -1093,24 +755,24 @@ def run_dials_reciprocal_lattice(self, tabs_num): latest_refl_time = file_time if latest_expt == "": self.append_output( - self.main_tab_txt, + self.log_output_txt, "\n\n *** Expt was not present in processing path, " "please wait unit after initial importing *** \n\n", ) return if latest_refl == "": self.append_output( - self.main_tab_txt, + self.log_output_txt, "\n\n ***Refl was not present in processing path, " "please wait unit after initial spot finding *** \n\n", ) return else: self.append_output( - self.main_tab_txt, "\nReflection file: " + str(latest_refl) + self.log_output_txt, "\nReflection file: " + str(latest_refl) ) self.append_output( - self.main_tab_txt, "Experiment file: " + str(latest_expt) + "\n" + self.log_output_txt, "Experiment file: " + str(latest_expt) + "\n" ) subprocess.Popen( [ @@ -1125,9 +787,10 @@ def run_dials_reciprocal_lattice(self, tabs_num): ) def run_dials_image_viewer(self, tabs_num): - self.append_output(self.main_tab_txt, "Opening dials image viewer") + self.append_output(self.log_output_txt, "Opening dials image viewer") self.append_output( - self.main_tab_txt, "Processing path:" + self.tabs_processing_path[tabs_num] + self.log_output_txt, + "Processing path:" + self.tabs_processing_path[tabs_num], ) latest_expt = "" @@ -1161,16 +824,16 @@ def run_dials_image_viewer(self, tabs_num): latest_refl_time = file_time if latest_expt == "": self.append_output( - self.main_tab_txt, + self.log_output_txt, "\n\n ***Expt was not present in processing path, " "please wait unit after initial importing *** \n\n", ) else: self.append_output( - self.main_tab_txt, "\nReflection file: " + str(latest_refl) + self.log_output_txt, "\nReflection file: " + str(latest_refl) ) self.append_output( - self.main_tab_txt, "Experiment file: " + str(latest_expt) + "\n" + self.log_output_txt, "Experiment file: " + str(latest_expt) + "\n" ) subprocess.Popen( [ @@ -1185,9 +848,10 @@ def run_dials_image_viewer(self, tabs_num): ) def run_dials_html(self, tabs_num): - self.append_output(self.main_tab_txt, "Opening HTML") + self.append_output(self.log_output_txt, "Opening HTML") self.append_output( - self.main_tab_txt, "Processing path:" + self.tabs_processing_path[tabs_num] + self.log_output_txt, + "Processing path:" + self.tabs_processing_path[tabs_num], ) latest_html = "" @@ -1208,14 +872,14 @@ def run_dials_html(self, tabs_num): if latest_html == "": self.append_output( - self.main_tab_txt, + self.log_output_txt, ( "\n\n *** html file was not present in processing path, " "please wait unit after initial importing *** \n\n" ), ) else: - self.append_output(self.main_tab_txt, "HTML file: " + str(latest_html)) + self.append_output(self.log_output_txt, "HTML file: " + str(latest_html)) subprocess.Popen( [ "sh", @@ -1226,7 +890,7 @@ def run_dials_html(self, tabs_num): # version menu, change version def version_current(self): - self.append_output(self.main_tab_txt, "Changing to dials version to current.") + self.append_output(self.log_output_txt, "Changing to dials version to current.") dial_version_pop = ( os.popen("module unload dials; module load dials; dials.version") .read() @@ -1236,11 +900,11 @@ def version_current(self): self.dials_version = "" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.main_tab_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") # version menu, change version to latest def version_latest(self): - self.append_output(self.main_tab_txt, "Changing to dials version to latest.") + self.append_output(self.log_output_txt, "Changing to dials version to latest.") dial_version_pop = ( os.popen("module unload dials; module load dials/latest; dials.version") .read() @@ -1250,11 +914,11 @@ def version_latest(self): self.dials_version = "/latest" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.main_tab_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") # version menu, change version to now def version_now(self): - self.append_output(self.main_tab_txt, "Changing to dials version to Now.") + self.append_output(self.log_output_txt, "Changing to dials version to Now.") dial_version_pop = ( os.popen("module unload dials; module load dials/now; dials.version") .read() @@ -1264,11 +928,11 @@ def version_now(self): self.dials_version = "/now" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.main_tab_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") # version menu, change version to 1.4 def version_1_4(self): - self.append_output(self.main_tab_txt, "Changing to dials version to 1.4.") + self.append_output(self.log_output_txt, "Changing to dials version to 1.4.") dial_version_pop = ( os.popen("module unload dials; module load dials/1.4; dials.version") .read() @@ -1278,11 +942,11 @@ def version_1_4(self): self.dials_version = "/1.4" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.main_tab_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") # version menu, change version to 2.1 def version_2_1(self): - self.append_output(self.main_tab_txt, "Changing to dials version to 2.1.") + self.append_output(self.log_output_txt, "Changing to dials version to 2.1.") dial_version_pop = ( os.popen("module unload dials; module load dials/2.1; dials.version") .read() @@ -1292,122 +956,14 @@ def version_2_1(self): self.dials_version = "/2.1" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.main_tab_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") # close tabs ###### def close_handler(self, index): self.append_output( - self.main_tab_txt, "close_handler called, index = %s" % index - ) - self.xia2_output.removeTab(index) - - #################################################### - def retranslate_ui(self, main_window): - _translate = QtCore.QCoreApplication.translate - # main window tile - main_window.setWindowTitle( - _translate("main_window", "Chemical Crystallography Xia2 GUI") - ) - # File menu - self.menu_file.setTitle(_translate("main_window", "File")) - self.menu_file_open.setText(_translate("main_window", "Open")) - self.menu_file_open.setStatusTip( - _translate("main_window", "Open the dataset - select dataset folder") - ) - self.menu_file_open.setShortcut(_translate("main_window", "Ctrl+O")) - self.menu_file_open_multiple.setText(_translate("main_window", "Open Multiple")) - self.menu_file_open_multiple.setStatusTip( - _translate( - "main_window", - "Open multiple datasets - " - "select multiple datasets using the Ctrl button", - ) - ) - self.menu_file_open_multiple.setShortcut(_translate("main_window", "Ctrl+M")) - self.menu_file_close_gui.setText(_translate("main_window", "Close GUI")) - self.menu_file_close_gui.setStatusTip( - _translate("main_window", "This will close the GUI") - ) - self.menu_file_close_gui.setShortcut(_translate("main_window", "Ctrl+C")) - # Edit menu - self.menu_edit.setTitle(_translate("main_window", "Edit")) - self.menu_edit_copy_command.setText(_translate("main_window", "Copy Command #")) - self.menu_edit_save_settings.setText( - _translate("main_window", "Save Settings #") - ) - self.menu_edit_save_settings.setStatusTip( - _translate("main_window", "Save all the GUI settings to a .txt file") - ) - self.menu_edit_load_settings.setText( - _translate("main_window", "Load Settings #") - ) - self.menu_edit_load_settings.setStatusTip( - _translate("main_window", "Load previous save GUI settings") - ) - # View menu - self.menu_view.setTitle(_translate("main_window", "View")) - # Settings menu - self.menu_settings.setTitle(_translate("main_window", "Settings")) - # Version menu - dial_version_pop = os.popen("dials.version").read().split("-")[0].split(" ")[1] - self.menu_version.setTitle( - _translate("main_window", "Version(" + dial_version_pop + ")") - ) - self.menu_version_current.setText(_translate("main_window", "dials_current")) - self.menu_version_latest.setText(_translate("main_window", "dials_latest")) - self.menu_version_now.setText(_translate("main_window", "dials_now")) - self.menu_version_1_4.setText(_translate("main_window", "dials_1.4 #")) - self.menu_version_2_1.setText(_translate("main_window", "dials_2.1 #")) - # Dataset labels info - self.labels_dataset.setText(_translate("main_window", "Dataset")) - self.labels_prefix.setText(_translate("main_window", "Prefix")) - self.labels_images.setText(_translate("main_window", "Runs images")) - self.dataset_info_dataset.setText(_translate("main_window", "none")) - self.dataset_info_prefix.setText(_translate("main_window", "none")) - self.dataset_info_images.setText(_translate("main_window", "0")) - # view buttons - self.view_buttons_xia2.setText(_translate("main_window", "Run Xia2")) - self.view_buttons_xia2.setStatusTip( - _translate("main_window", "Run Xia2 with current dataset and options") - ) - - self.view_buttons_screen19.setText(_translate("main_window", "Run screen19")) - self.view_buttons_screen19.setStatusTip( - _translate("main_window", "Run screen with current dataset and options") - ) - - self.view_buttons_options.setText(_translate("main_window", "Xia2 Options")) - self.view_buttons_options.setStatusTip( - _translate( - "main_window", - "Opens a second window with all additional xia2 processing options", - ) - ) - self.view_buttons_albula.setText(_translate("main_window", "Open Albula")) - self.view_buttons_albula.setStatusTip( - _translate( - "main_window", "Open Albula which is image viewing program from Dectris" - ) - ) - # processing path - self.processing_path_path.setText(_translate("main_window", "none")) - self.processing_path_label.setText(_translate("main_window", "Processing Path")) - # xia2 command - self.command_label.setText(_translate("main_window", "xia2 Command")) - self.command_command.setPlainText( - _translate("main_window", "xia2 small_molecule=true dataset_path") + self.log_output_txt, "close_handler called, index = %s" % index ) - self.command_command.setStatusTip( - _translate("main_window", "Current xia2 command (do not manually edit)") - ) - - # self.main_tab_txt.setText(_translate("main_window", "Main")) - - -######################################################################################## -######################################################################################## -######################################################################################## -######################################################################################## + self.output_tabs.removeTab(index) class MyThread2(QtCore.QThread): @@ -1415,14 +971,14 @@ class MyThread2(QtCore.QThread): finished = QtCore.pyqtSignal() def __init__( - self, processing_path, dataset, tabstxt, tabs_num, main_tab_txt, log_file + self, processing_path, dataset, tabstxt, tabs_num, log_output_txt, log_file ): QtCore.QThread.__init__(self) self.processingPath = processing_path self.tabstxt = tabstxt self.tabsNum = tabs_num self.dataset = dataset - self.mainTab_txt = main_tab_txt + self.mainTab_txt = log_output_txt self.logFile = log_file def __del__(self): @@ -1430,7 +986,7 @@ def __del__(self): def run(self): tab_name = self.tabstxt[self.tabsNum] - main_tab_txt = self.mainTab_txt + log_output_txt = self.mainTab_txt xia2_txt_lines_num_previous = 0 is_running = "Yes" sleep(3) @@ -1451,8 +1007,8 @@ def run(self): "\n\nEnd of xia2 processing detected.\n" "Stopping output to tab\n\n" ) - main_tab_txt.appendPlainText(output_message) - main_tab_txt.moveCursor(QtGui.QTextCursor.End) + log_output_txt.appendPlainText(output_message) + log_output_txt.moveCursor(QtGui.QTextCursor.End) sleep(0.1) tab_name.appendPlainText(output_message) tab_name.moveCursor(QtGui.QTextCursor.End) @@ -1461,17 +1017,17 @@ def run(self): "\n\nEnd of xia2 processing detected.\n" "Stopping output to tab\n\n" ) - main_tab_txt.appendPlainText(output_message) - main_tab_txt.moveCursor(QtGui.QTextCursor.End) + log_output_txt.appendPlainText(output_message) + log_output_txt.moveCursor(QtGui.QTextCursor.End) sleep(0.1) tab_name.appendPlainText(output_message) tab_name.moveCursor(QtGui.QTextCursor.End) else: - main_tab_txt.appendPlainText("xia2.txt file does not exist yet") - main_tab_txt.moveCursor(QtGui.QTextCursor.End) + log_output_txt.appendPlainText("xia2.txt file does not exist yet") + log_output_txt.moveCursor(QtGui.QTextCursor.End) sleep(5) - main_tab_txt.appendPlainText("finishing") - main_tab_txt.moveCursor(QtGui.QTextCursor.End) + log_output_txt.appendPlainText("finishing") + log_output_txt.moveCursor(QtGui.QTextCursor.End) self.finished.emit() @@ -1490,7 +1046,7 @@ def __init__( dataset_path, command_command, visit, - main_tab_txt, + log_output_txt, run_list, prefix, opening_visit, @@ -1502,7 +1058,7 @@ def __init__( self.command_command = command_command self.ref_geometry_path = "" self.visit = visit - self.main_tab_txt = main_tab_txt + self.log_output_txt = log_output_txt self.run_image_selector = False self.run_selection = [] self.image_selection = {} @@ -2716,8 +2272,8 @@ def browse_for_reference_model(self): + "\nReference Geometry File:\n " + str(ref_geometry_file_txt) ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) self.import_reference_geometry_path.setText(ref_geometry_file_txt) self.import_reference_geometry_path.setScaledContents(True) @@ -2739,8 +2295,8 @@ def update_options(self): " *** Reference Geometry Error. Please select " ".expt file with browse button first ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -2754,15 +2310,15 @@ def update_options(self): " *** Detector Distance Error. Please input " "detector distance e.g. 85.01" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: output_message = "Detector distance: " + str( self.import_dd_line_edit.text() ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) options = ( options + " detector_distance=" @@ -2772,15 +2328,15 @@ def update_options(self): if variable == self.import_beam_centre: if self.import_beam_centre_x_line_edit.text() == "": output_message = " *** Beam Centre Error. Please input Y" - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return elif self.import_beam_centre_y_line_edit.text() == "": output_message = ( " *** Detector Distance Error. Please input X" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: output_message = ( @@ -2789,8 +2345,8 @@ def update_options(self): + "," + str(self.import_beam_centre_y_line_edit.text()) ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) options = ( options + " mosflm_beam_centre=" @@ -2805,15 +2361,15 @@ def update_options(self): " *** Wavelength Input Error. " "Please add wavelength e.g. 85.01" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: output_message = "Wavelength: " + str( self.import_wavelength_line_edit.text() ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) options = ( options + " wavelength=" @@ -2832,10 +2388,10 @@ def update_options(self): for num, run in enumerate(self.runSelectorList, start=1): if run.isChecked(): self.run_selection.append(num) - self.main_tab_txt.appendPlainText( + self.log_output_txt.appendPlainText( "Run selector: " + str(self.run_selection) ) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) if variable == self.Import_type_checkBox: if self.Import_type_comboBox.currentText() == "Protein": pass @@ -2851,8 +2407,8 @@ def update_options(self): " *** Sigma Strong Error." " Please enter sigma strong e.g. 6 ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -2866,8 +2422,8 @@ def update_options(self): " *** Min Spot Size Error, " "please entre min spots size e.g. 2 ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -2881,8 +2437,8 @@ def update_options(self): " *** Max Spot Size Error, " "please entre max spots size e.g. 2 ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -2895,8 +2451,8 @@ def update_options(self): output_message = ( " *** D_min Error, please entre d_min e.g. 0.84 ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -2909,8 +2465,8 @@ def update_options(self): output_message = ( " *** D_max Error, please entre d_max e.g. 10 ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -2931,8 +2487,8 @@ def update_options(self): for entry in powder_ring_line_edits: if entry == "": output_message = " *** Powder ring mask error ***" - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return ice_rings_uv_command = " ice_rings.unit_cell=" + str( self.findSpots_powderRingsUC_lineEdit.text() @@ -2973,8 +2529,8 @@ def update_options(self): " *** Circle Mask Error, please entre is the " "following format: xc,yc,r ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -2989,8 +2545,8 @@ def update_options(self): " *** Rectangle Mask Error, please entre is " "the following format: x0,x1,y0,y1 ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -3016,14 +2572,14 @@ def update_options(self): self.Index_SG_lineEdit.text(), ] for entry in uc_sg_line_edits: - self.main_tab_txt.appendPlainText(entry) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(entry) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) if entry == "": output_message = ( " *** Error in unit cell or space group entry ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return uc_command = " unit_cell=" + str(self.Index_UN_lineEdit.text()) sg_command = " space_group=" + str(self.Index_SG_lineEdit.text()) @@ -3031,8 +2587,8 @@ def update_options(self): if variable == self.Index_minCell_checkBox: if self.Index_minCell_lineEdit.text() == "": output_message = " *** Please entre valid min cell ***" - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -3043,8 +2599,8 @@ def update_options(self): if variable == self.Index_maxCell_checkBox: if self.Index_maxCell_lineEdit.text() == "": output_message = " *** Please entre valid max cell ***" - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -3076,8 +2632,8 @@ def update_options(self): output_message = ( " *** Error in overall or per degree entry ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return if self.visit == "": output_message = ( @@ -3085,8 +2641,8 @@ def update_options(self): "this requires a the visit to be known." " Please open a dataset and retry (File>Open). ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return overall_line = ( " profile.gaussian_rs.min_spots.overall=" @@ -3164,8 +2720,8 @@ def update_options(self): " *** Reference Geometry Error. " "Please select .expt file with browse button first ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -3201,8 +2757,8 @@ def update_options(self): for entry in powder_ring_line_edits: if entry == "": output_message = " *** Powder ring mask error ***" - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return ice_rings_uv_command = " ice_rings.unit_cell=" + str( self.HP_gasketUserUC_lineEdit.text() @@ -3226,14 +2782,14 @@ def update_options(self): self.HP_SG_lineEdit.text(), ] for entry in uc_sg_line_edits: - self.main_tab_txt.appendPlainText(entry) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(entry) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) if entry == "": output_message = ( " *** Error in unit cell or space group entry ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return uc_command = " unit_cell=" + str(self.HP_UN_lineEdit.text()) sg_command = " space_group=" + str(self.HP_SG_lineEdit.text()) @@ -3244,8 +2800,8 @@ def update_options(self): output_message = ( " *** D_min HP Error, please entre d_min e.g. 0.84 ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -3277,8 +2833,8 @@ def update_options(self): output_message = "Image start/end option selected.\n" " " + str( self.image_selection ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) if variable == self.HP_FixBeamDetector_checkBox: options = ( @@ -3296,8 +2852,8 @@ def update_options(self): " *** Anvil Thickness Input Error, " "please enter thickness e.g. 2.1 ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: options = ( @@ -3312,8 +2868,8 @@ def update_options(self): " *** Anvil Opening Angle Input Error, " "please enter opening angle e.g. 38 ***" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: pass @@ -3328,11 +2884,11 @@ def update_options(self): else: # causing issues when multiple ########### if self.dataset_path == "": dataset_input = self.dataset_path - self.main_tab_txt.appendPlainText( + self.log_output_txt.appendPlainText( "Dataset must be selected before selecting runs or images " "start/end" ) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) else: dataset_input = "" if self.run_selection: # runs have been selected @@ -3376,8 +2932,8 @@ def update_options(self): + self.dataset_path + options ) - self.main_tab_txt.appendPlainText(options_update_text) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(options_update_text) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) self.ui_main_window.xia2_command = self.xia2_command self.ui_main_window.dataset_path = self.dataset_path @@ -3388,8 +2944,8 @@ def update_options(self): def reset_options(self): output_message = "\nResetting options" - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) for checkboxes in self.optionListImport: checkboxes.setChecked(False) @@ -3429,8 +2985,8 @@ def reset_options(self): + self.dataset_path + options ) - self.main_tab_txt.appendPlainText(options_update_text) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(options_update_text) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) self.ui_main_window.xia2_command = self.xia2_command self.ui_main_window.dataset_path = self.dataset_path @@ -3806,8 +3362,8 @@ def option_file_text_function(self): def save_options(self): output_message = "\n Saving options" - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) path = self.opening_visit option_file = QtWidgets.QFileDialog.getSaveFileName( @@ -3823,8 +3379,8 @@ def save_options(self): + "\n " + str(option_file_text) ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) with open(option_file, "a") as f: f.write(option_file_text) @@ -3833,8 +3389,8 @@ def save_options(self): def save_options_auto(self): output_message = "\n Saving current options" - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) if self.visit == "": return @@ -3849,8 +3405,8 @@ def save_options_auto(self): + "\n " + str(option_file_text) ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) with open(option_file, "a") as of: of.write(option_file_text) @@ -3863,8 +3419,8 @@ def load_options_auto(self): " Visit/Dataset has not been selected, " "therefore previous settings will not be loaded" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return if os.path.isfile(self.visit + "processing/autoSaveOptions.txt"): saved_options_path_txt = self.visit + "processing/autoSaveOptions.txt" @@ -3872,8 +3428,8 @@ def load_options_auto(self): def load_options(self): output_message = "\nLoading options" - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) path = self.opening_visit os.chdir(path) @@ -3886,8 +3442,8 @@ def load_options_main(self, saved_options_path_txt): output_message = ( " Loading previous settings (" + saved_options_path_txt + ")" ) - self.main_tab_txt.appendPlainText(output_message) - self.main_tab_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) with open(saved_options_path_txt) as options_input: for line in options_input: line = "".join(line.split("\n")) @@ -4619,14 +4175,8 @@ def retranslate_ui(self, xia2_options): ) -######################################################################################## -######################################################################################## -######################################################################################## -######################################################################################## if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) # QApplication.setOverrideCursor(Qt.WaitCursor) - MainWindow = QtWidgets.QMainWindow() - ui = UIMainWindow(MainWindow) - MainWindow.show() + ui = UIMainWindow() sys.exit(app.exec_()) From 28c9e5adad3135e7ba929ff7c40eaab6d952106d Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Fri, 20 Nov 2020 18:03:26 +0000 Subject: [PATCH 02/31] Add .ui design for the xia2 options window --- i19-gui/OptionsWindow.ui | 1460 +++++++++++++++++++++++ i19-gui/chemical_crystallography_gui.py | 1192 +----------------- 2 files changed, 1473 insertions(+), 1179 deletions(-) create mode 100644 i19-gui/OptionsWindow.ui diff --git a/i19-gui/OptionsWindow.ui b/i19-gui/OptionsWindow.ui new file mode 100644 index 0000000..82ab70d --- /dev/null +++ b/i19-gui/OptionsWindow.ui @@ -0,0 +1,1460 @@ + + + Xia2Options + + + + 0 + 0 + 690 + 684 + + + + Options - Xia2 Additional Commands + + + + + + + + + + + + Update command + + + + + + + Reset + + + + + + + Save settings + + + + + + + Load settings + + + + + + + + + true + + + 0 + + + + Import + + + + + + Trust beam centre + + + + + + + Reference geometry + + + + + + + + + Browse + + + + + + + true + + + true + + + path/to/instrument_model.expt + + + + + + + + + Detector distance (mm) + + + + + + + e.g. 85.19 + + + + + + + + + + Beam centre + + + + + + + + + + + X + + + + + + + e.g. 54.3 + + + + + + + + + + + Y + + + + + + + e.g. 43.3 + + + + + + + + + + + Wavelength (Å) + + + + + + + e.g. 0.6889 + + + + + + + Fix instrument model + + + + + + + Run selection + + + + + + + + + 3 + + + + + + + 9 + + + + + + + 2 + + + + + + + 5 + + + + + + + 7 + + + + + + + 11 + + + + + + + 12 + + + + + + + 8 + + + + + + + 4 + + + + + + + 16 + + + + + + + 13 + + + + + + + 15 + + + + + + + 14 + + + + + + + 1 + + + + + + + 6 + + + + + + + 10 + + + + + + + + + Method + + + + + + + + Chemical + + + + + Macromolecular + + + + + + + + + true + + + Spot finding + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + σ strong + + + + + + + e.g. 6 (default = 3) + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + Min spot size + + + + + + + e.g. 2 + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + Max spot size + + + + + + + e.g. 20 (default=1000) + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + d min (Å) + + + + + + + e.g. 0.84 + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + d max (Å) + + + + + + + e.g. 15 + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + Ice rings + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + Powder rings + + + + + + + + + + + Unit cell + + + + + + + e.g. 5.6,5.7,12.4,90,105.2,90 + + + + + + + + + + + Space group + + + + + + + e.g. P21 + + + + + + + + + + + Width + + + + + + + e.g. 0.04 (default = 0.002) + + + + + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + Resolution range + + + + + + + + + e.g. 1.02,0.98 + + + + + + + e.g. 1.02,0.98 + + + + + + + e.g. 1.02,0.98 + + + + + + + e.g. 1.02,0.98 + + + + + + + e.g. 1.02,0.98 + + + + + + + e.g. 1.02,0.98 + + + + + + + e.g. 1.02,0.98 + + + + + + + e.g. 1.02,0.98 + + + + + + + e.g. 1.02,0.98 + + + + + + + e.g. 1.02,0.98 + + + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + Circle mask + + + + + + + e.g. 620,851,27 (xc,yc,r) + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + Rectangle mask + + + + + + + e.g. 0,612,824,858 (x0, x1, y0, y1) + + + + + + + + Indexing + + + + + + Method + + + + + + + + fft3d + + + + + fft1d + + + + + real_space_grid_search + + + + + low_res_spot_match + + + + + + + + Unit cell and space group + + + + + + + + + + + Unit Cell + + + + + + + e.g. 5.1,6.2,7.3,90,95.1,90 + + + + + + + + + + + Space Group + + + + + + + e.g. P21/c + + + + + + + + + + + Minimium unit cell length (Å) + + + + + + + e.g. 6.0 (default = 3) + + + + + + + Maximium unit cell length (Å) + + + + + + + e.g. 30.0 + + + + + + + Multiple-sweep joint indexing + + + + + + + Multiple-sweep joint refinement + + + + + + + Include outliers + + + + + + + + + 0 + 0 + + + + Refine/scale + + + + + + Refinement + + + + + + Fix instrument model + + + + + + + Min number of reflections + + + + + + + + + + + Overall + + + + + + + + + + + + + + Per degree + + + + + + + + + + + + + + Scan varying + + + true + + + false + + + + + + + + + + Scaling + + + + + + Scaling method + + + + + + + + dials.scale + + + + + AIMLESS + + + + + + + + Keep all reflections + + + + + + + + + + + High pressure + + + + + + Standard options + + + + + + High pressure correction and dynamic shadowing + + + + + + + Scan varying + + + true + + + false + + + + + + + Reference geometry + + + + + + + + + Browse + + + + + + + true + + + path/to/instrument_model.expt + + + + + + + + + Mask gasket rings + + + + + + + + Tungsten + + + + + Steel + + + + + + + + Gasket (user defined) + + + + + + + + + + + Unit cell + + + + + + + e.g. 2.87,2.87,2.87,90,90,90 + + + + + + + + + + + Space group + + + + + + + e.g. Im-3m + + + + + + + + + + + Width + + + + + + + e.g. 0.02 + + + + + + + + + + + + + + Options for medium difficulty data + + + + + + Unit cell and space group + + + + + + + + + + + Unit cell + + + + + + + e.g. 5.4,5.4,5.4,90,90,90 + + + + + + + + + + + Space group + + + + + + + e.g. Im-3m + + + + + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + d min (Å) + + + + + + + e.g. 0.84 + + + + + + + Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + + + Run start/end + + + + + + + + + + + r1 + + + + + + + e.g. 20:600 + + + + + + + + + + + r2 + + + + + + + e.g. 20:600 + + + + + + + + + + + r3 + + + + + + + e.g. 20:600 + + + + + + + + + + + r4 + + + + + + + e.g. 20:600 + + + + + + + + + + + r5 + + + + + + + e.g. 20:600 + + + + + + + + + + + r6 + + + + + + + e.g. 20:600 + + + + + + + + + + + r7 + + + + + + + e.g. 20:600 + + + + + + + + + + + r8 + + + + + + + e.g. 20:600 + + + + + + + + + + + r9 + + + + + + + e.g. 20:600 + + + + + + + + + + + r10 + + + + + + + e.g. 20:600 + + + + + + + + + + + + + + + 50 + false + + + + Options for problematic data + + + + + + Fix instrument model + + + + + + + Anvil thickness (mm) + + + + + + + Default = 2.1 + + + + + + + + + + false + + + Pressure cell opening angle (°) + + + + + + + false + + + E.g. 80 + + + + + + + + + + + Other + + + + + + Failover + + + + + + + Manual input + + + + + + + + + + Processing computer + + + + + + + + Cluster + + + + + Local + + + + + + + + + All + + + + + + false + + + Plan to automatically generate a list of all options from the xia2-working.phil file. + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + + + + + + Integrate_scanVarying_checkBox_3 + toggled(bool) + Integrate_scanVarying_checkBox + setChecked(bool) + + + 86 + 152 + + + 86 + 152 + + + + + Integrate_scanVarying_checkBox + toggled(bool) + Integrate_scanVarying_checkBox_3 + setChecked(bool) + + + 86 + 152 + + + 86 + 152 + + + + + diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 9c1f7c0..bb47d38 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -1037,7 +1037,7 @@ def run(self): ######################################################################################## -class UIXia2Options: +class UIXia2Options(QtWidgets.QMainWindow): def __init__( self, ui_main_window, @@ -1065,1193 +1065,27 @@ def __init__( self.prefix = prefix self.opening_visit = opening_visit - xia2_options.setObjectName("xia2_options") - # xia2_options.resize(613, 454) - xia2_options.resize(613, 600) - self.central_widget = QtWidgets.QWidget(xia2_options) - self.central_widget.setObjectName("central_widget") - - # update button - self.update_button = QtWidgets.QPushButton(self.central_widget) - self.update_button.setGeometry(QtCore.QRect(10, 0, 131, 28)) - self.update_button.setObjectName("update_button") - self.update_button.clicked.connect(self.update_options) - - # reset button - self.reset_button = QtWidgets.QPushButton(self.central_widget) - self.reset_button.setGeometry(QtCore.QRect(150, 0, 131, 28)) - self.reset_button.setObjectName("reset_button") - self.reset_button.clicked.connect(self.reset_options) - - # save button - self.save_button = QtWidgets.QPushButton(self.central_widget) - self.save_button.setGeometry(QtCore.QRect(290, 0, 131, 28)) - self.save_button.setObjectName("save_button") - self.save_button.clicked.connect(self.save_options) - - # load button - self.load_button = QtWidgets.QPushButton(self.central_widget) - self.load_button.setGeometry(QtCore.QRect(430, 0, 131, 28)) - self.load_button.setObjectName("load_button") - self.load_button.clicked.connect(self.load_options) - - self.xia2_options = QtWidgets.QTabWidget(self.central_widget) - self.xia2_options.setGeometry(QtCore.QRect(0, 30, 601, 520)) - self.xia2_options.setObjectName("xia2_options") - - ################################################################################ - # dials import - - self.xia2_options_import = QtWidgets.QWidget() - self.xia2_options_import.setObjectName("xia2_options_import") - self.xia2_options.addTab(self.xia2_options_import, "") - - self.import_trust_beam_centre = QtWidgets.QCheckBox(self.xia2_options_import) - self.import_trust_beam_centre.setGeometry(QtCore.QRect(10, 20, 141, 20)) - self.import_trust_beam_centre.setObjectName("import_trust_beam_centre") - - self.import_reference_geometry = QtWidgets.QCheckBox(self.xia2_options_import) - self.import_reference_geometry.setGeometry(QtCore.QRect(10, 50, 161, 20)) - self.import_reference_geometry.setObjectName("import_reference_geometry") - self.import_reference_geometry_browse = QtWidgets.QPushButton( - self.xia2_options_import - ) - self.import_reference_geometry_browse.setGeometry(QtCore.QRect(160, 45, 93, 28)) - self.import_reference_geometry_browse.setObjectName( - "import_reference_geometry_browse" - ) - self.import_reference_geometry_browse.clicked.connect( - self.browse_for_reference_model - ) - self.import_reference_geometry_path = QtWidgets.QLabel(self.xia2_options_import) - self.import_reference_geometry_path.setGeometry(QtCore.QRect(260, 50, 271, 16)) - self.import_reference_geometry_path.setObjectName( - "import_reference_geometry_path" - ) - - self.import_dd = QtWidgets.QCheckBox(self.xia2_options_import) - self.import_dd.setGeometry(QtCore.QRect(10, 80, 161, 21)) - self.import_dd.setObjectName("import_dd") - self.import_dd_line_edit = QtWidgets.QLineEdit(self.xia2_options_import) - self.import_dd_line_edit.setGeometry(QtCore.QRect(160, 80, 100, 22)) - self.import_dd_line_edit.setObjectName("import_dd_line_edit") - self.import_dd_line_edit.setStatusTip("e.g. 85.19") - - self.import_beam_centre = QtWidgets.QCheckBox(self.xia2_options_import) - self.import_beam_centre.setGeometry(QtCore.QRect(10, 110, 161, 21)) - self.import_beam_centre.setObjectName("import_beam_centre") - self.import_beam_centre_x_label = QtWidgets.QLabel(self.xia2_options_import) - self.import_beam_centre_x_label.setGeometry(QtCore.QRect(180, 110, 16, 16)) - self.import_beam_centre_x_label.setObjectName("import_beam_centre_x_label") - self.import_beam_centre_x_line_edit = QtWidgets.QLineEdit( - self.xia2_options_import - ) - self.import_beam_centre_x_line_edit.setGeometry(QtCore.QRect(200, 110, 61, 22)) - self.import_beam_centre_x_line_edit.setObjectName( - "import_beam_centre_x_line_edit" - ) - self.import_beam_centre_x_line_edit.setStatusTip("e.g. 54.3") - self.import_beam_centre_y_label = QtWidgets.QLabel(self.xia2_options_import) - self.import_beam_centre_y_label.setGeometry(QtCore.QRect(270, 110, 16, 16)) - self.import_beam_centre_y_label.setObjectName("import_beam_centre_y_label") - self.import_beam_centre_y_line_edit = QtWidgets.QLineEdit( - self.xia2_options_import - ) - self.import_beam_centre_y_line_edit.setGeometry(QtCore.QRect(290, 110, 61, 22)) - self.import_beam_centre_y_line_edit.setObjectName( - "import_beam_centre_y_line_edit" - ) - self.import_beam_centre_y_line_edit.setStatusTip("e.g. 43.3") - - self.import_wavelengh = QtWidgets.QCheckBox(self.xia2_options_import) - self.import_wavelengh.setGeometry(QtCore.QRect(10, 140, 161, 21)) - self.import_wavelengh.setObjectName("import_wavelengh") - self.import_wavelength_line_edit = QtWidgets.QLineEdit(self.xia2_options_import) - self.import_wavelength_line_edit.setGeometry(QtCore.QRect(160, 140, 101, 22)) - self.import_wavelength_line_edit.setObjectName("import_wavelength_line_edit") - self.import_wavelength_line_edit.setStatusTip("e.g. 0.6889") - - self.import_fix_beam_detector_check_box = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.import_fix_beam_detector_check_box.setGeometry( - QtCore.QRect(10, 170, 151, 20) - ) - self.import_fix_beam_detector_check_box.setObjectName( - "import_fix_beam_detector_check_box" - ) - - self.import_run_selector_check_box = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.import_run_selector_check_box.setGeometry(QtCore.QRect(10, 200, 91, 20)) - self.import_run_selector_check_box.setObjectName( - "import_run_selector_check_box" - ) - self.Import_RunSelector_checkBox_1 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_1.setGeometry(QtCore.QRect(110, 200, 31, 20)) - self.Import_RunSelector_checkBox_1.setObjectName( - "Import_RunSelector_checkBox_1" - ) - self.Import_RunSelector_checkBox_2 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_2.setGeometry(QtCore.QRect(150, 200, 31, 20)) - self.Import_RunSelector_checkBox_2.setObjectName( - "Import_RunSelector_checkBox_2" - ) - self.Import_RunSelector_checkBox_3 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_3.setGeometry(QtCore.QRect(190, 200, 31, 20)) - self.Import_RunSelector_checkBox_3.setObjectName( - "Import_RunSelector_checkBox_3" - ) - self.Import_RunSelector_checkBox_4 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_4.setGeometry(QtCore.QRect(230, 200, 31, 20)) - self.Import_RunSelector_checkBox_4.setObjectName( - "Import_RunSelector_checkBox_4" - ) - self.Import_RunSelector_checkBox_5 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_5.setGeometry(QtCore.QRect(270, 200, 31, 20)) - self.Import_RunSelector_checkBox_5.setObjectName( - "Import_RunSelector_checkBox_5" - ) - self.Import_RunSelector_checkBox_6 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_6.setGeometry(QtCore.QRect(310, 200, 31, 20)) - self.Import_RunSelector_checkBox_6.setObjectName( - "Import_RunSelector_checkBox_6" - ) - self.Import_RunSelector_checkBox_7 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_7.setGeometry(QtCore.QRect(350, 200, 31, 20)) - self.Import_RunSelector_checkBox_7.setObjectName( - "Import_RunSelector_checkBox_7" - ) - self.Import_RunSelector_checkBox_8 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_8.setGeometry(QtCore.QRect(390, 200, 31, 20)) - self.Import_RunSelector_checkBox_8.setObjectName( - "Import_RunSelector_checkBox_8" - ) - self.Import_RunSelector_checkBox_9 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_9.setGeometry(QtCore.QRect(430, 200, 31, 20)) - self.Import_RunSelector_checkBox_9.setObjectName( - "Import_RunSelector_checkBox_9" - ) - self.Import_RunSelector_checkBox_10 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_10.setGeometry(QtCore.QRect(470, 200, 41, 20)) - self.Import_RunSelector_checkBox_10.setObjectName( - "Import_RunSelector_checkBox_10" - ) - self.Import_RunSelector_checkBox_11 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_11.setGeometry(QtCore.QRect(510, 200, 41, 20)) - self.Import_RunSelector_checkBox_11.setObjectName( - "Import_RunSelector_checkBox_11" - ) - self.Import_RunSelector_checkBox_12 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_12.setGeometry(QtCore.QRect(550, 200, 41, 20)) - self.Import_RunSelector_checkBox_12.setObjectName( - "Import_RunSelector_checkBox_12" - ) - - self.Import_RunSelector_checkBox_13 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_13.setGeometry(QtCore.QRect(110, 230, 41, 20)) - self.Import_RunSelector_checkBox_13.setObjectName( - "Import_RunSelector_checkBox_13" - ) - self.Import_RunSelector_checkBox_14 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_14.setGeometry(QtCore.QRect(150, 230, 41, 20)) - self.Import_RunSelector_checkBox_14.setObjectName( - "Import_RunSelector_checkBox_14" - ) - self.Import_RunSelector_checkBox_15 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_15.setGeometry(QtCore.QRect(190, 230, 41, 20)) - self.Import_RunSelector_checkBox_15.setObjectName( - "Import_RunSelector_checkBox_15" - ) - self.Import_RunSelector_checkBox_16 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_16.setGeometry(QtCore.QRect(230, 230, 41, 20)) - self.Import_RunSelector_checkBox_16.setObjectName( - "Import_RunSelector_checkBox_16" - ) - self.Import_RunSelector_checkBox_17 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_17.setGeometry(QtCore.QRect(270, 230, 41, 20)) - self.Import_RunSelector_checkBox_17.setObjectName( - "Import_RunSelector_checkBox_17" - ) - self.Import_RunSelector_checkBox_18 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_18.setGeometry(QtCore.QRect(310, 230, 41, 20)) - self.Import_RunSelector_checkBox_18.setObjectName( - "Import_RunSelector_checkBox_18" - ) - self.Import_RunSelector_checkBox_19 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_19.setGeometry(QtCore.QRect(350, 230, 41, 20)) - self.Import_RunSelector_checkBox_19.setObjectName( - "Import_RunSelector_checkBox_19" - ) - self.Import_RunSelector_checkBox_20 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_20.setGeometry(QtCore.QRect(390, 230, 41, 20)) - self.Import_RunSelector_checkBox_20.setObjectName( - "Import_RunSelector_checkBox_20" - ) - self.Import_RunSelector_checkBox_21 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_21.setGeometry(QtCore.QRect(430, 230, 41, 20)) - self.Import_RunSelector_checkBox_21.setObjectName( - "Import_RunSelector_checkBox_21" - ) - self.Import_RunSelector_checkBox_22 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_22.setGeometry(QtCore.QRect(470, 230, 41, 20)) - self.Import_RunSelector_checkBox_22.setObjectName( - "Import_RunSelector_checkBox_22" - ) - self.Import_RunSelector_checkBox_23 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_23.setGeometry(QtCore.QRect(510, 230, 41, 20)) - self.Import_RunSelector_checkBox_23.setObjectName( - "Import_RunSelector_checkBox_23" - ) - self.Import_RunSelector_checkBox_24 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_24.setGeometry(QtCore.QRect(550, 230, 41, 20)) - self.Import_RunSelector_checkBox_24.setObjectName( - "Import_RunSelector_checkBox_24" - ) - - self.Import_RunSelector_checkBox_25 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_25.setGeometry(QtCore.QRect(110, 260, 41, 20)) - self.Import_RunSelector_checkBox_25.setObjectName( - "Import_RunSelector_checkBox_25" - ) - self.Import_RunSelector_checkBox_26 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_26.setGeometry(QtCore.QRect(150, 260, 41, 20)) - self.Import_RunSelector_checkBox_26.setObjectName( - "Import_RunSelector_checkBox_26" - ) - self.Import_RunSelector_checkBox_27 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_27.setGeometry(QtCore.QRect(190, 260, 41, 20)) - self.Import_RunSelector_checkBox_27.setObjectName( - "Import_RunSelector_checkBox_27" - ) - self.Import_RunSelector_checkBox_28 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_28.setGeometry(QtCore.QRect(230, 260, 41, 20)) - self.Import_RunSelector_checkBox_28.setObjectName( - "Import_RunSelector_checkBox_28" - ) - self.Import_RunSelector_checkBox_29 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_29.setGeometry(QtCore.QRect(270, 260, 41, 20)) - self.Import_RunSelector_checkBox_29.setObjectName( - "Import_RunSelector_checkBox_29" - ) - self.Import_RunSelector_checkBox_30 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_30.setGeometry(QtCore.QRect(310, 260, 41, 20)) - self.Import_RunSelector_checkBox_30.setObjectName( - "Import_RunSelector_checkBox_30" - ) - self.Import_RunSelector_checkBox_31 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_31.setGeometry(QtCore.QRect(350, 260, 41, 20)) - self.Import_RunSelector_checkBox_31.setObjectName( - "Import_RunSelector_checkBox_31" - ) - self.Import_RunSelector_checkBox_32 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_32.setGeometry(QtCore.QRect(390, 260, 41, 20)) - self.Import_RunSelector_checkBox_32.setObjectName( - "Import_RunSelector_checkBox_32" - ) - self.Import_RunSelector_checkBox_33 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_33.setGeometry(QtCore.QRect(430, 260, 41, 20)) - self.Import_RunSelector_checkBox_33.setObjectName( - "Import_RunSelector_checkBox_33" - ) - self.Import_RunSelector_checkBox_34 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_34.setGeometry(QtCore.QRect(470, 260, 41, 20)) - self.Import_RunSelector_checkBox_34.setObjectName( - "Import_RunSelector_checkBox_34" - ) - self.Import_RunSelector_checkBox_35 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_35.setGeometry(QtCore.QRect(510, 260, 41, 20)) - self.Import_RunSelector_checkBox_35.setObjectName( - "Import_RunSelector_checkBox_35" - ) - self.Import_RunSelector_checkBox_36 = QtWidgets.QCheckBox( - self.xia2_options_import - ) - self.Import_RunSelector_checkBox_36.setGeometry(QtCore.QRect(550, 260, 41, 20)) - self.Import_RunSelector_checkBox_36.setObjectName( - "Import_RunSelector_checkBox_36" - ) - - self.Import_type_checkBox = QtWidgets.QCheckBox(self.xia2_options_import) - self.Import_type_checkBox.setGeometry(QtCore.QRect(10, 290, 121, 20)) - self.Import_type_checkBox.setObjectName("Import_type_checkBox") - self.Import_type_checkBox.setChecked(True) - self.Import_type_comboBox = QtWidgets.QComboBox(self.xia2_options_import) - self.Import_type_comboBox.setGeometry(QtCore.QRect(130, 290, 171, 22)) - self.Import_type_comboBox.setObjectName("Import_type_comboBox") - self.Import_type_comboBox.addItem("") - self.Import_type_comboBox.addItem("") - - ################################################################################ - # spotFinding - self.xia2options_SpotFinding = QtWidgets.QWidget() - self.xia2options_SpotFinding.setObjectName("xia2options_SpotFinding") - self.xia2_options.addTab(self.xia2options_SpotFinding, "") - - self.findSpots_sigmaStrong = QtWidgets.QCheckBox(self.xia2options_SpotFinding) - self.findSpots_sigmaStrong.setGeometry(QtCore.QRect(10, 10, 111, 20)) - self.findSpots_sigmaStrong.setObjectName("findSpots_sigmaStrong") - self.findSpots_sigmaStrong_lineEdit = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_sigmaStrong_lineEdit.setGeometry(QtCore.QRect(130, 10, 113, 22)) - self.findSpots_sigmaStrong_lineEdit.setObjectName( - "findSpots_sigmaStrong_lineEdit" - ) - self.findSpots_sigmaStrong_lineEdit.setStatusTip("e.g. 6 (default=3)") - - self.findSpots_minSpot = QtWidgets.QCheckBox(self.xia2options_SpotFinding) - self.findSpots_minSpot.setGeometry(QtCore.QRect(10, 40, 111, 20)) - self.findSpots_minSpot.setObjectName("findSpots_minSpot") - self.findSpots_minSpot_lineEdit = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_minSpot_lineEdit.setGeometry(QtCore.QRect(130, 40, 113, 22)) - self.findSpots_minSpot_lineEdit.setObjectName("findSpots_minSpot_lineEdit") - self.findSpots_minSpot_lineEdit.setStatusTip("e.g. 2") - - self.findSpots_maxSpot = QtWidgets.QCheckBox(self.xia2options_SpotFinding) - self.findSpots_maxSpot.setGeometry(QtCore.QRect(10, 70, 111, 20)) - self.findSpots_maxSpot.setObjectName("findSpots_maxSpot") - self.findSpots_maxSpot_lineEdit = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_maxSpot_lineEdit.setGeometry(QtCore.QRect(130, 70, 113, 22)) - self.findSpots_maxSpot_lineEdit.setObjectName("findSpots_maxSpot_lineEdit") - self.findSpots_maxSpot_lineEdit.setStatusTip("e.g. 20 (default=1000)") - - self.findSpots_dmin = QtWidgets.QCheckBox(self.xia2options_SpotFinding) - self.findSpots_dmin.setGeometry(QtCore.QRect(10, 100, 111, 20)) - self.findSpots_dmin.setObjectName("findSpots_dmin") - self.findSpots_dmin_lineEdit = QtWidgets.QLineEdit(self.xia2options_SpotFinding) - self.findSpots_dmin_lineEdit.setGeometry(QtCore.QRect(130, 100, 113, 22)) - self.findSpots_dmin_lineEdit.setObjectName("findSpots_dmin_lineEdit") - self.findSpots_dmin_lineEdit.setStatusTip("e.g. 0.84") - - self.findSpots_dmax = QtWidgets.QCheckBox(self.xia2options_SpotFinding) - self.findSpots_dmax.setGeometry(QtCore.QRect(10, 130, 111, 20)) - self.findSpots_dmax.setObjectName("findSpots_dmax") - self.findSpots_dmax_lineEdit = QtWidgets.QLineEdit(self.xia2options_SpotFinding) - self.findSpots_dmax_lineEdit.setGeometry(QtCore.QRect(130, 130, 113, 22)) - self.findSpots_dmax_lineEdit.setObjectName("findSpots_dmax_lineEdit") - self.findSpots_dmax_lineEdit.setStatusTip("e.g. 15") - - self.findSpots_iceRings = QtWidgets.QCheckBox(self.xia2options_SpotFinding) - self.findSpots_iceRings.setGeometry(QtCore.QRect(10, 160, 111, 20)) - self.findSpots_iceRings.setObjectName("findSpots_iceRings") - - self.findSpots_powderRings = QtWidgets.QCheckBox(self.xia2options_SpotFinding) - self.findSpots_powderRings.setGeometry(QtCore.QRect(10, 190, 111, 20)) - self.findSpots_powderRings.setObjectName("findSpots_powderRings") - self.findSpots_powderRingsUC_lineEdit = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_powderRingsUC_lineEdit.setGeometry( - QtCore.QRect(130, 190, 241, 22) - ) - self.findSpots_powderRingsUC_lineEdit.setObjectName( - "findSpots_powderRingsUC_lineEdit" - ) - self.findSpots_powderRingsUC_lineEdit.setStatusTip( - "e.g. 5.6,5.7,12.4,90,105.2,90" - ) - self.findSpots_powderRingsUC_label = QtWidgets.QLabel( - self.xia2options_SpotFinding - ) - self.findSpots_powderRingsUC_label.setGeometry(QtCore.QRect(200, 170, 55, 16)) - self.findSpots_powderRingsUC_label.setObjectName( - "findSpots_powderRingsUC_label" - ) - self.findSpots_powderRingsSG_lineEdit = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_powderRingsSG_lineEdit.setGeometry( - QtCore.QRect(380, 190, 71, 22) - ) - self.findSpots_powderRingsSG_lineEdit.setObjectName( - "findSpots_powderRingsSG_lineEdit" - ) - self.findSpots_powderRingsSG_lineEdit.setStatusTip("e.g. P21/c") - self.findSpots_powderRingsSG_label = QtWidgets.QLabel( - self.xia2options_SpotFinding - ) - self.findSpots_powderRingsSG_label.setGeometry(QtCore.QRect(380, 170, 81, 16)) - self.findSpots_powderRingsSG_label.setObjectName( - "findSpots_powderRingsSG_label" - ) - self.findSpots_powderRingsW_lineEdit = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_powderRingsW_lineEdit.setGeometry(QtCore.QRect(460, 190, 71, 22)) - self.findSpots_powderRingsW_lineEdit.setObjectName( - "findSpots_powderRingsW_lineEdit" - ) - self.findSpots_powderRingsW_lineEdit.setStatusTip("e.g. 0.04 (default=0.002)") - self.findSpots_powderRingsW_label = QtWidgets.QLabel( - self.xia2options_SpotFinding - ) - self.findSpots_powderRingsW_label.setGeometry(QtCore.QRect(480, 170, 41, 16)) - self.findSpots_powderRingsW_label.setObjectName("findSpots_powderRingsW_label") - - self.findSpots_resolutionRange = QtWidgets.QCheckBox( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange.setGeometry(QtCore.QRect(10, 220, 121, 20)) - self.findSpots_resolutionRange.setObjectName("findSpots_resolutionRange") - self.findSpots_resolutionRange_lineEdit_1 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_1.setGeometry( - QtCore.QRect(130, 220, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_1.setObjectName( - "findSpots_resolutionRange_lineEdit_1" - ) - self.findSpots_resolutionRange_lineEdit_1.setStatusTip("e.g. 1.02,0.98") - self.findSpots_resolutionRange_lineEdit_2 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_2.setGeometry( - QtCore.QRect(210, 220, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_2.setObjectName( - "findSpots_resolutionRange_lineEdit_2" - ) - self.findSpots_resolutionRange_lineEdit_3 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_3.setGeometry( - QtCore.QRect(290, 220, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_3.setObjectName( - "findSpots_resolutionRange_lineEdit_3" - ) - self.findSpots_resolutionRange_lineEdit_4 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_4.setGeometry( - QtCore.QRect(370, 220, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_4.setObjectName( - "findSpots_resolutionRange_lineEdit_4" - ) - self.findSpots_resolutionRange_lineEdit_5 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_5.setGeometry( - QtCore.QRect(450, 220, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_5.setObjectName( - "findSpots_resolutionRange_lineEdit_5" - ) - self.findSpots_resolutionRange_lineEdit_6 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_6.setGeometry( - QtCore.QRect(130, 250, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_6.setObjectName( - "findSpots_resolutionRange_lineEdit_6" - ) - self.findSpots_resolutionRange_lineEdit_7 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_7.setGeometry( - QtCore.QRect(210, 250, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_7.setObjectName( - "findSpots_resolutionRange_lineEdit_7" - ) - self.findSpots_resolutionRange_lineEdit_8 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_8.setGeometry( - QtCore.QRect(290, 250, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_8.setObjectName( - "findSpots_resolutionRange_lineEdit_8" - ) - self.findSpots_resolutionRange_lineEdit_9 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_9.setGeometry( - QtCore.QRect(370, 250, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_9.setObjectName( - "findSpots_resolutionRange_lineEdit_9" - ) - self.findSpots_resolutionRange_lineEdit_10 = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_resolutionRange_lineEdit_10.setGeometry( - QtCore.QRect(450, 250, 71, 22) - ) - self.findSpots_resolutionRange_lineEdit_10.setObjectName( - "findSpots_resolutionRange_lineEdit_10" - ) - - self.findSpots_circleMask = QtWidgets.QCheckBox(self.xia2options_SpotFinding) - self.findSpots_circleMask.setGeometry(QtCore.QRect(10, 280, 111, 20)) - self.findSpots_circleMask.setObjectName("findSpots_circleMask") - self.findSpots_circleMask_lineEdit = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_circleMask_lineEdit.setGeometry(QtCore.QRect(130, 280, 113, 22)) - self.findSpots_circleMask_lineEdit.setObjectName( - "findSpots_circleMask_lineEdit" - ) - self.findSpots_circleMask_lineEdit.setStatusTip("e.g. 620,851,27 (xc,yc,r)") - - self.findSpots_recMask = QtWidgets.QCheckBox(self.xia2options_SpotFinding) - self.findSpots_recMask.setGeometry(QtCore.QRect(10, 310, 121, 20)) - self.findSpots_recMask.setObjectName("findSpots_recMask") - self.findSpots_recMask_lineEdit = QtWidgets.QLineEdit( - self.xia2options_SpotFinding - ) - self.findSpots_recMask_lineEdit.setGeometry(QtCore.QRect(130, 310, 113, 22)) - self.findSpots_recMask_lineEdit.setObjectName("findSpots_recMask_lineEdit") - self.findSpots_recMask_lineEdit.setStatusTip( - "e.g. 0,612,824,858 (x0, x1, y0, y1)" - ) - - ################################################################################ - # indexing - self.xia2options_Indexing = QtWidgets.QWidget() - self.xia2options_Indexing.setObjectName("xia2options_Indexing") - self.xia2_options.addTab(self.xia2options_Indexing, "") - - self.Index_method_comboBox = QtWidgets.QComboBox(self.xia2options_Indexing) - self.Index_method_comboBox.setGeometry(QtCore.QRect(130, 10, 171, 22)) - self.Index_method_comboBox.setObjectName("Index_method_comboBox") - self.Index_method_comboBox.addItem("") - self.Index_method_comboBox.addItem("") - self.Index_method_comboBox.addItem("") - self.Index_method_comboBox.addItem("") - self.Index_method_checkBox = QtWidgets.QCheckBox(self.xia2options_Indexing) - self.Index_method_checkBox.setGeometry(QtCore.QRect(10, 10, 121, 20)) - self.Index_method_checkBox.setObjectName("Index_method_checkBox") - self.Index_scanVarying_checkBox = QtWidgets.QCheckBox(self.xia2options_Indexing) - self.Index_scanVarying_checkBox.setGeometry(QtCore.QRect(10, 40, 121, 20)) - self.Index_scanVarying_checkBox.setObjectName("Index_scanVarying_checkBox") - self.Index_UN_SG_checkBox = QtWidgets.QCheckBox(self.xia2options_Indexing) - self.Index_UN_SG_checkBox.setGeometry(QtCore.QRect(10, 70, 181, 20)) - self.Index_UN_SG_checkBox.setObjectName("Index_UN_SG_checkBox") - self.Index_UN_lineEdit = QtWidgets.QLineEdit(self.xia2options_Indexing) - self.Index_UN_lineEdit.setGeometry(QtCore.QRect(190, 70, 211, 22)) - self.Index_UN_lineEdit.setObjectName("Index_UN_lineEdit") - self.Index_UN_lineEdit.setStatusTip("e.g. 5.1,6.2,7.3,90,95.1,90") - self.Index_UN_label = QtWidgets.QLabel(self.xia2options_Indexing) - self.Index_UN_label.setGeometry(QtCore.QRect(260, 50, 51, 20)) - self.Index_UN_label.setObjectName("Index_UN_label") - - self.Index_SG_lineEdit = QtWidgets.QLineEdit(self.xia2options_Indexing) - self.Index_SG_lineEdit.setGeometry(QtCore.QRect(410, 70, 91, 22)) - self.Index_SG_lineEdit.setObjectName("Index_SG_lineEdit") - self.Index_SG_lineEdit.setStatusTip("e.g. P21/c") - # Index_SG_lineEdit - self.Index_SG_label = QtWidgets.QLabel(self.xia2options_Indexing) - self.Index_SG_label.setGeometry(QtCore.QRect(420, 50, 81, 20)) - self.Index_SG_label.setObjectName("Index_SG_label") - self.Index_minCell_checkBox = QtWidgets.QCheckBox(self.xia2options_Indexing) - self.Index_minCell_checkBox.setGeometry(QtCore.QRect(10, 100, 151, 20)) - self.Index_minCell_checkBox.setObjectName("Index_minCell_checkBox") - self.Index_maxCell_checkBox = QtWidgets.QCheckBox(self.xia2options_Indexing) - self.Index_maxCell_checkBox.setGeometry(QtCore.QRect(10, 130, 151, 20)) - self.Index_maxCell_checkBox.setObjectName("Index_maxCell_checkBox") - - self.Index_minCell_lineEdit = QtWidgets.QLineEdit(self.xia2options_Indexing) - self.Index_minCell_lineEdit.setGeometry(QtCore.QRect(170, 100, 91, 22)) - self.Index_minCell_lineEdit.setObjectName("Index_minCell_lineEdit") - self.Index_minCell_lineEdit.setStatusTip("e.g. 6.0 (default=3)") - # Index_maxCell_lineEdit - self.Index_maxCell_lineEdit = QtWidgets.QLineEdit(self.xia2options_Indexing) - self.Index_maxCell_lineEdit.setGeometry(QtCore.QRect(170, 130, 91, 22)) - self.Index_maxCell_lineEdit.setObjectName("Index_maxCell_lineEdit") - self.Index_maxCell_lineEdit.setStatusTip("e.g. 30.0") - self.Index_multiprocessing_checkBox = QtWidgets.QCheckBox( - self.xia2options_Indexing - ) - self.Index_multiprocessing_checkBox.setGeometry(QtCore.QRect(10, 160, 261, 20)) - self.Index_multiprocessing_checkBox.setObjectName( - "Index_multiprocessing_checkBox" - ) - self.Index_multiSweepRefine_checkBox = QtWidgets.QCheckBox( - self.xia2options_Indexing - ) - self.Index_multiSweepRefine_checkBox.setGeometry(QtCore.QRect(10, 190, 261, 20)) - self.Index_multiSweepRefine_checkBox.setObjectName( - "Index_multiSweepRefine_checkBox" - ) - self.Index_outliers_checkBox = QtWidgets.QCheckBox(self.xia2options_Indexing) - self.Index_outliers_checkBox.setGeometry(QtCore.QRect(10, 220, 261, 20)) - self.Index_outliers_checkBox.setObjectName("Index_outliers_checkBox") - - ################################################################################ - # dials integrate - self.xia2options_integrate = QtWidgets.QWidget() - self.xia2options_integrate.setObjectName("xia2options_integrate") - self.xia2_options.addTab(self.xia2options_integrate, "") - - self.Integrate_keepAllReflections_checkBox = QtWidgets.QCheckBox( - self.xia2options_integrate - ) - self.Integrate_keepAllReflections_checkBox.setGeometry( - QtCore.QRect(10, 10, 141, 20) - ) - self.Integrate_keepAllReflections_checkBox.setObjectName( - "Integrate_keepAllReflections_checkBox" - ) - self.Integrate_scanVarying_checkBox = QtWidgets.QCheckBox( - self.xia2options_integrate - ) - self.Integrate_scanVarying_checkBox.setGeometry(QtCore.QRect(10, 40, 141, 20)) - self.Integrate_scanVarying_checkBox.setObjectName( - "Integrate_scanVarying_checkBox" - ) - self.Integrate_minSpotProfile_checkBox = QtWidgets.QCheckBox( - self.xia2options_integrate - ) - self.Integrate_minSpotProfile_checkBox.setGeometry( - QtCore.QRect(10, 70, 141, 20) - ) - self.Integrate_minSpotProfile_checkBox.setObjectName( - "Integrate_minSpotProfile_checkBox" - ) - self.Integrate_minCellOverall_lineEdit = QtWidgets.QLineEdit( - self.xia2options_integrate - ) - self.Integrate_minCellOverall_lineEdit.setGeometry( - QtCore.QRect(150, 70, 91, 22) - ) - self.Integrate_minCellOverall_lineEdit.setObjectName( - "Integrate_minCellOverall_lineEdit" - ) - self.Integrate_minCellDegree_lineEdit = QtWidgets.QLineEdit( - self.xia2options_integrate - ) - self.Integrate_minCellDegree_lineEdit.setGeometry(QtCore.QRect(250, 70, 91, 22)) - self.Integrate_minCellDegree_lineEdit.setObjectName( - "Integrate_minCellDegree_lineEdit" - ) - self.Integrate_minCellOverall_label = QtWidgets.QLabel( - self.xia2options_integrate - ) - self.Integrate_minCellOverall_label.setGeometry(QtCore.QRect(170, 50, 51, 20)) - self.Integrate_minCellOverall_label.setObjectName( - "Integrate_minCellOverall_label" - ) - self.Integrate_minCellDegree_label = QtWidgets.QLabel( - self.xia2options_integrate - ) - self.Integrate_minCellDegree_label.setGeometry(QtCore.QRect(260, 50, 81, 20)) - self.Integrate_minCellDegree_label.setObjectName( - "Integrate_minCellDegree_label" - ) - - ################################################################################ - # dials refine - self.xia2options_refine_scale = QtWidgets.QWidget() - self.xia2options_refine_scale.setObjectName("xia2options_refine_scale") - self.xia2_options.addTab(self.xia2options_refine_scale, "") - - self.Refine_method_checkBox = QtWidgets.QCheckBox(self.xia2options_refine_scale) - self.Refine_method_checkBox.setGeometry(QtCore.QRect(10, 40, 121, 20)) - self.Refine_method_checkBox.setObjectName("Refine_method_checkBox") - self.Refine_method_comboBox = QtWidgets.QComboBox(self.xia2options_refine_scale) - self.Refine_method_comboBox.setGeometry(QtCore.QRect(130, 40, 171, 22)) - self.Refine_method_comboBox.setObjectName("Refine_method_comboBox") - self.Refine_method_comboBox.addItem("") - self.Refine_method_comboBox.addItem("") - self.Refine_FixBeamDetector_checkBox = QtWidgets.QCheckBox( - self.xia2options_refine_scale - ) - self.Refine_FixBeamDetector_checkBox.setGeometry(QtCore.QRect(10, 10, 151, 20)) - self.Refine_FixBeamDetector_checkBox.setObjectName( - "Refine_FixBeamDetector_checkBox" - ) - - ################################################################################ - # dials other - self.xia2options_Other = QtWidgets.QWidget() - self.xia2options_Other.setObjectName("xia2options_Other") - self.xia2_options.addTab(self.xia2options_Other, "") - - self.Other_failover_checkBox = QtWidgets.QCheckBox(self.xia2options_Other) - self.Other_failover_checkBox.setGeometry(QtCore.QRect(10, 10, 151, 20)) - self.Other_failover_checkBox.setObjectName("Other_failover_checkBox") - - self.Other_manualInput1_checkBox = QtWidgets.QCheckBox(self.xia2options_Other) - self.Other_manualInput1_checkBox.setGeometry(QtCore.QRect(10, 40, 111, 20)) - self.Other_manualInput1_checkBox.setObjectName("Other_manualInput1_checkBox") - self.Other_manualInput1_lineEdit = QtWidgets.QLineEdit(self.xia2options_Other) - self.Other_manualInput1_lineEdit.setGeometry(QtCore.QRect(130, 40, 400, 22)) - self.Other_manualInput1_lineEdit.setObjectName("Other_manualInput1_lineEdit") - self.Other_manualInput2_checkBox = QtWidgets.QCheckBox(self.xia2options_Other) - self.Other_manualInput2_checkBox.setGeometry(QtCore.QRect(10, 70, 111, 20)) - self.Other_manualInput2_checkBox.setObjectName("Other_manualInput2_checkBox") - self.Other_manualInput2_lineEdit = QtWidgets.QLineEdit(self.xia2options_Other) - self.Other_manualInput2_lineEdit.setGeometry(QtCore.QRect(130, 70, 400, 22)) - self.Other_manualInput2_lineEdit.setObjectName("Other_manualInput2_lineEdit") - self.Other_manualInput3_checkBox = QtWidgets.QCheckBox(self.xia2options_Other) - self.Other_manualInput3_checkBox.setGeometry(QtCore.QRect(10, 100, 111, 20)) - self.Other_manualInput3_checkBox.setObjectName("Other_manualInput3_checkBox") - self.Other_manualInput3_lineEdit = QtWidgets.QLineEdit(self.xia2options_Other) - self.Other_manualInput3_lineEdit.setGeometry(QtCore.QRect(130, 100, 400, 22)) - self.Other_manualInput3_lineEdit.setObjectName("Other_manualInput3_lineEdit") - self.Other_manualInput4_checkBox = QtWidgets.QCheckBox(self.xia2options_Other) - self.Other_manualInput4_checkBox.setGeometry(QtCore.QRect(10, 130, 111, 20)) - self.Other_manualInput4_checkBox.setObjectName("Other_manualInput4_checkBox") - self.Other_manualInput4_lineEdit = QtWidgets.QLineEdit(self.xia2options_Other) - self.Other_manualInput4_lineEdit.setGeometry(QtCore.QRect(130, 130, 400, 22)) - self.Other_manualInput4_lineEdit.setObjectName("Other_manualInput4_lineEdit") - - self.Other_clusterOrLocal_label = QtWidgets.QLabel(self.xia2options_Other) - self.Other_clusterOrLocal_label.setGeometry(QtCore.QRect(10, 160, 200, 16)) - self.Other_clusterOrLocal_label.setObjectName("Other_clusterOrLocal_label") - - self.Other_clusterOrLocal_comboBox = QtWidgets.QComboBox(self.xia2options_Other) - self.Other_clusterOrLocal_comboBox.setGeometry(QtCore.QRect(160, 160, 171, 22)) - self.Other_clusterOrLocal_comboBox.setObjectName( - "Other_clusterOrLocal_comboBox" - ) - self.Other_clusterOrLocal_comboBox.addItem("") - self.Other_clusterOrLocal_comboBox.addItem("") - - ################################################################################ - # dials ALL - self.xia2options_ALL = QtWidgets.QWidget() - self.xia2options_ALL.setObjectName("xia2options_ALL") - self.xia2_options.addTab(self.xia2options_ALL, "") + super().__init__() + uic.loadUi(Path(__file__).parent / "OptionsWindow.ui", self) - self.ALL_plainTextEdit = QtWidgets.QPlainTextEdit(self.xia2options_ALL) - self.ALL_plainTextEdit.setGeometry(QtCore.QRect(150, 10, 291, 121)) - self.ALL_plainTextEdit.setObjectName("ALL_plainTextEdit") + self.updateButton.clicked.connect(self.update_options) + self.resetButton.clicked.connect(self.reset_options) + self.saveButton.clicked.connect(self.save_options) + self.loadButton.clicked.connect(self.load_options) - ################################################################################ - # dials HP - self.xia2options_HP = QtWidgets.QWidget() - self.xia2options_HP.setObjectName("xia2options_HP") - self.xia2_options.addTab(self.xia2options_HP, "") - - self.HP_correction_shadowing_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_correction_shadowing_checkBox.setGeometry(QtCore.QRect(10, 20, 321, 20)) - self.HP_correction_shadowing_checkBox.setObjectName( - "HP_correction_shadowing_checkBox" - ) - - self.HP_scanVarying_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_scanVarying_checkBox.setGeometry(QtCore.QRect(420, 20, 121, 20)) - self.HP_scanVarying_checkBox.setObjectName("HP_scanVarying_checkBox") - - self.HP_ReferenceGeometry_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_ReferenceGeometry_checkBox.setGeometry(QtCore.QRect(10, 50, 161, 20)) - self.HP_ReferenceGeometry_checkBox.setObjectName( - "HP_ReferenceGeometry_checkBox" - ) - self.HP_ReferenceGeometry_browse = QtWidgets.QPushButton(self.xia2options_HP) - self.HP_ReferenceGeometry_browse.setGeometry(QtCore.QRect(160, 45, 93, 28)) - self.HP_ReferenceGeometry_browse.setObjectName("HP_ReferenceGeometry_browse") - self.HP_ReferenceGeometry_browse.clicked.connect( + # TODO: Connect duplicate widgets like the reference geometry file selection. + self.importReferenceGeometryBrowse.clicked.connect( self.browse_for_reference_model ) - self.HP_ReferenceGeometry_path = QtWidgets.QLabel(self.xia2options_HP) - self.HP_ReferenceGeometry_path.setGeometry(QtCore.QRect(260, 50, 271, 16)) - self.HP_ReferenceGeometry_path.setObjectName("HP_ReferenceGeometry_path") - self.HP_gasket_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_gasket_checkBox.setGeometry(QtCore.QRect(10, 80, 151, 20)) - self.HP_gasket_checkBox.setObjectName("HP_gasket_checkBox") - self.HP_gasket_comboBox = QtWidgets.QComboBox(self.xia2options_HP) - self.HP_gasket_comboBox.setGeometry(QtCore.QRect(90, 80, 101, 22)) - self.HP_gasket_comboBox.setObjectName("HP_gasket_comboBox") - self.HP_gasket_comboBox.addItem("") - self.HP_gasket_comboBox.addItem("") - - self.HP_gasketUser_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_gasketUser_checkBox.setGeometry(QtCore.QRect(10, 120, 151, 20)) - self.HP_gasketUser_checkBox.setObjectName("HP_gasketUser_checkBox") - - self.HP_gasketUserUC_lineEdit = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_gasketUserUC_lineEdit.setGeometry(QtCore.QRect(170, 120, 241, 22)) - self.HP_gasketUserUC_lineEdit.setObjectName("HP_gasketUserUC_lineEdit") - self.HP_gasketUserUC_lineEdit.setStatusTip("e.g. 2.87,2.87,2.87,90,90,90") - self.HP_gasketUserUC_label = QtWidgets.QLabel(self.xia2options_HP) - self.HP_gasketUserUC_label.setGeometry(QtCore.QRect(240, 100, 55, 16)) - self.HP_gasketUserUC_label.setObjectName("HP_gasketUserUC_label") - self.HP_gasketUserSG_lineEdit = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_gasketUserSG_lineEdit.setGeometry(QtCore.QRect(420, 120, 71, 22)) - self.HP_gasketUserSG_lineEdit.setObjectName("HP_gasketUserSG_lineEdit") - self.HP_gasketUserSG_lineEdit.setStatusTip("e.g. Im-3m") - self.HP_gasketUserSG_label = QtWidgets.QLabel(self.xia2options_HP) - self.HP_gasketUserSG_label.setGeometry(QtCore.QRect(420, 100, 81, 16)) - self.HP_gasketUserSG_label.setObjectName("HP_gasketUserSG_label") - self.HP_gasketUserW_label = QtWidgets.QLabel(self.xia2options_HP) - self.HP_gasketUserW_label.setGeometry(QtCore.QRect(520, 100, 41, 16)) - self.HP_gasketUserW_label.setObjectName("HP_gasketUserW_label") - self.HP_gasketUserW_lineEdit = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_gasketUserW_lineEdit.setGeometry(QtCore.QRect(500, 120, 71, 22)) - self.HP_gasketUserW_lineEdit.setObjectName("HP_gasketUserW_lineEdit") - self.HP_gasketUserW_lineEdit.setStatusTip("e.g. 0.02") - # medium difficulty - self.HP_UN_SG_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_UN_SG_checkBox.setGeometry(QtCore.QRect(10, 190, 181, 20)) - self.HP_UN_SG_checkBox.setObjectName("HP_UN_SG_checkBox") - self.HP_UN_lineEdit = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_UN_lineEdit.setGeometry(QtCore.QRect(190, 190, 211, 22)) - self.HP_UN_lineEdit.setObjectName("HP_UN_lineEdit") - self.HP_UN_lineEdit.setStatusTip("e.g. 5.4,5.4,5.4,90,90,90") - self.HP_UN_label = QtWidgets.QLabel(self.xia2options_HP) - self.HP_UN_label.setGeometry(QtCore.QRect(260, 170, 51, 20)) - self.HP_UN_label.setObjectName("HP_UN_label") - self.HP_SG_lineEdit = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_SG_lineEdit.setGeometry(QtCore.QRect(410, 190, 91, 22)) - self.HP_SG_lineEdit.setObjectName("HP_SG_lineEdit") - self.HP_SG_lineEdit.setStatusTip("e.g. Im-3m") - self.HP_SG_label = QtWidgets.QLabel(self.xia2options_HP) - self.HP_SG_label.setGeometry(QtCore.QRect(420, 170, 81, 20)) - self.HP_SG_label.setObjectName("HP_SG_label") - - self.HP_dmin_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_dmin_checkBox.setGeometry(QtCore.QRect(10, 220, 111, 20)) - self.HP_dmin_checkBox.setObjectName("HP_dmin_checkBox") - self.HP_dmin_lineEdit = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_dmin_lineEdit.setGeometry(QtCore.QRect(90, 220, 113, 22)) - self.HP_dmin_lineEdit.setObjectName("HP_dmin_lineEdit") - self.HP_dmin_lineEdit.setStatusTip("e.g. 0.84") - - self.HP_runStartEnd_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_runStartEnd_checkBox.setGeometry(QtCore.QRect(10, 250, 111, 20)) - self.HP_runStartEnd_checkBox.setObjectName("HP_runStartEnd_checkBox") - self.HP_runStartEnd_lineEdit_1 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_1.setGeometry(QtCore.QRect(149, 250, 61, 22)) - self.HP_runStartEnd_lineEdit_1.setObjectName("HP_runStartEnd_lineEdit_1") - self.HP_runStartEnd_lineEdit_1.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_label_1 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_1.setGeometry(QtCore.QRect(130, 250, 31, 20)) - self.HP_runStartEnd_label_1.setObjectName("HP_runStartEnd_label_1") - self.HP_runStartEnd_lineEdit_2 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_2.setGeometry(QtCore.QRect(240, 250, 61, 22)) - self.HP_runStartEnd_lineEdit_2.setObjectName("HP_runStartEnd_lineEdit_2") - self.HP_runStartEnd_lineEdit_2.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_label_2 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_2.setGeometry(QtCore.QRect(221, 250, 31, 20)) - self.HP_runStartEnd_label_2.setObjectName("HP_runStartEnd_label_2") - self.HP_runStartEnd_lineEdit_3 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_3.setGeometry(QtCore.QRect(329, 250, 61, 22)) - self.HP_runStartEnd_lineEdit_3.setObjectName("HP_runStartEnd_lineEdit_3") - self.HP_runStartEnd_lineEdit_3.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_label_3 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_3.setGeometry(QtCore.QRect(401, 250, 31, 20)) - self.HP_runStartEnd_label_3.setObjectName("HP_runStartEnd_label_3") - self.HP_runStartEnd_lineEdit_4 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_4.setGeometry(QtCore.QRect(420, 250, 61, 22)) - self.HP_runStartEnd_lineEdit_4.setObjectName("HP_runStartEnd_lineEdit_4") - self.HP_runStartEnd_lineEdit_4.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_label_4 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_4.setGeometry(QtCore.QRect(310, 250, 31, 20)) - self.HP_runStartEnd_label_4.setObjectName("HP_runStartEnd_label_4") - self.HP_runStartEnd_lineEdit_5 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_5.setGeometry(QtCore.QRect(510, 250, 61, 22)) - self.HP_runStartEnd_lineEdit_5.setObjectName("HP_runStartEnd_lineEdit_5") - self.HP_runStartEnd_lineEdit_5.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_label_5 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_5.setGeometry(QtCore.QRect(491, 250, 31, 20)) - self.HP_runStartEnd_label_5.setObjectName("HP_runStartEnd_label_5") - self.HP_runStartEnd_lineEdit_6 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_6.setGeometry(QtCore.QRect(149, 280, 61, 22)) - self.HP_runStartEnd_lineEdit_6.setObjectName("HP_runStartEnd_lineEdit_6") - self.HP_runStartEnd_lineEdit_6.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_label_7 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_7.setGeometry(QtCore.QRect(221, 280, 31, 20)) - self.HP_runStartEnd_label_7.setObjectName("HP_runStartEnd_label_7") - self.HP_runStartEnd_lineEdit_7 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_7.setGeometry(QtCore.QRect(240, 280, 61, 22)) - self.HP_runStartEnd_lineEdit_7.setObjectName("HP_runStartEnd_lineEdit_7") - self.HP_runStartEnd_lineEdit_7.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_lineEdit_8 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_8.setGeometry(QtCore.QRect(329, 280, 61, 22)) - self.HP_runStartEnd_lineEdit_8.setObjectName("HP_runStartEnd_lineEdit_8") - self.HP_runStartEnd_lineEdit_8.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_lineEdit_9 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_9.setGeometry(QtCore.QRect(420, 280, 61, 22)) - self.HP_runStartEnd_lineEdit_9.setObjectName("HP_runStartEnd_lineEdit_9") - self.HP_runStartEnd_lineEdit_9.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_lineEdit_10 = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_runStartEnd_lineEdit_10.setGeometry(QtCore.QRect(510, 280, 61, 22)) - self.HP_runStartEnd_lineEdit_10.setObjectName("HP_runStartEnd_lineEdit_10") - self.HP_runStartEnd_lineEdit_10.setStatusTip("e.g. 20:600") - self.HP_runStartEnd_label_6 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_6.setGeometry(QtCore.QRect(130, 280, 31, 20)) - self.HP_runStartEnd_label_6.setObjectName("HP_runStartEnd_label_6") - self.HP_runStartEnd_label_8 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_8.setGeometry(QtCore.QRect(310, 280, 31, 20)) - self.HP_runStartEnd_label_8.setObjectName("HP_runStartEnd_label_8") - self.HP_runStartEnd_label_9 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_9.setGeometry(QtCore.QRect(401, 280, 31, 20)) - self.HP_runStartEnd_label_9.setObjectName("HP_runStartEnd_label_9") - self.HP_runStartEnd_label_10 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_runStartEnd_label_10.setGeometry(QtCore.QRect(486, 280, 31, 20)) - self.HP_runStartEnd_label_10.setObjectName("HP_runStartEnd_label_10") - # problematic data options - self.HP_FixBeamDetector_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_FixBeamDetector_checkBox.setGeometry(QtCore.QRect(10, 320, 151, 20)) - self.HP_FixBeamDetector_checkBox.setObjectName("HP_FixBeamDetector_checkBox") - - self.HP_anvilThickness_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_anvilThickness_checkBox.setGeometry(QtCore.QRect(10, 350, 151, 20)) - self.HP_anvilThickness_checkBox.setObjectName("HP_anvilThickness_checkBox") - self.HP_anvilThickness_lineEdit = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_anvilThickness_lineEdit.setGeometry(QtCore.QRect(160, 350, 113, 22)) - self.HP_anvilThickness_lineEdit.setObjectName("HP_anvilThickness_lineEdit") - self.HP_anvilThickness_lineEdit.setStatusTip("e.g. 2.1") - - self.HP_anvilOpeningAngle_checkBox = QtWidgets.QCheckBox(self.xia2options_HP) - self.HP_anvilOpeningAngle_checkBox.setGeometry(QtCore.QRect(10, 380, 151, 20)) - self.HP_anvilOpeningAngle_checkBox.setObjectName( - "HP_anvilOpeningAngle_checkBox" - ) - self.HP_anvilOpeningAngle_lineEdit = QtWidgets.QLineEdit(self.xia2options_HP) - self.HP_anvilOpeningAngle_lineEdit.setGeometry(QtCore.QRect(160, 380, 113, 22)) - self.HP_anvilOpeningAngle_lineEdit.setObjectName( - "HP_anvilOpeningAngle_lineEdit" - ) - self.HP_anvilOpeningAngle_lineEdit.setStatusTip("e.g. 80") - - self.HP_line_1 = QtWidgets.QFrame(self.xia2options_HP) - self.HP_line_1.setGeometry(QtCore.QRect(0, 0, 581, 20)) - self.HP_line_1.setFrameShape(QtWidgets.QFrame.HLine) - self.HP_line_1.setFrameShadow(QtWidgets.QFrame.Sunken) - self.HP_line_1.setObjectName("HP_line_1") - self.HP_line_2 = QtWidgets.QFrame(self.xia2options_HP) - self.HP_line_2.setGeometry(QtCore.QRect(0, 150, 581, 20)) - self.HP_line_2.setFrameShape(QtWidgets.QFrame.HLine) - self.HP_line_2.setFrameShadow(QtWidgets.QFrame.Sunken) - self.HP_line_2.setObjectName("HP_line_2") - self.HP_line_3 = QtWidgets.QFrame(self.xia2options_HP) - self.HP_line_3.setGeometry(QtCore.QRect(0, 305, 581, 20)) - self.HP_line_3.setFrameShape(QtWidgets.QFrame.HLine) - self.HP_line_3.setFrameShadow(QtWidgets.QFrame.Sunken) - self.HP_line_3.setObjectName("HP_line_3") - - self.HP_difficulty_label_1 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_difficulty_label_1.setGeometry(QtCore.QRect(250, 1, 101, 16)) - self.HP_difficulty_label_1.setObjectName("HP_difficulty_label_1") - self.HP_difficulty_label_1.setAutoFillBackground(True) - self.HP_difficulty_label_2 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_difficulty_label_2.setGeometry(QtCore.QRect(230, 150, 151, 20)) - self.HP_difficulty_label_2.setObjectName("HP_difficulty_label_2") - self.HP_difficulty_label_2.setAutoFillBackground(True) - self.HP_difficulty_label_3 = QtWidgets.QLabel(self.xia2options_HP) - self.HP_difficulty_label_3.setGeometry(QtCore.QRect(230, 305, 141, 20)) - self.HP_difficulty_label_3.setObjectName("HP_difficulty_label_3") - self.HP_difficulty_label_3.setAutoFillBackground(True) - ################################################################################ - xia2_options.setCentralWidget(self.central_widget) - self.menubar = QtWidgets.QMenuBar(xia2_options) - self.menubar.setGeometry(QtCore.QRect(0, 0, 613, 26)) - self.menubar.setObjectName("menu_bar") - xia2_options.setMenuBar(self.menubar) - self.statusbar = QtWidgets.QStatusBar(xia2_options) - self.statusbar.setObjectName("status_bar") - xia2_options.setStatusBar(self.statusbar) - - self.retranslate_ui(xia2_options) - self.xia2_options.setCurrentIndex(0) + self.hpReferenceGeometryBrowse.clicked.connect(self.browse_for_reference_model) + # TODO: Dynamically create a checkbox for each sweep found. QtCore.QMetaObject.connectSlotsByName(xia2_options) - self.optionListImport = [ - self.import_trust_beam_centre, - self.import_reference_geometry, - self.import_dd, - self.import_beam_centre, - self.import_wavelengh, - self.import_fix_beam_detector_check_box, - self.import_run_selector_check_box, - self.Import_type_checkBox, - ] - - self.runSelectorList = [ - self.Import_RunSelector_checkBox_1, - self.Import_RunSelector_checkBox_2, - self.Import_RunSelector_checkBox_3, - self.Import_RunSelector_checkBox_4, - self.Import_RunSelector_checkBox_5, - self.Import_RunSelector_checkBox_6, - self.Import_RunSelector_checkBox_7, - self.Import_RunSelector_checkBox_8, - self.Import_RunSelector_checkBox_9, - self.Import_RunSelector_checkBox_10, - self.Import_RunSelector_checkBox_11, - self.Import_RunSelector_checkBox_12, - self.Import_RunSelector_checkBox_13, - self.Import_RunSelector_checkBox_14, - self.Import_RunSelector_checkBox_15, - self.Import_RunSelector_checkBox_16, - self.Import_RunSelector_checkBox_17, - self.Import_RunSelector_checkBox_18, - self.Import_RunSelector_checkBox_19, - self.Import_RunSelector_checkBox_20, - self.Import_RunSelector_checkBox_21, - self.Import_RunSelector_checkBox_22, - self.Import_RunSelector_checkBox_23, - self.Import_RunSelector_checkBox_24, - self.Import_RunSelector_checkBox_25, - self.Import_RunSelector_checkBox_26, - self.Import_RunSelector_checkBox_27, - self.Import_RunSelector_checkBox_28, - self.Import_RunSelector_checkBox_29, - self.Import_RunSelector_checkBox_30, - self.Import_RunSelector_checkBox_31, - self.Import_RunSelector_checkBox_32, - self.Import_RunSelector_checkBox_33, - self.Import_RunSelector_checkBox_34, - self.Import_RunSelector_checkBox_35, - self.Import_RunSelector_checkBox_36, - ] - - self.optionListSpotFinding = [ - self.findSpots_sigmaStrong, - self.findSpots_minSpot, - self.findSpots_maxSpot, - self.findSpots_dmin, - self.findSpots_dmax, - self.findSpots_iceRings, - self.findSpots_powderRings, - self.findSpots_resolutionRange, - self.findSpots_circleMask, - self.findSpots_recMask, - ] - - self.optionListIndexing = [ - self.Index_method_checkBox, - self.Index_scanVarying_checkBox, - self.Index_UN_SG_checkBox, - self.Index_minCell_checkBox, - self.Index_maxCell_checkBox, - self.Index_multiprocessing_checkBox, - self.Index_multiSweepRefine_checkBox, - self.Index_outliers_checkBox, - ] - - self.optionListIntegrate = [ - self.Integrate_keepAllReflections_checkBox, - self.Integrate_scanVarying_checkBox, - self.Integrate_minSpotProfile_checkBox, - ] - - self.optionListRefineScale = [ - self.Refine_FixBeamDetector_checkBox, - self.Refine_method_checkBox, - ] - - self.optionListOther = [ - self.Other_failover_checkBox, - self.Other_manualInput1_checkBox, - self.Other_manualInput2_checkBox, - self.Other_manualInput3_checkBox, - self.Other_manualInput4_checkBox, - ] - - self.optionListHP = [ - self.HP_correction_shadowing_checkBox, - self.HP_ReferenceGeometry_checkBox, - self.HP_gasket_checkBox, - self.HP_gasketUser_checkBox, - self.HP_UN_SG_checkBox, - self.HP_dmin_checkBox, - self.HP_runStartEnd_checkBox, - self.HP_FixBeamDetector_checkBox, - self.HP_scanVarying_checkBox, - self.HP_anvilThickness_checkBox, - self.HP_anvilOpeningAngle_checkBox, - ] - - self.runStartEnd_lineEdits = [ - self.HP_runStartEnd_lineEdit_1.text(), - self.HP_runStartEnd_lineEdit_2.text(), - self.HP_runStartEnd_lineEdit_3.text(), - self.HP_runStartEnd_lineEdit_4.text(), - self.HP_runStartEnd_lineEdit_5.text(), - self.HP_runStartEnd_lineEdit_6.text(), - self.HP_runStartEnd_lineEdit_7.text(), - self.HP_runStartEnd_lineEdit_8.text(), - self.HP_runStartEnd_lineEdit_9.text(), - self.HP_runStartEnd_lineEdit_10.text(), - ] - # load previous settings: self.load_options_auto() + self.show() + def browse_for_reference_model(self): path = self.opening_visit os.chdir(path) From 8a5cde8d8cd3fddb52a7d845cce3db3cca5d08da Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Fri, 20 Nov 2020 18:52:37 +0000 Subject: [PATCH 03/31] Show all Python LGTM query results --- .lgtm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lgtm.yml b/.lgtm.yml index 3727bc1..3a4daa8 100644 --- a/.lgtm.yml +++ b/.lgtm.yml @@ -1,2 +1,2 @@ queries: - - include: "py/*" + - include: "*" From 9faf1302cec8e39775b9e0929f165c89d70e5e34 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Sat, 21 Nov 2020 11:27:34 +0000 Subject: [PATCH 04/31] Fix xia2 options window parentage --- i19-gui/chemical_crystallography_gui.py | 43 +++++++++++++------------ 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index bb47d38..25585d5 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -20,7 +20,7 @@ class UIMainWindow(QtWidgets.QMainWindow): - def __init__(self): + def __init__(self, parent_window=None): self.dials_version = "" self.opening_visit = "/dls/i19-2/data/2020/" self.visit = "" @@ -84,7 +84,7 @@ def __init__(self): ] self.tabs_num = 0 - super().__init__() + super().__init__(parent_window) uic.loadUi(Path(__file__).parent / "MainWindow.ui", self) self.menuFile_Open.triggered.connect(self.select_dataset) @@ -292,10 +292,7 @@ def run_albula(self): # open options window ########################################################### def open_options(self): self.append_output(self.log_output_txt, "Opening options window") - self.secondWindow = QtWidgets.QMainWindow() - self.ui = UIXia2Options( - self, - self.secondWindow, + options_window = UIOptionsWindow( self.xia2_command, self.dataset_path, self.command_command, @@ -304,8 +301,9 @@ def open_options(self): self.run_list, self.prefix, self.opening_visit, + self, ) - self.secondWindow.show() + options_window.show() def update_options(self): self.command_command.setPlainText( @@ -1037,11 +1035,9 @@ def run(self): ######################################################################################## -class UIXia2Options(QtWidgets.QMainWindow): +class UIOptionsWindow(QtWidgets.QMainWindow): def __init__( self, - ui_main_window, - xia2_options, xia2_command, dataset_path, command_command, @@ -1050,8 +1046,8 @@ def __init__( run_list, prefix, opening_visit, + parent_window=None, ): - self.ui_main_window = ui_main_window self.xia2_command = xia2_command self.dataset_path = dataset_path self.run_list = run_list @@ -1065,7 +1061,7 @@ def __init__( self.prefix = prefix self.opening_visit = opening_visit - super().__init__() + super().__init__(parent_window) uic.loadUi(Path(__file__).parent / "OptionsWindow.ui", self) self.updateButton.clicked.connect(self.update_options) @@ -1079,7 +1075,8 @@ def __init__( ) self.hpReferenceGeometryBrowse.clicked.connect(self.browse_for_reference_model) # TODO: Dynamically create a checkbox for each sweep found. - QtCore.QMetaObject.connectSlotsByName(xia2_options) + # TODO: Make proper use of connectSlotsByName + QtCore.QMetaObject.connectSlotsByName(self) # load previous settings: self.load_options_auto() @@ -1769,10 +1766,11 @@ def update_options(self): self.log_output_txt.appendPlainText(options_update_text) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - self.ui_main_window.xia2_command = self.xia2_command - self.ui_main_window.dataset_path = self.dataset_path - self.ui_main_window.xia2_options_list = options - self.ui_main_window.update_options() + ui_main_window = self.parent() + ui_main_window.xia2_command = self.xia2_command + ui_main_window.dataset_path = self.dataset_path + ui_main_window.xia2_options_list = options + ui_main_window.update_options() self.save_options_auto() @@ -1822,10 +1820,11 @@ def reset_options(self): self.log_output_txt.appendPlainText(options_update_text) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - self.ui_main_window.xia2_command = self.xia2_command - self.ui_main_window.dataset_path = self.dataset_path - self.ui_main_window.xia2_options_list = options - self.ui_main_window.update_options() + ui_main_window = self.parent() + ui_main_window.xia2_command = self.xia2_command + ui_main_window.dataset_path = self.dataset_path + ui_main_window.xia2_options_list = options + ui_main_window.update_options() def option_file_text_function(self): option_file_text = "" @@ -3010,6 +3009,8 @@ def retranslate_ui(self, xia2_options): if __name__ == "__main__": + # We must assign the QApplication and MainWindow instances to variables to + # prevent garbage collection messing with the open UI. app = QtWidgets.QApplication(sys.argv) # QApplication.setOverrideCursor(Qt.WaitCursor) ui = UIMainWindow() From d5f02d3d1f5e103cd1eb524b6355ab502cff0cf7 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Sat, 21 Nov 2020 13:30:26 +0000 Subject: [PATCH 05/31] Add a margin to the xia2 options window --- i19-gui/OptionsWindow.ui | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/i19-gui/OptionsWindow.ui b/i19-gui/OptionsWindow.ui index 82ab70d..738789a 100644 --- a/i19-gui/OptionsWindow.ui +++ b/i19-gui/OptionsWindow.ui @@ -18,6 +18,18 @@ + + 10 + + + 10 + + + 10 + + + 0 + From 5b79f4b932165ddba4faefc3b4977a77bb419252 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Tue, 24 Nov 2020 17:00:10 +0000 Subject: [PATCH 06/31] Make removal of exit button more robust Make sure that we remove the exit button from the log output tab, regardless of its position in the tab bar. --- i19-gui/MainWindow.ui | 9 +- i19-gui/chemical_crystallography_gui.py | 153 ++++++++++++------------ 2 files changed, 80 insertions(+), 82 deletions(-) diff --git a/i19-gui/MainWindow.ui b/i19-gui/MainWindow.ui index b2aa2dd..8f7dde7 100644 --- a/i19-gui/MainWindow.ui +++ b/i19-gui/MainWindow.ui @@ -1163,7 +1163,7 @@ - + QTabWidget::North @@ -1179,16 +1179,19 @@ false - + Main - + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 25585d5..a5e93e0 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -102,16 +102,17 @@ def __init__(self, parent_window=None): # Remove the close button from the main log output tab, leaving the close # buttons on the other tabs active. - tab_bar = self.output_tabs.tabBar() - left_delete_button = tab_bar.tabButton(0, tab_bar.LeftSide) + tab_bar = self.outputTabs.tabBar() + log_output = self.outputTabs.indexOf(self.logOutput) + left_delete_button = tab_bar.tabButton(log_output, tab_bar.LeftSide) if left_delete_button: left_delete_button.deleteLater() - right_delete_button = tab_bar.tabButton(0, tab_bar.RightSide) + right_delete_button = tab_bar.tabButton(log_output, tab_bar.RightSide) if right_delete_button: right_delete_button.deleteLater() - tab_bar.setTabButton(0, tab_bar.LeftSide, None) - tab_bar.setTabButton(0, tab_bar.RightSide, None) - self.output_tabs.tabCloseRequested.connect(self.close_handler) + tab_bar.setTabButton(log_output, tab_bar.LeftSide, None) + tab_bar.setTabButton(log_output, tab_bar.RightSide, None) + self.outputTabs.tabCloseRequested.connect(self.close_handler) self.show() @@ -135,7 +136,7 @@ def select_dataset(self): if self.dataset_path: self.multiple_dataset = {} self.append_output( - self.log_output_txt, "\n Dataset Path: " + self.dataset_path + self.logOutputTxt, "\n Dataset Path: " + self.dataset_path ) self.dataset = self.dataset_path.split("/")[-1] # dataset name if "staging" in self.dataset_path.split("/"): @@ -145,15 +146,13 @@ def select_dataset(self): # /dls/i19-2/data/2020/cm26492-2/ self.visit = "/".join(self.dataset_path.split("/")[:6]) + "/" self.opening_visit = str(self.visit) - self.append_output( - self.log_output_txt, " Dataset: " + self.dataset - ) + self.append_output(self.logOutputTxt, " Dataset: " + self.dataset) for cbf_file in os.listdir(self.dataset_path): # prefix if cbf_file.endswith("_00001.cbf"): self.prefix = cbf_file[:-12] break - self.append_output(self.log_output_txt, " Prefix: " + self.prefix) + self.append_output(self.logOutputTxt, " Prefix: " + self.prefix) self.run_list = [] run_images_dict = {} for cbf_files in os.listdir(self.dataset_path): # runs in dataset @@ -164,7 +163,7 @@ def select_dataset(self): self.run_list.sort() self.append_output( - self.log_output_txt, + self.logOutputTxt, " Number of runs: " + " ".join(map(str, (len(self.run_list), self.run_list))), ) @@ -175,11 +174,11 @@ def select_dataset(self): ) run_images_dict[run] = num_cbf_run self.append_output( - self.log_output_txt, " Images per run: " + str(run_images_dict) + self.logOutputTxt, " Images per run: " + str(run_images_dict) ) total_num_images = sum(run_images_dict.values()) # total number of images self.append_output( - self.log_output_txt, + self.logOutputTxt, " Total number of images: " + str(total_num_images) + "\n", ) # update labels @@ -203,7 +202,7 @@ def open_multiple(self): if new_dataset_path: self.append_output( - self.log_output_txt, + self.logOutputTxt, "\n New Dataset Path: " + new_dataset_path, ) @@ -215,16 +214,14 @@ def open_multiple(self): # /dls/i19-2/data/2020/cm26492-2/ self.visit = "/".join(self.dataset_path.split("/")[:6]) + "/" self.opening_visit = str(self.visit) - self.append_output( - self.log_output_txt, " New Dataset: " + dataset - ) + self.append_output(self.logOutputTxt, " New Dataset: " + dataset) for cbf_file in os.listdir(new_dataset_path): # prefix if cbf_file.endswith("_00001.cbf"): prefix = cbf_file[:-12] break if prefix: - self.append_output(self.log_output_txt, " New Prefix: " + prefix) + self.append_output(self.logOutputTxt, " New Prefix: " + prefix) run_list = [] run_images_dict = {} for cbf_file in os.listdir(new_dataset_path): # runs in dataset @@ -235,7 +232,7 @@ def open_multiple(self): run_list.sort() self.append_output( - self.log_output_txt, + self.logOutputTxt, " New Number of runs: " + str(len(run_list)) + " " @@ -248,12 +245,12 @@ def open_multiple(self): ) run_images_dict[run] = num_cbf_run self.append_output( - self.log_output_txt, + self.logOutputTxt, " New Images per run: " + str(run_images_dict), ) total_num_images = sum(run_images_dict.values()) # total number of images self.append_output( - self.log_output_txt, + self.logOutputTxt, " New Total number of images: " + str(total_num_images) + "\n", ) # update labels @@ -266,24 +263,24 @@ def open_multiple(self): self.multiple_dataset[dataset] = [new_dataset_path, prefix, run_list] self.append_output( - self.log_output_txt, + self.logOutputTxt, " Multiple runs:\n " + str(self.multiple_dataset), ) # file menu, close -> close GUI #### def close_gui(self): - self.append_output(self.log_output_txt, "\n\nClosing GUI\n\n") + self.append_output(self.logOutputTxt, "\n\nClosing GUI\n\n") QtCore.QCoreApplication.instance().quit() # open albula #### def run_albula(self): - self.append_output(self.log_output_txt, self.dataset_path) + self.append_output(self.logOutputTxt, self.dataset_path) if self.dataset_path == "": subprocess.Popen( ["sh", "/dls_sw/i19/scripts/MarkWarren/PyQT/1_basic/albula.sh"] ) else: - self.append_output(self.log_output_txt, "opening albula with first image") + self.append_output(self.logOutputTxt, "opening albula with first image") image = f"{self.dataset_path}/{self.prefix}{self.run_list[0]:02d}_00001.cbf" subprocess.Popen( ["sh", "/dls_sw/i19/scripts/MarkWarren/PyQT/1_basic/albula.sh", image] @@ -291,13 +288,13 @@ def run_albula(self): # open options window ########################################################### def open_options(self): - self.append_output(self.log_output_txt, "Opening options window") + self.append_output(self.logOutputTxt, "Opening options window") options_window = UIOptionsWindow( self.xia2_command, self.dataset_path, self.command_command, self.visit, - self.log_output_txt, + self.logOutputTxt, self.run_list, self.prefix, self.opening_visit, @@ -311,17 +308,17 @@ def update_options(self): ) def run_xia2(self): - self.append_output(self.log_output_txt, "\nRunning xia2\n") + self.append_output(self.logOutputTxt, "\nRunning xia2\n") # single datasets ########### if not self.dataset_path == "MULTIPLE": - self.append_output(self.log_output_txt, "Single Dataset") + self.append_output(self.logOutputTxt, "Single Dataset") if self.prefix == "": self.append_output( - self.log_output_txt, + self.logOutputTxt, "\n\n #########################################################", ) self.append_output( - self.log_output_txt, + self.logOutputTxt, " No cbf images found in directory, " "please select dataset directory", ) @@ -329,7 +326,7 @@ def run_xia2(self): self.run_xia2_dataset(self.dataset, self.dataset_path) # multiple datasets ########### if self.dataset_path == "MULTIPLE": # if multiple input has been utilised - self.append_output(self.log_output_txt, "\n Multiple dataset processing\n") + self.append_output(self.logOutputTxt, "\n Multiple dataset processing\n") # { # "01_Prot1_21": [ # "/dls/i19-2/data/2020/cy23401-1/01_Prot1_21", @@ -343,12 +340,12 @@ def run_xia2(self): dataset_path, prefix, _ = self.multiple_dataset[dataset_key] if not prefix: self.append_output( - self.log_output_txt, + self.logOutputTxt, "\n\n ############################" "############################b", ) self.append_output( - self.log_output_txt, + self.logOutputTxt, " No cbf images found in directory, " "please select dataset directory", ) @@ -362,12 +359,12 @@ def run_xia2(self): runs = self.multiple_dataset[dataset_key][2] if prefix == "": self.append_output( - self.log_output_txt, + self.logOutputTxt, "\n\n ############################" "############################c", ) self.append_output( - self.log_output_txt, + self.logOutputTxt, " No cbf images found in directory, " "please select dataset directory", ) @@ -416,11 +413,11 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas self.processing_path_path.setText(self.processing_path) self.tabs_processing_path[self.tabs_num] = self.processing_path - self.append_output(self.log_output_txt, "Xia2 command:") + self.append_output(self.logOutputTxt, "Xia2 command:") # this is the bit I think i need to change!!! # dataset and prefix I would guess is required input_xia2_command = self.xia2_command + xia2_input + self.xia2_options_list - self.append_output(self.log_output_txt, " " + input_xia2_command) + self.append_output(self.logOutputTxt, " " + input_xia2_command) # create job file @@ -490,7 +487,7 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas dataset_error_statement = ( "\n\n No dataset has been selected (File>Open) \n\n" ) - self.append_output(self.log_output_txt, dataset_error_statement) + self.append_output(self.logOutputTxt, dataset_error_statement) self.append_output(tab_name, dataset_error_statement) else: if self.computing_location == "Local": @@ -522,7 +519,7 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas input_dataset, self.tabstxt, self.tabs_num, - self.log_output_txt, + self.logOutputTxt, "xia2.txt", ) @@ -538,14 +535,14 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas self.tabs_num = 0 def run_screen19(self): - self.append_output(self.log_output_txt, "\nRunning screen19\n") + self.append_output(self.logOutputTxt, "\nRunning screen19\n") if self.prefix == "": self.append_output( - self.log_output_txt, + self.logOutputTxt, "\n\n #########################################################", ) self.append_output( - self.log_output_txt, + self.logOutputTxt, " No cbf images found in directory, please select dataset directory", ) return @@ -568,7 +565,7 @@ def run_screen19(self): self.processing_path_path.setText(self.processing_path) self.tabs_processing_path[self.tabs_num] = self.processing_path - self.append_output(self.log_output_txt, "screen19 command:") + self.append_output(self.logOutputTxt, "screen19 command:") # remove unwanted xia2 commands screen19_options_list = "" @@ -581,7 +578,7 @@ def run_screen19(self): input_screen19_command = ( "screen19 " + self.dataset_path + screen19_options_list ) - self.append_output(self.log_output_txt, " " + input_screen19_command) + self.append_output(self.logOutputTxt, " " + input_screen19_command) # create job file job_file = self.processing_path + "job.sh" @@ -661,7 +658,7 @@ def run_screen19(self): dataset_error_statement = ( "\n\n Dataset has not be selected (File>Open) \n\n" ) - self.append_output(self.log_output_txt, dataset_error_statement) + self.append_output(self.logOutputTxt, dataset_error_statement) self.append_output(tab_name, dataset_error_statement) else: if self.computing_location == "Local": @@ -686,7 +683,7 @@ def run_screen19(self): self.dataset, self.tabstxt, self.tabs_num, - self.log_output_txt, + self.logOutputTxt, "screen19.log", ) @@ -702,23 +699,21 @@ def run_screen19(self): self.tabs_num = 0 def thread_started(self): - self.append_output(self.log_output_txt, "\n*** Thread Started ***\n") + self.append_output(self.logOutputTxt, "\n*** Thread Started ***\n") def thread_finished(self): - self.append_output(self.log_output_txt, "\n*** Thread Finished ***\n") + self.append_output(self.logOutputTxt, "\n*** Thread Finished ***\n") def stop_thread(self): - self.append_output(self.log_output_txt, "\n*** Stopping Thead ***\n") + self.append_output(self.logOutputTxt, "\n*** Stopping Thead ***\n") # self.MyThread2.stop() # self.MyThread2.quit() # open run dials Reciprocal Lattice viewer #### def run_dials_reciprocal_lattice(self, tabs_num): + self.append_output(self.logOutputTxt, "Opening dials reciprocal lattice viewer") self.append_output( - self.log_output_txt, "Opening dials reciprocal lattice viewer" - ) - self.append_output( - self.log_output_txt, + self.logOutputTxt, "Processing path:" + self.tabs_processing_path[tabs_num], ) @@ -753,24 +748,24 @@ def run_dials_reciprocal_lattice(self, tabs_num): latest_refl_time = file_time if latest_expt == "": self.append_output( - self.log_output_txt, + self.logOutputTxt, "\n\n *** Expt was not present in processing path, " "please wait unit after initial importing *** \n\n", ) return if latest_refl == "": self.append_output( - self.log_output_txt, + self.logOutputTxt, "\n\n ***Refl was not present in processing path, " "please wait unit after initial spot finding *** \n\n", ) return else: self.append_output( - self.log_output_txt, "\nReflection file: " + str(latest_refl) + self.logOutputTxt, "\nReflection file: " + str(latest_refl) ) self.append_output( - self.log_output_txt, "Experiment file: " + str(latest_expt) + "\n" + self.logOutputTxt, "Experiment file: " + str(latest_expt) + "\n" ) subprocess.Popen( [ @@ -785,9 +780,9 @@ def run_dials_reciprocal_lattice(self, tabs_num): ) def run_dials_image_viewer(self, tabs_num): - self.append_output(self.log_output_txt, "Opening dials image viewer") + self.append_output(self.logOutputTxt, "Opening dials image viewer") self.append_output( - self.log_output_txt, + self.logOutputTxt, "Processing path:" + self.tabs_processing_path[tabs_num], ) @@ -822,16 +817,16 @@ def run_dials_image_viewer(self, tabs_num): latest_refl_time = file_time if latest_expt == "": self.append_output( - self.log_output_txt, + self.logOutputTxt, "\n\n ***Expt was not present in processing path, " "please wait unit after initial importing *** \n\n", ) else: self.append_output( - self.log_output_txt, "\nReflection file: " + str(latest_refl) + self.logOutputTxt, "\nReflection file: " + str(latest_refl) ) self.append_output( - self.log_output_txt, "Experiment file: " + str(latest_expt) + "\n" + self.logOutputTxt, "Experiment file: " + str(latest_expt) + "\n" ) subprocess.Popen( [ @@ -846,9 +841,9 @@ def run_dials_image_viewer(self, tabs_num): ) def run_dials_html(self, tabs_num): - self.append_output(self.log_output_txt, "Opening HTML") + self.append_output(self.logOutputTxt, "Opening HTML") self.append_output( - self.log_output_txt, + self.logOutputTxt, "Processing path:" + self.tabs_processing_path[tabs_num], ) @@ -870,14 +865,14 @@ def run_dials_html(self, tabs_num): if latest_html == "": self.append_output( - self.log_output_txt, + self.logOutputTxt, ( "\n\n *** html file was not present in processing path, " "please wait unit after initial importing *** \n\n" ), ) else: - self.append_output(self.log_output_txt, "HTML file: " + str(latest_html)) + self.append_output(self.logOutputTxt, "HTML file: " + str(latest_html)) subprocess.Popen( [ "sh", @@ -888,7 +883,7 @@ def run_dials_html(self, tabs_num): # version menu, change version def version_current(self): - self.append_output(self.log_output_txt, "Changing to dials version to current.") + self.append_output(self.logOutputTxt, "Changing to dials version to current.") dial_version_pop = ( os.popen("module unload dials; module load dials; dials.version") .read() @@ -898,11 +893,11 @@ def version_current(self): self.dials_version = "" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.logOutputTxt, " Version(" + dial_version_pop + ")") # version menu, change version to latest def version_latest(self): - self.append_output(self.log_output_txt, "Changing to dials version to latest.") + self.append_output(self.logOutputTxt, "Changing to dials version to latest.") dial_version_pop = ( os.popen("module unload dials; module load dials/latest; dials.version") .read() @@ -912,11 +907,11 @@ def version_latest(self): self.dials_version = "/latest" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.logOutputTxt, " Version(" + dial_version_pop + ")") # version menu, change version to now def version_now(self): - self.append_output(self.log_output_txt, "Changing to dials version to Now.") + self.append_output(self.logOutputTxt, "Changing to dials version to Now.") dial_version_pop = ( os.popen("module unload dials; module load dials/now; dials.version") .read() @@ -926,11 +921,11 @@ def version_now(self): self.dials_version = "/now" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.logOutputTxt, " Version(" + dial_version_pop + ")") # version menu, change version to 1.4 def version_1_4(self): - self.append_output(self.log_output_txt, "Changing to dials version to 1.4.") + self.append_output(self.logOutputTxt, "Changing to dials version to 1.4.") dial_version_pop = ( os.popen("module unload dials; module load dials/1.4; dials.version") .read() @@ -940,11 +935,11 @@ def version_1_4(self): self.dials_version = "/1.4" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.logOutputTxt, " Version(" + dial_version_pop + ")") # version menu, change version to 2.1 def version_2_1(self): - self.append_output(self.log_output_txt, "Changing to dials version to 2.1.") + self.append_output(self.logOutputTxt, "Changing to dials version to 2.1.") dial_version_pop = ( os.popen("module unload dials; module load dials/2.1; dials.version") .read() @@ -954,12 +949,12 @@ def version_2_1(self): self.dials_version = "/2.1" # update version label self.menu_version.setTitle("Version(" + dial_version_pop + ")") - self.append_output(self.log_output_txt, " Version(" + dial_version_pop + ")") + self.append_output(self.logOutputTxt, " Version(" + dial_version_pop + ")") # close tabs ###### def close_handler(self, index): self.append_output( - self.log_output_txt, "close_handler called, index = %s" % index + self.logOutputTxt, "close_handler called, index = %s" % index ) self.output_tabs.removeTab(index) From 02c90279f88633e70f44df48d6d4ffd7436c3c55 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Tue, 24 Nov 2020 17:31:46 +0000 Subject: [PATCH 07/31] Make some margins more consistent --- i19-gui/MainWindow.ui | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/i19-gui/MainWindow.ui b/i19-gui/MainWindow.ui index 8f7dde7..d7334c3 100644 --- a/i19-gui/MainWindow.ui +++ b/i19-gui/MainWindow.ui @@ -18,16 +18,19 @@ + + 0 + - 10 + 9 - 10 + 9 - 10 + 9 0 From e3d57ce82b0757001b010363e7509631b3395903 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 25 Nov 2020 17:12:51 +0000 Subject: [PATCH 08/31] Update some attribute names to match Qt camelCase These previously changed in the OptionsWindow.ui design file. --- i19-gui/chemical_crystallography_gui.py | 34 +++++++++++-------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index a5e93e0..015bec9 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -1101,11 +1101,11 @@ def browse_for_reference_model(self): self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - self.import_reference_geometry_path.setText(ref_geometry_file_txt) - self.import_reference_geometry_path.setScaledContents(True) + self.importReferenceGeometryPath.setText(ref_geometry_file_txt) + self.importReferenceGeometryPath.setScaledContents(True) - self.HP_ReferenceGeometry_path.setText(ref_geometry_file_txt) - self.HP_ReferenceGeometry_path.setScaledContents(True) + self.hpReferenceGeometryPath.setText(ref_geometry_file_txt) + self.hpReferenceGeometryPath.setScaledContents(True) def update_options(self): options = "" @@ -2281,12 +2281,10 @@ def load_options_main(self, saved_options_path_txt): self.ref_geometry_path = line_split[2] ref_geometry_path_txt = str(self.ref_geometry_path) ref_geometry_file_txt = ref_geometry_path_txt.split("/")[-1] - self.import_reference_geometry_path.setText( - ref_geometry_file_txt - ) - self.import_reference_geometry_path.setScaledContents(True) - self.HP_ReferenceGeometry_path.setText(ref_geometry_file_txt) - self.HP_ReferenceGeometry_path.setScaledContents(True) + self.importReferenceGeometryPath.setText(ref_geometry_file_txt) + self.importReferenceGeometryPath.setScaledContents(True) + self.hpReferenceGeometryPath.setText(ref_geometry_file_txt) + self.hpReferenceGeometryPath.setScaledContents(True) self.optionListImport[int(line_split[1])].setChecked(True) if int(line_split[1]) == 2: self.import_dd_line_edit.setText(line_split[2]) @@ -2397,12 +2395,10 @@ def load_options_main(self, saved_options_path_txt): self.ref_geometry_path = line_split[2] ref_geometry_path_txt = str(self.ref_geometry_path) ref_geometry_file_txt = ref_geometry_path_txt.split("/")[-1] - self.import_reference_geometry_path.setText( - ref_geometry_file_txt - ) - self.import_reference_geometry_path.setScaledContents(True) - self.HP_ReferenceGeometry_path.setText(ref_geometry_file_txt) - self.HP_ReferenceGeometry_path.setScaledContents(True) + self.importReferenceGeometryPath.setText(ref_geometry_file_txt) + self.importReferenceGeometryPath.setScaledContents(True) + self.hpReferenceGeometryPath.setText(ref_geometry_file_txt) + self.hpReferenceGeometryPath.setScaledContents(True) self.optionListHP[int(line_split[1])].setChecked(True) if int(line_split[1]) == 2: self.HP_gasket_comboBox.setCurrentIndex(int(line_split[2])) @@ -2508,7 +2504,7 @@ def retranslate_ui(self, xia2_options): "xia2_options", "Experimental geometry from the models selected (.expt)" ) ) - self.import_reference_geometry_path.setText( + self.importReferenceGeometryPath.setText( _translate("xia2_options", "Path/To/instrument_model.expt") ) self.import_reference_geometry_browse.setText( @@ -2875,10 +2871,10 @@ def retranslate_ui(self, xia2_options): ) ) - self.HP_ReferenceGeometry_path.setText( + self.hpReferenceGeometryPath.setText( _translate("xia2_options", "path/to/instrument_model.expt") ) - self.HP_ReferenceGeometry_browse.setText(_translate("xia2_options", "Browse")) + self.hpReferenceGeometryBrowse.setText(_translate("xia2_options", "Browse")) self.HP_gasket_checkBox.setText(_translate("xia2_options", "Gasket")) self.HP_gasket_checkBox.setStatusTip( _translate( From 0ada396fbbaeb8caa148ad47388c526434c7a8cf Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 25 Nov 2020 18:57:02 +0000 Subject: [PATCH 09/31] Add some more tool tips to the .ui design file Simplify the code by removing the corresponding hard-coded definitions. --- i19-gui/OptionsWindow.ui | 150 +++++-- i19-gui/chemical_crystallography_gui.py | 558 +----------------------- 2 files changed, 124 insertions(+), 584 deletions(-) diff --git a/i19-gui/OptionsWindow.ui b/i19-gui/OptionsWindow.ui index 738789a..5d5b8e0 100644 --- a/i19-gui/OptionsWindow.ui +++ b/i19-gui/OptionsWindow.ui @@ -6,16 +6,13 @@ 0 0 - 690 + 692 684 Options - Xia2 Additional Commands - - - @@ -34,6 +31,9 @@ + + Update the xia2 options with the current selection. + Update command @@ -41,6 +41,9 @@ + + Return to default settings. + Reset @@ -48,6 +51,9 @@ + + Save the current options. + Save settings @@ -55,6 +61,9 @@ + + Load saved options. + Load settings @@ -77,6 +86,9 @@ + + Use the beam centre listed in the image headers, do not refine the beam centre. + Trust beam centre @@ -84,6 +96,9 @@ + + Add a calibrated instrument model (/dls/i19-2/data/2020/visit/dataset/DataFiles/*.expt). + Reference geometry @@ -115,6 +130,9 @@ + + Override the detector distance. + Detector distance (mm) @@ -132,6 +150,9 @@ + + Override the beam centre from the image headers. + Beam centre @@ -179,6 +200,9 @@ + + Override the wavelength. + Wavelength (Å) @@ -192,20 +216,16 @@ - - - Fix instrument model - - - - + + Select which sweeps to process. + Run selection - + @@ -321,14 +341,17 @@ - + + + Use default parameters for small-molecule (chemical) or macromolecular crystallography. + Method - + @@ -355,7 +378,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + Threshold for a 'strong' pixel (number of standard deviations above local mean intensity). σ strong @@ -372,7 +395,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + The minimum number of contiguous pixels to be considered a spot. Min spot size @@ -389,7 +412,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + The maximum number of contiguous pixels to be considered a spot. Max spot size @@ -406,7 +429,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + The high resolution limit of the region to search for spots. d min (Å) @@ -423,7 +446,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + The low resolution limit of the region to search for spots. d max (Å) @@ -440,7 +463,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + Mask ice rings. Ice rings @@ -450,7 +473,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + Mask the powder rings from a known material (provide all three parameters). Powder rings @@ -500,7 +523,7 @@ - Width + Mask width @@ -518,7 +541,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + Mask annuli between the specified resolution limits. Resolution range @@ -602,7 +625,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + Mask a circular region on all images. Circle mask @@ -619,7 +642,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + Mask a rectangular region on all images. Rectangle mask @@ -642,6 +665,9 @@ + + Select indexing algorithm. + Method @@ -673,6 +699,9 @@ + + Known unit cell and space group (must provide both). + Unit cell and space group @@ -720,6 +749,9 @@ + + Minimum length of candidate unit cell basis vectors. + Minimium unit cell length (Å) @@ -734,6 +766,9 @@ + + Maximum length of candidate unit cell basis vectors. + Maximium unit cell length (Å) @@ -748,6 +783,9 @@ + + Index and process each run individually. + Multiple-sweep joint indexing @@ -755,6 +793,9 @@ + + Refine and process each run individually. + Multiple-sweep joint refinement @@ -762,6 +803,9 @@ + + Include all reflections from spot finding, including outliers in reciprocal space. + Include outliers @@ -788,6 +832,9 @@ + + Fix the instrument model for refinement. + Fix instrument model @@ -795,6 +842,9 @@ + + Set the minimum number of reflections deemed necessary for refinement. + Min number of reflections @@ -834,6 +884,9 @@ + + During refinement, allow the instrument model to vary throughout a sweep. + Scan varying @@ -856,8 +909,11 @@ + + Select the choice of scaling tool. + - Scaling method + Scaling tool @@ -877,6 +933,9 @@ + + Discard reflections beyond a maximum resolution cut-off, determined according to CC½ value. + Keep all reflections @@ -900,13 +959,19 @@ + + Correct for absorption in the anvils, and mask regions shadowed by the cell body. + - High pressure correction and dynamic shadowing + Diamond anvil cell correction + + During refinement, allow the instrument model to vary throughout a sweep. + Scan varying @@ -920,6 +985,9 @@ + + Add a calibrated instrument model (/dls/i19-2/data/2020/visit/dataset/DataFiles/*.expt). + Reference geometry @@ -948,6 +1016,9 @@ + + Mask the powder rings from a standard gasket. + Mask gasket rings @@ -969,6 +1040,9 @@ + + Mask the powder rings from a non-standard gasket material (provide all three parameters). + Gasket (user defined) @@ -1043,6 +1117,9 @@ + + Known unit cell and space group (must provide both). + Unit cell and space group @@ -1090,9 +1167,6 @@ - - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float - d min (Å) @@ -1108,7 +1182,7 @@ - Area above which the pixel will be classified as strong. The number of standard deviations above the mean in the local, float + Set the start:end images for each sweep. Run start/end @@ -1316,6 +1390,9 @@ + + Fix the instrument model for refinement. + Fix instrument model @@ -1331,7 +1408,7 @@ - Default = 2.1 + Default = 1.5925, to match the I19 in-house diamond anvil cell. @@ -1370,6 +1447,9 @@ + + If processing of a sweep fails, continue to process the others. + Failover @@ -1377,6 +1457,9 @@ + + Add other xia2 options not otherwise supported in this interface. + Manual input @@ -1387,6 +1470,9 @@ + + Select whether to perform the processing on the cluster or on the local machine. + Processing computer diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 015bec9..4f7372e 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -18,6 +18,8 @@ from PyQt5 import QtCore, QtGui, QtWidgets, uic +_translate = QtCore.QCoreApplication.translate + class UIMainWindow(QtWidgets.QMainWindow): def __init__(self, parent_window=None): @@ -1079,10 +1081,11 @@ def __init__( self.show() def browse_for_reference_model(self): - path = self.opening_visit - os.chdir(path) self.ref_geometry_path = QtWidgets.QFileDialog.getOpenFileName( - filter="expt(*.expt)" + parent=self, + filter=_translate( + "UIOptionsWindow", "DIALS experiment list files (*.expt)" + ), )[0] # qfd = QtWidgets.QFileDialog() # path = "D:\ennine\SIG HTB\BGN" @@ -2449,555 +2452,6 @@ def load_options_main(self, saved_options_path_txt): if line_split[0] == "RS": self.runSelectorList[int(line_split[1])].setChecked(True) - def retranslate_ui(self, xia2_options): - _translate = QtCore.QCoreApplication.translate - xia2_options.setWindowTitle( - _translate("xia2_options", "Options - Xia2 Additional Commands") - ) - - self.update_button.setText(_translate("xia2_options", "Update Command")) - self.update_button.setStatusTip( - _translate( - "xia2_options", "Update the xia2 command with the current selection" - ) - ) - self.reset_button.setText(_translate("xia2_options", "Reset")) - self.reset_button.setStatusTip( - _translate("xia2_options", "The rest button will uncheck all check boxes") - ) - self.save_button.setText(_translate("xia2_options", "Save")) - self.save_button.setStatusTip( - _translate("xia2_options", "Save the current options") - ) - self.load_button.setText(_translate("xia2_options", "Load")) - self.load_button.setStatusTip( - _translate("xia2_options", "Load a pre-saved option selection") - ) - - self.import_trust_beam_centre.setText( - _translate("xia2_options", "Trust beam centre") - ) - self.import_trust_beam_centre.setStatusTip( - _translate( - "xia2_options", "Trust the beam centre in the headers, do not refine" - ) - ) - self.import_dd.setText(_translate("xia2_options", "Detector Distance")) - self.import_dd.setStatusTip( - _translate( - "xia2_options", "Override the detector distance from the image header" - ) - ) - self.import_beam_centre.setText(_translate("xia2_options", "Beam Centre")) - self.import_beam_centre.setStatusTip( - _translate( - "xia2_options", "Override the beam centre from the image headers" - ) - ) - self.import_beam_centre_x_label.setText(_translate("xia2_options", "X")) - self.import_beam_centre_y_label.setText(_translate("xia2_options", "Y")) - self.import_reference_geometry.setText( - _translate("xia2_options", "Reference Geometry") - ) - self.import_reference_geometry.setStatusTip( - _translate( - "xia2_options", "Experimental geometry from the models selected (.expt)" - ) - ) - self.importReferenceGeometryPath.setText( - _translate("xia2_options", "Path/To/instrument_model.expt") - ) - self.import_reference_geometry_browse.setText( - _translate("xia2_options", "Browse") - ) - self.import_wavelengh.setText(_translate("xia2_options", "Wavelength")) - self.import_wavelengh.setStatusTip( - _translate("xia2_options", "Override the beam wavelength") - ) - self.import_fix_beam_detector_check_box.setText( - _translate("xia2_options", "Fix instrument model") - ) - self.import_run_selector_check_box.setText( - _translate("xia2_options", "Run Select") - ) - self.Import_RunSelector_checkBox_1.setText(_translate("xia2_options", "1")) - self.Import_RunSelector_checkBox_2.setText(_translate("xia2_options", "2")) - self.Import_RunSelector_checkBox_3.setText(_translate("xia2_options", "3")) - self.Import_RunSelector_checkBox_4.setText(_translate("xia2_options", "4")) - self.Import_RunSelector_checkBox_5.setText(_translate("xia2_options", "5")) - self.Import_RunSelector_checkBox_6.setText(_translate("xia2_options", "6")) - self.Import_RunSelector_checkBox_7.setText(_translate("xia2_options", "7")) - self.Import_RunSelector_checkBox_8.setText(_translate("xia2_options", "8")) - self.Import_RunSelector_checkBox_9.setText(_translate("xia2_options", "9")) - self.Import_RunSelector_checkBox_10.setText(_translate("xia2_options", "10")) - self.Import_RunSelector_checkBox_11.setText(_translate("xia2_options", "11")) - self.Import_RunSelector_checkBox_12.setText(_translate("xia2_options", "12")) - - self.Import_RunSelector_checkBox_13.setText(_translate("xia2_options", "13")) - self.Import_RunSelector_checkBox_14.setText(_translate("xia2_options", "14")) - self.Import_RunSelector_checkBox_15.setText(_translate("xia2_options", "15")) - self.Import_RunSelector_checkBox_16.setText(_translate("xia2_options", "16")) - self.Import_RunSelector_checkBox_17.setText(_translate("xia2_options", "17")) - self.Import_RunSelector_checkBox_18.setText(_translate("xia2_options", "18")) - self.Import_RunSelector_checkBox_19.setText(_translate("xia2_options", "19")) - self.Import_RunSelector_checkBox_20.setText(_translate("xia2_options", "20")) - self.Import_RunSelector_checkBox_21.setText(_translate("xia2_options", "21")) - self.Import_RunSelector_checkBox_22.setText(_translate("xia2_options", "22")) - self.Import_RunSelector_checkBox_23.setText(_translate("xia2_options", "23")) - self.Import_RunSelector_checkBox_24.setText(_translate("xia2_options", "24")) - - self.Import_RunSelector_checkBox_25.setText(_translate("xia2_options", "25")) - self.Import_RunSelector_checkBox_26.setText(_translate("xia2_options", "26")) - self.Import_RunSelector_checkBox_27.setText(_translate("xia2_options", "27")) - self.Import_RunSelector_checkBox_28.setText(_translate("xia2_options", "28")) - self.Import_RunSelector_checkBox_29.setText(_translate("xia2_options", "29")) - self.Import_RunSelector_checkBox_30.setText(_translate("xia2_options", "30")) - self.Import_RunSelector_checkBox_31.setText(_translate("xia2_options", "31")) - self.Import_RunSelector_checkBox_32.setText(_translate("xia2_options", "32")) - self.Import_RunSelector_checkBox_33.setText(_translate("xia2_options", "33")) - self.Import_RunSelector_checkBox_34.setText(_translate("xia2_options", "34")) - self.Import_RunSelector_checkBox_35.setText(_translate("xia2_options", "35")) - self.Import_RunSelector_checkBox_36.setText(_translate("xia2_options", "36")) - - self.Import_type_checkBox.setText(_translate("xia2_options", "method")) - self.Import_type_checkBox.setStatusTip( - _translate("xia2_options", "Different indexing algorithms for indexing.") - ) - self.Import_type_comboBox.setItemText(0, _translate("xia2_options", "Chemical")) - self.Import_type_comboBox.setItemText(1, _translate("xia2_options", "Protein")) - - self.xia2_options.setTabText( - self.xia2_options.indexOf(self.xia2_options_import), - _translate("xia2_options", "Import"), - ) - - self.findSpots_sigmaStrong.setStatusTip( - _translate( - "xia2_options", - "Area above which the pixel will be classified as strong.", - ) - ) - self.findSpots_sigmaStrong.setText(_translate("xia2_options", "sigma_strong")) - self.findSpots_minSpot.setStatusTip( - _translate( - "xia2_options", - "The minimum number of contiguous pixels " - "for a spot to be accepted by the filtering algorithm.", - ) - ) - self.findSpots_minSpot.setText(_translate("xia2_options", "min spot size")) - self.findSpots_maxSpot.setStatusTip( - _translate( - "xia2_options", - "The minimum number of contiguous pixels " - "for a spot to be accepted by the filtering algorithm.", - ) - ) - self.findSpots_maxSpot.setText(_translate("xia2_options", "max spot size")) - self.findSpots_dmin.setStatusTip( - _translate( - "xia2_options", - "The high resolution limit in Angstrom " - "for a pixel to be accepted by the filtering algorithm.", - ) - ) - self.findSpots_dmin.setText(_translate("xia2_options", "d min")) - self.findSpots_dmax.setStatusTip( - _translate( - "xia2_options", - "The low resolution limit in Angstrom " - "for a pixel to be accepted by the filtering algorithm.", - ) - ) - self.findSpots_dmax.setText(_translate("xia2_options", "d max")) - self.findSpots_iceRings.setStatusTip( - _translate("xia2_options", "Mask to remove spots from ice rings") - ) - self.findSpots_iceRings.setText(_translate("xia2_options", "ice rings")) - self.findSpots_powderRings.setStatusTip( - _translate( - "xia2_options", - "Generates a powder mask for given unit cell and space group input, " - "reflections under the mask will not be used", - ) - ) - self.findSpots_powderRings.setText(_translate("xia2_options", "powder rings")) - self.findSpots_powderRingsUC_label.setText( - _translate("xia2_options", "Unit Cell") - ) - self.findSpots_powderRingsSG_label.setText( - _translate("xia2_options", "Space Group") - ) - self.findSpots_powderRingsW_label.setText(_translate("xia2_options", "width")) - self.findSpots_resolutionRange.setStatusTip( - _translate( - "xia2_options", - "Generates a mask between the given resolutions, " - "reflections under with mask will not be used", - ) - ) - self.findSpots_resolutionRange.setText( - _translate("xia2_options", "resolution range") - ) - self.findSpots_circleMask.setStatusTip( - _translate( - "xia2_options", - "Generates a circular mask, " - "reflections under with mask will not be used", - ) - ) - self.findSpots_circleMask.setText(_translate("xia2_options", "Circle mask")) - self.findSpots_recMask.setStatusTip( - _translate( - "xia2_options", - "Generates a rectangle mask, " - "reflections under with mask will not be used", - ) - ) - self.findSpots_recMask.setText(_translate("xia2_options", "Rectangle mask")) - - self.Index_method_checkBox.setText(_translate("xia2_options", "method")) - self.Index_method_checkBox.setStatusTip( - _translate("xia2_options", "Different indexing algorithms for indexing.") - ) - self.Index_method_comboBox.setItemText(0, _translate("xia2_options", "fft1d")) - self.Index_method_comboBox.setItemText(1, _translate("xia2_options", "fft3d")) - self.Index_method_comboBox.setItemText( - 2, _translate("xia2_options", "real_space_grid_search") - ) - self.Index_method_comboBox.setItemText( - 3, _translate("xia2_options", "low_res_spot_match") - ) - self.Index_scanVarying_checkBox.setText( - _translate("xia2_options", "scan varying off") - ) - self.Index_scanVarying_checkBox.setStatusTip( - _translate("xia2_options", "Does not allows models to vary during a scan.") - ) - self.Index_UN_SG_checkBox.setText( - _translate("xia2_options", "Unit Cell and Space Group") - ) - self.Index_UN_SG_checkBox.setStatusTip( - _translate( - "xia2_options", - "User input of known unit cell and space group (must provide both).", - ) - ) - self.Index_UN_label.setText(_translate("xia2_options", "Unit Cell")) - self.Index_SG_label.setText(_translate("xia2_options", "Space Group")) - self.Index_minCell_checkBox.setText( - _translate("xia2_options", "minimum cell length") - ) - self.Index_minCell_checkBox.setStatusTip( - _translate("xia2_options", "Minimum unit cell volume (in Angstrom^3).") - ) - self.Index_maxCell_checkBox.setText( - _translate("xia2_options", "maximum cell length") - ) - self.Index_maxCell_checkBox.setStatusTip( - _translate( - "xia2_options", - "Maximum length of candidate unit cell basis vectors (in Angstrom).", - ) - ) - self.Index_multiprocessing_checkBox.setText( - _translate("xia2_options", "Multi sweep indexing") - ) - self.Index_multiprocessing_checkBox.setStatusTip( - _translate("xia2_options", "Index and process each run individually.") - ) - self.Index_multiSweepRefine_checkBox.setText( - _translate("xia2_options", "Multi sweep refine") - ) - self.Index_multiSweepRefine_checkBox.setStatusTip( - _translate("xia2_options", "Refine and process each run individually.") - ) - self.Index_outliers_checkBox.setText( - _translate("xia2_options", "Include outliers") - ) - self.Index_outliers_checkBox.setStatusTip( - _translate( - "xia2_options", "Included all spots from spot finding (no rejection)." - ) - ) - - self.Integrate_keepAllReflections_checkBox.setText( - _translate("xia2_options", "Keep all reflections") - ) - self.Integrate_keepAllReflections_checkBox.setStatusTip( - _translate( - "xia2_options", - "Will add a max resolution cutoff on individual runs based on cc-half.", - ) - ) - self.Integrate_scanVarying_checkBox.setText( - _translate("xia2_options", "Scan Varying Off") - ) - self.Integrate_scanVarying_checkBox.setStatusTip( - _translate("xia2_options", "Does not allows models to vary during a scan.") - ) - - self.Integrate_minSpotProfile_checkBox.setText( - _translate("xia2_options", "Min Spots profiles") - ) - self.Integrate_minSpotProfile_checkBox.setStatusTip( - _translate( - "xia2_options", - "The minimum number of spots needed to do the profile modelling", - ) - ) - - self.Integrate_minCellOverall_label.setText( - _translate("xia2_options", "Overall") - ) - self.Integrate_minCellOverall_label.setStatusTip( - _translate( - "xia2_options", - "The minimum total number of spots needed to make the profile model.", - ) - ) - self.Integrate_minCellDegree_label.setText( - _translate("xia2_options", "Per degree") - ) - self.Integrate_minCellDegree_label.setStatusTip( - _translate( - "xia2_options", - "The minimum number of spots needed per degree to make the profile " - "model.", - ) - ) - - self.Refine_FixBeamDetector_checkBox.setText( - _translate("xia2_options", "Fix instrument model") - ) - self.Refine_FixBeamDetector_checkBox.setStatusTip( - _translate( - "xia2_options", - "Will fix beam, detector and goniometer parameters during refinement.", - ) - ) - - self.Refine_method_checkBox.setText( - _translate("xia2_options", "scaling method") - ) - self.Refine_method_checkBox.setStatusTip( - _translate("xia2_options", "Algorithm used during scaling.") - ) - self.Refine_method_comboBox.setItemText(0, _translate("xia2_options", "dials")) - self.Refine_method_comboBox.setItemText( - 1, _translate("xia2_options", "dials-aimless") - ) - - self.Other_failover_checkBox.setText(_translate("xia2_options", "Failover")) - self.Other_failover_checkBox.setStatusTip( - _translate( - "xia2_options", - "Will proceed with processing even if a single scan fails.", - ) - ) - - self.Other_manualInput1_checkBox.setText( - _translate("xia2_options", "Manual Input 1") - ) - self.Other_manualInput1_checkBox.setStatusTip( - _translate("xia2_options", "Manual input of xia command.") - ) - self.Other_manualInput2_checkBox.setText( - _translate("xia2_options", "Manual Input 2") - ) - self.Other_manualInput2_checkBox.setStatusTip( - _translate("xia2_options", "Manual input of xia command.") - ) - self.Other_manualInput3_checkBox.setText( - _translate("xia2_options", "Manual Input 3") - ) - self.Other_manualInput3_checkBox.setStatusTip( - _translate("xia2_options", "Manual input of xia command.") - ) - self.Other_manualInput4_checkBox.setText( - _translate("xia2_options", "Manual Input 4") - ) - self.Other_manualInput4_checkBox.setStatusTip( - _translate("xia2_options", "Manual input of xia command.") - ) - - self.Other_clusterOrLocal_label.setText( - _translate("xia2_options", "Processing computer") - ) - self.Other_clusterOrLocal_label.setStatusTip( - _translate( - "xia2_options", "Pick if the processing is local or on a cluster node." - ) - ) - self.Other_clusterOrLocal_comboBox.setItemText( - 0, _translate("xia2_options", "Cluster") - ) - self.Other_clusterOrLocal_comboBox.setItemText( - 1, _translate("xia2_options", "Local") - ) - - self.ALL_plainTextEdit.setPlainText( - _translate( - "xia2_options", - "Plan to automatically generate a list of all options " - "from the xia2-working.phil file. ", - ) - ) - - self.HP_correction_shadowing_checkBox.setText( - _translate("xia2_options", "High pressure correction and dynamic shadowing") - ) - self.HP_correction_shadowing_checkBox.setStatusTip( - _translate( - "xia2_options", - "Select this option to mask part of the image shadowed by the cell " - "and apply correction for beam going through the diamond anvils.", - ) - ) - self.HP_scanVarying_checkBox.setText( - _translate("xia2_options", "Scan varying off") - ) - self.HP_scanVarying_checkBox.setStatusTip( - _translate("xia2_options", "Does not allows models to vary during a scan.") - ) - self.HP_ReferenceGeometry_checkBox.setText( - _translate("xia2_options", "Reference Geometry") - ) - self.HP_ReferenceGeometry_checkBox.setStatusTip( - _translate( - "xia2_options", - "Add starting instrument model from test crystal " - "(/dls/i19-2/data/2020/visit/dataset/DataFiles/*.expt).", - ) - ) - - self.hpReferenceGeometryPath.setText( - _translate("xia2_options", "path/to/instrument_model.expt") - ) - self.hpReferenceGeometryBrowse.setText(_translate("xia2_options", "Browse")) - self.HP_gasket_checkBox.setText(_translate("xia2_options", "Gasket")) - self.HP_gasket_checkBox.setStatusTip( - _translate( - "xia2_options", "Generate masks for powder rings from gasket material" - ) - ) - self.HP_gasket_comboBox.setItemText(0, _translate("xia2_options", "Tungsten")) - self.HP_gasket_comboBox.setItemText(1, _translate("xia2_options", "Steel")) - self.HP_gasket_comboBox.setStatusTip( - _translate("xia2_options", "Select gasket material") - ) - self.HP_gasketUser_checkBox.setText( - _translate("xia2_options", "Gasket (user defined)") - ) - self.HP_gasketUser_checkBox.setStatusTip( - _translate( - "xia2_options", - "Generate masks for powder rings from gasket, user defined material", - ) - ) - self.HP_gasketUserW_label.setText(_translate("xia2_options", "Width")) - self.HP_gasketUserSG_label.setText(_translate("xia2_options", "Space Group")) - self.HP_gasketUserUC_label.setText(_translate("xia2_options", "Unit Cell")) - self.HP_FixBeamDetector_checkBox.setText( - _translate("xia2_options", "Fix instrument model") - ) - self.HP_FixBeamDetector_checkBox.setStatusTip( - _translate( - "xia2_options", - "Will fix the beam and diffractometer variables during integration", - ) - ) - self.HP_dmin_checkBox.setStatusTip( - _translate( - "xia2_options", - "Area above which the pixel will be classified as strong. " - "The number of standard deviations above the mean in the local, float", - ) - ) - self.HP_dmin_checkBox.setText(_translate("xia2_options", "d min")) - self.HP_UN_label.setText(_translate("xia2_options", "Unit Cell")) - self.HP_UN_SG_checkBox.setText( - _translate("xia2_options", "Unit Cell and Space Group") - ) - self.HP_UN_SG_checkBox.setStatusTip( - _translate( - "xia2_options", - "User input of known unit cell and space group (must provide both).", - ) - ) - self.HP_SG_label.setText(_translate("xia2_options", "Space Group")) - self.HP_difficulty_label_2.setText( - _translate("xia2_options", "medium difficulty options") - ) - self.HP_difficulty_label_3.setText( - _translate("xia2_options", "problematic data options") - ) - self.HP_difficulty_label_1.setText( - _translate("xia2_options", "standard options") - ) - self.HP_runStartEnd_checkBox.setStatusTip( - _translate( - "xia2_options", - "Set the start/end images that each run will processed " - "(remove images with additional cell body powder rings)", - ) - ) - self.HP_runStartEnd_checkBox.setText( - _translate("xia2_options", "Run start/end") - ) - self.HP_runStartEnd_label_1.setText(_translate("xia2_options", "r1")) - self.HP_runStartEnd_label_2.setText(_translate("xia2_options", "r2")) - self.HP_runStartEnd_label_3.setText(_translate("xia2_options", "r4")) - self.HP_runStartEnd_label_4.setText(_translate("xia2_options", "r3")) - self.HP_runStartEnd_label_5.setText(_translate("xia2_options", "r5")) - self.HP_runStartEnd_label_7.setText(_translate("xia2_options", "r7")) - self.HP_runStartEnd_label_6.setText(_translate("xia2_options", "r6")) - self.HP_runStartEnd_label_8.setText(_translate("xia2_options", "r8")) - self.HP_runStartEnd_label_9.setText(_translate("xia2_options", "r9")) - self.HP_runStartEnd_label_10.setText(_translate("xia2_options", "r10")) - - self.HP_anvilThickness_checkBox.setText( - _translate("xia2_options", "Anvil Thickness") - ) - self.HP_anvilThickness_checkBox.setStatusTip( - _translate("xia2_options", "Set DAC anvil thickness. Default: 1.5925 mm") - ) - self.HP_anvilOpeningAngle_checkBox.setText( - _translate("xia2_options", "Anvil Opening Angle") - ) - self.HP_anvilOpeningAngle_checkBox.setStatusTip( - _translate("xia2_options", "Set DAC anvil thickness. Default: 40 deg") - ) - - self.xia2_options.setTabText( - self.xia2_options.indexOf(self.xia2options_SpotFinding), - _translate("xia2_options", "Spot Finding"), - ) - self.xia2_options.setTabText( - self.xia2_options.indexOf(self.xia2options_Indexing), - _translate("xia2_options", "Indexing"), - ) - self.xia2_options.setTabText( - self.xia2_options.indexOf(self.xia2options_integrate), - _translate("xia2_options", "Integrate"), - ) - self.xia2_options.setTabText( - self.xia2_options.indexOf(self.xia2options_refine_scale), - _translate("xia2_options", "Refine/Scale"), - ) - self.xia2_options.setTabText( - self.xia2_options.indexOf(self.xia2options_Other), - _translate("xia2_options", "Other"), - ) - self.xia2_options.setTabText( - self.xia2_options.indexOf(self.xia2options_ALL), - _translate("xia2_options", "ALL"), - ) - self.xia2_options.setTabText( - self.xia2_options.indexOf(self.xia2options_HP), - _translate("xia2_options", "HP"), - ) - if __name__ == "__main__": # We must assign the QApplication and MainWindow instances to variables to From d855070231322bd92acdedd84c9322fe56fc1d26 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Thu, 26 Nov 2020 18:35:09 +0000 Subject: [PATCH 10/31] Slightly improve appearance of textEdit and labels --- i19-gui/OptionsWindow.ui | 83 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/i19-gui/OptionsWindow.ui b/i19-gui/OptionsWindow.ui index 5d5b8e0..4b27b3e 100644 --- a/i19-gui/OptionsWindow.ui +++ b/i19-gui/OptionsWindow.ui @@ -7,7 +7,7 @@ 0 0 692 - 684 + 676 @@ -118,6 +118,9 @@ true + + false + true @@ -167,6 +170,9 @@ X + + true + @@ -185,6 +191,9 @@ Y + + true + @@ -489,6 +498,9 @@ Unit cell + + true + @@ -507,6 +519,9 @@ Space group + + true + @@ -525,6 +540,9 @@ Mask width + + true + @@ -716,6 +734,9 @@ Unit Cell + + true + @@ -734,6 +755,9 @@ Space Group + + true + @@ -859,6 +883,9 @@ Overall + + true + @@ -873,6 +900,9 @@ Per degree + + true + @@ -1004,6 +1034,9 @@ + + true + true @@ -1057,6 +1090,9 @@ Unit cell + + true + @@ -1075,6 +1111,9 @@ Space group + + true + @@ -1093,6 +1132,9 @@ Width + + true + @@ -1134,6 +1176,9 @@ Unit cell + + true + @@ -1152,6 +1197,9 @@ Space group + + true + @@ -1198,6 +1246,9 @@ r1 + + true + @@ -1216,6 +1267,9 @@ r2 + + true + @@ -1234,6 +1288,9 @@ r3 + + true + @@ -1252,6 +1309,9 @@ r4 + + true + @@ -1270,6 +1330,9 @@ r5 + + true + @@ -1288,6 +1351,9 @@ r6 + + true + @@ -1306,6 +1372,9 @@ r7 + + true + @@ -1324,6 +1393,9 @@ r8 + + true + @@ -1342,6 +1414,9 @@ r9 + + true + @@ -1360,6 +1435,9 @@ r10 + + true + @@ -1476,6 +1554,9 @@ Processing computer + + true + From bc61ff52e5474260310d701df1c8b7627613e92b Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Thu, 26 Nov 2020 18:38:38 +0000 Subject: [PATCH 11/31] Improve selection of reference instrument model Add a caption to the dialogue widget and the filter selector. Default to the location of any previously selected instrument model file. Don't unset the reference instrument model file selection if the dialogue widget is cancelled. Remove redundant setScaledContents calls. --- i19-gui/chemical_crystallography_gui.py | 44 ++++++++++--------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 4f7372e..3dae242 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -10,6 +10,7 @@ import fnmatch import glob import os +import pathlib import subprocess import sys from datetime import datetime @@ -1026,12 +1027,6 @@ def run(self): self.finished.emit() -######################################################################################## -######################################################################################## -######################################################################################## -######################################################################################## - - class UIOptionsWindow(QtWidgets.QMainWindow): def __init__( self, @@ -1081,34 +1076,29 @@ def __init__( self.show() def browse_for_reference_model(self): - self.ref_geometry_path = QtWidgets.QFileDialog.getOpenFileName( + ref_geometry_path = self.ref_geometry_path or self.opening_visit + f_filter = _translate("UIOptionsWindow", "DIALS experiment list files (*.expt)") + ref_geometry_path, _filter = QtWidgets.QFileDialog.getOpenFileName( parent=self, - filter=_translate( - "UIOptionsWindow", "DIALS experiment list files (*.expt)" - ), - )[0] - # qfd = QtWidgets.QFileDialog() - # path = "D:\ennine\SIG HTB\BGN" - # filter = "csv(*.csv)" - # f = QtWidgets.QFileDialog.getOpenFileName(qfd, title, path, filter) - if self.ref_geometry_path: - ref_geometry_path_txt = str(self.ref_geometry_path) - ref_geometry_file_txt = ref_geometry_path_txt.split("/")[-1] + caption="Select calibrated instrument model", + directory=ref_geometry_path, + filter=f_filter, + ) + if ref_geometry_path: + self.ref_geometry_path = ref_geometry_path + ref_geometry_path = pathlib.Path(ref_geometry_path) output_message = ( - "Reference Geometry Path:\n " - + str(ref_geometry_path_txt) - + "\nReference Geometry File:\n " - + str(ref_geometry_file_txt) + "Reference Geometry Path:\n" + f"\t{ref_geometry_path.parent}\n" + "Reference Geometry File:\n" + f"\t{ref_geometry_path.name}" ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - self.importReferenceGeometryPath.setText(ref_geometry_file_txt) - self.importReferenceGeometryPath.setScaledContents(True) - - self.hpReferenceGeometryPath.setText(ref_geometry_file_txt) - self.hpReferenceGeometryPath.setScaledContents(True) + self.importReferenceGeometryPath.setText(ref_geometry_path.name) + self.hpReferenceGeometryPath.setText(ref_geometry_path.name) def update_options(self): options = "" From e40668261c932f41e24103d99a8a4bbdfe4d9a89 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Fri, 27 Nov 2020 18:10:23 +0000 Subject: [PATCH 12/31] =?UTF-8?q?Link=20duplicate=20widgets=20with=20signa?= =?UTF-8?q?ls=20=E2=86=92=20slots?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove a setText from UIOptionsWindow.browse_for_reference_model because it is now redundant. Also tidy up the wording of some widget labels. --- i19-gui/OptionsWindow.ui | 283 ++++++++++++++++++++++-- i19-gui/chemical_crystallography_gui.py | 1 - 2 files changed, 268 insertions(+), 16 deletions(-) diff --git a/i19-gui/OptionsWindow.ui b/i19-gui/OptionsWindow.ui index 4b27b3e..7537b8e 100644 --- a/i19-gui/OptionsWindow.ui +++ b/i19-gui/OptionsWindow.ui @@ -97,7 +97,7 @@ - Add a calibrated instrument model (/dls/i19-2/data/2020/visit/dataset/DataFiles/*.expt). + Use a calibrated instrument model (<visit-directory>/processed/dataset/DataFiles/*.expt). Reference geometry @@ -761,7 +761,7 @@ - + e.g. P21/c @@ -915,13 +915,10 @@ - During refinement, allow the instrument model to vary throughout a sweep. + During refinement, do not allow the instrument model to vary throughout a sweep. - Scan varying - - - true + Only perform scan-static refinement false @@ -1000,13 +997,10 @@ - During refinement, allow the instrument model to vary throughout a sweep. + During refinement, do not allow the instrument model to vary throughout a sweep. - Scan varying - - - true + Only perform scan-static refinement false @@ -1016,7 +1010,7 @@ - Add a calibrated instrument model (/dls/i19-2/data/2020/visit/dataset/DataFiles/*.expt). + Use a calibrated instrument model (<visit-directory>/processed/dataset/DataFiles/*.expt). Reference geometry @@ -1154,7 +1148,7 @@ - Options for medium difficulty data + Options for moderately difficult data @@ -1203,7 +1197,7 @@ - + e.g. Im-3m @@ -1215,6 +1209,9 @@ + + The high resolution limit of the region to search for spots. + d min (Å) @@ -1635,5 +1632,261 @@ + + findSpots_dmin + toggled(bool) + HP_dmin_checkBox + setChecked(bool) + + + 63 + 185 + + + 75 + 406 + + + + + HP_dmin_checkBox + toggled(bool) + findSpots_dmin + setChecked(bool) + + + 75 + 406 + + + 63 + 185 + + + + + findSpots_dmin_lineEdit + textChanged(QString) + HP_dmin_lineEdit + setText(QString) + + + 419 + 186 + + + 446 + 407 + + + + + HP_dmin_lineEdit + textChanged(QString) + findSpots_dmin_lineEdit + setText(QString) + + + 446 + 407 + + + 419 + 186 + + + + + import_ReferenceGeometry + toggled(bool) + HP_ReferenceGeometry_checkBox + setChecked(bool) + + + 104 + 121 + + + 116 + 182 + + + + + HP_ReferenceGeometry_checkBox + toggled(bool) + import_ReferenceGeometry + setChecked(bool) + + + 116 + 182 + + + 104 + 121 + + + + + importReferenceGeometryPath + textChanged(QString) + hpReferenceGeometryPath + setText(QString) + + + 484 + 123 + + + 528 + 184 + + + + + hpReferenceGeometryPath + textChanged(QString) + importReferenceGeometryPath + setText(QString) + + + 528 + 184 + + + 484 + 123 + + + + + Index_UN_SG_checkBox + toggled(bool) + HP_UN_SG_checkBox + setChecked(bool) + + + 118 + 123 + + + 130 + 348 + + + + + HP_UN_SG_checkBox + toggled(bool) + Index_UN_SG_checkBox + setChecked(bool) + + + 130 + 348 + + + 118 + 123 + + + + + Index_SG_lineEdit + textChanged(QString) + HP_SG_lineEdit + setText(QString) + + + 572 + 149 + + + 553 + 374 + + + + + HP_SG_lineEdit + textChanged(QString) + Index_SG_lineEdit + setText(QString) + + + 553 + 374 + + + 572 + 149 + + + + + Index_UN_lineEdit + textChanged(QString) + HP_UN_lineEdit + setText(QString) + + + 370 + 149 + + + 339 + 374 + + + + + HP_UN_lineEdit + textChanged(QString) + Index_UN_lineEdit + setText(QString) + + + 339 + 374 + + + 370 + 149 + + + + + Refine_FixBeamDetector_checkBox_2 + toggled(bool) + HP_FixBeamDetector_checkBox + setChecked(bool) + + + 117 + 124 + + + 117 + 555 + + + + + HP_FixBeamDetector_checkBox + toggled(bool) + Refine_FixBeamDetector_checkBox_2 + setChecked(bool) + + + 117 + 555 + + + 117 + 124 + + + diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 3dae242..8d4c263 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -1098,7 +1098,6 @@ def browse_for_reference_model(self): self.log_output_txt.moveCursor(QtGui.QTextCursor.End) self.importReferenceGeometryPath.setText(ref_geometry_path.name) - self.hpReferenceGeometryPath.setText(ref_geometry_path.name) def update_options(self): options = "" From 861fd33124f45e91163055a52685d2ca03de1ef6 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Fri, 27 Nov 2020 18:29:19 +0000 Subject: [PATCH 13/31] Remove redundant import Thanks LGTM! --- i19-gui/chemical_crystallography_gui.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 8d4c263..347888b 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -10,7 +10,6 @@ import fnmatch import glob import os -import pathlib import subprocess import sys from datetime import datetime @@ -1086,7 +1085,7 @@ def browse_for_reference_model(self): ) if ref_geometry_path: self.ref_geometry_path = ref_geometry_path - ref_geometry_path = pathlib.Path(ref_geometry_path) + ref_geometry_path = Path(ref_geometry_path) output_message = ( "Reference Geometry Path:\n" From fbe90d7993e2cffb0b25d6cba7093bce1a5f4b06 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Sat, 28 Nov 2020 18:04:42 +0000 Subject: [PATCH 14/31] Remove unused parameter --- i19-gui/chemical_crystallography_gui.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 347888b..90e2665 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -294,7 +294,6 @@ def open_options(self): options_window = UIOptionsWindow( self.xia2_command, self.dataset_path, - self.command_command, self.visit, self.logOutputTxt, self.run_list, @@ -1031,7 +1030,6 @@ def __init__( self, xia2_command, dataset_path, - command_command, visit, log_output_txt, run_list, @@ -1042,7 +1040,6 @@ def __init__( self.xia2_command = xia2_command self.dataset_path = dataset_path self.run_list = run_list - self.command_command = command_command self.ref_geometry_path = "" self.visit = visit self.log_output_txt = log_output_txt From 638d17cc283a28e3b71aaaedc9086a7beb8d39a2 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Sat, 28 Nov 2020 18:28:31 +0000 Subject: [PATCH 15/31] Simplify the tab closing behaviour Also correct some usages of a renamed attribute. --- i19-gui/chemical_crystallography_gui.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 90e2665..79a6890 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -114,7 +114,7 @@ def __init__(self, parent_window=None): right_delete_button.deleteLater() tab_bar.setTabButton(log_output, tab_bar.LeftSide, None) tab_bar.setTabButton(log_output, tab_bar.RightSide, None) - self.outputTabs.tabCloseRequested.connect(self.close_handler) + self.outputTabs.tabCloseRequested.connect(self.outputTabs.removeTab) self.show() @@ -469,9 +469,9 @@ def run_xia2_dataset(self, input_dataset, xia2_input): # prefix # visit # datas lambda: self.run_dials_html(tab_num) ) - self.output_tabs.addTab(self.tabs[self.tabs_num], "") - self.output_tabs.setTabText( - self.output_tabs.indexOf(self.tabs[self.tabs_num]), + self.outputTabs.addTab(self.tabs[self.tabs_num], "") + self.outputTabs.setTabText( + self.outputTabs.indexOf(self.tabs[self.tabs_num]), input_dataset + "_" + time_date, ) @@ -638,9 +638,9 @@ def run_screen19(self): lambda: self.run_dials_html(tab_num) ) - self.output_tabs.addTab(self.tabs[self.tabs_num], "") - self.output_tabs.setTabText( - self.output_tabs.indexOf(self.tabs[self.tabs_num]), + self.outputTabs.addTab(self.tabs[self.tabs_num], "") + self.outputTabs.setTabText( + self.outputTabs.indexOf(self.tabs[self.tabs_num]), self.dataset + "_s19_" + time_date, ) @@ -952,13 +952,6 @@ def version_2_1(self): self.menu_version.setTitle("Version(" + dial_version_pop + ")") self.append_output(self.logOutputTxt, " Version(" + dial_version_pop + ")") - # close tabs ###### - def close_handler(self, index): - self.append_output( - self.logOutputTxt, "close_handler called, index = %s" % index - ) - self.output_tabs.removeTab(index) - class MyThread2(QtCore.QThread): # finished = pyqtSignal(object) From 9b4c493747821ca2b8f3d8c5374b0a270dd85495 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Mon, 30 Nov 2020 10:28:01 +0000 Subject: [PATCH 16/31] Correct some typos and rationalise capitalisation --- i19-gui/chemical_crystallography_gui.py | 46 ++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 79a6890..02fb243 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -700,13 +700,13 @@ def run_screen19(self): self.tabs_num = 0 def thread_started(self): - self.append_output(self.logOutputTxt, "\n*** Thread Started ***\n") + self.append_output(self.logOutputTxt, "\n*** Thread started ***\n") def thread_finished(self): - self.append_output(self.logOutputTxt, "\n*** Thread Finished ***\n") + self.append_output(self.logOutputTxt, "\n*** Thread finished ***\n") def stop_thread(self): - self.append_output(self.logOutputTxt, "\n*** Stopping Thead ***\n") + self.append_output(self.logOutputTxt, "\n*** Stopping thread ***\n") # self.MyThread2.stop() # self.MyThread2.quit() @@ -1099,7 +1099,7 @@ def update_options(self): if variable == self.import_reference_geometry: if self.ref_geometry_path == "": output_message = ( - " *** Reference Geometry Error. Please select " + " *** Reference geometry error. Please select " ".expt file with browse button first ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1134,13 +1134,13 @@ def update_options(self): if variable == self.import_beam_centre: if self.import_beam_centre_x_line_edit.text() == "": - output_message = " *** Beam Centre Error. Please input Y" + output_message = " *** Beam centre error. Please input Y" self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return elif self.import_beam_centre_y_line_edit.text() == "": output_message = ( - " *** Detector Distance Error. Please input X" + " *** Detector distance error. Please input X" ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) @@ -1165,7 +1165,7 @@ def update_options(self): if variable == self.import_wavelengh: if self.import_wavelength_line_edit.text() == "": output_message = ( - " *** Wavelength Input Error. " + " *** Wavelength input error. " "Please add wavelength e.g. 85.01" ) self.log_output_txt.appendPlainText(output_message) @@ -1211,7 +1211,7 @@ def update_options(self): if variable == self.findSpots_sigmaStrong: if self.findSpots_sigmaStrong_lineEdit.text() == "": output_message = ( - " *** Sigma Strong Error." + " *** Sigma strong error." " Please enter sigma strong e.g. 6 ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1226,8 +1226,8 @@ def update_options(self): if variable == self.findSpots_minSpot: if self.findSpots_minSpot_lineEdit.text() == "": output_message = ( - " *** Min Spot Size Error, " - "please entre min spots size e.g. 2 ***" + " *** Min spot size error, " + "please enter min spots size e.g. 2 ***" ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) @@ -1241,8 +1241,8 @@ def update_options(self): if variable == self.findSpots_maxSpot: if self.findSpots_maxSpot_lineEdit.text() == "": output_message = ( - " *** Max Spot Size Error, " - "please entre max spots size e.g. 2 ***" + " *** Max spot size error, " + "please enter max spots size e.g. 2 ***" ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) @@ -1256,7 +1256,7 @@ def update_options(self): if variable == self.findSpots_dmin: if self.findSpots_dmin_lineEdit.text() == "": output_message = ( - " *** D_min Error, please entre d_min e.g. 0.84 ***" + " *** d_min error, please enter d_min e.g. 0.84 ***" ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) @@ -1270,7 +1270,7 @@ def update_options(self): if variable == self.findSpots_dmax: if self.findSpots_dmax_lineEdit.text() == "": output_message = ( - " *** D_max Error, please entre d_max e.g. 10 ***" + " *** d_max error, please enter d_max e.g. 10 ***" ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) @@ -1333,7 +1333,7 @@ def update_options(self): if variable == self.findSpots_circleMask: if self.findSpots_circleMask_lineEdit.text() == "": output_message = ( - " *** Circle Mask Error, please entre is the " + " *** Circle mask error, please enter in the " "following format: xc,yc,r ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1349,7 +1349,7 @@ def update_options(self): if variable == self.findSpots_recMask: if self.findSpots_recMask_lineEdit.text() == "": output_message = ( - " *** Rectangle Mask Error, please entre is " + " *** Rectangle mask error, please enter is " "the following format: x0,x1,y0,y1 ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1393,7 +1393,7 @@ def update_options(self): options = options + uc_command + sg_command if variable == self.Index_minCell_checkBox: if self.Index_minCell_lineEdit.text() == "": - output_message = " *** Please entre valid min cell ***" + output_message = " *** Please enter valid min cell ***" self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return @@ -1405,7 +1405,7 @@ def update_options(self): ) if variable == self.Index_maxCell_checkBox: if self.Index_maxCell_lineEdit.text() == "": - output_message = " *** Please entre valid max cell ***" + output_message = " *** Please enter valid max cell ***" self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return @@ -1444,7 +1444,7 @@ def update_options(self): return if self.visit == "": output_message = ( - " *** For this option a .phil need to be created, " + " *** For this option a .phil needs to be created, " "this requires a the visit to be known." " Please open a dataset and retry (File>Open). ***" ) @@ -1524,7 +1524,7 @@ def update_options(self): if variable == self.HP_ReferenceGeometry_checkBox: if self.ref_geometry_path == "": output_message = ( - " *** Reference Geometry Error. " + " *** Reference geometry error. " "Please select .expt file with browse button first ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1605,7 +1605,7 @@ def update_options(self): if variable == self.HP_dmin_checkBox: if self.HP_dmin_lineEdit.text() == "": output_message = ( - " *** D_min HP Error, please entre d_min e.g. 0.84 ***" + " *** d_min HP error, please enter d_min e.g. 0.84 ***" ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) @@ -1656,7 +1656,7 @@ def update_options(self): if variable == self.HP_anvilThickness_checkBox: if self.HP_anvilThickness_lineEdit.text() == "": output_message = ( - " *** Anvil Thickness Input Error, " + " *** Anvil thickness input error, " "please enter thickness e.g. 2.1 ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1672,7 +1672,7 @@ def update_options(self): if variable == self.HP_anvilOpeningAngle_checkBox: if self.HP_anvilOpeningAngle_lineEdit.text() == "": output_message = ( - " *** Anvil Opening Angle Input Error, " + " *** Anvil opening angle input error, " "please enter opening angle e.g. 38 ***" ) self.log_output_txt.appendPlainText(output_message) From f25dca9c6ac60e0f0acd9db120ed39c893d7492e Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 2 Dec 2020 16:54:07 +0000 Subject: [PATCH 17/31] Simplify logic for saving and loading xia2 options Serialise saved options to a JSON file. Options to be saved are determined by searching all the attributes of a UIOptionsWindow instance. If the type of an attribute matches a list of recognised user-input widget types, then we record the value of a specific pre-determined property of each widget. For now, the recognised user-input widget types are QCheckBox, QComboBox and QLineEdit, with the corresponding properties 'checked', 'currentIndex' and 'text' recorded. --- i19-gui/chemical_crystallography_gui.py | 807 ++++-------------------- 1 file changed, 115 insertions(+), 692 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 02fb243..0ab32a4 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -9,17 +9,35 @@ import fnmatch import glob +import json import os import subprocess import sys from datetime import datetime from pathlib import Path from time import sleep +from typing import Dict, Type, Union from PyQt5 import QtCore, QtGui, QtWidgets, uic +OptionWidgetDict = Dict[Type[QtWidgets.QWidget], str] +OptionValues = Dict[str, Union[bool, int, str]] _translate = QtCore.QCoreApplication.translate +# Dictionary of the key property name (in the Qt sense, i.e. the attribute name in +# Python terms) for each type of user option widget. +# Any children of a UIOptionsWindow instance that are of a type listed here will be +# considered user-defined settings. The values of each of the named properties will +# be serialised and de-serialised to (auto-)save or (auto-)load them, or to remember +# and reset default values. +option_widgets: OptionWidgetDict = { + QtWidgets.QCheckBox: "checked", + QtWidgets.QComboBox: "currentIndex", + QtWidgets.QLineEdit: "text", +} + +auto_save_filename = "processing/.i19.gui.autosave.json" + class UIMainWindow(QtWidgets.QMainWindow): def __init__(self, parent_window=None): @@ -1041,29 +1059,53 @@ def __init__( self.image_selection = {} self.prefix = prefix self.opening_visit = opening_visit + self.saved_options_path = None super().__init__(parent_window) uic.loadUi(Path(__file__).parent / "OptionsWindow.ui", self) + # Get all the widgets that record user-specified options. + # This approach is about ten times faster than the findChildren method. + self._option_widgets = { + name: attribute + for name, attribute in self.__dict__.items() + if type(attribute) in option_widgets + } + + self.default_options = self.options + + self.load_options_auto() + + # Connect buttons to methods. self.updateButton.clicked.connect(self.update_options) self.resetButton.clicked.connect(self.reset_options) - self.saveButton.clicked.connect(self.save_options) - self.loadButton.clicked.connect(self.load_options) + self.saveButton.clicked.connect(self.save_options_manually) + self.loadButton.clicked.connect(self.load_options_manually) + for reference_geometry_button in ( + self.importReferenceGeometryBrowse, + self.hpReferenceGeometryBrowse, + ): + reference_geometry_button.clicked.connect(self.browse_for_reference_model) - # TODO: Connect duplicate widgets like the reference geometry file selection. - self.importReferenceGeometryBrowse.clicked.connect( - self.browse_for_reference_model - ) - self.hpReferenceGeometryBrowse.clicked.connect(self.browse_for_reference_model) # TODO: Dynamically create a checkbox for each sweep found. - # TODO: Make proper use of connectSlotsByName - QtCore.QMetaObject.connectSlotsByName(self) - - # load previous settings: - self.load_options_auto() self.show() + @property + def options(self): + return { + name: widget.property(option_widgets[type(widget)]) + for name, widget in self._option_widgets.items() + } + + @options.setter + def options(self, new_values: OptionValues): + for name, widget in self._option_widgets.items(): + value = new_values.get(name) + if value is not None: + property_name = option_widgets[type(widget)] + widget.setProperty(property_name, value) + def browse_for_reference_model(self): ref_geometry_path = self.ref_geometry_path or self.opening_visit f_filter = _translate("UIOptionsWindow", "DIALS experiment list files (*.expt)") @@ -1088,6 +1130,67 @@ def browse_for_reference_model(self): self.importReferenceGeometryPath.setText(ref_geometry_path.name) + def reset_options(self): + self.options = self.default_options + + def save_options_manually(self): + path = self.saved_options_path or self.opening_visit + option_file, _ = QtWidgets.QFileDialog.getSaveFileName( + parent=self, + caption=self.tr("Choose a location for the saved settings"), + directory=path, + filter=self.tr("JSON files (*.json)"), + ) + if option_file: + self.saved_options_path = option_file + self.save_options(Path(option_file)) + + def save_options_auto(self): + if self.visit: + self.save_options(Path(self.visit) / auto_save_filename) + + def save_options(self, saved_options_path): + output_message = self.tr(f"\n\tSaving settings to {saved_options_path}.") + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + with open(saved_options_path, "w") as f: + json.dump(self.options, f) + + def load_options_manually(self): + path = self.saved_options_path or self.opening_visit + options_file, _ = QtWidgets.QFileDialog.getOpenFileName( + parent=self, + caption=self.tr("Choose a file containing saved settings"), + directory=path, + filter=self.tr("JSON files (*.json)"), + ) + if options_file: + self.saved_options_path = options_file + self.load_options(Path(options_file)) + + def load_options_auto(self): + saved_options_path = Path(self.visit) / auto_save_filename + if not self.visit: + output_message = self.tr( + "\nSince you have not selected a visit or dataset, " + "any previously auto-saved xia2 settings won't be loaded " + "and your new settings cannot be auto-saved.\n" + "If you have previously saved some settings and wish to load them, " + "press the 'Load settings' button.\n" + "You can also save your settings with the 'Save settings' button." + ) + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + elif saved_options_path.is_file(): + self.load_options(saved_options_path) + + def load_options(self, saved_options_path: Path): + output_message = self.tr(f"\n\tLoading settings from {saved_options_path}.") + self.log_output_txt.appendPlainText(output_message) + self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + with open(saved_options_path) as f: + self.options = json.load(f) + def update_options(self): options = "" @@ -1750,686 +1853,6 @@ def update_options(self): self.save_options_auto() - def reset_options(self): - output_message = "\nResetting options" - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - - for checkboxes in self.optionListImport: - checkboxes.setChecked(False) - for checkboxes in self.optionListSpotFinding: - checkboxes.setChecked(False) - for checkboxes in self.optionListIndexing: - checkboxes.setChecked(False) - for checkboxes in self.optionListIntegrate: - checkboxes.setChecked(False) - for checkboxes in self.optionListRefineScale: - checkboxes.setChecked(False) - for checkboxes in self.optionListOther: - checkboxes.setChecked(False) - for checkboxes in self.optionListHP: - checkboxes.setChecked(False) - for checkboxes in self.runSelectorList: - checkboxes.setChecked(False) - self.Import_type_checkBox.setChecked(True) - self.run_image_selector = False - self.run_selection = [] - self.image_selection = {} - - if self.visit == "": - return - if os.path.isfile(self.visit + "processing/autoSaveOptions.txt"): - option_file = self.visit + "processing/autoSaveOptions.txt" - with open(option_file, "w"): - pass - - options = "" - - options_update_text = ( - "\n\nUpdating options" - + "\n Xia2 command: " - + "\n " - + self.xia2_command - + self.dataset_path - + options - ) - self.log_output_txt.appendPlainText(options_update_text) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - - ui_main_window = self.parent() - ui_main_window.xia2_command = self.xia2_command - ui_main_window.dataset_path = self.dataset_path - ui_main_window.xia2_options_list = options - ui_main_window.update_options() - - def option_file_text_function(self): - option_file_text = "" - for num, checkboxes in enumerate(self.optionListImport): - if checkboxes.isChecked(): - if num == 1: - option_file_text = ( - option_file_text - + "I " - + str(num) - + " " - + str(self.ref_geometry_path) - + "\n" - ) - elif num == 2: - option_file_text = ( - option_file_text - + "I " - + str(num) - + " " - + str(self.import_dd_line_edit.text()) - + "\n" - ) - elif num == 3: - option_file_text = ( - option_file_text - + "I " - + str(num) - + " " - + str(self.import_beam_centre_x_line_edit.text()) - + " " - + str(self.import_beam_centre_y_line_edit.text()) - + "\n" - ) - elif num == 4: - option_file_text = ( - option_file_text - + "I " - + str(num) - + " " - + str(self.import_wavelength_line_edit.text()) - + "\n" - ) - elif num == 7: - option_file_text = ( - option_file_text - + "I " - + str(num) - + " " - + str(self.Import_type_comboBox.currentIndex()) - + "\n" - ) - else: - option_file_text = option_file_text + "I " + str(num) + "\n" - for num, checkboxes in enumerate(self.runSelectorList): - if checkboxes.isChecked(): - option_file_text = option_file_text + "RS " + str(num) + "\n" - # spot finding - for num, checkboxes in enumerate(self.optionListSpotFinding): - if checkboxes.isChecked(): - if num == 0: - option_file_text = ( - option_file_text - + "SF " - + str(num) - + " " - + str(self.findSpots_sigmaStrong_lineEdit.text()) - + "\n" - ) - elif num == 1: - option_file_text = ( - option_file_text - + "SF " - + str(num) - + " " - + str(self.findSpots_minSpot_lineEdit.text()) - + "\n" - ) - elif num == 2: - option_file_text = ( - option_file_text - + "SF " - + str(num) - + " " - + str(self.findSpots_maxSpot_lineEdit.text()) - + "\n" - ) - elif num == 3: - option_file_text = ( - option_file_text - + "SF " - + str(num) - + " " - + str(self.findSpots_dmin_lineEdit.text()) - + "\n" - ) - elif num == 4: - option_file_text = ( - option_file_text - + "SF " - + str(num) - + " " - + str(self.findSpots_dmax_lineEdit.text()) - + "\n" - ) - elif num == 6: - option_file_text = ( - option_file_text - + "SF " - + str(num) - + " " - + str(self.findSpots_powderRingsUC_lineEdit.text()) - + " " - + str(self.findSpots_powderRingsSG_lineEdit.text()) - + " " - + str(self.findSpots_powderRingsW_lineEdit.text()) - + "\n" - ) - elif num == 7: - - find_spot_res_range_list = [ - self.findSpots_resolutionRange_lineEdit_1.text(), - self.findSpots_resolutionRange_lineEdit_2.text(), - self.findSpots_resolutionRange_lineEdit_3.text(), - self.findSpots_resolutionRange_lineEdit_4.text(), - self.findSpots_resolutionRange_lineEdit_5.text(), - self.findSpots_resolutionRange_lineEdit_6.text(), - self.findSpots_resolutionRange_lineEdit_7.text(), - self.findSpots_resolutionRange_lineEdit_8.text(), - self.findSpots_resolutionRange_lineEdit_9.text(), - self.findSpots_resolutionRange_lineEdit_10.text(), - ] - option_file_text = option_file_text + "SF " + str(num) - for res_range in find_spot_res_range_list: - option_file_text = option_file_text + " " + str(res_range) - option_file_text = option_file_text + "\n" - elif num == 8: - option_file_text = ( - option_file_text - + "SF " - + str(num) - + " " - + str(self.findSpots_circleMask_lineEdit.text()) - + "\n" - ) - elif num == 9: - option_file_text = ( - option_file_text - + "SF " - + str(num) - + " " - + str(self.findSpots_recMask_lineEdit.text()) - + "\n" - ) - else: - option_file_text = option_file_text + "SF " + str(num) + "\n" - # indexing - for num, checkboxes in enumerate(self.optionListIndexing): - if checkboxes.isChecked(): - if num == 0: - option_file_text = ( - option_file_text - + "Ind " - + str(num) - + " " - + str(self.Index_method_comboBox.currentIndex()) - + "\n" - ) - elif num == 2: - option_file_text = ( - option_file_text - + "Ind " - + str(num) - + " " - + str(self.Index_UN_lineEdit.text()) - + " " - + str(self.Index_SG_lineEdit.text()) - + "\n" - ) - elif num == 3: - option_file_text = ( - option_file_text - + "Ind " - + str(num) - + " " - + str(self.Index_minCell_lineEdit.text()) - + "\n" - ) - elif num == 4: - option_file_text = ( - option_file_text - + "Ind " - + str(num) - + " " - + str(self.Index_maxCell_lineEdit.text()) - + "\n" - ) - else: - option_file_text = option_file_text + "Ind " + str(num) + "\n" - # Integrate - for num, checkboxes in enumerate(self.optionListIntegrate): - if checkboxes.isChecked(): - if num == 2: - option_file_text = ( - option_file_text - + "Int " - + str(num) - + " " - + str(self.Integrate_minCellOverall_lineEdit.text()) - + " " - + str(self.Integrate_minCellDegree_lineEdit.text()) - + "\n" - ) - else: - option_file_text = option_file_text + "Int " + str(num) + "\n" - # Refine and Scale - for num, checkboxes in enumerate(self.optionListRefineScale): - if checkboxes.isChecked(): - if num == 1: - option_file_text = ( - option_file_text - + "R " - + str(num) - + " " - + str(self.Refine_method_comboBox.currentIndex()) - + "\n" - ) - else: - option_file_text = option_file_text + "R " + str(num) + "\n" - # Other - for num, checkboxes in enumerate(self.optionListOther): - if checkboxes.isChecked(): - if num == 1: - option_file_text = ( - option_file_text - + "O " - + str(num) - + " " - + str(self.Other_manualInput1_lineEdit.text()) - + "\n" - ) - if num == 2: - option_file_text = ( - option_file_text - + "O " - + str(num) - + " " - + str(self.Other_manualInput1_lineEdit.text()) - + "\n" - ) - if num == 3: - option_file_text = ( - option_file_text - + "O " - + str(num) - + " " - + str(self.Other_manualInput1_lineEdit.text()) - + "\n" - ) - if num == 4: - option_file_text = ( - option_file_text - + "O " - + str(num) - + " " - + str(self.Other_manualInput1_lineEdit.text()) - + "\n" - ) - else: - option_file_text = option_file_text + "O " + str(num) + "\n" - - # HP - for num, checkboxes in enumerate(self.optionListHP): - if checkboxes.isChecked(): - if num == 1: - option_file_text = ( - option_file_text - + "HP " - + str(num) - + " " - + str(self.ref_geometry_path) - + "\n" - ) - elif num == 2: - option_file_text = ( - option_file_text - + "HP " - + str(num) - + " " - + str(self.HP_gasket_comboBox.currentIndex()) - + "\n" - ) - elif num == 3: - option_file_text = ( - option_file_text - + "HP " - + str(num) - + " " - + str(self.HP_gasketUserUC_lineEdit.text()) - + " " - + str(self.HP_gasketUserSG_lineEdit.text()) - + " " - + str(self.HP_gasketUserW_lineEdit.text()) - + "\n" - ) - elif num == 4: - option_file_text = ( - option_file_text - + "HP " - + str(num) - + " " - + str(self.HP_UN_lineEdit.text()) - + " " - + str(self.HP_SG_lineEdit.text()) - + "\n" - ) - elif num == 5: - option_file_text = ( - option_file_text - + "HP " - + str(num) - + " " - + str(self.HP_dmin_lineEdit.text()) - + "\n" - ) - elif num == 6: - option_file_text = option_file_text + "HP " + str(num) - self.runStartEnd_lineEdits = [ - self.HP_runStartEnd_lineEdit_1.text(), - self.HP_runStartEnd_lineEdit_2.text(), - self.HP_runStartEnd_lineEdit_3.text(), - self.HP_runStartEnd_lineEdit_4.text(), - self.HP_runStartEnd_lineEdit_5.text(), - self.HP_runStartEnd_lineEdit_6.text(), - self.HP_runStartEnd_lineEdit_7.text(), - self.HP_runStartEnd_lineEdit_8.text(), - self.HP_runStartEnd_lineEdit_9.text(), - self.HP_runStartEnd_lineEdit_10.text(), - ] - for entry in self.runStartEnd_lineEdits: - if entry == "": - option_file_text = option_file_text + " #" - else: - option_file_text = option_file_text + " " + str(entry) - option_file_text = option_file_text + "\n" - elif num == 8: - option_file_text = ( - option_file_text - + "HP " - + str(num) - + " " - + str(self.HP_anvilThickness_lineEdit.text()) - + "\n" - ) - elif num == 9: - option_file_text = ( - option_file_text - + "HP " - + str(num) - + " " - + str(self.HP_anvilOpeningAngle_checkBox.text()) - + "\n" - ) - - else: - option_file_text = option_file_text + "HP " + str(num) + "\n" - return option_file_text - - def save_options(self): - output_message = "\n Saving options" - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - - path = self.opening_visit - option_file = QtWidgets.QFileDialog.getSaveFileName( - None, "Save Current Options", path - )[0] - - if option_file: - option_file_text = self.option_file_text_function() - - output_message = ( - "\n File location: " - + str(option_file) - + "\n " - + str(option_file_text) - ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - - with open(option_file, "a") as f: - f.write(option_file_text) - f.write("") - f.close() - - def save_options_auto(self): - output_message = "\n Saving current options" - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - - if self.visit == "": - return - - option_file = self.visit + "processing/autoSaveOptions.txt" - - option_file_text = self.option_file_text_function() - - output_message = ( - "\n File location: " - + str(option_file) - + "\n " - + str(option_file_text) - ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - - with open(option_file, "a") as of: - of.write(option_file_text) - of.write("") - of.close() - - def load_options_auto(self): - if self.visit == "": - output_message = ( - " Visit/Dataset has not been selected, " - "therefore previous settings will not be loaded" - ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - return - if os.path.isfile(self.visit + "processing/autoSaveOptions.txt"): - saved_options_path_txt = self.visit + "processing/autoSaveOptions.txt" - self.load_options_main(saved_options_path_txt) - - def load_options(self): - output_message = "\nLoading options" - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - - path = self.opening_visit - os.chdir(path) - saved_options_path = QtWidgets.QFileDialog.getOpenFileName()[0] - if saved_options_path: - saved_options_path_txt = str(saved_options_path) - self.load_options_main(saved_options_path_txt) - - def load_options_main(self, saved_options_path_txt): - output_message = ( - " Loading previous settings (" + saved_options_path_txt + ")" - ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) - with open(saved_options_path_txt) as options_input: - for line in options_input: - line = "".join(line.split("\n")) - line_split = line.split(" ") - if line_split[0] == "I": - if int(line_split[1]) == 1: - self.ref_geometry_path = line_split[2] - ref_geometry_path_txt = str(self.ref_geometry_path) - ref_geometry_file_txt = ref_geometry_path_txt.split("/")[-1] - self.importReferenceGeometryPath.setText(ref_geometry_file_txt) - self.importReferenceGeometryPath.setScaledContents(True) - self.hpReferenceGeometryPath.setText(ref_geometry_file_txt) - self.hpReferenceGeometryPath.setScaledContents(True) - self.optionListImport[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 2: - self.import_dd_line_edit.setText(line_split[2]) - self.optionListImport[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 3: - self.import_beam_centre_x_line_edit.setText(line_split[2]) - self.import_beam_centre_y_line_edit.setText(line_split[3]) - self.optionListImport[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 4: - self.import_wavelength_line_edit.setText(line_split[2]) - self.optionListImport[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 7: - self.Import_type_comboBox.setCurrentIndex(int(line_split[2])) - self.optionListImport[int(line_split[1])].setChecked(True) - else: - self.optionListImport[int(line_split[1])].setChecked(True) - if line_split[0] == "SF": - if int(line_split[1]) == 0: - self.findSpots_sigmaStrong_lineEdit.setText(line_split[2]) - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 1: - self.findSpots_minSpot_lineEdit.setText(line_split[2]) - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 2: - self.findSpots_maxSpot_lineEdit.setText(line_split[2]) - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 3: - self.findSpots_dmin_lineEdit.setText(line_split[2]) - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 4: - self.findSpots_dmax_lineEdit.setText(line_split[2]) - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 6: - self.findSpots_powderRingsUC_lineEdit.setText(line_split[2]) - self.findSpots_powderRingsSG_lineEdit.setText(line_split[3]) - self.findSpots_powderRingsW_lineEdit.setText(line_split[4]) - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 7: - self.findSpots_resolutionRange_lineEdit_1.setText(line_split[2]) - self.findSpots_resolutionRange_lineEdit_2.setText(line_split[3]) - self.findSpots_resolutionRange_lineEdit_3.setText(line_split[4]) - self.findSpots_resolutionRange_lineEdit_4.setText(line_split[5]) - self.findSpots_resolutionRange_lineEdit_5.setText(line_split[6]) - self.findSpots_resolutionRange_lineEdit_6.setText(line_split[7]) - self.findSpots_resolutionRange_lineEdit_7.setText(line_split[8]) - self.findSpots_resolutionRange_lineEdit_8.setText(line_split[9]) - self.findSpots_resolutionRange_lineEdit_9.setText( - line_split[10] - ) - self.findSpots_resolutionRange_lineEdit_10.setText( - line_split[11] - ) - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 8: - self.findSpots_circleMask_lineEdit.setText(line_split[2]) - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 9: - self.findSpots_recMask_lineEdit.setText(line_split[2]) - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - else: - self.optionListSpotFinding[int(line_split[1])].setChecked(True) - if line_split[0] == "Ind": - if int(line_split[1]) == 0: - self.Index_method_comboBox.setCurrentIndex(int(line_split[2])) - self.optionListIndexing[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 2: - self.Index_UN_lineEdit.setText((line_split[2])) - self.Index_SG_lineEdit.setText((line_split[3])) - self.optionListIndexing[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 3: - self.Index_minCell_lineEdit.setText((line_split[2])) - self.optionListIndexing[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 4: - self.Index_maxCell_lineEdit.setText((line_split[2])) - self.optionListIndexing[int(line_split[1])].setChecked(True) - else: - self.optionListIndexing[int(line_split[1])].setChecked(True) - if line_split[0] == "Int": - if int(line_split[1]) == 2: - self.Integrate_minCellOverall_lineEdit.setText((line_split[2])) - self.Integrate_minCellDegree_lineEdit.setText((line_split[3])) - self.optionListIntegrate[int(line_split[1])].setChecked(True) - else: - self.optionListIntegrate[int(line_split[1])].setChecked(True) - if line_split[0] == "R": - if int(line_split[1]) == 1: - self.Refine_method_comboBox.setCurrentIndex(int(line_split[2])) - self.optionListRefineScale[int(line_split[1])].setChecked(True) - else: - self.optionListRefineScale[int(line_split[1])].setChecked(True) - if line_split[0] == "O": - if int(line_split[1]) == 1: - self.Other_manualInput1_lineEdit.setText((line_split[2])) - self.optionListOther[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 2: - self.Other_manualInput2_lineEdit.setText((line_split[2])) - self.optionListOther[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 3: - self.Other_manualInput3_lineEdit.setText((line_split[2])) - self.optionListOther[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 4: - self.Other_manualInput4_lineEdit.setText((line_split[2])) - self.optionListOther[int(line_split[1])].setChecked(True) - else: - self.optionListOther[int(line_split[1])].setChecked(True) - if line_split[0] == "HP": - if int(line_split[1]) == 1: - self.ref_geometry_path = line_split[2] - ref_geometry_path_txt = str(self.ref_geometry_path) - ref_geometry_file_txt = ref_geometry_path_txt.split("/")[-1] - self.importReferenceGeometryPath.setText(ref_geometry_file_txt) - self.importReferenceGeometryPath.setScaledContents(True) - self.hpReferenceGeometryPath.setText(ref_geometry_file_txt) - self.hpReferenceGeometryPath.setScaledContents(True) - self.optionListHP[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 2: - self.HP_gasket_comboBox.setCurrentIndex(int(line_split[2])) - self.optionListHP[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 3: - self.HP_gasketUserUC_lineEdit.setText((line_split[2])) - self.HP_gasketUserSG_lineEdit.setText((line_split[3])) - self.HP_gasketUserW_lineEdit.setText((line_split[4])) - self.optionListHP[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 4: - self.HP_UN_lineEdit.setText((line_split[2])) - self.HP_SG_lineEdit.setText((line_split[3])) - self.optionListHP[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 5: - self.HP_dmin_lineEdit.setText((line_split[2])) - self.optionListHP[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 6: - # if # then skip ### - if "#" not in line_split[2]: - self.HP_runStartEnd_lineEdit_1.setText((line_split[2])) - if "#" not in line_split[3]: - self.HP_runStartEnd_lineEdit_2.setText((line_split[3])) - if "#" not in line_split[4]: - self.HP_runStartEnd_lineEdit_3.setText((line_split[4])) - if "#" not in line_split[5]: - self.HP_runStartEnd_lineEdit_4.setText((line_split[5])) - if "#" not in line_split[6]: - self.HP_runStartEnd_lineEdit_5.setText((line_split[6])) - if "#" not in line_split[7]: - self.HP_runStartEnd_lineEdit_6.setText((line_split[7])) - if "#" not in line_split[8]: - self.HP_runStartEnd_lineEdit_7.setText((line_split[8])) - if "#" not in line_split[9]: - self.HP_runStartEnd_lineEdit_8.setText((line_split[9])) - if "#" not in line_split[10]: - self.HP_runStartEnd_lineEdit_9.setText((line_split[10])) - if "#" not in line_split[11]: - self.HP_runStartEnd_lineEdit_10.setText((line_split[11])) - self.optionListHP[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 8: - self.HP_anvilThickness_lineEdit.setText((line_split[2])) - self.optionListHP[int(line_split[1])].setChecked(True) - if int(line_split[1]) == 9: - self.HP_anvilOpeningAngle_lineEdit.setText((line_split[2])) - self.optionListHP[int(line_split[1])].setChecked(True) - else: - self.optionListHP[int(line_split[1])].setChecked(True) - if line_split[0] == "RS": - self.runSelectorList[int(line_split[1])].setChecked(True) - if __name__ == "__main__": # We must assign the QApplication and MainWindow instances to variables to From 75b664f4e806fe91665e56ed0764e5fc62bd8245 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 2 Dec 2020 17:31:46 +0000 Subject: [PATCH 18/31] Simplify Qt string translation Use QtCore.QObject.tr instead of QtCore.QCoreApplication.translate. Translate all user-facing strings. Rationalise some capitalisation. --- i19-gui/chemical_crystallography_gui.py | 90 ++++++++++++++----------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 0ab32a4..629809c 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -22,7 +22,6 @@ OptionWidgetDict = Dict[Type[QtWidgets.QWidget], str] OptionValues = Dict[str, Union[bool, int, str]] -_translate = QtCore.QCoreApplication.translate # Dictionary of the key property name (in the Qt sense, i.e. the attribute name in # Python terms) for each type of user option widget. @@ -1008,7 +1007,7 @@ def run(self): tab_name.appendPlainText(new_lines_print) tab_name.moveCursor(QtGui.QTextCursor.End) if "Status: normal termination" in xia2_txt_lines: - output_message = ( + output_message = self.tr( "\n\nEnd of xia2 processing detected.\n" "Stopping output to tab\n\n" ) @@ -1018,7 +1017,7 @@ def run(self): tab_name.appendPlainText(output_message) tab_name.moveCursor(QtGui.QTextCursor.End) if "xia2.support@gmail.com" in xia2_txt_lines: - output_message = ( + output_message = self.tr( "\n\nEnd of xia2 processing detected.\n" "Stopping output to tab\n\n" ) @@ -1108,21 +1107,20 @@ def options(self, new_values: OptionValues): def browse_for_reference_model(self): ref_geometry_path = self.ref_geometry_path or self.opening_visit - f_filter = _translate("UIOptionsWindow", "DIALS experiment list files (*.expt)") ref_geometry_path, _filter = QtWidgets.QFileDialog.getOpenFileName( parent=self, - caption="Select calibrated instrument model", + caption=self.tr("Select calibrated instrument model"), directory=ref_geometry_path, - filter=f_filter, + filter=self.tr("DIALS experiment list files (*.expt)"), ) if ref_geometry_path: self.ref_geometry_path = ref_geometry_path ref_geometry_path = Path(ref_geometry_path) - output_message = ( - "Reference Geometry Path:\n" + output_message = self.tr( + "\nReference geometry path:\n" f"\t{ref_geometry_path.parent}\n" - "Reference Geometry File:\n" + "Reference geometry file:\n" f"\t{ref_geometry_path.name}" ) self.log_output_txt.appendPlainText(output_message) @@ -1201,7 +1199,7 @@ def update_options(self): options = options + " trust_beam_centre=true" if variable == self.import_reference_geometry: if self.ref_geometry_path == "": - output_message = ( + output_message = self.tr( " *** Reference geometry error. Please select " ".expt file with browse button first ***" ) @@ -1216,7 +1214,7 @@ def update_options(self): ) if variable == self.import_dd: if self.import_dd_line_edit.text() == "": - output_message = ( + output_message = self.tr( " *** Detector Distance Error. Please input " "detector distance e.g. 85.01" ) @@ -1224,8 +1222,8 @@ def update_options(self): self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: - output_message = "Detector distance: " + str( - self.import_dd_line_edit.text() + output_message = self.tr( + "Detector distance: " + str(self.import_dd_line_edit.text()) ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) @@ -1237,19 +1235,21 @@ def update_options(self): if variable == self.import_beam_centre: if self.import_beam_centre_x_line_edit.text() == "": - output_message = " *** Beam centre error. Please input Y" + output_message = self.tr( + " *** Beam centre error. Please input Y" + ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return elif self.import_beam_centre_y_line_edit.text() == "": - output_message = ( + output_message = self.tr( " *** Detector distance error. Please input X" ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: - output_message = ( + output_message = self.tr( "Detector distance: " + str(self.import_beam_centre_x_line_edit.text()) + "," @@ -1267,7 +1267,7 @@ def update_options(self): if variable == self.import_wavelengh: if self.import_wavelength_line_edit.text() == "": - output_message = ( + output_message = self.tr( " *** Wavelength input error. " "Please add wavelength e.g. 85.01" ) @@ -1275,8 +1275,9 @@ def update_options(self): self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return else: - output_message = "Wavelength: " + str( - self.import_wavelength_line_edit.text() + output_message = self.tr( + "Wavelength: " + + str(self.import_wavelength_line_edit.text()) ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) @@ -1313,7 +1314,7 @@ def update_options(self): if variable.isChecked(): if variable == self.findSpots_sigmaStrong: if self.findSpots_sigmaStrong_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** Sigma strong error." " Please enter sigma strong e.g. 6 ***" ) @@ -1328,7 +1329,7 @@ def update_options(self): ) if variable == self.findSpots_minSpot: if self.findSpots_minSpot_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** Min spot size error, " "please enter min spots size e.g. 2 ***" ) @@ -1343,7 +1344,7 @@ def update_options(self): ) if variable == self.findSpots_maxSpot: if self.findSpots_maxSpot_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** Max spot size error, " "please enter max spots size e.g. 2 ***" ) @@ -1358,7 +1359,7 @@ def update_options(self): ) if variable == self.findSpots_dmin: if self.findSpots_dmin_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** d_min error, please enter d_min e.g. 0.84 ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1372,7 +1373,7 @@ def update_options(self): ) if variable == self.findSpots_dmax: if self.findSpots_dmax_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** d_max error, please enter d_max e.g. 10 ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1396,7 +1397,9 @@ def update_options(self): ] for entry in powder_ring_line_edits: if entry == "": - output_message = " *** Powder ring mask error ***" + output_message = self.tr( + " *** Powder ring mask error ***" + ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return @@ -1435,7 +1438,7 @@ def update_options(self): if variable == self.findSpots_circleMask: if self.findSpots_circleMask_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** Circle mask error, please enter in the " "following format: xc,yc,r ***" ) @@ -1451,7 +1454,7 @@ def update_options(self): if variable == self.findSpots_recMask: if self.findSpots_recMask_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** Rectangle mask error, please enter is " "the following format: x0,x1,y0,y1 ***" ) @@ -1485,7 +1488,7 @@ def update_options(self): self.log_output_txt.appendPlainText(entry) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) if entry == "": - output_message = ( + output_message = self.tr( " *** Error in unit cell or space group entry ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1496,7 +1499,9 @@ def update_options(self): options = options + uc_command + sg_command if variable == self.Index_minCell_checkBox: if self.Index_minCell_lineEdit.text() == "": - output_message = " *** Please enter valid min cell ***" + output_message = self.tr( + " *** Please enter valid min cell ***" + ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return @@ -1508,7 +1513,9 @@ def update_options(self): ) if variable == self.Index_maxCell_checkBox: if self.Index_maxCell_lineEdit.text() == "": - output_message = " *** Please enter valid max cell ***" + output_message = self.tr( + " *** Please enter valid max cell ***" + ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return @@ -1539,14 +1546,14 @@ def update_options(self): ] for entry in spot_profile_line_edits: if entry == "": - output_message = ( + output_message = self.tr( " *** Error in overall or per degree entry ***" ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return if self.visit == "": - output_message = ( + output_message = self.tr( " *** For this option a .phil needs to be created, " "this requires a the visit to be known." " Please open a dataset and retry (File>Open). ***" @@ -1626,7 +1633,7 @@ def update_options(self): options = options + " scan_varying=False" if variable == self.HP_ReferenceGeometry_checkBox: if self.ref_geometry_path == "": - output_message = ( + output_message = self.tr( " *** Reference geometry error. " "Please select .expt file with browse button first ***" ) @@ -1666,7 +1673,9 @@ def update_options(self): ] for entry in powder_ring_line_edits: if entry == "": - output_message = " *** Powder ring mask error ***" + output_message = self.tr( + " *** Powder ring mask error ***" + ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) return @@ -1695,7 +1704,7 @@ def update_options(self): self.log_output_txt.appendPlainText(entry) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) if entry == "": - output_message = ( + output_message = self.tr( " *** Error in unit cell or space group entry ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1707,7 +1716,7 @@ def update_options(self): if variable == self.HP_dmin_checkBox: if self.HP_dmin_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** d_min HP error, please enter d_min e.g. 0.84 ***" ) self.log_output_txt.appendPlainText(output_message) @@ -1740,8 +1749,9 @@ def update_options(self): else: self.image_selection[counter] = entry counter += 1 - output_message = "Image start/end option selected.\n" " " + str( - self.image_selection + output_message = self.tr( + "Image start/end option selected.\n" + " " + str(self.image_selection) ) self.log_output_txt.appendPlainText(output_message) self.log_output_txt.moveCursor(QtGui.QTextCursor.End) @@ -1758,7 +1768,7 @@ def update_options(self): if variable == self.HP_anvilThickness_checkBox: if self.HP_anvilThickness_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** Anvil thickness input error, " "please enter thickness e.g. 2.1 ***" ) @@ -1774,7 +1784,7 @@ def update_options(self): if variable == self.HP_anvilOpeningAngle_checkBox: if self.HP_anvilOpeningAngle_lineEdit.text() == "": - output_message = ( + output_message = self.tr( " *** Anvil opening angle input error, " "please enter opening angle e.g. 38 ***" ) From 1fb2212dcb9755798cdb9c5e518ba545394c0440 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 2 Dec 2020 17:50:25 +0000 Subject: [PATCH 19/31] Add precommit hooks to check and format JSON files --- .pre-commit-config.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index de4c8cb..3c99a39 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,6 +37,9 @@ repos: - id: end-of-file-fixer - id: requirements-txt-fixer - id: check-ast + - id: check-json + - id: pretty-format-json + args: [--autofix, --no-ensure-ascii, --no-sort-keys] - id: check-yaml - id: check-merge-conflict - id: check-added-large-files From 5a2f8ff56ce2ddfae7e50dec7cd6fd30e01daba2 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Thu, 3 Dec 2020 11:10:52 +0000 Subject: [PATCH 20/31] Simplify the logging call from a UIOptionsWindow Also make it so that a UIOptionsWindow without a parent falls back to logging with a simple print call. --- i19-gui/chemical_crystallography_gui.py | 128 +++++++++--------------- 1 file changed, 47 insertions(+), 81 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 629809c..3574812 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -1041,7 +1041,6 @@ def __init__( xia2_command, dataset_path, visit, - log_output_txt, run_list, prefix, opening_visit, @@ -1052,7 +1051,6 @@ def __init__( self.run_list = run_list self.ref_geometry_path = "" self.visit = visit - self.log_output_txt = log_output_txt self.run_image_selector = False self.run_selection = [] self.image_selection = {} @@ -1060,7 +1058,7 @@ def __init__( self.opening_visit = opening_visit self.saved_options_path = None - super().__init__(parent_window) + super().__init__(parent=parent_window) uic.loadUi(Path(__file__).parent / "OptionsWindow.ui", self) # Get all the widgets that record user-specified options. @@ -1090,6 +1088,15 @@ def __init__( self.show() + def log_output(self, message): + try: + log_widget = self.parent().logOutputTxt + except AttributeError: + print(message) + else: + log_widget.appendPlainText(message) + log_widget.moveCursor(QtGui.QTextCursor.End) + @property def options(self): return { @@ -1123,8 +1130,7 @@ def browse_for_reference_model(self): "Reference geometry file:\n" f"\t{ref_geometry_path.name}" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) self.importReferenceGeometryPath.setText(ref_geometry_path.name) @@ -1149,8 +1155,7 @@ def save_options_auto(self): def save_options(self, saved_options_path): output_message = self.tr(f"\n\tSaving settings to {saved_options_path}.") - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) with open(saved_options_path, "w") as f: json.dump(self.options, f) @@ -1177,15 +1182,12 @@ def load_options_auto(self): "press the 'Load settings' button.\n" "You can also save your settings with the 'Save settings' button." ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) elif saved_options_path.is_file(): self.load_options(saved_options_path) def load_options(self, saved_options_path: Path): - output_message = self.tr(f"\n\tLoading settings from {saved_options_path}.") - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(self.tr(f"\n\tLoading settings from {saved_options_path}.")) with open(saved_options_path) as f: self.options = json.load(f) @@ -1203,8 +1205,7 @@ def update_options(self): " *** Reference geometry error. Please select " ".expt file with browse button first ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1218,15 +1219,13 @@ def update_options(self): " *** Detector Distance Error. Please input " "detector distance e.g. 85.01" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: output_message = self.tr( "Detector distance: " + str(self.import_dd_line_edit.text()) ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) options = ( options + " detector_distance=" @@ -1238,15 +1237,13 @@ def update_options(self): output_message = self.tr( " *** Beam centre error. Please input Y" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return elif self.import_beam_centre_y_line_edit.text() == "": output_message = self.tr( " *** Detector distance error. Please input X" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: output_message = self.tr( @@ -1255,8 +1252,7 @@ def update_options(self): + "," + str(self.import_beam_centre_y_line_edit.text()) ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) options = ( options + " mosflm_beam_centre=" @@ -1271,16 +1267,14 @@ def update_options(self): " *** Wavelength input error. " "Please add wavelength e.g. 85.01" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: output_message = self.tr( "Wavelength: " + str(self.import_wavelength_line_edit.text()) ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) options = ( options + " wavelength=" @@ -1299,10 +1293,7 @@ def update_options(self): for num, run in enumerate(self.runSelectorList, start=1): if run.isChecked(): self.run_selection.append(num) - self.log_output_txt.appendPlainText( - "Run selector: " + str(self.run_selection) - ) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output("Run selector: " + str(self.run_selection)) if variable == self.Import_type_checkBox: if self.Import_type_comboBox.currentText() == "Protein": pass @@ -1318,8 +1309,7 @@ def update_options(self): " *** Sigma strong error." " Please enter sigma strong e.g. 6 ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1333,8 +1323,7 @@ def update_options(self): " *** Min spot size error, " "please enter min spots size e.g. 2 ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1348,8 +1337,7 @@ def update_options(self): " *** Max spot size error, " "please enter max spots size e.g. 2 ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1362,8 +1350,7 @@ def update_options(self): output_message = self.tr( " *** d_min error, please enter d_min e.g. 0.84 ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1376,8 +1363,7 @@ def update_options(self): output_message = self.tr( " *** d_max error, please enter d_max e.g. 10 ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1400,8 +1386,7 @@ def update_options(self): output_message = self.tr( " *** Powder ring mask error ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return ice_rings_uv_command = " ice_rings.unit_cell=" + str( self.findSpots_powderRingsUC_lineEdit.text() @@ -1442,8 +1427,7 @@ def update_options(self): " *** Circle mask error, please enter in the " "following format: xc,yc,r ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1458,8 +1442,7 @@ def update_options(self): " *** Rectangle mask error, please enter is " "the following format: x0,x1,y0,y1 ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1485,14 +1468,12 @@ def update_options(self): self.Index_SG_lineEdit.text(), ] for entry in uc_sg_line_edits: - self.log_output_txt.appendPlainText(entry) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(entry) if entry == "": output_message = self.tr( " *** Error in unit cell or space group entry ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return uc_command = " unit_cell=" + str(self.Index_UN_lineEdit.text()) sg_command = " space_group=" + str(self.Index_SG_lineEdit.text()) @@ -1502,8 +1483,7 @@ def update_options(self): output_message = self.tr( " *** Please enter valid min cell ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1516,8 +1496,7 @@ def update_options(self): output_message = self.tr( " *** Please enter valid max cell ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1549,8 +1528,7 @@ def update_options(self): output_message = self.tr( " *** Error in overall or per degree entry ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return if self.visit == "": output_message = self.tr( @@ -1558,8 +1536,7 @@ def update_options(self): "this requires a the visit to be known." " Please open a dataset and retry (File>Open). ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return overall_line = ( " profile.gaussian_rs.min_spots.overall=" @@ -1637,8 +1614,7 @@ def update_options(self): " *** Reference geometry error. " "Please select .expt file with browse button first ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1676,8 +1652,7 @@ def update_options(self): output_message = self.tr( " *** Powder ring mask error ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return ice_rings_uv_command = " ice_rings.unit_cell=" + str( self.HP_gasketUserUC_lineEdit.text() @@ -1701,14 +1676,12 @@ def update_options(self): self.HP_SG_lineEdit.text(), ] for entry in uc_sg_line_edits: - self.log_output_txt.appendPlainText(entry) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(entry) if entry == "": output_message = self.tr( " *** Error in unit cell or space group entry ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return uc_command = " unit_cell=" + str(self.HP_UN_lineEdit.text()) sg_command = " space_group=" + str(self.HP_SG_lineEdit.text()) @@ -1719,8 +1692,7 @@ def update_options(self): output_message = self.tr( " *** d_min HP error, please enter d_min e.g. 0.84 ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1753,8 +1725,7 @@ def update_options(self): "Image start/end option selected.\n" " " + str(self.image_selection) ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) if variable == self.HP_FixBeamDetector_checkBox: options = ( @@ -1772,8 +1743,7 @@ def update_options(self): " *** Anvil thickness input error, " "please enter thickness e.g. 2.1 ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: options = ( @@ -1788,8 +1758,7 @@ def update_options(self): " *** Anvil opening angle input error, " "please enter opening angle e.g. 38 ***" ) - self.log_output_txt.appendPlainText(output_message) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) + self.log_output(output_message) return else: pass @@ -1804,11 +1773,10 @@ def update_options(self): else: # causing issues when multiple ########### if self.dataset_path == "": dataset_input = self.dataset_path - self.log_output_txt.appendPlainText( + self.log_output( "Dataset must be selected before selecting runs or images " "start/end" ) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) else: dataset_input = "" if self.run_selection: # runs have been selected @@ -1844,7 +1812,7 @@ def update_options(self): self.dataset_path = dataset_input - options_update_text = ( + self.log_output( "\n\nUpdating options" + "\n Xia2 command: " + "\n " @@ -1852,8 +1820,6 @@ def update_options(self): + self.dataset_path + options ) - self.log_output_txt.appendPlainText(options_update_text) - self.log_output_txt.moveCursor(QtGui.QTextCursor.End) ui_main_window = self.parent() ui_main_window.xia2_command = self.xia2_command From c9f440cf1613f883405ebee545f0268a03635477 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Thu, 3 Dec 2020 12:13:04 +0000 Subject: [PATCH 21/31] Use some sensible default parameters --- i19-gui/chemical_crystallography_gui.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 3574812..3d484ce 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -39,7 +39,7 @@ class UIMainWindow(QtWidgets.QMainWindow): - def __init__(self, parent_window=None): + def __init__(self, parent_window=None, **kwargs): self.dials_version = "" self.opening_visit = "/dls/i19-2/data/2020/" self.visit = "" @@ -103,7 +103,7 @@ def __init__(self, parent_window=None): ] self.tabs_num = 0 - super().__init__(parent_window) + super().__init__(parent=parent_window, **kwargs) uic.loadUi(Path(__file__).parent / "MainWindow.ui", self) self.menuFile_Open.triggered.connect(self.select_dataset) @@ -1038,17 +1038,18 @@ def run(self): class UIOptionsWindow(QtWidgets.QMainWindow): def __init__( self, - xia2_command, - dataset_path, - visit, - run_list, - prefix, - opening_visit, + xia2_command="", + dataset_path="", + visit="", + run_list=None, + prefix="", + opening_visit="", parent_window=None, + **kwargs, ): self.xia2_command = xia2_command self.dataset_path = dataset_path - self.run_list = run_list + self.run_list = run_list or [] self.ref_geometry_path = "" self.visit = visit self.run_image_selector = False @@ -1058,7 +1059,7 @@ def __init__( self.opening_visit = opening_visit self.saved_options_path = None - super().__init__(parent=parent_window) + super().__init__(parent=parent_window, **kwargs) uic.loadUi(Path(__file__).parent / "OptionsWindow.ui", self) # Get all the widgets that record user-specified options. From d38e7012efc2ef0b66508c8c53de0797a7ea0a54 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Fri, 4 Dec 2020 18:03:00 +0000 Subject: [PATCH 22/31] Log the absence of previous auto-saved options --- i19-gui/chemical_crystallography_gui.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 3d484ce..580b7bd 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -1186,6 +1186,11 @@ def load_options_auto(self): self.log_output(output_message) elif saved_options_path.is_file(): self.load_options(saved_options_path) + else: + self.log_output( + f"No auto-saved options found for the visit {self.visit}.\n" + f"A new auto-save file will be created at {auto_save_filename}." + ) def load_options(self, saved_options_path: Path): self.log_output(self.tr(f"\n\tLoading settings from {saved_options_path}.")) From 0be95bcde91948285cfe99630eb7b519840549c0 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Fri, 4 Dec 2020 18:05:10 +0000 Subject: [PATCH 23/31] Define the translation of options to PHIL params Also add some handy placeholder text in some of the options widgets. --- i19-gui/OptionsWindow.ui | 397 ++++++++++++++++-------- i19-gui/chemical_crystallography_gui.py | 165 +++++++++- 2 files changed, 425 insertions(+), 137 deletions(-) diff --git a/i19-gui/OptionsWindow.ui b/i19-gui/OptionsWindow.ui index 7537b8e..e0ca74d 100644 --- a/i19-gui/OptionsWindow.ui +++ b/i19-gui/OptionsWindow.ui @@ -85,16 +85,27 @@ - - - Use the beam centre listed in the image headers, do not refine the beam centre. - + - Trust beam centre + Method - + + + + + Chemical (small molecule) + + + + + Macromolecular + + + + + Use a calibrated instrument model (<visit-directory>/processed/dataset/DataFiles/*.expt). @@ -104,7 +115,7 @@ - + @@ -131,7 +142,7 @@ - + Override the detector distance. @@ -141,7 +152,7 @@ - + e.g. 85.19 @@ -151,7 +162,7 @@ - + Override the beam centre from the image headers. @@ -161,7 +172,7 @@ - + @@ -207,7 +218,7 @@ - + Override the wavelength. @@ -217,15 +228,15 @@ - + e.g. 0.6889 - - + + Select which sweeps to process. @@ -234,146 +245,228 @@ - + + + Select which sweeps to process. + 3 + + true + + + Select which sweeps to process. + 9 + + true + + + Select which sweeps to process. + 2 + + true + + + Select which sweeps to process. + 5 + + true + + + Select which sweeps to process. + 7 + + true + + + Select which sweeps to process. + 11 + + true + + + Select which sweeps to process. + 12 + + true + + + Select which sweeps to process. + 8 + + true + + + Select which sweeps to process. + 4 + + true + + + Select which sweeps to process. + 16 + + true + + + Select which sweeps to process. + 13 + + true + + + Select which sweeps to process. + 15 + + true + + + Select which sweeps to process. + 14 + + true + + + Select which sweeps to process. + 1 + + true + + + Select which sweeps to process. + 6 + + true + + + Select which sweeps to process. + 10 + + true + - + - Use default parameters for small-molecule (chemical) or macromolecular crystallography. + Use the beam centre listed in the image headers, do not refine the beam centre. - Method + Trust beam centre - - - - - Chemical - - - - - Macromolecular - - - - @@ -399,6 +492,9 @@ e.g. 6 (default = 3) + + 3 + @@ -414,12 +510,18 @@ - e.g. 2 + e.g. 5 — default is 3 for pixel array detectors, 6 otherwise + + + + + false + The maximum number of contiguous pixels to be considered a spot. @@ -430,9 +532,15 @@ + + false + e.g. 20 (default=1000) + + 1000 + @@ -470,93 +578,16 @@ - - - Mask ice rings. - - - Ice rings - - - - Mask the powder rings from a known material (provide all three parameters). - Powder rings + Ice/powder rings - - - - - - - - Unit cell - - - true - - - - - - - e.g. 5.6,5.7,12.4,90,105.2,90 - - - - - - - - - - - Space group - - - true - - - - - - - e.g. P21 - - - - - - - - - - - Mask width - - - true - - - - - - - e.g. 0.04 (default = 0.002) - - - - - - - - + Mask annuli between the specified resolution limits. @@ -566,81 +597,81 @@ - + - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - e.g. 1.02,0.98 + e.g. 1.02, 0.98 - + Mask a circular region on all images. @@ -650,14 +681,14 @@ - + - e.g. 620,851,27 (xc,yc,r) + e.g. 620, 851, 27 (x, y, r) - + Mask a rectangular region on all images. @@ -667,13 +698,89 @@ - + - e.g. 0,612,824,858 (x0, x1, y0, y1) + e.g. 0, 612, 824, 858 (x0, x1, y0, y1) + + + + + + + + Unit cell (a, b, c in Å, α, β, γ in °) + + + true + + + + + + + e.g. 5.6, 5.7, 12.4, 90, 105.2, 90 — defaults to 4.498, 4.498, 7.338, 90, 90, 120 for water ice + + + 4.498,4.498,7.338,90,90,120 + + + + + + + + + + + Space group + + + true + + + + + + + symbol, e.g. P21, or number, e.g. 4 — defaults to P63/mmc for water ice + + + P63/mmc + + + + + + + + + + + Mask width (Å⁻²) + + + true + + + + + + + Width of each ring mask in d⁻², e.g. 0.04 (default = 0.002) + + + 0.002 + + + + + + + @@ -732,7 +839,7 @@ - Unit Cell + Unit cell (a, b, c in Å, α, β, γ in °) true @@ -742,7 +849,7 @@ - e.g. 5.1,6.2,7.3,90,95.1,90 + e.g. 5.1, 6.2, 7.3, 90, 95.1, 90 @@ -786,6 +893,9 @@ e.g. 6.0 (default = 3) + + 3 + @@ -1092,7 +1202,10 @@ - e.g. 2.87,2.87,2.87,90,90,90 + e.g. 2.87, 2.87, 2.87, 90, 90, 90 + + + a, b, c, α, β, γ @@ -1115,6 +1228,9 @@ e.g. Im-3m + + + @@ -1134,7 +1250,10 @@ - e.g. 0.02 + Width of each ring mask in d⁻², e.g. 0.04 (default = 0.002) + + + 0.002 @@ -1168,7 +1287,7 @@ - Unit cell + Unit cell (a, b, c in Å, α, β, γ in °) true @@ -1178,7 +1297,10 @@ - e.g. 5.4,5.4,5.4,90,90,90 + e.g. 5.4, 5.4, 5.4, 90, 90, 90 + + + a, b, c, α, β, γ @@ -1488,6 +1610,9 @@ + + 1.5925 + diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 580b7bd..68868f0 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -13,6 +13,7 @@ import os import subprocess import sys +from collections import namedtuple from datetime import datetime from pathlib import Path from time import sleep @@ -23,6 +24,8 @@ OptionWidgetDict = Dict[Type[QtWidgets.QWidget], str] OptionValues = Dict[str, Union[bool, int, str]] +auto_save_filename = "processing/.i19.gui.autosave.json" + # Dictionary of the key property name (in the Qt sense, i.e. the attribute name in # Python terms) for each type of user option widget. # Any children of a UIOptionsWindow instance that are of a type listed here will be @@ -35,7 +38,164 @@ QtWidgets.QLineEdit: "text", } -auto_save_filename = "processing/.i19.gui.autosave.json" +Option = namedtuple( + "Option", ["phil", "value", "condition", "convert"], defaults=[None, None, None] +) + + +def small_molecule(i): + return i == 0 + + +def csv(parameters, number=2): + # TODO: Add some exception handling to warn of mangled or invalid input. + parameters = [str(float(param.strip())) for param in parameters.split(",")] + assert len(parameters) == number + return ",".join(parameters) + + +def indexing_method(index=0): + return ["fft3d", "fft1d", "real_space_grid_search", "low_res_spot_match"][index] + + +gasket_params = [ + f"ice_rings.{param}" for param in ("filter", "unit_cell", "space_group", "width") +] + + +def gasket_values(index): + """Tungsten, steel""" + unit_cell_params = ["3.1652, 3.1652, 3.1652", "2.87, 2.87, 2.87"] + unit_cell = csv(f"{unit_cell_params[index]}, 90, 90, 90", number=6) + return True, unit_cell, "Im-3m", "0.02" + + +# Specify how option widgets translate to PHIL parameters to be passed to xia2. +# Once it is supported in xia2 (see #7, xia2/xia2#543), add this entry: +# findSpots_maxSpot_lineEdit=Option( +# "max_spot_size", condition="findSpots_maxSpot", convert=int +# ), +option_specification = dict( + comboBox=Option("small_molecule", condition=small_molecule, convert=small_molecule), + import_TrustBeamCentre=Option("trust_beam_centre", convert=bool), + importReferenceGeometryPath=Option( + "reference_geometry", condition="import_ReferenceGeometry" + ), + import_DD_lineEdit=Option( + "detector_distance", condition="import_DD", convert=float + ), + import_BeamCentre=Option( + "mosflm_beam_centre", + value=["import_BeamCentre_X_lineEdit", "import_BeamCentre_Y_lineEdit"], + convert=float, + ), + import_wavelength_lineEdit=Option( + "wavelength", condition="import_Wavelength", convert=float + ), + findSpots_sigmaStrong_lineEdit=Option( + "sigma_strong", condition="findSpots_sigmaStrong", convert=float + ), + findSpots_minSpot_lineEdit=Option( + "min_spot_size", condition="findSpots_minSpot", convert=int + ), + findSpots_dmin_lineEdit=Option("d_min", condition="findSpots_dmin", convert=float), + findSpots_dmax_lineEdit=Option("d_max", condition="findSpots_dmax", convert=float), + findSpots_powderRings=Option("ice_rings.filter"), + # Put gasket selection before user-specified powder rings, to allow the width of + # the pre-specified powder rings to be adjusted with the options below. + HP_gasket_comboBox=Option( + gasket_params, condition="HP_gasket_checkBox", value=gasket_values + ), + findSpots_powderRingsUC_lineEdit=Option( + "ice_rings.unit_cell", + condition=["ice_rings.filter", "findSpots_powderRingsSG_lineEdit"], + convert=lambda parameters: csv(parameters, number=6), + ), + findSpots_powderRingsSG_lineEdit=Option( + "ice_rings.space_group", + condition=["findSpots_powderRings", "findSpots_powderRingsUC_lineEdit"], + ), + findSpots_powderRingsW_lineEdit=Option( + "ice_rings.width", condition="findSpots_powderRings", convert=float + ), + findSpots_resolutionRange_lineEdit_1=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_resolutionRange_lineEdit_2=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_resolutionRange_lineEdit_3=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_resolutionRange_lineEdit_4=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_resolutionRange_lineEdit_5=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_resolutionRange_lineEdit_6=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_resolutionRange_lineEdit_7=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_resolutionRange_lineEdit_8=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_resolutionRange_lineEdit_9=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_resolutionRange_lineEdit_10=Option( + "resolution_range", condition="findSpots_resolutionRange", convert=csv + ), + findSpots_circleMask_lineEdit=Option( + "circle", + condition="findSpots_circleMask", + convert=lambda parameters: csv(parameters, number=3), + ), + findSpots_recMask_lineEdit=Option( + "rectangle", + condition="findSpots_recMask", + convert=lambda parameters: csv(parameters, number=4), + ), + Index_method_comboBox=Option("method", convert=indexing_method), + Index_UN_lineEdit=Option( + "unit_cell", + condition="Index_UN_SG_checkBox", + convert=lambda parameters: csv(parameters, number=6), + ), + Index_SG_lineEdit=Option("space_group", condition="Index_UN_SG_checkBox"), + Index_minCell_lineEdit=Option( + "min_cell", condition="Index_minCell_checkBox", convert=float + ), + Index_maxCell_lineEdit=Option( + "max_cell", condition="Index_maxCell_checkBox", convert=float + ), + Index_multiprocessing_checkBox=Option("multi_sweep_indexing", convert=bool), + Index_multiprocessing_checkBox_2=Option("multi_sweep_refinement", convert=bool), + Index_outliers_checkBox=Option("outlier.algorithm", convert=lambda _: "null"), + Refine_FixBeamDetector_checkBox_2=Option( + [ + "refinement.parameterisation.beam.fix", + "refinement.parameterisation.detector.fix", + "refinement.parameterisation.auto_reduction.action", + ], + convert=lambda _: ["all", "all", "fix"], + ), + Integrate_scanVarying_checkBox=Option("scan_varying", convert=lambda x: not x), + Index_minCell_lineEdit_2=Option( + "min_spots.overall", condition="Integrate_scanVarying_checkBox_2", convert=int + ), + Index_minCell_lineEdit_3=Option( + "min_spots.per_degree", + condition="Integrate_scanVarying_checkBox_2", + convert=int, + ), + Refine_method_comboBox=Option("pipeline", value="dials-aimless"), + Integrate_keepAllReflections_checkBox=Option("keep_all_reflections", convert=bool), + HP_correction_shaddowing_checkBox=Option("high_pressure.correction", convert=bool), + lineEdit_2=Option("anvil.thickness", condition="checkBox_3", convert=float), +) class UIMainWindow(QtWidgets.QMainWindow): @@ -1197,6 +1357,9 @@ def load_options(self, saved_options_path: Path): with open(saved_options_path) as f: self.options = json.load(f) + def phil_params(self): + pass + def update_options(self): options = "" From 491a72109a6356d8a14e63afedf71c8b6217c224 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Tue, 15 Dec 2020 17:02:34 +0000 Subject: [PATCH 24/31] Remove redundant checkboxes, clarify labels --- i19-gui/OptionsWindow.ui | 59 +++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/i19-gui/OptionsWindow.ui b/i19-gui/OptionsWindow.ui index e0ca74d..ac93d2f 100644 --- a/i19-gui/OptionsWindow.ui +++ b/i19-gui/OptionsWindow.ui @@ -503,7 +503,7 @@ The minimum number of contiguous pixels to be considered a spot. - Min spot size + Minimum spot size @@ -526,7 +526,7 @@ The maximum number of contiguous pixels to be considered a spot. - Max spot size + Maximum spot size @@ -549,7 +549,7 @@ The high resolution limit of the region to search for spots. - d min (Å) + Minimum d (Å) @@ -566,7 +566,7 @@ The low resolution limit of the region to search for spots. - d max (Å) + Maximum d (Å) @@ -788,36 +788,29 @@ Indexing - - + + Select indexing algorithm. - - Method - - - - - - fft3d + 3-d fast Fourier transform in reciprocal space - fft1d + 1-d fast Fourier transforms in reciprocal space - real_space_grid_search + Real space grid search - low_res_spot_match + Low resolution spot match @@ -825,7 +818,7 @@ - Known unit cell and space group (must provide both). + Known unit cell and space group. Unit cell and space group @@ -941,7 +934,14 @@ Include all reflections from spot finding, including outliers in reciprocal space. - Include outliers + Include indexing outliers + + + + + + + Method @@ -980,7 +980,7 @@ Set the minimum number of reflections deemed necessary for refinement. - Min number of reflections + Minimum number of reflections @@ -1044,16 +1044,6 @@ Scaling - - - - Select the choice of scaling tool. - - - Scaling tool - - - @@ -1078,6 +1068,13 @@ + + + + Scaling tool + + + @@ -1335,7 +1332,7 @@ The high resolution limit of the region to search for spots. - d min (Å) + Minimum d (Å) From 8c2543d52df1e8342d6be5d6fef03ea069f3ca13 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Tue, 15 Dec 2020 17:03:42 +0000 Subject: [PATCH 25/31] Connect some more duplicate widgets --- i19-gui/OptionsWindow.ui | 128 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/i19-gui/OptionsWindow.ui b/i19-gui/OptionsWindow.ui index ac93d2f..b74aa9a 100644 --- a/i19-gui/OptionsWindow.ui +++ b/i19-gui/OptionsWindow.ui @@ -2010,5 +2010,133 @@ + + HP_gasketUser_checkBox + toggled(bool) + findSpots_powderRings + setChecked(bool) + + + 118 + 246 + + + 90 + 247 + + + + + findSpots_powderRings + toggled(bool) + HP_gasketUser_checkBox + setChecked(bool) + + + 90 + 247 + + + 118 + 246 + + + + + HP_gasketUserUC_lineEdit + textChanged(QString) + findSpots_powderRingsUC_lineEdit + setText(QString) + + + 368 + 272 + + + 287 + 274 + + + + + findSpots_powderRingsUC_lineEdit + textChanged(QString) + HP_gasketUserUC_lineEdit + setText(QString) + + + 287 + 274 + + + 368 + 272 + + + + + HP_gasketUserSG_lineEdit + textChanged(QString) + findSpots_powderRingsSG_lineEdit + setText(QString) + + + 485 + 272 + + + 464 + 274 + + + + + findSpots_powderRingsSG_lineEdit + textChanged(QString) + HP_gasketUserSG_lineEdit + setText(QString) + + + 464 + 274 + + + 485 + 272 + + + + + HP_gasketUserW_lineEdit + textChanged(QString) + findSpots_powderRingsW_lineEdit + setText(QString) + + + 602 + 272 + + + 603 + 274 + + + + + findSpots_powderRingsW_lineEdit + textChanged(QString) + HP_gasketUserW_lineEdit + setText(QString) + + + 603 + 274 + + + 602 + 272 + + + From b4d1d7b5a7ca6731c040d819685c53913bd03106 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 16 Dec 2020 18:28:47 +0000 Subject: [PATCH 26/31] Find numbers in multi-number input by regex --- i19-gui/chemical_crystallography_gui.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 68868f0..b1fd39a 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -11,6 +11,7 @@ import glob import json import os +import re import subprocess import sys from collections import namedtuple @@ -47,9 +48,12 @@ def small_molecule(i): return i == 0 +numbers_regex = re.compile(r"(\d+\.?\d*|\.\d+)") + + def csv(parameters, number=2): # TODO: Add some exception handling to warn of mangled or invalid input. - parameters = [str(float(param.strip())) for param in parameters.split(",")] + parameters = [str(float(param)) for param in re.findall(numbers_regex, parameters)] assert len(parameters) == number return ",".join(parameters) From 25f32d68224853151f1f3ae8b3561f1c61ee72f9 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 16 Dec 2020 18:30:08 +0000 Subject: [PATCH 27/31] Repeat ourselves programatically --- i19-gui/chemical_crystallography_gui.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index b1fd39a..aad8bf1 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -16,6 +16,7 @@ import sys from collections import namedtuple from datetime import datetime +from itertools import chain, repeat from pathlib import Path from time import sleep from typing import Dict, Type, Union @@ -67,11 +68,12 @@ def indexing_method(index=0): ] -def gasket_values(index): +def gasket_values(index, check): """Tungsten, steel""" - unit_cell_params = ["3.1652, 3.1652, 3.1652", "2.87, 2.87, 2.87"] - unit_cell = csv(f"{unit_cell_params[index]}, 90, 90, 90", number=6) - return True, unit_cell, "Im-3m", "0.02" + unit_cell_params = ["3.1652", "2.87"] + if check: + unit_cell = ",".join(chain(repeat(unit_cell_params[index], 3), repeat("90", 3))) + return True, unit_cell, "Im-3m", "0.02" # Specify how option widgets translate to PHIL parameters to be passed to xia2. From 2eea7a862f036914a77009e25b701c7d01a4914e Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 16 Dec 2020 18:31:06 +0000 Subject: [PATCH 28/31] Correct some option specifications --- i19-gui/chemical_crystallography_gui.py | 29 +++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index aad8bf1..1e28fd3 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -10,6 +10,7 @@ import fnmatch import glob import json +import operator import os import re import subprocess @@ -83,20 +84,21 @@ def gasket_values(index, check): # ), option_specification = dict( comboBox=Option("small_molecule", condition=small_molecule, convert=small_molecule), - import_TrustBeamCentre=Option("trust_beam_centre", convert=bool), + import_TrustBeamCentre=Option("trust_beam_centre"), importReferenceGeometryPath=Option( "reference_geometry", condition="import_ReferenceGeometry" ), import_DD_lineEdit=Option( "detector_distance", condition="import_DD", convert=float ), - import_BeamCentre=Option( + import_BeamCentre_X_lineEdit=Option( "mosflm_beam_centre", - value=["import_BeamCentre_X_lineEdit", "import_BeamCentre_Y_lineEdit"], - convert=float, + value="import_BeamCentre_Y_lineEdit", + condition="import_BeamCentre", + convert=lambda *xy: ",".join(str(float(coord)) for coord in xy), ), import_wavelength_lineEdit=Option( - "wavelength", condition="import_Wavelength", convert=float + "wavelength", condition="import_Wavelengh", convert=float ), findSpots_sigmaStrong_lineEdit=Option( "sigma_strong", condition="findSpots_sigmaStrong", convert=float @@ -110,11 +112,14 @@ def gasket_values(index, check): # Put gasket selection before user-specified powder rings, to allow the width of # the pre-specified powder rings to be adjusted with the options below. HP_gasket_comboBox=Option( - gasket_params, condition="HP_gasket_checkBox", value=gasket_values + gasket_params, + value="HP_gasket_checkBox", + condition=gasket_values, + convert=gasket_values, ), findSpots_powderRingsUC_lineEdit=Option( "ice_rings.unit_cell", - condition=["ice_rings.filter", "findSpots_powderRingsSG_lineEdit"], + condition=["findSpots_powderRings", "findSpots_powderRingsSG_lineEdit"], convert=lambda parameters: csv(parameters, number=6), ), findSpots_powderRingsSG_lineEdit=Option( @@ -177,8 +182,8 @@ def gasket_values(index, check): Index_maxCell_lineEdit=Option( "max_cell", condition="Index_maxCell_checkBox", convert=float ), - Index_multiprocessing_checkBox=Option("multi_sweep_indexing", convert=bool), - Index_multiprocessing_checkBox_2=Option("multi_sweep_refinement", convert=bool), + Index_multiprocessing_checkBox=Option("multi_sweep_indexing"), + Index_multiprocessing_checkBox_2=Option("multi_sweep_refinement"), Index_outliers_checkBox=Option("outlier.algorithm", convert=lambda _: "null"), Refine_FixBeamDetector_checkBox_2=Option( [ @@ -188,7 +193,7 @@ def gasket_values(index, check): ], convert=lambda _: ["all", "all", "fix"], ), - Integrate_scanVarying_checkBox=Option("scan_varying", convert=lambda x: not x), + Integrate_scanVarying_checkBox=Option("scan_varying", convert=operator.not_), Index_minCell_lineEdit_2=Option( "min_spots.overall", condition="Integrate_scanVarying_checkBox_2", convert=int ), @@ -198,8 +203,8 @@ def gasket_values(index, check): convert=int, ), Refine_method_comboBox=Option("pipeline", value="dials-aimless"), - Integrate_keepAllReflections_checkBox=Option("keep_all_reflections", convert=bool), - HP_correction_shaddowing_checkBox=Option("high_pressure.correction", convert=bool), + Integrate_keepAllReflections_checkBox=Option("keep_all_reflections"), + HP_correction_shaddowing_checkBox=Option("high_pressure.correction"), lineEdit_2=Option("anvil.thickness", condition="checkBox_3", convert=float), ) From 7c5cdc609833333463d8710251d2b1f43a1e17b6 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 16 Dec 2020 18:32:07 +0000 Subject: [PATCH 29/31] Tidy up main widow module attributes --- i19-gui/chemical_crystallography_gui.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 1e28fd3..66d5857 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -228,7 +228,7 @@ def __init__(self, parent_window=None, **kwargs): self.computing_location = "Cluster" - self.xia2_options_list = " small_molecule=true" + self.xia2_options_list = "" self.xia2_command = "xia2 " self.tabs = ["tab1", "tab2", "tab3", "tab4", "tab5", "tab6", "tab7", "tab8"] self.tabstxt = [ @@ -483,7 +483,6 @@ def open_options(self): self.xia2_command, self.dataset_path, self.visit, - self.logOutputTxt, self.run_list, self.prefix, self.opening_visit, From 3670442cd909bece7c1e6f706bd2da7e178b27bf Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 16 Dec 2020 18:33:10 +0000 Subject: [PATCH 30/31] Simplify update_options using new parameter spec --- i19-gui/chemical_crystallography_gui.py | 708 ++---------------------- 1 file changed, 59 insertions(+), 649 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 66d5857..5472232 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -16,6 +16,7 @@ import subprocess import sys from collections import namedtuple +from collections.abc import Iterable from datetime import datetime from itertools import chain, repeat from pathlib import Path @@ -1283,28 +1284,6 @@ def options(self, new_values: OptionValues): property_name = option_widgets[type(widget)] widget.setProperty(property_name, value) - def browse_for_reference_model(self): - ref_geometry_path = self.ref_geometry_path or self.opening_visit - ref_geometry_path, _filter = QtWidgets.QFileDialog.getOpenFileName( - parent=self, - caption=self.tr("Select calibrated instrument model"), - directory=ref_geometry_path, - filter=self.tr("DIALS experiment list files (*.expt)"), - ) - if ref_geometry_path: - self.ref_geometry_path = ref_geometry_path - ref_geometry_path = Path(ref_geometry_path) - - output_message = self.tr( - "\nReference geometry path:\n" - f"\t{ref_geometry_path.parent}\n" - "Reference geometry file:\n" - f"\t{ref_geometry_path.name}" - ) - self.log_output(output_message) - - self.importReferenceGeometryPath.setText(ref_geometry_path.name) - def reset_options(self): self.options = self.default_options @@ -1370,643 +1349,74 @@ def load_options(self, saved_options_path: Path): def phil_params(self): pass - def update_options(self): - options = "" - - # import ####### - for variable in self.optionListImport: - if variable.isChecked(): - if variable == self.import_trust_beam_centre: - options = options + " trust_beam_centre=true" - if variable == self.import_reference_geometry: - if self.ref_geometry_path == "": - output_message = self.tr( - " *** Reference geometry error. Please select " - ".expt file with browse button first ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " reference_geometry=" - + str(self.ref_geometry_path) - ) - if variable == self.import_dd: - if self.import_dd_line_edit.text() == "": - output_message = self.tr( - " *** Detector Distance Error. Please input " - "detector distance e.g. 85.01" - ) - self.log_output(output_message) - return - else: - output_message = self.tr( - "Detector distance: " + str(self.import_dd_line_edit.text()) - ) - self.log_output(output_message) - options = ( - options - + " detector_distance=" - + str(self.import_dd_line_edit.text()) - ) - - if variable == self.import_beam_centre: - if self.import_beam_centre_x_line_edit.text() == "": - output_message = self.tr( - " *** Beam centre error. Please input Y" - ) - self.log_output(output_message) - return - elif self.import_beam_centre_y_line_edit.text() == "": - output_message = self.tr( - " *** Detector distance error. Please input X" - ) - self.log_output(output_message) - return - else: - output_message = self.tr( - "Detector distance: " - + str(self.import_beam_centre_x_line_edit.text()) - + "," - + str(self.import_beam_centre_y_line_edit.text()) - ) - self.log_output(output_message) - options = ( - options - + " mosflm_beam_centre=" - + str(self.import_beam_centre_x_line_edit.text()) - + "," - + str(self.import_beam_centre_y_line_edit.text()) - ) - - if variable == self.import_wavelengh: - if self.import_wavelength_line_edit.text() == "": - output_message = self.tr( - " *** Wavelength input error. " - "Please add wavelength e.g. 85.01" - ) - self.log_output(output_message) - return - else: - output_message = self.tr( - "Wavelength: " - + str(self.import_wavelength_line_edit.text()) - ) - self.log_output(output_message) - options = ( - options - + " wavelength=" - + str(self.import_wavelength_line_edit.text()) - ) - - if variable == self.import_fix_beam_detector_check_box: - options = ( - options + " integrate.phil_file=/dls_sw/i19/scripts/HP/" - "integration_additional_inputs.phil" - ) - - if variable == self.import_run_selector_check_box: - self.run_selection = [] - self.run_image_selector = True - for num, run in enumerate(self.runSelectorList, start=1): - if run.isChecked(): - self.run_selection.append(num) - self.log_output("Run selector: " + str(self.run_selection)) - if variable == self.Import_type_checkBox: - if self.Import_type_comboBox.currentText() == "Protein": - pass - else: - options = options + " small_molecule=True" - - # spot finding ####### - for variable in self.optionListSpotFinding: - if variable.isChecked(): - if variable == self.findSpots_sigmaStrong: - if self.findSpots_sigmaStrong_lineEdit.text() == "": - output_message = self.tr( - " *** Sigma strong error." - " Please enter sigma strong e.g. 6 ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " sigma_strong=" - + str(self.findSpots_sigmaStrong_lineEdit.text()) - ) - if variable == self.findSpots_minSpot: - if self.findSpots_minSpot_lineEdit.text() == "": - output_message = self.tr( - " *** Min spot size error, " - "please enter min spots size e.g. 2 ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " min_spot_size=" - + str(self.findSpots_minSpot_lineEdit.text()) - ) - if variable == self.findSpots_maxSpot: - if self.findSpots_maxSpot_lineEdit.text() == "": - output_message = self.tr( - " *** Max spot size error, " - "please enter max spots size e.g. 2 ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " max_spot_size=" - + str(self.findSpots_maxSpot_lineEdit.text()) - ) - if variable == self.findSpots_dmin: - if self.findSpots_dmin_lineEdit.text() == "": - output_message = self.tr( - " *** d_min error, please enter d_min e.g. 0.84 ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " d_min=" - + str(self.findSpots_dmin_lineEdit.text()) - ) - if variable == self.findSpots_dmax: - if self.findSpots_dmax_lineEdit.text() == "": - output_message = self.tr( - " *** d_max error, please enter d_max e.g. 10 ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " d_max=" - + str(self.findSpots_dmax_lineEdit.text()) - ) - if variable == self.findSpots_iceRings: - options = options + " ice_rings=true" - - if variable == self.findSpots_powderRings: - - powder_ring_line_edits = [ - self.findSpots_powderRingsUC_lineEdit.text(), - self.findSpots_powderRingsSG_lineEdit.text(), - self.findSpots_powderRingsW_lineEdit.text(), - ] - for entry in powder_ring_line_edits: - if entry == "": - output_message = self.tr( - " *** Powder ring mask error ***" - ) - self.log_output(output_message) - return - ice_rings_uv_command = " ice_rings.unit_cell=" + str( - self.findSpots_powderRingsUC_lineEdit.text() - ) - ice_rings_sg_command = " ice_rings.space_group=" + str( - self.findSpots_powderRingsSG_lineEdit.text() - ) - ice_rings_w_command = " ice_rings.width=" + str( - self.findSpots_powderRingsW_lineEdit.text() - ) - options = ( - options - + ice_rings_uv_command - + ice_rings_sg_command - + ice_rings_w_command - ) - - if variable == self.findSpots_resolutionRange: - find_spot_res_range_list = [ - self.findSpots_resolutionRange_lineEdit_1.text(), - self.findSpots_resolutionRange_lineEdit_2.text(), - self.findSpots_resolutionRange_lineEdit_3.text(), - self.findSpots_resolutionRange_lineEdit_4.text(), - self.findSpots_resolutionRange_lineEdit_5.text(), - self.findSpots_resolutionRange_lineEdit_6.text(), - self.findSpots_resolutionRange_lineEdit_7.text(), - self.findSpots_resolutionRange_lineEdit_8.text(), - self.findSpots_resolutionRange_lineEdit_9.text(), - self.findSpots_resolutionRange_lineEdit_10.text(), - ] - for res in find_spot_res_range_list: - if not res == "": - options = options + " resolution_range=" + str(res) - - if variable == self.findSpots_circleMask: - if self.findSpots_circleMask_lineEdit.text() == "": - output_message = self.tr( - " *** Circle mask error, please enter in the " - "following format: xc,yc,r ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " circle=" - + str(self.findSpots_circleMask_lineEdit.text()) - ) - - if variable == self.findSpots_recMask: - if self.findSpots_recMask_lineEdit.text() == "": - output_message = self.tr( - " *** Rectangle mask error, please enter is " - "the following format: x0,x1,y0,y1 ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " rectangle=" - + str(self.findSpots_recMask_lineEdit.text()) - ) - - # indexing ####### - for variable in self.optionListIndexing: - if variable.isChecked(): - if variable == self.Index_method_checkBox: - options = ( - options - + " method=" - + str(self.Index_method_comboBox.currentText()) - ) - if variable == self.Index_scanVarying_checkBox: - options = options + " scan_varying=False" - if variable == self.Index_UN_SG_checkBox: - uc_sg_line_edits = [ - self.Index_UN_lineEdit.text(), - self.Index_SG_lineEdit.text(), - ] - for entry in uc_sg_line_edits: - self.log_output(entry) - if entry == "": - output_message = self.tr( - " *** Error in unit cell or space group entry ***" - ) - self.log_output(output_message) - return - uc_command = " unit_cell=" + str(self.Index_UN_lineEdit.text()) - sg_command = " space_group=" + str(self.Index_SG_lineEdit.text()) - options = options + uc_command + sg_command - if variable == self.Index_minCell_checkBox: - if self.Index_minCell_lineEdit.text() == "": - output_message = self.tr( - " *** Please enter valid min cell ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " min_cell=" - + str(self.Index_minCell_lineEdit.text()) - ) - if variable == self.Index_maxCell_checkBox: - if self.Index_maxCell_lineEdit.text() == "": - output_message = self.tr( - " *** Please enter valid max cell ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " max_cell=" - + str(self.Index_maxCell_lineEdit.text()) - ) - if variable == self.Index_multiprocessing_checkBox: - options = options + " multi_sweep_processing=True" - if variable == self.Index_multiSweepRefine_checkBox: - options = options + " multi_sweep_refinement=False" - if variable == self.Index_outliers_checkBox: - options = options + " outlier.algorithm=null" - - # integrate ##### - for variable in self.optionListIntegrate: - if variable.isChecked(): - if variable == self.Integrate_keepAllReflections_checkBox: - options = options + " keep_all_reflections=true" - if variable == self.Integrate_scanVarying_checkBox: - options = options + " scan_varying=False" - if variable == self.Integrate_minSpotProfile_checkBox: - spot_profile_line_edits = [ - self.Integrate_minCellOverall_lineEdit.text(), - self.Integrate_minCellDegree_lineEdit.text(), - ] - for entry in spot_profile_line_edits: - if entry == "": - output_message = self.tr( - " *** Error in overall or per degree entry ***" - ) - self.log_output(output_message) - return - if self.visit == "": - output_message = self.tr( - " *** For this option a .phil needs to be created, " - "this requires a the visit to be known." - " Please open a dataset and retry (File>Open). ***" - ) - self.log_output(output_message) - return - overall_line = ( - " profile.gaussian_rs.min_spots.overall=" - + str(self.Integrate_minCellOverall_lineEdit.text()) - + "\n" - ) - degree_line = ( - " profile.gaussian_rs.min_spots.per_degree=" - + str(self.Integrate_minCellDegree_lineEdit.text()) - + "\n" - ) - xia2_gui_path = self.visit + "processing/xia2GUI/" - if not os.path.exists(xia2_gui_path): - os.makedirs(xia2_gui_path) - phil_file = xia2_gui_path + "integration_additional_inputs.phil" - with open(phil_file, "a") as f: - f.write( - "refinement_additional_inputs.phil:\n" - + overall_line - + degree_line - ) - options = options + " integrate.phil_file=" + phil_file - - # refine #### - for variable in self.optionListRefineScale: - if variable.isChecked(): - if variable == self.Refine_method_checkBox: - options = ( - options - + " method=" - + str(self.Refine_method_comboBox.currentText()) - ) - if variable == self.Refine_FixBeamDetector_checkBox: - xia2_gui_path = self.visit + "processing/xia2GUI/" - if not os.path.exists(xia2_gui_path): - os.makedirs(xia2_gui_path) - phil_file = xia2_gui_path + "refine_additional_inputs.phil" - with open(phil_file, "a") as f: - refine_line1 = "refinement.parameterisation.beam.fix=all\n" - refine_line2 = "refinement.parameterisation.detector.fix=all\n" - refine_line3 = ( - "refinement.parameterisation.auto_reduction.action=fix\n" - ) - f.write(refine_line1 + refine_line2 + refine_line3) - options = options + " refine.phil_file=" + phil_file - - # other ##### - for variable in self.optionListOther: - if variable.isChecked(): - if variable == self.Other_failover_checkBox: - options = options + " failover=true" - if variable == self.Other_manualInput1_checkBox: - options = options + " " + self.Other_manualInput1_lineEdit.text() - if variable == self.Other_manualInput2_checkBox: - options = options + " " + self.Other_manualInput2_lineEdit.text() - if variable == self.Other_manualInput3_checkBox: - options = options + " " + self.Other_manualInput3_lineEdit.text() - if variable == self.Other_manualInput4_checkBox: - options = options + " " + self.Other_manualInput4_lineEdit.text() - - # HP ##### - for variable in self.optionListHP: - if variable.isChecked(): - if variable == self.HP_correction_shadowing_checkBox: - options = ( - options - + " high_pressure.correction=True dynamic_shadowing=True " - "resolution_range=999,15" - ) - if variable == self.HP_scanVarying_checkBox: - options = options + " scan_varying=False" - if variable == self.HP_ReferenceGeometry_checkBox: - if self.ref_geometry_path == "": - output_message = self.tr( - " *** Reference geometry error. " - "Please select .expt file with browse button first ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " reference_geometry=" - + str(self.ref_geometry_path) - ) - if variable == self.HP_gasket_checkBox: - gasket_type = str(self.HP_gasket_comboBox.currentText()) - if gasket_type == "Tungsten": - options = ( - options + " ice_rings.filter=True " - "ice_rings.unit_cell=3.1652,3.1652,3.1652,90,90,90 " - "ice_rings.space_group=Im-3m " - "ice_rings.width=0.02" - ) - if gasket_type == "Steel": - # Steel gaskets are often either Fe or Ni. - # The unit cell for Fe is given below. - options = ( - options + " ice_rings.filter=True " - "ice_rings.unit_cell=2.87,2.87,2.87,90,90,90 " - "ice_rings.space_group=Im-3m " - "ice_rings.width=0.02" - ) - - if variable == self.HP_gasketUser_checkBox: - powder_ring_line_edits = [ - self.HP_gasketUserUC_lineEdit.text(), - self.HP_gasketUserSG_lineEdit.text(), - self.HP_gasketUserW_lineEdit.text(), - ] - for entry in powder_ring_line_edits: - if entry == "": - output_message = self.tr( - " *** Powder ring mask error ***" - ) - self.log_output(output_message) - return - ice_rings_uv_command = " ice_rings.unit_cell=" + str( - self.HP_gasketUserUC_lineEdit.text() - ) - ice_rings_sg_command = " ice_rings.space_group=" + str( - self.HP_gasketUserSG_lineEdit.text() - ) - ice_rings_w_command = " ice_rings.width=" + str( - self.HP_gasketUserW_lineEdit.text() - ) - options = ( - options - + ice_rings_uv_command - + ice_rings_sg_command - + ice_rings_w_command - ) - # medium difficulty: - if variable == self.HP_UN_SG_checkBox: - uc_sg_line_edits = [ - self.HP_UN_lineEdit.text(), - self.HP_SG_lineEdit.text(), - ] - for entry in uc_sg_line_edits: - self.log_output(entry) - if entry == "": - output_message = self.tr( - " *** Error in unit cell or space group entry ***" - ) - self.log_output(output_message) - return - uc_command = " unit_cell=" + str(self.HP_UN_lineEdit.text()) - sg_command = " space_group=" + str(self.HP_SG_lineEdit.text()) - options = options + uc_command + sg_command - - if variable == self.HP_dmin_checkBox: - if self.HP_dmin_lineEdit.text() == "": - output_message = self.tr( - " *** d_min HP error, please enter d_min e.g. 0.84 ***" - ) - self.log_output(output_message) - return - else: - options = ( - options + " d_min=" + str(self.HP_dmin_lineEdit.text()) - ) - - if variable == self.HP_runStartEnd_checkBox: - self.run_image_selector = True - counter = 0 - self.runStartEnd_lineEdits = [ - self.HP_runStartEnd_lineEdit_1.text(), - self.HP_runStartEnd_lineEdit_2.text(), - self.HP_runStartEnd_lineEdit_3.text(), - self.HP_runStartEnd_lineEdit_4.text(), - self.HP_runStartEnd_lineEdit_5.text(), - self.HP_runStartEnd_lineEdit_6.text(), - self.HP_runStartEnd_lineEdit_7.text(), - self.HP_runStartEnd_lineEdit_8.text(), - self.HP_runStartEnd_lineEdit_9.text(), - self.HP_runStartEnd_lineEdit_10.text(), - ] - - for entry in self.runStartEnd_lineEdits: - if entry == "": - counter += 1 - else: - self.image_selection[counter] = entry - counter += 1 - output_message = self.tr( - "Image start/end option selected.\n" - " " + str(self.image_selection) - ) - self.log_output(output_message) + def browse_for_reference_model(self): + ref_geometry_path = self.ref_geometry_path or self.opening_visit + ref_geometry_path, _filter = QtWidgets.QFileDialog.getOpenFileName( + parent=self, + caption=self.tr("Select calibrated instrument model"), + directory=ref_geometry_path, + filter=self.tr("DIALS experiment list files (*.expt)"), + ) + if ref_geometry_path: + self.ref_geometry_path = ref_geometry_path + ref_geometry_path = Path(ref_geometry_path) - if variable == self.HP_FixBeamDetector_checkBox: - options = ( - options + " integrate.phil_file=/dls_sw/i19/scripts/HP/" - "integration_additional_inputs.phil" - ) - # integration_additional_inputs.phil: - # refinement.parameterisation.beam.fix=all - # refinement.parameterisation.detector.fix=all - # refinement.parameterisation.auto_reduction.action=fix + output_message = self.tr( + "\nReference geometry path:\n" + f"\t{ref_geometry_path.parent}\n" + "Reference geometry file:\n" + f"\t{ref_geometry_path.name}" + ) + self.log_output(output_message) - if variable == self.HP_anvilThickness_checkBox: - if self.HP_anvilThickness_lineEdit.text() == "": - output_message = self.tr( - " *** Anvil thickness input error, " - "please enter thickness e.g. 2.1 ***" - ) - self.log_output(output_message) - return - else: - options = ( - options - + " high_pressure.anvil.thickness=" - + str(self.HP_anvilThickness_lineEdit.text()) - ) + self.importReferenceGeometryPath.setText(ref_geometry_path.name) - if variable == self.HP_anvilOpeningAngle_checkBox: - if self.HP_anvilOpeningAngle_lineEdit.text() == "": - output_message = self.tr( - " *** Anvil opening angle input error, " - "please enter opening angle e.g. 38 ***" - ) - self.log_output(output_message) - return - else: - pass - # options = options + " high_pressure.anvil.angle=" + \ - # str(self.HP_anvilOpeningAngle_lineEdit.text()) + def construct_phil_params(self, widget: str, specification: Option): + options = self.options - if not self.dataset_path == "MULTIPLE": + phil = specification.phil + if not isinstance(phil, list): + phil = [phil] - if not self.run_image_selector: - dataset_input = self.dataset_path - - else: # causing issues when multiple ########### - if self.dataset_path == "": - dataset_input = self.dataset_path - self.log_output( - "Dataset must be selected before selecting runs or images " - "start/end" - ) - else: - dataset_input = "" - if self.run_selection: # runs have been selected - for entry in self.run_selection: - dataset_input = ( - dataset_input - + " image=" - + self.dataset_path - + "/" - + self.prefix - + str("%02d_00001.cbf" % int(entry)) - ) - if (entry - 1) in self.image_selection: - dataset_input = ( - dataset_input - + ":" - + self.image_selection[entry - 1] - ) - else: # runs have NOT been selected - for run in self.run_list: - dataset_input = ( - dataset_input - + " image=" - + self.dataset_path - + "/" - + self.prefix - + str("%02d_00001.cbf" % int(run)) - ) - if (run - 1) in self.image_selection: - dataset_input = ( - dataset_input + ":" + self.image_selection[run - 1] - ) + value = specification.value + if value is None: + value = [] + elif not isinstance(value, list): + value = [value] + value = list(map(options.get, [widget] + value)) - self.dataset_path = dataset_input + condition = specification.condition + if callable(condition): + condition = condition(*value) + else: + if condition is None: + condition = [] + elif not isinstance(condition, list): + condition = [condition] + condition = list(map(options.get, condition)) + condition = all(condition + value) + + if condition: + convert = specification.convert + if convert: + result = convert(*value) + if isinstance(result, str) or not isinstance(result, Iterable): + result = [result] + else: + result = value - self.log_output( - "\n\nUpdating options" - + "\n Xia2 command: " - + "\n " - + self.xia2_command - + self.dataset_path - + options - ) + result = map(str, result) + return ["=".join(pair) for pair in zip(phil, result)] - ui_main_window = self.parent() - ui_main_window.xia2_command = self.xia2_command - ui_main_window.dataset_path = self.dataset_path - ui_main_window.xia2_options_list = options - ui_main_window.update_options() + def filterable_phil_params(self, item): + return self.construct_phil_params(*item) + def update_options(self): self.save_options_auto() + params = map(self.filterable_phil_params, option_specification.items()) + params = chain.from_iterable(filter(None, params)) + self.parent().xia2_options_list = " ".join(params) + self.parent().update_options() if __name__ == "__main__": From f68831cc3f819b24ee1511f819a6525eebdf67f9 Mon Sep 17 00:00:00 2001 From: Ben Williams Date: Wed, 16 Dec 2020 18:44:20 +0000 Subject: [PATCH 31/31] Simplify mapping of phil parameter generation --- i19-gui/chemical_crystallography_gui.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/i19-gui/chemical_crystallography_gui.py b/i19-gui/chemical_crystallography_gui.py index 5472232..1f9d9cb 100644 --- a/i19-gui/chemical_crystallography_gui.py +++ b/i19-gui/chemical_crystallography_gui.py @@ -1346,9 +1346,6 @@ def load_options(self, saved_options_path: Path): with open(saved_options_path) as f: self.options = json.load(f) - def phil_params(self): - pass - def browse_for_reference_model(self): ref_geometry_path = self.ref_geometry_path or self.opening_visit ref_geometry_path, _filter = QtWidgets.QFileDialog.getOpenFileName( @@ -1371,7 +1368,7 @@ def browse_for_reference_model(self): self.importReferenceGeometryPath.setText(ref_geometry_path.name) - def construct_phil_params(self, widget: str, specification: Option): + def phil_params(self, widget: str, specification: Option): options = self.options phil = specification.phil @@ -1408,12 +1405,10 @@ def construct_phil_params(self, widget: str, specification: Option): result = map(str, result) return ["=".join(pair) for pair in zip(phil, result)] - def filterable_phil_params(self, item): - return self.construct_phil_params(*item) - def update_options(self): self.save_options_auto() - params = map(self.filterable_phil_params, option_specification.items()) + items = option_specification.keys(), option_specification.values() + params = map(self.phil_params, *items) params = chain.from_iterable(filter(None, params)) self.parent().xia2_options_list = " ".join(params) self.parent().update_options()