From: Eduardo DAVILA Date: Fri, 29 Sep 2017 10:19:50 +0000 (+0200) Subject: #3125 creaFeature New Normal - branch changeWx28to30 compilation with wxWidgets3 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=946e6034021fe462f5a1604e18ea8121afb98a18;p=crea.git #3125 creaFeature New Normal - branch changeWx28to30 compilation with wxWidgets3 --- diff --git a/cmake/CREAMacro_FindAndUseWxWidgets.cmake b/cmake/CREAMacro_FindAndUseWxWidgets.cmake index 1ef548c..0e1dabd 100644 --- a/cmake/CREAMacro_FindAndUseWxWidgets.cmake +++ b/cmake/CREAMacro_FindAndUseWxWidgets.cmake @@ -38,7 +38,7 @@ MACRO(CREA_FIND_WXWIDGETS) #wxWidgets build related stuff # DO NOT FORCE DEBUG LIBS !! - SET(WXW_USE_DEBUG OFF) + SET(WXW_USE_DEBUG OFF) SET(WXW_USE_UNICODE OFF) SET(WXW_USE_SHARED ON) SET(WXW_USE_UNIV OFF) @@ -63,14 +63,14 @@ MACRO(CREA_FIND_WXWIDGETS) ## pkg_check_modules (GTK2 gtk+-2.0) ## pkg_check_modules (GTK322 gtk+-3.0) pkg_check_modules (GTK3 REQUIRED gtk+-3.0) + #MESSAGE("${GTK3_INCLUDE_DIRS}") - #MESSAGE("${GTK2_INCLUDE_DIRS}") # Can I require all my user to have the gl lib on linux, even if they do not really need it... -#EED SET(WXGLCANVASLIBS "gl") - # aui ? + SET(WXGLCANVASLIBS "gl") + SET(WXAUILIBS "aui") # LG : These options should be set by the user at top level of crea - FIND_PACKAGE(wxWidgets COMPONENTS base core adv html + FIND_PACKAGE(wxWidgets COMPONENTS base core adv html ${WXAUILIBS} ${WXGLCANVASLIBS}) # @@ -91,7 +91,8 @@ MACRO(CREA_USE_WXWIDGETS) # Preprocessor settings CREA_DEFINE( USE_WXWIDGETS ) CREA_DEFINE( _USE_WXWIDGETS_ ) - # + + # IF(WIN32) # Clean ? SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${WXWIDGETS_CXX_FLAGS}") @@ -119,7 +120,7 @@ MACRO(CREA_USE_WXWIDGETS) # GTK3 INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS}) LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS}) - LINK_LIBRARIES(${GTK3_LIBRARIES}) + LINK_LIBRARIES(${GTK3_LIBRARIES} ) # WX @@ -127,10 +128,14 @@ MACRO(CREA_USE_WXWIDGETS) INCLUDE( ${wxWidgets_USE_FILE} ) MARK_AS_ADVANCED(wxWidgets_CONFIG_EXECUTABLE) SET(WXWIDGETS_LIBRARIES - ${GTK2_LIBRARIES} +## GTK2 +## ${GTK2_LIBRARIES} + ${GTK3_LIBRARIES} #${GTK_LIBRARIES} + ${wxWidgets_LIBRARIES} ) + ENDIF(WIN32) ENDMACRO(CREA_USE_WXWIDGETS) #======================================================================= diff --git a/lib/creaDevManagerLib/wxCDMMainDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMMainDescriptionPanel.cpp index dbe66c1..1b9c970 100644 --- a/lib/creaDevManagerLib/wxCDMMainDescriptionPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMMainDescriptionPanel.cpp @@ -73,13 +73,16 @@ bool wxCDMMainDescriptionPanel::Create( long style ) { - wxPanel::Create(parent, id, pos, size, style); +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 + wxPanel::Create(parent, id, pos, size, style); +#else + wxScrolledWindow::Create(parent, id, pos, size, style); +#endif CreateControls(); //to scroll this->FitInside(); // ask the sizer about the needed size this->SetScrollRate(5, 5); - - return TRUE; } diff --git a/src/creawxVTKRenderWindowInteractor.cxx b/src/creawxVTKRenderWindowInteractor.cxx index 3c421e5..251a7cd 100644 --- a/src/creawxVTKRenderWindowInteractor.cxx +++ b/src/creawxVTKRenderWindowInteractor.cxx @@ -1,47 +1,48 @@ /* -# --------------------------------------------------------------------- -# -# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image -# pour la Santé) -# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton -# Previous Authors : Laurent Guigues, Jean-Pierre Roux -# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil -# -# This software is governed by the CeCILL-B license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL-B -# license as circulated by CEA, CNRS and INRIA at the following URL -# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -# or in the file LICENSE.txt. -# -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. -# -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL-B license and that you accept its terms. -# ------------------------------------------------------------------------ -*/ + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + /*========================================================================= Program: Visualization Toolkit - Module: $RCSfile: creawxVTKRenderWindowInteractor.cxx,v $ + Module: $RCSfile$ Language: C++ - Date: $Date: 2012/11/15 10:43:26 $ - Version: $Revision: 1.11 $ + 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 + 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. =========================================================================*/ -#ifdef USE_WXWIDGETS -#ifdef USE_VTK - #include #include "creawxVTKRenderWindowInteractor.h" @@ -58,15 +59,30 @@ #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 VTK_USE_COCOA - #include "vtkCocoaRenderWindow.h" +#ifdef __WXCOCOA__ +#include "vtkCocoaRenderWindow.h" #else - #include "vtkCarbonRenderWindow.h" +#include "vtkCarbonRenderWindow.h" #endif - #endif +//======================================================================= +// LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS +namespace crea +{ + + //Keep this for compatibilty reason, this was introduced in wxGTK 2.4.0 #if (!wxCHECK_VERSION(2, 4, 0)) wxWindow* wxGetTopLevelParent(wxWindow *win) @@ -76,6 +92,9 @@ wxWindow* wxGetTopLevelParent(wxWindow *win) return win; } #endif +} +// LG : EO namespace bbwxvtk +//======================================================================= // To access objc calls on cocoa #ifdef __WXCOCOA__ @@ -88,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_WINDOW_XWINDOW is found here in wxWidgets 2.8.0 - #include "gdk/gdkprivate.h" - #if wxCHECK_VERSION(2, 8, 0) - #ifdef __WXGTK20__ - #include - #else - #include - #endif - #else - #include - #endif - #define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \ + #include // 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 + #include + #include + #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 + #else + #include + #endif + #else + #include + #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 #include +#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: @@ -131,64 +162,93 @@ wxWindow* wxGetTopLevelParent(wxWindow *win) # define WX_USE_X_CAPTURE 1 #endif -#define ID_creawxVTKRenderWindowInteractor_TIMER 1001 +#define ID_wxVTKRenderWindowInteractor_TIMER 1001 +//======================================================================= +// LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS namespace crea { #if defined(__WXGTK__) && defined(USE_WXGLCANVAS) -IMPLEMENT_DYNAMIC_CLASS(creawxVTKRenderWindowInteractor, wxGLCanvas) - #else -IMPLEMENT_DYNAMIC_CLASS(creawxVTKRenderWindowInteractor, wxWindow) #endif //__WXGTK__ //--------------------------------------------------------------------------- #if defined(__WXGTK__) && defined(USE_WXGLCANVAS) -BEGIN_EVENT_TABLE(creawxVTKRenderWindowInteractor, 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(creawxVTKRenderWindowInteractor, 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 (creawxVTKRenderWindowInteractor::OnPaint) - EVT_ERASE_BACKGROUND(creawxVTKRenderWindowInteractor::OnEraseBackground) - EVT_MOTION (creawxVTKRenderWindowInteractor::OnMotion) + EVT_PAINT (wxVTKRenderWindowInteractor::OnPaint) + EVT_ERASE_BACKGROUND(wxVTKRenderWindowInteractor::OnEraseBackground) + EVT_MOTION (wxVTKRenderWindowInteractor::OnMotion) //Bind the events to the event converters - EVT_LEFT_DOWN (creawxVTKRenderWindowInteractor::OnButtonDown) - EVT_MIDDLE_DOWN (creawxVTKRenderWindowInteractor::OnButtonDown) - EVT_RIGHT_DOWN (creawxVTKRenderWindowInteractor::OnButtonDown) - EVT_LEFT_UP (creawxVTKRenderWindowInteractor::OnButtonUp) - EVT_MIDDLE_UP (creawxVTKRenderWindowInteractor::OnButtonUp) - EVT_RIGHT_UP (creawxVTKRenderWindowInteractor::OnButtonUp) + EVT_LEFT_DOWN (wxVTKRenderWindowInteractor::OnButtonDown) + EVT_MIDDLE_DOWN (wxVTKRenderWindowInteractor::OnButtonDown) + EVT_RIGHT_DOWN (wxVTKRenderWindowInteractor::OnButtonDown) + EVT_LEFT_UP (wxVTKRenderWindowInteractor::OnButtonUp) + EVT_MIDDLE_UP (wxVTKRenderWindowInteractor::OnButtonUp) + EVT_RIGHT_UP (wxVTKRenderWindowInteractor::OnButtonUp) #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1) - EVT_ENTER_WINDOW(creawxVTKRenderWindowInteractor::OnEnter) - EVT_LEAVE_WINDOW(creawxVTKRenderWindowInteractor::OnLeave) - EVT_MOUSEWHEEL (creawxVTKRenderWindowInteractor::OnMouseWheel) - EVT_KEY_DOWN (creawxVTKRenderWindowInteractor::OnKeyDown) - EVT_KEY_UP (creawxVTKRenderWindowInteractor::OnKeyUp) - EVT_CHAR (creawxVTKRenderWindowInteractor::OnChar) -#endif - EVT_TIMER (ID_creawxVTKRenderWindowInteractor_TIMER, creawxVTKRenderWindowInteractor::OnTimer) - EVT_SIZE (creawxVTKRenderWindowInteractor::OnSize) + 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) +#endif + EVT_TIMER (ID_wxVTKRenderWindowInteractor_TIMER, wxVTKRenderWindowInteractor::OnTimer) + EVT_SIZE (wxVTKRenderWindowInteractor::OnSize) END_EVENT_TABLE() -//EED win Compilation why??: vtkCxxRevisionMacro(creawxVTKRenderWindowInteractor, "$Revision: 1.11 $") -vtkInstantiatorNewMacro(creawxVTKRenderWindowInteractor) +vtkCxxRevisionMacro(wxVTKRenderWindowInteractor, "$Revision$") +vtkInstantiatorNewMacro(wxVTKRenderWindowInteractor) -//--------------------------------------------------------------------------- #if defined(__WXGTK__) && defined(USE_WXGLCANVAS) -#if (wxCHECK_VERSION(2, 8, 0)) -creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : wxGLCanvas(0, -1, wxDefaultPosition), vtkRenderWindowInteractor() -#else -creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : 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 -creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : wxWindow(), vtkRenderWindowInteractor() + : wxWindow(), #endif //__WXGTK__ - , timer(this, ID_creawxVTKRenderWindowInteractor_TIMER) + + vtkRenderWindowInteractor() + , timer(this, ID_wxVTKRenderWindowInteractor_TIMER) , ActiveButton(wxEVT_NULL) - , RenderAllowed(0) , Stereo(0) , Handle(0) , Created(true) @@ -196,27 +256,34 @@ creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : wxWindow(), , UseCaptureMouse(0) { #ifdef VTK_DEBUG_LEAKS - vtkDebugLeaks::ConstructClass("creawxVTKRenderWindowInteractor"); + vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor"); +#endif +#if defined(__WXGTK__) && defined(USE_WXGLCANVAS) + this->context = new wxGLContext(this); #endif this->RenderWindow = NULL; this->SetRenderWindow(vtkRenderWindow::New()); this->RenderWindow->Delete(); } //--------------------------------------------------------------------------- -creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor(wxWindow *parent, +wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, 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__ - , timer(this, ID_creawxVTKRenderWindowInteractor_TIMER) + , vtkRenderWindowInteractor() + , timer(this, ID_wxVTKRenderWindowInteractor_TIMER) , ActiveButton(wxEVT_NULL) - , RenderAllowed(0) , Stereo(0) , Handle(0) , Created(true) @@ -224,7 +291,10 @@ creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor(wxWindow *paren , UseCaptureMouse(0) { #ifdef VTK_DEBUG_LEAKS - vtkDebugLeaks::ConstructClass("creawxVTKRenderWindowInteractor"); + vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor"); +#endif +#if defined(__WXGTK__) && defined(USE_WXGLCANVAS) + this->context = new wxGLContext(this); #endif this->RenderWindow = NULL; this->SetRenderWindow(vtkRenderWindow::New()); @@ -236,19 +306,22 @@ creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor(wxWindow *paren #endif } //--------------------------------------------------------------------------- -creawxVTKRenderWindowInteractor::~creawxVTKRenderWindowInteractor() +wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor() { SetRenderWindow(NULL); SetInteractorStyle(NULL); +#if defined(__WXGTK__) && defined(USE_WXGLCANVAS) + delete this->context; +#endif } //--------------------------------------------------------------------------- -creawxVTKRenderWindowInteractor * creawxVTKRenderWindowInteractor::New() +wxVTKRenderWindowInteractor * wxVTKRenderWindowInteractor::New() { // we don't make use of the objectfactory, because we're not registered - return new creawxVTKRenderWindowInteractor; + return new wxVTKRenderWindowInteractor; } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::Initialize() +void wxVTKRenderWindowInteractor::Initialize() { int *size = RenderWindow->GetSize(); // enable everything and start rendering @@ -263,7 +336,7 @@ void creawxVTKRenderWindowInteractor::Initialize() Initialized = 1; } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::Enable() +void wxVTKRenderWindowInteractor::Enable() { // if already enabled then done if (Enabled) @@ -272,12 +345,12 @@ void creawxVTKRenderWindowInteractor::Enable() // that's it Enabled = 1; #if defined(__WXGTK__) && defined(USE_WXGLCANVAS) - SetCurrent(); + wxGLCanvas::SetCurrent(*this->context); #endif Modified(); } //--------------------------------------------------------------------------- -bool creawxVTKRenderWindowInteractor::Enable(bool enable) +bool wxVTKRenderWindowInteractor::Enable(bool enable) { #if defined(__WXGTK__) && defined(USE_WXGLCANVAS) return wxGLCanvas::Enable(enable); @@ -286,7 +359,7 @@ bool creawxVTKRenderWindowInteractor::Enable(bool enable) #endif } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::Disable() +void wxVTKRenderWindowInteractor::Disable() { // if already disabled then done if (!Enabled) @@ -297,14 +370,14 @@ void creawxVTKRenderWindowInteractor::Disable() Modified(); } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::Start() +void wxVTKRenderWindowInteractor::Start() { // the interactor cannot control the event loop - vtkErrorMacro( << "creawxVTKRenderWindowInteractor::Start() " + vtkErrorMacro( << "wxVTKRenderWindowInteractor::Start() " "interactor cannot control event loop."); } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::UpdateSize(int x, int y) +void wxVTKRenderWindowInteractor::UpdateSize(int x, int y) { if( RenderWindow ) { @@ -316,37 +389,63 @@ void creawxVTKRenderWindowInteractor::UpdateSize(int x, int y) Size[1] = y; // and our RenderWindow's size RenderWindow->SetSize(x, y); +#if defined(__WXMSW__) + this->Refresh(); +#endif //__WXMSW__ } } } //--------------------------------------------------------------------------- -int creawxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype)) +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 creawxVTKRenderWindowInteractor::DestroyTimer() +int wxVTKRenderWindowInteractor::DestroyTimer() { // do nothing return 1; } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event)) +void wxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event)) { if (!Enabled) 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 } @@ -359,43 +458,34 @@ void creawxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event)) // Anyway if this happen to break for you then compare to a recent version of wxPython // and look for the function long wxPyGetWinHandle(wxWindow* win) // in wxPython/src/helpers.cpp -long creawxVTKRenderWindowInteractor::GetHandleHack() +long wxVTKRenderWindowInteractor::GetHandleHack() { //helper function to hide the MSW vs GTK stuff 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( - wxGetTopLevelParent( this ) ); + wxTopLevelWindow* toplevel = dynamic_cast(wxGetTopLevelParent( this ) ); if (toplevel != NULL ) { - handle_tmp = (long)toplevel->GetNSWindow(); + handle_tmp = (long)toplevel->GetNSWindow(); } - // The NSView will be deducted from + // 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__ @@ -405,7 +495,7 @@ long creawxVTKRenderWindowInteractor::GetHandleHack() return handle_tmp; } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event)) +void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event)) { //must always be here wxPaintDC pDC(this); @@ -415,46 +505,63 @@ void creawxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event)) { Handle = GetHandleHack(); RenderWindow->SetWindowId(reinterpret_cast(Handle)); +// Cocoa +// this->GetNSView() <-> DisplayId +// this->GetTopLevel()->GetNSWindow() <-> WindowId #ifdef __WXMSW__ RenderWindow->SetParentId(reinterpret_cast(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__ - -#ifdef VTK_USE_COCOA - vtkCocoaRenderWindow* rwin = vtkCocoaRenderWindow::SafeDownCast(RenderWindow); - if( rwin ) - { - rwin->UpdateContext(); - } -#else // 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 creawxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event) +void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event) { //turn off background erase to reduce flickering on MSW event.Skip(false); } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event)) +void wxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event)) { int w, h; GetClientSize(&w, &h); UpdateSize(w, h); - if (!Enabled) + if (!Enabled) { return; } @@ -466,14 +573,14 @@ void creawxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event)) //Render(); } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event) +void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event) { - if (!Enabled) + if (!Enabled) { return; } #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) - SetEventInformationFlipY(event.GetX(), event.GetY(), + SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL); InvokeEvent(vtkCommand::MouseMoveEvent, NULL); @@ -484,49 +591,49 @@ void creawxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event) } //--------------------------------------------------------------------------- #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1) -void creawxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event) +void wxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event) { - if (!Enabled) + if (!Enabled) { return; } #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style - SetEventInformationFlipY(event.GetX(), event.GetY(), + SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL); InvokeEvent(vtkCommand::EnterEvent, NULL); #else // old style InteractorStyle->OnEnter(event.ControlDown(), event.ShiftDown(), - event.GetX(), Size[1] - event.GetY() - 1); + event.GetX(), Size[1] - event.GetY() - 1); #endif } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event) +void wxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event) { - if (!Enabled) + if (!Enabled) { return; } #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style - SetEventInformationFlipY(event.GetX(), event.GetY(), + SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL); InvokeEvent(vtkCommand::LeaveEvent, NULL); #else // old style InteractorStyle->OnLeave(event.ControlDown(), event.ShiftDown(), - event.GetX(), Size[1] - event.GetY() - 1); + event.GetX(), Size[1] - event.GetY() - 1); #endif } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event) +void wxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event) { - if (!Enabled) + if (!Enabled) { return; } @@ -544,19 +651,19 @@ void creawxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event) // 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, + SetEventInformationFlipY(mousePos.x, mousePos.y, event.ControlDown(), event.ShiftDown(), key, 0, NULL); InvokeEvent(vtkCommand::KeyPressEvent, NULL); #else - InteractorStyle->OnKeyDown(event.ControlDown(), event.ShiftDown(), + InteractorStyle->OnKeyDown(event.ControlDown(), event.ShiftDown(), event.GetKeyCode(), 1); #endif event.Skip(); } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event) +void wxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event) { - if (!Enabled) + if (!Enabled) { return; } @@ -574,24 +681,24 @@ void creawxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event) // 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, + SetEventInformationFlipY(mousePos.x, mousePos.y, event.ControlDown(), event.ShiftDown(), key, 0, NULL); InvokeEvent(vtkCommand::KeyReleaseEvent, NULL); #else - InteractorStyle->OnKeyUp(event.ControlDown(), event.ShiftDown(), + InteractorStyle->OnKeyUp(event.ControlDown(), event.ShiftDown(), event.GetKeyCode(), 1); #endif event.Skip(); } #endif //!(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1) //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event) +void wxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event) { - if (!Enabled) + if (!Enabled) { return; } - + #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style int keycode = event.GetKeyCode(); @@ -605,14 +712,14 @@ void creawxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event) // 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, + SetEventInformationFlipY(mousePos.x, mousePos.y, event.ControlDown(), event.ShiftDown(), key, 0, NULL); InvokeEvent(vtkCommand::CharEvent, NULL); #endif event.Skip(); } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event) +void wxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event) { if (!Enabled || (ActiveButton != wxEVT_NULL)) { @@ -627,7 +734,7 @@ void creawxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event) this->SetFocus(); #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) - SetEventInformationFlipY(event.GetX(), event.GetY(), + SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL); #endif @@ -636,7 +743,7 @@ void creawxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event) #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style InvokeEvent(vtkCommand::RightButtonPressEvent, NULL); -#else +#else // old style InteractorStyle->OnRightButtonDown(event.ControlDown(), event.ShiftDown(), event.GetX(), Size[1] - event.GetY() - 1); @@ -647,7 +754,7 @@ void creawxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event) #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL); -#else +#else // old style InteractorStyle->OnLeftButtonDown(event.ControlDown(), event.ShiftDown(), event.GetX(), Size[1] - event.GetY() - 1); @@ -658,7 +765,7 @@ void creawxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event) #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style InvokeEvent(vtkCommand::MiddleButtonPressEvent, NULL); -#else +#else // old style InteractorStyle->OnMiddleButtonDown(event.ControlDown(), event.ShiftDown(), event.GetX(), Size[1] - event.GetY() - 1); @@ -674,28 +781,31 @@ void creawxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event) } } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event) +void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event) { //EVT_xxx_DOWN == EVT_xxx_UP - 1 //This is only needed if two mouse buttons are pressed at the same time. - //In wxWindows 2.4 and later: better use of wxMOUSE_BTN_RIGHT or + //In wxWindows 2.4 and later: better use of wxMOUSE_BTN_RIGHT or //wxEVT_COMMAND_RIGHT_CLICK - if (!Enabled || (ActiveButton != (event.GetEventType()-1))) + if (!Enabled || (ActiveButton != (event.GetEventType()-1))) { 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(), + SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL); #endif - + if(ActiveButton == wxEVT_RIGHT_DOWN) { #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style InvokeEvent(vtkCommand::RightButtonReleaseEvent, NULL); -#else +#else // old style InteractorStyle->OnRightButtonUp(event.ControlDown(), event.ShiftDown(), event.GetX(), Size[1] - event.GetY() - 1); @@ -706,7 +816,7 @@ void creawxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event) #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL); -#else +#else // old style InteractorStyle->OnLeftButtonUp(event.ControlDown(), event.ShiftDown(), event.GetX(), Size[1] - event.GetY() - 1); @@ -717,7 +827,7 @@ void creawxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event) #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, NULL); -#else +#else // old style InteractorStyle->OnMiddleButtonUp(event.ControlDown(), event.ShiftDown(), event.GetX(), Size[1] - event.GetY() - 1); @@ -731,14 +841,14 @@ void creawxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event) ActiveButton = wxEVT_NULL; } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::OnMouseWheel(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) { @@ -751,14 +861,35 @@ void creawxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event) InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL); } #endif + +} +//--------------------------------------------------------------------------- +#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 creawxVTKRenderWindowInteractor::Render() +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 @@ -766,13 +897,16 @@ void creawxVTKRenderWindowInteractor::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(); @@ -792,7 +926,7 @@ void creawxVTKRenderWindowInteractor::Render() } } //--------------------------------------------------------------------------- -void creawxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue) +void wxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue) { //Change value of __RenderWhenDisabled ivar. //If __RenderWhenDisabled is false (the default), this widget will not @@ -805,19 +939,19 @@ void creawxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue) //it does this by disabling all windows (disallowing user-input to //prevent re-entrancy of code) and then handling all outstanding //GUI events. - + //However, this often triggers an OnPaint() method for wxVTKRWIs, //resulting in a Render(), resulting in Update() being called whilst //still in progress. - RenderWhenDisabled = newValue != 0; + RenderWhenDisabled = (bool)newValue; } //--------------------------------------------------------------------------- // // Set the variable that indicates that we want a stereo capable window // be created. This method can only be called before a window is realized. // -void creawxVTKRenderWindowInteractor::SetStereo(int capable) +void wxVTKRenderWindowInteractor::SetStereo(int capable) { if (Stereo != capable) { @@ -831,17 +965,14 @@ void creawxVTKRenderWindowInteractor::SetStereo(int capable) //--------------------------------------------------------------------------- // // -void creawxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent) +void wxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); } - } -// LG : EO namespace +// LG : EO namespace bbwxvtk //======================================================================= -#endif // USE_WX -#endif // USE_VTK diff --git a/src/creawxVTKRenderWindowInteractor.h b/src/creawxVTKRenderWindowInteractor.h index daf7f4e..0d03187 100644 --- a/src/creawxVTKRenderWindowInteractor.h +++ b/src/creawxVTKRenderWindowInteractor.h @@ -1,50 +1,54 @@ /* -# --------------------------------------------------------------------- -# -# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image -# pour la Santé) -# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton -# Previous Authors : Laurent Guigues, Jean-Pierre Roux -# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil -# -# This software is governed by the CeCILL-B license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL-B -# license as circulated by CEA, CNRS and INRIA at the following URL -# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -# or in the file LICENSE.txt. -# -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. -# -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL-B license and that you accept its terms. -# ------------------------------------------------------------------------ -*/ + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + /*========================================================================= Program: Visualization Toolkit - Module: $RCSfile: creawxVTKRenderWindowInteractor.h,v $ + Module: $RCSfile$ Language: C++ - Date: $Date: 2012/11/15 10:43:26 $ - Version: $Revision: 1.9 $ + 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. + 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 creawxVTKRenderWindowInteractor - class to enable VTK to render to +// .NAME wxVTKRenderWindowInteractor - class to enable VTK to render to // and interact with wxWindow. // .SECTION Description -// creawxVTKRenderWindowInteractor provide a VTK widget for wxWindow. This class +// wxVTKRenderWindowInteractor provide a VTK widget for wxWindow. This class // was completely rewrote to have the 'Look & Feel' of the python version: -// creawxVTKRenderWindowInteractor.py +// wxVTKRenderWindowInteractor.py // .SECTION Caveats // - There is a know bug that prevent this class to works for more info see // WX_USE_X_CAPTURE. This bug only affect wxGTK from 2.3.2 to wxGTK 2.4.0. @@ -55,16 +59,10 @@ // - This class might not be easily readable as it tried to work with VTK 3.2 // and 4.x. This class doesn't support reparenting with VTK 4.2 and earlier. // .SECTION see also -// creawxVTKRenderWindowInteractor.py wxVTKRenderWindow.py - -#ifndef _creawxVTKRenderWindowInteractor_h_ -#define _creawxVTKRenderWindowInteractor_h_ +// wxVTKRenderWindowInteractor.py wxVTKRenderWindow.py -#ifdef USE_WXWIDGETS -#ifdef USE_VTK - -#include -#include +#ifndef _wxVTKRenderWindowInteractor_h_ +#define _wxVTKRenderWindowInteractor_h_ // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -84,14 +82,7 @@ #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 @@ -103,7 +94,7 @@ // Motif version (renamed into wxX11 for wxWindow 2.4 and newer) #if defined(__WXMOTIF__) -# error This GUI is not supported by creawxVTKRenderWindowInteractor for now +# error This GUI is not supported by wxVTKRenderWindowInteractor for now #endif // wx forward declarations @@ -120,29 +111,34 @@ namespace crea #if defined(__WXGTK__) && defined(USE_WXGLCANVAS) -class CREA_EXPORT creawxVTKRenderWindowInteractor : public wxGLCanvas, virtual public vtkRenderWindowInteractor +class wxVTKRenderWindowInteractor : public wxGLCanvas, public vtkRenderWindowInteractor #else -class CREA_EXPORT creawxVTKRenderWindowInteractor : virtual public vtkRenderWindowInteractor, public wxWindow +class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInteractor #endif //__WXGTK__ { - DECLARE_DYNAMIC_CLASS(creawxVTKRenderWindowInteractor) +//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 - creawxVTKRenderWindowInteractor(); + wxVTKRenderWindowInteractor(); - creawxVTKRenderWindowInteractor(wxWindow *parent, + wxVTKRenderWindowInteractor(wxWindow *parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE, const wxString &name = wxPanelNameStr); - //EED win Compilation why ??: vtkTypeRevisionMacro(creawxVTKRenderWindowInteractor,vtkRenderWindowInteractor); - static creawxVTKRenderWindowInteractor * New(); + vtkTypeRevisionMacro(wxVTKRenderWindowInteractor,vtkRenderWindowInteractor); + static wxVTKRenderWindowInteractor * New(); void PrintSelf(ostream& os, vtkIndent indent); //destructor - ~creawxVTKRenderWindowInteractor(); + ~wxVTKRenderWindowInteractor(); // vtkRenderWindowInteractor overrides void Initialize(); @@ -165,13 +161,16 @@ class CREA_EXPORT creawxVTKRenderWindowInteractor : virtual public vtkRenderWind #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); @@ -190,10 +189,18 @@ class CREA_EXPORT creawxVTKRenderWindowInteractor : virtual public vtkRenderWind 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; @@ -206,13 +213,8 @@ class CREA_EXPORT creawxVTKRenderWindowInteractor : virtual public vtkRenderWind DECLARE_EVENT_TABLE() }; - } -// LG : EO namespace crea +// LG : EO namespace bbwxvtk //====================================================================== -#endif // USE_WX -#endif // USE_VTK - - -#endif //_creawxVTKRenderWindowInteractor_h_ +#endif //_wxVTKRenderWindowInteractor_h_