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