1 // Copyright (C) 2007-2021 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_DuplicateNodesDlg.cxx
25 // Author : Michael ZORIN, Open CASCADE S.A.S.
28 #include "SMESHGUI_DuplicateNodesDlg.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_MeshUtils.h"
33 #include "SMESHGUI_VTKUtils.h"
35 #include <SMESH_TypeFilter.hxx>
37 // SALOME GUI includes
38 #include <SUIT_Session.h>
39 #include <SUIT_ResourceMgr.h>
40 #include <SUIT_Desktop.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_OverrideCursor.h>
44 #include <LightApp_Application.h>
45 #include <LightApp_SelectionMgr.h>
47 #include <SalomeApp_Tools.h>
49 #include <SVTK_ViewWindow.h>
50 #include <SALOME_ListIO.hxx>
53 #include <QApplication>
54 #include <QButtonGroup>
58 #include <QPushButton>
59 #include <QRadioButton>
61 #include <QHBoxLayout>
62 #include <QVBoxLayout>
65 #include <utilities.h>
66 #include <SALOMEDSClient_SObject.hxx>
69 #include <SALOMEconfig.h>
70 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
77 \brief Simple 'busy state' flag locker.
84 //! Constructor. Sets passed boolean flag to \c true.
85 BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
86 //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
87 ~BusyLocker() { myBusy = false; }
89 bool& myBusy; //! External 'busy state' boolean flag
94 \param theModule Mesh module instance
96 SMESHGUI_DuplicateNodesDlg::SMESHGUI_DuplicateNodesDlg( SMESHGUI* theModule )
97 : QDialog( SMESH::GetDesktop( theModule ) ),
98 mySMESHGUI( theModule ),
99 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
103 setAttribute(Qt::WA_DeleteOnClose, true);
104 setWindowTitle(tr("SMESH_DUPLICATE_TITLE"));
105 setSizeGripEnabled(true);
107 // Icons for the dialog operation modes and selection button
108 SUIT_ResourceMgr* aResMgr = SMESH::GetResourceMgr( mySMESHGUI );
109 QPixmap iconWithoutElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES")));
110 QPixmap iconWithElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES_WITH_ELEM")));
111 QPixmap iconElemOnly (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_ELEM_ONLY")));
112 QPixmap iconGrpBoundary (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_GROUP_BOUNDARY")));
113 QPixmap iconSelect (aResMgr->loadPixmap("SMESH", tr("ICON_SELECT")));
116 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
117 aMainLayout->setSpacing(SPACING);
118 aMainLayout->setMargin(MARGIN);
120 // Operation modes selector
121 QGroupBox* aConstructorsBox = new QGroupBox(tr("DUPLICATION_MODE"), this);
122 myGroupConstructors = new QButtonGroup(this);
123 QHBoxLayout* aConstructorsBoxLayout = new QHBoxLayout(aConstructorsBox);
124 aConstructorsBoxLayout->setSpacing(SPACING);
125 aConstructorsBoxLayout->setMargin(MARGIN);
127 QRadioButton* aRadioButton1 = new QRadioButton(aConstructorsBox);
128 aRadioButton1->setIcon(iconWithoutElem);
129 QRadioButton* aRadioButton2 = new QRadioButton(aConstructorsBox);
130 aRadioButton2->setIcon(iconWithElem);
131 QRadioButton* aRadioButton3 = new QRadioButton(aConstructorsBox);
132 aRadioButton3->setIcon(iconElemOnly);
133 QRadioButton* aRadioButton4 = new QRadioButton(aConstructorsBox);
134 aRadioButton4->setIcon(iconGrpBoundary);
136 aConstructorsBoxLayout->addWidget(aRadioButton1);
137 aConstructorsBoxLayout->addWidget(aRadioButton2);
138 aConstructorsBoxLayout->addWidget(aRadioButton3);
139 aConstructorsBoxLayout->addWidget(aRadioButton4);
140 myGroupConstructors->addButton(aRadioButton1, 0);
141 myGroupConstructors->addButton(aRadioButton2, 1);
142 myGroupConstructors->addButton(aRadioButton3, 2);
143 myGroupConstructors->addButton(aRadioButton4, 3);
146 myGroupArguments = new QGroupBox(this);
147 QGridLayout* aGroupArgumentsLayout = new QGridLayout(myGroupArguments);
148 aGroupArgumentsLayout->setSpacing(SPACING);
149 aGroupArgumentsLayout->setMargin(MARGIN);
151 myTextLabel1 = new QLabel(myGroupArguments);
152 mySelectButton1 = new QPushButton(myGroupArguments);
153 mySelectButton1->setIcon(iconSelect);
154 myLineEdit1 = new QLineEdit(myGroupArguments);
155 myLineEdit1->setReadOnly(true);
157 myTextLabel2 = new QLabel(myGroupArguments);
158 mySelectButton2 = new QPushButton(myGroupArguments);
159 mySelectButton2->setIcon(iconSelect);
160 myLineEdit2 = new QLineEdit(myGroupArguments);
161 myLineEdit2->setReadOnly(true);
163 myTextLabel3 = new QLabel(myGroupArguments);
164 mySelectButton3 = new QPushButton(myGroupArguments);
165 mySelectButton3->setIcon(iconSelect);
166 myLineEdit3 = new QLineEdit(myGroupArguments);
167 myLineEdit3->setReadOnly(true);
168 myGenerateButton3 = new QPushButton(tr("GENERATE_GROUPS"), myGroupArguments);
170 myCheckBox1 = new QCheckBox(tr("CONSTRUCT_NEW_GROUP_ELEMENTS"), myGroupArguments);
171 myCheckBox2 = new QCheckBox(tr("CONSTRUCT_NEW_GROUP_NODES"), myGroupArguments);
173 aGroupArgumentsLayout->addWidget(myTextLabel1, 0, 0);
174 aGroupArgumentsLayout->addWidget(mySelectButton1, 0, 1);
175 aGroupArgumentsLayout->addWidget(myLineEdit1, 0, 2, 1, 2);
176 aGroupArgumentsLayout->addWidget(myTextLabel2, 1, 0);
177 aGroupArgumentsLayout->addWidget(mySelectButton2, 1, 1);
178 aGroupArgumentsLayout->addWidget(myLineEdit2, 1, 2, 1, 2);
179 aGroupArgumentsLayout->addWidget(myTextLabel3, 2, 0);
180 aGroupArgumentsLayout->addWidget(mySelectButton3, 2, 1);
181 aGroupArgumentsLayout->addWidget(myLineEdit3, 2, 2);
182 aGroupArgumentsLayout->addWidget(myGenerateButton3,2, 3);
183 aGroupArgumentsLayout->addWidget(myCheckBox1, 3, 0);
184 aGroupArgumentsLayout->addWidget(myCheckBox2, 4, 0);
185 aGroupArgumentsLayout->setRowStretch(5, 1);
188 QGroupBox* aGroupButtons = new QGroupBox(this);
189 QHBoxLayout* aGroupButtonsLayout = new QHBoxLayout(aGroupButtons);
190 aGroupButtonsLayout->setSpacing(SPACING);
191 aGroupButtonsLayout->setMargin(MARGIN);
193 myButtonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGroupButtons);
194 myButtonOk->setAutoDefault(true);
195 myButtonOk->setDefault(true);
196 myButtonApply = new QPushButton(tr("SMESH_BUT_APPLY"), aGroupButtons);
197 myButtonApply->setAutoDefault(true);
198 myButtonClose = new QPushButton(tr("SMESH_BUT_CLOSE"), aGroupButtons);
199 myButtonClose->setAutoDefault(true);
200 myButtonHelp = new QPushButton(tr("SMESH_BUT_HELP"), aGroupButtons);
201 myButtonHelp->setAutoDefault(true);
203 aGroupButtonsLayout->addWidget(myButtonOk);
204 aGroupButtonsLayout->addSpacing(10);
205 aGroupButtonsLayout->addWidget(myButtonApply);
206 aGroupButtonsLayout->addSpacing(10);
207 aGroupButtonsLayout->addStretch();
208 aGroupButtonsLayout->addWidget(myButtonClose);
209 aGroupButtonsLayout->addWidget(myButtonHelp);
211 // Add mode selector, arguments and buttons to the main layout
212 aMainLayout->addWidget(aConstructorsBox);
213 aMainLayout->addWidget(myGroupArguments);
214 aMainLayout->addWidget(aGroupButtons);
216 myCheckBox1->setChecked(true);
217 myCheckBox2->setChecked(true);
219 // Initialize the dialog
223 myHelpFileName = "double_nodes_page.html";
225 // Signals and slots connections
226 connect(myGroupConstructors, SIGNAL(buttonClicked(int)), SLOT(onConstructorsClicked(int)));
228 connect(mySelectButton1, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
229 connect(mySelectButton2, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
230 connect(mySelectButton3, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
231 connect(myGenerateButton3, SIGNAL (clicked()), this, SLOT(onGenerate()));
233 connect(myCheckBox2, SIGNAL(stateChanged(int)), SLOT(updateButtons()));
235 connect(myButtonOk, SIGNAL(clicked()), this, SLOT(onOk()));
236 connect(myButtonClose, SIGNAL(clicked()), this, SLOT(reject()));
237 connect(myButtonApply, SIGNAL(clicked()), this, SLOT(onApply()));
238 connect(myButtonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
240 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionChanged()));
242 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
243 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(reject()));
249 SMESHGUI_DuplicateNodesDlg::~SMESHGUI_DuplicateNodesDlg()
256 void SMESHGUI_DuplicateNodesDlg::Init()
258 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
260 // Set initial parameters
262 myCurrentLineEdit = myLineEdit1;
268 // Set selection mode
269 mySelectionMgr->installFilter(new SMESH_TypeFilter(SMESH::GROUP));
270 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
271 aViewWindow->SetSelectionMode(ActorSelection);
273 // Set construction mode
274 int operationMode = myGroupConstructors->checkedId();
275 if (operationMode < 0) {
276 // The dialog has been just displayed
278 myGroupConstructors->button(0)->setChecked(true);
280 onConstructorsClicked(operationMode);
284 \brief SLOT called to change the dialog operation mode.
285 \param constructorId id of the radio button in mode selector button group
287 void SMESHGUI_DuplicateNodesDlg::onConstructorsClicked (int constructorId)
290 myLineEdit1->clear();
291 myLineEdit2->clear();
292 myLineEdit3->clear();
298 // Set the first field as current
299 myCurrentLineEdit = myLineEdit1;
300 myCurrentLineEdit->setFocus();
302 switch (constructorId) {
305 // Set text to the group of arguments and to the first two labels
306 myGroupArguments->setTitle(tr("DUPLICATION_WITHOUT_ELEMS"));
307 myTextLabel1->setText(tr("GROUP_NODES_TO_DUPLICATE"));
308 myTextLabel3->setText(tr("GROUP_NODES_TO_REPLACE"));
312 myCheckBox2->setText( tr("CONSTRUCT_NEW_GROUP_NODES"));
314 // Hide the 2nd field
315 myTextLabel2 ->hide();
316 mySelectButton2 ->hide();
317 myLineEdit2 ->hide();
318 myTextLabel3 ->show();
319 mySelectButton3 ->show();
320 myLineEdit3 ->show();
321 myGenerateButton3->show();
327 // Set text to the group of arguments and to all the labels
328 myGroupArguments->setTitle(tr("DUPLICATION_WITH_ELEMS"));
329 myTextLabel1->setText(tr("GROUP_ELEMS_TO_DUPLICATE"));
330 myTextLabel2->setText(tr("GROUP_NODES_NOT_DUPLICATE"));
331 myTextLabel3->setText(tr("GROUP_ELEMS_TO_REPLACE"));
335 myCheckBox1->setText( tr("CONSTRUCT_NEW_GROUP_ELEMENTS"));
336 myCheckBox2->setText( tr("CONSTRUCT_NEW_GROUP_NODES"));
338 // Show the 2nd field
339 myTextLabel2 ->show();
340 mySelectButton2 ->show();
341 myLineEdit2 ->show();
342 myTextLabel3 ->show();
343 mySelectButton3 ->show();
344 myLineEdit3 ->show();
345 myGenerateButton3->show();
351 // Set text to the group of arguments and to all the labels
352 myGroupArguments->setTitle(tr("DUPLICATION_ONLY_ELEMS"));
353 myTextLabel1->setText(tr("GROUP_ELEMS_TO_DUPLICATE"));
356 myCheckBox1->setText( tr("CONSTRUCT_NEW_GROUP_ELEMENTS"));
359 // Hide the second and the third field
360 myTextLabel2 ->hide();
361 mySelectButton2 ->hide();
362 myLineEdit2 ->hide();
363 myTextLabel3 ->hide();
364 mySelectButton3 ->hide();
365 myLineEdit3 ->hide();
366 myGenerateButton3->hide();
372 // Set text to the group of arguments and to all the labels
373 myGroupArguments->setTitle(tr("DUPLICATION_GROUP_BOUNDARY"));
374 myTextLabel1->setText(tr("GROUP_VOLUME_GROUPS"));
378 myCheckBox1->setText( tr("CREATE_JOINT_ELEMENTS"));
379 myCheckBox2->setText( tr("ON_ALL_BOUNDARIES"));
381 // Hide the second and the third field
382 myTextLabel2 ->hide();
383 mySelectButton2 ->hide();
384 myLineEdit2 ->hide();
385 myTextLabel3 ->hide();
386 mySelectButton3 ->hide();
387 myLineEdit3 ->hide();
388 myGenerateButton3->hide();
393 myGroupArguments->hide();
394 myGroupArguments->show();
395 this->resize(this->sizeHint().width(), this->minimumSizeHint().height());
397 onSelectionChanged();
401 \brief SLOT called to apply changes.
403 bool SMESHGUI_DuplicateNodesDlg::onApply()
405 if ( SMESHGUI::isStudyLocked() || !isValid() )
408 BusyLocker lock( myBusy );
410 bool toCreateElemGroup = myCheckBox1->isChecked();
411 bool toCreateNodeGroup = myCheckBox2->isChecked();
412 int operationMode = myGroupConstructors->checkedId();
416 SUIT_OverrideCursor aWaitCursor;
417 QStringList anEntryList;
420 SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh();
421 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
423 switch ( operationMode ) {
426 SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
427 g1->length( myGroups1.count() );
428 for ( int i = 0; i < myGroups1.count(); i++ )
429 g1[i] = myGroups1[i];
430 SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
431 g2->length( myGroups3.count() );
432 for ( int i = 0; i < myGroups3.count(); i++ )
433 g2[i] = myGroups3[i];
435 if ( toCreateNodeGroup ) {
436 SMESH::SMESH_GroupBase_var aNewGroup =
437 aMeshEditor->DoubleNodeGroupsNew( g1.in(), g2.in() );
438 result = !CORBA::is_nil( aNewGroup );
441 result = aMeshEditor->DoubleNodeGroups( g1.in(), g2.in() );
447 SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
448 g1->length( myGroups1.count() );
449 for ( int i = 0; i < myGroups1.count(); i++ )
450 g1[i] = myGroups1[i];
451 SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
452 g2->length( myGroups2.count() );
453 for ( int i = 0; i < myGroups2.count(); i++ )
454 g2[i] = myGroups2[i];
455 SMESH::ListOfGroups_var g3 = new SMESH::ListOfGroups();
456 g3->length( myGroups3.count() );
458 for ( int i = 0; i < myGroups3.count(); i++ )
459 g3[i] = myGroups3[i];
460 if ( toCreateElemGroup || toCreateNodeGroup ) {
461 SMESH::ListOfGroups_var aNewGroups =
462 aMeshEditor->DoubleNodeElemGroups2New( g1.in(), g2.in(), g3.in(),
463 toCreateElemGroup, toCreateNodeGroup );
464 result = ( aNewGroups[ !toCreateElemGroup ].in() );
467 result = aMeshEditor->DoubleNodeElemGroups( g1.in(), g2.in(), g3.in() );
475 if ( toCreateElemGroup )
476 groupName = SMESH::UniqueName("DoubleElements");
477 for ( int i = 0; i < myGroups1.count(); i++ )
479 SMESH::SMESH_Group_var group =
480 aMeshEditor->DoubleElements( myGroups1[i], groupName.toUtf8().data() );
481 if ( group->_is_nil() )
483 if ( toCreateElemGroup )
488 if ( _PTR(SObject) so = SMESH::FindSObject( group ))
489 anEntryList.append( so->GetID().c_str() );
496 bool createJointElems = myCheckBox1->isChecked();
497 bool onAllBoundaries = myCheckBox2->isChecked();
499 SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
500 g1->length( myGroups1.count() );
501 for ( int i = 0; i < myGroups1.count(); i++ )
502 g1[i] = myGroups1[i];
504 result = aMeshEditor->DoubleNodesOnGroupBoundaries( g1.in(), createJointElems, onAllBoundaries );
508 } // switch( operationMode )
510 catch (const SALOME::SALOME_Exception& S_ex) {
511 SalomeApp_Tools::QtCatchCorbaException(S_ex);
513 catch ( const std::exception& exc ) {
514 INFOS( "Follow exception was caught:\n\t" << exc.what() );
517 INFOS( "Unknown exception was caught !!!" );
521 SUIT_MessageBox::warning(this,
522 tr("SMESH_WRN_WARNING"),
523 tr("SMESH_OPERATION_FAILED"));
528 mySelectionMgr->clearSelected();
530 SMESHGUI::Modified();
531 mySMESHGUI->updateObjBrowser(true);
533 if ( !anEntryList.isEmpty())
534 if( LightApp_Application* anApp =
535 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ))
536 anApp->browseObjects( anEntryList, true, false );
538 // Reinitialize the dialog
545 \brief SLOT called to apply changes and close the dialog.
547 void SMESHGUI_DuplicateNodesDlg::onOk()
554 \brief SLOT called to close the dialog.
556 void SMESHGUI_DuplicateNodesDlg::reject()
558 disconnect(mySelectionMgr, 0, this, 0);
559 disconnect(mySMESHGUI, 0, this, 0);
560 mySMESHGUI->ResetState();
561 mySelectionMgr->clearFilters();
566 \brief SLOT called when selection changed.
568 void SMESHGUI_DuplicateNodesDlg::onSelectionChanged()
570 if ( myBusy || !isEnabled() ) return;
572 int operationMode = myGroupConstructors->checkedId();
575 mySelectionMgr->selectedObjects( aList );
576 //int aNbSel = aList.Extent();
578 QList<SMESH::SMESH_GroupBase_var> aGroups;
580 SALOME_ListIteratorOfListIO anIter ( aList );
582 for ( ; anIter.More() && ok; anIter.Next()) {
583 SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>( anIter.Value() );
584 // check group is selected
585 ok = !CORBA::is_nil( aGroup );
586 // check groups of the same mesh are selected
588 SMESH::SMESH_Mesh_var aMesh1;
589 if ( !aGroups.isEmpty() ) aMesh1 = aGroups[0]->GetMesh();
590 SMESH::SMESH_Mesh_var aMesh2 = aGroup->GetMesh();
591 ok = CORBA::is_nil( aMesh1 ) || aMesh1->_is_equivalent( aMesh2 );
593 // check group of proper type is selected
595 SMESH::ElementType aGroupType = aGroup->GetType();
596 switch ( operationMode ) {
598 ok = ( myCurrentLineEdit == myLineEdit1 && aGroupType == SMESH::NODE ) ||
599 ( myCurrentLineEdit == myLineEdit2 && aGroupType != SMESH::NODE );
602 ok = ( myCurrentLineEdit == myLineEdit1 && ( aGroupType == SMESH::EDGE ||
603 aGroupType == SMESH::FACE ) ) ||
604 ( myCurrentLineEdit == myLineEdit2 && aGroupType == SMESH::NODE ) ||
605 ( myCurrentLineEdit == myLineEdit3 && aGroupType != SMESH::NODE );
608 ok = ( aGroupType != SMESH::NODE );
611 ok = ( aGroupType == SMESH::VOLUME ||
612 aGroupType == SMESH::FACE );
616 if ( ok ) aGroups << aGroup;
619 // Clear current field
620 myCurrentLineEdit->clear();
622 if ( ok && !aGroups.isEmpty() ) {
623 if ( myCurrentLineEdit == myLineEdit1 ) myGroups1 = aGroups;
624 else if ( myCurrentLineEdit == myLineEdit2 ) myGroups2 = aGroups;
625 else if ( myCurrentLineEdit == myLineEdit3 ) myGroups3 = aGroups;
626 CORBA::String_var name = aGroups[0]->GetName();
627 myCurrentLineEdit->setText( aGroups.count() == 1 ? QString(name).trimmed() :
628 QObject::tr( "SMESH_OBJECTS_SELECTED" ).arg( aGroups.count() ) );
631 if ( myCurrentLineEdit == myLineEdit1 ) myGroups1.clear();
632 else if ( myCurrentLineEdit == myLineEdit2 ) myGroups2.clear();
633 else if ( myCurrentLineEdit == myLineEdit3 ) myGroups3.clear();
634 myCurrentLineEdit->clear();
636 // Enable/disable "Apply and Close" and "Apply" buttons
641 * \brief Enable/disable "Apply and Close" and "Apply" buttons
643 void SMESHGUI_DuplicateNodesDlg::updateButtons()
645 bool isDataValid = isValid();
646 myButtonOk->setEnabled( isDataValid );
647 myButtonApply->setEnabled( isDataValid );
649 int operationMode = myGroupConstructors->checkedId();
650 myGenerateButton3->setEnabled( operationMode <= 1 && !myGroups1.empty() );
654 \brief SLOT called when selection button clicked.
656 void SMESHGUI_DuplicateNodesDlg::onEditCurrentArgument()
658 QPushButton* send = (QPushButton*)sender();
660 // Set current field for edition
661 if (send == mySelectButton1) {
662 myCurrentLineEdit = myLineEdit1;
664 else if (send == mySelectButton2) {
665 myCurrentLineEdit = myLineEdit2;
667 else if (send == mySelectButton3) {
668 myCurrentLineEdit = myLineEdit3;
671 myCurrentLineEdit->setFocus();
672 onSelectionChanged();
676 \brief Check if the input data is valid.
677 \return \c true if the data is valid
679 bool SMESHGUI_DuplicateNodesDlg::isValid()
681 switch( myGroupConstructors->checkedId() )
683 case 1: return ( !myGroups1.isEmpty() && !myGroups3.isEmpty() );
684 case 3: return ( myGroups1.count() > ( myCheckBox2->isChecked() ? 0 : 1 ));
685 default: return !myGroups1.isEmpty();
691 \brief SLOT called when dialog should be deactivated.
693 void SMESHGUI_DuplicateNodesDlg::onDeactivate()
696 mySelectionMgr->clearFilters();
698 mySMESHGUI->ResetState();
699 mySMESHGUI->SetActiveDialogBox(0);
704 \brief SLOT called when Generate button is clicked
706 void SMESHGUI_DuplicateNodesDlg::onGenerate()
708 if ( SMESHGUI::isStudyLocked() )
711 SUIT_OverrideCursor aWaitCursor;
712 BusyLocker lock( myBusy );
715 SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh();
716 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
718 SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
719 g1->length( myGroups1.count() );
720 for ( int i = 0; i < myGroups1.count(); i++ )
721 g1[i] = myGroups1[i];
722 SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
723 g2->length( myGroups2.count() );
724 for ( int i = 0; i < myGroups2.count(); i++ )
725 g2[i] = myGroups2[i];
727 SMESH::ListOfGroups_var newGroups =
728 aMeshEditor->AffectedElemGroupsInRegion( g1, g2, GEOM::GEOM_Object::_nil() );
731 switch ( newGroups->length() ) {
733 case 1: text = SMESH::toQStr( newGroups[0]->GetName() ); break;
734 default: text = tr( "SMESH_OBJECTS_SELECTED" ).arg( newGroups->length() );
736 myLineEdit3->setText( text );
739 for ( CORBA::ULong i = 0; i < newGroups->length(); ++i )
740 myGroups3 << SMESH::SMESH_GroupBase::_duplicate( newGroups[i] );
742 catch (const SALOME::SALOME_Exception& S_ex) {
743 SalomeApp_Tools::QtCatchCorbaException(S_ex);
745 catch ( const std::exception& exc ) {
746 INFOS( "Follow exception was caught:\n\t" << exc.what() );
749 INFOS( "Unknown exception was caught !!!" );
752 mySMESHGUI->updateObjBrowser(true);
757 \brief Receive dialog enter events.
758 Activates the dialog when the mouse cursor enters.
759 Reimplemented from QWidget class.
761 void SMESHGUI_DuplicateNodesDlg::enterEvent (QEvent*)
763 if ( !isEnabled() ) {
764 mySMESHGUI->EmitSignalDeactivateDialog();
766 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
768 // Set selection mode
769 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
770 aViewWindow->SetSelectionMode(ActorSelection);
771 mySelectionMgr->installFilter(new SMESH_TypeFilter (SMESH::GROUP));
776 \brief Receive key press events.
777 Reimplemented from QWidget class.
779 void SMESHGUI_DuplicateNodesDlg::keyPressEvent( QKeyEvent* e )
781 QDialog::keyPressEvent( e );
782 if ( e->isAccepted() )
785 if ( e->key() == Qt::Key_F1 ) {
792 \brief Show the dialog help page.
794 void SMESHGUI_DuplicateNodesDlg::onHelp()
796 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
798 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
802 platform = "winapplication";
804 platform = "application";
806 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
807 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
808 arg(app->resourceMgr()->stringValue("ExternalBrowser",
810 arg(myHelpFileName));