File indexing completed on 2025-01-05 03:59:24
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Torsten Rahn <tackat@kde.org> 0004 // 0005 0006 #ifndef MARBLE_GRATICULE_PLUGIN_H 0007 #define MARBLE_GRATICULE_PLUGIN_H 0008 0009 #include <QMap> 0010 #include <QHash> 0011 #include <QPen> 0012 #include <QIcon> 0013 #include <QColorDialog> 0014 0015 #include "DialogConfigurationInterface.h" 0016 #include "RenderPlugin.h" 0017 #include "GeoDataCoordinates.h" 0018 #include "GeoDataLatLonAltBox.h" 0019 0020 namespace Ui 0021 { 0022 class GraticuleConfigWidget; 0023 } 0024 0025 namespace Marble 0026 { 0027 0028 class GeoDataLatLonAltBox; 0029 0030 /** 0031 * @brief A plugin that creates a coordinate grid on top of the map. 0032 * Unlike in all other classes we are using degree by default in this class. 0033 * This choice was made due to the fact that all common coordinate grids focus fully 0034 * on the degree system. 0035 */ 0036 0037 class GraticulePlugin : public RenderPlugin, 0038 public DialogConfigurationInterface 0039 { 0040 Q_OBJECT 0041 Q_PLUGIN_METADATA(IID "org.kde.marble.GraticulePlugin") 0042 Q_INTERFACES( Marble::RenderPluginInterface ) 0043 Q_INTERFACES( Marble::DialogConfigurationInterface ) 0044 MARBLE_PLUGIN( GraticulePlugin ) 0045 0046 public: 0047 GraticulePlugin(); 0048 0049 explicit GraticulePlugin( const MarbleModel *marbleModel ); 0050 0051 QStringList backendTypes() const override; 0052 0053 QString renderPolicy() const override; 0054 0055 QStringList renderPosition() const override; 0056 0057 QString name() const override; 0058 0059 QString guiString() const override; 0060 0061 QString nameId() const override; 0062 0063 QString version() const override; 0064 0065 QString description() const override; 0066 0067 QString copyrightYears() const override; 0068 0069 QVector<PluginAuthor> pluginAuthors() const override; 0070 0071 QIcon icon () const override; 0072 0073 QDialog *configDialog() override; 0074 0075 void initialize () override; 0076 0077 bool isInitialized () const override; 0078 0079 bool render( GeoPainter *painter, ViewportParams *viewport, const QString& renderPos, GeoSceneLayer * layer = nullptr ) override; 0080 0081 qreal zValue() const override; 0082 0083 QHash<QString,QVariant> settings() const override; 0084 0085 void setSettings( const QHash<QString,QVariant> &settings ) override; 0086 0087 0088 0089 public Q_SLOTS: 0090 void readSettings(); 0091 void writeSettings(); 0092 0093 void gridGetColor(); 0094 void tropicsGetColor(); 0095 void equatorGetColor(); 0096 0097 0098 private: 0099 /** 0100 * @brief Renders the coordinate grid within the defined view bounding box. 0101 * @param painter the painter used to draw the grid 0102 * @param viewport the viewport 0103 */ 0104 void renderGrid( GeoPainter *painter, ViewportParams *viewport, 0105 const QPen& equatorCirclePen, 0106 const QPen& tropicsCirclePen, 0107 const QPen& gridCirclePen ); 0108 0109 /** 0110 * @brief Renders a latitude line within the defined view bounding box. 0111 * @param painter the painter used to draw the latitude line 0112 * @param latitude the latitude of the coordinate line measured in degree . 0113 * @param viewLatLonAltBox the latitude longitude bounding box that is covered by the view. 0114 */ 0115 static void renderLatitudeLine( GeoPainter *painter, qreal latitude, 0116 const GeoDataLatLonAltBox& viewLatLonAltBox = GeoDataLatLonAltBox(), 0117 const QString& lineLabel = QString(), 0118 LabelPositionFlags labelPositionFlags = LineCenter ); 0119 0120 /** 0121 * @brief Renders a longitude line within the defined view bounding box. 0122 * @param painter the painter used to draw the latitude line 0123 * @param longitude the longitude of the coordinate line measured in degree . 0124 * @param viewLatLonAltBox the latitude longitude bounding box that is covered by the view. 0125 * @param polarGap the area around the poles in which most longitude lines are not drawn 0126 * for reasons of aesthetics and clarity of the map. The polarGap avoids narrow 0127 * concurring lines around the poles which obstruct the view onto the surface. 0128 * The radius of the polarGap area is measured in degrees. 0129 * @param lineLabel draws a label using the font and color properties set for the painter. 0130 */ 0131 static void renderLongitudeLine( GeoPainter *painter, qreal longitude, 0132 const GeoDataLatLonAltBox& viewLatLonAltBox = GeoDataLatLonAltBox(), 0133 qreal northPolarGap = 0.0, qreal southPolarGap = 0.0, 0134 const QString& lineLabel = QString(), 0135 LabelPositionFlags labelPositionFlags = LineCenter ); 0136 0137 /** 0138 * @brief Renders the latitude lines that are visible within the defined view bounding box. 0139 * @param painter the painter used to draw the latitude lines 0140 * @param viewLatLonAltBox the latitude longitude bounding box that is covered by the view. 0141 * @param step the angular distance between the lines measured in degrees . 0142 */ 0143 void renderLatitudeLines( GeoPainter *painter, 0144 const GeoDataLatLonAltBox& viewLatLonAltBox, 0145 qreal step, qreal skipStep, 0146 LabelPositionFlags labelPositionFlags = LineCenter 0147 ); 0148 0149 /** 0150 * @brief Renders the longitude lines that are visible within the defined view bounding box. 0151 * @param painter the painter used to draw the latitude lines 0152 * @param viewLatLonAltBox the latitude longitude bounding box that is covered by the view. 0153 * @param step the angular distance between the lines measured in degrees . 0154 * @param northPolarGap the area around the north pole in which most longitude lines are not drawn 0155 * for reasons of aesthetics and clarity of the map. The polarGap avoids narrow 0156 * concurring lines around the poles which obstruct the view onto the surface. 0157 * The radius of the polarGap area is measured in degrees. 0158 * @param southPolarGap the area around the south pole in which most longitude lines are not drawn 0159 * for reasons of aesthetics and clarity of the map. The polarGap avoids narrow 0160 * concurring lines around the poles which obstruct the view onto the surface. 0161 * The radius of the polarGap area is measured in degrees. 0162 */ 0163 void renderLongitudeLines( GeoPainter *painter, 0164 const GeoDataLatLonAltBox& viewLatLonAltBox, 0165 qreal step, qreal skipStep, 0166 qreal northPolarGap = 0.0, qreal southPolarGap = 0.0, 0167 LabelPositionFlags labelPositionFlags = LineCenter 0168 ) const; 0169 0170 /** 0171 * @brief Renders UTM exceptions that are visible within the defined view bounding box. 0172 * @param painter the painter used to draw the latitude lines 0173 * @param viewLatLonAltBox the latitude longitude bounding box that is covered by the view. 0174 * @param step the angular distance between the lines measured in degrees . 0175 * @param northPolarGap the area around the north pole in which most longitude lines are not drawn 0176 * for reasons of aesthetics and clarity of the map. The polarGap avoids narrow 0177 * concurring lines around the poles which obstruct the view onto the surface. 0178 * The radius of the polarGap area is measured in degrees. 0179 * @param southPolarGap the area around the south pole in which most longitude lines are not drawn 0180 * for reasons of aesthetics and clarity of the map. The polarGap avoids narrow 0181 * concurring lines around the poles which obstruct the view onto the surface. 0182 * The radius of the polarGap area is measured in degrees. 0183 */ 0184 static void renderUtmExceptions( GeoPainter *painter, 0185 const GeoDataLatLonAltBox& viewLatLonAltBox, 0186 qreal step, 0187 qreal northPolarGap, qreal southPolarGap, 0188 const QString & label, 0189 LabelPositionFlags labelPositionFlags ); 0190 0191 /** 0192 * @brief Maps the number of coordinate lines per 360 deg against the globe radius on the screen. 0193 * @param notation Determines whether the graticule is according to the DMS or Decimal system. 0194 */ 0195 void initLineMaps( GeoDataCoordinates::Notation notation ); 0196 0197 GeoDataCoordinates::Notation m_currentNotation; 0198 0199 // Maps the zoom factor to the amount of lines per 360 deg 0200 QMap<qreal,qreal> m_boldLineMap; 0201 QMap<qreal,qreal> m_normalLineMap; 0202 0203 QPen m_equatorCirclePen; 0204 QPen m_tropicsCirclePen; 0205 QPen m_gridCirclePen; 0206 bool m_showPrimaryLabels; 0207 bool m_showSecondaryLabels; 0208 0209 bool m_isInitialized; 0210 0211 QIcon m_icon; 0212 0213 Ui::GraticuleConfigWidget *ui_configWidget; 0214 QDialog *m_configDialog; 0215 }; 0216 0217 } // namespace Marble 0218 0219 #endif // MARBLE_GRATICULEPLUGIN_H