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 <Model_ResultBody.h>
22 #include <Model_BodyBuilder.h>
23 #include <ModelAPI_ResultCompSolid.h>
24 #include <ModelAPI_Tools.h>
25 #include <Config_PropManager.h>
26 #include <ModelAPI_Events.h>
28 //#include <TCollection_AsciiString.hxx>
29 //#include <TDF_Tool.hxx>
30 //#define DEB_IMPORT 1
32 Model_ResultBody::Model_ResultBody()
34 myBuilder = new Model_BodyBuilder(this);
35 myWasConcealed = false;
36 myConnect = ConnectionNotComputed;
39 void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName,
40 std::string& theDefault)
42 theSection = "Visualization";
43 theName = "result_body_color";
44 theDefault = DEFAULT_COLOR();
47 bool Model_ResultBody::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
49 bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag);
50 if (aChanged) { // state is changed, so modifications are needed
51 myBuilder->evolutionToSelection(theFlag);
56 bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
58 return myBuilder->isLatestEqual(theShape);
61 bool Model_ResultBody::isConcealed()
64 if (ModelAPI_ResultBody::isConcealed()) {
67 ResultPtr aThis = std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner());
69 ResultCompSolidPtr aParent = ModelAPI_Tools::compSolidOwner(aThis);
71 if (aParent->isConcealed())
76 if (myWasConcealed != aResult) {
77 myWasConcealed = aResult;
78 if (aResult) { // hidden unit must be redisplayed (hidden)
79 ModelAPI_EventCreator::get()->sendDeleted(document(), this->groupName());
80 // redisplay for the viewer (it must be disappeared also)
81 static Events_ID EVENT_DISP =
82 Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
83 ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), EVENT_DISP);
84 } else { // was not concealed become concealed => delete event
85 static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
86 ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);