Salome HOME
Merge branch 'V9_2_2_BR'
[modules/shaper.git] / src / ModelAPI / ModelAPI_Object.cpp
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "ModelAPI_Object.h"
21 #include "ModelAPI_Document.h"
22 #include "ModelAPI_Data.h"
23 #include "ModelAPI_Events.h"
24 #include <Events_Loop.h>
25
26 bool ModelAPI_Object::isInHistory()
27 {
28   if (myData->isValid()) {
29     return myData->isInHistory();
30   }
31   return true; // default value
32 }
33
34 void ModelAPI_Object::setInHistory(
35   const std::shared_ptr<ModelAPI_Object> theObject, const bool theFlag)
36 {
37   if (isInHistory() != theFlag) {
38     if (myData->isValid()) {
39       myData->setIsInHistory(theFlag);
40     }
41     myDoc->updateHistory(theObject);
42   }
43 }
44
45 std::shared_ptr<ModelAPI_Data> ModelAPI_Object::data() const
46 {
47   return myData;
48 }
49
50 bool ModelAPI_Object::isSame(const std::shared_ptr<ModelAPI_Object>& theObject)
51 {
52   return theObject.get() == this;
53 }
54
55 std::shared_ptr<ModelAPI_Document> ModelAPI_Object::document() const
56 {
57   return myDoc;
58 }
59
60 void ModelAPI_Object::attributeChanged(const std::string& theID)
61 {
62 }
63
64 ModelAPI_Object::ModelAPI_Object()
65 {
66 }
67
68 ModelAPI_Object::~ModelAPI_Object()
69 {
70 }
71
72 void ModelAPI_Object::setData(std::shared_ptr<ModelAPI_Data> theData)
73 {
74   myData = theData;
75 }
76
77 void ModelAPI_Object::setDoc(std::shared_ptr<ModelAPI_Document> theDoc)
78 {
79   myDoc = theDoc;
80 }
81
82 void ModelAPI_Object::erase()
83 {
84   if (myData->isValid() && myData != myData->invalidPtr())
85     myData->erase();
86   setData(myData->invalidPtr());
87 }
88
89 bool ModelAPI_Object::isDisplayed()
90 {
91   return myData->isDisplayed();
92 }
93
94 void ModelAPI_Object::setDisplayed(const bool theDisplay)
95 {
96   myData->setDisplayed(theDisplay);
97 }