]> Creatis software - bbtk.git/commitdiff
#3127 BBTK Feature New Normal - branch changeWx28to30 compilation with wxWidgets3
authorEduardo DAVILA <davila@localhost.localdomain>
Fri, 29 Sep 2017 10:21:19 +0000 (12:21 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Fri, 29 Sep 2017 10:21:19 +0000 (12:21 +0200)
kernel/appli/bbi/bbi.cxx
packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx
packages/wxvtk/src/wxVTKRenderWindowInteractor.h

index ea8dd6cc5f504360e72013197270ecd90c7bc932..c594a081f5d939f8e5d30948b8eb1b3b3197bd5c 100644 (file)
@@ -27,6 +27,8 @@
 
 #ifdef _USE_WXWIDGETS_
 
+#include <exception>
+
 //==========================================================================
 // WITH WX
 //==========================================================================
@@ -111,13 +113,20 @@ void WxProcessCmdLine::Process(wxCmdLineParser& parser)
       bbtk::StaticInitTime::PrintObjectListInfo = true;
     }
   
-  debug = ( parser.Found(_T("d")) );  
-  quiet = ( parser.Found(_T("q")) );
-  help = ( parser.Found(_T("h")) );
-  graphical_dialog = ( parser.Found(_T("wxcommandlineg")) );
-  text_dialog = ( parser.Found(_T("t")) );
-  no_console = ( parser.Found(_T("N")) );
-  
+  debug                        = ( parser.Found(_T("d")) );  
+  quiet                        = ( parser.Found(_T("q")) );
+  help                         = ( parser.Found(_T("h")) );
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
+  graphical_dialog     = ( parser.Found(_T("wxcommandlineg")) );
+#else
+  printf("EED Warnning. WxProcessCmdLine::Process  g  wxcommandlineg   ");
+  graphical_dialog     = ( parser.Found(_T("g")) );
+#endif
+
+  text_dialog          = ( parser.Found(_T("t")) );
+  no_console           = ( parser.Found(_T("N")) );
   if (quiet) bbtk::MessageManager::SetMessageLevel("max",0);
   if (debug) bbtk::MessageManager::SetMessageLevel("all",9);
 
@@ -153,7 +162,7 @@ void WxProcessCmdLine::Process(wxCmdLineParser& parser)
              ((input_file.size() == 0) && 
               (!no_console) &&
               (!usage) ) );
-  
+
 }
 //==========================================================================
 
@@ -323,7 +332,7 @@ int main(int argc, char* argv[])
 
   if (!cmdline.proceed) return 0;
 
-  if (cmdline.no_console) 
+       if (cmdline.no_console) 
     {
       //      std::cout << "main NC"<<std::endl;
       // Interpreter 
@@ -336,27 +345,26 @@ int main(int argc, char* argv[])
       bool error = false;
       for (i=cmdline.input_file.begin(); 
           i!=cmdline.input_file.end(); ++i) 
-       {
-         error = ! I->InterpretFile(*i);
-         if (error) break;
-       }
-      if (help_on_script) 
-       {
-         I->SetNoExecMode(false);
-         std::string package; 
-         I->GetExecuter()->GetFactory()->PrintHelpDescriptor("workspace",
+               {
+                       error = ! I->InterpretFile(*i);
+                       if (error) break;
+               }
+       if (help_on_script) 
+               {
+                       I->SetNoExecMode(false);
+                       std::string package; 
+                       I->GetExecuter()->GetFactory()->PrintHelpDescriptor("workspace",
                                                              package,
                                                              false);
-       }
-      if (cmdline.input_file.size()==0)
-       I->CommandLineInterpreter();
-
+               }
+       if (cmdline.input_file.size()==0)
+               {
+                       I->CommandLineInterpreter();
+               } // if cmdline.input_file.size
       //
-    }
-  else 
-    {
+    } else {
       wxEntry(argc, argv);
-    }
+    } // if cmdline.no_console
 
 }
 
index 7668c982f11ca38264a55da20ccea5bfa1eeba8d..da5f670ee61c37af1a1e4640982300efce20c156 100644 (file)
 /*=========================================================================
 
   Program:   Visualization Toolkit
-  Module:    $RCSfile: wxVTKRenderWindowInteractor.cxx,v $
+  Module:    $RCSfile$
   Language:  C++
-  Date:      $Date: 2012/11/16 08:52:36 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date$
+  Version:   $Revision$
+
+  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
+  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notice for more information.
 
 =========================================================================*/
 
 #endif
 #include "vtkDebugLeaks.h"
 
