Commit 748a0837 authored by Martin Drechsler's avatar Martin Drechsler

Two buttons added nicely: erase and autoscale.

parent 23265307
......@@ -14,7 +14,7 @@ from PyQt5.QtCore import QTimer
#from myWidgets import anal_control_signal
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QMessageBox, QPushButton, QGraphicsProxyWidget
#from myWidgets import anal_control_signal
......@@ -27,7 +27,7 @@ class roiWindow(QMainWindow):
print(self.aoScan.name, self.aoScan.sb.val)
self.cap = cv2.VideoCapture(1)
self.cap = cv2.VideoCapture(0)
self.n = int(1e2)
self.data = np.zeros(self.n)
......@@ -60,14 +60,14 @@ class roiWindow(QMainWindow):
self.v2.addItem(self.im2)
#plot real time
self.p = self.w.addPlot(row = 3, col = 0, title="Updating plot")
self.p = self.w.addPlot(row = 3, col = 0, title="Time plot")
self.p.setRange(QtCore.QRectF(0, -10, 5000, 20))
self.p.setAutoPan(y=True)
self.p.setRange(xRange = (0, self.n), yRange = (0, 255))
self.curve = self.p.plot(pen='y')
self.pv = self.w.addPlot(row = 4, col = 0, title = "Updating plot")
self.pv = self.w.addPlot(row = 4, col = 0, title = "Voltage plot")
self.pv.setRange(QtCore.QRectF(0, -10, 5000, 20))
self.pv.setAutoPan(y=True)
self.curveVoltage = self.pv.plot(pen='y')
......@@ -75,12 +75,21 @@ class roiWindow(QMainWindow):
self.voltageDataY = []
self.aoScan.ScanTimer.timeout.connect(self.updateVoltagePlotvsI)
self.eraseButton = QPushButton('Erase')
self.optionsLayout = pg.LayoutWidget()
self.eraseButton = QPushButton('Erase plot')
self.eraseButton.clicked.connect(self.erasePlot)
self.autoScaleButton = QPushButton('Autoscale')
self.autoScaleButton.clicked.connect(self.autoScalePlot)
self.optionsLayout.addWidget(self.eraseButton, 0, 0)
self.optionsLayout.addWidget(self.autoScaleButton, 0, 1)
self.optionsLayout.setGeometry(10,10,300,200)
proxy = QGraphicsProxyWidget()
proxy.setWidget(self.eraseButton)
self.pv.addItem(proxy,row=1,col=1)
proxy.setWidget(self.optionsLayout)
self.w.addItem(proxy,row=5,col=0)
self.lastRoi = None
......@@ -101,13 +110,20 @@ class roiWindow(QMainWindow):
self.voltageDataY = np.append(self.voltageDataY, self.newData)
#○print(' Roi: ', self.voltageDataX[-1], self.voltageDataY[-1])
self.pv.setRange(xRange = (float(self.aoScan.scan_sb_start.val), float(self.aoScan.scan_sb_stop.val)), yRange = (0, 255))
self.curveVoltage.setData(self.voltageDataX, self.voltageDataY)
def erasePlot(self):
self.voltageDataX = []
self.voltageDataY = []
def autoScalePlot(self):
x_min = float(self.aoScan.scan_sb_start.val)
x_max = float(self.aoScan.scan_sb_stop.val)
y_min = 0
y_max = self.newData
self.pv.setRange(xRange = (x_min, x_max), yRange = (y_min, y_max))
def myCloseEvent(self, event):
# this overrides the closeEvent method
reply = QMessageBox.question(self, 'Message',
......@@ -127,8 +143,8 @@ class roiWindow(QMainWindow):
def capture(self):
ret, frame = self.cap.read()
#frame = cv2.resize(frame, None, fx = 0.5, fy = 0.5, interpolation = cv2.INTER_CUBIC)
gray_image = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
return gray_image
return frame[:, :, 0]
def updateImage(self):
self.im1.setImage(self.capture(), cmap = 'Gray')
......
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