Salome HOME
Issue #718 - Translation with parameters - wrong coordinates -- Add SketchPlugin_Tool...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Tools.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_Tools.cpp
4 // Created:     07 July 2015
5 // Author:      Sergey POKHODENKO
6
7 #include "SketchPlugin_Tools.h"
8
9 #include <GeomDataAPI_Point.h>
10 #include <GeomDataAPI_Point2D.h>
11 #include <ModelAPI_AttributeDouble.h>
12
13 void clearExpressions(AttributeDoublePtr theAttribute)
14 {
15   theAttribute->setText(std::string());
16 }
17
18 void clearExpressions(AttributePointPtr theAttribute)
19 {
20   theAttribute->setText(std::string(), std::string(), std::string());
21 }
22
23 void clearExpressions(AttributePoint2DPtr theAttribute)
24 {
25   theAttribute->setText(std::string(), std::string());
26 }
27
28 void clearExpressions(AttributePtr theAttribute)
29 {
30   // Double
31   AttributeDoublePtr anAttributeDouble = 
32       std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
33   if (anAttributeDouble.get())
34     clearExpressions(anAttributeDouble);
35   // Point
36   AttributePointPtr anAttributePoint = 
37       std::dynamic_pointer_cast<GeomDataAPI_Point>(theAttribute);
38   if (anAttributePoint.get())
39     clearExpressions(anAttributePoint);
40   // Point2D
41   AttributePoint2DPtr anAttributePoint2D = 
42       std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theAttribute);
43   if (anAttributePoint2D.get())
44     clearExpressions(anAttributePoint2D);
45 }
46
47 void clearExpressions(FeaturePtr theFeature)
48 {
49   if (!theFeature.get())
50     return;
51
52   std::list<AttributePtr> anAttributes = theFeature->data()->attributes(std::string());  
53   std::list<AttributePtr>::iterator anAttributeIt = anAttributes.begin();
54   for (; anAttributeIt != anAttributes.end(); ++anAttributeIt) {
55     clearExpressions(*anAttributeIt);
56   }
57 }