sync
This commit is contained in:
parent
0190511304
commit
f4478533d0
|
@ -172,6 +172,37 @@ class SolderListModel(QtCore.QAbstractListModel):
|
||||||
else:
|
else:
|
||||||
return QtCore.QVariant()
|
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):
|
class MyDynamicMplCanvas(FigureCanvas):
|
||||||
"""A canvas that updates itself every second with a new plot."""
|
"""A canvas that updates itself every second with a new plot."""
|
||||||
def __init__(self, parent=None, width=5, height=4, dpi=100):
|
def __init__(self, parent=None, width=5, height=4, dpi=100):
|
||||||
|
@ -189,7 +220,7 @@ class MyDynamicMplCanvas(FigureCanvas):
|
||||||
super(MyDynamicMplCanvas, self).__init__(self.fig)
|
super(MyDynamicMplCanvas, self).__init__(self.fig)
|
||||||
self.setParent(parent)
|
self.setParent(parent)
|
||||||
|
|
||||||
self.solder = Solder.unpack('/home/hotshelf/dev/reflow/solder_types/leadfree_noclean.xml')
|
self.solder = None
|
||||||
|
|
||||||
self.compute_initial_figure()
|
self.compute_initial_figure()
|
||||||
FigureCanvas.setSizePolicy(self,
|
FigureCanvas.setSizePolicy(self,
|
||||||
|
@ -317,33 +348,40 @@ class ApplicationWindow(QtGui.QMainWindow):
|
||||||
|
|
||||||
self.main_widget = QtGui.QWidget(self)
|
self.main_widget = QtGui.QWidget(self)
|
||||||
self.profile_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
|
self.dpi = 100
|
||||||
|
|
||||||
pl = QtGui.QHBoxLayout(self.profile_widget)
|
pl = QtGui.QHBoxLayout(self.profile_widget)
|
||||||
sl = QtGui.QVBoxLayout(self.profile_steps)
|
sl = QtGui.QVBoxLayout(self.steps_box)
|
||||||
|
|
||||||
self.solder_model = SolderListModel(self)
|
self.solder_model = SolderListModel(self)
|
||||||
|
self.pstep_model = PStepModel(self)
|
||||||
self.solder_view = QtGui.QListView()
|
self.solder_view = QtGui.QListView()
|
||||||
|
self.pstep_view = QtGui.QTableView()
|
||||||
self.solder_view.setModel(self.solder_model)
|
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)
|
self.connect(self.solder_view, QtCore.SIGNAL("clicked(QModelIndex)"), self.solder_selected)
|
||||||
pl.addWidget(self.solder_view)
|
pl.addWidget(self.solder_view)
|
||||||
|
pl.addWidget(self.pstep_view)
|
||||||
|
|
||||||
l = QtGui.QVBoxLayout(self.main_widget)
|
l = QtGui.QVBoxLayout(self.main_widget)
|
||||||
self.dc = MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=self.dpi)
|
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.profile_widget, 1)
|
||||||
l.addWidget(self.dc, 10)
|
l.addWidget(self.dc, 10)
|
||||||
|
|
||||||
self.main_widget.setFocus()
|
self.main_widget.setFocus()
|
||||||
self.setCentralWidget(self.main_widget)
|
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):
|
def solder_selected(self, index):
|
||||||
if index.isValid():
|
if index.isValid():
|
||||||
self.dc.solder = self.solder_model.listdata[index.row()]
|
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):
|
def save_plot(self):
|
||||||
file_choices = "PNG (*.png)|*.png"
|
file_choices = "PNG (*.png)|*.png"
|
||||||
|
|
Loading…
Reference in New Issue