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,323 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import logging
|
|
3
|
+
import math
|
|
4
|
+
import numpy as np
|
|
5
|
+
from pyqtgraph import CircleROI
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from PyQt5.QtWidgets import (
|
|
10
|
+
QMainWindow,
|
|
11
|
+
QWidget,
|
|
12
|
+
QVBoxLayout,
|
|
13
|
+
QPushButton, QLabel, QLineEdit
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
from PyQt5.QtGui import QDoubleValidator, QFont
|
|
17
|
+
|
|
18
|
+
from PyQt5.QtCore import (
|
|
19
|
+
pyqtSignal,
|
|
20
|
+
Qt,
|
|
21
|
+
QPointF
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
from ..app.rois.roi import Roi
|
|
25
|
+
from ..app.cif_rois.cif_peaks_calculation import cif_results
|
|
26
|
+
from ..app import App
|
|
27
|
+
from ..app.transformations import Transformation
|
|
28
|
+
|
|
29
|
+
from .basic_widgets import (
|
|
30
|
+
CustomImageViewer,
|
|
31
|
+
LabeledSlider,
|
|
32
|
+
BlackToolBar,
|
|
33
|
+
DrawRoiController
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
from .roi_widgets.roi_2d_ring_widget import Roi2DRing, CIF2DRing
|
|
37
|
+
from mlgidGUI.gui.roi_widgets.cif_peak_widget import CIFPoint
|
|
38
|
+
from .roi_widgets.abstract_roi_holder import AbstractRoiHolder
|
|
39
|
+
|
|
40
|
+
from .tools import (
|
|
41
|
+
Icon,
|
|
42
|
+
center_widget
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
class ImageViewer(AbstractRoiHolder, CustomImageViewer):
|
|
46
|
+
def __init__(self, parent=None):
|
|
47
|
+
AbstractRoiHolder.__init__(self, 'ImageViewer')
|
|
48
|
+
CustomImageViewer.__init__(
|
|
49
|
+
self, parent)
|
|
50
|
+
self.image_plot.getAxis('bottom').setLabel(text='<math>Q<sub>xy</sub> (A<sup>-1</sup>) </math>', color='white')
|
|
51
|
+
self.image_plot.getAxis('bottom').label.setFont(QFont("", 10))
|
|
52
|
+
self.image_plot.getAxis('left').setLabel(text='<math>Q<sub>z</sub> (A<sup>-1</sup>) </math>', color='white')
|
|
53
|
+
self.image_plot.getAxis('left').label.setFont(QFont("",10))
|
|
54
|
+
|
|
55
|
+
def _make_roi_widget(self, roi: Roi):
|
|
56
|
+
roi_widget = Roi2DRing(roi)
|
|
57
|
+
self.image_plot.addItem(roi_widget)
|
|
58
|
+
return roi_widget
|
|
59
|
+
|
|
60
|
+
def _delete_roi_widget(self, roi_widget: Roi2DRing):
|
|
61
|
+
self.image_plot.removeItem(roi_widget)
|
|
62
|
+
|
|
63
|
+
def _draw_cif_result(self, int_limit):
|
|
64
|
+
for item in self.image_plot.allChildItems():
|
|
65
|
+
if (type(item) is CIFPoint) or (type(item) is CIF2DRing):
|
|
66
|
+
self.image_plot.removeItem(item)
|
|
67
|
+
|
|
68
|
+
if self.app.fm.current_key and bool(cif_results):
|
|
69
|
+
try:
|
|
70
|
+
q_range = math.sqrt(math.pow(self.app.fm.current_key.get_q_range()[0], 2) + math.pow(self.app.fm.current_key.get_q_range()[1], 2))
|
|
71
|
+
y_max = self.app.geometry.shape[0]
|
|
72
|
+
x_max = self.app.geometry.shape[1]
|
|
73
|
+
y_min = self.app.geometry.beam_center[0]
|
|
74
|
+
x_min = self.app.geometry.beam_center[1]
|
|
75
|
+
|
|
76
|
+
for key, cif_result in cif_results.items():
|
|
77
|
+
if cif_result.intensity_perc > int_limit:
|
|
78
|
+
if cif_result.is_powder:
|
|
79
|
+
cif_result.radius = cif_result.q_z * (x_max-x_min)/self.app.fm.current_key.get_q_range()[0]
|
|
80
|
+
cif_result.roi_widget = CIF2DRing(cif_result, q_range)
|
|
81
|
+
self.image_plot.addItem(cif_result.roi_widget)
|
|
82
|
+
else:
|
|
83
|
+
rel_qxy = cif_result.q_xy / self.app.fm.current_key.get_q_range()[0]
|
|
84
|
+
rel_qz = cif_result.q_z / self.app.fm.current_key.get_q_range()[1]
|
|
85
|
+
cif_result.roi_widget = CIFPoint(self.image_item, self, (rel_qxy, rel_qz, cif_result.intensity), cif_result.cif_file_nr)
|
|
86
|
+
self.image_plot.addItem(cif_result.roi_widget)
|
|
87
|
+
except:
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
class MainImageViewer(ImageViewer):
|
|
91
|
+
class BeamCenterRoi(CircleROI):
|
|
92
|
+
_ROI_SIZE = 1
|
|
93
|
+
def __init__(self, beam_center, parent):
|
|
94
|
+
CircleROI.__init__(self, (beam_center[1], beam_center[0]),
|
|
95
|
+
self._ROI_SIZE, movable=False, parent=parent)
|
|
96
|
+
self._center = None
|
|
97
|
+
self._scale = 1
|
|
98
|
+
self.set_center(beam_center)
|
|
99
|
+
|
|
100
|
+
def set_center(self, value: tuple, y=None, update=True, finish=True, ):
|
|
101
|
+
self._center = value
|
|
102
|
+
radius = self.size().x() / 2
|
|
103
|
+
pos = (value[1] - radius, value[0] - radius)
|
|
104
|
+
super(MainImageViewer.BeamCenterRoi, self).setPos(
|
|
105
|
+
pos, y, update, finish)
|
|
106
|
+
|
|
107
|
+
def set_size(self, size: float = None):
|
|
108
|
+
size = size or self._ROI_SIZE
|
|
109
|
+
size *= self._scale
|
|
110
|
+
self.setSize((size, size), update=False, finish=False)
|
|
111
|
+
self.set_center(self._center)
|
|
112
|
+
|
|
113
|
+
def set_scale(self, scale: float):
|
|
114
|
+
self._scale = scale
|
|
115
|
+
self.set_size()
|
|
116
|
+
|
|
117
|
+
def __init__(self, parent=None):
|
|
118
|
+
super().__init__(parent)
|
|
119
|
+
|
|
120
|
+
self.app = App()
|
|
121
|
+
self.register_key_patch()
|
|
122
|
+
self._draw_roi = ImageDrawRoiController(self.view_box, self)
|
|
123
|
+
self._draw_roi.sigCreateRoi.connect(self.app.roi_dict.add_roi)
|
|
124
|
+
self._draw_roi.sigMoveRoi.connect(self.app.roi_dict.move_roi)
|
|
125
|
+
|
|
126
|
+
self._segments_hidden = False
|
|
127
|
+
self._geometry_params_widget = None
|
|
128
|
+
self.__init_center_roi()
|
|
129
|
+
self.app.geometry_holder.sigScaleChanged.connect(self._on_scale_changed)
|
|
130
|
+
self.app.geometry_holder.sigBeamCenterChanged.connect(self._on_beam_center_changed)
|
|
131
|
+
self.app.image_holder.sigImageChanged.connect(self._on_image_changed)
|
|
132
|
+
self.app.image_holder.sigEmptyImage.connect(self.clear_image)
|
|
133
|
+
self.app.image_holder.sigCIFPeaksChanged.connect(self._draw_cif_result)
|
|
134
|
+
|
|
135
|
+
def _on_scale_changed(self):
|
|
136
|
+
scale = self.app.geometry.scale
|
|
137
|
+
self.set_scale(scale)
|
|
138
|
+
self.center_roi.set_scale(scale)
|
|
139
|
+
|
|
140
|
+
def _on_image_changed(self):
|
|
141
|
+
image = self.app.image
|
|
142
|
+
if image is not None:
|
|
143
|
+
self.set_data(image)
|
|
144
|
+
|
|
145
|
+
def __init_center_roi(self):
|
|
146
|
+
beam_center = tuple(self.app.geometry.beam_center)
|
|
147
|
+
self.center_roi = self.BeamCenterRoi(beam_center, parent=self.image_item)
|
|
148
|
+
self.center_roi.setZValue(10)
|
|
149
|
+
self.image_plot.addItem(self.center_roi)
|
|
150
|
+
self.center_roi.hide()
|
|
151
|
+
|
|
152
|
+
def open_geometry_parameters(self):
|
|
153
|
+
image = self.app.image
|
|
154
|
+
scale = self.app.geometry.scale
|
|
155
|
+
beam_center = tuple(self.app.geometry.beam_center)
|
|
156
|
+
if image is not None and self._geometry_params_widget is None:
|
|
157
|
+
self._geometry_params_widget = GeometryParametersWidget(
|
|
158
|
+
image.shape, beam_center, scale=scale)
|
|
159
|
+
self.center_roi.show()
|
|
160
|
+
self._geometry_params_widget.change_center.connect(lambda x:
|
|
161
|
+
self.app.geometry_holder.set_beam_center(x, False))
|
|
162
|
+
self._geometry_params_widget.scale_changed.connect(
|
|
163
|
+
self.app.geometry_holder.set_scale)
|
|
164
|
+
self._geometry_params_widget.close_event.connect(self._on_closing_geometry_parameters)
|
|
165
|
+
|
|
166
|
+
def _on_closing_geometry_parameters(self):
|
|
167
|
+
self.center_roi.set_size()
|
|
168
|
+
self._geometry_params_widget = None
|
|
169
|
+
self.app.geometry_holder.sigGeometryChangeFinished.emit()
|
|
170
|
+
|
|
171
|
+
def _on_beam_center_changed(self):
|
|
172
|
+
beam_center = self.app.geometry.beam_center
|
|
173
|
+
self.set_center((beam_center.y, beam_center.z), pixel_units=True)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class ImageDrawRoiController(DrawRoiController):
|
|
177
|
+
def _update_roi(self, point: QPointF):
|
|
178
|
+
r1, r2 = self._init_point.x(), point.x()
|
|
179
|
+
p1, p2 = self._init_point.y(), point.y()
|
|
180
|
+
|
|
181
|
+
r1 = np.sqrt(r1 ** 2 + p1 ** 2)
|
|
182
|
+
r2 = np.sqrt(r2 ** 2 + p2 ** 2)
|
|
183
|
+
|
|
184
|
+
self._roi.radius, self._roi.width = (r1 + r2) / 2, abs(r2 - r1)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class GeometryParametersWidget(QWidget):
|
|
188
|
+
change_center = pyqtSignal(list)
|
|
189
|
+
change_zero_angle = pyqtSignal(float)
|
|
190
|
+
change_invert_angle = pyqtSignal(bool)
|
|
191
|
+
scale_changed = pyqtSignal(float)
|
|
192
|
+
|
|
193
|
+
close_event = pyqtSignal()
|
|
194
|
+
|
|
195
|
+
def __init__(self, image_shape: tuple,
|
|
196
|
+
beam_center: tuple, zero_angle: float = 0,
|
|
197
|
+
angle_direction: bool = True, scale: float = 1):
|
|
198
|
+
super(GeometryParametersWidget, self).__init__(None, Qt.WindowStaysOnTopHint)
|
|
199
|
+
self.beam_center = list(beam_center)
|
|
200
|
+
self.image_shape = image_shape
|
|
201
|
+
self.zero_angle = zero_angle
|
|
202
|
+
self.scale = scale
|
|
203
|
+
self.angle_direction = angle_direction
|
|
204
|
+
self._init__ui()
|
|
205
|
+
self.setWindowTitle('Set geometry')
|
|
206
|
+
self.setWindowIcon(Icon('setup'))
|
|
207
|
+
center_widget(self)
|
|
208
|
+
self.show()
|
|
209
|
+
|
|
210
|
+
def closeEvent(self, a0) -> None:
|
|
211
|
+
self.close_event.emit()
|
|
212
|
+
QWidget.closeEvent(self, a0)
|
|
213
|
+
|
|
214
|
+
def _init__ui(self):
|
|
215
|
+
layout = QVBoxLayout(self)
|
|
216
|
+
|
|
217
|
+
self.x_slider = LabeledSlider('Y center', (0, self.image_shape[1]),
|
|
218
|
+
self.beam_center[1], self, decimals=0)
|
|
219
|
+
self.x_slider.valueChanged.connect(self._connect_func(1))
|
|
220
|
+
|
|
221
|
+
self.y_slider = LabeledSlider('Z center', (0, self.image_shape[0]),
|
|
222
|
+
self.beam_center[0], self, decimals=0)
|
|
223
|
+
self.y_slider.valueChanged.connect(self._connect_func(0))
|
|
224
|
+
|
|
225
|
+
# self.angle_slider = AnimatedSlider('Zero angle', (0, 360),
|
|
226
|
+
# self.zero_angle, self,
|
|
227
|
+
# Qt.Horizontal, disable_changing_status=True)
|
|
228
|
+
# self.angle_slider.valueChanged.connect(self._connect_func(2))
|
|
229
|
+
#
|
|
230
|
+
# self.invert_angle_box = QCheckBox('Invert angle')
|
|
231
|
+
# self.invert_angle_box.toggled.connect(self._connect_func(3))
|
|
232
|
+
|
|
233
|
+
self.scale_edit = LabeledSlider('Q to pixel ratio', (1e-10, 10),
|
|
234
|
+
self.scale, self,
|
|
235
|
+
decimals=4)
|
|
236
|
+
self.scale_edit.valueChanged.connect(self.on_scale_changed)
|
|
237
|
+
|
|
238
|
+
layout.addWidget(self.x_slider)
|
|
239
|
+
layout.addWidget(self.y_slider)
|
|
240
|
+
layout.addWidget(self.scale_edit)
|
|
241
|
+
# layout.addWidget(self.angle_slider)
|
|
242
|
+
# layout.addWidget(self.invert_angle_box)
|
|
243
|
+
|
|
244
|
+
def on_scale_changed(self, value):
|
|
245
|
+
self.scale = value
|
|
246
|
+
self.scale_changed.emit(value)
|
|
247
|
+
|
|
248
|
+
def _connect_func(self, ind: int):
|
|
249
|
+
def beam_center_changed(value):
|
|
250
|
+
self.beam_center[ind] = value
|
|
251
|
+
self.change_center.emit(self.beam_center)
|
|
252
|
+
|
|
253
|
+
def angle_zero_changed(value):
|
|
254
|
+
self.zero_angle = value
|
|
255
|
+
self.change_zero_angle.emit(self.zero_angle)
|
|
256
|
+
|
|
257
|
+
def angle_direction_changed(value):
|
|
258
|
+
self.angle_direction = value
|
|
259
|
+
self.change_invert_angle.emit(self.angle_direction)
|
|
260
|
+
|
|
261
|
+
if ind < 2:
|
|
262
|
+
return beam_center_changed
|
|
263
|
+
elif ind == 2:
|
|
264
|
+
return angle_zero_changed
|
|
265
|
+
else:
|
|
266
|
+
return angle_direction_changed
|
|
267
|
+
|
|
268
|
+
class Basic2DImageWidget(QMainWindow):
|
|
269
|
+
|
|
270
|
+
def __init__(self, parent=None):
|
|
271
|
+
QMainWindow.__init__(self, parent)
|
|
272
|
+
self.app = parent.app
|
|
273
|
+
self.image_viewer = MainImageViewer(self)
|
|
274
|
+
self.setCentralWidget(self.image_viewer)
|
|
275
|
+
self._init_toolbar()
|
|
276
|
+
|
|
277
|
+
def _add_q_range_edits(self, suffix, toolbar):
|
|
278
|
+
label = QLabel('Q<sub>' + suffix +'</sub> (Å<sup>-1</sup>)')
|
|
279
|
+
label.setStyleSheet("font: 10pt;")
|
|
280
|
+
toolbar.addWidget(label)
|
|
281
|
+
qlineedit = QLineEdit('2.7')
|
|
282
|
+
qlineedit.setMaximumWidth(60)
|
|
283
|
+
qlineedit.setMaxLength(4)
|
|
284
|
+
qlineedit.setValidator(QDoubleValidator(0, 100, 2))
|
|
285
|
+
toolbar.addWidget(qlineedit)
|
|
286
|
+
return qlineedit
|
|
287
|
+
|
|
288
|
+
def _init_toolbar(self):
|
|
289
|
+
toolbar = BlackToolBar('Geometry', self)
|
|
290
|
+
self.addToolBar(toolbar)
|
|
291
|
+
|
|
292
|
+
rotate_action = toolbar.addAction(Icon('rotate'), 'Rotate')
|
|
293
|
+
rotate_action.triggered.connect(
|
|
294
|
+
lambda: self.app.geometry_holder.add_transform(Transformation.rotate_right))
|
|
295
|
+
|
|
296
|
+
flip_h = toolbar.addAction(Icon('flip_horizontal'), 'Horizontal flip')
|
|
297
|
+
flip_h.triggered.connect(
|
|
298
|
+
lambda: self.app.geometry_holder.add_transform(Transformation.horizontal_flip))
|
|
299
|
+
|
|
300
|
+
flip_v = toolbar.addAction(Icon('flip_vertical'), 'Vertical flip')
|
|
301
|
+
flip_v.triggered.connect(
|
|
302
|
+
lambda: self.app.geometry_holder.add_transform(Transformation.vertical_flip))
|
|
303
|
+
|
|
304
|
+
set_beam_center_action = toolbar.addAction(Icon('center'), 'Beam center')
|
|
305
|
+
set_beam_center_action.triggered.connect(
|
|
306
|
+
self.image_viewer.open_geometry_parameters)
|
|
307
|
+
|
|
308
|
+
self._set_default_geometry_button = QPushButton('Save as default geometry')
|
|
309
|
+
self._set_default_geometry_button.clicked.connect(self.app.geometry_holder.save_as_default)
|
|
310
|
+
toolbar.addWidget(self._set_default_geometry_button)
|
|
311
|
+
|
|
312
|
+
qz_range_edit = self._add_q_range_edits('z', toolbar)
|
|
313
|
+
qz_range_edit.editingFinished.connect(
|
|
314
|
+
lambda: self.app.fm.current_key.set_qz(float(qz_range_edit.text())))
|
|
315
|
+
|
|
316
|
+
qxy_range_edit = self._add_q_range_edits('xy', toolbar)
|
|
317
|
+
qxy_range_edit.editingFinished.connect(
|
|
318
|
+
lambda: self.app.fm.current_key.set_qz(float(qxy_range_edit.text())))
|
|
319
|
+
|
|
320
|
+
toolbar.addWidget(QLabel(''))
|
|
321
|
+
self._refresh_sim = QPushButton('Refresh CIF-Simulation')
|
|
322
|
+
self._refresh_sim.clicked.connect(lambda: self.app.fm.sigNewCIFFile.emit())
|
|
323
|
+
toolbar.addWidget(self._refresh_sim)
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import List
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from os import path
|
|
7
|
+
|
|
8
|
+
from PyQt5.QtWidgets import (QWidget, QPushButton, QGridLayout,
|
|
9
|
+
QVBoxLayout, QFileDialog, QLabel,
|
|
10
|
+
QLineEdit, QScrollArea, QSizePolicy)
|
|
11
|
+
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
|
|
12
|
+
|
|
13
|
+
from mlgidGUI.gui.dock_area import AppDockArea
|
|
14
|
+
from mlgidGUI.gui.load_window import LoadProjectFolder, LoadFromH5Widget
|
|
15
|
+
from mlgidGUI.app import App
|
|
16
|
+
from .tools import center_widget, show_error, Icon, color_animation, get_new_project_folder, get_folder_filepath
|
|
17
|
+
from .basic_widgets import Label
|
|
18
|
+
from ..__version import __version__
|
|
19
|
+
|
|
20
|
+
class InitWindow(QWidget):
|
|
21
|
+
sigOpenProject = pyqtSignal(object)
|
|
22
|
+
sigExit = pyqtSignal()
|
|
23
|
+
|
|
24
|
+
log = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
WIDTH = 600
|
|
27
|
+
HEIGHT = 700
|
|
28
|
+
|
|
29
|
+
def __init__(self,
|
|
30
|
+
recent_projects: List[Path] = None,
|
|
31
|
+
is_updated: bool = False):
|
|
32
|
+
flags = Qt.WindowFlags()
|
|
33
|
+
flags |= Qt.FramelessWindowHint
|
|
34
|
+
super().__init__(flags=flags)
|
|
35
|
+
|
|
36
|
+
self.setAttribute(Qt.WA_DeleteOnClose)
|
|
37
|
+
self.setWindowTitle('mlgidGUI')
|
|
38
|
+
self.setWindowIcon(Icon('window_icon'))
|
|
39
|
+
self.project_path = get_new_project_folder()
|
|
40
|
+
self.project_name: str = path.basename(self.project_path)
|
|
41
|
+
self.dock_area: AppDockArea = AppDockArea()
|
|
42
|
+
|
|
43
|
+
self.__init_ui(recent_projects, is_updated)
|
|
44
|
+
self.setMaximumHeight(self.HEIGHT)
|
|
45
|
+
self.setFixedWidth(self.WIDTH)
|
|
46
|
+
center_widget(self)
|
|
47
|
+
self.show()
|
|
48
|
+
|
|
49
|
+
def __init_ui(self, recent_projects: List[Path] or None, is_updated: bool = False):
|
|
50
|
+
layout = QGridLayout(self)
|
|
51
|
+
layout.setContentsMargins(40, 20, 40, 40)
|
|
52
|
+
self.file_line = QLineEdit(str(self.project_path), self)
|
|
53
|
+
self.file_line.textEdited.connect(self._on_text_editing)
|
|
54
|
+
|
|
55
|
+
browse_action = self.file_line.addAction(Icon('folder'), QLineEdit.LeadingPosition)
|
|
56
|
+
|
|
57
|
+
browse_action.triggered.connect(self._new_project_dialog)
|
|
58
|
+
self.create_button = QPushButton(f'Create project "{self.project_name}"', self)
|
|
59
|
+
self.create_button.clicked.connect(self._create)
|
|
60
|
+
|
|
61
|
+
if is_updated:
|
|
62
|
+
title = f'mlgidGUI. Updated to the latest version {__version__}!'
|
|
63
|
+
else:
|
|
64
|
+
title = f'mlgidGUI (version {__version__})'
|
|
65
|
+
|
|
66
|
+
layout.addWidget(Label(title, self, 11, True), 0, 0, 1, 3, alignment=Qt.AlignHCenter)
|
|
67
|
+
layout.addWidget(Label('', self, 9.5), 1, 0, 1, 3)
|
|
68
|
+
layout.addWidget(Label('Create new project', self, 9.5), 2, 0, 1, 3)
|
|
69
|
+
layout.addWidget(self.file_line, 3, 0, 1, 2)
|
|
70
|
+
layout.addWidget(self.create_button, 3, 2)
|
|
71
|
+
layout.addWidget(Label('Import from H5', self, 9.5), 5, 0, 1, 3)
|
|
72
|
+
import_h5_button = QPushButton('Import from H5', self)
|
|
73
|
+
import_h5_button.clicked.connect(self.__init__h5_button)
|
|
74
|
+
layout.addWidget(import_h5_button, 6, 0, 1, 3)
|
|
75
|
+
layout.addWidget(Label('Open project folder', self, 9.5), 7, 0, 1, 3)
|
|
76
|
+
open_project_button = QPushButton('Open project folder', self)
|
|
77
|
+
open_project_button.clicked.connect(self.__init__open_project_button)
|
|
78
|
+
layout.addWidget(open_project_button, 8, 0, 1, 3)
|
|
79
|
+
layout.addWidget(Label('Recent projects', self, 9.5), 9, 0, 1, 3)
|
|
80
|
+
|
|
81
|
+
if recent_projects:
|
|
82
|
+
layout.addWidget(self._init_recent_projects_area(recent_projects), 10, 0, 1, 3)
|
|
83
|
+
|
|
84
|
+
layout.addLayout(self._init_exit_button(), 12 if recent_projects else 11, 0, 1, 3)
|
|
85
|
+
|
|
86
|
+
def __init__h5_button(self, ):
|
|
87
|
+
app = App()
|
|
88
|
+
load_window = LoadFromH5Widget(app.data_manager.load_project_from_h5, self)
|
|
89
|
+
if load_window.exec() == 1:
|
|
90
|
+
self.sigOpenProject.emit(load_window.project_path)
|
|
91
|
+
else:
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
def __init__open_project_button(self, ):
|
|
95
|
+
app = App()
|
|
96
|
+
load_window = LoadProjectFolder(app.data_manager.load_project_from_h5, self)
|
|
97
|
+
if load_window.exec() == 1:
|
|
98
|
+
self.sigOpenProject.emit(load_window.project_path)
|
|
99
|
+
else:
|
|
100
|
+
return None
|
|
101
|
+
|
|
102
|
+
def _init_exit_button(self):
|
|
103
|
+
e_layout = QVBoxLayout()
|
|
104
|
+
exit_button = QPushButton('Exit')
|
|
105
|
+
exit_button.clicked.connect(self.sigExit)
|
|
106
|
+
e_layout.addWidget(QLabel(''))
|
|
107
|
+
e_layout.addWidget(exit_button)
|
|
108
|
+
return e_layout
|
|
109
|
+
|
|
110
|
+
def _init_recent_projects_area(self, recent_projects):
|
|
111
|
+
q_scroll_area = QScrollArea(self)
|
|
112
|
+
q_scroll_area.setWidgetResizable(True)
|
|
113
|
+
q_scroll_area.setGeometry(0, 0, self.WIDTH, self.HEIGHT)
|
|
114
|
+
|
|
115
|
+
projects_list_widget = QWidget(self)
|
|
116
|
+
projects_list_widget.setSizePolicy(
|
|
117
|
+
QSizePolicy.Expanding, QSizePolicy.Expanding
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
scroll_layout = QVBoxLayout(projects_list_widget)
|
|
121
|
+
scroll_layout.setContentsMargins(0,0,5,0)
|
|
122
|
+
for path in recent_projects:
|
|
123
|
+
btn = QPushButton(path.name)
|
|
124
|
+
btn.clicked.connect(
|
|
125
|
+
lambda *x, p=path: self.sigOpenProject.emit(p))
|
|
126
|
+
scroll_layout.addWidget(btn)
|
|
127
|
+
scroll_layout.addStretch()
|
|
128
|
+
q_scroll_area.setWidget(projects_list_widget)
|
|
129
|
+
|
|
130
|
+
return q_scroll_area
|
|
131
|
+
|
|
132
|
+
@pyqtSlot(str, name='onTextEditing')
|
|
133
|
+
def _on_text_editing(self, path: str):
|
|
134
|
+
path = Path(path)
|
|
135
|
+
folder, name = path.parent, path.name
|
|
136
|
+
if not folder.is_dir():
|
|
137
|
+
folder = self.project_path.parent
|
|
138
|
+
self.project_name = name
|
|
139
|
+
self.project_path = folder / name
|
|
140
|
+
self.create_button.setText(f'Create project "{self.project_name}"')
|
|
141
|
+
|
|
142
|
+
@pyqtSlot(name='NewProjectDialog')
|
|
143
|
+
def _new_project_dialog(self):
|
|
144
|
+
folder = QFileDialog.getExistingDirectory(
|
|
145
|
+
self, 'New project folder', options=
|
|
146
|
+
QFileDialog.ShowDirsOnly | QFileDialog.DontUseNativeDialog
|
|
147
|
+
)
|
|
148
|
+
if not folder:
|
|
149
|
+
return
|
|
150
|
+
folder = Path(folder).resolve()
|
|
151
|
+
if folder.is_dir():
|
|
152
|
+
self.project_path = folder / self.project_name
|
|
153
|
+
self.file_line.setText(str(self.project_path))
|
|
154
|
+
else:
|
|
155
|
+
color_animation(self.file_line)
|
|
156
|
+
show_error('Invalid folder. Please, select existing folder',
|
|
157
|
+
error_title='Wrong path')
|
|
158
|
+
|
|
159
|
+
def _create(self):
|
|
160
|
+
try:
|
|
161
|
+
self.project_path.mkdir(parents=True, exist_ok=True)
|
|
162
|
+
self.sigOpenProject.emit(self.project_path.resolve())
|
|
163
|
+
# except FileExistsError:
|
|
164
|
+
# show_error(f'The folder {str(self.project_path.resolve())} already exists', error_title='Folder exists')
|
|
165
|
+
# color_animation(self.file_line)
|
|
166
|
+
except PermissionError:
|
|
167
|
+
folder = get_folder_filepath(self, 'Permission denied, please, create a project folder manually',
|
|
168
|
+
directory=str(Path('~').expanduser().resolve()))
|
|
169
|
+
if folder and folder.is_dir():
|
|
170
|
+
self.sigOpenProject.emit(folder.resolve())
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Callable
|
|
3
|
+
|
|
4
|
+
from PyQt5.QtWidgets import QGridLayout, QPushButton, QDialog
|
|
5
|
+
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
|
6
|
+
|
|
7
|
+
from ...app.app import App
|
|
8
|
+
from ..tools import Icon, get_new_project_folder
|
|
9
|
+
from ..basic_widgets import PathLineModes, PathLine, Label, H5PathLine
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class LoadProjectFolder(QDialog):
|
|
13
|
+
sigLoadClicked = pyqtSignal(Path, Path)
|
|
14
|
+
|
|
15
|
+
def __init__(self, load_function: Callable, parent=None):
|
|
16
|
+
super().__init__(parent)
|
|
17
|
+
self.load_function = load_function
|
|
18
|
+
self.setWindowTitle('Load Project')
|
|
19
|
+
self.setWindowIcon(Icon('window_icon'))
|
|
20
|
+
self.setWindowFlag(Qt.Window, True)
|
|
21
|
+
self.setWindowModality(Qt.WindowModal)
|
|
22
|
+
self.setAttribute(Qt.WA_DeleteOnClose, True)
|
|
23
|
+
self.app = App()
|
|
24
|
+
|
|
25
|
+
self._init_ui()
|
|
26
|
+
self._init_layout()
|
|
27
|
+
self._init_connections()
|
|
28
|
+
|
|
29
|
+
if self.app.debug_tracker:
|
|
30
|
+
self.app.debug_tracker.add_object(self, 'LoadProjectFolder')
|
|
31
|
+
|
|
32
|
+
def _init_ui(self):
|
|
33
|
+
self.project_path = get_new_project_folder()
|
|
34
|
+
self.project_path_line = PathLine(str(self.project_path), parent=self, mode=PathLineModes.existing_dir)
|
|
35
|
+
self.label_project = Label('Existing project folder', self)
|
|
36
|
+
self.load_btn = QPushButton('Load', self)
|
|
37
|
+
self.cancel_btn = QPushButton('Cancel', self)
|
|
38
|
+
|
|
39
|
+
def _init_layout(self):
|
|
40
|
+
layout = QGridLayout(self)
|
|
41
|
+
|
|
42
|
+
layout.addWidget(self.label_project, 1, 0)
|
|
43
|
+
layout.addWidget(self.project_path_line, 1, 1)
|
|
44
|
+
|
|
45
|
+
layout.addWidget(self.load_btn, 2, 0)
|
|
46
|
+
layout.addWidget(self.cancel_btn, 2, 1)
|
|
47
|
+
|
|
48
|
+
self.setMinimumWidth(500)
|
|
49
|
+
|
|
50
|
+
def _init_connections(self):
|
|
51
|
+
self.load_btn.clicked.connect(self._save_clicked)
|
|
52
|
+
self.cancel_btn.clicked.connect(self.close)
|
|
53
|
+
|
|
54
|
+
@pyqtSlot(name='saveClicked')
|
|
55
|
+
def _save_clicked(self):
|
|
56
|
+
if self.project_path_line.is_valid:
|
|
57
|
+
self.project_path = self.project_path_line.path
|
|
58
|
+
self.accept()
|
|
59
|
+
return
|
|
60
|
+
else:
|
|
61
|
+
self.project_path_line.not_valid_action()
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Callable
|
|
3
|
+
|
|
4
|
+
from PyQt5.QtWidgets import QGridLayout, QPushButton, QDialog
|
|
5
|
+
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
|
6
|
+
|
|
7
|
+
from ...app.app import App
|
|
8
|
+
from ..tools import Icon, get_new_project_folder
|
|
9
|
+
from ..basic_widgets import PathLineModes, PathLine, Label, H5PathLine
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class LoadFromH5Widget(QDialog):
|
|
13
|
+
sigLoadClicked = pyqtSignal(Path, Path)
|
|
14
|
+
|
|
15
|
+
def __init__(self, load_function: Callable, parent=None):
|
|
16
|
+
super().__init__(parent)
|
|
17
|
+
self.load_function = load_function
|
|
18
|
+
self.setWindowTitle('Load Project')
|
|
19
|
+
self.setWindowIcon(Icon('window_icon'))
|
|
20
|
+
self.setWindowFlag(Qt.Window, True)
|
|
21
|
+
self.setWindowModality(Qt.WindowModal)
|
|
22
|
+
self.setAttribute(Qt.WA_DeleteOnClose, True)
|
|
23
|
+
self.app = App()
|
|
24
|
+
|
|
25
|
+
self._init_ui()
|
|
26
|
+
self._init_layout()
|
|
27
|
+
self._init_connections()
|
|
28
|
+
|
|
29
|
+
if self.app.debug_tracker:
|
|
30
|
+
self.app.debug_tracker.add_object(self, 'LoadFromH5Widget')
|
|
31
|
+
|
|
32
|
+
def _init_ui(self):
|
|
33
|
+
self.h5_path_line = H5PathLine(parent=self, mode=PathLineModes.existing_file)
|
|
34
|
+
self.project_path = get_new_project_folder()
|
|
35
|
+
self.project_path_line = PathLine(str(self.project_path), parent=self, mode=PathLineModes.new_dir)
|
|
36
|
+
self.label_h5 = Label('Source h5 file', self)
|
|
37
|
+
self.label_project = Label('New project folder', self)
|
|
38
|
+
self.load_btn = QPushButton('Load', self)
|
|
39
|
+
self.cancel_btn = QPushButton('Cancel', self)
|
|
40
|
+
|
|
41
|
+
def _init_layout(self):
|
|
42
|
+
layout = QGridLayout(self)
|
|
43
|
+
|
|
44
|
+
layout.addWidget(self.label_h5, 0, 0)
|
|
45
|
+
layout.addWidget(self.h5_path_line, 0, 1)
|
|
46
|
+
|
|
47
|
+
layout.addWidget(self.label_project, 1, 0)
|
|
48
|
+
layout.addWidget(self.project_path_line, 1, 1)
|
|
49
|
+
|
|
50
|
+
layout.addWidget(self.load_btn, 2, 0)
|
|
51
|
+
layout.addWidget(self.cancel_btn, 2, 1)
|
|
52
|
+
|
|
53
|
+
self.setMinimumWidth(500)
|
|
54
|
+
|
|
55
|
+
def _init_connections(self):
|
|
56
|
+
self.load_btn.clicked.connect(self._save_clicked)
|
|
57
|
+
self.cancel_btn.clicked.connect(self.close)
|
|
58
|
+
|
|
59
|
+
@pyqtSlot(name='saveClicked')
|
|
60
|
+
def _save_clicked(self):
|
|
61
|
+
try:
|
|
62
|
+
self.project_path_line.path.mkdir(parents=True, exist_ok=True)
|
|
63
|
+
except:
|
|
64
|
+
pass
|
|
65
|
+
if self.h5_path_line.is_valid and self.project_path_line.is_valid:
|
|
66
|
+
self.load_function(self.project_path_line.path, self.h5_path_line.path)
|
|
67
|
+
self.project_path = self.project_path_line.path
|
|
68
|
+
self.accept()
|
|
69
|
+
return
|
|
70
|
+
if not self.h5_path_line.is_valid:
|
|
71
|
+
self.h5_path_line.not_valid_action()
|
|
72
|
+
if not self.project_path_line.is_valid:
|
|
73
|
+
self.project_path_line.not_valid_action()
|