Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MultiRotation.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef SketchPlugin_MultiRotation_H_
22 #define SketchPlugin_MultiRotation_H_
23
24 #include "SketchPlugin.h"
25 #include <SketchPlugin_Sketch.h>
26 #include "SketchPlugin_ConstraintBase.h"
27
28 /** \class SketchPlugin_MultiRotation
29  *  \ingroup Plugins
30  *  \brief Feature for creation of a number of rotated copies of a list of objects
31  *
32  *  This constraint has two attributes:
33  *  SketchPlugin_Constraint::ENTITY_A() for initial list of objects and
34  *  SketchPlugin_Constraint::ENTITY_B() for the list of created objects
35  *
36  *  The list of created objects contains initial and copied objects of each object given. The
37  *  number copies is the NUMBER_OF_OBJECTS_ID() minus 1. At the start of the list, there are
38  * collected N copies of first object from initial list, then N copies of second object etc.
39  */
40 class SketchPlugin_MultiRotation : public SketchPlugin_ConstraintBase
41 {
42  public:
43   /// Multi-rotation kind
44   inline static const std::string& ID()
45   {
46     static const std::string MY_CONSTRAINT_ROTATION_ID("SketchMultiRotation");
47     return MY_CONSTRAINT_ROTATION_ID;
48   }
49   /// \brief Returns the kind of a feature
50   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
51   {
52     static std::string MY_KIND = SketchPlugin_MultiRotation::ID();
53     return MY_KIND;
54   }
55
56   /// List of objects to be mirrored
57   inline static const std::string& ROTATION_LIST_ID()
58   {
59     static const std::string MY_ROTATION_LIST_ID("MultiRotationList");
60     return MY_ROTATION_LIST_ID;
61   }
62
63   /// Center of rotation
64   inline static const std::string& CENTER_ID()
65   {
66     static const std::string MY_CENTER_ID("MultiRotationCenter");
67     return MY_CENTER_ID;
68   }
69   /// attribute name for first point
70   inline static const std::string& ANGLE_TYPE()
71   {
72     static const std::string ANGLE_TYPE_ATTR("AngleType");
73     return ANGLE_TYPE_ATTR;
74   }
75
76   /// End point of translation
77   inline static const std::string& ANGLE_ID()
78   {
79     static const std::string MY_ANGLE_ID("MultiRotationAngle");
80     return MY_ANGLE_ID;
81   }
82
83   /// Total number of objects, initial and translated objects
84   inline static const std::string& NUMBER_OF_OBJECTS_ID()
85   {
86     static const std::string MY_NUMBER_OF_OBJECTS_ID("MultiRotationObjects");
87     return MY_NUMBER_OF_OBJECTS_ID;
88   }
89
90   /// \brief Creates a new part document if needed
91   SKETCHPLUGIN_EXPORT virtual void execute();
92
93   /// \brief Request for initialization of data model of the feature: adding all attributes
94   SKETCHPLUGIN_EXPORT virtual void initAttributes();
95
96   /// Called on change of any argument-attribute of this object
97   /// \param theID identifier of changed attribute
98   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
99
100   /// Returns the AIS preview
101   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
102
103   /// removes all fields from this feature: results, data, etc
104   SKETCHPLUGIN_EXPORT virtual void erase();
105
106   /// \brief Use plugin manager for features creation
107   SketchPlugin_MultiRotation();
108
109 private:
110   ObjectPtr copyFeature(ObjectPtr theObject);
111   //void rotateFeature(ObjectPtr theInitial, ObjectPtr theTarget,
112   //                   double theCenterX, double theCenterY, double theAngle);
113
114   bool updateFullAngleValue();
115 };
116
117 #endif