Numerous updates merged from acq4

This commit is contained in:
Luke Campagnola 2010-05-01 12:19:27 -04:00
parent 11897061d1
commit 7efc975400
7 changed files with 386 additions and 304 deletions

View File

@ -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 "Event accepted:", ev.isAccepted()
#print "Grabber:", self.scene().mouseGrabberItem()
if not self.mouseEnabled:
return
self.lastMousePos = Point(ev.pos())

View File

@ -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))

View File

@ -188,6 +188,8 @@ 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,9 +350,12 @@ 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 = []
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:
@ -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()

View File

@ -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:

View File

@ -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)

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'plotConfigTemplate.ui'
#
# Created: Tue Jan 12 14:23:16 2010
# by: PyQt4 UI code generator 4.5.4
# Created: Mon Mar 29 22:40:47 2010
# by: PyQt4 UI code generator 4.6
#
# WARNING! All changes made in this file will be lost!
@ -12,7 +12,7 @@ from PyQt4 import QtCore, QtGui
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(210, 320)
Form.resize(210, 340)
Form.setMaximumSize(QtCore.QSize(250, 350))
self.gridLayout_3 = QtGui.QGridLayout(Form)
self.gridLayout_3.setMargin(0)
@ -51,7 +51,7 @@ class Ui_Form(object):
self.xAutoPercentSpin.setMinimum(1)
self.xAutoPercentSpin.setMaximum(100)
self.xAutoPercentSpin.setSingleStep(1)
self.xAutoPercentSpin.setProperty("value", QtCore.QVariant(100))
self.xAutoPercentSpin.setProperty("value", 100)
self.xAutoPercentSpin.setObjectName("xAutoPercentSpin")
self.gridLayout.addWidget(self.xAutoPercentSpin, 1, 1, 1, 2)
self.xLinkCombo = QtGui.QComboBox(self.groupBox)
@ -92,7 +92,7 @@ class Ui_Form(object):
self.yAutoPercentSpin.setMinimum(1)
self.yAutoPercentSpin.setMaximum(100)
self.yAutoPercentSpin.setSingleStep(1)
self.yAutoPercentSpin.setProperty("value", QtCore.QVariant(100))
self.yAutoPercentSpin.setProperty("value", 100)
self.yAutoPercentSpin.setObjectName("yAutoPercentSpin")
self.gridLayout_2.addWidget(self.yAutoPercentSpin, 1, 1, 1, 2)
self.yLinkCombo = QtGui.QComboBox(self.groupBox_2)
@ -129,13 +129,17 @@ class Ui_Form(object):
self.gridLayout_4.setSpacing(0)
self.gridLayout_4.setObjectName("gridLayout_4")
self.manualDecimateRadio = QtGui.QRadioButton(self.decimateGroup)
self.manualDecimateRadio.setChecked(True)
self.manualDecimateRadio.setObjectName("manualDecimateRadio")
self.gridLayout_4.addWidget(self.manualDecimateRadio, 0, 0, 1, 1)
self.decimateSpin = QtGui.QSpinBox(self.decimateGroup)
self.decimateSpin.setObjectName("decimateSpin")
self.gridLayout_4.addWidget(self.decimateSpin, 0, 1, 1, 1)
self.downsampleSpin = QtGui.QSpinBox(self.decimateGroup)
self.downsampleSpin.setMinimum(1)
self.downsampleSpin.setMaximum(100000)
self.downsampleSpin.setProperty("value", 1)
self.downsampleSpin.setObjectName("downsampleSpin")
self.gridLayout_4.addWidget(self.downsampleSpin, 0, 1, 1, 1)
self.autoDecimateRadio = QtGui.QRadioButton(self.decimateGroup)
self.autoDecimateRadio.setChecked(True)
self.autoDecimateRadio.setChecked(False)
self.autoDecimateRadio.setObjectName("autoDecimateRadio")
self.gridLayout_4.addWidget(self.autoDecimateRadio, 1, 0, 1, 1)
self.maxTracesCheck = QtGui.QCheckBox(self.decimateGroup)
@ -176,7 +180,7 @@ class Ui_Form(object):
self.horizontalLayout.addWidget(self.autoAlphaCheck)
self.alphaSlider = QtGui.QSlider(self.alphaGroup)
self.alphaSlider.setMaximum(1000)
self.alphaSlider.setProperty("value", QtCore.QVariant(1000))
self.alphaSlider.setProperty("value", 1000)
self.alphaSlider.setOrientation(QtCore.Qt.Horizontal)
self.alphaSlider.setObjectName("alphaSlider")
self.horizontalLayout.addWidget(self.alphaSlider)
@ -188,7 +192,7 @@ class Ui_Form(object):
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.gridAlphaSlider = QtGui.QSlider(self.gridGroup)
self.gridAlphaSlider.setMaximum(255)
self.gridAlphaSlider.setProperty("value", QtCore.QVariant(70))
self.gridAlphaSlider.setProperty("value", 70)
self.gridAlphaSlider.setOrientation(QtCore.Qt.Horizontal)
self.gridAlphaSlider.setObjectName("gridAlphaSlider")
self.verticalLayout_4.addWidget(self.gridAlphaSlider)
@ -257,11 +261,15 @@ class Ui_Form(object):
self.label_2.setText(QtGui.QApplication.translate("Form", "Link with:", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("Form", "Scale", None, QtGui.QApplication.UnicodeUTF8))
self.powerSpectrumGroup.setTitle(QtGui.QApplication.translate("Form", "Power Spectrum", None, QtGui.QApplication.UnicodeUTF8))
self.decimateGroup.setTitle(QtGui.QApplication.translate("Form", "Decimate", None, QtGui.QApplication.UnicodeUTF8))
self.decimateGroup.setTitle(QtGui.QApplication.translate("Form", "Downsample", None, QtGui.QApplication.UnicodeUTF8))
self.manualDecimateRadio.setText(QtGui.QApplication.translate("Form", "Manual", None, QtGui.QApplication.UnicodeUTF8))
self.autoDecimateRadio.setText(QtGui.QApplication.translate("Form", "Auto", None, QtGui.QApplication.UnicodeUTF8))
self.maxTracesCheck.setToolTip(QtGui.QApplication.translate("Form", "If multiple curves are displayed in this plot, check this box to limit the number of traces that are displayed.", None, QtGui.QApplication.UnicodeUTF8))
self.maxTracesCheck.setText(QtGui.QApplication.translate("Form", "Max Traces:", None, QtGui.QApplication.UnicodeUTF8))
self.maxTracesSpin.setToolTip(QtGui.QApplication.translate("Form", "If multiple curves are displayed in this plot, check \"Max Traces\" and set this value to limit the number of traces that are displayed.", None, QtGui.QApplication.UnicodeUTF8))
self.forgetTracesCheck.setToolTip(QtGui.QApplication.translate("Form", "If MaxTraces is checked, remove curves from memory after they are hidden (saves memory, but traces can not be un-hidden).", None, QtGui.QApplication.UnicodeUTF8))
self.forgetTracesCheck.setText(QtGui.QApplication.translate("Form", "Forget hidden traces", None, QtGui.QApplication.UnicodeUTF8))
self.averageGroup.setToolTip(QtGui.QApplication.translate("Form", "Display averages of the curves displayed in this plot. The parameter list allows you to choose parameters to average over (if any are available).", None, QtGui.QApplication.UnicodeUTF8))
self.averageGroup.setTitle(QtGui.QApplication.translate("Form", "Average", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtGui.QApplication.translate("Form", "Data", None, QtGui.QApplication.UnicodeUTF8))
self.alphaGroup.setTitle(QtGui.QApplication.translate("Form", "Alpha", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -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>