From: apo Date: Wed, 5 Oct 2005 16:03:26 +0000 (+0000) Subject: To apply picking settings to VVTK_InteractorStyle X-Git-Tag: BR-D5-38-2003_D2005-12-10~51 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=81697f2e2a5666105db1b0134820b34b2e60ca4a;p=modules%2Fvisu.git To apply picking settings to VVTK_InteractorStyle --- diff --git a/src/VVTK/VVTK_InteractorStyle.cxx b/src/VVTK/VVTK_InteractorStyle.cxx index 43f85d68..841b5f0d 100644 --- a/src/VVTK/VVTK_InteractorStyle.cxx +++ b/src/VVTK/VVTK_InteractorStyle.cxx @@ -28,6 +28,7 @@ #include "VVTK_InteractorStyle.h" +#include "VISU_GaussPtsSettings.h" #include "SVTK_Selector.h" #include "VVTK_Event.h" @@ -48,7 +49,8 @@ VVTK_InteractorStyle myIsMidButtonDown( false ), myIsLeftButtonDown( false ), mySMDecreaseMagnificationBtn(10), - mySMIncreaseMagnificationBtn(11) + mySMIncreaseMagnificationBtn(11), + myPickingSettings(NULL) { } @@ -204,19 +206,14 @@ void VVTK_InteractorStyle::onFinishOperation() aNbObjNow=GetSelector()->IObjectCount(); if (aNbObjWas+aNbObjNow==1){ - double aScale, aCoeff; - vtkRenderer *aRenderer=GetCurrentRenderer(); - vtkCamera *aCamera = aRenderer->GetActiveCamera(); - // - aCoeff=0.667; - aScale = aCamera->GetParallelScale(); - // + vtkCamera *aCamera = GetCurrentRenderer()->GetActiveCamera(); + float aZoomFactor = myPickingSettings->GetZoomFactor(); + double aScale = aCamera->GetParallelScale(); if (!aNbObjWas && aNbObjNow) { - aCamera->SetParallelScale(aScale*aCoeff); + aCamera->SetParallelScale(aScale/aZoomFactor); } else { - aCoeff=1./aCoeff; - aCamera->SetParallelScale(aScale*aCoeff); + aCamera->SetParallelScale(aScale*aZoomFactor); } } } @@ -236,6 +233,16 @@ VVTK_InteractorStyle } } + +//---------------------------------------------------------------------------- +void +VVTK_InteractorStyle +::SetPickingSettings(VISU_PickingSettings* thePickingSettings) +{ + myPickingSettings = thePickingSettings; +} + + //---------------------------------------------------------------------------- void VVTK_InteractorStyle diff --git a/src/VVTK/VVTK_InteractorStyle.h b/src/VVTK/VVTK_InteractorStyle.h index 14a9b087..f180b788 100644 --- a/src/VVTK/VVTK_InteractorStyle.h +++ b/src/VVTK/VVTK_InteractorStyle.h @@ -33,6 +33,9 @@ #include "SVTK_InteractorStyle.h" +class VISU_PickingSettings; + + class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle { public: @@ -48,6 +51,9 @@ class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle void SetInteractor( vtkRenderWindowInteractor* ); + void + SetPickingSettings(VISU_PickingSettings* thePickingSettings); + protected: VVTK_InteractorStyle(); ~VVTK_InteractorStyle(); @@ -78,6 +84,8 @@ class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle // SpaceMouse short cuts int mySMDecreaseMagnificationBtn; int mySMIncreaseMagnificationBtn; + + VISU_PickingSettings* myPickingSettings; bool myIsMidButtonDown; bool myIsLeftButtonDown; diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index 47e53d04..01219d93 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -69,6 +69,13 @@ VVTK_MainWindow ::~VVTK_MainWindow() {} +VVTK_InteractorStyle* +VVTK_MainWindow +::GetVInteractorStyle() +{ + return myInteractorStyle.GetPointer(); +} + //---------------------------------------------------------------------------- void @@ -179,6 +186,7 @@ VVTK_MainWindow1 myRenderer = theRenderer; VVTK_MainWindow::Initialize(theInteractor); mySegmentationCursorDlg->SetWidget( theRenderer->GetImplicitFunctionWidget() ); + GetVInteractorStyle()->SetPickingSettings( GetPickingSettings() ); } VVTK_MainWindow1 @@ -193,12 +201,14 @@ VVTK_MainWindow1 const char* theName, SUIT_ResourceMgr* theResourceMgr) { - return new VVTK_MainWindow2(theParent, - theName, - theResourceMgr, - this, - myStyleSwitchAction, - myPickingDlg); + VVTK_MainWindow2* aMainWindow2 = new VVTK_MainWindow2(theParent, + theName, + theResourceMgr, + this, + myStyleSwitchAction, + myPickingDlg); + aMainWindow2->GetVInteractorStyle()->SetPickingSettings(GetPickingSettings()); + return aMainWindow2; } @@ -264,6 +274,14 @@ VVTK_MainWindow1 return myRenderer->GetImplicitFunctionWidget(); } +VISU_PickingSettings* +VVTK_MainWindow1 +::GetPickingSettings() +{ + return myPickingDlg->GetPickingSettings(); +} + + //---------------------------------------------------------------------------- QSize VVTK_MainWindow1 diff --git a/src/VVTK/VVTK_MainWindow.h b/src/VVTK/VVTK_MainWindow.h index 0b6f7995..f697a677 100644 --- a/src/VVTK/VVTK_MainWindow.h +++ b/src/VVTK/VVTK_MainWindow.h @@ -12,6 +12,8 @@ class QSplitter; class VISU_ImplicitFunctionWidget; class VVTK_SegmentationCursorDlg; +class VISU_PickingSettings; +class VVTK_InteractorStyle; class VVTK_PickingDlg; class VVTK_MainWindow2; class VVTK_Renderer1; @@ -33,6 +35,9 @@ public: virtual ~VVTK_MainWindow(); + VVTK_InteractorStyle* + GetVInteractorStyle(); + public slots: virtual void @@ -47,7 +52,7 @@ public: action( const int ); protected: - vtkSmartPointer myInteractorStyle; + vtkSmartPointer myInteractorStyle; }; @@ -90,6 +95,9 @@ public: VISU_ImplicitFunctionWidget* GetImplicitFunctionWidget(); + VISU_PickingSettings* + GetPickingSettings(); + virtual QSize sizeHint() const; diff --git a/src/VVTK/VVTK_PickingDlg.cxx b/src/VVTK/VVTK_PickingDlg.cxx index 11bddded..e8ab5ed8 100644 --- a/src/VVTK/VVTK_PickingDlg.cxx +++ b/src/VVTK/VVTK_PickingDlg.cxx @@ -208,6 +208,14 @@ void VVTK_PickingDlg::Update() onClickApply(); } + +VISU_PickingSettings* +VVTK_PickingDlg +::GetPickingSettings() +{ + return myPickingSettings.GetPointer(); +} + void VVTK_PickingDlg::onClickApply() { myPickingSettings->SetInitial( false ); diff --git a/src/VVTK/VVTK_PickingDlg.h b/src/VVTK/VVTK_PickingDlg.h index 74dae19e..67c973aa 100644 --- a/src/VVTK/VVTK_PickingDlg.h +++ b/src/VVTK/VVTK_PickingDlg.h @@ -45,6 +45,8 @@ public: void Update(); + VISU_PickingSettings* GetPickingSettings(); + protected: virtual void closeEvent( QCloseEvent* );