mlgidGUI 0.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mlgidGUI/__init__.py +52 -0
- mlgidGUI/__main__.py +7 -0
- mlgidGUI/__version.py +1 -0
- mlgidGUI/app/__init__.py +8 -0
- mlgidGUI/app/actions_stack.py +1 -0
- mlgidGUI/app/app.py +67 -0
- mlgidGUI/app/cif_rois/__init__.py +0 -0
- mlgidGUI/app/cif_rois/cif_peaks_calculation.py +57 -0
- mlgidGUI/app/cif_rois/cif_simulation/__init__.py +0 -0
- mlgidGUI/app/cif_rois/cif_simulation/data/__init__.py +0 -0
- mlgidGUI/app/cif_rois/cif_simulation/data/atoms.py +15 -0
- mlgidGUI/app/cif_rois/cif_simulation/data/export_database.py +28 -0
- mlgidGUI/app/cif_rois/cif_simulation/experiment.py +57 -0
- mlgidGUI/app/cif_rois/cif_simulation/giwaxs_sim.py +286 -0
- mlgidGUI/app/cif_rois/cif_simulation/int_sim.py +105 -0
- mlgidGUI/app/cif_rois/cif_simulation/possible_directions.py +20 -0
- mlgidGUI/app/cif_rois/cif_simulation/q_sim.py +159 -0
- mlgidGUI/app/data_manager/__init__.py +4 -0
- mlgidGUI/app/data_manager/data_manager.py +164 -0
- mlgidGUI/app/data_manager/import_from_h5.py +68 -0
- mlgidGUI/app/data_manager/load_data.py +78 -0
- mlgidGUI/app/data_manager/pascal/__init__.py +2 -0
- mlgidGUI/app/data_manager/pascal/annotation_fabric.py +59 -0
- mlgidGUI/app/data_manager/pascal/draw_objects.py +119 -0
- mlgidGUI/app/data_manager/pascal/exceptions.py +6 -0
- mlgidGUI/app/data_manager/pascal/format_convertor.py +127 -0
- mlgidGUI/app/data_manager/pascal/pascal_annotation.py +85 -0
- mlgidGUI/app/data_manager/pascal/protocol_implementations.py +28 -0
- mlgidGUI/app/data_manager/pascal/protocols.py +47 -0
- mlgidGUI/app/data_manager/pascal/utils.py +64 -0
- mlgidGUI/app/data_manager/save_dataset.py +57 -0
- mlgidGUI/app/data_manager/save_h5.py +178 -0
- mlgidGUI/app/data_manager/saving_parameters.py +88 -0
- mlgidGUI/app/debug_tracker.py +129 -0
- mlgidGUI/app/edf_reader.py +135 -0
- mlgidGUI/app/file_manager/__init__.py +201 -0
- mlgidGUI/app/file_manager/config_manager.py +76 -0
- mlgidGUI/app/file_manager/keys.py +542 -0
- mlgidGUI/app/file_manager/npy_file_manager.py +17 -0
- mlgidGUI/app/file_manager/object_file_manager.py +77 -0
- mlgidGUI/app/file_manager/project_structure.py +169 -0
- mlgidGUI/app/file_manager/read_fits.py +76 -0
- mlgidGUI/app/file_manager/read_geometry.py +54 -0
- mlgidGUI/app/file_manager/read_images.py +31 -0
- mlgidGUI/app/file_manager/read_meta_roi.py +40 -0
- mlgidGUI/app/file_manager/read_polar_images.py +22 -0
- mlgidGUI/app/file_manager/read_radial_profile.py +6 -0
- mlgidGUI/app/file_manager/read_roi_data.py +39 -0
- mlgidGUI/app/fitting/__init__.py +5 -0
- mlgidGUI/app/fitting/background.py +92 -0
- mlgidGUI/app/fitting/fit.py +128 -0
- mlgidGUI/app/fitting/fit_holder.py +273 -0
- mlgidGUI/app/fitting/fit_object.py +247 -0
- mlgidGUI/app/fitting/functions.py +107 -0
- mlgidGUI/app/fitting/range_strategy.py +14 -0
- mlgidGUI/app/fitting/utils.py +17 -0
- mlgidGUI/app/geometry.py +236 -0
- mlgidGUI/app/geometry_holder.py +131 -0
- mlgidGUI/app/image_holder.py +200 -0
- mlgidGUI/app/image_processing.py +23 -0
- mlgidGUI/app/polar_image.py +96 -0
- mlgidGUI/app/profiles/__init__.py +5 -0
- mlgidGUI/app/profiles/angular_profile.py +20 -0
- mlgidGUI/app/profiles/basic_profile.py +169 -0
- mlgidGUI/app/profiles/radial_profile.py +38 -0
- mlgidGUI/app/read_image.py +21 -0
- mlgidGUI/app/rois/__init__.py +4 -0
- mlgidGUI/app/rois/new_roi_dict.py +670 -0
- mlgidGUI/app/rois/roi.py +194 -0
- mlgidGUI/app/rois/roi_colors.py +76 -0
- mlgidGUI/app/rois/roi_data.py +177 -0
- mlgidGUI/app/rois/roi_dict.py +466 -0
- mlgidGUI/app/rois/roi_meta_data.py +149 -0
- mlgidGUI/app/structures/__init__.py +6 -0
- mlgidGUI/app/structures/crystal_ring.py +19 -0
- mlgidGUI/app/structures/crystals_holders.py +144 -0
- mlgidGUI/app/structures/custom_crystal.py +45 -0
- mlgidGUI/app/structures/get_ring_list.py +89 -0
- mlgidGUI/app/transformations.py +82 -0
- mlgidGUI/app/update/__init__.py +3 -0
- mlgidGUI/app/update/check_version.py +51 -0
- mlgidGUI/app/update/launch_program.py +15 -0
- mlgidGUI/app/update/script_update.py +64 -0
- mlgidGUI/app/utils.py +124 -0
- mlgidGUI/gui/__init__.py +3 -0
- mlgidGUI/gui/background_tasks.py +41 -0
- mlgidGUI/gui/background_update.py +87 -0
- mlgidGUI/gui/basic_widgets/__init__.py +12 -0
- mlgidGUI/gui/basic_widgets/buttons.py +144 -0
- mlgidGUI/gui/basic_widgets/labels.py +51 -0
- mlgidGUI/gui/basic_widgets/mouse_events.py +119 -0
- mlgidGUI/gui/basic_widgets/path_line.py +162 -0
- mlgidGUI/gui/basic_widgets/plots_1d.py +365 -0
- mlgidGUI/gui/basic_widgets/plots_2d.py +224 -0
- mlgidGUI/gui/basic_widgets/popups.py +164 -0
- mlgidGUI/gui/basic_widgets/progress_bar.py +127 -0
- mlgidGUI/gui/basic_widgets/setup_widgets.py +138 -0
- mlgidGUI/gui/basic_widgets/sliders.py +616 -0
- mlgidGUI/gui/basic_widgets/spinner.py +65 -0
- mlgidGUI/gui/basic_widgets/toolbars.py +19 -0
- mlgidGUI/gui/debug_widgets.py +388 -0
- mlgidGUI/gui/dock_area.py +115 -0
- mlgidGUI/gui/exception_message.py +42 -0
- mlgidGUI/gui/fitting/__init__.py +2 -0
- mlgidGUI/gui/fitting/fit_widget.py +966 -0
- mlgidGUI/gui/fitting/inplace_fit.py +536 -0
- mlgidGUI/gui/fitting/selected_fit_widget.py +286 -0
- mlgidGUI/gui/gui_main.py +349 -0
- mlgidGUI/gui/image_viewer.py +323 -0
- mlgidGUI/gui/init_window.py +170 -0
- mlgidGUI/gui/load_window/__init__.py +2 -0
- mlgidGUI/gui/load_window/load_folder.py +61 -0
- mlgidGUI/gui/load_window/load_h5.py +73 -0
- mlgidGUI/gui/notifications.py +68 -0
- mlgidGUI/gui/polar_image_viewer.py +153 -0
- mlgidGUI/gui/profiles/__init__.py +1 -0
- mlgidGUI/gui/profiles/angular_profile_widget.py +62 -0
- mlgidGUI/gui/profiles/radial_profile_widget.py +164 -0
- mlgidGUI/gui/project_manager/__init__.py +17 -0
- mlgidGUI/gui/project_manager/cif_files_widget.py +196 -0
- mlgidGUI/gui/project_manager/cif_results.py +146 -0
- mlgidGUI/gui/project_manager/metadata_widget.py +15 -0
- mlgidGUI/gui/project_manager/project_viewer.py +151 -0
- mlgidGUI/gui/project_manager/roi_widget.py +171 -0
- mlgidGUI/gui/roi_widgets/__init__.py +6 -0
- mlgidGUI/gui/roi_widgets/abstract_roi_holder.py +189 -0
- mlgidGUI/gui/roi_widgets/abstract_roi_widget.py +111 -0
- mlgidGUI/gui/roi_widgets/cif_file_widget.py +16 -0
- mlgidGUI/gui/roi_widgets/cif_peak_widget.py +43 -0
- mlgidGUI/gui/roi_widgets/confidence_level_widget.py +105 -0
- mlgidGUI/gui/roi_widgets/roi_1d_widget.py +136 -0
- mlgidGUI/gui/roi_widgets/roi_2d_rect_widget.py +98 -0
- mlgidGUI/gui/roi_widgets/roi_2d_ring_widget.py +203 -0
- mlgidGUI/gui/roi_widgets/rois_context_menu.py +150 -0
- mlgidGUI/gui/roi_widgets/select_roi_color_widget.py +58 -0
- mlgidGUI/gui/save_window/__init__.py +152 -0
- mlgidGUI/gui/save_window/format_box.py +33 -0
- mlgidGUI/gui/save_window/num_selected_widget.py +45 -0
- mlgidGUI/gui/save_window/options_widgets.py +105 -0
- mlgidGUI/gui/save_window/save_mode_box.py +30 -0
- mlgidGUI/gui/save_window/select_images.py +198 -0
- mlgidGUI/gui/tools.py +179 -0
- mlgidGUI/static/__init__.py +0 -0
- mlgidGUI/static/icons/__init__.py +0 -0
- mlgidGUI/static/icons/add.png +0 -0
- mlgidGUI/static/icons/add_yellow.png +0 -0
- mlgidGUI/static/icons/angular_profile.png +0 -0
- mlgidGUI/static/icons/arrow.png +0 -0
- mlgidGUI/static/icons/baseline.png +0 -0
- mlgidGUI/static/icons/center.png +0 -0
- mlgidGUI/static/icons/confirm.png +0 -0
- mlgidGUI/static/icons/control_widget.png +0 -0
- mlgidGUI/static/icons/data.png +0 -0
- mlgidGUI/static/icons/delete.png +0 -0
- mlgidGUI/static/icons/delete_yellow.png +0 -0
- mlgidGUI/static/icons/error.png +0 -0
- mlgidGUI/static/icons/find.png +0 -0
- mlgidGUI/static/icons/fit.png +0 -0
- mlgidGUI/static/icons/fix_all.png +0 -0
- mlgidGUI/static/icons/flip_horizontal.png +0 -0
- mlgidGUI/static/icons/flip_vertical.png +0 -0
- mlgidGUI/static/icons/folder.png +0 -0
- mlgidGUI/static/icons/fromfullscreen.png +0 -0
- mlgidGUI/static/icons/h5_folder.png +0 -0
- mlgidGUI/static/icons/h5_group_folder.png +0 -0
- mlgidGUI/static/icons/info.png +0 -0
- mlgidGUI/static/icons/interpolate.png +0 -0
- mlgidGUI/static/icons/item.png +0 -0
- mlgidGUI/static/icons/properties.png +0 -0
- mlgidGUI/static/icons/radial_profile.png +0 -0
- mlgidGUI/static/icons/roi_item.png +0 -0
- mlgidGUI/static/icons/rotate.png +0 -0
- mlgidGUI/static/icons/rotate_image.png +0 -0
- mlgidGUI/static/icons/rotate_right.png +0 -0
- mlgidGUI/static/icons/setup.png +0 -0
- mlgidGUI/static/icons/setup_white.png +0 -0
- mlgidGUI/static/icons/tofullscreen.png +0 -0
- mlgidGUI/static/icons/unfix_all.png +0 -0
- mlgidGUI/static/icons/update.png +0 -0
- mlgidGUI/static/icons/update_suggested.png +0 -0
- mlgidGUI/static/icons/window_icon.png +0 -0
- mlgidGUI/static/icons/window_icon_256.png +0 -0
- mlgidGUI/utils/__init__.py +1 -0
- mlgidGUI/utils/project2h5.py +11 -0
- mlgidgui-0.4.1.dist-info/METADATA +119 -0
- mlgidgui-0.4.1.dist-info/RECORD +202 -0
- mlgidgui-0.4.1.dist-info/WHEEL +5 -0
- mlgidgui-0.4.1.dist-info/entry_points.txt +5 -0
- mlgidgui-0.4.1.dist-info/licenses/LICENSE +674 -0
- mlgidgui-0.4.1.dist-info/top_level.txt +4 -0
- tests/__init__.py +0 -0
- tests/conftest.py +1 -0
- tests/fixures/__init__.py +2 -0
- tests/fixures/projects.py +102 -0
- tests/func/__init__.py +1 -0
- tests/func/test_loading_state.py +21 -0
- tests/func/test_parse_project_data.py +23 -0
- tests/func/test_save.py +62 -0
- tests/unit/__init__.py +0 -0
- tests/unit/rois/__init__.py +0 -0
- tests/unit/rois/test_basic_operations.py +18 -0
- tests/unit/test_add_data.py +33 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# import logging
|
|
2
|
+
# from typing import List, Dict, Iterable, Union
|
|
3
|
+
# from enum import Enum, auto
|
|
4
|
+
# import gc
|
|
5
|
+
#
|
|
6
|
+
# import numpy as np
|
|
7
|
+
#
|
|
8
|
+
# from PyQt5.QtWidgets import (QWidget, QGridLayout, QPushButton,
|
|
9
|
+
# QLabel, QFrame, QSplitter, QMenu,
|
|
10
|
+
# QMessageBox, QComboBox, QScrollArea,
|
|
11
|
+
# QSizePolicy)
|
|
12
|
+
# from PyQt5.QtGui import QColor, QCursor
|
|
13
|
+
# from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
|
14
|
+
#
|
|
15
|
+
# from ..roi_widgets.roi_2d_rect_widget import Roi2DRect
|
|
16
|
+
# from ..roi_widgets.roi_1d_widget import Roi1D
|
|
17
|
+
#
|
|
18
|
+
# from ...app.fitting import Fit, FitObject, FittingType, BackgroundType, RangeStrategyType, RangeStrategy
|
|
19
|
+
# from ...app.file_manager import ImageKey, FolderKey
|
|
20
|
+
# from ...app.rois.roi_data import Roi, RoiTypes
|
|
21
|
+
# from ...app import App
|
|
22
|
+
# from ..tools import Icon, get_pen, center_widget
|
|
23
|
+
# from ..basic_widgets import (Custom1DPlot, CustomImageViewer, PlotBC,
|
|
24
|
+
# ParametersSlider, LabeledSlider)
|
|
25
|
+
#
|
|
26
|
+
#
|
|
27
|
+
# class SelectedFitMode(Enum):
|
|
28
|
+
# view = auto()
|
|
29
|
+
# fit = auto()
|
|
30
|
+
#
|
|
31
|
+
#
|
|
32
|
+
# class SelectedFitWidget(QWidget):
|
|
33
|
+
# sigFitChanged = pyqtSignal()
|
|
34
|
+
#
|
|
35
|
+
# def __init__(self, fit: Fit = None,
|
|
36
|
+
# mode: SelectedFitMode = SelectedFitMode.view,
|
|
37
|
+
# parent=None, flags=None):
|
|
38
|
+
# super().__init__(parent, flags=flags)
|
|
39
|
+
# self.__fit: Fit or None = None
|
|
40
|
+
# self.__mode: SelectedFitMode = mode
|
|
41
|
+
#
|
|
42
|
+
# if fit:
|
|
43
|
+
# self.set_fit(fit)
|
|
44
|
+
#
|
|
45
|
+
#
|
|
46
|
+
# class SelectedFitLabel(QLabel):
|
|
47
|
+
# def __init__(self, fit: Fit = None, parent=None):
|
|
48
|
+
# super().__init__(parent=parent)
|
|
49
|
+
# self._fit = fit
|
|
50
|
+
# self.update_text()
|
|
51
|
+
#
|
|
52
|
+
# @pyqtSlot(name='updateText')
|
|
53
|
+
# def update_text(self):
|
|
54
|
+
# if not self._fit:
|
|
55
|
+
# text = 'Selected Fit'
|
|
56
|
+
# elif self._fit.roi.type == RoiTypes.ring:
|
|
57
|
+
# text = f'Selected Fit: Ring {self._fit.roi.name}'
|
|
58
|
+
# else:
|
|
59
|
+
# text = f'Selected Fit: Segment {self._fit.roi.name} (no baseline correction)'
|
|
60
|
+
# self.setText(text)
|
|
61
|
+
#
|
|
62
|
+
# @pyqtSlot(object, name='setFit')
|
|
63
|
+
# def set_fit(self, fit: Fit):
|
|
64
|
+
# self._fit = fit
|
|
65
|
+
# self.update_text()
|
|
66
|
+
#
|
|
67
|
+
# @pyqtSlot(name='removeFit')
|
|
68
|
+
# def remove_fit(self):
|
|
69
|
+
# self._fit = None
|
|
70
|
+
# self.update_text()
|
|
71
|
+
#
|
|
72
|
+
#
|
|
73
|
+
# class SlidersWidget(QWidget):
|
|
74
|
+
# sigValueChanged = pyqtSignal()
|
|
75
|
+
#
|
|
76
|
+
# DEFAULT_LABEL = 'lower bound; init value; upper bound'
|
|
77
|
+
#
|
|
78
|
+
# log = logging.getLogger(__name__)
|
|
79
|
+
#
|
|
80
|
+
# def __init__(self, param_names: tuple = (), parent=None):
|
|
81
|
+
# super().__init__(parent=parent)
|
|
82
|
+
# self.fit: Fit = None
|
|
83
|
+
# self.param_names = param_names
|
|
84
|
+
#
|
|
85
|
+
# self._sliders: Dict[int, ParametersSlider] = {}
|
|
86
|
+
# self._labels: Dict[int, QLabel] = {}
|
|
87
|
+
# self._param_labels: Dict[int, QLabel] = {}
|
|
88
|
+
#
|
|
89
|
+
# self._init_ui()
|
|
90
|
+
#
|
|
91
|
+
# @pyqtSlot(object, name='setFit')
|
|
92
|
+
# def set_fit(self, fit: Fit):
|
|
93
|
+
# self.fit = fit
|
|
94
|
+
# self._set_param_names(fit.param_names)
|
|
95
|
+
# self.update_values()
|
|
96
|
+
#
|
|
97
|
+
# @pyqtSlot(name='updateFit')
|
|
98
|
+
# def update_fit(self):
|
|
99
|
+
# if self.fit:
|
|
100
|
+
# self._set_param_names(self.fit.param_names)
|
|
101
|
+
# self.update_values()
|
|
102
|
+
#
|
|
103
|
+
# @pyqtSlot(name='updateValues')
|
|
104
|
+
# def update_values(self):
|
|
105
|
+
# if not self.fit:
|
|
106
|
+
# return
|
|
107
|
+
# fit = self.fit
|
|
108
|
+
# for idx, (l, i, u) in enumerate(zip(fit.lower_bounds, fit.init_params, fit.upper_bounds)):
|
|
109
|
+
# try:
|
|
110
|
+
# self._sliders[idx].setValues(l, i, u, new_range=(l, u))
|
|
111
|
+
# except ValueError as err:
|
|
112
|
+
# self.log.error(f'{self._param_labels[idx].text()} received wrong values.')
|
|
113
|
+
# self.log.exception(err)
|
|
114
|
+
# self._update_label(idx, l, i, u)
|
|
115
|
+
#
|
|
116
|
+
# def remove_fit(self):
|
|
117
|
+
# self.fit = None
|
|
118
|
+
# for l in self._labels.values():
|
|
119
|
+
# l.setText(self.DEFAULT_LABEL)
|
|
120
|
+
#
|
|
121
|
+
# def _set_param_names(self, param_names: tuple):
|
|
122
|
+
# if param_names == self.param_names:
|
|
123
|
+
# return
|
|
124
|
+
#
|
|
125
|
+
# i = 0
|
|
126
|
+
# for i, name in enumerate(param_names):
|
|
127
|
+
# if i == len(self._param_labels):
|
|
128
|
+
# self._add_parameter(i, name)
|
|
129
|
+
# else:
|
|
130
|
+
# self._param_labels[i].setText(name)
|
|
131
|
+
#
|
|
132
|
+
# if i < len(self.param_names) - 1:
|
|
133
|
+
# for j in range(i + 1, len(self.param_names)):
|
|
134
|
+
# self._remove_parameter(j)
|
|
135
|
+
#
|
|
136
|
+
# self.param_names = param_names
|
|
137
|
+
#
|
|
138
|
+
# def _init_ui(self):
|
|
139
|
+
# self._layout = QGridLayout(self)
|
|
140
|
+
#
|
|
141
|
+
# for i, param_name in enumerate(self.param_names):
|
|
142
|
+
# self._add_parameter(i, param_name)
|
|
143
|
+
#
|
|
144
|
+
# def _add_parameter(self, i: int, param_name: str):
|
|
145
|
+
# self._param_labels[i] = pl = QLabel(param_name)
|
|
146
|
+
# self._sliders[i] = sl = ParametersSlider()
|
|
147
|
+
# self._labels[i] = ll = QLabel(self.DEFAULT_LABEL)
|
|
148
|
+
# self._layout.addWidget(pl, i, 0, alignment=Qt.AlignCenter)
|
|
149
|
+
# self._layout.addWidget(_SliderWithLabels(sl, ll, self), i, 1)
|
|
150
|
+
# sl.sigLowerValueChanged.connect(lambda x, idx=i: self._send_value(x, 0, idx))
|
|
151
|
+
# sl.sigMiddleValueChanged.connect(lambda x, idx=i: self._send_value(x, 1, idx))
|
|
152
|
+
# sl.sigUpperValueChanged.connect(lambda x, idx=i: self._send_value(x, 2, idx))
|
|
153
|
+
#
|
|
154
|
+
# if App().debug_tracker:
|
|
155
|
+
# App().debug_tracker.add_object(pl)
|
|
156
|
+
# App().debug_tracker.add_object(sl)
|
|
157
|
+
# App().debug_tracker.add_object(ll)
|
|
158
|
+
#
|
|
159
|
+
# def _remove_parameter(self, i: int):
|
|
160
|
+
# pl = self._param_labels.pop(i)
|
|
161
|
+
# sl = self._sliders.pop(i)
|
|
162
|
+
# ll = self._labels.pop(i)
|
|
163
|
+
# self._layout.removeWidget(pl)
|
|
164
|
+
# self._layout.removeWidget(sl)
|
|
165
|
+
# self._layout.removeWidget(ll)
|
|
166
|
+
# pl.deleteLater()
|
|
167
|
+
# sl.deleteLater()
|
|
168
|
+
# ll.deleteLater()
|
|
169
|
+
#
|
|
170
|
+
# def _update_label(self, idx: int, l: float, i: float, u: float):
|
|
171
|
+
# self._labels[idx].setText(f'lower bound = {l:0.3f}; init value = {i:0.3f}; upper bound = {u:0.3f}')
|
|
172
|
+
#
|
|
173
|
+
# def _send_value(self, value: float, place: int, idx: int):
|
|
174
|
+
# if not self.fit:
|
|
175
|
+
# return
|
|
176
|
+
# if place == 0:
|
|
177
|
+
# params = self.fit.lower_bounds
|
|
178
|
+
# elif place == 1:
|
|
179
|
+
# params = self.fit.init_params
|
|
180
|
+
# else:
|
|
181
|
+
# params = self.fit.upper_bounds
|
|
182
|
+
# params[idx] = value
|
|
183
|
+
#
|
|
184
|
+
# self._update_label(
|
|
185
|
+
# idx, self.fit.lower_bounds[idx], self.fit.init_params[idx], self.fit.upper_bounds[idx])
|
|
186
|
+
#
|
|
187
|
+
# self.sigValueChanged.emit()
|
|
188
|
+
#
|
|
189
|
+
#
|
|
190
|
+
# class CurrentFitButtonStatus(Enum):
|
|
191
|
+
# fit = 'Fit roi'
|
|
192
|
+
# unfix = 'Unfix'
|
|
193
|
+
#
|
|
194
|
+
#
|
|
195
|
+
# class FitOptionsWidget(QWidget):
|
|
196
|
+
# def __init__(self, fit: Fit = None, parent=None):
|
|
197
|
+
# super().__init__(parent)
|
|
198
|
+
# self.fit = None
|
|
199
|
+
# self._init_ui()
|
|
200
|
+
# if fit:
|
|
201
|
+
# self.set_fit(fit)
|
|
202
|
+
#
|
|
203
|
+
# def _init_ui(self):
|
|
204
|
+
# self.functions_box = QComboBox(self)
|
|
205
|
+
# self.background_box = QComboBox(self)
|
|
206
|
+
# self.range_strategies_box = QComboBox(self)
|
|
207
|
+
#
|
|
208
|
+
# self.range_factor_slider = LabeledSlider('Y range factor', (0, 10), parent=self, decimals=2)
|
|
209
|
+
# self.range_factor_slider.valueChanged.connect(self._on_range_slider_moved)
|
|
210
|
+
# self.sigma_slider = LabeledSlider('Sigma', (0, 10), parent=self, decimals=2)
|
|
211
|
+
# self.sigma_slider.valueChanged.connect(self._on_sigma_slider_moved)
|
|
212
|
+
# self.fit_current_button = QPushButton(CurrentFitButtonStatus.fit.value)
|
|
213
|
+
# self.fit_current_button.clicked.connect(self._fit_current_clicked)
|
|
214
|
+
# self.update_data_button = QPushButton('Update fit')
|
|
215
|
+
#
|
|
216
|
+
# self.functions_box.addItem('Fitting functions')
|
|
217
|
+
# for t in FittingType:
|
|
218
|
+
# self.functions_box.addItem(t.value)
|
|
219
|
+
# self.background_box.addItem('Backgrounds')
|
|
220
|
+
# for t in BackgroundType:
|
|
221
|
+
# self.background_box.addItem(t.value)
|
|
222
|
+
# self.range_strategies_box.addItem('Range strategy')
|
|
223
|
+
# for t in RangeStrategyType:
|
|
224
|
+
# self.range_strategies_box.addItem(t.value)
|
|
225
|
+
#
|
|
226
|
+
# @pyqtSlot(object, name='setFit')
|
|
227
|
+
# def set_fit(self, fit: Fit):
|
|
228
|
+
# pass
|
|
229
|
+
#
|
|
230
|
+
#
|
|
231
|
+
# class FitPlot(Custom1DPlot):
|
|
232
|
+
# log = logging.getLogger(__name__)
|
|
233
|
+
#
|
|
234
|
+
# def __init__(self, parent=None):
|
|
235
|
+
# super().__init__(parent=parent)
|
|
236
|
+
# self.fit: Fit or None = None
|
|
237
|
+
# self.fit_plot = self.plot_item.plot()
|
|
238
|
+
# self.background_plot = self.plot_item.plot()
|
|
239
|
+
# self.fit_plot.setPen(get_pen(color='red', style=Qt.DashDotDotLine, width=4))
|
|
240
|
+
# self.background_plot.setPen(get_pen(color='blue', style=Qt.DashDotDotLine, width=4))
|
|
241
|
+
#
|
|
242
|
+
# @pyqtSlot(object, name='setFit')
|
|
243
|
+
# def set_fit(self, fit: Fit):
|
|
244
|
+
# self.fit = fit
|
|
245
|
+
# self.update_plot()
|
|
246
|
+
#
|
|
247
|
+
# @pyqtSlot(name='updatePlot')
|
|
248
|
+
# def update_plot(self):
|
|
249
|
+
# if not self.fit:
|
|
250
|
+
# return
|
|
251
|
+
# try:
|
|
252
|
+
# self.plot.setData(self.fit.x, self.fit.y)
|
|
253
|
+
# self.fit_plot.setData(self.fit.x, self.fit.init_curve)
|
|
254
|
+
# if self.fit.background_curve is not None:
|
|
255
|
+
# self.background_plot.setData(self.fit.x, self.fit.background_curve)
|
|
256
|
+
# else:
|
|
257
|
+
# self.background_plot.clear()
|
|
258
|
+
# self.plot_item.autoRange()
|
|
259
|
+
#
|
|
260
|
+
# except Exception as err:
|
|
261
|
+
# self.log.exception(err)
|
|
262
|
+
# self._clear_plot()
|
|
263
|
+
#
|
|
264
|
+
# @pyqtSlot(name='removeFit')
|
|
265
|
+
# def remove_fit(self):
|
|
266
|
+
# self.fit = None
|
|
267
|
+
# self._clear_plot()
|
|
268
|
+
#
|
|
269
|
+
# def _clear_plot(self):
|
|
270
|
+
# self.plot.clear()
|
|
271
|
+
# self.fit_plot.clear()
|
|
272
|
+
# self.background_plot.clear()
|
|
273
|
+
# self.update()
|
|
274
|
+
#
|
|
275
|
+
#
|
|
276
|
+
# class _SliderWithLabels(QFrame):
|
|
277
|
+
# def __init__(self, slider: ParametersSlider, label: QLabel, parent=None):
|
|
278
|
+
# super().__init__(parent=parent)
|
|
279
|
+
# self.slider = slider
|
|
280
|
+
# self.label = label
|
|
281
|
+
# self._init_ui()
|
|
282
|
+
#
|
|
283
|
+
# def _init_ui(self):
|
|
284
|
+
# layout = QGridLayout(self)
|
|
285
|
+
# layout.addWidget(self.label, 0, 0, alignment=Qt.AlignHCenter)
|
|
286
|
+
# layout.addWidget(self.slider, 1, 0)
|
mlgidGUI/gui/gui_main.py
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from PyQt5.QtWidgets import (QMainWindow, QWidget, QSizePolicy,
|
|
5
|
+
QApplication, QShortcut, QMessageBox,
|
|
6
|
+
QFileDialog)
|
|
7
|
+
from PyQt5.QtCore import (Qt, pyqtSlot, pyqtSignal,
|
|
8
|
+
QObject)
|
|
9
|
+
from PyQt5.QtGui import QKeySequence
|
|
10
|
+
|
|
11
|
+
import qdarkstyle
|
|
12
|
+
import qdarkgraystyle
|
|
13
|
+
|
|
14
|
+
from ..app import App
|
|
15
|
+
|
|
16
|
+
from ..__version import __version__
|
|
17
|
+
|
|
18
|
+
from .dock_area import AppDockArea
|
|
19
|
+
from .basic_widgets import ToolBar, confirmation_box
|
|
20
|
+
from .tools import Icon, get_filepath_dialog, get_folder_filepath, save_file_dialog
|
|
21
|
+
|
|
22
|
+
from .init_window import InitWindow
|
|
23
|
+
from .debug_widgets import DebugWindow
|
|
24
|
+
from .exception_message import UncaughtHook
|
|
25
|
+
from .notifications import PopUpWrapper
|
|
26
|
+
from .background_tasks import BackgroundTasks
|
|
27
|
+
from .background_update import BackgroundUpdate
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class GIWAXSMainController(QObject):
|
|
31
|
+
EXIT_CODE_REBOOT: int = -123456789
|
|
32
|
+
|
|
33
|
+
log = logging.getLogger(__name__)
|
|
34
|
+
|
|
35
|
+
def __init__(self):
|
|
36
|
+
super().__init__()
|
|
37
|
+
self.app = App(parent=self)
|
|
38
|
+
self.background_tasks = BackgroundTasks(self)
|
|
39
|
+
self.background_update = BackgroundUpdate(self)
|
|
40
|
+
self.background_update.sigRestartAfterUpdate.connect(self.restart_after_update)
|
|
41
|
+
|
|
42
|
+
self.init_window = None
|
|
43
|
+
self.main_window = None
|
|
44
|
+
|
|
45
|
+
if self.log.level <= logging.DEBUG:
|
|
46
|
+
self.debug_window = DebugWindow()
|
|
47
|
+
self.exception_hook = UncaughtHook()
|
|
48
|
+
|
|
49
|
+
self.log.info(f'{"*" * 10}')
|
|
50
|
+
self.log.info(f'Starting mlgidGUI {__version__}!')
|
|
51
|
+
self.log.info(f'{"*" * 10}')
|
|
52
|
+
self.set_style(self.app.fm.config['style'] or 'Gray Dark')
|
|
53
|
+
self.open_init_window()
|
|
54
|
+
|
|
55
|
+
def open_main_window(self):
|
|
56
|
+
self.main_window = GIWAXSMainWindow(self.app)
|
|
57
|
+
|
|
58
|
+
self.main_window.sigCloseApp.connect(self.close_app)
|
|
59
|
+
self.main_window.sigRestartApp.connect(self.restart_app)
|
|
60
|
+
self.main_window.sigOpenProject.connect(self.open_new_project)
|
|
61
|
+
self.main_window.sigCloseProject.connect(self.close_project)
|
|
62
|
+
self.main_window.sigSetStyle.connect(self.set_style)
|
|
63
|
+
|
|
64
|
+
self.background_update.run()
|
|
65
|
+
|
|
66
|
+
def open_init_window(self):
|
|
67
|
+
self.init_window = InitWindow(self.app.fm.recent_projects, self.background_update.is_updated)
|
|
68
|
+
self.init_window.sigOpenProject.connect(self.open_new_project)
|
|
69
|
+
self.init_window.sigExit.connect(self.close_app)
|
|
70
|
+
|
|
71
|
+
@pyqtSlot(name='closeProject')
|
|
72
|
+
def close_project(self):
|
|
73
|
+
self.app.fm.close_project()
|
|
74
|
+
self.main_window.hide()
|
|
75
|
+
self.open_init_window()
|
|
76
|
+
|
|
77
|
+
@pyqtSlot(object, name='NewProject')
|
|
78
|
+
def open_new_project(self, path: Path):
|
|
79
|
+
if self.init_window:
|
|
80
|
+
self.init_window.close()
|
|
81
|
+
self.init_window = None
|
|
82
|
+
if not self.main_window:
|
|
83
|
+
self.open_main_window()
|
|
84
|
+
else:
|
|
85
|
+
self.main_window.show()
|
|
86
|
+
self.app.fm.open_project(path)
|
|
87
|
+
|
|
88
|
+
@pyqtSlot(name='restartAppAfterUpdate')
|
|
89
|
+
def restart_after_update(self):
|
|
90
|
+
self.app.fm.config['is_updated'] = True
|
|
91
|
+
self.restart_app()
|
|
92
|
+
|
|
93
|
+
@pyqtSlot(name='restartApp')
|
|
94
|
+
def restart_app(self):
|
|
95
|
+
self.app.close()
|
|
96
|
+
q_app = QApplication.instance()
|
|
97
|
+
App._instance = None
|
|
98
|
+
q_app.exit(self.EXIT_CODE_REBOOT)
|
|
99
|
+
|
|
100
|
+
@pyqtSlot(name='closeApp')
|
|
101
|
+
def close_app(self):
|
|
102
|
+
self.app.close()
|
|
103
|
+
q_app = QApplication.instance()
|
|
104
|
+
App._instance = None
|
|
105
|
+
q_app.exit(0)
|
|
106
|
+
|
|
107
|
+
@pyqtSlot(str, name='setStyle')
|
|
108
|
+
def set_style(self, name: str = 'Gray Dark'):
|
|
109
|
+
q_app = QApplication.instance()
|
|
110
|
+
if not q_app:
|
|
111
|
+
raise RuntimeError('No running application found.')
|
|
112
|
+
if name == 'Dark':
|
|
113
|
+
q_app.setStyleSheet('')
|
|
114
|
+
q_app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
|
|
115
|
+
elif name == 'Gray Dark':
|
|
116
|
+
q_app.setStyleSheet('')
|
|
117
|
+
q_app.setStyleSheet(qdarkgraystyle.load_stylesheet())
|
|
118
|
+
else:
|
|
119
|
+
return
|
|
120
|
+
|
|
121
|
+
self.app.fm.config['style'] = name
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class GIWAXSMainWindow(QMainWindow):
|
|
125
|
+
_MinimumSize = (500, 500)
|
|
126
|
+
|
|
127
|
+
sigCloseApp = pyqtSignal()
|
|
128
|
+
sigOpenProject = pyqtSignal(object)
|
|
129
|
+
sigCloseProject = pyqtSignal()
|
|
130
|
+
sigRestartApp = pyqtSignal()
|
|
131
|
+
sigSetStyle = pyqtSignal(str)
|
|
132
|
+
|
|
133
|
+
def __init__(self, app: App, parent=None):
|
|
134
|
+
super(GIWAXSMainWindow, self).__init__(parent=parent)
|
|
135
|
+
self.__closing: bool = False
|
|
136
|
+
self.app = app
|
|
137
|
+
self.dock_area = AppDockArea(self)
|
|
138
|
+
self.popups = PopUpWrapper(self)
|
|
139
|
+
self._connect_background_tasks()
|
|
140
|
+
|
|
141
|
+
self._init_toolbar()
|
|
142
|
+
self._init_shortcuts()
|
|
143
|
+
self._init_menubar()
|
|
144
|
+
|
|
145
|
+
self.app.fm.sigProjectClosed.connect(self.update_window_title)
|
|
146
|
+
self.app.fm.sigProjectOpened.connect(self.update_window_title)
|
|
147
|
+
|
|
148
|
+
self.setCentralWidget(self.dock_area)
|
|
149
|
+
self.update_window_title()
|
|
150
|
+
self.setWindowIcon(Icon('window_icon'))
|
|
151
|
+
self.setMinimumSize(*self._MinimumSize)
|
|
152
|
+
self.setWindowState(Qt.WindowMaximized)
|
|
153
|
+
self.show()
|
|
154
|
+
#open the fit view and the angular profile view by default
|
|
155
|
+
self.dock_area.show_hide_docks('fit_view')
|
|
156
|
+
self.dock_area.show_hide_docks('angular_profile')
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _connect_background_tasks(self):
|
|
160
|
+
background_tasks = BackgroundTasks()
|
|
161
|
+
background_tasks.tasks.sigAddNotification.connect(self.popups.add_notification)
|
|
162
|
+
background_tasks.tasks.sigRemoveNotification.connect(self.popups.remove_by_name)
|
|
163
|
+
background_tasks.tasks.sigAddProgressBar.connect(self._add_progress_bar)
|
|
164
|
+
|
|
165
|
+
def _add_progress_bar(self, progress_bar_func):
|
|
166
|
+
return progress_bar_func(self)
|
|
167
|
+
|
|
168
|
+
def update_window_title(self):
|
|
169
|
+
if self.app.fm.project_opened:
|
|
170
|
+
self.setWindowTitle(f'{self.app.fm.project_name} - mlgidGUI')
|
|
171
|
+
else:
|
|
172
|
+
self.setWindowTitle('mlgidGUI')
|
|
173
|
+
|
|
174
|
+
@pyqtSlot(name='NewProjectDialog')
|
|
175
|
+
def _new_project_dialog(self):
|
|
176
|
+
folder = QFileDialog.getExistingDirectory(self, 'New project folder')
|
|
177
|
+
if not folder:
|
|
178
|
+
return
|
|
179
|
+
folder = Path(folder)
|
|
180
|
+
if folder.is_dir():
|
|
181
|
+
self.sigOpenProject.emit(folder)
|
|
182
|
+
|
|
183
|
+
@pyqtSlot(name='addExSitu')
|
|
184
|
+
def _add_file_dialog(self, cif = False):
|
|
185
|
+
if cif:
|
|
186
|
+
filepath = get_filepath_dialog(self, message='Select CIF file', formats ='Cif file (*.cif)')
|
|
187
|
+
if filepath:
|
|
188
|
+
self.app.data_manager.import_cif(filepath)
|
|
189
|
+
else:
|
|
190
|
+
filepath = get_filepath_dialog(self)
|
|
191
|
+
if filepath:
|
|
192
|
+
self.app.data_manager.import_image(filepath)
|
|
193
|
+
|
|
194
|
+
def _save_as_h5(self):
|
|
195
|
+
path = save_file_dialog(self, title='Save project')
|
|
196
|
+
if path:
|
|
197
|
+
self.app.fm.save_as_h5(path)
|
|
198
|
+
|
|
199
|
+
def _add_folder_dialog(self):
|
|
200
|
+
filepath = get_folder_filepath(self, message='Choose directory containing images or h5 files')
|
|
201
|
+
if filepath:
|
|
202
|
+
folder_size = self.app.data_manager.estimate_folder_size(filepath)
|
|
203
|
+
confirmation = confirmation_box("Import whole folder", "Do you whish to import the folder?",
|
|
204
|
+
"This would copy " + folder_size + " of data. ")
|
|
205
|
+
if confirmation:
|
|
206
|
+
self.app.data_manager.import_folder(filepath)
|
|
207
|
+
|
|
208
|
+
def _init_menubar(self):
|
|
209
|
+
self.menubar = self.menuBar()
|
|
210
|
+
|
|
211
|
+
# File menu
|
|
212
|
+
|
|
213
|
+
self.file_menu = self.menubar.addMenu('File')
|
|
214
|
+
self.file_menu.addAction('New project', self._new_project_dialog)
|
|
215
|
+
recent_projects_menu = self.file_menu.addMenu('Recent projects')
|
|
216
|
+
|
|
217
|
+
for project_path in self.app.fm.recent_projects:
|
|
218
|
+
recent_projects_menu.addAction(
|
|
219
|
+
project_path.name, lambda *x, p=project_path: self.sigOpenProject.emit(p))
|
|
220
|
+
|
|
221
|
+
# Save
|
|
222
|
+
|
|
223
|
+
self.save_action = self.file_menu.addAction('Save project ...', lambda *x: self.dock_area.open_save_window())
|
|
224
|
+
|
|
225
|
+
# Load from h5
|
|
226
|
+
self.save_action = self.file_menu.addAction(
|
|
227
|
+
'Load from h5', lambda *x: self.dock_area.open_load_from_h5_window()
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
# Close project
|
|
231
|
+
|
|
232
|
+
self.file_menu.addAction('Close project', lambda *x: self.sigCloseProject.emit())
|
|
233
|
+
|
|
234
|
+
# Restart
|
|
235
|
+
|
|
236
|
+
self.file_menu.addAction('Restart', lambda *x: self.restart())
|
|
237
|
+
|
|
238
|
+
# Data menu
|
|
239
|
+
|
|
240
|
+
self.data_menu = self.menubar.addMenu('Data')
|
|
241
|
+
|
|
242
|
+
self.data_menu.addAction('Add image file', self._add_file_dialog)
|
|
243
|
+
self.data_menu.addAction('Add CIF file', lambda: self._add_file_dialog(cif=True))
|
|
244
|
+
self.data_menu.addAction('Add folder', self._add_folder_dialog)
|
|
245
|
+
|
|
246
|
+
# Preferences menu
|
|
247
|
+
|
|
248
|
+
self.preferences = self.menubar.addMenu('Preferences')
|
|
249
|
+
self.themes_menu = self.preferences.addMenu('Themes')
|
|
250
|
+
themes = ['Dark', 'Gray Dark']
|
|
251
|
+
# themes = CSS.list_css() + QStyleFactory.keys()
|
|
252
|
+
for theme in themes:
|
|
253
|
+
theme_action = self.themes_menu.addAction(theme)
|
|
254
|
+
theme_action.triggered.connect(lambda *x, t=theme: self.sigSetStyle.emit(t))
|
|
255
|
+
|
|
256
|
+
def _init_shortcuts(self):
|
|
257
|
+
self.copy_shortcut = QShortcut(QKeySequence("Ctrl+C"), self)
|
|
258
|
+
self.copy_shortcut.activated.connect(lambda *x: self.app.roi_dict.copy_rois('selected'))
|
|
259
|
+
|
|
260
|
+
self.paste_shortcut = QShortcut(QKeySequence("Ctrl+V"), self)
|
|
261
|
+
self.paste_shortcut.activated.connect(lambda *x: self.app.roi_dict.paste_rois())
|
|
262
|
+
|
|
263
|
+
self.select_shortcut = QShortcut(QKeySequence("Ctrl+A"), self)
|
|
264
|
+
self.select_shortcut.activated.connect(lambda *x: self.app.roi_dict.select_all())
|
|
265
|
+
|
|
266
|
+
self.delete_shortcut = QShortcut(QKeySequence('Del'), self)
|
|
267
|
+
self.delete_shortcut.activated.connect(lambda *x: self.app.roi_dict.delete_selected_roi())
|
|
268
|
+
|
|
269
|
+
self.fit_shortcut = QShortcut(QKeySequence('Ctrl+F'), self)
|
|
270
|
+
self.fit_shortcut.activated.connect(lambda *x: self.app.roi_dict.open_fit_rois(True))
|
|
271
|
+
|
|
272
|
+
self.save_shortcut = QShortcut(QKeySequence('Ctrl+S'), self)
|
|
273
|
+
self.save_shortcut.activated.connect(self.save_state)
|
|
274
|
+
|
|
275
|
+
def raise_err(*_):
|
|
276
|
+
raise ValueError('Congratulations, you found an error combination used for testing! '
|
|
277
|
+
'Your project will be deleted in 3 seconds...')
|
|
278
|
+
|
|
279
|
+
self.raise_shortcut = QShortcut(QKeySequence('Ctrl+R'), self)
|
|
280
|
+
self.raise_shortcut.activated.connect(raise_err)
|
|
281
|
+
|
|
282
|
+
def save_state(self, *args):
|
|
283
|
+
self.app.save_state()
|
|
284
|
+
res = QMessageBox.information(
|
|
285
|
+
self, 'Image is saved',
|
|
286
|
+
'The fitted peaks are successfully saved to the project folder.',
|
|
287
|
+
QMessageBox.Ok
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
def _init_toolbar(self):
|
|
291
|
+
|
|
292
|
+
docks_toolbar = ToolBar('Docks', self)
|
|
293
|
+
docks_toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
|
|
294
|
+
self.addToolBar(docks_toolbar)
|
|
295
|
+
|
|
296
|
+
control_widget = docks_toolbar.addAction(Icon('folder'), 'Project Manager')
|
|
297
|
+
control_widget.triggered.connect(lambda: self.dock_area.show_hide_docks('file_widget'))
|
|
298
|
+
|
|
299
|
+
radial_profile = docks_toolbar.addAction(Icon('radial_profile'), 'Radial Profile')
|
|
300
|
+
radial_profile.triggered.connect(lambda: self.dock_area.show_hide_docks('radial_profile'))
|
|
301
|
+
|
|
302
|
+
angular_profile = docks_toolbar.addAction(Icon('angular_profile'), 'Angular Profile')
|
|
303
|
+
angular_profile.triggered.connect(lambda: self.dock_area.show_hide_docks('angular_profile'))
|
|
304
|
+
|
|
305
|
+
polar_viewer = docks_toolbar.addAction(Icon('interpolate'), 'Polar Viewer')
|
|
306
|
+
polar_viewer.triggered.connect(lambda: self.dock_area.show_hide_docks('polar'))
|
|
307
|
+
|
|
308
|
+
fit_view = docks_toolbar.addAction(Icon('fit'), 'Radial Fit')
|
|
309
|
+
fit_view.triggered.connect(lambda: self.dock_area.show_hide_docks('fit_view'))
|
|
310
|
+
|
|
311
|
+
self.gen_toolbar = ToolBar('General')
|
|
312
|
+
self.gen_toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
|
|
313
|
+
self.addToolBar(self.gen_toolbar)
|
|
314
|
+
spacer_widget = QWidget()
|
|
315
|
+
spacer_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
|
|
316
|
+
spacer_widget.setVisible(True)
|
|
317
|
+
self.gen_toolbar.addWidget(spacer_widget)
|
|
318
|
+
|
|
319
|
+
self.fullscreen_action = self.gen_toolbar.addAction(Icon('tofullscreen'), 'Full screen')
|
|
320
|
+
self.fullscreen_action.triggered.connect(self._on_fullscreen_changed)
|
|
321
|
+
|
|
322
|
+
def _on_fullscreen_changed(self):
|
|
323
|
+
if self.isFullScreen():
|
|
324
|
+
self.setWindowState(Qt.WindowMaximized)
|
|
325
|
+
self.fullscreen_action.setIcon(Icon('tofullscreen'))
|
|
326
|
+
else:
|
|
327
|
+
self.setWindowState(Qt.WindowFullScreen)
|
|
328
|
+
self.fullscreen_action.setIcon(Icon('fromfullscreen'))
|
|
329
|
+
|
|
330
|
+
@pyqtSlot(name='restartApp')
|
|
331
|
+
def restart(self):
|
|
332
|
+
self.__closing = True
|
|
333
|
+
self.sigRestartApp.emit()
|
|
334
|
+
|
|
335
|
+
def closeEvent(self, a0) -> None:
|
|
336
|
+
if self.__closing:
|
|
337
|
+
super().closeEvent(a0)
|
|
338
|
+
else:
|
|
339
|
+
reply = QMessageBox.question(self, 'Message',
|
|
340
|
+
"Are you sure to quit? The project will be saved.",
|
|
341
|
+
QMessageBox.Yes |
|
|
342
|
+
QMessageBox.No, QMessageBox.No)
|
|
343
|
+
|
|
344
|
+
if reply == QMessageBox.Yes:
|
|
345
|
+
a0.accept()
|
|
346
|
+
self.__closing = True
|
|
347
|
+
self.sigCloseApp.emit()
|
|
348
|
+
else:
|
|
349
|
+
a0.ignore()
|