File indexing completed on 2024-05-12 03:50:18

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2007 Murad Tagirov <tmurad@gmail.com>
0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
0005 //
0006 
0007 
0008 #ifndef MARBLE_GEODATASTYLE_H
0009 #define MARBLE_GEODATASTYLE_H
0010 
0011 
0012 #include "GeoDataStyleSelector.h"
0013 
0014 #include "geodata_export.h"
0015 
0016 #include <QSharedPointer>
0017 #include <QMetaType>
0018 
0019 class QFont;
0020 class QColor;
0021 
0022 namespace Marble
0023 {
0024 
0025 class GeoDataBalloonStyle;
0026 class GeoDataIconStyle;
0027 class GeoDataLabelStyle;
0028 class GeoDataLineStyle;
0029 class GeoDataListStyle;
0030 class GeoDataPolyStyle;
0031 class GeoDataStylePrivate;
0032 
0033 /**
0034  * @short an addressable style group
0035  *
0036  * A GeoDataStyle defines an addressable style group that can be
0037  * referenced by GeoDataStyleMaps and GeoDataFeatures. GeoDataStyles
0038  * affect how Geometry is presented in the 3D viewer (not yet
0039  * implemented) and how Features appear. Shared styles are collected
0040  * in a GeoDataDocument and must have an id defined for them so that
0041  * they can be referenced by the individual Features that use them.
0042  *
0043  * @see GeoDataIconStyle
0044  * @see GeoDataLabelStyle
0045  * @see GeoDataLineStyle
0046  * @see GeoDataPolyStyle
0047  * @see GeoDataBalloonStyle
0048  * @see GeoDataListStyle
0049  */
0050 class GEODATA_EXPORT GeoDataStyle : public GeoDataStyleSelector
0051 {
0052   public:
0053     using Ptr = QSharedPointer<GeoDataStyle>;
0054     using ConstPtr = QSharedPointer<const GeoDataStyle>;
0055 
0056     /// Construct a default style
0057     GeoDataStyle();
0058     GeoDataStyle( const GeoDataStyle& other );
0059     /**
0060      * @brief Construct a new style
0061      * @param  iconPath used to construct the icon style
0062      * @param  font   used to construct the label styles
0063      * @param  color  used to construct the label styles
0064      */
0065     GeoDataStyle( const QString& iconPath,
0066                   const QFont &font, const QColor &color  );
0067     ~GeoDataStyle() override;
0068 
0069     /// Provides type information for downcasting a GeoNode
0070     const char* nodeType() const override;
0071 
0072     /// set the icon style
0073     void setIconStyle( const GeoDataIconStyle& style );
0074     /// Return the icon style of this style
0075     GeoDataIconStyle& iconStyle();
0076     const GeoDataIconStyle& iconStyle() const;
0077     /// set the label style
0078     void setLabelStyle( const GeoDataLabelStyle& style );
0079     /// Return the label style of this style
0080     GeoDataLabelStyle& labelStyle();
0081     const GeoDataLabelStyle& labelStyle() const;
0082     /// set the line style
0083     void setLineStyle( const GeoDataLineStyle& style );
0084     /// Return the label style of this style
0085     GeoDataLineStyle& lineStyle();
0086     const GeoDataLineStyle& lineStyle() const;
0087     /// set the poly style
0088     void setPolyStyle( const GeoDataPolyStyle& style );
0089     /// Return the label style of this style
0090     GeoDataPolyStyle& polyStyle();
0091     const GeoDataPolyStyle& polyStyle() const;
0092     /// set the balloon style
0093     void setBalloonStyle( const GeoDataBalloonStyle& style );
0094     /// Return the balloon style of this style
0095     GeoDataBalloonStyle& balloonStyle();
0096     const GeoDataBalloonStyle& balloonStyle() const;
0097     /// set the list style
0098     void setListStyle( const GeoDataListStyle& style );
0099     /// Return the list style of this style
0100     GeoDataListStyle& listStyle();
0101     const GeoDataListStyle& listStyle() const;
0102 
0103     /**
0104     * @brief assignment operator
0105     * @param other the GeoDataStyle that gets duplicated
0106     */
0107     GeoDataStyle& operator=( const GeoDataStyle& other );
0108 
0109     bool operator==( const GeoDataStyle &other ) const;
0110     bool operator!=( const GeoDataStyle &other ) const;
0111 
0112     /**
0113      * @brief Serialize the style to a stream
0114      * @param  stream  the stream
0115      */
0116     void pack( QDataStream& stream ) const override;
0117     /**
0118      * @brief  Unserialize the style from a stream
0119      * @param  stream  the stream
0120      */
0121     void unpack( QDataStream& stream ) override;
0122 
0123   private:
0124     GeoDataStylePrivate * const d;
0125 };
0126 
0127 }
0128 
0129 Q_DECLARE_METATYPE( Marble::GeoDataStyle* )
0130 Q_DECLARE_METATYPE( const Marble::GeoDataStyle* )
0131 
0132 #endif