1 from Model import Model
2 from utils import toUnicodeWithWarning
4 class XYPlotSetModel(Model):
6 def __init__(self, controller):
7 Model.__init__(self, controller)
8 self._title = "Plot set %d" % self.getID()
9 self._curves = {} # Key: model ID, value: CurveModel
10 self._currentCurve = None
16 self._currentCurve = None
17 self.notifyChange("ClearAll")
19 def setTitle(self, title, silent=False):
20 title = toUnicodeWithWarning(title, "XYPlotSetModel::setTitle()")
23 self.notifyChange("TitleChange")
28 def setCurrentCurve(self, curveID, silent=False):
29 if curveID not in self._curves and curveID != -1:
30 raise ValueError("Invalid curve ID (%d)!" % curveID)
31 self._currentCurve = self._curves.get(curveID, None)
33 self.notifyChange("CurrentCurveChange")
35 def getCurrentCurve(self):
36 return self._currentCurve
38 def addCurve(self, curve, silent=False):
39 self._curves[curve.getID()] = curve
41 self.notifyChange("AddCurve")
43 def removeCurve(self, curveID, silent=False):
44 if curveID not in self._curves:
45 raise ValueError("Curve ID (%d) not found for deletion!" % curveID)
46 c = self._curves.pop(curveID)
47 if self._currentCurve is c:
48 self._currentCurve = None
50 self.notifyChange("RemoveCurve")
52 def setXLabel(self, x_label, silent=False):
53 x_label = toUnicodeWithWarning(x_label, "XYPlotSetModel::setXLabel()")
54 self._xlabel = x_label
56 self.notifyChange("XLabelChange")
58 def setYLabel(self, y_label, silent=False):
59 y_label = toUnicodeWithWarning(y_label, "XYPlotSetModel::setYLabel()")
60 self._ylabel = y_label
62 self.notifyChange("YLabelChange")