diff --git a/friture/plotting/glCanvasWidget.py b/friture/plotting/glCanvasWidget.py index 4927100c..a1ecc1b8 100644 --- a/friture/plotting/glCanvasWidget.py +++ b/friture/plotting/glCanvasWidget.py @@ -43,6 +43,7 @@ def __init__(self, parent, verticalScaleTransform, horizontalScaleTransform): self.attachedItems = [] self.gridList = None + self.gridNeedsUpdating = True self.horizontalScaleTransform = horizontalScaleTransform self.verticalScaleTransform = verticalScaleTransform @@ -104,7 +105,8 @@ def setGrid(self, xMajorTick, xMinorTick, yMajorTick, yMinorTick): self.yMajorTick = self.verticalScaleTransform.toScreen(yMajorTick) self.yMinorTick = self.verticalScaleTransform.toScreen(yMinorTick) - self.updateGrid() + # trigger a grid update on next paintGL call + self.gridNeedsUpdating = True def updateGrid(self): if self.gridList is None or self.gridList == 0: @@ -149,6 +151,8 @@ def updateGrid(self): GL.glEndList() + self.gridNeedsUpdating = False + def paintGL(self): GL.glMatrixMode(GL.GL_PROJECTION) GL.glPushMatrix() @@ -281,7 +285,8 @@ def drawTrackerText(self, painter): def resizeGL(self, width, height): self.setupViewport(self.width(), self.height()) - self.updateGrid() + + self.gridNeedsUpdating = True # give the opportunity to the scales to adapt self.resized.emit(self.width(), self.height()) @@ -320,6 +325,7 @@ def drawGrid(self): if self.gridList == 0 or self.gridList is None: raise RuntimeError("""Unable to generate a new display-list, context may not support display lists""") + if self.gridNeedsUpdating: self.updateGrid() GL.glCallList(self.gridList)