File indexing completed on 2024-04-28 03:49:22

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
0004 // SPDX-FileCopyrightText: 2010 Thibaut Gridel <tgridel@free.fr>
0005 // SPDX-FileCopyrightText: 2011-2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
0006 //
0007 
0008 #ifndef MARBLE_GEOMETRYLAYER_H
0009 #define MARBLE_GEOMETRYLAYER_H
0010 
0011 #include <QObject>
0012 #include "LayerInterface.h"
0013 #include "GeoDataCoordinates.h"
0014 #include "GeoDataRelation.h"
0015 
0016 class QAbstractItemModel;
0017 class QModelIndex;
0018 class QPoint;
0019 
0020 namespace Marble
0021 {
0022 class GeoPainter;
0023 class GeoDataFeature;
0024 class GeoDataPlacemark;
0025 class GeoDataRelation;
0026 class StyleBuilder;
0027 class ViewportParams;
0028 
0029 class GeometryLayerPrivate;
0030 
0031 class GeometryLayer : public QObject, public LayerInterface
0032 {
0033     Q_OBJECT
0034 public:
0035     explicit GeometryLayer(const QAbstractItemModel *model, const StyleBuilder *styleBuilder);
0036     ~GeometryLayer() override;
0037 
0038     QStringList renderPosition() const override;
0039 
0040     bool render( GeoPainter *painter, ViewportParams *viewport,
0041                          const QString& renderPos = QLatin1String("NONE"),
0042                          GeoSceneLayer * layer = nullptr ) override;
0043 
0044     RenderState renderState() const override;
0045 
0046     QString runtimeTrace() const override;
0047 
0048     bool hasFeatureAt(const QPoint& curpos, const ViewportParams * viewport);
0049 
0050     QVector<const GeoDataFeature*> whichFeatureAt( const QPoint& curpos, const ViewportParams * viewport );
0051 
0052     void highlightRouteRelation(qint64 osmId, bool enabled);
0053 
0054     void setVisibleRelationTypes(GeoDataRelation::RelationTypes relationTypes);
0055 
0056     void setLevelTagDebugModeEnabled(bool enabled);
0057 
0058     bool levelTagDebugModeEnabled() const;
0059 
0060     void setDebugLevelTag(int level);
0061 
0062     int debugLevelTag() const;
0063 
0064 public Q_SLOTS:
0065     void addPlacemarks( const QModelIndex& index, int first, int last );
0066     void removePlacemarks( const QModelIndex& index, int first, int last );
0067     void resetCacheData();
0068     void setTileLevel(int tileLevel);
0069 
0070     /**
0071      * Finds all placemarks that contain the clicked point.
0072      *
0073      * The placemarks under the clicked position may
0074      * have their styleUrl set to a style map which
0075      * doesn't specify any highlight styleId. Such
0076      * placemarks will be fletered out in GeoGraphicsScene
0077      * and will not be highlighted.
0078      */
0079     void handleHighlight( qreal lon, qreal lat, GeoDataCoordinates::Unit unit );
0080 
0081 Q_SIGNALS:
0082     void repaintNeeded();
0083 
0084     /**
0085      * @p selectedPlacemarks may contain placemarks which don't have
0086      * their styleUrl set to id of the style map which specifies
0087      * a highlight styleId. Such placemarks will be filtered out
0088      * in GeoGraphicsScene which will query for placemark->styleUrl()
0089      * to decide whether the placemark should be highlighted ot not.
0090      */
0091     void highlightedPlacemarksChanged( const QVector<GeoDataPlacemark*>& clickedPlacemarks );
0092 
0093 private:
0094     GeometryLayerPrivate *d;
0095 };
0096 
0097 } // namespace Marble
0098 #endif // MARBLE_GEOMETRYLAYER_H