X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_FilterDlg.cxx;h=baf6c82a65c173fd0c77228e27d31c7442cfb17f;hb=85c0f447729c6ed2f90d83051d79a4d308596a2e;hp=547eae30bdd6738d74cdb75442be1e0f6775b83d;hpb=4ff5bd61540272713e48de1eee75625028c32155;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index 547eae30b..baf6c82a6 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -1,6 +1,6 @@ -// SMESH SMESHGUI : GUI for SMESH component +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_FilterDlg.cxx // Author : Sergey LITONIN // Module : SMESH - +// #include "SMESHGUI_FilterDlg.h" #include "SMESHGUI.h" @@ -44,8 +43,10 @@ #include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" -#include "SalomeApp_Application.h" +#include "LightApp_Application.h" #include "SalomeApp_Tools.h" #include "SalomeApp_Study.h" @@ -674,6 +675,7 @@ bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType) aCriterion == FT_BelongToGeom || aCriterion == FT_BelongToPlane || aCriterion == FT_BelongToCylinder || + aCriterion == FT_BelongToGenSurface || aCriterion == FT_LyingOnGeom) { if (aTable->text(i, 2).isEmpty()) { if (theMess) @@ -784,6 +786,7 @@ void SMESHGUI_FilterTable::GetCriterion (const int theRow, aCriterionType != FT_BelongToGeom && aCriterionType != FT_BelongToPlane && aCriterionType != FT_BelongToCylinder && + aCriterionType != FT_BelongToGenSurface && aCriterionType != FT_LyingOnGeom) { theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->GetValue(); @@ -831,10 +834,14 @@ void SMESHGUI_FilterTable::SetCriterion (const int theRow, aTable->SetEditable(false, theRow, 4); if (theCriterion.Type != FT_RangeOfIds && - theCriterion.Type != FT_BelongToGeom && - theCriterion.Type != FT_BelongToPlane && - theCriterion.Type != FT_BelongToCylinder && - theCriterion.Type != FT_LyingOnGeom) + theCriterion.Type != FT_BelongToGeom && + theCriterion.Type != FT_BelongToPlane && + theCriterion.Type != FT_BelongToCylinder && + theCriterion.Type != FT_BelongToGenSurface && + theCriterion.Type != FT_LyingOnGeom && + theCriterion.Type != FT_FreeBorders && + theCriterion.Type != FT_FreeEdges && + theCriterion.Type != FT_BadOrientedVolume) aTable->setText(theRow, 2, QString("%1").arg(theCriterion.Threshold, 0, 'g', 15)); else { @@ -845,7 +852,8 @@ void SMESHGUI_FilterTable::SetCriterion (const int theRow, if (theCriterion.Compare == FT_EqualTo || theCriterion.Type == FT_BelongToPlane || - theCriterion.Type == FT_BelongToCylinder) + theCriterion.Type == FT_BelongToCylinder || + theCriterion.Type == FT_BelongToGenSurface) { QTableItem* anItem = aTable->item(theRow, 0); if (!myAddWidgets.contains(anItem)) @@ -958,7 +966,7 @@ void SMESHGUI_FilterTable::onRemoveBtn() if (aTable->isRowSelected(i)) { aRows.resize(aRows.size() + 1); - aRows[ aRows.size() - 1 ] = i; + aRows[ (int)(aRows.size() - 1) ] = i; removeAdditionalWidget(aTable, i); } } @@ -1076,6 +1084,7 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con aCriterionType == SMESH::FT_BelongToGeom || aCriterionType == SMESH::FT_BelongToPlane || aCriterionType == SMESH::FT_BelongToCylinder || + aCriterionType == SMESH::FT_BelongToGenSurface || aCriterionType == SMESH::FT_LyingOnGeom) { QMap aMap; @@ -1270,6 +1279,7 @@ const QMap& SMESHGUI_FilterTable::getCriteria (const int theType) aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM"); aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE"); aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER"); + aCriteria[ SMESH::FT_BelongToGenSurface]= tr("BELONG_TO_GENSURFACE"); aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); } return aCriteria; @@ -1286,6 +1296,7 @@ const QMap& SMESHGUI_FilterTable::getCriteria (const int theType) aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM"); aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE"); aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER"); + aCriteria[ SMESH::FT_BelongToGenSurface]= tr("BELONG_TO_GENSURFACE"); aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); } return aCriteria; @@ -1306,6 +1317,7 @@ const QMap& SMESHGUI_FilterTable::getCriteria (const int theType) aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM"); aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE"); aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER"); + aCriteria[ SMESH::FT_BelongToGenSurface]= tr("BELONG_TO_GENSURFACE"); aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D"); aCriteria[ SMESH::FT_MultiConnection2D] = tr("MULTI2D_BORDERS"); @@ -1695,6 +1707,8 @@ void SMESHGUI_FilterDlg::construct (const QValueList& theTypes) aDlgLay->setStretchFactor(myMainFrame, 1); + myHelpFileName = "selection_filter_library_page.html"; + Init(myTypes); } @@ -1782,7 +1796,7 @@ QFrame* SMESHGUI_FilterDlg::createButtonFrame (QWidget* theParent) { QGroupBox* aGrp = new QGroupBox(1, Qt::Vertical, theParent); - myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_OK" ), aGrp); + myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGrp); myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp); QLabel* aLbl = new QLabel(aGrp); @@ -1790,11 +1804,13 @@ QFrame* SMESHGUI_FilterDlg::createButtonFrame (QWidget* theParent) 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); connect(myButtons[ BTN_OK ], SIGNAL(clicked()), SLOT(onOk())); connect(myButtons[ BTN_Cancel ], SIGNAL(clicked()), SLOT(onClose())); connect(myButtons[ BTN_Close ], SIGNAL(clicked()), SLOT(onClose())); connect(myButtons[ BTN_Apply ], SIGNAL(clicked()), SLOT(onApply())); + connect(myButtons[ BTN_Help ], SIGNAL(clicked()), SLOT(onHelp())); updateMainButtons(); @@ -1939,6 +1955,29 @@ void SMESHGUI_FilterDlg::onClose() return; } +//================================================================================= +// function : onHelp() +// purpose : +//================================================================================= +void SMESHGUI_FilterDlg::onHelp() +{ + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName), + QObject::tr("BUT_OK")); + } +} + //======================================================================= // name : SMESHGUI_FilterDlg::onDeactivate // Purpose : SLOT called when dialog must be deativated @@ -2080,6 +2119,7 @@ bool SMESHGUI_FilterDlg::isValid() const if (aType == FT_BelongToGeom || aType == FT_BelongToPlane || aType == FT_BelongToCylinder || + aType == FT_BelongToGenSurface || aType == FT_LyingOnGeom) { QString aName; myTable->GetThreshold(i, aName); @@ -2092,7 +2132,9 @@ bool SMESHGUI_FilterDlg::isValid() const return false; } - if (aType == FT_BelongToCylinder || aType == FT_BelongToPlane) { + if (aType == FT_BelongToCylinder || + aType == FT_BelongToPlane || + aType == FT_BelongToGenSurface ) { CORBA::Object_var anObject = SMESH::SObjectToObject(aList[ 0 ]); //GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(aList[ 0 ]->GetObject()); GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObject); @@ -2146,9 +2188,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); + } } //======================================================================= @@ -2263,9 +2309,11 @@ void SMESHGUI_FilterDlg::insertFilterInViewer() myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() || !mySetInViewer->isChecked()) { SMESH::RemoveFilter(getFilterId(anEntType), aSelector); - } else { + } + else { Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter(); aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate()); + SMESH::RemoveFilter(getFilterId(anEntType), aSelector); //skl for IPAL12631 SMESH::SetFilter(aFilter, aSelector); } } @@ -2481,11 +2529,20 @@ void SMESHGUI_FilterDlg::onSelectionDone() int aRow, aCol; const SALOME_ListIO& aList = mySelector->StoredIObjects(); + if ( myMesh->_is_nil() && aList.Extent()>0 ) { + myMesh = SMESH::IObjectToInterface(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) != FT_BelongToGeom && myTable->GetCriterionType(aRow) != FT_BelongToPlane && myTable->GetCriterionType(aRow) != FT_BelongToCylinder && + myTable->GetCriterionType(aRow) != FT_BelongToGenSurface && myTable->GetCriterionType(aRow) != FT_LyingOnGeom) return; @@ -2494,10 +2551,12 @@ void SMESHGUI_FilterDlg::onSelectionDone() if (!anObj->_is_nil()) { myTable->SetThreshold(aRow, GEOMBase::GetName(anObj)); - myTable->SetID( aRow, GEOMBase::GetIORFromObject(anObj)); + //myTable->SetID( aRow, GEOMBase::GetIORFromObject(anObj)); + myTable->SetID(aRow, anIO->getEntry()); } } + //======================================================================= // name : SMESHGUI_FilterDlg::onCriterionChanged // Purpose : SLOT called when cretarion of current row changed. Update selection @@ -2541,9 +2600,11 @@ void SMESHGUI_FilterDlg::updateSelection() (myTable->GetCriterionType(aRow) == FT_BelongToGeom || myTable->GetCriterionType(aRow) == FT_BelongToPlane || myTable->GetCriterionType(aRow) == FT_BelongToCylinder || + myTable->GetCriterionType(aRow) == FT_BelongToGenSurface || myTable->GetCriterionType(aRow) == FT_LyingOnGeom)) { if (myTable->GetCriterionType(aRow) == FT_BelongToGeom || + myTable->GetCriterionType(aRow) == FT_BelongToGenSurface || myTable->GetCriterionType(aRow) == FT_LyingOnGeom) { mySelectionMgr->installFilter(new GEOM_SelectionFilter( aStudy, true )); @@ -2562,3 +2623,21 @@ void SMESHGUI_FilterDlg::updateSelection() } } } + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void SMESHGUI_FilterDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Key_F1 ) + { + e->accept(); + onHelp(); + } +} +