]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
1. Port from QValueStack to std::stack.
authorapo <apo@opencascade.com>
Tue, 13 Sep 2005 04:08:49 +0000 (04:08 +0000)
committerapo <apo@opencascade.com>
Tue, 13 Sep 2005 04:08:49 +0000 (04:08 +0000)
2. To provide correct memory menagement

src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_RenderWindowInteractor.h

index 709505d89d3e9e41c6931782e32c97c9e01fe1e9..f371c025d5fec5f8988ad685fc1f0d790441343d 100644 (file)
@@ -21,8 +21,8 @@
 //
 //
 //
-//  File   : VTKViewer_RenderWindowInteractor.cxx
-//  Author : Nicolas REJNERI
+//  File   : 
+//  Author : 
 //  Module : SALOME
 //  $Header$
 
@@ -405,6 +405,19 @@ SVTK_RenderWindowInteractor
 ::~SVTK_RenderWindowInteractor() 
 {
   if(MYDEBUG) INFOS("~SVTK_RenderWindowInteractor() - "<<this);
+
+  // Sequence of the destruction call are fixed and should be changed.
+  // vtkRenderWindow instance should be destroyed after all vtkRenderer's
+  GetDevice()->SetInteractorStyle(NULL); 
+  while(!myInteractorStyles.empty()){
+    const PInteractorStyle& aStyle = myInteractorStyles.top();
+    aStyle->SetInteractor(NULL);
+    myInteractorStyles.pop();
+  }
+
+  SetRenderer(NULL);
+
+  GetDevice()->SetRenderWindow(NULL);
 }
 
 vtkRenderWindow* 
@@ -439,7 +452,7 @@ SVTK_RenderWindowInteractor
 
   if(GetRenderer()){
     myRenderWindow->RemoveRenderer(getRenderer());
-    theRenderer->SetInteractor(NULL);
+    myRenderer->SetInteractor(NULL);
   }
 
   myRenderer = theRenderer;
@@ -488,7 +501,7 @@ vtkInteractorStyle*
 SVTK_RenderWindowInteractor
 ::GetInteractorStyle()
 {
-  return myInteractorStyles.isEmpty() ? 0 : myInteractorStyles.top().GetPointer();
+  return myInteractorStyles.empty() ? 0 : myInteractorStyles.top().GetPointer();
 }
 
 
@@ -616,6 +629,10 @@ SVTK_RenderWindowInteractor
 ::wheelEvent( QWheelEvent* event )
 {
   QVTK_RenderWindowInteractor::wheelEvent(event);
+  if(event->delta() > 0)
+    GetDevice()->InvokeEvent(SVTK::ZoomInEvent,NULL);
+  else
+    GetDevice()->InvokeEvent(SVTK::ZoomOutEvent,NULL);
 #ifdef GENERATE_SUIT_EVENTS
   emit WheelMoved( event );
 #endif
index 146be1081fe1b7a7ca151ac6140470f561d175f6..e36bfd23dc1d7e511883b4ac1bc4b988e9e82b68 100644 (file)
 #include "SVTK.h"
 #include "SVTK_Selection.h"
 
-#include <qwidget.h>
-#include <qvaluestack.h>
-
 #include <vtkSmartPointer.h>
+#include <qwidget.h>
+#include <stack>
 
 class vtkGenericRenderWindowInteractor;
 class vtkInteractorStyle;
@@ -202,7 +201,8 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteracto
   vtkSmartPointer<vtkRenderWindow> myRenderWindow;
 
   typedef vtkSmartPointer<vtkInteractorStyle> PInteractorStyle;
-  QValueStack<PInteractorStyle> myInteractorStyles;
+  typedef std::stack<PInteractorStyle> TInteractorStyles;
+  TInteractorStyles myInteractorStyles;
 };