]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Thu, 17 Feb 2011 11:01:27 +0000 (11:01 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Thu, 17 Feb 2011 11:01:27 +0000 (11:01 +0000)
packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx
packages/wxvtk/src/wxVTKRenderWindowInteractor.h

index 6c33bf3484ad8b0a728b2bf0f0d673440e886cb3..d952cf6906a4eb130f7cf9fbc8b5a97370cdbeb2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   Visualization Toolkit
   Module:    $RCSfile: wxVTKRenderWindowInteractor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/06/26 18:45:58 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2011/02/17 11:01:27 $
+  Version:   $Revision: 1.4 $
 
   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
   All rights reserved.
@@ -16,6 +16,8 @@
 
 =========================================================================*/
 
+#include <assert.h>
+
 #include "wxVTKRenderWindowInteractor.h"
 
 //This is needed for vtk 3.1 :
 #  include "vtkVersion.h"
 #endif
 
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
 #  include "vtkCommand.h"
 #else
 #  include "vtkInteractorStyle.h"
 #endif
+#include "vtkDebugLeaks.h"
+
+#ifdef __WXMAC__
+#include "vtkCarbonRenderWindow.h"
+#endif
 
 //=======================================================================
 // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS
 namespace bbwxvtk
 {
 
-  //Keep this for compatibilty reason, this was introduced in wxGTK 2.4.0
+
+//Keep this for compatibilty reason, this was introduced in wxGTK 2.4.0
 #if (!wxCHECK_VERSION(2, 4, 0))
-  wxWindow* wxGetTopLevelParent(wxWindow *win)
-  {
+wxWindow* wxGetTopLevelParent(wxWindow *win)
+{
     while ( win && !win->IsTopLevel() )
-      win = win->GetParent();
+         win = win->GetParent();
     return win;
-  }
+}
 #endif
 }
 // LG : EO namespace bbwxvtk
@@ -61,11 +69,15 @@ namespace bbwxvtk
 #ifdef __WXGTK__
 #    include <gdk/gdkx.h> // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0
 #    include "gdk/gdkprivate.h"
+#if wxCHECK_VERSION(2, 8, 0)
 #ifdef __WXGTK20__
 #include <wx/gtk/win_gtk.h>
 #else
 #include <wx/gtk1/win_gtk.h>
 #endif
+#else
+#include <wx/gtk/win_gtk.h>
+#endif
 #define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
                           GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \
                           GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
@@ -121,22 +133,26 @@ BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
   EVT_ENTER_WINDOW(wxVTKRenderWindowInteractor::OnEnter)
   EVT_LEAVE_WINDOW(wxVTKRenderWindowInteractor::OnLeave)
   EVT_MOUSEWHEEL  (wxVTKRenderWindowInteractor::OnMouseWheel)
-// If we use EVT_KEY_DOWN instead of EVT_CHAR, capital versions
-// of all characters are always returned.  EVT_CHAR also performs
-// other necessary keyboard-dependent translations.
-  //EVT_KEY_DOWN    (wxVTKRenderWindowInteractor::OnKeyDown)
-  EVT_CHAR        (wxVTKRenderWindowInteractor::OnKeyDown)
+  EVT_KEY_DOWN    (wxVTKRenderWindowInteractor::OnKeyDown)
   EVT_KEY_UP      (wxVTKRenderWindowInteractor::OnKeyUp)
+  EVT_CHAR        (wxVTKRenderWindowInteractor::OnChar)
 #endif
   EVT_TIMER       (ID_wxVTKRenderWindowInteractor_TIMER, wxVTKRenderWindowInteractor::OnTimer)
   EVT_SIZE        (wxVTKRenderWindowInteractor::OnSize)
 END_EVENT_TABLE()
 
+vtkCxxRevisionMacro(wxVTKRenderWindowInteractor, "$Revision: 1.4 $")
+vtkInstantiatorNewMacro(wxVTKRenderWindowInteractor)
+
 //---------------------------------------------------------------------------
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : vtkRenderWindowInteractor(), wxGLCanvas()
+#if (wxCHECK_VERSION(2, 8, 0))
+wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(0, -1, wxDefaultPosition), vtkRenderWindowInteractor()
+#else
+wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(), vtkRenderWindowInteractor()
+#endif
 #else
-wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : vtkRenderWindowInteractor(), wxWindow()
+wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxWindow(), vtkRenderWindowInteractor()
 #endif //__WXGTK__
       , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
       , ActiveButton(wxEVT_NULL)
@@ -147,12 +163,12 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : vtkRenderWindowInte
       , RenderWhenDisabled(1)
       , UseCaptureMouse(0)
 {
-  
+#ifdef VTK_DEBUG_LEAKS
+  vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
+#endif
   this->RenderWindow = NULL;
   this->SetRenderWindow(vtkRenderWindow::New());
   this->RenderWindow->Delete();
-  
-  //this->SetBackgroundColour( wxColour(255,0,255) );
 }
 //---------------------------------------------------------------------------
 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
@@ -162,9 +178,9 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
                                                          long style,
                                                          const wxString &name)
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-      : vtkRenderWindowInteractor(), wxGLCanvas(parent, id, pos, size, style, name)
+      : wxGLCanvas(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
 #else
-      : vtkRenderWindowInteractor(), wxWindow(parent, id, pos, size, style, name)
+      : wxWindow(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
 #endif //__WXGTK__
       , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
       , ActiveButton(wxEVT_NULL)
@@ -175,19 +191,23 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
       , RenderWhenDisabled(1)
       , UseCaptureMouse(0)
 {
-  
+#ifdef VTK_DEBUG_LEAKS
+  vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
+#endif
   this->RenderWindow = NULL;
   this->SetRenderWindow(vtkRenderWindow::New());
   this->RenderWindow->Delete();
-  
-  // this->SetBackgroundColour( wxColour(255,0,0) );
+#ifdef __WXMAC__
+  // On Mac (Carbon) we don't get notified of the initial window size with an EVT_SIZE event,
+  // so we update the size information of the interactor/renderwindow here
+  this->UpdateSize(size.x, size.y);
+#endif
 }
 //---------------------------------------------------------------------------
 wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor()
-{   
-  // LG : trompe la mort !
+{
   SetRenderWindow(NULL);
-  SetReferenceCount(0);
+  SetInteractorStyle(NULL);
 }
 //---------------------------------------------------------------------------
 wxVTKRenderWindowInteractor * wxVTKRenderWindowInteractor::New()
@@ -289,7 +309,7 @@ void wxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event))
   if (!Enabled)
     return;
     
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
     InvokeEvent(vtkCommand::TimerEvent, NULL);
 #else
@@ -313,7 +333,7 @@ long wxVTKRenderWindowInteractor::GetHandleHack()
   long handle_tmp = 0;
 
 // __WXMSW__ is for Win32
-//__WXMAX__ stands for using Carbon C-headers, using either the CarbonLib/CFM or the native Mach-O builds (which then also use the latest features available)
+//__WXMAC__ stands for using Carbon C-headers, using either the CarbonLib/CFM or the native Mach-O builds (which then also use the latest features available)
 // __WXGTK__ is for both gtk 1.2.x and gtk 2.x
 #if defined(__WXMSW__) || defined(__WXMAC__)
     handle_tmp = (long)this->GetHandle();
@@ -347,7 +367,6 @@ long wxVTKRenderWindowInteractor::GetHandleHack()
 //---------------------------------------------------------------------------
 void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
 {
-
   //must always be here
   wxPaintDC pDC(this);
 
@@ -361,21 +380,20 @@ void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
 #endif //__WXMSW__
   }
   // get vtk to render to the wxWindows
-  //bbtkDebugMessage("Wx",9,"wxVTKRenderWindowInteractor::OnPaint"<<std::endl);
-  //std::cout << "wxVTKRenderWindowInteractor::OnPaint"<<std::endl;
   Render();
-
-#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-  //  bbtkDebugMessage("Core",9,"wxVTKRenderWindowInteractor::OnPaint   public wxGLCanvas, virtual public vtkRenderWindowInteractor  \n");
-#else
-  //  bbtkDebugMessage("Core",9,"wxVTKRenderWindowInteractor::OnPaint public wxWindow, virtual public vtkRenderWindowInteractor     \n");
-#endif //__WXGTK__
-
+#ifdef __WXMAC__
+  // This solves a problem with repainting after a window resize
+  // See also: http://sourceforge.net/mailarchive/forum.php?thread_id=31690967&forum_id=41789
+  vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow);
+  if( rwin )
+  {
+    rwin->UpdateGLRegion();
+  }
+#endif
 }
 //---------------------------------------------------------------------------
 void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event)
 {
-  //printf("EED wxVTKRenderWindowInteractor::OnEraseBackground \n");
   //turn off background erase to reduce flickering on MSW
   event.Skip(false);
 }
