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::storeModified(const GeomShapePtr& theOldShape,
70 const GeomShapePtr& theNewShape,
71 const bool theIsCleanStored)
73 myBuilder->storeModified(theOldShape, theNewShape, theIsCleanStored);
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(theNewShape);
84 GeomShapePtr ModelAPI_ResultBody::shape()
86 return myBuilder->shape();
89 void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape,
90 const GeomShapePtr& theNewShape,
91 const std::string& theName)
93 myBuilder->generated(theOldShape, theNewShape, theName);
96 void ModelAPI_ResultBody::modified(const GeomShapePtr& theOldShape,
97 const GeomShapePtr& theNewShape,
98 const std::string& theName)
100 myBuilder->modified(theOldShape, theNewShape, theName);
104 void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
105 const GeomShapePtr& theOldShape,
106 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
107 const GeomShapePtr& theShapesToExclude)
109 myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude);
112 void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
113 const std::string& theName)
115 myBuilder->loadFirstLevel(theShape, theName);
119 bool ModelAPI_ResultBody::isConnectedTopology()
121 if (myConnect == ConnectionNotComputed) {
122 myConnect = shape()->isConnectedTopology() ? IsConnected : IsNotConnected;
124 return myConnect == IsConnected;
127 void ModelAPI_ResultBody::setDisplayed(const bool theDisplay)
129 ModelAPI_Result::setDisplayed(theDisplay);
130 for (int i = 0; i < numberOfSubs(); i++)
131 subResult(i)->setDisplayed(theDisplay);