contrib/brl/bbas/bgui3d/bgui3d_tableau.h
Go to the documentation of this file.
00001 // This is brl/bbas/bgui3d/bgui3d_tableau.h
00002 #ifndef bgui3d_tableau_h_
00003 #define bgui3d_tableau_h_
00004 //:
00005 // \file
00006 // \brief  Basic tableau that wraps Coin3D into VGUI
00007 // \author Matt Leotta (mleotta@lems.brown.edu)
00008 // \date   May 24, 2004
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   <none yet>
00013 // \endverbatim
00014 
00015 #include <vcl_memory.h>
00016 #include <vgui/vgui_clear_tableau.h>
00017 #include <vgui/vgui_event.h>
00018 #include <vpgl/vpgl_proj_camera.h>
00019 #include "bgui3d_tableau_sptr.h"
00020 
00021 // forward declarations
00022 class SbColor;
00023 class SoNode;
00024 class SoSceneManager;
00025 class SbViewportRegion;
00026 
00027 //:  Tableau that wraps Coin3D into VGUI.
00028 class bgui3d_tableau : public vgui_tableau
00029 {
00030  public:
00031   //: Constructor - don't use this, use bgui3d_tableau_new.
00032   bgui3d_tableau(SoNode* scene_root = NULL);
00033 
00034   //: Destructor
00035   virtual ~bgui3d_tableau();
00036 
00037   //: Return the type name of this tableau
00038   virtual vcl_string type_name() const;
00039 
00040   //: file name isn't valid, so return the type_name
00041   virtual vcl_string file_name() const { return this->type_name(); }
00042 
00043   //: Handle vgui events
00044   virtual bool handle(const vgui_event& event);
00045 
00046   //: Set up OpenGL for rendering
00047   virtual void setup_opengl() const;
00048 
00049   //: Render the scene graph (called on draw events)
00050   virtual bool render();
00051 
00052   //: Render the overlay scene graph (called on draw overlay events)
00053   virtual bool render_overlay();
00054 
00055   //: Called when the scene manager requests a render action
00056   virtual void request_render();
00057 
00058   //: Called when the scene manager requests a render overlay action
00059   virtual void request_render_overlay();
00060 
00061   //: Called when VGUI is idle
00062   virtual bool idle();
00063 
00064   //: Enable handling of idle events
00065   void enable_idle();
00066 
00067   //: Disable handling of idle events
00068   void disable_idle();
00069 
00070   //: Returns true if idle event handling is enabled
00071   bool is_idle_enabled();
00072 
00073   //---------------------Scene Methods------------------------------
00074   //: Set scene root node
00075   virtual void set_scene_root(SoNode* scene_root);
00076 
00077   //: Return the root node in the scene graph
00078   SoNode* scene_root() const { return scene_root_; }
00079 
00080   //: Set overlay scene root node
00081   virtual void set_overlay_scene_root(SoNode* scene_root);
00082 
00083   //: Return the root node in the overlay scene graph
00084   SoNode* overlay_scene_root() const { return overlay_scene_root_; }
00085 
00086   //---------------------Camera Methods-----------------------------
00087   //: Set the scene camera
00088   // creates a graphics camera from a vpgl camera (either perspective or affine)
00089   virtual bool set_camera(const vpgl_proj_camera<double>& camera);
00090 
00091   //: Get the scene camera
00092   // creates a vpgl camera (either perspective or affine) from the graphics camera
00093   virtual vcl_auto_ptr<vpgl_proj_camera<double> > camera() const;
00094   //----------------------------------------------------------------
00095 
00096   //: Set the viewport
00097   void set_viewport_region(const SbViewportRegion& region);
00098 
00099   //: Get the viewport
00100   const SbViewportRegion& get_viewport_region() const;
00101 
00102 
00103   //--------------Interaction Methods ----------------
00104   enum interaction_type_enum {CAMERA, SCENEGRAPH};
00105 
00106   //: Set the interaction type
00107   virtual void set_interaction_type( interaction_type_enum );
00108 
00109   //: Return the type of the interaction
00110   interaction_type_enum interaction_type() const;
00111 
00112 
00113   SoSceneManager* scene_manager() const;
00114 
00115  protected:
00116   //: The root node of the scene graph
00117   SoNode* scene_root_;
00118   SoNode* overlay_scene_root_;
00119 
00120   //: The scene manager
00121   SoSceneManager* scene_manager_;
00122   SoSceneManager* overlay_scene_manager_;
00123   bool idle_enabled_;
00124   interaction_type_enum interaction_type_;
00125 };
00126 
00127 
00128 //: Create a smart pointer to a bgui3d_tableau tableau.
00129 struct bgui3d_tableau_new : public bgui3d_tableau_sptr
00130 {
00131   typedef bgui3d_tableau_sptr base;
00132   bgui3d_tableau_new(SoNode* scene_root = NULL)
00133    : base(new bgui3d_tableau(scene_root)) { }
00134 };
00135 
00136 #endif // bgui3d_tableau_h_