1 // Copyright (C) 2007-2010 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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_GroupOpDlg.cxx
25 // Author : Sergey LITONIN, Open CASCADE S.A.S.
28 #include "SMESHGUI_GroupOpDlg.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
34 #include <SMESH_TypeFilter.hxx>
36 // SALOME GUI includes
37 #include <SUIT_ResourceMgr.h>
38 #include <SUIT_Desktop.h>
39 #include <SUIT_Session.h>
40 #include <SUIT_MessageBox.h>
42 #include <LightApp_Application.h>
43 #include <LightApp_SelectionMgr.h>
44 #include <SVTK_Selection.h>
45 #include <SVTK_ViewWindow.h>
46 #include <SALOME_ListIO.hxx>
49 #include <QHBoxLayout>
50 #include <QVBoxLayout>
51 #include <QGridLayout>
52 #include <QPushButton>
57 #include <QListWidget>
58 #include <QButtonGroup>
59 #include <SALOME_ListIteratorOfListIO.hxx>
61 #include <QtxColorButton.h>
67 * Class : SMESHGUI_GroupOpDlg
68 * Description : Perform boolean operations on groups
73 \param theModule pointer on module instance
75 SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule )
76 : QDialog( SMESH::GetDesktop( theModule ) ),
77 mySMESHGUI( theModule ),
78 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
82 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
84 QVBoxLayout* aDlgLay = new QVBoxLayout (this);
85 aDlgLay->setMargin(MARGIN);
86 aDlgLay->setSpacing(SPACING);
88 QWidget* aMainFrame = createMainFrame (this);
89 QWidget* aBtnFrame = createButtonFrame(this);
91 aDlgLay->addWidget(aMainFrame);
92 aDlgLay->addWidget(aBtnFrame);
98 \brief Creates frame containing dialog's input fields
99 \param theParent parent widget
100 \return pointer on created widget
102 QWidget* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent )
104 QWidget* aMainGrp = new QWidget(theParent);
105 QVBoxLayout* aLay = new QVBoxLayout(aMainGrp);
107 aLay->setSpacing(SPACING);
109 // ------------------------------------------------------
110 QGroupBox* aNameGrp = new QGroupBox(tr("NAME"), aMainGrp);
111 QHBoxLayout* aNameGrpLayout = new QHBoxLayout(aNameGrp);
112 aNameGrpLayout->setMargin(MARGIN);
113 aNameGrpLayout->setSpacing(SPACING);
115 QLabel* aNameLab = new QLabel(tr("RESULT_NAME"), aNameGrp);
116 myNameEdit = new QLineEdit(aNameGrp);
118 aNameGrpLayout->addWidget(aNameLab);
119 aNameGrpLayout->addWidget(myNameEdit);
121 // ------------------------------------------------------
122 myArgGrp = new QGroupBox(tr("ARGUMENTS"), aMainGrp);
125 // ------------------------------------------------------
127 QGroupBox* aColorBox = new QGroupBox(tr( "SMESH_SET_COLOR" ), this);
128 QHBoxLayout* aColorBoxLayout = new QHBoxLayout(aColorBox);
129 aColorBoxLayout->setMargin(MARGIN);
130 aColorBoxLayout->setSpacing(SPACING);
132 QLabel* aColorLab = new QLabel(tr( "SMESH_CHECK_COLOR" ), aColorBox );
133 myColorBtn = new QtxColorButton(aColorBox);
134 myColorBtn->setSizePolicy( QSizePolicy::MinimumExpanding,
135 myColorBtn->sizePolicy().verticalPolicy() );
137 aColorBoxLayout->addWidget(aColorLab);
138 aColorBoxLayout->addWidget(myColorBtn);
140 // ------------------------------------------------------
141 aLay->addWidget( aNameGrp );
142 aLay->addWidget( myArgGrp );
143 aLay->addWidget( aColorBox );
149 \brief Gets pointer on arguments group box
150 \return pointer on arguments group box
152 QGroupBox* SMESHGUI_GroupOpDlg::getArgGrp() const
158 \brief Sets help file name
159 \param theFName help file name
161 void SMESHGUI_GroupOpDlg::setHelpFileName( const QString& theFName )
163 myHelpFileName = theFName;
167 \brief Gets pointer to the module instance
168 \return pointer to the module instance
170 SMESHGUI* SMESHGUI_GroupOpDlg::getSMESHGUI() const
176 \brief Create frame containing buttons
177 \param theParent parent widget
178 \return pointer to the created frame
180 QWidget* SMESHGUI_GroupOpDlg::createButtonFrame (QWidget* theParent)
182 QGroupBox* aFrame = new QGroupBox(theParent);
184 myOkBtn = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
185 myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
186 myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
187 myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
189 QHBoxLayout* aLay = new QHBoxLayout(aFrame);
190 aLay->setMargin(MARGIN);
191 aLay->setSpacing(SPACING);
193 aLay->addWidget(myOkBtn);
194 aLay->addSpacing(10);
195 aLay->addWidget(myApplyBtn);
196 aLay->addSpacing(10);
198 aLay->addWidget(myCloseBtn);
199 aLay->addWidget(myHelpBtn);
201 // connect signals and slots
202 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
203 connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
204 connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
205 connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
213 SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg()
218 \brief Init dialog fields, connect signals and slots, show dialog
220 void SMESHGUI_GroupOpDlg::Init()
222 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
224 // selection and SMESHGUI
225 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
226 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
227 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose()));
229 // set selection mode
230 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
231 aViewWindow->SetSelectionMode(ActorSelection);
232 mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
236 \brief Validate list of groups used for operation. Checks whether they corresponds
237 to the same face and have one type
238 \param theListGrp input list of groups
239 \return TRUE if groups are valid, FALSE otherwise
241 bool SMESHGUI_GroupOpDlg::isValid( const QList<SMESH::SMESH_GroupBase_var>& theListGrp )
243 if ( theListGrp.isEmpty() )
245 SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
246 tr("INCORRECT_ARGUMENTS") );
250 int aMeshId = -1, aGrpType = -1;
251 QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter;
252 for ( anIter = theListGrp.begin(); anIter != theListGrp.end(); ++anIter )
254 SMESH::SMESH_GroupBase_var aGrp = *anIter;
255 if ( CORBA::is_nil( aGrp ) )
256 continue; // nonsence
258 SMESH::SMESH_Mesh_var aMesh = aGrp->GetMesh();
259 if ( CORBA::is_nil( aMesh ) )
263 int aCurrId = aMesh->GetId();
268 if ( aMeshId != aCurrId )
270 aMeshId = -1; // different meshes
276 int aCurrType = aGrp->GetType();
277 if ( aGrpType == -1 )
278 aGrpType = aCurrType;
281 if ( aGrpType != aCurrType )
283 aGrpType = -1; // different types
292 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
297 if ( aGrpType == -1 )
299 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
308 \brief SLOT called when "Ok" button pressed performs operation and closes dialog box
310 void SMESHGUI_GroupOpDlg::onOk()
317 \brief SLOT called when "Close" button pressed closes dialog
319 void SMESHGUI_GroupOpDlg::onClose()
321 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
322 aViewWindow->SetSelectionMode(ActorSelection);
323 disconnect( mySelectionMgr, 0, this, 0 );
324 disconnect( mySMESHGUI, 0, this, 0 );
325 mySMESHGUI->ResetState();
326 mySelectionMgr->clearFilters();
332 \brief SLOT called when "Help" button pressed shows "Help" page
334 void SMESHGUI_GroupOpDlg::onHelp()
336 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
338 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
342 platform = "winapplication";
344 platform = "application";
346 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
347 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
348 arg(app->resourceMgr()->stringValue("ExternalBrowser",
350 arg(myHelpFileName));
355 \brief Gets list of currently selected groups from selection manager
356 \param theOutList out list of groups
357 \param theOutNames out list of group of group names
358 \return TRUE if operation theOutList is not empty, FALSE otherwise
360 bool SMESHGUI_GroupOpDlg::getSelectedGroups( QList<SMESH::SMESH_GroupBase_var>& theOutList,
361 QStringList& theOutNames )
368 SALOME_ListIO aListIO;
369 mySelectionMgr->selectedObjects( aListIO );
370 SALOME_ListIteratorOfListIO anIter ( aListIO );
371 for ( ; anIter.More(); anIter.Next())
373 SMESH::SMESH_GroupBase_var aGroup =
374 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
375 if ( !aGroup->_is_nil())
377 theOutList.append( aGroup );
378 theOutNames.append( aGroup->GetName() );
382 return theOutList.count() > 0;
386 \brief Converts QT-list of group to the list acceptable by IDL interface
387 \param theIn input list
388 \return list acceptable by IDL interface
390 SMESH::ListOfGroups* SMESHGUI_GroupOpDlg::convert(
391 const QList<SMESH::SMESH_GroupBase_var>& theIn )
393 SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
394 aList->length( theIn.count() );
396 QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter = theIn.begin();
397 for ( int i = 0; anIter != theIn.end(); ++anIter, ++i )
398 aList[ i ] = *anIter;
400 return aList._retn();
404 \brief Get color to be assigned to group
405 \return color to be assigned to group
407 SALOMEDS::Color SMESHGUI_GroupOpDlg::getColor() const
409 QColor aQColor = myColorBtn->color();
411 SALOMEDS::Color aColor;
412 aColor.R = (float)aQColor.red() / 255.0;
413 aColor.G = (float)aQColor.green() / 255.0;
414 aColor.B = (float)aQColor.blue() / 255.0;
420 \brief SLOT, called when selection is changed. Current implementation does
421 nothing. The method should be redefined in derived classes to update
422 corresponding GUI controls
424 void SMESHGUI_GroupOpDlg::onSelectionDone()
429 \brief Calls onSelectionDone() and setVisible() method of base class
430 \param visible the visible state of the dialog
432 void SMESHGUI_GroupOpDlg::setVisible( bool visible )
437 resize( minimumSizeHint().width(), sizeHint().height() );
439 QDialog::setVisible( visible );
443 \brief SLOT called when dialog must be deativated
445 void SMESHGUI_GroupOpDlg::onDeactivate()
448 mySelectionMgr->clearFilters();
452 \brief Event filter updates selection mode and selection filter. This virtual method
453 is redefined from the base class it is called when dialog obtains input focus
455 void SMESHGUI_GroupOpDlg::enterEvent(QEvent*)
457 mySMESHGUI->EmitSignalDeactivateDialog();
459 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
460 aViewWindow->SetSelectionMode(ActorSelection);
461 mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
465 \brief Provides reaction on close event, closes the dialog box
467 void SMESHGUI_GroupOpDlg::closeEvent(QCloseEvent*)
473 \brief Resets state of the dialog, initializes its fields with default value, etc.
474 Usually called by onApply() slot to reinitialize dialog fields. This virtual method
475 should be redefined in derived class to update its own fileds
477 void SMESHGUI_GroupOpDlg::reset()
479 myNameEdit->setText("");
480 myNameEdit->setFocus();
484 \brief Gets name of group to be created
485 \return name of group to be created
488 QString SMESHGUI_GroupOpDlg::getName() const
490 return myNameEdit->text();
494 \brief Sets name of group to be created
495 \param theName name of group to be created
498 void SMESHGUI_GroupOpDlg::setName( const QString& theName )
500 myNameEdit->setText( theName );
504 \brief Provides reaction on
\93F1
\94 button pressing
505 \param e key press event
507 void SMESHGUI_GroupOpDlg::keyPressEvent( QKeyEvent* e )
509 QDialog::keyPressEvent( e );
510 if ( e->isAccepted() )
513 if ( e->key() == Qt::Key_F1 ) {
520 \brief This virtual slot does nothing and should be redefined in derived classes
521 \return return false;
523 bool SMESHGUI_GroupOpDlg::onApply()
528 // === === === === === === === === === === === === === === === === === === === === ===
532 \param theModule module
534 SMESHGUI_UnionGroupsDlg::SMESHGUI_UnionGroupsDlg( SMESHGUI* theModule )
535 : SMESHGUI_GroupOpDlg( theModule )
537 setWindowTitle(tr("UNION_OF_GROUPS"));
538 setHelpFileName( "using_operations_on_groups_page.html#union_anchor" );
540 QGroupBox* anArgGrp = getArgGrp();
541 myListWg = new QListWidget( anArgGrp );
543 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
544 aLay->addWidget( myListWg );
550 SMESHGUI_UnionGroupsDlg::~SMESHGUI_UnionGroupsDlg()
555 \brief This virtual method redefined from the base class resets state
556 of the dialog, initializes its fields with default value, etc.
558 void SMESHGUI_UnionGroupsDlg::reset()
560 SMESHGUI_GroupOpDlg::reset();
566 \brief SLOT called when apply button is pressed performs operation
567 \return TRUE if operation has been completed successfully, FALSE otherwise
569 bool SMESHGUI_UnionGroupsDlg::onApply()
571 if ( getSMESHGUI()->isActiveStudyLocked())
574 // Verify validity of group name
575 if ( getName() == "" )
577 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
578 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
582 if ( !isValid( myGroups ) )
585 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
586 QString aName = getName();
591 SMESH::ListOfGroups_var aList = convert( myGroups );
592 SMESH::SMESH_Group_var aNewGrp =
593 aMesh->UnionListOfGroups( aList, aName.toLatin1().constData() );
594 if ( !CORBA::is_nil( aNewGrp ) )
596 aNewGrp->SetColor( getColor() );
607 SMESHGUI::Modified();
608 getSMESHGUI()->updateObjBrowser(true);
614 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
615 tr("SMESH_OPERATION_FAILED"));
621 \brief SLOT, called when selection is changed, updates corresponding GUI controls
623 void SMESHGUI_UnionGroupsDlg::onSelectionDone()
626 getSelectedGroups( myGroups, aNames );
628 myListWg->addItems( aNames );
631 // === === === === === === === === === === === === === === === === === === === === ===
635 \param theModule module
637 SMESHGUI_IntersectGroupsDlg::SMESHGUI_IntersectGroupsDlg( SMESHGUI* theModule )
638 : SMESHGUI_GroupOpDlg( theModule )
640 setWindowTitle(tr("INTERSECTION_OF_GROUPS"));
641 setHelpFileName( "using_operations_on_groups_page.html#intersection_anchor" );
643 QGroupBox* anArgGrp = getArgGrp();
644 myListWg = new QListWidget( anArgGrp );
646 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
647 aLay->addWidget( myListWg );
653 SMESHGUI_IntersectGroupsDlg::~SMESHGUI_IntersectGroupsDlg()
658 \brief This virtual method redefined from the base class resets state
659 of the dialog, initializes its fields with default value, etc.
661 void SMESHGUI_IntersectGroupsDlg::reset()
663 SMESHGUI_GroupOpDlg::reset();
669 \brief SLOT called when apply button is pressed performs operation
670 \return TRUE if operation has been completed successfully, FALSE otherwise
672 bool SMESHGUI_IntersectGroupsDlg::onApply()
674 if ( getSMESHGUI()->isActiveStudyLocked())
677 // Verify validity of group name
678 if ( getName() == "" )
680 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
681 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
685 if ( !isValid( myGroups ) )
688 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
689 QString aName = getName();
694 SMESH::ListOfGroups_var aList = convert( myGroups );
695 SMESH::SMESH_Group_var aNewGrp =
696 aMesh->IntersectListOfGroups( aList, aName.toLatin1().constData() );
697 if ( !CORBA::is_nil( aNewGrp ) )
699 aNewGrp->SetColor( getColor() );
710 SMESHGUI::Modified();
711 getSMESHGUI()->updateObjBrowser(true);
717 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
718 tr("SMESH_OPERATION_FAILED"));
724 \brief SLOT, called when selection is changed, updates corresponding GUI controls
726 void SMESHGUI_IntersectGroupsDlg::onSelectionDone()
729 getSelectedGroups( myGroups, aNames );
731 myListWg->addItems( aNames );
734 // === === === === === === === === === === === === === === === === === === === === ===
738 \param theModule module
740 SMESHGUI_CutGroupsDlg::SMESHGUI_CutGroupsDlg( SMESHGUI* theModule )
741 : SMESHGUI_GroupOpDlg( theModule )
743 setWindowTitle(tr("CUT_OF_GROUPS"));
744 setHelpFileName( "using_operations_on_groups_page.html#cut_anchor" );
746 QGroupBox* anArgGrp = getArgGrp();
748 QPixmap aPix (SMESH::GetResourceMgr( getSMESHGUI() )->loadPixmap("SMESH", tr("ICON_SELECT")));
751 QFrame* aFrame1 = new QFrame( anArgGrp );
752 QLabel* aLbl1 = new QLabel( tr("MAIN_OBJECT"), aFrame1 );
753 aLbl1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
754 myBtn1 = new QPushButton( aFrame1 );
755 myBtn1->setIcon(aPix);
756 myListWg1 = new QListWidget( aFrame1 );
758 QGridLayout* aLay1 = new QGridLayout( aFrame1 );
759 aLay1->setSpacing( SPACING );
760 aLay1->addWidget( aLbl1, 0, 0 );
761 aLay1->addWidget( myBtn1, 0, 1 );
762 aLay1->addWidget( myListWg1, 1, 0, 1, 2 );
763 //QSpacerItem* aHSpacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
764 //aLay1->addItem( aHSpacer1, 0, 2 );
768 QFrame* aFrame2 = new QFrame( anArgGrp );
769 QLabel* aLbl2 = new QLabel( tr("TOOL_OBJECT"), aFrame2 );
770 aLbl2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
771 myBtn2 = new QPushButton( aFrame2 );
772 myBtn2->setIcon(aPix);
773 myListWg2 = new QListWidget( aFrame2 );
775 QGridLayout* aLay2 = new QGridLayout( aFrame2 );
776 aLay2->setSpacing( SPACING );
777 aLay2->addWidget( aLbl2, 0, 0 );
778 aLay2->addWidget( myBtn2, 0, 1 );
779 aLay2->addWidget( myListWg2, 1, 0, 1, 2 );
780 //QSpacerItem* aHSpacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
781 //aLay2->addItem( aHSpacer2, 0, 2 );
783 // create button group
785 QButtonGroup* aGrp = new QButtonGroup( anArgGrp );
786 aGrp->addButton( myBtn1, 0 );
787 aGrp->addButton( myBtn2, 1 );
788 myBtn1->setCheckable( true );
789 myBtn2->setCheckable( true );
790 aGrp->setExclusive( true );
791 myBtn1->setChecked( true );
794 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
795 aLay->setSpacing( SPACING );
796 aLay->addWidget( aFrame1 );
797 aLay->addWidget( aFrame2 );
803 SMESHGUI_CutGroupsDlg::~SMESHGUI_CutGroupsDlg()
808 \brief This virtual method redefined from the base class resets state
809 of the dialog, initializes its fields with default value, etc.
811 void SMESHGUI_CutGroupsDlg::reset()
813 SMESHGUI_GroupOpDlg::reset();
823 \brief SLOT called when apply button is pressed performs operation
824 \return TRUE if operation has been completed successfully, FALSE otherwise
826 bool SMESHGUI_CutGroupsDlg::onApply()
828 if ( getSMESHGUI()->isActiveStudyLocked())
831 // Verify validity of group name
832 if ( getName() == "" )
834 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
835 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
839 if ( myGroups1.isEmpty() || myGroups2.isEmpty() )
841 SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
842 SMESHGUI_GroupOpDlg::tr("INCORRECT_ARGUMENTS") );
846 QList<SMESH::SMESH_GroupBase_var> aGroups = myGroups1;
847 QList<SMESH::SMESH_GroupBase_var>::iterator anIter;
848 for ( anIter = myGroups2.begin(); anIter != myGroups2.end(); ++anIter )
849 aGroups.append( *anIter );
851 if ( !isValid( aGroups ) )
854 SMESH::SMESH_Mesh_var aMesh = myGroups1.first()->GetMesh();
855 QString aName = getName();
860 SMESH::ListOfGroups_var aList1 = convert( myGroups1 );
861 SMESH::ListOfGroups_var aList2 = convert( myGroups2 );
862 SMESH::SMESH_Group_var aNewGrp =
863 aMesh->CutListOfGroups( aList1, aList2, aName.toLatin1().constData() );
864 if ( !CORBA::is_nil( aNewGrp ) )
866 aNewGrp->SetColor( getColor() );
877 SMESHGUI::Modified();
878 getSMESHGUI()->updateObjBrowser(true);
884 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
885 tr("SMESH_OPERATION_FAILED"));
891 \brief SLOT, called when selection is changed, updates corresponding GUI controls
893 void SMESHGUI_CutGroupsDlg::onSelectionDone()
896 if ( myBtn2->isChecked() )
898 getSelectedGroups( myGroups2, aNames );
900 myListWg2->addItems( aNames );
904 getSelectedGroups( myGroups1, aNames );
906 myListWg1->addItems( aNames );
910 // === === === === === === === === === === === === === === === === === === === === ===
914 \param theModule module
916 SMESHGUI_DimGroupDlg::SMESHGUI_DimGroupDlg( SMESHGUI* theModule )
917 : SMESHGUI_GroupOpDlg( theModule )
919 setWindowTitle( tr( "CREATE_GROUP_OF_UNDERLYING_ELEMS" ) );
920 setHelpFileName( "creating_groups_page.html#gui_create_dim_group" );
922 QGroupBox* anArgGrp = getArgGrp();
924 QLabel* aLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp );
926 myCombo = new QComboBox( anArgGrp );
927 static QStringList anItems;
928 if ( anItems.isEmpty() )
930 anItems.append( tr( "NODE" ) );
931 anItems.append( tr( "EDGE" ) );
932 anItems.append( tr( "FACE" ) );
933 anItems.append( tr( "VOLUME" ) );
935 myCombo->addItems( anItems );
936 myCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
938 myListWg = new QListWidget( anArgGrp );
941 QGridLayout* aLay = new QGridLayout( anArgGrp );
942 aLay->setSpacing( SPACING );
943 aLay->addWidget( aLbl, 0, 0 );
944 aLay->addWidget( myCombo, 0, 1 );
945 aLay->addWidget( myListWg, 1, 0, 1, 2 );
951 SMESHGUI_DimGroupDlg::~SMESHGUI_DimGroupDlg()
956 \brief This virtual method redefined from the base class resets state
957 of the dialog, initializes its fields with default value, etc.
959 void SMESHGUI_DimGroupDlg::reset()
961 SMESHGUI_GroupOpDlg::reset();
967 \brief Gets elements type
968 \return elements type
971 SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const
973 return (SMESH::ElementType)( myCombo->currentIndex() + 1 );
977 \brief Sets elements type
978 \param theElemType elements type
981 void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType )
983 myCombo->setCurrentIndex( theElemType - 1 );
987 \brief SLOT called when apply button is pressed performs operation
988 \return TRUE if operation has been completed successfully, FALSE otherwise
990 bool SMESHGUI_DimGroupDlg::onApply()
992 if ( getSMESHGUI()->isActiveStudyLocked())
995 // Verify validity of group name
996 if ( getName() == "" )
998 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
999 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
1003 if ( !isValid( myGroups ) )
1006 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
1007 QString aName = getName();
1012 SMESH::ListOfGroups_var aList = convert( myGroups );
1013 SMESH::ElementType anElemType = getElementType();
1014 SMESH::SMESH_Group_var aNewGrp =
1015 aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData() );
1016 if ( !CORBA::is_nil( aNewGrp ) )
1018 aNewGrp->SetColor( getColor() );
1029 SMESHGUI::Modified();
1030 getSMESHGUI()->updateObjBrowser(true);
1036 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
1037 tr("SMESH_OPERATION_FAILED"));
1043 \brief SLOT, called when selection is changed, updates corresponding GUI controls
1045 void SMESHGUI_DimGroupDlg::onSelectionDone()
1048 getSelectedGroups( myGroups, aNames );
1050 myListWg->addItems( aNames );