Skip to content

Commit

Permalink
Grain selector persists choices between sims if the number of grains …
Browse files Browse the repository at this point in the history
…has not changed
  • Loading branch information
reilleya committed Jul 9, 2019
1 parent ca6691e commit 84dc366
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions uilib/widgets/grainSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ def getUnselectedGrains(self):
if not check.isChecked():
selected.append(checkId)
return selected

def setChecks(self, checks):
for check in self.checks:
check.setCheckState(0)
for check in checks:
self.checks[check].setCheckState(2)
1 change: 1 addition & 0 deletions uilib/widgets/propellantMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def newPropellant(self):
self.setupPropList()
self.setupButtons()
self.manager.savePropellants()
self.repaint() # OSX needs this

def deleteProp(self):
del self.manager.propellants[self.ui.listWidgetPropellants.currentRow()]
Expand Down
12 changes: 10 additions & 2 deletions uilib/widgets/resultsWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ def __init__(self, parent):
self.ui.setupUi(self)
self.preferences = None
self.simResult = None
self.cachedChecks = None

self.ui.channelSelectorX.setupChecks(False, default='time', exclude=['mass', 'massFlow', 'massFlux'])
self.ui.channelSelectorX.setupChecks(False, default='time', exclude=['kn', 'pressure', 'force', 'mass',
'massFlow', 'massFlux'])
self.ui.channelSelectorX.setTitle('X Axis')
self.ui.channelSelectorY.setupChecks(True, default=['kn', 'pressure', 'force'])
self.ui.channelSelectorY.setTitle('Y Axis')
Expand All @@ -35,9 +37,15 @@ def setPreferences(self, pref):
self.ui.widgetGraph.setPreferences(pref)

def showData(self, simResult):
if self.simResult is not None:
newMotor = len(simResult.motor.grains) != len(self.simResult.motor.grains)
else:
newMotor = True
self.simResult = simResult
self.ui.grainSelector.resetChecks()
self.ui.grainSelector.setupChecks(simResult, True)
if not newMotor and self.cachedChecks is not None:
self.ui.grainSelector.setChecks(self.cachedChecks)
self.drawGraphs()

self.cleanupGrainTab()
Expand Down Expand Up @@ -109,7 +117,7 @@ def updateGrainTab(self):
self.ui.labelISPRemaining.setText('-')

def resetPlot(self):
self.simResult = None
self.cachedChecks = self.ui.grainSelector.getSelectedGrains()
self.ui.grainSelector.resetChecks()
self.ui.widgetGraph.resetPlot()
self.cleanupGrainTab()
Expand Down

0 comments on commit 84dc366

Please sign in to comment.