Bases: QWidget
The main application window for RionID.
This class acts as the central container, arranging the input parameters panel
(left) and the visualization plot (right) using a QSplitter. It handles the
signal connections between the input logic and the plotting display.
Attributes:
| Name |
Type |
Description |
visualization_widget |
CreatePyGUI
|
The right-hand panel containing the PyQtGraph plot.
|
rion_input |
RionID_GUI
|
The left-hand panel containing input fields and control buttons.
|
Source code in src/rionid/gui/app.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 | class MainWindow(QWidget):
"""
The main application window for RionID.
This class acts as the central container, arranging the input parameters panel
(left) and the visualization plot (right) using a QSplitter. It handles the
signal connections between the input logic and the plotting display.
Attributes
----------
visualization_widget : CreatePyGUI
The right-hand panel containing the PyQtGraph plot.
rion_input : RionID_GUI
The left-hand panel containing input fields and control buttons.
"""
def __init__(self):
"""
Initializes the main window, sets geometry, and connects signals.
"""
super().__init__()
self.setWindowTitle("RionID")
screen = QApplication.primaryScreen()
screen_geom = screen.availableGeometry()
width = int(screen_geom.width() * 0.8)
height = int(screen_geom.height() * 0.8)
# Center the window
x = (screen_geom.width() - width) // 2
y = (screen_geom.height() - height) // 2
self.setGeometry(x, y, width, height)
# Create a QSplitter to hold both the input and the visualization
splitter = QSplitter(Qt.Horizontal)
# Create Visualization Widget FIRST
# We must create this first because rion_input needs a reference to it
# to handle the 'Pick' cursor events.
self.visualization_widget = CreatePyGUI()
# 2. Create Input Widget
# Pass the plot widget so inputs can trigger cursor picking
self.rion_input = RionID_GUI(plot_widget=self.visualization_widget)
# Add widgets to the splitter
splitter.addWidget(self.rion_input)
splitter.addWidget(self.visualization_widget)
# Set initial size ratios (1 part input, 2 parts plot)
splitter.setStretchFactor(0, 1)
splitter.setStretchFactor(1, 2)
# Create the main layout
layout = QVBoxLayout()
layout.addWidget(splitter)
self.setLayout(layout)
# --- Signal Connections ---
# 1. Update plot when a full simulation run finishes
self.rion_input.visualization_signal.connect(self.update_visualization)
# 2. Overlay specific simulation (used for Quick PID visual feedback loop)
self.rion_input.overlay_sim_signal.connect(self.overlay_simulation)
# 3. Handle plot clicks (used to stop Quick PID loops or pick coordinates)
self.visualization_widget.plotClicked.connect(self.rion_input.onPlotClicked)
def update_visualization(self, data):
"""
Updates the visualization widget with new experimental and simulated data.
This slot is triggered when a full simulation run is completed. It replaces
all existing data on the plot (experimental and simulated).
Parameters
----------
data : ImportData
The data object containing experimental spectrum arrays and
simulated ion frequency dictionaries.
"""
self.visualization_widget.updateData(data)
def overlay_simulation(self, data):
"""
Overlays a specific simulation result onto the existing plot.
This is primarily used during the 'Quick PID' scan to show visual feedback
of the fitting process without reloading or clearing the heavy experimental
data every frame. It clears previous simulation lines but keeps the
experimental spectrum.
Parameters
----------
data : ImportData
The data object containing the specific simulation iteration to display.
"""
self.visualization_widget.clear_simulated_data()
self.visualization_widget.plot_simulated_data(data)
|
__init__()
Initializes the main window, sets geometry, and connects signals.
Source code in src/rionid/gui/app.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 | def __init__(self):
"""
Initializes the main window, sets geometry, and connects signals.
"""
super().__init__()
self.setWindowTitle("RionID")
screen = QApplication.primaryScreen()
screen_geom = screen.availableGeometry()
width = int(screen_geom.width() * 0.8)
height = int(screen_geom.height() * 0.8)
# Center the window
x = (screen_geom.width() - width) // 2
y = (screen_geom.height() - height) // 2
self.setGeometry(x, y, width, height)
# Create a QSplitter to hold both the input and the visualization
splitter = QSplitter(Qt.Horizontal)
# Create Visualization Widget FIRST
# We must create this first because rion_input needs a reference to it
# to handle the 'Pick' cursor events.
self.visualization_widget = CreatePyGUI()
# 2. Create Input Widget
# Pass the plot widget so inputs can trigger cursor picking
self.rion_input = RionID_GUI(plot_widget=self.visualization_widget)
# Add widgets to the splitter
splitter.addWidget(self.rion_input)
splitter.addWidget(self.visualization_widget)
# Set initial size ratios (1 part input, 2 parts plot)
splitter.setStretchFactor(0, 1)
splitter.setStretchFactor(1, 2)
# Create the main layout
layout = QVBoxLayout()
layout.addWidget(splitter)
self.setLayout(layout)
# --- Signal Connections ---
# 1. Update plot when a full simulation run finishes
self.rion_input.visualization_signal.connect(self.update_visualization)
# 2. Overlay specific simulation (used for Quick PID visual feedback loop)
self.rion_input.overlay_sim_signal.connect(self.overlay_simulation)
# 3. Handle plot clicks (used to stop Quick PID loops or pick coordinates)
self.visualization_widget.plotClicked.connect(self.rion_input.onPlotClicked)
|
overlay_simulation(data)
Overlays a specific simulation result onto the existing plot.
This is primarily used during the 'Quick PID' scan to show visual feedback
of the fitting process without reloading or clearing the heavy experimental
data every frame. It clears previous simulation lines but keeps the
experimental spectrum.
Parameters:
| Name |
Type |
Description |
Default |
data
|
ImportData
|
The data object containing the specific simulation iteration to display.
|
required
|
Source code in src/rionid/gui/app.py
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 | def overlay_simulation(self, data):
"""
Overlays a specific simulation result onto the existing plot.
This is primarily used during the 'Quick PID' scan to show visual feedback
of the fitting process without reloading or clearing the heavy experimental
data every frame. It clears previous simulation lines but keeps the
experimental spectrum.
Parameters
----------
data : ImportData
The data object containing the specific simulation iteration to display.
"""
self.visualization_widget.clear_simulated_data()
self.visualization_widget.plot_simulated_data(data)
|
update_visualization(data)
Updates the visualization widget with new experimental and simulated data.
This slot is triggered when a full simulation run is completed. It replaces
all existing data on the plot (experimental and simulated).
Parameters:
| Name |
Type |
Description |
Default |
data
|
ImportData
|
The data object containing experimental spectrum arrays and
simulated ion frequency dictionaries.
|
required
|
Source code in src/rionid/gui/app.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93 | def update_visualization(self, data):
"""
Updates the visualization widget with new experimental and simulated data.
This slot is triggered when a full simulation run is completed. It replaces
all existing data on the plot (experimental and simulated).
Parameters
----------
data : ImportData
The data object containing experimental spectrum arrays and
simulated ion frequency dictionaries.
"""
self.visualization_widget.updateData(data)
|