Salome HOME
Update copyrights
[modules/shaper.git] / src / ModelAPI / ModelAPI_ResultBody.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_ResultBody.h"
21
22 #include <ModelAPI_BodyBuilder.h>
23 #include <Events_Loop.h>
24 #include <ModelAPI_Events.h>
25
26 ModelAPI_ResultBody::ModelAPI_ResultBody()
27   : myBuilder(0)
28 {
29   myConnect = ConnectionNotComputed;
30 }
31
32 ModelAPI_ResultBody::~ModelAPI_ResultBody()
33 {
34 }
35
36 std::string ModelAPI_ResultBody::groupName()
37 {
38   return group();
39 }
40
41 void ModelAPI_ResultBody::store(const GeomShapePtr& theShape,
42                                 const bool theIsStoreSameShapes)
43 {
44   myBuilder->store(theShape, theIsStoreSameShapes);
45   myConnect = ConnectionNotComputed;
46
47   static Events_Loop* aLoop = Events_Loop::loop();
48   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
49   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
50   aECreator->sendUpdated(data()->owner(), aRedispEvent);
51
52   updateSubs(theShape);
53 }
54
55 void ModelAPI_ResultBody::storeGenerated(const GeomShapePtr& theFromShape,
56                                          const GeomShapePtr& theToShape)
57 {
58   myBuilder->storeGenerated(theFromShape, theToShape);
59   myConnect = ConnectionNotComputed;
60
61   static Events_Loop* aLoop = Events_Loop::loop();
62   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
63   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
64   aECreator->sendUpdated(data()->owner(), aRedispEvent);
65
66   updateSubs(theToShape);
67 }
68
69 void ModelAPI_ResultBody::storeModified(const GeomShapePtr& theOldShape,
70                                         const GeomShapePtr& theNewShape,
71                                         const bool theIsCleanStored)
72 {
73   myBuilder->storeModified(theOldShape, theNewShape, theIsCleanStored);
74   myConnect = ConnectionNotComputed;
75
76   static Events_Loop* aLoop = Events_Loop::loop();
77   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
78   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
79   aECreator->sendUpdated(data()->owner(), aRedispEvent);
80
81   updateSubs(theNewShape);
82 }
83
84 GeomShapePtr ModelAPI_ResultBody::shape()
85 {
86   return myBuilder->shape();
87 }
88
89 void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape,
90                                     const GeomShapePtr& theNewShape,
91                                     const std::string& theName)
92 {
93   myBuilder->generated(theOldShape, theNewShape, theName);
94 }
95
96 void ModelAPI_ResultBody::modified(const GeomShapePtr& theOldShape,
97                                    const GeomShapePtr& theNewShape,
98                                    const std::string& theName)
99 {
100   myBuilder->modified(theOldShape, theNewShape, theName);
101 }
102
103
104 void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
105                                             const GeomShapePtr& theOldShape,
106                                             const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
107                                             const GeomShapePtr& theShapesToExclude)
108 {
109   myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude);
110 }
111
112 void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
113                                          const std::string& theName)
114 {
115   myBuilder->loadFirstLevel(theShape, theName);
116 }
117
118 // LCOV_EXCL_START
119 bool ModelAPI_ResultBody::isConnectedTopology()
120 {
121   if (myConnect == ConnectionNotComputed) {
122     myConnect = shape()->isConnectedTopology() ? IsConnected : IsNotConnected;
123   }
124   return myConnect == IsConnected;
125 }
126
127 void ModelAPI_ResultBody::setDisplayed(const bool theDisplay)
128 {
129   ModelAPI_Result::setDisplayed(theDisplay);
130   for (int i = 0; i < numberOfSubs(); i++)
131     subResult(i)->setDisplayed(theDisplay);
132 }
133 // LCOV_EXCL_STOP