Salome HOME
Sending events on attributes data changed
[modules/shaper.git] / src / GeomData / GeomData_Point.cpp
1 // File:        GeomData_Point.cxx
2 // Created:     24 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include "GeomData_Point.h"
6 #include "Model_Events.h"
7 #include <Events_Loop.h>
8
9 using namespace std;
10
11 void GeomData_Point::setValue(const double theX, const double theY, const double theZ)
12 {
13   if (myCoords->Value(0) != theX || myCoords->Value(1) != theY || myCoords->Value(2) != theZ) {
14     myCoords->SetValue(0, theX);
15     myCoords->SetValue(1, theY);
16     myCoords->SetValue(2, theZ);
17     static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
18     Model_FeatureUpdatedMessage aMsg(feature(), anEvent);
19     Events_Loop::loop()->send(aMsg);
20   }
21 }
22
23 double GeomData_Point::x() const
24 {
25   return myCoords->Value(0);
26 }
27
28 double GeomData_Point::y() const
29 {
30   return myCoords->Value(1);
31 }
32
33 double GeomData_Point::z() const
34 {
35   return myCoords->Value(2);
36 }
37
38 GeomData_Point::GeomData_Point(TDF_Label& theLabel)
39 {
40   // check the attribute could be already presented in this doc (after load document)
41   if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
42     // create attribute: not initialized by value yet, just zero
43     myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);
44   }
45 }