File indexing completed on 2025-01-05 03:59:19
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // 0006 0007 // 0008 // VisiblePlacemarks are those Placemarks which become visible on the map 0009 // 0010 0011 #ifndef MARBLE_VISIBLEPLACEMARK_H 0012 #define MARBLE_VISIBLEPLACEMARK_H 0013 0014 #include <QObject> 0015 #include <QPixmap> 0016 #include <QPoint> 0017 #include <QRectF> 0018 0019 #include <GeoDataStyle.h> 0020 #include <GeoDataCoordinates.h> 0021 0022 namespace Marble 0023 { 0024 0025 class GeoDataPlacemark; 0026 0027 static const qreal s_labelOutlineWidth = 2.5; 0028 0029 /** 0030 * @short A class which represents the visible place marks on a map. 0031 * 0032 * This class is used by PlacemarkLayout to pass the visible place marks 0033 * to the PlacemarkPainter. 0034 */ 0035 class VisiblePlacemark : public QObject 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 explicit VisiblePlacemark(const GeoDataPlacemark *placemark, const GeoDataCoordinates &coordinates, const GeoDataStyle::ConstPtr &style); 0041 0042 /** 0043 * Returns the index of the place mark model which 0044 * is associated with this visible place mark. 0045 */ 0046 const GeoDataPlacemark* placemark() const; 0047 0048 /** 0049 * Returns the pixmap of the place mark symbol. 0050 */ 0051 const QPixmap& symbolPixmap() const; 0052 0053 /** 0054 * Returns the id for the place mark symbol. 0055 */ 0056 const QString& symbolId() const; 0057 0058 /** 0059 * Returns the state of the place mark. 0060 */ 0061 bool selected() const; 0062 0063 /** 0064 * Sets the state of the place mark. 0065 */ 0066 void setSelected( bool selected ); 0067 0068 /** 0069 * Returns the position of the place mark symbol on the map. 0070 */ 0071 const QPointF& symbolPosition() const; 0072 0073 /** 0074 * Returns the top left corner of the place mark symbol's hot spot 0075 */ 0076 const QPointF hotSpot() const; 0077 0078 /** 0079 * Sets the @p position of the place mark symbol on the map. 0080 */ 0081 void setSymbolPosition(const QPointF &position ); 0082 0083 /** 0084 * Returns the pixmap of the place mark name label. 0085 */ 0086 const QPixmap& labelPixmap(); 0087 0088 /** 0089 * Returns the area covered by the place mark name label on the map. 0090 */ 0091 const QRectF& labelRect() const; 0092 0093 /** 0094 * Sets the @p area covered by the place mark name label on the map. 0095 */ 0096 void setLabelRect( const QRectF& area ); 0097 0098 enum LabelStyle { 0099 Normal = 0, 0100 Glow, 0101 Selected 0102 }; 0103 0104 void setStyle(const GeoDataStyle::ConstPtr &style); 0105 0106 GeoDataStyle::ConstPtr style() const; 0107 0108 QRectF symbolRect() const; 0109 0110 QRectF boundingBox() const; 0111 0112 const GeoDataCoordinates & coordinates() const; 0113 0114 Q_SIGNALS: 0115 void updateNeeded(); 0116 0117 private Q_SLOTS: 0118 void setSymbolPixmap(); 0119 0120 private: 0121 static void drawLabelText( QPainter &labelPainter, const QString &text, const QFont &labelFont, LabelStyle labelStyle, const QColor &color ); 0122 void drawLabelPixmap(); 0123 0124 const GeoDataPlacemark *m_placemark; 0125 0126 // View stuff 0127 QPointF m_symbolPosition; // position of the placemark's symbol 0128 bool m_selected; // state of the placemark 0129 QPixmap m_labelPixmap; // the text label (most often name) 0130 bool m_labelDirty; 0131 QRectF m_labelRect; // bounding box of label 0132 0133 GeoDataStyle::ConstPtr m_style; 0134 GeoDataCoordinates m_coordinates; 0135 0136 mutable QPixmap m_symbolPixmap; // cached value 0137 QString m_symbolId; 0138 }; 0139 0140 } 0141 0142 #endif