+// AKT: wxOSX 2.9.x defines __WXOSX_COCOA__ rather than __WXCOCOA__
+#ifdef __WXOSX_COCOA__
+#define __WXCOCOA__
+#endif
+
+#if defined(__WXMAC__) && wxCHECK_VERSION(2,9,0)
+    // ControlDown has been changed to mean Command key down
+    #define ControlDown RawControlDown
+#endif
+
 #ifdef __WXMAC__
+#ifdef __WXCOCOA__
+#include "vtkCocoaRenderWindow.h"
+#else
 #include "vtkCarbonRenderWindow.h"
 #endif
+#endif
 
 //=======================================================================
 // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS
@@ -85,40 +107,52 @@ wxWindow* wxGetTopLevelParent(wxWindow *win)
 #endif //VTK_USE_COCOA
 #endif //__WXCOCOA__
 
-
-//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
 #if wxMAJOR_VERSION <= 2
+
        #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)
+        #include <gdk/gdkx.h> // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0
+        #include "gdk/gdkprivate.h"
+        #if wxCHECK_VERSION(2, 9, 0)
+         // thanks to: http://thomasfischer.biz/?p=382
+         #include <gtk/gtkfixed.h>
+         #include <gtk/gtkwidget.h>
+         #include <wx/gtk/private/win_gtk.h>
+         #define piz(wxwin) WX_PIZZA((wxwin)->m_wxwindow)
+         #define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
+               GDK_WINDOW_XWINDOW(((GtkWidget*)piz(wxwin))->window) : \
+               GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
+        #else
+         #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)
+        #endif
        #endif
+
 #else
        #ifdef __WXGTK__
            #include <gdk/gdkx.h>
            #include <gtk/gtk.h>
+#define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
+                          GDK_WINDOW_XID(gtk_widget_get_window((wxwin)->m_wxwindow)) : \
+                        GDK_WINDOW_XID(gtk_widget_get_window((wxwin)->m_widget))
        #endif
 #endif
 
-
-
 #ifdef __WXX11__
 #include "wx/x11/privx.h"
 #define GetXWindow(wxwin)   ((Window)(wxwin)->GetHandle())
 #endif
 
-
 //For more info on this class please go to:
 //http://wxvtk.sf.net
 //This hack is for some buggy wxGTK version:
@@ -136,16 +170,28 @@ namespace bbwxvtk
 {
 
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxGLCanvas)
 #else
-IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxWindow)
 #endif  //__WXGTK__
 
 //---------------------------------------------------------------------------
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxGLCanvas)
+               //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+               #if wxMAJOR_VERSION <= 2
+                       IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxGLCanvas)
+                       BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxGLCanvas)
+               #else
+                       wxIMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxGLCanvas);
+                       wxBEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxGLCanvas)
+               #endif
 #else
-BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
+               //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+               #if wxMAJOR_VERSION <= 2
+                       IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxWindow)
+                       BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
+               #else
+                       wxIMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxWindow);
+                       wxBEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
+               #endif
 #endif //__WXGTK__
   //refresh window by doing a Render
   EVT_PAINT       (wxVTKRenderWindowInteractor::OnPaint)
@@ -163,6 +209,9 @@ BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
   EVT_ENTER_WINDOW(wxVTKRenderWindowInteractor::OnEnter)
   EVT_LEAVE_WINDOW(wxVTKRenderWindowInteractor::OnLeave)
   EVT_MOUSEWHEEL  (wxVTKRenderWindowInteractor::OnMouseWheel)
+#if wxCHECK_VERSION(2, 8, 0)
+  EVT_MOUSE_CAPTURE_LOST(wxVTKRenderWindowInteractor::OnMouseCaptureLost)
+#endif
   EVT_KEY_DOWN    (wxVTKRenderWindowInteractor::OnKeyDown)
   EVT_KEY_UP      (wxVTKRenderWindowInteractor::OnKeyUp)
   EVT_CHAR        (wxVTKRenderWindowInteractor::OnChar)
@@ -171,22 +220,35 @@ BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
   EVT_SIZE        (wxVTKRenderWindowInteractor::OnSize)
 END_EVENT_TABLE()
 
-vtkCxxRevisionMacro(wxVTKRenderWindowInteractor, "$Revision: 1.5 $")
+vtkCxxRevisionMacro(wxVTKRenderWindowInteractor, "$Revision$")
 vtkInstantiatorNewMacro(wxVTKRenderWindowInteractor)
 
-//---------------------------------------------------------------------------
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-#if (wxCHECK_VERSION(2, 8, 0))
-wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(0, -1, wxDefaultPosition), vtkRenderWindowInteractor()
-#else
-wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(), vtkRenderWindowInteractor()
+static int wxvtk_attributes[]={
+  WX_GL_DOUBLEBUFFER,
+  WX_GL_RGBA,
+  WX_GL_DEPTH_SIZE,
+  16,
+  0
+};
 #endif
