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 email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
20 #include <Model_ResultBody.h>
21 #include <Model_BodyBuilder.h>
22 #include <ModelAPI_ResultCompSolid.h>
23 #include <ModelAPI_Tools.h>
24 #include <Config_PropManager.h>
25 #include <ModelAPI_Events.h>
27 //#include <TCollection_AsciiString.hxx>
28 //#include <TDF_Tool.hxx>
29 //#define DEB_IMPORT 1
31 Model_ResultBody::Model_ResultBody()
33 myBuilder = new Model_BodyBuilder(this);
34 myWasConcealed = false;
35 myConnect = ConnectionNotComputed;
38 void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName,
39 std::string& theDefault)
41 theSection = "Visualization";
42 theName = "result_body_color";
43 theDefault = DEFAULT_COLOR();
46 bool Model_ResultBody::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
48 bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag);
49 if (aChanged) { // state is changed, so modifications are needed
50 myBuilder->evolutionToSelection(theFlag);
55 bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
57 return myBuilder->isLatestEqual(theShape);
60 bool Model_ResultBody::isConcealed()
63 if (ModelAPI_ResultBody::isConcealed()) {
66 ResultPtr aThis = std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner());
68 ResultCompSolidPtr aParent = ModelAPI_Tools::compSolidOwner(aThis);
70 if (aParent->isConcealed())
75 if (myWasConcealed != aResult) {
76 myWasConcealed = aResult;
77 if (aResult) { // hidden unit must be redisplayed (hidden)
78 ModelAPI_EventCreator::get()->sendDeleted(document(), this->groupName());
79 // redisplay for the viewer (it must be disappeared also)
80 static Events_ID EVENT_DISP =
81 Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
82 ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), EVENT_DISP);
83 } else { // was not concealed become concealed => delete event
84 static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
85 ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);