@@ -391,7 +409,7 @@ void wxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event))
     return;
     }
 
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
   InvokeEvent(vtkCommand::ConfigureEvent, NULL);
 #endif
   //this will check for Handle
@@ -402,10 +420,9 @@ void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event)
 {
  if (!Enabled) 
     {
-   return;
+    return;
     }
-
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
   SetEventInformationFlipY(event.GetX(), event.GetY(), 
     event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
 
@@ -424,7 +441,7 @@ void wxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event)
     return;
     }
 
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
   SetEventInformationFlipY(event.GetX(), event.GetY(), 
       event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
@@ -444,7 +461,7 @@ void wxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event)
     return;
     }
 
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
   SetEventInformationFlipY(event.GetX(), event.GetY(), 
       event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
@@ -464,21 +481,22 @@ void wxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event)
     return;
     }
 
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
   int keycode = event.GetKeyCode();
   char key = '\0';
-  if (keycode < 256)
+  if (((unsigned int)keycode) < 256)
   {
     // TODO: Unicode in non-Unicode mode ??
     key = (char)keycode;
   }
 
-  SetEventInformationFlipY(event.GetX(), event.GetY(), 
-    event.ControlDown(), event.ShiftDown(), key, 0, NULL);
-
+  // we don't get a valid mouse position inside the key event on every platform
+  // so we retrieve the mouse position explicitly and pass it along
+  wxPoint mousePos = ScreenToClient(wxGetMousePosition());
+  SetEventInformationFlipY(mousePos.x, mousePos.y, 
+                           event.ControlDown(), event.ShiftDown(), key, 0, NULL);
   InvokeEvent(vtkCommand::KeyPressEvent, NULL);
