Salome HOME
Deleting the option of "Scale" feature from dimensions in X, in Y and in Z.
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Scale.cpp
1 // Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Scale.cpp
4 // Created:     24 Jan 2017
5 // Author:      Clarisse Genrault (CEA)
6
7 #include "FeaturesAPI_Scale.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 //==================================================================================================
20 FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21                                      const std::list<ModelHighAPI_Selection>& theMainObjects,
22                                      const ModelHighAPI_Selection& theCenterPoint,
23                                      const ModelHighAPI_Double& theScaleFactor)
24 : ModelHighAPI_Interface(theFeature)
25 {
26   if (initialize()) {
27     fillAttribute(theMainObjects, mainObjects());
28     fillAttribute(theCenterPoint, centerPoint());
29     setScaleFactor(theScaleFactor);
30   }
31 }
32
33 //==================================================================================================
34 FeaturesAPI_Scale::~FeaturesAPI_Scale()
35 {
36 }
37
38 //==================================================================================================
39 void FeaturesAPI_Scale::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
40 {
41   fillAttribute(theMainObjects, mainObjects());
42   execute();
43 }
44
45 //==================================================================================================
46 void FeaturesAPI_Scale::setCenterPoint(const ModelHighAPI_Selection& theCenterPoint)
47 {
48   fillAttribute(theCenterPoint, centerPoint());
49   execute();
50 }
51
52 //==================================================================================================
53 void FeaturesAPI_Scale::setScaleFactor(const ModelHighAPI_Double& theScaleFactor)
54 {
55   fillAttribute(theScaleFactor, scaleFactor());
56   execute();
57 }
58
59 //==================================================================================================
60 void FeaturesAPI_Scale::dump(ModelHighAPI_Dumper& theDumper) const
61 {
62   FeaturePtr aBase = feature();
63   const std::string& aDocName = theDumper.name(aBase->document());
64
65   AttributeSelectionListPtr anAttrObjects =
66     aBase->selectionList(FeaturesPlugin_Scale::OBJECTS_LIST_ID());
67   theDumper << aBase << " = model.addScale(" << aDocName << ", " << anAttrObjects;
68
69   AttributeSelectionPtr anAttrPoint =
70     aBase->selection(FeaturesPlugin_Scale::CENTER_POINT_ID());
71   theDumper << " , " << anAttrPoint;
72
73   AttributeDoublePtr anAttrScaleFactor =
74       aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_ID());
75     theDumper << ", " << anAttrScaleFactor;
76
77   theDumper << ")" << std::endl;
78 }
79
80 //==================================================================================================
81 ScalePtr addScale(const std::shared_ptr<ModelAPI_Document>& thePart,
82                   const std::list<ModelHighAPI_Selection>& theMainObjects,
83                   const ModelHighAPI_Selection& theCenterPoint,
84                   const ModelHighAPI_Double& theScaleFactor)
85 {
86   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Scale::ID());
87   return ScalePtr(new FeaturesAPI_Scale(aFeature, theMainObjects, theCenterPoint, theScaleFactor));
88 }