Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help buttons to indexing dialogs #1551

Merged
merged 8 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hexrd/ui/indexing/indexing_results_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from hexrd.ui.navigation_toolbar import NavigationToolbar
from hexrd.ui.ui_loader import UiLoader
from hexrd.ui.utils import block_signals
from hexrd.ui.utils.dialog import add_help_url


class IndexingResultsDialog(QObject):
Expand All @@ -29,6 +30,8 @@ def __init__(self, ome_maps, grains_table, parent=None):
loader = UiLoader()
self.ui = loader.load_file('indexing_results_dialog.ui', parent)

add_help_url(self.ui.button_box, 'hedm/indexing/#results')

self.ome_maps = ome_maps
self.grains_table = grains_table
self.cmap = HexrdConfig().default_cmap
Expand Down
4 changes: 4 additions & 0 deletions hexrd/ui/indexing/ome_maps_select_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from hexrd.ui.reflections_table import ReflectionsTable
from hexrd.ui.ui_loader import UiLoader
from hexrd.ui.utils import block_signals
from hexrd.ui.utils.dialog import add_help_url


class OmeMapsSelectDialog(QObject):
Expand All @@ -21,6 +22,9 @@ def __init__(self, parent=None):
self.ui = loader.load_file('ome_maps_select_dialog.ui', parent)
self.ui.setWindowTitle('Load/Generate Eta Omega Maps')

url = 'hedm/indexing/#generating-eta-omega-maps'
add_help_url(self.ui.button_box, url)

# Hide the tab bar. It gets selected by changes to the combo box.
self.ui.tab_widget.tabBar().hide()
self.setup_combo_box_data()
Expand Down
4 changes: 4 additions & 0 deletions hexrd/ui/indexing/ome_maps_viewer_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from hexrd.ui.select_items_widget import SelectItemsWidget
from hexrd.ui.ui_loader import UiLoader
from hexrd.ui.utils import block_signals
from hexrd.ui.utils.dialog import add_help_url

import hexrd.ui.constants
import hexrd.ui.resources.indexing
Expand All @@ -46,6 +47,9 @@ def __init__(self, data, parent=None):
loader = UiLoader()
self.ui = loader.load_file('ome_maps_viewer_dialog.ui', parent)

url = 'hedm/indexing/#find-orientations'
add_help_url(self.ui.button_box, url)

self.data = data
self.cmap = HexrdConfig().default_cmap
self.norm = None
Expand Down
17 changes: 16 additions & 1 deletion hexrd/ui/indexing/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def operation_canceled(self):
class IndexingRunner(Runner):

clustering_ran = Signal(bool)
indexing_results_rejected = Signal()

def __init__(self, parent=None):
super().__init__(parent)
Expand All @@ -97,6 +98,7 @@ def clear(self):
self.indexing_results_dialog = None
self.ome_maps = None
self.grains_table = None
self.is_rerunning_clustering = False

def run(self):
# We will go through these steps:
Expand Down Expand Up @@ -188,7 +190,10 @@ def view_ome_maps(self):
# Now, show the Ome Map viewer
dialog = OmeMapsViewerDialog(self.ome_maps, self.parent)
dialog.accepted.connect(self.ome_maps_viewed)
dialog.rejected.connect(self.clear)
# Don't clear if this is rejected because we might have just
# gone back after rejecting indexing results, and the user
# might want to rerun the clustering.

# Show later so the dialog will move to the front on Mac
dialog.show_later()

Expand Down Expand Up @@ -394,6 +399,16 @@ def confirm_indexing_results(self):
# is complete. The user can cancel this if they don't want to do it.
dialog.accepted.connect(self.start_fit_grains_runner)

def on_rejected():
if not self.is_rerunning_clustering:
# If the dialog is rejected, go back to the
# eta-omega maps viewer
self.view_ome_maps()

self.indexing_results_rejected.emit()

dialog.rejected.connect(on_rejected)

# Show later so the dialog will move to the front on Mac
dialog.show_later()
self.indexing_results_dialog = dialog
Expand Down
14 changes: 10 additions & 4 deletions hexrd/ui/rerun_clustering_dialog.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import copy
import numpy as np
from pathlib import Path

from PySide2.QtWidgets import QDialog, QFileDialog
from PySide2.QtCore import Qt

from hexrd.ui.async_worker import AsyncWorker
from hexrd.ui.hexrd_config import HexrdConfig
from hexrd.ui.ui_loader import UiLoader

from PySide2.QtWidgets import QDialog, QFileDialog
from PySide2.QtCore import Qt
from hexrd.ui.utils.dialog import add_help_url


