This commit is contained in:
Stefan Kögl 2012-11-15 22:58:19 +01:00
parent 0190511304
commit f4478533d0
1 changed files with 44 additions and 6 deletions

View File

@ -172,6 +172,37 @@ class SolderListModel(QtCore.QAbstractListModel):
else:
return QtCore.QVariant()
class PStepModel(QtCore.QAbstractTableModel):
def __init__(self, parent=None, *args):
super(PStepModel, self).__init__(parent, *args)
self.psteps = list()
def rowCount(self, parent):
return len(self.psteps)
def columnCount(self, parent):
return 2
def data(self, index, role):
if not index.isValid():
return QtCore.QVariant()
elif role != QtCore.Qt.DisplayRole:
return QtCore.QVariant()
col = index.column()
if col == 0:
return QtCore.QVariant(self.psteps[index.row()].name)
else:
return QtCore.QVariant(self.psteps[index.row()].temperature)
def removeRows(self, start, _count, _parent):
print type(start), type(_count)
self.beginRemoveRows(_parent, start, start + _count)
self.psteps[:start].extend(self.psteps[start + _count:])
self.endRemoveRows()
class MyDynamicMplCanvas(FigureCanvas):
"""A canvas that updates itself every second with a new plot."""
def __init__(self, parent=None, width=5, height=4, dpi=100):
@ -189,12 +220,12 @@ class MyDynamicMplCanvas(FigureCanvas):
super(MyDynamicMplCanvas, self).__init__(self.fig)
self.setParent(parent)
self.solder = Solder.unpack('/home/hotshelf/dev/reflow/solder_types/leadfree_noclean.xml')
self.solder = None
self.compute_initial_figure()
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
timer = QtCore.QTimer(self)
@ -317,33 +348,40 @@ class ApplicationWindow(QtGui.QMainWindow):
self.main_widget = QtGui.QWidget(self)
self.profile_widget = QtGui.QWidget(self)
self.profile_steps = QtGui.QGroupBox(self)
self.steps_box = QtGui.QGroupBox(self)
self.dpi = 100
pl = QtGui.QHBoxLayout(self.profile_widget)
sl = QtGui.QVBoxLayout(self.profile_steps)
sl = QtGui.QVBoxLayout(self.steps_box)
self.solder_model = SolderListModel(self)
self.pstep_model = PStepModel(self)
self.solder_view = QtGui.QListView()
self.pstep_view = QtGui.QTableView()
self.solder_view.setModel(self.solder_model)
self.pstep_view.setModel(self.pstep_model)
self.connect(self.solder_view, QtCore.SIGNAL("clicked(QModelIndex)"), self.solder_selected)
pl.addWidget(self.solder_view)
pl.addWidget(self.pstep_view)
l = QtGui.QVBoxLayout(self.main_widget)
self.dc = MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=self.dpi)
self.dc.solder = self.solder_model.listdata[0]
l.addWidget(self.profile_widget, 1)
l.addWidget(self.dc, 10)
self.main_widget.setFocus()
self.setCentralWidget(self.main_widget)
self.statusBar().showMessage("All hail matplotlib!", 2000)
self.statusBar().showMessage("I'm in reflow heaven", 2000)
def solder_selected(self, index):
if index.isValid():
self.dc.solder = self.solder_model.listdata[index.row()]
self.pstep_model.removeRows(0, self.pstep_model.rowCount(QtCore.QModelIndex()))
self.pstep_model.insertRows()
def save_plot(self):
file_choices = "PNG (*.png)|*.png"