Salome HOME
Merge branch 'Pre_2.8.0_development'
[modules/shaper.git] / src / ModelAPI / ModelAPI_Object.cpp
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include "ModelAPI_Object.h"
22 #include "ModelAPI_Document.h"
23 #include "ModelAPI_Data.h"
24 #include "ModelAPI_Events.h"
25 #include <Events_Loop.h>
26
27 bool ModelAPI_Object::isInHistory()
28 {
29   if (myData->isValid()) {
30     return myData->isInHistory();
31   }
32   return true; // default value
33 }
34
35 void ModelAPI_Object::setInHistory(
36   const std::shared_ptr<ModelAPI_Object> theObject, const bool theFlag)
37 {
38   if (isInHistory() != theFlag) {
39     if (myData->isValid()) {
40       myData->setIsInHistory(theFlag);
41     }
42     myDoc->updateHistory(theObject);
43   }
44 }
45
46 std::shared_ptr<ModelAPI_Data> ModelAPI_Object::data() const
47 {
48   return myData;
49 }
50
51 bool ModelAPI_Object::isSame(const std::shared_ptr<ModelAPI_Object>& theObject)
52 {
53   return theObject.get() == this;
54 }
55
56 std::shared_ptr<ModelAPI_Document> ModelAPI_Object::document() const
57 {
58   return myDoc;
59 }
60
61 void ModelAPI_Object::attributeChanged(const std::string& theID)
62 {
63 }
64
65 ModelAPI_Object::ModelAPI_Object()
66 {
67 }
68
69 ModelAPI_Object::~ModelAPI_Object()
70 {
71 }
72
73 void ModelAPI_Object::setData(std::shared_ptr<ModelAPI_Data> theData)
74 {
75   myData = theData;
76 }
77
78 void ModelAPI_Object::setDoc(std::shared_ptr<ModelAPI_Document> theDoc)
79 {
80   myDoc = theDoc;
81 }
82
83 void ModelAPI_Object::erase()
84 {
85   if (myData->isValid() && myData != myData->invalidPtr())
86     myData->erase();
87   setData(myData->invalidPtr());
88 }
89
90 bool ModelAPI_Object::isDisplayed()
91 {
92   return myData->isDisplayed();
93 }
94
95 void ModelAPI_Object::setDisplayed(const bool theDisplay)
96 {
97   myData->setDisplayed(theDisplay);
98 }