X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FPythonAPI%2Fmodel%2Froots.py;h=f14c47f1aada48651e0be30a41f3704117af22db;hb=ade68d25465a422af49d71881550bd89a2ecb824;hp=5f1c294bf13214e7acae6202a80d53cbca385f4e;hpb=b52ce90edb127b6bce5f8b42e55875e306384ccf;p=modules%2Fshaper.git diff --git a/src/PythonAPI/model/roots.py b/src/PythonAPI/model/roots.py index 5f1c294bf..f14c47f1a 100644 --- a/src/PythonAPI/model/roots.py +++ b/src/PythonAPI/model/roots.py @@ -1,3 +1,23 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + """Abstract root classes of user-defined Python features producing a Body Author: Daniel Brunier-Coulin Copyright (C) 2014-20xx CEA/DEN, EDF R&D @@ -5,9 +25,6 @@ Copyright (C) 2014-20xx CEA/DEN, EDF R&D import ModelAPI -from model import tools - - class Feature(ModelAPI.ModelAPI_Feature): """Base class of user-defined Python features.""" @@ -24,6 +41,10 @@ class Feature(ModelAPI.ModelAPI_Feature): """F.getRealInput(str) -- get real value of the attribute""" return self.data().real(inputid).value() + def getTextInput(self, inputid): + """F.getTextInput(str) -- get text value of the attribute""" + return self.data().real(inputid).text() + def addResult(self, result): """F.addResult(ModelAPI_Result) -- add ModelAPI_Result shape as a result""" shape = result.shape() @@ -31,73 +52,3 @@ class Feature(ModelAPI.ModelAPI_Feature): body.store(shape) self.setResult(body) - -class Interface(): - """Base class of high level Python interfaces to features.""" - - def __init__(self, feature): - """x.__init__(...) initializes x; see x.__class__.__doc__ for signature""" - self._feature = feature - - def __getattr__(self, name): - """Process missing attributes. - - Add get*() methods for access feature attributes. - """ - if name.startswith("get"): - possible_names = [ - "_" + name[3:], - "_" + tools.convert_to_underscore(name[3:]), - ] - for possible_name in possible_names: - if hasattr(self, possible_name): - def getter(): - return getattr(self, possible_name) - return getter - - raise AttributeError() - - def _fillAttribute(self, attribute, value): - """Fill ModelAPI_Attribute* with value.""" - tools.fill_attribute(attribute, value) - - def feature(self): - """Return ModelAPI_Feature.""" - return self._feature - - def getKind(self): - """Return the unique kind of the feature""" - return self._feature.getKind() - - def results(self): - """Return current results of the feature""" - return self._feature.results() - - def firstResult(self): - """Return the first result in the list of results""" - return self._feature.firstResult() - - def lastResult(self): - """Return the last result in the list of results""" - return self._feature.lastResult() - - def setRealInput(self, inputid, value): - """I.setRealInput(str, float) -- set real value to the attribute""" - self._feature.data().real(inputid).setValue(value) - - def areInputValid(self): - """I.areInputValid() -> True or False validation result""" - validators = ModelAPI.ModelAPI_Session.get().validators() - return validators.validate(self._feature) - - def execute(self): - """I.execute() -- validate and execute the feature. - - Raises RuntimeError if validation fails. - """ - if self.areInputValid(): - self._feature.execute() - else: - raise RuntimeError("Can not execute %s: %s" % - (self._feature.getKind(), self._feature.error()) - )