From: ouv Date: Tue, 4 Oct 2005 13:47:58 +0000 (+0000) Subject: Picking settings dialog X-Git-Tag: BR-D5-38-2003_D2005-12-10~70 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dc547c89e74b1370e4d90732d188d4ea7852ef8f;p=modules%2Fvisu.git Picking settings dialog --- diff --git a/src/VVTK/Makefile.in b/src/VVTK/Makefile.in index 0e1e27d5..1516f7dc 100755 --- a/src/VVTK/Makefile.in +++ b/src/VVTK/Makefile.in @@ -17,6 +17,7 @@ EXPORT_HEADERS = \ VVTK_ViewManager.h \ VVTK_ViewModel.h \ VVTK_InteractorStyle.h \ + VVTK_PickingDlg.h \ VVTK_SegmentationCursorDlg.h \ VVTK_ViewWindow.h \ VVTK_MainWindow.h @@ -28,6 +29,7 @@ LIB_SRC = \ VVTK_ViewManager.cxx \ VVTK_ViewModel.cxx \ VVTK_InteractorStyle.cxx \ + VVTK_PickingDlg.cxx \ VVTK_SegmentationCursorDlg.cxx \ VVTK_ViewWindow.cxx \ VVTK_Renderer.cxx \ @@ -37,6 +39,7 @@ LIB_MOC = \ VVTK_ViewWindow.h \ VVTK_ViewModel.h \ VVTK_ViewManager.h \ + VVTK_PickingDlg.h \ VVTK_SegmentationCursorDlg.h \ VVTK_MainWindow.h diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index 6591795f..1feda1dd 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -33,6 +33,7 @@ #include "SVTK_RenderWindowInteractor.h" #include "VVTK_Renderer.h" +#include "VVTK_PickingDlg.h" #include "VVTK_SegmentationCursorDlg.h" #include "SUIT_ResourceMgr.h" @@ -150,6 +151,9 @@ VVTK_MainWindow1 connect(anAction, SIGNAL(toggled(bool)), this, SLOT(OnSelectionModeSwitch(bool))); anAction->addTo( myPtsToolBar ); + myPickingDlg = new VVTK_PickingDlg( this, "PickingDlg" ); + myPickingDlg->SetAction( anAction ); + aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_PLANE_SEGMENTATION_SWITCH")); anAction = new QtxAction(tr("MNU_VVTK_PLANE_SEGMENTATION_SWITCH"), aPixmap, @@ -193,7 +197,25 @@ VVTK_MainWindow1 theName, theResourceMgr, this, - myStyleSwitchAction); + myStyleSwitchAction, + myPickingDlg); +} + + +//---------------------------------------------------------------------------- +void +VVTK_MainWindow1 +::OnSelectionModeSwitch(bool theIsSelectionOn) +{ + VVTK_MainWindow::OnSelectionModeSwitch(theIsSelectionOn); + + if( theIsSelectionOn ) + { + myPickingDlg->Update(); + myPickingDlg->show(); + } + else + myPickingDlg->hide(); } @@ -203,8 +225,11 @@ VVTK_MainWindow1 ::AddActor(VTKViewer_Actor* theActor, bool theIsUpdate) { - if(VISU_GaussPtsAct1* anActor = dynamic_cast(theActor)) - mySegmentationCursorDlg->AddActor( anActor ); + if(VISU_GaussPtsAct1* anActor1 = dynamic_cast(theActor)) + mySegmentationCursorDlg->AddActor( anActor1 ); + + if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) + myPickingDlg->AddActor( anActor ); SVTK_MainWindow::AddActor( theActor, theIsUpdate ); } @@ -215,8 +240,11 @@ VVTK_MainWindow1 ::RemoveActor(VTKViewer_Actor* theActor, bool theIsUpdate) { - if(VISU_GaussPtsAct1* anActor = dynamic_cast(theActor)) - mySegmentationCursorDlg->RemoveActor( anActor ); + if(VISU_GaussPtsAct1* anActor1 = dynamic_cast(theActor)) + mySegmentationCursorDlg->RemoveActor( anActor1 ); + + if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) + myPickingDlg->RemoveActor( anActor ); SVTK_MainWindow::RemoveActor( theActor, theIsUpdate ); } @@ -268,9 +296,11 @@ VVTK_MainWindow2 const char* theName, SUIT_ResourceMgr* theResourceMgr, VVTK_MainWindow1* theMainWindow, - QtxAction* theStyleSwitchAction): + QtxAction* theStyleSwitchAction, + VVTK_PickingDlg* thePickingDlg): VVTK_MainWindow(theParent,theName,theResourceMgr), - myMainWindow(theMainWindow) + myMainWindow(theMainWindow), + myPickingDlg(thePickingDlg) { connect(theStyleSwitchAction, SIGNAL(toggled(bool)), this, SLOT(OnInteractorStyleSwitch(bool))); } @@ -290,6 +320,30 @@ VVTK_MainWindow2 ::~VVTK_MainWindow2() {} +//---------------------------------------------------------------------------- +void +VVTK_MainWindow2 +::AddActor(VTKViewer_Actor* theActor, + bool theIsUpdate) +{ + if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) + myPickingDlg->AddActor( anActor ); + + SVTK_MainWindow::AddActor( theActor, theIsUpdate ); +} + +//---------------------------------------------------------------------------- +void +VVTK_MainWindow2 +::RemoveActor(VTKViewer_Actor* theActor, + bool theIsUpdate) +{ + if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) + myPickingDlg->RemoveActor( anActor ); + + SVTK_MainWindow::RemoveActor( theActor, theIsUpdate ); +} + //---------------------------------------------------------------------------- QSize VVTK_MainWindow2 diff --git a/src/VVTK/VVTK_MainWindow.h b/src/VVTK/VVTK_MainWindow.h index bc9e4009..5c2f0329 100644 --- a/src/VVTK/VVTK_MainWindow.h +++ b/src/VVTK/VVTK_MainWindow.h @@ -10,6 +10,7 @@ class QSplitter; +class VVTK_PickingDlg; class VVTK_SegmentationCursorDlg; class VVTK_MainWindow2; class VVTK_Renderer1; @@ -32,8 +33,13 @@ public: ~VVTK_MainWindow(); public slots: - void OnInteractorStyleSwitch(bool theIsGaussStyleOn); - void OnSelectionModeSwitch(bool theIsSelectionOn); + virtual + void + OnInteractorStyleSwitch(bool theIsGaussStyleOn); + + virtual + void + OnSelectionModeSwitch(bool theIsSelectionOn); virtual void @@ -85,7 +91,12 @@ public: sizeHint() const; public slots: - void OnPlaneSegmentationSwitch(bool theIsPlaneSegmentationOn); + void + OnPlaneSegmentationSwitch(bool theIsPlaneSegmentationOn); + + virtual + void + OnSelectionModeSwitch(bool theIsSelectionOn); protected: VVTK_Renderer1* myRenderer; @@ -94,6 +105,7 @@ public: QToolBar* myPtsToolBar; QSplitter* mySplitter; + VVTK_PickingDlg* myPickingDlg; VVTK_SegmentationCursorDlg* mySegmentationCursorDlg; }; @@ -109,7 +121,8 @@ class VVTK_EXPORT VVTK_MainWindow2: public VVTK_MainWindow const char* theName, SUIT_ResourceMgr* theResourceMgr, VVTK_MainWindow1* theMainWindow, - QtxAction* theStyleSwitchAction); + QtxAction* theStyleSwitchAction, + VVTK_PickingDlg* thePickingDlg); public: virtual void @@ -119,6 +132,16 @@ public: virtual ~VVTK_MainWindow2(); + virtual + void + AddActor(VTKViewer_Actor* theActor, + bool theIsUpdate = false); + + virtual + void + RemoveActor(VTKViewer_Actor* theActor, + bool theIsUpdate = false); + virtual QSize sizeHint() const; @@ -126,6 +149,8 @@ public: protected: VVTK_MainWindow1* myMainWindow; VVTK_Renderer2* myRenderer; + + VVTK_PickingDlg* myPickingDlg; }; diff --git a/src/VVTK/VVTK_PickingDlg.cxx b/src/VVTK/VVTK_PickingDlg.cxx new file mode 100644 index 00000000..9a901e23 --- /dev/null +++ b/src/VVTK/VVTK_PickingDlg.cxx @@ -0,0 +1,233 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VVTK_PickingDlg.cxx +// Author : Oleg Uvarov +// Module : VISU + +#include "VVTK_PickingDlg.h" + +#include "VISU_GaussPtsAct.h" + +#include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" + +#include +#include +#include +#include +#include +#include + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include + +#include "QtxAction.h" +#include "QtxDblSpinBox.h" +#include "QtxIntSpinBox.h" + +using namespace std; + +VVTK_PickingDlg::VVTK_PickingDlg( QWidget* parent, const char* name ) + :QDialog( parent, name, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + myPickingSettings( VISU_PickingSettings::New() ) +{ + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + + setCaption( tr( "PICKING_DLG_TITLE" ) ); + setSizeGripEnabled(TRUE); + + QVBoxLayout* TopLayout = new QVBoxLayout( this ); + TopLayout->setSpacing(6); + TopLayout->setMargin(11); + + QVBox* aBox = new QVBox( this ); + aBox->setMargin(0); + aBox->setSpacing(6); + + // Cursor + QGroupBox* CursorGroup = new QGroupBox( tr( "CURSOR_TITLE" ), aBox, "CursorGroup" ); + CursorGroup->setColumnLayout(0, Qt::Vertical ); + CursorGroup->layout()->setSpacing( 0 ); + CursorGroup->layout()->setMargin( 0 ); + + QGridLayout* CursorGroupLayout = new QGridLayout (CursorGroup->layout()); + CursorGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + CursorGroupLayout->setSpacing(6); + CursorGroupLayout->setMargin(11); + + QLabel* PyramidHeightLabel = new QLabel( tr( "PYRAMID_HEIGHT" ), CursorGroup ); + myPyramidHeightSpinBox = new QtxDblSpinBox( 1.0, 100.0, 1.0, CursorGroup ); + myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + CursorGroupLayout->addWidget( PyramidHeightLabel, 0, 0 ); + CursorGroupLayout->addWidget( myPyramidHeightSpinBox, 0, 1 ); + + // Information window + QGroupBox* InfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), aBox, "InfoWindowGroup" ); + InfoWindowGroup->setColumnLayout(0, Qt::Vertical ); + InfoWindowGroup->layout()->setSpacing( 0 ); + InfoWindowGroup->layout()->setMargin( 0 ); + + QGridLayout* InfoWindowGroupLayout = new QGridLayout (InfoWindowGroup->layout()); + InfoWindowGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + InfoWindowGroupLayout->setSpacing(6); + InfoWindowGroupLayout->setMargin(11); + + QLabel* TransparencyLabel = new QLabel( tr( "TRANSPARENCY" ), InfoWindowGroup ); + myTransparencySpinBox = new QtxDblSpinBox( 0.0, 1.0, 0.1, InfoWindowGroup ); + myTransparencySpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); + InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); + + QLabel* PositionLabel = new QLabel( tr( "POSITION" ), InfoWindowGroup ); + myPositionComboBox = new QComboBox( InfoWindowGroup ); + myPositionComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myPositionComboBox->insertItem( tr( "BELOW_POINT" ) ); + myPositionComboBox->insertItem( tr( "TOP_LEFT_CORNER" ) ); + + InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); + InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); + InfoWindowGroupLayout->addWidget( PositionLabel, 0, 2 ); + InfoWindowGroupLayout->addWidget( myPositionComboBox, 0, 3 ); + + // Movement of the camera + QGroupBox* CameraGroup = new QGroupBox( tr( "CAMERA_TITLE" ), aBox, "CameraGroup" ); + CameraGroup->setColumnLayout(0, Qt::Vertical ); + CameraGroup->layout()->setSpacing( 0 ); + CameraGroup->layout()->setMargin( 0 ); + + QGridLayout* CameraGroupLayout = new QGridLayout (CameraGroup->layout()); + CameraGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + CameraGroupLayout->setSpacing(6); + CameraGroupLayout->setMargin(11); + + QLabel* ZoomFactorLabel = new QLabel( tr( "ZOOM_FACTOR" ), CameraGroup ); + myZoomFactorSpinBox = new QtxDblSpinBox( 0.1, 10.0, 0.1, CameraGroup ); + myZoomFactorSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + QLabel* StepNumberLabel = new QLabel( tr( "STEP_NUMBER" ), CameraGroup ); + myStepNumberSpinBox = new QtxIntSpinBox( 1, 100, 1, CameraGroup ); + myStepNumberSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + CameraGroupLayout->addWidget( ZoomFactorLabel, 0, 0 ); + CameraGroupLayout->addWidget( myZoomFactorSpinBox, 0, 1 ); + CameraGroupLayout->addWidget( StepNumberLabel, 1, 0 ); + CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 ); + + + // Common buttons =========================================================== + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons, "buttonApply" ); + buttonApply->setAutoDefault( TRUE ); + buttonApply->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* buttonClose = new QPushButton( tr( "&Close" ) , GroupButtons, "buttonClose" ); + buttonClose->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonClose, 0, 2 ); + + TopLayout->addWidget( aBox ); + TopLayout->addWidget( GroupButtons ); + + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onClickApply() ) ); + connect( buttonClose, SIGNAL( clicked() ), this, SLOT( onClickClose() ) ); +} + +VVTK_PickingDlg::~VVTK_PickingDlg() +{ +} + +void VVTK_PickingDlg::AddActor( VISU_GaussPtsAct* theActor ) +{ + theActor->SetPickingSettings( myPickingSettings.GetPointer() ); +} + +void VVTK_PickingDlg::RemoveActor( VISU_GaussPtsAct* theActor ) +{ + theActor->SetPickingSettings( NULL ); +} + +void VVTK_PickingDlg::Update() +{ + float aPyramidHeight = 10.0; + float anInfoWindowTransparency = 0.5; + int anInfoWindowPosition = VISU_PickingSettings::BelowPoint; + float aZoomFactor = 1.5; + int aStepNumber = 10; + + if( !myPickingSettings->GetInitial() ) + { + myPyramidHeightSpinBox->setValue( myPickingSettings->GetPyramidHeight() ); + myTransparencySpinBox->setValue( myPickingSettings->GetInfoWindowTransparency() ); + myPositionComboBox->setCurrentItem( myPickingSettings->GetInfoWindowPosition() ); + myZoomFactorSpinBox->setValue( myPickingSettings->GetZoomFactor() ); + myStepNumberSpinBox->setValue( myPickingSettings->GetStepNumber() ); + + return; + } + + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + + aPyramidHeight = aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", aPyramidHeight ); + myPyramidHeightSpinBox->setValue( aPyramidHeight ); + + anInfoWindowTransparency = aResourceMgr->doubleValue( "VISU", "picking_transparency", anInfoWindowTransparency ); + myTransparencySpinBox->setValue( anInfoWindowTransparency ); + + anInfoWindowPosition = aResourceMgr->integerValue( "VISU", "picking_position", anInfoWindowPosition ); + myPositionComboBox->setCurrentItem( anInfoWindowPosition ); + + aZoomFactor = aResourceMgr->doubleValue( "VISU", "picking_zoom_factor", aZoomFactor ); + myZoomFactorSpinBox->setValue( aZoomFactor ); + + aStepNumber = aResourceMgr->integerValue( "VISU", "picking_step_number", aStepNumber ); + myStepNumberSpinBox->setValue( aStepNumber ); + + onClickApply(); +} + +void VVTK_PickingDlg::onClickApply() +{ + myPickingSettings->SetInitial( false ); + + myPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() ); + myPickingSettings->SetInfoWindowTransparency( myTransparencySpinBox->value() ); + myPickingSettings->SetInfoWindowPosition( myPositionComboBox->currentItem() ); + myPickingSettings->SetZoomFactor( myZoomFactorSpinBox->value() ); + myPickingSettings->SetStepNumber( myStepNumberSpinBox->value() ); + + myPickingSettings->InvokeEvent(vtkCommand::ModifiedEvent,NULL); +} + +void VVTK_PickingDlg::onClickClose() +{ + myAction->setOn( false ); + + reject(); +} + +void VVTK_PickingDlg::closeEvent( QCloseEvent* ) +{ + myAction->setOn( false ); +} diff --git a/src/VVTK/VVTK_PickingDlg.h b/src/VVTK/VVTK_PickingDlg.h new file mode 100644 index 00000000..74dae19e --- /dev/null +++ b/src/VVTK/VVTK_PickingDlg.h @@ -0,0 +1,66 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VVTK_PickingDlg.h +// Author : Oleg Uvarov +// Module : VISU + +#ifndef VVTK_PICKINGDLG_H +#define VVTK_PICKINGDLG_H + +#include + +#include +#include + +class vtkActorCollection; +class vtkCallbackCommand; +class vtkImageData; + +class QLabel; +class QComboBox; + +class QtxAction; +class QtxDblSpinBox; +class QtxIntSpinBox; + +class VISU_GaussPtsAct; +class VISU_PickingSettings; + +class VVTK_PickingDlg : public QDialog +{ + Q_OBJECT + +public: + VVTK_PickingDlg( QWidget* parent = 0, const char* name = 0 ); + ~VVTK_PickingDlg(); + + void SetAction( QtxAction* theAction ) { myAction = theAction; } + + void AddActor( VISU_GaussPtsAct* ); + void RemoveActor( VISU_GaussPtsAct* ); + + void Update(); + +protected: + virtual void closeEvent( QCloseEvent* ); + +private slots: + void onClickApply(); + void onClickClose(); + +private: + QtxDblSpinBox* myPyramidHeightSpinBox; + QtxDblSpinBox* myTransparencySpinBox; + QComboBox* myPositionComboBox; + QtxDblSpinBox* myZoomFactorSpinBox; + QtxIntSpinBox* myStepNumberSpinBox; + + QtxAction* myAction; + vtkSmartPointer myPickingSettings; +}; + +#endif