1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "ModelAPI_ResultBody.h"
23 #include <ModelAPI_BodyBuilder.h>
24 #include <Events_Loop.h>
25 #include <ModelAPI_Events.h>
27 ModelAPI_ResultBody::ModelAPI_ResultBody()
30 myConnect = ConnectionNotComputed;
33 ModelAPI_ResultBody::~ModelAPI_ResultBody()
37 std::string ModelAPI_ResultBody::groupName()
42 void ModelAPI_ResultBody::store(const GeomShapePtr& theShape,
43 const bool theIsStoreSameShapes)
45 myBuilder->store(theShape, theIsStoreSameShapes);
46 myConnect = ConnectionNotComputed;
48 static Events_Loop* aLoop = Events_Loop::loop();
49 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
50 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
51 aECreator->sendUpdated(data()->owner(), aRedispEvent);
56 void ModelAPI_ResultBody::storeGenerated(const GeomShapePtr& theFromShape,
57 const GeomShapePtr& theToShape)
59 myBuilder->storeGenerated(theFromShape, theToShape);
60 myConnect = ConnectionNotComputed;
62 static Events_Loop* aLoop = Events_Loop::loop();
63 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
64 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
65 aECreator->sendUpdated(data()->owner(), aRedispEvent);
67 updateSubs(theToShape);
70 void ModelAPI_ResultBody::storeGenerated(
71 const std::list<GeomShapePtr>& theFromShapes, const GeomShapePtr& theToShape,
72 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
74 myBuilder->storeGenerated(theFromShapes, theToShape, theMakeShape);
75 myConnect = ConnectionNotComputed;
77 static Events_Loop* aLoop = Events_Loop::loop();
78 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
79 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
80 aECreator->sendUpdated(data()->owner(), aRedispEvent);
82 updateSubs(theToShape, theFromShapes, theMakeShape, true);
85 void ModelAPI_ResultBody::storeModified(const GeomShapePtr& theOldShape,
86 const GeomShapePtr& theNewShape,
87 const bool theIsCleanStored)
89 myBuilder->storeModified(theOldShape, theNewShape, theIsCleanStored);
90 myConnect = ConnectionNotComputed;
92 static Events_Loop* aLoop = Events_Loop::loop();
93 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
94 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
95 aECreator->sendUpdated(data()->owner(), aRedispEvent);
97 updateSubs(theNewShape);
100 void ModelAPI_ResultBody::storeModified(
101 const std::list<GeomShapePtr>& theOldShapes, const GeomShapePtr& theNewShape,
102 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
104 myBuilder->storeModified(theOldShapes, theNewShape, theMakeShape);
105 myConnect = ConnectionNotComputed;
107 static Events_Loop* aLoop = Events_Loop::loop();
108 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
109 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
110 aECreator->sendUpdated(data()->owner(), aRedispEvent);
112 updateSubs(theNewShape, theOldShapes, theMakeShape, false);
115 GeomShapePtr ModelAPI_ResultBody::shape()
117 return myBuilder->shape();
120 void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape,
121 const GeomShapePtr& theNewShape,
122 const std::string& theName)
124 myBuilder->generated(theOldShape, theNewShape, theName);
127 void ModelAPI_ResultBody::modified(const GeomShapePtr& theOldShape,
128 const GeomShapePtr& theNewShape,
129 const std::string& theName)
131 myBuilder->modified(theOldShape, theNewShape, theName);
135 void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
136 const GeomShapePtr& theOldShape,
137 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
138 const GeomShapePtr& theShapesToExclude)
140 myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude);
143 void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
144 const std::string& theName)
146 myBuilder->loadFirstLevel(theShape, theName);
150 bool ModelAPI_ResultBody::isConnectedTopology()
152 if (myConnect == ConnectionNotComputed) {
153 myConnect = shape()->isConnectedTopology() ? IsConnected : IsNotConnected;
155 return myConnect == IsConnected;
158 void ModelAPI_ResultBody::setDisplayed(const bool theDisplay)
160 ModelAPI_Result::setDisplayed(theDisplay);
161 for (int i = 0; i < numberOfSubs(); i++)
162 subResult(i)->setDisplayed(theDisplay);