Skip to content

Commit

Permalink
Navigate to image/graph tabs when all alerts cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
reilleya committed Dec 16, 2024
1 parent 545a8e1 commit fdfc219
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
20 changes: 20 additions & 0 deletions uilib/widgets/grainPreviewWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def __init__(self):
self.ui.tabRegression.setupImagePlot()
self.ui.tabAreaGraph.setupGraphPlot()

# Used to navigate back to the tab the user was on after they clear alerts
self.lastNonAlertTab = 1

self.ui.tabWidget.currentChanged.connect(self.onTabChanged)

self.previewReady.connect(self.updateView)

def loadGrain(self, grain):
Expand All @@ -31,8 +36,18 @@ def loadGrain(self, grain):

for alert in geomAlerts:
if alert.level == motorlib.simResult.SimAlertLevel.ERROR:
# Go to alerts tab and clear up graph/images
self.ui.tabWidget.setCurrentIndex(0)
self.ui.tabFace.cleanup()
self.ui.tabRegression.cleanup()
self.ui.tabAreaGraph.cleanup()
return

# If they were on the alert tab, go to their last image/graph tab. Otherwise, let them stay
if self.ui.tabWidget.currentIndex() == 0:
self.ui.tabWidget.setCurrentIndex(self.lastNonAlertTab)

# Generate the contents to show on the image/graph tabs
dataThread = Thread(target=self._genData, args=[grain])
dataThread.start()

Expand Down Expand Up @@ -60,7 +75,12 @@ def updateView(self, data):
self.ui.tabAreaGraph.cleanup()
self.ui.tabAreaGraph.showGraph(points)

def onTabChanged(self, tabIndex):
if tabIndex != 0:
self.lastNonAlertTab = tabIndex

def cleanup(self):
self.lastNonAlertTab = 1
self.ui.tabAlerts.clear()
self.ui.tabRegression.cleanup()
self.ui.tabFace.cleanup()
Expand Down
3 changes: 3 additions & 0 deletions uilib/widgets/nozzlePreviewWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def loadNozzle(self, nozzle):

for alert in geomAlerts:
if alert.level == motorlib.simResult.SimAlertLevel.ERROR:
self.ui.tabWidget.setCurrentIndex(0)
return

convAngle = radians(nozzle.props['convAngle'].getValue())
Expand Down Expand Up @@ -84,6 +85,8 @@ def loadNozzle(self, nozzle):
self.lower.setPolygon(lower)
self.rescale()

self.ui.tabWidget.setCurrentIndex(1)

def rescale(self):
self.scene.setSceneRect(self.scene.itemsBoundingRect())
self.ui.tabCrossSection.fitInView(self.scene.sceneRect(), Qt.AspectRatioMode.KeepAspectRatio)
6 changes: 6 additions & 0 deletions uilib/widgets/propertyEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
class PropertyEditor(QWidget):

valueChanged = pyqtSignal()
# Emitted when the user presses shift+enter and wants to close the collection editor
applyChanges = pyqtSignal()

def __init__(self, parent, prop, preferences):
super(PropertyEditor, self).__init__(QWidget(parent))
Expand Down Expand Up @@ -40,6 +42,7 @@ def __init__(self, parent, prop, preferences):

self.editor.setValue(motorlib.units.convert(self.prop.getValue(), prop.unit, self.dispUnit))
self.editor.valueChanged.connect(self.valueChanged.emit)
self.editor.valueChanged.connect(self.checkApplyChanges)
self.layout().addWidget(self.editor)

elif isinstance(prop, motorlib.properties.IntProperty):
Expand Down Expand Up @@ -115,3 +118,6 @@ def getValue(self):
return self.editor.getTabs()

return None

def checkApplyChanges(self):
print('hello')

0 comments on commit fdfc219

Please sign in to comment.