]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Implementation of Open/Save and Break-Link functionality on SHAPER shapes
authormpv <mpv@opencascade.com>
Thu, 26 Dec 2019 06:35:08 +0000 (09:35 +0300)
committermpv <mpv@opencascade.com>
Thu, 26 Dec 2019 06:35:08 +0000 (09:35 +0300)
src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py
src/SHAPERGUI/SHAPERGUI_DataModel.cpp

index a18f292036a0fccb37b595c832554c78d61f3726..a6b8d91e0a8d8c3549cf6195ae5e7f3c10ce3700 100644 (file)
@@ -96,35 +96,33 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature):
             aSShape.SetShapeByStream(aRes.shape().getShapeStream(False))
             if not aSShape.GetSO(): # publish in case it is a new shape
               anEngine.AddInStudy(aSShape, aRes.data().name(), None)
+            else: # restore a red reference if it was deleted
+              aRes, aSO2 = aSShape.GetSO().FindSubObject(1)
+              if aRes:
+                aRes, aRef = aSO2.ReferencedObject()
+                if not aRes:
+                  aBuilder = SHAPERSTUDY_utils.getStudy().NewBuilder()
+                  aBuilder.Addreference(aSO2, aSShape.GetSO())
+
             allProcessed.append(aSSEntry)
 
         # process all SHAPER-STUDY shapes to find dead
-        deadNames = []
         aSOIter = SHAPERSTUDY_utils.getStudy().NewChildIterator(aComponent)
         while aSOIter.More():
           aSO = aSOIter.Value()
           anIOR = aSO.GetIOR()
-          anObj = salome.orb.string_to_object(anIOR)
-          if isinstance(anObj, SHAPERSTUDY_ORB._objref_SHAPER_Object):
-            anEntry = anObj.GetEntry()
-            if len(anEntry) == 0:
-              continue;
-            elif anEntry.startswith("dead"):
-              deadNames.append(anObj.GetEntry())
-            elif anEntry not in allProcessed: # found a removed shape: make it dead
-              anIndex = 1
-              aName = "dead" + str(anIndex) + "_" + anEntry
-              while aName in deadNames:
-                anIndex = anIndex + 1
-                aName = "dead" + str(anIndex) + "_" + anEntry
-              anObj.SetEntry(aName)
-              aSO.SetAttrString("AttributeName", aSO.GetName() + " (" + str(anIndex) + ")")
-              # remove the reference - red node
-              aSOIter2 = SHAPERSTUDY_utils.getStudy().NewChildIterator(aSO)
-              while aSOIter2.More():
-                aSO2 = aSOIter2.Value()
-                if aSO2.ReferencedObject()[0] and aSO2.ReferencedObject()[1].GetID() == aSO.GetID():
-                  aBuilder = SHAPERSTUDY_utils.getStudy().NewBuilder()
-                  aBuilder.RemoveReference(aSO2)
-                aSOIter2.Next()
+          if len(anIOR):
+            anObj = salome.orb.string_to_object(anIOR)
+            if isinstance(anObj, SHAPERSTUDY_ORB._objref_SHAPER_Object):
+              anEntry = anObj.GetEntry()
+              if len(anEntry) == 0:
+                continue;
+              elif anEntry not in allProcessed: # found a removed shape: make it dead for the moment
+                # remove the reference - red node
+                aRes, aSO2 = aSO.FindSubObject(1)
+                if aRes:
+                  aRes, aRef = aSO2.ReferencedObject()
+                  if aRes:
+                    aBuilder = SHAPERSTUDY_utils.getStudy().NewBuilder()
+                    aBuilder.RemoveReference(aSO2)
           aSOIter.Next()
index a156bc8304ddb9469f6e1f0051379ade4051d2a4..a84de59dfca76318575047d820a3e9538cf3177f 100644 (file)
@@ -85,7 +85,7 @@ bool SHAPERGUI_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStr
 
 bool SHAPERGUI_DataModel::save(QStringList& theFiles)
 {
-  // Pyblish to study before saving of the data model
+  // Publish to study before saving of the data model
   myModule->publishToStudy();
 
   LightApp_DataModel::save( theFiles );