contrib/brl/bbas/bgui/bgui_vtol2D_tableau.h
Go to the documentation of this file.
00001 // This is brl/bbas/bgui/bgui_vtol2D_tableau.h
00002 #ifndef bgui_vtol2D_tableau_h_
00003 #define bgui_vtol2D_tableau_h_
00004 //-----------------------------------------------------------------------------
00005 //:
00006 // \file
00007 // \brief A child tableau of bgui_vsol2D_tableau that knows how to display vtol objects.
00008 // \author J.L. Mundy
00009 //
00010 //   Default styles are defined for each geometry and topology object soview.
00011 //   Users can change the default style by using the set_*_style commands,
00012 //   e.g. set_edge_style(0.0, 0.5, 0.5, 3) will define the style for each
00013 //   new edge added to the display.  This default is the style that the
00014 //   edge appearance will resume after being highlighted.
00015 //
00016 // \verbatim
00017 //  Modifications
00018 //   J.L. Mundy November 28, 2002  Initial version.
00019 //   J.L. Mundy December 16, 2002  Added map between soviews and vtol objects
00020 //   J.L. Mundy March 22, 2003     Added set style commands
00021 //   Amir Tamrakar April 22, 2002  Removed the functions to display vsol objects
00022 //                                 to bgui_vsol2D_tableau and subclasses this
00023 //                                 from it instead
00024 //   Mark Johnson June 13, 2003    Stopped using interior class functions to
00025 //                                 highlight objects. Added support for
00026 //                                 specifying colors of individual objects.
00027 //   Peter Vanroose  August 2004   Moved bgui_vtol2D_rubberband_client to separate file
00028 // \endverbatim
00029 //-----------------------------------------------------------------------------
00030 #include <vcl_vector.h>
00031 #include <vcl_map.h>
00032 #include <vcl_string.h>
00033 #include <vgui/vgui_style_sptr.h>
00034 #include <vtol/vtol_vertex_2d_sptr.h>
00035 #include <vtol/vtol_edge_2d_sptr.h>
00036 #include <vtol/vtol_face_2d_sptr.h>
00037 #include <vtol/vtol_topology_object_sptr.h>
00038 #include <vgui/vgui_tableau_sptr.h>
00039 #include <vgui/vgui_image_tableau_sptr.h>
00040 #include <bgui/bgui_vsol2D_tableau.h>
00041 #include <bgui/bgui_vsol2D_tableau_sptr.h>
00042 
00043 #include "bgui_vtol2D_tableau_sptr.h"
00044 
00045 class bgui_vtol_soview2D_vertex;
00046 class bgui_vtol_soview2D_edge;
00047 class bgui_vtol_soview2D_edge_group;
00048 class bgui_vtol_soview2D_face;
00049 
00050 class bgui_vtol2D_tableau : public bgui_vsol2D_tableau
00051 {
00052  public:
00053   bgui_vtol2D_tableau(const char* n="unnamed");
00054 
00055   bgui_vtol2D_tableau(vgui_image_tableau_sptr const& it,
00056                       const char* n="unnamed");
00057 
00058   bgui_vtol2D_tableau(vgui_tableau_sptr const& t,
00059                       const char* n="unnamed");
00060 
00061   ~bgui_vtol2D_tableau();
00062 
00063   virtual vcl_string type_name() const { return "bgui_vtol2D_tableau"; }
00064 
00065   //:virtual handle method for events
00066   virtual bool handle(vgui_event const &);
00067 
00068   //: the vtol display methods for individual topology classes
00069   bgui_vtol_soview2D_vertex* add_vertex(vtol_vertex_2d_sptr const& v,
00070                                         const vgui_style_sptr& style = NULL);
00071 
00072   bgui_vtol_soview2D_edge* add_edge(vtol_edge_2d_sptr const& e,
00073                                     const vgui_style_sptr& style = NULL);
00074 
00075   bgui_vtol_soview2D_edge_group* add_edge_group(vcl_vector<vtol_edge_2d_sptr>& edges,
00076                                                 const vgui_style_sptr& style = NULL);
00077 
00078   bgui_vtol_soview2D_face* add_face(vtol_face_2d_sptr const& f,
00079                                     const vgui_style_sptr& style = NULL);
00080 
00081   //: display methods for vectors of topology classes (not grouped)
00082   void add_topology_object(vtol_topology_object_sptr const& tos,
00083                            const vgui_style_sptr& style = NULL);
00084 
00085   void add_topology_objects(vcl_vector<vtol_topology_object_sptr> const& tos,
00086                             const vgui_style_sptr& style = NULL);
00087 
00088   void add_edges(vcl_vector<vtol_edge_2d_sptr> const & edges,
00089                  bool verts=false,
00090                  const vgui_style_sptr& style = NULL);
00091 
00092   void add_faces(vcl_vector<vtol_face_2d_sptr> const & faces, bool verts=false,
00093                  const vgui_style_sptr& style = NULL);
00094 
00095   //: clear the tableau including the highlight map
00096   void clear_all();
00097 
00098   //: Methods for getting mapped objects
00099   //void enable_highlight() { highlight_ = true; }
00100   //void disable_highlight() { highlight_ = false; }
00101   vtol_edge_2d_sptr get_mapped_edge(const int id);
00102   vtol_face_2d_sptr get_mapped_face(const int id);
00103 
00104   //: Methods for changing the default style of displayable objects
00105   void set_vtol_topology_object_style(vtol_topology_object_sptr tos,
00106                                       const vgui_style_sptr& style = NULL);
00107   void set_vertex_style(const vgui_style_sptr& style);
00108   void set_edge_style(const vgui_style_sptr& style);
00109   void set_edge_group_style(const vgui_style_sptr& style);
00110   void set_face_style(const vgui_style_sptr& style);
00111 
00112   //: Access to temporary cached object, useful for new rubberbanded objects
00113   void set_temp(vtol_topology_object_sptr const& to) { temp_=to; }
00114   vtol_topology_object_sptr get_temp() { return temp_; }
00115  protected:
00116   vgui_style_sptr vertex_style_;
00117   vgui_style_sptr edge_style_;
00118   vgui_style_sptr edge_group_style_;
00119   vgui_style_sptr face_style_;
00120   void init();
00121   vtol_topology_object_sptr temp_; //temporary storage for a topology object
00122   vcl_map<int, vtol_topology_object_sptr> obj_map_;
00123 };
00124 
00125 //this stuff is needed to establish inheritance between tableau  smart pointers
00126 //cloned from xcv_image_tableau
00127 struct bgui_vtol2D_tableau_new : public bgui_vtol2D_tableau_sptr
00128 {
00129   typedef bgui_vtol2D_tableau_sptr base;
00130 
00131   bgui_vtol2D_tableau_new(const char* n="unnamed") :
00132     base(new bgui_vtol2D_tableau(n)) { }
00133   bgui_vtol2D_tableau_new(vgui_image_tableau_sptr const& it,
00134                           const char* n="unnamed") :
00135     base(new bgui_vtol2D_tableau(it,n)) { }
00136 
00137   bgui_vtol2D_tableau_new(vgui_tableau_sptr const& t, const char* n="unnamed")
00138     :  base(new bgui_vtol2D_tableau(t, n)) { }
00139 
00140   operator bgui_vsol2D_tableau_sptr () const { bgui_vsol2D_tableau_sptr tt; tt.vertical_cast(*this); return tt; }
00141 };
00142 
00143 #endif // bgui_vtol2D_tableau_h_