Salome HOME
IMP 10199 (add Volume Control)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterDlg.cxx
index 873c5f68816618332dd27a6699b8e9c064c6c2f9..95f8ed3039d5e3e72b2157a38ba6a641790c1e4f 100755 (executable)
@@ -396,7 +396,7 @@ void SMESHGUI_FilterTable::Table::insertRows (int row, int count)
   if (anEditRow >= 0 && anEditCol >= 0)
     endEdit(anEditRow, anEditCol, true, false);
 
   if (anEditRow >= 0 && anEditCol >= 0)
     endEdit(anEditRow, anEditCol, true, false);
 
-  QTable::insertRows(row, count);
+  QTable::insertRows( row, count );
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -427,9 +427,12 @@ QString SMESHGUI_FilterTable::Table::text (int row, int col) const
 // name    : SMESHGUI_FilterTable::SMESHGUI_FilterTable
 // Purpose : Constructor
 //=======================================================================
 // name    : SMESHGUI_FilterTable::SMESHGUI_FilterTable
 // Purpose : Constructor
 //=======================================================================
-SMESHGUI_FilterTable::SMESHGUI_FilterTable (QWidget* parent,
+SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
+                                            QWidget* parent,
                                             const int type)
                                             const int type)
-: QFrame(parent)
+: QFrame(parent),
+  myIsLocked( false ),
+  mySMESHGUI( theModule )
 {
   myEntityType = -1;
   Init(type);
 {
   myEntityType = -1;
   Init(type);
@@ -439,9 +442,12 @@ SMESHGUI_FilterTable::SMESHGUI_FilterTable (QWidget* parent,
 // name    : SMESHGUI_FilterTable::SMESHGUI_FilterTable
 // Purpose : Constructor
 //=======================================================================
 // name    : SMESHGUI_FilterTable::SMESHGUI_FilterTable
 // Purpose : Constructor
 //=======================================================================
-SMESHGUI_FilterTable::SMESHGUI_FilterTable (QWidget* parent,
+SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
+                                            QWidget* parent,
                                             const QValueList<int>& types)
                                             const QValueList<int>& types)
-: QFrame(parent)
+: QFrame(parent),
+  myIsLocked( false ),
+  mySMESHGUI( theModule )
 {
   myEntityType = -1;
   Init(types);
 {
   myEntityType = -1;
   Init(types);
@@ -668,7 +674,7 @@ bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType)
          aCriterion == FT_BelongToGeom ||
          aCriterion == FT_BelongToPlane ||
          aCriterion == FT_BelongToCylinder ||
          aCriterion == FT_BelongToGeom ||
          aCriterion == FT_BelongToPlane ||
          aCriterion == FT_BelongToCylinder ||
-        aCriterion == FT_LyingOnGeom) {
+         aCriterion == FT_LyingOnGeom) {
       if (aTable->text(i, 2).isEmpty()) {
         if (theMess)
           QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
       if (aTable->text(i, 2).isEmpty()) {
         if (theMess)
           QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
@@ -842,7 +848,7 @@ void SMESHGUI_FilterTable::SetCriterion (const int                       theRow,
     myAddWidgets[ anItem ]->SetDouble(AdditionalWidget::Tolerance, theCriterion.Tolerance);
   }
 
     myAddWidgets[ anItem ]->SetDouble(AdditionalWidget::Tolerance, theCriterion.Tolerance);
   }
 
-  emit CretarionChanged(theRow, aType);
+  emit CriterionChanged(theRow, aType);
 
 }
 
 
 }
 
@@ -978,7 +984,7 @@ void SMESHGUI_FilterTable::updateAdditionalWidget()
                   GetCriterionType(aRow) != FT_LyingOnGeom &&
                   GetCriterionType(aRow) != FT_RangeOfIds &&
                   GetCriterionType(aRow) != FT_FreeEdges &&
                   GetCriterionType(aRow) != FT_LyingOnGeom &&
                   GetCriterionType(aRow) != FT_RangeOfIds &&
                   GetCriterionType(aRow) != FT_FreeEdges &&
-                 GetCriterionType(aRow) != FT_BadOrientedVolume;
+                  GetCriterionType(aRow) != FT_BadOrientedVolume;
   if (!myAddWidgets.contains(anItem))
   {
     myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack);
   if (!myAddWidgets.contains(anItem))
   {
     myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack);
@@ -1033,7 +1039,8 @@ void SMESHGUI_FilterTable::onClearBtn()
 //=======================================================================
 void SMESHGUI_FilterTable::onCurrentChanged (int theRow, int theCol)
 {
 //=======================================================================
 void SMESHGUI_FilterTable::onCurrentChanged (int theRow, int theCol)
 {
-  updateAdditionalWidget();
+  if( !myIsLocked )
+    updateAdditionalWidget();
   emit CurrentChanged(theRow, theCol);
 }
 
   emit CurrentChanged(theRow, theCol);
 }
 
@@ -1058,10 +1065,10 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
     aTable->SetEditable(false, row, 2);
   }
   else if (aCriterionType == SMESH::FT_RangeOfIds ||
     aTable->SetEditable(false, row, 2);
   }
   else if (aCriterionType == SMESH::FT_RangeOfIds ||
-            aCriterionType == SMESH::FT_BelongToGeom ||
-            aCriterionType == SMESH::FT_BelongToPlane ||
-            aCriterionType == SMESH::FT_BelongToCylinder ||
-           aCriterionType == SMESH::FT_LyingOnGeom)
+           aCriterionType == SMESH::FT_BelongToGeom ||
+           aCriterionType == SMESH::FT_BelongToPlane ||
+           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");
@@ -1087,7 +1094,7 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
 
   updateAdditionalWidget();
 
 
   updateAdditionalWidget();
 
-  emit CretarionChanged(row, entityType);
+  emit CriterionChanged(row, entityType);
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -1125,6 +1132,7 @@ void SMESHGUI_FilterTable::addRow (Table* theTable, const int theType, const boo
   int aSelectedRow = getFirstSelectedRow();
   int aCurrCol = theTable->currentColumn();
 
   int aSelectedRow = getFirstSelectedRow();
   int aCurrCol = theTable->currentColumn();
 
+  myIsLocked = true;
   if (toTheEnd || aSelectedRow == -1)
   {
     theTable->insertRows(theTable->numRows());
   if (toTheEnd || aSelectedRow == -1)
   {
     theTable->insertRows(theTable->numRows());
@@ -1135,6 +1143,7 @@ void SMESHGUI_FilterTable::addRow (Table* theTable, const int theType, const boo
     theTable->insertRows(aSelectedRow);
     aCurrRow = aSelectedRow;
   }
     theTable->insertRows(aSelectedRow);
     aCurrRow = aSelectedRow;
   }
+  myIsLocked = false;
 
   // Criteria
   theTable->setItem(aCurrRow, 0, getCriterionItem(theTable, theType));
 
   // Criteria
   theTable->setItem(aCurrRow, 0, getCriterionItem(theTable, theType));
@@ -1305,6 +1314,7 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria (const int theType)
       aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
       aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
       aCriteria[ SMESH::FT_BadOrientedVolume ] = tr("BAD_ORIENTED_VOLUME");
       aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
       aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
       aCriteria[ SMESH::FT_BadOrientedVolume ] = tr("BAD_ORIENTED_VOLUME");
+      aCriteria[ SMESH::FT_Volume3D ] = tr("VOLUME_3D");
     }
     return aCriteria;
   }
     }
     return aCriteria;
   }
