Salome HOME
Implementation of multi-translation and multi-rotation
[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 a number of copies of each object given in
23  *  the NUMBER_OF_COPIES_ID() attribute plus 1 (the initial objects are stored into this
24  *  attribute too). At the start of the list, there are collected N copies
25  *  of first object from initial list, then N copies of second object etc.
26  */
27 class SketchPlugin_MultiTranslation : public SketchPlugin_ConstraintBase
28 {
29  public:
30   /// Multi-translation kind
31   inline static const std::string& ID()
32   {
33     static const std::string MY_CONSTRAINT_TRANSLATION_ID("SketchMultiTranslation");
34     return MY_CONSTRAINT_TRANSLATION_ID;
35   }
36   /// \brief Returns the kind of a feature
37   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
38   {
39     static std::string MY_KIND = SketchPlugin_MultiTranslation::ID();
40     return MY_KIND;
41   }
42
43   /// List of objects to be mirrored
44   inline static const std::string& TRANSLATION_LIST_ID()
45   {
46     static const std::string MY_TRANSLATION_LIST_ID("MultiTranslationList");
47     return MY_TRANSLATION_LIST_ID;
48   }
49
50   /// Start point of translation
51   inline static const std::string& START_POINT_ID()
52   {
53     static const std::string MY_START_POINT_ID("MultiTranslationStartPoint");
54     return MY_START_POINT_ID;
55   }
56   /// End point of translation
57   inline static const std::string& END_POINT_ID()
58   {
59     static const std::string MY_END_POINT_ID("MultiTranslationEndPoint");
60     return MY_END_POINT_ID;
61   }
62   /// Number of translated objects
63   inline static const std::string& NUMBER_OF_COPIES_ID()
64   {
65     static const std::string MY_NUMBER_OF_COPIES_ID("MultiTranslationCopies");
66     return MY_NUMBER_OF_COPIES_ID;
67   }
68
69   /// \brief Creates a new part document if needed
70   SKETCHPLUGIN_EXPORT virtual void execute();
71
72   /// \brief Request for initialization of data model of the feature: adding all attributes
73   SKETCHPLUGIN_EXPORT virtual void initAttributes();
74
75   /// Returns the AIS preview
76   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
77
78   /// \brief Use plugin manager for features creation
79   SketchPlugin_MultiTranslation();
80
81 private:
82   ObjectPtr copyFeature(ObjectPtr theObject);
83   void shiftFeature(ObjectPtr theInitial, ObjectPtr theTarget, double theDeltaX, double theDeltaY);
84 };
85
86 #endif