Commit 94b3cc65 authored by Poseidon's avatar Poseidon

Customização do Plot em tempo real em pyqtgraph.

parent c3f21e4d
......@@ -8,7 +8,7 @@
"""
import sys
import newplotview as pw
from newplotview import PlotWidget
#from TabWidget import TabWidget
from PyQt4 import QtGui, Qt
......@@ -25,7 +25,7 @@ class MainWindow(QtGui.QMainWindow):
self.setWindowIcon(QtGui.QIcon('resources/icon.png'))
### CENTRAL FRAME
self.central_frame = QtGui.QGraphicsView()
self.central_frame = PlotWidget()
self.setCentralWidget(self.central_frame)
### ACTIONS
......
......@@ -201,6 +201,6 @@ if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
main_w = LogSpecWidget()
main_w.setFixedSize(400, 300)
main_w.setFixedSize(400, 325)
main_w.show()
sys.exit(app.exec_())
......@@ -4,128 +4,56 @@
"""
Real time plot widget
"""
import pyqtgraph as pg
from PyQt4 import QtGui
import pyqtgraph as Pg
import numpy as np
from PyQt4 import QtGui, QtCore
Pg.setConfigOption('background','w')
Pg.setConfigOption('foreground','k')
class NewPlotWindow(QtGui.QWidget):
def __init__(self, pattern = None):
super(NewPlotWindow, self).__init__()
self.splitter = QtGui.QSplitter(self)
self.plot_widget = PlotWidget(self)
self.splitter.addWidget(self.plot_widget)
self.splitter_btt = QtGui.QToolButton(self.splitter)
self.splitter_btt.clicked.connect(lambda: self.splitterButton())
self.splitter_btt.setArrowType(QtCore.Qt.RightArrow)
self.splitter_btt.setFixedWidth(20)
self.splitter.addWidget(self.splitter_btt)
self.dock_widget = self.initDockWidget()
self.splitter.addWidget(QtGui.QTextEdit(self))
self.splitter.handle(0).setEnabled(False)
self.splitter.handle(1).setEnabled(False)
self.splitter.handle(2).setEnabled(False)
layout = QtGui.QVBoxLayout()
layout.addWidget(self.splitter)
self.setLayout(layout)
def initDockWidget(self):
main_frame = QtGui.QWidget(self)
main_frame.setFixedWidth(300)
layout = QtGui.QVBoxLayout(main_frame)
tabs = QtGui.QTabWidget(main_frame)
tabs.addTab(log_prop, "Log Specification")
tabs.addTab(plot_prop, "Plot Properties")
status = self.initStatusWidget()
main_layout.addWidget(tabs)
main_layout.addStretch(1)
main_layout.addWidget(status)
main_frame.setLayout(main_layout)
return main_frame
def initLogSpecWidget(self):
widget = QtGui.QWiget(self.dock_widget)
vbox = QtGui.QVBoxLayout(widget)
hbox = QtGui.QHBoxLayout(widget)
lbl = QtGui.QLabel(status)
lbl.setText("Serial Port:")
self.serial_cb = QtGui.QComboBox()
self.serial_btt = QtGui.QToolButton()
self.serial_btt.setIcon(QtGui.QIcon('resources/play.png'))
self.serial_btt.clicked.connect()
def initStatusWidget(self):
status = QtGui.QWidget(self.dock_widget)
vbox = QtGui.QVBoxLayout(status)
hbox = QtGui.QHBoxLayout(status)
time_lbl1 = QtGui.QLabel(status)
time_lbl2.setText('Current Time: ')
self.curr_time = QtGui.QLabel(status)
self.curr_time.setText('00.00 s')
time_lbl1 = QtGui.QLabel(status)
time_lbl1.setText('Total Time: ')
self.total_time = QtGui.QLabel(status)
self.total_time.setText('00.00 s')
hbox.addWidget(time_lbl1)
hbox.addWidget(self.curr_time)
hbox.addStretch(1)
hbox.addWidget(time_lbl2)
hbox.addWidget(self.total_time)
vbox.addLayout(hbox)
self.progress_bar = QtGui.QProgressBar(status)
self.progress_bar.setFixedHeight(40)
vbox.addWidget(self.progress_bar)
vbox.addStretch(1)
self.ok_stop_btt = QtGui.QPushButton("OK")
self.cancel_btt = QtGui.QPushButton("Cancel")
hbox = QtGui.QHBoxLayout(status)
hbox.addStretch(1)
hbox.addWidget(self.ok_stop_btt)
hbox.addWidget(self.cancel_btt)
vbox.addLayout(hbox)
status.setLayout(vbox)
return status
def splitterButton(self):
if (self.state == True):
self.splitter.setSizes([0, 1, 1])
self.splitter_btt.setArrowType(QtCore.Qt.LeftArrow)
self.state = False
else:
self.splitter.setSizes([1, 1, 1])
self.splitter_btt.setArrowType(QtCore.Qt.RightArrow)
self.state = True
class OkStopButton(QtGui.QPushButton):
def __init__(self):
super(OkStopButton, self).__init__()
class PlotWidget(pg.GraphicsLayoutWidget):
class PlotWidget(Pg.GraphicsLayoutWidget):
def __init__(self):
super(PlotWidget, self).__init__()
self.initPlot()
def initPlot(self):
self.setBackground('w')
p1 = self.addPlot(color=(255,255,255))
p1.setMenuEnabled(False)
p1.hideButtons()
p1.vb.setMouseEnabled(False, False)
p1.setRange(xRange=[0,100])
data1 = np.random.normal(size=300)
curve1 = p1.plot(data1, pen=(0,0,0))
print(p1.__dict__)
def update():
data1[:-1] = data1[1:] # shift data in the array one sample left
# (see also: np.roll)
data1[-1] = np.random.normal()
curve1.setData(data1)
ptr1 += 1
curve2.setData(data1)
curve2.setPos(ptr1, 0)
class RealTimePlotItem(Pg.PlotItem):
def __init__(self, **kwargs):
super(RealTimePlotItem, self).__init__()
self.setMenuEnabled(False)
self.hideButtons()
self.vb.setMouseEnabled(False, False)
self.data_points = 500
self.curves = list()
def update(self):
pass
class RealTimePlotCurve():
def __init__(self, plot_item=None):
self.color = list()
self.plot_item = plot_item
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