From d72d95195cff80e11734325856974e3d40dce7ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=A9rald=20NICOLAS?= Date: Thu, 4 Jun 2020 17:41:47 +0200 Subject: [PATCH] =?utf8?q?m=C3=A9nage?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/SMESHGUI/SMESHGUI_AdaptDlg.cxx | 2964 +--------------------------- src/SMESHGUI/SMESHGUI_AdaptDlg.h | 171 +- 2 files changed, 53 insertions(+), 3082 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx b/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx index 48ab56388..a83311fdf 100644 --- a/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx @@ -24,99 +24,21 @@ // SMESH includes #include "SMESHGUI.h" #include "SMESHGUI_AdaptDlg.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_GroupUtils.h" -#include "SMESHGUI_FilterUtils.h" -#include "SMESHGUI_GEOMGenUtils.h" -#include "SMESHGUI_FilterDlg.h" -#include "SMESHGUI_ShapeByMeshDlg.h" - -#include -#include -//#include -#include - -// SALOME GEOM includes -#include -#include -#include // SALOME GUI includes -#include -#include -#include #include -#include -#include #include #include -#include #include #include -#include -#include - -// Qt includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // HOMARD includes #include "MonCreateCase.h" -// STL includes -#include -#include -#include - -// VTK includes -#include -#include - // SALOME KERNEL includes -#include -#include -#include -#include -#include -#include #include "utilities.h" #include -// OCCT includes -#include - -#define SPACING 6 -#define MARGIN 11 - -enum grpSelectionMode { - grpNoSelection = -1, - grpNodeSelection = 0, - grp0DSelection = 1, - grpBallSelection = 2, - grpEdgeSelection = 3, - grpFaceSelection = 4, - grpVolumeSelection = 5, - grpSubMeshSelection = 6, - grpGroupSelection = 7, - grpMeshSelection = 8, - grpGeomSelection = 9, - grpAllSelection = 10, -}; - //================================================================================= // function : SMESHGUI_AdaptDlg() // purpose : @@ -124,18 +46,19 @@ enum grpSelectionMode { SMESHGUI_AdaptDlg::SMESHGUI_AdaptDlg( SMESHGUI* theModule, int theCommandID, SMESH::SMESH_Mesh_ptr theMesh ) - : QDialog( SMESH::GetDesktop( theModule ) ), - mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), myStoredShownEntity(0), - mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ), - myIsBusy( false ), - myNameChanged( false ), - myNbChangesOfContents(0), - myIsApplyAndClose( false ) + : mySMESHGUI( theModule ) { bool ok = action( theCommandID ) ; } +//================================================================================= +// function : ~SMESHGUI_AdaptDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_AdaptDlg::~SMESHGUI_AdaptDlg() +{ +} + /*! * \brief Pilote les actions d'adaption de maillage * \param @@ -145,10 +68,10 @@ bool SMESHGUI_AdaptDlg::action (int theCommandID) //======================================================================= { std::cout << "SMESHGUI_AdaptDlg::action avec theCommandID : " << theCommandID << std::endl; - + // Preferences recupPreferences(); - + // Menus and actions bool ok = OnGUIEvent (theCommandID) ; if ( ! ok ) INFOS("Erreur"); @@ -160,7 +83,7 @@ bool SMESHGUI_AdaptDlg::action (int theCommandID) * \brief Gets the preferences for the adaptation * \param * \return - * + * * Pour chaque valeur, le defaut est la valeur definie dans ADAPT_Gen * . Si la recuperation dans config/salome s'est bien passee a la creation de ADAPT_Gen * ces valeurs sont les valeurs definies. @@ -186,7 +109,7 @@ void SMESHGUI_AdaptDlg::recupPreferences() _LanguageShort = resMgr->stringValue("language", "language", "en" ); INFOS ("Enregistrement de LanguageShort = " << _LanguageShort.toStdString().c_str() ); - adaptGen->SetLanguageShort(_LanguageShort.toStdString().c_str()); +// adaptGen->SetLanguageShort(_LanguageShort.toStdString().c_str()); // B.2. Les publications bool publish_mesh ; @@ -200,7 +123,7 @@ void SMESHGUI_AdaptDlg::recupPreferences() else { _PublisMeshOUT = 0 ; } INFOS ("Enregistrement de PublisMeshIN = " << _PublisMeshIN<<", PublisMeshOUT = "<< _PublisMeshOUT); - adaptGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT); +// adaptGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT); // B.3. Les maximum pour YACS @@ -209,7 +132,7 @@ void SMESHGUI_AdaptDlg::recupPreferences() _YACSMaxElem = resMgr->integerValue("HOMARD", "yacs_max_elem", 0 ); INFOS ("Enregistrement de YACSMaxIter = " << _YACSMaxIter<<", YACSMaxNode = "<< _YACSMaxNode<<", YACSMaxElem = "<< _YACSMaxElem); - adaptGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem); +// adaptGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem); // B.4. La convergence pour YACS @@ -219,7 +142,7 @@ void SMESHGUI_AdaptDlg::recupPreferences() else { _YACSTypeTest = 0 ; } INFOS ("Enregistrement de YACSTypeTest = " << _YACSTypeTest); - adaptGen->SetYACSConvergenceType(_YACSTypeTest); +// adaptGen->SetYACSConvergenceType(_YACSTypeTest); INFOS("Fin de recupPreferences") } @@ -254,2862 +177,77 @@ bool SMESHGUI_AdaptDlg::OnGUIEvent (int theCommandID) mySMESHGUI->getApp()->updateObjectBrowser(); // // B. Choix selon les commandes + bool ok = true ; SCRUTE(theCommandID); switch (theCommandID) { - case 8011: // Creation d un Cas + case 8000: // Raffinement uniforme + { + INFOS("Raffinement uniforme"); +// A faire + break; + } + case 8011: // Création d'un Cas { - INFOS("Creation d'un Cas"); + INFOS("Création d'un Cas"); MonCreateCase *aDlg = new MonCreateCase( true, ADAPT::ADAPT_Gen::_duplicate(adaptGen) ) ; aDlg->show(); break; } - -// case 8012: // Poursuite d une iteration -// { -// INFOS("command " << theCommandID << " activated"); + case 8012: // Création d'un cas en poursuite d'une itération + { + INFOS("Création d'un cas en poursuite d'une itération"); // MonPursueIteration *aDlg = new MonPursueIteration( true, // ADAPT::ADAPT_Gen::_duplicate(adaptGen) ) ; // aDlg->show(); // break; -// } - -// case 8013: // Creation d une Iteration -// { -// INFOS("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); + } + case 8013: // Création d'une itération + { + INFOS("Création d'une itération" ); // MonCreateIteration *IterDlg = new MonCreateIteration( parent, true, // ADAPT::ADAPT_Gen::_duplicate(adaptGen), _ObjectName ) ; // IterDlg->show(); -// break; -// } - -// case 8014: // Compute une iteration -// { -// INFOS("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); + break; + } + case 8014: // Calcule une itération + { + INFOS("Calcule une itération" ); // try { adaptGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 1); } // catch( SALOME::SALOME_Exception& S_ex ) // { // QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), // QObject::tr(CORBA::string_dup(S_ex.details.text)) ); // mySMESHGUI->getApp()->updateObjectBrowser(); -// return false; +// ok = false; // } -// break; -// } - -// case 8015: // Compute une iteration et publication -// { -// INFOS("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); + break; + } + case 8015: // Calcule une itération et publication + { + INFOS("Calcule une itération et publication"); // try { adaptGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 2); } // catch( SALOME::SALOME_Exception& S_ex ) // { // QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), // QObject::tr(CORBA::string_dup(S_ex.details.text)) ); // mySMESHGUI->getApp()->updateObjectBrowser(); -// return false; -// } -// break; -// } - -// case 1121: // Information sur le maillage de l'iteration -// { -// INFOS("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); -// MonIterInfo *IterDlg = new MonIterInfo( parent, true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), _ObjectName ) ; -// IterDlg->show(); -// break; -// } -// -// case 1131: // Publication du maillage de l'iteration -// { -// INFOS("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); -// adaptGen->PublishMeshIterInSmesh(_ObjectName.toStdString().c_str()); -// break; -// } -// -// case 1132: // Publication du maillage de l'iteration a partir du fichier -// { -// INFOS("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); -// adaptGen->PublishResultInSmesh(_ObjectName.toStdString().c_str(), 1); -// break; -// } -// -// case 1201: // Edition d'un objet -// { -// INFOS("command " << theCommandID << " activated"); -// QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1); -// if (nomObjet == QString("")) break; -// _PTR(SObject) obj = chercheMonObjet(); -// if (obj) -// { -// // Edition d'une frontiere CAO -// if (HOMARD_UTILS::isBoundaryCAO(obj)) -// { -// MonEditBoundaryCAO *aDlg = new MonEditBoundaryCAO(0, true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), QString(""), _ObjectName ) ; -// aDlg->show(); -// } -// // Edition d'une frontiere discrete -// else if (HOMARD_UTILS::isBoundaryDi(obj)) -// { -// MonEditBoundaryDi *aDlg = new MonEditBoundaryDi(0, true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), QString(""), _ObjectName ) ; -// aDlg->show(); -// } -// // Edition d'une frontiere analytique -// else if (HOMARD_UTILS::isBoundaryAn(obj)) -// { -// MonEditBoundaryAn *aDlg = new MonEditBoundaryAn(0, true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), QString(""), _ObjectName ) ; -// aDlg->show(); -// } -// // Edition d'un cas -// else if (HOMARD_UTILS::isCase(obj)) -// { -// MonEditCase *aDlg = new MonEditCase(true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), _ObjectName ) ; -// aDlg->show(); -// } -// // Edition d'une hypothese -// else if (HOMARD_UTILS::isHypo(obj)) -// { -// MonEditHypothesis *aDlg = new MonEditHypothesis(0, true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), _ObjectName, QString(""), QString("")) ; -// aDlg->show(); -// } -// // Edition d'une iteration -// else if (HOMARD_UTILS::isIter(obj)) -// { -// MonEditIteration *aDlg = new MonEditIteration(parent, true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), QString(""), _ObjectName ) ; -// aDlg->show(); -// } -// // Edition d'un schema YACS -// else if (HOMARD_UTILS::isYACS(obj)) -// { -// INFOS("appel de MonEditYACS"); -// MonEditYACS *aDlg = new MonEditYACS(true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), _ObjectName) ; -// aDlg->show(); -// } -// // Edition d'une zone -// else if (HOMARD_UTILS::isZone(obj)) -// { -// MonEditZone *aDlg = new MonEditZone(0, true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), QString(""), _ObjectName ) ; -// aDlg->show(); -// } -// } -// break; -// } -// -// case 1211: // Suppression d'un objet -// { -// INFOS("command " << theCommandID << " activated"); -// QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1); -// if (nomObjet == QString("")) break; -// _PTR(SObject) obj = chercheMonObjet(); -// if (obj) -// { -// // Suppression d'une frontiere -// if ( HOMARD_UTILS::isBoundaryCAO(obj) || HOMARD_UTILS::isBoundaryDi(obj) || HOMARD_UTILS::isBoundaryAn(obj) ) -// { -// try -// { adaptGen->DeleteBoundary(_ObjectName.toStdString().c_str()); } -// catch( SALOME::SALOME_Exception& S_ex ) -// { -// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), -// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); -// mySMESHGUI->getApp()->updateObjectBrowser(); -// return false; -// } -// } -// // Suppression d'un cas -// else if (HOMARD_UTILS::isCase(obj)) -// { -// try -// { adaptGen->DeleteCase(_ObjectName.toStdString().c_str(), 1); } -// catch( SALOME::SALOME_Exception& S_ex ) -// { -// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), -// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); -// mySMESHGUI->getApp()->updateObjectBrowser(); -// return false; -// } -// } -// // Suppression d'une hypothese -// else if (HOMARD_UTILS::isHypo(obj)) -// { -// try -// { adaptGen->DeleteHypo(_ObjectName.toStdString().c_str()); } -// catch( SALOME::SALOME_Exception& S_ex ) -// { -// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), -// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); -// mySMESHGUI->getApp()->updateObjectBrowser(); -// return false; -// } -// } -// // Suppression d'une iteration -// else if (HOMARD_UTILS::isIter(obj)) -// { -// try -// { adaptGen->DeleteIteration(_ObjectName.toStdString().c_str(), 1); } -// catch( SALOME::SALOME_Exception& S_ex ) -// { -// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), -// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); -// mySMESHGUI->getApp()->updateObjectBrowser(); -// return false; -// } -// } -// // Suppression d'un schema YACS -// else if (HOMARD_UTILS::isYACS(obj)) -// { -// try -// { adaptGen->DeleteYACS(_ObjectName.toStdString().c_str(), 1); } -// catch( SALOME::SALOME_Exception& S_ex ) -// { -// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), -// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); -// mySMESHGUI->getApp()->updateObjectBrowser(); -// return false; -// } -// } -// // Suppression d'une zone -// else if (HOMARD_UTILS::isZone(obj)) -// { -// try -// { adaptGen->DeleteZone(_ObjectName.toStdString().c_str()); } -// catch( SALOME::SALOME_Exception& S_ex ) -// { -// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), -// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); -// mySMESHGUI->getApp()->updateObjectBrowser(); -// return false; -// } -// } -// } -// break; -// } -// -// case 1301: // Information sur un maillage -// { -// INFOS("etape 1301") -// INFOS("command " << theCommandID << " activated"); -// MonMeshInfo *aDlg = new MonMeshInfo( parent, true, ADAPT::ADAPT_Gen::_duplicate(adaptGen) ) ; -// aDlg->show(); -// break; -// } -// -// case 1302: // Affichage de fichier texte -// { -// INFOS("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); -// _PTR(SObject) obj = chercheMonObjet(); -// if ( (obj) && ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) ) ) -// { -// MonEditFile *aDlg = new MonEditFile( 0, true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), _ObjectName, 0 ) ; -// if ( aDlg->_codret == 0 ) { aDlg->show(); } -// } -// break; -// } -// -// case 1401: // Création d'un schema YACS -// { -// INFOS("etape 1401") -// INFOS("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); -// MonCreateYACS *aDlg = new MonCreateYACS( true, ADAPT::ADAPT_Gen::_duplicate(adaptGen), _ObjectName ) ; -// aDlg->show(); -// break; -// } -// -// case 1402: // Ecriture d'un schéma YACS -// { -// INFOS("etape 1402") -// INFOS("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); -// try { adaptGen->YACSWrite(_ObjectName.toStdString().c_str()); } -// catch( SALOME::SALOME_Exception& S_ex ) -// { -// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), -// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); -// mySMESHGUI->getApp()->updateObjectBrowser(); -// return false; +// ok = false; // } -// break; -// } - - } -// mySMESHGUI->getApp()->updateObjectBrowser(); - return true; -} - -//================================================================================= -// function : SMESHGUI_AdaptDlg() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::initDialog( bool create) -{ - std::cout << "passage par initDialog" << std::endl; - setModal( false ); - setAttribute( Qt::WA_DeleteOnClose, true ); - - myFilterDlg = 0; - myCreate = create; - myCurrentLineEdit = 0; - - myShapeByMeshOp = 0; - myGeomPopup = 0; - myGeomObjects = new GEOM::ListOfGO(); - myGeomObjects->length( 0 ); - - QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); - - setWindowTitle( create ? tr( "SMESH_CREATE_GROUP_TITLE" ) : tr( "SMESH_EDIT_GROUP_TITLE" ) ); - myHelpFileName = create ? "creating_groups.html" : "editing_groups.html"; - - setSizeGripEnabled( true); - - QGridLayout* aMainLayout = new QGridLayout( this ); - aMainLayout->setMargin( MARGIN ); - aMainLayout->setSpacing( SPACING ); - - /***************************************************************/ - QLabel* meshGroupLab = new QLabel( create ? tr( "SMESH_MESH" ) : tr( "SMESH_GROUP" ), this ); - myMeshGroupBtn = new QPushButton( this ); - myMeshGroupBtn->setIcon( image0 ); - myMeshGroupLine = new QLineEdit( this ); - myMeshGroupLine->setReadOnly( true ); - - /***************************************************************/ - QGroupBox* aTypeBox = new QGroupBox( tr( "SMESH_ELEMENTS_TYPE" ), this ); - myTypeGroup = new QButtonGroup( this ); - QHBoxLayout* aTypeBoxLayout = new QHBoxLayout( aTypeBox ); - aTypeBoxLayout->setMargin( MARGIN ); - aTypeBoxLayout->setSpacing( SPACING ); - - QStringList types; - types.append( tr( "MESH_NODE" ) ); - types.append( tr( "SMESH_ELEM0D" ) ); - types.append( tr( "SMESH_BALL_ELEM" ) ); - types.append( tr( "SMESH_EDGE" ) ); - types.append( tr( "SMESH_FACE" ) ); - types.append( tr( "SMESH_VOLUME" ) ); - QRadioButton* rb; - for ( int i = 0; i < types.count(); i++ ) - { - rb = new QRadioButton( types[i], aTypeBox ); - myTypeGroup->addButton( rb, i ); - aTypeBoxLayout->addWidget( rb ); - } - aTypeBox->setEnabled( create ); - myTypeId = -1; - - /***************************************************************/ - QLabel* aName = new QLabel( tr( "SMESH_NAME" ), this ); - aName->setMinimumWidth( 50 ); - myName = new QLineEdit( this ); - - /***************************************************************/ - QGroupBox* aGrpTypeBox = new QGroupBox( tr( "SMESH_GROUP_TYPE" ), this ); - myGrpTypeGroup = new QButtonGroup( this ); - QHBoxLayout* aGrpTypeBoxLayout = new QHBoxLayout( aGrpTypeBox ); - aGrpTypeBoxLayout->setMargin( MARGIN ); - aGrpTypeBoxLayout->setSpacing( SPACING ); - - QRadioButton* rb1 = new QRadioButton( tr( "SMESH_GROUP_STANDALONE" ), aGrpTypeBox ); - QRadioButton* rb2 = new QRadioButton( tr( "SMESH_GROUP_GEOMETRY" ), aGrpTypeBox ); - QRadioButton* rb3 = new QRadioButton( tr( "SMESH_GROUP_FILTER" ), aGrpTypeBox ); - myGrpTypeGroup->addButton( rb1, 0 ); - myGrpTypeGroup->addButton( rb2, 1 ); - myGrpTypeGroup->addButton( rb3, 2 ); - aGrpTypeBoxLayout->addWidget( rb1 ); - aGrpTypeBoxLayout->addWidget( rb2 ); - aGrpTypeBoxLayout->addWidget( rb3 ); - aGrpTypeBox->setEnabled( create ); - myGrpTypeId = -1; - - /***************************************************************/ - myWGStack = new QStackedWidget( this ); - QWidget* wg1 = new QWidget( myWGStack ); - QWidget* wg2 = new QWidget( myWGStack ); - QWidget* wg3 = new QWidget( myWGStack ); - - /***************************************************************/ - QGroupBox* aContentBox = new QGroupBox( tr( "SMESH_CONTENT" ), wg1 ); - QGridLayout* aContentBoxLayout = new QGridLayout( aContentBox ); - aContentBoxLayout->setMargin( MARGIN ); - aContentBoxLayout->setSpacing( SPACING ); - - mySelectAll = new QCheckBox( tr( "SELECT_ALL" ), aContentBox ); - myAllowElemsModif = new QCheckBox( tr( "ALLOW_ELEM_LIST_MODIF" ), aContentBox ); - - myElementsLab = new QLabel( tr( "SMESH_ID_ELEMENTS" ), aContentBox ); - myElements = new QListWidget( aContentBox ); - myElements->setSelectionMode( QListWidget::ExtendedSelection ); - - myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), aContentBox ); - myAddBtn = new QPushButton( tr( "SMESH_BUT_ADD" ), aContentBox ); - myRemoveBtn = new QPushButton( tr( "SMESH_BUT_REMOVE" ), aContentBox ); - mySortBtn = new QPushButton( tr( "SMESH_BUT_SORT" ), aContentBox ); - - aContentBoxLayout->addWidget( mySelectAll, 0, 0 ); - aContentBoxLayout->addWidget( myAllowElemsModif, 1, 0 ); - aContentBoxLayout->addWidget( myFilterBtn, 1, 1 ); - aContentBoxLayout->addWidget( myElementsLab, 2, 0 ); - aContentBoxLayout->addWidget( myElements, 3, 0, 6, 1 ); - aContentBoxLayout->addWidget( myAddBtn, 3, 1 ); - aContentBoxLayout->addWidget( myRemoveBtn, 4, 1 ); - aContentBoxLayout->addWidget( mySortBtn, 8, 1 ); - - aContentBoxLayout->setColumnStretch( 0, 1 ); - aContentBoxLayout->setRowStretch( 3, 1 ); - aContentBoxLayout->setRowStretch( 6, 1 ); - - /***************************************************************/ - mySelectBox = new QGroupBox( tr( "SMESH_SELECT_FROM" ), wg1 ); - QGridLayout* mySelectBoxLayout = new QGridLayout( mySelectBox ); - mySelectBoxLayout->setMargin( MARGIN ); - mySelectBoxLayout->setSpacing( SPACING ); - - mySelectSubMesh = new QCheckBox( tr( "SMESH_SUBMESH" ), mySelectBox ); - mySubMeshBtn = new QPushButton( mySelectBox ); - mySubMeshBtn->setIcon( image0 ); - mySubMeshLine = new QLineEdit( mySelectBox ); - mySubMeshLine->setReadOnly( true ); - onSelectSubMesh( false ); - - mySelectGroup = new QCheckBox( tr( "SMESH_GROUP" ), mySelectBox ); - myGroupBtn = new QPushButton( mySelectBox ); - myGroupBtn->setIcon( image0 ); - myGroupLine = new QLineEdit( mySelectBox ); - myGroupLine->setReadOnly( true ); - onSelectGroup( false ); - - mySelectBoxLayout->addWidget( mySelectSubMesh, 0, 0 ); - mySelectBoxLayout->addWidget( mySubMeshBtn, 0, 1 ); - mySelectBoxLayout->addWidget( mySubMeshLine, 0, 2 ); - mySelectBoxLayout->addWidget( mySelectGroup, 1, 0 ); - mySelectBoxLayout->addWidget( myGroupBtn, 1, 1 ); - mySelectBoxLayout->addWidget( myGroupLine, 1, 2 ); - - /***************************************************************/ - QVBoxLayout* wg1Layout = new QVBoxLayout( wg1 ); - wg1Layout->setMargin( 0 ); - wg1Layout->setSpacing( SPACING ); - wg1Layout->addWidget( aContentBox ); - wg1Layout->addWidget( mySelectBox ); - wg1Layout->setStretchFactor( aContentBox, 10 ); - - /***************************************************************/ - QLabel* geomObject = new QLabel( tr( "SMESH_OBJECT_GEOM" ), wg2 ); - myGeomGroupBtn = new QToolButton( wg2 ); - myGeomGroupBtn->setIcon( image0 ); - myGeomGroupBtn->setCheckable( true ); - myGeomGroupLine = new QLineEdit( wg2 ); - myGeomGroupLine->setReadOnly( true ); //VSR ??? - onSelectGeomGroup( false ); - - myGeomGroupBtn->setEnabled( create ); - myGeomGroupLine->setEnabled( create ); - - /***************************************************************/ - QGridLayout* wg2Layout = new QGridLayout( wg2 ); - wg2Layout->setMargin( 0 ); - wg2Layout->setSpacing( SPACING ); - wg2Layout->addWidget( geomObject, 0, 0 ); - wg2Layout->addWidget( myGeomGroupBtn, 0, 1 ); - wg2Layout->addWidget( myGeomGroupLine,0, 2 ); - wg2Layout->setRowStretch( 1, 5 ); - - /***************************************************************/ - QPushButton * aFilter2 = new QPushButton( tr( "SMESH_BUT_FILTER" ), wg3 ); - QGridLayout* wg3Layout = new QGridLayout( wg3 ); - wg3Layout->setMargin( 0 ); - wg3Layout->setSpacing( SPACING ); - wg3Layout->addWidget( aFilter2, 0, 0 ); - wg3Layout->setRowStretch( 1, 5 ); - - /***************************************************************/ - myWGStack->insertWidget( 0, wg1 ); - myWGStack->insertWidget( 1, wg2 ); - myWGStack->insertWidget( 2, wg3 ); - - /***************************************************************/ - QGroupBox* aColorBox = new QGroupBox(tr( "SMESH_SET_COLOR" ), this); - QHBoxLayout* aColorBoxLayout = new QHBoxLayout(aColorBox); - aColorBoxLayout->setMargin(MARGIN); - aColorBoxLayout->setSpacing(SPACING); - - QLabel* aColorLab = new QLabel(tr( "SMESH_CHECK_COLOR" ), aColorBox ); - myColorBtn = new QtxColorButton(aColorBox); - myColorBtn->setSizePolicy( QSizePolicy::MinimumExpanding, - myColorBtn->sizePolicy().verticalPolicy() ); - - aColorBoxLayout->addWidget(aColorLab); - aColorBoxLayout->addWidget(myColorBtn); - - /***************************************************************/ - - QFrame* aButtons = new QFrame(this); - aButtons->setFrameStyle( QFrame::Box | QFrame::Sunken ); - QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons); - aBtnLayout->setMargin(MARGIN); - aBtnLayout->setSpacing(SPACING); - - myOKBtn = new QPushButton(tr( "SMESH_BUT_APPLY_AND_CLOSE" ), aButtons); - myOKBtn->setAutoDefault(true); - myOKBtn->setDefault(true); - myApplyBtn = new QPushButton(tr( "SMESH_BUT_APPLY" ), aButtons); - myApplyBtn->setAutoDefault(true); - myCloseBtn = new QPushButton(tr( "SMESH_BUT_CLOSE" ), aButtons); - myCloseBtn->setAutoDefault(true); - myHelpBtn = new QPushButton(tr( "SMESH_BUT_HELP" ), aButtons); - myHelpBtn->setAutoDefault(true); - - aBtnLayout->addWidget(myOKBtn); - aBtnLayout->addSpacing(10); - aBtnLayout->addWidget(myApplyBtn); - aBtnLayout->addSpacing(10); - aBtnLayout->addStretch(); - aBtnLayout->addWidget(myCloseBtn); - aBtnLayout->addWidget(myHelpBtn); - - /***************************************************************/ - aMainLayout->addWidget(meshGroupLab, 0, 0); - aMainLayout->addWidget(myMeshGroupBtn, 0, 1); - aMainLayout->addWidget(myMeshGroupLine, 0, 2); - aMainLayout->addWidget(aTypeBox, 1, 0, 1, 3); - aMainLayout->addWidget(aName, 2, 0); - aMainLayout->addWidget(myName, 2, 2); - aMainLayout->addWidget(aGrpTypeBox, 3, 0, 1, 3); - aMainLayout->addWidget(myWGStack, 4, 0, 1, 3); - aMainLayout->addWidget(aColorBox, 5, 0, 1, 3); - aMainLayout->addWidget(aButtons, 6, 0, 1, 3); - - /* signals and slots connections */ - connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); - connect(myGrpTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onGrpTypeChanged(int))); - connect(myTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onTypeChanged(int))); - - connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&))); - connect(myElements, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged())); - - connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); - connect(aFilter2, SIGNAL(clicked()), this, SLOT(setFilters())); - connect(mySelectAll, SIGNAL(toggled(bool)), this, SLOT(onSelectAll())); - connect(myAllowElemsModif,SIGNAL(toggled(bool)), this, SLOT(onSelectAll())); - connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAdd())); - connect(myRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove())); - connect(mySortBtn, SIGNAL(clicked()), this, SLOT(onSort())); - - connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool))); - connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool))); - connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); - connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); - connect(myGeomGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onGeomSelectionButton(bool))); - - connect(myColorBtn, SIGNAL(changed( QColor )), this, SLOT(onColorChanged( QColor ))); - - connect(myOKBtn, SIGNAL(clicked()), this, SLOT(onOK())); - connect(myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply())); - connect(myCloseBtn, SIGNAL(clicked()), this, SLOT(reject())); - connect(myHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp())); - - /* Init selection */ - mySMESHGUI->SetActiveDialogBox(this); - - SalomeApp_Study* aStudy = dynamic_cast( mySMESHGUI->application()->activeStudy() ); - mySelectionMode = grpNoSelection; - - myMeshFilter = new SMESH_TypeFilter(SMESH::MESH); - mySubMeshFilter = new SMESH_LogicalFilter(QList(), - SMESH_LogicalFilter::LO_OR, - /*takeOwnership=*/true); - myGroupFilter = new SMESH_LogicalFilter(QList(), - SMESH_LogicalFilter::LO_OR, - /*takeOwnership=*/true); - myGeomFilter = new GEOM_SelectionFilter( aStudy, true ); - - connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate())); - connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject())); - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); - connect(mySMESHGUI, SIGNAL(SignalVisibilityChanged()), this, SLOT(onVisibilityChanged())); - connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), this, SLOT(onOpenView())); - connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView())); - rb1->setChecked(true); // VSR !!! - onGrpTypeChanged(0); // VSR!!! - - if (myMesh->_is_nil() ) - myTypeGroup->button(0)->setChecked(true); - - onSelectAll(); //updateButtons(); -} - -//================================================================================= -// function : ~SMESHGUI_AdaptDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -SMESHGUI_AdaptDlg::~SMESHGUI_AdaptDlg() -{ - // no need to delete child widgets, Qt does it all for us - if ( myFilterDlg != 0 ) { - myFilterDlg->setParent( 0 ); - delete myFilterDlg; - } - if ( myMeshFilter ) delete myMeshFilter; - if ( mySubMeshFilter ) delete mySubMeshFilter; - if ( myGroupFilter ) delete myGroupFilter; - if ( myGeomFilter ) delete myGeomFilter; -} - -//================================================================================= -// function : GetDefaultName() -// purpose : Get the Group Name if Create new Group -//================================================================================= -QString SMESHGUI_AdaptDlg::GetDefaultName(const QString& theOperation) -{ - std::cout << "passage par GetDefaultName" << std::endl; - QString aName = ""; - - // collect all object names of SMESH component - _PTR(Study) aStudy = SMESH::getStudy(); - - std::set aSet; - _PTR(SComponent) aMeshCompo (aStudy->FindComponent( "SMESH" )); - if (aMeshCompo) { - _PTR(ChildIterator) it (aStudy->NewChildIterator(aMeshCompo)); - _PTR(SObject) obj; - for (it->InitEx(true); it->More(); it->Next()) { - obj = it->Value(); - aSet.insert(obj->GetName()); - } - } - - // build a unique name - int aNumber = 0; - bool isUnique = false; - while (!isUnique) { - aName = theOperation + "_" + QString::number(++aNumber); - isUnique = (aSet.count(std::string(aName.toUtf8().constData())) == 0); - } - - return aName; -} - -void SMESHGUI_AdaptDlg::setDefaultName() const -{ - std::cout << "passage par setDefaultName" << std::endl; - QString aResName; - int i=1; - QString aPrefix ="Group_"; - _PTR(SObject) anObj; - do - { - aResName = aPrefix + QString::number( i++ ); - anObj = SMESH::getStudy()->FindObject( aResName.toUtf8().constData() ); - } - while ( anObj ); - myName->setText(aResName); -} - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::init (SMESH::SMESH_Mesh_ptr theMesh) -{ - std::cout << "passage par init (SMESH::SMESH_Mesh_ptr theMesh)" << std::endl; - mySelectionMgr->installFilter(myMeshFilter); - - /* init data from current selection */ - restoreShowEntityMode(); - myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh); - setShowEntityMode(); - myGroup = SMESH::SMESH_Group::_nil(); - myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); - myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil(); - - // NPAL19389: create a group with a selection in another group - // set actor of myMesh, if it is visible, else try - // any visible actor of group or submesh of myMesh - SetAppropriateActor(); - - setDefaultGroupColor(); - setDefaultName(); - - - SALOME_ListIO aList; - mySelectionMgr->selectedObjects( aList ); - if( !aList.IsEmpty() ) - { - QString aName = aList.First()->getName(); - myMeshGroupLine->setText(aName);//?????? - myMeshGroupLine->home( false ); - } - - myCurrentLineEdit = 0; - - myTypeGroup->button(0)->setChecked(true); - onTypeChanged(0); -} - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::init (SMESH::SMESH_GroupBase_ptr theGroup) -{ - std::cout << "passage par init (SMESH::SMESH_GroupBase_ptr theGroup)" << std::endl; - restoreShowEntityMode(); - myMesh = theGroup->GetMesh(); - setShowEntityMode(); - - myNameChanged = true; - myName->blockSignals(true); - myName->setText(SMESH::fromUtf8(theGroup->GetName())); - myName->blockSignals(false); - myName->home(false); - - SALOMEDS::Color aColor = theGroup->GetColor(); - setGroupColor( aColor ); - - myMeshGroupLine->setText(theGroup->GetName()); - - int aType = 0; - switch(theGroup->GetType()) { - case SMESH::NODE: aType = grpNodeSelection; break; - case SMESH::ELEM0D: aType = grp0DSelection; break; - case SMESH::BALL: aType = grpBallSelection; break; - case SMESH::EDGE: aType = grpEdgeSelection; break; - case SMESH::FACE: aType = grpFaceSelection; break; - case SMESH::VOLUME: aType = grpVolumeSelection; break; - case SMESH::ALL: - case SMESH::NB_ELEMENT_TYPES: break; - } - myTypeGroup->button(aType)->setChecked(true); - - myGroup = SMESH::SMESH_Group::_narrow( theGroup ); - myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup ); - myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_narrow( theGroup ); - myFilter = SMESH::Filter::_nil(); - - if (myGroup->_is_nil() && myGroupOnGeom->_is_nil() && myGroupOnFilter->_is_nil() ) - return; - - // NPAL19389: create a group with a selection in another group - // set actor of myMesh, if it is visible, else set - // actor of theGroup, if it is visible, else try - // any visible actor of group or submesh of myMesh - // commented, because an attempt to set selection on not displayed cells leads to error - SetAppropriateActor(); - - /* SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); - if ( !anActor ) - anActor = SMESH::FindActorByObject(theGroup); - SMESH::SetPickable(anActor);*/ - int grpType = (!myGroup->_is_nil() ? 0 : (false ? 0 : myGroupOnGeom->_is_nil() ? 2 : 1)); - myGrpTypeGroup->button(grpType)->setChecked(true); - onGrpTypeChanged(grpType); - - myTypeId = aType; - if ( grpType == 0 ) { // standalone group - myCurrentLineEdit = 0; - myElements->clear(); - myAllowElemsModif->setChecked( true ); - - setSelectionMode(aType); - - setShowEntityMode(); // depends on myTypeId - - myIdList.clear(); - if (!theGroup->IsEmpty()) { - SMESH::long_array_var anElements = theGroup->GetListOfID(); - int k = anElements->length(); - for (int i = 0; i < k; i++) { - myIdList.append(anElements[i]); - myElements->addItem(QString::number(anElements[i])); - } - myElements->selectAll(); - } - } - else if ( grpType == 1 ) // group on geom - { - QString aShapeName( "" ); - _PTR(Study) aStudy = SMESH::getStudy(); - GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape(); - if (!aGroupShape->_is_nil()) - { - _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry()); - if ( aGroupShapeSO ) - aShapeName = aGroupShapeSO->GetName().c_str(); - } - myGeomGroupLine->setText( aShapeName ); - } - else // group on filter - { - myFilter = myGroupOnFilter->GetFilter(); - if ( !myFilter->_is_nil() ) { - SMESH::Predicate_var perdicate = myFilter->GetPredicate(); - if ( perdicate->_is_nil() ) - myFilter = SMESH::Filter::_nil(); - } - } - - if ( grpType != 0 ) - { - myNameChanged = true; - myName->blockSignals(true); - myName->setText(theGroup->GetName()); - myName->blockSignals(false); - } - - onSelectAll(); //updateButtons(); -} - -//================================================================================= -// function : updateButtons() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::updateButtons() -{ - std::cout << "passage par updateButtons" << std::endl; - bool enable = !myName->text().trimmed().isEmpty(); - if ( enable ) - { - if (myGrpTypeId == 0) { // standalone - if ( !mySelectAll->isChecked() ) - { - if ( myAllowElemsModif->isChecked() ) - { - enable = ( myElements->count() > 0 ); - } - else if ((enable = !myFilter->_is_nil() )) - { - SMESH::array_of_ElementType_var types = myFilter->GetTypes(); - enable = types->length(); - } - } - enable = enable && (!myGroup->_is_nil() || !myMesh->_is_nil()); - } - else if (myGrpTypeId == 1) // on geom - { - if (CORBA::is_nil(myGroupOnGeom)) // creation mode - enable = ( myGeomObjects->length() > 0 && !myMesh->_is_nil() ); + break; } - else if (myGrpTypeId == 2) // on filter + case 8020: // Adaptation avec MG-Adpat { - if (( enable = !myFilter->_is_nil() )) - if (CORBA::is_nil(myGroupOnFilter) ) // creation mode - enable = !myMesh->_is_nil(); + INFOS("Interface avec MG-Adapt" ); +// A faire + break; } - } - - bool meshHasGeom = ( myMesh->_is_nil() || myMesh->HasShapeToMesh() ); - if ( myGrpTypeId != 1 ) - { - myGrpTypeGroup->button(1)->setEnabled( meshHasGeom ); - } - else - { - myGeomGroupBtn->setEnabled( meshHasGeom ); - myGeomGroupLine->setEnabled( meshHasGeom ); - } - - myOKBtn->setEnabled(enable); - myApplyBtn->setEnabled(enable); -} - -//================================================================================= -// function : onNameChanged() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onNameChanged (const QString& text) -{ - std::cout << "passage par onNameChanged" << std::endl; - myOldName = myName->text(); - updateButtons(); - myNameChanged = !myName->text().trimmed().isEmpty(); -} - -//================================================================================= -// function : onTypeChanged() -// purpose : Group elements type radio button management -//================================================================================= -void SMESHGUI_AdaptDlg::onTypeChanged (int id) -{ - if (myTypeId != id) { - myElements->clear(); - myTypeId = id; - if ( myGrpTypeId == 0 && myCurrentLineEdit == 0) - setSelectionMode(id); - else - setSelectionMode( mySelectionMode++ ); // update according to mySelectionMode - onObjectSelectionChanged(); - setShowEntityMode(); } + mySMESHGUI->getApp()->updateObjectBrowser(); + return ok; } -//================================================================================= -// function : onGrpTypeChanged() -// purpose : Group type radio button management -//================================================================================= -void SMESHGUI_AdaptDlg::onGrpTypeChanged (int id) -{ - if (myGrpTypeId != id) { - myGrpTypeId = id; - myWGStack->setCurrentIndex( id ); - myName->blockSignals(true); - myName->setText(myOldName); - myName->blockSignals(false); - onSelectGeomGroup(id != 0); - } - updateButtons(); -} - -//================================================================================= -// function : onColorChanged() -// purpose : Color button management -//================================================================================= -void SMESHGUI_AdaptDlg::onColorChanged(QColor theColor) -{ - updateButtons(); -} - -//================================================================================= -// function : setSelectionMode() -// purpose : Radio button management -//================================================================================= -void SMESHGUI_AdaptDlg::setSelectionMode (int theMode) -{ - // PAL7314 - if (myMesh->_is_nil()) - return; - SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); - bool isSelectAll = mySelectAll->isChecked() || !myAllowElemsModif->isChecked() || myGrpTypeId != 0; - if (mySelectionMode != theMode) { - // [PAL10408] mySelectionMgr->clearSelected(); - mySelectionMgr->clearFilters(); - SMESH::RemoveFilters(); - - if (myActorsList.count() > 0) - for (QListIterator it( myActorsList ); it.hasNext(); ) - it.next()->SetPointRepresentation(false); - else - SMESH::SetPointRepresentation(false); - - switch (theMode) { - case grpNodeSelection: - if ( myGrpTypeId == 0 ) // standalone - { - if (myActorsList.count() > 0) - for (QListIterator it( myActorsList ); it.hasNext(); ) - it.next()->SetPointRepresentation(true); - else - SMESH::SetPointRepresentation(true); - } - if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : NodeSelection); - break; - case grpEdgeSelection: - if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : EdgeSelection); - break; - case grpBallSelection: - if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : BallSelection); - break; - case grp0DSelection: - if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : Elem0DSelection); - break; - case grpFaceSelection: - if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : FaceSelection); - break; - case grpVolumeSelection: - if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : VolumeSelection); - break; - case grpSubMeshSelection: { - - SMESH_TypeFilter* f = 0; - switch (myTypeId) { - case grpNodeSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH); break; - case grpEdgeSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH_EDGE); break; - case grpFaceSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH_FACE); break; - case grpVolumeSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH_SOLID); break; - default: f = new SMESH_TypeFilter(SMESH::SUBMESH); - } - QList filtList; - filtList.append( f ); - filtList.append( new SMESH_TypeFilter(SMESH::SUBMESH_COMPOUND)); - mySubMeshFilter->setFilters( filtList ); - mySelectionMgr->installFilter( mySubMeshFilter ); - if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection); - break; - } - case grpGroupSelection: { - - SMESH_TypeFilter* f = 0; - switch (myTypeId) { - case grpNodeSelection: f = new SMESH_TypeFilter(SMESH::GROUP_NODE); break; - case grp0DSelection: f = new SMESH_TypeFilter(SMESH::GROUP_0D); break; - case grpBallSelection: f = new SMESH_TypeFilter(SMESH::GROUP_BALL); break; - case grpEdgeSelection: f = new SMESH_TypeFilter(SMESH::GROUP_EDGE); break; - case grpFaceSelection: f = new SMESH_TypeFilter(SMESH::GROUP_FACE); break; - case grpVolumeSelection: f = new SMESH_TypeFilter(SMESH::GROUP_VOLUME); break; - default: f = new SMESH_TypeFilter(SMESH::GROUP); - } - QList filtList; - filtList.append( f ); - myGroupFilter->setFilters( filtList ); - - mySelectionMgr->installFilter(myGroupFilter); - if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection); - break; - } - case grpMeshSelection: - mySelectionMgr->installFilter(myMeshFilter); - if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection); - break; - case grpGeomSelection: - mySelectionMgr->installFilter(myGeomFilter); - if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection); - break; - default: - if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection); - break; - } - if ( aViewWindow ) aViewWindow->Repaint(); - mySelectionMode = theMode; - } -} - -//================================================================================= -// function : onApply() -// purpose : -//================================================================================= -bool SMESHGUI_AdaptDlg::onApply() -{ - if (SMESHGUI::isStudyLocked()) - return false; - - if (myName->text().trimmed().isEmpty()) - return false; - - SMESH::ElementType aType = SMESH::ALL; - switch (myTypeId) { - case grpNodeSelection: aType = SMESH::NODE; break; - case grp0DSelection: aType = SMESH::ELEM0D; break; - case grpBallSelection: aType = SMESH::BALL; break; - case grpEdgeSelection: aType = SMESH::EDGE; break; - case grpFaceSelection: aType = SMESH::FACE; break; - case grpVolumeSelection: aType = SMESH::VOLUME; break; - } - - bool anIsOk = false; - QStringList anEntryList; - - SMESH::SMESH_GroupBase_var resultGroup; - bool isCreation = false, isConversion = false; - - SUIT_OverrideCursor wc; - - if (myGrpTypeId == 0) // standalone - { - if (!mySelectAll->isChecked() && !myElements->count() && myAllowElemsModif->isChecked()) - return false; - - mySelectionMgr->clearSelected(); - - if (myGroup->_is_nil()) { // creation or conversion - // check if group on geometry is not null - if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil()) { - if (myMesh->_is_nil()) - return false; - if ( myGroupOnGeom->_is_nil() ) - myGroup = myMesh->ConvertToStandalone( myGroupOnFilter ); - else - myGroup = myMesh->ConvertToStandalone( myGroupOnGeom ); - - myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); - myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil(); - isConversion = true; - } - } - - if (myGroup->_is_nil()) { // creation - if (myMesh->_is_nil()) - return false; - - myGroup = SMESH::AddGroup(myMesh, aType, myName->text()); - - resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroup ); - isCreation = true; - - if ( mySelectAll->isChecked() ) { - // select all - myGroup->AddFrom(myMesh.in()); - } - else { - // select manually - - if ( !myFilter->_is_nil() && - ( myNbChangesOfContents == 1 || !myAllowElemsModif->isChecked())) - { - myGroup->AddFrom( myFilter ); - } - else - { - SMESH::long_array_var anIdList = new SMESH::long_array; - int i, k = myElements->count(); - anIdList->length(k); - for (i = 0; i < k; i++) { - anIdList[i] = myElements->item(i)->text().toInt(); - } - myGroup->Add(anIdList.inout()); - } - } - - - } else { // edition - - resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroup ); - isCreation = false; - - if ( mySelectAll->isChecked() ) { - // select all - myGroup->Clear(); - myGroup->AddFrom(myMesh.in()); - } - else { - QList aAddList; - - int i, total = myElements->count(); - for (i = 0; i < total; i++) { - int anId = myElements->item(i)->text().toInt(); - int idx = myIdList.indexOf(anId); - if ( idx == -1 ) - aAddList.append(anId); - else - myIdList.removeAt(idx); - } - if (!aAddList.empty()) { - SMESH::long_array_var anIdList = new SMESH::long_array; - int added = aAddList.count(); - anIdList->length(added); - for (i = 0; i < added; i++) - anIdList[i] = aAddList[i]; - myGroup->Add(anIdList.inout()); - } - if (!myIdList.empty()) { - SMESH::long_array_var anIdList = new SMESH::long_array; - int removed = myIdList.count(); - anIdList->length(removed); - for (i = 0; i < removed; i++) - anIdList[i] = myIdList[i]; - myGroup->Remove(anIdList.inout()); - } - /* init for next operation */ - myIdList.clear(); - for (i = 0; i < total; i++) { - myIdList.append(myElements->item(i)->text().toInt()); - } - } - } - - anIsOk = true; - } - else if (myGrpTypeId == 1) // on geom object - { - if (CORBA::is_nil(myGroupOnGeom)) { // creation - if (myMesh->_is_nil() || !myGeomObjects->length()) - return false; - - _PTR(Study) aStudy = SMESH::getStudy(); - - if (myGeomObjects->length() == 1) { - myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, - myName->text().toUtf8(), - myGeomObjects[0]); - } - else { - SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen(); - if ( aSMESHGen->_is_nil() || myGeomObjects->length() == 0 ) - return false; - - // create a geometry group - GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( myGeomObjects[0] ); - if (geomGen->_is_nil()) - return false; - - GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(); - if (op->_is_nil()) - return false; - - // check and add all selected GEOM objects: they must be - // a sub-shapes of the main GEOM and must be of one type - TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE; - for ( CORBA::ULong i =0; i < myGeomObjects->length(); i++) - { - TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType(); - if ( i == 0 ) - aGroupType = aSubShapeType; - else if ( aSubShapeType != aGroupType ) { - aGroupType = TopAbs_SHAPE; - break; - } - } - - GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh(); - GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType); - if ( aGroupVar->_is_nil() ) - return false; - op->UnionList(aGroupVar, myGeomObjects); - - if (op->IsDone()) { - // publish the GEOM group in study - QString aNewGeomGroupName ( "Auto_group_for_" ); - aNewGeomGroupName += myName->text(); - SALOMEDS::SObject_var aNewGroupSO = - geomGen->AddInStudy(aGroupVar, - aNewGeomGroupName.toUtf8(), aMeshShape); - } - - myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, - myName->text().toUtf8(), - aGroupVar); - } - resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom ); - isCreation = true; - - } - else { // edition - - resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom ); - isCreation = false; - } - anIsOk = true; - } - if (myGrpTypeId == 2) // group on filter - { - if ( myFilter->_is_nil() ) return false; - - if (CORBA::is_nil(myGroupOnFilter)) // creation - { - if (myMesh->_is_nil()) - return false; - - myGroupOnFilter = myMesh->CreateGroupFromFilter(aType, - myName->text().toUtf8(), - myFilter); - resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter ); - isCreation = true; - } - else - { - myGroupOnFilter->SetFilter( myFilter ); - - resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter ); - isCreation = false; - } - anIsOk = true; - } - - if ( anIsOk ) - { - SALOMEDS::Color aColor = getGroupColor(); - resultGroup->SetColor(aColor); - - _PTR(SObject) aMeshGroupSO = SMESH::FindSObject( resultGroup ); - if( aMeshGroupSO ) - anEntryList.append( aMeshGroupSO->GetID().c_str() ); - - resultGroup->SetName(myName->text().trimmed().toUtf8()); - - if ( isCreation ) - { - SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" ); - - /* init for the next operation */ - setDefaultName(); - myElements->clear(); - myGroup = SMESH::SMESH_Group::_nil(); - myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); - myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil(); - myFilter = SMESH::Filter::_nil(); - - setDefaultGroupColor(); // reset color for case if 'auto-color' feature is enabled. - } - else - { - if ( aMeshGroupSO ) - { - if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) - { - Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); - if ( isConversion ) { // need to reset TVisualObj and actor - SMESH::RemoveVisualObjectWithActors( anIO->getEntry(), true ); - SMESH::Update( anIO,true); - myActorsList.clear(); - anActor = SMESH::FindActorByEntry( anIO->getEntry() ); - if ( !anActor ) return false; - myActorsList.append( anActor ); - } - anActor->setName(myName->text().toUtf8()); - QColor c; - int delta; - switch ( myTypeId ) { - case grpNodeSelection: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break; - case grp0DSelection: anActor->Set0DColor ( aColor.R, aColor.G, aColor.B ); break; - case grpBallSelection: anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break; - case grpEdgeSelection: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break; - case grpVolumeSelection: - SMESH::GetColor("SMESH", "volume_color", c , delta, "255,0,170|-100"); - anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break; - break; - case grpFaceSelection: - default: - SMESH::GetColor("SMESH", "fill_color", c , delta, "0,170,255|-100"); - anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break; - break; - } - // update a visible group according to a changed contents - if ( !isConversion && anActor->GetVisibility() ) - { - SMESH::Update( anIO, true ); - SMESH::RepaintCurrentView(); - } - } - } - } - SMESHGUI::Modified(); - mySMESHGUI->updateObjBrowser(true); - mySelectionMgr->clearSelected(); - - if( LightApp_Application* anApp = - dynamic_cast( SUIT_Session::session()->activeApplication() ) ) - myObjectToSelect = anApp->browseObjects( anEntryList, isApplyAndClose() ); - } - return anIsOk; -} - -//================================================================================= -// function : onOK() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onOK() -{ - setIsApplyAndClose( true ); - if ( onApply() ) - reject(); - setIsApplyAndClose( false ); - - if ( myFilterDlg ) myFilterDlg->UnRegisterFilters(); -} - -//================================================================================= -// function : onListSelectionChanged() -// purpose : Called when selection in element list is changed -//================================================================================= -void SMESHGUI_AdaptDlg::onListSelectionChanged() -{ - //INFOS( "SMESHGUI_AdaptDlg::onListSelectionChanged(); myActorsList.count() = " << myActorsList.count()); - if( myIsBusy || myActorsList.count() == 0 ) return; - myIsBusy = true; - - if (myCurrentLineEdit == 0) { - mySelectionMgr->clearSelected(); - TColStd_MapOfInteger aIndexes; - QList selItems = myElements->selectedItems(); - QListWidgetItem* anItem; - foreach(anItem, selItems) aIndexes.Add(anItem->text().toInt()); - mySelector->AddOrRemoveIndex(myActorsList.first()->getIO(), aIndexes, false); - SALOME_ListIO aList; - aList.Append(myActorsList.first()->getIO()); - mySelectionMgr->setSelectedObjects(aList,false); - } - myIsBusy = false; -} - -//================================================================================= -// function : onObjectSelectionChanged() -// purpose : Called when selection in 3D view or ObjectBrowser is changed -//================================================================================= -void SMESHGUI_AdaptDlg::onObjectSelectionChanged() -{ - if ( myIsBusy || !isEnabled()) return; - if (myCurrentLineEdit == myGeomGroupLine && !myGeomGroupBtn->isChecked()) return; - - myIsBusy = true; - - SALOME_ListIO aList; - mySelectionMgr->selectedObjects( aList ); - - int aNbSel = aList.Extent(); - myElements->clearSelection(); - - if (myCurrentLineEdit) - { - myCurrentLineEdit->setText( "" ); - QString aString = ""; - - if (myCurrentLineEdit == myMeshGroupLine) - { - mySelectSubMesh->setEnabled(false); - mySelectGroup->setEnabled(false); - myGroupLine->setText( "" ); - mySubMeshLine->setText( "" ); - - myGeomGroupBtn->setEnabled(false); - myGeomGroupLine->setEnabled(false); - myGeomGroupLine->setText( "" ); - myGeomObjects = new GEOM::ListOfGO(); - myGeomObjects->length(0); - - if (myGeomGroupBtn->isChecked()) - myGeomGroupBtn->setChecked(false); - if (!myCreate) - myName->setText( "" ); - - myElements->clear(); - - if (aNbSel != 1 ) { - myGroup = SMESH::SMESH_Group::_nil(); - myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); - restoreShowEntityMode(); - myMesh = SMESH::SMESH_Mesh::_nil(); - updateGeomPopup(); - updateButtons(); - myIsBusy = false; - return; - } - Handle(SALOME_InteractiveObject) IO = aList.First(); - - if (myCreate) { - restoreShowEntityMode(); - myMesh = SMESH::IObjectToInterface(IO); - setShowEntityMode(); - updateGeomPopup(); - if (myMesh->_is_nil()) - { - updateButtons(); - myIsBusy = false; - return; - } - - if ( myFilterDlg && !myMesh->_is_nil()){ - myFilterDlg->SetMesh( myMesh ); - } - myGroup = SMESH::SMESH_Group::_nil(); - - // NPAL19389: create a group with a selection in another group - // set actor of myMesh, if it is visible, else try - // any visible actor of group or submesh of myMesh - SetAppropriateActor(); - - setDefaultGroupColor(); - if (myName->text().isEmpty()) - setDefaultName(); - - aString = aList.First()->getName(); - myMeshGroupLine->setText(aString); - myMeshGroupLine->home( false ); - - mySelectSubMesh->setEnabled(true); - mySelectGroup->setEnabled(true); - myGeomGroupBtn->setEnabled(true); - myGeomGroupLine->setEnabled(true); - updateButtons(); - } - else { - SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - { - myIsBusy = false; - return; - } - myIsBusy = false; - - myGroup = SMESH::SMESH_Group::_nil(); - myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); - - init(aGroup); - myIsBusy = true; - mySelectSubMesh->setEnabled(true); - mySelectGroup->setEnabled(true); - } - myCurrentLineEdit = 0; - myIsBusy = false; - if (!myCreate) - return; - - if (myGrpTypeId == 0) - { - if (myTypeId == -1) - onTypeChanged(0); - else - { - myElements->clear(); - setSelectionMode(myTypeId); - } - } - - myIsBusy = false; - return; - - } - else if (myCurrentLineEdit == myGeomGroupLine) - { - myGeomObjects = new GEOM::ListOfGO(); - - // The mesh SObject - _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); - - if (aNbSel == 0 || !aMeshSO) - { - myGeomObjects->length(0); - updateButtons(); - myIsBusy = false; - return; - } - - myGeomObjects->length(aNbSel); - - GEOM::GEOM_Object_var aGeomGroup; - int i = 0; - - SALOME_ListIteratorOfListIO anIt (aList); - for (; anIt.More(); anIt.Next()) - { - aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value()); - - // Check if the object is a geometry group - if (CORBA::is_nil(aGeomGroup)) - continue; - - // Check if group constructed on the same shape as a mesh or on its child - - // The main shape of the group - GEOM::GEOM_Object_var aGroupMainShape; - if (aGeomGroup->GetType() == 37) - { - GEOM::GEOM_IGroupOperations_wrap anOp = - SMESH::GetGEOMGen( aGeomGroup )->GetIGroupOperations(); - aGroupMainShape = anOp->GetMainShape( aGeomGroup ); - // aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap - } - else - { - aGroupMainShape = aGeomGroup; - aGroupMainShape->Register(); - } - CORBA::String_var entry = aGroupMainShape->GetStudyEntry(); - _PTR(SObject) aGroupMainShapeSO = - SMESH::getStudy()->FindObjectID( entry.in() ); - - _PTR(SObject) anObj, aRef; - bool isRefOrSubShape = false; - if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) { - if (aRef->GetID() == aGroupMainShapeSO->GetID()) { - isRefOrSubShape = true; - } else { - _PTR(SObject) aFather = aGroupMainShapeSO->GetFather(); - _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent(); - while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) { - if (aRef->GetID() == aFather->GetID()) - isRefOrSubShape = true; - else - aFather = aFather->GetFather(); - } - } - } - if (isRefOrSubShape) - myGeomObjects[i++] = aGeomGroup; - } - - myGeomObjects->length(i); - if ( i == 0 ) - { - myIsBusy = false; - return; - } - - aNbSel = i; - } - - if (aNbSel >= 1) { - if (aNbSel > 1) { - if (myCurrentLineEdit == mySubMeshLine) - aString = tr( "SMESH_SUBMESH_SELECTED" ).arg(aNbSel); - else if (myCurrentLineEdit == myGroupLine) - aString = tr( "SMESH_GROUP_SELECTED" ).arg(aNbSel); - else if (myCurrentLineEdit == myGeomGroupLine) - aString = tr( "%1 Objects" ).arg(aNbSel); - } - else { - aString = aList.First()->getName(); - } - } - - myCurrentLineEdit->setText(aString); - myCurrentLineEdit->home(false); - // 07.06.2008 skl for IPAL19574: - // change name of group only if it is empty - if( myName->text().trimmed().isEmpty() || !myNameChanged ) { - myOldName = myName->text(); - myName->blockSignals(true); - myName->setText(aString); - myName->blockSignals(false); - } - - updateButtons(); - } - else // !myCurrentLineEdit: local selection of nodes or elements - { - if (aNbSel == 1 && myActorsList.count() > 0 ) - { - // NPAL19389: create a group with a selection in another group - // Switch myActor to the newly selected one, if the last - // is visible and belongs to group or submesh of myMesh - /* Handle(SALOME_InteractiveObject) curIO = myActor->getIO(); - Handle(SALOME_InteractiveObject) selIO = aList.First(); - if (curIO->hasEntry() && selIO->hasEntry()) { - const char* selEntry = selIO->getEntry(); - if (strcmp(curIO->getEntry(), selEntry) != 0) { - // different objects: selected and myActor - SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView(); - if (aViewWindow && aViewWindow->isVisible(selIO)) { - // newly selected actor is visible - - // mesh entry - _PTR(SObject) aSObject = SMESH::FindSObject(myMesh); - if (aSObject) { - CORBA::String_var meshEntry = aSObject->GetID().c_str(); - int len = strlen(meshEntry); - - if (strncmp(selEntry, meshEntry, len) == 0) { - // selected object is myMesh or a part of it - SMESH_Actor* anActor = SMESH::FindActorByEntry(selEntry); - if (anActor) { - myActor = anActor; - SMESH::SetPickable(myActor); - } - } - } - } - } - }*/ - // NPAL19389 END - - QString aListStr = ""; - int aNbItems = 0; - if (myTypeId == 0) { - QListIterator it( myActorsList ); - while ( it.hasNext() ) { - QString tmpStr; - aNbItems += SMESH::GetNameOfSelectedNodes(mySelector, it.next()->getIO(), tmpStr); - aListStr += tmpStr; - } - } else { - QListIterator it( myActorsList ); - while ( it.hasNext() ) { - QString tmpStr; - aNbItems += SMESH::GetNameOfSelectedElements(mySelector, it.next()->getIO(), tmpStr); - aListStr += tmpStr; - } - } - if (aNbItems > 0) { - QListWidgetItem* anItem; - QList listItemsToSel; - QStringList anElements = aListStr.split( " ", QString::SkipEmptyParts); - for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) { - QList found = myElements->findItems(*it, Qt::MatchExactly); - foreach(anItem, found) - if (!anItem->isSelected()) - listItemsToSel.push_back(anItem); - } - bool blocked = myElements->signalsBlocked(); - myElements->blockSignals(true); - foreach(anItem, listItemsToSel) anItem->setSelected(true); - myElements->blockSignals(blocked); - onListSelectionChanged(); - listItemsToSel.clear(); - } - } - } - - if (myActorsList.count() == 0) { - if (!myGroup->_is_nil()) { - SMESH_Actor* anActor = SMESH::FindActorByObject(myGroup); - if ( anActor ) - myActorsList.append( anActor ); - } - else if(!myGroupOnGeom->_is_nil()) { - SMESH_Actor* anActor = SMESH::FindActorByObject(myGroupOnGeom); - if ( anActor ) - myActorsList.append( anActor ); - } - else { - SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh ); - if ( anActor ) - myActorsList.append( anActor ); - } - } - - // somehow, if we display the mesh, while selecting from another actor, - // the mesh becomes pickable, and there is no way to select any element - if (myActorsList.count() > 0) { - QListIterator it( myActorsList ); - while ( it.hasNext() ) { - SMESH_Actor* anActor = it.next(); - if ( IsActorVisible(anActor) ) - anActor->SetPickable(true); - } - } - - myIsBusy = false; -} - -//================================================================================= -// function : onSelectAll() -// purpose : Called when "Select all" is checked -//================================================================================= -void SMESHGUI_AdaptDlg::onSelectAll() -{ - bool noElemsModif = ( mySelectAll->isChecked() || !myAllowElemsModif->isChecked() ); - - myElementsLab->setEnabled( !noElemsModif ); - myElements->setEnabled ( !noElemsModif ); - myFilterBtn->setEnabled ( !noElemsModif ); - myAddBtn->setEnabled ( !noElemsModif ); - myRemoveBtn->setEnabled ( !noElemsModif ); - mySortBtn->setEnabled ( !noElemsModif ); - mySelectBox->setEnabled ( !noElemsModif ); - myAllowElemsModif->setEnabled( !mySelectAll->isChecked() ); - if ( noElemsModif ) mySMESHGUI->ResetState(); - else mySMESHGUI->SetState(800); - - int selMode = mySelectionMode; - mySelectionMode = grpNoSelection; - setSelectionMode( selMode ); - updateButtons(); -} - -//================================================================================= -// function : onSelectSubMesh() -// purpose : Called when selection in 3D view or ObjectBrowser is changed -//================================================================================= -void SMESHGUI_AdaptDlg::onSelectSubMesh(bool on) -{ - if (on) { - if (mySelectGroup->isChecked()) { - mySelectGroup->setChecked(false); - } - //VSR: else if (mySelectGeomGroup->isChecked()) { - //VSR: mySelectGeomGroup->setChecked(false); - //VSR: } - myCurrentLineEdit = mySubMeshLine; - setSelectionMode(grpSubMeshSelection); - } - else { - mySubMeshLine->setText( "" ); - myCurrentLineEdit = 0; - if (myTypeId != -1) - setSelectionMode(myTypeId); - } - mySubMeshBtn->setEnabled(on); - mySubMeshLine->setEnabled(on); -} - - -//================================================================================= -// function : (onSelectGroup) -// purpose : Called when selection in 3D view or ObjectBrowser is changed -//================================================================================= -void SMESHGUI_AdaptDlg::onSelectGroup(bool on) -{ - if (on) { - if (mySelectSubMesh->isChecked()) { - mySelectSubMesh->setChecked(false); - } - myCurrentLineEdit = myGroupLine; - setSelectionMode(grpGroupSelection); - } - else { - myGroupLine->setText( "" ); - myCurrentLineEdit = 0; - if (myTypeId != -1) - setSelectionMode(myTypeId); - } - myGroupBtn->setEnabled(on); - myGroupLine->setEnabled(on); -} - - -//================================================================================= -// function : (onSelectGeomGroup) -// purpose : Called when group type changed. on == "on geometry" or "on filter" -//================================================================================= -void SMESHGUI_AdaptDlg::onSelectGeomGroup(bool on) -{ - if (on) { - if (mySelectSubMesh->isChecked()) { - mySelectSubMesh->setChecked(false); - } - else if (mySelectGroup->isChecked()) { - mySelectGroup->setChecked(false); - } - if ( myGrpTypeId == 1 ) { // on geometry - myCurrentLineEdit = myGeomGroupLine; - updateGeomPopup(); - } - else { // on filter - myCurrentLineEdit = 0; - } - setSelectionMode(grpAllSelection); - } - else { - myGeomGroupBtn->setChecked(false); - myGeomObjects->length(0); - myGeomGroupLine->setText( "" ); - myCurrentLineEdit = 0; - if (myTypeId != -1) - setSelectionMode( myTypeId ); - } -} - -//================================================================================= -// function : setCurrentSelection() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::setCurrentSelection() -{ - QPushButton* send = (QPushButton*)sender(); - myCurrentLineEdit = 0; - if (send == myMeshGroupBtn) { - disconnect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); - mySelectionMgr->clearSelected(); - if (myCreate) - setSelectionMode(grpMeshSelection); - else - setSelectionMode(grpGroupSelection); - connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); - myCurrentLineEdit = myMeshGroupLine; - onObjectSelectionChanged(); - } - else if (send == mySubMeshBtn) { - myCurrentLineEdit = mySubMeshLine; - onObjectSelectionChanged(); - } - else if (send == myGroupBtn) { - myCurrentLineEdit = myGroupLine; - onObjectSelectionChanged(); - } -} - - -//================================================================================= -// function : setFilters() -// purpose : SLOT. Called when "Filter" button pressed. -//================================================================================= -void SMESHGUI_AdaptDlg::setFilters() -{ - if(myMesh->_is_nil()) { - SUIT_MessageBox::critical(this, - tr("SMESH_ERROR"), - tr("NO_MESH_SELECTED")); - return; - } - - SMESH::ElementType aType = SMESH::ALL; - switch ( myTypeId ) - { - case grpNodeSelection: aType = SMESH::NODE; break; - case grp0DSelection: aType = SMESH::ELEM0D; break; - case grpBallSelection: aType = SMESH::BALL; break; - case grpEdgeSelection: aType = SMESH::EDGE; break; - case grpFaceSelection: aType = SMESH::FACE; break; - case grpVolumeSelection: aType = SMESH::VOLUME; break; - default: return; - } - - if ( myFilterDlg == 0 ) - { - myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType ); - connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) ); - } - else - myFilterDlg->Init( aType ); - - if ( !myGroupOnFilter->_is_nil() ) - { - myFilterDlg->SetFilter( myFilter, aType ); - myFilterDlg->Init( aType ); - } - - bool isStandalone = ( sender() == myFilterBtn ); - myFilterDlg->SetEnabled( /*setInViewer=*/isStandalone, - /*diffSources=*/isStandalone ); - myFilterDlg->SetMesh( myMesh ); - myFilterDlg->SetGroup( myGroupOnFilter ); - myFilterDlg->SetSelection(); - myFilterDlg->SetSourceWg( myElements, false ); - - myFilterDlg->show(); -} - -//================================================================================= -// function : onFilterAccepted() -// purpose : SLOT. Called when Filter dlg closed with OK button. -// Uncheck "Select submesh" and "Select group" checkboxes -//================================================================================= -void SMESHGUI_AdaptDlg::onFilterAccepted() -{ - if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() ) - { - mySelectionMode = myTypeId; - mySelectSubMesh->setChecked( false ); - mySelectGroup->setChecked( false ); - } - // get a filter from myFilterDlg - myFilter = myFilterDlg->GetFilter(); - if ( !myFilter->_is_nil() ) { - SMESH::Predicate_var perdicate = myFilter->GetPredicate(); - if ( perdicate->_is_nil() ) - myFilter = SMESH::Filter::_nil(); - } - // set mesh to myFilter - if ( !myFilter->_is_nil() ) { - SMESH::SMESH_Mesh_var mesh = myMesh; - if ( mesh->_is_nil() ) { - if ( !myGroup->_is_nil() ) - mesh = myGroup->GetMesh(); - else if ( !myGroupOnGeom->_is_nil() ) - mesh = myGroupOnGeom->GetMesh(); - else if ( !myGroupOnFilter->_is_nil() ) - mesh = myGroupOnFilter->GetMesh(); - } - myFilter->SetMesh( mesh ); - - // highlight ids if selection changed in the Viewer (IPAL52924) - myCurrentLineEdit = 0; - onObjectSelectionChanged(); - } - - updateButtons(); -} - -//================================================================================= -// function : onAdd() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onAdd() -{ - SALOME_ListIO aList; - mySelectionMgr->selectedObjects( aList ); - - int aNbSel = aList.Extent(); - - if (aNbSel == 0 || myActorsList.count() == 0 || myMesh->_is_nil()) return; - - SUIT_OverrideCursor wc; - - myIsBusy = true; - int sizeBefore = myElements->count(); - - SMESH::ElementType aType = SMESH::ALL; - switch(myTypeId) { - case grpNodeSelection: - aType = SMESH::NODE; - mySelector->SetSelectionMode(NodeSelection); - break; - case grpBallSelection: - aType = SMESH::BALL; - mySelector->SetSelectionMode(BallSelection); - break; - case grp0DSelection: - aType = SMESH::ELEM0D; - mySelector->SetSelectionMode(Elem0DSelection); - break; - case grpEdgeSelection: - aType = SMESH::EDGE; - mySelector->SetSelectionMode(EdgeSelection); - break; - case grpFaceSelection: - aType = SMESH::FACE; - mySelector->SetSelectionMode(FaceSelection); - break; - case grpVolumeSelection: - aType = SMESH::VOLUME; - mySelector->SetSelectionMode(VolumeSelection); - break; - default: - mySelector->SetSelectionMode(ActorSelection); - } - - QListWidgetItem* anItem = 0; - QList listItemsToSel; - - if ( myCurrentLineEdit == 0 ) - { - //if (aNbSel != 1) { myIsBusy = false; return; } - QString aListStr = ""; - int aNbItems = 0; - if (myTypeId == 0) { - QListIterator it( myActorsList ); - while ( it.hasNext() ) { - QString tmpStr; - aNbItems += SMESH::GetNameOfSelectedNodes(mySelector, it.next()->getIO(), tmpStr); - aListStr += tmpStr; - } - } - else { - QListIterator it( myActorsList ); - while ( it.hasNext() ) { - QString tmpStr; - aNbItems += SMESH::GetNameOfSelectedElements(mySelector, it.next()->getIO(), tmpStr); - aListStr += tmpStr; - } - } - if (aNbItems > 0) { - QStringList anElements = aListStr.split( " ", QString::SkipEmptyParts); - for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) { - QList found = myElements->findItems(*it, Qt::MatchExactly); - if (found.count() == 0) { - anItem = new QListWidgetItem(*it); - myElements->addItem(anItem); - if (!anItem->isSelected()) - listItemsToSel.push_back(anItem); - } - else { - foreach(anItem, found) - if (!anItem->isSelected()) - listItemsToSel.push_back(anItem); - } - } - bool blocked = myElements->signalsBlocked(); - myElements->blockSignals(true); - foreach(anItem, listItemsToSel) anItem->setSelected(true); - myElements->blockSignals(blocked); - onListSelectionChanged(); - listItemsToSel.clear(); - } - } - else if ( myCurrentLineEdit == mySubMeshLine ) - { - //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - - SALOME_ListIO aList; - mySelectionMgr->selectedObjects( aList ); - - SALOME_ListIteratorOfListIO anIt (aList); - for ( ; anIt.More(); anIt.Next()) { - SMESH::SMESH_subMesh_var aSubMesh = - SMESH::IObjectToInterface(anIt.Value()); - if (!aSubMesh->_is_nil()) { - // check if mesh is the same - if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { - try { - SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType); - int k = anElements->length(); - for (int i = 0; i < k; i++) { - QString aText = QString::number(anElements[i]); - QList found = myElements->findItems(aText, Qt::MatchExactly); - if (found.count() == 0) { - anItem = new QListWidgetItem(aText); - myElements->addItem(anItem); - if (!anItem->isSelected()) - listItemsToSel.push_back(anItem); - } - else { - foreach(anItem, found) - if (!anItem->isSelected()) - listItemsToSel.push_back(anItem); - } - } - bool blocked = myElements->signalsBlocked(); - myElements->blockSignals(true); - foreach(anItem, listItemsToSel) anItem->setSelected(true); - myElements->blockSignals(blocked); - onListSelectionChanged(); - listItemsToSel.clear(); - } - catch (const SALOME::SALOME_Exception& ex) { - SalomeApp_Tools::QtCatchCorbaException(ex); - } - } - } - } - mySelectSubMesh->setChecked(false); - myIsBusy = false; - onListSelectionChanged(); - - } - else if ( myCurrentLineEdit == myGroupLine ) - { - //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - SALOME_ListIO aList; - mySelectionMgr->selectedObjects( aList ); - - SALOME_ListIteratorOfListIO anIt (aList); - for ( ; anIt.More(); anIt.Next()) { - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(anIt.Value()); - if (!aGroup->_is_nil()) { - // check if mesh is the same - if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { - SMESH::long_array_var anElements = aGroup->GetListOfID(); - int k = anElements->length(); - for (int i = 0; i < k; i++) { - QString aText = QString::number(anElements[i]); - QList found = myElements->findItems(aText, Qt::MatchExactly); - if (found.count() == 0) { - anItem = new QListWidgetItem(aText); - myElements->addItem(anItem); - if (!anItem->isSelected()) - listItemsToSel.push_back(anItem); - } - else { - foreach(anItem, found) - if (!anItem->isSelected()) - listItemsToSel.push_back(anItem); - } - } - bool blocked = myElements->signalsBlocked(); - myElements->blockSignals(true); - foreach(anItem, listItemsToSel) anItem->setSelected(true); - myElements->blockSignals(blocked); - onListSelectionChanged(); - listItemsToSel.clear(); - } - } - } - mySelectGroup->setChecked(false); - myIsBusy = false; - onListSelectionChanged(); - - } - else if ( myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1 ) - { - GEOM::GEOM_IGroupOperations_wrap aGroupOp = - SMESH::GetGEOMGen( myGeomObjects[0] )->GetIGroupOperations(); - - SMESH::ElementType aGroupType = SMESH::ALL; - switch(aGroupOp->GetType(myGeomObjects[0])) { - case TopAbs_VERTEX: aGroupType = SMESH::NODE; break; - case TopAbs_EDGE: aGroupType = SMESH::EDGE; break; - case TopAbs_FACE: aGroupType = SMESH::FACE; break; - case TopAbs_SOLID: aGroupType = SMESH::VOLUME; break; - default: myIsBusy = false; return; - } - - if (aGroupType == aType) { - _PTR(SObject) aGroupSO = - //SMESH::getStudy()->FindObjectIOR(SMESH::getStudy()->ConvertObjectToIOR(myGeomGroup)); - SMESH::getStudy()->FindObjectID(myGeomObjects[0]->GetStudyEntry()); - // Construct filter - SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); - SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); - SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom(); - aBelongToGeom->SetGeom(myGeomObjects[0]); - aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str()); - aBelongToGeom->SetElementType(aType); - aFilter->SetPredicate(aBelongToGeom); - - SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh); - - int k = anElements->length(); - for (int i = 0; i < k; i++) { - QString aText = QString::number(anElements[i]); - QList found = myElements->findItems(aText, Qt::MatchExactly); - if (found.count() == 0) { - anItem = new QListWidgetItem(aText); - myElements->addItem(anItem); - if (!anItem->isSelected()) - listItemsToSel.push_back(anItem); - } - else { - foreach(anItem, found) - if (!anItem->isSelected()) - listItemsToSel.push_back(anItem); - } - } - bool blocked = myElements->signalsBlocked(); - myElements->blockSignals(true); - foreach(anItem, listItemsToSel) anItem->setSelected(true); - myElements->blockSignals(blocked); - onListSelectionChanged(); - listItemsToSel.clear(); - } - - //VSR: mySelectGeomGroup->setChecked(false); - myIsBusy = false; - onListSelectionChanged(); - } - myIsBusy = false; - if ( sizeBefore < myElements->count() ) - ++myNbChangesOfContents; - // mySelectionMgr->clearSelected(); - updateButtons(); -} - -//================================================================================= -// function : onRemove() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onRemove() -{ - myIsBusy = true; - int sizeBefore = myElements->count(); - - if (myCurrentLineEdit == 0) { - QList selItems = myElements->selectedItems(); - QListWidgetItem* item; - foreach(item, selItems) delete item; - } else { - SALOME_ListIO aList; - mySelectionMgr->selectedObjects( aList ); - - int aNbSel = aList.Extent(); - - if (aNbSel == 0) { myIsBusy = false; return; } - - SMESH::ElementType aType = SMESH::ALL; - switch(myTypeId) { - case grpNodeSelection: aType = SMESH::NODE; break; - case grp0DSelection: aType = SMESH::ELEM0D; break; - case grpBallSelection: aType = SMESH::BALL; break; - case grpEdgeSelection: aType = SMESH::EDGE; break; - case grpFaceSelection: aType = SMESH::FACE; break; - case grpVolumeSelection: aType = SMESH::VOLUME; break; - } - - if (myCurrentLineEdit == mySubMeshLine) { - //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); - SALOME_ListIO aList; - mySelectionMgr->selectedObjects( aList ); - - SALOME_ListIteratorOfListIO anIt (aList); - for ( ; anIt.More(); anIt.Next()) { - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIt.Value()); - if (!aSubMesh->_is_nil()) { - // check if mesh is the same - if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { - if (aType == SMESH::NODE) { - try { - SMESH::long_array_var anElements = aSubMesh->GetNodesId(); - int k = anElements->length(); - for (int i = 0; i < k; i++) { - QList found = - myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly); - QListWidgetItem* anItem; - foreach(anItem, found) delete anItem; - } - } - catch (const SALOME::SALOME_Exception& ex) { - SalomeApp_Tools::QtCatchCorbaException(ex); - } - } - else { - try { - SMESH::long_array_var anElements = aSubMesh->GetElementsId(); - int k = anElements->length(); - for (int i = 0; i < k; i++) { - QList found = - myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly); - QListWidgetItem* anItem; - foreach(anItem, found) delete anItem; - } - } - catch (const SALOME::SALOME_Exception& ex) { - SalomeApp_Tools::QtCatchCorbaException(ex); - } - } - } - } - } - } - else if (myCurrentLineEdit == myGroupLine) { - SALOME_ListIO aList; - mySelectionMgr->selectedObjects( aList ); - - SALOME_ListIteratorOfListIO anIt (aList); - for ( ; anIt.More(); anIt.Next()) { - SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(anIt.Value()); - if (!aGroup->_is_nil()) { - // check if mesh is the same - if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { - SMESH::long_array_var anElements = aGroup->GetListOfID(); - int k = anElements->length(); - for (int i = 0; i < k; i++) { - QList found = - myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly); - QListWidgetItem* anItem; - foreach(anItem, found) delete anItem; - } - } - } - } - } - } - myIsBusy = false; - if ( sizeBefore > myElements->count() ) - myNbChangesOfContents += 2; // it's used to detect that "Add" was only once - updateButtons(); -} - -//================================================================================= -// function : onSort() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onSort() -{ - // PAL5412: sorts items in ascending by "string" value - // myElements->sort(true); - // myElements->update(); - int i, k = myElements->count(); - if (k > 0) { - myIsBusy = true; - QList aSelected; - std::vector anArray(k); - // QMemArray anArray(k); - // fill the array - for (i = 0; i < k; i++) { - int id = myElements->item(i)->text().toInt(); - anArray[i] = id; - if (myElements->item(i)->isSelected()) - aSelected.append(id); - } - // sort & update list - std::sort(anArray.begin(), anArray.end()); - // anArray.sort(); - myElements->clear(); - QListWidgetItem* anItem; - QList listItemsToSel; - for (i = 0; i < k; i++) { - anItem = new QListWidgetItem(QString::number(anArray[i])); - myElements->addItem(anItem); - if (aSelected.contains(anArray[i])) - listItemsToSel.push_back(anItem); - } - bool blocked = myElements->signalsBlocked(); - myElements->blockSignals(true); - foreach(anItem, listItemsToSel) anItem->setSelected(true); - myElements->blockSignals(blocked); - listItemsToSel.clear(); - myIsBusy = false; - } -} - -//================================================================================= -// function : onVisibilityChanged() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onVisibilityChanged() -{ - SetAppropriateActor(); -} - -//================================================================================= -// function : SMESHGUI_AdaptDlg::reject -// purpose : SLOT called when "Close" button pressed. Close dialog -//================================================================================= -void SMESHGUI_AdaptDlg::reject() -{ - if (SMESH::GetCurrentVtkView()) { - SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters - SMESH::SetPointRepresentation(false); - SMESH::SetPickable(); - restoreShowEntityMode(); - } - - if( isApplyAndClose() && !myObjectToSelect.isEmpty() ) { - SUIT_DataOwnerPtrList aList; - aList.append( new LightApp_DataOwner( myObjectToSelect ) ); - mySelectionMgr->setSelected( aList ); - } - else - mySelectionMgr->clearSelected(); - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(ActorSelection); - mySelectionMgr->clearFilters(); - mySMESHGUI->ResetState(); - - QDialog::reject(); - - if ( myFilterDlg ) myFilterDlg->UnRegisterFilters(); -} - -//================================================================================= -// function : onOpenView() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onOpenView() -{ - if ( mySelector ) { - SMESH::SetPointRepresentation(false); - } - else { - mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); - mySMESHGUI->EmitSignalDeactivateDialog(); - setEnabled(true); - } -} - -//================================================================================= -// function : onCloseView() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onCloseView() -{ - onDeactivate(); - mySelector = 0; -} - -//================================================================================= -// function : onHelp() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onHelp() -{ - LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - if (app) - { - app->onHelpContextModule - ( mySMESHGUI ? app->moduleName( mySMESHGUI->moduleName() ) : QString(""), myHelpFileName ); - } - else - { -#ifdef WIN32 - QString platform = "winapplication"; -#else - QString platform = "application"; -#endif - SUIT_MessageBox::warning(this, tr( "WRN_WARNING" ), - tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ). - arg(app->resourceMgr()->stringValue( "ExternalBrowser", platform)). - arg(myHelpFileName)); - } -} - -//================================================================================= -// function : SMESHGUI_AdaptDlg::onDeactivate -// purpose : SLOT called when dialog must be deactivated -//================================================================================= -void SMESHGUI_AdaptDlg::onDeactivate() -{ - mySMESHGUI->ResetState(); - setEnabled(false); -} - -//================================================================================= -// function : SMESHGUI_AdaptDlg::enterEvent -// purpose : Event filter -//================================================================================= -void SMESHGUI_AdaptDlg::enterEvent (QEvent*) -{ - if (!isEnabled()) { - SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); - if ( aViewWindow && !mySelector) { - mySelector = aViewWindow->GetSelector(); - } - mySMESHGUI->EmitSignalDeactivateDialog(); - setEnabled(true); - mySelectionMode = grpNoSelection; - setSelectionMode(myTypeId); - mySMESHGUI->SetActiveDialogBox(this); - if ( mySelectBox->isEnabled() ) mySMESHGUI->SetState(800); - else mySMESHGUI->ResetState(); - } -} - -//================================================================================= -// function : keyPressEvent() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::keyPressEvent( QKeyEvent* e ) -{ - QDialog::keyPressEvent( e ); - if ( e->isAccepted() ) - return; - - if ( e->key() == Qt::Key_F1 ) - { - e->accept(); - onHelp(); - } -} - -//================================================================================ -/*! - * \brief Enable showing of the popup when Geometry selection btn is clicked - * \param enable - true to enable - */ -//================================================================================ - -enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX }; - -void SMESHGUI_AdaptDlg::updateGeomPopup() -{ - bool enable = false; - - if ( !myMesh->_is_nil() ) - enable = myMesh->NbEdges() > 0; - - if ( myGeomGroupBtn ) - { - disconnect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) )); - if ( enable ) { - if ( !myGeomPopup ) { - myGeomPopup = new QMenu(this); - myActions[myGeomPopup->addAction( tr( "DIRECT_GEOM_SELECTION" ) )] = DIRECT_GEOM_INDEX; - myActions[myGeomPopup->addAction( tr( "GEOM_BY_MESH_ELEM_SELECTION" ) )] = GEOM_BY_MESH_INDEX; - connect( myGeomPopup, SIGNAL( triggered( QAction* ) ), SLOT( onGeomPopup( QAction* ) ) ); - } - connect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) )); - } - } -} - - -//================================================================================= -// function : onGeomSelectionButton() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onGeomSelectionButton(bool isBtnOn) -{ - if ( myGeomPopup && isBtnOn ) - { - myCurrentLineEdit = myGeomGroupLine; - QAction* a = myGeomPopup->exec( QCursor::pos() ); - if (!a || myActions[a] == DIRECT_GEOM_INDEX) - setSelectionMode(grpGeomSelection); - } - else if (!isBtnOn) - { - myCurrentLineEdit = 0; - setSelectionMode(grpAllSelection); - } -} - -//================================================================================= -// function : onGeomPopup() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::onGeomPopup( QAction* a ) -{ - int index = myActions[a]; - if ( index == GEOM_BY_MESH_INDEX ) - { - mySelectionMode = grpNoSelection; - if ( !myShapeByMeshOp ) { - myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true); - connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)), - SLOT(onPublishShapeByMeshDlg(SUIT_Operation*))); - connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)), - SLOT(onCloseShapeByMeshDlg(SUIT_Operation*))); - } - // set mesh object to SMESHGUI_ShapeByMeshOp and start it - if ( !myMesh->_is_nil() ) { - myIsBusy = true; - hide(); // stop processing selection - myIsBusy = false; - myShapeByMeshOp->setModule( mySMESHGUI ); - myShapeByMeshOp->setStudy( 0 ); // it's really necessary - myShapeByMeshOp->SetMesh( myMesh ); - myShapeByMeshOp->start(); - } - } -} - -//================================================================================ -/*! - * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg - */ -//================================================================================ - -void SMESHGUI_AdaptDlg::onPublishShapeByMeshDlg(SUIT_Operation* op) -{ - if ( myShapeByMeshOp == op ) { - mySMESHGUI->getApp()->updateObjectBrowser(); - show(); - // Select a found geometry object - GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape(); - if ( !aGeomVar->_is_nil() ) - { - QString ID = aGeomVar->GetStudyEntry(); - if ( _PTR(SObject) aGeomSO = SMESH::getStudy()->FindObjectID( ID.toLatin1().data() )) { - SALOME_ListIO anIOList; - Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject - ( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() ); - anIOList.Append( anIO ); - mySelectionMgr->setSelectedObjects( anIOList, false ); - onObjectSelectionChanged(); - } - } - } -} - -//================================================================================ -/*! - * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg - */ -//================================================================================ - -void SMESHGUI_AdaptDlg::onCloseShapeByMeshDlg(SUIT_Operation* op) -{ - if ( myShapeByMeshOp == op ) - { - show(); - setSelectionMode(grpGeomSelection); - } -} - -//================================================================================= -// function : setGroupColor() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::setGroupColor( const SALOMEDS::Color& theColor ) -{ - QColor aQColor( (int)( theColor.R * 255.0 ), - (int)( theColor.G * 255.0 ), - (int)( theColor.B * 255.0 ) ); - setGroupQColor( aQColor ); -} - -//================================================================================= -// function : getGroupColor() -// purpose : -//================================================================================= -SALOMEDS::Color SMESHGUI_AdaptDlg::getGroupColor() const -{ - QColor aQColor = getGroupQColor(); - - SALOMEDS::Color aColor; - aColor.R = (float)aQColor.red() / 255.0; - aColor.G = (float)aQColor.green() / 255.0; - aColor.B = (float)aQColor.blue() / 255.0; - - return aColor; -} - -//================================================================================= -// function : setGroupQColor() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::setGroupQColor( const QColor& theColor ) -{ - if( theColor.isValid() ) - myColorBtn->setColor( theColor ); -} - -//================================================================================= -// function : getGroupQColor() -// purpose : -//================================================================================= -QColor SMESHGUI_AdaptDlg::getGroupQColor() const -{ - return myColorBtn->color(); -} - -//================================================================================= -// function : setDefaultGroupColor() -// purpose : -//================================================================================= -void SMESHGUI_AdaptDlg::setDefaultGroupColor() -{ - if( myMesh->_is_nil() ) - return; - - bool isAutoColor = myMesh->GetAutoColor(); - - QColor aQColor = myColorBtn->color(); - if( !isAutoColor ) - { - if ( !aQColor.isValid() ) { - int r = 0, g = 0, b = 0; - SMESH::GetColor( "SMESH", "default_grp_color", r, g, b, QColor( 255, 170, 0 ) ); - aQColor.setRgb( r, g, b ); - } - } - else - { -#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors - SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor(); -#else // old algorithm for auto-colors - SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups(); - - QList aReservedColors; - for( int i = 0, n = aListOfGroups.length(); i < n; i++ ) - { - SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i]; - SALOMEDS::Color aReservedColor = aGroupObject->GetColor(); - aReservedColors.append( aReservedColor ); - } - - SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors ); -#endif // SIMPLE_AUTOCOLOR - - aQColor.setRgb( (int)( aColor.R * 255.0 ), - (int)( aColor.G * 255.0 ), - (int)( aColor.B * 255.0 ) ); - - } - - setGroupQColor( aQColor ); -} - -//================================================================================= -// function : SetAppropriateActor() -// purpose : Find more appropriate of visible actors, set it to myActor, allow picking -// NPAL19389: create a group with a selection in another group. -// if mesh actor is not visible - find any first visible group or sub-mesh -//================================================================================= -bool SMESHGUI_AdaptDlg::SetAppropriateActor() -{ - bool isActor = false; - myActorsList.clear(); - - if (myMesh->_is_nil()) return false; - - SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView(); - - if (myGrpTypeGroup->checkedId() > 0) { // try current group on geometry actor - SMESH_Actor* anActor = 0; - if (!myGroupOnGeom->_is_nil()) - anActor = SMESH::FindActorByObject(myGroupOnGeom); - if (!myGroupOnFilter->_is_nil()) - anActor = SMESH::FindActorByObject(myGroupOnFilter); - if (anActor && anActor->hasIO()) - { - isActor = true; - if (aViewWindow && !aViewWindow->isVisible(anActor->getIO())) - isActor = false; - else - myActorsList.append(anActor); - } - return anActor; - } - else { - // try mesh actor - SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); - if (anActor && anActor->hasIO()) { - isActor = true; - if (aViewWindow && !aViewWindow->isVisible(anActor->getIO())) - isActor = false; - else - myActorsList.append(anActor); - } - - // try group actor - SMESH_Actor* aGroupActor = 0; - if (!isActor && !myGroup->_is_nil()) { - aGroupActor = SMESH::FindActorByObject(myGroup); - if (aGroupActor && aGroupActor->hasIO()) - myActorsList.append(aGroupActor); - } - - // try any visible actor of group or sub-mesh of current mesh - if (aViewWindow) { - // mesh entry - _PTR(SObject) aSObject = SMESH::FindSObject(myMesh); - if (aSObject) { - CORBA::String_var meshEntry = aSObject->GetID().c_str(); - int len = strlen(meshEntry); - - // iterate on all actors in current view window, search for - // any visible actor, that belongs to group or submesh of current mesh - VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors()); - vtkActorCollection *aCollection = aCopy.GetActors(); - int nbItems = aCollection->GetNumberOfItems(); - for (int i=0; i(aCollection->GetItemAsObject(i)); - if (anActor && anActor->hasIO()) { - Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); - if (aViewWindow->isVisible(anIO)) { - if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0 && !myActorsList.contains(anActor) ) - myActorsList.append(anActor); - } - } - } - } - } - - // Show a standalone group if nothing else is visible (IPAL52227) - if ( myActorsList.count() == 1 && - myActorsList[0] == aGroupActor && - aViewWindow && !aViewWindow->isVisible(aGroupActor->getIO())) - SMESH::UpdateView( aViewWindow, SMESH::eDisplay, aGroupActor->getIO()->getEntry() ); - } - - - if (myActorsList.count() > 0) { - QListIterator it( myActorsList ); - while ( it.hasNext() ) { - SMESH_Actor* anActor = it.next(); - if ( IsActorVisible(anActor) ) - anActor->SetPickable(true); - } - } - - return ( isActor || (myActorsList.count() > 0) ); -} - -//======================================================================= -//function : setShowEntityMode -//purpose : make shown only entity corresponding to my type -//======================================================================= -void SMESHGUI_AdaptDlg::setShowEntityMode() -{ - if ( !myMesh->_is_nil() ) { - if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) { - if (!myStoredShownEntity) - myStoredShownEntity = actor->GetEntityMode(); - switch ( myTypeId ) { - case grpNodeSelection: restoreShowEntityMode(); break; - case grp0DSelection: actor->SetEntityMode( SMESH_Actor::e0DElements ); break; - case grpBallSelection: actor->SetEntityMode( SMESH_Actor::eBallElem ); break; - case grpEdgeSelection: actor->SetEntityMode( SMESH_Actor::eEdges ); break; - case grpFaceSelection: actor->SetEntityMode( SMESH_Actor::eFaces ); break; - case grpVolumeSelection: actor->SetEntityMode( SMESH_Actor::eVolumes ); break; - } - } - } -} - -//======================================================================= -//function : restoreShowEntityMode -//purpose : restore ShowEntity mode of myActor -//======================================================================= -void SMESHGUI_AdaptDlg::restoreShowEntityMode() -{ - if ( myStoredShownEntity && !myMesh->_is_nil() ) { - if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) { - actor->SetEntityMode(myStoredShownEntity); - } - } - myStoredShownEntity = 0; -} - -//======================================================================= -//function : IsActorVisible -//purpose : return visibility of the actor -//======================================================================= -bool SMESHGUI_AdaptDlg::IsActorVisible( SMESH_Actor* theActor ) -{ - SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView(); - if (theActor && aViewWindow) - return aViewWindow->isVisible(theActor->getIO()); - return false; -} - -//================================================================ -//function : setIsApplyAndClose -//purpose : Set value of the flag indicating that the dialog is -// accepted by Apply & Close button -//================================================================ -void SMESHGUI_AdaptDlg::setIsApplyAndClose( const bool theFlag ) -{ - myIsApplyAndClose = theFlag; -} - -//================================================================ -//function : isApplyAndClose -//purpose : Get value of the flag indicating that the dialog is -// accepted by Apply & Close button -//================================================================ -bool SMESHGUI_AdaptDlg::isApplyAndClose() const -{ - return myIsApplyAndClose; -} diff --git a/src/SMESHGUI/SMESHGUI_AdaptDlg.h b/src/SMESHGUI/SMESHGUI_AdaptDlg.h index 2b139a3c0..4392340ea 100644 --- a/src/SMESHGUI/SMESHGUI_AdaptDlg.h +++ b/src/SMESHGUI/SMESHGUI_AdaptDlg.h @@ -29,36 +29,12 @@ // Qt includes #include -#include -#include // IDL includes #include #include CORBA_SERVER_HEADER(SMESH_Mesh) -#include CORBA_SERVER_HEADER(SMESH_Group) -#include CORBA_SERVER_HEADER(SMESH_Filter) - -class QGroupBox; -class QLabel; -class QLineEdit; -class QButtonGroup; -class QListWidget; -class QMenu; -class QPushButton; -class QToolButton; -class QCheckBox; -class QStackedWidget; -class QAction; + class SMESHGUI; -class SMESH_Actor; -class SMESHGUI_FilterDlg; -class SMESHGUI_ShapeByMeshOp; -class QtxColorButton; -class SUIT_Operation; -class SVTK_Selector; -class SUIT_SelectionFilter; -class LightApp_SelectionMgr; -class SMESH_LogicalFilter; //================================================================================= // class : SMESHGUI_AdaptDlg @@ -77,161 +53,18 @@ public: virtual bool action (int theCommandID); virtual bool OnGUIEvent (int theCommandID); - static QString GetDefaultName( const QString& ); - -// static ADAPT::ADAPT_Gen_var InitAdaptGen(SalomeApp_Application*); +// static ADAPT::ADAPT_Gen_var InitAdaptGen(SalomeApp_Application*); public slots: - void onAdd(); - void onRemove(); protected slots: - virtual void reject(); private slots: - void onTypeChanged( int ); - void onGrpTypeChanged( int ); - void onColorChanged( QColor ); - - void onOK(); - bool onApply(); - void onHelp(); - void onDeactivate(); - void onVisibilityChanged(); - - void onListSelectionChanged(); - void onObjectSelectionChanged(); - - void onSelectAll(); - void onSelectSubMesh( bool ); - void onSelectGroup( bool ); - void onSelectGeomGroup( bool ); - void setCurrentSelection(); - - void setFilters(); - void onSort(); - - void onNameChanged( const QString& ); - void onFilterAccepted(); - - void onGeomPopup( QAction* ); - void onGeomSelectionButton( bool ); - - void onPublishShapeByMeshDlg( SUIT_Operation* ); - void onCloseShapeByMeshDlg( SUIT_Operation* ); - - void onOpenView(); - void onCloseView(); private: - void initDialog( bool ); - void init( SMESH::SMESH_Mesh_ptr ); - void init( SMESH::SMESH_GroupBase_ptr ); - void enterEvent( QEvent* ); - void keyPressEvent( QKeyEvent* ); - void setSelectionMode( int ); - void updateButtons(); - void updateGeomPopup(); - bool SetAppropriateActor(); - void setShowEntityMode(); - void restoreShowEntityMode(); - - bool IsActorVisible( SMESH_Actor* ); - - void setGroupColor( const SALOMEDS::Color& ); - SALOMEDS::Color getGroupColor() const; - - void setGroupQColor( const QColor& ); - QColor getGroupQColor() const; - void setDefaultName() const; - void setDefaultGroupColor(); - - void setIsApplyAndClose( const bool theFlag ); - bool isApplyAndClose() const; - - private: void recupPreferences(); SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ - LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ - int myGrpTypeId; /* Current group type id : standalone or group on geometry */ - int myTypeId; /* Current type id = radio button id */ - int myStoredShownEntity; /* Store ShowEntity mode of myMesh */ - QLineEdit* myCurrentLineEdit; /* Current LineEdit */ - SVTK_Selector* mySelector; - - QPushButton* myMeshGroupBtn; - QLineEdit* myMeshGroupLine; - - QButtonGroup* myTypeGroup; - QLineEdit* myName; - QString myOldName; - - QButtonGroup* myGrpTypeGroup; - - QStackedWidget* myWGStack; - QCheckBox* mySelectAll; - QCheckBox* myAllowElemsModif; - QLabel* myElementsLab; - QListWidget* myElements; - QPushButton* myFilterBtn; - QPushButton* myAddBtn; - QPushButton* myRemoveBtn; - QPushButton* mySortBtn; - - QGroupBox* mySelectBox; - QCheckBox* mySelectSubMesh; - QPushButton* mySubMeshBtn; - QLineEdit* mySubMeshLine; - QCheckBox* mySelectGroup; - QPushButton* myGroupBtn; - QLineEdit* myGroupLine; - - QtxColorButton* myColorBtn; - - QCheckBox* mySelectGeomGroup; - QToolButton* myGeomGroupBtn; - QLineEdit* myGeomGroupLine; - QMenu* myGeomPopup; - - QPushButton* myOKBtn; - QPushButton* myApplyBtn; - QPushButton* myCloseBtn; - QPushButton* myHelpBtn; - - SMESHGUI_ShapeByMeshOp* myShapeByMeshOp; - - SMESH::SMESH_Mesh_var myMesh; - QList myActorsList; - SMESH::SMESH_Group_var myGroup; - SMESH::SMESH_GroupOnGeom_var myGroupOnGeom; - SMESH::SMESH_GroupOnFilter_var myGroupOnFilter; - SMESH::Filter_var myFilter; - QList myIdList; - GEOM::ListOfGO_var myGeomObjects; - - int mySelectionMode; - //Handle(SMESH_TypeFilter) myMeshFilter; - //Handle(SMESH_TypeFilter) mySubMeshFilter; - //Handle(SMESH_TypeFilter) myGroupFilter; - SUIT_SelectionFilter* myMeshFilter; - SMESH_LogicalFilter* mySubMeshFilter; - SMESH_LogicalFilter* myGroupFilter; - SUIT_SelectionFilter* myGeomFilter; - - SMESHGUI_FilterDlg* myFilterDlg; - - bool myCreate, myIsBusy; - - QString myHelpFileName; - - QMap myActions; - - bool myNameChanged; //added by skl for IPAL19574 - int myNbChangesOfContents; // nb add's and remove's - - QString myObjectToSelect; - bool myIsApplyAndClose; QString _ObjectName; QString _LanguageShort ; -- 2.30.2