Salome HOME
Avoid SketchSolver documentation warnings
[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       myAdjusted(false)
28   {}
29
30   virtual int getType() const
31   { return SLVS_C_UNKNOWN; }
32
33   /// \brief Update constraint
34   virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
35
36   /// \brief Tries to remove constraint
37   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
38   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
39
40   /// \brief Adds a feature to constraint and create its analogue in SolveSpace
41   virtual void addFeature(FeaturePtr theFeature);
42
43   /// \brief Update SketchPlugin attributes using the data obtained from SolveSpace entities
44   virtual void refresh()
45   {
46     myAdjusted = false;
47     SketchSolver_Constraint::refresh();
48   }
49
50   /// \brief Verifies, the coincidence between points of copied entities appears or disappears,
51   ///        and removes or adds fixing of corresponding points.
52   void checkCoincidence();
53
54 protected:
55   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
56   virtual void process()
57   { /* do nothing here */ }
58
59   /// \brief Collect entities and their copies, like circles and arcs
60   void processEntities(const std::vector< std::vector<Slvs_hEntity> >& theEntAndCopies);
61
62   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
63   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
64   /// \param[out] theAttributes list of attributes to be filled
65   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
66   { /* do nothing here */ }
67
68   /// \brief This method is used in derived objects to check consistence of constraint.
69   virtual void adjustConstraint();
70
71   /// \brief Update parameters of derived classes
72   virtual void updateLocal() = 0;
73
74   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
75   virtual const std::string& nameNbCopies() = 0;
76
77 protected:
78   /// \brief Convert absolute coordinates to relative coordinates
79   virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY) = 0;
80   /// \brief Convert relative coordinates to absolute coordinates
81   virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY) = 0;
82   /// \brief Apply transformation for relative coordinates
83   virtual void transformRelative(double& theX, double& theY) = 0;
84
85 protected:
86   size_t myNumberOfObjects; ///< number of previous initial objects
87   size_t myNumberOfCopies;  ///< number of previous copies of initial objects
88
89   std::vector< std::vector<Slvs_hEntity> > myPointsAndCopies; ///< list of initial points and their copies
90   std::vector< std::vector<Slvs_hEntity> > myCircsAndCopies;  ///< list of circles and their copies (to change their radii together)
91
92   std::set<Slvs_hEntity> myPointsJustUpdated; ///< list of points touched by user
93   std::set<Slvs_hEntity> myInitialPoints;     ///< list of points containing initial objects
94
95   bool myAdjusted; ///< the constraint is already adjusted (to not do it several times)
96 };
97
98 #endif