1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_GroupOpDlg.cxx
24 // Author : Sergey LITONIN, Open CASCADE S.A.S.
27 #include "SMESHGUI_GroupOpDlg.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
33 #include <SMESH_TypeFilter.hxx>
35 // SALOME GUI includes
36 #include <SUIT_ResourceMgr.h>
37 #include <SUIT_Desktop.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
41 #include <LightApp_Application.h>
42 #include <LightApp_SelectionMgr.h>
43 #include <SVTK_Selection.h>
44 #include <SVTK_ViewWindow.h>
45 #include <SALOME_ListIO.hxx>
48 #include <QHBoxLayout>
49 #include <QVBoxLayout>
50 #include <QGridLayout>
51 #include <QPushButton>
56 #include <QListWidget>
57 #include <QButtonGroup>
58 #include <SALOME_ListIteratorOfListIO.hxx>
60 #include <QtxColorButton.h>
66 * Class : SMESHGUI_GroupOpDlg
67 * Description : Perform boolean operations on groups
72 \param theModule pointer on module instance
74 SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule )
75 : QDialog( SMESH::GetDesktop( theModule ) ),
76 mySMESHGUI( theModule ),
77 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
81 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
83 QVBoxLayout* aDlgLay = new QVBoxLayout (this);
84 aDlgLay->setMargin(MARGIN);
85 aDlgLay->setSpacing(SPACING);
87 QWidget* aMainFrame = createMainFrame (this);
88 QWidget* aBtnFrame = createButtonFrame(this);
90 aDlgLay->addWidget(aMainFrame);
91 aDlgLay->addWidget(aBtnFrame);
97 \brief Creates frame containing dialog's input fields
98 \param theParent parent widget
99 \return pointer on created widget
101 QWidget* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent )
103 QWidget* aMainGrp = new QWidget(theParent);
104 QVBoxLayout* aLay = new QVBoxLayout(aMainGrp);
106 aLay->setSpacing(SPACING);
108 // ------------------------------------------------------
109 QGroupBox* aNameGrp = new QGroupBox(tr("NAME"), aMainGrp);
110 QHBoxLayout* aNameGrpLayout = new QHBoxLayout(aNameGrp);
111 aNameGrpLayout->setMargin(MARGIN);
112 aNameGrpLayout->setSpacing(SPACING);
114 QLabel* aNameLab = new QLabel(tr("RESULT_NAME"), aNameGrp);
115 myNameEdit = new QLineEdit(aNameGrp);
117 aNameGrpLayout->addWidget(aNameLab);
118 aNameGrpLayout->addWidget(myNameEdit);
120 // ------------------------------------------------------
121 myArgGrp = new QGroupBox(tr("ARGUMENTS"), aMainGrp);
124 // ------------------------------------------------------
126 QGroupBox* aColorBox = new QGroupBox(tr( "SMESH_SET_COLOR" ), this);
127 QHBoxLayout* aColorBoxLayout = new QHBoxLayout(aColorBox);
128 aColorBoxLayout->setMargin(MARGIN);
129 aColorBoxLayout->setSpacing(SPACING);
131 QLabel* aColorLab = new QLabel(tr( "SMESH_CHECK_COLOR" ), aColorBox );
132 myColorBtn = new QtxColorButton(aColorBox);
133 myColorBtn->setSizePolicy( QSizePolicy::MinimumExpanding,
134 myColorBtn->sizePolicy().verticalPolicy() );
136 aColorBoxLayout->addWidget(aColorLab);
137 aColorBoxLayout->addWidget(myColorBtn);
139 // ------------------------------------------------------
140 aLay->addWidget( aNameGrp );
141 aLay->addWidget( myArgGrp );
142 aLay->addWidget( aColorBox );
148 \brief Gets pointer on arguments group box
149 \return pointer on arguments group box
151 QGroupBox* SMESHGUI_GroupOpDlg::getArgGrp() const
157 \brief Sets help file name
158 \param theFName help file name
160 void SMESHGUI_GroupOpDlg::setHelpFileName( const QString& theFName )
162 myHelpFileName = theFName;
166 \brief Gets pointer to the module instance
167 \return pointer to the module instance
169 SMESHGUI* SMESHGUI_GroupOpDlg::getSMESHGUI() const
175 \brief Create frame containing buttons
176 \param theParent parent widget
177 \return pointer to the created frame
179 QWidget* SMESHGUI_GroupOpDlg::createButtonFrame (QWidget* theParent)
181 QGroupBox* aFrame = new QGroupBox(theParent);
183 myOkBtn = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
184 myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
185 myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
186 myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
188 QHBoxLayout* aLay = new QHBoxLayout(aFrame);
189 aLay->setMargin(MARGIN);
190 aLay->setSpacing(SPACING);
192 aLay->addWidget(myOkBtn);
193 aLay->addSpacing(10);
194 aLay->addWidget(myApplyBtn);
195 aLay->addSpacing(10);
197 aLay->addWidget(myCloseBtn);
198 aLay->addWidget(myHelpBtn);
200 // connect signals and slots
201 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
202 connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
203 connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
204 connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
212 SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg()
217 \brief Init dialog fields, connect signals and slots, show dialog
219 void SMESHGUI_GroupOpDlg::Init()
221 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
223 // selection and SMESHGUI
224 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
225 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
226 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose()));
228 // set selection mode
229 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
230 aViewWindow->SetSelectionMode(ActorSelection);
231 mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
235 \brief Validate list of groups used for operation. Checks whether they corresponds
236 to the same face and have one type
237 \param theListGrp input list of groups
238 \return TRUE if groups are valid, FALSE otherwise
240 bool SMESHGUI_GroupOpDlg::isValid( const QList<SMESH::SMESH_GroupBase_var>& theListGrp )
242 if ( theListGrp.isEmpty() )
244 SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
245 tr("INCORRECT_ARGUMENTS") );
249 int aMeshId = -1, aGrpType = -1;
250 QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter;
251 for ( anIter = theListGrp.begin(); anIter != theListGrp.end(); ++anIter )
253 SMESH::SMESH_GroupBase_var aGrp = *anIter;
254 if ( CORBA::is_nil( aGrp ) )
255 continue; // nonsence
257 SMESH::SMESH_Mesh_var aMesh = aGrp->GetMesh();
258 if ( CORBA::is_nil( aMesh ) )
262 int aCurrId = aMesh->GetId();
267 if ( aMeshId != aCurrId )
269 aMeshId = -1; // different meshes
275 int aCurrType = aGrp->GetType();
276 if ( aGrpType == -1 )
277 aGrpType = aCurrType;
280 if ( aGrpType != aCurrType )
282 aGrpType = -1; // different types
291 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
296 if ( aGrpType == -1 )
298 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
307 \brief SLOT called when "Ok" button pressed performs operation and closes dialog box
309 void SMESHGUI_GroupOpDlg::onOk()
316 \brief SLOT called when "Close" button pressed closes dialog
318 void SMESHGUI_GroupOpDlg::onClose()
320 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
321 aViewWindow->SetSelectionMode(ActorSelection);
322 disconnect( mySelectionMgr, 0, this, 0 );
323 disconnect( mySMESHGUI, 0, this, 0 );
324 mySMESHGUI->ResetState();
325 mySelectionMgr->clearFilters();
331 \brief SLOT called when "Help" button pressed shows "Help" page
333 void SMESHGUI_GroupOpDlg::onHelp()
335 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
337 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
341 platform = "winapplication";
343 platform = "application";
345 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
346 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
347 arg(app->resourceMgr()->stringValue("ExternalBrowser",
349 arg(myHelpFileName));
354 \brief Gets list of currently selected groups from selection manager
355 \param theOutList out list of groups
356 \param theOutNames out list of group of group names
357 \return TRUE if operation theOutList is not empty, FALSE otherwise
359 bool SMESHGUI_GroupOpDlg::getSelectedGroups( QList<SMESH::SMESH_GroupBase_var>& theOutList,
360 QStringList& theOutNames )
367 SALOME_ListIO aListIO;
368 mySelectionMgr->selectedObjects( aListIO );
369 SALOME_ListIteratorOfListIO anIter ( aListIO );
370 for ( ; anIter.More(); anIter.Next())
372 SMESH::SMESH_GroupBase_var aGroup =
373 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
374 if ( !aGroup->_is_nil())
376 theOutList.append( aGroup );
377 theOutNames.append( aGroup->GetName() );
381 return theOutList.count() > 0;
385 \brief Converts QT-list of group to the list acceptable by IDL interface
386 \param theIn input list
387 \return list acceptable by IDL interface
389 SMESH::ListOfGroups* SMESHGUI_GroupOpDlg::convert(
390 const QList<SMESH::SMESH_GroupBase_var>& theIn )
392 SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
393 aList->length( theIn.count() );
395 QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter = theIn.begin();
396 for ( int i = 0; anIter != theIn.end(); ++anIter, ++i )
397 aList[ i ] = *anIter;
399 return aList._retn();
403 \brief Get color to be assigned to group
404 \return color to be assigned to group
406 SALOMEDS::Color SMESHGUI_GroupOpDlg::getColor() const
408 QColor aQColor = myColorBtn->color();
410 SALOMEDS::Color aColor;
411 aColor.R = (float)aQColor.red() / 255.0;
412 aColor.G = (float)aQColor.green() / 255.0;
413 aColor.B = (float)aQColor.blue() / 255.0;
419 \brief SLOT, called when selection is changed. Current implementation does
420 nothing. The method should be redefined in derived classes to update
421 corresponding GUI controls
423 void SMESHGUI_GroupOpDlg::onSelectionDone()
428 \brief Calls onSelectionDone() and setVisible() method of base class
429 \param visible the visible state of the dialog
431 void SMESHGUI_GroupOpDlg::setVisible( bool visible )
436 resize( minimumSizeHint().width(), sizeHint().height() );
438 QDialog::setVisible( visible );
442 \brief SLOT called when dialog must be deativated
444 void SMESHGUI_GroupOpDlg::onDeactivate()
447 mySelectionMgr->clearFilters();
451 \brief Event filter updates selection mode and selection filter. This virtual method
452 is redefined from the base class it is called when dialog obtains input focus
454 void SMESHGUI_GroupOpDlg::enterEvent(QEvent*)
456 mySMESHGUI->EmitSignalDeactivateDialog();
458 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
459 aViewWindow->SetSelectionMode(ActorSelection);
460 mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
464 \brief Provides reaction on close event, closes the dialog box
466 void SMESHGUI_GroupOpDlg::closeEvent(QCloseEvent*)
472 \brief Resets state of the dialog, initializes its fields with default value, etc.
473 Usually called by onApply() slot to reinitialize dialog fields. This virtual method
474 should be redefined in derived class to update its own fileds
476 void SMESHGUI_GroupOpDlg::reset()
478 myNameEdit->setText("");
479 myNameEdit->setFocus();
483 \brief Gets name of group to be created
484 \return name of group to be created
487 QString SMESHGUI_GroupOpDlg::getName() const
489 return myNameEdit->text();
493 \brief Sets name of group to be created
494 \param theName name of group to be created
497 void SMESHGUI_GroupOpDlg::setName( const QString& theName )
499 myNameEdit->setText( theName );
503 \brief Provides reaction on
\93F1
\94 button pressing
504 \param e key press event
506 void SMESHGUI_GroupOpDlg::keyPressEvent( QKeyEvent* e )
508 QDialog::keyPressEvent( e );
509 if ( e->isAccepted() )
512 if ( e->key() == Qt::Key_F1 ) {
519 \brief This virtual slot does nothing and should be redefined in derived classes
520 \return return false;
522 bool SMESHGUI_GroupOpDlg::onApply()
527 // === === === === === === === === === === === === === === === === === === === === ===
531 \param theModule module
533 SMESHGUI_UnionGroupsDlg::SMESHGUI_UnionGroupsDlg( SMESHGUI* theModule )
534 : SMESHGUI_GroupOpDlg( theModule )
536 setWindowTitle(tr("UNION_OF_GROUPS"));
537 setHelpFileName( "using_operations_on_groups_page.html#union_anchor" );
539 QGroupBox* anArgGrp = getArgGrp();
540 myListWg = new QListWidget( anArgGrp );
542 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
543 aLay->addWidget( myListWg );
549 SMESHGUI_UnionGroupsDlg::~SMESHGUI_UnionGroupsDlg()
554 \brief This virtual method redefined from the base class resets state
555 of the dialog, initializes its fields with default value, etc.
557 void SMESHGUI_UnionGroupsDlg::reset()
559 SMESHGUI_GroupOpDlg::reset();
565 \brief SLOT called when apply button is pressed performs operation
566 \return TRUE if operation has been completed successfully, FALSE otherwise
568 bool SMESHGUI_UnionGroupsDlg::onApply()
570 if ( getSMESHGUI()->isActiveStudyLocked())
573 // Verify validity of group name
574 if ( getName() == "" )
576 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
577 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
581 if ( !isValid( myGroups ) )
584 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
585 QString aName = getName();
590 SMESH::ListOfGroups_var aList = convert( myGroups );
591 SMESH::SMESH_Group_var aNewGrp =
592 aMesh->UnionListOfGroups( aList, aName.toLatin1().constData() );
593 if ( !CORBA::is_nil( aNewGrp ) )
595 aNewGrp->SetColor( getColor() );
606 getSMESHGUI()->updateObjBrowser(true);
612 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
613 tr("SMESH_OPERATION_FAILED"));
619 \brief SLOT, called when selection is changed, updates corresponding GUI controls
621 void SMESHGUI_UnionGroupsDlg::onSelectionDone()
624 getSelectedGroups( myGroups, aNames );
626 myListWg->addItems( aNames );
629 // === === === === === === === === === === === === === === === === === === === === ===
633 \param theModule module
635 SMESHGUI_IntersectGroupsDlg::SMESHGUI_IntersectGroupsDlg( SMESHGUI* theModule )
636 : SMESHGUI_GroupOpDlg( theModule )
638 setWindowTitle(tr("INTERSECTION_OF_GROUPS"));
639 setHelpFileName( "using_operations_on_groups_page.html#intersection_anchor" );
641 QGroupBox* anArgGrp = getArgGrp();
642 myListWg = new QListWidget( anArgGrp );
644 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
645 aLay->addWidget( myListWg );
651 SMESHGUI_IntersectGroupsDlg::~SMESHGUI_IntersectGroupsDlg()
656 \brief This virtual method redefined from the base class resets state
657 of the dialog, initializes its fields with default value, etc.
659 void SMESHGUI_IntersectGroupsDlg::reset()
661 SMESHGUI_GroupOpDlg::reset();
667 \brief SLOT called when apply button is pressed performs operation
668 \return TRUE if operation has been completed successfully, FALSE otherwise
670 bool SMESHGUI_IntersectGroupsDlg::onApply()
672 if ( getSMESHGUI()->isActiveStudyLocked())
675 // Verify validity of group name
676 if ( getName() == "" )
678 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
679 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
683 if ( !isValid( myGroups ) )
686 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
687 QString aName = getName();
692 SMESH::ListOfGroups_var aList = convert( myGroups );
693 SMESH::SMESH_Group_var aNewGrp =
694 aMesh->IntersectListOfGroups( aList, aName.toLatin1().constData() );
695 if ( !CORBA::is_nil( aNewGrp ) )
697 aNewGrp->SetColor( getColor() );
708 getSMESHGUI()->updateObjBrowser(true);
714 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
715 tr("SMESH_OPERATION_FAILED"));
721 \brief SLOT, called when selection is changed, updates corresponding GUI controls
723 void SMESHGUI_IntersectGroupsDlg::onSelectionDone()
726 getSelectedGroups( myGroups, aNames );
728 myListWg->addItems( aNames );
731 // === === === === === === === === === === === === === === === === === === === === ===
735 \param theModule module
737 SMESHGUI_CutGroupsDlg::SMESHGUI_CutGroupsDlg( SMESHGUI* theModule )
738 : SMESHGUI_GroupOpDlg( theModule )
740 setWindowTitle(tr("CUT_OF_GROUPS"));
741 setHelpFileName( "using_operations_on_groups_page.html#cut_anchor" );
743 QGroupBox* anArgGrp = getArgGrp();
745 QPixmap aPix (SMESH::GetResourceMgr( getSMESHGUI() )->loadPixmap("SMESH", tr("ICON_SELECT")));
748 QFrame* aFrame1 = new QFrame( anArgGrp );
749 QLabel* aLbl1 = new QLabel( tr("MAIN_OBJECT"), aFrame1 );
750 aLbl1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
751 myBtn1 = new QPushButton( aFrame1 );
752 myBtn1->setIcon(aPix);
753 myListWg1 = new QListWidget( aFrame1 );
755 QGridLayout* aLay1 = new QGridLayout( aFrame1 );
756 aLay1->setSpacing( SPACING );
757 aLay1->addWidget( aLbl1, 0, 0 );
758 aLay1->addWidget( myBtn1, 0, 1 );
759 aLay1->addWidget( myListWg1, 1, 0, 1, 2 );
760 //QSpacerItem* aHSpacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
761 //aLay1->addItem( aHSpacer1, 0, 2 );
765 QFrame* aFrame2 = new QFrame( anArgGrp );
766 QLabel* aLbl2 = new QLabel( tr("TOOL_OBJECT"), aFrame2 );
767 aLbl2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
768 myBtn2 = new QPushButton( aFrame2 );
769 myBtn2->setIcon(aPix);
770 myListWg2 = new QListWidget( aFrame2 );
772 QGridLayout* aLay2 = new QGridLayout( aFrame2 );
773 aLay2->setSpacing( SPACING );
774 aLay2->addWidget( aLbl2, 0, 0 );
775 aLay2->addWidget( myBtn2, 0, 1 );
776 aLay2->addWidget( myListWg2, 1, 0, 1, 2 );
777 //QSpacerItem* aHSpacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
778 //aLay2->addItem( aHSpacer2, 0, 2 );
780 // create button group
782 QButtonGroup* aGrp = new QButtonGroup( anArgGrp );
783 aGrp->addButton( myBtn1, 0 );
784 aGrp->addButton( myBtn2, 1 );
785 myBtn1->setCheckable( true );
786 myBtn2->setCheckable( true );
787 aGrp->setExclusive( true );
788 myBtn1->setChecked( true );
791 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
792 aLay->setSpacing( SPACING );
793 aLay->addWidget( aFrame1 );
794 aLay->addWidget( aFrame2 );
800 SMESHGUI_CutGroupsDlg::~SMESHGUI_CutGroupsDlg()
805 \brief This virtual method redefined from the base class resets state
806 of the dialog, initializes its fields with default value, etc.
808 void SMESHGUI_CutGroupsDlg::reset()
810 SMESHGUI_GroupOpDlg::reset();
820 \brief SLOT called when apply button is pressed performs operation
821 \return TRUE if operation has been completed successfully, FALSE otherwise
823 bool SMESHGUI_CutGroupsDlg::onApply()
825 if ( getSMESHGUI()->isActiveStudyLocked())
828 // Verify validity of group name
829 if ( getName() == "" )
831 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
832 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
836 if ( myGroups1.isEmpty() || myGroups2.isEmpty() )
838 SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
839 SMESHGUI_GroupOpDlg::tr("INCORRECT_ARGUMENTS") );
843 QList<SMESH::SMESH_GroupBase_var> aGroups = myGroups1;
844 QList<SMESH::SMESH_GroupBase_var>::iterator anIter;
845 for ( anIter = myGroups2.begin(); anIter != myGroups2.end(); ++anIter )
846 aGroups.append( *anIter );
848 if ( !isValid( aGroups ) )
851 SMESH::SMESH_Mesh_var aMesh = myGroups1.first()->GetMesh();
852 QString aName = getName();
857 SMESH::ListOfGroups_var aList1 = convert( myGroups1 );
858 SMESH::ListOfGroups_var aList2 = convert( myGroups2 );
859 SMESH::SMESH_Group_var aNewGrp =
860 aMesh->CutListOfGroups( aList1, aList2, aName.toLatin1().constData() );
861 if ( !CORBA::is_nil( aNewGrp ) )
863 aNewGrp->SetColor( getColor() );
874 getSMESHGUI()->updateObjBrowser(true);
880 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
881 tr("SMESH_OPERATION_FAILED"));
887 \brief SLOT, called when selection is changed, updates corresponding GUI controls
889 void SMESHGUI_CutGroupsDlg::onSelectionDone()
892 if ( myBtn2->isChecked() )
894 getSelectedGroups( myGroups2, aNames );
896 myListWg2->addItems( aNames );
900 getSelectedGroups( myGroups1, aNames );
902 myListWg1->addItems( aNames );
906 // === === === === === === === === === === === === === === === === === === === === ===
910 \param theModule module
912 SMESHGUI_DimGroupDlg::SMESHGUI_DimGroupDlg( SMESHGUI* theModule )
913 : SMESHGUI_GroupOpDlg( theModule )
915 setWindowTitle( tr( "CREATE_GROUP_OF_UNDERLYING_ELEMS" ) );
916 setHelpFileName( "creating_groups_page.html#gui_create_dim_group" );
918 QGroupBox* anArgGrp = getArgGrp();
920 QLabel* aLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp );
922 myCombo = new QComboBox( anArgGrp );
923 static QStringList anItems;
924 if ( anItems.isEmpty() )
926 anItems.append( tr( "NODE" ) );
927 anItems.append( tr( "EDGE" ) );
928 anItems.append( tr( "FACE" ) );
929 anItems.append( tr( "VOLUME" ) );
931 myCombo->addItems( anItems );
932 myCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
934 myListWg = new QListWidget( anArgGrp );
937 QGridLayout* aLay = new QGridLayout( anArgGrp );
938 aLay->setSpacing( SPACING );
939 aLay->addWidget( aLbl, 0, 0 );
940 aLay->addWidget( myCombo, 0, 1 );
941 aLay->addWidget( myListWg, 1, 0, 1, 2 );
947 SMESHGUI_DimGroupDlg::~SMESHGUI_DimGroupDlg()
952 \brief This virtual method redefined from the base class resets state
953 of the dialog, initializes its fields with default value, etc.
955 void SMESHGUI_DimGroupDlg::reset()
957 SMESHGUI_GroupOpDlg::reset();
963 \brief Gets elements type
964 \return elements type
967 SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const
969 return (SMESH::ElementType)( myCombo->currentIndex() + 1 );
973 \brief Sets elements type
974 \param theElemType elements type
977 void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType )
979 myCombo->setCurrentIndex( theElemType - 1 );
983 \brief SLOT called when apply button is pressed performs operation
984 \return TRUE if operation has been completed successfully, FALSE otherwise
986 bool SMESHGUI_DimGroupDlg::onApply()
988 if ( getSMESHGUI()->isActiveStudyLocked())
991 // Verify validity of group name
992 if ( getName() == "" )
994 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
995 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
999 if ( !isValid( myGroups ) )
1002 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
1003 QString aName = getName();
1008 SMESH::ListOfGroups_var aList = convert( myGroups );
1009 SMESH::ElementType anElemType = getElementType();
1010 SMESH::SMESH_Group_var aNewGrp =
1011 aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData() );
1012 if ( !CORBA::is_nil( aNewGrp ) )
1014 aNewGrp->SetColor( getColor() );
1025 getSMESHGUI()->updateObjBrowser(true);
1031 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
1032 tr("SMESH_OPERATION_FAILED"));
1038 \brief SLOT, called when selection is changed, updates corresponding GUI controls
1040 void SMESHGUI_DimGroupDlg::onSelectionDone()
1043 getSelectedGroups( myGroups, aNames );
1045 myListWg->addItems( aNames );