1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: creawxVTKRenderWindowInteractor.h,v $
6 Date: $Date: 2008/12/11 14:27:00 $
7 Version: $Revision: 1.2 $
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 creawxVTKRenderWindowInteractor - class to enable VTK to render to
20 // and interact with wxWindow.
21 // .SECTION Description
22 // creawxVTKRenderWindowInteractor provide a VTK widget for wxWindow. This class
23 // was completely rewrote to have the 'Look & Feel' of the python version:
24 // creawxVTKRenderWindowInteractor.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 // creawxVTKRenderWindowInteractor.py creawxVTKRenderWindow.py
37 #ifndef _creawxVTKRenderWindowInteractor_h_
38 #define _creawxVTKRenderWindowInteractor_h_
43 #include <creaSystem.h>
47 // For compilers that support precompilation, includes "wx/wx.h".
48 #include "wx/wxprec.h"
59 #include <wx/dcclient.h>
62 #include "vtkRenderWindowInteractor.h"
63 #include "vtkRenderWindow.h"
65 // Apparently since wxGTK 2.8.0 one can finally use wxWindow (just as in any
67 #if (!wxCHECK_VERSION(2, 8, 0))
68 #define USE_WXGLCANVAS
72 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
74 # include <wx/glcanvas.h>
76 # error "problem of wxGLCanvas, you need to build wxWidgets with opengl"
77 # endif //wxUSE_GLCANVAS
80 // Motif version (renamed into wxX11 for wxWindow 2.4 and newer)
81 #if defined(__WXMOTIF__)
82 # error This GUI is not supported by creawxVTKRenderWindowInteractor for now
86 // wx forward declarations
93 //=======================================================================
94 // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS
99 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
100 class CREA_EXPORT creawxVTKRenderWindowInteractor : public wxGLCanvas, virtual public vtkRenderWindowInteractor
102 class CREA_EXPORT creawxVTKRenderWindowInteractor : public wxWindow, virtual public vtkRenderWindowInteractor
105 DECLARE_DYNAMIC_CLASS(creawxVTKRenderWindowInteractor)
109 creawxVTKRenderWindowInteractor();
111 creawxVTKRenderWindowInteractor(wxWindow *parent,
113 const wxPoint &pos = wxDefaultPosition,
114 const wxSize &size = wxDefaultSize,
115 long style = wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE,
116 const wxString &name = wxPanelNameStr);
118 static creawxVTKRenderWindowInteractor * New();
119 void PrintSelf(ostream& os, vtkIndent indent);
122 ~creawxVTKRenderWindowInteractor();
125 const char * creawxVTKRenderWindowInteractor::GetClassName() const;
129 // vtkRenderWindowInteractor overrides
132 bool Enable(bool enable);
135 void UpdateSize(int x, int y);
136 int CreateTimer(int timertype);
138 void TerminateApp() {};
141 void OnPaint(wxPaintEvent &event);
142 void OnEraseBackground (wxEraseEvent& event);
143 void OnMotion(wxMouseEvent &event);
145 void OnButtonDown(wxMouseEvent &event);
146 void OnButtonUp(wxMouseEvent &event);
147 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
148 void OnEnter(wxMouseEvent &event);
149 void OnLeave(wxMouseEvent &event);
150 void OnKeyDown(wxKeyEvent &event);
151 void OnKeyUp(wxKeyEvent &event);
153 void OnTimer(wxTimerEvent &event);
154 void OnSize(wxSizeEvent &event);
155 void OnMouseWheel(wxMouseEvent& event);
158 void SetRenderWhenDisabled(int newValue);
161 // Prescribe that the window be created in a stereo-capable mode. This
162 // method must be called before the window is realized. Default if off.
163 vtkGetMacro(Stereo,int);
164 vtkBooleanMacro(Stereo,int);
165 virtual void SetStereo(int capable);
168 // As CaptureMouse could be a problem sometimes on a window box
169 // This method allow to set or not the CaptureMouse.
170 // This method actually will works only if WX_USE_X_CAPTURE was set to 1
171 vtkSetMacro(UseCaptureMouse,int);
172 vtkBooleanMacro(UseCaptureMouse,int);
178 long GetHandleHack();
184 int RenderWhenDisabled;
187 DECLARE_EVENT_TABLE()
191 // LG : EO namespace crea
192 //======================================================================
196 #endif //_creawxVTKRenderWindowInteractor_h_