Skip to content

Commit

Permalink
Dict blocks are now updated on fit finish
Browse files Browse the repository at this point in the history
  • Loading branch information
rozyczko committed Oct 14, 2024
1 parent 626c4d6 commit 5f3ed25
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
3 changes: 3 additions & 0 deletions easyDiffractionApp/Logic/Connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,16 @@ def updateExperimentPageOnly(self):
#########

def onFittingFitFinished(self):
# Update the blocks first
self._proxy.model.updateBlocksFromPhases()
# Model page
console.debug(formatMsg('main', 'Updating structure view for the current model...'))
self._proxy.model.updateCurrentModelStructView()
console.debug(formatMsg('main', '(Re)converting model data blocks to CIF...'))
self._proxy.model.setDataBlocksCif()

# Experiment page
self._proxy.experiment.updateBlocksFromJob()
console.debug(formatMsg('main', 'Replacing arrays...'))
self._proxy.experiment.replaceArrays()
console.debug(formatMsg('main', f'Redrawing curves on experiment page using {self._proxy.plotting.currentLib1d}...'))
Expand Down
6 changes: 6 additions & 0 deletions easyDiffractionApp/Logic/Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ def loadExperimentFromCifString(self, cifString="", job_name=""):
# self._job.interface = self._interface
self.dataBlocksChanged.emit()

def updateBlocksFromJob(self):
blocks = self.jobToBlock(job=self.job)
self._dataBlocksNoMeas = []
self._dataBlocksNoMeas.append(blocks)
self.dataBlocksChanged.emit()

def jobToBlock(self, job=None):
'''
Convert a Job object to a list of data blocks, without the measured data
Expand Down
12 changes: 7 additions & 5 deletions easyDiffractionApp/Logic/Fittables.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ def editSilently(self, blockType, blockIdx, category, rowIndex, name, field, val
changedIntern = self._proxy.model.editDataBlockLoopParam(blockIdx, category, name, rowIndex, field, value)
self._proxy.model.blocksToLoopPhase(blockIdx, category, name, rowIndex, field, value)
changedCryspy = self._proxy.model.editCalculatorDictByLoopParam(blockIdx, category, name, rowIndex, field, value)
if changedIntern and changedCryspy:
if blockType == 'model':
self.modelChangedSilently.emit()
elif blockType == 'experiment':
self.experimentChangedSilently.emit()
#if changedIntern and changedCryspy:
### genericUpdate now messes with changedIntern and changedCryspy
### so we just force the updates
if blockType == 'model':
self.modelChangedSilently.emit()
elif blockType == 'experiment':
self.experimentChangedSilently.emit()

def set(self):
_data = []
Expand Down
7 changes: 7 additions & 0 deletions easyDiffractionApp/Logic/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ def loadModelsFromEdCif(self, edCif):
self.updateCifOnInterface(cif=edCif)
self.dataBlocksChanged.emit()

def updateBlocksFromPhases(self):
self._dataBlocks = [] # clear the list
for phase in self.job.phases:
self._dataBlocks.append(self.phaseToBlocks([phase]))
self.setDataBlocksCif()
self.dataBlocksChanged.emit()

def updateCifOnInterface(self, cif=None):
'''
Update the CIF representation on the current interface
Expand Down

0 comments on commit 5f3ed25

Please sign in to comment.