Salome HOME
IPAL 12085: It is impossible to set "Threshold value" in the "Selection filter librar...
authoreap <eap@opencascade.com>
Tue, 22 Apr 2014 15:40:07 +0000 (19:40 +0400)
committereap <eap@opencascade.com>
Tue, 22 Apr 2014 15:40:07 +0000 (19:40 +0400)
52413: TC7.4.0:Selection filters Library

src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx
src/SMESHGUI/SMESHGUI_FilterLibraryDlg.h

index d360c4a6f2e1a073003a6d39dde6522c86a60f70..ee16256859428f94085d8cd6ac260c724a84a8c8 100644 (file)
@@ -30,6 +30,9 @@
 #include "SMESHGUI.h"
 #include "SMESHGUI_FilterUtils.h"
 #include "SMESHGUI_FilterDlg.h"
+#include "SMESHGUI_VTKUtils.h"
+
+#include <GEOMBase.h>
 
 // SALOME GUI includes
 #include <SUIT_Session.h>
@@ -37,8 +40,9 @@
 #include <SUIT_FileDlg.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_ResourceMgr.h>
-
 #include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SALOME_ListIO.hxx>
 
 // Qt includes
 #include <QApplication>
@@ -233,13 +237,16 @@ QWidget* SMESHGUI_FilterLibraryDlg::createMainFrame (QWidget* theParent)
   connect(myDeleteBtn, SIGNAL(clicked()), this, SLOT(onDeleteBtnPressed()));
 
   connect(myName, SIGNAL(textChanged(const QString&)),
-           this, SLOT(onFilterNameChanged(const QString&)));
+          this, SLOT(onFilterNameChanged(const QString&)));
 
   connect(myTable, SIGNAL(EntityTypeChanged(const int)),
-           this, SLOT(onEntityTypeChanged(const int)));
+          this, SLOT(onEntityTypeChanged(const int)));
 
   connect(myTable, SIGNAL(NeedValidation()), this, SLOT(onNeedValidation()));
 
+  LightApp_SelectionMgr* selMgr = SMESH::GetSelectionMgr( mySMESHGUI );
+  connect( selMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
+
   return aMainFrame;
 }
 
@@ -1179,6 +1186,73 @@ void SMESHGUI_FilterLibraryDlg::onNeedValidation()
   }
 }
 
+
+//=======================================================================
+// name    : SMESHGUI_FilterLibraryDlg::onSelectionDone
+// Purpose : SLOT called when selection changed.
+//           If current cell corresponds to the threshold value of
+//           BelongToGeom criterion name of selected object is set in this cell
+//=======================================================================
+
+void SMESHGUI_FilterLibraryDlg::onSelectionDone()
+{
+  SALOME_ListIO aList;
+  if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
+    aSel->selectedObjects( aList );
+
+  int aRow, aCol;
+  if (aList.Extent() != 1 || !myTable->CurrentCell(aRow, aCol))
+    return;
+
+  const int type = myTable->GetCriterionType(aRow);
+  QList<int> types; 
+  types << SMESH::FT_BelongToGeom     << SMESH::FT_BelongToPlane 
+        << SMESH::FT_BelongToCylinder << SMESH::FT_BelongToGenSurface
+        << SMESH::FT_LyingOnGeom      << SMESH::FT_CoplanarFaces
+        << SMESH::FT_ConnectedElements;
+  if ( !types.contains( type ))
+    return;
+
+  Handle(SALOME_InteractiveObject) anIO = aList.First();
+  switch ( type )
+  {
+  case SMESH::FT_CoplanarFaces: // get ID of a selected mesh face
+    {
+      QString aString;
+      int nbElems = SMESH::GetNameOfSelectedElements(SMESH::GetSelector(), anIO, aString);
+      if (nbElems == 1)
+        myTable->SetThreshold(aRow, aString);
+      break;
+    }
+  case SMESH::FT_ConnectedElements: // get either VERTEX or a node ID
+    {
+      GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
+      if (!anObj->_is_nil())
+      {
+        myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
+        myTable->SetID       (aRow, anIO->getEntry());
+      }
+      else
+      {
+        QString aString;
+        int nbElems = SMESH::GetNameOfSelectedElements(SMESH::GetSelector(), anIO, aString);
+        if (nbElems == 1)
+          myTable->SetThreshold(aRow, aString);
+      }
+      break;
+    }
+  default: // get a GEOM object
+    {
+      GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
+      if (!anObj->_is_nil())
+      {
+        myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
+        myTable->SetID       (aRow, anIO->getEntry());
+      }
+    }
+  }
+}
+
 //=================================================================================
 // function : keyPressEvent()
 // purpose  :
index 12158bef8a66e7c7919ccb974ad2bbf3a7399886..cc5d1f7ce6b32f9ef4fadde6c456c26b95556992 100644 (file)
@@ -98,6 +98,7 @@ private slots:
   void                        onFilterNameChanged( const QString& );
   void                        onEntityTypeChanged( const int );
   void                        onNeedValidation();
+  void                        onSelectionDone();
 
 private:
   void                        construct( const QList<int>&, const int );