]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_ResultBody.cpp
Salome HOME
#2027 Sketcher Trim Feature: 1. preview/selected attributes in trim; 2. avoid includi...
[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_ResultCompSolid.h>
10 #include <ModelAPI_Tools.h>
11 #include <Config_PropManager.h>
12 #include <ModelAPI_Events.h>
13 // DEB
14 //#include <TCollection_AsciiString.hxx>
15 //#include <TDF_Tool.hxx>
16 //#define DEB_IMPORT 1
17
18 Model_ResultBody::Model_ResultBody()
19 {
20   myBuilder = new Model_BodyBuilder(this);
21   myWasConcealed = false;
22   myConnect = ConnectionNotComputed;
23 }
24
25 void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName,
26   std::string& theDefault)
27 {
28   theSection = "Visualization";
29   theName = "result_body_color";
30   theDefault = DEFAULT_COLOR();
31 }
32
33 bool Model_ResultBody::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
34 {
35   bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag);
36   if (aChanged) { // state is changed, so modifications are needed
37     myBuilder->evolutionToSelection(theFlag);
38   }
39   return aChanged;
40 }
41
42 bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
43 {
44   return myBuilder->isLatestEqual(theShape);
45 }
46
47 bool Model_ResultBody::isConcealed()
48 {
49   bool aResult = false;
50   if (ModelAPI_ResultBody::isConcealed()) {
51     aResult = true;
52   } else {
53     ResultPtr aThis = std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner());
54     if (aThis.get()) {
55       ResultCompSolidPtr aParent = ModelAPI_Tools::compSolidOwner(aThis);
56       if (aParent.get()) {
57         if (aParent->isConcealed())
58           aResult = true;
59       }
60     }
61   }
62   if (myWasConcealed != aResult) {
63     myWasConcealed = aResult;
64     if (aResult) { // hidden unit must be redisplayed (hidden)
65       ModelAPI_EventCreator::get()->sendDeleted(document(), this->groupName());
66       // redisplay for the viewer (it must be disappeared also)
67       static Events_ID EVENT_DISP =
68         Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
69       ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), EVENT_DISP);
70     } else { // was not concealed become concealed => delete event
71       static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
72       ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
73     }
74   }
75
76   return aResult;
77 }