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 getSMESHGUI()->updateObjBrowser(true);
613 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
614 tr("SMESH_OPERATION_FAILED"));
620 \brief SLOT, called when selection is changed, updates corresponding GUI controls
622 void SMESHGUI_UnionGroupsDlg::onSelectionDone()
625 getSelectedGroups( myGroups, aNames );
627 myListWg->addItems( aNames );
630 // === === === === === === === === === === === === === === === === === === === === ===
634 \param theModule module
636 SMESHGUI_IntersectGroupsDlg::SMESHGUI_IntersectGroupsDlg( SMESHGUI* theModule )
637 : SMESHGUI_GroupOpDlg( theModule )
639 setWindowTitle(tr("INTERSECTION_OF_GROUPS"));
640 setHelpFileName( "using_operations_on_groups_page.html#intersection_anchor" );
642 QGroupBox* anArgGrp = getArgGrp();
643 myListWg = new QListWidget( anArgGrp );
645 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
646 aLay->addWidget( myListWg );
652 SMESHGUI_IntersectGroupsDlg::~SMESHGUI_IntersectGroupsDlg()
657 \brief This virtual method redefined from the base class resets state
658 of the dialog, initializes its fields with default value, etc.
660 void SMESHGUI_IntersectGroupsDlg::reset()
662 SMESHGUI_GroupOpDlg::reset();
668 \brief SLOT called when apply button is pressed performs operation
669 \return TRUE if operation has been completed successfully, FALSE otherwise
671 bool SMESHGUI_IntersectGroupsDlg::onApply()
673 if ( getSMESHGUI()->isActiveStudyLocked())
676 // Verify validity of group name
677 if ( getName() == "" )
679 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
680 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
684 if ( !isValid( myGroups ) )
687 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
688 QString aName = getName();
693 SMESH::ListOfGroups_var aList = convert( myGroups );
694 SMESH::SMESH_Group_var aNewGrp =
695 aMesh->IntersectListOfGroups( aList, aName.toLatin1().constData() );
696 if ( !CORBA::is_nil( aNewGrp ) )
698 aNewGrp->SetColor( getColor() );
709 getSMESHGUI()->updateObjBrowser(true);
715 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
716 tr("SMESH_OPERATION_FAILED"));
722 \brief SLOT, called when selection is changed, updates corresponding GUI controls
724 void SMESHGUI_IntersectGroupsDlg::onSelectionDone()
727 getSelectedGroups( myGroups, aNames );
729 myListWg->addItems( aNames );
732 // === === === === === === === === === === === === === === === === === === === === ===
736 \param theModule module
738 SMESHGUI_CutGroupsDlg::SMESHGUI_CutGroupsDlg( SMESHGUI* theModule )
739 : SMESHGUI_GroupOpDlg( theModule )
741 setWindowTitle(tr("CUT_OF_GROUPS"));
742 setHelpFileName( "using_operations_on_groups_page.html#cut_anchor" );
744 QGroupBox* anArgGrp = getArgGrp();
746 QPixmap aPix (SMESH::GetResourceMgr( getSMESHGUI() )->loadPixmap("SMESH", tr("ICON_SELECT")));
749 QFrame* aFrame1 = new QFrame( anArgGrp );
750 QLabel* aLbl1 = new QLabel( tr("MAIN_OBJECT"), aFrame1 );
751 aLbl1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
752 myBtn1 = new QPushButton( aFrame1 );
753 myBtn1->setIcon(aPix);
754 myListWg1 = new QListWidget( aFrame1 );
756 QGridLayout* aLay1 = new QGridLayout( aFrame1 );
757 aLay1->setSpacing( SPACING );
758 aLay1->addWidget( aLbl1, 0, 0 );
759 aLay1->addWidget( myBtn1, 0, 1 );
760 aLay1->addWidget( myListWg1, 1, 0, 1, 2 );
761 //QSpacerItem* aHSpacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
762 //aLay1->addItem( aHSpacer1, 0, 2 );
766 QFrame* aFrame2 = new QFrame( anArgGrp );
767 QLabel* aLbl2 = new QLabel( tr("TOOL_OBJECT"), aFrame2 );
768 aLbl2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
769 myBtn2 = new QPushButton( aFrame2 );
770 myBtn2->setIcon(aPix);
771 myListWg2 = new QListWidget( aFrame2 );
773 QGridLayout* aLay2 = new QGridLayout( aFrame2 );
774 aLay2->setSpacing( SPACING );
775 aLay2->addWidget( aLbl2, 0, 0 );
776 aLay2->addWidget( myBtn2, 0, 1 );
777 aLay2->addWidget( myListWg2, 1, 0, 1, 2 );
778 //QSpacerItem* aHSpacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
779 //aLay2->addItem( aHSpacer2, 0, 2 );
781 // create button group
783 QButtonGroup* aGrp = new QButtonGroup( anArgGrp );
784 aGrp->addButton( myBtn1, 0 );
785 aGrp->addButton( myBtn2, 1 );
786 myBtn1->setCheckable( true );
787 myBtn2->setCheckable( true );
788 aGrp->setExclusive( true );
789 myBtn1->setChecked( true );
792 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
793 aLay->setSpacing( SPACING );
794 aLay->addWidget( aFrame1 );
795 aLay->addWidget( aFrame2 );
801 SMESHGUI_CutGroupsDlg::~SMESHGUI_CutGroupsDlg()
806 \brief This virtual method redefined from the base class resets state
807 of the dialog, initializes its fields with default value, etc.
809 void SMESHGUI_CutGroupsDlg::reset()
811 SMESHGUI_GroupOpDlg::reset();
821 \brief SLOT called when apply button is pressed performs operation
822 \return TRUE if operation has been completed successfully, FALSE otherwise
824 bool SMESHGUI_CutGroupsDlg::onApply()
826 if ( getSMESHGUI()->isActiveStudyLocked())
829 // Verify validity of group name
830 if ( getName() == "" )
832 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
833 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
837 if ( myGroups1.isEmpty() || myGroups2.isEmpty() )
839 SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
840 SMESHGUI_GroupOpDlg::tr("INCORRECT_ARGUMENTS") );
844 QList<SMESH::SMESH_GroupBase_var> aGroups = myGroups1;
845 QList<SMESH::SMESH_GroupBase_var>::iterator anIter;
846 for ( anIter = myGroups2.begin(); anIter != myGroups2.end(); ++anIter )
847 aGroups.append( *anIter );
849 if ( !isValid( aGroups ) )
852 SMESH::SMESH_Mesh_var aMesh = myGroups1.first()->GetMesh();
853 QString aName = getName();
858 SMESH::ListOfGroups_var aList1 = convert( myGroups1 );
859 SMESH::ListOfGroups_var aList2 = convert( myGroups2 );
860 SMESH::SMESH_Group_var aNewGrp =
861 aMesh->CutListOfGroups( aList1, aList2, aName.toLatin1().constData() );
862 if ( !CORBA::is_nil( aNewGrp ) )
864 aNewGrp->SetColor( getColor() );
875 getSMESHGUI()->updateObjBrowser(true);
881 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
882 tr("SMESH_OPERATION_FAILED"));
888 \brief SLOT, called when selection is changed, updates corresponding GUI controls
890 void SMESHGUI_CutGroupsDlg::onSelectionDone()
893 if ( myBtn2->isChecked() )
895 getSelectedGroups( myGroups2, aNames );
897 myListWg2->addItems( aNames );
901 getSelectedGroups( myGroups1, aNames );
903 myListWg1->addItems( aNames );
907 // === === === === === === === === === === === === === === === === === === === === ===
911 \param theModule module
913 SMESHGUI_DimGroupDlg::SMESHGUI_DimGroupDlg( SMESHGUI* theModule )
914 : SMESHGUI_GroupOpDlg( theModule )
916 setWindowTitle( tr( "CREATE_GROUP_OF_UNDERLYING_ELEMS" ) );
917 setHelpFileName( "creating_groups_page.html#gui_create_dim_group" );
919 QGroupBox* anArgGrp = getArgGrp();
921 QLabel* aLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp );
923 myCombo = new QComboBox( anArgGrp );
924 static QStringList anItems;
925 if ( anItems.isEmpty() )
927 anItems.append( tr( "NODE" ) );
928 anItems.append( tr( "EDGE" ) );
929 anItems.append( tr( "FACE" ) );
930 anItems.append( tr( "VOLUME" ) );
932 myCombo->addItems( anItems );
933 myCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
935 myListWg = new QListWidget( anArgGrp );
938 QGridLayout* aLay = new QGridLayout( anArgGrp );
939 aLay->setSpacing( SPACING );
940 aLay->addWidget( aLbl, 0, 0 );
941 aLay->addWidget( myCombo, 0, 1 );
942 aLay->addWidget( myListWg, 1, 0, 1, 2 );
948 SMESHGUI_DimGroupDlg::~SMESHGUI_DimGroupDlg()
953 \brief This virtual method redefined from the base class resets state
954 of the dialog, initializes its fields with default value, etc.
956 void SMESHGUI_DimGroupDlg::reset()
958 SMESHGUI_GroupOpDlg::reset();
964 \brief Gets elements type
965 \return elements type
968 SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const
970 return (SMESH::ElementType)( myCombo->currentIndex() + 1 );
974 \brief Sets elements type
975 \param theElemType elements type
978 void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType )
980 myCombo->setCurrentIndex( theElemType - 1 );
984 \brief SLOT called when apply button is pressed performs operation
985 \return TRUE if operation has been completed successfully, FALSE otherwise
987 bool SMESHGUI_DimGroupDlg::onApply()
989 if ( getSMESHGUI()->isActiveStudyLocked())
992 // Verify validity of group name
993 if ( getName() == "" )
995 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
996 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
1000 if ( !isValid( myGroups ) )
1003 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
1004 QString aName = getName();
1009 SMESH::ListOfGroups_var aList = convert( myGroups );
1010 SMESH::ElementType anElemType = getElementType();
1011 SMESH::SMESH_Group_var aNewGrp =
1012 aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData() );
1013 if ( !CORBA::is_nil( aNewGrp ) )
1015 aNewGrp->SetColor( getColor() );
1026 getSMESHGUI()->updateObjBrowser(true);
1032 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
1033 tr("SMESH_OPERATION_FAILED"));
1039 \brief SLOT, called when selection is changed, updates corresponding GUI controls
1041 void SMESHGUI_DimGroupDlg::onSelectionDone()
1044 getSelectedGroups( myGroups, aNames );
1046 myListWg->addItems( aNames );