Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / Model / Model_ResultBody.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_ResultBody.cpp
4 // Created:     08 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include <Model_ResultBody.h>
8 #include <Model_BodyBuilder.h>
9 #include <ModelAPI_Tools.h>
10 #include <Config_PropManager.h>
11 #include <ModelAPI_Events.h>
12 // DEB
13 //#include <TCollection_AsciiString.hxx>
14 //#include <TDF_Tool.hxx>
15 //#define DEB_IMPORT 1
16
17 Model_ResultBody::Model_ResultBody()
18 {
19   myBuilder = new Model_BodyBuilder(this);
20   myWasConcealed = false;
21   myConnect = ConnectionNotComputed;
22 }
23
24 void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName,
25   std::string& theDefault)
26 {
27   theSection = "Visualization";
28   theName = "result_body_color";
29   theDefault = DEFAULT_COLOR();
30 }
31
32 bool Model_ResultBody::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
33 {
34   bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag);
35   if (aChanged) { // state is changed, so modifications are needed
36     myBuilder->evolutionToSelection(theFlag);
37   }
38   return aChanged;
39 }
40
41 bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
42 {
43   return myBuilder->isLatestEqual(theShape);
44 }
45
46 bool Model_ResultBody::isConcealed()
47 {
48   bool aResult = false;
49   if (ModelAPI_ResultBody::isConcealed()) {
50     aResult = true;
51   } else {
52     ResultPtr aThis = std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner());
53     if (aThis.get()) {
54       ResultCompSolidPtr aParent = ModelAPI_Tools::compSolidOwner(aThis);
55       if (aParent.get()) {
56         if (aParent->isConcealed())
57           aResult = true;
58       }
59     }
60   }
61   if (myWasConcealed != aResult) {
62     myWasConcealed = aResult;
63     if (aResult) { // hidden unit must be redisplayed (hidden)
64       ModelAPI_EventCreator::get()->sendDeleted(document(), this->groupName());
65       // redisplay for the viewer (it must be disappeared also)
66       static Events_ID EVENT_DISP =
67         Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
68       ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), EVENT_DISP);
69     } else { // was not concealed become concealed => delete event
70       static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
71       ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
72     }
73   }
74
75   return aResult;
76 }