contrib/brl/bbas/bgui/bgui_vsol_soview2D.h
Go to the documentation of this file.
00001 // This is brl/bbas/bgui/bgui_vsol_soview2D.h
00002 #ifndef bgui_vsol_soview2D_h_
00003 #define bgui_vsol_soview2D_h_
00004 //--------------------------------------------------------------------------------
00005 //:
00006 // \file
00007 // \brief A collection of vgui_soview2D objects
00008 // \author
00009 //   J.L. Mundy
00010 //
00011 // \verbatim
00012 //  Modifications:
00013 //   J.L. Mundy     June 2, 2003  Initial version.
00014 //   Amir Tamrakar June 06, 2003  Added soview for vsol_polyline_2d.
00015 //   M.R. Johnson  June 20, 2003  Initial version of linked soviews.
00016 //   M.J. Leotta   April 3, 2004  Merged linked soviews back into this file
00017 //   Sancar Adali    May 5, 2004  Created a base class bgui_vsol_soview2D, a base
00018 //                                class for all bgui_vsol_soview2D_xxx objects
00019 //                                It has the sptr to the vsol data object
00020 // \endverbatim
00021 //--------------------------------------------------------------------------------
00022 
00023 #include <vcl_iosfwd.h>
00024 #include <vdgl/vdgl_digital_curve_sptr.h>
00025 #include <vsol/vsol_spatial_object_2d_sptr.h>
00026 #include <vsol/vsol_line_2d_sptr.h>
00027 #include <vsol/vsol_conic_2d_sptr.h>
00028 #include <vsol/vsol_point_2d_sptr.h>
00029 #include <vsol/vsol_polyline_2d_sptr.h>
00030 #include <vsol/vsol_polygon_2d_sptr.h>
00031 #include <vsol/vsol_poly_set_2d_sptr.h>
00032 #include <vsol/vsol_digital_curve_2d_sptr.h>
00033 
00034 #include <vgui/vgui_soview2D.h>
00035 
00036 
00037 class bgui_vsol_soview2D : public vgui_soview2D
00038 {
00039  public:
00040   //: Constructor - creates a default vsol_spatial_object_2d view
00041   bgui_vsol_soview2D( vsol_spatial_object_2d_sptr const & pt);
00042 
00043   //: Destructor
00044   ~bgui_vsol_soview2D() {}
00045 
00046   //: Print details about this vsol object to the given stream.
00047   vcl_ostream& print(vcl_ostream&) const;
00048 
00049   //: Returns the type of this class
00050   virtual vcl_string type_name() const=0;
00051 
00052   //: Render this 2D digital_curve on the display.
00053   virtual void draw() const=0;
00054 
00055   vsol_spatial_object_2d_sptr base_sptr() const { return sptr_; }
00056 
00057   //: Translate this 2D digital_curve by the given x and y distances.
00058   virtual void translate(float x, float y)=0;
00059 
00060  protected:
00061   //: Smart pointer to a vsol_spatial_object
00062   vsol_spatial_object_2d_sptr sptr_;
00063 };
00064 
00065 
00066 class bgui_vsol_soview2D_point : public bgui_vsol_soview2D
00067 {
00068  public:
00069   //: Constructor - creates a default vsol_point_2d view
00070   bgui_vsol_soview2D_point( vsol_point_2d_sptr const & pt);
00071 
00072   ~bgui_vsol_soview2D_point() {}
00073 
00074   //: Returns the type of this class ('bgui_vsol_soview2D_point').
00075   static vcl_string type_name_() { return "bgui_vsol_soview2D_point"; }
00076   vcl_string type_name() const { return type_name_(); }
00077 
00078   //: Render this 2D point on the display.
00079   void draw() const;
00080 
00081   // Returns vsol_point_2d_sptr of the vsol_spatial_object_2d_sptr
00082   vsol_point_2d_sptr sptr() const;
00083 
00084   //: Returns the distance squared from this 2D point to the given position.
00085   virtual float distance_squared(float x, float y) const;
00086 
00087   //: Returns the centroid of this point (the point location).
00088   void get_centroid(float* x, float* y) const;
00089 
00090   //: Translate this 2D point by the given x and y distances.
00091   void translate(float x, float y);
00092 };
00093 
00094 
00095 //: vsol_line_2d
00096 class bgui_vsol_soview2D_line_seg : public bgui_vsol_soview2D
00097 {
00098  public:
00099   //: Constructor - creates a view of a given vsol_line_2d
00100   bgui_vsol_soview2D_line_seg( vsol_line_2d_sptr const & line);
00101 
00102   //: Destructor - does nothing, smart pointers pass out of scope automatically
00103   ~bgui_vsol_soview2D_line_seg() {}
00104 
00105   //: Returns the type of this class ('bgui_vsol_soview2D_line_seg').
00106   static vcl_string type_name_() { return "bgui_vsol_soview2D_line_seg"; }
00107   vcl_string type_name() const { return type_name_(); }
00108 
00109   //: Render this curve on the display.
00110   virtual void draw() const;
00111 
00112   // Returns a smart pointer to the line
00113   // \note cast from a vsol_spatial_object_2d_sptr in the base class
00114   vsol_line_2d_sptr sptr() const;
00115 
00116   //: Returns the distance squared from this 2D curve to the given position.
00117   virtual float distance_squared(float x, float y) const;
00118 
00119   //: Returns the centroid of this 2D digital_curve.
00120   void get_centroid(float* x, float* y) const;
00121 
00122   //: Translate this 2D digital_curve by the given x and y distances.
00123   virtual void translate(float x, float y);
00124 };
00125 
00126 
00127 //: vsol_conic_2d
00128 // The current implementation is restricted to conics that are a real ellipse
00129 class bgui_vsol_soview2D_conic_seg : public bgui_vsol_soview2D
00130 {
00131  public:
00132   //: Constructor - creates a view of a given vsol_conic_2d
00133   bgui_vsol_soview2D_conic_seg( vsol_conic_2d_sptr const & conic);
00134 
00135   //: Destructor - does nothing, smart pointers pass out of scope automatically
00136   ~bgui_vsol_soview2D_conic_seg() {}
00137 
00138   //: Returns the type of this class ('bgui_vsol_soview2D_conic_seg').
00139   static vcl_string type_name_() { return "bgui_vsol_soview2D_conic_seg"; }
00140   vcl_string type_name() const { return type_name_(); }
00141 
00142   //: Render this 2D digital_curve on the display.
00143   virtual void draw() const;
00144 
00145   // Returns a smart pointer to the line
00146   // \note cast from a vsol_spatial_object_2d_sptr in the base class
00147   vsol_conic_2d_sptr sptr() const;
00148 
00149   //: Returns the distance squared from this curve to the given position.
00150   virtual float distance_squared(float x, float y) const;
00151 
00152   //: Returns the centroid of the conic
00153   void get_centroid(float* x, float* y) const;
00154 
00155   //: Translate this conic  by the given x and y distances.
00156   virtual void translate(float x, float y);
00157 
00158  protected:
00159   //: the center of the ellipse
00160   double xc_, yc_;
00161   //: the major_axis
00162   double major_axis_;
00163   //: the minor_axis
00164   double minor_axis_;
00165   //: the orientation angle
00166   double angle_;
00167   //: parametric angle at p0;
00168   double start_angle_;
00169   //: parametric angle at p1;
00170   double end_angle_;
00171 };
00172 
00173 
00174 //: vsol_polyline_2d
00175 class bgui_vsol_soview2D_polyline : public bgui_vsol_soview2D
00176 {
00177  public:
00178   //: Constructor - creates a view of a given vsol_polyline_2d
00179   bgui_vsol_soview2D_polyline(vsol_polyline_2d_sptr const& pline);
00180 
00181   //: Destructor
00182   ~bgui_vsol_soview2D_polyline() {}
00183 
00184   //: Returns the type of this class ('bgui_vsol_soview2D_polyline').
00185   static vcl_string type_name_() { return "bgui_vsol_soview2D_polyline"; }
00186   vcl_string type_name() const { return type_name_(); }
00187 
00188   //: Render this 2D digital_curve on the display.
00189   void draw() const;
00190 
00191   // Returns a smart pointer to the polyline
00192   // \note cast from a vsol_spatial_object_2d_sptr in the base class
00193   vsol_polyline_2d_sptr sptr() const;
00194 
00195   //: Returns the distance squared from this 2D digital_curve to the given position.
00196   virtual float distance_squared(float x, float y) const;
00197 
00198   //: Returns the centroid of this 2D digital_curve.
00199   void get_centroid(float* x, float* y) const;
00200 
00201   //: Translate this 2D digital_curve by the given x and y distances.
00202   void translate(float x, float y);
00203 };
00204 
00205 
00206 //: vsol_polygon_2d
00207 class bgui_vsol_soview2D_polygon : public bgui_vsol_soview2D
00208 {
00209  public:
00210   //: Constructor - creates a view of a vdgl_polygon
00211   bgui_vsol_soview2D_polygon(vsol_polygon_2d_sptr const& e);
00212 
00213   //: Destructor
00214   ~bgui_vsol_soview2D_polygon() {}
00215 
00216   //: Returns the type of this class ('bgui_vsol_soview2D_polygon').
00217   static vcl_string type_name_() { return "bgui_vsol_soview2D_polygon"; }
00218   vcl_string type_name() const { return type_name_(); }
00219 
00220   // Returns a smart pointer to the polygon
00221   // \note cast from a vsol_spatial_object_2d_sptr in the base class
00222   vsol_polygon_2d_sptr sptr() const;
00223 
00224   //: Render this 2D digital_curve on the display.
00225   void draw() const;
00226 
00227   //: Returns the distance squared from this 2D digital_curve to the given position.
00228   virtual float distance_squared(float x, float y) const;
00229 
00230   //: Returns the centroid of this 2D digital_curve.
00231   void get_centroid(float* x, float* y) const;
00232 
00233   //: Translate this 2D digital_curve by the given x and y distances.
00234   void translate(float x, float y);
00235 };
00236 
00237 //: vsol_polygon_2d
00238 class bgui_vsol_soview2D_polygon_set : public bgui_vsol_soview2D
00239 {
00240  public:
00241   //: Constructor - creates a view of a vdgl_polygon
00242   bgui_vsol_soview2D_polygon_set(vsol_poly_set_2d_sptr const& e);
00243 
00244   //: Destructor
00245   ~bgui_vsol_soview2D_polygon_set() {}
00246 
00247   //: Returns the type of this class ('bgui_vsol_soview2D_polygon').
00248   static vcl_string type_name_() { return "bgui_vsol_soview2D_polygon_set"; }
00249   vcl_string type_name() const { return type_name_(); }
00250 
00251   // Returns a smart pointer to the polygon set
00252   // \note cast from a vsol_spatial_object_2d_sptr in the base class
00253   vsol_poly_set_2d_sptr sptr() const;
00254 
00255   //: Render this 2D digital_curve on the display.
00256   void draw() const;
00257 
00258   //: Returns the distance squared from this 2D digital_curve to the given position.
00259   virtual float distance_squared(float x, float y) const;
00260 
00261   //: Returns the centroid of this 2D digital_curve.
00262   void get_centroid(float* x, float* y) const;
00263 
00264   //: Translate this 2D digital_curve by the given x and y distances.
00265   void translate(float x, float y);
00266 };
00267 
00268 //: vsol_digital_curve_2d
00269 class bgui_vsol_soview2D_digital_curve : public bgui_vsol_soview2D
00270 {
00271  public:
00272   //: Constructor - creates a view of a vsol_digital_curve_2d
00273   bgui_vsol_soview2D_digital_curve(vsol_digital_curve_2d_sptr const& dc, bool dotted = false);
00274 
00275   //: Destructor - does nothing, smart pointers pass out of scope automatically
00276   ~bgui_vsol_soview2D_digital_curve() {}
00277 
00278   //: Returns the type of this class ('bgui_vsol_soview2D_digital_curve').
00279   static vcl_string type_name_() { return "bgui_vsol_soview2D_digital_curve"; }
00280   vcl_string type_name() const { return type_name_(); }
00281 
00282   // Returns a smart pointer to the digital curve
00283   // \note cast from a vsol_spatial_object_2d_sptr in the base class
00284   vsol_digital_curve_2d_sptr sptr() const;
00285 
00286   //: Render this 2D digital_curve on the display.
00287   void draw() const;
00288 
00289   //: Returns the distance squared from this 2D digital_curve to the given position.
00290   virtual float distance_squared(float x, float y) const;
00291 
00292   //: Returns the centroid of this 2D digital_curve.
00293   void get_centroid(float* x, float* y) const;
00294 
00295   //: Translate this 2D digital_curve by the given x and y distances.
00296   void translate(float x, float y);
00297 
00298  protected:
00299   //: draw the sample points over the line segments
00300   bool draw_dotted_;
00301 };
00302 
00303 
00304 //: vdgl_digital_curve (chain of edgels)
00305 class bgui_vsol_soview2D_edgel_curve : public bgui_vsol_soview2D
00306 {
00307  public:
00308   //: Constructor - creates a view of a vdgl_digital_curve
00309   bgui_vsol_soview2D_edgel_curve(vdgl_digital_curve_sptr const& e, bool dotted = false);
00310 
00311   //: Destructor - does nothing, smart pointers pass out of scope automatically
00312   ~bgui_vsol_soview2D_edgel_curve() {}
00313 
00314   //: Returns the type of this class ('bgui_vsol_soview2D_edgel_curve').
00315   static vcl_string type_name_() { return "bgui_vsol_soview2D_edgel_curve"; }
00316   vcl_string type_name() const { return type_name_(); }
00317 
00318   // Returns a smart pointer to the digital edgel curve
00319   // \note cast from a vsol_spatial_object_2d_sptr in the base class
00320   vdgl_digital_curve_sptr sptr() const;
00321 
00322   //: Render this 2D digital_curve on the display.
00323   void draw() const;
00324 
00325   //: Returns the distance squared from this 2D digital_curve to the given position.
00326   virtual float distance_squared(float x, float y) const;
00327 
00328   //: Returns the centroid of this 2D digital_curve.
00329   void get_centroid(float* x, float* y) const;
00330 
00331   //: Translate this 2D digital_curve by the given x and y distances.
00332   void translate(float x, float y);
00333 
00334  protected:
00335   bool draw_dotted_;
00336 };
00337 
00338 
00339 #endif // bgui_vsol_soview2D_h_