Skip to content

Commit

Permalink
Merge pull request #2558 from SasView/disable-residuals
Browse files Browse the repository at this point in the history
Two options to disable residuals and polydispersity distribution plots
  • Loading branch information
butlerpd authored Aug 1, 2023
2 parents c8a3cc5 + bb8f3b9 commit 96f9f42
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/sas/qtgui/MainWindow/DataExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,17 @@ def displayData(self, data_list, id=None):

plot_name = plot_to_show.name
role = plot_to_show.plot_role
stand_alone_types = [DataRole.ROLE_RESIDUAL, DataRole.ROLE_STAND_ALONE]
stand_alone_types = [DataRole.ROLE_RESIDUAL, DataRole.ROLE_STAND_ALONE, DataRole.ROLE_POLYDISPERSITY]

if (role in stand_alone_types and shown) or role == DataRole.ROLE_DELETABLE:
# Nothing to do if stand-alone plot already shown or plot to be deleted
continue
elif role == DataRole.ROLE_RESIDUAL and config.DISABLE_RESIDUAL_PLOT:
# Nothing to do if residuals are not plotted
continue
elif role == DataRole.ROLE_POLYDISPERSITY and config.DISABLE_POLYDISPERSITY_PLOT:
# Nothing to do if polydispersity plot is not plotted
continue
elif role in stand_alone_types:
# Stand-alone plots should always be separate
self.plotData([(plot_item, plot_to_show)])
Expand Down
2 changes: 1 addition & 1 deletion src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def plotPolydispersities(model):
data1d.symbol = 'Line'
data1d.name = "{} polydispersity".format(name)
data1d.id = data1d.name # placeholder, has to be completed later
data1d.plot_role = DataRole.ROLE_STAND_ALONE
data1d.plot_role = DataRole.ROLE_POLYDISPERSITY
plots.append(data1d)
return plots

Expand Down
2 changes: 2 additions & 0 deletions src/sas/qtgui/Plotting/PlotterData.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class DataRole(Enum):
ROLE_RESIDUAL = 3
# Stand alone is for plots that should be plotted separately
ROLE_STAND_ALONE = 4
# Polydispersity is for stand-alone polydispersity plot
ROLE_POLYDISPERSITY = 5


class Data1D(PlottableData1D, LoadData1D):
Expand Down
19 changes: 18 additions & 1 deletion src/sas/qtgui/Utilities/Preferences/DisplayPreferencesWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
class DisplayPreferencesWidget(PreferencesWidget):
def __init__(self):
super(DisplayPreferencesWidget, self).__init__("Display Settings")
self.config_params = ['QT_SCALE_FACTOR', 'QT_AUTO_SCREEN_SCALE_FACTOR']
self.config_params = ['QT_SCALE_FACTOR',
'QT_AUTO_SCREEN_SCALE_FACTOR',
'DISABLE_RESIDUAL_PLOT',
'DISABLE_POLYDISPERSITY_PLOT']
self.restart_params = {'QT_SCALE_FACTOR': 'QT Screen Scale Factor',
'QT_AUTO_SCREEN_SCALE_FACTOR': "Enable Automatic Scaling"}

Expand All @@ -21,12 +24,26 @@ def _addAllWidgets(self):
checked=config.QT_AUTO_SCREEN_SCALE_FACTOR)
self.autoScaling.clicked.connect(
lambda: self._stageChange('QT_AUTO_SCREEN_SCALE_FACTOR', self.autoScaling.isChecked()))
self.disableResidualPlot = self.addCheckBox(
title="Disable Residuals Display",
checked=config.DISABLE_RESIDUAL_PLOT)
self.disableResidualPlot.clicked.connect(
lambda: self._stageChange('DISABLE_RESIDUAL_PLOT', self.disableResidualPlot.isChecked()))
self.disablePolydispersityPlot = self.addCheckBox(
title="Disable Polydispersity Plot Display",
checked=config.DISABLE_POLYDISPERSITY_PLOT)
self.disablePolydispersityPlot.clicked.connect(
lambda: self._stageChange('DISABLE_POLYDISPERSITY_PLOT', self.disablePolydispersityPlot.isChecked()))

def _toggleBlockAllSignaling(self, toggle):
self.qtScaleFactor.blockSignals(toggle)
self.autoScaling.blockSignals(toggle)
self.disableResidualPlot.blockSignals(toggle)
self.disablePolydispersityPlot.blockSignals(toggle)

def _restoreFromConfig(self):
self.qtScaleFactor.setText(str(config.QT_SCALE_FACTOR))
self.qtScaleFactor.setStyleSheet("background-color: white")
self.autoScaling.setChecked(bool(config.QT_AUTO_SCREEN_SCALE_FACTOR))
self.disableResidualPlot.setChecked(config.DISABLE_RESIDUAL_PLOT)
self.disablePolydispersityPlot.setChecked(config.DISABLE_POLYDISPERSITY_PLOT)
8 changes: 8 additions & 0 deletions src/sas/system/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ def __init__(self):
# sets the maximum number of characters per Fitting plot legend entry.
self.FITTING_PLOT_LEGEND_MAX_LINE_LENGTH = 30

# Residuals management
# If true, disables residual plot display
self.DISABLE_RESIDUAL_PLOT = False

# Polydispersity plot management
# If true, disables polydispersity plot display
self.DISABLE_POLYDISPERSITY_PLOT = False

# Default fitting optimizer
self.FITTING_DEFAULT_OPTIMIZER = 'lm'

Expand Down

0 comments on commit 96f9f42

Please # to comment.