Salome HOME
PAL10397 - Selection isn't cleared after apply
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_AddMeshElementDlg.cxx
index 823716a853bb6cd4f69b87c496538c69aba2e665..bfb3ff8d7b2302d5bc17f7faf28a33b63e13e4bf 100644 (file)
@@ -457,6 +457,7 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply()
     }
 
     SALOME_ListIO aList; aList.Append( myActor->getIO() );
+    mySelector->ClearIndex();
     mySelectionMgr->setSelectedObjects( aList, false );
 
     SMESH::UpdateView();
@@ -524,23 +525,30 @@ void SMESHGUI_AddMeshElementDlg::onTextChange (const QString& theNewText)
     TColStd_MapOfInteger newIndices;
     
     QStringList aListId = QStringList::split(" ", theNewText, false);
+    bool allOk = true;
     for (int i = 0; i < aListId.count(); i++) {
       if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
       {
        newIndices.Add( n->GetID() );
        myNbOkNodes++;
       }
+      else
+       allOk = false;  
     }
     
     mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
       aViewWindow->highlight( myActor->getIO(), true, true );
     
-    bool aNodesOK = false;
-    if (myIsPoly && myElementType == SMDSAbs_Face && aListId.count() >=3 ){
-      myNbOkNodes = aListId.count();
-      aNodesOK = true;
-    }
+    myNbOkNodes = ( allOk && myNbNodes == aListId.count() );
+    
+    if (myIsPoly)
+      {
+       if ( !allOk || myElementType != SMDSAbs_Face || aListId.count() < 3 )
+         myNbOkNodes = 0;
+       else
+         myNbOkNodes = aListId.count();
+      }
   }
   
   if(myNbOkNodes) {