Salome HOME
Dump Python in the High Level Parameterized Geometry API (issue #1648)
[modules/shaper.git] / src / SketchAPI / SketchAPI_SketchEntity.cpp
1 // Name   : SketchAPI_SketchEntity.cpp
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_SketchEntity.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelHighAPI_Dumper.h>
11 #include <ModelHighAPI_Tools.h>
12 //--------------------------------------------------------------------------------------
13 SketchAPI_SketchEntity::SketchAPI_SketchEntity(
14     const std::shared_ptr<ModelAPI_Feature> & theFeature)
15 : ModelHighAPI_Interface(theFeature)
16 {
17   initialize();
18 }
19
20 SketchAPI_SketchEntity::~SketchAPI_SketchEntity()
21 {
22
23 }
24
25 //--------------------------------------------------------------------------------------
26 bool SketchAPI_SketchEntity::initialize()
27 {
28   SET_ATTRIBUTE(Auxiliary, ModelAPI_AttributeBoolean, SketchPlugin_SketchEntity::AUXILIARY_ID())
29
30   return true;
31 }
32
33 //--------------------------------------------------------------------------------------
34 std::shared_ptr<ModelAPI_AttributeBoolean> SketchAPI_SketchEntity::auxiliary() const
35 {
36   return myAuxiliary;
37 }
38
39 void SketchAPI_SketchEntity::setAuxiliary(bool theAuxiliary)
40 {
41   fillAttribute(theAuxiliary, myAuxiliary);
42
43   execute();
44 }
45
46 //--------------------------------------------------------------------------------------
47 void SketchAPI_SketchEntity::dump(ModelHighAPI_Dumper& theDumper) const
48 {
49   FeaturePtr aBase = feature();
50   AttributeBooleanPtr anAux = aBase->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
51   if (anAux->value()) {
52     const std::string& aName = theDumper.name(aBase);
53     theDumper << aName << ".setAuxiliary(" << anAux << ")" <<std::endl;
54   }
55 }
56
57 bool SketchAPI_SketchEntity::isCopy() const
58 {
59   // check the feature is a copy of another entity
60   std::shared_ptr<SketchPlugin_SketchEntity> aSketchEntity =
61       std::dynamic_pointer_cast<SketchPlugin_SketchEntity>(feature());
62   return aSketchEntity && aSketchEntity->isCopy();
63 }