-  InvokeEvent(vtkCommand::CharEvent, NULL);
 #else
   InteractorStyle->OnKeyDown(event.ControlDown(), event.ShiftDown(), 
     event.GetKeyCode(), 1);
@@ -493,18 +511,21 @@ void wxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event)
     return;
     }
 
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
   int keycode = event.GetKeyCode();
   char key = '\0';
-  if (keycode < 256)
+  if (((unsigned int)keycode) < 256)
   {
     // TODO: Unicode in non-Unicode mode ??
     key = (char)keycode;
   }
 
-  SetEventInformationFlipY(event.GetX(), event.GetY(), 
-    event.ControlDown(), event.ShiftDown(), key, 0, NULL);
+  // we don't get a valid mouse position inside the key event on every platform
+  // so we retrieve the mouse position explicitly and pass it along
+  wxPoint mousePos = ScreenToClient(wxGetMousePosition());
+  SetEventInformationFlipY(mousePos.x, mousePos.y, 
+                           event.ControlDown(), event.ShiftDown(), key, 0, NULL);
   InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
 #else
   InteractorStyle->OnKeyUp(event.ControlDown(), event.ShiftDown(), 
@@ -513,6 +534,33 @@ void wxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event)
   event.Skip();
 }
 #endif //!(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
+ //---------------------------------------------------------------------------
+void wxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event)
+{
+  if (!Enabled) 
+    {
+    return;
+    }
+    
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+  // new style
+  int keycode = event.GetKeyCode();
+  char key = '\0';
+  if (((unsigned int)keycode) < 256)
+    {
+    // TODO: Unicode in non-Unicode mode ??
+    key = (char)keycode;
+    }
+
+  // we don't get a valid mouse position inside the key event on every platform
+  // so we retrieve the mouse position explicitly and pass it along
+  wxPoint mousePos = ScreenToClient(wxGetMousePosition());
+  SetEventInformationFlipY(mousePos.x, mousePos.y, 
+                           event.ControlDown(), event.ShiftDown(), key, 0, NULL);
+  InvokeEvent(vtkCommand::CharEvent, NULL);
+#endif
+  event.Skip();
+}
 //---------------------------------------------------------------------------
 void wxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
 {
@@ -522,14 +570,20 @@ void wxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
     }
   ActiveButton = event.GetEventType();
 
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+    // On Mac (Carbon) and Windows we don't automatically get the focus when
+    // you click inside the window
+    // we therefore set the focus explicitly
+    // Apparently we need that on linux (GTK) too:
+    this->SetFocus();
+
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
   SetEventInformationFlipY(event.GetX(), event.GetY(), 
     event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
 #endif
 
   if(event.RightDown())
   {
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
     InvokeEvent(vtkCommand::RightButtonPressEvent, NULL);
 #else            
@@ -540,7 +594,7 @@ void wxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
   }
   else if(event.LeftDown())
   {
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
     InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
 #else            
@@ -551,7 +605,7 @@ void wxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
   }
   else if(event.MiddleDown())
   {
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
     InvokeEvent(vtkCommand::MiddleButtonPressEvent, NULL);
 #else            
@@ -581,14 +635,14 @@ void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
     return;
     }
 
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
   SetEventInformationFlipY(event.GetX(), event.GetY(), 
     event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
 #endif
   
   if(ActiveButton == wxEVT_RIGHT_DOWN)
   {
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
     InvokeEvent(vtkCommand::RightButtonReleaseEvent, NULL);
 #else            
@@ -599,7 +653,7 @@ void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
   }
   else if(ActiveButton == wxEVT_LEFT_DOWN)
   {
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
     InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
 #else            
@@ -610,7 +664,7 @@ void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
   }
   else if(ActiveButton == wxEVT_MIDDLE_DOWN)
   {
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
     // new style
     InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, NULL);
 #else            
@@ -630,7 +684,7 @@ void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
 void wxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event)
 {
 // Mouse wheel was only added after VTK 4.4 (I think...)
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
   // new style
   //Set vtk event information ... The numebr of wheel rotations is stored in
   //the x varible.  y varible is zero
@@ -639,14 +693,12 @@ void wxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event)
   if(event.GetWheelRotation() > 0)
     {
       //Send event to VTK
-// EED
-//      InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL);
+      InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL);
     }
   else
     {
       //Send event to VTK
-// EED
-//      InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL);
+      InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL);
     }
 #endif
     
