Salome HOME
Create Presentation for rigid constraint
[modules/shaper.git] / src / GeomData / GeomData_Dir.cpp
index 44f04fe307900b6867a4bba70a6d7bd480b7c984..b7c2b1c30223a41bfe0a7e81cdee09b76dad6b52 100644 (file)
@@ -5,26 +5,26 @@
 #include "GeomData_Dir.h"
 #include "GeomAPI_Dir.h"
 #include <gp_Dir.hxx>
-#include "Model_Events.h"
-#include <Events_Loop.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
 
 using namespace std;
 
 void GeomData_Dir::setValue(const double theX, const double theY, const double theZ)
 {
-  if (myCoords->Value(0) != theX || myCoords->Value(1) != theY || myCoords->Value(2) != theZ) {
+  if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY
+      || myCoords->Value(2) != theZ) {
     myCoords->SetValue(0, theX);
     myCoords->SetValue(1, theY);
     myCoords->SetValue(2, theZ);
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
-    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
-    Events_Loop::loop()->send(aMsg);
+    owner()->data()->sendAttributeUpdated(this);
   }
 }
 
 void GeomData_Dir::setValue(const boost::shared_ptr<GeomAPI_Dir>& theDir)
 {
   setValue(theDir->x(), theDir->y(), theDir->z());
+  owner()->data()->sendAttributeUpdated(this);
 }
 
 double GeomData_Dir::x() const
@@ -44,14 +44,14 @@ double GeomData_Dir::z() const
 
 boost::shared_ptr<GeomAPI_Dir> GeomData_Dir::dir()
 {
-  return boost::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(
-    myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
+  return boost::shared_ptr<GeomAPI_Dir>(
+      new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
 }
 
 GeomData_Dir::GeomData_Dir(TDF_Label& theLabel)
 {
-  // check the attribute could be already presented in this doc (after load document)
-  if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
+  myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
+  if (!myIsInitialized) {
     // create attribute: not initialized by value yet, just zero
     myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);
   }