1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef SketchPlugin_MultiTranslation_H_
22 #define SketchPlugin_MultiTranslation_H_
24 #include "SketchPlugin.h"
25 #include <SketchPlugin_Sketch.h>
26 #include "SketchPlugin_ConstraintBase.h"
28 /** \class SketchPlugin_MultiTranslation
30 * \brief Feature for creation of a number of shifted copies of a list of objects
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
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.
40 class SketchPlugin_MultiTranslation : public SketchPlugin_ConstraintBase
43 /// Multi-translation kind
44 inline static const std::string& ID()
46 static const std::string MY_CONSTRAINT_TRANSLATION_ID("SketchMultiTranslation");
47 return MY_CONSTRAINT_TRANSLATION_ID;
49 /// \brief Returns the kind of a feature
50 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
52 static std::string MY_KIND = SketchPlugin_MultiTranslation::ID();
56 /// List of objects to be mirrored
57 inline static const std::string& TRANSLATION_LIST_ID()
59 static const std::string MY_TRANSLATION_LIST_ID("MultiTranslationList");
60 return MY_TRANSLATION_LIST_ID;
63 /// attribute name for first point
64 inline static const std::string& VALUE_TYPE()
66 static const std::string VALUE_TYPE_ATTR("ValueType");
67 return VALUE_TYPE_ATTR;
70 /// Start point of translation
71 inline static const std::string& START_POINT_ID()
73 static const std::string MY_START_POINT_ID("MultiTranslationStartPoint");
74 return MY_START_POINT_ID;
77 /// End point of translation
78 inline static const std::string& END_POINT_ID()
80 static const std::string MY_END_POINT_ID("MultiTranslationEndPoint");
81 return MY_END_POINT_ID;
84 /// Total number of objects, initial and translated objects
85 inline static const std::string& NUMBER_OF_OBJECTS_ID()
87 static const std::string MY_NUMBER_OF_OBJECTS_ID("MultiTranslationObjects");
88 return MY_NUMBER_OF_OBJECTS_ID;
91 /// \brief Creates a new part document if needed
92 SKETCHPLUGIN_EXPORT virtual void execute();
94 /// \brief Request for initialization of data model of the feature: adding all attributes
95 SKETCHPLUGIN_EXPORT virtual void initAttributes();
97 /// Called on change of any argument-attribute of this object
98 /// \param theID identifier of changed attribute
99 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
101 /// Returns the AIS preview
102 SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
104 /// removes all fields from this feature: results, data, etc
105 SKETCHPLUGIN_EXPORT virtual void erase();
107 /// \brief Use plugin manager for features creation
108 SketchPlugin_MultiTranslation();
111 ObjectPtr copyFeature(ObjectPtr theObject);