1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 /*=========================================================================
28 Program: Visualization Toolkit
29 Module: $RCSfile: wxVTKRenderWindowInteractor.h,v $
31 Date: $Date: 2012/11/15 14:14:35 $
32 Version: $Revision: 1.5 $
34 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
36 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
38 This software is distributed WITHOUT ANY WARRANTY; without even
39 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
40 PURPOSE. See the above copyright notice for more information.
42 =========================================================================*/
44 // .NAME wxVTKRenderWindowInteractor - class to enable VTK to render to
45 // and interact with wxWindow.
46 // .SECTION Description
47 // wxVTKRenderWindowInteractor provide a VTK widget for wxWindow. This class
48 // was completely rewrote to have the 'Look & Feel' of the python version:
49 // wxVTKRenderWindowInteractor.py
51 // - There is a know bug that prevent this class to works for more info see
52 // WX_USE_X_CAPTURE. This bug only affect wxGTK from 2.3.2 to wxGTK 2.4.0.
53 // - Furthermore this class is tempated over either wxWindows or wxGLCanvas,
54 // in wxWindows 2.3.1 and earlier, the wxGLCanvas had scroll bars, you can avoid
55 // this effect by playing with WX_BASE_CLASS at your risk (you might end up with
56 // lot of flickering.)
57 // - This class might not be easily readable as it tried to work with VTK 3.2
58 // and 4.x. This class doesn't support reparenting with VTK 4.2 and earlier.
60 // wxVTKRenderWindowInteractor.py wxVTKRenderWindow.py
62 #ifndef _wxVTKRenderWindowInteractor_h_
63 #define _wxVTKRenderWindowInteractor_h_
65 // For compilers that support precompilation, includes "wx/wx.h".
66 #include "wx/wxprec.h"
77 #include <wx/dcclient.h>
80 #include "vtkRenderWindowInteractor.h"
81 #include "vtkRenderWindow.h"
83 // Apparently since wxGTK 2.8.0 one can finally use wxWindow (just as in any
85 // MM: tested on 2008/04/08: experienced some heavy flickering with wx-widget 2.6.0
86 // using a wxWindow instead of wxGLCanvas fixed the symptoms
87 //#if (!wxCHECK_VERSION(2, 6, 0))
88 #if (!wxCHECK_VERSION(2, 8, 0))
89 #define USE_WXGLCANVAS
92 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
94 # include <wx/glcanvas.h>
96 # error "problem of wxGLCanvas, you need to build wxWidgets with opengl"
97 # endif //wxUSE_GLCANVAS
100 // Motif version (renamed into wxX11 for wxWindow 2.4 and newer)
101 #if defined(__WXMOTIF__)
102 # error This GUI is not supported by wxVTKRenderWindowInteractor for now
105 // wx forward declarations
112 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
113 class wxVTKRenderWindowInteractor : public wxGLCanvas, public vtkRenderWindowInteractor
115 class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInteractor
118 DECLARE_DYNAMIC_CLASS(wxVTKRenderWindowInteractor)
122 wxVTKRenderWindowInteractor();
124 wxVTKRenderWindowInteractor(wxWindow *parent,
126 const wxPoint &pos = wxDefaultPosition,
127 const wxSize &size = wxDefaultSize,
128 long style = wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE,
129 const wxString &name = wxPanelNameStr);
132 //EED 2017-01-01 Migration VTK7
133 #if VTK_MAJOR_VERSION <= 5
134 vtkTypeRevisionMacro(wxVTKRenderWindowInteractor,vtkRenderWindowInteractor);
136 vtkTypeMacro(wxVTKRenderWindowInteractor,vtkRenderWindowInteractor);
139 static wxVTKRenderWindowInteractor * New();
140 void PrintSelf(ostream& os, vtkIndent indent);
143 ~wxVTKRenderWindowInteractor();
145 // vtkRenderWindowInteractor overrides
148 bool Enable(bool enable);
151 void UpdateSize(int x, int y);
152 int CreateTimer(int timertype);
154 void TerminateApp() {};
157 void OnPaint(wxPaintEvent &event);
158 void OnEraseBackground (wxEraseEvent& event);
159 void OnMotion(wxMouseEvent &event);
161 void OnButtonDown(wxMouseEvent &event);
162 void OnButtonUp(wxMouseEvent &event);
163 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
164 void OnEnter(wxMouseEvent &event);
165 void OnLeave(wxMouseEvent &event);
166 void OnKeyDown(wxKeyEvent &event);
167 void OnKeyUp(wxKeyEvent &event);
168 void OnChar(wxKeyEvent &event);
170 void OnTimer(wxTimerEvent &event);
171 void OnSize(wxSizeEvent &event);
172 void OnMouseWheel(wxMouseEvent& event);
175 void SetRenderWhenDisabled(int newValue);
178 // Prescribe that the window be created in a stereo-capable mode. This
179 // method must be called before the window is realized. Default if off.
180 vtkGetMacro(Stereo,int);
181 vtkBooleanMacro(Stereo,int);
182 virtual void SetStereo(int capable);
185 // As CaptureMouse could be a problem sometimes on a window box
186 // This method allow to set or not the CaptureMouse.
187 // This method actually will works only if WX_USE_X_CAPTURE was set to 1
188 vtkSetMacro(UseCaptureMouse,int);
189 vtkBooleanMacro(UseCaptureMouse,int);
195 long GetHandleHack();
201 int RenderWhenDisabled;
204 DECLARE_EVENT_TABLE()
207 #endif //_wxVTKRenderWindowInteractor_h_