Salome HOME
Update in accordance with changes in QtxComboBox.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterDlg.cxx
index afbfd6861468424e494f144d0660aa9885ff8b88..b55632f0a753c123c7e4ebbd0724acf7eadd5d72 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  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
@@ -870,8 +870,8 @@ SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
                                             QWidget* parent,
                                             const int type )
 : QWidget( parent ),
-  myIsLocked( false ),
-  mySMESHGUI( theModule )
+  mySMESHGUI( theModule ),
+  myIsLocked( false )
 {
   myEntityType = -1;
 
@@ -888,8 +888,8 @@ SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
                                             QWidget* parent,
                                             const QList<int>& types )
 : QWidget( parent ),
-  myIsLocked( false ),
-  mySMESHGUI( theModule )
+  mySMESHGUI( theModule ),
+  myIsLocked( false )
 {
   myEntityType = -1;
   Init(types);
@@ -1012,6 +1012,7 @@ void SMESHGUI_FilterTable::Init (const QList<int>& theTypes)
         Table* aTable = createTable(mySwitchTableGrp, *typeIt);
         myTables[ *typeIt ] = aTable;
         ((QVBoxLayout*)mySwitchTableGrp->layout())->addWidget(myTables[ *typeIt ]);
+        myEntityType = -1;
       }
     }
   }
@@ -1154,7 +1155,7 @@ bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType)
       bool aRes = false;
       bool isSignalsBlocked = aTable->signalsBlocked();
       aTable->blockSignals(true);
-      double  aThreshold = (int)aTable->text(i, 2).toDouble(&aRes);
+      /*double  aThreshold =*/ aTable->text(i, 2).toDouble( &aRes );
       aTable->blockSignals(isSignalsBlocked);
 
       if (!aRes && aTable->isEditable(i, 2))
@@ -2891,6 +2892,11 @@ void SMESHGUI_FilterDlg::Init (const int type, const bool setInViewer)
 //=======================================================================
 void SMESHGUI_FilterDlg::Init (const QList<int>& theTypes, const bool setInViewer)
 {
+  if ( theTypes.empty() )
+  {
+    Init( SMESH::ALL, setInViewer );
+    return;
+  }
   mySourceWg  = 0;
   myTypes     = theTypes;
   myMesh      = SMESH::SMESH_Mesh::_nil();
@@ -3358,8 +3364,8 @@ bool SMESHGUI_FilterDlg::onApply()
     insertFilterInViewer();
 
     if (!myFilter[ aCurrType ]->GetPredicate()->_is_nil()) {
-      // 
-      bool toFilter = (( SMESH::FindActorByObject( myMesh )) ||
+      //
+      bool toFilter = (( getActor() ) ||
                        ( myInitSourceWgOnApply && mySourceWg ) ||
                        ( mySourceGrp->checkedId() == Dialog && mySourceWg ));
       if ( toFilter ) {
@@ -3367,6 +3373,9 @@ bool SMESHGUI_FilterDlg::onApply()
         filterSource(aCurrType, aResultIds);
         // select in viewer
         selectInViewer(aCurrType, aResultIds);
+        // set ids to the dialog
+        if ( myInitSourceWgOnApply || mySourceGrp->checkedId() == Dialog )
+          setIdsToWg(mySourceWg, aResultIds);
       }
     }
 
@@ -3407,7 +3416,7 @@ bool SMESHGUI_FilterDlg::createFilter (const int theType)
   if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
     aPrecision = mgr->integerValue( "SMESH", "controls_precision", aPrecision );
 
-  for (CORBA::ULong i = 0; i < n; i++) {
+  for ( int i = 0; i < n; i++) {
     SMESH::Filter::Criterion aCriterion = createCriterion();
     myTable->GetCriterion(i, aCriterion);
     aCriterion.Precision = aPrecision;
@@ -3542,9 +3551,6 @@ void SMESHGUI_FilterDlg::filterSource (const int theType,
       if (aPred->IsSatisfy(*anIter))
         theResIds.append(*anIter);
   }
-  // set ids to the dialog
-  if (myInitSourceWgOnApply || aSourceId == Dialog)
-    setIdsToWg(mySourceWg, theResIds);
 }
 
 //=======================================================================
@@ -3616,6 +3622,35 @@ void SMESHGUI_FilterDlg::filterSelectionSource (const int theType,
       theResIds.append(aResIter.Key());
 }
 
+//=======================================================================
+//function : getActor
+//purpose  : Returns an actor to show filtered entities
+//=======================================================================
+
+SMESH_Actor* SMESHGUI_FilterDlg::getActor()
+{
+  SMESH_Actor* meshActor = SMESH::FindActorByObject( myMesh );
+  if ( meshActor && meshActor->GetVisibility() )
+    return meshActor;
+
+  SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter(myIObjects);
+  for ( ; anIter.More(); anIter.Next())
+  {
+    Handle(SALOME_InteractiveObject) io = anIter.Key();
+    if ( io->hasEntry() )
+    {
+      SMESH_Actor* actor = SMESH::FindActorByEntry( io->getEntry() );
+      if ( !actor )
+        continue;
+      if ( actor->GetVisibility() )
+        return actor;
+      if ( !meshActor )
+        meshActor = actor;
+    }
+  }
+  return meshActor;
+}
+
 //=======================================================================
 // name    : SMESHGUI_FilterDlg::selectInViewer
 // Purpose : Select given entities in viewer
@@ -3638,8 +3673,8 @@ void SMESHGUI_FilterDlg::selectInViewer (const int theType, const QList<int>& th
   }
 
   // Clear selection
-  SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
-  if (!anActor || !anActor->hasIO())
+  SMESH_Actor* anActor = getActor();
+  if ( !anActor || !anActor->hasIO() )
     return;
 
   Handle(SALOME_InteractiveObject) anIO = anActor->getIO();