]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fixed bug GVIEW10537 : selection cursor presentation
authorouv <ouv@opencascade.com>
Thu, 17 Nov 2005 09:31:33 +0000 (09:31 +0000)
committerouv <ouv@opencascade.com>
Thu, 17 Nov 2005 09:31:33 +0000 (09:31 +0000)
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsSettings.cxx
src/OBJECT/VISU_GaussPtsSettings.h
src/VISUGUI/VISUM_msg_en.po
src/VISUGUI/VisuGUI_Module.cxx
src/VVTK/VVTK_PickingDlg.cxx
src/VVTK/VVTK_PickingDlg.h
src/VVTK/VVTK_Renderer.cxx
src/VVTK/VVTK_Renderer.h

index c7c86a54178a8aef5b012af307ecb6b18eed8cfc..97f3c6f087bfbcfcb29e334d1992deefb26450c9 100644 (file)
@@ -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();
index f60ae626b7f99f9403853182ab0ff592c8cd6dde..85d1967732f7533401a7fb4067a9c92c468907ed 100644 (file)
@@ -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;
index 178cd51785657c4d76ded438ea6098ebe2658aba..1296cd6e8676902d9399d14693e6b64f542e5333 100644 (file)
@@ -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;
index aefad0c72611a631d069ad21f95ff160c681ab5c..5fc6576b3580e9b92256dd042b14627891f62df8 100644 (file)
@@ -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"
 
index 41b82b75b8792575f9b334dcb02f5d5fc13faf09..781347dd838b2b61123d75c952105ab5446905b7 100644 (file)
@@ -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 );
 
index ca0d7f09e3ccb3329c36f108ff0510b13ec2d43e..af0a00b7985b1ef8e04f414e4ca3dd3dac176310 100644 (file)
@@ -28,6 +28,7 @@
 #include "utilities.h"
 
 #include <qcheckbox.h>
+#include <qcolordialog.h>
 #include <qcombobox.h>
 #include <qgroupbox.h>
 #include <qlabel.h>
@@ -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 );
+}
index 7e8b375db940d859d47564a5142a13a5bdde9443..01ba29cd2e9c00adcd9d7dc1debdd81f146eae3f 100644 (file)
@@ -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;
index 596e9a19e0b9b1501234328973a7ce39202d4954..1502efa1cd81301b760b44c27f75a315d139989b 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <vtkObjectFactory.h>
 #include <vtkProperty.h>
+#include <vtkPointPicker.h>
 
 #include <vtkRenderWindowInteractor.h>
 #include <vtkCallbackCommand.h>
@@ -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() - "<<this);
 
@@ -157,6 +159,8 @@ VVTK_Renderer
   myFPSActor->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<VISU_GaussPtsAct*>(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<VISU_GaussPtsAct1*>(theActor)){
     anActor->SetPickingSettings(NULL);
+
+    anActor->SetPointPicker(NULL);
   }
-  Superclass::RemoveActor(theActor);
 }
 
 //----------------------------------------------------------------------------
index b23cb02666ae843af6a1879c9f745f7afc140078..bcfc31ac644386e70fcf8b43279f8cf5dc953229 100644 (file)
@@ -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<VISU_FPSActor> myFPSActor; //!< To show FPS of the rendering at run-time
+  vtkSmartPointer<vtkPointPicker> myGaussPointPicker;
 };