Salome HOME
0023064: [CEA 1471] Create and support quadratic polygons in SMESH
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MergeDlg.cxx
index 99c7d49edff9b72dc7bf7164a7d63018f1812b3e..1a37b7760fc0cbfbb9d5260d0b5f9cc8d5afd30f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  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
@@ -570,7 +570,8 @@ void SMESHGUI_MergeDlg::Init()
   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
   /* to close dialog if study change */
   connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(reject()));
-
+  connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this,  SLOT(onOpenView()));
+  connect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView()));
   // Init Mesh field from selection
   SelectionIntoArgument();
 
@@ -721,6 +722,31 @@ void SMESHGUI_MergeDlg::reject()
   QDialog::reject();
 }
 
+//=================================================================================
+// function : onOpenView()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MergeDlg::onOpenView()
+{
+  if ( mySelector ) {
+    SMESH::SetPointRepresentation(false);
+  }
+  else {
+    mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
+    ActivateThisDialog();
+  }
+}
+
+//=================================================================================
+// function : onCloseView()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MergeDlg::onCloseView()
+{
+  DeactivateActiveDialog();
+  mySelector = 0;
+}
+
 //=================================================================================
 // function : ClickOnHelp()
 // purpose  :
@@ -778,6 +804,7 @@ void SMESHGUI_MergeDlg::updateControls()
   bool enable = !(myMesh->_is_nil()) && (ListCoincident->count() || (myTypeId == 0));
   buttonOk->setEnabled(enable);
   buttonApply->setEnabled(enable);
+  DetectButton->setEnabled( !myMesh->_is_nil() );
 }
 
 //=================================================================================
@@ -835,6 +862,7 @@ void SMESHGUI_MergeDlg::onDetect()
 
   ListCoincident->selectAll();
   updateControls();
+  SMESH::UpdateView();
 }
 
 //=================================================================================
@@ -845,6 +873,10 @@ void SMESHGUI_MergeDlg::onSelectGroup()
 {
   if (myIsBusy || !myActor)
     return;
+
+  if( ListCoincident->count() != ListCoincident->selectedItems().count() )
+    SelectAllCB->setChecked( false );
+
   myEditCurrentArgument = (QWidget*)ListCoincident;
 
   myIsBusy = true;
@@ -994,6 +1026,11 @@ void SMESHGUI_MergeDlg::onRemoveGroup()
   updateControls();
   SMESH::UpdateView();
   myIsBusy = false;
+
+  if( ListCoincident->count() == 0 ) {
+    myEditCurrentArgument = (QWidget*)LineEditMesh;
+    SelectAllCB->setChecked( false );
+  }
 }
 
 //=================================================================================
@@ -1050,6 +1087,11 @@ void SMESHGUI_MergeDlg::onRemoveElement()
   
   myIsBusy = false;
   onEditGroup();
+
+  if( ListCoincident->count() == 0 ) {
+    myEditCurrentArgument = (QWidget*)LineEditMesh;
+    SelectAllCB->setChecked( false );
+  }
 }
 
 //=================================================================================
@@ -1109,12 +1151,13 @@ void SMESHGUI_MergeDlg::SelectionIntoArgument()
   if (myEditCurrentArgument == (QWidget*)LineEditMesh) {
     QString aString = "";
     LineEditMesh->setText(aString);
-    
+
     ListCoincident->clear();
     ListEdit->clear();
     myActor = 0;
+    myMesh = SMESH::SMESH_Mesh::_nil();
     QString aCurrentEntry = myEntry;
-    
+
     int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
     if (nbSel != 1) {
       myIdPreview->SetPointsLabeled(false);
@@ -1127,20 +1170,20 @@ void SMESHGUI_MergeDlg::SelectionIntoArgument()
 
     SALOME_ListIO aList;
     mySelectionMgr->selectedObjects(aList);
-    
+
     Handle(SALOME_InteractiveObject) IO = aList.First();
     myEntry = IO->getEntry();
     myMesh = SMESH::GetMeshByIO(IO);
-    
+
     if (myMesh->_is_nil())
       return;
 
     LineEditMesh->setText(aString);
-    
+
     myActor = SMESH::FindActorByEntry(IO->getEntry());
     if (!myActor)
       myActor = SMESH::FindActorByObject(myMesh);
-    
+
     if ( myActor && myTypeId == 1 && mySelector->IsSelectionEnabled() ) {
       mySubMeshOrGroup = SMESH::SMESH_IDSource::_nil();
       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
@@ -1229,10 +1272,15 @@ void SMESHGUI_MergeDlg::ActivateThisDialog()
 // function : enterEvent()
 // purpose  :
 //=================================================================================
-void SMESHGUI_MergeDlg::enterEvent(QEvent*)
+void SMESHGUI_MergeDlg::enterEvent (QEvent*)
 {
-  if (!GroupConstructors->isEnabled())
+  if ( !GroupConstructors->isEnabled() ) {
+    SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+    if ( aViewWindow && !mySelector) {
+      mySelector = aViewWindow->GetSelector();
+    }
     ActivateThisDialog();
+  }
 }
 
 //=================================================================================
@@ -1294,12 +1342,14 @@ void SMESHGUI_MergeDlg::onTypeChanged (int id)
       GroupCoincidentWidget->show();
       SMESH::SetPointRepresentation(true);
       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-        aViewWindow->SetSelectionMode(NodeSelection);
+        if( mySelector->IsSelectionEnabled() )
+          aViewWindow->SetSelectionMode(NodeSelection);
     }
     else {
       GroupCoincident->show();
       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-        aViewWindow->SetSelectionMode(CellSelection);
+        if( mySelector->IsSelectionEnabled() )
+          aViewWindow->SetSelectionMode(CellSelection);
     }
     GroupEdit->show();
     break;