From: mpa Date: Thu, 28 Feb 2013 06:51:46 +0000 (+0000) Subject: 0022126: [CEA 768] Boolean operations on groups: it is not possible to graphically... X-Git-Tag: V6_main_FINAL~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fa473c8e8c3afa1039183cc981ac633446c7f305;p=modules%2Fgeom.git 0022126: [CEA 768] Boolean operations on groups: it is not possible to graphically select sub-shapes --- diff --git a/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx b/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx index dc47e1f0e..78a0548e8 100644 --- a/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx @@ -80,6 +80,12 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup { SetErrorCode(KO); + if ( theShapeType != TopAbs_VERTEX && theShapeType != TopAbs_EDGE && + theShapeType != TopAbs_FACE && theShapeType != TopAbs_SOLID ) { + SetErrorCode( "Error: You could create group only next type: vertex, edge, face or solid" ); + return NULL; + } + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); anArray->SetValue(1, -1); @@ -113,6 +119,11 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS SetErrorCode(KO); if(theGroup.IsNull()) return; + if ( theGroup->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return; + } + Handle(GEOM_Function) aFunction = theGroup->GetLastFunction(); if(aFunction.IsNull()) return; @@ -129,6 +140,13 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS TopTools_IndexedMapOfShape aMapOfShapes; TopExp::MapShapes(aMainShape, aMapOfShapes); + TopAbs_ShapeEnum aGroupType = GetType(theGroup); + TopAbs_ShapeEnum aShapeType = aMapOfShapes.FindKey(theSubShapeID).ShapeType(); + if ( aGroupType != aShapeType ) { + SetErrorCode( "Error: You could perform this operation only with object the same type as the type of group." ); + return; + } + if (theSubShapeID < 1 || aMapOfShapes.Extent() < theSubShapeID) { SetErrorCode("Invalid sub-shape index: out of range"); return; @@ -184,6 +202,11 @@ void GEOMImpl_IGroupOperations::RemoveObject (Handle(GEOM_Object) theGroup, int SetErrorCode(KO); if(theGroup.IsNull()) return; + if ( theGroup->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return; + } + Handle(GEOM_Function) aFunction = theGroup->GetLastFunction(); if(aFunction.IsNull()) return; @@ -263,6 +286,11 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup, SetErrorCode(KO); if (theGroup.IsNull()) return; + if ( theGroup->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return; + } + Standard_Integer aLen = theSubShapes->Length(); if (aLen < 1) { //SetErrorCode("The list is empty"); @@ -413,6 +441,11 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup, SetErrorCode(KO); if (theGroup.IsNull()) return; + if ( theGroup->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return; + } + Standard_Integer aLen = theSubShapes->Length(); if (aLen < 1) { //SetErrorCode("The list is empty"); @@ -558,6 +591,11 @@ void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup, SetErrorCode(KO); if (theGroup.IsNull()) return; + if ( theGroup->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return; + } + Standard_Integer aLen = theSubShapes->Length(); if (aLen < 1) { //SetErrorCode("The list is empty"); @@ -657,6 +695,11 @@ void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup, SetErrorCode(KO); if (theGroup.IsNull()) return; + if ( theGroup->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return; + } + Standard_Integer aLen = theSubShapes->Length(); if (aLen < 1) { //SetErrorCode("The list is empty"); @@ -760,6 +803,11 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::UnionGroups (Handle(GEOM_Object) SetErrorCode(KO); if (theGroup1.IsNull() || theGroup2.IsNull()) return NULL; + if ( theGroup1->GetType() != GEOM_GROUP || theGroup2->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return NULL; + } + // Get group type TopAbs_ShapeEnum aType1 = GetType(theGroup1); TopAbs_ShapeEnum aType2 = GetType(theGroup2); @@ -866,6 +914,11 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::IntersectGroups (Handle(GEOM_Obje SetErrorCode(KO); if (theGroup1.IsNull() || theGroup2.IsNull()) return NULL; + if ( theGroup1->GetType() != GEOM_GROUP || theGroup2->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return NULL; + } + // Get group type TopAbs_ShapeEnum aType1 = GetType(theGroup1); TopAbs_ShapeEnum aType2 = GetType(theGroup2); @@ -972,6 +1025,11 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CutGroups (Handle(GEOM_Object) th SetErrorCode(KO); if (theGroup1.IsNull() || theGroup2.IsNull()) return NULL; + if ( theGroup1->GetType() != GEOM_GROUP || theGroup2->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return NULL; + } + // Get group type TopAbs_ShapeEnum aType1 = GetType(theGroup1); TopAbs_ShapeEnum aType2 = GetType(theGroup2); @@ -1092,7 +1150,10 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::UnionListOfGroups // Iterate on the initial groups for (i = 1; i <= aLen; i++) { Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList->Value(i)); - + if ( aGr_i->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return NULL; + } // Get group type aType_i = GetType(aGr_i); if (i == 1) @@ -1204,7 +1265,10 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::IntersectListOfGroups // Iterate on the initial groups for (i = 1; i <= aLen; i++) { Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList->Value(i)); - + if ( aGr_i->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return NULL; + } // Get group type aType_i = GetType(aGr_i); if (i == 1) @@ -1342,7 +1406,10 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CutListOfGroups // 1. Collect indices to be excluded (from theGList2) into the mapIDs for (i = 1; i <= aLen2; i++) { Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList2->Value(i)); - + if ( aGr_i->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return NULL; + } // Get group type aType_i = GetType(aGr_i); if (i == 1) @@ -1393,7 +1460,10 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CutListOfGroups // 2. Collect indices from theGList1, avoiding indices from theGList2 (mapIDs) for (i = 1; i <= aLen1; i++) { Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList1->Value(i)); - + if ( aGr_i->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return NULL; + } // Get group type aType_i = GetType(aGr_i); if (i == 1 && aLen2 < 1) @@ -1513,7 +1583,10 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape (Handle(GEOM_Object) SetErrorCode(KO); if(theGroup.IsNull()) return NULL; - + if ( theGroup->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return NULL; + } Handle(GEOM_Function) aGroupFunction = theGroup->GetFunction(1); if (aGroupFunction.IsNull()) return NULL; @@ -1543,7 +1616,10 @@ Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GE SetErrorCode(KO); if(theGroup.IsNull()) return NULL; - + if ( theGroup->GetType() != GEOM_GROUP ) { + SetErrorCode( "Error: You could perform this operation only with group. Please select a group." ); + return NULL; + } Handle(GEOM_Function) aFunction = theGroup->GetLastFunction(); if(aFunction.IsNull()) return NULL; diff --git a/src/GEOM_I/GEOM_IGroupOperations_i.cc b/src/GEOM_I/GEOM_IGroupOperations_i.cc index 60a26e129..c129da936 100644 --- a/src/GEOM_I/GEOM_IGroupOperations_i.cc +++ b/src/GEOM_I/GEOM_IGroupOperations_i.cc @@ -99,6 +99,9 @@ void GEOM_IGroupOperations_i::AddObject(GEOM::GEOM_Object_ptr theGroup, CORBA::L if (aGroupRef.IsNull()) return; GetOperations()->AddObject(aGroupRef, theSubShapeId); + + // Update GUI. + UpdateGUIForObject(theGroup); } //============================================================================= @@ -116,6 +119,9 @@ void GEOM_IGroupOperations_i::RemoveObject(GEOM::GEOM_Object_ptr theGroup, CORBA if (aGroupRef.IsNull()) return; GetOperations()->RemoveObject(aGroupRef, theSubShapeId); + + // Update GUI. + UpdateGUIForObject(theGroup); } //=============================================================================