Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / Model / Model_Document.cxx
index 075866f567121d1bcb07be0a8586af216cecb0d6..b7f195242b01c28297f02a454a682fc245861acf 100644 (file)
@@ -178,9 +178,9 @@ void Model_Document::addFeature(const std::shared_ptr<ModelAPI_Feature> theFeatu
   TDataStd_Comment::Set(anObjLab, theFeature->getKind().c_str());
 
   // event: model is updated
-  static Event_ID anEvent = Event_Loop::eventByName(EVENT_MODEL_UPDATED);
-  Event_Message anUpdateMsg(anEvent, this);
-  Event_Loop::loop()->send(anUpdateMsg);
+  static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_UPDATED);
+  ModelAPI_FeatureUpdatedMessage aMsg(theFeature);
+  Event_Loop::loop()->send(aMsg);
 }
 
 shared_ptr<ModelAPI_Feature> Model_Document::feature(TDF_Label& theLabel)
@@ -226,8 +226,8 @@ shared_ptr<ModelAPI_Feature> Model_Document::feature(const string& theGroupID, c
 {
   // TODO: optimize this method
   shared_ptr<ModelAPI_Iterator>  anIter = featuresIterator(theGroupID);
-  for(int a = 0; a != theIndex; anIter->next()) a++;
-  return anIter->current();
+  for(int a = 0; a != theIndex && anIter->more(); anIter->next()) a++;
+  return anIter->more() ? anIter->current() : shared_ptr<ModelAPI_Feature>();
 }
 
 const vector<string>& Model_Document::getGroups() const
@@ -278,3 +278,20 @@ void Model_Document::setUniqueName(
 
   theFeature->data()->setName(aName);
 }
+
+
+ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage(
+  shared_ptr<ModelAPI_Feature> theFeature)
+  : Event_Message(messageId(), 0), myFeature(theFeature)
+{}
+
+const Event_ID ModelAPI_FeatureUpdatedMessage::messageId()
+{
+  static Event_ID MY_ID = Event_Loop::eventByName("FeatureUpdated");
+  return MY_ID;
+}
+
+shared_ptr<ModelAPI_Feature> ModelAPI_FeatureUpdatedMessage::feature()
+{
+  return myFeature;
+}