@@ -675,7 +727,7 @@ void wxVTKRenderWindowInteractor::Render()
       {
       RenderWindow->Render();
       }
-#if VTK_MAJOR_VERSION == 5 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
     else if(GetHandleHack())
       {
       //this means the user has reparented us; let's adapt to the
@@ -735,22 +787,8 @@ void wxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
 }
 
 
-void wxVTKRenderWindowInteractor::Refresh(bool eraseBackground , const wxRect* rect )
-{
-//  wxWindow::Refresh(false,rect);
-}
-
-
-#if defined(_WIN32)
-const char * wxVTKRenderWindowInteractor::GetClassName() const
-{
-  return "wxVTKRenderWindowInteractor";
-}
-#endif //_WIN32
-
-
-
 }
 // LG : EO namespace bbwxvtk
 //=======================================================================
 
+
index 7567a691f4a79b8dc4226489f42b35dc01ac79d3..ccf9b6d8280d017c717c6647514d14eea54aa075 100644 (file)
@@ -3,8 +3,8 @@
   Program:   Visualization Toolkit
   Module:    $RCSfile: wxVTKRenderWindowInteractor.h,v $
   Language:  C++
-  Date:      $Date: 2008/06/26 18:45:58 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2011/02/17 11:01:27 $
+  Version:   $Revision: 1.3 $
 
   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
   All rights reserved.
 
 // Apparently since wxGTK 2.8.0 one can finally use wxWindow (just as in any
 // other port):
