1 // Copyright (C) 2007-2020 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_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 theMesh->SetParameters( theParameters.join(":").toUtf8().constData() );
104 aNodeId = aMeshEditor->AddNode( x, y, z );
105 if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj( aSobj->GetID().c_str() ) ) {
106 aVisualObj->Update( true );
109 catch ( SALOME::SALOME_Exception& exc ) {
110 INFOS( "Follow exception was cought:\n\t" << exc.details.text );
112 catch ( const std::exception& exc ) {
113 INFOS( "Follow exception was cought:\n\t" << exc.what() );
116 INFOS( "Unknown exception was cought !!!" );
121 class TNodeSimulation
123 SVTK_ViewWindow* myViewWindow;
125 SALOME_Actor* myPreviewActor;
126 vtkDataSetMapper* myMapper;
130 TNodeSimulation( SVTK_ViewWindow* theViewWindow ):
131 myViewWindow( theViewWindow )
133 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
136 myPoints = vtkPoints::New();
137 myPoints->SetNumberOfPoints( 1 );
138 myPoints->SetPoint( 0, 0.0, 0.0, 0.0 );
141 vtkIdList *anIdList = vtkIdList::New();
142 anIdList->SetNumberOfIds( 1 );
144 vtkCellArray *aCells = vtkCellArray::New();
145 aCells->Allocate( 2, 0 );
147 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
148 aCellTypesArray->SetNumberOfComponents( 1 );
149 aCellTypesArray->Allocate( 1 );
151 anIdList->SetId( 0, 0 );
152 aCells->InsertNextCell( anIdList );
153 aCellTypesArray->InsertNextValue( VTK_VERTEX );
155 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
156 aCellLocationsArray->SetNumberOfComponents( 1 );
157 aCellLocationsArray->SetNumberOfTuples( 1 );
159 aCells->InitTraversal();
161 aCellLocationsArray->SetValue( 0, aCells->GetTraversalLocation( npts ) );
163 aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
165 aGrid->SetPoints( myPoints );
166 aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
167 aCellLocationsArray->Delete();
168 aCellTypesArray->Delete();
172 // Create and display actor
173 myMapper = vtkDataSetMapper::New();
174 myMapper->SetInputData( aGrid );
177 myPreviewActor = SALOME_Actor::New();
178 myPreviewActor->SetInfinitive( true );
179 myPreviewActor->VisibilityOff();
180 myPreviewActor->PickableOff();
181 myPreviewActor->SetMapper( myMapper );
183 vtkProperty* aProp = vtkProperty::New();
184 aProp->SetRepresentationToPoints();
187 GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
188 aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
190 double aPointSize = GetFloat( "SMESH:node_size", 3 );
191 aProp->SetPointSize( aPointSize );
193 myPreviewActor->SetProperty( aProp );
196 myViewWindow->AddActor( myPreviewActor );
199 void SetPosition( float x, float y, float z )
201 myPoints->SetPoint( 0, x, y, z );
202 myPoints->Modified();
203 SetVisibility( true );
206 void SetVisibility( bool theVisibility )
208 myPreviewActor->SetVisibility( theVisibility );
209 RepaintCurrentView();
214 myViewWindow->RemoveActor( myPreviewActor );
215 myPreviewActor->Delete();
217 myMapper->RemoveAllInputs();
225 //=================================================================================
226 // class : SMESHGUI_NodesDlg()
228 //=================================================================================
229 SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( SMESHGUI* theModule ):
230 QDialog( SMESH::GetDesktop( theModule ) ),
231 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
232 mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ),
233 mySMESHGUI( theModule )
236 setAttribute( Qt::WA_DeleteOnClose, true );
237 setWindowTitle( tr("MESH_NODE_TITLE") );
238 setSizeGripEnabled( true );
240 mySimulation = new SMESH::TNodeSimulation( SMESH::GetViewWindow( mySMESHGUI ) );
242 QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH",
243 tr( "ICON_DLG_NODE" ) ) );
245 QVBoxLayout* SMESHGUI_NodesDlgLayout = new QVBoxLayout( this );
246 SMESHGUI_NodesDlgLayout->setSpacing( SPACING );
247 SMESHGUI_NodesDlgLayout->setMargin( MARGIN );
249 /***************************************************************/
250 GroupConstructors = new QGroupBox( tr( "MESH_NODE" ), this );
251 QButtonGroup* ButtonGroup = new QButtonGroup(this);
252 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout( GroupConstructors );
253 GroupConstructorsLayout->setSpacing( SPACING );
254 GroupConstructorsLayout->setMargin( MARGIN );
256 Constructor1 = new QRadioButton( GroupConstructors );
257 Constructor1->setIcon( image0 );
258 Constructor1->setChecked( true );
260 GroupConstructorsLayout->addWidget( Constructor1 );
261 ButtonGroup->addButton( Constructor1, 0 );
263 /***************************************************************/
264 GroupCoordinates = new QGroupBox( tr( "SMESH_COORDINATES" ), this );
265 QHBoxLayout* GroupCoordinatesLayout = new QHBoxLayout(GroupCoordinates);
266 GroupCoordinatesLayout->setSpacing(SPACING);
267 GroupCoordinatesLayout->setMargin(MARGIN);
269 TextLabel_X = new QLabel( tr( "SMESH_X" ), GroupCoordinates );
270 SpinBox_X = new SMESHGUI_SpinBox( GroupCoordinates );
272 TextLabel_Y = new QLabel( tr( "SMESH_Y" ), GroupCoordinates );
273 SpinBox_Y = new SMESHGUI_SpinBox( GroupCoordinates );
275 TextLabel_Z = new QLabel( tr( "SMESH_Z" ), GroupCoordinates );
276 SpinBox_Z = new SMESHGUI_SpinBox( GroupCoordinates );
278 GroupCoordinatesLayout->addWidget( TextLabel_X );
279 GroupCoordinatesLayout->addWidget( SpinBox_X );
280 GroupCoordinatesLayout->addWidget( TextLabel_Y);
281 GroupCoordinatesLayout->addWidget( SpinBox_Y );
282 GroupCoordinatesLayout->addWidget( TextLabel_Z );
283 GroupCoordinatesLayout->addWidget( SpinBox_Z );
284 GroupCoordinatesLayout->setStretch(1, 1);
285 GroupCoordinatesLayout->setStretch(3, 1);
286 GroupCoordinatesLayout->setStretch(5, 1);
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 );
298 ComboBox_GroupName->setInsertPolicy( QComboBox::NoInsert );
300 GroupGroupsLayout->addWidget( TextLabel_GroupName );
301 GroupGroupsLayout->addWidget( ComboBox_GroupName, 1 );
303 /***************************************************************/
304 GroupButtons = new QGroupBox( this );
305 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
306 GroupButtonsLayout->setSpacing( SPACING );
307 GroupButtonsLayout->setMargin( MARGIN );
308 buttonOk = new QPushButton( tr( "SMESH_BUT_APPLY_AND_CLOSE" ), GroupButtons );
309 buttonOk->setAutoDefault( true );
310 buttonOk->setDefault( true );
311 buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons );
312 buttonApply->setAutoDefault( true );
313 buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons );
314 buttonCancel->setAutoDefault( true );
315 buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), GroupButtons );
316 buttonHelp->setAutoDefault( true );
318 GroupButtonsLayout->addWidget( buttonOk );
319 GroupButtonsLayout->addSpacing( 10 );
320 GroupButtonsLayout->addWidget( buttonApply );
321 GroupButtonsLayout->addSpacing( 10 );
322 GroupButtonsLayout->addStretch();
323 GroupButtonsLayout->addWidget( buttonCancel );
324 GroupButtonsLayout->addWidget( buttonHelp );
326 /***************************************************************/
327 SMESHGUI_NodesDlgLayout->addWidget( GroupConstructors );
328 SMESHGUI_NodesDlgLayout->addWidget( GroupCoordinates );
329 SMESHGUI_NodesDlgLayout->addWidget( GroupGroups );
330 SMESHGUI_NodesDlgLayout->addWidget( GroupButtons );
332 myHelpFileName = "adding_nodes_and_elements.html#adding-nodes-anchor";
334 /* Initialisation and display */
338 //=======================================================================
339 // function : ~SMESHGUI_NodesDlg()
340 // purpose : Destructor
341 //=======================================================================
342 SMESHGUI_NodesDlg::~SMESHGUI_NodesDlg()
347 //=================================================================================
350 //=================================================================================
351 void SMESHGUI_NodesDlg::Init()
353 /* Get setting of step value from file configuration */
356 /* min, max, step and decimals for spin boxes */
357 SpinBox_X->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, "length_precision" );
358 SpinBox_Y->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, "length_precision" );
359 SpinBox_Z->RangeStepAndValidator( COORD_MIN, COORD_MAX, step, "length_precision" );
360 SpinBox_X->SetValue( 0.0 );
361 SpinBox_Y->SetValue( 0.0 );
362 SpinBox_Z->SetValue( 0.0 );
364 /* reset "Add to group" control */
365 GroupGroups->setChecked( false );
367 mySMESHGUI->SetActiveDialogBox( this );
369 /* signals and slots connections */
370 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
371 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
372 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
373 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
375 connect( SpinBox_X, SIGNAL( valueChanged( double ) ), SLOT( ValueChangedInSpinBox( double ) ) );
376 connect( SpinBox_Y, SIGNAL( valueChanged( double ) ), SLOT( ValueChangedInSpinBox( double ) ) );
377 connect( SpinBox_Z, SIGNAL( valueChanged( double ) ), SLOT( ValueChangedInSpinBox( double ) ) );
379 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( SelectionIntoArgument() ) );
380 connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( DeactivateActiveDialog() ) );
381 /* to close dialog if study frame change */
382 connect( mySMESHGUI, SIGNAL( SignalStudyFrameChanged() ), SLOT( reject() ) );
383 connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( reject() ) );
384 connect( mySMESHGUI, SIGNAL( SignalActivatedViewManager() ), SLOT( onOpenView() ) );
385 connect( mySMESHGUI, SIGNAL( SignalCloseView() ), SLOT( onCloseView() ) );
386 // set selection mode
387 SMESH::SetPointRepresentation( true );
388 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
389 aViewWindow->SetSelectionMode( NodeSelection );
391 SelectionIntoArgument();
394 //=================================================================================
395 // function : ValueChangedInSpinBox()
397 //=================================================================================
398 void SMESHGUI_NodesDlg::ValueChangedInSpinBox( double /*newValue*/ )
400 if ( !myMesh->_is_nil() ) {
401 double vx = SpinBox_X->GetValue();
402 double vy = SpinBox_Y->GetValue();
403 double vz = SpinBox_Z->GetValue();
404 mySimulation->SetPosition( vx, vy, vz );
408 //=================================================================================
409 // function : ClickOnOk()
411 //=================================================================================
412 void SMESHGUI_NodesDlg::ClickOnOk()
414 if ( ClickOnApply() )
418 //=================================================================================
419 // function : ClickOnApply()
421 //=================================================================================
422 bool SMESHGUI_NodesDlg::ClickOnApply()
424 if ( SMESHGUI::isStudyLocked() )
427 if ( myMesh->_is_nil() ) {
428 SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ),
429 tr( "MESH_IS_NOT_SELECTED" ) );
436 /* Recup args and call method */
437 double x = SpinBox_X->GetValue();
438 double y = SpinBox_Y->GetValue();
439 double z = SpinBox_Z->GetValue();
441 QStringList aParameters;
442 aParameters << SpinBox_X->text();
443 aParameters << SpinBox_Y->text();
444 aParameters << SpinBox_Z->text();
446 bool addToGroup = GroupGroups->isChecked();
449 SMESH::SMESH_GroupBase_var aGroup;
452 aGroupName = ComboBox_GroupName->currentText();
453 for ( int i = 1; i <= ComboBox_GroupName->count(); i++ ) {
454 QString aName = ComboBox_GroupName->itemText( i );
455 if ( aGroupName == aName && ( i == ComboBox_GroupName->currentIndex() || idx == 0 ) )
458 if ( idx > 0 && idx <= myGroups.count() ) {
459 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] );
460 if ( !aGeomGroup->_is_nil() ) {
461 int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
462 tr( "MESH_STANDALONE_GRP_CHOSEN" ).arg( aGroupName ),
463 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
464 if ( res == 1 ) return false;
466 aGroup = myGroups[idx-1];
470 mySimulation->SetVisibility( false );
472 long aNodeId = SMESH::AddNode( myMesh, x, y, z, aParameters );
474 SMESH::SetPointRepresentation( true );
476 if ( aNodeId != -1 && addToGroup && !aGroupName.isEmpty() ) {
477 SMESH::SMESH_Group_var aGroupUsed;
478 if ( aGroup->_is_nil() ){
480 aGroupUsed = SMESH::AddGroup( myMesh, SMESH::NODE, aGroupName );
481 if ( !aGroupUsed->_is_nil() ) {
482 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroupUsed));
483 ComboBox_GroupName->addItem( aGroupName );
487 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup );
488 if ( !aGeomGroup->_is_nil() ) {
489 aGroupUsed = myMesh->ConvertToStandalone( aGeomGroup );
490 if ( !aGroupUsed->_is_nil() && idx > 0 ) {
491 myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed);
492 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
496 aGroupUsed = SMESH::SMESH_Group::_narrow( aGroup );
499 if ( !aGroupUsed->_is_nil() ) {
500 SMESH::long_array_var anIdList = new SMESH::long_array;
501 anIdList->length( 1 );
502 anIdList[0] = aNodeId;
503 aGroupUsed->Add( anIdList.inout() );
509 mySelectionMgr->selectedObjects( aList );
510 if ( aList.Extent() != 1 ) {
511 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() ) {
512 VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
513 vtkActorCollection *aCollection = aCopy.GetActors();
514 aCollection->InitTraversal();
515 while ( vtkActor *anAct = aCollection->GetNextActor() ) {
516 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) ) {
517 if ( anActor->hasIO() ) {
518 if ( SMESH_MeshObj *aMeshObj = dynamic_cast<SMESH_MeshObj*>( anActor->GetObject().get() ) ) {
519 if ( myMesh->_is_equivalent( aMeshObj->GetMeshServer() ) ) {
521 aList.Append( anActor->getIO() );
522 mySelectionMgr->setSelectedObjects( aList, false );
532 SMESHGUI::Modified();
534 mySimulation->SetVisibility(false);
539 //=================================================================================
540 // function : reject()
542 //=================================================================================
543 void SMESHGUI_NodesDlg::reject()
545 disconnect( mySelectionMgr, 0, this, 0 );
546 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
547 aViewWindow->SetSelectionMode( ActorSelection );
548 mySimulation->SetVisibility( false );
549 SMESH::SetPointRepresentation( false );
550 mySMESHGUI->ResetState();
555 //=================================================================================
556 // function : onOpenView()
558 //=================================================================================
559 void SMESHGUI_NodesDlg::onOpenView()
561 if ( mySelector && mySimulation ) {
562 mySimulation->SetVisibility(false);
563 SMESH::SetPointRepresentation(false);
566 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
567 mySelector = aViewWindow->GetSelector();
568 mySimulation = new SMESH::TNodeSimulation(aViewWindow);
569 ActivateThisDialog();
573 //=================================================================================
574 // function : onCloseView()
576 //=================================================================================
577 void SMESHGUI_NodesDlg::onCloseView()
579 DeactivateActiveDialog();
585 //=================================================================================
586 // function : ClickOnHelp()
588 //=================================================================================
589 void SMESHGUI_NodesDlg::ClickOnHelp()
591 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
593 app->onHelpContextModule( mySMESHGUI ? app->moduleName( mySMESHGUI->moduleName() ) :
594 QString( "" ), myHelpFileName );
598 platform = "winapplication";
600 platform = "application";
602 SUIT_MessageBox::warning( this, tr("WRN_WARNING"),
603 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
604 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
606 arg( myHelpFileName ) );
610 //=================================================================================
611 // function : SelectionIntoArgument()
612 // purpose : Called when selection as changed or other case
613 //=================================================================================
614 void SMESHGUI_NodesDlg::SelectionIntoArgument()
616 if ( !GroupConstructors->isEnabled() )
619 mySimulation->SetVisibility( false );
620 SMESH::SetPointRepresentation( true );
622 QString aCurrentEntry = myEntry;
624 const SALOME_ListIO& aList = mySelector->StoredIObjects();
625 if ( aList.Extent() == 1 ) {
626 Handle(SALOME_InteractiveObject) anIO = aList.First();
627 if ( anIO->hasEntry() ) {
628 myEntry = anIO->getEntry();
629 myMesh = SMESH::GetMeshByIO( anIO );
630 if ( myMesh->_is_nil() ) return;
632 if ( SMESH::GetNameOfSelectedNodes( mySelector, anIO, aText ) == 1 ) {
633 if ( SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh.in() ) ) {
634 if ( SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh() ) {
635 if ( const SMDS_MeshNode* aNode = aMesh->FindNode( aText.toInt() ) ) {
636 SpinBox_X->SetValue( aNode->X() );
637 SpinBox_Y->SetValue( aNode->Y() );
638 SpinBox_Z->SetValue( aNode->Z() );
643 mySimulation->SetPosition( SpinBox_X->GetValue(),
644 SpinBox_Y->GetValue(),
645 SpinBox_Z->GetValue() );
650 if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
652 ComboBox_GroupName->clear();
653 ComboBox_GroupName->addItem( QString() );
654 SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
655 for( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
656 SMESH::SMESH_GroupBase_var aGroup = aListOfGroups[i];
657 if ( !aGroup->_is_nil() && aGroup->GetType() == SMESH::NODE ) {
658 QString aGroupName( aGroup->GetName() );
659 if ( !aGroupName.isEmpty() ) {
660 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
661 ComboBox_GroupName->addItem( aGroupName );
668 //=================================================================================
669 // function : enterEvent()
670 // purpose : to reactivate this dialog box when mouse enter onto the window
671 //=================================================================================
672 void SMESHGUI_NodesDlg::enterEvent( QEvent* )
674 if ( !GroupConstructors->isEnabled() ) {
675 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
676 if ( aViewWindow && !mySelector && !mySimulation) {
677 mySelector = aViewWindow->GetSelector();
678 mySimulation = new SMESH::TNodeSimulation(aViewWindow);
680 ActivateThisDialog();
684 //=================================================================================
685 // function : DeactivateActiveDialog()
686 // purpose : public slot to deactivate if active
687 //=================================================================================
688 void SMESHGUI_NodesDlg::DeactivateActiveDialog()
690 if ( GroupConstructors->isEnabled() ) {
691 GroupConstructors->setEnabled( false );
692 GroupCoordinates->setEnabled( false );
693 GroupButtons->setEnabled( false );
694 mySimulation->SetVisibility( false );
695 mySMESHGUI->ResetState();
696 mySMESHGUI->SetActiveDialogBox( 0 );
700 //=================================================================================
701 // function : ActivateThisDialog()
703 //=================================================================================
704 void SMESHGUI_NodesDlg::ActivateThisDialog()
706 mySMESHGUI->EmitSignalDeactivateDialog();
707 GroupConstructors->setEnabled( true );
708 GroupCoordinates->setEnabled( true );
709 GroupButtons->setEnabled( true );
711 SMESH::SetPointRepresentation( true );
712 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
713 aViewWindow->SetSelectionMode( NodeSelection );
714 SelectionIntoArgument();
717 //=================================================================================
718 // function : keyPressEvent()
720 //=================================================================================
721 void SMESHGUI_NodesDlg::keyPressEvent( QKeyEvent* e )
723 QDialog::keyPressEvent( e );
724 if ( e->isAccepted() )
727 if ( e->key() == Qt::Key_F1 ) {
733 //=================================================================================
734 // function : isValid
736 //=================================================================================
737 bool SMESHGUI_NodesDlg::isValid()
741 ok = SpinBox_X->isValid( msg, true ) && ok;
742 ok = SpinBox_Y->isValid( msg, true ) && ok;
743 ok = SpinBox_Z->isValid( msg, true ) && ok;
746 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
747 if ( !msg.isEmpty() )
749 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
753 if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
754 SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );