Salome HOME
Qt4 porting. Modification, Orientation, Filter. Bad oriented volume criterion. Compar...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterDlg.cxx
index 7a12b1522513b79a55d1ed46ca6e13f44c6cee24..1ad06d9d0e88262278db9448f28a4594bd002919 100755 (executable)
@@ -1308,6 +1308,7 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
 
     if (aCompareItem->count() > 0)
       aCompareItem->clear();
+    aTable->setEditable(false, row, 1);
     aTable->setEditable(false, row, 2);
 
     aTable->blockSignals( isSignalsBlocked );
@@ -1322,6 +1323,8 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
     QMap<int, QString> aMap;
     aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO");
     aCompareItem->setItems(aMap);
+    if (!aTable->isEditable(row, 2))
+      aTable->setEditable(true, row, 1);
     if (!aTable->isEditable(row, 2))
       aTable->setEditable(true, row, 2);
   }
@@ -1336,6 +1339,8 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
     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);
   }
@@ -1691,6 +1696,21 @@ void SMESHGUI_FilterTable::SetEditable (const bool isEditable)
   {
     anIter.value()->setReadOnly(!isEditable);
 
+    // Set Flags for CheckItems directly IPAL 19974
+    Table* aTable = anIter.value();
+    for (int i = 0, n = aTable->rowCount(); i < n; i++)
+      for (int j = 0, m = aTable->columnCount(); j < m; j++)
+       {
+         QTableWidgetItem* anItem = aTable->item(i, j);
+         if ( dynamic_cast<SMESHGUI_FilterTable::CheckItem*>( anItem ) ) {
+           Qt::ItemFlags f = anItem->flags();
+           if (!isEditable) f = f & ~Qt::ItemIsUserCheckable;
+           else f = f | Qt::ItemIsUserCheckable;
+           anItem->setFlags( f );
+         }
+       }
+    //end of IPAL19974
+
     if (isEditable)
     {
       myAddBtn->show();
@@ -2062,11 +2082,11 @@ QWidget* SMESHGUI_FilterDlg::createButtonFrame (QWidget* theParent)
   aLay->setMargin(MARGIN);
   aLay->setSpacing(SPACING);
 
-  myButtons[ BTN_OK     ] = new QPushButton(tr("SMESH_BUT_OK"   ),  aGrp);
-  myButtons[ BTN_Apply  ] = new QPushButton(tr("SMESH_BUT_APPLY"),  aGrp);
-  myButtons[ BTN_Cancel ] = new QPushButton(tr("SMESH_BUT_CANCEL"), aGrp);
-  myButtons[ BTN_Close  ] = new QPushButton(tr("SMESH_BUT_CLOSE"),  aGrp);
-  myButtons[ BTN_Help   ] = new QPushButton(tr("SMESH_BUT_HELP"),   aGrp);
+  myButtons[ BTN_OK     ] = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGrp);
+  myButtons[ BTN_Apply  ] = new QPushButton(tr("SMESH_BUT_APPLY"),           aGrp);
+  myButtons[ BTN_Cancel ] = new QPushButton(tr("SMESH_BUT_CANCEL"),          aGrp);
+  myButtons[ BTN_Close  ] = new QPushButton(tr("SMESH_BUT_CLOSE"),           aGrp);
+  myButtons[ BTN_Help   ] = new QPushButton(tr("SMESH_BUT_HELP"),            aGrp);
 
   aLay->addWidget(myButtons[ BTN_OK     ]);
   aLay->addSpacing(10);
@@ -2460,9 +2480,13 @@ void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg)
 // name    : SMESHGUI_FilterDlg::SetGroupIds
 // Purpose : Set mesh
 //=======================================================================
-void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_ptr theMesh)
+void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_var theMesh)
 {
   myMesh = theMesh;
+  if ( myMesh->_is_nil() ) {
+    myButtons[BTN_OK]->setEnabled(false);
+    myButtons[BTN_Apply]->setEnabled(false);
+  }
 }
 
 //=======================================================================
@@ -2797,6 +2821,14 @@ void SMESHGUI_FilterDlg::onSelectionDone()
   int aRow, aCol;
   const SALOME_ListIO& aList = mySelector->StoredIObjects();
 
+  if ( myMesh->_is_nil() && aList.Extent()>0 ) {
+    myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(aList.First());
+    if ( !(myMesh->_is_nil()) ) {
+      myButtons[BTN_OK]->setEnabled(true);
+      myButtons[BTN_Apply]->setEnabled(true);
+    }
+  }
+
   if (aList.Extent() != 1 ||
       !myTable->CurrentCell(aRow, aCol) ||
       myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGeom &&
@@ -2816,6 +2848,7 @@ void SMESHGUI_FilterDlg::onSelectionDone()
     }
 }
 
+
 //=======================================================================
 // name    : SMESHGUI_FilterDlg::onCriterionChanged
 // Purpose : SLOT called when cretarion of current row changed. Update selection