TopoDS_Shape mainShape, subShape;
if ( GEOMBase::GetShape( mainGeom, mainShape ) &&
GEOMBase::GetShape( subGeom, subShape ) )
- // 1 is index of mainShape itself
- return GEOMBase::GetIndex( subShape, mainShape, 0 ) > 1;
+ {
+ int index = GEOMBase::GetIndex( subShape, mainShape, 0 );
+ if ( index > 0 ) {
+ // 1 is index of mainShape itself
+ return index > 1; // it is a subshape
+ }
+ // is it a group?
+ GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ if ( !geomGen->_is_nil() && aStudy ) {
+ GEOM::GEOM_IGroupOperations_var op =
+ geomGen->GetIGroupOperations( aStudy->StudyId() );
+ if ( ! op->_is_nil() ) {
+ GEOM::GEOM_Object_var mainObj = op->GetMainShape( subGeom );
+ if ( !mainObj->_is_nil() )
+ return ( string( mainObj->GetEntry() ) == string( mainGeom->GetEntry() ));
+ }
+ }
+ }
}
}
}
//================================================================================
void SMESHGUI_MeshOp::selectionDone()
{
+ if ( myShapeByMeshDlg && myShapeByMeshDlg->isShown() )
+ return;
+
SMESHGUI_SelectionOp::selectionDone();
try
{
- if ( !myToCreate ) // edition
+ // Enable tabs according to shape dimension
+
+ int shapeDim = 3;
+
+ GEOM::GEOM_Object_var aGeomVar;
+ QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
+ if ( pGeom ) {
+ aGeomVar = GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
+ }
+ else {
+ QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
+ aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+ }
+ if ( !aGeomVar->_is_nil() ) {
+ shapeDim = 0;
+ switch ( aGeomVar->GetShapeType() ) {
+ case GEOM::SOLID:
+ case GEOM::SHELL: shapeDim = 3; break;
+ case GEOM::FACE: shapeDim = 2; break;
+ case GEOM::WIRE:
+ case GEOM::EDGE: shapeDim = 1; break;
+ case GEOM::VERTEX: shapeDim = 0; break;
+ default:
+ TopoDS_Shape aShape;
+ if ( GEOMBase::GetShape(aGeomVar, aShape)) {
+ TopExp_Explorer exp( aShape, TopAbs_SHELL );
+ if ( exp.More() )
+ shapeDim = 3;
+ else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
+ shapeDim = 2;
+ else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
+ shapeDim = 1;
+ else
+ shapeDim = 0;
+ }
+ }
+ }
+ myDlg->setMaxHypoDim( shapeDim );
+
+ if ( !myToCreate ) // edition: read hypotheses
{
QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
_PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
selectionMgr()->clearFilters();
selectObject( pSubmesh );
SMESHGUI::GetSMESHGUI()->switchToOperation(704);
+ return;
}
else
{
myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
}
}
- // enable/disable popup for choice of geom selection way
- myDlg->setGeomPopupEnabled( !myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ).isEmpty() );
-
- }
- }
- catch ( const SALOME::SALOME_Exception& S_ex )
- {
- SalomeApp_Tools::QtCatchCorbaException( S_ex );
- }
- catch ( ... )
- {
- }
-
- // Enable tabs according to shape dimension
-
- int shapeDim = 3;
- try
- {
- GEOM::GEOM_Object_var aGeomVar;
- QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
- _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
- if ( pGeom ) {
- aGeomVar = GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
- }
- else {
- QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
- aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
- }
- if ( !aGeomVar->_is_nil() ) {
- shapeDim = 0;
- switch ( aGeomVar->GetShapeType() ) {
- case GEOM::SOLID:
- case GEOM::SHELL: shapeDim = 3; break;
- case GEOM::FACE: shapeDim = 2; break;
- case GEOM::WIRE:
- case GEOM::EDGE: shapeDim = 1; break;
- case GEOM::VERTEX: shapeDim = 0; break;
- default:
- TopoDS_Shape aShape;
- if ( GEOMBase::GetShape(aGeomVar, aShape)) {
- TopExp_Explorer exp( aShape, TopAbs_SHELL );
- if ( exp.More() )
- shapeDim = 3;
- else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
- shapeDim = 2;
- else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
- shapeDim = 1;
- else
- shapeDim = 0;
- }
- }
+ // enable/disable popup for choice of geom selection way
+ bool enable = false;
+ QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+ if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
+ SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+ if ( !mesh->_is_nil() )
+ enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
+ }
+ myDlg->setGeomPopupEnabled( enable );
}
}
catch ( const SALOME::SALOME_Exception& S_ex )
catch ( ... )
{
}
- myDlg->setMaxHypoDim( shapeDim );
}
//================================================================================
SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
if ( !aMeshVar->_is_nil() ) {
myDlg->hide();
+ myDlg->activateObject( SMESHGUI_MeshDlg::Mesh );
myShapeByMeshDlg->Init();
myShapeByMeshDlg->SetMesh( aMeshVar );
myShapeByMeshDlg->show();
void SMESHGUI_MeshOp::onPublishShapeByMeshDlg()
{
- onCloseShapeByMeshDlg();
-
if ( myShapeByMeshDlg ) {
// Select a found geometry object
GEOM::GEOM_Object_var aGeomVar = myShapeByMeshDlg->GetShape();
{
QString ID = aGeomVar->GetStudyEntry();
if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID )) {
+ SMESH::SMESH_Mesh_ptr aMeshPtr = myShapeByMeshDlg->GetMesh();
+ if ( !CORBA::is_nil( aMeshPtr )) {
+ if (_PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshPtr )) {
+ myDlg->activateObject( SMESHGUI_MeshDlg::Mesh );
+ myDlg->selectObject( aMeshSO->GetName(), SMESHGUI_MeshDlg::Mesh, aMeshSO->GetID() );
+ }
+ }
+ myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
selectObject( aGeomSO );
- selectionDone();
+ //selectionDone();
}
}
+ else {
+ onCloseShapeByMeshDlg();
+ }
}
+ myDlg->show();
}
//================================================================================
/*!
- * \brief SLOT. Is called Close Ok is pressed in SMESHGUI_ShapeByMeshDlg
+ * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
*/
//================================================================================
{
if ( myDlg ) {
myDlg->show();
- myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
+ myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
}
}