papyrus logo

region.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the papyrus library.                             *
00006  *                                                                         *
00007  *   papyrus is free software; you can redistribute it and/or modify       *
00008  *   it under the terms of the GNU Lesser General Public License           *
00009  *   version 3.0 as published by the Free Software Foundation.             *
00010  *                                                                         *
00011  *   papyrus is distributed in the hope that it will be useful,            *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Lesser General Public License version 3.0 for more details.       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with the papyrus library. If not, see                   *
00018  *   <http://www.gnu.org/licenses/>.                                       *
00019  ***************************************************************************/
00020 #ifndef PAPYRUSREGION_H
00021 #define PAPYRUSREGION_H
00022 
00023 #include <cairomm/cairomm.h>
00024 
00025 #include <papyrus/object.h>
00026 #include <papyrus/matrix.h>
00027 
00028 namespace Papyrus
00029 {
00030 
00038   class Region: public sigc::trackable
00039   {
00040     public:
00041 
00042       Region ( double x=NAN, double y=NAN, double w=NAN, double h=NAN );
00043 
00044       virtual ~Region();
00045 
00046       double x() const;
00047       double y() const;
00048       double width() const;
00049       double height() const;
00050 
00051       void xywh ( double& x, double& y, double& w, double& h ) const;
00052 
00053       double left() const;
00054       double right() const;
00055       double top() const;
00056       double bottom() const;
00057       void lrtb ( double& l, double& r, double& t, double& b ) const;
00058 
00059       void center ( double& x, double& y ) const;
00060 
00061 
00062       void set_x ( double x );
00063       void set_y ( double y );
00064       void set_width ( double w );
00065       void set_height ( double h );
00066       void set_xywh ( double x, double y, double w, double h );
00067 
00069       void invalidate();
00070 
00079       bool include ( const Region& other );
00080 
00086       bool include ( double x, double y );
00087 
00092       bool include_x ( double x );
00093 
00098       bool include_y ( double y );
00099 
00100       void left_bottom ( double& l, double& b ) const;
00101       void right_top ( double& r, double& t ) const;
00102 
00103       Region& operator= ( const Region& other );
00104 
00106       bool operator== ( const Region& other ) const;
00107 
00108       bool operator!= ( const Region& other ) const;
00109 
00111       bool operator< ( const Region& other ) const;
00112 
00113       bool operator<= ( const Region& other ) const;
00114 
00116       bool operator> ( const Region& other ) const;
00117 
00118       bool operator>= ( const Region& other ) const;
00119 
00120       operator bool() const;
00121 
00123       bool is_inside ( double x, double y ) const ;
00124 
00126       bool is_interior ( double x, double y ) const ;
00127 
00129       bool is_boundary ( double x, double y ) const ;
00130 
00132       bool overlaps( const Region& other ) const;
00133 
00134       void transform ( const Matrix& matrix );
00135 
00136       sigc::signal<void>& signal_changed();
00137 
00138     protected:
00139       double m_x, m_y, m_w, m_h;
00140       bool m_suppress_change_signal;
00141       sigc::signal<void> m_signal_changed;
00142 
00143       bool include_point(double x, double y);
00144 
00145       
00146   };
00147 
00148 }
00149 
00150 #endif

Generated on Wed Mar 18 12:34:04 2009 for papyrus by doxygen 1.5.7.1