Salome HOME
Merge branch 'Dev_1.1.1' of newgeom:newgeom into Dev_1.2.0
[modules/shaper.git] / src / ModelAPI / ModelAPI_Result.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_Result.cpp
4 // Created:     07 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include "ModelAPI_Result.h"
8 #include <ModelAPI_Events.h>
9 #include <ModelAPI_Data.h>
10 #include <ModelAPI_Attribute.h>
11 #include <Events_Loop.h>
12
13 ModelAPI_Result::~ModelAPI_Result()
14 {
15 }
16
17 bool ModelAPI_Result::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
18 {
19   if (myIsDisabled != theFlag) {
20     myIsDisabled = theFlag;
21     // this must be before "updated" message send to have history updated for OB update
22     document()->updateHistory(groupName()); // to update the history cash data in the document
23     // generate related events
24     static Events_Loop* aLoop = Events_Loop::loop();
25     static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
26     if (myIsDisabled) { // disabled result looks like removed
27       aECreator->sendDeleted(document(), groupName());
28     } else { // un-disabled equals to created
29       static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
30       aECreator->sendUpdated(theThis, anEvent /*, false*/); // flush is in setCurrentFeature
31     }
32     static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
33     aECreator->sendUpdated(theThis, EVENT_DISP/*, false*/); // flush is in setCurrentFeature
34     return true;
35   }
36   return false;
37 }
38
39 bool ModelAPI_Result::isDisabled() const
40 {
41   return myIsDisabled;
42 }
43
44 void ModelAPI_Result::setIsConcealed(const bool theValue)
45 {
46   if (myIsConcealed != theValue) {
47     myIsConcealed = theValue;
48     if (document().get()) // can be on creation of result
49       document()->updateHistory(groupName()); // to update the history cash data in the document
50   }
51 }
52
53
54 std::shared_ptr<GeomAPI_Shape> ModelAPI_Result::shape()
55 {
56   return std::shared_ptr<GeomAPI_Shape>();
57 }
58
59 void ModelAPI_Result::attributeChanged(const std::string& theID)
60 {
61   static Events_Loop* aLoop = Events_Loop::loop();
62   static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
63   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
64   aECreator->sendUpdated(data()->attribute(theID)->owner(), EVENT_DISP);
65 }