From: Jérôme Date: Mon, 14 Dec 2020 16:13:10 +0000 (+0100) Subject: #20442 add new group in connector plugin to plublish feature X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=af92fd082c3b1c84db659126b28ac2e0f1e03371;p=modules%2Fshaper.git #20442 add new group in connector plugin to plublish feature --- diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py index a2e401aae..2f36d1ed4 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -160,51 +160,55 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): # If theFields is true, the same is performed for Fields. def processGroups(self, theRes, theEngine, thePartFeatureId, theStudyShape, theFields): allGroupsProcessed = [] + allRefGroups = [] if theFields: - aRefGroups = ModelAPI.referencedFeatures(theRes, "Field", True) + allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Field", True)) else: - aRefGroups = ModelAPI.referencedFeatures(theRes, "Group", True) - for aRef in aRefGroups: - aGroupIndices = [] - aGroupHasIndex = {} - aResShape = theRes.shape() - if theFields: - aSelList = aRef.selectionList("selected") - else: - aSelList = aRef.selectionList("group_list") - aSelType = GeomAPI_Shape.shapeTypeByStr(aSelList.selectionType()) - for aGroupRes in aRef.results(): - aShape = aGroupRes.shape() - anExplorer = GeomAPI_ShapeExplorer(aShape, aSelType) - while anExplorer.more(): - anId = GeomAlgoAPI.GeomAlgoAPI_CompoundBuilder.id(aResShape, anExplorer.current()) - if anId > 0 and not anId in aGroupHasIndex: - aGroupIndices.append(anId) - aGroupHasIndex[anId] = 0 - anExplorer.next() - if len(aGroupIndices): # create group - aGroupFeatureId = aRef.data().featureId() + allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Group", True)) + allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Shared_faces", True)) + allRefGroups.append(ModelAPI.referencedFeatures(theRes, "Duplicated_faces", True)) + for aRefGroups in allRefGroups: + for aRef in aRefGroups: + aGroupIndices = [] + aGroupHasIndex = {} + aResShape = theRes.shape() if theFields: - aFieldOp = theEngine.GetIFieldOperations() - aGroupEntry = "field" + str(thePartFeatureId) + ":" + str(aGroupFeatureId) - aGroup = aFieldOp.FindField(theStudyShape, aGroupEntry) + aSelList = aRef.selectionList("selected") else: - aGroupOp = theEngine.GetIGroupOperations() - aGroupEntry = "group" + str(thePartFeatureId) + ":" + str(aGroupFeatureId) - aGroup = aGroupOp.FindGroup(theStudyShape, aGroupEntry) - if not aGroup: # create a new + aSelList = aRef.selectionList("group_list") + aSelType = GeomAPI_Shape.shapeTypeByStr(aSelList.selectionType()) + for aGroupRes in aRef.results(): + aShape = aGroupRes.shape() + anExplorer = GeomAPI_ShapeExplorer(aShape, aSelType) + while anExplorer.more(): + anId = GeomAlgoAPI.GeomAlgoAPI_CompoundBuilder.id(aResShape, anExplorer.current()) + if anId > 0 and not anId in aGroupHasIndex: + aGroupIndices.append(anId) + aGroupHasIndex[anId] = 0 + anExplorer.next() + if len(aGroupIndices): # create group + aGroupFeatureId = aRef.data().featureId() if theFields: - aGroup = aFieldOp.CreateFieldByType(theStudyShape, aSelType) + aFieldOp = theEngine.GetIFieldOperations() + aGroupEntry = "field" + str(thePartFeatureId) + ":" + str(aGroupFeatureId) + aGroup = aFieldOp.FindField(theStudyShape, aGroupEntry) else: - aGroup = aGroupOp.CreateGroup(theStudyShape, aSelType) - aGroup.SetEntry(aGroupEntry) - theEngine.AddInStudy(aGroup, aRef.firstResult().data().name(), theStudyShape) - aGroup.SetSelection(aGroupIndices) - if theFields: - self.fillField(aGroup, aRef, theEngine, aGroupIndices) - # a group takes shape from the main result - #aGroup.SetShapeByStream(aRef.firstResult().shape().getShapeStream(False)) # group shape - allGroupsProcessed.append(aGroupEntry) + aGroupOp = theEngine.GetIGroupOperations() + aGroupEntry = "group" + str(thePartFeatureId) + ":" + str(aGroupFeatureId) + aGroup = aGroupOp.FindGroup(theStudyShape, aGroupEntry) + if not aGroup: # create a new + if theFields: + aGroup = aFieldOp.CreateFieldByType(theStudyShape, aSelType) + else: + aGroup = aGroupOp.CreateGroup(theStudyShape, aSelType) + aGroup.SetEntry(aGroupEntry) + theEngine.AddInStudy(aGroup, aRef.firstResult().data().name(), theStudyShape) + aGroup.SetSelection(aGroupIndices) + if theFields: + self.fillField(aGroup, aRef, theEngine, aGroupIndices) + # a group takes shape from the main result + #aGroup.SetShapeByStream(aRef.firstResult().shape().getShapeStream(False)) # group shape + allGroupsProcessed.append(aGroupEntry) # check all existing groups: if some does not processed, remove it from the tree aSOIter = SHAPERSTUDY_utils.getStudy().NewChildIterator(theStudyShape.GetSO()) while aSOIter.More(): diff --git a/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.h index ff7273ec4..b243b43d9 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.h +++ b/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.h @@ -58,7 +58,7 @@ public: /// Attribute name for z coodinate. inline static const std::string& LIST_FACES_ID() { - static const std::string MY_LIST_FACES_ID("faces"); + static const std::string MY_LIST_FACES_ID("group_list"); return MY_LIST_FACES_ID; } diff --git a/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.h index 995ef7790..5fc5d45aa 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.h +++ b/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.h @@ -58,7 +58,7 @@ public: /// Attribute name for z coodinate. inline static const std::string& LIST_FACES_ID() { - static const std::string MY_LIST_FACES_ID("faces"); + static const std::string MY_LIST_FACES_ID("group_list"); return MY_LIST_FACES_ID; } diff --git a/src/FeaturesPlugin/Test/TestCheckSharedFaces.py b/src/FeaturesPlugin/Test/TestCheckSharedFaces.py index c0d98ace1..0b8da66d7 100644 --- a/src/FeaturesPlugin/Test/TestCheckSharedFaces.py +++ b/src/FeaturesPlugin/Test/TestCheckSharedFaces.py @@ -60,7 +60,7 @@ if __name__ == '__main__': assert Shared_faces_1_Feature.error() == '' assert Shared_faces_1_Feature.name() == "Shared_faces_1" - aSelectionList = Shared_faces_1_Feature.selectionList("faces") + aSelectionList = Shared_faces_1_Feature.selectionList("group_list") assert aSelectionList.size() == 1 assert(Part_1_doc.size("Groups") == 1) diff --git a/src/FeaturesPlugin/shared_Faces_macro_widget.xml b/src/FeaturesPlugin/shared_Faces_macro_widget.xml index 960c960c6..9fc5197f5 100644 --- a/src/FeaturesPlugin/shared_Faces_macro_widget.xml +++ b/src/FeaturesPlugin/shared_Faces_macro_widget.xml @@ -10,7 +10,7 @@