+
+//---------------------------------------------------------------------------
+wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() 
+
+#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
+    #if wxCHECK_VERSION(2, 9, 0) // the order of the parameters to wxGLCanvas::wxGLCanvas has changed
+               : wxGLCanvas(0, -1, wxvtk_attributes, wxDefaultPosition, wxDefaultSize, 0, wxT("wxVTKRenderWindowInteractor")), 
+       #else
+               : wxGLCanvas(0, -1, wxDefaultPosition, wxDefaultSize, 0, wxT("wxVTKRenderWindowInteractor"), wxvtk_attributes), 
+       #endif
 #else
-wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxWindow(), vtkRenderWindowInteractor()
+               : wxWindow(), 
 #endif //__WXGTK__
+
+         vtkRenderWindowInteractor()
       , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
       , ActiveButton(wxEVT_NULL)
-      , RenderAllowed(0)
       , Stereo(0)
       , Handle(0)
       , Created(true)
@@ -195,6 +257,9 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxWindow(), vtkRend
 {
 #ifdef VTK_DEBUG_LEAKS
   vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
+#endif
+#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
+  this->context = new wxGLContext(this);
 #endif
   this->RenderWindow = NULL;
   this->SetRenderWindow(vtkRenderWindow::New());
@@ -208,13 +273,17 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
                                                          long style,
                                                          const wxString &name)
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-      : wxGLCanvas(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
+    #if wxCHECK_VERSION(2, 9, 0) // the order of the parameters to wxGLCanvas::wxGLCanvas has changed
+      : wxGLCanvas(parent, id, wxvtk_attributes, pos, size, style, name)
+    #else
+      : wxGLCanvas(parent, id, pos, size, style, name, wxvtk_attributes)
+    #endif
 #else
-      : wxWindow(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
+      : wxWindow(parent, id, pos, size, style, name)
 #endif //__WXGTK__
+         , vtkRenderWindowInteractor()
       , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
       , ActiveButton(wxEVT_NULL)
-      , RenderAllowed(0)
       , Stereo(0)
       , Handle(0)
       , Created(true)
@@ -223,6 +292,9 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
 {
 #ifdef VTK_DEBUG_LEAKS
   vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
+#endif
+#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
+  this->context = new wxGLContext(this);
 #endif
   this->RenderWindow = NULL;
   this->SetRenderWindow(vtkRenderWindow::New());
@@ -238,6 +310,9 @@ wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor()
 {
   SetRenderWindow(NULL);
   SetInteractorStyle(NULL);
+#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
+  delete this->context;
+#endif
 }
 //---------------------------------------------------------------------------
 wxVTKRenderWindowInteractor * wxVTKRenderWindowInteractor::New()
@@ -270,7 +345,7 @@ void wxVTKRenderWindowInteractor::Enable()
   // that's it
   Enabled = 1;
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-  SetCurrent();
+  wxGLCanvas::SetCurrent(*this->context);
 #endif
   Modified();
 }
@@ -314,6 +389,9 @@ void wxVTKRenderWindowInteractor::UpdateSize(int x, int y)
       Size[1] = y;
       // and our RenderWindow's size
       RenderWindow->SetSize(x, y);
+#if defined(__WXMSW__)
+      this->Refresh();
+#endif //__WXMSW__
     }
   }
 }
@@ -322,11 +400,28 @@ int wxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype))
 {
   // it's a one shot timer
   if (!timer.Start(10, TRUE))
-    assert(false);
+    return 0;
 
   return 1;
   
 }
+#if VTK_MAJOR_VERSION > 5 || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 2)
+//------------------------------------------------------------------
+int wxVTKRenderWindowInteractor::InternalCreateTimer(int timerId, int timerType,
+                                                     unsigned long duration)
+{
+  if (!timer.Start(duration, timerType == OneShotTimer))
+    return 0;
+    
+  return ID_wxVTKRenderWindowInteractor_TIMER;
+}
+//------------------------------------------------------------------
+int wxVTKRenderWindowInteractor::InternalDestroyTimer(int platformTimerId)
+{
+  timer.Stop();
+  return 1;
+}
+#endif
 //---------------------------------------------------------------------------
 int wxVTKRenderWindowInteractor::DestroyTimer()
 {
@@ -340,11 +435,17 @@ void wxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event))
     return;
     
 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-    InvokeEvent(vtkCommand::TimerEvent, NULL);
