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