Salome HOME
Part debug
authormpv <mikhail.ponikarov@opencascade.com>
Tue, 15 Jul 2014 12:00:26 +0000 (16:00 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Tue, 15 Jul 2014 12:00:26 +0000 (16:00 +0400)
src/Model/Model_Document.cpp
src/ModelAPI/ModelAPI_Document.h
src/PartSetPlugin/PartSetPlugin_Part.cpp

index 091e70c63c05fb18aeeae78ed5168f0537f52ebb..79406ba8cd6033bfa359da0c7c8c30aee3d01ddc 100644 (file)
@@ -358,13 +358,13 @@ FeaturePtr Model_Document::addFeature(std::string theID)
       initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
       // keep the feature ID to restore document later correctly
       TDataStd_Comment::Set(aFeatureLab, aFeature->getKind().c_str());
+      setUniqueName(aFeature);
       myObjs[ModelAPI_Feature::group()].push_back(aFeature);
       // store feature in the history of features array
       if (aFeature->isInHistory()) {
         AddToRefArray(aFeaturesLab, aFeatureLab);
       }
     }
-    setUniqueName(aFeature);
     if (!aFeature->isAction()) {// do not add action to the data model
       // event: feature is added
       static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
@@ -698,7 +698,11 @@ void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData
   theResult->setDoc(aThis);
   initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
     label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex);
-  theResult->data()->setName(theFeatureData->name());
+  if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name
+    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+    ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
+    theResult->data()->setName(theFeatureData->name());
+  }
 }
 
 boost::shared_ptr<ModelAPI_ResultConstruction> Model_Document::createConstruction(
index 0a1a7f5b09c0f839d55fccb88ee08021977554c0..2aebf34d9d4ad326283d83eeddff0179b49b598d 100644 (file)
@@ -97,10 +97,6 @@ public:
   virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
     const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
 
-  //! Allows to store the result in the data tree of the document (attaches 'data' of result to tree)
-  virtual void storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData,
-    boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex = 0) = 0;
-
   //! Returns a feature by result (owner of result)
   virtual boost::shared_ptr<ModelAPI_Feature> feature(
     const boost::shared_ptr<ModelAPI_Result>& theResult) = 0;
index 4c0d0dc110f08f808fcc743a0e42c35099028914..362841fb7fa28d31b0b03b481f716c6a042b1d1b 100644 (file)
@@ -31,9 +31,7 @@ void PartSetPlugin_Part::execute()
   // create a result only once
   if (results().empty()) {
     boost::shared_ptr<ModelAPI_ResultPart> aResult = document()->createPart(data());
-    document()->storeResult(data(), aResult);
-    if (aResult->data()->name().empty())
-      aResult->data()->setName(data()->name());
+    setResult(aResult);
   }
 }