Salome HOME
Fix for Bug PAL7766 ( An exception appears during construction of a group in the...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterDlg.cxx
index 7aeb763d3f6655cdd93c1f08f7159fe6168df0bf..0f8a797794d16d73bad4a029af4b6ca0c71e16a9 100755 (executable)
 #include <qobjectlist.h>
 #include <qvalidator.h>
 
 #include <qobjectlist.h>
 #include <qvalidator.h>
 
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
 #define SPACING 5                  
 #define MARGIN  10
 
 #define SPACING 5                  
 #define MARGIN  10
 
@@ -654,7 +658,8 @@ bool SMESHGUI_FilterTable::IsValid( const bool theMess, const int theEntityType
     if ( aCriterion == FT_RangeOfIds ||
          aCriterion == FT_BelongToGeom ||
          aCriterion == FT_BelongToPlane ||
     if ( aCriterion == FT_RangeOfIds ||
          aCriterion == FT_BelongToGeom ||
          aCriterion == FT_BelongToPlane ||
-         aCriterion == FT_BelongToCylinder )
+         aCriterion == FT_BelongToCylinder ||
+        aCriterion == FT_LyingOnGeom)
     {
       if ( aTable->text( i, 2 ).isEmpty() )
       {
     {
       if ( aTable->text( i, 2 ).isEmpty() )
       {
@@ -768,7 +773,8 @@ void SMESHGUI_FilterTable::GetCriterion( const int                 theRow,
   if ( aCriterionType != FT_RangeOfIds &&
        aCriterionType != FT_BelongToGeom &&
        aCriterionType != FT_BelongToPlane &&
   if ( aCriterionType != FT_RangeOfIds &&
        aCriterionType != FT_BelongToGeom &&
        aCriterionType != FT_BelongToPlane &&
-       aCriterionType != FT_BelongToCylinder )
+       aCriterionType != FT_BelongToCylinder &&
+       aCriterionType != FT_LyingOnGeom)
   {
     theCriterion.Compare = ( (ComboItem*)aTable->item( theRow, 1 ) )->GetValue();
     theCriterion.Threshold = aTable->item( theRow, 2 )->text().toDouble();
   {
     theCriterion.Compare = ( (ComboItem*)aTable->item( theRow, 1 ) )->GetValue();
     theCriterion.Threshold = aTable->item( theRow, 2 )->text().toDouble();
@@ -813,7 +819,8 @@ void SMESHGUI_FilterTable::SetCriterion( const int                       theRow,
   if ( theCriterion.Type != FT_RangeOfIds &&
        theCriterion.Type != FT_BelongToGeom &&
        theCriterion.Type != FT_BelongToPlane &&
   if ( theCriterion.Type != FT_RangeOfIds &&
        theCriterion.Type != FT_BelongToGeom &&
        theCriterion.Type != FT_BelongToPlane &&
-       theCriterion.Type != FT_BelongToCylinder )
+       theCriterion.Type != FT_BelongToCylinder &&
+       theCriterion.Type != FT_LyingOnGeom)
     aTable->setText( theRow, 2, QString( "%1" ).arg( theCriterion.Threshold, 0, 'g', 15 ) );
   else
     aTable->setText( theRow, 2, QString( theCriterion.ThresholdStr ) );
     aTable->setText( theRow, 2, QString( "%1" ).arg( theCriterion.Threshold, 0, 'g', 15 ) );
   else
     aTable->setText( theRow, 2, QString( theCriterion.ThresholdStr ) );
@@ -902,7 +909,6 @@ void SMESHGUI_FilterTable::onAddBtn()
   int aType = GetType();
   addRow( myTables[ aType ], aType );
 
   int aType = GetType();
   addRow( myTables[ aType ], aType );
 
-  Table* aTable = myTables[ aType ];
   Update();
 }
 
   Update();
 }
 
@@ -965,6 +971,7 @@ void SMESHGUI_FilterTable::updateAdditionalWidget()
   ComboItem* anItem = ( (ComboItem*)aTable->item( aRow, 0 ) );
   bool toEnable = ( (ComboItem*)aTable->item( aRow, 1 ) )->GetValue() == FT_EqualTo &&
                   GetCriterionType( aRow ) != FT_BelongToGeom &&
   ComboItem* anItem = ( (ComboItem*)aTable->item( aRow, 0 ) );
   bool toEnable = ( (ComboItem*)aTable->item( aRow, 1 ) )->GetValue() == FT_EqualTo &&
                   GetCriterionType( aRow ) != FT_BelongToGeom &&
+                  GetCriterionType( aRow ) != FT_LyingOnGeom &&
                   GetCriterionType( aRow ) != FT_RangeOfIds &&
                   GetCriterionType( aRow ) != FT_FreeEdges;
   if ( !myAddWidgets.contains( anItem ) )
                   GetCriterionType( aRow ) != FT_RangeOfIds &&
                   GetCriterionType( aRow ) != FT_FreeEdges;
   if ( !myAddWidgets.contains( anItem ) )
@@ -1047,7 +1054,8 @@ void SMESHGUI_FilterTable::onCriterionChanged( const int row, const int col, con
   else if ( aCriterionType == SMESH::FT_RangeOfIds ||
             aCriterionType == SMESH::FT_BelongToGeom ||
             aCriterionType == SMESH::FT_BelongToPlane ||
   else if ( aCriterionType == SMESH::FT_RangeOfIds ||
             aCriterionType == SMESH::FT_BelongToGeom ||
             aCriterionType == SMESH::FT_BelongToPlane ||
-            aCriterionType == SMESH::FT_BelongToCylinder )
+            aCriterionType == SMESH::FT_BelongToCylinder ||
+           aCriterionType == SMESH::FT_LyingOnGeom)
   {
     QMap<int, QString> aMap;
     aMap[ FT_EqualTo ] = tr( "EQUAL_TO" );
   {
     QMap<int, QString> aMap;
     aMap[ FT_EqualTo ] = tr( "EQUAL_TO" );
@@ -1239,6 +1247,7 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria( const int theType )
       aCriteria[ SMESH::FT_BelongToGeom     ] = tr( "BELONG_TO_GEOM" );
       aCriteria[ SMESH::FT_BelongToPlane    ] = tr( "BELONG_TO_PLANE" );
       aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
       aCriteria[ SMESH::FT_BelongToGeom     ] = tr( "BELONG_TO_GEOM" );
       aCriteria[ SMESH::FT_BelongToPlane    ] = tr( "BELONG_TO_PLANE" );
       aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
+      aCriteria[ SMESH::FT_LyingOnGeom      ] = tr( "LYING_ON_GEOM" );
     }
     return aCriteria;
   }
     }
     return aCriteria;
   }
@@ -1254,6 +1263,7 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria( const int theType )
       aCriteria[ SMESH::FT_BelongToGeom     ] = tr( "BELONG_TO_GEOM" );
       aCriteria[ SMESH::FT_BelongToPlane    ] = tr( "BELONG_TO_PLANE" );
       aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
       aCriteria[ SMESH::FT_BelongToGeom     ] = tr( "BELONG_TO_GEOM" );
       aCriteria[ SMESH::FT_BelongToPlane    ] = tr( "BELONG_TO_PLANE" );
       aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
+      aCriteria[ SMESH::FT_LyingOnGeom      ] = tr( "LYING_ON_GEOM" );
     }
     return aCriteria;
   }
     }
     return aCriteria;
   }
@@ -1273,6 +1283,9 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria( const int theType )
       aCriteria[ SMESH::FT_BelongToGeom     ] = tr( "BELONG_TO_GEOM" );
       aCriteria[ SMESH::FT_BelongToPlane    ] = tr( "BELONG_TO_PLANE" );
       aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
       aCriteria[ SMESH::FT_BelongToGeom     ] = tr( "BELONG_TO_GEOM" );
       aCriteria[ SMESH::FT_BelongToPlane    ] = tr( "BELONG_TO_PLANE" );
       aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
+      aCriteria[ SMESH::FT_LyingOnGeom      ] = tr( "LYING_ON_GEOM" );
+      aCriteria[ SMESH::FT_Length2D         ] = tr( "LENGTH2D" );
+      aCriteria[ SMESH::FT_MultiConnection2D] = tr( "MULTI2D_BORDERS" );
     }
     return aCriteria;
   }
     }
     return aCriteria;
   }