+  // new style
+#if VTK_MAJOR_VERSION > 5 || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 2)
+  // pass the right timer id
+  int timerId = this->GetCurrentTimerId();
+  this->InvokeEvent(vtkCommand::TimerEvent, &timerId);
 #else
-    // old style
-    InteractorStyle->OnTimer();
+  this->InvokeEvent(vtkCommand::TimerEvent, NULL);
+#endif
+#else
+  // old style
+  InteractorStyle->OnTimer();
 #endif
 }
 
@@ -363,37 +464,28 @@ long wxVTKRenderWindowInteractor::GetHandleHack()
   long handle_tmp = 0;
 
 // __WXMSW__ is for Win32
-//__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)
+// __WXMAC__ is for Carbon or Cocoa builds
 // __WXGTK__ is for both gtk 1.2.x and gtk 2.x
 #if defined(__WXMSW__) || defined(__WXMAC__)
     handle_tmp = (long)this->GetHandle();
 #endif //__WXMSW__
 
-//__WXCOCOA__ stands for using the objective-c Cocoa API
-#ifdef __WXCOCOA__
+// using above GetHandle() works fine with wxOSX 2.9.x
+#if defined(__WXCOCOA__) && !wxCHECK_VERSION(2, 9, 0)
    // Here is how to find the NSWindow
-   wxTopLevelWindow* toplevel = dynamic_cast<wxTopLevelWindow*>(
-     wxGetTopLevelParent( this ) );
-   if (toplevel != NULL )    
+   wxTopLevelWindow* toplevel = dynamic_cast<wxTopLevelWindow*>(wxGetTopLevelParent( this ) );
+   if (toplevel != NULL )
    {
-     handle_tmp = (long)toplevel->GetNSWindow();
+      handle_tmp = (long)toplevel->GetNSWindow();
    }
    // The NSView will be deducted from 
    // [(NSWindow*)Handle contentView]
    // if only I knew how to write that in c++
-#endif //__WXCOCOA__
+#endif //__WXCOCOA__ && !wxCHECK_VERSION(2, 9, 0)
 
     // Find and return the actual X-Window.
 #if defined(__WXGTK__) || defined(__WXX11__)
-
-       //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
-       #if wxMAJOR_VERSION <= 2
-               return (long)GetXWindow(this);
-       #else
-               GdkWindow* Win = gtk_widget_get_window( (GtkWidget *) GetHandle() );
-               return (long int)GDK_WINDOW_XDISPLAY(Win);
-       #endif
-
+    return (long)GetXWindow(this);
 #endif
 
 //#ifdef __WXMOTIF__
@@ -413,21 +505,48 @@ void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
   {
     Handle = GetHandleHack();
     RenderWindow->SetWindowId(reinterpret_cast<void *>(Handle));
+// Cocoa
+// this->GetNSView() <-> DisplayId
+// this->GetTopLevel()->GetNSWindow() <-> WindowId
 #ifdef __WXMSW__
     RenderWindow->SetParentId(reinterpret_cast<void *>(this->GetParent()->GetHWND()));
 #endif //__WXMSW__
+      
+    // This is another hack to prevent the VTK Render Window from closing the display.
+    // If VTK closes the display, ~wxContext chashes while trying to destroy its
+    // glContext (because the display is closed). The Get -> Set makes this VTK
+    // object think someone else is responsible for the display. 
+    #ifdef __WXCOCOA__
+      // avoid "Method not implemented" messages in Console
+    #else
+      this->RenderWindow->SetDisplayId(this->RenderWindow->GetGenericDisplayId());
+    #endif
   }
   // get vtk to render to the wxWindows
   Render();
 #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
+#ifdef __WXCOCOA__
+  #if !wxCHECK_VERSION(2, 9, 0)
+    // this doesn't seem necessary with wxOSX 2.9.x
+    vtkCocoaRenderWindow * rwin = vtkCocoaRenderWindow::SafeDownCast(RenderWindow);
+    if( rwin )
+    {
+      rwin->UpdateContext();
+    }
+  #endif
+#else
   vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow);
   if( rwin )
   {
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 4)
+    // Must be somewhere after VTK 4.4
     rwin->UpdateGLRegion();
+#endif
   }
 #endif
+#endif
 }
 //---------------------------------------------------------------------------
 void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event)
@@ -673,6 +792,9 @@ void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
     return;
     }
 
+  // See report by Shang Mu / Kerry Loux on wxVTK mailing list
+    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);
@@ -722,11 +844,11 @@ 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 > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
+#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 4)
   // new style
   //Set vtk event information ... The numebr of wheel rotations is stored in
   //the x varible.  y varible is zero
