From 274215dc43724fefcfe03e679e6e1d983a05b5db Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 17 Nov 2005 09:31:33 +0000 Subject: [PATCH] Fixed bug GVIEW10537 : selection cursor presentation --- src/OBJECT/VISU_GaussPtsAct.cxx | 21 ++++++++--- src/OBJECT/VISU_GaussPtsSettings.cxx | 4 ++ src/OBJECT/VISU_GaussPtsSettings.h | 8 ++++ src/VISUGUI/VISUM_msg_en.po | 18 +++++++++ src/VISUGUI/VisuGUI_Module.cxx | 18 +++++++++ src/VVTK/VVTK_PickingDlg.cxx | 56 ++++++++++++++++++++++++++++ src/VVTK/VVTK_PickingDlg.h | 5 +++ src/VVTK/VVTK_Renderer.cxx | 14 +++++-- src/VVTK/VVTK_Renderer.h | 2 + 9 files changed, 138 insertions(+), 8 deletions(-) diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index c7c86a54..97f3c6f0 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -539,10 +539,16 @@ bool VISU_GaussPtsAct::PreHighlight(vtkInteractorStyle* theInteractorStyle, float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray); float aPyramidHeight = myPickingSettings->GetPyramidHeight(); aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); + //float aColor[3] = myPreHighlightActor->GetProperty()->GetColor(); + float aColor[3]; + theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor ); + aColor[0] = 1. - aColor[0]; + aColor[1] = 1. - aColor[1]; + aColor[2] = 1. - aColor[2]; myCursorPyramid->Init(aPyramidHeight, aRadius, aNodeCoord, - myPreHighlightActor->GetProperty()->GetColor()); + aColor); } myLastObjPointID = anObjId; } @@ -820,23 +826,28 @@ VISU_GaussPtsAct myPickingSettings = thePickingSettings; if(thePickingSettings) + { thePickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, myEventCallbackCommand.GetPointer(), myPriority); + this->UpdatePickingSettings(); + } } void VISU_GaussPtsAct ::UpdatePickingSettings() { - // Update picking parameters using myPickingSettings object myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition()); myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency()); - float aHeight= - myGaussPointsPL->GetMaxPointSize()*myPickingSettings->GetPyramidHeight(); + + float aHeight = myGaussPointsPL->GetMaxPointSize()*myPickingSettings->GetPyramidHeight(); myCursorPyramid->SetHeight(aHeight); myCursorPyramidSelected->SetHeight(aHeight); - // + + myHighlightActor->GetProperty()->SetColor( myPickingSettings->GetColor() ); + myPointPicker->SetTolerance( myPickingSettings->GetPointTolerance() ); + Highlight(isHighlighted()); Update(); diff --git a/src/OBJECT/VISU_GaussPtsSettings.cxx b/src/OBJECT/VISU_GaussPtsSettings.cxx index f60ae626..85d19677 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.cxx +++ b/src/OBJECT/VISU_GaussPtsSettings.cxx @@ -60,6 +60,10 @@ VISU_PickingSettings::VISU_PickingSettings() this->Initial = true; this->PyramidHeight = -1; + this->PointTolerance = -1; + this->Color[0] = -1; + this->Color[1] = -1; + this->Color[1] = -1; this->InfoWindowTransparency = -1; this->InfoWindowPosition = -1; this->ZoomFactor = -1; diff --git a/src/OBJECT/VISU_GaussPtsSettings.h b/src/OBJECT/VISU_GaussPtsSettings.h index 178cd517..1296cd6e 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.h +++ b/src/OBJECT/VISU_GaussPtsSettings.h @@ -118,6 +118,12 @@ class VISU_PickingSettings : public vtkObject vtkSetMacro( PyramidHeight, float ); vtkGetMacro( PyramidHeight, float ); + vtkSetVector3Macro( Color, float ); + vtkGetVector3Macro( Color, float ); + + vtkSetMacro( PointTolerance, float ); + vtkGetMacro( PointTolerance, float ); + vtkSetMacro( InfoWindowTransparency, float ); vtkGetMacro( InfoWindowTransparency, float ); @@ -137,6 +143,8 @@ private: bool Initial; float PyramidHeight; + float PointTolerance; + float Color[3]; float InfoWindowTransparency; int InfoWindowPosition; float ZoomFactor; diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po index aefad0c7..5fc6576b 100644 --- a/src/VISUGUI/VISUM_msg_en.po +++ b/src/VISUGUI/VISUM_msg_en.po @@ -106,6 +106,15 @@ msgstr "Cursor" msgid "VisuGUI_Module::VISU_PICKING_PREF_PYRAMID_HEIGHT" msgstr "Height of the pyramids" +msgid "VisuGUI_Module::VISU_PICKING_PREF_SELECTION_COLOR" +msgstr "Selection cursor color" + +msgid "VisuGUI_Module::VISU_PICKING_PREF_TOLERANCE_GROUP_TTL" +msgstr "Tolerance" + +msgid "VisuGUI_Module::VISU_PICKING_PREF_POINT_SELECTION_TOLERANCE" +msgstr "Point selection tolerance" + msgid "VisuGUI_Module::VISU_PICKING_PREF_INFO_WINDOW_GROUP_TTL" msgstr "Information window" @@ -481,6 +490,15 @@ msgstr "Cursor" msgid "VVTK_PickingDlg::PYRAMID_HEIGHT" msgstr "Height of the pyramids :" +msgid "VVTK_PickingDlg::SELECTION_COLOR" +msgstr "Selection cursor color :" + +msgid "VVTK_PickingDlg::TOLERANCE_TITLE" +msgstr "Tolerance" + +msgid "VVTK_PickingDlg::POINT_TOLERANCE" +msgstr "Point tolerance :" + msgid "VVTK_PickingDlg::INFO_WINDOW_TITLE" msgstr "Information window" diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 41b82b75..781347dd 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -509,12 +509,28 @@ VisuGUI_Module { int pickingTab = addPreference( tr( "VISU_PICKING_PREF_TAB_TTL" ) ); + // Cursor int cursorGr = addPreference( tr( "VISU_PICKING_PREF_CURSOR_GROUP_TTL" ), pickingTab ); + setPreferenceProperty( cursorGr, "columns", 1 ); + int pyramidHeightPref = addPreference( tr( "VISU_PICKING_PREF_PYRAMID_HEIGHT" ), cursorGr, SalomeApp_Preferences::DblSpin, "VISU", "picking_pyramid_height" ); setPreferenceProperty( pyramidHeightPref, "min", 1 ); setPreferenceProperty( pyramidHeightPref, "max", 100 ); + int selectionColorPref = addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr, + SalomeApp_Preferences::Color, "VISU", "picking_selection_color" ); + + // Tolerance + int toleranceGr = addPreference( tr( "VISU_PICKING_PREF_TOLERANCE_GROUP_TTL" ), pickingTab ); + + int pointTolerancePref = addPreference( tr( "VISU_PICKING_PREF_POINT_SELECTION_TOLERANCE" ), toleranceGr, + SalomeApp_Preferences::DblSpin, "VISU", "picking_point_tolerance" ); + setPreferenceProperty( pointTolerancePref, "min", 0.001 ); + setPreferenceProperty( pointTolerancePref, "max", 10 ); + setPreferenceProperty( pointTolerancePref, "step", 0.01 ); + + // Info window int infoWindowGr = addPreference( tr( "VISU_PICKING_PREF_INFO_WINDOW_GROUP_TTL" ), pickingTab ); setPreferenceProperty( infoWindowGr, "columns", 1 ); @@ -535,6 +551,7 @@ VisuGUI_Module setPreferenceProperty( positionPref, "strings", values ); setPreferenceProperty( positionPref, "indexes", indices ); + // Camera int cameraGr = addPreference( tr( "VISU_PICKING_PREF_CAMERA_GROUP_TTL" ), pickingTab ); setPreferenceProperty( cameraGr, "columns", 1 ); @@ -549,6 +566,7 @@ VisuGUI_Module setPreferenceProperty( stepNumberPref, "min", 1 ); setPreferenceProperty( stepNumberPref, "max", 100 ); + // Display parent mesh int parentMeshGr = addPreference( tr( "VISU_PICKING_PREF_PARENT_MESH_TTL" ), pickingTab ); setPreferenceProperty( parentMeshGr, "columns", 1 ); diff --git a/src/VVTK/VVTK_PickingDlg.cxx b/src/VVTK/VVTK_PickingDlg.cxx index ca0d7f09..af0a00b7 100644 --- a/src/VVTK/VVTK_PickingDlg.cxx +++ b/src/VVTK/VVTK_PickingDlg.cxx @@ -28,6 +28,7 @@ #include "utilities.h" #include +#include #include #include #include @@ -79,8 +80,34 @@ VVTK_PickingDlg::VVTK_PickingDlg( QWidget* parent, const char* name ) myPyramidHeightSpinBox = new QtxDblSpinBox( 1.0, 100.0, 1.0, CursorGroup ); myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + QLabel* SelectionColorLabel = new QLabel( tr( "SELECTION_COLOR" ), CursorGroup ); + mySelectionColorButton = new QPushButton( CursorGroup ); + mySelectionColorButton->setPaletteBackgroundColor( Qt::blue ); + mySelectionColorButton->setPaletteForegroundColor( Qt::blue ); + connect( mySelectionColorButton, SIGNAL( clicked() ), this, SLOT( onColorButtonPressed() ) ); + CursorGroupLayout->addWidget( PyramidHeightLabel, 0, 0 ); CursorGroupLayout->addWidget( myPyramidHeightSpinBox, 0, 1 ); + CursorGroupLayout->addWidget( SelectionColorLabel, 1, 0 ); + CursorGroupLayout->addWidget( mySelectionColorButton, 1, 1 ); + + // Tolerance + QGroupBox* ToleranceGroup = new QGroupBox( tr( "TOLERANCE_TITLE" ), aBox, "ToleranceGroup" ); + ToleranceGroup->setColumnLayout(0, Qt::Vertical ); + ToleranceGroup->layout()->setSpacing( 0 ); + ToleranceGroup->layout()->setMargin( 0 ); + + QGridLayout* ToleranceGroupLayout = new QGridLayout (ToleranceGroup->layout()); + ToleranceGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + ToleranceGroupLayout->setSpacing(6); + ToleranceGroupLayout->setMargin(11); + + QLabel* PointToleranceLabel = new QLabel( tr( "POINT_TOLERANCE" ), ToleranceGroup ); + myPointToleranceSpinBox = new QtxDblSpinBox( 0.001, 10.0, 0.01, ToleranceGroup ); + myPointToleranceSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + ToleranceGroupLayout->addWidget( PointToleranceLabel, 0, 0 ); + ToleranceGroupLayout->addWidget( myPointToleranceSpinBox, 0, 1 ); // Information window QGroupBox* InfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), aBox, "InfoWindowGroup" ); @@ -194,6 +221,8 @@ void VVTK_PickingDlg::RemoveActor( VISU_GaussPtsAct* theActor ) void VVTK_PickingDlg::Update() { float aPyramidHeight = 10.0; + float aPointTolerance = 0.1; + QColor aColor = Qt::yellow; int anInfoWindowTransparency = 50; int anInfoWindowPosition = VISU_PickingSettings::BelowPoint; float aZoomFactor = 1.5; @@ -203,12 +232,18 @@ void VVTK_PickingDlg::Update() if( !myPickingSettings->GetInitial() ) { myPyramidHeightSpinBox->setValue( myPickingSettings->GetPyramidHeight() ); + myPointToleranceSpinBox->setValue( myPickingSettings->GetPointTolerance() ); myTransparencySpinBox->setValue( myPickingSettings->GetInfoWindowTransparency() * 100.0 ); myPositionComboBox->setCurrentItem( myPickingSettings->GetInfoWindowPosition() ); myZoomFactorSpinBox->setValue( myPickingSettings->GetZoomFactor() ); myStepNumberSpinBox->setValue( myPickingSettings->GetStepNumber() ); myDisplayParentMeshCheckBox->setChecked( myPickingSettings->GetDisplayParentMesh() ); + float* aColor = myPickingSettings->GetColor(); + mySelectionColorButton->setPaletteBackgroundColor( QColor( ( int )( aColor[0] * 255.0 ), + ( int )( aColor[1] * 255.0 ), + ( int )( aColor[2] * 255.0 ) ) ); + return; } @@ -217,6 +252,12 @@ void VVTK_PickingDlg::Update() aPyramidHeight = aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", aPyramidHeight ); myPyramidHeightSpinBox->setValue( aPyramidHeight ); + aPointTolerance = aResourceMgr->doubleValue( "VISU", "picking_point_tolerance", aPointTolerance ); + myPointToleranceSpinBox->setValue( aPointTolerance ); + + aColor = aResourceMgr->colorValue( "VISU", "picking_selection_color", aColor ); + mySelectionColorButton->setPaletteBackgroundColor( aColor ); + anInfoWindowTransparency = aResourceMgr->integerValue( "VISU", "picking_transparency", anInfoWindowTransparency ); myTransparencySpinBox->setValue( anInfoWindowTransparency ); @@ -285,12 +326,20 @@ void VVTK_PickingDlg::onClickApply() myPickingSettings->SetInitial( false ); myPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() ); + myPickingSettings->SetPointTolerance( myPointToleranceSpinBox->value() ); myPickingSettings->SetInfoWindowTransparency( myTransparencySpinBox->value() / 100.0 ); myPickingSettings->SetInfoWindowPosition( myPositionComboBox->currentItem() ); myPickingSettings->SetZoomFactor( myZoomFactorSpinBox->value() ); myPickingSettings->SetStepNumber( myStepNumberSpinBox->value() ); myPickingSettings->SetDisplayParentMesh( myDisplayParentMeshCheckBox->isChecked() ); + QColor aButtonColor = mySelectionColorButton->paletteBackgroundColor(); + float aColor[3]; + aColor[0] = aButtonColor.red() / 255.0; + aColor[1] = aButtonColor.green() / 255.0; + aColor[2] = aButtonColor.blue() / 255.0; + myPickingSettings->SetColor( aColor ); + myPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL); } @@ -305,3 +354,10 @@ void VVTK_PickingDlg::done( int r ) myAction->setOn( false ); QDialog::done( r ); } + +void VVTK_PickingDlg::onColorButtonPressed() +{ + QColor aColor = QColorDialog::getColor( mySelectionColorButton->paletteBackgroundColor(), this ); + if( aColor.isValid() ) + mySelectionColorButton->setPaletteBackgroundColor( aColor ); +} diff --git a/src/VVTK/VVTK_PickingDlg.h b/src/VVTK/VVTK_PickingDlg.h index 7e8b375d..01ba29cd 100644 --- a/src/VVTK/VVTK_PickingDlg.h +++ b/src/VVTK/VVTK_PickingDlg.h @@ -23,6 +23,7 @@ class vtkImageData; class QLabel; class QComboBox; class QCheckBox; +class QPushButton; class QtxAction; class QtxDblSpinBox; @@ -66,6 +67,8 @@ protected slots: void onClickApply(); void onClickClose(); + void onColorButtonPressed(); + private: static void ProcessEvents(vtkObject* theObject, unsigned long theEvent, @@ -76,6 +79,8 @@ private: private: QtxDblSpinBox* myPyramidHeightSpinBox; + QPushButton* mySelectionColorButton; + QtxDblSpinBox* myPointToleranceSpinBox; QtxIntSpinBox* myTransparencySpinBox; QComboBox* myPositionComboBox; QtxDblSpinBox* myZoomFactorSpinBox; diff --git a/src/VVTK/VVTK_Renderer.cxx b/src/VVTK/VVTK_Renderer.cxx index 596e9a19..1502efa1 100644 --- a/src/VVTK/VVTK_Renderer.cxx +++ b/src/VVTK/VVTK_Renderer.cxx @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -138,7 +139,8 @@ vtkStandardNewMacro(VVTK_Renderer); VVTK_Renderer ::VVTK_Renderer(): myFPSActor(VISU_FPSActor::New()), - myPickingSettings(NULL) + myPickingSettings(NULL), + myGaussPointPicker(vtkPointPicker::New()) { if(MYDEBUG) INFOS("VVTK_Renderer() - "<SetMapper(aTextMapper); aTextMapper->Delete(); + myGaussPointPicker->Delete(); + GetDevice()->AddActor2D(myFPSActor.GetPointer()); } @@ -171,10 +175,12 @@ void VVTK_Renderer ::AddActor(VTKViewer_Actor* theActor) { + Superclass::AddActor(theActor); if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)){ anActor->SetPickingSettings(myPickingSettings); + + anActor->SetPointPicker(myGaussPointPicker.GetPointer()); } - Superclass::AddActor(theActor); } //---------------------------------------------------------------------------- @@ -182,11 +188,13 @@ void VVTK_Renderer ::RemoveActor(VTKViewer_Actor* theActor) { + Superclass::RemoveActor(theActor); using namespace VISU; if(VISU_GaussPtsAct1* anActor = dynamic_cast(theActor)){ anActor->SetPickingSettings(NULL); + + anActor->SetPointPicker(NULL); } - Superclass::RemoveActor(theActor); } //---------------------------------------------------------------------------- diff --git a/src/VVTK/VVTK_Renderer.h b/src/VVTK/VVTK_Renderer.h index b23cb026..bcfc31ac 100644 --- a/src/VVTK/VVTK_Renderer.h +++ b/src/VVTK/VVTK_Renderer.h @@ -38,6 +38,7 @@ class VISU_OutsideCursorSettings; class VISU_PickingSettings; class VISU_FPSActor; +class vtkPointPicker; class vtkImplicitFunction; //---------------------------------------------------------------------------- @@ -71,6 +72,7 @@ class VVTK_EXPORT VVTK_Renderer : public SVTK_Renderer VISU_PickingSettings* myPickingSettings; //! Keeps reference of the VISU_PickingSettings vtkSmartPointer myFPSActor; //!< To show FPS of the rendering at run-time + vtkSmartPointer myGaussPointPicker; }; -- 2.39.2