else
myDlg->activateObject( SMESHGUI_MeshDlg::Obj );
- myDlg->setHypoSets( SMESH::GetHypothesesSets() );
-
myDlg->setCurrentTab( SMESH::DIM_3D );
myDlg->show();
}
if (aSeq->length() > 0) {
- shapeDim = 0;
+ shapeDim = -1;
for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
switch ( aGeomVar->GetShapeType() ) {
case GEOM::SHELL:
{
//shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
- shapeDim = (shapeDim < 2) ? 2 : shapeDim;
TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aGeomVar, aShape)) {
- if (/*aShape.Closed()*/BRep_Tool::IsClosed(aShape))
- shapeDim = 3;
- }
+ bool isClosed = GEOMBase::GetShape(aGeomVar, aShape) && /*aShape.Closed()*/BRep_Tool::IsClosed(aShape);
+ shapeDim = qMax(isClosed ? 3 : 2, shapeDim);
}
break;
- case GEOM::FACE: shapeDim = (shapeDim < 2) ? 2 : shapeDim; break;
+ case GEOM::FACE: shapeDim = qMax(2, shapeDim); break;
case GEOM::WIRE:
- case GEOM::EDGE: shapeDim = (shapeDim < 1) ? 1 : shapeDim; break;
- case GEOM::VERTEX: break;
+ case GEOM::EDGE: shapeDim = qMax(1, shapeDim); break;
+ case GEOM::VERTEX: shapeDim = qMax(0, shapeDim); break;
default:
{
TopoDS_Shape aShape;
TopExp_Explorer exp (aShape, TopAbs_SHELL);
if (exp.More()) {
//shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
- shapeDim = (shapeDim < 2) ? 2 : shapeDim;
+ shapeDim = qMax(2, shapeDim);
for (; exp.More() && shapeDim == 2; exp.Next()) {
if (/*exp.Current().Closed()*/BRep_Tool::IsClosed(exp.Current()))
shapeDim = 3;
}
}
else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
- shapeDim = (shapeDim < 2) ? 2 : shapeDim;
+ shapeDim = qMax(2, shapeDim);
else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
- shapeDim = (shapeDim < 1) ? 1 : shapeDim;
- else
- ;//shapeDim = 0;
+ shapeDim = qMax(1, shapeDim);
+ else if ( exp.Init( aShape, TopAbs_VERTEX ), exp.More() )
+ shapeDim = qMax(0, shapeDim);
}
}
}
onAlgoSelected(-1, i);
}
myDlg->setMaxHypoDim( shapeDim );
-
+ myDlg->setHypoSets( SMESH::GetHypothesesSets( shapeDim ));
if (!myToCreate) // edition: read hypotheses
{
QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
- if ( !mesh->_is_nil() )
+ if ( !mesh->_is_nil() ) {
+ //rnv: issue 21056: EDF 1608 SMESH: Dialog Box "Create Sub Mesh": focus should automatically switch to geometry
+ QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
+ if ( !pGeom || GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() )->_is_nil() )
+ myDlg->activateObject(SMESHGUI_MeshDlg::Geom);
enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
+ }
}
myDlg->setGeomPopupEnabled( enable );
}
}
- else {
+ else { // no geometry defined
myDlg->enableTab( SMESH::DIM_3D );
QStringList hypList;
availableHyps( SMESH::DIM_3D, Algo, hypList,
*/
//================================================================================
void SMESHGUI_MeshOp::createHypothesis(const int theDim,
- const int theType,
- const QString& theTypeName)
+ const int theType,
+ const QString& theTypeName)
{
HypothesisData* aData = SMESH::GetHypothesisData(theTypeName);
if (!aData)
SMESH::CreateHypothesis(theTypeName, aHypName, false);
#ifdef WITHGENERICOBJ
if (!CORBA::is_nil(aHyp))
- aHyp->Destroy();
+ aHyp->UnRegister();
#endif
} else {
// Get hypotheses creator client (GUI)
aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
- if ( aMeshEntry != "" ) { // Get Geom object from Mesh
+ if ( myToCreate && myIsMesh )
+ aMeshEntry = aGeomEntry;
+
+ if ( aMeshEntry != aGeomEntry ) { // Get Geom object from Mesh of a sub-mesh being edited
_PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
aMeshEntry = ( aGeomVar->_is_nil() ) ? "" : aMeshEntry = aGeomVar->GetStudyEntry();
}
- if ( aMeshEntry == "" && aGeomEntry == "" ) {
+ if ( aMeshEntry == "" && aGeomEntry == "" ) { // get geom of an object being edited
_PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+ bool isMesh;
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj, &isMesh );
if ( !aGeomVar->_is_nil() )
+ {
aGeomEntry = aGeomVar->GetStudyEntry();
+ if ( isMesh )
+ aMeshEntry = aGeomEntry;
+ }
}
- if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) { // take geometry from submesh
+ if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) {
+ // take geometry from submesh being created
_PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
if ( pObj ) {
// if current object is sub-mesh
SMESH::CreateHypothesis(theTypeName, aHypName, false);
#ifdef WITHGENERICOBJ
if (!CORBA::is_nil(aHyp))
- aHyp->Destroy();
+ aHyp->UnRegister();
#endif
}
}
if ( aHyp->_is_nil() )
return;
- // BUG 0020378
- //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHyp->GetName());
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHyp->GetName());
if ( aCreator )
{
aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
- if ( aMeshEntry != "" ) { // Get Geom object from Mesh
+ if ( myToCreate && myIsMesh )
+ aMeshEntry = aGeomEntry;
+
+ if ( aMeshEntry != aGeomEntry ) { // Get Geom object from Mesh of a sub-mesh being edited
_PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
aMeshEntry = ( aGeomVar->_is_nil() ) ? "" : aMeshEntry = aGeomVar->GetStudyEntry();
}
- if ( aMeshEntry == "" && aGeomEntry == "" ) {
+ if ( aMeshEntry == "" && aGeomEntry == "" ) { // get geom of an object being edited
_PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+ bool isMesh;
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj, &isMesh );
if ( !aGeomVar->_is_nil() )
+ {
aGeomEntry = aGeomVar->GetStudyEntry();
+ if ( isMesh )
+ aMeshEntry = aGeomEntry;
+ }
}
- if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) { // take geometry from submesh
+ if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) {
+ // take geometry from submesh being created
_PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
if ( pObj ) {
// if current object is sub-mesh
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
if (aMeshSO)
- aMeshVar->Destroy();
+ aMeshVar->UnRegister();
#endif
}
return true;
SMESH::CreateHypothesis(aHypName, aHypName, true);
#ifdef WITHGENERICOBJ
if (!CORBA::is_nil(aHyp))
- aHyp->Destroy();
+ aHyp->UnRegister();
#endif
}
else
{
// Get hypotheses creator client (GUI)
// BUG 0020378
- //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
// Create algorithm
SMESH::CreateHypothesis(aHypName, aHypName, true);
#ifdef WITHGENERICOBJ
if (!CORBA::is_nil(aHyp))
- aHyp->Destroy();
+ aHyp->UnRegister();
#endif
}
}