Salome HOME
Merge remote-tracking branch 'remotes/origin/master'
[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
9 using namespace std;
10
11 void GeomData_Point2D::setValue(const double theX, const double theY)
12 {
13   if (myCoords->Value(0) != theX || myCoords->Value(1) != theY) {
14     myCoords->SetValue(0, theX);
15     myCoords->SetValue(1, theY);
16     static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
17     Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
18     Events_Loop::loop()->send(aMsg);
19   }
20 }
21
22 double GeomData_Point2D::x() const
23 {
24   return myCoords->Value(0);
25 }
26
27 double GeomData_Point2D::y() const
28 {
29   return myCoords->Value(1);
30 }
31
32 GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
33 {
34   // check the attribute could be already presented in this doc (after load document)
35   if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
36     // create attribute: not initialized by value yet, just zero
37     myCoords = TDataStd_RealArray::Set(theLabel, 0, 1);
38   }
39 }