1 # Copyright (C) 2016-2019 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from .Model import Model
21 from .utils import toUnicodeWithWarning
23 class XYPlotSetModel(Model):
25 def __init__(self, controller):
26 Model.__init__(self, controller)
27 self._title = "Plot set %d" % self.getID()
28 self._curves = {} # Key: model ID, value: CurveModel
29 self._currentCurve = None
35 self._currentCurve = None
36 self.notifyChange("ClearAll")
38 def setTitle(self, title, silent=False):
39 title = toUnicodeWithWarning(title, "XYPlotSetModel::setTitle()")
42 self.notifyChange("TitleChange")
47 def setCurrentCurve(self, curveID, silent=False):
48 if curveID not in self._curves and curveID != -1:
49 raise ValueError("Invalid curve ID (%d)!" % curveID)
50 self._currentCurve = self._curves.get(curveID, None)
52 self.notifyChange("CurrentCurveChange")
54 def getCurrentCurve(self):
55 return self._currentCurve
57 def addCurve(self, curve, silent=False):
58 self._curves[curve.getID()] = curve
60 self.notifyChange("AddCurve")
62 def removeCurve(self, curveID, silent=False):
63 if curveID not in self._curves:
64 raise ValueError("Curve ID (%d) not found for deletion!" % curveID)
65 c = self._curves.pop(curveID)
66 if self._currentCurve is c:
67 self._currentCurve = None
69 self.notifyChange("RemoveCurve")
71 def setXLabel(self, x_label, silent=False):
72 x_label = toUnicodeWithWarning(x_label, "XYPlotSetModel::setXLabel()")
73 self._xlabel = x_label
75 self.notifyChange("XLabelChange")
77 def setYLabel(self, y_label, silent=False):
78 y_label = toUnicodeWithWarning(y_label, "XYPlotSetModel::setYLabel()")
79 self._ylabel = y_label
81 self.notifyChange("YLabelChange")