]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomData/GeomData_Point2D.cpp
Salome HOME
Changes for modifying of GeomData objects by GeomAPI objects
[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 "Model_Events.h"
7 #include <Events_Loop.h>
8 #include <GeomAPI_Pnt2d.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     static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
18     Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
19     Events_Loop::loop()->send(aMsg);
20   }
21 }
22
23 void GeomData_Point2D::setValue(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
24 {
25   setValue(thePoint->x(), thePoint->y());
26 }
27
28 double GeomData_Point2D::x() const
29 {
30   return myCoords->Value(0);
31 }
32
33 double GeomData_Point2D::y() const
34 {
35   return myCoords->Value(1);
36 }
37
38 boost::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
39 {
40   boost::shared_ptr<GeomAPI_Pnt2d> aResult(
41     new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1)));
42   return aResult;
43 }
44
45 GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
46 {
47   // check the attribute could be already presented in this doc (after load document)
48   if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
49     // create attribute: not initialized by value yet, just zero
50     myCoords = TDataStd_RealArray::Set(theLabel, 0, 1);
51   }
52 }