core/vgui/vgui_viewer3D_tableau.h
Go to the documentation of this file.
00001 // This is core/vgui/vgui_viewer3D_tableau.h
00002 #ifndef vgui_viewer3D_tableau_h_
00003 #define vgui_viewer3D_tableau_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  Tableau with functions to view 3D objects (eg, rotate, zoom, etc).
00010 // \author Philip C. Pritchett, Robotics Research Group, University of Oxford
00011 // \date   14-SEP-1999
00012 //
00013 //  Contains classes  vgui_viewer3D_tableau  vgui_viewer3D_tableau_new
00014 //
00015 // \verbatim
00016 //  Modifications
00017 //   14-SEP-1999 P.Pritchett - Initial version.
00018 //   07-AUG-2002 K.Y.McGaul - Changed to and added Doxygen style comments.
00019 //   01-OCT-2002 K.Y.McGaul - Moved vgui_viewer3D to vgui_viewer3D_tableau.
00020 // \endverbatim
00021 
00022 #include "vgui_viewer3D_tableau_sptr.h"
00023 #include <vgui/vgui_wrapper_tableau.h>
00024 #include <vgui/vgui_drag_mixin.h>
00025 #include <vgui/vgui_event_condition.h>
00026 #include "dll.h"
00027 
00028 struct vgui_viewer3D_tableau_spin;
00029 
00030 //:  Tableau with functions to view 3D objects (eg, rotate, zoom, etc).
00031 class vgui_viewer3D_tableau : public vgui_wrapper_tableau, public vgui_drag_mixin
00032 {
00033  public:
00034   //: Constructor - don't use this, use vgui_viewer3D_tableau_new.
00035   vgui_viewer3D_tableau(vgui_tableau_sptr const&);
00036 
00037   // vgui_tableau methods
00038   void draw_before_child();
00039   virtual bool handle(const vgui_event& event);
00040   vcl_string type_name() const;
00041 
00042   // Drag mixin methods
00043   bool key_press(int, int, vgui_key, vgui_modifier);
00044   bool help();
00045   bool mouse_up(int x, int y, vgui_button button, vgui_modifier modifier);
00046   bool mouse_drag(int x, int y, vgui_button button, vgui_modifier modifier);
00047   bool mouse_down(int x, int y, vgui_button button, vgui_modifier modifier);
00048 
00049   // Key/mouse codes that initiate various actions
00050   vgui_event_condition c_mouse_rotate;
00051   vgui_event_condition c_mouse_translate;
00052   vgui_event_condition c_mouse_zoom;
00053   vgui_event_condition c_lock_dolly;
00054   vgui_event_condition c_lock_zoom;
00055   vgui_event_condition c_lighting;
00056   vgui_event_condition c_shading;
00057   vgui_event_condition c_spinning;
00058   vgui_event_condition c_render_mode;
00059   vgui_event_condition c_niceness;
00060   vgui_event_condition c_headlight;
00061   vgui_event_condition c_save_home;
00062   vgui_event_condition c_restore_home;
00063 
00064   // Implementation
00065   void setup_gl_matrices();
00066 
00067   //: Data on the current state of vgui_viewer3D_tableau (eg, the amount we are zoomed).
00068   struct token_t
00069   {
00070     float quat[4];     // quaternion
00071     float scale;
00072     float trans[3];
00073     float fov;
00074     token_t() {
00075       quat[0] = quat[1] = quat[2] = quat[3] = 0.0f;
00076       scale = 0.0;
00077       trans[0] = trans[1] = trans[2] = 0.0;
00078       fov = 45;
00079     }
00080   };
00081 
00082   token_t token;
00083   token_t home;
00084 
00085   static vgui_DLLDATA const void * const SPIN_EVENT;
00086 
00087 
00088   enum {wireframe, shaded, textured} gl_mode;
00089 
00090   bool spinning;
00091   bool allow_spinning;
00092   bool lighting;
00093   bool smooth_shading;
00094   bool high_quality;
00095   bool headlight;
00096 
00097  protected:
00098  ~vgui_viewer3D_tableau();
00099 
00100  private:
00101   vgui_event event;
00102   vgui_event last;
00103 
00104   vgui_viewer3D_tableau *viewer;
00105   float beginx;
00106   float beginy;
00107   token_t lastpos;
00108   float prevx;
00109   float prevy;
00110 
00111   bool lock_dolly;
00112   bool lock_zoom;
00113 
00114   vgui_viewer3D_tableau_spin *spin_data;
00115 };
00116 
00117 //: Create a smart pointer to a vgui_viewer3D_tableau tableau.
00118 struct vgui_viewer3D_tableau_new : public vgui_viewer3D_tableau_sptr
00119 {
00120   typedef vgui_viewer3D_tableau_sptr base;
00121   vgui_viewer3D_tableau_new(vgui_tableau_sptr const& a) : base(new vgui_viewer3D_tableau(a)) { }
00122 };
00123 
00124 #endif // vgui_viewer3D_tableau_h_