+
+ if (myCurrentLineEdit == myMeshGroupLine)
+ {
+ mySelectSubMesh->setEnabled(false);
+ mySelectGroup->setEnabled(false);
+ myGroupLine->setText("");
+ mySubMeshLine->setText("");
+
+ myGeomGroupBtn->setEnabled(false);
+ myGeomGroupLine->setEnabled(false);
+ myGeomGroupLine->setText("");
+ if (!myCreate)
+ myName->setText("");
+
+ myElements->clear();
+
+ if(aNbSel != 1)
+ {
+ myGroup = SMESH::SMESH_Group::_nil();
+ myMesh = SMESH::SMESH_Mesh::_nil();
+ busy = false;
+ return;
+ }
+ Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
+
+ if (myCreate)
+ {
+ myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
+ if(myMesh->_is_nil())
+ return;
+ myGroup = SMESH::SMESH_Group::_nil();
+
+ myActor = SMESH::FindActorByObject(myMesh);
+ SMESH::SetPickable(myActor);
+
+ aString = mySelection->firstIObject()->getName();
+ myMeshGroupLine->setText(aString) ;
+ myMeshGroupLine->home( false );
+
+ mySelectSubMesh->setEnabled(true);
+ mySelectGroup->setEnabled(true);
+ myGeomGroupBtn->setEnabled(true);
+ myGeomGroupLine->setEnabled(true);
+ updateButtons();
+ }
+ else
+ {
+ SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(IO);
+ if(aGroup->_is_nil())
+ return;
+ busy = false;
+ myCurrentLineEdit = 0;
+ init(aGroup);
+ busy = true;
+ mySelectSubMesh->setEnabled(true);
+ mySelectGroup->setEnabled(true);
+ myGeomGroupBtn->setEnabled(true);
+ myGeomGroupLine->setEnabled(true);
+ }
+ myCurrentLineEdit = 0;
+ busy = false;
+ if (!myCreate)
+ return;
+
+ if (myTypeId == -1)
+ onTypeChanged(0);
+ else
+ {
+ myElements->clear();
+ setSelectionMode(myTypeId);
+ }
+
+ return;
+ }
+ else if (myCurrentLineEdit == myGeomGroupLine)
+ {
+
+ if(aNbSel != 1)
+ {
+ myGeomGroup = GEOM::GEOM_Object::_nil();
+ busy = false;
+ return;
+ }
+
+ Standard_Boolean testResult = Standard_False;
+ myGeomGroup = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult );
+
+ // Check if the object is a geometry group
+ if(!testResult || CORBA::is_nil( myGeomGroup ))
+ {
+ myGeomGroup = GEOM::GEOM_Object::_nil();
+ busy = false;
+ return;
+ }
+ // Check if group constructed on the same shape as a mesh or on its child
+ SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
+ GEOM::GEOM_IGroupOperations_var anOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
+ // The main shape of the group
+ GEOM::GEOM_Object_var aGroupMainShape;
+ if( myGeomGroup->GetType() == 37 )
+ aGroupMainShape = anOp->GetMainShape( myGeomGroup );
+ else
+ aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup);
+ SALOMEDS::SObject_var aGroupMainShapeSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(aGroupMainShape) );
+ // The mesh SObject
+ SALOMEDS::SObject_var aMeshSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myMesh) );
+ if ( aMeshSO->_is_nil() ) {
+ myGeomGroup = GEOM::GEOM_Object::_nil();
+ busy = false;
+ return;
+ }
+ SALOMEDS::SObject_var anObj, aRef;
+ bool isRefOrSubShape = false;
+ if ( aMeshSO->FindSubObject( 1, anObj ) && anObj->ReferencedObject( aRef )) {
+ if ( strcmp( aRef->GetID(), aGroupMainShapeSO->GetID() ) == 0 )
+ isRefOrSubShape = true;
+ else
+ {
+ SALOMEDS::SObject_var aFather = aGroupMainShapeSO->GetFather();
+ SALOMEDS::SComponent_var aComponent = aGroupMainShapeSO->GetFatherComponent();
+ while ( !isRefOrSubShape && strcmp( aFather->GetID(), aComponent->GetID() ) != 0 )
+ {
+ if (strcmp( aRef->GetID(), aFather->GetID() ) == 0)
+ isRefOrSubShape = true;
+ else
+ aFather = aFather->GetFather();
+ }
+ }
+ }
+ if ( !isRefOrSubShape )
+ {
+ myGeomGroup = GEOM::GEOM_Object::_nil();
+ busy = false;
+ return;
+ }
+ }
+