Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / PartSet / PartSet_Listener.cpp
1 // File:        PartSet_Listener.h
2 // Created:     28 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #include <PartSet_Listener.h>
6
7 #include <PartSet_Module.h>
8
9 #include <XGUI_Displayer.h>
10
11 #include <Events_Loop.h>
12 #include <Model_Events.h>
13
14 #ifdef _DEBUG
15 #include <QDebug>
16 #endif
17
18 using namespace std;
19
20 PartSet_Listener::PartSet_Listener(PartSet_Module* theModule)
21 : myModule(theModule)
22 {
23   Events_Loop* aLoop = Events_Loop::loop();
24   Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED);
25   aLoop->registerListener(this, aFeatureUpdatedId);
26 }
27
28 PartSet_Listener::~PartSet_Listener()
29 {
30 }
31
32 //******************************************************
33 void PartSet_Listener::processEvent(const Events_Message* theMessage)
34 {
35   if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_UPDATED)
36   {
37     const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
38     boost::shared_ptr<ModelAPI_Feature> aFeature = aUpdMsg->feature();
39     if (myModule->workshop()->displayer()->IsVisible(aFeature))
40       myModule->visualizePreview(aFeature, true);
41   }
42 }