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.

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