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