1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: creawxVTKRenderWindowInteractor.cxx,v $
6 Date: $Date: 2011/02/22 08:26:24 $
7 Version: $Revision: 1.7 $
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 =========================================================================*/
24 #include "creawxVTKRenderWindowInteractor.h"
26 //This is needed for vtk 3.1 :
27 #ifndef VTK_MAJOR_VERSION
28 # include "vtkVersion.h"
31 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
32 # include "vtkCommand.h"
34 # include "vtkInteractorStyle.h"
36 #include "vtkDebugLeaks.h"
39 #include "vtkCarbonRenderWindow.h"
42 //Keep this for compatibilty reason, this was introduced in wxGTK 2.4.0
43 #if (!wxCHECK_VERSION(2, 4, 0))
44 wxWindow* wxGetTopLevelParent(wxWindow *win)
46 while ( win && !win->IsTopLevel() )
47 win = win->GetParent();
52 // To access objc calls on cocoa
55 #import <Cocoa/Cocoa.h>
56 // This trick is no longer need in VTK CVS, should get rid of that:
59 #error Build mismatch you need both wxWidgets and VTK to be configure against Cocoa to work
60 #endif //VTK_USE_COCOA
64 # include <gdk/gdkx.h> // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0
65 # include "gdk/gdkprivate.h"
66 #if wxCHECK_VERSION(2, 8, 0)
68 #include <wx/gtk/win_gtk.h>
70 #include <wx/gtk1/win_gtk.h>
73 #include <wx/gtk/win_gtk.h>
75 #define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
76 GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \
77 GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
81 #include "wx/x11/privx.h"
82 #define GetXWindow(wxwin) ((Window)(wxwin)->GetHandle())
86 //For more info on this class please go to:
88 //This hack is for some buggy wxGTK version:
89 #if wxCHECK_VERSION(2, 3, 2) && !wxCHECK_VERSION(2, 4, 1) && defined(__WXGTK__)
90 # define WX_USE_X_CAPTURE 0
92 # define WX_USE_X_CAPTURE 1
95 #define ID_creawxVTKRenderWindowInteractor_TIMER 1001
100 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
101 IMPLEMENT_DYNAMIC_CLASS(creawxVTKRenderWindowInteractor, wxGLCanvas)
104 IMPLEMENT_DYNAMIC_CLASS(creawxVTKRenderWindowInteractor, wxWindow)
107 //---------------------------------------------------------------------------
108 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
109 BEGIN_EVENT_TABLE(creawxVTKRenderWindowInteractor, wxGLCanvas)
111 BEGIN_EVENT_TABLE(creawxVTKRenderWindowInteractor, wxWindow)
113 //refresh window by doing a Render
114 EVT_PAINT (creawxVTKRenderWindowInteractor::OnPaint)
115 EVT_ERASE_BACKGROUND(creawxVTKRenderWindowInteractor::OnEraseBackground)
116 EVT_MOTION (creawxVTKRenderWindowInteractor::OnMotion)
118 //Bind the events to the event converters
119 EVT_LEFT_DOWN (creawxVTKRenderWindowInteractor::OnButtonDown)
120 EVT_MIDDLE_DOWN (creawxVTKRenderWindowInteractor::OnButtonDown)
121 EVT_RIGHT_DOWN (creawxVTKRenderWindowInteractor::OnButtonDown)
122 EVT_LEFT_UP (creawxVTKRenderWindowInteractor::OnButtonUp)
123 EVT_MIDDLE_UP (creawxVTKRenderWindowInteractor::OnButtonUp)
124 EVT_RIGHT_UP (creawxVTKRenderWindowInteractor::OnButtonUp)
125 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
126 EVT_ENTER_WINDOW(creawxVTKRenderWindowInteractor::OnEnter)
127 EVT_LEAVE_WINDOW(creawxVTKRenderWindowInteractor::OnLeave)
128 EVT_MOUSEWHEEL (creawxVTKRenderWindowInteractor::OnMouseWheel)
129 EVT_KEY_DOWN (creawxVTKRenderWindowInteractor::OnKeyDown)
130 EVT_KEY_UP (creawxVTKRenderWindowInteractor::OnKeyUp)
131 EVT_CHAR (creawxVTKRenderWindowInteractor::OnChar)
133 EVT_TIMER (ID_creawxVTKRenderWindowInteractor_TIMER, creawxVTKRenderWindowInteractor::OnTimer)
134 EVT_SIZE (creawxVTKRenderWindowInteractor::OnSize)
137 //EED win Compilation why??: vtkCxxRevisionMacro(creawxVTKRenderWindowInteractor, "$Revision: 1.7 $")
138 vtkInstantiatorNewMacro(creawxVTKRenderWindowInteractor)
140 //---------------------------------------------------------------------------
141 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
142 #if (wxCHECK_VERSION(2, 8, 0))
143 creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : wxGLCanvas(0, -1, wxDefaultPosition), vtkRenderWindowInteractor()
145 creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : wxGLCanvas(), vtkRenderWindowInteractor()
148 creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : wxWindow(), vtkRenderWindowInteractor()
150 , timer(this, ID_creawxVTKRenderWindowInteractor_TIMER)
151 , ActiveButton(wxEVT_NULL)
156 , RenderWhenDisabled(1)
159 #ifdef VTK_DEBUG_LEAKS
160 vtkDebugLeaks::ConstructClass("creawxVTKRenderWindowInteractor");
162 this->RenderWindow = NULL;
163 this->SetRenderWindow(vtkRenderWindow::New());
164 this->RenderWindow->Delete();
166 //---------------------------------------------------------------------------
167 creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor(wxWindow *parent,
172 const wxString &name)
173 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
174 : wxGLCanvas(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
176 : wxWindow(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
178 , timer(this, ID_creawxVTKRenderWindowInteractor_TIMER)
179 , ActiveButton(wxEVT_NULL)
184 , RenderWhenDisabled(1)
187 #ifdef VTK_DEBUG_LEAKS
188 vtkDebugLeaks::ConstructClass("creawxVTKRenderWindowInteractor");
190 this->RenderWindow = NULL;
191 this->SetRenderWindow(vtkRenderWindow::New());
192 this->RenderWindow->Delete();
194 // On Mac (Carbon) we don't get notified of the initial window size with an EVT_SIZE event,
195 // so we update the size information of the interactor/renderwindow here
196 this->UpdateSize(size.x, size.y);
199 //---------------------------------------------------------------------------
200 creawxVTKRenderWindowInteractor::~creawxVTKRenderWindowInteractor()
202 SetRenderWindow(NULL);
203 SetInteractorStyle(NULL);
205 //---------------------------------------------------------------------------
206 creawxVTKRenderWindowInteractor * creawxVTKRenderWindowInteractor::New()
208 // we don't make use of the objectfactory, because we're not registered
209 return new creawxVTKRenderWindowInteractor;
211 //---------------------------------------------------------------------------
212 void creawxVTKRenderWindowInteractor::Initialize()
214 int *size = RenderWindow->GetSize();
215 // enable everything and start rendering
217 //RenderWindow->Start();
219 // set the size in the render window interactor
223 // this is initialized
226 //---------------------------------------------------------------------------
227 void creawxVTKRenderWindowInteractor::Enable()
229 // if already enabled then done
235 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
240 //---------------------------------------------------------------------------
241 bool creawxVTKRenderWindowInteractor::Enable(bool enable)
243 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
244 return wxGLCanvas::Enable(enable);
246 return wxWindow::Enable(enable);
249 //---------------------------------------------------------------------------
250 void creawxVTKRenderWindowInteractor::Disable()
252 // if already disabled then done
256 // that's it (we can't remove the event handler like it should be...)
260 //---------------------------------------------------------------------------
261 void creawxVTKRenderWindowInteractor::Start()
263 // the interactor cannot control the event loop
264 vtkErrorMacro( << "creawxVTKRenderWindowInteractor::Start() "
265 "interactor cannot control event loop.");
267 //---------------------------------------------------------------------------
268 void creawxVTKRenderWindowInteractor::UpdateSize(int x, int y)
272 // if the size changed tell render window
273 if ( x != Size[0] || y != Size[1] )
275 // adjust our (vtkRenderWindowInteractor size)
278 // and our RenderWindow's size
279 RenderWindow->SetSize(x, y);
283 //---------------------------------------------------------------------------
284 int creawxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype))
286 // it's a one shot timer
287 if (!timer.Start(10, TRUE))
293 //---------------------------------------------------------------------------
294 int creawxVTKRenderWindowInteractor::DestroyTimer()
299 //---------------------------------------------------------------------------
300 void creawxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event))
305 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
307 InvokeEvent(vtkCommand::TimerEvent, NULL);
310 InteractorStyle->OnTimer();
314 //---------------------------------------------------------------------------
315 // NOTE on implementation:
316 // Bad luck you ended up in the only tricky place of this code.
317 // A few note, wxWidgets still refuse to provide such convenient method
318 // so I have to maintain it myself, eventhough this is completely integrated
320 // Anyway if this happen to break for you then compare to a recent version of wxPython
321 // and look for the function long wxPyGetWinHandle(wxWindow* win)
322 // in wxPython/src/helpers.cpp
323 long creawxVTKRenderWindowInteractor::GetHandleHack()
325 //helper function to hide the MSW vs GTK stuff
328 // __WXMSW__ is for Win32
329 //__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)
330 // __WXGTK__ is for both gtk 1.2.x and gtk 2.x
331 #if defined(__WXMSW__) || defined(__WXMAC__)
332 handle_tmp = (long)this->GetHandle();
335 //__WXCOCOA__ stands for using the objective-c Cocoa API
337 // Here is how to find the NSWindow
338 wxTopLevelWindow* toplevel = dynamic_cast<wxTopLevelWindow*>(
339 wxGetTopLevelParent( this ) );
340 if (toplevel != NULL )
342 handle_tmp = (long)toplevel->GetNSWindow();
344 // The NSView will be deducted from
345 // [(NSWindow*)Handle contentView]
346 // if only I knew how to write that in c++
349 // Find and return the actual X-Window.
350 #if defined(__WXGTK__) || defined(__WXX11__)
351 return (long)GetXWindow(this);
355 // handle_tmp = (long)this->GetXWindow();
360 //---------------------------------------------------------------------------
361 void creawxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
363 //must always be here
366 //do it here rather than in the cstor: this is safer.
369 Handle = GetHandleHack();
370 RenderWindow->SetWindowId(reinterpret_cast<void *>(Handle));
372 RenderWindow->SetParentId(reinterpret_cast<void *>(this->GetParent()->GetHWND()));
375 // get vtk to render to the wxWindows
378 // This solves a problem with repainting after a window resize
379 // See also: http://sourceforge.net/mailarchive/forum.php?thread_id=31690967&forum_id=41789
380 vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow);
383 rwin->UpdateGLRegion();
387 //---------------------------------------------------------------------------
388 void creawxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event)
390 //turn off background erase to reduce flickering on MSW
393 //---------------------------------------------------------------------------
394 void creawxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event))
397 GetClientSize(&w, &h);
405 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
406 InvokeEvent(vtkCommand::ConfigureEvent, NULL);
408 //this will check for Handle
411 //---------------------------------------------------------------------------
412 void creawxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event)
418 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
419 SetEventInformationFlipY(event.GetX(), event.GetY(),
420 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
422 InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
424 InteractorStyle->OnMouseMove(event.ControlDown(), event.ShiftDown(),
425 event.GetX(), Size[1] - event.GetY() - 1);
428 //---------------------------------------------------------------------------
429 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
430 void creawxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event)
437 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
439 SetEventInformationFlipY(event.GetX(), event.GetY(),
440 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
442 InvokeEvent(vtkCommand::EnterEvent, NULL);
445 InteractorStyle->OnEnter(event.ControlDown(), event.ShiftDown(),
446 event.GetX(), Size[1] - event.GetY() - 1);
449 //---------------------------------------------------------------------------
450 void creawxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event)
457 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
459 SetEventInformationFlipY(event.GetX(), event.GetY(),
460 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
462 InvokeEvent(vtkCommand::LeaveEvent, NULL);
465 InteractorStyle->OnLeave(event.ControlDown(), event.ShiftDown(),
466 event.GetX(), Size[1] - event.GetY() - 1);
469 //---------------------------------------------------------------------------
470 void creawxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event)
477 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
479 int keycode = event.GetKeyCode();
481 if (((unsigned int)keycode) < 256)
483 // TODO: Unicode in non-Unicode mode ??
487 // we don't get a valid mouse position inside the key event on every platform
488 // so we retrieve the mouse position explicitly and pass it along
489 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
490 SetEventInformationFlipY(mousePos.x, mousePos.y,
491 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
492 InvokeEvent(vtkCommand::KeyPressEvent, NULL);
494 InteractorStyle->OnKeyDown(event.ControlDown(), event.ShiftDown(),
495 event.GetKeyCode(), 1);
499 //---------------------------------------------------------------------------
500 void creawxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event)
507 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
509 int keycode = event.GetKeyCode();
511 if (((unsigned int)keycode) < 256)
513 // TODO: Unicode in non-Unicode mode ??
517 // we don't get a valid mouse position inside the key event on every platform
518 // so we retrieve the mouse position explicitly and pass it along
519 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
520 SetEventInformationFlipY(mousePos.x, mousePos.y,
521 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
522 InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
524 InteractorStyle->OnKeyUp(event.ControlDown(), event.ShiftDown(),
525 event.GetKeyCode(), 1);
529 #endif //!(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
530 //---------------------------------------------------------------------------
531 void creawxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event)
538 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
540 int keycode = event.GetKeyCode();
542 if (((unsigned int)keycode) < 256)
544 // TODO: Unicode in non-Unicode mode ??
548 // we don't get a valid mouse position inside the key event on every platform
549 // so we retrieve the mouse position explicitly and pass it along
550 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
551 SetEventInformationFlipY(mousePos.x, mousePos.y,
552 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
553 InvokeEvent(vtkCommand::CharEvent, NULL);
557 //---------------------------------------------------------------------------
558 void creawxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
560 if (!Enabled || (ActiveButton != wxEVT_NULL))
564 ActiveButton = event.GetEventType();
566 // On Mac (Carbon) and Windows we don't automatically get the focus when
567 // you click inside the window
568 // we therefore set the focus explicitly
569 // Apparently we need that on linux (GTK) too:
572 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
573 SetEventInformationFlipY(event.GetX(), event.GetY(),
574 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
577 if(event.RightDown())
579 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
581 InvokeEvent(vtkCommand::RightButtonPressEvent, NULL);
584 InteractorStyle->OnRightButtonDown(event.ControlDown(), event.ShiftDown(),
585 event.GetX(), Size[1] - event.GetY() - 1);
588 else if(event.LeftDown())
590 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
592 InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
595 InteractorStyle->OnLeftButtonDown(event.ControlDown(), event.ShiftDown(),
596 event.GetX(), Size[1] - event.GetY() - 1);
599 else if(event.MiddleDown())
601 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
603 InvokeEvent(vtkCommand::MiddleButtonPressEvent, NULL);
606 InteractorStyle->OnMiddleButtonDown(event.ControlDown(), event.ShiftDown(),
607 event.GetX(), Size[1] - event.GetY() - 1);
610 //save the button and capture mouse until the button is released
612 //1. it is possible (WX_USE_X_CAPTURE)
613 //2. user decided to.
614 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
619 //---------------------------------------------------------------------------
620 void creawxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
622 //EVT_xxx_DOWN == EVT_xxx_UP - 1
623 //This is only needed if two mouse buttons are pressed at the same time.
624 //In wxWindows 2.4 and later: better use of wxMOUSE_BTN_RIGHT or
625 //wxEVT_COMMAND_RIGHT_CLICK
626 if (!Enabled || (ActiveButton != (event.GetEventType()-1)))
631 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
632 SetEventInformationFlipY(event.GetX(), event.GetY(),
633 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
636 if(ActiveButton == wxEVT_RIGHT_DOWN)
638 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
640 InvokeEvent(vtkCommand::RightButtonReleaseEvent, NULL);
643 InteractorStyle->OnRightButtonUp(event.ControlDown(), event.ShiftDown(),
644 event.GetX(), Size[1] - event.GetY() - 1);
647 else if(ActiveButton == wxEVT_LEFT_DOWN)
649 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
651 InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
654 InteractorStyle->OnLeftButtonUp(event.ControlDown(), event.ShiftDown(),
655 event.GetX(), Size[1] - event.GetY() - 1);
658 else if(ActiveButton == wxEVT_MIDDLE_DOWN)
660 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
662 InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, NULL);
665 InteractorStyle->OnMiddleButtonUp(event.ControlDown(), event.ShiftDown(),
666 event.GetX(), Size[1] - event.GetY() - 1);
669 //if the ActiveButton is realeased, then release mouse capture
670 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
674 ActiveButton = wxEVT_NULL;
676 //---------------------------------------------------------------------------
677 void creawxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event)
679 // Mouse wheel was only added after VTK 4.4 (I think...)
680 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
682 //Set vtk event information ... The numebr of wheel rotations is stored in
683 //the x varible. y varible is zero
684 SetEventInformationFlipY(event.GetWheelRotation() / event.GetWheelDelta(), 0,
685 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
686 if(event.GetWheelRotation() > 0)
689 InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL);
694 InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL);
700 //---------------------------------------------------------------------------
701 void creawxVTKRenderWindowInteractor::Render()
704 if (!RenderWhenDisabled)
706 //the user doesn't want us to render when the toplevel frame
707 //is disabled - first find the top level parent
708 wxWindow *topParent = wxGetTopLevelParent(this);
711 //if it exists, check whether it's enabled
712 //if it's not enabeld, RenderAllowed will be false
713 RenderAllowed = topParent->IsEnabled();
719 if(Handle && (Handle == GetHandleHack()) )
721 RenderWindow->Render();
723 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
724 else if(GetHandleHack())
726 //this means the user has reparented us; let's adapt to the
727 //new situation by doing the WindowRemap dance
728 //store the new situation
729 Handle = GetHandleHack();
730 RenderWindow->SetNextWindowId(reinterpret_cast<void *>(Handle));
731 RenderWindow->WindowRemap();
732 RenderWindow->Render();
737 //---------------------------------------------------------------------------
738 void creawxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue)
740 //Change value of __RenderWhenDisabled ivar.
741 //If __RenderWhenDisabled is false (the default), this widget will not
742 //call Render() on the RenderWindow if the top level frame (i.e. the
743 //containing frame) has been disabled.
745 //This prevents recursive rendering during wxSafeYield() calls.
746 //wxSafeYield() can be called during the ProgressMethod() callback of
747 //a VTK object to have progress bars and other GUI elements updated -
748 //it does this by disabling all windows (disallowing user-input to
749 //prevent re-entrancy of code) and then handling all outstanding
752 //However, this often triggers an OnPaint() method for wxVTKRWIs,
753 //resulting in a Render(), resulting in Update() being called whilst
756 RenderWhenDisabled = (bool)newValue;
758 //---------------------------------------------------------------------------
760 // Set the variable that indicates that we want a stereo capable window
761 // be created. This method can only be called before a window is realized.
763 void creawxVTKRenderWindowInteractor::SetStereo(int capable)
765 if (Stereo != capable)
768 RenderWindow->StereoCapableWindowOn();
769 RenderWindow->SetStereoTypeToCrystalEyes();
774 //---------------------------------------------------------------------------
777 void creawxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
779 this->Superclass::PrintSelf(os, indent);
786 //=======================================================================