1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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>
48 // SALOME KERNEL includes
49 #include <SALOMEDSClient_SObject.hxx>
52 #include <QHBoxLayout>
53 #include <QVBoxLayout>
54 #include <QGridLayout>
55 #include <QPushButton>
60 #include <QListWidget>
61 #include <QButtonGroup>
63 #include <QtxColorButton.h>
69 * Class : SMESHGUI_GroupOpDlg
70 * Description : Perform boolean operations on groups
75 \param theModule pointer on module instance
77 SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule )
78 : QDialog( SMESH::GetDesktop( theModule ) ),
79 mySMESHGUI( theModule ),
80 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
81 myIsApplyAndClose( false )
85 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
87 QVBoxLayout* aDlgLay = new QVBoxLayout (this);
88 aDlgLay->setMargin(MARGIN);
89 aDlgLay->setSpacing(SPACING);
91 QWidget* aMainFrame = createMainFrame (this);
92 QWidget* aBtnFrame = createButtonFrame(this);
94 aDlgLay->addWidget(aMainFrame);
95 aDlgLay->addWidget(aBtnFrame);
101 \brief Creates frame containing dialog's input fields
102 \param theParent parent widget
103 \return pointer on created widget
105 QWidget* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent )
107 QWidget* aMainGrp = new QWidget(theParent);
108 QVBoxLayout* aLay = new QVBoxLayout(aMainGrp);
110 aLay->setSpacing(SPACING);
112 // ------------------------------------------------------
113 QGroupBox* aNameGrp = new QGroupBox(tr("NAME"), aMainGrp);
114 QHBoxLayout* aNameGrpLayout = new QHBoxLayout(aNameGrp);
115 aNameGrpLayout->setMargin(MARGIN);
116 aNameGrpLayout->setSpacing(SPACING);
118 QLabel* aNameLab = new QLabel(tr("RESULT_NAME"), aNameGrp);
119 myNameEdit = new QLineEdit(aNameGrp);
121 aNameGrpLayout->addWidget(aNameLab);
122 aNameGrpLayout->addWidget(myNameEdit);
124 // ------------------------------------------------------
125 myArgGrp = new QGroupBox(tr("ARGUMENTS"), aMainGrp);
128 // ------------------------------------------------------
130 QGroupBox* aColorBox = new QGroupBox(tr( "SMESH_SET_COLOR" ), this);
131 QHBoxLayout* aColorBoxLayout = new QHBoxLayout(aColorBox);
132 aColorBoxLayout->setMargin(MARGIN);
133 aColorBoxLayout->setSpacing(SPACING);
135 QLabel* aColorLab = new QLabel(tr( "SMESH_CHECK_COLOR" ), aColorBox );
136 myColorBtn = new QtxColorButton(aColorBox);
137 myColorBtn->setSizePolicy( QSizePolicy::MinimumExpanding,
138 myColorBtn->sizePolicy().verticalPolicy() );
140 aColorBoxLayout->addWidget(aColorLab);
141 aColorBoxLayout->addWidget(myColorBtn);
143 // ------------------------------------------------------
144 aLay->addWidget( aNameGrp );
145 aLay->addWidget( myArgGrp );
146 aLay->addWidget( aColorBox );
152 \brief Gets pointer on arguments group box
153 \return pointer on arguments group box
155 QGroupBox* SMESHGUI_GroupOpDlg::getArgGrp() const
161 \brief Sets help file name
162 \param theFName help file name
164 void SMESHGUI_GroupOpDlg::setHelpFileName( const QString& theFName )
166 myHelpFileName = theFName;
170 \brief Gets pointer to the module instance
171 \return pointer to the module instance
173 SMESHGUI* SMESHGUI_GroupOpDlg::getSMESHGUI() const
179 \brief Create frame containing buttons
180 \param theParent parent widget
181 \return pointer to the created frame
183 QWidget* SMESHGUI_GroupOpDlg::createButtonFrame (QWidget* theParent)
185 QGroupBox* aFrame = new QGroupBox(theParent);
187 myOkBtn = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
188 myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
189 myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
190 myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
192 QHBoxLayout* aLay = new QHBoxLayout(aFrame);
193 aLay->setMargin(MARGIN);
194 aLay->setSpacing(SPACING);
196 aLay->addWidget(myOkBtn);
197 aLay->addSpacing(10);
198 aLay->addWidget(myApplyBtn);
199 aLay->addSpacing(10);
201 aLay->addWidget(myCloseBtn);
202 aLay->addWidget(myHelpBtn);
204 // connect signals and slots
205 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
206 connect(myCloseBtn, SIGNAL(clicked()), SLOT(reject()));
207 connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
208 connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
216 SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg()
221 \brief Init dialog fields, connect signals and slots, show dialog
223 void SMESHGUI_GroupOpDlg::Init()
225 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
227 // selection and SMESHGUI
228 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
229 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
230 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject()));
232 // set selection mode
233 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
234 aViewWindow->SetSelectionMode(ActorSelection);
235 mySelectionMgr->installFilter(new SMESH_TypeFilter (SMESH::GROUP));
239 \brief Validate list of groups used for operation. Checks whether they corresponds
240 to the same face and have one type
241 \param theListGrp input list of groups
242 \return TRUE if groups are valid, FALSE otherwise
244 bool SMESHGUI_GroupOpDlg::isValid( const QList<SMESH::SMESH_GroupBase_var>& theListGrp )
246 if ( theListGrp.isEmpty() )
248 SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
249 tr("INCORRECT_ARGUMENTS") );
253 int aMeshId = -1, aGrpType = -1;
254 QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter;
255 for ( anIter = theListGrp.begin(); anIter != theListGrp.end(); ++anIter )
257 SMESH::SMESH_GroupBase_var aGrp = *anIter;
258 if ( CORBA::is_nil( aGrp ) )
259 continue; // nonsence
261 SMESH::SMESH_Mesh_var aMesh = aGrp->GetMesh();
262 if ( CORBA::is_nil( aMesh ) )
266 int aCurrId = aMesh->GetId();
271 if ( aMeshId != aCurrId )
273 aMeshId = -1; // different meshes
279 int aCurrType = aGrp->GetType();
280 if ( aGrpType == -1 )
281 aGrpType = aCurrType;
284 if ( aGrpType != aCurrType )
286 aGrpType = -1; // different types
295 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
300 if ( aGrpType == -1 )
302 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
311 \brief SLOT called when "Ok" button pressed performs operation and closes dialog box
313 void SMESHGUI_GroupOpDlg::onOk()
315 setIsApplyAndClose( true );
318 setIsApplyAndClose( false );
322 \brief SLOT called when dialog is closed
324 void SMESHGUI_GroupOpDlg::reject()
326 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
327 aViewWindow->SetSelectionMode(ActorSelection);
328 disconnect( mySelectionMgr, 0, this, 0 );
329 disconnect( mySMESHGUI, 0, this, 0 );
330 mySMESHGUI->ResetState();
331 mySelectionMgr->clearFilters();
337 \brief SLOT called when "Help" button pressed shows "Help" page
339 void SMESHGUI_GroupOpDlg::onHelp()
341 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
343 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
347 platform = "winapplication";
349 platform = "application";
351 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
352 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
353 arg(app->resourceMgr()->stringValue("ExternalBrowser",
355 arg(myHelpFileName));
360 \brief Gets list of currently selected groups from selection manager
361 \param theOutList out list of groups
362 \param theOutNames out list of group of group names
363 \return TRUE if operation theOutList is not empty, FALSE otherwise
365 bool SMESHGUI_GroupOpDlg::getSelectedGroups( QList<SMESH::SMESH_GroupBase_var>& theOutList,
366 QStringList& theOutNames )
373 SALOME_ListIO aListIO;
374 mySelectionMgr->selectedObjects( aListIO );
375 SALOME_ListIteratorOfListIO anIter ( aListIO );
376 for ( ; anIter.More(); anIter.Next())
378 SMESH::SMESH_GroupBase_var aGroup =
379 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
380 if ( !aGroup->_is_nil())
382 theOutList.append( aGroup );
383 theOutNames.append( aGroup->GetName() );
387 return theOutList.count() > 0;
391 \brief Converts QT-list of group to the list acceptable by IDL interface
392 \param theIn input list
393 \return list acceptable by IDL interface
395 SMESH::ListOfGroups* SMESHGUI_GroupOpDlg::convert(
396 const QList<SMESH::SMESH_GroupBase_var>& theIn )
398 SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
399 aList->length( theIn.count() );
401 QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter = theIn.begin();
402 for ( int i = 0; anIter != theIn.end(); ++anIter, ++i )
403 aList[ i ] = *anIter;
405 return aList._retn();
409 \brief Get color to be assigned to group
410 \return color to be assigned to group
412 SALOMEDS::Color SMESHGUI_GroupOpDlg::getColor() const
414 QColor aQColor = myColorBtn->color();
416 SALOMEDS::Color aColor;
417 aColor.R = (float)aQColor.red() / 255.0;
418 aColor.G = (float)aQColor.green() / 255.0;
419 aColor.B = (float)aQColor.blue() / 255.0;
425 \brief SLOT, called when selection is changed. Current implementation does
426 nothing. The method should be redefined in derived classes to update
427 corresponding GUI controls
429 void SMESHGUI_GroupOpDlg::onSelectionDone()
434 \brief Calls onSelectionDone() and setVisible() method of base class
435 \param visible the visible state of the dialog
437 void SMESHGUI_GroupOpDlg::setVisible( bool visible )
442 resize( minimumSizeHint().width(), sizeHint().height() );
444 QDialog::setVisible( visible );
448 \brief SLOT called when dialog must be deativated
450 void SMESHGUI_GroupOpDlg::onDeactivate()
453 mySelectionMgr->clearFilters();
457 \brief Event filter updates selection mode and selection filter. This virtual method
458 is redefined from the base class it is called when dialog obtains input focus
460 void SMESHGUI_GroupOpDlg::enterEvent(QEvent*)
462 mySMESHGUI->EmitSignalDeactivateDialog();
464 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
465 aViewWindow->SetSelectionMode(ActorSelection);
466 mySelectionMgr->installFilter(new SMESH_TypeFilter (SMESH::GROUP));
470 \brief Resets state of the dialog, initializes its fields with default value, etc.
471 Usually called by onApply() slot to reinitialize dialog fields. This virtual method
472 should be redefined in derived class to update its own fileds
474 void SMESHGUI_GroupOpDlg::reset()
476 myNameEdit->setText("");
477 myNameEdit->setFocus();
481 \brief Gets name of group to be created
482 \return name of group to be created
485 QString SMESHGUI_GroupOpDlg::getName() const
487 return myNameEdit->text();
491 \brief Sets name of group to be created
492 \param theName name of group to be created
495 void SMESHGUI_GroupOpDlg::setName( const QString& theName )
497 myNameEdit->setText( theName );
501 \brief Provides reaction on
\93F1
\94 button pressing
502 \param e key press event
504 void SMESHGUI_GroupOpDlg::keyPressEvent( QKeyEvent* e )
506 QDialog::keyPressEvent( e );
507 if ( e->isAccepted() )
510 if ( e->key() == Qt::Key_F1 ) {
517 \brief This virtual slot does nothing and should be redefined in derived classes
518 \return return false;
520 bool SMESHGUI_GroupOpDlg::onApply()
526 \brief Set value of the flag indicating that the dialog is
527 accepted by Apply & Close button
528 \param theFlag value of the flag
529 \sa isApplyAndClose()
531 void SMESHGUI_GroupOpDlg::setIsApplyAndClose( const bool theFlag )
533 myIsApplyAndClose = theFlag;
537 \brief Get value of the flag indicating that the dialog is
538 accepted by Apply & Close button
539 \return value of the flag
540 \sa setApplyAndClose()
542 bool SMESHGUI_GroupOpDlg::isApplyAndClose() const
544 return myIsApplyAndClose;
547 // === === === === === === === === === === === === === === === === === === === === ===
551 \param theModule module
553 SMESHGUI_UnionGroupsDlg::SMESHGUI_UnionGroupsDlg( SMESHGUI* theModule )
554 : SMESHGUI_GroupOpDlg( theModule )
556 setWindowTitle(tr("UNION_OF_GROUPS"));
557 setHelpFileName( "using_operations_on_groups_page.html#union_anchor" );
559 QGroupBox* anArgGrp = getArgGrp();
560 myListWg = new QListWidget( anArgGrp );
562 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
563 aLay->addWidget( myListWg );
569 SMESHGUI_UnionGroupsDlg::~SMESHGUI_UnionGroupsDlg()
574 \brief This virtual method redefined from the base class resets state
575 of the dialog, initializes its fields with default value, etc.
577 void SMESHGUI_UnionGroupsDlg::reset()
579 SMESHGUI_GroupOpDlg::reset();
585 \brief SLOT called when apply button is pressed performs operation
586 \return TRUE if operation has been completed successfully, FALSE otherwise
588 bool SMESHGUI_UnionGroupsDlg::onApply()
590 if ( getSMESHGUI()->isActiveStudyLocked())
593 // Verify validity of group name
594 if ( getName() == "" )
596 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
597 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
601 if ( !isValid( myGroups ) )
604 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
605 QString aName = getName();
608 QStringList anEntryList;
611 SMESH::ListOfGroups_var aList = convert( myGroups );
612 SMESH::SMESH_Group_var aNewGrp =
613 aMesh->UnionListOfGroups( aList, aName.toLatin1().constData() );
614 if ( !CORBA::is_nil( aNewGrp ) )
616 aNewGrp->SetColor( getColor() );
617 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
618 anEntryList.append( aSObject->GetID().c_str() );
629 SMESHGUI::Modified();
630 getSMESHGUI()->updateObjBrowser(true);
632 if( LightApp_Application* anApp =
633 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
634 anApp->browseObjects( anEntryList, isApplyAndClose() );
639 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
640 tr("SMESH_OPERATION_FAILED"));
646 \brief SLOT, called when selection is changed, updates corresponding GUI controls
648 void SMESHGUI_UnionGroupsDlg::onSelectionDone()
651 getSelectedGroups( myGroups, aNames );
653 myListWg->addItems( aNames );
656 // === === === === === === === === === === === === === === === === === === === === ===
660 \param theModule module
662 SMESHGUI_IntersectGroupsDlg::SMESHGUI_IntersectGroupsDlg( SMESHGUI* theModule )
663 : SMESHGUI_GroupOpDlg( theModule )
665 setWindowTitle(tr("INTERSECTION_OF_GROUPS"));
666 setHelpFileName( "using_operations_on_groups_page.html#intersection_anchor" );
668 QGroupBox* anArgGrp = getArgGrp();
669 myListWg = new QListWidget( anArgGrp );
671 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
672 aLay->addWidget( myListWg );
678 SMESHGUI_IntersectGroupsDlg::~SMESHGUI_IntersectGroupsDlg()
683 \brief This virtual method redefined from the base class resets state
684 of the dialog, initializes its fields with default value, etc.
686 void SMESHGUI_IntersectGroupsDlg::reset()
688 SMESHGUI_GroupOpDlg::reset();
694 \brief SLOT called when apply button is pressed performs operation
695 \return TRUE if operation has been completed successfully, FALSE otherwise
697 bool SMESHGUI_IntersectGroupsDlg::onApply()
699 if ( getSMESHGUI()->isActiveStudyLocked())
702 // Verify validity of group name
703 if ( getName() == "" )
705 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
706 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
710 if ( !isValid( myGroups ) )
713 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
714 QString aName = getName();
717 QStringList anEntryList;
720 SMESH::ListOfGroups_var aList = convert( myGroups );
721 SMESH::SMESH_Group_var aNewGrp =
722 aMesh->IntersectListOfGroups( aList, aName.toLatin1().constData() );
723 if ( !CORBA::is_nil( aNewGrp ) )
725 aNewGrp->SetColor( getColor() );
726 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
727 anEntryList.append( aSObject->GetID().c_str() );
738 SMESHGUI::Modified();
739 getSMESHGUI()->updateObjBrowser(true);
741 if( LightApp_Application* anApp =
742 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
743 anApp->browseObjects( anEntryList, isApplyAndClose() );
748 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
749 tr("SMESH_OPERATION_FAILED"));
755 \brief SLOT, called when selection is changed, updates corresponding GUI controls
757 void SMESHGUI_IntersectGroupsDlg::onSelectionDone()
760 getSelectedGroups( myGroups, aNames );
762 myListWg->addItems( aNames );
765 // === === === === === === === === === === === === === === === === === === === === ===
769 \param theModule module
771 SMESHGUI_CutGroupsDlg::SMESHGUI_CutGroupsDlg( SMESHGUI* theModule )
772 : SMESHGUI_GroupOpDlg( theModule )
774 setWindowTitle(tr("CUT_OF_GROUPS"));
775 setHelpFileName( "using_operations_on_groups_page.html#cut_anchor" );
777 QGroupBox* anArgGrp = getArgGrp();
779 QPixmap aPix (SMESH::GetResourceMgr( getSMESHGUI() )->loadPixmap("SMESH", tr("ICON_SELECT")));
782 QFrame* aFrame1 = new QFrame( anArgGrp );
783 QLabel* aLbl1 = new QLabel( tr("MAIN_OBJECT"), aFrame1 );
784 aLbl1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
785 myBtn1 = new QPushButton( aFrame1 );
786 myBtn1->setIcon(aPix);
787 myListWg1 = new QListWidget( aFrame1 );
789 QGridLayout* aLay1 = new QGridLayout( aFrame1 );
790 aLay1->setSpacing( SPACING );
791 aLay1->addWidget( aLbl1, 0, 0 );
792 aLay1->addWidget( myBtn1, 0, 1 );
793 aLay1->addWidget( myListWg1, 1, 0, 1, 2 );
794 //QSpacerItem* aHSpacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
795 //aLay1->addItem( aHSpacer1, 0, 2 );
799 QFrame* aFrame2 = new QFrame( anArgGrp );
800 QLabel* aLbl2 = new QLabel( tr("TOOL_OBJECT"), aFrame2 );
801 aLbl2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
802 myBtn2 = new QPushButton( aFrame2 );
803 myBtn2->setIcon(aPix);
804 myListWg2 = new QListWidget( aFrame2 );
806 QGridLayout* aLay2 = new QGridLayout( aFrame2 );
807 aLay2->setSpacing( SPACING );
808 aLay2->addWidget( aLbl2, 0, 0 );
809 aLay2->addWidget( myBtn2, 0, 1 );
810 aLay2->addWidget( myListWg2, 1, 0, 1, 2 );
811 //QSpacerItem* aHSpacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
812 //aLay2->addItem( aHSpacer2, 0, 2 );
814 // create button group
816 QButtonGroup* aGrp = new QButtonGroup( anArgGrp );
817 aGrp->addButton( myBtn1, 0 );
818 aGrp->addButton( myBtn2, 1 );
819 myBtn1->setCheckable( true );
820 myBtn2->setCheckable( true );
821 aGrp->setExclusive( true );
822 myBtn1->setChecked( true );
825 QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
826 aLay->setSpacing( SPACING );
827 aLay->addWidget( aFrame1 );
828 aLay->addWidget( aFrame2 );
834 SMESHGUI_CutGroupsDlg::~SMESHGUI_CutGroupsDlg()
839 \brief This virtual method redefined from the base class resets state
840 of the dialog, initializes its fields with default value, etc.
842 void SMESHGUI_CutGroupsDlg::reset()
844 SMESHGUI_GroupOpDlg::reset();
854 \brief SLOT called when apply button is pressed performs operation
855 \return TRUE if operation has been completed successfully, FALSE otherwise
857 bool SMESHGUI_CutGroupsDlg::onApply()
859 if ( getSMESHGUI()->isActiveStudyLocked())
862 // Verify validity of group name
863 if ( getName() == "" )
865 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
866 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
870 if ( myGroups1.isEmpty() || myGroups2.isEmpty() )
872 SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
873 SMESHGUI_GroupOpDlg::tr("INCORRECT_ARGUMENTS") );
877 QList<SMESH::SMESH_GroupBase_var> aGroups = myGroups1;
878 QList<SMESH::SMESH_GroupBase_var>::iterator anIter;
879 for ( anIter = myGroups2.begin(); anIter != myGroups2.end(); ++anIter )
880 aGroups.append( *anIter );
882 if ( !isValid( aGroups ) )
885 SMESH::SMESH_Mesh_var aMesh = myGroups1.first()->GetMesh();
886 QString aName = getName();
889 QStringList anEntryList;
892 SMESH::ListOfGroups_var aList1 = convert( myGroups1 );
893 SMESH::ListOfGroups_var aList2 = convert( myGroups2 );
894 SMESH::SMESH_Group_var aNewGrp =
895 aMesh->CutListOfGroups( aList1, aList2, aName.toLatin1().constData() );
896 if ( !CORBA::is_nil( aNewGrp ) )
898 aNewGrp->SetColor( getColor() );
899 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
900 anEntryList.append( aSObject->GetID().c_str() );
911 SMESHGUI::Modified();
912 getSMESHGUI()->updateObjBrowser(true);
914 if( LightApp_Application* anApp =
915 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
916 anApp->browseObjects( anEntryList, isApplyAndClose() );
921 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
922 tr("SMESH_OPERATION_FAILED"));
928 \brief SLOT, called when selection is changed, updates corresponding GUI controls
930 void SMESHGUI_CutGroupsDlg::onSelectionDone()
933 if ( myBtn2->isChecked() )
935 getSelectedGroups( myGroups2, aNames );
937 myListWg2->addItems( aNames );
941 getSelectedGroups( myGroups1, aNames );
943 myListWg1->addItems( aNames );
947 // === === === === === === === === === === === === === === === === === === === === ===
951 \param theModule module
953 SMESHGUI_DimGroupDlg::SMESHGUI_DimGroupDlg( SMESHGUI* theModule )
954 : SMESHGUI_GroupOpDlg( theModule )
956 setWindowTitle( tr( "CREATE_GROUP_OF_UNDERLYING_ELEMS" ) );
957 setHelpFileName( "group_of_underlying_elements_page.html" );
959 QGroupBox* anArgGrp = getArgGrp();
961 QLabel* aLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp );
963 myCombo = new QComboBox( anArgGrp );
964 static QStringList anItems;
965 if ( anItems.isEmpty() )
967 anItems.append( tr( "NODE" ) );
968 anItems.append( tr( "EDGE" ) );
969 anItems.append( tr( "FACE" ) );
970 anItems.append( tr( "VOLUME" ) );
972 myCombo->addItems( anItems );
973 myCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
975 myListWg = new QListWidget( anArgGrp );
978 QGridLayout* aLay = new QGridLayout( anArgGrp );
979 aLay->setSpacing( SPACING );
980 aLay->addWidget( aLbl, 0, 0 );
981 aLay->addWidget( myCombo, 0, 1 );
982 aLay->addWidget( myListWg, 1, 0, 1, 2 );
988 SMESHGUI_DimGroupDlg::~SMESHGUI_DimGroupDlg()
993 \brief This virtual method redefined from the base class resets state
994 of the dialog, initializes its fields with default value, etc.
996 void SMESHGUI_DimGroupDlg::reset()
998 SMESHGUI_GroupOpDlg::reset();
1004 \brief Gets elements type
1005 \return elements type
1006 \sa setElementType()
1008 SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const
1010 return (SMESH::ElementType)( myCombo->currentIndex() + 1 );
1014 \brief Sets elements type
1015 \param theElemType elements type
1016 \sa getElementType()
1018 void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType )
1020 myCombo->setCurrentIndex( theElemType - 1 );
1024 \brief SLOT called when apply button is pressed performs operation
1025 \return TRUE if operation has been completed successfully, FALSE otherwise
1027 bool SMESHGUI_DimGroupDlg::onApply()
1029 if ( getSMESHGUI()->isActiveStudyLocked())
1032 // Verify validity of group name
1033 if ( getName() == "" )
1035 SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
1036 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
1040 if ( !isValid( myGroups ) )
1043 SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
1044 QString aName = getName();
1047 QStringList anEntryList;
1050 SMESH::ListOfGroups_var aList = convert( myGroups );
1051 SMESH::ElementType anElemType = getElementType();
1052 SMESH::SMESH_Group_var aNewGrp =
1053 aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData() );
1054 if ( !CORBA::is_nil( aNewGrp ) )
1056 aNewGrp->SetColor( getColor() );
1057 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
1058 anEntryList.append( aSObject->GetID().c_str() );
1069 SMESHGUI::Modified();
1070 getSMESHGUI()->updateObjBrowser(true);
1072 if( LightApp_Application* anApp =
1073 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
1074 anApp->browseObjects( anEntryList, isApplyAndClose() );
1079 SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
1080 tr("SMESH_OPERATION_FAILED"));
1086 \brief SLOT, called when selection is changed, updates corresponding GUI controls
1088 void SMESHGUI_DimGroupDlg::onSelectionDone()
1091 getSelectedGroups( myGroups, aNames );
1093 myListWg->addItems( aNames );