]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchAPI/SketchAPI_SketchEntity.cpp
Salome HOME
Dump names of features copied in Multi-Translation, Multi-Rotation and Mirror macro...
[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 #include <SketchAPI_Arc.h>
10 #include <SketchAPI_Circle.h>
11 #include <SketchAPI_IntersectionPoint.h>
12 #include <SketchAPI_Line.h>
13 #include <SketchAPI_Point.h>
14 //--------------------------------------------------------------------------------------
15 #include <ModelHighAPI_Dumper.h>
16 #include <ModelHighAPI_Tools.h>
17
18 #include <SketchPlugin_Arc.h>
19 #include <SketchPlugin_Circle.h>
20 #include <SketchPlugin_IntersectionPoint.h>
21 #include <SketchPlugin_Line.h>
22 #include <SketchPlugin_Point.h>
23 //--------------------------------------------------------------------------------------
24 SketchAPI_SketchEntity::SketchAPI_SketchEntity(
25     const std::shared_ptr<ModelAPI_Feature> & theFeature)
26 : ModelHighAPI_Interface(theFeature)
27 {
28   initialize();
29 }
30
31 SketchAPI_SketchEntity::~SketchAPI_SketchEntity()
32 {
33
34 }
35
36 //--------------------------------------------------------------------------------------
37 bool SketchAPI_SketchEntity::initialize()
38 {
39   SET_ATTRIBUTE(Auxiliary, ModelAPI_AttributeBoolean, SketchPlugin_SketchEntity::AUXILIARY_ID())
40
41   return true;
42 }
43
44 //--------------------------------------------------------------------------------------
45 std::shared_ptr<ModelAPI_AttributeBoolean> SketchAPI_SketchEntity::auxiliary() const
46 {
47   return myAuxiliary;
48 }
49
50 void SketchAPI_SketchEntity::setAuxiliary(bool theAuxiliary)
51 {
52   fillAttribute(theAuxiliary, myAuxiliary);
53
54   execute();
55 }
56
57 //--------------------------------------------------------------------------------------
58 void SketchAPI_SketchEntity::dump(ModelHighAPI_Dumper& theDumper) const
59 {
60   FeaturePtr aBase = feature();
61   AttributeBooleanPtr anAux = aBase->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
62   if (anAux->value()) {
63     const std::string& aName = theDumper.name(aBase);
64     theDumper << aName << ".setAuxiliary(" << anAux << ")" <<std::endl;
65   }
66 }
67
68 bool SketchAPI_SketchEntity::isCopy() const
69 {
70   // check the feature is a copy of another entity
71   AttributeBooleanPtr isCopy = feature()->boolean(SketchPlugin_SketchEntity::COPY_ID());
72   return isCopy.get() && isCopy->value();
73 }
74
75 std::list<std::shared_ptr<ModelHighAPI_Interface> >
76 SketchAPI_SketchEntity::wrap(const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures)
77 {
78   std::list<std::shared_ptr<ModelHighAPI_Interface> > aResult;
79   std::list<std::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = theFeatures.begin();
80   for (; anIt != theFeatures.end(); ++anIt) {
81     if ((*anIt)->getKind() == SketchPlugin_Line::ID())
82       aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Line(*anIt)));
83     else if ((*anIt)->getKind() == SketchPlugin_Arc::ID())
84       aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Arc(*anIt)));
85     else if ((*anIt)->getKind() == SketchPlugin_Circle::ID())
86       aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Circle(*anIt)));
87     else if ((*anIt)->getKind() == SketchPlugin_Point::ID())
88       aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Point(*anIt)));
89     else if ((*anIt)->getKind() == SketchPlugin_IntersectionPoint::ID())
90       aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_IntersectionPoint(*anIt)));
91   }
92   return aResult;
93 }