1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_Result.cpp
4 // Created: 07 Jul 2014
5 // Author: Mikhail PONIKAROV
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>
13 ModelAPI_Result::~ModelAPI_Result()
17 bool ModelAPI_Result::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
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
32 static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
33 aECreator->sendUpdated(theThis, EVENT_DISP/*, false*/); // flush is in setCurrentFeature
39 bool ModelAPI_Result::isDisabled() const
44 void ModelAPI_Result::setIsConcealed(const bool theValue)
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
54 std::shared_ptr<GeomAPI_Shape> ModelAPI_Result::shape()
56 return std::shared_ptr<GeomAPI_Shape>();
59 void ModelAPI_Result::attributeChanged(const std::string& theID)
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);