-  SetEventInformationFlipY(event.GetWheelRotation() / event.GetWheelDelta(), 0
+  SetEventInformationFlipY(event.GetX() , event.GetY()
                            event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
   if(event.GetWheelRotation() > 0)
     {
@@ -742,11 +864,32 @@ void wxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event)
     
 }
 
+//---------------------------------------------------------------------------
+#if wxCHECK_VERSION(2, 8, 0)
+void wxVTKRenderWindowInteractor::OnMouseCaptureLost(wxMouseCaptureLostEvent& event)
+{
+   if (ActiveButton != wxEVT_NULL)
+   {
+       //Maybe also invoke the button release event here
+   }
+   // Reset ActiveButton so that
+   // 1. we do not process mouse button up events any more,
+   // 2. the next button down event will be processed and call CaptureMouse().
+   // Otherwise ReleaseMouse() will be called
+   // without a previous CaptureMouse().
+   ActiveButton = wxEVT_NULL;
+}
+#endif
+
 //---------------------------------------------------------------------------
 void wxVTKRenderWindowInteractor::Render()
 {
-  RenderAllowed = 1;
-  if (!RenderWhenDisabled)
+#if wxCHECK_VERSION(2, 8, 0)
+  int renderAllowed = !IsFrozen();
+#else
+  int renderAllowed = 1;
+#endif
+  if (renderAllowed && !RenderWhenDisabled)
     {
     //the user doesn't want us to render when the toplevel frame
     //is disabled - first find the top level parent
@@ -754,13 +897,16 @@ void wxVTKRenderWindowInteractor::Render()
     if (topParent)
       {
       //if it exists, check whether it's enabled
-      //if it's not enabeld, RenderAllowed will be false
-      RenderAllowed = topParent->IsEnabled();
+      //if it's not enabeld, renderAllowed will be false
+      renderAllowed = topParent->IsEnabled();
       }
     }
 
-  if (RenderAllowed)
+  if (renderAllowed)
     {
+#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
+    wxGLCanvas::SetCurrent(*(this->context));
+#endif
     if(Handle && (Handle == GetHandleHack()) )
       {
       RenderWindow->Render();
index 12f33f88b272156d3ebb14bed6576f387548c589..c7f60514cb2842929846979775cadaa2ebebaf4a 100644 (file)
 /*=========================================================================
 
   Program:   Visualization Toolkit
-  Module:    $RCSfile: wxVTKRenderWindowInteractor.h,v $
+  Module:    $RCSfile$
   Language:  C++
-  Date:      $Date: 2012/11/16 08:52:36 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date$
+  Version:   $Revision$
+
+  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
+  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notice for more information.
+
 =========================================================================*/
 
 // .NAME  wxVTKRenderWindowInteractor - class to enable VTK to render to 
 #include "vtkRenderWindowInteractor.h"
 #include "vtkRenderWindow.h"
 
-// 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
@@ -115,7 +116,12 @@ class wxVTKRenderWindowInteractor : public wxGLCanvas, public vtkRenderWindowInt
 class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInteractor
 #endif //__WXGTK__
 {
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
   DECLARE_DYNAMIC_CLASS(wxVTKRenderWindowInteractor)
+#else
+  wxDECLARE_DYNAMIC_CLASS(wxVTKRenderWindowInteractor);
+#endif
   
   public:
     //constructors
@@ -155,13 +161,16 @@ class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInter
 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
     void OnEnter(wxMouseEvent &event);
     void OnLeave(wxMouseEvent &event);
+    void OnMouseWheel(wxMouseEvent& event);
+#if wxCHECK_VERSION(2, 8, 0)
+    void OnMouseCaptureLost(wxMouseCaptureLostEvent& event);
+#endif
     void OnKeyDown(wxKeyEvent &event);
     void OnKeyUp(wxKeyEvent &event);
     void OnChar(wxKeyEvent &event);
 #endif
     void OnTimer(wxTimerEvent &event);
     void OnSize(wxSizeEvent &event);
-    void OnMouseWheel(wxMouseEvent& event);
 
     void Render();
     void SetRenderWhenDisabled(int newValue);
@@ -180,10 +189,18 @@ class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInter
     vtkSetMacro(UseCaptureMouse,int);
     vtkBooleanMacro(UseCaptureMouse,int);
 
+#if VTK_MAJOR_VERSION > 5 || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 2)
   protected:
+    virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration);
+    virtual int InternalDestroyTimer(int platformTimerId);
+#endif
+
+  protected:
+#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
+    wxGLContext *context;
+#endif
     wxTimer timer;
     int ActiveButton;
-    int RenderAllowed;
     long GetHandleHack();
     int Stereo;