Salome HOME
Merge remote branch 'origin/V8_5_asterstudy'
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterLibraryDlg.cxx
index 2fc4c48fd58947ca399c36f6ebac37713fc73e97..ed2c421c7a806b59ce9df20999b4aa01d37674a5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -153,7 +153,7 @@ void SMESHGUI_FilterLibraryDlg::construct (const QList<int>& theTypes,
 
   aDlgLay->setStretchFactor(myMainFrame, 1);
 
-  myHelpFileName = "selection_filter_library_page.html";
+  myHelpFileName = "selection_filter_library.html";
   
   Init(myTypes, myMode);
 }
@@ -430,7 +430,7 @@ bool SMESHGUI_FilterLibraryDlg::onApply()
   }
 
   if (myFileName->text() != myLibrary->GetFileName())
-    myLibrary->SetFileName( myFileName->text().toLatin1().constData() );
+    myLibrary->SetFileName( myFileName->text().toUtf8().constData() );
 
   bool aResult = false;
 
@@ -439,8 +439,8 @@ bool SMESHGUI_FilterLibraryDlg::onApply()
   } else if (myMode == EDIT || myMode == ADD_TO) {
     SMESH::Filter_var aFilter = createFilter();
     if (!myListBox->selectedItems().empty() && 
-        !myLibrary->Replace(myCurrFilterName.toLatin1().constData(),
-                            myName->text().toLatin1().constData(),
+        !myLibrary->Replace(myCurrFilterName.toUtf8().constData(),
+                            myName->text().toUtf8().constData(),
                             aFilter.in())) {
       SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
                                    tr("ERROR_OF_EDITING"));
@@ -517,7 +517,7 @@ void SMESHGUI_FilterLibraryDlg::onHelp()
 
 //=======================================================================
 // name    : SMESHGUI_FilterLibraryDlg::onDeactivate
-// Purpose : SLOT called when dialog must be deativated
+// Purpose : SLOT called when dialog must be deactivated
 //=======================================================================
 void SMESHGUI_FilterLibraryDlg::onDeactivate()
 {
@@ -602,7 +602,7 @@ QStringList SMESHGUI_FilterLibraryDlg::prepareFilters() const
 
 //================================================================
 // Function : onBrowse
-// Purpose  : SLOT. Display "Open file" dialog for chosing library name
+// Purpose  : SLOT. Display "Open file" dialog for choosing library name
 //================================================================
 void SMESHGUI_FilterLibraryDlg::onBrowse()
 {
@@ -611,7 +611,7 @@ void SMESHGUI_FilterLibraryDlg::onBrowse()
 
   //aDlg->setMode(myMode == COPY_FROM ? QFileDialogP::ExistingFile : QFileDialogP::AnyFile);
   aDlg->setFileMode(myMode == COPY_FROM ? QFileDialog::ExistingFile : QFileDialog::AnyFile);
-  aDlg->setFilters(prepareFilters());
+  aDlg->setNameFilters(prepareFilters());
   aDlg->selectFile(getFileName());
 
   QPushButton* anOkBtn = (QPushButton*)aDlg->findChild<QPushButton*>("OK");
@@ -629,8 +629,8 @@ void SMESHGUI_FilterLibraryDlg::onBrowse()
   if (QFileInfo(fName).suffix().isEmpty())
     fName = autoExtension(fName);
 
-  fName = QDir::convertSeparators(fName);
-  QString prev = QDir::convertSeparators(getFileName());
+  fName = QDir::toNativeSeparators(fName);
+  QString prev = QDir::toNativeSeparators(getFileName());
 
   if (prev == fName)
     return;
@@ -662,7 +662,7 @@ void SMESHGUI_FilterLibraryDlg::processNewLibrary()
   if (aFilterMgr->_is_nil())
     return;
 
-  myLibrary = aFilterMgr->LoadLibrary(autoExtension(getFileName()).toLatin1().constData());
+  myLibrary = aFilterMgr->LoadLibrary(autoExtension(getFileName()).toUtf8().constData());
   if (myLibrary->_is_nil()) {
     if (myMode == COPY_FROM) {
       SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
@@ -670,7 +670,7 @@ void SMESHGUI_FilterLibraryDlg::processNewLibrary()
       return;
     } else {
       myLibrary = aFilterMgr->CreateLibrary();
-      myLibrary->SetFileName(getFileName().toLatin1().constData());
+      myLibrary->SetFileName(getFileName().toUtf8().constData());
     }
   }
 
@@ -756,7 +756,7 @@ bool SMESHGUI_FilterLibraryDlg::isPermissionValid(const bool theIsExistingOnly)
   if (QFileInfo(fName).suffix().isEmpty())
     fName = autoExtension(fName);
 
-  fName = QDir::convertSeparators(fName);
+  fName = QDir::toNativeSeparators(fName);
 
   if (QFileInfo(fName).exists()) {
     isWritable = QFileInfo(fName).isWritable();
@@ -822,14 +822,14 @@ void SMESHGUI_FilterLibraryDlg::onFilterChanged()
     }
 
     SMESH::Filter_var aFilter = createFilter();
-    myLibrary->Replace(myCurrFilterName.toLatin1().constData(), 
-                       myName->text().toLatin1().constData(), 
+    myLibrary->Replace(myCurrFilterName.toUtf8().constData(), 
+                       myName->text().toUtf8().constData(), 
                        aFilter);
   }
 
   // Fill table with filter parameters
 
-  SMESH::Filter_var aFilter = myLibrary->Copy(theName.toLatin1().constData());
+  SMESH::Filter_var aFilter = myLibrary->Copy(theName.toUtf8().constData());
   myCurrFilterName = theName;
   myCurrFilter = myListBox->currentRow();
   myName->setText(theName);
@@ -892,7 +892,7 @@ void SMESHGUI_FilterLibraryDlg::enableMainButtons()
 
 //=======================================================================
 // name    : SMESHGUI_FilterLibraryDlg::createFilter
-// Purpose : Cerate filter in accordance with library
+// Purpose : Create filter in accordance with library
 //=======================================================================
 SMESH::Filter_ptr SMESHGUI_FilterLibraryDlg::createFilter(const int theType)
 {
@@ -929,8 +929,8 @@ void SMESHGUI_FilterLibraryDlg::onAddBtnPressed()
       return;
 
     SMESH::Filter_var aFilter = createFilter();
-    myLibrary->Replace(myCurrFilterName.toLatin1().constData(), 
-                       myName->text().toLatin1().constData(), 
+    myLibrary->Replace(myCurrFilterName.toUtf8().constData(), 
+                       myName->text().toUtf8().constData(), 
                        aFilter);
   }
   myTable->Clear(myTable->GetType());
@@ -966,8 +966,8 @@ void SMESHGUI_FilterLibraryDlg::addFilterToLib (const QString& theName)
 
   // add new filter in library
   bool aResult = !aFilter->GetPredicate()->_is_nil()
-    ? myLibrary->Add(aName.toLatin1().constData(), aFilter)
-    : myLibrary->AddEmpty(aName.toLatin1().constData(), (SMESH::ElementType)myTable->GetType());
+    ? myLibrary->Add(aName.toUtf8().constData(), aFilter)
+    : myLibrary->AddEmpty(aName.toUtf8().constData(), (SMESH::ElementType)myTable->GetType());
 
   if (!aResult) {
     SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
@@ -1087,7 +1087,7 @@ void SMESHGUI_FilterLibraryDlg::onDeleteBtnPressed()
 
   int anIndex = getIndex(myCurrFilterName);
 
-  if (anIndex == -1 || !myLibrary->Delete(myCurrFilterName.toLatin1().constData())) {
+  if (anIndex == -1 || !myLibrary->Delete(myCurrFilterName.toUtf8().constData())) {
     SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
                                  tr("ERROR_OF_DELETING"));
   } else {
@@ -1179,8 +1179,8 @@ void SMESHGUI_FilterLibraryDlg::onNeedValidation()
     if (valid)
     {
       SMESH::Filter_var aFilter = createFilter(myTable->GetType());
-      myLibrary->Replace(myCurrFilterName.toLatin1().constData(),
-                         myName->text().toLatin1().constData(),
+      myLibrary->Replace(myCurrFilterName.toUtf8().constData(),
+                         myName->text().toUtf8().constData(),
                          aFilter);
     }
   }
@@ -1205,11 +1205,11 @@ void SMESHGUI_FilterLibraryDlg::onSelectionDone()
     return;
 
   const int type = myTable->GetCriterionType(aRow);
-  QList<int> types; 
-  types << SMESH::FT_BelongToGeom     << SMESH::FT_BelongToPlane 
-        << SMESH::FT_BelongToCylinder << SMESH::FT_BelongToGenSurface
-        << SMESH::FT_LyingOnGeom      << SMESH::FT_CoplanarFaces
-        << SMESH::FT_ConnectedElements;
+  QList<int> types;
+  types << SMESH::FT_BelongToGeom      << SMESH::FT_BelongToPlane 
+        << SMESH::FT_BelongToCylinder  << SMESH::FT_BelongToGenSurface
+        << SMESH::FT_LyingOnGeom       << SMESH::FT_CoplanarFaces
+        << SMESH::FT_ConnectedElements << SMESH::FT_BelongToMeshGroup;
   if ( !types.contains( type ))
     return;
 
@@ -1241,6 +1241,10 @@ void SMESHGUI_FilterLibraryDlg::onSelectionDone()
       }
       break;
     }
+  case SMESH::FT_BelongToMeshGroup: // get a group name and IOR
+    {
+      myTable->SetThreshold(aRow, anIO->getName() );
+    }
   default: // get a GEOM object
     {
       GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);