Salome HOME
Sketcher: Remove obsolete interfaces. Code cleanup.
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMulti.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintMulti.h
4 // Created: 2 Sep 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintMulti_H_
8 #define SketchSolver_ConstraintMulti_H_
9
10 #include <SketchSolver_Constraint.h>
11
12 #include <vector>
13
14 /** \class   SketchSolver_ConstraintMulti
15  *  \ingroup Plugins
16  *  \brief   Common base class for the Multi constraints
17  */
18 class SketchSolver_ConstraintMulti : public SketchSolver_Constraint
19 {
20 public:
21   /// Constructor based on SketchPlugin constraint
22   SketchSolver_ConstraintMulti(ConstraintPtr theConstraint) :
23       SketchSolver_Constraint(theConstraint),
24       myNumberOfObjects(0),
25       myNumberOfCopies(0),
26       myIsFullValue(false),
27       myAdjusted(false),
28       myIsEventsBlocked(false)
29   {}
30
31   /// \brief Update constraint
32   virtual void update();
33
34   /// \brief Notify this object about the feature is changed somewhere
35   virtual void notify(const FeaturePtr& theFeature, PlaneGCSSolver_Update*);
36
37   /// \brief Tries to remove constraint
38   /// \return \c false, if current constraint contains another SketchPlugin
39   /// constraints (like for multiple coincidence)
40   virtual bool remove();
41
42   /// \brief Block or unblock events from this constraint
43   virtual void blockEvents(bool isBlocked);
44
45 protected:
46   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
47   virtual void process()
48   { /* do nothing here */ }
49
50   /// \brief Collect entities which are translated or rotated (not their copies)
51   void getEntities(std::list<EntityWrapperPtr>& theEntities);
52
53   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
54   virtual void getAttributes(EntityWrapperPtr&, std::vector<EntityWrapperPtr>&)
55   { /* do nothing here */ }
56
57   /// \brief This method is used in derived objects to check consistence of constraint.
58   virtual void adjustConstraint();
59
60   /// \brief Update parameters of derived classes
61   virtual void updateLocal() = 0;
62
63   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
64   virtual const std::string& nameNbObjects() = 0;
65
66 protected:
67   /// \brief Convert absolute coordinates to relative coordinates
68   virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY) = 0;
69   /// \brief Convert relative coordinates to absolute coordinates
70   virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY) = 0;
71   /// \brief Apply transformation for relative coordinates
72   virtual void transformRelative(double& theX, double& theY) = 0;
73
74 protected:
75   int myNumberOfObjects; ///< number of previous initial objects
76   int myNumberOfCopies;  ///< number of previous copies of initial objects
77   bool myIsFullValue;    ///< value whether the angle/distance is a full or single for objects
78
79   bool myAdjusted; ///< the constraint is already adjusted (to not do it several times)
80
81   /// list of features and their copies to find whether some of them are disappeared
82   std::set<FeaturePtr> myFeatures;
83
84   bool myIsEventsBlocked;
85 };
86
87 #endif