core/vgui/vgui_roi_tableau.h
Go to the documentation of this file.
00001 // This is core/vgui/vgui_roi_tableau.h
00002 #ifndef vgui_roi_tableau_h_
00003 #define vgui_roi_tableau_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  Tableau which makes an ROI of an image act like a whole image.
00010 // \author Marko Bacic, Robotics Research Group, University of Oxford
00011 // \date   18 Jul 2000
00012 //
00013 //  ROI means "region of interest".  In this case it can only be
00014 //  a rectangular region.
00015 //  Contains classes  vgui_roi_tableau  vgui_roi_tableau_new
00016 //
00017 // \verbatim
00018 //  Modifications
00019 //   18-Jul-2000  Marko Bacic - Initial version.
00020 //   08-Aug-2002  K.Y.McGaul - Changed to Doxygen style comments.
00021 // \endverbatim
00022 
00023 
00024 #include <vgui/vgui_tableau.h>
00025 #include <vil1/vil1_image.h>
00026 class vil1_crop_image_impl;
00027 class vil1_image;
00028 class vgui_image_tableau;
00029 
00030 #include "vgui_roi_tableau_sptr.h"
00031 
00032 //: Tableau which makes an ROI of an image act like a whole image.
00033 //
00034 //  ROI means "region of interest".  In this case it can only be
00035 //  a rectangular region.
00036 class vgui_roi_tableau : public vgui_tableau
00037 {
00038  public:
00039   //: Data defining a region of interest (position, height and width).
00040   typedef struct region_of_interest {
00041     float sx;
00042     float sy;
00043     float width;
00044     float height;
00045   }  ROI;
00046 
00047  private:
00048   ROI roi_;
00049   vil1_image cropped_image_;
00050   vcl_string name_;
00051 
00052  public:
00053   //: Constructor - don't use this, use vgui_roi_tableau_new.
00054   vgui_roi_tableau();
00055 
00056   //: Constructor - don't use this, use vgui_roi_tableau_new.
00057   vgui_roi_tableau(vil1_image const &, char const *, float, float, float, float);
00058 
00059   //: Returns the type of this tableau ('vgui_roi_tableau').
00060   vcl_string type_name() const;
00061 
00062   //: Returns the filename of the image (if it knows it).
00063   vcl_string file_name() const;
00064 
00065   //: Returns a nice version of the name, including the filename.
00066   vcl_string pretty_name() const;
00067 
00068   //: Returns the image cropped by the ROI.
00069   vil1_image get_image() const;
00070 
00071   //: Make the given image the underlying image for this tableau.
00072   void set_image(vil1_image const &);
00073 
00074   //: Make image loaded from the given filename the image for this tableau.
00075   void set_image(char const *);          // <- convenience
00076 
00077   //: Width of image (0 if none).
00078   unsigned width() const;
00079 
00080   //: Height of image (0 if none).
00081   unsigned height() const;
00082 
00083   //: Returns the bounding box of the ROI.
00084   bool get_bounding_box(float low[3], float high[3]) const;
00085 
00086  protected:
00087   //: Destructor - called by vgui_roi_tableau_sptr.
00088   ~vgui_roi_tableau();
00089 
00090   //: Handle all events passed to this tableau.
00091   bool handle(vgui_event const &e);
00092 };
00093 
00094 //: Creates a smart-pointer to a vgui_roi_tableau.
00095 struct vgui_roi_tableau_new : public vgui_roi_tableau_sptr
00096 {
00097   typedef vgui_roi_tableau_sptr base;
00098 
00099   //: Constructor - creates a vgui_roi_tableau.
00100   vgui_roi_tableau_new() : base(new vgui_roi_tableau()) { }
00101 };
00102 
00103 #endif // vgui_roi_tableau_h_