X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConnectorPlugin%2FConnectorPlugin_PublishToStudyFeature.py;h=15efb9750ecc4a3b206c338a1bae40f104588ba4;hb=a13f87935d2a6f52f942790b6abc874f1016c9fc;hp=509b9a31b2569aacbafaf8bc1dcf2d94f28dcaef;hpb=645e2cb70c0e40290725f28fdc5fec8a93338d28;p=modules%2Fshaper.git diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py index 509b9a31b..15efb9750 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -86,11 +86,19 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): EventsAPI.Events_InfoMessage("PublishToStudy", "For publish to SHAPER-STUDY some Part is not activated", self).send() break aPartFeatureId = aPartSet.feature(aPartRes).data().featureId() + # Collects all features of exported results to find results of the same features and extend id. + # Map from feature index to index of result. If index is zero (initial), no surrfix to entry is added. + aFeaturesIndices = {} for aResId in range(aPartDoc.size(model.ModelAPI_ResultBody_group())): aResObject = aPartDoc.object(model.ModelAPI_ResultBody_group(), aResId) aRes = model.objectToResult(aResObject) - aResFeatureId = aPartDoc.feature(aRes).data().featureId() - aSSEntry = str(aPartFeatureId) + ":" + str(aResFeatureId) + aResFeatureId = str(aPartDoc.feature(aRes).data().featureId()) + if aResFeatureId in aFeaturesIndices: + aFeaturesIndices[aResFeatureId] += 1 + aResFeatureId += ":" + str(aFeaturesIndices[aResFeatureId]) + else: + aFeaturesIndices[aResFeatureId] = 0 + aSSEntry = str(aPartFeatureId) + ":" + aResFeatureId aSShape = anEngine.FindOrCreateShape(aSSEntry) aSShape.SetShapeByStream(aRes.shape().getShapeStream(False)) if not aSShape.GetSO(): # publish in case it is a new shape @@ -112,7 +120,7 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): aSOIter = SHAPERSTUDY_utils.getStudy().NewChildIterator(aComponent) while aSOIter.More(): aSO = aSOIter.Value() - aSOIter.Next() ### here because there is continue inside the loop! + aSOIter.Next() # here because there is continue inside the loop anIOR = aSO.GetIOR() if len(anIOR): anObj = salome.orb.string_to_object(anIOR) @@ -128,6 +136,25 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): if aRes: aBuilder = SHAPERSTUDY_utils.getStudy().NewBuilder() aBuilder.RemoveReference(aSO2) + # if the object is not marked as dead, mark it (#3201) to make all entries unique + aDeadEntry = anObj.GetEntry() + if not aDeadEntry.startswith("dead"): + anIndex = aSO.Tag() + anObj.SetEntry("dead0" + str(anIndex) + "_" + aDeadEntry) + + # also for groups + aGrSOIter = SHAPERSTUDY_utils.getStudy().NewChildIterator(aSO) + while aGrSOIter.More(): + aGroupSO = aGrSOIter.Value() + aGrSOIter.Next() + anIOR = aGroupSO.GetIOR() + if len(anIOR): + aGroup = salome.orb.string_to_object(anIOR) + if isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Group) or \ + isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Field): + if not aGroup.GetEntry().startswith("dead"): + aDeadGroupEntry = "dead0" + str(anIndex) + "_" + aGroup.GetEntry() + aGroup.SetEntry(aDeadGroupEntry) # Part of the "execute" method: processes the Groups of theRes result publication. # If theFields is true, the same is performed for Fields. @@ -152,7 +179,7 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): aShape = aSelection.value() if aShape: allShapesList = [] # collect all sub-shapes selected in the group - if aShape.shapeType() == 0: # compound + if aShape.shapeType() == 0 or aShape.shapeType() != aSelType: # compound or whole res anExplorer = GeomAPI_ShapeExplorer(aShape, aSelType) while anExplorer.more(): allShapesList.append(anExplorer.current())