@@ -1490,7 +1500,7 @@ void SMESHGUI_FilterTable::onCopyFromBtn()
 {
   if (myLibDlg == 0)
     myLibDlg = new SMESHGUI_FilterLibraryDlg(
 {
   if (myLibDlg == 0)
     myLibDlg = new SMESHGUI_FilterLibraryDlg(
-      this, GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
+      mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
   else
     myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
 
   else
     myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
 
@@ -1512,7 +1522,7 @@ void SMESHGUI_FilterTable::onAddToBtn()
     return;
   if (myLibDlg == 0)
     myLibDlg = new SMESHGUI_FilterLibraryDlg(
     return;
   if (myLibDlg == 0)
     myLibDlg = new SMESHGUI_FilterLibraryDlg(
-      this, GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
+      mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
   else
     myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
 
   else
     myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
 
@@ -1595,10 +1605,11 @@ SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI*              theModule,
 : QDialog( SMESH::GetDesktop( theModule ), theName, false,
            WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
      mySMESHGUI( theModule ),
 : QDialog( SMESH::GetDesktop( theModule ), theName, false,
            WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
      mySMESHGUI( theModule ),
-     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
-     myViewWindow( SMESH::GetViewWindow( theModule ) ),
-     mySelector( myViewWindow->GetSelector() )
+     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
 {
 {
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    mySelector = aViewWindow->GetSelector();
+
   construct(theTypes);
 }
 
   construct(theTypes);
 }
 
@@ -1612,10 +1623,10 @@ SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI*   theModule,
 : QDialog( SMESH::GetDesktop( theModule ), theName, false,
            WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
      mySMESHGUI( theModule ),
 : QDialog( SMESH::GetDesktop( theModule ), theName, false,
            WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
      mySMESHGUI( theModule ),
-     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
-     myViewWindow( SMESH::GetViewWindow( theModule ) ),
-     mySelector( myViewWindow->GetSelector() )
+     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
 {
 {
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    mySelector = aViewWindow->GetSelector();
   QValueList<int> aTypes;
   aTypes.append(theType);
   construct(aTypes);
   QValueList<int> aTypes;
   aTypes.append(theType);
   construct(aTypes);
@@ -1656,7 +1667,7 @@ QFrame* SMESHGUI_FilterDlg::createMainFrame (QWidget* theParent)
 
   // filter frame
 
 
   // filter frame
 
-  myTable = new SMESHGUI_FilterTable(aMainFrame, myTypes);
+  myTable = new SMESHGUI_FilterTable( mySMESHGUI, aMainFrame, myTypes );
   myTable->SetLibsEnabled(true);
 
   QFrame* aLine = new QFrame(myTable->GetTableGrp());
   myTable->SetLibsEnabled(true);
 
   QFrame* aLine = new QFrame(myTable->GetTableGrp());
@@ -1668,7 +1679,7 @@ QFrame* SMESHGUI_FilterDlg::createMainFrame (QWidget* theParent)
   // other controls
   mySourceGrp = createSourceGroup(aMainFrame);
 
   // other controls
   mySourceGrp = createSourceGroup(aMainFrame);
 
-  connect(myTable, SIGNAL(CretarionChanged(const int, const int)),
+  connect(myTable, SIGNAL(CriterionChanged(const int, const int)),
                     SLOT(onCriterionChanged(const int, const int)));
 
   connect(myTable, SIGNAL(CurrentChanged(int, int)),
                     SLOT(onCriterionChanged(const int, const int)));
 
   connect(myTable, SIGNAL(CurrentChanged(int, int)),
@@ -1876,7 +1887,8 @@ void SMESHGUI_FilterDlg::onClose()
         aResMap.Add(anIndMap(i));
 
       mySelector->AddOrRemoveIndex( anIter.Key(), aResMap, false);
         aResMap.Add(anIndMap(i));
 
       mySelector->AddOrRemoveIndex( anIter.Key(), aResMap, false);
-      myViewWindow->highlight( anIter.Key(), true, true );
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+        aViewWindow->highlight( anIter.Key(), true, true );
     }
     mySelectionMgr->setSelectedObjects(aList, false);
   }
     }
     mySelectionMgr->setSelectedObjects(aList, false);
   }
@@ -2027,9 +2039,9 @@ bool SMESHGUI_FilterDlg::isValid() const
   {
     int aType = myTable->GetCriterionType(i);
     if (aType == FT_BelongToGeom ||
   {
     int aType = myTable->GetCriterionType(i);
     if (aType == FT_BelongToGeom ||
-         aType == FT_BelongToPlane ||
-         aType == FT_BelongToCylinder ||
-        aType == FT_LyingOnGeom) {
+        aType == FT_BelongToPlane ||
+        aType == FT_BelongToCylinder ||
+        aType == FT_LyingOnGeom) {
       QString aName;
       myTable->GetThreshold(i, aName);
 
       QString aName;
       myTable->GetThreshold(i, aName);
 
@@ -2181,15 +2193,10 @@ bool SMESHGUI_FilterDlg::createFilter (const int theType)
   aCriteria->length(n);
 
   long aPrecision = -1;
   aCriteria->length(n);
 
   long aPrecision = -1;
-  SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
+  SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
 
 
-  if (mgr && mgr->hasValue("SMESH", "ControlsPrecision")) {
-    QString aStr = mgr->stringValue("SMESH", "ControlsPrecision");
-    bool isOk = false;
-    int aVal = aStr.toInt(&isOk);
-    if (isOk)
-      aPrecision = aVal;
-  }
+  if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
+    aPrecision = mgr->integerValue( "SMESH", "controls_precision", aPrecision );
 
   for (CORBA::ULong i = 0; i < n; i++) {
     SMESH::Filter::Criterion aCriterion = createCriterion();
 
   for (CORBA::ULong i = 0; i < n; i++) {
     SMESH::Filter::Criterion aCriterion = createCriterion();
@@ -2357,12 +2364,13 @@ void SMESHGUI_FilterDlg::selectInViewer (const int theType, const QValueList<int
 
   // Set new selection mode if necessary
   Selection_Mode aSelMode = getSelMode(theType);
 
   // Set new selection mode if necessary
   Selection_Mode aSelMode = getSelMode(theType);
-  if (myViewWindow->SelectionMode()!=aSelMode) {
+  SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+  if ( aViewWindow && aViewWindow->SelectionMode()!=aSelMode) {
     mySelectionMgr->clearSelected();
     mySelectionMgr->clearFilters();
     if (aSelMode == NodeSelection)
       SMESH::SetPointRepresentation(true);
     mySelectionMgr->clearSelected();
     mySelectionMgr->clearFilters();
     if (aSelMode == NodeSelection)
       SMESH::SetPointRepresentation(true);
-    myViewWindow->SetSelectionMode(aSelMode);
+    aViewWindow->SetSelectionMode(aSelMode);
   }
 
   // Clear selection
   }
 
   // Clear selection
@@ -2395,7 +2403,8 @@ void SMESHGUI_FilterDlg::selectInViewer (const int theType, const QValueList<int
 
   // Set new selection
   mySelector->AddOrRemoveIndex(anIO, aMap, false);
 
   // Set new selection
   mySelector->AddOrRemoveIndex(anIO, aMap, false);
-  myViewWindow->highlight( anIO, true, true );
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    aViewWindow->highlight( anIO, true, true );
 
   // insert previously stored filter in viewer if necessary
   if (!aFilter.IsNull())
 
   // insert previously stored filter in viewer if necessary
   if (!aFilter.IsNull())
@@ -2486,15 +2495,15 @@ void SMESHGUI_FilterDlg::updateSelection()
   int aRow, aCol;
 
   if (myTable->CurrentCell(aRow, aCol) &&
   int aRow, aCol;
 
   if (myTable->CurrentCell(aRow, aCol) &&
-       (myTable->GetCriterionType(aRow) == FT_BelongToGeom ||
-         myTable->GetCriterionType(aRow) == FT_BelongToPlane ||
-         myTable->GetCriterionType(aRow) == FT_BelongToCylinder ||
-        myTable->GetCriterionType(aRow) == FT_LyingOnGeom)) {
+      (myTable->GetCriterionType(aRow) == FT_BelongToGeom ||
+       myTable->GetCriterionType(aRow) == FT_BelongToPlane ||
+       myTable->GetCriterionType(aRow) == FT_BelongToCylinder ||
+       myTable->GetCriterionType(aRow) == FT_LyingOnGeom)) {
 
     if (myTable->GetCriterionType(aRow) == FT_BelongToGeom ||
         myTable->GetCriterionType(aRow) == FT_LyingOnGeom) {
 
 
     if (myTable->GetCriterionType(aRow) == FT_BelongToGeom ||
         myTable->GetCriterionType(aRow) == FT_LyingOnGeom) {
 
-      mySelectionMgr->installFilter(new SMESH_NumberFilter("GEOM",TopAbs_SHAPE,0,allTypes));
+      mySelectionMgr->installFilter(new GEOM_SelectionFilter( aStudy, true ));
 
     } else if (myTable->GetCriterionType(aRow) == FT_BelongToPlane) {
       mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) );
 
     } else if (myTable->GetCriterionType(aRow) == FT_BelongToPlane) {
       mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) );
@@ -2506,7 +2515,7 @@ void SMESHGUI_FilterDlg::updateSelection()
 
   } else {
     if (myIsSelectionChanged) {
 
   } else {
     if (myIsSelectionChanged) {
-      mySelectionMgr->installFilter(new SMESH_NumberFilter ("This filter deactivates selection",TopAbs_SHAPE,0,allTypes));
+      mySelectionMgr->installFilter( new GEOM_TypeFilter( aStudy, -1 ) ); // This filter deactivates selection
     }
   }
 }
     }
   }
 }