]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Duplication and removing of part
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 18 Jul 2014 07:08:34 +0000 (11:08 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 18 Jul 2014 07:08:34 +0000 (11:08 +0400)
src/Model/Model_Document.cpp
src/PartSetPlugin/PartSetPlugin_Duplicate.cpp
src/PartSetPlugin/PartSetPlugin_Duplicate.h
src/PartSetPlugin/PartSetPlugin_Remove.cpp

index 1d693b73cadc8eda4f84d910fa707a9be16dc9a6..30bd5e293cceef5d1a5cdf336c346a7665d5c6b2 100644 (file)
@@ -456,7 +456,7 @@ ObjectPtr Model_Document::object(TDF_Label theLabel)
     for(; aRIter != aResults.cend(); aRIter++) {
       boost::shared_ptr<Model_Data> aResData = 
         boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
-      if (aResData->label().IsEqual(theLabel))
+      if (aResData->label().Father().IsEqual(theLabel))
         return *aRIter;
     }
   }
@@ -735,7 +735,7 @@ boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
 {
   boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theResult->data());
   if (aData) {
-    TDF_Label aFeatureLab = aData->label().Father().Father();
+    TDF_Label aFeatureLab = aData->label().Father().Father().Father();
     return feature(aFeatureLab);
   }
   return FeaturePtr();
index b02ae41f83810e9400f5293793bdf5d91be21861..28c8ce3defba9d875f50bba959f1f6502ce5edab 100644 (file)
@@ -35,5 +35,12 @@ void PartSetPlugin_Duplicate::initAttributes()
     boost::shared_ptr<ModelAPI_Document> aCopy = aPManager->copy(
       aSource->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value(),
       data()->name());
+    data()->refattr(ORIGIN_REF())->setObject(aSource);
   }
 }
+
+void PartSetPlugin_Duplicate::execute()
+{
+  if (data()->refattr(ORIGIN_REF())->object())
+    PartSetPlugin_Part::execute();
+}
index cecac050548943a950686bf2cc488f185a195986..57117a81330d1d33474189921a1fe0f8eb97c8fa 100644 (file)
@@ -25,6 +25,9 @@ public:
 
   /// Request for initialization of data model of the feature: adding all attributes
   PARTSETPLUGIN_EXPORT virtual void initAttributes();
+
+  /// doesn't call creation of new document, just does nothing if document was not copied
+  PARTSETPLUGIN_EXPORT virtual void execute();
 };
 
 #endif
index da0dd7ee15654c3047d3a29715bd7558676a27fd..d7dbf434cb51cb7dacee46447622e3b3d67fa572 100644 (file)
@@ -15,18 +15,17 @@ void PartSetPlugin_Remove::execute()
   boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
   boost::shared_ptr<ModelAPI_Document> aCurrent;
   boost::shared_ptr<PartSetPlugin_Part> a;
-  for(int a = aRoot->size(ModelAPI_Feature::group()) - 1; a >= 0; a--) {
-    FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(
-      aRoot->object(ModelAPI_Feature::group(), a));
-    if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
-      boost::shared_ptr<PartSetPlugin_Part> aPart = 
-        boost::static_pointer_cast<PartSetPlugin_Part>(aFeature);
-      if (aPart && aPart->firstResult() &&
-          aPart->firstResult()->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() == 
-            aPManager->currentDocument()) {
+  for(int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) {
+    ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(
+      aRoot->object(ModelAPI_ResultPart::group(), a));
+    if (aPart && aPart->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() == 
+        aPManager->currentDocument()) 
+    {
+      FeaturePtr aFeature = aRoot->feature(aPart);
+      if (aFeature) {
         // do remove
-        aPart->firstResult()->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value()->close();
-        aRoot->removeFeature(aPart);
+        aPart->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value()->close();
+        aRoot->removeFeature(aFeature);
       }
     }
   }