+ myNameEdit->setText( theName );
+}
+
+/*!
+ \brief Provides reaction on �F1� button pressing
+ \param e key press event
+*/
+void SMESHGUI_GroupOpDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 ) {
+ e->accept();
+ onHelp();
+ }
+}
+
+/*!
+ \brief This virtual slot does nothing and should be redefined in derived classes
+ \return return false;
+*/
+bool SMESHGUI_GroupOpDlg::onApply()
+{
+ return false;
+}
+
+/*!
+ \brief Set value of the flag indicating that the dialog is
+ accepted by Apply & Close button
+ \param theFlag value of the flag
+ \sa isApplyAndClose()
+*/
+void SMESHGUI_GroupOpDlg::setIsApplyAndClose( const bool theFlag )
+{
+ myIsApplyAndClose = theFlag;
+}
+
+/*!
+ \brief Get value of the flag indicating that the dialog is
+ accepted by Apply & Close button
+ \return value of the flag
+ \sa setApplyAndClose()
+*/
+bool SMESHGUI_GroupOpDlg::isApplyAndClose() const
+{
+ return myIsApplyAndClose;
+}
+
+// === === === === === === === === === === === === === === === === === === === === ===
+
+/*!
+ \brief Constructor
+ \param theModule module
+*/
+SMESHGUI_UnionGroupsDlg::SMESHGUI_UnionGroupsDlg( SMESHGUI* theModule )
+: SMESHGUI_GroupOpDlg( theModule )
+{
+ setWindowTitle(tr("UNION_OF_GROUPS"));
+ setHelpFileName( "using_operations_on_groups_page.html#union_anchor" );
+
+ QGroupBox* anArgGrp = getArgGrp();
+ myListWg = new QListWidget( anArgGrp );
+
+ QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
+ aLay->addWidget( myListWg );
+}
+
+/*!
+ \brief Destructor
+*/
+SMESHGUI_UnionGroupsDlg::~SMESHGUI_UnionGroupsDlg()
+{
+}
+
+/*!
+ \brief This virtual method redefined from the base class resets state
+ of the dialog, initializes its fields with default value, etc.
+*/
+void SMESHGUI_UnionGroupsDlg::reset()
+{
+ SMESHGUI_GroupOpDlg::reset();
+ myListWg->clear();
+ myGroups.clear();
+}
+
+/*!
+ \brief SLOT called when apply button is pressed performs operation
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+bool SMESHGUI_UnionGroupsDlg::onApply()
+{
+ if ( getSMESHGUI()->isActiveStudyLocked())
+ return false;
+
+ // Verify validity of group name
+ if ( getName() == "" )
+ {
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
+ return false;
+ }
+
+ if ( !isValid( myGroups ) )
+ return false;
+
+ SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
+ QString aName = getName();
+
+ bool aRes = false;
+ QStringList anEntryList;
+ try
+ {
+ SMESH::ListOfGroups_var aList = convert( myGroups );
+ SMESH::SMESH_Group_var aNewGrp =
+ aMesh->UnionListOfGroups( aList, aName.toLatin1().constData() );
+ if ( !CORBA::is_nil( aNewGrp ) )
+ {
+ aNewGrp->SetColor( getColor() );
+ if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
+ anEntryList.append( aSObject->GetID().c_str() );
+ aRes = true;
+ }
+ }
+ catch( ... )
+ {
+ aRes = false;
+ }
+
+ if ( aRes )
+ {
+ SMESHGUI::Modified();
+ getSMESHGUI()->updateObjBrowser(true);
+ reset();
+ if( LightApp_Application* anApp =
+ dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+ anApp->browseObjects( anEntryList, isApplyAndClose() );
+ return true;
+ }
+ else
+ {
+ SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
+ tr("SMESH_OPERATION_FAILED"));
+ return false;
+ }
+}
+
+/*!
+ \brief SLOT, called when selection is changed, updates corresponding GUI controls
+*/
+void SMESHGUI_UnionGroupsDlg::onSelectionDone()
+{
+ QStringList aNames;
+ getSelectedGroups( myGroups, aNames );
+ myListWg->clear();
+ myListWg->addItems( aNames );
+}
+
+// === === === === === === === === === === === === === === === === === === === === ===
+
+/*!
+ \brief Constructor
+ \param theModule module
+*/
+SMESHGUI_IntersectGroupsDlg::SMESHGUI_IntersectGroupsDlg( SMESHGUI* theModule )
+: SMESHGUI_GroupOpDlg( theModule )
+{
+ setWindowTitle(tr("INTERSECTION_OF_GROUPS"));
+ setHelpFileName( "using_operations_on_groups_page.html#intersection_anchor" );
+
+ QGroupBox* anArgGrp = getArgGrp();
+ myListWg = new QListWidget( anArgGrp );
+
+ QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
+ aLay->addWidget( myListWg );
+}
+
+/*!
+ \brief Destructor
+*/
+SMESHGUI_IntersectGroupsDlg::~SMESHGUI_IntersectGroupsDlg()
+{
+}
+
+/*!
+ \brief This virtual method redefined from the base class resets state
+ of the dialog, initializes its fields with default value, etc.
+*/
+void SMESHGUI_IntersectGroupsDlg::reset()
+{
+ SMESHGUI_GroupOpDlg::reset();
+ myListWg->clear();
+ myGroups.clear();
+}
+
+/*!
+ \brief SLOT called when apply button is pressed performs operation
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+bool SMESHGUI_IntersectGroupsDlg::onApply()
+{
+ if ( getSMESHGUI()->isActiveStudyLocked())
+ return false;
+
+ // Verify validity of group name
+ if ( getName() == "" )
+ {
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
+ return false;
+ }
+
+ if ( !isValid( myGroups ) )
+ return false;
+
+ SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
+ QString aName = getName();
+
+ bool aRes = false;
+ QStringList anEntryList;
+ try
+ {
+ SMESH::ListOfGroups_var aList = convert( myGroups );
+ SMESH::SMESH_Group_var aNewGrp =
+ aMesh->IntersectListOfGroups( aList, aName.toLatin1().constData() );
+ if ( !CORBA::is_nil( aNewGrp ) )
+ {
+ aNewGrp->SetColor( getColor() );
+ if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
+ anEntryList.append( aSObject->GetID().c_str() );
+ aRes = true;
+ }
+ }
+ catch( ... )
+ {
+ aRes = false;
+ }
+
+ if ( aRes )
+ {
+ SMESHGUI::Modified();
+ getSMESHGUI()->updateObjBrowser(true);
+ reset();
+ if( LightApp_Application* anApp =
+ dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+ anApp->browseObjects( anEntryList, isApplyAndClose() );
+ return true;
+ }
+ else
+ {
+ SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
+ tr("SMESH_OPERATION_FAILED"));
+ return false;
+ }
+}
+
+/*!
+ \brief SLOT, called when selection is changed, updates corresponding GUI controls
+*/
+void SMESHGUI_IntersectGroupsDlg::onSelectionDone()
+{
+ QStringList aNames;
+ getSelectedGroups( myGroups, aNames );
+ myListWg->clear();
+ myListWg->addItems( aNames );
+}
+
+// === === === === === === === === === === === === === === === === === === === === ===
+
+/*!
+ \brief Constructor
+ \param theModule module
+*/
+SMESHGUI_CutGroupsDlg::SMESHGUI_CutGroupsDlg( SMESHGUI* theModule )
+: SMESHGUI_GroupOpDlg( theModule )
+{
+ setWindowTitle(tr("CUT_OF_GROUPS"));
+ setHelpFileName( "using_operations_on_groups_page.html#cut_anchor" );
+
+ QGroupBox* anArgGrp = getArgGrp();
+
+ QPixmap aPix (SMESH::GetResourceMgr( getSMESHGUI() )->loadPixmap("SMESH", tr("ICON_SELECT")));
+
+ // frame 1
+ QFrame* aFrame1 = new QFrame( anArgGrp );
+ QLabel* aLbl1 = new QLabel( tr("MAIN_OBJECT"), aFrame1 );
+ aLbl1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myBtn1 = new QPushButton( aFrame1 );
+ myBtn1->setIcon(aPix);
+ myListWg1 = new QListWidget( aFrame1 );
+
+ QGridLayout* aLay1 = new QGridLayout( aFrame1 );
+ aLay1->setSpacing( SPACING );
+ aLay1->addWidget( aLbl1, 0, 0 );
+ aLay1->addWidget( myBtn1, 0, 1 );
+ aLay1->addWidget( myListWg1, 1, 0, 1, 2 );
+ //QSpacerItem* aHSpacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ //aLay1->addItem( aHSpacer1, 0, 2 );
+
+
+ // frame 2
+ QFrame* aFrame2 = new QFrame( anArgGrp );
+ QLabel* aLbl2 = new QLabel( tr("TOOL_OBJECT"), aFrame2 );
+ aLbl2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myBtn2 = new QPushButton( aFrame2 );
+ myBtn2->setIcon(aPix);
+ myListWg2 = new QListWidget( aFrame2 );
+
+ QGridLayout* aLay2 = new QGridLayout( aFrame2 );
+ aLay2->setSpacing( SPACING );
+ aLay2->addWidget( aLbl2, 0, 0 );
+ aLay2->addWidget( myBtn2, 0, 1 );
+ aLay2->addWidget( myListWg2, 1, 0, 1, 2 );
+ //QSpacerItem* aHSpacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ //aLay2->addItem( aHSpacer2, 0, 2 );
+
+ // create button group
+
+ QButtonGroup* aGrp = new QButtonGroup( anArgGrp );
+ aGrp->addButton( myBtn1, 0 );
+ aGrp->addButton( myBtn2, 1 );
+ myBtn1->setCheckable( true );
+ myBtn2->setCheckable( true );
+ aGrp->setExclusive( true );
+ myBtn1->setChecked( true );
+
+ // fill layout
+ QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
+ aLay->setSpacing( SPACING );
+ aLay->addWidget( aFrame1 );
+ aLay->addWidget( aFrame2 );
+}
+
+/*!
+ \brief Destructor
+*/
+SMESHGUI_CutGroupsDlg::~SMESHGUI_CutGroupsDlg()
+{
+}
+
+/*!
+ \brief This virtual method redefined from the base class resets state
+ of the dialog, initializes its fields with default value, etc.
+*/
+void SMESHGUI_CutGroupsDlg::reset()
+{
+ SMESHGUI_GroupOpDlg::reset();
+
+ myListWg1->clear();
+ myGroups1.clear();
+
+ myListWg2->clear();
+ myGroups2.clear();
+}
+
+/*!
+ \brief SLOT called when apply button is pressed performs operation
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+bool SMESHGUI_CutGroupsDlg::onApply()
+{
+ if ( getSMESHGUI()->isActiveStudyLocked())
+ return false;
+
+ // Verify validity of group name
+ if ( getName() == "" )
+ {
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
+ return false;
+ }
+
+ if ( myGroups1.isEmpty() || myGroups2.isEmpty() )
+ {
+ SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("INCORRECT_ARGUMENTS") );
+ return false;
+ }
+
+ QList<SMESH::SMESH_GroupBase_var> aGroups = myGroups1;
+ QList<SMESH::SMESH_GroupBase_var>::iterator anIter;
+ for ( anIter = myGroups2.begin(); anIter != myGroups2.end(); ++anIter )
+ aGroups.append( *anIter );
+
+ if ( !isValid( aGroups ) )
+ return false;
+
+ SMESH::SMESH_Mesh_var aMesh = myGroups1.first()->GetMesh();
+ QString aName = getName();
+
+ bool aRes = false;
+ QStringList anEntryList;
+ try
+ {
+ SMESH::ListOfGroups_var aList1 = convert( myGroups1 );
+ SMESH::ListOfGroups_var aList2 = convert( myGroups2 );
+ SMESH::SMESH_Group_var aNewGrp =
+ aMesh->CutListOfGroups( aList1, aList2, aName.toLatin1().constData() );
+ if ( !CORBA::is_nil( aNewGrp ) )
+ {
+ aNewGrp->SetColor( getColor() );
+ if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
+ anEntryList.append( aSObject->GetID().c_str() );
+ aRes = true;
+ }
+ }
+ catch( ... )
+ {
+ aRes = false;
+ }
+
+ if ( aRes )
+ {
+ SMESHGUI::Modified();
+ getSMESHGUI()->updateObjBrowser(true);
+ reset();
+ if( LightApp_Application* anApp =
+ dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+ anApp->browseObjects( anEntryList, isApplyAndClose() );
+ return true;
+ }
+ else
+ {
+ SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
+ tr("SMESH_OPERATION_FAILED"));
+ return false;
+ }
+}
+
+/*!
+ \brief SLOT, called when selection is changed, updates corresponding GUI controls
+*/
+void SMESHGUI_CutGroupsDlg::onSelectionDone()
+{
+ QStringList aNames;
+ if ( myBtn2->isChecked() )
+ {
+ getSelectedGroups( myGroups2, aNames );
+ myListWg2->clear();
+ myListWg2->addItems( aNames );
+ }
+ else
+ {
+ getSelectedGroups( myGroups1, aNames );
+ myListWg1->clear();
+ myListWg1->addItems( aNames );
+ }
+}
+
+// === === === === === === === === === === === === === === === === === === === === ===
+
+/*!
+ \brief Constructor
+ \param theModule module
+*/
+SMESHGUI_DimGroupDlg::SMESHGUI_DimGroupDlg( SMESHGUI* theModule )
+ : SMESHGUI_GroupOpDlg( theModule )
+{
+ setWindowTitle( tr( "CREATE_GROUP_OF_UNDERLYING_ELEMS" ) );
+ setHelpFileName( "group_of_underlying_elements_page.html" );
+
+ QGroupBox* anArgGrp = getArgGrp();
+
+ QLabel* aTypeLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp );
+
+ myTypeCombo = new QComboBox( anArgGrp );
+ QStringList anItems;
+ {
+ anItems.append( tr( "MESH_NODE" ) );
+ anItems.append( tr( "SMESH_EDGE" ) );
+ anItems.append( tr( "SMESH_FACE" ) );
+ anItems.append( tr( "SMESH_VOLUME" ) );
+ anItems.append( tr( "SMESH_ELEM0D" ) );
+ anItems.append( tr( "SMESH_BALL" ) );
+ }
+ myTypeCombo->addItems( anItems );
+ myTypeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ QLabel* aNbNoLbl = new QLabel( tr( "NUMBER_OF_COMMON_NODES" ), anArgGrp );
+
+ myNbNoCombo = new QComboBox( anArgGrp );
+ anItems.clear();
+ {
+ anItems.append( tr( "ALL" ) );
+ anItems.append( tr( "MAIN" ) );
+ anItems.append( tr( "AT_LEAST_ONE" ) );
+ anItems.append( tr( "MAJORITY" ) );
+ }
+ myNbNoCombo->addItems( anItems );
+ myNbNoCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ myListWg = new QListWidget( anArgGrp );
+
+ myUnderlOnlyChk = new QCheckBox( tr("UNDERLYING_ENTITIES_ONLY"), anArgGrp );
+ myUnderlOnlyChk->setChecked( false );
+
+ // layout
+ QGridLayout* aLay = new QGridLayout( anArgGrp );
+ aLay->setSpacing( SPACING );
+ aLay->addWidget( aTypeLbl, 0, 0 );
+ aLay->addWidget( myTypeCombo, 0, 1 );
+ aLay->addWidget( aNbNoLbl, 1, 0 );
+ aLay->addWidget( myNbNoCombo, 1, 1 );
+ aLay->addWidget( myListWg, 2, 0, 1, 2 );
+ aLay->addWidget( myUnderlOnlyChk, 3, 0 );
+}
+
+/*!
+ \brief Destructor
+*/
+SMESHGUI_DimGroupDlg::~SMESHGUI_DimGroupDlg()
+{
+}
+
+/*!
+ \brief This virtual method redefined from the base class resets state
+ of the dialog, initializes its fields with default value, etc.
+*/
+void SMESHGUI_DimGroupDlg::reset()
+{
+ SMESHGUI_GroupOpDlg::reset();
+ myListWg->clear();
+ myGroups.clear();
+}
+
+/*!
+ \brief Gets elements type
+ \return elements type
+ \sa setElementType()
+*/
+SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const
+{
+ return (SMESH::ElementType)( myTypeCombo->currentIndex() + 1 );
+}
+
+/*!
+ \brief Sets elements type
+ \param theElemType elements type
+ \sa getElementType()
+*/
+void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType )
+{
+ myTypeCombo->setCurrentIndex( theElemType - 1 );
+}
+
+/*!
+ \brief SLOT called when apply button is pressed performs operation
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+bool SMESHGUI_DimGroupDlg::onApply()
+{
+ if ( getSMESHGUI()->isActiveStudyLocked())
+ return false;
+
+ // Verify validity of group name
+ if ( getName() == "" )
+ {
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
+ return false;
+ }
+
+ if ( !isValid( myGroups ) )
+ return false;
+
+ SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
+ QString aName = getName();
+
+ bool aRes = false;
+ QStringList anEntryList;
+ try
+ {
+ SMESH::ListOfIDSources_var aList = new SMESH::ListOfIDSources();
+ aList->length( myGroups.count() );
+ QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter = myGroups.begin();
+ for ( int i = 0; anIter != myGroups.end(); ++anIter, ++i )
+ aList[ i ] = SMESH::SMESH_IDSource::_narrow( *anIter );
+
+ SMESH::ElementType anElemType = getElementType();
+ SMESH::NB_COMMON_NODES_ENUM aNbCoNodes =
+ (SMESH::NB_COMMON_NODES_ENUM) myNbNoCombo->currentIndex();
+
+ SMESH::SMESH_Group_var aNewGrp =
+ aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData(),
+ aNbCoNodes, myUnderlOnlyChk->isChecked() );
+ if ( !CORBA::is_nil( aNewGrp ) )
+ {
+ aNewGrp->SetColor( getColor() );
+ if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
+ anEntryList.append( aSObject->GetID().c_str() );
+ aRes = true;
+ }
+ }
+ catch( ... )
+ {
+ aRes = false;
+ }
+
+ if ( aRes )
+ {
+ SMESHGUI::Modified();
+ getSMESHGUI()->updateObjBrowser(true);
+ reset();
+ if( LightApp_Application* anApp =
+ dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+ anApp->browseObjects( anEntryList, isApplyAndClose() );
+ return true;
+ }
+ else
+ {
+ SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
+ tr("SMESH_OPERATION_FAILED"));
+ return false;
+ }
+}
+
+/*!
+ \brief SLOT, called when selection is changed, updates corresponding GUI controls
+*/
+void SMESHGUI_DimGroupDlg::onSelectionDone()
+{
+ QStringList aNames;
+ getSelectedGroups( myGroups, aNames );
+ myListWg->clear();
+ myListWg->addItems( aNames );