1 // File: PartSet_Listener.h
2 // Created: 28 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #include <PartSet_Listener.h>
7 #include <PartSet_Module.h>
9 #include <XGUI_Displayer.h>
11 #include <Events_Loop.h>
12 #include <Model_Events.h>
20 PartSet_Listener::PartSet_Listener(PartSet_Module* theModule)
23 Events_Loop* aLoop = Events_Loop::loop();
24 aLoop->registerListener(this, aLoop->eventByName(EVENT_FEATURE_UPDATED));
25 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
26 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
29 PartSet_Listener::~PartSet_Listener()
33 //******************************************************
34 void PartSet_Listener::processEvent(const Events_Message* theMessage)
36 QString aType = QString(theMessage->eventID().eventText());
37 if (aType == EVENT_FEATURE_UPDATED ||
38 aType == EVENT_FEATURE_CREATED)
40 const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
41 boost::shared_ptr<ModelAPI_Feature> aFeature = aUpdMsg->feature();
42 if (myModule->workshop()->displayer()->IsVisible(aFeature) ||
43 aType == EVENT_FEATURE_CREATED)
44 myModule->visualizePreview(aFeature, true);
46 if (aType == EVENT_FEATURE_DELETED)
48 const Model_FeatureDeletedMessage* aDelMsg = dynamic_cast<const Model_FeatureDeletedMessage*>(theMessage);
49 boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
51 std::string aGroup = aDelMsg->group();
52 if (aDelMsg->group().compare("Sketch") == 0) { // Update only Sketch group
53 //myModule->workshop()->displayer()->EraseDeletedFeatures();
54 myModule->updateCurrentPreview(aGroup);