Salome HOME
Merge from V5_1_main 10/06/2010
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.cxx
index 310f34d3f176033462168a9872ccdc6477b1b809..4ceb159ee0d3ea39527e71b1c5002feb230bdcca 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // SMESH SMESHGUI : GUI for SMESH component
 // File   : SMESHGUI_MeshOp.cxx
 // Author : Sergey LITONIN, Open CASCADE S.A.S.
-
 // SMESH includes
+//
 #include "SMESHGUI_MeshOp.h"
 
 #include "SMESHGUI.h"
@@ -149,7 +150,10 @@ bool SMESHGUI_MeshOp::onApply()
     else if ( !myToCreate )
       aResult = editMeshOrSubMesh( aMess );
     if ( aResult )
+    {
+      SMESHGUI::Modified();
       update( UF_ObjBrowser | UF_Model );
+    }
   }
   catch ( const SALOME::SALOME_Exception& S_ex )
   {
@@ -576,11 +580,11 @@ void SMESHGUI_MeshOp::selectionDone()
             SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
           bool editSubmesh = ( !sm->_is_nil() &&
                                SUIT_MessageBox::question( myDlg, tr( "SMESH_WARNING" ),
-                                                         tr( "EDIT_SUBMESH_QUESTION"),
-                                                         SUIT_MessageBox::Yes | 
-                                                         SUIT_MessageBox::No,
-                                                         SUIT_MessageBox::No )
-                              == SUIT_MessageBox::Yes );
+                                                          tr( "EDIT_SUBMESH_QUESTION"),
+                                                          SUIT_MessageBox::Yes | 
+                                                          SUIT_MessageBox::No,
+                                                          SUIT_MessageBox::No )
+                               == SUIT_MessageBox::Yes );
           if ( editSubmesh )
           {
             selectionMgr()->clearFilters();
@@ -945,12 +949,19 @@ SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
     }
   }
 
-  return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
-                                                                aServerLib.toLatin1().data(),
-                                                                aMeshVar,
-                                                                aGeomVar,
-                                                                /*byMesh = */isSubMesh);
-
+  SMESH::SMESH_Hypothesis_var hyp =
+    SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
+                                                           aServerLib.toLatin1().data(),
+                                                           aMeshVar,
+                                                           aGeomVar,
+                                                           /*byMesh = */isSubMesh);
+  if ( hyp->_is_nil() && isSubMesh )
+    hyp = SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
+                                                                 aServerLib.toLatin1().data(),
+                                                                 aMeshVar,
+                                                                 aGeomVar,
+                                                                 /*byMesh = */false);
+  return hyp;
 }
 
 //================================================================================
@@ -1085,7 +1096,8 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim,
       if ( aMeshEntry == "" && aGeomEntry == "" ) {
         _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
         GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
-        aGeomEntry = aGeomVar->GetStudyEntry();
+        if ( !aGeomVar->_is_nil() )
+          aGeomEntry = aGeomVar->GetStudyEntry();
       }
 
       if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) { // take geometry from submesh
@@ -1099,7 +1111,8 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim,
             if ( !aMeshVar->_is_nil() ) {
               _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
               GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO );
-              aMeshEntry = aGeomVar->GetStudyEntry();
+              if ( !aGeomVar->_is_nil() )
+                aMeshEntry = aGeomVar->GetStudyEntry();
             }
           }
         }
@@ -1206,7 +1219,8 @@ void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
     if ( aMeshEntry == "" && aGeomEntry == "" ) {
       _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
       GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
-      aGeomEntry = aGeomVar->GetStudyEntry();
+      if ( !aGeomVar->_is_nil() )
+        aGeomEntry = aGeomVar->GetStudyEntry();
     }
 
     if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) { // take geometry from submesh
@@ -1220,7 +1234,8 @@ void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
           if ( !aMeshVar->_is_nil() ) {
             _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
             GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO );
-            aMeshEntry = aGeomVar->GetStudyEntry();
+            if ( !aGeomVar->_is_nil() )
+              aMeshEntry = aGeomVar->GetStudyEntry();
           }
         }
       }
@@ -1662,7 +1677,7 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess )
           aNewGeomGroupName += aName;
           SALOMEDS::SObject_var aNewGroupSO =
             geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar, 
-                               aNewGeomGroupName.toLatin1().data(), mainGeom);
+                                aNewGeomGroupName.toLatin1().data(), mainGeom);
         }
       }
     }