Skip to content

Support drag and drop on main window#1819

Merged
psavery merged 11 commits intomasterfrom
drag-and-drop
Apr 10, 2025
Merged

Support drag and drop on main window#1819
psavery merged 11 commits intomasterfrom
drag-and-drop

Conversation

@bnmajor
Copy link
Collaborator

@bnmajor bnmajor commented Apr 2, 2025

If a file or files are dropped on the main window we will attempt to automatically load them as a state file, instrument config, materials file, or as images.

@bnmajor bnmajor requested review from psavery and saransh13 April 2, 2025 20:32
@bnmajor
Copy link
Collaborator Author

bnmajor commented Apr 2, 2025

@psavery @saransh13 If we have old files or something that may not follow the typical pattern they would be great to also test this with. The files that I tested appear to get loaded correctly.

Comment on lines 1771 to 1776
try:
# Try loading it as a state file first
self.load_state_file(paths[0])
except:
# If that fails, try loading it as a materials file
HexrdConfig().load_materials(paths[0])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's true that we normally raise exceptions when we attempt to load a file that isn't the right kind. Since we are now relying on it, now we should definitely make sure we do that 🙂.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some improvements here and we do get an error when trying to load non-image file(s):

Failed to process imageseries.

zero length imageseries.

If you try to load an invalid image file you will still have to go through the steps of selecting the path (for .h5, .hdf5) and associating the image(s) with the correct detectors before you get the error, both of which can be cancelled if you realize this was a mistake.

bnmajor and others added 9 commits April 10, 2025 09:13
If a file or files are dropped on the main window we will attempt to
automatically load them as a state file, instrument config, materials file, or
as images.

Signed-off-by: Brianna Major <brianna.major@kitware.com>
Signed-off-by: Brianna Major <brianna.major@kitware.com>
Signed-off-by: Brianna Major <brianna.major@kitware.com>
Signed-off-by: Brianna Major <brianna.major@kitware.com>
Signed-off-by: Brianna Major <brianna.major@kitware.com>
Signed-off-by: Brianna Major <brianna.major@kitware.com>
Before, it was replacing the materials with every load. I also don't
think it would work with cif files.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
Signed-off-by: Brianna Major <brianna.major@kitware.com>
Rather than raising an exception if a materials file contains a material that
already exists, add the duplicate value but add a "_1" suffix and print a warning.

Signed-off-by: Brianna Major <brianna.major@kitware.com>
bnmajor and others added 2 commits April 10, 2025 16:22
Signed-off-by: Brianna Major <brianna.major@kitware.com>
Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
@psavery psavery merged commit dd455a9 into master Apr 10, 2025
9 checks passed
@psavery psavery deleted the drag-and-drop branch April 10, 2025 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants