diff --git a/src/snapred/ui/view/DiffCalTweakPeakView.py b/src/snapred/ui/view/DiffCalTweakPeakView.py index 82f4ea91d..6fbf06dd4 100644 --- a/src/snapred/ui/view/DiffCalTweakPeakView.py +++ b/src/snapred/ui/view/DiffCalTweakPeakView.py @@ -61,6 +61,9 @@ def __init__(self, samples=[], groups=[], parent=None): self.signalRunNumberUpdate.connect(self._updateRunNumber) self.signalMaxChiSqUpdate.connect(self._updateMaxChiSq) + # skip pixel calibration toggle + self.skipPixelCalToggle = self._labeledToggle("Skip Pixel Calibration", False) + self.continueAnyway = False self.signalContinueAnyway.connect(self._updateContinueAnyway) @@ -100,7 +103,8 @@ def __init__(self, samples=[], groups=[], parent=None): # add all elements to the grid layout self.layout.addWidget(self.runNumberField, 0, 0) - self.layout.addWidget(self.litemodeToggle, 0, 1) + self.layout.addWidget(self.litemodeToggle, 0, 1, 1, 2) + self.layout.addWidget(self.skipPixelCalToggle, 0, 2) self.layout.addWidget(self.navigationBar, 1, 0) self.layout.addWidget(self.canvas, 2, 0, 1, -1) self.layout.addLayout(peakControlLayout, 3, 0, 1, 2) @@ -325,3 +329,6 @@ def verify(self): self._testContinueAnywayStates() return True + + def getSkipPixelCalibration(self): + return self.skipPixelCalToggle.field.getState() diff --git a/src/snapred/ui/workflow/DiffCalWorkflow.py b/src/snapred/ui/workflow/DiffCalWorkflow.py index 80b589eae..2ab4e305d 100644 --- a/src/snapred/ui/workflow/DiffCalWorkflow.py +++ b/src/snapred/ui/workflow/DiffCalWorkflow.py @@ -97,6 +97,10 @@ def __init__(self, parent=None): self._requestView.litemodeToggle.stateChanged.connect(self._tweakPeakView.litemodeToggle.setState) self._tweakPeakView.litemodeToggle.stateChanged.connect(self._requestView.litemodeToggle.setState) + # connect the skip pixelcal toggles across the views + self._requestView.skipPixelCalToggle.stateChanged.connect(self._tweakPeakView.skipPixelCalToggle.setState) + self._tweakPeakView.skipPixelCalToggle.stateChanged.connect(self._requestView.skipPixelCalToggle.setState) + self.prevFWHM = DiffCalTweakPeakView.FWHM self.prevXtalDMin = DiffCalTweakPeakView.XTAL_DMIN self.prevXtalDMax = DiffCalTweakPeakView.XTAL_DMAX @@ -257,6 +261,10 @@ def _specifyRun(self, workflowPresenter): self._renewFitPeaks(self.peakFunction) response = self._calculateResidual() + # freeze these toggles, as they can no longer function + self._requestView.litemodeToggle.setEnabled(False) + self._requestView.skipPixelCalToggle.setEnabled(False) + self._tweakPeakView.updateGraphs( self.focusedWorkspace, self.ingredients.groupedPeakLists, @@ -280,8 +288,26 @@ def renewWhenRecalculate(self, groupingIndex, xtalDMin, xtalDMax, peakFunction, self.focusGroupPath = list(self.focusGroups.items())[groupingIndex][0] + newSkipPixelSelection = self._tweakPeakView.skipPixelCalToggle.getState() + + # if the user made a change in skip pixelcal election, redo everything + if self.skipPixelCal != newSkipPixelSelection: + self.skipPixelCal = newSkipPixelSelection + self._renewIngredients(xtalDMin, xtalDMax, peakFunction, fwhm, maxChiSq) + self._renewPixelCal() + self._renewFocus(groupingIndex) + self._renewFitPeaks(peakFunction) + self._calculateResidual() + + # if the grouping file changes, load new grouping and refocus + elif groupingIndex != self.prevGroupingIndex: + self._renewIngredients(xtalDMin, xtalDMax, peakFunction, fwhm, maxChiSq) + self._renewFocus(groupingIndex) + self._renewFitPeaks(peakFunction) + self._calculateResidual() + # if peaks will change, redo only the smoothing - if ( + elif ( xtalDMin != self.prevXtalDMin or xtalDMax != self.prevXtalDMax or peakFunction != self.peakFunction @@ -293,13 +319,6 @@ def renewWhenRecalculate(self, groupingIndex, xtalDMin, xtalDMax, peakFunction, self._renewFitPeaks(peakFunction) self._calculateResidual() - # if the grouping file changes, load new grouping and refocus - if groupingIndex != self.prevGroupingIndex: - self._renewIngredients(xtalDMin, xtalDMax, peakFunction, fwhm, maxChiSq) - self._renewFocus(groupingIndex) - self._renewFitPeaks(peakFunction) - self._calculateResidual() - self.peaksWerePurged = False # NOTE it was determined pixel calibration NOT need to be re-calculated when peak params change.