geometry.h 5 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
/*
*
* This file is part of QMapControl,
* an open-source cross-platform map widget
*
* Copyright (C) 2007 - 2008 Kai Winter
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with QMapControl. If not, see <http://www.gnu.org/licenses/>.
*
* Contact e-mail: kaiwinter@gmx.de
* Program URL   : http://qmapcontrol.sourceforge.net/
*
*/

#ifndef GEOMETRY_H
#define GEOMETRY_H
#include <QObject>
#include <QPainter>
#include <QDebug>
#include "mapadapter.h"

namespace qmapcontrol
{
    class Point;
    //! Main class for objects that should be painted in maps
    /*!
     * Geometry is the root class of the hierarchy. Geometry is an abstract (non-instantiable) class.
     *
     * This class and the derived classes Point, Curve and LineString are leant on the Simple
     * Feature Specification of the Open Geospatial Consortium.
     * @see www.opengeospatial.com
     *
     *	@author Kai Winter <kaiwinter@gmx.de>
     */
    class Geometry : public QObject
    {
        friend class LineString;
        Q_OBJECT
    public:
        explicit Geometry(QString name = QString());
52

pixhawk's avatar
pixhawk committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
        virtual ~Geometry();

        QString GeometryType;

        //!
        /*! returns true if the given Geometry is equal to this Geometry
         *  not implemented yet!
         * @param geom The Geometry to be tested
         * @return true if the given Geometry is equal to this
         */
        bool Equals(Geometry* geom);

        //! returns a String representation of this Geometry
        /*!
         * not implemented yet!
         * @return a String representation of this Geometry
         */
        QString toString();

        //! returns the name of this Geometry
        /*!
         * @return the name of this Geometry
         */
        QString name() const;

78 79 80 81 82 83
        //! returns the index of this Geometry
        /*!
         * @return the index of this Geometry
         */
        int get_myIndex() const;

pixhawk's avatar
pixhawk committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
        //! returns the parent Geometry of this Geometry
        /*!
         * A LineString is a composition of many Points. This methods returns the parent (the LineString) of a Point
         * @return the parent Geometry of this Geometry
         */
        Geometry* parentGeometry() const;

        //! returns true if this Geometry is visible
        /*!
         * @return true if this Geometry is visible
         */
        bool isVisible() const;

        //! sets the name of the geometry
        /*!
         * @param name the new name of the geometry
         */
        void setName(QString name);

        //! returns the QPen which is used on drawing
        /*!
         * The pen is set depending on the Geometry. A CirclePoint for example takes one with the constructor.
         * @return the QPen which is used for drawing
         */
        QPen* pen() const;

        //! returns the BoundingBox
        /*!
         * The bounding box in world coordinates
         * @return the BoundingBox
         */
        virtual QRectF boundingBox()=0;
        virtual bool Touches(Point* geom, const MapAdapter* mapadapter)=0;
        virtual void draw(QPainter* painter, const MapAdapter* mapadapter, const QRect &viewport, const QPoint offset)=0;
        virtual bool hasPoints() const;
        virtual bool hasClickedPoints() const;
        virtual void setPen(QPen* pen);
        virtual QList<Geometry*> clickedPoints();
        virtual QList<Point*> points()=0;

    private:
        Geometry* myparentGeometry;
        Geometry(const Geometry& old);
        Geometry& operator=(const Geometry& rhs);

    protected:
        QPen* mypen;
        bool visible;
        QString myname;
133
        int myIndex;
pixhawk's avatar
pixhawk committed
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
        void setParentGeometry(Geometry* geom);

    signals:
        void updateRequest(Geometry* geom);
        void updateRequest(QRectF rect);
        //! This signal is emitted when a Geometry is clicked
        /*!
         * A Geometry is clickable, if the containing layer is clickable.
         * The objects emits a signal if it gets clicked
         * @param  geometry The clicked Geometry
         * @param  point -unused-
         */
        void geometryClicked(Geometry* geometry, QPoint point);

        //! A Geometry emits this signal, when its position gets changed
        /*!
         * @param geom the Geometry
         */
        void positionChanged(Geometry* geom);

    public slots:
        //! if visible is true, the layer is made visible
        /*!
         * @param  visible if the layer should be visible
         */
        virtual void setVisible(bool visible);
160 161


pixhawk's avatar
pixhawk committed
162 163 164
    };
}
#endif