Commit aaece4ba authored by Luke Campagnola's avatar Luke Campagnola
Browse files

bugfixes

parent d4e8e2b8
......@@ -298,6 +298,7 @@ class Canvas(QtGui.QWidget):
Common options are name, pos, scale, and z
"""
citem = CanvasItem(item, **opts)
item._canvasItem = citem
self.addItem(citem)
return citem
......@@ -493,12 +494,13 @@ class Canvas(QtGui.QWidget):
def removeItem(self, item):
if isinstance(item, CanvasItem):
item.setCanvas(None)
#self.view.scene().removeItem(item.item)
self.itemList.removeTopLevelItem(item.listItem)
#del self.items[item.name]
self.items.remove(item)
else:
self.view.removeItem(item)
if hasattr(item, '_canvasItem'):
self.removeItem(item._canvasItem)
else:
self.view.removeItem(item)
## disconnect signals, remove from list, etc..
......
......@@ -11,14 +11,14 @@ class ArrowItem(QtGui.QGraphicsPolygonItem):
def __init__(self, **opts):
QtGui.QGraphicsPolygonItem.__init__(self)
QtGui.QGraphicsPolygonItem.__init__(self, opts.get('parent', None))
defOpts = {
'style': 'tri',
'pxMode': True,
'size': 20,
'angle': -150,
'angle': -150, ## If the angle is 0, the arrow points left
'pos': (0,0),
'width': 8,
'width': None, ## width is automatically size / 2.
'tipAngle': 25,
'baseAngle': 90,
'pen': (200,200,200),
......@@ -38,10 +38,15 @@ class ArrowItem(QtGui.QGraphicsPolygonItem):
self.opts = opts
if opts['style'] == 'tri':
if opts['width'] is None:
width = opts['size'] / 2.
else:
width = opts['width']
points = [
QtCore.QPointF(0,0),
QtCore.QPointF(opts['size'],-opts['width']/2.),
QtCore.QPointF(opts['size'],opts['width']/2.),
QtCore.QPointF(opts['size'],-width/2.),
QtCore.QPointF(opts['size'],width/2.),
]
poly = QtGui.QPolygonF(points)
......
......@@ -284,7 +284,7 @@ class AxisItem(GraphicsWidget):
lengthInPixels = Point(points[1] - points[0]).length()
## decide optimal tick spacing in pixels
pixelSpacing = np.log(lengthInPixels+10) * 3
pixelSpacing = np.log(lengthInPixels+10) * 2
optimalTickCount = lengthInPixels / pixelSpacing
## Determine optimal tick spacing
......@@ -328,9 +328,11 @@ class AxisItem(GraphicsWidget):
## draw three different intervals, long ticks first
texts = []
for i in [2,1,0]:
if i1+i > len(intervals):
if i1+i >= len(intervals) or i1+i < 0:
print "AxisItem.paint error: i1=%d, i=%d, len(intervals)=%d" % (i1, i, len(intervals))
continue
## spacing for this interval
sp = pw*intervals[i1+i]
## determine starting tick
......
This diff is collapsed.
......@@ -206,7 +206,10 @@ class ViewBox(GraphicsWidget):
#print "addItem:", item, item.boundingRect()
def removeItem(self, item):
self.addedItems.remove(item)
try:
self.addedItems.remove(item)
except:
pass
self.scene().removeItem(item)
self.updateAutoRange()
......
......@@ -23,9 +23,9 @@ from pyqtgraph.graphicsItems.ViewBox import *
from pyqtgraph.Qt import QtCore, QtGui
import sys
#from numpy import ndarray
import ptime
import pyqtgraph.ptime as ptime
import numpy as np
import debug
import pyqtgraph.debug as debug
from pyqtgraph.SignalProxy import SignalProxy
......
......@@ -11,7 +11,7 @@ from pyqtgraph.Qt import QtCore, QtGui, QtOpenGL, QtSvg
from pyqtgraph.Point import Point
#from vector import *
import sys, os
import debug
#import debug
from FileDialog import FileDialog
from pyqtgraph.GraphicsScene import GraphicsScene
import numpy as np
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment