Salome HOME
Fix for bug PAL9590 (SIGSEV when creating a SMESH group on Debian Sarge).
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterDlg.cxx
index 7aeb763d3f6655cdd93c1f08f7159fe6168df0bf..d0b3578b44a6a3390d63aec27773fee4fe0f592a 100755 (executable)
 #include <qobjectlist.h>
 #include <qvalidator.h>
 
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
 #define SPACING 5                  
 #define MARGIN  10
 
@@ -416,7 +420,8 @@ QString SMESHGUI_FilterTable::Table::text( int row, int col ) const
 //=======================================================================
 SMESHGUI_FilterTable::SMESHGUI_FilterTable( QWidget* parent, 
                                             const int type )
-: QFrame( parent )                                            
+: QFrame( parent ),
+  myIsLocked( false )
 {
   myEntityType = -1;
   Init( type );
@@ -428,7 +433,8 @@ SMESHGUI_FilterTable::SMESHGUI_FilterTable( QWidget* parent,
 //=======================================================================
 SMESHGUI_FilterTable::SMESHGUI_FilterTable( QWidget* parent, 
                                             const QValueList<int>& types )
-: QFrame( parent )                                            
+: QFrame( parent ),
+  myIsLocked( false )
 {
   myEntityType = -1;
   Init( types );
@@ -654,7 +660,8 @@ bool SMESHGUI_FilterTable::IsValid( const bool theMess, const int theEntityType
     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() )
       {
@@ -768,7 +775,8 @@ void SMESHGUI_FilterTable::GetCriterion( const int                 theRow,
   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();
@@ -813,7 +821,8 @@ void SMESHGUI_FilterTable::SetCriterion( const int                       theRow,
   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 ) );
@@ -902,7 +911,6 @@ void SMESHGUI_FilterTable::onAddBtn()
   int aType = GetType();
   addRow( myTables[ aType ], aType );
 
-  Table* aTable = myTables[ aType ];
   Update();
 }
 
@@ -965,8 +973,10 @@ 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 &&
+                  GetCriterionType( aRow ) != FT_LyingOnGeom &&
                   GetCriterionType( aRow ) != FT_RangeOfIds &&
-                  GetCriterionType( aRow ) != FT_FreeEdges;
+                  GetCriterionType( aRow ) != FT_FreeEdges && 
+                 GetCriterionType( aRow ) != FT_BadOrientedVolume;
   if ( !myAddWidgets.contains( anItem ) )
   {
     myAddWidgets[ anItem ] = new AdditionalWidget( myWgStack );
@@ -1021,7 +1031,8 @@ void SMESHGUI_FilterTable::onClearBtn()
 //=======================================================================
 void SMESHGUI_FilterTable::onCurrentChanged( int theRow, int theCol )
 {
-  updateAdditionalWidget();
+  if( !myIsLocked )
+    updateAdditionalWidget();
   emit CurrentChanged( theRow, theCol );
 }
 
@@ -1038,7 +1049,8 @@ void SMESHGUI_FilterTable::onCriterionChanged( const int row, const int col, con
   int aCriterionType = GetCriterionType( row );
 
   if ( aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders ||
-       aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges )
+       aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges || 
+       aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume )
   {
     if ( aCompareItem->count() > 0 )
       aCompareItem->setStringList( QStringList() );
@@ -1047,7 +1059,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 ||
-            aCriterionType == SMESH::FT_BelongToCylinder )
+            aCriterionType == SMESH::FT_BelongToCylinder ||
+           aCriterionType == SMESH::FT_LyingOnGeom)
   {
     QMap<int, QString> aMap;
     aMap[ FT_EqualTo ] = tr( "EQUAL_TO" );
@@ -1111,6 +1124,7 @@ void SMESHGUI_FilterTable::addRow( Table* theTable, const int theType, const boo
   int aSelectedRow = getFirstSelectedRow();
   int aCurrCol = theTable->currentColumn();
 
+  myIsLocked = true;
   if ( toTheEnd || aSelectedRow == -1 )
   {
     theTable->insertRows( theTable->numRows() );
@@ -1121,6 +1135,7 @@ void SMESHGUI_FilterTable::addRow( Table* theTable, const int theType, const boo
     theTable->insertRows( aSelectedRow );
     aCurrRow = aSelectedRow;
   }
+  myIsLocked = false;
 
   // Criteria
   theTable->setItem( aCurrRow, 0, getCriterionItem( theTable, theType ) );
@@ -1239,6 +1254,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_LyingOnGeom      ] = tr( "LYING_ON_GEOM" );
     }
     return aCriteria;
   }
@@ -1254,6 +1270,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_LyingOnGeom      ] = tr( "LYING_ON_GEOM" );
     }
     return aCriteria;
   }
@@ -1273,6 +1290,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_LyingOnGeom      ] = tr( "LYING_ON_GEOM" );
+      aCriteria[ SMESH::FT_Length2D         ] = tr( "LENGTH2D" );
+      aCriteria[ SMESH::FT_MultiConnection2D] = tr( "MULTI2D_BORDERS" );
     }
     return aCriteria;
   }
@@ -1281,8 +1301,11 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria( const int theType )
     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_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
+      aCriteria[ SMESH::FT_BadOrientedVolume ] = tr( "BAD_ORIENTED_VOLUME" );
     }
     return aCriteria;
   }
@@ -1341,9 +1364,6 @@ SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable( QWidget*  thePar
   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;
@@ -1876,6 +1896,8 @@ void SMESHGUI_FilterDlg::onDeactivate()
 void SMESHGUI_FilterDlg::enterEvent( QEvent* )
 {
 //  mySMESHGUI->EmitSignalDeactivateDialog();
+  mySMESHGUI->SetActiveDialogBox( (QDialog*)this );
+  mySMESHGUI->ResetState();
   setEnabled( true );
 }
 
@@ -1999,7 +2021,8 @@ bool SMESHGUI_FilterDlg::isValid() const
     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 );
@@ -2312,7 +2335,7 @@ void SMESHGUI_FilterDlg::filterSelectionSource( const int theType,
 
       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) );
@@ -2418,13 +2441,14 @@ void SMESHGUI_FilterDlg::onSelectionDone()
         !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() ;
   GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>( anIO ) ;
   if ( !anObj->_is_nil() )
-    myTable->SetThreshold( aRow, anIO->getName() );
+    myTable->SetThreshold( aRow, GEOMBase::GetName(anObj) );
 }
 
 //=======================================================================
@@ -2461,9 +2485,10 @@ void SMESHGUI_FilterDlg::updateSelection()
   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 ) );