#include <PartSet_Listener.h>
#include <PartSet_Module.h>
+#include <PartSet_OperationSketchBase.h>
#include <XGUI_Displayer.h>
#include <XGUI_Workshop.h>
+#include <XGUI_OperationMgr.h>
+
+#include <ModuleBase_Operation.h>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
: myModule(theModule)
{
Events_Loop* aLoop = Events_Loop::loop();
- aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_UPDATED));
+ //aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
}
//******************************************************
void PartSet_Listener::processEvent(const Events_Message* theMessage)
{
+ ModuleBase_Operation* anOperation = myModule->workshop()->operationMgr()->currentOperation();
+ PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+ if (!aSketchOp)
+ return;
+
+ XGUI_Displayer* aDisplayer = myModule->workshop()->displayer();
QString aType = QString(theMessage->eventID().eventText());
- if (aType == EVENT_OBJECT_UPDATED ||
- aType == EVENT_OBJECT_CREATED)
- {
+ if (aType == EVENT_OBJECT_CREATED) {
const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
std::set<ObjectPtr > aFeatures = aUpdMsg->objects();
std::set<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
for (; anIt != aLast; anIt++) {
- ObjectPtr aObject = *anIt;
- FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
- if (aFeature) {
- if (myModule->workshop()->displayer()->isVisible(aFeature->firstResult()) ||
- aType == EVENT_OBJECT_CREATED) {
- myModule->activateFeature(aFeature, true);
- // TODO myModule->visualizePreview(aFeature, true, false);
- }
- }
+ aDisplayer->deactivate(*anIt, false);
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
+ if (aFeature)
+ myModule->activateFeature(aFeature, false);
}
- myModule->workshop()->displayer()->updateViewer();
- }
- if (aType == EVENT_OBJECT_DELETED) {
+
+ } else if (aType == EVENT_OBJECT_DELETED) {
const ModelAPI_ObjectDeletedMessage* aDelMsg =
dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
aDisplayer->activateInLocalContext((*aIt), aModes, false);
}
}
- FeaturePtr aFeature = aPrevOp->feature();
+ }
+/* FeaturePtr aFeature = aPrevOp->feature();
if (aFeature) {
std::list<ResultPtr> aResList = aFeature->results();
std::list<ResultPtr>::iterator aIt;
aDisplayer->deactivate((*aIt), false);
}
}
- }
+ }*/
ModelAPI_EventCreator::get()->sendUpdated(theFeature,
Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
// }
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
- isUpdateViewer);
+ std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
+ aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
}
}