Skip to content

Commit

Permalink
Allow users to disable detector coating, filter or phosphor
Browse files Browse the repository at this point in the history
Signed-off-by: Brianna Major <[email protected]>
  • Loading branch information
Brianna Major committed Jan 9, 2025
1 parent 7e3dc2b commit 4a7a949
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 10 deletions.
43 changes: 41 additions & 2 deletions hexrdgui/absorption_correction_options_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,23 @@ def update_gui(self):
self.ui.filter_material.setCurrentText(filter.material)
self.ui.filter_density.setValue(filter.density)
self.ui.filter_thickness.setValue(filter.thickness)
self.ui.apply_filters.setChecked(filter.thickness > 0)
# COATING
if coating.material not in self.mat_options:
self.ui.coating_material_input.setText(coating.material)
else:
self.ui.coating_material.setCurrentText(coating.material)
self.ui.coating_density.setValue(coating.density)
self.ui.coating_thickness.setValue(coating.thickness)
self.ui.apply_coating.setChecked(coating.thickness > 0)
# PHOSPHOR
if phosphor.material not in self.mat_options:
self.ui.phosphor_material_input.setText(phosphor.material)
else:
self.ui.phosphor_material.setCurrentText(phosphor.material)
self.ui.phosphor_density.setValue(phosphor.density)
self.ui.phosphor_thickness.setValue(phosphor.thickness)
self.ui.apply_phosphor.setChecked(phosphor.thickness > 0)
self.ui.phosphor_readout_length.setValue(phosphor.readout_length)
self.ui.phosphor_pre_U0.setValue(phosphor.pre_U0)

Expand All @@ -106,6 +109,9 @@ def setup_connections(self):
self.ui.button_box.accepted.connect(self.accept_changes)
self.ui.button_box.accepted.connect(self.ui.accept)
self.ui.button_box.rejected.connect(self.ui.reject)
self.ui.apply_filters.toggled.connect(self.toggle_apply_filters)
self.ui.apply_coating.toggled.connect(self.toggle_apply_coating)
self.ui.apply_phosphor.toggled.connect(self.toggle_apply_phosphor)

def exec(self):
return self.ui.exec()
Expand All @@ -130,8 +136,9 @@ def material_changed(self, index, category):
else:
self.density_inputs[category].setValue(0.0)

def filter_info_changed(self):
det_name = self.ui.detectors.currentText()
def filter_info_changed(self, new_value=None, det_name=None):
if det_name is None:
det_name = self.ui.detectors.currentText()
self.filters.setdefault(det_name, {})
self.filters[det_name]['density'] = self.ui.filter_density.value()
self.filters[det_name]['thickness'] = self.ui.filter_thickness.value()
Expand Down Expand Up @@ -176,3 +183,35 @@ def accept_changes(self):
density=self.ui.phosphor_density.value(),
thickness=self.ui.phosphor_thickness.value()
)

def toggle_apply_filters(self, checked):
if not checked:
self.ui.filter_thickness.setValue(0.0)
for det in HexrdConfig().detector_names:
self.filter_info_changed(det_name=det)
self.ui.detectors.setEnabled(checked)
self.ui.filter_material.setEnabled(checked)
index = self.ui.filter_material.currentIndex()
self.ui.filter_material_input.setEnabled(checked and index == 0)
self.ui.filter_density.setEnabled(checked)
self.ui.filter_thickness.setEnabled(checked)

def toggle_apply_coating(self, checked):
if not checked:
self.ui.coating_thickness.setValue(0.0)
self.ui.coating_material.setEnabled(checked)
index = self.ui.coating_material.currentIndex()
self.ui.coating_material_input.setEnabled(checked and index == 0)
self.ui.coating_density.setEnabled(checked)
self.ui.coating_thickness.setEnabled(checked)

def toggle_apply_phosphor(self, checked):
if not checked:
self.ui.phosphor_thickness.setValue(0.0)
self.ui.phosphor_material.setEnabled(checked)
index = self.ui.phosphor_material.currentIndex()
self.ui.phosphor_material_input.setEnabled(checked and index == 0)
self.ui.phosphor_density.setEnabled(checked)
self.ui.phosphor_thickness.setEnabled(checked)
self.ui.phosphor_readout_length.setEnabled(checked)
self.ui.phosphor_pre_U0.setEnabled(checked)
6 changes: 4 additions & 2 deletions hexrdgui/hexrd_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3058,8 +3058,10 @@ def use_physics_package(self, v):
if v != self.use_physics_package:
self._use_physics_package = v
self.physics_package_modified.emit()
if self.use_physics_package and self.physics_package is None:
self.create_default_physics_package()
if self.use_physics_package:
self.create_default_physics_package()
else:
self.physics_package = None

@property
def physics_package_dictified(self):
Expand Down
48 changes: 42 additions & 6 deletions hexrdgui/resources/ui/absorption_correction_options_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>332</height>
<width>347</width>
<height>365</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -20,16 +20,46 @@
<string>Absorption Correction Editor</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<item row="1" column="0" alignment="Qt::AlignHCenter">
<widget class="QCheckBox" name="apply_filters">
<property name="text">
<string>Filter</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" alignment="Qt::AlignHCenter">
<widget class="QCheckBox" name="apply_coating">
<property name="text">
<string>Coating</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2" alignment="Qt::AlignLeft">
<widget class="QCheckBox" name="apply_phosphor">
<property name="text">
<string>Phosphor</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<item row="2" column="0">
<widget class="QDialogButtonBox" name="button_box">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QTabWidget" name="tab_widget">
<property name="tabPosition">
<enum>QTabWidget::North</enum>
Expand Down Expand Up @@ -308,6 +338,13 @@
</item>
</layout>
</item>
<item row="0" column="0" colspan="3" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="apply_label">
<property name="text">
<string>Apply:</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand All @@ -318,7 +355,6 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tab_widget</tabstop>
<tabstop>detectors</tabstop>
<tabstop>filter_material</tabstop>
<tabstop>filter_material_input</tabstop>
Expand Down

0 comments on commit 4a7a949

Please sign in to comment.