region.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation version 2.1.                *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this library; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018  ***************************************************************************/
00019 #ifndef PAPYRUSREGION_H
00020 #define PAPYRUSREGION_H
00021 
00022 #include <papyrus/object.h>
00023 
00024 #include <cairomm/cairomm.h>
00025 
00026 namespace Papyrus {
00027 
00031 class Region: public Object {
00032 public:
00033 
00034     Region(double x=0.0, double y=0.0, double w=0.0, double h=0.0);
00035 
00036     ~Region();
00037 
00038     double x() const;
00039     double y() const;
00040     double width() const;
00041     double height() const;
00042 
00043     double xywh(double& x, double& y, double& w, double& h) const;
00044 
00045     double left() const;
00046     double right() const;
00047     double top() const;
00048     double bottom() const;
00049     void lrtb(double& l, double& r, double& t, double& b) const;
00050 
00051     void center(double& x, double& y) const;
00052 
00053 
00054     void set_x(double x);
00055     void set_y(double y);
00056     void set_width(double w);
00057     void set_height(double h);
00058     void set_xywh(double x, double y, double w, double h);
00059 
00060     bool include(const Region& other);
00061     bool include(double x, double y);
00062     bool include_x(double x);
00063     bool include_y(double y);
00064 
00065     void left_bottom(double& l, double& b) const;
00066     void right_top(double& r, double& t) const;
00067 
00068     Region& operator=(const Region& other);
00069 
00071     bool operator==(const Region& other) const;
00072 
00073     bool operator!=(const Region& other) const {
00074         return !(*this == other);
00075     }
00076 
00078     bool operator<(const Region& other) const;
00079 
00080     bool operator<=(const Region& other) const;
00081 
00083     bool operator>(const Region& other) const;
00084 
00085     bool operator>=(const Region& other) const;
00086 
00088     bool is_inside(double x, double y) const ;
00089 
00091     bool is_interior(double x, double y) const ;
00092 
00094     bool is_boundary(double x, double y) const ;
00095 
00096     void transform(const Cairo::Matrix& matrix);
00097 
00098 protected:
00099     double m_x, m_y, m_w, m_h;
00100 };
00101 
00102 }
00103 
00104 #endif

Generated on Sun Mar 11 10:01:28 2007 by  doxygen 1.5.1