Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/sas/qtgui/MainWindow/DataExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ def isItemReady(index):
self._perspective().swapData(selected_items[0])
else:
self._perspective().setData(data_item=selected_items, is_batch=self.chkBatch.isChecked())

except Exception as ex:
msg = "%s perspective returned the following message: \n%s\n" % (self._perspective().name, str(ex))
logging.error(ex, exc_info=True)
Expand Down
25 changes: 25 additions & 0 deletions src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

from sas.qtgui.Utilities.Reports.reportdata import ReportData

from sas import config
import time

import logging
logger = logging.getLogger(__name__)

class FittingWindow(QtWidgets.QTabWidget, Perspective):
"""
"""
Expand Down Expand Up @@ -263,9 +269,27 @@ def addFit(self, data, is_batch=False, tab_index=None):
self.addTab(tab, icon, tab_name)
# Show the new tab
self.setCurrentWidget(tab)
# If configured, plot the current data
self.maybePlotOnLoad(tab)

# Notify listeners
self.tabsModifiedSignal.emit()

def maybePlotOnLoad(self,tab):
if tab.data_is_loaded and config.FITTING_PLOT_ON_SEND_DATA:
#First, create model and residuals inside this data.
def tidyup(self):
logger.info(msg='calculation complete, running tidy-up function')
#time.sleep(2)
#tab.onPlot()
#QtWidgets.QApplication.processEvents()
tab.showPlot()
#QtWidgets.QApplication.processEvents()
#time.sleep(2)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Playing with processEvents means there were issues with plot lifetimes? What did you observe?

tab._model_model.clear()
tab.cmdPlot.setEnabled(False)
tab.SASModelToQModel('porod')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did you choose "porod" here, and not the currently active model?

tab.calculateQGridForModelExt(completefn= tidyup)
def addConstraintTab(self):
"""
Add a new C&S fitting tab
Expand Down Expand Up @@ -431,6 +455,7 @@ def setData(self, data_item=None, is_batch=False, tab_index=None):
self.tabs[first_good_tab].data = data
tab_name = str(self.tabText(first_good_tab))
self.updateFitDict(data, tab_name)
self.maybePlotOnLoad(self.tabs[first_good_tab])
else:
self.addFit(data, is_batch=is_batch)

Expand Down
2 changes: 1 addition & 1 deletion src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,7 @@ def _requestPlots(self, item_name, item_model):
data_shown = False
item = None
for item, plot in plots.items():
if fitpage_name in plot.name:
if plot.plot_role != Data1D.ROLE_DATA and fitpage_name in plot.name:
data_shown = True
self.communicate.plotRequestedSignal.emit([item, plot], self.tab_id)
# return the last data item seen, if nothing was plotted; supposed to be just data)
Expand Down
11 changes: 11 additions & 0 deletions src/sas/qtgui/Utilities/Preferences/FittingPreferencesWidget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from sas.system import config

from .PreferencesWidget import PreferencesWidget, config_value_setter_generator


class FittingPreferencesWidget(PreferencesWidget):
def __init__(self):
super(FittingPreferencesWidget, self).__init__("Fitting Settings")
self.addCheckBox(title="Auto-plot data when sent to fitting perspective",
callback=config_value_setter_generator('FITTING_PLOT_ON_SEND_DATA', dtype=bool),
checked=config.FITTING_PLOT_ON_SEND_DATA)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this needs porting to the new way of describing preferences

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class PlottingPreferencesWidget(PreferencesWidget):
def __init__(self):
super(PlottingPreferencesWidget, self).__init__("Plotting Options")
super(PlottingPreferencesWidget, self).__init__("Plotting Settings")
self.addCheckBox(title="Use full-width plot legends (most compatible)?",
callback=config_value_setter_generator('FITTING_PLOT_FULL_WIDTH_LEGENDS', dtype=bool),
checked=config.FITTING_PLOT_FULL_WIDTH_LEGENDS)
Expand Down
6 changes: 4 additions & 2 deletions src/sas/qtgui/Utilities/Preferences/PreferencesPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
from sas.qtgui.Utilities.Preferences.UI.PreferencesUI import Ui_preferencesUI
from sas.qtgui.Utilities.Preferences.PreferencesWidget import PreferencesWidget
from sas.qtgui.Utilities.Preferences.DisplayPreferencesWidget import DisplayPreferencesWidget

from sas.qtgui.Utilities.Preferences.PlottingPreferencesWidget import PlottingPreferencesWidget
from sas.qtgui.Utilities.Preferences.FittingPreferencesWidget import FittingPreferencesWidget
# The PreferencesPanel object will instantiate all widgets during its instantiation.
# e.g:
# `from foo.bar import BarWidget # BarWidget is a child of PreferencesWidget`
# `BASE_PANELS = {"Bar Widget Options": BarWidget}`
# PreferenceWidget Imports go here and then are added to the BASE_PANELS, but not instantiated.
from .PlottingPreferencesWidget import PlottingPreferencesWidget

# Pre-made option widgets

BASE_PANELS = {"Plotting Settings":PlottingPreferencesWidget,
"Display Settings":DisplayPreferencesWidget,
"Fitting Settings":FittingPreferencesWidget,
} # Type: Dict[str, Union[Type[PreferencesWidget], Callable[[],QWidget]]

logger = logging.getLogger(__name__)
Expand Down
3 changes: 3 additions & 0 deletions src/sas/system/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ def __init__(self):
self.QT_SCALE_FACTOR = 1.0
self.QT_AUTO_SCREEN_SCALE_FACTOR = False

# Auto-plot when sending data to Fitting
self.FITTING_PLOT_ON_SEND_DATA = True

# If True, use an ugly but more robust legend plotting method in Fitting that results in full-
# width legends.
self.FITTING_PLOT_FULL_WIDTH_LEGENDS = False
Expand Down