Salome HOME
Make the copies fixed in multi-rotation, multi-translation (issue #1471)
[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_ANGLE,
24   ENTITY_POINT,
25   ENTITY_NORMAL,
26   ENTITY_LINE,
27   ENTITY_CIRCLE,
28   ENTITY_ARC,
29   ENTITY_SKETCH
30 };
31
32 /**
33  *  Wrapper providing operations with entities regardless the solver.
34  */
35 class SketchSolver_IEntityWrapper
36 {
37 public:
38   virtual ~SketchSolver_IEntityWrapper() {}
39
40   /// \brief Return base feature
41   const FeaturePtr& baseFeature() const
42   { return myBaseFeature; }
43   /// \brief Return base attribute
44   const AttributePtr& baseAttribute() const
45   { return myBaseAttribute; }
46
47   /// \brief Check the feature is basis for this wrapper
48   bool isBase(FeaturePtr theFeature) const
49   { return myBaseFeature && myBaseFeature == theFeature; }
50   /// \brief Check the attribute is basis for this wrapper
51   bool isBase(AttributePtr theAttribute) const
52   { return myBaseAttribute && myBaseAttribute == theAttribute; }
53
54   /// \brief Assign list of parameters for this entity
55   void setParameters(const std::list<ParameterWrapperPtr>& theParams)
56   { myParameters = theParams; }
57   /// \brief Return list of parameters
58   const std::list<ParameterWrapperPtr>& parameters() const
59   { return myParameters; }
60
61   /// \brief Assign list of sub-entities
62   void setSubEntities(const std::list<std::shared_ptr<SketchSolver_IEntityWrapper> >& theEntities)
63   { mySubEntities = theEntities; }
64   /// \brief Return list of sub-entities
65   const std::list<std::shared_ptr<SketchSolver_IEntityWrapper> >& subEntities() const
66   { return mySubEntities; }
67
68   /// \brief Return ID of current entity
69   virtual EntityID id() const = 0;
70
71   /// \brief Change group for the entity
72   virtual void setGroup(const GroupID& theGroup) = 0;
73   /// \brief Return identifier of the group the entity belongs to
74   virtual GroupID group() const = 0;
75
76   /// \brief Return type of current entity
77   virtual SketchSolver_EntityType type() const = 0;
78
79   /// \brief Verify the feature is used in the entity
80   virtual bool isUsed(FeaturePtr theFeature) const = 0;
81   /// \brief Verify the attribute is used in the entity
82   virtual bool isUsed(AttributePtr theAttribute) const = 0;
83
84   /// \brief Compare current entity with other
85   virtual bool isEqual(const std::shared_ptr<SketchSolver_IEntityWrapper>& theOther) = 0;
86
87   /// \brief Update values of parameters of this entity by the parameters of given one
88   /// \return \c true if some parameters change their values
89   virtual bool update(const std::shared_ptr<SketchSolver_IEntityWrapper>& theOther) = 0;
90
91 protected:
92   FeaturePtr   myBaseFeature;
93   AttributePtr myBaseAttribute;
94
95   std::list<ParameterWrapperPtr>                            myParameters;
96   std::list<std::shared_ptr<SketchSolver_IEntityWrapper> >  mySubEntities;
97 };
98
99 typedef std::shared_ptr<SketchSolver_IEntityWrapper> EntityWrapperPtr;
100
101 #endif