From c8ee4a86be7b2d3a6c5075e6657531153ae685d8 Mon Sep 17 00:00:00 2001
From: Luke Campagnola <luke.campagnola@gmail.com>
Date: Sun, 9 Feb 2014 10:39:20 -0500
Subject: [PATCH] Added support for GL_LINES in GLLinePlotItem

---
 pyqtgraph/opengl/items/GLLinePlotItem.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/pyqtgraph/opengl/items/GLLinePlotItem.py b/pyqtgraph/opengl/items/GLLinePlotItem.py
index a578dd1d..459d701e 100644
--- a/pyqtgraph/opengl/items/GLLinePlotItem.py
+++ b/pyqtgraph/opengl/items/GLLinePlotItem.py
@@ -16,6 +16,7 @@ class GLLinePlotItem(GLGraphicsItem):
         glopts = kwds.pop('glOptions', 'additive')
         self.setGLOptions(glopts)
         self.pos = None
+        self.mode = 'line_strip'
         self.width = 1.
         self.color = (1.0,1.0,1.0,1.0)
         self.setData(**kwds)
@@ -35,9 +36,13 @@ class GLLinePlotItem(GLGraphicsItem):
                               a single color for the entire item.
         width                 float specifying line width
         antialias             enables smooth line drawing
+        mode                  'lines': Each pair of vertexes draws a single line
+                                       segment.
+                              'line_strip': All vertexes are drawn as a
+                                            continuous set of line segments.
         ====================  ==================================================
         """
-        args = ['pos', 'color', 'width', 'connected', 'antialias']
+        args = ['pos', 'color', 'width', 'mode', 'antialias']
         for k in kwds.keys():
             if k not in args:
                 raise Exception('Invalid keyword argument: %s (allowed arguments are %s)' % (k, str(args)))
@@ -93,7 +98,13 @@ class GLLinePlotItem(GLGraphicsItem):
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
                 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
                 
-            glDrawArrays(GL_LINE_STRIP, 0, int(self.pos.size / self.pos.shape[-1]))
+            if self.mode == 'line_strip':
+                glDrawArrays(GL_LINE_STRIP, 0, int(self.pos.size / self.pos.shape[-1]))
+            elif self.mode == 'lines':
+                glDrawArrays(GL_LINES, 0, int(self.pos.size / self.pos.shape[-1]))
+            else:
+                raise Exception("Unknown line mode '%s'. (must be 'lines' or 'line_strip')" % self.mode)
+                
         finally:
             glDisableClientState(GL_COLOR_ARRAY)
             glDisableClientState(GL_VERTEX_ARRAY)
-- 
GitLab