1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VVTK_PickingDlg.cxx
21 // Author : Oleg Uvarov
24 #include "VVTK_PickingDlg.h"
26 #include "VISU_GaussPtsAct.h"
27 #include "VISU_GaussPtsSettings.h"
28 #include "VISU_GaussPointsPL.hxx"
30 #include "SUIT_MessageBox.h"
31 #include "SUIT_ResourceMgr.h"
32 #include "SUIT_Session.h"
34 #include "SVTK_Selector.h"
35 #include "SVTK_MainWindow.h"
36 #include "SVTK_RenderWindowInteractor.h"
38 #include "VTKViewer_Algorithm.h"
39 #include "SVTK_Functor.h"
41 #include <vtkActorCollection.h>
42 #include <vtkCallbackCommand.h>
43 #include <vtkObjectFactory.h>
44 #include <vtkRenderer.h>
45 #include <vtkGenericRenderWindowInteractor.h>
46 #include <vtkSmartPointer.h>
48 #include "utilities.h"
50 #include <qcheckbox.h>
51 #include <qcolordialog.h>
52 #include <qcombobox.h>
53 #include <qgroupbox.h>
56 #include <qpushbutton.h>
58 #include <qvalidator.h>
60 #include "QtxAction.h"
61 #include "QtxDblSpinBox.h"
62 #include "QtxIntSpinBox.h"
64 #include "LightApp_Application.h"
71 SelectorHelper( SVTK_RenderWindowInteractor* theInteractor ):
72 myInteractor( theInteractor )
87 mySelector = myInteractor->GetSelector();
91 const SALOME_ListIO& aListIO = mySelector->StoredIObjects();
92 if ( aListIO.Extent() != 1 )
95 myIO = aListIO.First();
96 if ( mySelector->HasIndex( myIO ) )
97 mySelector->GetIndex(myIO, myMapIndex);
99 myActor = SVTK::Find<VISU_GaussPtsAct>(myInteractor->getRenderer()->GetActors(),
100 SVTK::TIsSameIObject<VISU_GaussPtsAct>( myIO ));
104 myPipeLine = myActor->GetGaussPointsPL();
109 SVTK_RenderWindowInteractor* myInteractor;
110 TColStd_IndexedMapOfInteger myMapIndex;
111 Handle(SALOME_InteractiveObject) myIO;
112 SVTK_Selector* mySelector;
114 VISU_GaussPointsPL* myPipeLine;
115 VISU_GaussPtsAct* myActor;
120 class GaussPtsIDValidator: public QIntValidator
123 GaussPtsIDValidator( SVTK_RenderWindowInteractor* theInteractor,
124 QObject * theParent ):
125 QIntValidator( 0, VTK_LARGE_ID, theParent ),
126 myHelper(theInteractor)
131 validate ( QString & theInput, int & thePos ) const
133 if ( QIntValidator::validate( theInput, thePos ) == QValidator::Invalid)
134 return QValidator::Invalid;
136 if ( !myHelper.get() )
137 return QValidator::Invalid;
139 return QValidator::Acceptable;
143 mutable SelectorHelper myHelper;
147 class GaussCellIDValidator: public GaussPtsIDValidator
150 GaussCellIDValidator( QLineEdit* theLocalPointLabel,
151 SVTK_RenderWindowInteractor* theInteractor,
152 QObject * theParent ):
153 GaussPtsIDValidator( theInteractor, theParent ),
154 myLocalPointLineEdit( theLocalPointLabel )
159 validate ( QString & theInput, int & thePos ) const
161 if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
162 return QValidator::Invalid;
164 VISU::TCellID aCellID = theInput.toInt();
165 VISU::TLocalPntID aLocalPntID = myLocalPointLineEdit->text().toInt();
166 VISU::PGaussPtsIDMapper anIDMapper = myHelper.myPipeLine->GetGaussPtsIDMapper();
167 if ( anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) ) < 0 )
168 return QValidator::Intermediate;
170 return QValidator::Acceptable;
174 QLineEdit* myLocalPointLineEdit;
178 class GaussLocalPointIDValidator: public GaussPtsIDValidator
181 GaussLocalPointIDValidator( QLineEdit* theParentElementLineEdit,
182 SVTK_RenderWindowInteractor* theInteractor,
183 QObject * theParent ):
184 GaussPtsIDValidator( theInteractor, theParent ),
185 myParentElementLineEdit( theParentElementLineEdit )
190 validate ( QString & theInput, int & thePos ) const
192 if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
193 return QValidator::Invalid;
195 VISU::TLocalPntID aLocalPntID = theInput.toInt();
196 VISU::TCellID aCellID = myParentElementLineEdit->text().toInt();
197 VISU::PGaussPtsIDMapper anIDMapper = myHelper.myPipeLine->GetGaussPtsIDMapper();
198 if ( anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) ) < 0 )
199 return QValidator::Intermediate;
201 return QValidator::Acceptable;
205 QLineEdit* myParentElementLineEdit;
210 VVTK_ValidatedLineEdit::VVTK_ValidatedLineEdit( QWidget * parent, const char * name ):
211 QLineEdit( parent, name )
213 connect( this, SIGNAL( textChanged( const QString& ) ), this, SLOT( MarkValidated( const QString& ) ) );
216 void VVTK_ValidatedLineEdit::MarkValidated( const QString& theText )
222 QString aText( theText );
223 switch ( validator()->validate( aText, aPos ) ) {
224 case QValidator::Invalid:
225 case QValidator::Intermediate:
226 setPaletteForegroundColor( QColor( 255, 0, 0 ) );
228 case QValidator::Acceptable:
229 setPaletteForegroundColor( QColor( 0, 0, 0 ) );
234 //---------------------------------------------------------------------------------
236 VVTK_PickingDlg::VVTK_PickingDlg(QtxAction* theAction,
237 SVTK_MainWindow* theParent,
238 const char* theName):
239 SVTK_DialogBase(theAction,
242 myEventCallbackCommand( vtkCallbackCommand::New() ),
243 myPickingSettings( VISU_PickingSettings::New() )
246 myEventCallbackCommand->Delete();
247 myEventCallbackCommand->SetClientData(this);
248 myEventCallbackCommand->SetCallback(VVTK_PickingDlg::ProcessEvents);
250 setCaption( tr( "PICKING_DLG_TITLE" ) );
251 setSizeGripEnabled(TRUE);
253 QVBoxLayout* TopLayout = new QVBoxLayout( this );
254 TopLayout->setSpacing(6);
255 TopLayout->setMargin(11);
257 QVBox* aBox = new QVBox( this );
262 QGroupBox* CursorGroup = new QGroupBox( tr( "CURSOR_TITLE" ), aBox, "CursorGroup" );
263 CursorGroup->setColumnLayout(0, Qt::Vertical );
264 CursorGroup->layout()->setSpacing( 0 );
265 CursorGroup->layout()->setMargin( 0 );
267 QGridLayout* CursorGroupLayout = new QGridLayout (CursorGroup->layout());
268 CursorGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
269 CursorGroupLayout->setSpacing(6);
270 CursorGroupLayout->setMargin(11);
272 QLabel* CursorSizeLabel = new QLabel( tr( "CURSOR_SIZE" ), CursorGroup );
273 myCursorSizeSpinBox = new QtxDblSpinBox( 0, 1, 0.1, CursorGroup );
274 myCursorSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
276 QLabel* PyramidHeightLabel = new QLabel( tr( "PYRAMID_HEIGHT" ), CursorGroup );
277 double aHeightMin=1.e-7;
278 double aHeightMax=10.;
279 double aHeightStep=0.1;
280 myPyramidHeightSpinBox = new QtxDblSpinBox(aHeightMin, aHeightMax, aHeightStep, CursorGroup );
281 myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
283 QLabel* SelectionColorLabel = new QLabel( tr( "SELECTION_COLOR" ), CursorGroup );
284 mySelectionColorButton = new QPushButton( CursorGroup );
285 mySelectionColorButton->setPaletteBackgroundColor( Qt::blue );
286 mySelectionColorButton->setPaletteForegroundColor( Qt::blue );
287 connect( mySelectionColorButton, SIGNAL( clicked() ), this, SLOT( onColorButtonPressed() ) );
289 CursorGroupLayout->addWidget( CursorSizeLabel, 0, 0 );
290 CursorGroupLayout->addWidget( myCursorSizeSpinBox, 0, 1 );
291 CursorGroupLayout->addWidget( PyramidHeightLabel, 1, 0 );
292 CursorGroupLayout->addWidget( myPyramidHeightSpinBox, 1, 1 );
293 CursorGroupLayout->addWidget( SelectionColorLabel, 2, 0 );
294 CursorGroupLayout->addWidget( mySelectionColorButton, 2, 1 );
297 QGroupBox* ToleranceGroup = new QGroupBox( tr( "TOLERANCE_TITLE" ), aBox, "ToleranceGroup" );
298 ToleranceGroup->setColumnLayout(0, Qt::Vertical );
299 ToleranceGroup->layout()->setSpacing( 0 );
300 ToleranceGroup->layout()->setMargin( 0 );
302 QGridLayout* ToleranceGroupLayout = new QGridLayout (ToleranceGroup->layout());
303 ToleranceGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
304 ToleranceGroupLayout->setSpacing(6);
305 ToleranceGroupLayout->setMargin(11);
307 QLabel* PointToleranceLabel = new QLabel( tr( "POINT_TOLERANCE" ), ToleranceGroup );
308 myPointToleranceSpinBox = new QtxDblSpinBox( 0.001, 10.0, 0.01, ToleranceGroup );
309 myPointToleranceSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
311 ToleranceGroupLayout->addWidget( PointToleranceLabel, 0, 0 );
312 ToleranceGroupLayout->addWidget( myPointToleranceSpinBox, 0, 1 );
314 // Information window
315 QGroupBox* InfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), aBox, "InfoWindowGroup" );
316 InfoWindowGroup->setColumnLayout(0, Qt::Vertical );
317 InfoWindowGroup->layout()->setSpacing( 0 );
318 InfoWindowGroup->layout()->setMargin( 0 );
320 QGridLayout* InfoWindowGroupLayout = new QGridLayout (InfoWindowGroup->layout());
321 InfoWindowGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
322 InfoWindowGroupLayout->setSpacing(6);
323 InfoWindowGroupLayout->setMargin(11);
325 QLabel* TransparencyLabel = new QLabel( tr( "TRANSPARENCY" ), InfoWindowGroup );
326 myTransparencySpinBox = new QtxIntSpinBox( 0, 100, 10, InfoWindowGroup );
327 myTransparencySpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
329 InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 );
330 InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 );
332 QLabel* PositionLabel = new QLabel( tr( "POSITION" ), InfoWindowGroup );
333 myPositionComboBox = new QComboBox( InfoWindowGroup );
334 myPositionComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
336 myPositionComboBox->insertItem( tr( "BELOW_POINT" ) );
337 myPositionComboBox->insertItem( tr( "TOP_LEFT_CORNER" ) );
339 InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 );
340 InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 );
341 InfoWindowGroupLayout->addWidget( PositionLabel, 1, 0 );
342 InfoWindowGroupLayout->addWidget( myPositionComboBox, 1, 1 );
344 // Movement of the camera
345 QGroupBox* CameraGroup = new QGroupBox( tr( "CAMERA_TITLE" ), aBox, "CameraGroup" );
346 CameraGroup->setColumnLayout(0, Qt::Vertical );
347 CameraGroup->layout()->setSpacing( 0 );
348 CameraGroup->layout()->setMargin( 0 );
350 QGridLayout* CameraGroupLayout = new QGridLayout (CameraGroup->layout());
351 CameraGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
352 CameraGroupLayout->setSpacing(6);
353 CameraGroupLayout->setMargin(11);
355 QLabel* ZoomFactorLabel = new QLabel( tr( "ZOOM_FACTOR" ), CameraGroup );
356 myZoomFactorSpinBox = new QtxDblSpinBox( 0.1, 10.0, 0.1, CameraGroup );
357 myZoomFactorSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
359 QLabel* StepNumberLabel = new QLabel( tr( "STEP_NUMBER" ), CameraGroup );
360 myStepNumberSpinBox = new QtxIntSpinBox( 1, 100, 1, CameraGroup );
361 myStepNumberSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
363 CameraGroupLayout->addWidget( ZoomFactorLabel, 0, 0 );
364 CameraGroupLayout->addWidget( myZoomFactorSpinBox, 0, 1 );
365 CameraGroupLayout->addWidget( StepNumberLabel, 1, 0 );
366 CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 );
368 // Display parent mesh element
369 QGroupBox* PositionGroup = new QGroupBox( tr( "DATA_POSITION" ), aBox, "Position" );
370 PositionGroup->setColumnLayout(0, Qt::Vertical );
371 PositionGroup->layout()->setSpacing( 0 );
372 PositionGroup->layout()->setMargin( 0 );
374 QGridLayout* PositionGroupLayout = new QGridLayout (PositionGroup->layout());
375 PositionGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
376 PositionGroupLayout->setSpacing(6);
377 PositionGroupLayout->setMargin(11);
379 QLabel* ParentElementLabel = new QLabel( tr( "PARENT_ELEMENT" ), PositionGroup );
380 PositionGroupLayout->addMultiCellWidget( ParentElementLabel, 0, 0, 0, 2 );
382 myParentElementLineEdit = new VVTK_ValidatedLineEdit( PositionGroup );
383 PositionGroupLayout->addMultiCellWidget( myParentElementLineEdit, 0, 0, 3, 3 );
385 QLabel* LocalPointLabel = new QLabel( tr( "LOCAL_POINT" ), PositionGroup );
386 PositionGroupLayout->addMultiCellWidget( LocalPointLabel, 1, 1, 0, 2 );
388 myLocalPointLineEdit = new VVTK_ValidatedLineEdit( PositionGroup );
389 PositionGroupLayout->addMultiCellWidget( myLocalPointLineEdit, 1, 1, 3, 3 );
391 myDisplayParentMeshCheckBox = new QCheckBox( tr( "DISPLAY_PARENT_MESH" ), PositionGroup );
392 PositionGroupLayout->addMultiCellWidget( myDisplayParentMeshCheckBox, 2, 2, 0, 3 );
394 // Common buttons ===========================================================
395 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
396 GroupButtons->setColumnLayout(0, Qt::Vertical );
397 GroupButtons->layout()->setSpacing( 0 );
398 GroupButtons->layout()->setMargin( 0 );
399 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
400 GroupButtonsLayout->setAlignment( Qt::AlignTop );
401 GroupButtonsLayout->setSpacing( 6 );
402 GroupButtonsLayout->setMargin( 11 );
404 QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons, "buttonApply" );
405 buttonApply->setAutoDefault( TRUE );
406 buttonApply->setDefault( TRUE );
407 GroupButtonsLayout->addWidget( buttonApply, 0, 0 );
408 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
410 QPushButton* buttonClose = new QPushButton( tr( "&Close" ) , GroupButtons, "buttonClose" );
411 buttonClose->setAutoDefault( TRUE );
412 GroupButtonsLayout->addWidget( buttonClose, 0, 2 );
414 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
415 buttonHelp->setAutoDefault( TRUE );
416 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
418 TopLayout->addWidget( aBox );
419 TopLayout->addWidget( GroupButtons );
421 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onClickApply() ) );
422 connect( buttonClose, SIGNAL( clicked() ), this, SLOT( onClickClose() ) );
423 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onClickHelp() ) );
425 connect( myParentElementLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) );
426 connect( myLocalPointLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) );
430 VVTK_PickingDlg::~VVTK_PickingDlg()
434 void VVTK_PickingDlg::AddActor( VISU_GaussPtsAct* theActor )
436 theActor->SetPickingSettings( myPickingSettings.GetPointer() );
439 void VVTK_PickingDlg::RemoveActor( VISU_GaussPtsAct* theActor )
441 theActor->SetPickingSettings( NULL );
444 void VVTK_PickingDlg::Update()
446 float aCursorSize = 0.5;
447 float aPyramidHeight = 10.0;
448 float aPointTolerance = 0.1;
449 QColor aColor = Qt::yellow;
450 int anInfoWindowTransparency = 50;
451 int anInfoWindowPosition = VISU_PickingSettings::BelowPoint;
452 float aZoomFactor = 1.5;
453 int aStepNumber = 10;
454 bool aDisplayParentMesh = false;
456 if( !myPickingSettings->GetInitial() )
458 myCursorSizeSpinBox->setValue( myPickingSettings->GetCursorSize() );
459 myPyramidHeightSpinBox->setValue( myPickingSettings->GetPyramidHeight() );
460 myPointToleranceSpinBox->setValue( myPickingSettings->GetPointTolerance() );
461 myTransparencySpinBox->setValue( int(myPickingSettings->GetInfoWindowTransparency() * 100.0) );
462 myPositionComboBox->setCurrentItem( myPickingSettings->GetInfoWindowPosition() );
463 myZoomFactorSpinBox->setValue( myPickingSettings->GetZoomFactor() );
464 myStepNumberSpinBox->setValue( myPickingSettings->GetStepNumber() );
465 myDisplayParentMeshCheckBox->setChecked( myPickingSettings->GetDisplayParentMesh() );
467 vtkFloatingPointType* aColor = myPickingSettings->GetColor();
468 mySelectionColorButton->setPaletteBackgroundColor( QColor( ( int )( aColor[0] * 255.0 ),
469 ( int )( aColor[1] * 255.0 ),
470 ( int )( aColor[2] * 255.0 ) ) );
475 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
477 aCursorSize = aResourceMgr->doubleValue( "VISU", "picking_cursor_size", aCursorSize );
478 myCursorSizeSpinBox->setValue( aCursorSize );
480 aPyramidHeight = aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", aPyramidHeight );
481 myPyramidHeightSpinBox->setValue( aPyramidHeight );
483 aPointTolerance = aResourceMgr->doubleValue( "VISU", "picking_point_tolerance", aPointTolerance );
484 myPointToleranceSpinBox->setValue( aPointTolerance );
486 aColor = aResourceMgr->colorValue( "VISU", "picking_selection_color", aColor );
487 mySelectionColorButton->setPaletteBackgroundColor( aColor );
489 anInfoWindowTransparency = aResourceMgr->integerValue( "VISU", "picking_transparency", anInfoWindowTransparency );
490 myTransparencySpinBox->setValue( anInfoWindowTransparency );
492 anInfoWindowPosition = aResourceMgr->integerValue( "VISU", "picking_position", anInfoWindowPosition );
493 myPositionComboBox->setCurrentItem( anInfoWindowPosition );
495 aZoomFactor = aResourceMgr->doubleValue( "VISU", "picking_zoom_factor", aZoomFactor );
496 myZoomFactorSpinBox->setValue( aZoomFactor );
498 aStepNumber = aResourceMgr->integerValue( "VISU", "picking_step_number", aStepNumber );
499 myStepNumberSpinBox->setValue( aStepNumber );
501 aDisplayParentMesh = aResourceMgr->booleanValue( "VISU", "picking_display_parent_mesh", aDisplayParentMesh );
502 myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh );
507 void VVTK_PickingDlg::onSelectionValidate()
509 myParentElementLineEdit->MarkValidated( myParentElementLineEdit->text() );
510 myLocalPointLineEdit->MarkValidated( myLocalPointLineEdit->text() );
513 void VVTK_PickingDlg::onSelectionEvent()
515 SelectorHelper aHelper( myInteractor );
516 if ( !aHelper.get() )
519 const TColStd_IndexedMapOfInteger& aMapIndex = aHelper.myMapIndex;
520 if ( aMapIndex.Extent() != 1 )
523 int anObjId = aHelper.myMapIndex(1);
525 VISU::TGaussPointID aGaussPointID = aHelper.myPipeLine->GetObjID( anObjId );
527 VISU::TCellID aCellID = aGaussPointID.first;
528 myParentElementLineEdit->setText( QString::number( aCellID ) );
530 VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
531 myLocalPointLineEdit->setText( QString::number( aLocalPntID ) );
534 VISU_PickingSettings*
536 ::GetPickingSettings()
538 return myPickingSettings.GetPointer();
541 void VVTK_PickingDlg::SetInteractor( SVTK_RenderWindowInteractor* theInteractor )
543 myInteractor = theInteractor;
545 theInteractor->GetDevice()->AddObserver(vtkCommand::KeyPressEvent,
546 myEventCallbackCommand.GetPointer(),
548 theInteractor->GetDevice()->AddObserver(vtkCommand::EndPickEvent,
549 myEventCallbackCommand.GetPointer(),
552 QValidator* aValidator = new GaussCellIDValidator( myLocalPointLineEdit, theInteractor, myParentElementLineEdit );
553 myParentElementLineEdit->setValidator( aValidator );
556 QValidator* aValidator = new GaussLocalPointIDValidator( myParentElementLineEdit, theInteractor, myLocalPointLineEdit );
557 myLocalPointLineEdit->setValidator( aValidator );
561 void VVTK_PickingDlg::ProcessEvents(vtkObject* vtkNotUsed(theObject),
562 unsigned long theEvent,
564 void* vtkNotUsed(theCallData))
566 VVTK_PickingDlg* self = reinterpret_cast<VVTK_PickingDlg*>(theClientData);
569 case vtkCommand::KeyPressEvent:
572 case vtkCommand::EndPickEvent:
573 self->onSelectionEvent();
578 void VVTK_PickingDlg::KeyPressed()
580 if( myInteractor->GetDevice()->GetKeyCode() == 'P' )
582 bool aDisplayParentMesh = !myPickingSettings->GetDisplayParentMesh();
583 myPickingSettings->SetDisplayParentMesh( aDisplayParentMesh );
585 myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh );
587 myPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL);
591 void VVTK_PickingDlg::onClickApply()
593 myPickingSettings->SetInitial( false );
595 myPickingSettings->SetCursorSize( myCursorSizeSpinBox->value() );
596 myPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() );
597 myPickingSettings->SetPointTolerance( myPointToleranceSpinBox->value() );
598 myPickingSettings->SetInfoWindowTransparency( myTransparencySpinBox->value() / 100.0 );
599 myPickingSettings->SetInfoWindowPosition( myPositionComboBox->currentItem() );
600 myPickingSettings->SetZoomFactor( myZoomFactorSpinBox->value() );
601 myPickingSettings->SetStepNumber( myStepNumberSpinBox->value() );
602 myPickingSettings->SetDisplayParentMesh( myDisplayParentMeshCheckBox->isChecked() );
604 QColor aButtonColor = mySelectionColorButton->paletteBackgroundColor();
605 vtkFloatingPointType aColor[3];
606 aColor[0] = aButtonColor.red() / 255.0;
607 aColor[1] = aButtonColor.green() / 255.0;
608 aColor[2] = aButtonColor.blue() / 255.0;
609 myPickingSettings->SetColor( aColor );
611 myPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL );
613 SelectorHelper aHelper( myInteractor );
614 if ( !aHelper.get() )
617 VISU::TCellID aCellID = myParentElementLineEdit->text().toInt();
618 VISU::TLocalPntID aLocalPntID = myLocalPointLineEdit->text().toInt();
619 VISU::PGaussPtsIDMapper anIDMapper = aHelper.myPipeLine->GetGaussPtsIDMapper();
620 vtkIdType anObjId = anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) );
624 aHelper.myMapIndex.Clear();
625 aHelper.myMapIndex.Add( anObjId );
626 aHelper.mySelector->AddOrRemoveIndex( aHelper.myIO, aHelper.myMapIndex, false );
627 aHelper.myActor->Highlight( aHelper.myIO );
628 myInteractor->GetDevice()->CreateTimer( VTKI_TIMER_FIRST );
631 void VVTK_PickingDlg::onClickClose()
636 void VVTK_PickingDlg::onClickHelp()
638 QString aHelpFileName = "picking.htm";
639 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
641 app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
645 platform = "winapplication";
647 platform = "application";
649 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
650 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
651 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
652 QObject::tr("BUT_OK"));
656 void VVTK_PickingDlg::onColorButtonPressed()
658 QColor aColor = QColorDialog::getColor( mySelectionColorButton->paletteBackgroundColor(), this );
659 if( aColor.isValid() )
660 mySelectionColorButton->setPaletteBackgroundColor( aColor );
663 void VVTK_PickingDlg::keyPressEvent( QKeyEvent* e )
665 QDialog::keyPressEvent( e );
666 if ( e->isAccepted() )
669 if ( e->key() == Key_F1 )