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

Two options to disable residuals and polydispersity distribution plots #2558

Merged
merged 6 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
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_RESIDUALS:
# 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_RESIDUALS',
'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.disableResiduals = self.addCheckBox(
title="Disable Residuals Display",
checked=config.DISABLE_RESIDUALS)
self.disableResiduals.clicked.connect(
lambda: self._stageChange('DISABLE_RESIDUALS', self.disableResiduals.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.disableResiduals.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.disableResiduals.setChecked(config.DISABLE_RESIDUALS)
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 residuals display
self.DISABLE_RESIDUALS = False
Copy link
Contributor

Choose a reason for hiding this comment

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

please make config entries as explicit as reasonably possible,

I suggest DISABLE_RESIDUAL_PLOT at least

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, done.


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

# Default fitting optimizer
self.FITTING_DEFAULT_OPTIMIZER = 'lm'

Expand Down