Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

bgui_vsol_camera_tableau.h

Go to the documentation of this file.
00001 // This is brl/bbas/bgui/bgui_vsol_camera_tableau.h
00002 #ifndef bgui_vsol_camera_tableau_h_
00003 #define bgui_vsol_camera_tableau_h_
00004 //-----------------------------------------------------------------------------
00005 //:
00006 // \file
00007 // \brief A tableau that knows how to project 3-d vsol objects with a camera
00008 // \author
00009 //   J.L. Mundy
00010 //
00011 // \verbatim
00012 //  Created June 2, 2003
00013 //  Modifications:
00014 //   Peter Vanroose - 8 May 2004 - re-implemented add_vsol_box_3d() with a single polygon
00015 // \endverbatim
00016 //-----------------------------------------------------------------------------
00017 #include <vcl_vector.h>
00018 #include <vcl_map.h>
00019 #include <vgl/algo/vgl_p_matrix.h>
00020 #include <vgui/vgui_style.h>
00021 #include <vgl/vgl_point_2d.h>
00022 #include <vsol/vsol_spatial_object_3d_sptr.h>
00023 #include <vsol/vsol_point_3d_sptr.h>
00024 #include <vsol/vsol_line_3d_sptr.h>
00025 #include <vsol/vsol_polygon_3d_sptr.h>
00026 #include <vsol/vsol_box_3d_sptr.h>
00027 #include <vgui/vgui_tableau_sptr.h>
00028 #include <vgui/vgui_style_sptr.h>
00029 #include <vgui/vgui_image_tableau_sptr.h>
00030 #include <vgui/vgui_easy2D_tableau.h>
00031 
00032 #include "bgui_vsol_camera_tableau_sptr.h"
00033 class bgui_vsol_soview2D_point;
00034 class bgui_vsol_soview2D_line_seg;
00035 class bgui_vsol_soview2D_polygon;
00036 
00037 class bgui_vsol_camera_tableau : public vgui_easy2D_tableau
00038 {
00039  public:
00040   bgui_vsol_camera_tableau(const char* n="unnamed");
00041 
00042   bgui_vsol_camera_tableau(vgui_image_tableau_sptr const& it,
00043                            const char* n="unnamed");
00044 
00045   bgui_vsol_camera_tableau(vgui_tableau_sptr const& t,
00046                            const char* n="unnamed");
00047 
00048   ~bgui_vsol_camera_tableau();
00049 
00050   //:virtual handle method for events
00051   virtual bool handle(vgui_event const &);
00052 
00053   //:the projection camera
00054   void set_camera(vgl_p_matrix<double> const& camera) { camera_=camera; }
00055   vgl_p_matrix<double> get_camera() { return camera_; }
00056 
00057   //: display for projected vsol_point_3d
00058   bgui_vsol_soview2D_point*
00059     add_vsol_point_3d(vsol_point_3d_sptr const& point);
00060 
00061   //: display for vsol_line_3d
00062   bgui_vsol_soview2D_line_seg*
00063     add_vsol_line_3d(vsol_line_3d_sptr const& line);
00064 
00065   //: display for vsol_polygon_3d
00066   bgui_vsol_soview2D_polygon*
00067     add_vsol_polygon_3d(vsol_polygon_3d_sptr const& poly);
00068 
00069   //:display for a 3D box
00070   bgui_vsol_soview2D_polygon*
00071     add_vsol_box_3d(vsol_box_3d_sptr const& box);
00072 
00073   //: display for general spatial object
00074   void add_spatial_object_3d(vsol_spatial_object_3d_sptr const& sos);
00075 
00076   //: display methods for sets of objects
00077   void add_spatial_objects_3d(vcl_vector<vsol_spatial_object_3d_sptr> const& sos);
00078 
00079   void add_points_3d(vcl_vector<vsol_point_3d_sptr> const & lines);
00080 
00081   void add_lines_3d(vcl_vector<vsol_line_3d_sptr> const & lines);
00082 
00083   void add_polygons_3d(vcl_vector<vsol_polygon_3d_sptr> const & lines);
00084 
00085   void add_boxes_3d(vcl_vector<vsol_box_3d_sptr> const & lines);
00086 
00087 
00088   //: clear the tableau including the highlight map
00089   void clear_all();
00090 
00091   //: Methods for getting mapped objects
00092   void enable_highlight() { highlight_ = true; }
00093   void disable_highlight() { highlight_ = false; }
00094 
00095   //: Methods for changing the default style of displayable objects
00096 
00097   void set_vsol_point_3d_style(const float r, const float g, const float b,
00098                                const float point_radius);
00099 
00100   void set_vsol_line_3d_style(const float r, const float g, const float b,
00101                               const float line_width);
00102 
00103   void set_vsol_polygon_3d_style(const float r, const float g, const float b,
00104                                  const float line_width);
00105 
00106   void set_vsol_box_3d_style(const float r, const float g, const float b,
00107                              const float line_width);
00108 
00109  protected:
00110   //internal methods
00111   vgl_point_2d<double>  project(vsol_point_3d_sptr const& p3d);
00112   //members
00113   bool highlight_;
00114   void init();
00115   vcl_map<int, vsol_spatial_object_3d_sptr> obj_map_;
00116   vcl_map<vcl_string, vgui_style_sptr> style_map_;
00117   int old_id_;
00118   vgui_style_sptr highlight_style_;
00119   vgui_style_sptr old_style_;
00120   vgl_p_matrix<double> camera_;
00121 };
00122 
00123 //this stuff is needed to establish inheritance between tableau  smart pointers
00124 //cloned from xcv_image_tableau
00125 struct bgui_vsol_camera_tableau_new : public bgui_vsol_camera_tableau_sptr
00126 {
00127   typedef bgui_vsol_camera_tableau_sptr base;
00128 
00129   bgui_vsol_camera_tableau_new(const char* n="unnamed") :
00130     base(new bgui_vsol_camera_tableau(n)) { }
00131   bgui_vsol_camera_tableau_new(vgui_image_tableau_sptr const& it,
00132                                const char* n="unnamed") :
00133     base(new bgui_vsol_camera_tableau(it,n)) { }
00134 
00135   bgui_vsol_camera_tableau_new(vgui_tableau_sptr const& t, const char* n="unnamed")
00136     :  base(new bgui_vsol_camera_tableau(t, n)) { }
00137 
00138   operator vgui_easy2D_tableau_sptr () const { vgui_easy2D_tableau_sptr tt; tt.vertical_cast(*this); return tt; }
00139 };
00140 
00141 #endif // bgui_vsol_camera_tableau_h_

Generated on Thu Jan 10 14:52:11 2008 for contrib/brl/bbas/bgui by  doxygen 1.4.4