Salome HOME
8232a8ee995df67e556794051854f93b6c5beef0
[modules/shaper.git] / src / ModelAPI / ModelAPI_AttributeSelection.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
18 //
19
20 #ifndef ModelAPI_AttributeSelection_H_
21 #define ModelAPI_AttributeSelection_H_
22
23 #include "ModelAPI_Attribute.h"
24 #include <ModelAPI_Result.h>
25
26 /**\class ModelAPI_AttributeSelection
27  * \ingroup DataModel
28  * \brief Attribute that contains reference to the sub-shape of some result, the selected shape.
29  */
30
31 class ModelAPI_AttributeSelection : public ModelAPI_Attribute
32 {
33  public:
34   /// Defines the result and its selected sub-shape
35   /// \param theContext object where the sub-shape was selected
36   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
37   /// \param theTemporarily if it is true, do not store and name the added in the data framework
38   ///           (used to remove immideately, without the following updates)
39   virtual void setValue(
40     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
41     const bool theTemporarily = false) = 0;
42
43   /// Reset temporary stored values
44   virtual void removeTemporaryValues() = 0;
45
46   /// Returns the selected subshape
47   virtual std::shared_ptr<GeomAPI_Shape> value() = 0;
48
49   /// Returns the context of the selection (the whole shape owner)
50   virtual ResultPtr context() = 0;
51
52   /// Updates the underlied selection due to the changes in the referenced objects
53   /// \returns false if update is failed
54   virtual bool update() = 0;
55
56   /// Returns the type of this class of attributes
57   static std::string typeId()
58   {
59     return "Selection";
60   }
61
62   /// Returns the type of this class of attributes, not static method
63   MODELAPI_EXPORT virtual std::string attributeType();
64
65   /// Returns a textual string of the selection
66   /// \param theDefaultValue a value, which is used if the naming name can not be obtained
67   virtual std::string namingName(const std::string& theDefaultValue = "") = 0;
68
69   /// Returns an id of the selection
70   virtual int Id() = 0;
71
72   /// Defines an id of the selection
73   virtual void setId(int theID) = 0;
74
75   /// Selects sub-shape by the textual Name
76   virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName) = 0;
77
78   /// Returns true if recompute of selection become impossible
79   virtual bool isInvalid() = 0;
80
81   /// To virtually destroy the fields of successors
82   MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection();
83
84  protected:
85   /// Objects are created for features automatically
86   MODELAPI_EXPORT ModelAPI_AttributeSelection();
87 };
88
89 //! Pointer on double attribute
90 typedef std::shared_ptr<ModelAPI_AttributeSelection> AttributeSelectionPtr;
91
92 #endif