1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: wxVTKRenderWindowInteractor.cxx,v $
6 Date: $Date: 2011/02/17 11:02:20 $
7 Version: $Revision: 1.6 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
21 #include "wxVTKRenderWindowInteractor.h"
23 //This is needed for vtk 3.1 :
24 #ifndef VTK_MAJOR_VERSION
25 # include "vtkVersion.h"
28 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
29 # include "vtkCommand.h"
31 # include "vtkInteractorStyle.h"
33 #include "vtkDebugLeaks.h"
36 #include "vtkCarbonRenderWindow.h"
39 //Keep this for compatibilty reason, this was introduced in wxGTK 2.4.0
40 #if (!wxCHECK_VERSION(2, 4, 0))
41 wxWindow* wxGetTopLevelParent(wxWindow *win)
43 while ( win && !win->IsTopLevel() )
44 win = win->GetParent();
49 // To access objc calls on cocoa
52 #import <Cocoa/Cocoa.h>
53 // This trick is no longer need in VTK CVS, should get rid of that:
56 #error Build mismatch you need both wxWidgets and VTK to be configure against Cocoa to work
57 #endif //VTK_USE_COCOA
61 # include <gdk/gdkx.h> // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0
62 # include "gdk/gdkprivate.h"
63 #if wxCHECK_VERSION(2, 8, 0)
65 #include <wx/gtk/win_gtk.h>
67 #include <wx/gtk1/win_gtk.h>
70 #include <wx/gtk/win_gtk.h>
72 #define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
73 GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \
74 GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
78 #include "wx/x11/privx.h"
79 #define GetXWindow(wxwin) ((Window)(wxwin)->GetHandle())
83 //For more info on this class please go to:
85 //This hack is for some buggy wxGTK version:
86 #if wxCHECK_VERSION(2, 3, 2) && !wxCHECK_VERSION(2, 4, 1) && defined(__WXGTK__)
87 # define WX_USE_X_CAPTURE 0
89 # define WX_USE_X_CAPTURE 1
92 #define ID_wxVTKRenderWindowInteractor_TIMER 1001
94 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
95 IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxGLCanvas)
97 IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxWindow)
100 //---------------------------------------------------------------------------
101 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
102 BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxGLCanvas)
104 BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
106 //refresh window by doing a Render
107 EVT_PAINT (wxVTKRenderWindowInteractor::OnPaint)
108 EVT_ERASE_BACKGROUND(wxVTKRenderWindowInteractor::OnEraseBackground)
109 EVT_MOTION (wxVTKRenderWindowInteractor::OnMotion)
111 //Bind the events to the event converters
112 EVT_LEFT_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
113 EVT_MIDDLE_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
114 EVT_RIGHT_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
115 EVT_LEFT_UP (wxVTKRenderWindowInteractor::OnButtonUp)
116 EVT_MIDDLE_UP (wxVTKRenderWindowInteractor::OnButtonUp)
117 EVT_RIGHT_UP (wxVTKRenderWindowInteractor::OnButtonUp)
118 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
119 EVT_ENTER_WINDOW(wxVTKRenderWindowInteractor::OnEnter)
120 EVT_LEAVE_WINDOW(wxVTKRenderWindowInteractor::OnLeave)
121 EVT_MOUSEWHEEL (wxVTKRenderWindowInteractor::OnMouseWheel)
122 EVT_KEY_DOWN (wxVTKRenderWindowInteractor::OnKeyDown)
123 EVT_KEY_UP (wxVTKRenderWindowInteractor::OnKeyUp)
124 EVT_CHAR (wxVTKRenderWindowInteractor::OnChar)
126 EVT_TIMER (ID_wxVTKRenderWindowInteractor_TIMER, wxVTKRenderWindowInteractor::OnTimer)
127 EVT_SIZE (wxVTKRenderWindowInteractor::OnSize)
130 vtkCxxRevisionMacro(wxVTKRenderWindowInteractor, "$Revision: 1.6 $")
131 vtkInstantiatorNewMacro(wxVTKRenderWindowInteractor)
133 //---------------------------------------------------------------------------
134 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
135 #if (wxCHECK_VERSION(2, 8, 0))
136 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(0, -1, wxDefaultPosition), vtkRenderWindowInteractor()
138 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(), vtkRenderWindowInteractor()
141 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxWindow(), vtkRenderWindowInteractor()
143 , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
144 , ActiveButton(wxEVT_NULL)
149 , RenderWhenDisabled(1)
152 #ifdef VTK_DEBUG_LEAKS
153 vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
155 this->RenderWindow = NULL;
156 this->SetRenderWindow(vtkRenderWindow::New());
157 this->RenderWindow->Delete();
159 //---------------------------------------------------------------------------
160 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
165 const wxString &name)
166 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
167 : wxGLCanvas(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
169 : wxWindow(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
171 , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
172 , ActiveButton(wxEVT_NULL)
177 , RenderWhenDisabled(1)
180 #ifdef VTK_DEBUG_LEAKS
181 vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
183 this->RenderWindow = NULL;
184 this->SetRenderWindow(vtkRenderWindow::New());
185 this->RenderWindow->Delete();
187 // On Mac (Carbon) we don't get notified of the initial window size with an EVT_SIZE event,
188 // so we update the size information of the interactor/renderwindow here
189 this->UpdateSize(size.x, size.y);
192 //---------------------------------------------------------------------------
193 wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor()
195 SetRenderWindow(NULL);
196 SetInteractorStyle(NULL);
198 //---------------------------------------------------------------------------
199 wxVTKRenderWindowInteractor * wxVTKRenderWindowInteractor::New()
201 // we don't make use of the objectfactory, because we're not registered
202 return new wxVTKRenderWindowInteractor;
204 //---------------------------------------------------------------------------
205 void wxVTKRenderWindowInteractor::Initialize()
207 int *size = RenderWindow->GetSize();
208 // enable everything and start rendering
210 //RenderWindow->Start();
212 // set the size in the render window interactor
216 // this is initialized
219 //---------------------------------------------------------------------------
220 void wxVTKRenderWindowInteractor::Enable()
222 // if already enabled then done
228 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
233 //---------------------------------------------------------------------------
234 bool wxVTKRenderWindowInteractor::Enable(bool enable)
236 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
237 return wxGLCanvas::Enable(enable);
239 return wxWindow::Enable(enable);
242 //---------------------------------------------------------------------------
243 void wxVTKRenderWindowInteractor::Disable()
245 // if already disabled then done
249 // that's it (we can't remove the event handler like it should be...)
253 //---------------------------------------------------------------------------
254 void wxVTKRenderWindowInteractor::Start()
256 // the interactor cannot control the event loop
257 vtkErrorMacro( << "wxVTKRenderWindowInteractor::Start() "
258 "interactor cannot control event loop.");
260 //---------------------------------------------------------------------------
261 void wxVTKRenderWindowInteractor::UpdateSize(int x, int y)
265 // if the size changed tell render window
266 if ( x != Size[0] || y != Size[1] )
268 // adjust our (vtkRenderWindowInteractor size)
271 // and our RenderWindow's size
272 RenderWindow->SetSize(x, y);
276 //---------------------------------------------------------------------------
277 int wxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype))
279 // it's a one shot timer
280 if (!timer.Start(10, TRUE))
286 //---------------------------------------------------------------------------
287 int wxVTKRenderWindowInteractor::DestroyTimer()
292 //---------------------------------------------------------------------------
293 void wxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event))
298 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
300 InvokeEvent(vtkCommand::TimerEvent, NULL);
303 InteractorStyle->OnTimer();
307 //---------------------------------------------------------------------------
308 // NOTE on implementation:
309 // Bad luck you ended up in the only tricky place of this code.
310 // A few note, wxWidgets still refuse to provide such convenient method
311 // so I have to maintain it myself, eventhough this is completely integrated
313 // Anyway if this happen to break for you then compare to a recent version of wxPython
314 // and look for the function long wxPyGetWinHandle(wxWindow* win)
315 // in wxPython/src/helpers.cpp
316 long wxVTKRenderWindowInteractor::GetHandleHack()
318 //helper function to hide the MSW vs GTK stuff
321 // __WXMSW__ is for Win32
322 //__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)
323 // __WXGTK__ is for both gtk 1.2.x and gtk 2.x
324 #if defined(__WXMSW__) || defined(__WXMAC__)
325 handle_tmp = (long)this->GetHandle();
328 //__WXCOCOA__ stands for using the objective-c Cocoa API
330 // Here is how to find the NSWindow
331 wxTopLevelWindow* toplevel = dynamic_cast<wxTopLevelWindow*>(
332 wxGetTopLevelParent( this ) );
333 if (toplevel != NULL )
335 handle_tmp = (long)toplevel->GetNSWindow();
337 // The NSView will be deducted from
338 // [(NSWindow*)Handle contentView]
339 // if only I knew how to write that in c++
342 // Find and return the actual X-Window.
343 #if defined(__WXGTK__) || defined(__WXX11__)
344 return (long)GetXWindow(this);
348 // handle_tmp = (long)this->GetXWindow();
353 //---------------------------------------------------------------------------
354 void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
356 //must always be here
359 //do it here rather than in the cstor: this is safer.
362 Handle = GetHandleHack();
363 RenderWindow->SetWindowId(reinterpret_cast<void *>(Handle));
365 RenderWindow->SetParentId(reinterpret_cast<void *>(this->GetParent()->GetHWND()));
368 // get vtk to render to the wxWindows
371 // This solves a problem with repainting after a window resize
372 // See also: http://sourceforge.net/mailarchive/forum.php?thread_id=31690967&forum_id=41789
373 vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow);
376 rwin->UpdateGLRegion();
380 //---------------------------------------------------------------------------
381 void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event)
383 //turn off background erase to reduce flickering on MSW
386 //---------------------------------------------------------------------------
387 void wxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event))
390 GetClientSize(&w, &h);
398 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
399 InvokeEvent(vtkCommand::ConfigureEvent, NULL);
401 //this will check for Handle
404 //---------------------------------------------------------------------------
405 void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event)
411 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
412 SetEventInformationFlipY(event.GetX(), event.GetY(),
413 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
415 InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
417 InteractorStyle->OnMouseMove(event.ControlDown(), event.ShiftDown(),
418 event.GetX(), Size[1] - event.GetY() - 1);
421 //---------------------------------------------------------------------------
422 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
423 void wxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event)
430 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
432 SetEventInformationFlipY(event.GetX(), event.GetY(),
433 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
435 InvokeEvent(vtkCommand::EnterEvent, NULL);
438 InteractorStyle->OnEnter(event.ControlDown(), event.ShiftDown(),
439 event.GetX(), Size[1] - event.GetY() - 1);
442 //---------------------------------------------------------------------------
443 void wxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event)
450 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
452 SetEventInformationFlipY(event.GetX(), event.GetY(),
453 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
455 InvokeEvent(vtkCommand::LeaveEvent, NULL);
458 InteractorStyle->OnLeave(event.ControlDown(), event.ShiftDown(),
459 event.GetX(), Size[1] - event.GetY() - 1);
462 //---------------------------------------------------------------------------
463 void wxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event)
470 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
472 int keycode = event.GetKeyCode();
474 if (((unsigned int)keycode) < 256)
476 // TODO: Unicode in non-Unicode mode ??
480 // we don't get a valid mouse position inside the key event on every platform
481 // so we retrieve the mouse position explicitly and pass it along
482 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
483 SetEventInformationFlipY(mousePos.x, mousePos.y,
484 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
485 InvokeEvent(vtkCommand::KeyPressEvent, NULL);
487 InteractorStyle->OnKeyDown(event.ControlDown(), event.ShiftDown(),
488 event.GetKeyCode(), 1);
492 //---------------------------------------------------------------------------
493 void wxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event)
500 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
502 int keycode = event.GetKeyCode();
504 if (((unsigned int)keycode) < 256)
506 // TODO: Unicode in non-Unicode mode ??
510 // we don't get a valid mouse position inside the key event on every platform
511 // so we retrieve the mouse position explicitly and pass it along
512 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
513 SetEventInformationFlipY(mousePos.x, mousePos.y,
514 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
515 InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
517 InteractorStyle->OnKeyUp(event.ControlDown(), event.ShiftDown(),
518 event.GetKeyCode(), 1);
522 #endif //!(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
523 //---------------------------------------------------------------------------
524 void wxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event)
531 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
533 int keycode = event.GetKeyCode();
535 if (((unsigned int)keycode) < 256)
537 // TODO: Unicode in non-Unicode mode ??
541 // we don't get a valid mouse position inside the key event on every platform
542 // so we retrieve the mouse position explicitly and pass it along
543 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
544 SetEventInformationFlipY(mousePos.x, mousePos.y,
545 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
546 InvokeEvent(vtkCommand::CharEvent, NULL);
550 //---------------------------------------------------------------------------
551 void wxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
553 if (!Enabled || (ActiveButton != wxEVT_NULL))
557 ActiveButton = event.GetEventType();
559 // On Mac (Carbon) and Windows we don't automatically get the focus when
560 // you click inside the window
561 // we therefore set the focus explicitly
562 // Apparently we need that on linux (GTK) too:
565 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
566 SetEventInformationFlipY(event.GetX(), event.GetY(),
567 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
570 if(event.RightDown())
572 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
574 InvokeEvent(vtkCommand::RightButtonPressEvent, NULL);
577 InteractorStyle->OnRightButtonDown(event.ControlDown(), event.ShiftDown(),
578 event.GetX(), Size[1] - event.GetY() - 1);
581 else if(event.LeftDown())
583 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
585 InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
588 InteractorStyle->OnLeftButtonDown(event.ControlDown(), event.ShiftDown(),
589 event.GetX(), Size[1] - event.GetY() - 1);
592 else if(event.MiddleDown())
594 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
596 InvokeEvent(vtkCommand::MiddleButtonPressEvent, NULL);
599 InteractorStyle->OnMiddleButtonDown(event.ControlDown(), event.ShiftDown(),
600 event.GetX(), Size[1] - event.GetY() - 1);
603 //save the button and capture mouse until the button is released
605 //1. it is possible (WX_USE_X_CAPTURE)
606 //2. user decided to.
607 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
612 //---------------------------------------------------------------------------
613 void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
615 //EVT_xxx_DOWN == EVT_xxx_UP - 1
616 //This is only needed if two mouse buttons are pressed at the same time.
617 //In wxWindows 2.4 and later: better use of wxMOUSE_BTN_RIGHT or
618 //wxEVT_COMMAND_RIGHT_CLICK
619 if (!Enabled || (ActiveButton != (event.GetEventType()-1)))
624 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
625 SetEventInformationFlipY(event.GetX(), event.GetY(),
626 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
629 if(ActiveButton == wxEVT_RIGHT_DOWN)
631 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
633 InvokeEvent(vtkCommand::RightButtonReleaseEvent, NULL);
636 InteractorStyle->OnRightButtonUp(event.ControlDown(), event.ShiftDown(),
637 event.GetX(), Size[1] - event.GetY() - 1);
640 else if(ActiveButton == wxEVT_LEFT_DOWN)
642 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
644 InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
647 InteractorStyle->OnLeftButtonUp(event.ControlDown(), event.ShiftDown(),
648 event.GetX(), Size[1] - event.GetY() - 1);
651 else if(ActiveButton == wxEVT_MIDDLE_DOWN)
653 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
655 InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, NULL);
658 InteractorStyle->OnMiddleButtonUp(event.ControlDown(), event.ShiftDown(),
659 event.GetX(), Size[1] - event.GetY() - 1);
662 //if the ActiveButton is realeased, then release mouse capture
663 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
667 ActiveButton = wxEVT_NULL;
669 //---------------------------------------------------------------------------
670 void wxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event)
672 // Mouse wheel was only added after VTK 4.4 (I think...)
673 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
675 //Set vtk event information ... The numebr of wheel rotations is stored in
676 //the x varible. y varible is zero
677 SetEventInformationFlipY(event.GetWheelRotation() / event.GetWheelDelta(), 0,
678 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
679 if(event.GetWheelRotation() > 0)
682 InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL);
687 InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL);
693 //---------------------------------------------------------------------------
694 void wxVTKRenderWindowInteractor::Render()
697 if (!RenderWhenDisabled)
699 //the user doesn't want us to render when the toplevel frame
700 //is disabled - first find the top level parent
701 wxWindow *topParent = wxGetTopLevelParent(this);
704 //if it exists, check whether it's enabled
705 //if it's not enabeld, RenderAllowed will be false
706 RenderAllowed = topParent->IsEnabled();
712 if(Handle && (Handle == GetHandleHack()) )
714 RenderWindow->Render();
716 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
717 else if(GetHandleHack())
719 //this means the user has reparented us; let's adapt to the
720 //new situation by doing the WindowRemap dance
721 //store the new situation
722 Handle = GetHandleHack();
723 RenderWindow->SetNextWindowId(reinterpret_cast<void *>(Handle));
724 RenderWindow->WindowRemap();
725 RenderWindow->Render();
730 //---------------------------------------------------------------------------
731 void wxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue)
733 //Change value of __RenderWhenDisabled ivar.
734 //If __RenderWhenDisabled is false (the default), this widget will not
735 //call Render() on the RenderWindow if the top level frame (i.e. the
736 //containing frame) has been disabled.
738 //This prevents recursive rendering during wxSafeYield() calls.
739 //wxSafeYield() can be called during the ProgressMethod() callback of
740 //a VTK object to have progress bars and other GUI elements updated -
741 //it does this by disabling all windows (disallowing user-input to
742 //prevent re-entrancy of code) and then handling all outstanding
745 //However, this often triggers an OnPaint() method for wxVTKRWIs,
746 //resulting in a Render(), resulting in Update() being called whilst
749 RenderWhenDisabled = (bool)newValue;
751 //---------------------------------------------------------------------------
753 // Set the variable that indicates that we want a stereo capable window
754 // be created. This method can only be called before a window is realized.
756 void wxVTKRenderWindowInteractor::SetStereo(int capable)
758 if (Stereo != capable)
761 RenderWindow->StereoCapableWindowOn();
762 RenderWindow->SetStereoTypeToCrystalEyes();
767 //---------------------------------------------------------------------------
770 void wxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
772 this->Superclass::PrintSelf(os, indent);