From a55d58024d4b49c8787dcf5c8e3d6b4f2c02cae2 Mon Sep 17 00:00:00 2001
From: Luke Campagnola <luke.campagnola@gmail.com>
Date: Wed, 22 May 2013 14:09:56 -0400
Subject: [PATCH] Added Dock.close() Fixed bugs in functions weave usage
 Documented ROI signals Fixed 3D view updating after every scene change

---
 pyqtgraph/dockarea/Dock.py         |  7 +++++++
 pyqtgraph/functions.py             | 31 +++++++++++++++---------------
 pyqtgraph/graphicsItems/ROI.py     | 15 +++++++++++++++
 pyqtgraph/opengl/GLGraphicsItem.py |  2 +-
 4 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/pyqtgraph/dockarea/Dock.py b/pyqtgraph/dockarea/Dock.py
index 19ebc76e..414980ac 100644
--- a/pyqtgraph/dockarea/Dock.py
+++ b/pyqtgraph/dockarea/Dock.py
@@ -209,6 +209,13 @@ class Dock(QtGui.QWidget, DockDrop):
             
         self.setOrientation(force=True)
 
+    def close(self):
+        """Remove this dock from the DockArea it lives inside."""
+        self.setParent(None)
+        self.label.setParent(None)
+        self._container.apoptose()
+        self._container = None
+
     def __repr__(self):
         return "<Dock %s %s>" % (self.name(), self.stretch())
 
diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py
index 6c52e775..836ae433 100644
--- a/pyqtgraph/functions.py
+++ b/pyqtgraph/functions.py
@@ -23,7 +23,7 @@ SI_PREFIXES_ASCII = 'yzafpnum kMGTPEZY'
 
 
 from .Qt import QtGui, QtCore, USE_PYSIDE
-from pyqtgraph import getConfigOption
+import pyqtgraph as pg
 import numpy as np
 import decimal, re
 import ctypes
@@ -32,12 +32,12 @@ import sys, struct
 try:
     import scipy.ndimage
     HAVE_SCIPY = True
-    WEAVE_DEBUG = getConfigOption('weaveDebug')
-    try:
-        import scipy.weave
-        USE_WEAVE = getConfigOption('useWeave')
-    except:
-        USE_WEAVE = False
+    WEAVE_DEBUG = pg.getConfigOption('weaveDebug')
+    if pg.getConfigOption('useWeave'):
+        try:
+            import scipy.weave
+        except ImportError:
+            pg.setConfigOptions(useWeave=False)
 except ImportError:
     HAVE_SCIPY = False
 
@@ -611,18 +611,19 @@ def rescaleData(data, scale, offset, dtype=None):
         
     Uses scipy.weave (if available) to improve performance.
     """
-    global USE_WEAVE
     if dtype is None:
         dtype = data.dtype
+    else:
+        dtype = np.dtype(dtype)
     
     try:
-        if not USE_WEAVE:
+        if not pg.getConfigOption('useWeave'):
             raise Exception('Weave is disabled; falling back to slower version.')
         
         ## require native dtype when using weave
-        if not data.dtype.isnative():
+        if not data.dtype.isnative:
             data = data.astype(data.dtype.newbyteorder('='))
-        if not dtype.isnative():
+        if not dtype.isnative:
             weaveDtype = dtype.newbyteorder('=')
         else:
             weaveDtype = dtype
@@ -643,10 +644,10 @@ def rescaleData(data, scale, offset, dtype=None):
             newData = newData.astype(dtype)
         data = newData.reshape(data.shape)
     except:
-        if USE_WEAVE:
-            if WEAVE_DEBUG:
+        if pg.getConfigOption('useWeave'):
+            if pg.getConfigOption('weaveDebug'):
                 debug.printExc("Error; disabling weave.")
-            USE_WEAVE = False
+            pg.setConfigOption('useWeave', False)
         
         #p = np.poly1d([scale, -offset*scale])
         #data = p(data).astype(dtype)
@@ -663,8 +664,6 @@ def applyLookupTable(data, lut):
     Uses scipy.weave to improve performance if it is available.
     Note: color gradient lookup tables can be generated using GradientWidget.
     """
-    global USE_WEAVE
-    
     if data.dtype.kind not in ('i', 'u'):
         data = data.astype(int)
     
diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py
index 97669fe0..bdfc8508 100644
--- a/pyqtgraph/graphicsItems/ROI.py
+++ b/pyqtgraph/graphicsItems/ROI.py
@@ -38,6 +38,21 @@ def rectStr(r):
 class ROI(GraphicsObject):
     """Generic region-of-interest widget. 
     Can be used for implementing many types of selection box with rotate/translate/scale handles.
+    
+    Signals
+    ----------------------- ----------------------------------------------------
+    sigRegionChangeFinished Emitted when the user stops dragging the ROI (or
+                            one of its handles) or if the ROI is changed
+                            programatically.
+    sigRegionChangeStarted  Emitted when the user starts dragging the ROI (or
+                            one of its handles).
+    sigRegionChanged        Emitted any time the position of the ROI changes,
+                            including while it is being dragged by the user.
+    sigHoverEvent           Emitted when the mouse hovers over the ROI.
+    sigClicked              Emitted when the user clicks on the ROI
+    sigRemoveRequested      Emitted when the user selects 'remove' from the 
+                            ROI's context menu (if available).
+    ----------------------- ----------------------------------------------------
     """
     
     sigRegionChangeFinished = QtCore.Signal(object)
diff --git a/pyqtgraph/opengl/GLGraphicsItem.py b/pyqtgraph/opengl/GLGraphicsItem.py
index f73b0a7a..59bc4449 100644
--- a/pyqtgraph/opengl/GLGraphicsItem.py
+++ b/pyqtgraph/opengl/GLGraphicsItem.py
@@ -240,7 +240,7 @@ class GLGraphicsItem(QtCore.QObject):
         v = self.view()
         if v is None:
             return
-        v.updateGL()
+        v.update()
         
     def mapToParent(self, point):
         tr = self.transform()
-- 
GitLab