1 // This is brl/bbas/bgui3d/bgui3d_tableau.h 2 #ifndef bgui3d_tableau_h_ 3 #define bgui3d_tableau_h_ 4 //: 5 // \file 6 // \brief Basic tableau that wraps Coin3D into VGUI 7 // \author Matt Leotta (mleotta@lems.brown.edu) 8 // \date May 24, 2004 9 // 10 // \verbatim 11 // Modifications 12 // <none yet> 13 // \endverbatim 14 15 #include <iostream> 16 #include <memory> 17 #ifdef _MSC_VER 18 # include <vcl_msvc_warnings.h> 19 #endif 20 #include <vgui/vgui_clear_tableau.h> 21 #include <vgui/vgui_event.h> 22 #include <vpgl/vpgl_proj_camera.h> 23 #include "bgui3d_tableau_sptr.h" 24 25 // forward declarations 26 class SbColor; 27 class SoNode; 28 class SoSceneManager; 29 class SbViewportRegion; 30 31 //: Tableau that wraps Coin3D into VGUI. 32 class bgui3d_tableau : public vgui_tableau 33 { 34 public: 35 //: Constructor - don't use this, use bgui3d_tableau_new. 36 bgui3d_tableau(SoNode* scene_root = NULL); 37 38 //: Destructor 39 virtual ~bgui3d_tableau(); 40 41 //: Return the type name of this tableau 42 virtual std::string type_name() const; 43 44 //: file name isn't valid, so return the type_name file_name()45 virtual std::string file_name() const { return this->type_name(); } 46 47 //: Handle vgui events 48 virtual bool handle(const vgui_event& event); 49 50 //: Set up OpenGL for rendering 51 virtual void setup_opengl() const; 52 53 //: Render the scene graph (called on draw events) 54 virtual bool render(); 55 56 //: Render the overlay scene graph (called on draw overlay events) 57 virtual bool render_overlay(); 58 59 //: Called when the scene manager requests a render action 60 virtual void request_render(); 61 62 //: Called when the scene manager requests a render overlay action 63 virtual void request_render_overlay(); 64 65 //: Called when VGUI is idle 66 virtual bool idle(); 67 68 //: Enable handling of idle events 69 void enable_idle(); 70 71 //: Disable handling of idle events 72 void disable_idle(); 73 74 //: Returns true if idle event handling is enabled 75 bool is_idle_enabled(); 76 77 //---------------------Scene Methods------------------------------ 78 //: Set scene root node 79 virtual void set_scene_root(SoNode* scene_root); 80 81 //: Return the root node in the scene graph scene_root()82 SoNode* scene_root() const { return scene_root_; } 83 84 //: Set overlay scene root node 85 virtual void set_overlay_scene_root(SoNode* scene_root); 86 87 //: Return the root node in the overlay scene graph overlay_scene_root()88 SoNode* overlay_scene_root() const { return overlay_scene_root_; } 89 90 //---------------------Camera Methods----------------------------- 91 //: Set the scene camera 92 // creates a graphics camera from a vpgl camera (either perspective or affine) 93 virtual bool set_camera(const vpgl_proj_camera<double>& camera); 94 95 //: Get the scene camera 96 // creates a vpgl camera (either perspective or affine) from the graphics camera 97 virtual std::unique_ptr<vpgl_proj_camera<double> > camera() const; 98 //---------------------------------------------------------------- 99 100 //: Set the viewport 101 void set_viewport_region(const SbViewportRegion& region); 102 103 //: Get the viewport 104 const SbViewportRegion& get_viewport_region() const; 105 106 107 //--------------Interaction Methods ---------------- 108 enum interaction_type_enum {CAMERA, SCENEGRAPH}; 109 110 //: Set the interaction type 111 virtual void set_interaction_type( interaction_type_enum ); 112 113 //: Return the type of the interaction 114 interaction_type_enum interaction_type() const; 115 116 117 SoSceneManager* scene_manager() const; 118 119 protected: 120 //: The root node of the scene graph 121 SoNode* scene_root_; 122 SoNode* overlay_scene_root_; 123 124 //: The scene manager 125 SoSceneManager* scene_manager_; 126 SoSceneManager* overlay_scene_manager_; 127 bool idle_enabled_; 128 interaction_type_enum interaction_type_; 129 }; 130 131 132 //: Create a smart pointer to a bgui3d_tableau tableau. 133 struct bgui3d_tableau_new : public bgui3d_tableau_sptr 134 { 135 typedef bgui3d_tableau_sptr base; 136 bgui3d_tableau_new(SoNode* scene_root = NULL) basebgui3d_tableau_new137 : base(new bgui3d_tableau(scene_root)) { } 138 }; 139 140 #endif // bgui3d_tableau_h_ 141