Salome HOME
First phase of SketchSolver refactoring
[modules/shaper.git] / src / SketchSolver / SketchSolver_IEntityWrapper.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_IEntityWrapper.h
4 // Created: 30 Nov 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_IEntityWrapper_H_
8 #define SketchSolver_IEntityWrapper_H_
9
10 #include <SketchSolver.h>
11 #include <SketchSolver_IParameterWrapper.h>
12
13 #include <ModelAPI_Attribute.h>
14 #include <ModelAPI_Feature.h>
15
16 #include <list>
17 #include <memory>
18
19 /// Types of entities
20 enum SketchSolver_EntityType {
21   ENTITY_UNKNOWN = 0,
22   ENTITY_SCALAR,
23   ENTITY_POINT,
24   ENTITY_NORMAL,
25   ENTITY_LINE,
26   ENTITY_CIRCLE,
27   ENTITY_ARC,
28   ENTITY_SKETCH
29 };
30
31 /**
32  *  Wrapper providing operations with entities regardless the solver.
33  */
34 class SketchSolver_IEntityWrapper
35 {
36 public:
37   virtual ~SketchSolver_IEntityWrapper() {}
38
39   /// \brief Return base feature
40   const FeaturePtr& baseFeature() const
41   { return myBaseFeature; }
42   /// \brief Return base attribute
43   const AttributePtr& baseAttribute() const
44   { return myBaseAttribute; }
45
46   /// \brief Check the feature is basis for this wrapper
47   bool isBase(FeaturePtr theFeature) const
48   { return myBaseFeature && myBaseFeature == theFeature; }
49   /// \brief Check the attribute is basis for this wrapper
50   bool isBase(AttributePtr theAttribute) const
51   { return myBaseAttribute && myBaseAttribute == theAttribute; }
52
53   /// \brief Assign list of parameters for this entity
54   void setParameters(const std::list<ParameterWrapperPtr>& theParams)
55   { myParameters = theParams; }
56   /// \brief Return list of parameters
57   const std::list<ParameterWrapperPtr>& parameters() const
58   { return myParameters; }
59
60   /// \brief Assign list of sub-entities
61   void setSubEntities(const std::list<std::shared_ptr<SketchSolver_IEntityWrapper> >& theEntities)
62   { mySubEntities = theEntities; }
63   /// \brief Return list of sub-entities
64   const std::list<std::shared_ptr<SketchSolver_IEntityWrapper> >& subEntities() const
65   { return mySubEntities; }
66
67   /// \brief Return ID of current entity
68   virtual EntityID id() const = 0;
69
70   /// \brief Change group for the entity
71   virtual void setGroup(const GroupID& theGroup) = 0;
72   /// \brief Return identifier of the group the entity belongs to
73   virtual const GroupID& group() const = 0;
74
75   /// \brief Return type of current entity
76   virtual SketchSolver_EntityType type() const = 0;
77
78   /// \brief Verify the feature is used in the entity
79   virtual bool isUsed(FeaturePtr theFeature) const = 0;
80   /// \brief Verify the attribute is used in the entity
81   virtual bool isUsed(AttributePtr theAttribute) const = 0;
82
83   /// \brief Compare current entity with other
84   virtual bool isEqual(const std::shared_ptr<SketchSolver_IEntityWrapper>& theOther) = 0;
85
86   /// \brief Update values of parameters of this entity by the parameters of given one
87   /// \return \c true if some parameters change their values
88   virtual bool update(const std::shared_ptr<SketchSolver_IEntityWrapper>& theOther) = 0;
89
90 protected:
91   FeaturePtr   myBaseFeature;
92   AttributePtr myBaseAttribute;
93
94   std::list<ParameterWrapperPtr>                            myParameters;
95   std::list<std::shared_ptr<SketchSolver_IEntityWrapper> >  mySubEntities;
96 };
97
98 typedef std::shared_ptr<SketchSolver_IEntityWrapper> EntityWrapperPtr;
99
100 #endif