]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0019923: EDF 765 SMESH : default values of hypothesis
authoreap <eap@opencascade.com>
Tue, 13 Jan 2009 13:07:24 +0000 (13:07 +0000)
committereap <eap@opencascade.com>
Tue, 13 Jan 2009 13:07:24 +0000 (13:07 +0000)
improve
SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
                                          const QString& aServerLib ) const

src/SMESHGUI/SMESHGUI_MeshOp.cxx

index 01470b95b6269762bd0540a9da70292a320cc38e..6c29524ca3ad862cb4d02ed16b28791bf80ffec5 100644 (file)
@@ -890,13 +890,14 @@ SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
     !myIsMesh :
     myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).count(':') > nbColonsInMeshEntry;
 
+  // get mesh and geom object
+  SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
+  GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
+
+  QString anEntry;
   if ( isSubMesh )
   {
-    // get mesh and geom object
-    SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
-    GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
-
-    QString anEntry = myDlg->selectedObject
+    anEntry = myDlg->selectedObject
       ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
     if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
     {
@@ -917,13 +918,35 @@ SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
         }
       }
     }
-
-    if ( !aMeshVar->_is_nil() && !aGeomVar->_is_nil() )
-      return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
-                                                                    aServerLib.toLatin1().data(),
-                                                                    aMeshVar,
-                                                                    aGeomVar );
   }
+  else // mesh
+  {
+    if ( !myToCreate ) // mesh to edit can be selected
+    {
+      anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+      if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
+      {
+        aMeshVar = SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
+        if ( !aMeshVar->_is_nil() )
+          aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pMesh );
+      }
+    }
+    if ( aGeomVar->_is_nil() ) {
+      anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+      if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
+      {
+        aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
+      }
+    }
+  }
+
+  if ( (!isSubMesh || !aMeshVar->_is_nil()) && !aGeomVar->_is_nil() )
+    return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
+                                                                  aServerLib.toLatin1().data(),
+                                                                  aMeshVar,
+                                                                  aGeomVar,
+                                                                  /*byMesh = */isSubMesh);
+
   return SMESH::SMESH_Hypothesis::_nil();
 }