Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
305 | KeyOz | 1 | /* |
2 | * |
||
3 | * This file is part of QMapControl, |
||
4 | * an open-source cross-platform map widget |
||
5 | * |
||
6 | * Copyright (C) 2007 - 2008 Kai Winter |
||
7 | * |
||
8 | * This program is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU Lesser General Public License as published by |
||
10 | * the Free Software Foundation, either version 3 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU Lesser General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Lesser General Public License |
||
19 | * along with QMapControl. If not, see <http://www.gnu.org/licenses/>. |
||
20 | * |
||
21 | * Contact e-mail: kaiwinter@gmx.de |
||
22 | * Program URL : http://qmapcontrol.sourceforge.net/ |
||
23 | * |
||
24 | */ |
||
25 | |||
26 | #ifndef GEOMETRY_H |
||
27 | #define GEOMETRY_H |
||
28 | #include <QObject> |
||
29 | #include <QPainter> |
||
30 | #include <QDebug> |
||
31 | #include "mapadapter.h" |
||
32 | |||
33 | namespace qmapcontrol |
||
34 | { |
||
35 | class Point; |
||
36 | //! Main class for objects that should be painted in maps |
||
37 | /*! |
||
38 | * Geometry is the root class of the hierarchy. Geometry is an abstract (non-instantiable) class. |
||
39 | * |
||
40 | * This class and the derived classes Point, Curve and LineString are leant on the Simple |
||
41 | * Feature Specification of the Open Geospatial Consortium. |
||
42 | * @see www.opengeospatial.com |
||
43 | * |
||
44 | * @author Kai Winter <kaiwinter@gmx.de> |
||
45 | */ |
||
46 | class Geometry : public QObject |
||
47 | { |
||
48 | friend class LineString; |
||
49 | Q_OBJECT |
||
50 | public: |
||
51 | explicit Geometry(QString name = QString()); |
||
52 | virtual ~Geometry(); |
||
53 | |||
54 | QString GeometryType; |
||
55 | |||
56 | //! |
||
57 | /*! returns true if the given Geometry is equal to this Geometry |
||
58 | * not implemented yet! |
||
59 | * @param geom The Geometry to be tested |
||
60 | * @return true if the given Geometry is equal to this |
||
61 | */ |
||
62 | bool Equals(Geometry* geom); |
||
63 | |||
64 | //! returns a String representation of this Geometry |
||
65 | /*! |
||
66 | * not implemented yet! |
||
67 | * @return a String representation of this Geometry |
||
68 | */ |
||
69 | QString toString(); |
||
70 | |||
71 | //! returns the name of this Geometry |
||
72 | /*! |
||
73 | * @return the name of this Geometry |
||
74 | */ |
||
75 | QString name() const; |
||
76 | |||
77 | //! returns the parent Geometry of this Geometry |
||
78 | /*! |
||
79 | * A LineString is a composition of many Points. This methods returns the parent (the LineString) of a Point |
||
80 | * @return the parent Geometry of this Geometry |
||
81 | */ |
||
82 | Geometry* parentGeometry() const; |
||
83 | |||
84 | //! returns true if this Geometry is visible |
||
85 | /*! |
||
86 | * @return true if this Geometry is visible |
||
87 | */ |
||
88 | bool isVisible() const; |
||
89 | |||
90 | //! sets the name of the geometry |
||
91 | /*! |
||
92 | * @param name the new name of the geometry |
||
93 | */ |
||
94 | void setName(QString name); |
||
95 | |||
96 | //! returns the QPen which is used on drawing |
||
97 | /*! |
||
98 | * The pen is set depending on the Geometry. A CirclePoint for example takes one with the constructor. |
||
99 | * @return the QPen which is used for drawing |
||
100 | */ |
||
101 | QPen* pen() const; |
||
102 | |||
103 | //! returns the BoundingBox |
||
104 | /*! |
||
105 | * The bounding box in world coordinates |
||
106 | * @return the BoundingBox |
||
107 | */ |
||
108 | virtual QRectF boundingBox()=0; |
||
109 | virtual bool Touches(Point* geom, const MapAdapter* mapadapter)=0; |
||
110 | virtual void draw(QPainter* painter, const MapAdapter* mapadapter, const QRect &viewport, const QPoint offset)=0; |
||
111 | virtual bool hasPoints() const; |
||
112 | virtual bool hasClickedPoints() const; |
||
113 | virtual void setPen(QPen* pen); |
||
114 | virtual QList<Geometry*> clickedPoints(); |
||
115 | virtual QList<Point*> points()=0; |
||
116 | |||
117 | private: |
||
118 | Geometry* myparentGeometry; |
||
119 | Geometry(const Geometry& old); |
||
120 | Geometry& operator=(const Geometry& rhs); |
||
121 | |||
122 | protected: |
||
123 | QPen* mypen; |
||
124 | bool visible; |
||
125 | QString myname; |
||
126 | void setParentGeometry(Geometry* geom); |
||
127 | |||
128 | signals: |
||
129 | void updateRequest(Geometry* geom); |
||
130 | void updateRequest(QRectF rect); |
||
131 | //! This signal is emitted when a Geometry is clicked |
||
132 | /*! |
||
133 | * A Geometry is clickable, if the containing layer is clickable. |
||
134 | * The objects emits a signal if it gets clicked |
||
135 | * @param geometry The clicked Geometry |
||
136 | * @param point -unused- |
||
137 | */ |
||
138 | void geometryClicked(Geometry* geometry, QPoint point); |
||
139 | |||
140 | //! A Geometry emits this signal, when its position gets changed |
||
141 | /*! |
||
142 | * @param geom the Geometry |
||
143 | */ |
||
144 | void positionChanged(Geometry* geom); |
||
145 | |||
146 | public slots: |
||
147 | //! if visible is true, the layer is made visible |
||
148 | /*! |
||
149 | * @param visible if the layer should be visible |
||
150 | */ |
||
151 | virtual void setVisible(bool visible); |
||
152 | }; |
||
153 | } |
||
154 | #endif |