You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
4.6 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #ifndef GEOMETRY_H
  26. #define GEOMETRY_H
  27. #include "qmapcontrol_global.h"
  28. #include <QtCore/QObject>
  29. #include <QtGui/QPainter>
  30. #include <QtCore/QDebug>
  31. #include "mapadapter.h"
  32. class mapPoint;
  33. //! Main class for objects that should be painted in maps
  34. /*!
  35. * Geometry is the root class of the hierarchy. Geometry is an abstract (non-instantiable) class.
  36. *
  37. * This class and the derived classes Point, Curve and LineString are leant on the Simple
  38. * Feature Specification of the Open Geospatial Consortium.
  39. * @see www.opengeospatial.com
  40. *
  41. * @author Kai Winter <kaiwinter@gmx.de>
  42. */
  43. class Geometry : public QObject {
  44. friend class LineString;
  45. //Q_OBJECT
  46. public:
  47. explicit Geometry(QString name = QString());
  48. virtual ~Geometry();
  49. QString GeometryType;
  50. //!
  51. /*! returns true if the given Geometry is equal to this Geometry
  52. * not implemented yet!
  53. * @param geom The Geometry to be tested
  54. * @return true if the given Geometry is equal to this
  55. */
  56. bool Equals(Geometry* geom);
  57. //! returns a String representation of this Geometry
  58. /*!
  59. * not implemented yet!
  60. * @return a String representation of this Geometry
  61. */
  62. QString toString();
  63. //! returns the name of this Geometry
  64. /*!
  65. * @return the name of this Geometry
  66. */
  67. QString name() const;
  68. //! returns the parent Geometry of this Geometry
  69. /*!
  70. * A LineString is a composition of many Points. This methods returns the parent (the LineString) of a Point
  71. * @return the parent Geometry of this Geometry
  72. */
  73. Geometry* parentGeometry() const;
  74. //! returns true if this Geometry is visible
  75. /*!
  76. * @return true if this Geometry is visible
  77. */
  78. bool isVisible() const;
  79. //! sets the name of the geometry
  80. /*!
  81. * @param name the new name of the geometry
  82. */
  83. void setName(QString name);
  84. //! returns the QPen which is used on drawing
  85. /*!
  86. * The pen is set depending on the Geometry. A CirclePoint for example takes one with the constructor.
  87. * @return the QPen which is used for drawing
  88. */
  89. QPen* pen() const;
  90. //! returns the BoundingBox
  91. /*!
  92. * The bounding box in world coordinates
  93. * @return the BoundingBox
  94. */
  95. virtual QRectF boundingBox()=0;
  96. virtual bool Touches(mapPoint* geom, const MapAdapter* mapadapter)=0;
  97. virtual void draw(QPainter* painter, const MapAdapter* mapadapter, const QRect &viewport, const QPoint offset)=0;
  98. virtual bool hasPoints() const;
  99. virtual bool hasClickedPoints() const;
  100. virtual void setPen(QPen* pen);
  101. virtual QList<Geometry*>& clickedPoints();
  102. virtual QList<mapPoint*> points()=0;
  103. private:
  104. Q_DISABLE_COPY( Geometry )
  105. Geometry* myparentGeometry;
  106. QList<Geometry*> touchedPoints;
  107. protected:
  108. QPen* mypen;
  109. bool visible;
  110. QString myname;
  111. void setParentGeometry(Geometry* geom);
  112. signals:
  113. void updateRequest(Geometry* geom);
  114. void updateRequest(QRectF rect);
  115. //! This signal is emitted when a Geometry is clicked
  116. /*!
  117. * A Geometry is clickable, if the containing layer is clickable.
  118. * The objects emits a signal if it gets clicked
  119. * @param geometry The clicked Geometry
  120. * @param point -unused-
  121. */
  122. void geometryClicked(Geometry* geometry, QPoint point);
  123. //! A Geometry emits this signal, when its position gets changed
  124. /*!
  125. * @param geom the Geometry
  126. */
  127. void positionChanged(Geometry* geom);
  128. public slots:
  129. //! if visible is true, the layer is made visible
  130. /*!
  131. * @param visible if the layer should be visible
  132. */
  133. virtual void setVisible(bool visible);
  134. };
  135. #endif