Skip to content

Commit

Permalink
Support instruments with no default physics package
Browse files Browse the repository at this point in the history
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
  • Loading branch information
Brianna Major committed Sep 20, 2024
1 parent a06ec0c commit 0172e05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions hexrdgui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,15 @@ def action_apply_absorption_correction_toggled(self, b):
HexrdConfig().apply_absorption_correction = b
return

# Make sure the physics package exists first
if HexrdConfig().physics_package is None:
msg = (
'Physics package must be set before absorption correction can be '
'applied. See the "Physics Package" editor under the "Edit" menu.'
)
QMessageBox.warning(self.ui, 'HEXRD', msg)
return

# Get the user to first select the absorption correction options
d = AbsorptionCorrectionOptionsDialog(self.ui)
if not d.exec():
Expand Down
7 changes: 6 additions & 1 deletion hexrdgui/physics_package_manager_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def setup_form(self):

# Set default values
physics = HexrdConfig().physics_package
if physics is None:
return

# PINHOLE
self.ui.pinhole_material.setCurrentText(physics.pinhole_material)
self.ui.pinhole_density.setValue(physics.pinhole_density)
Expand Down Expand Up @@ -189,7 +192,9 @@ def material_changed(self, index, category):
self.density_inputs[category].setValue(density)
else:
self.density_inputs[category].setValue(0.0)
self.ui.absorption_length.setValue(HexrdConfig().absorption_length())

if HexrdConfig().physics_package is not None:
self.ui.absorption_length.setValue(HexrdConfig().absorption_length())

def accept_changes(self):
materials = {}
Expand Down

0 comments on commit 0172e05

Please sign in to comment.