Fixes against previous commits:

- fixed example testing script
 - Added finer axis ticks back in some instances
 - fixed improper bounds caching in log/fft mode
 - fixed exception handling in remoteproxy
This commit is contained in:
Luke Campagnola 2013-01-11 20:21:11 -05:00
parent 9a1d7d74cb
commit 91ff9bbda4
4 changed files with 16 additions and 59 deletions

View File

@ -350,9 +350,7 @@ class AxisItem(GraphicsWidget):
## decide optimal minor tick spacing in pixels (this is just aesthetics) ## decide optimal minor tick spacing in pixels (this is just aesthetics)
pixelSpacing = np.log(size+10) * 5 pixelSpacing = np.log(size+10) * 5
optimalTickCount = size / pixelSpacing optimalTickCount = max(2., size / pixelSpacing)
if optimalTickCount < 1:
optimalTickCount = 1
## optimal minor tick spacing ## optimal minor tick spacing
optimalSpacing = dif / optimalTickCount optimalSpacing = dif / optimalTickCount
@ -366,12 +364,21 @@ class AxisItem(GraphicsWidget):
while intervals[minorIndex+1] <= optimalSpacing: while intervals[minorIndex+1] <= optimalSpacing:
minorIndex += 1 minorIndex += 1
return [ levels = [
(intervals[minorIndex+2], 0), (intervals[minorIndex+2], 0),
(intervals[minorIndex+1], 0), (intervals[minorIndex+1], 0),
#(intervals[minorIndex], 0) ## Pretty, but eats up CPU #(intervals[minorIndex], 0) ## Pretty, but eats up CPU
] ]
## decide whether to include the last level of ticks
minSpacing = min(size / 20., 30.)
maxTickCount = size / minSpacing
if dif / intervals[minorIndex] <= maxTickCount:
levels.append((intervals[minorIndex], 0))
return levels
##### This does not work -- switching between 2/5 confuses the automatic text-level-selection ##### This does not work -- switching between 2/5 confuses the automatic text-level-selection
### Determine major/minor tick spacings which flank the optimal spacing. ### Determine major/minor tick spacings which flank the optimal spacing.
#intervals = np.array([1., 2., 5., 10., 20., 50., 100.]) * p10unit #intervals = np.array([1., 2., 5., 10., 20., 50., 100.]) * p10unit
@ -587,7 +594,7 @@ class AxisItem(GraphicsWidget):
ticks = tickLevels[i][1] ticks = tickLevels[i][1]
## length of tick ## length of tick
tickLength = self.tickLength / ((i*1.0)+1.0) tickLength = self.tickLength / ((i*0.5)+1.0)
lineAlpha = 255 / (i+1) lineAlpha = 255 / (i+1)
if self.grid is not False: if self.grid is not False:

View File

@ -149,39 +149,6 @@ class PlotCurveItem(GraphicsObject):
self.invalidateBounds() self.invalidateBounds()
self.update() self.update()
#def setColor(self, color):
#self.pen.setColor(color)
#self.update()
#def setAlpha(self, alpha, auto):
#self.opts['alphaHint'] = alpha
#self.opts['alphaMode'] = auto
#self.update()
#def setSpectrumMode(self, mode):
#self.opts['spectrumMode'] = mode
#self.xDisp = self.yDisp = None
#self.path = None
#self.update()
#def setLogMode(self, mode):
#self.opts['logMode'] = mode
#self.xDisp = self.yDisp = None
#self.path = None
#self.update()
#def setPointMode(self, mode):
#self.opts['pointMode'] = mode
#self.update()
#def setDownsampling(self, ds):
#if self.opts['downsample'] != ds:
#self.opts['downsample'] = ds
#self.xDisp = self.yDisp = None
#self.path = None
#self.update()
def setData(self, *args, **kargs): def setData(self, *args, **kargs):
""" """
============== ======================================================== ============== ========================================================
@ -483,25 +450,6 @@ class PlotCurveItem(GraphicsObject):
self.path = None self.path = None
#del self.xData, self.yData, self.xDisp, self.yDisp, self.path #del self.xData, self.yData, self.xDisp, self.yDisp, self.path
#def mousePressEvent(self, ev):
##GraphicsObject.mousePressEvent(self, ev)
#if not self.clickable:
#ev.ignore()
#if ev.button() != QtCore.Qt.LeftButton:
#ev.ignore()
#self.mousePressPos = ev.pos()
#self.mouseMoved = False
#def mouseMoveEvent(self, ev):
##GraphicsObject.mouseMoveEvent(self, ev)
#self.mouseMoved = True
##print "move"
#def mouseReleaseEvent(self, ev):
##GraphicsObject.mouseReleaseEvent(self, ev)
#if not self.mouseMoved:
#self.sigClicked.emit(self)
def mouseClickEvent(self, ev): def mouseClickEvent(self, ev):
if not self.clickable or ev.button() != QtCore.Qt.LeftButton: if not self.clickable or ev.button() != QtCore.Qt.LeftButton:
return return

View File

@ -164,6 +164,7 @@ class PlotDataItem(GraphicsObject):
self.opts['fftMode'] = mode self.opts['fftMode'] = mode
self.xDisp = self.yDisp = None self.xDisp = self.yDisp = None
self.updateItems() self.updateItems()
self.informViewBoundsChanged()
def setLogMode(self, xMode, yMode): def setLogMode(self, xMode, yMode):
if self.opts['logMode'] == [xMode, yMode]: if self.opts['logMode'] == [xMode, yMode]:
@ -171,6 +172,7 @@ class PlotDataItem(GraphicsObject):
self.opts['logMode'] = [xMode, yMode] self.opts['logMode'] = [xMode, yMode]
self.xDisp = self.yDisp = None self.xDisp = self.yDisp = None
self.updateItems() self.updateItems()
self.informViewBoundsChanged()
def setPointMode(self, mode): def setPointMode(self, mode):
if self.opts['pointMode'] == mode: if self.opts['pointMode'] == mode:

View File

@ -114,7 +114,7 @@ class RemoteEventHandler(object):
result = None result = None
try: try:
cmd, reqId, nByteMsgs, optStr = self.conn.recv() ## args, kwds are double-pickled to ensure this recv() call never fails cmd, reqId, nByteMsgs, optStr = self.conn.recv() ## args, kwds are double-pickled to ensure this recv() call never fails
except EOFError, IOError: except (EOFError, IOError):
## remote process has shut down; end event loop ## remote process has shut down; end event loop
raise ClosedError() raise ClosedError()
#print os.getpid(), "received request:", cmd, reqId #print os.getpid(), "received request:", cmd, reqId
@ -124,7 +124,7 @@ class RemoteEventHandler(object):
for i in range(nByteMsgs): for i in range(nByteMsgs):
try: try:
byteData.append(self.conn.recv_bytes()) byteData.append(self.conn.recv_bytes())
except EOFError, IOError: except (EOFError, IOError):
raise ClosedError() raise ClosedError()