X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_FilterLibraryDlg.cxx;h=acb75c27319dfe500a97ca49f449e0e1d15a710c;hp=d360c4a6f2e1a073003a6d39dde6522c86a60f70;hb=79c2ca913cedd84dfa84aa672d9acc1b12ad335d;hpb=5d68554076bbca0e1e95fb0db215a6c2b84b6c54 diff --git a/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx index d360c4a6f..acb75c273 100644 --- a/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 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 @@ -30,6 +30,9 @@ #include "SMESHGUI.h" #include "SMESHGUI_FilterUtils.h" #include "SMESHGUI_FilterDlg.h" +#include "SMESHGUI_VTKUtils.h" + +#include // SALOME GUI includes #include @@ -37,8 +40,9 @@ #include #include #include - #include +#include +#include // Qt includes #include @@ -233,13 +237,16 @@ QWidget* SMESHGUI_FilterLibraryDlg::createMainFrame (QWidget* theParent) connect(myDeleteBtn, SIGNAL(clicked()), this, SLOT(onDeleteBtnPressed())); connect(myName, SIGNAL(textChanged(const QString&)), - this, SLOT(onFilterNameChanged(const QString&))); + this, SLOT(onFilterNameChanged(const QString&))); connect(myTable, SIGNAL(EntityTypeChanged(const int)), - this, SLOT(onEntityTypeChanged(const int))); + this, SLOT(onEntityTypeChanged(const int))); connect(myTable, SIGNAL(NeedValidation()), this, SLOT(onNeedValidation())); + LightApp_SelectionMgr* selMgr = SMESH::GetSelectionMgr( mySMESHGUI ); + connect( selMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + return aMainFrame; } @@ -604,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("OK"); @@ -622,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; @@ -749,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(); @@ -1179,6 +1186,77 @@ void SMESHGUI_FilterLibraryDlg::onNeedValidation() } } + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onSelectionDone +// Purpose : SLOT called when selection changed. +// If current cell corresponds to the threshold value of +// BelongToGeom criterion name of selected object is set in this cell +//======================================================================= + +void SMESHGUI_FilterLibraryDlg::onSelectionDone() +{ + SALOME_ListIO aList; + if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() ) + aSel->selectedObjects( aList ); + + int aRow, aCol; + if (aList.Extent() != 1 || !myTable->CurrentCell(aRow, aCol)) + return; + + const int type = myTable->GetCriterionType(aRow); + QList 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; + + Handle(SALOME_InteractiveObject) anIO = aList.First(); + switch ( type ) + { + case SMESH::FT_CoplanarFaces: // get ID of a selected mesh face + { + QString aString; + int nbElems = SMESH::GetNameOfSelectedElements(SMESH::GetSelector(), anIO, aString); + if (nbElems == 1) + myTable->SetThreshold(aRow, aString); + break; + } + case SMESH::FT_ConnectedElements: // get either VERTEX or a node ID + { + GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface(anIO); + if (!anObj->_is_nil()) + { + myTable->SetThreshold(aRow, GEOMBase::GetName(anObj)); + myTable->SetID (aRow, anIO->getEntry()); + } + else + { + QString aString; + int nbElems = SMESH::GetNameOfSelectedElements(SMESH::GetSelector(), anIO, aString); + if (nbElems == 1) + myTable->SetThreshold(aRow, aString); + } + 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(anIO); + if (!anObj->_is_nil()) + { + myTable->SetThreshold(aRow, GEOMBase::GetName(anObj)); + myTable->SetID (aRow, anIO->getEntry()); + } + } + } +} + //================================================================================= // function : keyPressEvent() // purpose :