Salome HOME
Fix of problem with colors of result on undo-redo of result creation and color assign...
[modules/shaper.git] / src / GeomData / GeomData_Point.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomData_Point.cxx
4 // Created:     24 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include "GeomData_Point.h"
8 #include <GeomAPI_Pnt.h>
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
11
12 using namespace std;
13
14 void GeomData_Point::setValue(const double theX, const double theY, const double theZ)
15 {
16   if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY
17       || myCoords->Value(2) != theZ) {
18     myCoords->SetValue(0, theX);
19     myCoords->SetValue(1, theY);
20     myCoords->SetValue(2, theZ);
21     owner()->data()->sendAttributeUpdated(this);
22   }
23 }
24
25 void GeomData_Point::setValue(const std::shared_ptr<GeomAPI_Pnt>& thePoint)
26 {
27   setValue(thePoint->x(), thePoint->y(), thePoint->z());
28 }
29
30 double GeomData_Point::x() const
31 {
32   return myCoords->Value(0);
33 }
34
35 double GeomData_Point::y() const
36 {
37   return myCoords->Value(1);
38 }
39
40 double GeomData_Point::z() const
41 {
42   return myCoords->Value(2);
43 }
44
45 std::shared_ptr<GeomAPI_Pnt> GeomData_Point::pnt()
46 {
47   std::shared_ptr<GeomAPI_Pnt> aResult(
48       new GeomAPI_Pnt(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
49   return aResult;
50 }
51
52 GeomData_Point::GeomData_Point(TDF_Label& theLabel)
53 {
54   myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
55   if (!myIsInitialized) {
56     // create attribute: not initialized by value yet, just zero
57     myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);
58   }
59 }