Salome HOME
bos #20256: [CEA 18523] Porting SMESH to int 64 bits
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MergeDlg.cxx
index f7977d196d83683df32377dd11f88c782a0867a8..3c37a0cba2afe406f750c6e7e4279f70831cdfec 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  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
@@ -469,7 +469,7 @@ void SMESHGUI_MergeDlg::Init()
 // function : FindGravityCenter()
 // purpose  :
 //=================================================================================
-void SMESHGUI_MergeDlg::FindGravityCenter(TColStd_MapOfInteger & theElemsIdMap,
+void SMESHGUI_MergeDlg::FindGravityCenter(SVTK_TVtkIDsMap &      theElemsIdMap,
                                           std::vector<int>&      theIDs,
                                           std::list< gp_XYZ > &  theGrCentersXYZ)
 {
@@ -484,7 +484,7 @@ void SMESHGUI_MergeDlg::FindGravityCenter(TColStd_MapOfInteger & theElemsIdMap,
   int nbNodes;
 
   theIDs.reserve( theElemsIdMap.Extent() );
-  TColStd_MapIteratorOfMapOfInteger idIter( theElemsIdMap );
+  SVTK_TVtkIDsMapIterator idIter( theElemsIdMap );
   for( ; idIter.More(); idIter.Next() ) {
     const SMDS_MeshElement* anElem = aMesh->FindElement(idIter.Key());
     if ( !anElem )
@@ -556,7 +556,7 @@ bool SMESHGUI_MergeDlg::ClickOnApply()
       int i, nb = KeepList->count();
       if ( isKeepIDsSelection() )
       {
-        SMESH::long_array_var anIdList = new SMESH::long_array();
+        SMESH::smIdType_array_var anIdList = new SMESH::smIdType_array();
         anIdList->length(nb);
         for (i = 0; i < nb; i++)
           anIdList[i] = KeepList->item(i)->text().toInt();
@@ -845,7 +845,7 @@ void SMESHGUI_MergeDlg::onSelectGroup()
   myIsBusy = true;
   ListEdit->clear();
 
-  TColStd_MapOfInteger anIndices;
+  SVTK_TVtkIDsMap anIndices;
   QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
   QListWidgetItem* anItem;
   QStringList aListIds;
@@ -908,7 +908,7 @@ void SMESHGUI_MergeDlg::onSelectElementFromGroup()
   if (myIsBusy || !myActor)
     return;
 
-  TColStd_MapOfInteger anIndices;
+  SVTK_TVtkIDsMap anIndices;
   QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
   QListWidgetItem* anItem;
 
@@ -1144,6 +1144,9 @@ void SMESHGUI_MergeDlg::SetEditCurrentArgument()
 //=================================================================================
 void SMESHGUI_MergeDlg::SelectionIntoArgument()
 {
+  if ( myIsBusy )
+    return;
+
   if (myEditCurrentArgument == (QWidget*)LineEditMesh)
   {
     QString aString = "";
@@ -1222,6 +1225,9 @@ void SMESHGUI_MergeDlg::SelectionIntoArgument()
 
     LineEditMesh->setText( aString );
 
+    
+    myIsBusy = true; // here selection can change
+
     if (myAction == MERGE_NODES) {
       SMESH::SetPointRepresentation(true);
       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
@@ -1231,6 +1237,8 @@ void SMESHGUI_MergeDlg::SelectionIntoArgument()
       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
         aViewWindow->SetSelectionMode(CellSelection);
 
+    myIsBusy = false;
+
     // process groups
     myGroups.clear();
     ListExclude->clear();
@@ -1408,9 +1416,11 @@ void SMESHGUI_MergeDlg::onTypeChanged (int id)
 
     myIdPreview->SetPointsLabeled(false);
     SMESH::SetPointRepresentation(false);
+    myIsBusy = true; // keep currently selected mesh
     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
       aViewWindow->SetSelectionMode(ActorSelection);
     mySelectionMgr->clearFilters();
+    myIsBusy = false;
     GroupCoincident->hide();
     GroupEdit->hide();
 
@@ -1424,6 +1434,7 @@ void SMESHGUI_MergeDlg::onTypeChanged (int id)
 
     myMeshOrSubMeshOrGroupFilter = new SMESH_TypeFilter (SMESH::IDSOURCE);
 
+    myIsBusy = true; // keep currently selected mesh
     if (myAction == MERGE_NODES) {
       SMESH::SetPointRepresentation(true);
       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
@@ -1435,11 +1446,14 @@ void SMESHGUI_MergeDlg::onTypeChanged (int id)
         if( mySelector->IsSelectionEnabled() )
           aViewWindow->SetSelectionMode(CellSelection);
     }
+    myIsBusy = false;
     GroupCoincident->show();
     GroupEdit->show();
     break;
   }
-  SelectionIntoArgument();
+
+  if ( myMesh->_is_nil() )
+    SelectionIntoArgument();
 
   updateControls();
 
@@ -1581,7 +1595,7 @@ void SMESHGUI_MergeDlg::onSelectKeep()
     if ( myActor )
     {
       mySelectionMgr->clearSelected();
-      TColStd_MapOfInteger aIndexes;
+      SVTK_TVtkIDsMap aIndexes;
       QList<QListWidgetItem*> selItems = KeepList->selectedItems();
       QListWidgetItem* anItem;
       foreach(anItem, selItems) aIndexes.Add(anItem->text().toInt());
@@ -1607,7 +1621,7 @@ void SMESHGUI_MergeDlg::onSelectKeep()
 //           IDs to groups or vice versa
 //=======================================================================
 
-void SMESHGUI_MergeDlg::onKeepSourceChanged(int isGroup)
+void SMESHGUI_MergeDlg::onKeepSourceChanged(int /*isGroup*/)
 {
   KeepList->clear();
   SelectKeepButton->click();