wxVTKRenderWindowInteractor.h

00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004 
00005   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00006   All rights reserved.
00007   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even 
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 
00015 // .NAME  wxVTKRenderWindowInteractor - class to enable VTK to render to 
00016 // and interact with wxWindow.
00017 // .SECTION Description
00018 //  wxVTKRenderWindowInteractor provide a VTK widget for wxWindow. This class
00019 // was completely rewrote to have the 'Look & Feel' of the python version:
00020 // wxVTKRenderWindowInteractor.py
00021 // .SECTION Caveats 
00022 //  - There is a know bug that prevent this class to works for more info see 
00023 // WX_USE_X_CAPTURE. This bug only affect wxGTK from 2.3.2 to wxGTK 2.4.0.
00024 //  - Furthermore this class is tempated over either wxWindows or wxGLCanvas,
00025 // in wxWindows 2.3.1 and earlier, the wxGLCanvas had scroll bars, you can avoid
00026 // this effect by playing with WX_BASE_CLASS at your risk (you might end up with
00027 // lot of flickering.)
00028 //  - This class might not be easily readable as it tried to work with VTK 3.2
00029 //  and 4.x. This class doesn't support reparenting with VTK 4.2 and earlier.
00030 // .SECTION see also
00031 // wxVTKRenderWindowInteractor.py wxVTKRenderWindow.py
00032 
00033 #ifndef _wxVTKRenderWindowInteractor_h_
00034 #define _wxVTKRenderWindowInteractor_h_
00035 
00036 // For compilers that support precompilation, includes "wx/wx.h".
00037 #include "wx/wxprec.h"
00038 
00039 #ifdef __BORLANDC__
00040 #  pragma hdrstop
00041 #endif
00042 
00043 #ifndef WX_PRECOMP
00044 #include <wx/wx.h>
00045 #endif
00046 
00047 #include <wx/timer.h>
00048 #include <wx/dcclient.h>
00049 
00050 // vtk includes
00051 #include "vtkRenderWindowInteractor.h"
00052 #include "vtkRenderWindow.h"
00053 
00054 #ifdef __WXGTK__
00055 #  if wxUSE_GLCANVAS
00056 #    include <wx/glcanvas.h>
00057 #  else
00058 #    error "problem of wxGLCanvas, you need to build wxWidgets with opengl"
00059 #  endif //wxUSE_GLCANVAS
00060 #endif //__WXGTK__
00061 
00062 // Motif version (renamed into wxX11 for wxWindow 2.4 and newer)
00063 #if defined(__WXMOTIF__) 
00064 # error This GUI is not supported by wxVTKRenderWindowInteractor for now
00065 #endif
00066 
00067 // wx forward declarations
00068 class wxPaintEvent;
00069 class wxMouseEvent;
00070 class wxTimerEvent;
00071 class wxKeyEvent;
00072 class wxSizeEvent;
00073 
00074 /*
00075                       VTK static     VTK dynamic
00076 wxWindows static        1                3
00077 wxWindows dynamic       2                4
00078 
00079 Just open the file: wxVTKRenderWindowInteractor.h, find the line:
00080 class VTK_RENDERING_EXPORT wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInteractor
00081 
00082 And change it accordingly
00083 
00084    1. VTK_RENDERING_EXPORT is ok
00085    2. VTK_RENDERING_EXPORT is ok
00086    3. WXDLLEXPORT is ok
00087    4. remove WXDLLEXPORT / VTK_RENDERING_EXPORT
00088  */
00089 
00090 #ifdef __WXGTK__
00091 class VTK_RENDERING_EXPORT wxVTKRenderWindowInteractor : public wxGLCanvas, virtual public vtkRenderWindowInteractor
00092 #else
00093 //class VTK_RENDERING_EXPORT wxVTKRenderWindowInteractor : public wxWindow, virtual public vtkRenderWindowInteractor
00094 class wxVTKRenderWindowInteractor : public wxWindow, virtual public vtkRenderWindowInteractor
00095 #endif //__WXGTK__
00096 {
00097   DECLARE_DYNAMIC_CLASS(wxVTKRenderWindowInteractor)
00098   
00099   public:
00100     //constructors
00101     wxVTKRenderWindowInteractor();
00102 
00103     wxVTKRenderWindowInteractor(wxWindow *parent,
00104                                 wxWindowID id,
00105                                 const wxPoint &pos = wxDefaultPosition,
00106                                 const wxSize &size = wxDefaultSize,
00107                                 long style = wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE,
00108                                 const wxString &name = wxPanelNameStr);
00109     //vtk ::New()
00110     static wxVTKRenderWindowInteractor * New();
00111     void PrintSelf(ostream& os, vtkIndent indent);
00112 
00113       //destructor
00114     ~wxVTKRenderWindowInteractor();
00115 
00116     // vtkRenderWindowInteractor overrides
00117     void Initialize();
00118     void Enable();
00119     bool Enable(bool enable);
00120     void Disable();
00121     void Start();
00122     void UpdateSize(int x, int y);
00123     int CreateTimer(int timertype);
00124     int DestroyTimer();
00125     void TerminateApp() {};
00126 
00127     // event handlers
00128     void OnPaint(wxPaintEvent &event);
00129     void OnEraseBackground (wxEraseEvent& event);
00130     void OnMotion(wxMouseEvent &event);
00131 
00132     void OnButtonDown(wxMouseEvent &event);
00133     void OnButtonUp(wxMouseEvent &event);
00134 #if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
00135     void OnEnter(wxMouseEvent &event);
00136     void OnLeave(wxMouseEvent &event);
00137     void OnKeyDown(wxKeyEvent &event);
00138     void OnKeyUp(wxKeyEvent &event);
00139 #endif
00140     void OnTimer(wxTimerEvent &event);
00141     void OnSize(wxSizeEvent &event);
00142 
00143     void Render();
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 Wed Jan 24 15:56:26 2007 for MechSys by  doxygen 1.4.7