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

2350: Close the BUMPS/DREAM results panel when data is deleted #2365

Merged
merged 3 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions src/sas/qtgui/MainWindow/DataExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ def deleteFile(self, event):

# Delete corresponding open plots
self.closePlotsForItem(item)
# Close result panel if results represent the deleted data item
# Results panel only stores Data1D/Data2D object
# => QStandardItems must still exist for direct comparison
self.closeResultPanelOnDelete(GuiUtils.dataFromItem(item))

self.model.removeRow(ind)
# Decrement index since we just deleted it
Expand Down Expand Up @@ -1905,6 +1909,13 @@ def closePlotsForItem(self, item):

pass # debugger anchor

def closeResultPanelOnDelete(self, data):
"""
Given a standard item, close the fitting results panel if currently populated with item
"""
# items - List[HashableStandardItem] of deleted data items
self.parent.results_panel.dataDeleted(data)

def onAnalysisUpdate(self, new_perspective_name: str):
"""
Update the perspective combo index based on passed string
Expand Down
13 changes: 11 additions & 2 deletions src/sas/qtgui/Utilities/ResultPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from PyQt5 import QtGui
from PyQt5 import QtWidgets


class ResultPanel(QtWidgets.QTabWidget):
"""
FitPanel class contains fields allowing to fit models and data
Expand All @@ -28,6 +29,7 @@ def __init__(self, parent, manager=None, *args, **kwargs):
self.manager = manager
self.communicator = self.manager.communicator()
self.setMinimumSize(400, 400)
self.data_id = None

self.updateBumps() # patch bumps ## TEMPORARY ##

Expand Down Expand Up @@ -63,9 +65,10 @@ def onPlotResults(self, results, optimizer="Unknown"):
self.removeTab(index)

result = results[0][0]
filename = result.data.sas_data.filename
name = result.data.sas_data.name
current_optimizer = optimizer
self.setWindowTitle(self.window_name + " - " + filename + " - " + current_optimizer)
self.data_id = result.data.sas_data.id
self.setWindowTitle(self.window_name + " - " + name + " - " + current_optimizer)
if hasattr(result, 'convergence') and len(result.convergence) > 0:
best, pop = result.convergence[:, 0], result.convergence[:, 1:]
self.convergenceView.update(best, pop)
Expand Down Expand Up @@ -94,6 +97,12 @@ def onPlotResults(self, results, optimizer="Unknown"):
if self.count()==0:
self.close()

def dataDeleted(self, data):
if not data or not self.isVisible():
return
if data.id == self.data_id:
self.close()

def closeEvent(self, event):
"""
Overwrite QDialog close method to allow for custom widget close
Expand Down