Subversion Repositories Projects

Rev

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 LINESTRING_H
27
#define LINESTRING_H
28
 
29
#include "curve.h"
30
 
31
namespace qmapcontrol
32
{
33
    //! A collection of Point objects to describe a line
34
    /*!
35
     * A LineString is a Curve with linear interpolation between Points. Each consecutive pair of Points defines a Line segment.
36
     *  @author Kai Winter <kaiwinter@gmx.de>
37
     */
38
    class LineString : public Curve
39
    {
40
        Q_OBJECT
41
 
42
    public:
43
        LineString();
44
        //! constructor
45
        /*!
46
         * The constructor of a LineString takes a list of Points to form a line.
47
         * @param points a list of points
48
         * @param name the name of the LineString
49
         * @param pen a QPen can be used to modify the look of the line.
50
         * @see http://doc.trolltech.com/4.3/qpen.html
51
         */
52
        LineString ( QList<Point*> const points, QString name = QString(), QPen* pen = 0 );
53
        virtual ~LineString();
54
 
55
        //! returns the points of the LineString
56
        /*!
57
         * @return  a list with the points of the LineString
58
         */
59
        QList<Point*>   points();
60
 
61
        //! adds a point at the end of the LineString
62
        /*!
63
         * @param point the point which should be added to the LineString
64
         */
65
        void addPoint ( Point* point );
66
 
67
        //! sets the given list as points of the LineString
68
        /*!
69
         * @param points the points which should be set for the LineString
70
         */
71
        void setPoints ( QList<Point*> points );
72
 
73
        //! returns the number of Points the LineString consists of
74
        /*!
75
         * @return the number of the LineString´s Points
76
         */
77
        int numberOfPoints() const;
78
 
79
        // virtual Geometry     Clone();
80
        virtual QRectF boundingBox();
81
        // virtual Point EndPoint();
82
        // virtual Point StartPoint();
83
        // virtual Point Value();
84
 
85
        //! returns true if the LineString has Childs
86
        /*!
87
         * This is equal to: numberOfPoints() > 0
88
         * @return true it the LineString has Childs (=Points)
89
         * @see clickedPoints()
90
         */
91
        virtual bool hasPoints() const;
92
 
93
        //! returns true if the LineString has clicked Points
94
        /*!
95
         * @return true if childs of a LineString were clicked
96
         * @see clickedPoints()
97
         */
98
        virtual bool hasClickedPoints() const;
99
 
100
        //! returns the clicked Points
101
        /*!
102
         * If a LineString was clicked it could be neccessary to figure out which of its points where clicked.
103
         * Do do so the methods hasPoints() and clickedPoints() can be used.
104
         * When a point is added to a LineString the Point becomes its child.
105
         * It is possible (depending on the zoomfactor) to click more than one Point of a LineString, so this method returns a list.
106
         * @return the clicked Points of the LineString
107
         */
108
        virtual QList<Geometry*> clickedPoints();
109
 
110
    protected:
111
        virtual bool Touches ( Geometry* geom, const MapAdapter* mapadapter );
112
        virtual bool Touches ( Point* geom, const MapAdapter* mapadapter );
113
        virtual void draw ( QPainter* painter, const MapAdapter* mapadapter, const QRect &screensize, const QPoint offset );
114
 
115
    private:
116
        QList<Point*>   vertices;
117
        QList<Geometry*>        touchedPoints;
118
    };
119
}
120
#endif