File indexing completed on 2025-01-05 03:59:02
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Andrew Manson <g.real.ate@gmail.com> 0004 // 0005 0006 #ifndef MARBLE_GEOLINESTRINGGRAPHICSITEM_H 0007 #define MARBLE_GEOLINESTRINGGRAPHICSITEM_H 0008 0009 #include "GeoGraphicsItem.h" 0010 #include "GeoDataCoordinates.h" 0011 #include "GeoDataLineString.h" 0012 #include "MarbleGlobal.h" 0013 #include "digikam_export.h" 0014 0015 #include <QRegion> 0016 0017 namespace Marble 0018 { 0019 0020 class GeoDataPlacemark; 0021 0022 class DIGIKAM_EXPORT GeoLineStringGraphicsItem : public GeoGraphicsItem 0023 { 0024 Q_DECLARE_TR_FUNCTIONS(GeoLineStringGraphicsItem) 0025 0026 public: 0027 explicit GeoLineStringGraphicsItem(const GeoDataPlacemark *placemark, const GeoDataLineString *lineString); 0028 ~GeoLineStringGraphicsItem() override; 0029 0030 void setLineString( const GeoDataLineString* lineString ); 0031 const GeoDataLineString* lineString() const; 0032 static GeoDataLineString merge(const QVector<const GeoDataLineString*> &lineStrings); 0033 void setMergedLineString(const GeoDataLineString &sharedLineString); 0034 0035 const GeoDataLatLonAltBox& latLonAltBox() const override; 0036 0037 void paint(GeoPainter* painter, const ViewportParams *viewport, const QString &layer, int tileZoomLevel) override; 0038 bool contains(const QPoint &screenPosition, const ViewportParams *viewport) const override; 0039 0040 static const GeoDataStyle *s_previousStyle; 0041 static bool s_paintInline; 0042 static bool s_paintOutline; 0043 0044 protected: 0045 void handleRelationUpdate(const QVector<const GeoDataRelation *> &relations) override; 0046 0047 private: 0048 void paintOutline(GeoPainter *painter, const ViewportParams *viewport) const; 0049 void paintInline(GeoPainter *painter, const ViewportParams *viewport); 0050 void paintLabel(GeoPainter *painter, const ViewportParams *viewport) const; 0051 0052 bool configurePainterForLine(GeoPainter* painter, const ViewportParams *viewport, const bool isOutline = false) const; 0053 bool configurePainterForLabel(GeoPainter* painter, const ViewportParams *viewport, LabelPositionFlags &labelPositionFlags) const; 0054 0055 static bool canMerge(const GeoDataCoordinates &a, const GeoDataCoordinates &b); 0056 0057 const GeoDataLineString *m_lineString; 0058 const GeoDataLineString *m_renderLineString; 0059 GeoDataLineString m_mergedLineString; 0060 QVector<QPolygonF*> m_cachedPolygons; 0061 bool m_renderLabel; 0062 qreal m_penWidth; 0063 mutable QRegion m_cachedRegion; 0064 QString m_name; 0065 }; 0066 0067 } 0068 0069 #endif