Salome HOME
Sources formated according to the codeing standards
[modules/shaper.git] / src / GeomData / GeomData_Point2D.cpp
1 // File:        GeomData_Point2D.cxx
2 // Created:     24 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include "GeomData_Point2D.h"
6 #include <GeomAPI_Pnt2d.h>
7 #include <ModelAPI_Feature.h>
8 #include <ModelAPI_Data.h>
9
10 using namespace std;
11
12 void GeomData_Point2D::setValue(const double theX, const double theY)
13 {
14   if (myCoords->Value(0) != theX || myCoords->Value(1) != theY) {
15     myCoords->SetValue(0, theX);
16     myCoords->SetValue(1, theY);
17     owner()->data()->sendAttributeUpdated(this);
18   }
19 }
20
21 void GeomData_Point2D::setValue(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
22 {
23   setValue(thePoint->x(), thePoint->y());
24   owner()->data()->sendAttributeUpdated(this);
25 }
26
27 double GeomData_Point2D::x() const
28 {
29   return myCoords->Value(0);
30 }
31
32 double GeomData_Point2D::y() const
33 {
34   return myCoords->Value(1);
35 }
36
37 boost::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
38 {
39   boost::shared_ptr<GeomAPI_Pnt2d> aResult(
40       new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1)));
41   return aResult;
42 }
43
44 GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
45 {
46   myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
47   if (!myIsInitialized) {
48     // create attribute: not initialized by value yet, just zero
49     myCoords = TDataStd_RealArray::Set(theLabel, 0, 1);
50   }
51 }