1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "ModelAPI_ResultBody.h"
22 #include <ModelAPI_BodyBuilder.h>
23 #include <Events_Loop.h>
24 #include <ModelAPI_Events.h>
26 ModelAPI_ResultBody::ModelAPI_ResultBody()
29 myConnect = ConnectionNotComputed;
32 ModelAPI_ResultBody::~ModelAPI_ResultBody()
36 std::string ModelAPI_ResultBody::groupName()
41 void ModelAPI_ResultBody::store(const GeomShapePtr& theShape,
42 const bool theIsStoreSameShapes)
44 myBuilder->store(theShape, theIsStoreSameShapes);
45 myConnect = ConnectionNotComputed;
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);
55 void ModelAPI_ResultBody::storeGenerated(const GeomShapePtr& theFromShape,
56 const GeomShapePtr& theToShape)
58 myBuilder->storeGenerated(theFromShape, theToShape);
59 myConnect = ConnectionNotComputed;
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);
66 updateSubs(theToShape);
69 void ModelAPI_ResultBody::storeGenerated(
70 const std::list<GeomShapePtr>& theFromShapes, const GeomShapePtr& theToShape,
71 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
73 myBuilder->storeGenerated(theFromShapes, theToShape, theMakeShape);
74 myConnect = ConnectionNotComputed;
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);
81 updateSubs(theToShape, theFromShapes, theMakeShape, true);
84 void ModelAPI_ResultBody::storeModified(const GeomShapePtr& theOldShape,
85 const GeomShapePtr& theNewShape,
86 const bool theIsCleanStored)
88 myBuilder->storeModified(theOldShape, theNewShape, theIsCleanStored);
89 myConnect = ConnectionNotComputed;
91 static Events_Loop* aLoop = Events_Loop::loop();
92 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
93 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
94 aECreator->sendUpdated(data()->owner(), aRedispEvent);
96 updateSubs(theNewShape);
99 void ModelAPI_ResultBody::storeModified(
100 const std::list<GeomShapePtr>& theOldShapes, const GeomShapePtr& theNewShape,
101 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
103 myBuilder->storeModified(theOldShapes, theNewShape, theMakeShape);
104 myConnect = ConnectionNotComputed;
106 static Events_Loop* aLoop = Events_Loop::loop();
107 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
108 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
109 aECreator->sendUpdated(data()->owner(), aRedispEvent);
111 updateSubs(theNewShape, theOldShapes, theMakeShape, false);
114 GeomShapePtr ModelAPI_ResultBody::shape()
116 return myBuilder->shape();
119 void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape,
120 const GeomShapePtr& theNewShape,
121 const std::string& theName)
123 myBuilder->generated(theOldShape, theNewShape, theName);
126 void ModelAPI_ResultBody::modified(const GeomShapePtr& theOldShape,
127 const GeomShapePtr& theNewShape,
128 const std::string& theName)
130 myBuilder->modified(theOldShape, theNewShape, theName);
134 void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
135 const GeomShapePtr& theOldShape,
136 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
137 const GeomShapePtr& theShapesToExclude)
139 myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude);
142 void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
143 const std::string& theName)
145 myBuilder->loadFirstLevel(theShape, theName);
149 bool ModelAPI_ResultBody::isConnectedTopology()
151 if (myConnect == ConnectionNotComputed) {
152 myConnect = shape()->isConnectedTopology() ? IsConnected : IsNotConnected;
154 return myConnect == IsConnected;
157 void ModelAPI_ResultBody::setDisplayed(const bool theDisplay)
159 ModelAPI_Result::setDisplayed(theDisplay);
160 for (int i = 0; i < numberOfSubs(); i++)
161 subResult(i)->setDisplayed(theDisplay);