Salome HOME
#1123 Cancel constraint after preview: the edge does not go back to its previous...
[modules/shaper.git] / src / SketchSolver / SketchSolver_FeatureStorage.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_FeatureStorage.h
4 // Created: 23 Mar 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_FeatureStorage_H_
8 #define SketchSolver_FeatureStorage_H_
9
10 #include <SketchSolver.h>
11 #include <SketchPlugin_Feature.h>
12 #include <SketchPlugin_Constraint.h>
13
14 #include <set>
15 #include <map>
16
17 typedef std::map<FeaturePtr, std::set<ConstraintPtr> > MapFeatureConstraint;
18 typedef std::map<AttributePtr, std::set<FeaturePtr> >  MapAttributeFeature;
19
20 /** \class   SketchSolver_FeatureStorage
21  *  \ingroup Plugins
22  *  \brief   Collects information about SketchPlugin constraints used in specific group
23  */
24 class SketchSolver_FeatureStorage
25 {
26 public:
27   SketchSolver_FeatureStorage() {}
28
29   /// \brief Adds or changes a constraint and all features it uses in the storage
30   void changeConstraint(ConstraintPtr theConstraint);
31   /// \brief Removes a constraint and all its features not used by other constraints
32   void removeConstraint(ConstraintPtr theConstraint);
33   /// \brief Verifies a constraint is used in the current storage
34   bool isInteract(ConstraintPtr theConstraint) const;
35
36   /// \brief Adds or changes a feature in the storage
37   void changeFeature(FeaturePtr theFeature);
38   /// \brief Adds or changes a feature in the storage. The feature is used in specified constraint
39   void changeFeature(FeaturePtr theFeature, ConstraintPtr theConstraint);
40   /// \brief Removes a feature
41   void removeFeature(FeaturePtr theFeature);
42   /// \brief Removes a feature according to a given constraint
43   void removeFeature(FeaturePtr theFeature, ConstraintPtr theConstraint);
44   /// \brief Verifies a feature is used in the current storage
45   bool isInteract(FeaturePtr theFeature) const;
46
47   /// \brief Adds or changes an attribute in the storage
48   void changeAttribute(AttributePtr theAttribute);
49   /// \brief Adds or changes a attribute in the storage.
50   ///        The attribute is used in specified feature or constraint (theFeature)
51   void changeAttribute(AttributePtr theAttribute, FeaturePtr theFeature);
52   /// \brief Removes an attribute
53   void removeAttribute(AttributePtr theAttribute);
54   /// \brief Removes an attribute according to a given feature
55   void removeAttribute(AttributePtr theAttribute, FeaturePtr theFeature);
56   /// \brief Verifies an attribute is used in the current storage
57   bool isInteract(AttributePtr theAttribute) const;
58
59   /// \brief Check the features is not removed
60   bool isConsistent() const;
61
62   /// \brief Prepares list of constraints, which using specified feature or its attributes
63   std::set<ConstraintPtr> getConstraints(FeaturePtr theFeature) const;
64   /// \brief Prepares list of constraints, which using specified attribute
65   std::set<ConstraintPtr> getConstraints(AttributePtr theAttribute) const;
66
67   /// \brief Block/unblock events of changing attributes of the features
68   void blockEvents(bool isBlocked) const;
69
70 private:
71   std::set<ConstraintPtr> myConstraints; ///< list of SketchPlugin constraints used in the current group
72   MapFeatureConstraint myFeatures; ///< list of features used in the group and corresponding constraints which use the feature
73   MapAttributeFeature myAttributes; ///< list of attributes used in the group and corresponding features which are based on the attribute
74 };
75
76 typedef std::shared_ptr<SketchSolver_FeatureStorage> FeatureStoragePtr;
77
78 #endif // SketchSolver_FeatureStorage_H_