@@ -79,20 +79,23 @@ def update_gui(self):
7979 self .ui .filter_material .setCurrentText (filter .material )
8080 self .ui .filter_density .setValue (filter .density )
8181 self .ui .filter_thickness .setValue (filter .thickness )
82+ self .ui .apply_filters .setChecked (filter .thickness > 0 )
8283 # COATING
8384 if coating .material not in self .mat_options :
8485 self .ui .coating_material_input .setText (coating .material )
8586 else :
8687 self .ui .coating_material .setCurrentText (coating .material )
8788 self .ui .coating_density .setValue (coating .density )
8889 self .ui .coating_thickness .setValue (coating .thickness )
90+ self .ui .apply_coating .setChecked (coating .thickness > 0 )
8991 # PHOSPHOR
9092 if phosphor .material not in self .mat_options :
9193 self .ui .phosphor_material_input .setText (phosphor .material )
9294 else :
9395 self .ui .phosphor_material .setCurrentText (phosphor .material )
9496 self .ui .phosphor_density .setValue (phosphor .density )
9597 self .ui .phosphor_thickness .setValue (phosphor .thickness )
98+ self .ui .apply_phosphor .setChecked (phosphor .thickness > 0 )
9699 self .ui .phosphor_readout_length .setValue (phosphor .readout_length )
97100 self .ui .phosphor_pre_U0 .setValue (phosphor .pre_U0 )
98101
@@ -106,6 +109,9 @@ def setup_connections(self):
106109 self .ui .button_box .accepted .connect (self .accept_changes )
107110 self .ui .button_box .accepted .connect (self .ui .accept )
108111 self .ui .button_box .rejected .connect (self .ui .reject )
112+ self .ui .apply_filters .toggled .connect (self .toggle_apply_filters )
113+ self .ui .apply_coating .toggled .connect (self .toggle_apply_coating )
114+ self .ui .apply_phosphor .toggled .connect (self .toggle_apply_phosphor )
109115
110116 def exec (self ):
111117 return self .ui .exec ()
@@ -130,8 +136,9 @@ def material_changed(self, index, category):
130136 else :
131137 self .density_inputs [category ].setValue (0.0 )
132138
133- def filter_info_changed (self ):
134- det_name = self .ui .detectors .currentText ()
139+ def filter_info_changed (self , new_value = None , det_name = None ):
140+ if det_name is None :
141+ det_name = self .ui .detectors .currentText ()
135142 self .filters .setdefault (det_name , {})
136143 self .filters [det_name ]['density' ] = self .ui .filter_density .value ()
137144 self .filters [det_name ]['thickness' ] = self .ui .filter_thickness .value ()
@@ -176,3 +183,35 @@ def accept_changes(self):
176183 density = self .ui .phosphor_density .value (),
177184 thickness = self .ui .phosphor_thickness .value ()
178185 )
186+
187+ def toggle_apply_filters (self , checked ):
188+ if not checked :
189+ self .ui .filter_thickness .setValue (0.0 )
190+ for det in HexrdConfig ().detector_names :
191+ self .filter_info_changed (det_name = det )
192+ self .ui .detectors .setEnabled (checked )
193+ self .ui .filter_material .setEnabled (checked )
194+ index = self .ui .filter_material .currentIndex ()
195+ self .ui .filter_material_input .setEnabled (checked and index == 0 )
196+ self .ui .filter_density .setEnabled (checked )
197+ self .ui .filter_thickness .setEnabled (checked )
198+
199+ def toggle_apply_coating (self , checked ):
200+ if not checked :
201+ self .ui .coating_thickness .setValue (0.0 )
202+ self .ui .coating_material .setEnabled (checked )
203+ index = self .ui .coating_material .currentIndex ()
204+ self .ui .coating_material_input .setEnabled (checked and index == 0 )
205+ self .ui .coating_density .setEnabled (checked )
206+ self .ui .coating_thickness .setEnabled (checked )
207+
208+ def toggle_apply_phosphor (self , checked ):
209+ if not checked :
210+ self .ui .phosphor_thickness .setValue (0.0 )
211+ self .ui .phosphor_material .setEnabled (checked )
212+ index = self .ui .phosphor_material .currentIndex ()
213+ self .ui .phosphor_material_input .setEnabled (checked and index == 0 )
214+ self .ui .phosphor_density .setEnabled (checked )
215+ self .ui .phosphor_thickness .setEnabled (checked )
216+ self .ui .phosphor_readout_length .setEnabled (checked )
217+ self .ui .phosphor_pre_U0 .setEnabled (checked )
0 commit comments