Salome HOME
Issue #901 - It is possible to define empty name for parameter
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMultiRotation.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintMultiRotation.h
4 // Created: 1 Apr 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintMultiRotation_H_
8 #define SketchSolver_ConstraintMultiRotation_H_
9
10 #include "SketchSolver.h"
11 #include <SketchSolver_ConstraintMulti.h>
12
13 /** \class   SketchSolver_ConstraintMultiRotation
14  *  \ingroup Plugins
15  *  \brief   Convert rotated features to the list of SolveSpace constraints
16  */
17 class SketchSolver_ConstraintMultiRotation : public SketchSolver_ConstraintMulti
18 {
19 public:
20   SketchSolver_ConstraintMultiRotation(ConstraintPtr theConstraint) :
21       SketchSolver_ConstraintMulti(theConstraint)
22   {}
23
24   virtual int getType() const
25   { return SLVS_C_MULTI_ROTATION; }
26
27 protected:
28   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
29   virtual void process();
30
31   /// \brief Generate list of rotated entities
32   /// \param[out] theCenter   ID of central point of rotation
33   /// \param[out] theAngle    rotation angle
34   /// \param[out] thePoints   list of IDs of initial points and their rotated copies
35   /// \param[out] theEntities list of IDs of entities and their rotated copies
36   void getAttributes(Slvs_hEntity& theCenter, double& theAngle,
37                      std::vector< std::vector<Slvs_hEntity> >& thePoints,
38                      std::vector< std::vector<Slvs_hEntity> >& theEntities);
39
40   /// \brief This method is used in derived objects to check consistence of constraint.
41   virtual void adjustConstraint();
42
43   /// \brief Update parameters (called from base class)
44   virtual void updateLocal();
45
46 private:
47   /// \brief Convert absolute coordinates to relative coordinates
48   virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY);
49   /// \brief Convert relative coordinates to absolute coordinates
50   virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY);
51   /// \brief Apply transformation for relative coordinates
52   virtual void transformRelative(double& theX, double& theY);
53
54 private:
55   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
56   virtual const std::string& nameNbCopies();
57
58 private:
59   Slvs_hEntity myRotationCenter; ///< ID of center of rotation
60   double       myAngle;           ///< angle of rotation
61
62   double myCenterCoord[2]; ///< coordinates of rotation center
63   double myRotationVal[2]; ///< sinus and cosinus of rotation angle
64 };
65
66 #endif