diff --git a/reflowctl/edge_widget.py b/reflowctl/edge_widget.py
index 2674459..8491d45 100644
--- a/reflowctl/edge_widget.py
+++ b/reflowctl/edge_widget.py
@@ -11,6 +11,11 @@ class Edge(QtCore.QObject):
self.duration = duration
self.rate = rate
+ def contains(self, temp_level):
+ return (
+ (self.from_tl.temp < temp_level.temp < self.to_tl.temp) or
+ (self.from_tl.temp > temp_level.temp > self.to_tl.temp))
+
def __repr__(self):
return "Edge(%r, %r, %r, %r)" % (self.from_tl, self.to_tl, self.duration, self.rate)
@@ -141,19 +146,33 @@ class ConstraintWidget(QtGui.QWidget):
print self.temp_level_added
self.edge_changed.emit()
- def temp_level_added(self, old_tl, new_tl):
+ def temp_level_added(self, new_tl):
print self.temp_level_added, len(self.edge_model.edges)
- new_edge = None
+ new_edges = list()
ix = 0
- for ix, edge in enumerate(self.edge_model.edges):
- print ix, edge
- if edge.from_tl == old_tl:
+ batch = list()
+ for edge in self.edge_model.edges:
+ if edge.contains(new_tl):
+ batch.append(edge)
+
+ for edge in batch:
+ if edge.from_tl < new_tl:
duration = None if edge.duration is None else edge.duration / 2
new_edge = Edge(new_tl, edge.to_tl, duration, edge.rate)
edge.duration = duration
edge.to_tl = new_tl
- break
- self.edge_model.edges.insert(ix+1, new_edge)
- self.edge_model.reset()
- print "end", self.temp_level_added
+ ix = self.edge_model.edges.index(edge)
+ self.edge_model.edges.insert(ix+1, new_edge)
+ else:
+ duration = None if edge.duration is None else edge.duration / 2
+ new_edge = Edge(new_tl, edge.to_tl, duration, edge.rate)
+ edge.duration = duration
+ edge.to_tl = new_tl
+ ix = self.edge_model.edges.index(edge)
+ self.edge_model.edges.insert(ix+1, new_edge)
+ #for i in new_edges:
+ #print repr(i)
+ #for edge, new_edge in new_edges:
+
+ self.edge_model.reset()
diff --git a/reflowctl/reflowctl_gui.py b/reflowctl/reflowctl_gui.py
index 5303487..24f2626 100755
--- a/reflowctl/reflowctl_gui.py
+++ b/reflowctl/reflowctl_gui.py
@@ -100,12 +100,9 @@ class Plotter(FigureCanvas):
self.y = list()
try:
- (self.x, self.y, self.xmin, self.xmax, self.ymin, self.ymax,
- self.used, self.unused) = self.solder.calc_profile()
+ (self.x, self.y, self.xmin, self.xmax, self.ymin, self.ymax) = self.solder.calc_profile()
except ValueError:
- (self.x, self.y, self.xmin, self.xmax, self.ymin, self.ymax,
- self.used, self.unused) = ([], [], 0., 300., 0., 300., [],
- self.solder.temp_levels)
+ (self.x, self.y, self.xmin, self.xmax, self.ymin, self.ymax) = ([], [], 0., 300., 0., 300.)
self.plot_data.set_xdata(self.x)
self.plot_data.set_ydata(self.y)
@@ -363,6 +360,8 @@ class ApplicationWindow(QtGui.QMainWindow):
self.plotter_splitter.addWidget(self.plotter)
self.plotter_splitter.addWidget(self.profile_log)
+ self.plotter_splitter.setStretchFactor(0, 8)
+ self.plotter_splitter.setStretchFactor(1, 2)
self.splitter.addWidget(self.settings_widget)
self.splitter.addWidget(self.controls_widget)
@@ -374,7 +373,7 @@ class ApplicationWindow(QtGui.QMainWindow):
self.setCentralWidget(self.splitter)
self.statusBar().showMessage("Reflow GORE!1!", 10000)
- self.plotter.solder_changed()
+ self.plotter.update_figure()
def getPlotter(self):
return self.plotter
@@ -386,6 +385,8 @@ class ApplicationWindow(QtGui.QMainWindow):
self.constraint_widget.setData(solder)
self.plotter.setData(solder)
solder.log_message.connect(self.profile_log.setPlainText)
+ if not self.plotter.started:
+ self.plotter.update_figure()
def edge_picked(self, ix):
if self.tab_widget.currentIndex() != 1:
diff --git a/reflowctl/solder.py b/reflowctl/solder.py
index 82d2461..584f101 100644
--- a/reflowctl/solder.py
+++ b/reflowctl/solder.py
@@ -50,13 +50,7 @@ class Solder(QtCore.QObject):
return i
return None
- #def get_temp_level(self, ix):
- #assert isinstance(ix, int)
- #return self.temp_levels[ix]
-
-
def calc_profile(self):
- print self.calc_profile
self.log = list()
x = list()
y = list()
@@ -69,16 +63,17 @@ class Solder(QtCore.QObject):
return time + edge.duration
elif edge.rate:
return time + (edge.to_tl.temp - edge.from_tl.temp) / edge.rate
+ else:
+ raise Exception("edge %r has neither duration nor rate set" % edge)
for _edge in self.edges:
- x.append(time)
- y.append(_edge.from_tl.temp)
+ x.append(float(time))
+ y.append(float(_edge.from_tl.temp))
time = calc(_edge)
x.append(time)
y.append(_edge.to_tl.temp)
- print "end", self.calc_profile
- return array(map(float, x)), array(map(float, y)), min(x), max(x), min(y), max(y), set(), set()
+ return array(x), array(y), min(x), max(x), min(y), max(y)
@staticmethod
@@ -223,8 +218,8 @@ class SolderWidget(QtGui.QWidget):
self.solder_controls = AddRemoveWidget(self)
layout = QtGui.QHBoxLayout(self)
- layout.addWidget(self.solder_view, 3)
- layout.addWidget(self.solder_controls, 1)
+ layout.addWidget(self.solder_view)
+ layout.addWidget(self.solder_controls)
self.connect(
self.solder_controls.add_button,
diff --git a/reflowctl/solder_types/lead_noclean.xml b/reflowctl/solder_types/lead_noclean.xml
index 46e1c98..615f2c4 100644
--- a/reflowctl/solder_types/lead_noclean.xml
+++ b/reflowctl/solder_types/lead_noclean.xml
@@ -1,2 +1,2 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/reflowctl/temp_level.py b/reflowctl/temp_level.py
index 3d1bb53..79f84c3 100644
--- a/reflowctl/temp_level.py
+++ b/reflowctl/temp_level.py
@@ -140,7 +140,7 @@ class TempLevelModel(QtCore.QAbstractTableModel):
if index.isValid() and role == QtCore.Qt.EditRole:
col = index.column()
if col == 0:
- self.temp_levels[index.row()].name = str(variant.toString())
+ self.temp_levels[index.row()].name = unicode(variant.toString())
elif col == 1:
temp, res = variant.toInt()
tl = self.temp_levels[index.row()]
@@ -195,7 +195,7 @@ class TempLevelModel(QtCore.QAbstractTableModel):
class TempLevelWidget(QtGui.QWidget):
temp_level_removed = QtCore.pyqtSignal(TempLevel)
- temp_level_added = QtCore.pyqtSignal(TempLevel, TempLevel)
+ temp_level_added = QtCore.pyqtSignal(TempLevel)
temp_levels_changed = QtCore.pyqtSignal()
solder_changed = QtCore.pyqtSignal()
@@ -260,7 +260,7 @@ class TempLevelWidget(QtGui.QWidget):
self.temp_level_view.setCurrentIndex(self.temp_level_model.index(index.row() + 1, 0))
self.temp_levels_changed.emit()
print "TempLevelWidget.add_temp_level 1", old_tl, new_tl
- self.temp_level_added.emit(old_tl, new_tl)
+ self.temp_level_added.emit(new_tl)
print "TempLevelWidget.add_temp_level 2"