Salome HOME
2D point selection in multi-rotation/multi-translation.
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MultiRotation.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:    SketchPlugin_MultiRotation.h
4 // Created: 21 Apr 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchPlugin_MultiRotation_H_
8 #define SketchPlugin_MultiRotation_H_
9
10 #include "SketchPlugin.h"
11 #include <SketchPlugin_Sketch.h>
12 #include "SketchPlugin_ConstraintBase.h"
13
14 /** \class SketchPlugin_MultiRotation
15  *  \ingroup Plugins
16  *  \brief Feature for creation of a number of rotated copies of a list of objects
17  *
18  *  This constraint has two attributes:
19  *  SketchPlugin_Constraint::ENTITY_A() for initial list of objects and
20  *  SketchPlugin_Constraint::ENTITY_B() for the list of created objects
21  *
22  *  The list of created objects contains initial and copied objects of each object given. The
23  *  number copies is the NUMBER_OF_OBJECTS_ID() minus 1. At the start of the list, there are
24  * collected N copies of first object from initial list, then N copies of second object etc.
25  */
26 class SketchPlugin_MultiRotation : public SketchPlugin_ConstraintBase
27 {
28  public:
29   /// Multi-rotation kind
30   inline static const std::string& ID()
31   {
32     static const std::string MY_CONSTRAINT_ROTATION_ID("SketchMultiRotation");
33     return MY_CONSTRAINT_ROTATION_ID;
34   }
35   /// \brief Returns the kind of a feature
36   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
37   {
38     static std::string MY_KIND = SketchPlugin_MultiRotation::ID();
39     return MY_KIND;
40   }
41
42   /// List of objects to be mirrored
43   inline static const std::string& ROTATION_LIST_ID()
44   {
45     static const std::string MY_ROTATION_LIST_ID("MultiRotationList");
46     return MY_ROTATION_LIST_ID;
47   }
48
49   /// Center of rotation
50   inline static const std::string& CENTER_ID()
51   {
52     static const std::string MY_CENTER_ID("MultiRotationCenter");
53     return MY_CENTER_ID;
54   }
55   /// attribute name for first point
56   inline static const std::string& ANGLE_TYPE()
57   {
58     static const std::string ANGLE_TYPE_ATTR("AngleType");
59     return ANGLE_TYPE_ATTR;
60   }
61
62   /// End point of translation
63   inline static const std::string& ANGLE_ID()
64   {
65     static const std::string MY_ANGLE_ID("MultiRotationAngle");
66     return MY_ANGLE_ID;
67   }
68
69   /// Total number of objects, initial and translated objects
70   inline static const std::string& NUMBER_OF_OBJECTS_ID()
71   {
72     static const std::string MY_NUMBER_OF_OBJECTS_ID("MultiRotationObjects");
73     return MY_NUMBER_OF_OBJECTS_ID;
74   }
75
76   /// \brief Creates a new part document if needed
77   SKETCHPLUGIN_EXPORT virtual void execute();
78
79   /// \brief Request for initialization of data model of the feature: adding all attributes
80   SKETCHPLUGIN_EXPORT virtual void initAttributes();
81
82   /// Called on change of any argument-attribute of this object
83   /// \param theID identifier of changed attribute
84   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
85
86   /// Returns the AIS preview
87   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
88
89   /// \brief Use plugin manager for features creation
90   SketchPlugin_MultiRotation();
91
92 private:
93   ObjectPtr copyFeature(ObjectPtr theObject);
94   //void rotateFeature(ObjectPtr theInitial, ObjectPtr theTarget,
95   //                   double theCenterX, double theCenterY, double theAngle);
96
97   bool updateFullAngleValue();
98 };
99
100 #endif