]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To apply picking settings to VVTK_InteractorStyle
authorapo <apo@opencascade.com>
Wed, 5 Oct 2005 16:03:26 +0000 (16:03 +0000)
committerapo <apo@opencascade.com>
Wed, 5 Oct 2005 16:03:26 +0000 (16:03 +0000)
src/VVTK/VVTK_InteractorStyle.cxx
src/VVTK/VVTK_InteractorStyle.h
src/VVTK/VVTK_MainWindow.cxx
src/VVTK/VVTK_MainWindow.h
src/VVTK/VVTK_PickingDlg.cxx
src/VVTK/VVTK_PickingDlg.h

index 43f85d68e0fce5cff0f094233fbbed39902ac952..841b5f0da07b44f71c1565e39b883d5cc883c20c 100644 (file)
@@ -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
index 14a9b08745780d83f9a680900b54face10eee7ab..f180b7882ba3496965293ce019c513c5ad7593a1 100644 (file)
@@ -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;
index 47e53d045e8aae8d7e5b72154f374e612ed849b2..01219d9397accefbf53ad0197bdd06416190a1bc 100644 (file)
@@ -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
index 0b6f7995a14ffadc5eef09ee163e005cac8932c9..f697a677292ae401e747c4e6248e1ae4db3ba33a 100644 (file)
@@ -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<vtkInteractorStyle> myInteractorStyle;
+  vtkSmartPointer<VVTK_InteractorStyle> myInteractorStyle;
 };
 
 
@@ -90,6 +95,9 @@ public:
   VISU_ImplicitFunctionWidget*
   GetImplicitFunctionWidget();
 
+  VISU_PickingSettings* 
+  GetPickingSettings();
+
   virtual
   QSize
   sizeHint() const;
index 11bdddedb6267d9c69d38c81d9c3628994dd304d..e8ab5ed83c47ebd55fb655ed9e2195e5dcf2ceb8 100644 (file)
@@ -208,6 +208,14 @@ void VVTK_PickingDlg::Update()
   onClickApply();
 }
 
+
+VISU_PickingSettings* 
+VVTK_PickingDlg
+::GetPickingSettings()
+{
+  return myPickingSettings.GetPointer();
+}
+
 void VVTK_PickingDlg::onClickApply()
 {
   myPickingSettings->SetInitial( false );
index 74dae19e4375d08fc30d5110d2f8b779519d218c..67c973aa9b022db0a8a04fd87301625769408d4c 100644 (file)
@@ -45,6 +45,8 @@ public:
 
   void             Update();
 
+  VISU_PickingSettings* GetPickingSettings();
+
 protected:
   virtual void     closeEvent( QCloseEvent* );