2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Program: Visualization Toolkit
31 Module: $RCSfile: wxVTKRenderWindowInteractor.cxx,v $
33 Date: $Date: 2012/11/16 08:52:36 $
34 Version: $Revision: 1.5 $
36 =========================================================================*/
40 #include "wxVTKRenderWindowInteractor.h"
42 //This is needed for vtk 3.1 :
43 #ifndef VTK_MAJOR_VERSION
44 # include "vtkVersion.h"
47 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
48 # include "vtkCommand.h"
50 # include "vtkInteractorStyle.h"
52 #include "vtkDebugLeaks.h"
55 #include "vtkCarbonRenderWindow.h"
58 //=======================================================================
59 // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS
64 //Keep this for compatibilty reason, this was introduced in wxGTK 2.4.0
65 #if (!wxCHECK_VERSION(2, 4, 0))
66 wxWindow* wxGetTopLevelParent(wxWindow *win)
68 while ( win && !win->IsTopLevel() )
69 win = win->GetParent();
74 // LG : EO namespace bbwxvtk
75 //=======================================================================
77 // To access objc calls on cocoa
80 #import <Cocoa/Cocoa.h>
81 // This trick is no longer need in VTK CVS, should get rid of that:
84 #error Build mismatch you need both wxWidgets and VTK to be configure against Cocoa to work
85 #endif //VTK_USE_COCOA
89 # include <gdk/gdkx.h> // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0
90 # include "gdk/gdkprivate.h"
91 #if wxCHECK_VERSION(2, 8, 0)
93 #include <wx/gtk/win_gtk.h>
95 #include <wx/gtk1/win_gtk.h>
98 #include <wx/gtk/win_gtk.h>
100 #define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
101 GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \
102 GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
106 #include "wx/x11/privx.h"
107 #define GetXWindow(wxwin) ((Window)(wxwin)->GetHandle())
111 //For more info on this class please go to:
112 //http://wxvtk.sf.net
113 //This hack is for some buggy wxGTK version:
114 #if wxCHECK_VERSION(2, 3, 2) && !wxCHECK_VERSION(2, 4, 1) && defined(__WXGTK__)
115 # define WX_USE_X_CAPTURE 0
117 # define WX_USE_X_CAPTURE 1
120 #define ID_wxVTKRenderWindowInteractor_TIMER 1001
122 //=======================================================================
123 // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS
127 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
128 IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxGLCanvas)
130 IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxWindow)
133 //---------------------------------------------------------------------------
134 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
135 BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxGLCanvas)
137 BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
139 //refresh window by doing a Render
140 EVT_PAINT (wxVTKRenderWindowInteractor::OnPaint)
141 EVT_ERASE_BACKGROUND(wxVTKRenderWindowInteractor::OnEraseBackground)
142 EVT_MOTION (wxVTKRenderWindowInteractor::OnMotion)
144 //Bind the events to the event converters
145 EVT_LEFT_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
146 EVT_MIDDLE_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
147 EVT_RIGHT_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
148 EVT_LEFT_UP (wxVTKRenderWindowInteractor::OnButtonUp)
149 EVT_MIDDLE_UP (wxVTKRenderWindowInteractor::OnButtonUp)
150 EVT_RIGHT_UP (wxVTKRenderWindowInteractor::OnButtonUp)
151 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
152 EVT_ENTER_WINDOW(wxVTKRenderWindowInteractor::OnEnter)
153 EVT_LEAVE_WINDOW(wxVTKRenderWindowInteractor::OnLeave)
154 EVT_MOUSEWHEEL (wxVTKRenderWindowInteractor::OnMouseWheel)
155 EVT_KEY_DOWN (wxVTKRenderWindowInteractor::OnKeyDown)
156 EVT_KEY_UP (wxVTKRenderWindowInteractor::OnKeyUp)
157 EVT_CHAR (wxVTKRenderWindowInteractor::OnChar)
159 EVT_TIMER (ID_wxVTKRenderWindowInteractor_TIMER, wxVTKRenderWindowInteractor::OnTimer)
160 EVT_SIZE (wxVTKRenderWindowInteractor::OnSize)
165 //EED 2017-01-01 Migration VTK7
166 #if VTK_MAJOR_VERSION <= 5
167 vtkCxxRevisionMacro(wxVTKRenderWindowInteractor, "$Revision: 1.5 $")
172 vtkInstantiatorNewMacro(wxVTKRenderWindowInteractor)
174 //---------------------------------------------------------------------------
175 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
176 #if (wxCHECK_VERSION(2, 8, 0))
177 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(0, -1, wxDefaultPosition), vtkRenderWindowInteractor()
179 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(), vtkRenderWindowInteractor()
182 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxWindow(), vtkRenderWindowInteractor()
184 , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
185 , ActiveButton(wxEVT_NULL)
190 , RenderWhenDisabled(1)
193 #ifdef VTK_DEBUG_LEAKS
194 vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
196 this->RenderWindow = NULL;
197 this->SetRenderWindow(vtkRenderWindow::New());
198 this->RenderWindow->Delete();
200 //---------------------------------------------------------------------------
201 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
206 const wxString &name)
207 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
208 : wxGLCanvas(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
210 : wxWindow(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
212 , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
213 , ActiveButton(wxEVT_NULL)
218 , RenderWhenDisabled(1)
221 #ifdef VTK_DEBUG_LEAKS
222 vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
224 this->RenderWindow = NULL;
225 this->SetRenderWindow(vtkRenderWindow::New());
226 this->RenderWindow->Delete();
228 // On Mac (Carbon) we don't get notified of the initial window size with an EVT_SIZE event,
229 // so we update the size information of the interactor/renderwindow here
230 this->UpdateSize(size.x, size.y);
233 //---------------------------------------------------------------------------
234 wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor()
236 SetRenderWindow(NULL);
237 SetInteractorStyle(NULL);
239 //---------------------------------------------------------------------------
240 wxVTKRenderWindowInteractor * wxVTKRenderWindowInteractor::New()
242 // we don't make use of the objectfactory, because we're not registered
243 return new wxVTKRenderWindowInteractor;
245 //---------------------------------------------------------------------------
246 void wxVTKRenderWindowInteractor::Initialize()
248 int *size = RenderWindow->GetSize();
249 // enable everything and start rendering
251 //RenderWindow->Start();
253 // set the size in the render window interactor
257 // this is initialized
260 //---------------------------------------------------------------------------
261 void wxVTKRenderWindowInteractor::Enable()
263 // if already enabled then done
269 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
274 //---------------------------------------------------------------------------
275 bool wxVTKRenderWindowInteractor::Enable(bool enable)
277 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
278 return wxGLCanvas::Enable(enable);
280 return wxWindow::Enable(enable);
283 //---------------------------------------------------------------------------
284 void wxVTKRenderWindowInteractor::Disable()
286 // if already disabled then done
290 // that's it (we can't remove the event handler like it should be...)
294 //---------------------------------------------------------------------------
295 void wxVTKRenderWindowInteractor::Start()
297 // the interactor cannot control the event loop
298 vtkErrorMacro( << "wxVTKRenderWindowInteractor::Start() "
299 "interactor cannot control event loop.");
301 //---------------------------------------------------------------------------
302 void wxVTKRenderWindowInteractor::UpdateSize(int x, int y)
306 // if the size changed tell render window
307 if ( x != Size[0] || y != Size[1] )
309 // adjust our (vtkRenderWindowInteractor size)
312 // and our RenderWindow's size
313 RenderWindow->SetSize(x, y);
317 //---------------------------------------------------------------------------
318 int wxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype))
320 // it's a one shot timer
321 if (!timer.Start(10, TRUE))
327 //---------------------------------------------------------------------------
328 int wxVTKRenderWindowInteractor::DestroyTimer()
333 //---------------------------------------------------------------------------
334 void wxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event))
339 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
341 InvokeEvent(vtkCommand::TimerEvent, NULL);
344 InteractorStyle->OnTimer();
348 //---------------------------------------------------------------------------
349 // NOTE on implementation:
350 // Bad luck you ended up in the only tricky place of this code.
351 // A few note, wxWidgets still refuse to provide such convenient method
352 // so I have to maintain it myself, eventhough this is completely integrated
354 // Anyway if this happen to break for you then compare to a recent version of wxPython
355 // and look for the function long wxPyGetWinHandle(wxWindow* win)
356 // in wxPython/src/helpers.cpp
357 long wxVTKRenderWindowInteractor::GetHandleHack()
359 //helper function to hide the MSW vs GTK stuff
362 // __WXMSW__ is for Win32
363 //__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)
364 // __WXGTK__ is for both gtk 1.2.x and gtk 2.x
365 #if defined(__WXMSW__) || defined(__WXMAC__)
366 handle_tmp = (long)this->GetHandle();
369 //__WXCOCOA__ stands for using the objective-c Cocoa API
371 // Here is how to find the NSWindow
372 wxTopLevelWindow* toplevel = dynamic_cast<wxTopLevelWindow*>(
373 wxGetTopLevelParent( this ) );
374 if (toplevel != NULL )
376 handle_tmp = (long)toplevel->GetNSWindow();
378 // The NSView will be deducted from
379 // [(NSWindow*)Handle contentView]
380 // if only I knew how to write that in c++
383 // Find and return the actual X-Window.
384 #if defined(__WXGTK__) || defined(__WXX11__)
385 return (long)GetXWindow(this);
389 // handle_tmp = (long)this->GetXWindow();
394 //---------------------------------------------------------------------------
395 void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
397 //must always be here
400 //do it here rather than in the cstor: this is safer.
403 Handle = GetHandleHack();
404 RenderWindow->SetWindowId(reinterpret_cast<void *>(Handle));
406 RenderWindow->SetParentId(reinterpret_cast<void *>(this->GetParent()->GetHWND()));
409 // get vtk to render to the wxWindows
412 // This solves a problem with repainting after a window resize
413 // See also: http://sourceforge.net/mailarchive/forum.php?thread_id=31690967&forum_id=41789
414 vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow);
417 rwin->UpdateGLRegion();
421 //---------------------------------------------------------------------------
422 void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event)
424 //turn off background erase to reduce flickering on MSW
427 //---------------------------------------------------------------------------
428 void wxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event))
431 GetClientSize(&w, &h);
439 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
440 InvokeEvent(vtkCommand::ConfigureEvent, NULL);
442 //this will check for Handle
445 //---------------------------------------------------------------------------
446 void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event)
452 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
453 SetEventInformationFlipY(event.GetX(), event.GetY(),
454 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
456 InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
458 InteractorStyle->OnMouseMove(event.ControlDown(), event.ShiftDown(),
459 event.GetX(), Size[1] - event.GetY() - 1);
462 //---------------------------------------------------------------------------
463 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
464 void wxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event)
471 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
473 SetEventInformationFlipY(event.GetX(), event.GetY(),
474 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
476 InvokeEvent(vtkCommand::EnterEvent, NULL);
479 InteractorStyle->OnEnter(event.ControlDown(), event.ShiftDown(),
480 event.GetX(), Size[1] - event.GetY() - 1);
483 //---------------------------------------------------------------------------
484 void wxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event)
491 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
493 SetEventInformationFlipY(event.GetX(), event.GetY(),
494 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
496 InvokeEvent(vtkCommand::LeaveEvent, NULL);
499 InteractorStyle->OnLeave(event.ControlDown(), event.ShiftDown(),
500 event.GetX(), Size[1] - event.GetY() - 1);
503 //---------------------------------------------------------------------------
504 void wxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event)
511 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
513 int keycode = event.GetKeyCode();
515 if (((unsigned int)keycode) < 256)
517 // TODO: Unicode in non-Unicode mode ??
521 // we don't get a valid mouse position inside the key event on every platform
522 // so we retrieve the mouse position explicitly and pass it along
523 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
524 SetEventInformationFlipY(mousePos.x, mousePos.y,
525 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
526 InvokeEvent(vtkCommand::KeyPressEvent, NULL);
528 InteractorStyle->OnKeyDown(event.ControlDown(), event.ShiftDown(),
529 event.GetKeyCode(), 1);
533 //---------------------------------------------------------------------------
534 void wxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event)
541 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
543 int keycode = event.GetKeyCode();
545 if (((unsigned int)keycode) < 256)
547 // TODO: Unicode in non-Unicode mode ??
551 // we don't get a valid mouse position inside the key event on every platform
552 // so we retrieve the mouse position explicitly and pass it along
553 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
554 SetEventInformationFlipY(mousePos.x, mousePos.y,
555 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
556 InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
558 InteractorStyle->OnKeyUp(event.ControlDown(), event.ShiftDown(),
559 event.GetKeyCode(), 1);
563 #endif //!(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
564 //---------------------------------------------------------------------------
565 void wxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event)
572 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
574 int keycode = event.GetKeyCode();
576 if (((unsigned int)keycode) < 256)
578 // TODO: Unicode in non-Unicode mode ??
582 // we don't get a valid mouse position inside the key event on every platform
583 // so we retrieve the mouse position explicitly and pass it along
584 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
585 SetEventInformationFlipY(mousePos.x, mousePos.y,
586 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
587 InvokeEvent(vtkCommand::CharEvent, NULL);
591 //---------------------------------------------------------------------------
592 void wxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
594 if (!Enabled || (ActiveButton != wxEVT_NULL))
598 ActiveButton = event.GetEventType();
600 // On Mac (Carbon) and Windows we don't automatically get the focus when
601 // you click inside the window
602 // we therefore set the focus explicitly
603 // Apparently we need that on linux (GTK) too:
606 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
607 SetEventInformationFlipY(event.GetX(), event.GetY(),
608 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
611 if(event.RightDown())
613 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
615 InvokeEvent(vtkCommand::RightButtonPressEvent, NULL);
618 InteractorStyle->OnRightButtonDown(event.ControlDown(), event.ShiftDown(),
619 event.GetX(), Size[1] - event.GetY() - 1);
622 else if(event.LeftDown())
624 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
626 InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
629 InteractorStyle->OnLeftButtonDown(event.ControlDown(), event.ShiftDown(),
630 event.GetX(), Size[1] - event.GetY() - 1);
633 else if(event.MiddleDown())
635 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
637 InvokeEvent(vtkCommand::MiddleButtonPressEvent, NULL);
640 InteractorStyle->OnMiddleButtonDown(event.ControlDown(), event.ShiftDown(),
641 event.GetX(), Size[1] - event.GetY() - 1);
644 //save the button and capture mouse until the button is released
646 //1. it is possible (WX_USE_X_CAPTURE)
647 //2. user decided to.
648 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
653 //---------------------------------------------------------------------------
654 void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
656 //EVT_xxx_DOWN == EVT_xxx_UP - 1
657 //This is only needed if two mouse buttons are pressed at the same time.
658 //In wxWindows 2.4 and later: better use of wxMOUSE_BTN_RIGHT or
659 //wxEVT_COMMAND_RIGHT_CLICK
660 if (!Enabled || (ActiveButton != (event.GetEventType()-1)))
665 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
666 SetEventInformationFlipY(event.GetX(), event.GetY(),
667 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
670 if(ActiveButton == wxEVT_RIGHT_DOWN)
672 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
674 InvokeEvent(vtkCommand::RightButtonReleaseEvent, NULL);
677 InteractorStyle->OnRightButtonUp(event.ControlDown(), event.ShiftDown(),
678 event.GetX(), Size[1] - event.GetY() - 1);
681 else if(ActiveButton == wxEVT_LEFT_DOWN)
683 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
685 InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
688 InteractorStyle->OnLeftButtonUp(event.ControlDown(), event.ShiftDown(),
689 event.GetX(), Size[1] - event.GetY() - 1);
692 else if(ActiveButton == wxEVT_MIDDLE_DOWN)
694 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
696 InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, NULL);
699 InteractorStyle->OnMiddleButtonUp(event.ControlDown(), event.ShiftDown(),
700 event.GetX(), Size[1] - event.GetY() - 1);
703 //if the ActiveButton is realeased, then release mouse capture
704 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
708 ActiveButton = wxEVT_NULL;
710 //---------------------------------------------------------------------------
711 void wxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event)
713 // Mouse wheel was only added after VTK 4.4 (I think...)
714 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
716 //Set vtk event information ... The numebr of wheel rotations is stored in
717 //the x varible. y varible is zero
718 SetEventInformationFlipY(event.GetWheelRotation() / event.GetWheelDelta(), 0,
719 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
720 if(event.GetWheelRotation() > 0)
723 InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL);
728 InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL);
734 //---------------------------------------------------------------------------
735 void wxVTKRenderWindowInteractor::Render()
738 if (!RenderWhenDisabled)
740 //the user doesn't want us to render when the toplevel frame
741 //is disabled - first find the top level parent
742 wxWindow *topParent = wxGetTopLevelParent(this);
745 //if it exists, check whether it's enabled
746 //if it's not enabeld, RenderAllowed will be false
747 RenderAllowed = topParent->IsEnabled();
753 if(Handle && (Handle == GetHandleHack()) )
755 RenderWindow->Render();
757 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
758 else if(GetHandleHack())
760 //this means the user has reparented us; let's adapt to the
761 //new situation by doing the WindowRemap dance
762 //store the new situation
763 Handle = GetHandleHack();
764 RenderWindow->SetNextWindowId(reinterpret_cast<void *>(Handle));
765 RenderWindow->WindowRemap();
766 RenderWindow->Render();
771 //---------------------------------------------------------------------------
772 void wxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue)
774 //Change value of __RenderWhenDisabled ivar.
775 //If __RenderWhenDisabled is false (the default), this widget will not
776 //call Render() on the RenderWindow if the top level frame (i.e. the
777 //containing frame) has been disabled.
779 //This prevents recursive rendering during wxSafeYield() calls.
780 //wxSafeYield() can be called during the ProgressMethod() callback of
781 //a VTK object to have progress bars and other GUI elements updated -
782 //it does this by disabling all windows (disallowing user-input to
783 //prevent re-entrancy of code) and then handling all outstanding
786 //However, this often triggers an OnPaint() method for wxVTKRWIs,
787 //resulting in a Render(), resulting in Update() being called whilst
790 RenderWhenDisabled = (bool)newValue;
792 //---------------------------------------------------------------------------
794 // Set the variable that indicates that we want a stereo capable window
795 // be created. This method can only be called before a window is realized.
797 void wxVTKRenderWindowInteractor::SetStereo(int capable)
799 if (Stereo != capable)
802 RenderWindow->StereoCapableWindowOn();
803 RenderWindow->SetStereoTypeToCrystalEyes();
808 //---------------------------------------------------------------------------
811 void wxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
813 this->Superclass::PrintSelf(os, indent);
818 // LG : EO namespace bbwxvtk
819 //=======================================================================