class RerunClusteringDialog(QDialog):
Expand All @@ -17,6 +17,9 @@ def __init__(self, indexing_runner, parent=None):

loader = UiLoader()
self.ui = loader.load_file('rerun_clustering_dialog.ui', parent)

add_help_url(self.ui.button_box, 'hedm/indexing/#rerun-clustering')

self.indexing_runner = indexing_runner
self.qfib = None
self.completeness = None
Expand Down Expand Up @@ -77,10 +80,13 @@ def accept(self):
self.save_input()

runner = self.indexing_runner
runner.is_rerunning_clustering = True
worker = AsyncWorker(runner.run_cluster)
runner.thread_pool.start(worker)
worker.signals.result.connect(
runner.confirm_indexing_results, Qt.QueuedConnection)
runner.indexing_results_rejected.connect(
self.exec_, Qt.QueuedConnection)
worker.signals.finished.connect(runner.accept_progress)
worker.signals.error.connect(runner.on_async_error)
runner.progress_dialog.exec_()
Expand Down
2 changes: 1 addition & 1 deletion hexrd/ui/resources/ui/indexing_results_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string>Indexing Results</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="1" colspan="2">
<item row="6" column="0" colspan="3">
<widget class="QDialogButtonBox" name="button_box">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
Expand Down
2 changes: 1 addition & 1 deletion hexrd/ui/resources/ui/ome_maps_select_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
</item>
</widget>
</item>
<item row="3" column="1">
<item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="button_box">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
Expand Down
69 changes: 45 additions & 24 deletions hexrd/ui/resources/ui/ome_maps_viewer_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="3" rowspan="8">
<item row="3" column="3" rowspan="7">
<layout class="QVBoxLayout" name="canvas_layout"/>
</item>
<item row="3" column="4" rowspan="4">
Expand Down Expand Up @@ -172,13 +172,33 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="write_scored_orientations">
<property name="text">
<string>Write scored orientations?</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="select_working_dir">
<property name="text">
<string>Select Directory</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="8" column="1" colspan="2">
<widget class="QGroupBox" name="eta_group_box">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="title">
<string>Eta</string>
</property>
Expand Down Expand Up @@ -246,6 +266,12 @@
</item>
<item row="9" column="1" colspan="2">
<widget class="QGroupBox" name="clustering_group_box">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>125</height>
</size>
</property>
<property name="title">
<string>Clustering</string>
</property>
Expand Down Expand Up @@ -403,6 +429,9 @@
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> FWHM</string>
</property>
<property name="decimals">
<number>8</number>
</property>
Expand Down Expand Up @@ -855,25 +884,14 @@
</layout>
</widget>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="write_scored_orientations">
<property name="text">
<string>Write scored orientations?</string>
</property>
</widget>
</item>
<item row="11" column="3" colspan="2">
<widget class="QDialogButtonBox" name="button_box">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<widget class="QGroupBox" name="omega_group_box">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>75</height>
</size>
</property>
<property name="title">
<string>Omega</string>
</property>
Expand Down Expand Up @@ -913,10 +931,13 @@
</layout>
</widget>
</item>
<item row="11" column="2">
<widget class="QPushButton" name="select_working_dir">
<property name="text">
<string>Select Directory</string>
<item row="11" column="1" colspan="4">
<widget class="QDialogButtonBox" name="button_box">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
Expand Down Expand Up @@ -955,14 +976,14 @@
<tabstop>clustering_radius</tabstop>
<tabstop>clustering_completeness</tabstop>
<tabstop>clustering_algorithm</tabstop>
<tabstop>write_scored_orientations</tabstop>
<tabstop>select_working_dir</tabstop>
<tabstop>apply_filtering</tabstop>
<tabstop>filtering_apply_gaussian_laplace</tabstop>
<tabstop>filtering_fwhm</tabstop>
<tabstop>active_hkl</tabstop>
<tabstop>label_spots</tabstop>
<tabstop>export_button</tabstop>
<tabstop>write_scored_orientations</tabstop>
<tabstop>select_working_dir</tabstop>
</tabstops>
<resources/>
<connections>
Expand Down
22 changes: 11 additions & 11 deletions hexrd/ui/resources/ui/rerun_clustering_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>401</width>
<height>207</height>
<height>221</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -96,16 +96,6 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDialogButtonBox" name="button_box">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="ScientificDoubleSpinBox" name="radius" native="true">
<property name="decimals" stdset="0">
Expand All @@ -126,6 +116,16 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QDialogButtonBox" name="button_box">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand Down
Loading