Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into azv/SketchSolver_Refactoring
[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 #include "GeomDataAPI_Point2D.h"
14
15 /** \class   SketchSolver_ConstraintMultiRotation
16  *  \ingroup Plugins
17  *  \brief   Convert rotated features to the list of SolveSpace constraints
18  */
19 class SketchSolver_ConstraintMultiRotation : public SketchSolver_ConstraintMulti
20 {
21 public:
22   /// Constructor based on SketchPlugin constraint
23   SketchSolver_ConstraintMultiRotation(ConstraintPtr theConstraint) :
24       SketchSolver_ConstraintMulti(theConstraint)
25   {}
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   central point of rotation
33   /// \param[out] theAngle    rotation angle
34   /// \param[out] theFullValue  applying translation using the disstance as a full or single value
35   /// \param[out] theEntities list of base entities
36   void getAttributes(EntityWrapperPtr&            theCenter,
37                      EntityWrapperPtr&            theAngle,
38                      bool&                        theFullValue,
39                      std::list<EntityWrapperPtr>& theEntities);
40
41   /// \brief This method is used in derived objects to check consistence of constraint.
42   virtual void adjustConstraint();
43
44   /// \brief Update parameters (called from base class)
45   virtual void updateLocal();
46
47 private:
48   /// \brief Convert absolute coordinates to relative coordinates
49   virtual void getRelative(double theAbsX, double theAbsY,
50                            double& theRelX, double& theRelY);
51   /// \brief Convert relative coordinates to absolute coordinates
52   virtual void getAbsolute(double theRelX, double theRelY,
53                            double& theAbsX, double& theAbsY);
54   /// \brief Apply transformation for relative coordinates
55   virtual void transformRelative(double& theX, double& theY);
56
57   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
58   virtual const std::string& nameNbObjects();
59
60 private:
61   AttributePoint2DPtr myCenterPointAttribute; ///< a center of rotation
62   double              myAngle;           ///< angle of rotation
63
64   double myCenterCoord[2]; ///< coordinates of rotation center
65   double myRotationVal[2]; ///< sinus and cosine of rotation angle
66 };
67
68 #endif