Mercator
Area.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2005 Alistair Riddoch
4 
5 #ifndef MERCATOR_AREA_H
6 #define MERCATOR_AREA_H
7 
8 #include <Mercator/Effector.h>
9 
10 #include <wfmath/axisbox.h>
11 #include <wfmath/polygon.h>
12 
13 namespace Mercator
14 {
15 
16 class Segment;
17 class Shader;
18 
28 class Area : public Effector
29 {
30 public:
35  Area(int layer, bool hole);
36 
41  void setLayer(int layer, bool hole);
42 
44  void setShape(const WFMath::Polygon<2>& p);
45 
46  void setShader(const Shader * shader) const;
47 
49  bool contains(double x, double y) const;
50 
52  int getLayer() const
53  {
54  return m_layer;
55  }
56 
58  bool isHole() const
59  {
60  return m_hole;
61  }
62 
64  const WFMath::Polygon<2> & shape() const
65  {
66  return m_shape;
67  }
68 
69  const Shader * getShader() const
70  {
71  return m_shader;
72  }
73 
74  int addToSegment(Segment &) const;
75  void updateToSegment(Segment &) const;
76  void removeFromSegment(Segment &) const;
77 
81  bool checkIntersects(const Segment& s) const;
82 
90  WFMath::Polygon<2> clipToSegment(const Segment& s) const;
91 private:
92 
94  int m_layer;
96  bool m_hole;
98  WFMath::Polygon<2> m_shape;
100  mutable const Shader * m_shader;
101 };
102 
103 }
104 
105 #endif // of MERCATOR_AREA_H