1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomData_Point2D.cxx
4 // Created: 24 Apr 2014
5 // Author: Mikhail PONIKAROV
7 #include "GeomData_Point2D.h"
8 #include <GeomAPI_Pnt2d.h>
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
14 void GeomData_Point2D::setValue(const double theX, const double theY)
16 if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY) {
17 myCoords->SetValue(0, theX);
18 myCoords->SetValue(1, theY);
19 owner()->data()->sendAttributeUpdated(this);
23 void GeomData_Point2D::setValue(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
25 setValue(thePoint->x(), thePoint->y());
28 double GeomData_Point2D::x() const
30 return myCoords->Value(0);
33 double GeomData_Point2D::y() const
35 return myCoords->Value(1);
38 std::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
40 std::shared_ptr<GeomAPI_Pnt2d> aResult(
41 new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1)));
45 void GeomData_Point2D::setText(const std::string& theX,
46 const std::string& theY)
48 TCollection_ExtendedString aX(theX.c_str());
49 TCollection_ExtendedString aY(theY.c_str());
51 if (!myIsInitialized ||
52 myTextArray->Value(0) != aX ||
53 myTextArray->Value(1) != aY) {
54 myTextArray->SetValue(0, aX);
55 myTextArray->SetValue(1, aY);
56 owner()->data()->sendAttributeUpdated(this);
60 std::string GeomData_Point2D::textX()
62 return TCollection_AsciiString(myTextArray->Value(0)).ToCString();;
64 std::string GeomData_Point2D::textY()
66 return TCollection_AsciiString(myTextArray->Value(1)).ToCString();;
69 void GeomData_Point2D::setExpressionInvalid(int theComponent, bool theFlag)
71 if (!myIsInitialized || myExpressionInvalidArray->Value(theComponent) != theFlag) {
72 myExpressionInvalidArray->SetValue(theComponent, theFlag);
76 bool GeomData_Point2D::expressionInvalid(int theComponent)
78 return myExpressionInvalidArray->Value(theComponent);
81 GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
83 myIsInitialized = true;
85 if (theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) != Standard_True) {
86 // create attribute: not initialized by value yet, just zero
87 myCoords = TDataStd_RealArray::Set(theLabel, 0, 1);
88 myIsInitialized = false;
90 if (theLabel.FindAttribute(TDataStd_ExtStringArray::GetID(), myTextArray) != Standard_True) {
91 // create attribute: not initialized by value yet, just zero
92 myTextArray = TDataStd_ExtStringArray::Set(theLabel, 0, 1);
93 myIsInitialized = false;
95 if (theLabel.FindAttribute(TDataStd_BooleanArray::GetID(), myExpressionInvalidArray) != Standard_True) {
96 // create attribute: not initialized by value yet, just zero
97 myExpressionInvalidArray = TDataStd_BooleanArray::Set(theLabel, 0, 1);
98 myIsInitialized = false;