pymodaq 3.6.13__py3-none-any.whl → 4.0.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.
Potentially problematic release.
This version of pymodaq might be problematic. Click here for more details.
- pymodaq/__init__.py +13 -6
- pymodaq/control_modules/__init__.py +0 -7
- pymodaq/control_modules/daq_move.py +965 -2
- pymodaq/control_modules/daq_move_ui.py +319 -0
- pymodaq/control_modules/daq_viewer.py +1573 -3
- pymodaq/control_modules/daq_viewer_ui.py +393 -0
- pymodaq/control_modules/mocks.py +51 -0
- pymodaq/control_modules/move_utility_classes.py +709 -8
- pymodaq/control_modules/utils.py +256 -0
- pymodaq/control_modules/viewer_utility_classes.py +663 -6
- pymodaq/daq_utils.py +89 -0
- pymodaq/dashboard.py +91 -72
- pymodaq/examples/custom_app.py +12 -11
- pymodaq/examples/custom_viewer.py +10 -10
- pymodaq/examples/function_plotter.py +16 -13
- pymodaq/examples/nonlinearscanner.py +8 -6
- pymodaq/examples/parameter_ex.py +7 -7
- pymodaq/examples/preset_MockCamera.xml +1 -0
- pymodaq/extensions/__init__.py +16 -0
- pymodaq/extensions/console.py +76 -0
- pymodaq/{daq_logger.py → extensions/daq_logger.py} +115 -65
- pymodaq/extensions/daq_scan.py +1339 -0
- pymodaq/extensions/daq_scan_ui.py +240 -0
- pymodaq/extensions/h5browser.py +23 -0
- pymodaq/{pid → extensions/pid}/__init__.py +4 -2
- pymodaq/{pid → extensions/pid}/daq_move_PID.py +2 -2
- pymodaq/{pid → extensions/pid}/pid_controller.py +48 -36
- pymodaq/{pid → extensions/pid}/utils.py +52 -6
- pymodaq/extensions/utils.py +40 -0
- pymodaq/post_treatment/__init__.py +6 -0
- pymodaq/{daq_analysis → post_treatment/daq_analysis}/daq_analysis_main.py +17 -17
- pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_main.py +8 -14
- pymodaq/post_treatment/load_and_plot.py +219 -0
- pymodaq/post_treatment/process_to_scalar.py +263 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +1 -1
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +1 -0
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +109784 -109173
- pymodaq/resources/QtDesigner_Ressources/icons.svg +142 -0
- pymodaq/resources/VERSION +1 -1
- pymodaq/resources/config_template.toml +32 -13
- pymodaq/resources/preset_default.xml +1 -1
- pymodaq/{daq_utils → utils}/Tuto innosetup/script_full_setup.iss +1 -1
- pymodaq/utils/__init__.py +0 -29
- pymodaq/utils/abstract/__init__.py +48 -0
- pymodaq/{daq_utils → utils}/abstract/logger.py +7 -3
- pymodaq/utils/array_manipulation.py +379 -8
- pymodaq/{daq_utils → utils}/calibration_camera.py +6 -6
- pymodaq/{daq_utils → utils}/chrono_timer.py +1 -1
- pymodaq/utils/config.py +448 -0
- pymodaq/utils/conftests.py +5 -0
- pymodaq/utils/daq_utils.py +828 -8
- pymodaq/utils/data.py +1873 -7
- pymodaq/{daq_utils → utils}/db/db_logger/db_logger.py +86 -47
- pymodaq/{daq_utils → utils}/db/db_logger/db_logger_models.py +31 -10
- pymodaq/{daq_utils → utils}/enums.py +12 -7
- pymodaq/utils/exceptions.py +37 -0
- pymodaq/utils/factory.py +82 -0
- pymodaq/{daq_utils → utils}/gui_utils/__init__.py +1 -1
- pymodaq/utils/gui_utils/custom_app.py +129 -0
- pymodaq/utils/gui_utils/file_io.py +66 -0
- pymodaq/{daq_utils → utils}/gui_utils/layout.py +2 -2
- pymodaq/{daq_utils → utils}/gui_utils/utils.py +13 -3
- pymodaq/{daq_utils → utils}/gui_utils/widgets/__init__.py +2 -2
- pymodaq/utils/gui_utils/widgets/label.py +24 -0
- pymodaq/{daq_utils → utils}/gui_utils/widgets/lcd.py +12 -7
- pymodaq/{daq_utils → utils}/gui_utils/widgets/push.py +66 -2
- pymodaq/{daq_utils → utils}/gui_utils/widgets/qled.py +6 -4
- pymodaq/utils/gui_utils/widgets/spinbox.py +24 -0
- pymodaq/{daq_utils → utils}/gui_utils/widgets/table.py +2 -2
- pymodaq/utils/h5modules/__init__.py +1 -0
- pymodaq/{daq_utils/h5backend.py → utils/h5modules/backends.py} +200 -112
- pymodaq/utils/h5modules/browsing.py +683 -0
- pymodaq/utils/h5modules/data_saving.py +839 -0
- pymodaq/utils/h5modules/h5logging.py +110 -0
- pymodaq/utils/h5modules/module_saving.py +350 -0
- pymodaq/utils/h5modules/saving.py +914 -0
- pymodaq/utils/h5modules/utils.py +85 -0
- pymodaq/utils/logger.py +64 -6
- pymodaq/utils/managers/action_manager.py +460 -0
- pymodaq/{daq_utils → utils}/managers/batchscan_manager.py +144 -112
- pymodaq/{daq_utils → utils}/managers/modules_manager.py +188 -114
- pymodaq/{daq_utils → utils}/managers/overshoot_manager.py +3 -3
- pymodaq/utils/managers/parameter_manager.py +110 -0
- pymodaq/{daq_utils → utils}/managers/preset_manager.py +17 -13
- pymodaq/{daq_utils → utils}/managers/preset_manager_utils.py +8 -7
- pymodaq/{daq_utils → utils}/managers/remote_manager.py +7 -6
- pymodaq/{daq_utils → utils}/managers/roi_manager.py +148 -57
- pymodaq/utils/math_utils.py +546 -10
- pymodaq/{daq_utils → utils}/messenger.py +5 -1
- pymodaq/utils/parameter/__init__.py +2 -15
- pymodaq/{daq_utils → utils}/parameter/ioxml.py +12 -6
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/__init__.py +1 -3
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/filedir.py +1 -1
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/itemselect.py +3 -0
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/led.py +1 -1
- pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +161 -0
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/slide.py +1 -1
- pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/table.py +1 -1
- pymodaq/utils/parameter/utils.py +206 -11
- pymodaq/utils/plotting/data_viewers/__init__.py +6 -0
- pymodaq/utils/plotting/data_viewers/viewer.py +393 -0
- pymodaq/utils/plotting/data_viewers/viewer0D.py +251 -0
- pymodaq/utils/plotting/data_viewers/viewer1D.py +574 -0
- pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer1Dbasic.py +8 -3
- pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D.py +292 -357
- pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D_basic.py +58 -75
- pymodaq/utils/plotting/data_viewers/viewerND.py +738 -0
- pymodaq/{daq_utils → utils}/plotting/gant_chart.py +2 -2
- pymodaq/{daq_utils → utils}/plotting/items/axis_scaled.py +4 -2
- pymodaq/{daq_utils → utils}/plotting/items/image.py +8 -6
- pymodaq/utils/plotting/navigator.py +355 -0
- pymodaq/utils/plotting/scan_selector.py +480 -0
- pymodaq/utils/plotting/utils/axes_viewer.py +88 -0
- pymodaq/utils/plotting/utils/filter.py +538 -0
- pymodaq/utils/plotting/utils/lineout.py +224 -0
- pymodaq/{daq_utils → utils}/plotting/utils/plot_utils.py +196 -84
- pymodaq/{daq_utils → utils}/plotting/utils/signalND.py +21 -13
- pymodaq/utils/plotting/widgets.py +76 -0
- pymodaq/utils/scanner/__init__.py +10 -0
- pymodaq/utils/scanner/scan_factory.py +204 -0
- pymodaq/utils/scanner/scanner.py +271 -0
- pymodaq/utils/scanner/scanners/_1d_scanners.py +117 -0
- pymodaq/utils/scanner/scanners/_2d_scanners.py +293 -0
- pymodaq/utils/scanner/scanners/sequential.py +192 -0
- pymodaq/utils/scanner/scanners/tabular.py +294 -0
- pymodaq/utils/scanner/utils.py +83 -0
- pymodaq/utils/slicing.py +47 -0
- pymodaq/utils/svg/__init__.py +6 -0
- pymodaq/utils/svg/svg_renderer.py +20 -0
- pymodaq/utils/svg/svg_view.py +35 -0
- pymodaq/utils/svg/svg_viewer2D.py +51 -0
- pymodaq/{daq_utils → utils}/tcp_server_client.py +36 -37
- pymodaq/{daq_utils → utils}/tree_layout/tree_layout_main.py +50 -35
- pymodaq/utils/units.py +216 -0
- pymodaq-4.0.1.dist-info/METADATA +159 -0
- {pymodaq-3.6.13.dist-info → pymodaq-4.0.1.dist-info}/RECORD +167 -170
- {pymodaq-3.6.13.dist-info → pymodaq-4.0.1.dist-info}/WHEEL +1 -2
- pymodaq-4.0.1.dist-info/entry_points.txt +8 -0
- pymodaq/daq_move/daq_move_gui.py +0 -279
- pymodaq/daq_move/daq_move_gui.ui +0 -534
- pymodaq/daq_move/daq_move_main.py +0 -1042
- pymodaq/daq_move/process_from_QtDesigner_DAQ_Move_GUI.bat +0 -2
- pymodaq/daq_move/utility_classes.py +0 -686
- pymodaq/daq_scan.py +0 -2160
- pymodaq/daq_utils/array_manipulation.py +0 -386
- pymodaq/daq_utils/config.py +0 -273
- pymodaq/daq_utils/conftests.py +0 -7
- pymodaq/daq_utils/custom_parameter_tree.py +0 -9
- pymodaq/daq_utils/daq_enums.py +0 -133
- pymodaq/daq_utils/daq_utils.py +0 -1402
- pymodaq/daq_utils/exceptions.py +0 -71
- pymodaq/daq_utils/gui_utils/custom_app.py +0 -103
- pymodaq/daq_utils/gui_utils/file_io.py +0 -75
- pymodaq/daq_utils/gui_utils/widgets/spinbox.py +0 -9
- pymodaq/daq_utils/h5exporter_hyperspy.py +0 -115
- pymodaq/daq_utils/h5exporters.py +0 -242
- pymodaq/daq_utils/h5modules.py +0 -1559
- pymodaq/daq_utils/h5utils.py +0 -241
- pymodaq/daq_utils/managers/action_manager.py +0 -236
- pymodaq/daq_utils/managers/parameter_manager.py +0 -57
- pymodaq/daq_utils/math_utils.py +0 -705
- pymodaq/daq_utils/parameter/__init__.py +0 -1
- pymodaq/daq_utils/parameter/oldpymodaq_ptypes.py +0 -1626
- pymodaq/daq_utils/parameter/pymodaq_ptypes/pixmap.py +0 -85
- pymodaq/daq_utils/parameter/utils.py +0 -136
- pymodaq/daq_utils/plotting/data_viewers/__init__.py +0 -0
- pymodaq/daq_utils/plotting/data_viewers/process_from_QtDesigner_0DViewer_GUI.bat +0 -2
- pymodaq/daq_utils/plotting/data_viewers/viewer0D.py +0 -204
- pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.py +0 -89
- pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.ui +0 -131
- pymodaq/daq_utils/plotting/data_viewers/viewer1D.py +0 -781
- pymodaq/daq_utils/plotting/data_viewers/viewerND.py +0 -894
- pymodaq/daq_utils/plotting/data_viewers/viewerbase.py +0 -64
- pymodaq/daq_utils/plotting/items/__init__.py +0 -0
- pymodaq/daq_utils/plotting/navigator.py +0 -500
- pymodaq/daq_utils/plotting/scan_selector.py +0 -289
- pymodaq/daq_utils/plotting/utils/__init__.py +0 -0
- pymodaq/daq_utils/plotting/utils/filter.py +0 -236
- pymodaq/daq_utils/plotting/viewer0D/__init__.py +0 -0
- pymodaq/daq_utils/plotting/viewer0D/viewer0D_main.py +0 -4
- pymodaq/daq_utils/plotting/viewer1D/__init__.py +0 -0
- pymodaq/daq_utils/plotting/viewer1D/viewer1D_main.py +0 -4
- pymodaq/daq_utils/plotting/viewer1D/viewer1Dbasic.py +0 -4
- pymodaq/daq_utils/plotting/viewer2D/viewer_2D_basic.py +0 -4
- pymodaq/daq_utils/plotting/viewer2D/viewer_2D_main.py +0 -4
- pymodaq/daq_utils/plotting/viewerND/__init__.py +0 -0
- pymodaq/daq_utils/plotting/viewerND/viewerND_main.py +0 -4
- pymodaq/daq_utils/scanner.py +0 -1289
- pymodaq/daq_utils/tree_layout/__init__.py +0 -0
- pymodaq/daq_viewer/__init__.py +0 -0
- pymodaq/daq_viewer/daq_gui_settings.py +0 -237
- pymodaq/daq_viewer/daq_gui_settings.ui +0 -441
- pymodaq/daq_viewer/daq_viewer_main.py +0 -2225
- pymodaq/daq_viewer/process_from_QtDesigner_DAQ_GUI_settings.bat +0 -2
- pymodaq/daq_viewer/utility_classes.py +0 -673
- pymodaq/examples/logger_image/__init__.py +0 -0
- pymodaq/examples/logger_image/logger_displayer.py +0 -121
- pymodaq/examples/logger_image/setup.svg +0 -3119
- pymodaq/examples/logger_image/setup_svg.py +0 -114
- pymodaq/h5browser.py +0 -39
- pymodaq/utils/scanner.py +0 -15
- pymodaq-3.6.13.dist-info/METADATA +0 -39
- pymodaq-3.6.13.dist-info/entry_points.txt +0 -8
- pymodaq-3.6.13.dist-info/top_level.txt +0 -1
- /pymodaq/{daq_analysis → post_treatment/daq_analysis}/__init__.py +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/__init__.py +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.py +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.ui +0 -0
- /pymodaq/{daq_measurement → post_treatment/daq_measurement}/process_from_QtDesigner_DAQ_Measurement_GUI.bat +0 -0
- /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.odt +0 -0
- /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.pdf +0 -0
- /pymodaq/{daq_move → utils/db}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils/db/db_logger}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/gui_utils/dock.py +0 -0
- /pymodaq/{daq_utils → utils}/gui_utils/list_picker.py +0 -0
- /pymodaq/{daq_utils/abstract → utils/managers}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/bool.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/date.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/list.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/numeric.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/tableview.py +0 -0
- /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/text.py +0 -0
- /pymodaq/{daq_utils/db → utils/plotting}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/plotting/image_viewer.py +0 -0
- /pymodaq/{daq_utils/db/db_logger → utils/plotting/items}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/plotting/items/crosshair.py +0 -0
- /pymodaq/{daq_utils/managers → utils/plotting/utils}/__init__.py +0 -0
- /pymodaq/{daq_utils → utils}/qvariant.py +0 -0
- /pymodaq/{daq_utils/plotting/viewer2D → utils/scanner/scanners}/__init__.py +0 -0
- /pymodaq/{daq_utils/plotting → utils/tree_layout}/__init__.py +0 -0
- {pymodaq-3.6.13.dist-info → pymodaq-4.0.1.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import List, Union, Dict
|
|
3
|
+
from pymodaq.utils.parameter import Parameter, ParameterTree, ioxml
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ParameterManager:
|
|
7
|
+
"""Class dealing with Parameter and ParameterTree
|
|
8
|
+
|
|
9
|
+
Attributes
|
|
10
|
+
----------
|
|
11
|
+
params: list of dicts
|
|
12
|
+
Defining the Parameter tree like structure
|
|
13
|
+
settings_name: str
|
|
14
|
+
The particular name to give to the object parent Parameter (self.settings)
|
|
15
|
+
settings: Parameter
|
|
16
|
+
The higher level (parent) Parameter
|
|
17
|
+
settings_tree: ParameterTree
|
|
18
|
+
"""
|
|
19
|
+
settings_name = 'custom_settings'
|
|
20
|
+
params = []
|
|
21
|
+
|
|
22
|
+
def __init__(self, settings_name: str = None):
|
|
23
|
+
if settings_name is None:
|
|
24
|
+
settings_name = self.settings_name
|
|
25
|
+
# create a settings tree to be shown eventually in a dock
|
|
26
|
+
self.settings_tree: ParameterTree = ParameterTree()
|
|
27
|
+
self.settings_tree.setMinimumWidth(150)
|
|
28
|
+
self.settings_tree.setMinimumHeight(300)
|
|
29
|
+
|
|
30
|
+
self.settings: Parameter = Parameter.create(name=settings_name, type='group', children=self.params) # create a Parameter
|
|
31
|
+
# object containing the settings defined in the preamble
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def settings(self):
|
|
35
|
+
return self._settings
|
|
36
|
+
|
|
37
|
+
@settings.setter
|
|
38
|
+
def settings(self, settings: Union[Parameter, List[Dict[str, str]], Path]):
|
|
39
|
+
settings = self.create_parameter(settings)
|
|
40
|
+
self._settings = settings
|
|
41
|
+
self.settings_tree.setParameters(self._settings, showTop=False) # load the tree with this parameter object
|
|
42
|
+
self._settings.sigTreeStateChanged.connect(self.parameter_tree_changed)
|
|
43
|
+
|
|
44
|
+
@staticmethod
|
|
45
|
+
def create_parameter(settings: Union[Parameter, List[Dict[str, str]], Path]) -> Parameter:
|
|
46
|
+
|
|
47
|
+
if isinstance(settings, List):
|
|
48
|
+
_settings = Parameter.create(title='Settings', name='settings', type='group', children=settings)
|
|
49
|
+
elif isinstance(settings, Path) or isinstance(settings, str):
|
|
50
|
+
settings = Path(settings)
|
|
51
|
+
_settings = Parameter.create(title='Settings', name='settings',
|
|
52
|
+
type='group', children=ioxml.XML_file_to_parameter(str(settings)))
|
|
53
|
+
elif isinstance(settings, Parameter):
|
|
54
|
+
_settings = Parameter.create(title='Settings', name=settings.name(), type='group')
|
|
55
|
+
_settings.restoreState(settings.saveState())
|
|
56
|
+
else:
|
|
57
|
+
raise TypeError(f'Cannot create Parameter object from {settings}')
|
|
58
|
+
return _settings
|
|
59
|
+
|
|
60
|
+
def parameter_tree_changed(self, param, changes):
|
|
61
|
+
for param, change, data in changes:
|
|
62
|
+
path = self._settings.childPath(param)
|
|
63
|
+
if change == 'childAdded':
|
|
64
|
+
self.child_added(param, data)
|
|
65
|
+
|
|
66
|
+
elif change == 'value':
|
|
67
|
+
self.value_changed(param)
|
|
68
|
+
|
|
69
|
+
elif change == 'parent':
|
|
70
|
+
self.param_deleted(param)
|
|
71
|
+
|
|
72
|
+
def value_changed(self, param):
|
|
73
|
+
"""Non-mandatory method to be subclassed for actions to perform (methods to call) when one of the param's
|
|
74
|
+
value in self._settings is changed
|
|
75
|
+
|
|
76
|
+
Parameters
|
|
77
|
+
----------
|
|
78
|
+
param: Parameter
|
|
79
|
+
the parameter whose value just changed
|
|
80
|
+
|
|
81
|
+
Examples
|
|
82
|
+
--------
|
|
83
|
+
>>> if param.name() == 'do_something':
|
|
84
|
+
>>> if param.value():
|
|
85
|
+
>>> print('Do something')
|
|
86
|
+
>>> self.settings.child('main_settings', 'something_done').setValue(False)
|
|
87
|
+
"""
|
|
88
|
+
...
|
|
89
|
+
|
|
90
|
+
def child_added(self, param, data):
|
|
91
|
+
"""Non-mandatory method to be subclassed for actions to perform when a param has been added in self.settings
|
|
92
|
+
|
|
93
|
+
Parameters
|
|
94
|
+
----------
|
|
95
|
+
param: Parameter
|
|
96
|
+
the parameter where child will be added
|
|
97
|
+
data: Parameter
|
|
98
|
+
the child parameter
|
|
99
|
+
"""
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
def param_deleted(self, param):
|
|
103
|
+
"""Non-mandatory method to be subclassed for actions to perform when one of the param in self.settings has been deleted
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
param: Parameter
|
|
108
|
+
the parameter that has been deleted
|
|
109
|
+
"""
|
|
110
|
+
pass
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
from pymodaq.extensions import get_models
|
|
2
|
+
import pymodaq.utils.config
|
|
3
|
+
from pymodaq.utils.logger import set_logger, get_module_name, get_module_name
|
|
4
|
+
from pymodaq.utils.gui_utils.file_io import select_file
|
|
3
5
|
from qtpy import QtWidgets
|
|
4
6
|
import sys
|
|
5
7
|
import os
|
|
6
8
|
from pyqtgraph.parametertree import Parameter, ParameterTree
|
|
7
|
-
from pymodaq.
|
|
8
|
-
from pymodaq.
|
|
9
|
+
from pymodaq.utils.parameter import ioxml
|
|
10
|
+
from pymodaq.utils import daq_utils as utils
|
|
9
11
|
from pathlib import Path
|
|
10
|
-
import pymodaq.
|
|
12
|
+
import pymodaq.utils.managers.preset_manager_utils # to register move and det types
|
|
11
13
|
|
|
12
|
-
logger =
|
|
14
|
+
logger = set_logger(get_module_name(__file__))
|
|
13
15
|
|
|
14
16
|
# check if preset_mode directory exists on the drive
|
|
15
|
-
pid_path = pymodaq.
|
|
16
|
-
preset_path = pymodaq.
|
|
17
|
-
overshoot_path = pymodaq.
|
|
18
|
-
layout_path = pymodaq.
|
|
17
|
+
pid_path = pymodaq.utils.config.get_set_pid_path()
|
|
18
|
+
preset_path = pymodaq.utils.config.get_set_preset_path()
|
|
19
|
+
overshoot_path = pymodaq.utils.config.get_set_overshoot_path()
|
|
20
|
+
layout_path = pymodaq.utils.config.get_set_layout_path()
|
|
19
21
|
|
|
20
|
-
pid_models = [mod['name'] for mod in
|
|
22
|
+
pid_models = [mod['name'] for mod in get_models()]
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
class PresetManager:
|
|
@@ -67,7 +69,7 @@ class PresetManager:
|
|
|
67
69
|
|
|
68
70
|
def get_set_pid_model_params(self, model_file):
|
|
69
71
|
self.preset_params.child('model_settings').clearChildren()
|
|
70
|
-
model =
|
|
72
|
+
model = get_models(model_file)
|
|
71
73
|
if model is not None:
|
|
72
74
|
params = model['class'].params
|
|
73
75
|
self.preset_params.child('model_settings').addChildren(params)
|
|
@@ -117,7 +119,7 @@ class PresetManager:
|
|
|
117
119
|
for param, change, data in changes:
|
|
118
120
|
path = self.preset_params.childPath(param)
|
|
119
121
|
if change == 'childAdded':
|
|
120
|
-
|
|
122
|
+
data[0].child('params', 'main_settings', 'module_name').setValue(data[0].child('name').value())
|
|
121
123
|
|
|
122
124
|
elif change == 'value':
|
|
123
125
|
|
|
@@ -126,6 +128,8 @@ class PresetManager:
|
|
|
126
128
|
self.preset_params.child('model_settings').show(param.value())
|
|
127
129
|
if param.name() == 'pid_models' and param.value() != '':
|
|
128
130
|
self.get_set_pid_model_params(param.value())
|
|
131
|
+
if param.name() == 'name':
|
|
132
|
+
param.parent().child('params', 'main_settings', 'module_name').setValue(param.value())
|
|
129
133
|
|
|
130
134
|
elif change == 'parent':
|
|
131
135
|
pass
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import random
|
|
2
|
-
|
|
3
|
-
from pymodaq.
|
|
4
|
-
from pymodaq.
|
|
2
|
+
|
|
3
|
+
from pymodaq.utils.logger import set_logger, get_module_name, get_module_name
|
|
4
|
+
from pymodaq.utils import daq_utils as utils
|
|
5
|
+
from pymodaq.control_modules.move_utility_classes import params as daq_move_params
|
|
6
|
+
from pymodaq.control_modules.viewer_utility_classes import params as daq_viewer_params
|
|
5
7
|
|
|
6
8
|
from pyqtgraph.parametertree.Parameter import registerParameterType
|
|
7
9
|
from pyqtgraph.parametertree.parameterTypes.basetypes import GroupParameter
|
|
8
|
-
logger =
|
|
10
|
+
logger = set_logger(get_module_name(__file__))
|
|
9
11
|
|
|
10
12
|
DAQ_Move_Stage_type = utils.get_plugins('daq_move')
|
|
11
13
|
DAQ_0DViewer_Det_types = utils.get_plugins('daq_0Dviewer')
|
|
@@ -177,10 +179,9 @@ class PresetScalableGroupDet(GroupParameter):
|
|
|
177
179
|
|
|
178
180
|
for main_child in params:
|
|
179
181
|
if main_child['name'] == 'detector_settings':
|
|
180
|
-
while len(main_child['children'])
|
|
182
|
+
while len(main_child['children']) > 0:
|
|
181
183
|
for child in main_child['children']:
|
|
182
|
-
|
|
183
|
-
main_child['children'].remove(child)
|
|
184
|
+
main_child['children'].remove(child)
|
|
184
185
|
|
|
185
186
|
main_child['children'].extend(params_hardware)
|
|
186
187
|
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
3
|
|
|
4
|
-
import pymodaq.
|
|
4
|
+
import pymodaq.utils.config
|
|
5
5
|
from qtpy.QtCore import QObject, Signal
|
|
6
6
|
from qtpy import QtGui, QtWidgets
|
|
7
7
|
|
|
8
|
-
from pymodaq.
|
|
9
|
-
from pymodaq.
|
|
10
|
-
from pymodaq.
|
|
8
|
+
from pymodaq.utils.logger import set_logger, get_module_name, get_module_name
|
|
9
|
+
from pymodaq.utils.parameter import ioxml
|
|
10
|
+
from pymodaq.utils import daq_utils as utils
|
|
11
|
+
from pymodaq.utils.gui_utils import select_file
|
|
11
12
|
from pyqtgraph.parametertree import Parameter, ParameterTree, registerParameterType
|
|
12
13
|
from pyqtgraph.parametertree.parameterTypes.basetypes import GroupParameter
|
|
13
14
|
|
|
14
|
-
logger =
|
|
15
|
-
remote_path = pymodaq.
|
|
15
|
+
logger = set_logger(get_module_name(__file__))
|
|
16
|
+
remote_path = pymodaq.utils.config.get_set_remote_path()
|
|
16
17
|
remote_types = ['ShortCut', 'Joystick']
|
|
17
18
|
|
|
18
19
|
actuator_actions = ['move_Rel', 'move_Rel_p', 'move_Rel_m']
|
|
@@ -1,32 +1,105 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
|
-
|
|
4
|
-
import pymodaq.
|
|
3
|
+
from typing import List, TYPE_CHECKING
|
|
4
|
+
import pymodaq.utils
|
|
5
5
|
from qtpy import QtCore, QtGui, QtWidgets
|
|
6
6
|
from qtpy.QtCore import QObject, Slot, Signal, QPointF
|
|
7
7
|
from qtpy.QtGui import QIcon, QPixmap
|
|
8
8
|
from collections import OrderedDict
|
|
9
9
|
|
|
10
|
-
from pymodaq.
|
|
11
|
-
from pymodaq.
|
|
10
|
+
from pymodaq.utils.parameter import ioxml
|
|
11
|
+
from pymodaq.utils.parameter import utils as putils
|
|
12
12
|
from pyqtgraph.parametertree import Parameter, ParameterTree
|
|
13
13
|
from pyqtgraph.parametertree.parameterTypes.basetypes import GroupParameter
|
|
14
|
-
from pymodaq.
|
|
15
|
-
from pymodaq.
|
|
14
|
+
from pymodaq.utils.parameter import pymodaq_ptypes
|
|
15
|
+
from pymodaq.utils.managers.action_manager import QAction
|
|
16
16
|
from pyqtgraph import ROI as pgROI
|
|
17
|
+
from pyqtgraph import RectROI as pgRectROI
|
|
17
18
|
from pyqtgraph import functions as fn
|
|
18
19
|
from pyqtgraph import LinearRegionItem as pgLinearROI
|
|
19
|
-
from pymodaq.
|
|
20
|
-
from pymodaq.
|
|
21
|
-
from pymodaq.
|
|
20
|
+
from pymodaq.utils.daq_utils import plot_colors
|
|
21
|
+
from pymodaq.utils.logger import get_module_name, set_logger
|
|
22
|
+
from pymodaq.utils.config import get_set_roi_path
|
|
23
|
+
from pymodaq.utils.gui_utils import select_file
|
|
22
24
|
import numpy as np
|
|
23
25
|
from pathlib import Path
|
|
26
|
+
from pymodaq.post_treatment.process_to_scalar import DataProcessorFactory
|
|
27
|
+
|
|
28
|
+
if TYPE_CHECKING:
|
|
29
|
+
from pymodaq.control_modules.daq_viewer import DAQ_Viewer
|
|
24
30
|
|
|
31
|
+
data_processors = DataProcessorFactory()
|
|
25
32
|
|
|
26
33
|
roi_path = get_set_roi_path()
|
|
34
|
+
logger = set_logger(get_module_name(__file__))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ROIPositionMapper(QtWidgets.QWidget):
|
|
38
|
+
""" Widget presenting a Tree structure representing a ROI positions.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__(self, roi_pos, roi_size):
|
|
42
|
+
super().__init__()
|
|
43
|
+
self.roi_pos = roi_pos
|
|
44
|
+
self.roi_size = roi_size
|
|
45
|
+
|
|
46
|
+
def show_dialog(self):
|
|
47
|
+
self.params = [
|
|
48
|
+
{'name': 'position', 'type': 'group', 'children': [
|
|
49
|
+
{'name': 'x0', 'type': 'float', 'value': self.roi_pos[0] + self.roi_size[0] / 2, 'step': 1},
|
|
50
|
+
{'name': 'y0', 'type': 'float', 'value': self.roi_pos[1] + self.roi_size[1] / 2, 'step': 1}
|
|
51
|
+
]},
|
|
52
|
+
{'name': 'size', 'type': 'group', 'children': [
|
|
53
|
+
{'name': 'width', 'type': 'float', 'value': self.roi_size[0], 'step': 1},
|
|
54
|
+
{'name': 'height', 'type': 'float', 'value': self.roi_size[1], 'step': 1}]
|
|
55
|
+
}]
|
|
56
|
+
|
|
57
|
+
dialog = QtWidgets.QDialog(self)
|
|
58
|
+
vlayout = QtWidgets.QVBoxLayout()
|
|
59
|
+
self.settings_tree = ParameterTree()
|
|
60
|
+
vlayout.addWidget(self.settings_tree, 10)
|
|
61
|
+
self.settings_tree.setMinimumWidth(300)
|
|
62
|
+
self.settings = Parameter.create(name='settings', type='group', children=self.params)
|
|
63
|
+
self.settings_tree.setParameters(self.settings, showTop=False)
|
|
64
|
+
dialog.setLayout(vlayout)
|
|
65
|
+
|
|
66
|
+
buttonBox = QtWidgets.QDialogButtonBox(parent=self);
|
|
67
|
+
buttonBox.addButton('Apply', buttonBox.AcceptRole)
|
|
68
|
+
buttonBox.accepted.connect(dialog.accept)
|
|
69
|
+
buttonBox.addButton('Cancel', buttonBox.RejectRole)
|
|
70
|
+
buttonBox.rejected.connect(dialog.reject)
|
|
71
|
+
|
|
72
|
+
vlayout.addWidget(buttonBox)
|
|
73
|
+
self.setWindowTitle('Set Precise positions for the ROI')
|
|
74
|
+
res = dialog.exec()
|
|
75
|
+
|
|
76
|
+
if res == dialog.Accepted:
|
|
77
|
+
|
|
78
|
+
return self.settings
|
|
79
|
+
else:
|
|
80
|
+
return None
|
|
27
81
|
|
|
28
82
|
|
|
29
|
-
class
|
|
83
|
+
class ROI(pgROI):
|
|
84
|
+
def __init__(self, *args, **kwargs):
|
|
85
|
+
super().__init__(*args, **kwargs)
|
|
86
|
+
self._menu = QtWidgets.QMenu()
|
|
87
|
+
self._menu.addAction('Set ROI positions', self.set_positions)
|
|
88
|
+
|
|
89
|
+
def set_positions(self):
|
|
90
|
+
mapper = ROIPositionMapper(self.pos(), self.size())
|
|
91
|
+
settings = mapper.show_dialog()
|
|
92
|
+
if settings is not None:
|
|
93
|
+
self.setSize((settings['size', 'width'], settings['size', 'height']))
|
|
94
|
+
self.setPos((settings['position', 'x0'] - settings['size', 'width'] / 2,
|
|
95
|
+
settings['position', 'y0'] - settings['size', 'height'] / 2))
|
|
96
|
+
|
|
97
|
+
def contextMenuEvent(self, event):
|
|
98
|
+
if self._menu is not None:
|
|
99
|
+
self._menu.exec(event.screenPos())
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class ROIBrushable(ROI):
|
|
30
103
|
def __init__(self, brush=None, *args, **kwargs):
|
|
31
104
|
super().__init__(*args, **kwargs)
|
|
32
105
|
|
|
@@ -76,7 +149,7 @@ class LinearROI(pgLinearROI):
|
|
|
76
149
|
self.index_signal.emit(self.index)
|
|
77
150
|
|
|
78
151
|
|
|
79
|
-
class EllipseROI(
|
|
152
|
+
class EllipseROI(ROI):
|
|
80
153
|
"""
|
|
81
154
|
Elliptical ROI subclass with one scale handle and one rotation handle.
|
|
82
155
|
|
|
@@ -156,7 +229,25 @@ class EllipseROI(pgROI):
|
|
|
156
229
|
return self.size().x()
|
|
157
230
|
|
|
158
231
|
|
|
159
|
-
class
|
|
232
|
+
class SimpleRectROI(ROI):
|
|
233
|
+
r"""
|
|
234
|
+
Rectangular ROI subclass with a single scale handle at the top-right corner.
|
|
235
|
+
"""
|
|
236
|
+
|
|
237
|
+
def __init__(self, pos=[0, 0], size=[10, 10], centered=False, sideScalers=False, **args):
|
|
238
|
+
super().__init__(pos, size, **args)
|
|
239
|
+
if centered:
|
|
240
|
+
center = [0.5, 0.5]
|
|
241
|
+
else:
|
|
242
|
+
center = [0, 0]
|
|
243
|
+
|
|
244
|
+
self.addScaleHandle([1, 1], center)
|
|
245
|
+
if sideScalers:
|
|
246
|
+
self.addScaleHandle([1, 0.5], [center[0], 0.5])
|
|
247
|
+
self.addScaleHandle([0.5, 1], [0.5, center[1]])
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class RectROI(ROI):
|
|
160
251
|
index_signal = Signal(int)
|
|
161
252
|
|
|
162
253
|
def __init__(self, index=0, pos=[0, 0], size=[10, 10]):
|
|
@@ -202,12 +293,13 @@ class ROIScalableGroup(GroupParameter):
|
|
|
202
293
|
children.extend([{'title': 'ROI Type', 'name': 'roi_type', 'type': 'str', 'value': typ, 'readonly': True},
|
|
203
294
|
{'title': 'Use channel', 'name': 'use_channel', 'type': 'list',
|
|
204
295
|
'limits': ['red', 'green', 'blue', 'spread']}, ])
|
|
296
|
+
children.append({'title': 'Math type:', 'name': 'math_function', 'type': 'list',
|
|
297
|
+
'limits': data_processors.functions_filtered('Data2D')})
|
|
205
298
|
else:
|
|
206
299
|
children.append({'title': 'Use channel', 'name': 'use_channel', 'type': 'list'})
|
|
300
|
+
children.append({'title': 'Math type:', 'name': 'math_function', 'type': 'list',
|
|
301
|
+
'limits': data_processors.functions_filtered('Data1D')})
|
|
207
302
|
|
|
208
|
-
functions = ['Sum', 'Mean', 'half-life', 'expotime', 'fwhm', 'moment', 'fwhm_moment2']
|
|
209
|
-
children.append({'title': 'Math type:', 'name': 'math_function', 'type': 'list', 'limits': functions,
|
|
210
|
-
'value': 'Sum', 'visible': self.roi_type == '1D'})
|
|
211
303
|
children.extend([
|
|
212
304
|
{'name': 'Color', 'type': 'color', 'value': list(np.roll(self.color_list, newindex)[0])}, ])
|
|
213
305
|
if self.roi_type == '2D':
|
|
@@ -261,7 +353,10 @@ class ROIManager(QObject):
|
|
|
261
353
|
def ROIs(self):
|
|
262
354
|
return self._ROIs
|
|
263
355
|
|
|
264
|
-
def
|
|
356
|
+
def __len__(self):
|
|
357
|
+
return len(self._ROIs)
|
|
358
|
+
|
|
359
|
+
def get_roi_from_index(self, index: int) -> ROI:
|
|
265
360
|
return self.ROIs[self.roi_format(index)]
|
|
266
361
|
|
|
267
362
|
def _set_roi_from_index(self, index: int, roi):
|
|
@@ -322,17 +417,17 @@ class ROIManager(QObject):
|
|
|
322
417
|
par = data[0]
|
|
323
418
|
newindex = int(par.name()[-2:])
|
|
324
419
|
|
|
325
|
-
if par.child(
|
|
420
|
+
if par.child('type').value() == '1D':
|
|
326
421
|
roi_type = ''
|
|
327
422
|
|
|
328
423
|
pos = self.viewer_widget.plotItem.vb.viewRange()[0]
|
|
329
424
|
newroi = LinearROI(index=newindex, pos=pos)
|
|
330
425
|
newroi.setZValue(-10)
|
|
331
|
-
newroi.setBrush(par.child(
|
|
426
|
+
newroi.setBrush(par.child('Color').value())
|
|
332
427
|
newroi.setOpacity(0.2)
|
|
333
428
|
|
|
334
|
-
elif par.child(
|
|
335
|
-
roi_type = par.child(
|
|
429
|
+
elif par.child('type').value() == '2D':
|
|
430
|
+
roi_type = par.child('roi_type').value()
|
|
336
431
|
xrange = self.viewer_widget.plotItem.vb.viewRange()[0]
|
|
337
432
|
yrange = self.viewer_widget.plotItem.vb.viewRange()[1]
|
|
338
433
|
width = np.max(((xrange[1] - xrange[0]) / 10, 2))
|
|
@@ -345,7 +440,7 @@ class ROIManager(QObject):
|
|
|
345
440
|
else:
|
|
346
441
|
newroi = EllipseROI(index=newindex, pos=pos,
|
|
347
442
|
size=[width, height])
|
|
348
|
-
newroi.setPen(par
|
|
443
|
+
newroi.setPen(par['Color'])
|
|
349
444
|
|
|
350
445
|
newroi.sigRegionChanged.connect(lambda: self.ROI_changed.emit())
|
|
351
446
|
newroi.sigRegionChangeFinished.connect(lambda: self.ROI_changed_finished.emit())
|
|
@@ -363,7 +458,7 @@ class ROIManager(QObject):
|
|
|
363
458
|
self.update_roi_tree(newindex)
|
|
364
459
|
|
|
365
460
|
elif change == 'value':
|
|
366
|
-
if param.name() in putils.iter_children(self.settings.child(
|
|
461
|
+
if param.name() in putils.iter_children(self.settings.child('ROIs'), []):
|
|
367
462
|
parent_name = putils.get_param_path(param)[putils.get_param_path(param).index('ROIs')+1]
|
|
368
463
|
self.update_roi(parent_name, param)
|
|
369
464
|
self.roi_value_changed.emit(parent_name, (param, param.value()))
|
|
@@ -376,6 +471,13 @@ class ROIManager(QObject):
|
|
|
376
471
|
|
|
377
472
|
self.ROI_changed_finished.emit()
|
|
378
473
|
|
|
474
|
+
def update_use_channel(self, channels: List[str]):
|
|
475
|
+
for ind in range(len(self)):
|
|
476
|
+
val = self.settings['ROIs', self.roi_format(ind), 'use_channel']
|
|
477
|
+
self.settings.child('ROIs', self.roi_format(ind), 'use_channel').setOpts(limits=channels)
|
|
478
|
+
if val not in channels:
|
|
479
|
+
self.settings.child('ROIs', self.roi_format(ind), 'use_channel').setValue(channels[0])
|
|
480
|
+
|
|
379
481
|
def update_roi(self, roi_key, param):
|
|
380
482
|
self._ROIs[roi_key].index_signal[int].disconnect()
|
|
381
483
|
if param.name() == 'Color':
|
|
@@ -435,7 +537,7 @@ class ROIManager(QObject):
|
|
|
435
537
|
|
|
436
538
|
try:
|
|
437
539
|
data = ioxml.parameter_to_xml_string(self.settings.child(('ROIs')))
|
|
438
|
-
path = select_file(start_path=Path.home(), ext='xml')
|
|
540
|
+
path = select_file(start_path=Path.home(), ext='xml', save=True, force_save_extension=True)
|
|
439
541
|
|
|
440
542
|
if path != '':
|
|
441
543
|
with open(path, 'wb') as f:
|
|
@@ -453,7 +555,7 @@ class ROIManager(QObject):
|
|
|
453
555
|
try:
|
|
454
556
|
if params is None:
|
|
455
557
|
if path is None:
|
|
456
|
-
path = select_file(start_path=Path.home(), save=False, ext='xml')
|
|
558
|
+
path = select_file(start_path=Path.home(), save=False, ext='xml', filter=['xml'])
|
|
457
559
|
if path != '':
|
|
458
560
|
params = Parameter.create(title='Settings', name='settings', type='group',
|
|
459
561
|
children=ioxml.XML_file_to_parameter(path))
|
|
@@ -464,21 +566,13 @@ class ROIManager(QObject):
|
|
|
464
566
|
|
|
465
567
|
for param in params:
|
|
466
568
|
if 'roi_type' in putils.iter_children(param, []):
|
|
467
|
-
self.settings.child(
|
|
569
|
+
self.settings.child('ROIs').addNew(param.child('roi_type').value())
|
|
468
570
|
else:
|
|
469
|
-
self.settings.child(
|
|
470
|
-
# self.settings.child(('ROIs')).addChildren(params)
|
|
571
|
+
self.settings.child('ROIs').addNew()
|
|
471
572
|
QtWidgets.QApplication.processEvents()
|
|
472
|
-
|
|
473
|
-
# settings = Parameter.create(title='Settings', name='settings', type='group')
|
|
474
|
-
#
|
|
475
|
-
# for param in params:
|
|
476
|
-
# settings.addChildren(custom_tree.XML_string_to_parameter(custom_tree.parameter_to_xml_string(param)))
|
|
477
|
-
|
|
478
|
-
self.set_roi(self.settings.child(('ROIs')).children(), params)
|
|
479
|
-
|
|
573
|
+
self.set_roi(self.settings.child('ROIs').children(), params)
|
|
480
574
|
except Exception as e:
|
|
481
|
-
|
|
575
|
+
logger.exception(str(e))
|
|
482
576
|
|
|
483
577
|
def set_roi(self, roi_params, roi_params_new):
|
|
484
578
|
for child, new_child in zip(roi_params, roi_params_new):
|
|
@@ -491,7 +585,7 @@ class ROIManager(QObject):
|
|
|
491
585
|
|
|
492
586
|
if __name__ == '__main__':
|
|
493
587
|
app = QtWidgets.QApplication(sys.argv)
|
|
494
|
-
from pymodaq.
|
|
588
|
+
from pymodaq.utils.plotting.widgets import ImageWidget
|
|
495
589
|
from pyqtgraph import PlotWidget
|
|
496
590
|
|
|
497
591
|
im = ImageWidget()
|
|
@@ -516,7 +610,7 @@ class ROISaver:
|
|
|
516
610
|
|
|
517
611
|
if msgbox:
|
|
518
612
|
msgBox = QtWidgets.QMessageBox()
|
|
519
|
-
msgBox.setText("
|
|
613
|
+
msgBox.setText("ROI Manager?")
|
|
520
614
|
msgBox.setInformativeText("What do you want to do?")
|
|
521
615
|
cancel_button = msgBox.addButton(QtWidgets.QMessageBox.Cancel)
|
|
522
616
|
modify_button = msgBox.addButton('Modify', QtWidgets.QMessageBox.AcceptRole)
|
|
@@ -535,26 +629,24 @@ class ROISaver:
|
|
|
535
629
|
|
|
536
630
|
"""
|
|
537
631
|
|
|
538
|
-
children =
|
|
632
|
+
children = ioxml.XML_file_to_parameter(filename)
|
|
539
633
|
self.roi_presets = Parameter.create(title='roi', name='rois', type='group', children=children)
|
|
540
634
|
|
|
541
635
|
det_children = [child for child in self.roi_presets.children() if 'det' in child.opts['name']]
|
|
542
|
-
det_names = [child.child(
|
|
636
|
+
det_names = [child.child('detname').value() for child in self.roi_presets.children() if
|
|
543
637
|
'det' in child.opts['name']]
|
|
544
638
|
det_module_names = [det.title for det in self.detector_modules]
|
|
545
639
|
for ind_det, det_roi in enumerate(det_children):
|
|
546
|
-
det_module = self.detector_modules[det_module_names.index(det_names[ind_det])]
|
|
640
|
+
det_module: DAQ_Viewer = self.detector_modules[det_module_names.index(det_names[ind_det])]
|
|
547
641
|
viewer_children = [child for child in det_roi.children() if 'viewer' in child.opts['name']]
|
|
548
|
-
for ind_viewer, viewer in enumerate(det_module.
|
|
642
|
+
for ind_viewer, viewer in enumerate(det_module.viewers):
|
|
549
643
|
rois_params = [child for child in viewer_children[ind_viewer].children() if 'ROI' in child.opts['name']]
|
|
550
|
-
if
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
viewer.roi_manager.load_ROI(params=rois_params)
|
|
557
|
-
QtWidgets.QApplication.processEvents()
|
|
644
|
+
if len(rois_params) > 0:
|
|
645
|
+
if hasattr(viewer, 'roi_manager'):
|
|
646
|
+
if hasattr(viewer, 'activate_roi'): # because for viewer 0D it is irrelevant
|
|
647
|
+
viewer.activate_roi()
|
|
648
|
+
viewer.roi_manager.load_ROI(params=rois_params)
|
|
649
|
+
QtWidgets.QApplication.processEvents()
|
|
558
650
|
|
|
559
651
|
if show:
|
|
560
652
|
self.show_rois()
|
|
@@ -577,12 +669,12 @@ class ROISaver:
|
|
|
577
669
|
|
|
578
670
|
if hasattr(viewer, 'roi_manager'):
|
|
579
671
|
viewer_param.addChild({'title': 'ROI type:', 'name': 'roi_type', 'type': 'str',
|
|
580
|
-
'value': viewer.roi_manager.settings.child(
|
|
581
|
-
viewer_param.addChildren(viewer.roi_manager.settings.child(
|
|
672
|
+
'value': viewer.roi_manager.settings.child('ROIs').roi_type})
|
|
673
|
+
viewer_param.addChildren(viewer.roi_manager.settings.child('ROIs').children())
|
|
582
674
|
det_param.addChild(viewer_param)
|
|
583
675
|
self.roi_presets.addChild(det_param)
|
|
584
676
|
|
|
585
|
-
|
|
677
|
+
ioxml.parameter_to_xml_file(self.roi_presets, os.path.join(roi_path, file))
|
|
586
678
|
self.show_rois()
|
|
587
679
|
|
|
588
680
|
def show_rois(self):
|
|
@@ -613,7 +705,6 @@ class ROISaver:
|
|
|
613
705
|
# save managers parameters in a xml file
|
|
614
706
|
# start = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]
|
|
615
707
|
# start = os.path.join("..",'daq_scan')
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
'filename')).value()))
|
|
708
|
+
ioxml.parameter_to_xml_file(
|
|
709
|
+
self.roi_presets, os.path.join(roi_path, self.roi_presets.child('filename').value()))
|
|
710
|
+
|