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;
}
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();
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;
vtkSetMacro( PyramidHeight, float );
vtkGetMacro( PyramidHeight, float );
+ vtkSetVector3Macro( Color, float );
+ vtkGetVector3Macro( Color, float );
+
+ vtkSetMacro( PointTolerance, float );
+ vtkGetMacro( PointTolerance, float );
+
vtkSetMacro( InfoWindowTransparency, float );
vtkGetMacro( InfoWindowTransparency, float );
bool Initial;
float PyramidHeight;
+ float PointTolerance;
+ float Color[3];
float InfoWindowTransparency;
int InfoWindowPosition;
float ZoomFactor;
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"
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"
{
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 );
setPreferenceProperty( positionPref, "strings", values );
setPreferenceProperty( positionPref, "indexes", indices );
+ // Camera
int cameraGr = addPreference( tr( "VISU_PICKING_PREF_CAMERA_GROUP_TTL" ), pickingTab );
setPreferenceProperty( cameraGr, "columns", 1 );
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 );
#include "utilities.h"
#include <qcheckbox.h>
+#include <qcolordialog.h>
#include <qcombobox.h>
#include <qgroupbox.h>
#include <qlabel.h>
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" );
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;
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;
}
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 );
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);
}
myAction->setOn( false );
QDialog::done( r );
}
+
+void VVTK_PickingDlg::onColorButtonPressed()
+{
+ QColor aColor = QColorDialog::getColor( mySelectionColorButton->paletteBackgroundColor(), this );
+ if( aColor.isValid() )
+ mySelectionColorButton->setPaletteBackgroundColor( aColor );
+}
class QLabel;
class QComboBox;
class QCheckBox;
+class QPushButton;
class QtxAction;
class QtxDblSpinBox;
void onClickApply();
void onClickClose();
+ void onColorButtonPressed();
+
private:
static void ProcessEvents(vtkObject* theObject,
unsigned long theEvent,
private:
QtxDblSpinBox* myPyramidHeightSpinBox;
+ QPushButton* mySelectionColorButton;
+ QtxDblSpinBox* myPointToleranceSpinBox;
QtxIntSpinBox* myTransparencySpinBox;
QComboBox* myPositionComboBox;
QtxDblSpinBox* myZoomFactorSpinBox;
#include <vtkObjectFactory.h>
#include <vtkProperty.h>
+#include <vtkPointPicker.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCallbackCommand.h>
VVTK_Renderer
::VVTK_Renderer():
myFPSActor(VISU_FPSActor::New()),
- myPickingSettings(NULL)
+ myPickingSettings(NULL),
+ myGaussPointPicker(vtkPointPicker::New())
{
if(MYDEBUG) INFOS("VVTK_Renderer() - "<<this);
myFPSActor->SetMapper(aTextMapper);
aTextMapper->Delete();
+ myGaussPointPicker->Delete();
+
GetDevice()->AddActor2D(myFPSActor.GetPointer());
}
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);
}
//----------------------------------------------------------------------------
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);
}
//----------------------------------------------------------------------------
class VISU_PickingSettings;
class VISU_FPSActor;
+class vtkPointPicker;
class vtkImplicitFunction;
//----------------------------------------------------------------------------
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;
};