make antialiasing optional for paintGL in PlotCurveItem (#1932)

* make antialiasing optional for paintGL in PlotCurveItem

* reversion to standard values if aa is disabled

* remove unnecessary lines
This commit is contained in:
Martin Schulz 2021-07-30 21:19:02 +02:00 committed by GitHub
parent 5084d9b537
commit 96cccd96ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 4 deletions

View File

@ -628,10 +628,20 @@ class PlotCurveItem(GraphicsObject):
width = 1
gl.glPointSize(width)
gl.glLineWidth(width)
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST)
# enable antialiasing if requested
if self._exportOpts is not False:
aa = self._exportOpts.get('antialias', True)
else:
aa = self.opts['antialias']
if aa:
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST)
else:
gl.glDisable(gl.GL_LINE_SMOOTH)
gl.glDrawArrays(gl.GL_LINE_STRIP, 0, int(pos.size / pos.shape[-1]))
finally:
gl.glDisableClientState(gl.GL_VERTEX_ARRAY)