Salome HOME
IPAL54678: TC-9.5.0: Sub-mesh priority: not all sub-meshes are displayed in the dialog
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.cxx
index c33a4fe927cf45fac1d706b6b8439eef6b475445..f143b01368028d22786f5fbffe3f0f18907da481 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020  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
@@ -346,7 +346,7 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const
   myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
 
   if (aGEOMs.count() > 0) {
-    GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
+    GEOM::GEOM_Gen_var geomGen = mainGeom->GetGen();
     if (geomGen->_is_nil()) return false;
 
     GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations();
@@ -780,7 +780,7 @@ bool SMESHGUI_MeshOp::isCompatibleToGeometry(HypothesisData* theAlgoData,
 
   bool isApplicable = false;
   if ( myGeomEntry == myLastGeomEntry && !myGeomEntry.isEmpty() ) {
-    THypLabelIsAppMap::const_iterator lab2isApp = myHypMapIsApplicable.find( theAlgoData->Label );
+    THypLabelIsAppMap::const_iterator lab2isApp = myHypMapIsApplicable.find( theAlgoData->TypeName );
     if ( lab2isApp != myHypMapIsApplicable.end() ) {
       isApplicable = lab2isApp.value();
       return isApplicable;
@@ -791,7 +791,7 @@ bool SMESHGUI_MeshOp::isCompatibleToGeometry(HypothesisData* theAlgoData,
     toCheckIsApplicableToAll = ( myGeom->GetType() == GEOM_GROUP );
 
   isApplicable = SMESH::IsApplicable( theAlgoData->TypeName, myGeom, toCheckIsApplicableToAll );
-  myHypMapIsApplicable.insert( theAlgoData->Label, isApplicable );
+  myHypMapIsApplicable.insert( theAlgoData->TypeName, isApplicable );
   return isApplicable;
 }
 
@@ -1756,7 +1756,7 @@ void SMESHGUI_MeshOp::createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr theMes
   for ( size_t i = 0; i < internalEdges.size(); ++i )
     intIDSet.insert( shapeIDs.FindIndex( internalEdges[ i ]));
 
-  GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
+  GEOM::GEOM_Gen_var geomGen = theMainShape->GetGen();
   if (geomGen->_is_nil()) return;
 
   GEOM::GEOM_Object_var edgeGroup;
@@ -1913,6 +1913,7 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
   if ( aHypoSet->toUseCommonSize() && !getAverageSize( myAverageSize ))
     return;
 
+  int maxDim = -1;
   for ( int isAlgo = 1; isAlgo >= 0; --isAlgo )
     for ( aHypoSet->init( isAlgo, setType ); aHypoSet->more(); aHypoSet->next() )
     {
@@ -1930,6 +1931,7 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
         {
           setCurrentHyp( myDim, Algo, index );
           onAlgoSelected( index, myDim );
+          maxDim = Max( maxDim, myDim );
         }
       }
       else
@@ -1963,6 +1965,9 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
       }
     }
 
+  if ( maxDim > 0 )
+    myDlg->setCurrentTab( maxDim );
+
   return;
 }
 
@@ -2062,7 +2067,7 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
     {
       // Create groups on all geom groups
 
-      GEOM::GEOM_Gen_var           geomGen = SMESH::GetGEOMGen();
+      GEOM::GEOM_Gen_var           geomGen = aGeomVar->GetGen();
       GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
       GEOM::ListOfGO_var        geomGroups = op->GetExistingSubObjects( aGeomVar,
                                                                         /*groupsOnly=*/false );
@@ -2138,11 +2143,11 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
   else if (aGEOMs.count() > 1)
   {
     // create a GEOM group
-    GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
-    if (!geomGen->_is_nil()) {
-      GEOM::GEOM_IGroupOperations_wrap op =
-        geomGen->GetIGroupOperations();
-      if (!op->_is_nil()) {
+    GEOM::GEOM_Gen_var geomGen = mainGeom->GetGen();
+    if ( !geomGen->_is_nil() ) {
+      GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations();
+      if ( !op->_is_nil() )
+      {
         // check and add all selected GEOM objects: they must be
         // a sub-shapes of the main GEOM and must be of one type
         int iSubSh = 0;
@@ -2946,9 +2951,19 @@ void SMESHGUI_MeshOp::updateHypoSets()
       }
       currentHypoSet->setAlgoAvailable( sType, isAvailable );
     }
+    if ( currentHypoSet->hasAlgo( HypothesesSet::MAIN ) &&
+         currentHypoSet->hasAlgo( HypothesesSet::ALT ))
+    {
+      HypothesesSet::SetType setType = HypothesesSet::getPreferredHypType();
+      if ( !currentHypoSet->getAlgoAvailable( setType ))
+        continue; // not add if a preferred type not available currently
+    }
+
     if ( currentHypoSet->getAlgoAvailable( HypothesesSet::MAIN ) ||
          currentHypoSet->getAlgoAvailable( HypothesesSet::ALT ))
+    {
       aFilteredHypothesesSetsList.append( *inHypoSetName );
+    }
   }
   myDlg->setHypoSets( aFilteredHypothesesSetsList );
 }