]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
SMH: Debug of selection in VISU
authorsmh <smh@opencascade.com>
Fri, 7 May 2004 08:55:46 +0000 (08:55 +0000)
committersmh <smh@opencascade.com>
Fri, 7 May 2004 08:55:46 +0000 (08:55 +0000)
src/VISUGUI/VisuGUI_Selection.cxx

index f90df49bf1358655075393931471fb40920dffb7..17eb9d224b1ca7bcf077c142db888ad5f06d0814 100644 (file)
@@ -50,7 +50,6 @@
 #include <qlayout.h>
 #include <qhbuttongroup.h>
 #include <qradiobutton.h>
-#include <qpushbutton.h>
 
 #include <vtkDataSet.h>
 #include <vtkCell.h>
@@ -220,7 +219,8 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
 
   mySelection = SALOME_Selection::Selection(visuGUI->GetActiveStudy()->getSelection());
   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionEvent()));
-  
+
+  myFl = false;
   onSelectionChange(0);
 }
 
@@ -414,7 +414,7 @@ void VisuGUI_SelectionDlg::clearFields() {
 
 typedef  vtkIdType (vtkDataSet::* TDataSetMethod)();
 
-void onIdEdit(const QString& theText, 
+bool onIdEdit(const QString& theText, 
              TDataSetMethod theMethod, 
              bool theIsCell,
              SALOME_Selection* theSelection, 
@@ -429,29 +429,42 @@ void onIdEdit(const QString& theText,
     int aMaxId = (aDataSet->*theMethod)();
     if(anId < 0) anId = 0;
     if(aMaxId <= anId) anId = aMaxId-1;
+    theSelection->ClearIObjects();
     theSelection->AddIObject(anIO);
     VISU_Actor* anVISUActor = visuGUI->GetActor(aPrs3d);
-    if(theIsCell && !anVISUActor->GetVtkId(anId).empty()){
-      theSelection->AddOrRemoveIndex( anIO, anVISUActor->GetVtkId(anId), false );
+    if(theIsCell){
+      VISU_Actor::TVectorId aVec = anVISUActor->GetVtkId(anId);
+      if(!aVec.empty()){
+       theSelection->AddOrRemoveIndex( anIO, aVec, false );
+       return true;
+      }
     }else{
       theSelection->AddOrRemoveIndex(anIO, anId, false);
+      return true;
     }
   }else{
     theMeshName->setText(theValue);
     theFieldName->setText("");
   }
+  return false;
 }
 
 void VisuGUI_SelectionDlg::onPointIdEdit(const QString& theText){
   if (myFl) return;
   TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints;
-  onIdEdit(theText,aMethod,false,mySelection,
-          myMeshName,tr("WRN_NO_AVAILABLE_DATA"),myFieldName);
+  bool anIsSelected = onIdEdit(theText,aMethod,false,mySelection,
+                              myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
+                              myFieldName);
+  if(!anIsSelected)
+    clearFields();
 }
 
 void VisuGUI_SelectionDlg::onCellIdEdit(const QString& theText){
   if (myFl) return;
   TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells;
-  onIdEdit(theText,aMethod,true,mySelection,
-          myMeshName,tr("WRN_NO_AVAILABLE_DATA"),myFieldName);
+  bool anIsSelected = onIdEdit(theText,aMethod,true,mySelection,
+                              myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
+                              myFieldName);
+  if(!anIsSelected)
+    clearFields();
 }