]> Creatis software - bbtk.git/blob - packages/wxvtk/src/wxVTKRenderWindowInteractor.h
#3107 BBTK Bug New Normal - branch vtk7itk4 compilation with vtk7
[bbtk.git] / packages / wxvtk / src / wxVTKRenderWindowInteractor.h
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29
30   Program:   Visualization Toolkit
31   Module:    $RCSfile: wxVTKRenderWindowInteractor.h,v $
32   Language:  C++
33   Date:      $Date: 2012/11/16 08:52:36 $
34   Version:   $Revision: 1.4 $
35  
36 =========================================================================*/
37
38 // .NAME  wxVTKRenderWindowInteractor - class to enable VTK to render to 
39 // and interact with wxWindow.
40 // .SECTION Description
41 //  wxVTKRenderWindowInteractor provide a VTK widget for wxWindow. This class
42 // was completely rewrote to have the 'Look & Feel' of the python version:
43 // wxVTKRenderWindowInteractor.py
44 // .SECTION Caveats 
45 //  - There is a know bug that prevent this class to works for more info see 
46 // WX_USE_X_CAPTURE. This bug only affect wxGTK from 2.3.2 to wxGTK 2.4.0.
47 //  - Furthermore this class is tempated over either wxWindows or wxGLCanvas,
48 // in wxWindows 2.3.1 and earlier, the wxGLCanvas had scroll bars, you can avoid
49 // this effect by playing with WX_BASE_CLASS at your risk (you might end up with
50 // lot of flickering.)
51 //  - This class might not be easily readable as it tried to work with VTK 3.2
52 //  and 4.x. This class doesn't support reparenting with VTK 4.2 and earlier.
53 // .SECTION see also
54 // wxVTKRenderWindowInteractor.py wxVTKRenderWindow.py
55
56 #ifndef _wxVTKRenderWindowInteractor_h_
57 #define _wxVTKRenderWindowInteractor_h_
58
59 // For compilers that support precompilation, includes "wx/wx.h".
60 #include "wx/wxprec.h"
61
62 #ifdef __BORLANDC__
63 #  pragma hdrstop
64 #endif
65
66 #ifndef WX_PRECOMP
67 #include <wx/wx.h>
68 #endif
69
70 #include <wx/timer.h>
71 #include <wx/dcclient.h>
72
73 // vtk includes
74 #include "vtkRenderWindowInteractor.h"
75 #include "vtkRenderWindow.h"
76
77 // Apparently since wxGTK 2.8.0 one can finally use wxWindow (just as in any
78 // other port):
79 // MM: tested on 2008/04/08: experienced some heavy flickering with wx-widget 2.6.0
80 // using a wxWindow instead of wxGLCanvas fixed the symptoms
81 //#if (!wxCHECK_VERSION(2, 6, 0))
82 #if (!wxCHECK_VERSION(2, 8, 0))
83 #define USE_WXGLCANVAS
84 #endif
85
86 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
87 #  if wxUSE_GLCANVAS
88 #    include <wx/glcanvas.h>
89 #  else
90 #    error "problem of wxGLCanvas, you need to build wxWidgets with opengl"
91 #  endif //wxUSE_GLCANVAS
92 #endif //__WXGTK__
93
94 // Motif version (renamed into wxX11 for wxWindow 2.4 and newer)
95 #if defined(__WXMOTIF__) 
96 # error This GUI is not supported by wxVTKRenderWindowInteractor for now
97 #endif
98
99 // wx forward declarations
100 class wxPaintEvent;
101 class wxMouseEvent;
102 class wxTimerEvent;
103 class wxKeyEvent;
104 class wxSizeEvent;
105
106 //=======================================================================
107 // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS
108 namespace bbwxvtk
109 {
110
111
112 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
113 class wxVTKRenderWindowInteractor : public wxGLCanvas, public vtkRenderWindowInteractor
114 #else
115 class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInteractor
116 #endif //__WXGTK__
117 {
118   DECLARE_DYNAMIC_CLASS(wxVTKRenderWindowInteractor)
119   
120   public:
121     //constructors
122     wxVTKRenderWindowInteractor();
123
124     wxVTKRenderWindowInteractor(wxWindow *parent,
125                                 wxWindowID id,
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);
130
131 //EED 2017-01-01 Migration VTK7
132 #if VTK_MAJOR_VERSION <= 5
133     vtkTypeRevisionMacro(wxVTKRenderWindowInteractor,vtkRenderWindowInteractor);
134 #else
135     vtkTypeMacro(wxVTKRenderWindowInteractor,vtkRenderWindowInteractor);
136 #endif
137
138     static wxVTKRenderWindowInteractor * New();
139     void PrintSelf(ostream& os, vtkIndent indent);
140
141           //destructor
142     ~wxVTKRenderWindowInteractor();
143
144     // vtkRenderWindowInteractor overrides
145     void Initialize();
146     void Enable();
147     bool Enable(bool enable);
148     void Disable();
149     void Start();
150     void UpdateSize(int x, int y);
151     int  CreateTimer(int timertype);
152     int  DestroyTimer();
153     void TerminateApp() {};
154
155     // event handlers
156     void OnPaint(wxPaintEvent &event);
157     void OnEraseBackground (wxEraseEvent& event);
158     void OnMotion(wxMouseEvent &event);
159
160     void OnButtonDown(wxMouseEvent &event);
161     void OnButtonUp(wxMouseEvent &event);
162 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
163     void OnEnter(wxMouseEvent &event);
164     void OnLeave(wxMouseEvent &event);
165     void OnKeyDown(wxKeyEvent &event);
166     void OnKeyUp(wxKeyEvent &event);
167     void OnChar(wxKeyEvent &event);
168 #endif
169     void OnTimer(wxTimerEvent &event);
170     void OnSize(wxSizeEvent &event);
171     void OnMouseWheel(wxMouseEvent& event);
172
173     void Render();
174     void SetRenderWhenDisabled(int newValue);
175
176     // Description:
177     // Prescribe that the window be created in a stereo-capable mode. This
178     // method must be called before the window is realized. Default if off.
179     vtkGetMacro(Stereo,int);
180     vtkBooleanMacro(Stereo,int);
181     virtual void SetStereo(int capable);
182
183     // Description:
184     // As CaptureMouse could be a problem sometimes on a window box
185     // This method allow to set or not the CaptureMouse.
186     // This method actually will works only if WX_USE_X_CAPTURE was set to 1
187     vtkSetMacro(UseCaptureMouse,int);
188     vtkBooleanMacro(UseCaptureMouse,int);
189
190   protected:
191     wxTimer     timer;
192     int         ActiveButton;
193     int         RenderAllowed;
194     long        GetHandleHack();
195     int         Stereo;
196     
197   private:
198     long        Handle;
199     bool        Created;
200     int         RenderWhenDisabled;
201     int         UseCaptureMouse;
202
203     DECLARE_EVENT_TABLE()
204 };
205
206
207 // LG : EO namespace bbwxvtk
208 //======================================================================
209
210 #endif //_wxVTKRenderWindowInteractor_h_