Skip to content

Commit

Permalink
Merge tag 'pyqtgraph-0.9.7' into pyqtgraph-core
Browse files Browse the repository at this point in the history
  • Loading branch information
campagnola committed Dec 23, 2013
2 parents 9126b27 + 03683a5 commit ef0ee7c
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 79 deletions.
4 changes: 4 additions & 0 deletions GraphicsScene/exportDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ def __init__(self, scene):

def show(self, item=None):
if item is not None:
## Select next exportable parent of the item originally clicked on
while not isinstance(item, pg.ViewBox) and not isinstance(item, pg.PlotItem) and item is not None:
item = item.parentItem()
## if this is a ViewBox inside a PlotItem, select the parent instead.
if isinstance(item, pg.ViewBox) and isinstance(item.parentItem(), pg.PlotItem):
item = item.parentItem()
self.updateItemList(select=item)
self.setVisible(True)
self.activateWindow()
Expand Down
2 changes: 1 addition & 1 deletion PlotData.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self):
self.maxVals = {} ## cache for max/min
self.minVals = {}

def addFields(self, fields):
def addFields(self, **fields):
for f in fields:
if f not in self.fields:
self.fields[f] = None
Expand Down
4 changes: 2 additions & 2 deletions configfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""

import re, os, sys
from pgcollections import OrderedDict
from .pgcollections import OrderedDict
GLOBAL_PATH = None # so not thread safe.
from . import units
from .python2_3 import asUnicode
Expand Down Expand Up @@ -199,4 +199,4 @@ def measureIndent(s):
print("============")
data = readConfigFile(fn)
print(data)
os.remove(fn)
os.remove(fn)
13 changes: 13 additions & 0 deletions dockarea/Dock.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,19 @@ def containerChanged(self, c):
def __repr__(self):
return "<Dock %s %s>" % (self.name(), self.stretch())

## PySide bug: We need to explicitly redefine these methods
## or else drag/drop events will not be delivered.
def dragEnterEvent(self, *args):
DockDrop.dragEnterEvent(self, *args)

def dragMoveEvent(self, *args):
DockDrop.dragMoveEvent(self, *args)

def dragLeaveEvent(self, *args):
DockDrop.dragLeaveEvent(self, *args)

def dropEvent(self, *args):
DockDrop.dropEvent(self, *args)

class DockLabel(VerticalLabel):

Expand Down
26 changes: 24 additions & 2 deletions dockarea/DockArea.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,26 @@ def __init__(self, temporary=False, home=None):
def type(self):
return "top"

def addDock(self, dock, position='bottom', relativeTo=None):
def addDock(self, dock=None, position='bottom', relativeTo=None, **kwds):
"""Adds a dock to this area.
=========== =================================================================
Arguments:
dock The new Dock object to add.
dock The new Dock object to add. If None, then a new Dock will be
created.
position 'bottom', 'top', 'left', 'right', 'over', or 'under'
relativeTo If relativeTo is None, then the new Dock is added to fill an
entire edge of the window. If relativeTo is another Dock, then
the new Dock is placed adjacent to it (or in a tabbed
configuration for 'over' and 'under').
=========== =================================================================
All extra keyword arguments are passed to Dock.__init__() if *dock* is
None.
"""
if dock is None:
dock = Dock(**kwds)


## Determine the container to insert this dock into.
## If there is no neighbor, then the container is the top.
Expand Down Expand Up @@ -100,6 +106,8 @@ def addDock(self, dock, position='bottom', relativeTo=None):
dock.area = self
self.docks[dock.name()] = dock

return dock

