wxVTKRenderWindowInteractor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: wxVTKRenderWindowInteractor.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009/05/14 13:54:35 $
00007   Version:   $Revision: 1.3 $
00008 
00009   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00010   All rights reserved.
00011   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00012 
00013      This software is distributed WITHOUT ANY WARRANTY; without even 
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00015      PURPOSE.  See the above copyright notice for more information.
00016 
00017 =========================================================================*/
00018 
00019 // .NAME  wxVTKRenderWindowInteractor - class to enable VTK to render to 
00020 // and interact with wxWindow.
00021 // .SECTION Description
00022 //  wxVTKRenderWindowInteractor provide a VTK widget for wxWindow. This class
00023 // was completely rewrote to have the 'Look & Feel' of the python version:
00024 // wxVTKRenderWindowInteractor.py
00025 // .SECTION Caveats 
00026 //  - There is a know bug that prevent this class to works for more info see 
00027 // WX_USE_X_CAPTURE. This bug only affect wxGTK from 2.3.2 to wxGTK 2.4.0.
00028 //  - Furthermore this class is tempated over either wxWindows or wxGLCanvas,
00029 // in wxWindows 2.3.1 and earlier, the wxGLCanvas had scroll bars, you can avoid
00030 // this effect by playing with WX_BASE_CLASS at your risk (you might end up with
00031 // lot of flickering.)
00032 //  - This class might not be easily readable as it tried to work with VTK 3.2
00033 //  and 4.x. This class doesn't support reparenting with VTK 4.2 and earlier.
00034 // .SECTION see also
00035 // wxVTKRenderWindowInteractor.py wxVTKRenderWindow.py
00036 
00037 #ifndef _wxVTKRenderWindowInteractor_h_
00038 #define _wxVTKRenderWindowInteractor_h_
00039 
00040 // For compilers that support precompilation, includes "wx/wx.h".
00041 #include "wx/wxprec.h"
00042 
00043 #ifdef __BORLANDC__
00044 #  pragma hdrstop
00045 #endif
00046 
00047 #ifndef WX_PRECOMP
00048 #include <wx/wx.h>
00049 #endif
00050 
00051 #include <wx/timer.h>
00052 #include <wx/dcclient.h>
00053 
00054 // vtk includes
00055 #include "vtkRenderWindowInteractor.h"
00056 #include "vtkRenderWindow.h"
00057 
00058 // Apparently since wxGTK 2.8.0 one can finally use wxWindow (just as in any
00059 // other port):
00060 #if (!wxCHECK_VERSION(2, 8, 0))
00061 #define USE_WXGLCANVAS
00062 #endif
00063 
00064 
00065 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
00066 # if wxUSE_GLCANVAS
00067 #    include <wx/glcanvas.h>
00068 # else
00069 #    error "problem of wxGLCanvas, you need to build wxWidgets with opengl"
00070 # endif //wxUSE_GLCANVAS
00071 #endif //__WXGTK__
00072 
00073 // Motif version (renamed into wxX11 for wxWindow 2.4 and newer)
00074 #if defined(__WXMOTIF__) 
00075 # error This GUI is not supported by wxVTKRenderWindowInteractor for now
00076 #endif
00077 
00078 // wx forward declarations
00079 class wxPaintEvent;
00080 class wxMouseEvent;
00081 class wxTimerEvent;
00082 class wxKeyEvent;
00083 class wxSizeEvent;
00084 
00085 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
00086 class VTK_RENDERING_EXPORT wxVTKRenderWindowInteractor : public wxGLCanvas, virtual public vtkRenderWindowInteractor
00087 #else
00088 class /*VTK_RENDERING_EXPORT*/ wxVTKRenderWindowInteractor : public wxWindow, virtual public vtkRenderWindowInteractor
00089 #endif //__WXGTK__
00090 {
00091   DECLARE_DYNAMIC_CLASS(wxVTKRenderWindowInteractor)
00092   
00093   public:
00094     //constructors
00095     wxVTKRenderWindowInteractor();
00096 
00097     wxVTKRenderWindowInteractor(wxWindow *parent,
00098                                 wxWindowID id,
00099                                 const wxPoint &pos = wxDefaultPosition,
00100                                 const wxSize &size = wxDefaultSize,
00101                                 long style = wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE,
00102                                 const wxString &name = wxPanelNameStr);
00103         //vtk ::New()
00104     static wxVTKRenderWindowInteractor * New();
00105     void PrintSelf(ostream& os, vtkIndent indent);
00106 
00107           //destructor
00108     ~wxVTKRenderWindowInteractor();
00109 
00110 #if defined(_WIN32)
00111     const char * wxVTKRenderWindowInteractor::GetClassName() const;
00112 #endif //_WIN32
00113 
00114 
00115     // vtkRenderWindowInteractor overrides
00116     void Initialize();
00117     void Enable();
00118     bool Enable(bool enable);
00119     void Disable();
00120     void Start();
00121     void UpdateSize(int x, int y);
00122     int CreateTimer(int timertype);
00123     int DestroyTimer();
00124     void TerminateApp() {};
00125 
00126     // event handlers
00127     void OnPaint(wxPaintEvent &event);
00128     void OnEraseBackground (wxEraseEvent& event);
00129     void OnMotion(wxMouseEvent &event);
00130 
00131     void OnButtonDown(wxMouseEvent &event);
00132     void OnButtonUp(wxMouseEvent &event);
00133 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
00134     void OnEnter(wxMouseEvent &event);
00135     void OnLeave(wxMouseEvent &event);
00136     void OnKeyDown(wxKeyEvent &event);
00137     void OnKeyUp(wxKeyEvent &event);
00138 #endif
00139     void OnTimer(wxTimerEvent &event);
00140     void OnSize(wxSizeEvent &event);
00141     void OnMouseWheel(wxMouseEvent& event);
00142 
00143     void Render()throw (char*);
00144     void SetRenderWhenDisabled(int newValue);
00145 
00146     // Description:
00147     // Prescribe that the window be created in a stereo-capable mode. This
00148     // method must be called before the window is realized. Default if off.
00149     vtkGetMacro(Stereo,int);
00150     vtkBooleanMacro(Stereo,int);
00151     virtual void SetStereo(int capable);
00152 
00153     // Description:
00154     // As CaptureMouse could be a problem sometimes on a window box
00155     // This method allow to set or not the CaptureMouse.
00156     // This method actually will works only if WX_USE_X_CAPTURE was set to 1
00157     vtkSetMacro(UseCaptureMouse,int);
00158     vtkBooleanMacro(UseCaptureMouse,int);
00159 
00160   protected:
00161     wxTimer timer;
00162     int ActiveButton;
00163     int RenderAllowed;
00164     long GetHandleHack();
00165     int Stereo;
00166     
00167   private:
00168     long Handle;
00169     bool Created;
00170     int RenderWhenDisabled;
00171     int UseCaptureMouse;
00172 
00173     DECLARE_EVENT_TABLE()
00174 };
00175 
00176 #endif //_wxVTKRenderWindowInteractor_h_

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1