1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: wxVTKRenderWindowInteractor.h,v $
6 Date: $Date: 2009/05/14 13:54:35 $
7 Version: $Revision: 1.3 $
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 =========================================================================*/
19 // .NAME wxVTKRenderWindowInteractor - class to enable VTK to render to
20 // and interact with wxWindow.
21 // .SECTION Description
22 // wxVTKRenderWindowInteractor provide a VTK widget for wxWindow. This class
23 // was completely rewrote to have the 'Look & Feel' of the python version:
24 // wxVTKRenderWindowInteractor.py
26 // - There is a know bug that prevent this class to works for more info see
27 // WX_USE_X_CAPTURE. This bug only affect wxGTK from 2.3.2 to wxGTK 2.4.0.
28 // - Furthermore this class is tempated over either wxWindows or wxGLCanvas,
29 // in wxWindows 2.3.1 and earlier, the wxGLCanvas had scroll bars, you can avoid
30 // this effect by playing with WX_BASE_CLASS at your risk (you might end up with
31 // lot of flickering.)
32 // - This class might not be easily readable as it tried to work with VTK 3.2
33 // and 4.x. This class doesn't support reparenting with VTK 4.2 and earlier.
35 // wxVTKRenderWindowInteractor.py wxVTKRenderWindow.py
37 #ifndef _wxVTKRenderWindowInteractor_h_
38 #define _wxVTKRenderWindowInteractor_h_
40 // For compilers that support precompilation, includes "wx/wx.h".
41 #include "wx/wxprec.h"
52 #include <wx/dcclient.h>
55 #include "vtkRenderWindowInteractor.h"
56 #include "vtkRenderWindow.h"
58 // Apparently since wxGTK 2.8.0 one can finally use wxWindow (just as in any
60 #if (!wxCHECK_VERSION(2, 8, 0))
61 #define USE_WXGLCANVAS
65 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
67 # include <wx/glcanvas.h>
69 # error "problem of wxGLCanvas, you need to build wxWidgets with opengl"
70 # endif //wxUSE_GLCANVAS
73 // Motif version (renamed into wxX11 for wxWindow 2.4 and newer)
74 #if defined(__WXMOTIF__)
75 # error This GUI is not supported by wxVTKRenderWindowInteractor for now
78 // wx forward declarations
85 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
86 class VTK_RENDERING_EXPORT wxVTKRenderWindowInteractor : public wxGLCanvas, virtual public vtkRenderWindowInteractor
88 class /*VTK_RENDERING_EXPORT*/ wxVTKRenderWindowInteractor : public wxWindow, virtual public vtkRenderWindowInteractor
91 DECLARE_DYNAMIC_CLASS(wxVTKRenderWindowInteractor)
95 wxVTKRenderWindowInteractor();
97 wxVTKRenderWindowInteractor(wxWindow *parent,
99 const wxPoint &pos = wxDefaultPosition,
100 const wxSize &size = wxDefaultSize,
101 long style = wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE,
102 const wxString &name = wxPanelNameStr);
104 static wxVTKRenderWindowInteractor * New();
105 void PrintSelf(ostream& os, vtkIndent indent);
108 ~wxVTKRenderWindowInteractor();
111 const char * wxVTKRenderWindowInteractor::GetClassName() const;
115 // vtkRenderWindowInteractor overrides
118 bool Enable(bool enable);
121 void UpdateSize(int x, int y);
122 int CreateTimer(int timertype);
124 void TerminateApp() {};
127 void OnPaint(wxPaintEvent &event);
128 void OnEraseBackground (wxEraseEvent& event);
129 void OnMotion(wxMouseEvent &event);
131 void OnButtonDown(wxMouseEvent &event);
132 void OnButtonUp(wxMouseEvent &event);
133 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
134 void OnEnter(wxMouseEvent &event);
135 void OnLeave(wxMouseEvent &event);
136 void OnKeyDown(wxKeyEvent &event);
137 void OnKeyUp(wxKeyEvent &event);
139 void OnTimer(wxTimerEvent &event);
140 void OnSize(wxSizeEvent &event);
141 void OnMouseWheel(wxMouseEvent& event);
143 void Render()throw (char*);
144 void SetRenderWhenDisabled(int newValue);
147 // Prescribe that the window be created in a stereo-capable mode. This
148 // method must be called before the window is realized. Default if off.
149 vtkGetMacro(Stereo,int);
150 vtkBooleanMacro(Stereo,int);
151 virtual void SetStereo(int capable);
154 // As CaptureMouse could be a problem sometimes on a window box
155 // This method allow to set or not the CaptureMouse.
156 // This method actually will works only if WX_USE_X_CAPTURE was set to 1
157 vtkSetMacro(UseCaptureMouse,int);
158 vtkBooleanMacro(UseCaptureMouse,int);
164 long GetHandleHack();
170 int RenderWhenDisabled;
173 DECLARE_EVENT_TABLE()
176 #endif //_wxVTKRenderWindowInteractor_h_