Salome HOME
0020321: EDF : Some windows do not appear depending on the platform (MinimumSizeHint())
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterDlg.cxx
index 0b55d8b711ff4b2f1b4ed8f739136bca667dea49..c6b4b699fe38ba7e4090eb5aa6b9fedb7b60d7c3 100755 (executable)
@@ -1120,10 +1120,12 @@ void SMESHGUI_FilterTable::SetCriterion (const int                       theRow,
       aTable->item( theRow, 5 )->setText( QString( theCriterion.ThresholdID ) );
   }
 
-  if (theCriterion.Compare == SMESH::FT_EqualTo ||
+  if (theCriterion.Compare  == SMESH::FT_EqualTo ||
        theCriterion.Type    == SMESH::FT_BelongToPlane ||
        theCriterion.Type    == SMESH::FT_BelongToCylinder ||
-       theCriterion.Type    == SMESH::FT_BelongToGenSurface)
+       theCriterion.Type    == SMESH::FT_BelongToGenSurface ||
+       theCriterion.Type    == SMESH::FT_BelongToGeom ||
+       theCriterion.Type    == SMESH::FT_LyingOnGeom)
   {
     QTableWidgetItem* anItem = aTable->item(theRow, 0);
     if (!myAddWidgets.contains(anItem))
@@ -1264,8 +1266,6 @@ void SMESHGUI_FilterTable::updateAdditionalWidget()
   ComboItem* anItem = ((ComboItem*)aTable->item(aRow, 0));
   int aCriterion = GetCriterionType(aRow);
   bool toEnable = ((ComboItem*)aTable->item(aRow, 1))->value() == SMESH::FT_EqualTo &&
-                  aCriterion != SMESH::FT_BelongToGeom &&
-                  aCriterion != SMESH::FT_LyingOnGeom &&
                   aCriterion != SMESH::FT_RangeOfIds &&
                   aCriterion != SMESH::FT_FreeEdges &&
                   aCriterion != SMESH::FT_FreeFaces &&
@@ -1370,7 +1370,13 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
 
   int aCriterionType = GetCriterionType(row);
   QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(row, 2));
-  bool isComboItem = aTable->item(row, 2)->type() == ComboItem::Type();
+  int aComboType = ComboItem::Type();
+  QTableWidgetItem* aTableItem = aTable->item(row, 2);
+  bool isComboItem = false;
+  if (aTableItem) {
+    int aTableType = aTable->item(row, 2)->type();
+    isComboItem = aTableType == aComboType ? true : false;
+  }
   
   if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) ||
        (aCriterionType != SMESH::FT_ElemGeomType && isComboItem) )
@@ -1445,19 +1451,21 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
   }
   else
   {
-    if (aCompareItem->count() != 3)
+    if (aCompareItem && aCompareItem->count() != 3)
     {
       aCompareItem->setItems(getCompare());
     }
 
-    QString aText = aTable->text(row, 2);
-    bool isOk = false;
-    aText.toDouble(&isOk);
-    aTable->item( row, 2 )->setText(isOk ? aText : QString(""));
-    if (!aTable->isEditable(row, 1))
-      aTable->setEditable(true, row, 1);
-    if (!aTable->isEditable(row, 2))
-      aTable->setEditable(true, row, 2);
+    if (aTable->item( row, 2 )) {
+      QString aText = aTable->text(row, 2);
+      bool isOk = false;
+      aText.toDouble(&isOk);
+      aTable->item( row, 2 )->setText(isOk ? aText : QString(""));
+      if (!aTable->isEditable(row, 1))
+       aTable->setEditable(true, row, 1);
+      if (!aTable->isEditable(row, 2))
+       aTable->setEditable(true, row, 2);
+    }
   }
 
   updateAdditionalWidget();
@@ -2057,7 +2065,8 @@ SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI*         theModule,
                                         const QList<int>& theTypes )
 : QDialog( SMESH::GetDesktop( theModule ) ),
   mySMESHGUI( theModule ),
-  mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+  mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+  myInitSourceWgOnApply( true )
 {
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
     mySelector = aViewWindow->GetSelector();
@@ -2073,7 +2082,8 @@ SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI*   theModule,
                                         const int   theType )
 : QDialog( SMESH::GetDesktop( theModule ) ),
   mySMESHGUI( theModule ),
-  mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+  mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+  myInitSourceWgOnApply( true )
 {
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
     mySelector = aViewWindow->GetSelector();
@@ -2609,9 +2619,11 @@ bool SMESHGUI_FilterDlg::isValid() const
 // Purpose : Set widget of parent dialog containing idsto be filtered if
 //           user select corresponding source radio button
 //=======================================================================
-void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg)
+void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg,
+                                      const bool initOnApply)
 {
   mySourceWg = theWg;
+  myInitSourceWgOnApply = initOnApply;
 }
 
 //=======================================================================
@@ -2637,7 +2649,7 @@ void SMESHGUI_FilterDlg::SetSelection()
 
   if (mySelectionMgr) {
     myIObjects.Clear();
-    const SALOME_ListIO& anObjs = mySelector->StoredIObjects();
+    const SALOME_ListIO& anObjs = mySelector->StoredIObjects(); 
     SALOME_ListIteratorOfListIO anIter (anObjs);
     for ( ; anIter.More(); anIter.Next()) {
       TColStd_IndexedMapOfInteger aMap;
@@ -2674,9 +2686,11 @@ bool SMESHGUI_FilterDlg::onApply()
     if (!myFilter[ aCurrType ]->GetPredicate()->_is_nil()) {
       QList<int> aResultIds;
       filterSource(aCurrType, aResultIds);
+      // select in viewer
       selectInViewer(aCurrType, aResultIds);
     }
 
+
     myInsertState[ aCurrType ] = mySetInViewer->isChecked();
     myApplyToState[ aCurrType ] = mySourceGrp->checkedId();
   }
@@ -2792,10 +2806,10 @@ void SMESHGUI_FilterDlg::filterSource (const int theType,
     for (anIter = aDialogIds.begin(); anIter != aDialogIds.end(); ++ anIter)
       if (aPred->IsSatisfy(*anIter))
         theResIds.append(*anIter);
-
-    // set ids to the dialog
-    setIdsToWg(mySourceWg, theResIds);
   }
+  // set ids to the dialog
+  if (myInitSourceWgOnApply || aSourceId == Dialog)
+    setIdsToWg(mySourceWg, theResIds);
 }
 
 //=======================================================================