File indexing completed on 2024-04-21 03:49:59

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2016 Dennis Nienhüser <nienhueser@kde.org>
0004 //
0005 
0006 #ifndef MARBLE_STYLEBUILDER_H
0007 #define MARBLE_STYLEBUILDER_H
0008 
0009 #include "marble_export.h"
0010 
0011 #include <GeoDataPlacemark.h>
0012 #include <GeoDataStyle.h>
0013 #include <GeoDataRelation.h>
0014 
0015 #include <QHash>
0016 #include <QPair>
0017 
0018 class QFont;
0019 class QColor;
0020 
0021 namespace Marble {
0022 class OsmPlacemarkData;
0023 
0024 class MARBLE_EXPORT StyleParameters
0025 {
0026 public:
0027     explicit StyleParameters(const GeoDataPlacemark *placemark_ = nullptr, int tileLevel = 0);
0028 
0029     const GeoDataPlacemark *placemark;
0030     int tileLevel;
0031     const GeoDataRelation *relation;
0032 };
0033 
0034 enum StyleEffect {
0035     NoEffect,
0036     InvertedEffect,
0037     GrayscaleEffect,
0038     RedModeEffect
0039 };
0040 
0041 class MARBLE_EXPORT StyleBuilder
0042 {
0043 public:
0044     typedef QPair<QString, QString> OsmTag;
0045 
0046     StyleBuilder();
0047     ~StyleBuilder();
0048 
0049     /**
0050      * Return the label font of the placemark.
0051      */
0052     QFont defaultFont() const;
0053     void setDefaultFont( const QFont& font );
0054 
0055     QColor defaultLabelColor() const;
0056     void setDefaultLabelColor( const QColor& color );
0057 
0058     GeoDataStyle::ConstPtr createStyle(const StyleParameters &parameters) const;
0059 
0060     /**
0061      * @brief Returns the order in which the visual categories used in the theme shall be painted on the map.
0062      * @return order in which the visual categories shall be painted on the map
0063      */
0064     QStringList renderOrder() const;
0065 
0066     void reset();
0067 
0068     /**
0069      * @brief Returns the zoom level from which on the given visual category will be visible.
0070      * @param placemark the placemark for which the minimum zoom level shall be returned
0071      * @return zoom level from which on the given visual category will be visible
0072      */
0073     int minimumZoomLevel(const GeoDataPlacemark &placemark) const;
0074 
0075     static int minimumZoomLevel(const GeoDataPlacemark::GeoDataVisualCategory &visualCategory);
0076 
0077     static qint64 popularity(const GeoDataPlacemark* placemark);
0078 
0079     /**
0080      * @brief Returns the maximum zoom level in the theme.
0081      * @return maximum zoom level in the theme
0082      */
0083     int maximumZoomLevel() const;
0084 
0085     static QString visualCategoryName(GeoDataPlacemark::GeoDataVisualCategory category);
0086 
0087     static QColor effectColor(const QColor& color);
0088     static StyleEffect styleEffect();
0089     static void setStyleEffect(StyleEffect effect);
0090 
0091     /**
0092      * @brief Mapping between osm key=value pairs and visual categories
0093      */
0094     static QHash<OsmTag, GeoDataPlacemark::GeoDataVisualCategory> osmTagMapping();
0095 
0096     static QStringList shopValues();
0097     static QSet<OsmTag> buildingTags();
0098 
0099     static GeoDataPlacemark::GeoDataVisualCategory determineVisualCategory(const OsmPlacemarkData &osmData);
0100 
0101 private:
0102     Q_DISABLE_COPY(StyleBuilder)
0103 
0104     class Private;
0105     Private * const d;
0106 };
0107 
0108 }
0109 
0110 #endif