@@ -1281,8 +1294,10 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria( const int theType )
     static QMap<int, QString> aCriteria;
     if ( aCriteria.isEmpty() )
     {
     static QMap<int, QString> aCriteria;
     if ( aCriteria.isEmpty() )
     {
+      aCriteria[ SMESH::FT_AspectRatio3D] = tr( "ASPECT_RATIO_3D" );
       aCriteria[ SMESH::FT_RangeOfIds   ] = tr( "RANGE_OF_IDS" );
       aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
       aCriteria[ SMESH::FT_RangeOfIds   ] = tr( "RANGE_OF_IDS" );
       aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
+      aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
     }
     return aCriteria;
   }
     }
     return aCriteria;
   }
@@ -1341,9 +1356,6 @@ SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable( QWidget*  thePar
   static int aLenCr = abs(  aMaxLenCr -
                             aMetrics.width( tr( "CRITERION" ) ) ) / aMetrics.width( ' ' ) + 5;
 
   static int aLenCr = abs(  aMaxLenCr -
                             aMetrics.width( tr( "CRITERION" ) ) ) / aMetrics.width( ' ' ) + 5;
 
-  static int aLenCo = abs(  maxLength( getCompare(), aMetrics ) -
-                            aMetrics.width( tr( "COMPARE" ) ) ) / aMetrics.width( ' ' ) + 5;
-
   QString aCrStr;
   aCrStr.fill( ' ', aLenCr );
   QString aCoStr;
   QString aCrStr;
   aCrStr.fill( ' ', aLenCr );
   QString aCoStr;
@@ -1876,6 +1888,8 @@ void SMESHGUI_FilterDlg::onDeactivate()
 void SMESHGUI_FilterDlg::enterEvent( QEvent* )
 {
 //  mySMESHGUI->EmitSignalDeactivateDialog();
 void SMESHGUI_FilterDlg::enterEvent( QEvent* )
 {
 //  mySMESHGUI->EmitSignalDeactivateDialog();
+  mySMESHGUI->SetActiveDialogBox( (QDialog*)this );
+  mySMESHGUI->ResetState();
   setEnabled( true );
 }
 
   setEnabled( true );
 }
 
@@ -1999,7 +2013,8 @@ bool SMESHGUI_FilterDlg::isValid() const
     int aType = myTable->GetCriterionType( i );
     if ( aType == FT_BelongToGeom ||
          aType == FT_BelongToPlane ||
     int aType = myTable->GetCriterionType( i );
     if ( aType == FT_BelongToGeom ||
          aType == FT_BelongToPlane ||
-         aType == FT_BelongToCylinder  )
+         aType == FT_BelongToCylinder ||
+        aType == FT_LyingOnGeom)
     {
       QString aName;
       myTable->GetThreshold( i, aName );
     {
       QString aName;
       myTable->GetThreshold( i, aName );
@@ -2312,7 +2327,7 @@ void SMESHGUI_FilterDlg::filterSelectionSource( const int theType,
 
       if ( aSelMap.Extent() > 0 )
       {
 
       if ( aSelMap.Extent() > 0 )
       {
-        if(SMESH_Actor *anActor = SMESH::FindActorByEntry( anIter.Key()->getEntry() ) )
+        if( SMESH::FindActorByEntry( anIter.Key()->getEntry() ) )
         {
           for ( int i = 1; i <= aSelMap.Extent(); i++ )
             aToBeFiltered.Add( aSelMap(i) );
         {
           for ( int i = 1; i <= aSelMap.Extent(); i++ )
             aToBeFiltered.Add( aSelMap(i) );
@@ -2418,7 +2433,8 @@ void SMESHGUI_FilterDlg::onSelectionDone()
         !myTable->CurrentCell( aRow, aCol ) ||
         myTable->GetCriterionType( aRow ) != FT_BelongToGeom &&
         myTable->GetCriterionType( aRow ) != FT_BelongToPlane &&
         !myTable->CurrentCell( aRow, aCol ) ||
         myTable->GetCriterionType( aRow ) != FT_BelongToGeom &&
         myTable->GetCriterionType( aRow ) != FT_BelongToPlane &&
-        myTable->GetCriterionType( aRow ) != FT_BelongToCylinder)
+        myTable->GetCriterionType( aRow ) != FT_BelongToCylinder &&
+       myTable->GetCriterionType( aRow ) != FT_LyingOnGeom )
     return;
 
   Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject() ;
     return;
 
   Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject() ;
@@ -2461,9 +2477,10 @@ void SMESHGUI_FilterDlg::updateSelection()
   if ( myTable->CurrentCell( aRow, aCol ) &&
        ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom ||
          myTable->GetCriterionType( aRow ) == FT_BelongToPlane ||
   if ( myTable->CurrentCell( aRow, aCol ) &&
        ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom ||
          myTable->GetCriterionType( aRow ) == FT_BelongToPlane ||
-         myTable->GetCriterionType( aRow ) == FT_BelongToCylinder ) )
+         myTable->GetCriterionType( aRow ) == FT_BelongToCylinder ||
+        myTable->GetCriterionType( aRow ) == FT_LyingOnGeom) )
   {
   {
-    if ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom )
+    if ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom ||  myTable->GetCriterionType( aRow ) == FT_LyingOnGeom )
       mySelection->AddFilter( new SALOME_TypeFilter( "GEOM" ) );
     else if ( myTable->GetCriterionType( aRow ) == FT_BelongToPlane )
       mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Plane ) );
       mySelection->AddFilter( new SALOME_TypeFilter( "GEOM" ) );
     else if ( myTable->GetCriterionType( aRow ) == FT_BelongToPlane )
       mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Plane ) );