Mercator
Area.h
00001 // This file may be redistributed and modified only under the terms of
00002 // the GNU General Public License (See COPYING for details).
00003 // Copyright (C) 2005 Alistair Riddoch
00004 
00005 #ifndef MERCATOR_AREA_H
00006 #define MERCATOR_AREA_H
00007 
00008 #include <Mercator/Effector.h>
00009 
00010 #include <wfmath/axisbox.h>
00011 #include <wfmath/polygon.h>
00012 
00013 namespace Mercator
00014 {
00015 
00016 class Segment;
00017 class Shader;
00018 
00028 class Area : public Effector
00029 {
00030 public:
00035     Area(int layer, bool hole);
00036     
00041     void setLayer(int layer, bool hole);
00042 
00044     void setShape(const WFMath::Polygon<2>& p);
00045 
00046     void setShader(const Shader * shader) const;
00047 
00049     bool contains(double x, double y) const;
00050 
00052     int getLayer() const
00053     {
00054         return m_layer;
00055     }
00056     
00058     bool isHole() const
00059     {
00060         return m_hole;
00061     }
00062     
00064     const WFMath::Polygon<2> & shape() const
00065     {
00066         return m_shape;
00067     }
00068 
00069     const Shader * getShader() const
00070     {
00071         return m_shader;
00072     }
00073 
00074     int addToSegment(Segment &) const;
00075     void updateToSegment(Segment &) const;
00076     void removeFromSegment(Segment &) const;
00077     
00081     bool checkIntersects(const Segment& s) const;
00082 
00090     WFMath::Polygon<2> clipToSegment(const Segment& s) const;
00091 private:
00092 
00094     int m_layer;
00096     bool m_hole;
00098     WFMath::Polygon<2> m_shape;
00100     mutable const Shader * m_shader;
00101 };
00102 
00103 }
00104 
00105 #endif // of MERCATOR_AREA_H