def moveDock(self, dock, position, neighbor):
"""
Move an existing Dock to a new location.
Expand Down Expand Up @@ -293,5 +301,19 @@ def apoptose(self):
self.home.removeTempArea(self)
#self.close()

## PySide bug: We need to explicitly redefine these methods
## or else drag/drop events will not be delivered.
def dragEnterEvent(self, *args):
DockDrop.dragEnterEvent(self, *args)

def dragMoveEvent(self, *args):
DockDrop.dragMoveEvent(self, *args)

def dragLeaveEvent(self, *args):
DockDrop.dragLeaveEvent(self, *args)

def dropEvent(self, *args):
DockDrop.dropEvent(self, *args)



12 changes: 5 additions & 7 deletions exporters/CSVExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self, item):
Exporter.__init__(self, item)
self.params = Parameter(name='params', type='group', children=[
{'name': 'separator', 'type': 'list', 'value': 'comma', 'values': ['comma', 'tab']},
{'name': 'precision', 'type': 'int', 'value': 10, 'limits': [0, None]},
])

def parameters(self):
Expand Down Expand Up @@ -42,18 +43,15 @@ def export(self, fileName=None):

fd.write(sep.join(header) + '\n')
i = 0
while True:
done = True
numFormat = '%%0.%dg' % self.params['precision']
numRows = reduce(max, [len(d[0]) for d in data])
for i in range(numRows):
for d in data:
if i < len(d[0]):
fd.write('%g%s%g%s'%(d[0][i], sep, d[1][i], sep))
done = False
fd.write(numFormat % d[0][i] + sep + numFormat % d[1][i] + sep)
else:
fd.write(' %s %s' % (sep, sep))
fd.write('\n')
if done:
break
i += 1
fd.close()


Expand Down
8 changes: 0 additions & 8 deletions flowchart/Flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,12 @@ def addNode(self, node, name, pos=None):
item = node.graphicsItem()
item.setZValue(self.nextZVal*2)
self.nextZVal += 1
#item.setParentItem(self.chartGraphicsItem())
self.viewBox.addItem(item)
#item.setPos(pos2.x(), pos2.y())
item.moveBy(*pos)
self._nodes[name] = node
self.widget().addNode(node)
#QtCore.QObject.connect(node, QtCore.SIGNAL('closed'), self.nodeClosed)
node.sigClosed.connect(self.nodeClosed)
#QtCore.QObject.connect(node, QtCore.SIGNAL('renamed'), self.nodeRenamed)
node.sigRenamed.connect(self.nodeRenamed)
#QtCore.QObject.connect(node, QtCore.SIGNAL('outputChanged'), self.nodeOutputChanged)
node.sigOutputChanged.connect(self.nodeOutputChanged)

def removeNode(self, node):
Expand All @@ -225,17 +220,14 @@ def removeNode(self, node):
def nodeClosed(self, node):
del self._nodes[node.name()]
self.widget().removeNode(node)
#QtCore.QObject.disconnect(node, QtCore.SIGNAL('closed'), self.nodeClosed)
try:
node.sigClosed.disconnect(self.nodeClosed)
except TypeError:
pass
#QtCore.QObject.disconnect(node, QtCore.SIGNAL('renamed'), self.nodeRenamed)
try:
node.sigRenamed.disconnect(self.nodeRenamed)
except TypeError:
pass
#QtCore.QObject.disconnect(node, QtCore.SIGNAL('outputChanged'), self.nodeOutputChanged)
try:
node.sigOutputChanged.disconnect(self.nodeOutputChanged)
except TypeError:
Expand Down
2 changes: 1 addition & 1 deletion flowchart/FlowchartTemplate.ui
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<customwidget>
<class>FlowchartGraphicsView</class>
<extends>QGraphicsView</extends>
<header>FlowchartGraphicsView</header>
<header>pyqtgraph.flowchart.FlowchartGraphicsView</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
6 changes: 3 additions & 3 deletions flowchart/FlowchartTemplate_pyqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Form implementation generated from reading ui file './flowchart/FlowchartTemplate.ui'
#
# Created: Sun Sep 9 14:41:29 2012
# by: PyQt4 UI code generator 4.9.1
# Created: Sun Feb 24 19:47:29 2013
# by: PyQt4 UI code generator 4.9.3
#
# WARNING! All changes made in this file will be lost!

Expand Down Expand Up @@ -56,4 +56,4 @@ def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))

from pyqtgraph.widgets.DataTreeWidget import DataTreeWidget
from FlowchartGraphicsView import FlowchartGraphicsView
from pyqtgraph.flowchart.FlowchartGraphicsView import FlowchartGraphicsView
6 changes: 3 additions & 3 deletions flowchart/FlowchartTemplate_pyside.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Form implementation generated from reading ui file './flowchart/FlowchartTemplate.ui'
#
# Created: Sun Sep 9 14:41:30 2012
# by: pyside-uic 0.2.13 running on PySide 1.1.0
# Created: Sun Feb 24 19:47:30 2013
# by: pyside-uic 0.2.13 running on PySide 1.1.1
#
# WARNING! All changes made in this file will be lost!

Expand Down Expand Up @@ -51,4 +51,4 @@ def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))

from pyqtgraph.widgets.DataTreeWidget import DataTreeWidget
from FlowchartGraphicsView import FlowchartGraphicsView
from pyqtgraph.flowchart.FlowchartGraphicsView import FlowchartGraphicsView
3 changes: 1 addition & 2 deletions flowchart/library/Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def process(self, data=None, display=True):
#print " new rgn:", c, region
#self.items[c].setYRange([0., 0.2], relative=True)

if self.selected.isConnected():
if self['selected'].isConnected():
if data is None:
sliced = None
elif (hasattr(data, 'implements') and data.implements('MetaArray')):
Expand Down Expand Up @@ -219,7 +219,6 @@ def focusOutEvent(self, ev):
text = str(self.text.toPlainText())
if text != self.lastText:
self.lastText = text
print("eval node update")
self.update()
return QtGui.QTextEdit.focusOutEvent(self.text, ev)

Expand Down
2 changes: 1 addition & 1 deletion flowchart/library/Display.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, name):
self.items = {}

def disconnected(self, localTerm, remoteTerm):
if localTerm is self.In and remoteTerm in self.items:
if localTerm is self['In'] and remoteTerm in self.items:
self.plot.removeItem(self.items[remoteTerm])
del self.items[remoteTerm]

Expand Down
35 changes: 34 additions & 1 deletion graphicsItems/ArrowItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,41 @@ def setStyle(self, **opts):
def paint(self, p, *args):
p.setRenderHint(QtGui.QPainter.Antialiasing)
QtGui.QGraphicsPathItem.paint(self, p, *args)

#p.setPen(fn.mkPen('r'))
#p.setBrush(fn.mkBrush(None))
#p.drawRect(self.boundingRect())

def shape(self):
#if not self.opts['pxMode']:
#return QtGui.QGraphicsPathItem.shape(self)
return self.path
return self.path

## dataBounds and pixelPadding methods are provided to ensure ViewBox can
## properly auto-range
def dataBounds(self, ax, frac, orthoRange=None):
pw = 0
pen = self.pen()
if not pen.isCosmetic():
pw = pen.width() * 0.7072
if self.opts['pxMode']:
return [0,0]
else:
br = self.boundingRect()
if ax == 0:
return [br.left()-pw, br.right()+pw]
else:
return [br.top()-pw, br.bottom()+pw]

def pixelPadding(self):
pad = 0
if self.opts['pxMode']:
br = self.boundingRect()
pad += (br.width()**2 + br.height()**2) ** 0.5
pen = self.pen()
if pen.isCosmetic():
pad += max(1, pen.width()) * 0.7072
return pad



5 changes: 3 additions & 2 deletions graphicsItems/GradientEditorItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,8 @@ def setColorMap(self, cm):
self.sigGradientChangeFinished.emit(self)


class Tick(GraphicsObject):
class Tick(QtGui.QGraphicsObject): ## NOTE: Making this a subclass of GraphicsObject instead results in
## activating this bug: https://bugreports.qt-project.org/browse/PYSIDE-86
## private class

sigMoving = QtCore.Signal(object)
Expand All @@ -802,7 +803,7 @@ def __init__(self, view, pos, color, movable=True, scale=10, pen='w'):
self.pg.lineTo(QtCore.QPointF(scale/3**0.5, scale))
self.pg.closeSubpath()

GraphicsObject.__init__(self)
QtGui.QGraphicsObject.__init__(self)
self.setPos(pos[0], pos[1])
if self.movable:
self.setZValue(1)
Expand Down
10 changes: 5 additions & 5 deletions graphicsItems/ScatterPlotItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ def setSize(self, size, update=True, dataSet=None, mask=None):

if isinstance(size, np.ndarray) or isinstance(size, list):
sizes = size
if kargs['mask'] is not None:
sizes = sizes[kargs['mask']]
if mask is not None:
sizes = sizes[mask]
if len(sizes) != len(dataSet):
raise Exception("Number of sizes does not match number of points (%d != %d)" % (len(sizes), len(dataSet)))
dataSet['size'] = sizes
Expand All @@ -508,13 +508,13 @@ def setSize(self, size, update=True, dataSet=None, mask=None):
if update:
self.updateSpots(dataSet)

def setPointData(self, data, dataSet=None):
def setPointData(self, data, dataSet=None, mask=None):
if dataSet is None:
dataSet = self.data

if isinstance(data, np.ndarray) or isinstance(data, list):
if kargs['mask'] is not None:
data = data[kargs['mask']]
if mask is not None:
data = data[mask]
if len(data) != len(dataSet):
raise Exception("Length of meta data does not match number of points (%d != %d)" % (len(data), len(dataSet)))

Expand Down
Loading

0 comments on commit ef0ee7c

Please sign in to comment.