]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Document selection on activation of Parts
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 23 May 2014 09:05:45 +0000 (13:05 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 23 May 2014 09:05:45 +0000 (13:05 +0400)
src/XGUI/XGUI_Workshop.cpp

index 40a31159a878e85a88d36aa7a51e2f6a579a22cd..df5f2e75efb683f49cca5e8b0342b5db9f9a9759 100644 (file)
@@ -740,9 +740,15 @@ void XGUI_Workshop::changeCurrentDocument(FeaturePtr thePart)
 {
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   if (thePart) {
-    boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = thePart->data()->docRef("PartDocument");
-    if (aDocRef)
-      aMgr->setCurrentDocument(aDocRef->value());
+    DocumentPtr aFeaDoc;
+    if (thePart->data()) {
+      aFeaDoc = thePart->data()->docRef("PartDocument")->value();
+    } else {
+      ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(thePart);
+      aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
+    }
+    if (aFeaDoc)
+      aMgr->setCurrentDocument(aFeaDoc);
   } else {
     aMgr->setCurrentDocument(aMgr->rootDocument());
   }
@@ -801,7 +807,13 @@ void XGUI_Workshop::deleteFeatures(QFeatureList theList)
     aMgr->rootDocument()->startOperation();
     foreach (FeaturePtr aFeature, theList) {
       if (aFeature->getKind() == "Part") {
-        DocumentPtr aDoc = aFeature->data()->docRef("PartDocument")->value();
+        DocumentPtr aDoc;
+        if (aFeature->data()) {
+          aDoc = aFeature->data()->docRef("PartDocument")->value();
+        } else {
+          ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
+          aDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
+        }
         if (aDoc == aMgr->currentDocument()) {
           aDoc->close();
         }