Salome HOME
Implementation of mechanism of grouping of messages
authornds <natalia.donis@opencascade.com>
Thu, 22 May 2014 11:49:33 +0000 (15:49 +0400)
committernds <natalia.donis@opencascade.com>
Thu, 22 May 2014 11:49:33 +0000 (15:49 +0400)
Compillation correction

src/Model/Model_Events.h
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_OperationEditLine.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp

index 0e750f5a6f29dad229606a22b9eb4070e32bff07..4423238e05b83b63b38e7f1aecf55420dbf42773 100644 (file)
@@ -22,7 +22,7 @@ static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated";
 /// Event ID that data of feature is deleted (comes with Model_FeatureDeletedMessage)
 static const char * EVENT_FEATURE_DELETED = "FeatureDeleted";
 /// Event ID that data of feature is updated (comes with Model_FeaturesMovedMessage)
-static const char * EVENT_FEATURES_MOVED = "FeaturesMoved";
+static const char * EVENT_FEATURE_MOVED = "FeaturesMoved";
 
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
 class Model_FeatureUpdatedMessage : public Events_MessageGroup {
index 06af416d2126fd71e46db484992169a55ae4e3f5..355142a31449d3cf0eff57d1dad009b7f04e57f9 100644 (file)
@@ -37,24 +37,34 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
   if (aType == EVENT_FEATURE_UPDATED ||
       aType == EVENT_FEATURE_CREATED)
   {
-    const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
-    boost::shared_ptr<ModelAPI_Feature> aFeature = aUpdMsg->feature();
-    if (myModule->workshop()->displayer()->IsVisible(aFeature) ||
-        aType == EVENT_FEATURE_CREATED) {
-      myModule->visualizePreview(aFeature, true, false);
-      myModule->activateFeature(aFeature, true);
-      myModule->workshop()->displayer()->UpdateViewer();
+    const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>
+                                                                                    (theMessage);
+    std::set<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aUpdMsg->features();
+    std::set<boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = aFeatures.begin(),
+                                                                   aLast = aFeatures.end();
+    for (; anIt != aLast; anIt++) {
+      boost::shared_ptr<ModelAPI_Feature> aFeature = *anIt;
+      if (myModule->workshop()->displayer()->IsVisible(aFeature) ||
+          aType == EVENT_FEATURE_CREATED) {
+        myModule->visualizePreview(aFeature, true, false);
+        myModule->activateFeature(aFeature, true);
+      }
     }
+    myModule->workshop()->displayer()->UpdateViewer();
   }
   if (aType == EVENT_FEATURE_DELETED)
   {
     const Model_FeatureDeletedMessage* aDelMsg = dynamic_cast<const Model_FeatureDeletedMessage*>(theMessage);
     boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
 
-    std::string aGroup = aDelMsg->group();
-    if (aDelMsg->group().compare("Sketch") == 0) { // Update only Sketch group
-      myModule->workshop()->displayer()->EraseDeletedFeatures();
-      myModule->updateCurrentPreview(aGroup);
+    std::set<std::string> aGroups = aDelMsg->groups();
+    std::set<std::string>::const_iterator anIt = aGroups.begin(), aLast = aGroups.end();
+    for (; anIt != aLast; anIt++) {
+      std::string aGroup = *anIt;
+      if (aGroup.compare("Sketch") == 0) { // Update only Sketch group
+        myModule->workshop()->displayer()->EraseDeletedFeatures();
+        myModule->updateCurrentPreview(aGroup);
+      }
     }
   }
 }
index 7b37976e8a0f041f2f19f85a18b9aa9ec11437dd..c66f38f35281f25db8804a67c9c0fc19538ad566 100644 (file)
@@ -7,6 +7,7 @@
 #include <PartSet_OperationSketch.h>
 
 #include <ModuleBase_OperationDescription.h>
+#include <Model_Events.h>
 
 #include <XGUI_ViewerPrs.h>
 
@@ -171,17 +172,18 @@ void PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr<ModelAPI_Feature
 
 void PartSet_OperationEditLine::sendFeatures()
 {
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED);
+
   std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures;
   std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
   for (; anIt != aLast; anIt++) {
     boost::shared_ptr<ModelAPI_Feature> aFeature = (*anIt).feature();
     if (!aFeature || aFeature == feature())
       continue;
-  }
 
-  static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetEditEvent");
-  Model_FeaturesMovedMessage aMessage;
-  aMessage.setFeatures(aFeatures);
-  Events_Loop::loop()->send(aMessage);
+    Model_FeatureUpdatedMessage aMessage(aFeature, anEvent);
+    Events_Loop::loop()->send(aMessage);
+  }
+  Events_Loop::loop()->flush(anEvent);
 }
 
index 4a47879faab6da65aadfed7598a0fe0620468d31..ab6786fa77582acd003b0c1b4bd9493b2e1e9c0d 100644 (file)
@@ -61,7 +61,7 @@ SketchSolver_ConstraintManager::SketchSolver_ConstraintManager()
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
-  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURES_MOVED));
+  Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_MOVED));
 }
 
 SketchSolver_ConstraintManager::~SketchSolver_ConstraintManager()
@@ -118,7 +118,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
       }
     }
   }
-  else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURES_MOVED))
+  else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED))
   {
     // Solve the set of constraints
     resolveConstraints();