Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / Model / Model_Document.cpp
index c022362e82d372f38824e1f6b4d6a26724fad4ee..304bef421dd7a3fca954e164ea484e4607b50c4e 100644 (file)
@@ -9,7 +9,7 @@
 #include <Model_PluginManager.h>
 #include <Model_Iterator.h>
 #include <Model_Events.h>
-#include <Event_Loop.h>
+#include <Events_Loop.h>
 
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_Comment.hxx>
@@ -223,10 +223,11 @@ void Model_Document::addFeature(const boost::shared_ptr<ModelAPI_Feature> theFea
   TDF_Label aGroupLab = groupLabel(aGroup);
   TDF_Label anObjLab = aGroupLab.NewChild();
   boost::shared_ptr<Model_Data> aData(new Model_Data);
+  aData->setFeature(theFeature);
   aData->setLabel(anObjLab);
   boost::shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
-  aData->setDocument(aThis);
   theFeature->setData(aData);
+  theFeature->setDoc(aThis);
   setUniqueName(theFeature);
   theFeature->initAttributes();
   // keep the feature ID to restore document later correctly
@@ -236,9 +237,9 @@ void Model_Document::addFeature(const boost::shared_ptr<ModelAPI_Feature> theFea
   myFeatures[aGroup].push_back(theFeature);
 
   // event: feature is added
-  static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
-  ModelAPI_FeatureUpdatedMessage aMsg(aThis, theFeature, anEvent);
-  Event_Loop::loop()->send(aMsg);
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
+  Model_FeatureUpdatedMessage aMsg(theFeature, anEvent);
+  Events_Loop::loop()->send(aMsg);
 }
 
 boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(TDF_Label& theLabel)
@@ -256,8 +257,8 @@ boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(TDF_Label& theLabel)
 
 int Model_Document::featureIndex(boost::shared_ptr<ModelAPI_Feature> theFeature)
 {
-  if (theFeature->data()->document().get() != this) {
-    return theFeature->data()->document()->featureIndex(theFeature);
+  if (theFeature->document().get() != this) {
+    return theFeature->document()->featureIndex(theFeature);
   }
   boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
   Handle(TDataStd_Integer) aFeatureIndex;
@@ -370,8 +371,8 @@ void Model_Document::synchronizeFeatures()
     myGroups.erase(aGroupName);
     aGroupNamesIter = myGroupsNames.erase(aGroupNamesIter);
     // say that features were deleted from group
-    ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName);
-    Event_Loop::loop()->send(aMsg);
+    Model_FeatureDeletedMessage aMsg(aThis, aGroupName);
+    Events_Loop::loop()->send(aMsg);
   }
   // create new groups basing on the following data model update
   for(; aGroupsIter.More(); aGroupsIter.Next()) {
@@ -407,8 +408,8 @@ void Model_Document::synchronizeFeatures()
       if (aDSTag > aFeatureTag) { // feature is removed
         aFIter = aFeatures.erase(aFIter);
         // event: model is updated
-        ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName);
-        Event_Loop::loop()->send(aMsg);
+        Model_FeatureDeletedMessage aMsg(aThis, aGroupName);
+        Events_Loop::loop()->send(aMsg);
       } else if (aDSTag < aFeatureTag) { // a new feature is inserted
         // create a feature
         boost::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(
@@ -418,13 +419,14 @@ void Model_Document::synchronizeFeatures()
         boost::shared_ptr<Model_Data> aData(new Model_Data);
         TDF_Label aLab = aFLabIter.Value()->Label();
         aData->setLabel(aLab);
-        aData->setDocument(Model_Application::getApplication()->getDocument(myID));
+        aData->setFeature(aFeature);
+        aFeature->setDoc(aThis);
         aFeature->setData(aData);
         aFeature->initAttributes();
         // event: model is updated
-        static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
-        ModelAPI_FeatureUpdatedMessage aMsg(aThis, aFeature, anEvent);
-        Event_Loop::loop()->send(aMsg);
+        static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
+        Model_FeatureUpdatedMessage aMsg(aFeature, anEvent);
+        Events_Loop::loop()->send(aMsg);
 
         if (aFIter == aFeatures.end()) {
           aFeatures.push_back(aFeature);