1 # Copyright (C) 2016-2020 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 CurveModel(Model):
24 def __init__(self, controller, table=None, index=-1):
25 Model.__init__(self, controller)
26 self._title = "Curve %d" % self.getID()
28 self._yaxisIndex = index # column index in the table
29 self._xaxisIndex = 0 # By default the first column of the table is used for the X-s
32 ret = CurveModel(self._controller)
33 ret._title = self._title
34 ret._table = self._table # TO CHECK: deep copy here? (I think not needed in Python ...)
35 ret._yaxisIndex = self._yaxisIndex
36 ret._xaxisIndex = self._xaxisIndex
39 def setTable(self, t, silent=False):
42 self.notifyChange("DataChange")
47 def extendData(self, t, silent=False):
50 self.notifyChange("DataChange")
54 self.notifyChange("DataChange")
56 def setTitle(self, ti, silent=False):
57 ti = toUnicodeWithWarning(ti, "CurveModel::setTitle()")
60 self.notifyChange("CurveTitleChange")
65 def getYAxisIndex(self):
66 return self._yaxisIndex
68 def setYAxisIndex(self, idx, silent=False):
69 self._yaxisIndex = idx
71 self.notifyChange("YAxisIndexChange")
73 def getXAxisIndex(self):
74 return self._xaxisIndex
76 def setXAxisIndex(self, idx, silent=False):
77 sh = self._table.getShape()
79 raise ValueError("Index out of bound (is %d, but max is %d)" % (idx, sh[1]))
80 self._xaxisIndex = idx
82 self.notifyChange("XAxisIndexChange")