X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModelAPI%2FModelAPI_Expression.h;h=6b7c8839e99ddc1d6cd4c4374aa52aeed90b9d24;hb=bb4d0036dd0785056ab21fc237ec7fcc0870ae5f;hp=2c140b63b11865a2ee5000e738549ce057657be4;hpb=f8c36784f4699f0e3d04f4e8e067c7bd317b4a1c;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI_Expression.h b/src/ModelAPI/ModelAPI_Expression.h index 2c140b63b..6b7c8839e 100644 --- a/src/ModelAPI/ModelAPI_Expression.h +++ b/src/ModelAPI/ModelAPI_Expression.h @@ -1,13 +1,27 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModelAPI_Expression.h -// Created: 5 Aug 2015 -// Author: Sergey POKHODENKO +// Copyright (C) 2014-2019 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 +// #ifndef ModelAPI_Expression_H_ #define ModelAPI_Expression_H_ #include "ModelAPI.h" + #include #include #include @@ -18,9 +32,6 @@ */ class ModelAPI_Expression { - protected: - bool myIsInitialized; ///< is some value assigned to this attribute - public: /// To virtually destroy the fields of successors MODELAPI_EXPORT virtual ~ModelAPI_Expression(); @@ -31,12 +42,6 @@ class ModelAPI_Expression /// Makes attribute initialized MODELAPI_EXPORT virtual void setInitialized(); - /// Defines the double value - MODELAPI_EXPORT virtual void setValue(const double theValue) = 0; - - /// Returns the double value - MODELAPI_EXPORT virtual double value() = 0; - /// Sets the text of this Expression MODELAPI_EXPORT virtual void setText(const std::string& theText) = 0; @@ -56,19 +61,80 @@ class ModelAPI_Expression MODELAPI_EXPORT virtual std::string error() = 0; /// Defines the used parameters (by the parameters listener) - MODELAPI_EXPORT virtual void setUsedParameters(const std::set& theUsedParameters) = 0; + MODELAPI_EXPORT virtual + void setUsedParameters(const std::set& theUsedParameters) = 0; /// Returns the used parameters MODELAPI_EXPORT virtual std::set usedParameters() const = 0; + /// Returns True if the given string can be defined as a name of an expression variable + MODELAPI_EXPORT static bool isVariable(const std::string& theString); + protected: /// Objects are created for features automatically MODELAPI_EXPORT ModelAPI_Expression(); + /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc) + MODELAPI_EXPORT virtual void reinit() = 0; + /// Resets attribute to deafult state. + MODELAPI_EXPORT virtual void reset() { + myIsInitialized = false; + }; + + bool myIsInitialized; ///< is some value assigned to this attribute friend class Model_Data; + friend class Model_AttributeDouble; + friend class Model_AttributeInteger; + friend class GeomData_Point; + friend class GeomData_Point2D; }; -//! Pointer on Expression object + +/**\class ModelAPI_ExpressionDouble + * \ingroup DataModel + * \brief Expression for calculated double values. + */ +class ModelAPI_ExpressionDouble : public virtual ModelAPI_Expression +{ + public: + /// Defines the double value + MODELAPI_EXPORT virtual void setValue(const double theValue) = 0; + + /// Returns the double value + MODELAPI_EXPORT virtual double value() = 0; + + protected: + /// Objects are created for features automatically + MODELAPI_EXPORT ModelAPI_ExpressionDouble(); + + friend class Model_Data; +}; + + +/**\class ModelAPI_ExpressionInteger + * \ingroup DataModel + * \brief Expression for calculated integer values. + */ +class ModelAPI_ExpressionInteger : public virtual ModelAPI_Expression +{ + public: + /// Defines the integer value + MODELAPI_EXPORT virtual void setValue(const int theValue) = 0; + + /// Returns the integer value + MODELAPI_EXPORT virtual int value() = 0; + + protected: + /// Objects are created for features automatically + MODELAPI_EXPORT ModelAPI_ExpressionInteger(); + + friend class Model_Data; +}; + + +//! Smart pointers for objects typedef std::shared_ptr ExpressionPtr; +typedef std::shared_ptr ExpressionDoublePtr; +typedef std::shared_ptr ExpressionIntegerPtr; #endif