1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: wxVTKRenderWindowInteractor.cxx,v $
6 Date: $Date: 2011/02/17 11:01:27 $
7 Version: $Revision: 1.4 $
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 //=======================================================================
40 // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS
45 //Keep this for compatibilty reason, this was introduced in wxGTK 2.4.0
46 #if (!wxCHECK_VERSION(2, 4, 0))
47 wxWindow* wxGetTopLevelParent(wxWindow *win)
49 while ( win && !win->IsTopLevel() )
50 win = win->GetParent();
55 // LG : EO namespace bbwxvtk
56 //=======================================================================
58 // To access objc calls on cocoa
61 #import <Cocoa/Cocoa.h>
62 // This trick is no longer need in VTK CVS, should get rid of that:
65 #error Build mismatch you need both wxWidgets and VTK to be configure against Cocoa to work
66 #endif //VTK_USE_COCOA
70 # include <gdk/gdkx.h> // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0
71 # include "gdk/gdkprivate.h"
72 #if wxCHECK_VERSION(2, 8, 0)
74 #include <wx/gtk/win_gtk.h>
76 #include <wx/gtk1/win_gtk.h>
79 #include <wx/gtk/win_gtk.h>
81 #define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
82 GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \
83 GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
87 #include "wx/x11/privx.h"
88 #define GetXWindow(wxwin) ((Window)(wxwin)->GetHandle())
92 //For more info on this class please go to:
94 //This hack is for some buggy wxGTK version:
95 #if wxCHECK_VERSION(2, 3, 2) && !wxCHECK_VERSION(2, 4, 1) && defined(__WXGTK__)
96 # define WX_USE_X_CAPTURE 0
98 # define WX_USE_X_CAPTURE 1
101 #define ID_wxVTKRenderWindowInteractor_TIMER 1001
103 //=======================================================================
104 // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS
108 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
109 IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxGLCanvas)
111 IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxWindow)
114 //---------------------------------------------------------------------------
115 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
116 BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxGLCanvas)
118 BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
120 //refresh window by doing a Render
121 EVT_PAINT (wxVTKRenderWindowInteractor::OnPaint)
122 EVT_ERASE_BACKGROUND(wxVTKRenderWindowInteractor::OnEraseBackground)
123 EVT_MOTION (wxVTKRenderWindowInteractor::OnMotion)
125 //Bind the events to the event converters
126 EVT_LEFT_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
127 EVT_MIDDLE_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
128 EVT_RIGHT_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
129 EVT_LEFT_UP (wxVTKRenderWindowInteractor::OnButtonUp)
130 EVT_MIDDLE_UP (wxVTKRenderWindowInteractor::OnButtonUp)
131 EVT_RIGHT_UP (wxVTKRenderWindowInteractor::OnButtonUp)
132 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
133 EVT_ENTER_WINDOW(wxVTKRenderWindowInteractor::OnEnter)
134 EVT_LEAVE_WINDOW(wxVTKRenderWindowInteractor::OnLeave)
135 EVT_MOUSEWHEEL (wxVTKRenderWindowInteractor::OnMouseWheel)
136 EVT_KEY_DOWN (wxVTKRenderWindowInteractor::OnKeyDown)
137 EVT_KEY_UP (wxVTKRenderWindowInteractor::OnKeyUp)
138 EVT_CHAR (wxVTKRenderWindowInteractor::OnChar)
140 EVT_TIMER (ID_wxVTKRenderWindowInteractor_TIMER, wxVTKRenderWindowInteractor::OnTimer)
141 EVT_SIZE (wxVTKRenderWindowInteractor::OnSize)
144 vtkCxxRevisionMacro(wxVTKRenderWindowInteractor, "$Revision: 1.4 $")
145 vtkInstantiatorNewMacro(wxVTKRenderWindowInteractor)
147 //---------------------------------------------------------------------------
148 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
149 #if (wxCHECK_VERSION(2, 8, 0))
150 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(0, -1, wxDefaultPosition), vtkRenderWindowInteractor()
152 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(), vtkRenderWindowInteractor()
155 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxWindow(), vtkRenderWindowInteractor()
157 , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
158 , ActiveButton(wxEVT_NULL)
163 , RenderWhenDisabled(1)
166 #ifdef VTK_DEBUG_LEAKS
167 vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
169 this->RenderWindow = NULL;
170 this->SetRenderWindow(vtkRenderWindow::New());
171 this->RenderWindow->Delete();
173 //---------------------------------------------------------------------------
174 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
179 const wxString &name)
180 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
181 : wxGLCanvas(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
183 : wxWindow(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
185 , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
186 , ActiveButton(wxEVT_NULL)
191 , RenderWhenDisabled(1)
194 #ifdef VTK_DEBUG_LEAKS
195 vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
197 this->RenderWindow = NULL;
198 this->SetRenderWindow(vtkRenderWindow::New());
199 this->RenderWindow->Delete();
201 // On Mac (Carbon) we don't get notified of the initial window size with an EVT_SIZE event,
202 // so we update the size information of the interactor/renderwindow here
203 this->UpdateSize(size.x, size.y);
206 //---------------------------------------------------------------------------
207 wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor()
209 SetRenderWindow(NULL);
210 SetInteractorStyle(NULL);
212 //---------------------------------------------------------------------------
213 wxVTKRenderWindowInteractor * wxVTKRenderWindowInteractor::New()
215 // we don't make use of the objectfactory, because we're not registered
216 return new wxVTKRenderWindowInteractor;
218 //---------------------------------------------------------------------------
219 void wxVTKRenderWindowInteractor::Initialize()
221 int *size = RenderWindow->GetSize();
222 // enable everything and start rendering
224 //RenderWindow->Start();
226 // set the size in the render window interactor
230 // this is initialized
233 //---------------------------------------------------------------------------
234 void wxVTKRenderWindowInteractor::Enable()
236 // if already enabled then done
242 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
247 //---------------------------------------------------------------------------
248 bool wxVTKRenderWindowInteractor::Enable(bool enable)
250 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
251 return wxGLCanvas::Enable(enable);
253 return wxWindow::Enable(enable);
256 //---------------------------------------------------------------------------
257 void wxVTKRenderWindowInteractor::Disable()
259 // if already disabled then done
263 // that's it (we can't remove the event handler like it should be...)
267 //---------------------------------------------------------------------------
268 void wxVTKRenderWindowInteractor::Start()
270 // the interactor cannot control the event loop
271 vtkErrorMacro( << "wxVTKRenderWindowInteractor::Start() "
272 "interactor cannot control event loop.");
274 //---------------------------------------------------------------------------
275 void wxVTKRenderWindowInteractor::UpdateSize(int x, int y)
279 // if the size changed tell render window
280 if ( x != Size[0] || y != Size[1] )
282 // adjust our (vtkRenderWindowInteractor size)
285 // and our RenderWindow's size
286 RenderWindow->SetSize(x, y);
290 //---------------------------------------------------------------------------
291 int wxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype))
293 // it's a one shot timer
294 if (!timer.Start(10, TRUE))
300 //---------------------------------------------------------------------------
301 int wxVTKRenderWindowInteractor::DestroyTimer()
306 //---------------------------------------------------------------------------
307 void wxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event))
312 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
314 InvokeEvent(vtkCommand::TimerEvent, NULL);
317 InteractorStyle->OnTimer();
321 //---------------------------------------------------------------------------
322 // NOTE on implementation:
323 // Bad luck you ended up in the only tricky place of this code.
324 // A few note, wxWidgets still refuse to provide such convenient method
325 // so I have to maintain it myself, eventhough this is completely integrated
327 // Anyway if this happen to break for you then compare to a recent version of wxPython
328 // and look for the function long wxPyGetWinHandle(wxWindow* win)
329 // in wxPython/src/helpers.cpp
330 long wxVTKRenderWindowInteractor::GetHandleHack()
332 //helper function to hide the MSW vs GTK stuff
335 // __WXMSW__ is for Win32
336 //__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)
337 // __WXGTK__ is for both gtk 1.2.x and gtk 2.x
338 #if defined(__WXMSW__) || defined(__WXMAC__)
339 handle_tmp = (long)this->GetHandle();
342 //__WXCOCOA__ stands for using the objective-c Cocoa API
344 // Here is how to find the NSWindow
345 wxTopLevelWindow* toplevel = dynamic_cast<wxTopLevelWindow*>(
346 wxGetTopLevelParent( this ) );
347 if (toplevel != NULL )
349 handle_tmp = (long)toplevel->GetNSWindow();
351 // The NSView will be deducted from
352 // [(NSWindow*)Handle contentView]
353 // if only I knew how to write that in c++
356 // Find and return the actual X-Window.
357 #if defined(__WXGTK__) || defined(__WXX11__)
358 return (long)GetXWindow(this);
362 // handle_tmp = (long)this->GetXWindow();
367 //---------------------------------------------------------------------------
368 void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
370 //must always be here
373 //do it here rather than in the cstor: this is safer.
376 Handle = GetHandleHack();
377 RenderWindow->SetWindowId(reinterpret_cast<void *>(Handle));
379 RenderWindow->SetParentId(reinterpret_cast<void *>(this->GetParent()->GetHWND()));
382 // get vtk to render to the wxWindows
385 // This solves a problem with repainting after a window resize
386 // See also: http://sourceforge.net/mailarchive/forum.php?thread_id=31690967&forum_id=41789
387 vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow);
390 rwin->UpdateGLRegion();
394 //---------------------------------------------------------------------------
395 void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event)
397 //turn off background erase to reduce flickering on MSW
400 //---------------------------------------------------------------------------
401 void wxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event))
404 GetClientSize(&w, &h);
412 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
413 InvokeEvent(vtkCommand::ConfigureEvent, NULL);
415 //this will check for Handle
418 //---------------------------------------------------------------------------
419 void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event)
425 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
426 SetEventInformationFlipY(event.GetX(), event.GetY(),
427 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
429 InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
431 InteractorStyle->OnMouseMove(event.ControlDown(), event.ShiftDown(),
432 event.GetX(), Size[1] - event.GetY() - 1);
435 //---------------------------------------------------------------------------
436 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
437 void wxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event)
444 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
446 SetEventInformationFlipY(event.GetX(), event.GetY(),
447 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
449 InvokeEvent(vtkCommand::EnterEvent, NULL);
452 InteractorStyle->OnEnter(event.ControlDown(), event.ShiftDown(),
453 event.GetX(), Size[1] - event.GetY() - 1);
456 //---------------------------------------------------------------------------
457 void wxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event)
464 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
466 SetEventInformationFlipY(event.GetX(), event.GetY(),
467 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
469 InvokeEvent(vtkCommand::LeaveEvent, NULL);
472 InteractorStyle->OnLeave(event.ControlDown(), event.ShiftDown(),
473 event.GetX(), Size[1] - event.GetY() - 1);
476 //---------------------------------------------------------------------------
477 void wxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event)
484 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
486 int keycode = event.GetKeyCode();
488 if (((unsigned int)keycode) < 256)
490 // TODO: Unicode in non-Unicode mode ??
494 // we don't get a valid mouse position inside the key event on every platform
495 // so we retrieve the mouse position explicitly and pass it along
496 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
497 SetEventInformationFlipY(mousePos.x, mousePos.y,
498 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
499 InvokeEvent(vtkCommand::KeyPressEvent, NULL);
501 InteractorStyle->OnKeyDown(event.ControlDown(), event.ShiftDown(),
502 event.GetKeyCode(), 1);
506 //---------------------------------------------------------------------------
507 void wxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event)
514 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
516 int keycode = event.GetKeyCode();
518 if (((unsigned int)keycode) < 256)
520 // TODO: Unicode in non-Unicode mode ??
524 // we don't get a valid mouse position inside the key event on every platform
525 // so we retrieve the mouse position explicitly and pass it along
526 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
527 SetEventInformationFlipY(mousePos.x, mousePos.y,
528 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
529 InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
531 InteractorStyle->OnKeyUp(event.ControlDown(), event.ShiftDown(),
532 event.GetKeyCode(), 1);
536 #endif //!(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
537 //---------------------------------------------------------------------------
538 void wxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event)
545 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
547 int keycode = event.GetKeyCode();
549 if (((unsigned int)keycode) < 256)
551 // TODO: Unicode in non-Unicode mode ??
555 // we don't get a valid mouse position inside the key event on every platform
556 // so we retrieve the mouse position explicitly and pass it along
557 wxPoint mousePos = ScreenToClient(wxGetMousePosition());
558 SetEventInformationFlipY(mousePos.x, mousePos.y,
559 event.ControlDown(), event.ShiftDown(), key, 0, NULL);
560 InvokeEvent(vtkCommand::CharEvent, NULL);
564 //---------------------------------------------------------------------------
565 void wxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
567 if (!Enabled || (ActiveButton != wxEVT_NULL))
571 ActiveButton = event.GetEventType();
573 // On Mac (Carbon) and Windows we don't automatically get the focus when
574 // you click inside the window
575 // we therefore set the focus explicitly
576 // Apparently we need that on linux (GTK) too:
579 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
580 SetEventInformationFlipY(event.GetX(), event.GetY(),
581 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
584 if(event.RightDown())
586 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
588 InvokeEvent(vtkCommand::RightButtonPressEvent, NULL);
591 InteractorStyle->OnRightButtonDown(event.ControlDown(), event.ShiftDown(),
592 event.GetX(), Size[1] - event.GetY() - 1);
595 else if(event.LeftDown())
597 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
599 InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
602 InteractorStyle->OnLeftButtonDown(event.ControlDown(), event.ShiftDown(),
603 event.GetX(), Size[1] - event.GetY() - 1);
606 else if(event.MiddleDown())
608 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
610 InvokeEvent(vtkCommand::MiddleButtonPressEvent, NULL);
613 InteractorStyle->OnMiddleButtonDown(event.ControlDown(), event.ShiftDown(),
614 event.GetX(), Size[1] - event.GetY() - 1);
617 //save the button and capture mouse until the button is released
619 //1. it is possible (WX_USE_X_CAPTURE)
620 //2. user decided to.
621 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
626 //---------------------------------------------------------------------------
627 void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
629 //EVT_xxx_DOWN == EVT_xxx_UP - 1
630 //This is only needed if two mouse buttons are pressed at the same time.
631 //In wxWindows 2.4 and later: better use of wxMOUSE_BTN_RIGHT or
632 //wxEVT_COMMAND_RIGHT_CLICK
633 if (!Enabled || (ActiveButton != (event.GetEventType()-1)))
638 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
639 SetEventInformationFlipY(event.GetX(), event.GetY(),
640 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
643 if(ActiveButton == wxEVT_RIGHT_DOWN)
645 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
647 InvokeEvent(vtkCommand::RightButtonReleaseEvent, NULL);
650 InteractorStyle->OnRightButtonUp(event.ControlDown(), event.ShiftDown(),
651 event.GetX(), Size[1] - event.GetY() - 1);
654 else if(ActiveButton == wxEVT_LEFT_DOWN)
656 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
658 InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
661 InteractorStyle->OnLeftButtonUp(event.ControlDown(), event.ShiftDown(),
662 event.GetX(), Size[1] - event.GetY() - 1);
665 else if(ActiveButton == wxEVT_MIDDLE_DOWN)
667 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
669 InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, NULL);
672 InteractorStyle->OnMiddleButtonUp(event.ControlDown(), event.ShiftDown(),
673 event.GetX(), Size[1] - event.GetY() - 1);
676 //if the ActiveButton is realeased, then release mouse capture
677 if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
681 ActiveButton = wxEVT_NULL;
683 //---------------------------------------------------------------------------
684 void wxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event)
686 // Mouse wheel was only added after VTK 4.4 (I think...)
687 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
689 //Set vtk event information ... The numebr of wheel rotations is stored in
690 //the x varible. y varible is zero
691 SetEventInformationFlipY(event.GetWheelRotation() / event.GetWheelDelta(), 0,
692 event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
693 if(event.GetWheelRotation() > 0)
696 InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL);
701 InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL);
707 //---------------------------------------------------------------------------
708 void wxVTKRenderWindowInteractor::Render()
711 if (!RenderWhenDisabled)
713 //the user doesn't want us to render when the toplevel frame
714 //is disabled - first find the top level parent
715 wxWindow *topParent = wxGetTopLevelParent(this);
718 //if it exists, check whether it's enabled
719 //if it's not enabeld, RenderAllowed will be false
720 RenderAllowed = topParent->IsEnabled();
726 if(Handle && (Handle == GetHandleHack()) )
728 RenderWindow->Render();
730 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
731 else if(GetHandleHack())
733 //this means the user has reparented us; let's adapt to the
734 //new situation by doing the WindowRemap dance
735 //store the new situation
736 Handle = GetHandleHack();
737 RenderWindow->SetNextWindowId(reinterpret_cast<void *>(Handle));
738 RenderWindow->WindowRemap();
739 RenderWindow->Render();
744 //---------------------------------------------------------------------------
745 void wxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue)
747 //Change value of __RenderWhenDisabled ivar.
748 //If __RenderWhenDisabled is false (the default), this widget will not
749 //call Render() on the RenderWindow if the top level frame (i.e. the
750 //containing frame) has been disabled.
752 //This prevents recursive rendering during wxSafeYield() calls.
753 //wxSafeYield() can be called during the ProgressMethod() callback of
754 //a VTK object to have progress bars and other GUI elements updated -
755 //it does this by disabling all windows (disallowing user-input to
756 //prevent re-entrancy of code) and then handling all outstanding
759 //However, this often triggers an OnPaint() method for wxVTKRWIs,
760 //resulting in a Render(), resulting in Update() being called whilst
763 RenderWhenDisabled = (bool)newValue;
765 //---------------------------------------------------------------------------
767 // Set the variable that indicates that we want a stereo capable window
768 // be created. This method can only be called before a window is realized.
770 void wxVTKRenderWindowInteractor::SetStereo(int capable)
772 if (Stereo != capable)
775 RenderWindow->StereoCapableWindowOn();
776 RenderWindow->SetStereoTypeToCrystalEyes();
781 //---------------------------------------------------------------------------
784 void wxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
786 this->Superclass::PrintSelf(os, indent);
791 // LG : EO namespace bbwxvtk
792 //=======================================================================