Commit 7efc9754 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Numerous updates merged from acq4

parent 11897061
......@@ -234,11 +234,14 @@ class GraphicsView(QtGui.QGraphicsView):
def mousePressEvent(self, ev):
QtGui.QGraphicsView.mousePressEvent(self, ev)
#print "Press over:"
#for i in self.items(ev.pos()):
#print i.zValue(), int(i.acceptedMouseButtons()), i, i.scenePos()
# print i.zValue(), int(i.acceptedMouseButtons()), i, i.scenePos()
#print "Event accepted:", ev.isAccepted()
#print "Grabber:", self.scene().mouseGrabberItem()
if not self.mouseEnabled:
return
self.lastMousePos = Point(ev.pos())
......
......@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'ImageViewTemplate.ui'
#
# Created: Fri Nov 20 08:22:10 2009
# Created: Mon Mar 29 22:40:48 2010
# by: PyQt4 UI code generator 4.6
#
# WARNING! All changes made in this file will be lost!
......@@ -134,9 +134,6 @@ class Ui_Form(object):
self.label_10.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_10.setObjectName("label_10")
self.gridLayout_2.addWidget(self.label_10, 4, 5, 1, 1)
self.normTBlurSpin = QtGui.QDoubleSpinBox(self.normGroup)
self.normTBlurSpin.setObjectName("normTBlurSpin")
self.gridLayout_2.addWidget(self.normTBlurSpin, 4, 6, 1, 1)
self.normStopLabel = QtGui.QLabel(self.normGroup)
self.normStopLabel.setObjectName("normStopLabel")
self.gridLayout_2.addWidget(self.normStopLabel, 3, 6, 1, 1)
......@@ -153,6 +150,9 @@ class Ui_Form(object):
self.normFrameCheck = QtGui.QCheckBox(self.normGroup)
self.normFrameCheck.setObjectName("normFrameCheck")
self.gridLayout_2.addWidget(self.normFrameCheck, 1, 2, 1, 1)
self.normTBlurSpin = QtGui.QDoubleSpinBox(self.normGroup)
self.normTBlurSpin.setObjectName("normTBlurSpin")
self.gridLayout_2.addWidget(self.normTBlurSpin, 4, 6, 1, 1)
self.gridLayout.addWidget(self.normGroup, 5, 0, 1, 4)
self.roiPlot = PlotWidget(self.splitter)
self.roiPlot.setMinimumSize(QtCore.QSize(0, 40))
......
......@@ -187,7 +187,9 @@ class PlotItem(QtGui.QGraphicsWidget):
QtCore.QObject.connect(self.ctrl.xLinkCombo, QtCore.SIGNAL('currentIndexChanged(int)'), self.xLinkComboChanged)
QtCore.QObject.connect(self.ctrl.yLinkCombo, QtCore.SIGNAL('currentIndexChanged(int)'), self.yLinkComboChanged)
QtCore.QObject.connect(c.downsampleSpin, QtCore.SIGNAL('valueChanged(int)'), self.updateDownsampling)
QtCore.QObject.connect(self.ctrl.avgParamList, QtCore.SIGNAL('itemClicked(QListWidgetItem*)'), self.avgParamListClicked)
QtCore.QObject.connect(self.ctrl.averageGroup, QtCore.SIGNAL('toggled(bool)'), self.avgToggled)
......@@ -348,18 +350,21 @@ class PlotItem(QtGui.QGraphicsWidget):
def addAvgCurve(self, curve):
"""Add a single curve into the pool of curves averaged together"""
### First determine the key of the curve to which this new data should be averaged
## If there are plot parameters, then we need to determine which to average together.
remKeys = []
addKeys = []
for i in range(self.ctrl.avgParamList.count()):
item = self.ctrl.avgParamList.item(i)
if item.checkState() == QtCore.Qt.Checked:
remKeys.append(str(item.text()))
else:
addKeys.append(str(item.text()))
if len(remKeys) < 1: ## In this case, there would be 1 average plot for each data plot; not useful.
return
if self.ctrl.avgParamList.count() > 0:
### First determine the key of the curve to which this new data should be averaged
for i in range(self.ctrl.avgParamList.count()):
item = self.ctrl.avgParamList.item(i)
if item.checkState() == QtCore.Qt.Checked:
remKeys.append(str(item.text()))
else:
addKeys.append(str(item.text()))
if len(remKeys) < 1: ## In this case, there would be 1 average plot for each data plot; not useful.
return
p = curve.meta().copy()
for k in p:
......@@ -438,6 +443,8 @@ class PlotItem(QtGui.QGraphicsWidget):
self.ctrl.xAutoRadio.setChecked(True)
self.ctrl.yAutoRadio.setChecked(True)
self.autoBtn.hide()
self.updateXScale()
self.updateYScale()
self.replot()
def updateXScale(self):
......@@ -551,6 +558,7 @@ class PlotItem(QtGui.QGraphicsWidget):
(alpha, auto) = self.alphaState()
c.setAlpha(alpha, auto)
c.setSpectrumMode(self.ctrl.powerSpectrumGroup.isChecked())
c.setDownsampling(self.downsampleMode())
c.setPointMode(self.pointMode())
## Hide older plots if needed
......@@ -621,16 +629,22 @@ class PlotItem(QtGui.QGraphicsWidget):
#print "paramList:", self.paramList
def writeSvg(self, fileName=None):
print "writeSvg"
if fileName is None:
fileName = QtGui.QFileDialog.getSaveFileName()
fileName = str(fileName)
self.svg = QtSvg.QSvgGenerator()
self.svg.setFileName(fileName)
res = 120.
self.svg.setResolution(res)
self.svg.setSize(QtCore.QSize(self.size().width(), self.size().height()))
self.svg.setResolution(600)
painter = QtGui.QPainter(self.svg)
self.scene().render(painter, QtCore.QRectF(), self.mapRectToScene(self.boundingRect()))
#self.scene().render(painter, QtCore.QRectF(), self.mapRectToScene(self.boundingRect()))
items = self.scene().items()
self.scene().views()[0].drawItems(painter, len(items), items)
def writeImage(self, fileName=None):
if fileName is None:
......@@ -679,6 +693,25 @@ class PlotItem(QtGui.QGraphicsWidget):
self.recomputeAverages()
def updateDownsampling(self):
ds = self.downsampleMode()
for c in self.curves:
c.setDownsampling(ds)
self.recomputeAverages()
#for c in self.avgCurves.values():
#c[1].setDownsampling(ds)
def downsampleMode(self):
if self.ctrl.decimateGroup.isChecked():
if self.ctrl.manualDecimateRadio.isChecked():
ds = self.ctrl.downsampleSpin.value()
else:
ds = True
else:
ds = False
return ds
def updateDecimation(self):
if self.ctrl.maxTracesCheck.isChecked():
numCurves = self.ctrl.maxTracesSpin.value()
......
......@@ -28,7 +28,7 @@ def siScale(x, minVal=1e-25):
def mkPen(color=None, hsv=None, width=1, style=None, cosmetic=True):
def mkPen(color=None, width=1, style=None, cosmetic=True, hsv=None, ):
if color is None:
color = [255, 255, 255]
if hsv is not None:
......
......@@ -13,6 +13,7 @@ from numpy import *
import scipy.weave as weave
from scipy.weave import converters
from scipy.fftpack import fft
from scipy.signal import resample
#from metaarray import MetaArray
from Point import *
from functions import *
......@@ -232,7 +233,7 @@ class PlotCurveItem(QtGui.QGraphicsWidget):
'logMode': [False, False],
'pointMode': False,
'pointStyle': None,
'decimation': False,
'downsample': False,
'alphaHint': 1.0,
'alphaMode': False
}
......@@ -245,6 +246,10 @@ class PlotCurveItem(QtGui.QGraphicsWidget):
if self.xDisp is None:
x = self.xData
y = self.yData
ds = self.opts['downsample']
if ds > 1:
x = x[::ds]
y = resample(y[:len(x)*ds], len(x))
if self.opts['spectrumMode']:
f = fft(y) / len(y)
y = abs(f[1:len(f)/2])
......@@ -342,6 +347,13 @@ class PlotCurveItem(QtGui.QGraphicsWidget):
self.shadow = pen
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, x, y, copy=False):
"""For Qwt compatibility"""
self.updateData(y, x, copy)
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>210</width>
<height>320</height>
<height>340</height>
</rect>
</property>
<property name="maximumSize">
......@@ -35,7 +35,7 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
......@@ -267,7 +267,7 @@
<item>
<widget class="QGroupBox" name="decimateGroup">
<property name="title">
<string>Decimate</string>
<string>Downsample</string>
</property>
<property name="checkable">
<bool>true</bool>
......@@ -284,10 +284,23 @@
<property name="text">
<string>Manual</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="decimateSpin"/>
<widget class="QSpinBox" name="downsampleSpin">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="autoDecimateRadio">
......@@ -295,22 +308,32 @@
<string>Auto</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="maxTracesCheck">
<property name="toolTip">
<string>If multiple curves are displayed in this plot, check this box to limit the number of traces that are displayed.</string>
</property>
<property name="text">
<string>Max Traces:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="maxTracesSpin"/>
<widget class="QSpinBox" name="maxTracesSpin">
<property name="toolTip">
<string>If multiple curves are displayed in this plot, check &quot;Max Traces&quot; and set this value to limit the number of traces that are displayed.</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="forgetTracesCheck">
<property name="toolTip">
<string>If MaxTraces is checked, remove curves from memory after they are hidden (saves memory, but traces can not be un-hidden).</string>
</property>
<property name="text">
<string>Forget hidden traces</string>
</property>
......@@ -321,6 +344,9 @@
</item>
<item>
<widget class="QGroupBox" name="averageGroup">
<property name="toolTip">
<string>Display averages of the curves displayed in this plot. The parameter list allows you to choose parameters to average over (if any are available).</string>
</property>
<property name="title">
<string>Average</string>
</property>
......
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