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_NodesDlg.cxx
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
28 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_SpinBox.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_GroupUtils.h"
37 #include <SMESH_Actor.h>
38 #include <SMESH_ActorUtils.h>
39 #include <SMESH_ObjectDef.h>
41 #include <SMDS_Mesh.hxx>
42 #include <SMDS_MeshNode.hxx>
44 // SALOME GUI includes
45 #include <SUIT_Session.h>
46 #include <SUIT_OverrideCursor.h>
47 #include <SUIT_MessageBox.h>
48 #include <SUIT_Desktop.h>
49 #include <SUIT_ResourceMgr.h>
51 #include <LightApp_Application.h>
52 #include <LightApp_SelectionMgr.h>
54 #include <SalomeApp_Application.h>
56 #include <SVTK_ViewWindow.h>
57 #include <VTKViewer_Algorithm.h>
58 #include <VTKViewer_CellLocationsArray.h>
60 // SALOME KERNEL includes
61 #include <SALOMEDS_Study.hxx>
62 #include <SALOMEDS_SObject.hxx>
64 #include <utilities.h>
67 #include <vtkIdList.h>
68 #include <vtkCellArray.h>
69 #include <vtkUnsignedCharArray.h>
70 #include <vtkUnstructuredGrid.h>
71 #include <vtkDataSetMapper.h>
72 #include <vtkRenderer.h>
73 #include <vtkProperty.h>
74 #include <vtkPoints.h>
80 #include <QPushButton>
81 #include <QRadioButton>
82 #include <QHBoxLayout>
83 #include <QVBoxLayout>
85 #include <QButtonGroup>
88 #include <SALOMEconfig.h>
89 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
96 long AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z, const QStringList& theParameters )
99 SUIT_OverrideCursor wc;
101 _PTR(SObject) aSobj = SMESH::FindSObject( theMesh );
102 SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
103 aNodeId = aMeshEditor->AddNode( x, y, z );
104 theMesh->SetParameters( theParameters.join(":").toLatin1().constData() );
105 _PTR(Study) aStudy = GetActiveStudyDocument();
106 CORBA::Long anId = aStudy->StudyId();
107 if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj( anId, aSobj->GetID().c_str() ) ) {
108 aVisualObj->Update( true );
111 catch ( SALOME::SALOME_Exception& exc ) {
112 INFOS( "Follow exception was cought:\n\t" << exc.details.text );
114 catch ( const std::exception& exc ) {
115 INFOS( "Follow exception was cought:\n\t" << exc.what() );
118 INFOS( "Unknown exception was cought !!!" );
123 class TNodeSimulation
125 SVTK_ViewWindow* myViewWindow;
127 SALOME_Actor* myPreviewActor;
128 vtkDataSetMapper* myMapper;
132 TNodeSimulation( SVTK_ViewWindow* theViewWindow ):
133 myViewWindow( theViewWindow )
135 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
138 myPoints = vtkPoints::New();
139 myPoints->SetNumberOfPoints( 1 );
140 myPoints->SetPoint( 0, 0.0, 0.0, 0.0 );
143 vtkIdList *anIdList = vtkIdList::New();
144 anIdList->SetNumberOfIds( 1 );
146 vtkCellArray *aCells = vtkCellArray::New();
147 aCells->Allocate( 2, 0 );
149 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
150 aCellTypesArray->SetNumberOfComponents( 1 );
151 aCellTypesArray->Allocate( 1 );
153 anIdList->SetId( 0, 0 );
154 aCells->InsertNextCell( anIdList );
155 aCellTypesArray->InsertNextValue( VTK_VERTEX );
157 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
158 aCellLocationsArray->SetNumberOfComponents( 1 );
159 aCellLocationsArray->SetNumberOfTuples( 1 );
161 aCells->InitTraversal();
163 aCellLocationsArray->SetValue( 0, aCells->GetTraversalLocation( npts ) );
165 aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
167 aGrid->SetPoints( myPoints );
168 aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
169 aCellLocationsArray->Delete();
170 aCellTypesArray->Delete();
174 // Create and display actor
175 myMapper = vtkDataSetMapper::New();
176 myMapper->SetInput( aGrid );
179 myPreviewActor = SALOME_Actor::New();
180 myPreviewActor->SetInfinitive( true );
181 myPreviewActor->VisibilityOff();
182 myPreviewActor->PickableOff();
183 myPreviewActor->SetMapper( myMapper );
185 vtkProperty* aProp = vtkProperty::New();
186 aProp->SetRepresentationToPoints();
188 vtkFloatingPointType anRGB[3];
189 GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
190 aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
192 vtkFloatingPointType aPointSize = GetFloat( "SMESH:node_size", 3 );
193 aProp->SetPointSize( aPointSize );
195 myPreviewActor->SetProperty( aProp );
198 myViewWindow->AddActor( myPreviewActor );
201 void SetPosition( float x, float y, float z )
203 myPoints->SetPoint( 0, x, y, z );
204 myPoints->Modified();
205 SetVisibility( true );
208 void SetVisibility( bool theVisibility )
210 myPreviewActor->SetVisibility( theVisibility );
211 RepaintCurrentView();
216 myViewWindow->RemoveActor( myPreviewActor );
217 myPreviewActor->Delete();
219 myMapper->RemoveAllInputs();
227 //=================================================================================
228 // class : SMESHGUI_NodesDlg()
230 //=================================================================================
231 SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( SMESHGUI* theModule ):
232 QDialog( SMESH::GetDesktop( theModule ) ),
233 mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ),
234 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
235 mySMESHGUI( theModule )
238 setAttribute( Qt::WA_DeleteOnClose, true );
239 setWindowTitle( tr("MESH_NODE_TITLE") );
240 setSizeGripEnabled( true );
242 mySimulation = new SMESH::TNodeSimulation( SMESH::GetViewWindow( mySMESHGUI ) );
244 QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH",
245 tr( "ICON_DLG_NODE" ) ) );
247 QVBoxLayout* SMESHGUI_NodesDlgLayout = new QVBoxLayout( this );
248 SMESHGUI_NodesDlgLayout->setSpacing( SPACING );
249 SMESHGUI_NodesDlgLayout->setMargin( MARGIN );
251 /***************************************************************/
252 GroupConstructors = new QGroupBox( tr( "MESH_NODE" ), this );
253 QButtonGroup* ButtonGroup = new QButtonGroup(this);
254 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout( GroupConstructors );
255 GroupConstructorsLayout->setSpacing( SPACING );
256 GroupConstructorsLayout->setMargin( MARGIN );
258 Constructor1 = new QRadioButton( GroupConstructors );
259 Constructor1->setIcon( image0 );
260 Constructor1->setChecked( true );
262 GroupConstructorsLayout->addWidget( Constructor1 );
263 ButtonGroup->addButton( Constructor1, 0 );
265 /***************************************************************/
266 GroupCoordinates = new QGroupBox( tr( "SMESH_COORDINATES" ), this );
267 QHBoxLayout* GroupCoordinatesLayout = new QHBoxLayout(GroupCoordinates);
268 GroupCoordinatesLayout->setSpacing(SPACING);
269 GroupCoordinatesLayout->setMargin(MARGIN);
271 TextLabel_X = new QLabel( tr( "SMESH_X" ), GroupCoordinates );
272 SpinBox_X = new SMESHGUI_SpinBox( GroupCoordinates );
274 TextLabel_Y = new QLabel( tr( "SMESH_Y" ), GroupCoordinates );
275 SpinBox_Y = new SMESHGUI_SpinBox( GroupCoordinates );
277 TextLabel_Z = new QLabel( tr( "SMESH_Z" ), GroupCoordinates );
278 SpinBox_Z = new SMESHGUI_SpinBox( GroupCoordinates );
280 GroupCoordinatesLayout->addWidget( TextLabel_X );
281 GroupCoordinatesLayout->addWidget( SpinBox_X );
282 GroupCoordinatesLayout->addWidget( TextLabel_Y);
283 GroupCoordinatesLayout->addWidget( SpinBox_Y );
284 GroupCoordinatesLayout->addWidget( TextLabel_Z );
285 GroupCoordinatesLayout->addWidget( SpinBox_Z );
288 /***************************************************************/
289 GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this );
290 GroupGroups->setCheckable( true );
291 QHBoxLayout* GroupGroupsLayout = new QHBoxLayout(GroupGroups);
292 GroupGroupsLayout->setSpacing(SPACING);
293 GroupGroupsLayout->setMargin(MARGIN);
295 TextLabel_GroupName = new QLabel( tr( "SMESH_GROUP" ), GroupGroups );
296 ComboBox_GroupName = new QComboBox( GroupGroups );
297 ComboBox_GroupName->setEditable( true );
299 GroupGroupsLayout->addWidget( TextLabel_GroupName );
300 GroupGroupsLayout->addWidget( ComboBox_GroupName, 1 );
302 /***************************************************************/
303 GroupButtons = new QGroupBox( this );
304 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
305 GroupButtonsLayout->setSpacing( SPACING );
306 GroupButtonsLayout->setMargin( MARGIN );
307 buttonOk = new QPushButton( tr( "SMESH_BUT_APPLY_AND_CLOSE" ), GroupButtons );
308 buttonOk->setAutoDefault( true );
309 buttonOk->setDefault( true );
310 buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons );
311 buttonApply->setAutoDefault( true );
312 buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons );
313 buttonCancel->setAutoDefault( true );
314 buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), GroupButtons );
315 buttonHelp->setAutoDefault( true );
317 GroupButtonsLayout->addWidget( buttonOk );
318 GroupButtonsLayout->addSpacing( 10 );
319 GroupButtonsLayout->addWidget( buttonApply );
320 GroupButtonsLayout->addSpacing( 10 );
321 GroupButtonsLayout->addStretch();
322 GroupButtonsLayout->addWidget( buttonCancel );
323 GroupButtonsLayout->addWidget( buttonHelp );
325 /***************************************************************/
326 SMESHGUI_NodesDlgLayout->addWidget( GroupConstructors );
327 SMESHGUI_NodesDlgLayout->addWidget( GroupCoordinates );
328 SMESHGUI_NodesDlgLayout->addWidget( GroupGroups );
329 SMESHGUI_NodesDlgLayout->addWidget( GroupButtons );
331 myHelpFileName = "adding_nodes_and_elements_page.html#adding_nodes_anchor";
333 /* Initialisation and display */
337 //=======================================================================
338 // function : ~SMESHGUI_NodesDlg()
339 // purpose : Destructor
340 //=======================================================================
341 SMESHGUI_NodesDlg::~SMESHGUI_NodesDlg()
346 //=================================================================================
349 //=================================================================================
350 void SMESHGUI_NodesDlg::Init()
352 /* Get setting of step value from file configuration */
355 /* min, max, step and decimals for spin boxes */
356 SpinBox_X->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, "length_precision" );
357 SpinBox_Y->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, "length_precision" );
358 SpinBox_Z->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, "length_precision" );
359 SpinBox_X->SetValue( 0.0 );
360 SpinBox_Y->SetValue( 0.0 );
361 SpinBox_Z->SetValue( 0.0 );
363 /* reset "Add to group" control */
364 GroupGroups->setChecked( false );
366 mySMESHGUI->SetActiveDialogBox( this );
368 /* signals and slots connections */
369 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
370 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
371 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
372 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
374 connect( SpinBox_X, SIGNAL( valueChanged( double ) ), SLOT( ValueChangedInSpinBox( double ) ) );
375 connect( SpinBox_Y, SIGNAL( valueChanged( double ) ), SLOT( ValueChangedInSpinBox( double ) ) );
376 connect( SpinBox_Z, SIGNAL( valueChanged( double ) ), SLOT( ValueChangedInSpinBox( double ) ) );
378 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( SelectionIntoArgument() ) );
379 connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( DeactivateActiveDialog() ) );
380 /* to close dialog if study frame change */
381 connect( mySMESHGUI, SIGNAL( SignalStudyFrameChanged() ), SLOT( ClickOnCancel() ) );
382 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnCancel()));
384 // set selection mode
385 SMESH::SetPointRepresentation( true );
386 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
387 aViewWindow->SetSelectionMode( NodeSelection );
389 SelectionIntoArgument();
392 //=================================================================================
393 // function : ValueChangedInSpinBox()
395 //=================================================================================
396 void SMESHGUI_NodesDlg::ValueChangedInSpinBox( double newValue )
398 if ( !myMesh->_is_nil() ) {
399 double vx = SpinBox_X->GetValue();
400 double vy = SpinBox_Y->GetValue();
401 double vz = SpinBox_Z->GetValue();
403 mySimulation->SetPosition( vx, vy, vz );
407 //=================================================================================
408 // function : ClickOnOk()
410 //=================================================================================
411 void SMESHGUI_NodesDlg::ClickOnOk()
413 if ( ClickOnApply() )
417 //=================================================================================
418 // function : ClickOnApply()
420 //=================================================================================
421 bool SMESHGUI_NodesDlg::ClickOnApply()
423 if ( mySMESHGUI->isActiveStudyLocked() )
426 if ( myMesh->_is_nil() ) {
427 SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ),
428 tr( "MESH_IS_NOT_SELECTED" ) );
435 /* Recup args and call method */
436 double x = SpinBox_X->GetValue();
437 double y = SpinBox_Y->GetValue();
438 double z = SpinBox_Z->GetValue();
440 QStringList aParameters;
441 aParameters << SpinBox_X->text();
442 aParameters << SpinBox_Y->text();
443 aParameters << SpinBox_Z->text();
445 bool addToGroup = GroupGroups->isChecked();
448 SMESH::SMESH_GroupBase_var aGroup;
451 aGroupName = ComboBox_GroupName->currentText();
452 for ( int i = 1; i < ComboBox_GroupName->count(); i++ ) {
453 QString aName = ComboBox_GroupName->itemText( i );
454 if ( aGroupName == aName && ( i == ComboBox_GroupName->currentIndex() || idx == 0 ) )
458 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] );
459 if ( !aGeomGroup->_is_nil() ) {
460 int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
461 tr( "MESH_STANDALONE_GRP_CHOSEN" ).arg( aGroupName ),
462 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
463 if ( res == 1 ) return false;
465 aGroup = myGroups[idx-1];
469 mySimulation->SetVisibility( false );
471 long aNodeId = SMESH::AddNode( myMesh, x, y, z, aParameters );
473 SMESH::SetPointRepresentation( true );
475 if ( aNodeId != -1 && addToGroup && !aGroupName.isEmpty() ) {
476 SMESH::SMESH_Group_var aGroupUsed;
477 if ( aGroup->_is_nil() ){
479 aGroupUsed = SMESH::AddGroup( myMesh, SMESH::NODE, aGroupName );
480 if ( !aGroupUsed->_is_nil() ) {
481 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroupUsed));
482 ComboBox_GroupName->addItem( aGroupName );
486 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup );
487 if ( !aGeomGroup->_is_nil() ) {
488 aGroupUsed = myMesh->ConvertToStandalone( aGeomGroup );
489 if ( !aGroupUsed->_is_nil() && idx > 0 ) {
490 myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed);
491 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
495 aGroupUsed = SMESH::SMESH_Group::_narrow( aGroup );
498 if ( !aGroupUsed->_is_nil() ) {
499 SMESH::long_array_var anIdList = new SMESH::long_array;
500 anIdList->length( 1 );
501 anIdList[0] = aNodeId;
502 aGroupUsed->Add( anIdList.inout() );
508 mySelectionMgr->selectedObjects( aList );
509 if ( aList.Extent() != 1 ) {
510 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() ) {
511 VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
512 vtkActorCollection *aCollection = aCopy.GetActors();
513 aCollection->InitTraversal();
514 while ( vtkActor *anAct = aCollection->GetNextActor() ) {
515 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) ) {
516 if ( anActor->hasIO() ) {
517 if ( SMESH_MeshObj *aMeshObj = dynamic_cast<SMESH_MeshObj*>( anActor->GetObject().get() ) ) {
518 if ( myMesh->_is_equivalent( aMeshObj->GetMeshServer() ) ) {
520 aList.Append( anActor->getIO() );
521 mySelectionMgr->setSelectedObjects( aList, false );
531 SMESHGUI::Modified();
533 mySimulation->SetVisibility(false);
538 //=================================================================================
539 // function : ClickOnCancel()
541 //=================================================================================
542 void SMESHGUI_NodesDlg::ClickOnCancel()
544 disconnect( mySelectionMgr, 0, this, 0 );
545 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
546 aViewWindow->SetSelectionMode( ActorSelection );
548 mySimulation->SetVisibility( false );
549 SMESH::SetPointRepresentation( false );
550 mySMESHGUI->ResetState();
555 //=================================================================================
556 // function : ClickOnHelp()
558 //=================================================================================
559 void SMESHGUI_NodesDlg::ClickOnHelp()
561 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
563 app->onHelpContextModule( mySMESHGUI ? app->moduleName( mySMESHGUI->moduleName() ) :
564 QString( "" ), myHelpFileName );
568 platform = "winapplication";
570 platform = "application";
572 SUIT_MessageBox::warning( this, tr("WRN_WARNING"),
573 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
574 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
576 arg( myHelpFileName ) );
580 //=================================================================================
581 // function : SelectionIntoArgument()
582 // purpose : Called when selection as changed or other case
583 //=================================================================================
584 void SMESHGUI_NodesDlg::SelectionIntoArgument()
586 if ( !GroupConstructors->isEnabled() )
589 mySimulation->SetVisibility( false );
590 SMESH::SetPointRepresentation( true );
592 QString aCurrentEntry = myEntry;
594 const SALOME_ListIO& aList = mySelector->StoredIObjects();
595 if ( aList.Extent() == 1 ) {
596 Handle(SALOME_InteractiveObject) anIO = aList.First();
597 if ( anIO->hasEntry() ) {
598 myEntry = anIO->getEntry();
599 myMesh = SMESH::GetMeshByIO( anIO );
600 if ( myMesh->_is_nil() ) return;
602 if ( SMESH::GetNameOfSelectedNodes( mySelector, anIO, aText ) == 1 ) {
603 if ( SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh.in() ) ) {
604 if ( SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh() ) {
605 if ( const SMDS_MeshNode* aNode = aMesh->FindNode( aText.toInt() ) ) {
606 SpinBox_X->SetValue( aNode->X() );
607 SpinBox_Y->SetValue( aNode->Y() );
608 SpinBox_Z->SetValue( aNode->Z() );
613 mySimulation->SetPosition( SpinBox_X->GetValue(),
614 SpinBox_Y->GetValue(),
615 SpinBox_Z->GetValue() );
620 if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
622 ComboBox_GroupName->clear();
623 ComboBox_GroupName->addItem( QString() );
624 SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
625 for( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
626 SMESH::SMESH_GroupBase_var aGroup = aListOfGroups[i];
627 if ( !aGroup->_is_nil() && aGroup->GetType() == SMESH::NODE ) {
628 QString aGroupName( aGroup->GetName() );
629 if ( !aGroupName.isEmpty() ) {
630 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
631 ComboBox_GroupName->addItem( aGroupName );
638 //=================================================================================
639 // function : closeEvent()
641 //=================================================================================
642 void SMESHGUI_NodesDlg::closeEvent( QCloseEvent* )
644 this->ClickOnCancel(); /* same than click on cancel button */
647 //=================================================================================
648 // function : hideEvent()
649 // purpose : caused by ESC key
650 //=================================================================================
651 void SMESHGUI_NodesDlg::hideEvent( QHideEvent* )
653 if ( !isMinimized() )
657 //=================================================================================
658 // function : enterEvent()
659 // purpose : to reactivate this dialog box when mouse enter onto the window
660 //=================================================================================
661 void SMESHGUI_NodesDlg::enterEvent( QEvent* )
663 if ( !GroupConstructors->isEnabled() )
664 ActivateThisDialog();
667 //=================================================================================
668 // function : DeactivateActiveDialog()
669 // purpose : public slot to deactivate if active
670 //=================================================================================
671 void SMESHGUI_NodesDlg::DeactivateActiveDialog()
673 if ( GroupConstructors->isEnabled() ) {
674 GroupConstructors->setEnabled( false );
675 GroupCoordinates->setEnabled( false );
676 GroupButtons->setEnabled( false );
677 mySimulation->SetVisibility( false );
678 mySMESHGUI->ResetState();
679 mySMESHGUI->SetActiveDialogBox( 0 );
683 //=================================================================================
684 // function : ActivateThisDialog()
686 //=================================================================================
687 void SMESHGUI_NodesDlg::ActivateThisDialog()
689 mySMESHGUI->EmitSignalDeactivateDialog();
690 GroupConstructors->setEnabled( true );
691 GroupCoordinates->setEnabled( true );
692 GroupButtons->setEnabled( true );
694 SMESH::SetPointRepresentation( true );
695 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
696 aViewWindow->SetSelectionMode( NodeSelection );
698 SelectionIntoArgument();
701 //=================================================================================
702 // function : keyPressEvent()
704 //=================================================================================
705 void SMESHGUI_NodesDlg::keyPressEvent( QKeyEvent* e )
707 QDialog::keyPressEvent( e );
708 if ( e->isAccepted() )
711 if ( e->key() == Qt::Key_F1 ) {
717 //=================================================================================
718 // function : isValid
720 //=================================================================================
721 bool SMESHGUI_NodesDlg::isValid()
725 ok = SpinBox_X->isValid( msg, true ) && ok;
726 ok = SpinBox_Y->isValid( msg, true ) && ok;
727 ok = SpinBox_Z->isValid( msg, true ) && ok;
730 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
731 if ( !msg.isEmpty() )
733 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
737 if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
738 SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );