Skip to content

Commit

Permalink
Physics package is now TARDIS/PXRDIP only
Browse files Browse the repository at this point in the history
We are running into trouble using it for other systems. For now,
disable them. We'll add them back in later.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
  • Loading branch information
psavery committed Sep 27, 2024
1 parent b407b04 commit eaffc68
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
26 changes: 25 additions & 1 deletion hexrdgui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils import block_signals, unique_name
from hexrdgui.utils.dialog import add_help_url
from hexrdgui.utils.guess_instrument_type import guess_instrument_type
from hexrdgui.zoom_canvas_dialog import ZoomCanvasDialog
from hexrdgui.rerun_clustering_dialog import RerunClusteringDialog
from hexrdgui.physics_package_manager_dialog import PhysicsPackageManagerDialog
Expand Down Expand Up @@ -166,6 +167,7 @@ def __init__(self, parent=None, image_files=None):
self.setup_connections()

self.update_config_gui()
self.update_physics_package_visibilities()

self.update_action_check_states()

Expand Down Expand Up @@ -350,7 +352,8 @@ def setup_connections(self):
self.ui.action_apply_absorption_correction.toggled.connect(
self.action_apply_absorption_correction_toggled)

HexrdConfig().instrument_config_loaded.connect(self.update_config_gui)
HexrdConfig().instrument_config_loaded.connect(
self.on_instrument_config_loaded)
HexrdConfig().state_loaded.connect(self.on_state_loaded)
HexrdConfig().image_view_loaded.connect(self.on_image_view_loaded)
HexrdConfig().polar_masks_reapplied.connect(
Expand Down Expand Up @@ -431,6 +434,10 @@ def enable_canvas_focus_mode(self, b):
for w in disable_widgets:
w.setEnabled(not b)

def on_instrument_config_loaded(self):
self.update_config_gui()
self.update_physics_package_visibilities()

def on_action_open_config_file_triggered(self):
selected_file, selected_filter = QFileDialog.getOpenFileName(
self.ui, 'Load Configuration', HexrdConfig().working_dir,
Expand Down Expand Up @@ -459,6 +466,23 @@ def on_action_save_config_hexrd_triggered(self):
def on_action_save_config_yaml_triggered(self):
self._save_config('.yml', 'YAML files (*.yml)')

def update_physics_package_visibilities(self):
instr_type = guess_instrument_type(HexrdConfig().detector_names)
visible = instr_type not in ('TARDIS', 'PXRDIP')

self.ui.action_physics_package_editor.setVisible(visible)
self.ui.action_apply_absorption_correction.setVisible(visible)

if not visible:
# Turn off absorption correction
self.ui.action_apply_absorption_correction.setChecked(False)

# Set the physics package to None
HexrdConfig().update_physics_package()

# Turn off all detector coatings
HexrdConfig().detector_coatings_dictified = {}

def open_grain_fitting_results(self):
selected_file, _ = QFileDialog.getOpenFileName(
self.ui, 'Open Grain Fitting File', HexrdConfig().working_dir,
Expand Down
5 changes: 4 additions & 1 deletion hexrdgui/physics_package_manager_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def load_additional_materials(self):

def update_instrument_type(self):
new_instr_type = guess_instrument_type(HexrdConfig().detector_names)
if new_instr_type == self.instrument_type:
if (
new_instr_type == self.instrument_type or
new_instr_type not in ('TARDIS', 'PXRDIP')
):
return

self.initialize_detector_coatings()
Expand Down

0 comments on commit eaffc68

Please sign in to comment.