Salome HOME
Implementation of the "21056: EDF 1608 SMESH: Dialog Box "Create Sub Mesh": focus...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.cxx
index 48806273dc28b53edc80c7b25ad8a62c844ea592..b8d9d5a01bf59e46cd77c4bc19a9c8d32b7a8a41 100644 (file)
@@ -240,8 +240,6 @@ void SMESHGUI_MeshOp::startOperation()
   else
     myDlg->activateObject( SMESHGUI_MeshDlg::Obj );
 
-  myDlg->setHypoSets( SMESH::GetHypothesesSets() );
-
   myDlg->setCurrentTab( SMESH::DIM_3D );
   myDlg->show();
 
@@ -474,7 +472,7 @@ void SMESHGUI_MeshOp::selectionDone()
     {
       // Enable tabs according to shape dimension
 
-      int shapeDim = -1;
+      int shapeDim = 3;
 
       QStringList aGEOMs;
       myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
@@ -504,7 +502,7 @@ void SMESHGUI_MeshOp::selectionDone()
       }
 
       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() ) {
@@ -513,7 +511,7 @@ void SMESHGUI_MeshOp::selectionDone()
             {
               //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
               TopoDS_Shape aShape;
-             bool isClosed = GEOMBase::GetShape(aGeomVar, aShape) && /*aShape.Closed()*/BRep_Tool::IsClosed(aShape);
+              bool isClosed = GEOMBase::GetShape(aGeomVar, aShape) && /*aShape.Closed()*/BRep_Tool::IsClosed(aShape);
               shapeDim = qMax(isClosed ? 3 : 2, shapeDim);
             }
             break;
@@ -550,7 +548,7 @@ void SMESHGUI_MeshOp::selectionDone()
         onAlgoSelected(-1, i);
       }
       myDlg->setMaxHypoDim( shapeDim );
-
+      myDlg->setHypoSets( SMESH::GetHypothesesSets( shapeDim ));
 
       if (!myToCreate) // edition: read hypotheses
       {
@@ -614,13 +612,19 @@ void SMESHGUI_MeshOp::selectionDone()
         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,
@@ -1062,7 +1066,7 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim,
       SMESH::CreateHypothesis(theTypeName, aHypName, false);
 #ifdef WITHGENERICOBJ
     if (!CORBA::is_nil(aHyp))
-      aHyp->Destroy();
+      aHyp->UnRegister();
 #endif
   } else {
     // Get hypotheses creator client (GUI)
@@ -1138,7 +1142,7 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim,
        SMESH::CreateHypothesis(theTypeName, aHypName, false);
 #ifdef WITHGENERICOBJ
      if (!CORBA::is_nil(aHyp))
-       aHyp->Destroy();
+       aHyp->UnRegister();
 #endif
     }
   }
@@ -1612,7 +1616,7 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess )
     // 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;
@@ -1875,14 +1879,13 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
           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
@@ -1893,7 +1896,7 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
             SMESH::CreateHypothesis(aHypName, aHypName, true);
 #ifdef WITHGENERICOBJ
           if (!CORBA::is_nil(aHyp))
-            aHyp->Destroy();
+            aHyp->UnRegister();
 #endif
         }
       }