Salome HOME
COPY attribute in SketchEntity now persistent
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MultiTranslation.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:    SketchPlugin_MultiTranslation.h
4 // Created: 21 Apr 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchPlugin_MultiTranslation_H_
8 #define SketchPlugin_MultiTranslation_H_
9
10 #include "SketchPlugin.h"
11 #include <SketchPlugin_Sketch.h>
12 #include "SketchPlugin_ConstraintBase.h"
13
14 /** \class SketchPlugin_MultiTranslation
15  *  \ingroup Plugins
16  *  \brief Feature for creation of a number of shifted 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_MultiTranslation : public SketchPlugin_ConstraintBase
27 {
28  public:
29   /// Multi-translation kind
30   inline static const std::string& ID()
31   {
32     static const std::string MY_CONSTRAINT_TRANSLATION_ID("SketchMultiTranslation");
33     return MY_CONSTRAINT_TRANSLATION_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_MultiTranslation::ID();
39     return MY_KIND;
40   }
41
42   /// List of objects to be mirrored
43   inline static const std::string& TRANSLATION_LIST_ID()
44   {
45     static const std::string MY_TRANSLATION_LIST_ID("MultiTranslationList");
46     return MY_TRANSLATION_LIST_ID;
47   }
48
49   /// attribute name for first point
50   inline static const std::string& VALUE_TYPE()
51   {
52     static const std::string VALUE_TYPE_ATTR("ValueType");
53     return VALUE_TYPE_ATTR;
54   }
55
56   /// Start point of translation
57   inline static const std::string& START_POINT_ID()
58   {
59     static const std::string MY_START_POINT_ID("MultiTranslationStartPoint");
60     return MY_START_POINT_ID;
61   }
62
63   /// End point of translation
64   inline static const std::string& END_POINT_ID()
65   {
66     static const std::string MY_END_POINT_ID("MultiTranslationEndPoint");
67     return MY_END_POINT_ID;
68   }
69
70   /// Total number of objects, initial and translated objects
71   inline static const std::string& NUMBER_OF_OBJECTS_ID()
72   {
73     static const std::string MY_NUMBER_OF_OBJECTS_ID("MultiTranslationObjects");
74     return MY_NUMBER_OF_OBJECTS_ID;
75   }
76
77   /// \brief Creates a new part document if needed
78   SKETCHPLUGIN_EXPORT virtual void execute();
79
80   /// \brief Request for initialization of data model of the feature: adding all attributes
81   SKETCHPLUGIN_EXPORT virtual void initAttributes();
82
83   /// Called on change of any argument-attribute of this object
84   /// \param theID identifier of changed attribute
85   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
86
87   /// Returns the AIS preview
88   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
89
90   /// removes all fields from this feature: results, data, etc
91   SKETCHPLUGIN_EXPORT virtual void erase();
92
93   /// \brief Use plugin manager for features creation
94   SketchPlugin_MultiTranslation();
95
96 private:
97   ObjectPtr copyFeature(ObjectPtr theObject);
98
99 };
100
101 #endif