1 // Copyright (C) 2014-2023 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SketchPlugin_MultiRotation_H_
21 #define SketchPlugin_MultiRotation_H_
23 #include "SketchPlugin.h"
24 #include <SketchPlugin_Sketch.h>
25 #include "SketchPlugin_ConstraintBase.h"
27 /** \class SketchPlugin_MultiRotation
29 * \brief Feature for creation of a number of rotated copies of a list of objects
31 * This constraint has two attributes:
32 * SketchPlugin_Constraint::ENTITY_A() for initial list of objects and
33 * SketchPlugin_Constraint::ENTITY_B() for the list of created objects
35 * The list of created objects contains initial and copied objects of each object given. The
36 * number copies is the NUMBER_OF_OBJECTS_ID() minus 1. At the start of the list, there are
37 * collected N copies of first object from initial list, then N copies of second object etc.
39 class SketchPlugin_MultiRotation : public SketchPlugin_ConstraintBase
42 /// Multi-rotation kind
43 inline static const std::string& ID()
45 static const std::string MY_CONSTRAINT_ROTATION_ID("SketchMultiRotation");
46 return MY_CONSTRAINT_ROTATION_ID;
48 /// \brief Returns the kind of a feature
49 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
51 static std::string MY_KIND = SketchPlugin_MultiRotation::ID();
55 /// List of objects to be mirrored
56 inline static const std::string& ROTATION_LIST_ID()
58 static const std::string MY_ROTATION_LIST_ID("MultiRotationList");
59 return MY_ROTATION_LIST_ID;
62 /// Center of rotation
63 inline static const std::string& CENTER_ID()
65 static const std::string MY_CENTER_ID("MultiRotationCenter");
68 /// attribute name for first point
69 inline static const std::string& ANGLE_TYPE()
71 static const std::string ANGLE_TYPE_ATTR("AngleType");
72 return ANGLE_TYPE_ATTR;
75 /// End point of translation
76 inline static const std::string& ANGLE_ID()
78 static const std::string MY_ANGLE_ID("MultiRotationAngle");
82 /// Total number of objects, initial and translated objects
83 inline static const std::string& NUMBER_OF_OBJECTS_ID()
85 static const std::string MY_NUMBER_OF_OBJECTS_ID("MultiRotationObjects");
86 return MY_NUMBER_OF_OBJECTS_ID;
89 /// Name of the flag to reverse rotation
90 inline static const std::string& REVERSED_ID()
92 static const std::string MY_REVERSED_ID("MultiRotationReversed");
93 return MY_REVERSED_ID;
96 /// \brief Creates a new part document if needed
97 SKETCHPLUGIN_EXPORT virtual void execute();
99 /// \brief Request for initialization of data model of the feature: adding all attributes
100 SKETCHPLUGIN_EXPORT virtual void initAttributes();
102 /// Called on change of any argument-attribute of this object
103 /// \param theID identifier of changed attribute
104 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
106 /// Returns the AIS preview
107 SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
109 /// removes all fields from this feature: results, data, etc
110 SKETCHPLUGIN_EXPORT virtual void erase();
112 /// \brief Use plugin manager for features creation
113 SketchPlugin_MultiRotation();
116 ObjectPtr copyFeature(ObjectPtr theObject);
117 //void rotateFeature(ObjectPtr theInitial, ObjectPtr theTarget,
118 // double theCenterX, double theCenterY, double theAngle);
120 bool updateFullAngleValue();
122 bool isUpdatingAngle;