Salome HOME
INT PAL 0052786: <None> 2D algorithm shown when mesh edition invoked
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.cxx
index c98495e8b39d543e0f75609ba2fbb01902465414..53e1ea98e459560e02a7b8f1ce05c62b23ae8c80 100644 (file)
@@ -551,9 +551,17 @@ void SMESHGUI_MeshOp::selectionDone()
         for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
           QString aSubGeomEntry = (*aSubShapesIter);
           _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
-          GEOM::GEOM_Object_var aSubGeomVar =
-            GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
-          aSeq[iSubSh] = aSubGeomVar;
+         
+          if( pSubGeom ) { 
+            SALOMEDS_SObject* sobj = _CAST(SObject,pSubGeom);
+            if( sobj ) {
+              GEOM::GEOM_Object_var aSubGeomVar =
+                GEOM::GEOM_Object::_narrow(sobj->GetObject());
+              if( !aSubGeomVar->_is_nil() ){
+                aSeq[iSubSh] = aSubGeomVar;
+              }
+            }
+          }
         }
       } else {
         // get geometry by selected sub-mesh
@@ -1488,14 +1496,32 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
       if ( anAvailable.count() == 1 )
         soleCompatible = myAvailableHypData[dim][Algo][0];
       if ( dim == aTopDim && prevAlgo ) {// all available algoritms should be selectable any way
-        if (myDlg->currentMeshType() == MT_ANY)
+        if (aTopDim == SMESH::DIM_2D && myFilteredAlgoData[dim].count() > 0) {
+          anAvailable.clear();
+          for (int i = 0; i < myFilteredAlgoData[dim].count(); ++i) {
+            HypothesisData* aCurAlgo = myFilteredAlgoData[dim][ i ];
+            anAvailable.append( aCurAlgo->Label );
+          }
+        }
+        if (aTopDim == SMESH::DIM_3D && myDlg->currentMeshType() == MT_ANY)
           availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], 0 );
       }
       myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
       noCompatible = anAvailable.isEmpty();
 
       // restore previously selected algo
-      algoIndex = myAvailableHypData[dim][Algo].indexOf( curAlgo );
+      if (dim == aTopDim && prevAlgo && aTopDim == SMESH::DIM_2D && myFilteredAlgoData[dim].count() > 0) {
+        algoIndex = myFilteredAlgoData[dim].indexOf( curAlgo );
+        setCurrentHyp( dim, Algo, algoIndex);
+        if (algoIndex >= 0)
+          prevAlgo = algoByDim[ dim ] = myFilteredAlgoData[dim][algoIndex];
+        else
+          prevAlgo = algoByDim[ dim ] = 0;
+        continue;
+      }
+      else {
+        algoIndex = myAvailableHypData[dim][Algo].indexOf( curAlgo );
+      }
       if ( !isSubmesh && algoIndex < 0 && soleCompatible && !forward && dim != SMESH::DIM_0D)
         // select the sole compatible algo
         algoIndex = myAvailableHypData[dim][Algo].indexOf( soleCompatible );
@@ -2638,6 +2664,7 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
         algoCur = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) );
       }
       myAvailableHypData[dim][Algo].clear();
+      myFilteredAlgoData[dim].clear();
       anAvailableAlgs.clear();
       if ( dim != SMESH::DIM_2D || currentHyp( SMESH::DIM_3D, Algo ) < 0 ||
            myAvailableHypData[SMESH::DIM_3D][Algo].empty() ||
@@ -2651,6 +2678,7 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
           {
             anAvailableAlgs.append( curAlgo->Label );
             myAvailableHypData[dim][Algo].append( curAlgo );
+            myFilteredAlgoData[dim].append( curAlgo );
           }
         }
         if ( !isNone && algoCur ) {