+// MM: tested on 2008/04/08: experienced some heavy flickering with wx-widget 2.6.0
+// using a wxWindow instead of wxGLCanvas fixed the symptoms
+//#if (!wxCHECK_VERSION(2, 6, 0))
 #if (!wxCHECK_VERSION(2, 8, 0))
 #define USE_WXGLCANVAS
 #endif
 
-
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-# if wxUSE_GLCANVAS
+#  if wxUSE_GLCANVAS
 #    include <wx/glcanvas.h>
-# else
+#  else
 #    error "problem of wxGLCanvas, you need to build wxWidgets with opengl"
-# endif //wxUSE_GLCANVAS
+#  endif //wxUSE_GLCANVAS
 #endif //__WXGTK__
 
 // Motif version (renamed into wxX11 for wxWindow 2.4 and newer)
@@ -75,7 +77,6 @@
 # error This GUI is not supported by wxVTKRenderWindowInteractor for now
 #endif
 
-
 // wx forward declarations
 class wxPaintEvent;
 class wxMouseEvent;
@@ -90,9 +91,9 @@ namespace bbwxvtk
 
 
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-class VTK_RENDERING_EXPORT wxVTKRenderWindowInteractor : public wxGLCanvas, virtual public vtkRenderWindowInteractor
+class wxVTKRenderWindowInteractor : public wxGLCanvas, public vtkRenderWindowInteractor
 #else
-class /*VTK_RENDERING_EXPORT*/ wxVTKRenderWindowInteractor : public wxWindow, virtual public vtkRenderWindowInteractor
+class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInteractor
 #endif //__WXGTK__
 {
   DECLARE_DYNAMIC_CLASS(wxVTKRenderWindowInteractor)
@@ -107,18 +108,13 @@ class /*VTK_RENDERING_EXPORT*/ wxVTKRenderWindowInteractor : public wxWindow, vi
                                 const wxSize &size = wxDefaultSize,
                                 long style = wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE,
                                 const wxString &name = wxPanelNameStr);
-       //vtk ::New()
+    vtkTypeRevisionMacro(wxVTKRenderWindowInteractor,vtkRenderWindowInteractor);
     static wxVTKRenderWindowInteractor * New();
     void PrintSelf(ostream& os, vtkIndent indent);
 
          //destructor
     ~wxVTKRenderWindowInteractor();
 
-#if defined(_WIN32)
-    const char * wxVTKRenderWindowInteractor::GetClassName() const;
-#endif //_WIN32
-
-
     // vtkRenderWindowInteractor overrides
     void Initialize();
     void Enable();
@@ -142,6 +138,7 @@ class /*VTK_RENDERING_EXPORT*/ wxVTKRenderWindowInteractor : public wxWindow, vi
     void OnLeave(wxMouseEvent &event);
     void OnKeyDown(wxKeyEvent &event);
     void OnKeyUp(wxKeyEvent &event);
+    void OnChar(wxKeyEvent &event);
 #endif
     void OnTimer(wxTimerEvent &event);
     void OnSize(wxSizeEvent &event);
@@ -164,8 +161,6 @@ class /*VTK_RENDERING_EXPORT*/ wxVTKRenderWindowInteractor : public wxWindow, vi
     vtkSetMacro(UseCaptureMouse,int);
     vtkBooleanMacro(UseCaptureMouse,int);
 
-    virtual void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
-
   protected:
     wxTimer timer;
     int ActiveButton;