1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: creawxVTKRenderWindowInteractor.cxx,v $
6 Date: $Date: 2011/07/22 17:42:59 $
7 Version: $Revision: 1.9 $
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"
40 #include "vtkCocoaRenderWindow.h"
42 #include "vtkCarbonRenderWindow.h"
47 //Keep this for compatibilty reason, this was introduced in wxGTK 2.4.0
48 #if (!wxCHECK_VERSION(2, 4, 0))
49 wxWindow* wxGetTopLevelParent(wxWindow *win)
51 while ( win && !win->IsTopLevel() )
52 win = win->GetParent();
57 // To access objc calls on cocoa
60 #import <Cocoa/Cocoa.h>
61 // This trick is no longer need in VTK CVS, should get rid of that:
64 #error Build mismatch you need both wxWidgets and VTK to be configure against Cocoa to work
65 #endif //VTK_USE_COCOA
69 # include <gdk/gdkx.h> // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0
70 # include "gdk/gdkprivate.h"
71 #if wxCHECK_VERSION(2, 8, 0)
73 #include <wx/gtk/win_gtk.h>
75 #include <wx/gtk1/win_gtk.h>
78 #include <wx/gtk/win_gtk.h>
80 #define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
81 GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \
82 GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
86 #include "wx/x11/privx.h"
87 #define GetXWindow(wxwin) ((Window)(wxwin)->GetHandle())
91 //For more info on this class please go to:
93 //This hack is for some buggy wxGTK version:
94 #if wxCHECK_VERSION(2, 3, 2) && !wxCHECK_VERSION(2, 4, 1) && defined(__WXGTK__)
95 # define WX_USE_X_CAPTURE 0
97 # define WX_USE_X_CAPTURE 1
100 #define ID_creawxVTKRenderWindowInteractor_TIMER 1001
105 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
106 IMPLEMENT_DYNAMIC_CLASS(creawxVTKRenderWindowInteractor, wxGLCanvas)
109 IMPLEMENT_DYNAMIC_CLASS(creawxVTKRenderWindowInteractor, wxWindow)
112 //---------------------------------------------------------------------------
113 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
114 BEGIN_EVENT_TABLE(creawxVTKRenderWindowInteractor, wxGLCanvas)
116 BEGIN_EVENT_TABLE(creawxVTKRenderWindowInteractor, wxWindow)
118 //refresh window by doing a Render
119 EVT_PAINT (creawxVTKRenderWindowInteractor::OnPaint)
120 EVT_ERASE_BACKGROUND(creawxVTKRenderWindowInteractor::OnEraseBackground)
121 EVT_MOTION (creawxVTKRenderWindowInteractor::OnMotion)
123 //Bind the events to the event converters
124 EVT_LEFT_DOWN (creawxVTKRenderWindowInteractor::OnButtonDown)
125 EVT_MIDDLE_DOWN (creawxVTKRenderWindowInteractor::OnButtonDown)
126 EVT_RIGHT_DOWN (creawxVTKRenderWindowInteractor::OnButtonDown)
127 EVT_LEFT_UP (creawxVTKRenderWindowInteractor::OnButtonUp)
128 EVT_MIDDLE_UP (creawxVTKRenderWindowInteractor::OnButtonUp)
129 EVT_RIGHT_UP (creawxVTKRenderWindowInteractor::OnButtonUp)
130 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
131 EVT_ENTER_WINDOW(creawxVTKRenderWindowInteractor::OnEnter)
132 EVT_LEAVE_WINDOW(creawxVTKRenderWindowInteractor::OnLeave)
133 EVT_MOUSEWHEEL (creawxVTKRenderWindowInteractor::OnMouseWheel)
134 EVT_KEY_DOWN (creawxVTKRenderWindowInteractor::OnKeyDown)
135 EVT_KEY_UP (creawxVTKRenderWindowInteractor::OnKeyUp)
136 EVT_CHAR (creawxVTKRenderWindowInteractor::OnChar)
138 EVT_TIMER (ID_creawxVTKRenderWindowInteractor_TIMER, creawxVTKRenderWindowInteractor::OnTimer)
139 EVT_SIZE (creawxVTKRenderWindowInteractor::OnSize)
142 //EED win Compilation why??: vtkCxxRevisionMacro(creawxVTKRenderWindowInteractor, "$Revision: 1.9 $")
143 vtkInstantiatorNewMacro(creawxVTKRenderWindowInteractor)
145 //---------------------------------------------------------------------------
146 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
147 #if (wxCHECK_VERSION(2, 8, 0))
148 creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : wxGLCanvas(0, -1, wxDefaultPosition), vtkRenderWindowInteractor()
150 creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : wxGLCanvas(), vtkRenderWindowInteractor()
153 creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor() : wxWindow(), vtkRenderWindowInteractor()
155 , timer(this, ID_creawxVTKRenderWindowInteractor_TIMER)
156 , ActiveButton(wxEVT_NULL)
161 , RenderWhenDisabled(1)
164 #ifdef VTK_DEBUG_LEAKS
165 vtkDebugLeaks::ConstructClass("creawxVTKRenderWindowInteractor");
167 this->RenderWindow = NULL;
168 this->SetRenderWindow(vtkRenderWindow::New());
169 this->RenderWindow->Delete();
171 //---------------------------------------------------------------------------
172 creawxVTKRenderWindowInteractor::creawxVTKRenderWindowInteractor(wxWindow *parent,
177 const wxString &name)
178 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
179 : wxGLCanvas(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
181 : wxWindow(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
183 , timer(this, ID_creawxVTKRenderWindowInteractor_TIMER)
184 , ActiveButton(wxEVT_NULL)
189 , RenderWhenDisabled(1)
192 #ifdef VTK_DEBUG_LEAKS
193 vtkDebugLeaks::ConstructClass("creawxVTKRenderWindowInteractor");
195 this->RenderWindow = NULL;
196 this->SetRenderWindow(vtkRenderWindow::New());
197 this->RenderWindow->Delete();
199 // On Mac (Carbon) we don't get notified of the initial window size with an EVT_SIZE event,
200 // so we update the size information of the interactor/renderwindow here
201 this->UpdateSize(size.x, size.y);
204 //---------------------------------------------------------------------------
205 creawxVTKRenderWindowInteractor::~creawxVTKRenderWindowInteractor()
207 SetRenderWindow(NULL);
208 SetInteractorStyle(NULL);
210 //---------------------------------------------------------------------------
211 creawxVTKRenderWindowInteractor * creawxVTKRenderWindowInteractor::New()
213 // we don't make use of the objectfactory, because we're not registered
214 return new creawxVTKRenderWindowInteractor;
216 //---------------------------------------------------------------------------
217 void creawxVTKRenderWindowInteractor::Initialize()
219 int *size = RenderWindow->GetSize();
220 // enable everything and start rendering
222 //RenderWindow->Start();
224 // set the size in the render window interactor
228 // this is initialized
231 //---------------------------------------------------------------------------
232 void creawxVTKRenderWindowInteractor::Enable()
234 // if already enabled then done
240 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
245 //---------------------------------------------------------------------------
246 bool creawxVTKRenderWindowInteractor::Enable(bool enable)
248 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
249 return wxGLCanvas::Enable(enable);
251 return wxWindow::Enable(enable);
254 //---------------------------------------------------------------------------
255 void creawxVTKRenderWindowInteractor::Disable()
257 // if already disabled then done
261 // that's it (we can't remove the event handler like it should be...)
265 //---------------------------------------------------------------------------
266 void creawxVTKRenderWindowInteractor::Start()
268 // the interactor cannot control the event loop
269 vtkErrorMacro( << "creawxVTKRenderWindowInteractor::Start() "
270 "interactor cannot control event loop.");
272 //---------------------------------------------------------------------------
273 void creawxVTKRenderWindowInteractor::UpdateSize(int x, int y)
277 // if the size changed tell render window
278 if ( x != Size[0] || y != Size[1] )
280 // adjust our (vtkRenderWindowInteractor size)
283 // and our RenderWindow's size
284 RenderWindow->SetSize(x, y);
288 //---------------------------------------------------------------------------
289 int creawxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype))
291 // it's a one shot timer
292 if (!timer.Start(10, TRUE))
298 //---------------------------------------------------------------------------
299 int creawxVTKRenderWindowInteractor::DestroyTimer()
304 //---------------------------------------------------------------------------
305 void creawxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event))
310 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
312 InvokeEvent(vtkCommand::TimerEvent, NULL);
315 InteractorStyle->OnTimer();
319 //---------------------------------------------------------------------------
320 // NOTE on implementation:
321 // Bad luck you ended up in the only tricky place of this code.
322 // A few note, wxWidgets still refuse to provide such convenient method
323 // so I have to maintain it myself, eventhough this is completely integrated
325 // Anyway if this happen to break for you then compare to a recent version of wxPython
326 // and look for the function long wxPyGetWinHandle(wxWindow* win)
327 // in wxPython/src/helpers.cpp
328 long creawxVTKRenderWindowInteractor::GetHandleHack()
330 //helper function to hide the MSW vs GTK stuff
333 // __WXMSW__ is for Win32
334 //__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)
335 // __WXGTK__ is for both gtk 1.2.x and gtk 2.x
336 #if defined(__WXMSW__) || defined(__WXMAC__)
337 handle_tmp = (long)this->GetHandle();
340 //__WXCOCOA__ stands for using the objective-c Cocoa API
342 // Here is how to find the NSWindow
343 wxTopLevelWindow* toplevel = dynamic_cast<wxTopLevelWindow*>(
344 wxGetTopLevelParent( this ) );
345 if (toplevel != NULL )
347 handle_tmp = (long)toplevel->GetNSWindow();
349 // The NSView will be deducted from
350 // [(NSWindow*)Handle contentView]
351 // if only I knew how to write that in c++
354 // Find and return the actual X-Window.
355 #if defined(__WXGTK__) || defined(__WXX11__)
356 return (long)GetXWindow(this);
360 // handle_tmp = (long)this->GetXWindow();
365 //---------------------------------------------------------------------------
366 void creawxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
368 //must always be here
371 //do it here rather than in the cstor: this is safer.
374 Handle = GetHandleHack();
375 RenderWindow->SetWindowId(reinterpret_cast<void *>(Handle));
377 RenderWindow->SetParentId(reinterpret_cast<void *>(this->GetParent()->GetHWND()));
380 // get vtk to render to the wxWindows
385 vtkCocoaRenderWindow* rwin = vtkCocoaRenderWindow::SafeDownCast(RenderWindow);
388 rwin->UpdateContext();
391 // This solves a problem with repainting after a window resize
392 // See also: http://sourceforge.net/mailarchive/forum.php?thread_id=31690967&forum_id=41789
393 vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow);
396 rwin->UpdateGLRegion();
402 //---------------------------------------------------------------------------
403 void creawxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event)
405 //turn off background erase to reduce flickering on MSW
408 //---------------------------------------------------------------------------
409 void creawxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event))
412 GetClientSize(&w, &h);
420 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
421 InvokeEvent(vtkCommand::ConfigureEvent, NULL);
423 //this will check for Handle
426 //---------------------------------------------------------------------------
427 void creawxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event)
433 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
434 SetEventInformationFlipY(event.GetX(), event.GetY(),
435 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
437 InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
439 InteractorStyle->OnMouseMove(event.ControlDown(), event.ShiftDown(),
440 event.GetX(), Size[1] - event.GetY() - 1);
443 //---------------------------------------------------------------------------
444 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
445 void creawxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event)
452 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
454 SetEventInformationFlipY(event.GetX(), event.GetY(),
455 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
457 InvokeEvent(vtkCommand::EnterEvent, NULL);
460 InteractorStyle->OnEnter(event.ControlDown(), event.ShiftDown(),
461 event.GetX(), Size[1] - event.GetY() - 1);
464 //---------------------------------------------------------------------------
465 void creawxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event)
472 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
474 SetEventInformationFlipY(event.GetX(), event.GetY(),
475 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
477 InvokeEvent(vtkCommand::LeaveEvent, NULL);
480 InteractorStyle->OnLeave(event.ControlDown(), event.ShiftDown(),
481 event.GetX(), Size[1] - event.GetY() - 1);
484 //---------------------------------------------------------------------------
485 void creawxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event)
492 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
494 int keycode = event.GetKeyCode();
496 if (((unsigned int)keycode) < 256)
498 // TODO: Unicode in non-Unicode mode ??
502 // we don't get a valid mouse position inside the key event on every platform
503 // so we retrieve the mouse position explicitly and pass it along
504 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
505 SetEventInformationFlipY(mousePos.x, mousePos.y,
506 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
507 InvokeEvent(vtkCommand::KeyPressEvent, NULL);
509 InteractorStyle->OnKeyDown(event.ControlDown(), event.ShiftDown(),
510 event.GetKeyCode(), 1);
514 //---------------------------------------------------------------------------
515 void creawxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event)
522 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
524 int keycode = event.GetKeyCode();
526 if (((unsigned int)keycode) < 256)
528 // TODO: Unicode in non-Unicode mode ??
532 // we don't get a valid mouse position inside the key event on every platform
533 // so we retrieve the mouse position explicitly and pass it along
534 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
535 SetEventInformationFlipY(mousePos.x, mousePos.y,
536 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
537 InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
539 InteractorStyle->OnKeyUp(event.ControlDown(), event.ShiftDown(),
540 event.GetKeyCode(), 1);
544 #endif //!(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
545 //---------------------------------------------------------------------------
546 void creawxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event)
553 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
555 int keycode = event.GetKeyCode();
557 if (((unsigned int)keycode) < 256)
559 // TODO: Unicode in non-Unicode mode ??
563 // we don't get a valid mouse position inside the key event on every platform
564 // so we retrieve the mouse position explicitly and pass it along
565 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
566 SetEventInformationFlipY(mousePos.x, mousePos.y,
567 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
568 InvokeEvent(vtkCommand::CharEvent, NULL);
572 //---------------------------------------------------------------------------
573 void creawxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
575 if (!Enabled || (ActiveButton != wxEVT_NULL))
579 ActiveButton = event.GetEventType();
581 // On Mac (Carbon) and Windows we don't automatically get the focus when
582 // you click inside the window
583 // we therefore set the focus explicitly
584 // Apparently we need that on linux (GTK) too:
587 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
588 SetEventInformationFlipY(event.GetX(), event.GetY(),
589 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
592 if(event.RightDown())
594 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
596 InvokeEvent(vtkCommand::RightButtonPressEvent, NULL);
599 InteractorStyle->OnRightButtonDown(event.ControlDown(), event.ShiftDown(),
600 event.GetX(), Size[1] - event.GetY() - 1);
603 else if(event.LeftDown())
605 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
607 InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
610 InteractorStyle->OnLeftButtonDown(event.ControlDown(), event.ShiftDown(),
611 event.GetX(), Size[1] - event.GetY() - 1);
614 else if(event.MiddleDown())
616 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
618 InvokeEvent(vtkCommand::MiddleButtonPressEvent, NULL);
621 InteractorStyle->OnMiddleButtonDown(event.ControlDown(), event.ShiftDown(),
622 event.GetX(), Size[1] - event.GetY() - 1);
625 //save the button and capture mouse until the button is released
627 //1. it is possible (WX_USE_X_CAPTURE)
628 //2. user decided to.
629 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
634 //---------------------------------------------------------------------------
635 void creawxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
637 //EVT_xxx_DOWN == EVT_xxx_UP - 1
638 //This is only needed if two mouse buttons are pressed at the same time.
639 //In wxWindows 2.4 and later: better use of wxMOUSE_BTN_RIGHT or
640 //wxEVT_COMMAND_RIGHT_CLICK
641 if (!Enabled || (ActiveButton != (event.GetEventType()-1)))
646 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
647 SetEventInformationFlipY(event.GetX(), event.GetY(),
648 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
651 if(ActiveButton == wxEVT_RIGHT_DOWN)
653 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
655 InvokeEvent(vtkCommand::RightButtonReleaseEvent, NULL);
658 InteractorStyle->OnRightButtonUp(event.ControlDown(), event.ShiftDown(),
659 event.GetX(), Size[1] - event.GetY() - 1);
662 else if(ActiveButton == wxEVT_LEFT_DOWN)
664 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
666 InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
669 InteractorStyle->OnLeftButtonUp(event.ControlDown(), event.ShiftDown(),
670 event.GetX(), Size[1] - event.GetY() - 1);
673 else if(ActiveButton == wxEVT_MIDDLE_DOWN)
675 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
677 InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, NULL);
680 InteractorStyle->OnMiddleButtonUp(event.ControlDown(), event.ShiftDown(),
681 event.GetX(), Size[1] - event.GetY() - 1);
684 //if the ActiveButton is realeased, then release mouse capture
685 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
689 ActiveButton = wxEVT_NULL;
691 //---------------------------------------------------------------------------
692 void creawxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event)
694 // Mouse wheel was only added after VTK 4.4 (I think...)
695 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
697 //Set vtk event information ... The numebr of wheel rotations is stored in
698 //the x varible. y varible is zero
699 SetEventInformationFlipY(event.GetWheelRotation() / event.GetWheelDelta(), 0,
700 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
701 if(event.GetWheelRotation() > 0)
704 InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL);
709 InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL);
715 //---------------------------------------------------------------------------
716 void creawxVTKRenderWindowInteractor::Render()
719 if (!RenderWhenDisabled)
721 //the user doesn't want us to render when the toplevel frame
722 //is disabled - first find the top level parent
723 wxWindow *topParent = wxGetTopLevelParent(this);
726 //if it exists, check whether it's enabled
727 //if it's not enabeld, RenderAllowed will be false
728 RenderAllowed = topParent->IsEnabled();
734 if(Handle && (Handle == GetHandleHack()) )
736 RenderWindow->Render();
738 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
739 else if(GetHandleHack())
741 //this means the user has reparented us; let's adapt to the
742 //new situation by doing the WindowRemap dance
743 //store the new situation
744 Handle = GetHandleHack();
745 RenderWindow->SetNextWindowId(reinterpret_cast<void *>(Handle));
746 RenderWindow->WindowRemap();
747 RenderWindow->Render();
752 //---------------------------------------------------------------------------
753 void creawxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue)
755 //Change value of __RenderWhenDisabled ivar.
756 //If __RenderWhenDisabled is false (the default), this widget will not
757 //call Render() on the RenderWindow if the top level frame (i.e. the
758 //containing frame) has been disabled.
760 //This prevents recursive rendering during wxSafeYield() calls.
761 //wxSafeYield() can be called during the ProgressMethod() callback of
762 //a VTK object to have progress bars and other GUI elements updated -
763 //it does this by disabling all windows (disallowing user-input to
764 //prevent re-entrancy of code) and then handling all outstanding
767 //However, this often triggers an OnPaint() method for wxVTKRWIs,
768 //resulting in a Render(), resulting in Update() being called whilst
771 RenderWhenDisabled = (bool)newValue;
773 //---------------------------------------------------------------------------
775 // Set the variable that indicates that we want a stereo capable window
776 // be created. This method can only be called before a window is realized.
778 void creawxVTKRenderWindowInteractor::SetStereo(int capable)
780 if (Stereo != capable)
783 RenderWindow->StereoCapableWindowOn();
784 RenderWindow->SetStereoTypeToCrystalEyes();
789 //---------------------------------------------------------------------------
792 void creawxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
794 this->Superclass::PrintSelf(os, indent);
801 //=======================================================================