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

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2007-2009 Torsten Rahn <tackat@kde.org>
0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
0005 //
0006 
0007 #ifndef MARBLE_GLOBAL_H
0008 #define MARBLE_GLOBAL_H
0009 
0010 
0011 #include <cmath>
0012 
0013 #include <QString>
0014 
0015 #include "marble_export.h"
0016 #include "marble_version.h"
0017 
0018 // #define QT_STRICT_ITERATORS
0019 
0020 /* M_PI is a #define that may or may not be handled in <cmath> */
0021 #ifndef M_PI
0022 #define M_PI 3.14159265358979323846264338327950288419717
0023 #endif
0024 
0025 namespace Marble
0026 {
0027 
0028 enum TessellationFlag {
0029     NoTessellation = 0x0,
0030     Tessellate = 0x1, 
0031     RespectLatitudeCircle = 0x2,
0032     FollowGround = 0x4,
0033     PreventNodeFiltering = 0x8
0034 };
0035 
0036 Q_DECLARE_FLAGS(TessellationFlags, TessellationFlag)
0037 
0038 /**
0039  * @brief This enum is used to choose the projection shown in the view.
0040  */
0041 enum Projection { 
0042     Spherical,          ///< Spherical projection ("Orthographic")
0043     Equirectangular,    ///< Flat projection ("plate carree")
0044     Mercator,           ///< Mercator projection
0045     Gnomonic,           ///< Gnomonic projection
0046     Stereographic,      ///< Stereographic projection
0047     LambertAzimuthal,   ///< Lambert Azimuthal Equal-Area projection
0048     AzimuthalEquidistant,   ///< Azimuthal Equidistant projection
0049     VerticalPerspective ///< Vertical perspective projection
0050     // NOTE: MarbleWidget::setProjection(int) relies on VerticalPerspective being the last
0051     // value above. Adjust that method if you do changes here
0052 };
0053 
0054 /**
0055  * @brief This enum is used to choose the unit chosen to measure angles.
0056  */
0057 enum AngleUnit {
0058     DMSDegree,          ///< Degrees in DMS notation
0059     DecimalDegree,      ///< Degrees in decimal notation
0060     UTM                 ///< UTM
0061 };
0062 
0063 /**
0064  * @brief This enum is used to choose context in which map quality gets used.
0065  */
0066 enum ViewContext {
0067     Still,              ///< still image
0068     Animation           ///< animated view (e.g. while rotating the globe)
0069 }; 
0070 
0071 /**
0072  * @brief This enum is used to choose the map quality shown in the view.
0073  */
0074 enum MapQuality {
0075     OutlineQuality,     ///< Only a wire representation is drawn
0076     LowQuality,         ///< Low resolution (e.g. interlaced)
0077     NormalQuality,      ///< Normal quality
0078     HighQuality,        ///< High quality (e.g. antialiasing for lines)
0079     PrintQuality        ///< Print quality
0080 }; 
0081 
0082 /**
0083  * @brief This enum is used to specify the proxy that is used.
0084  */
0085 enum ProxyType {
0086     HttpProxy,          ///< Uses an Http proxy
0087     Socks5Proxy         ///< Uses a Socks5Proxy
0088 };
0089 
0090 /**
0091  * @brief This enum is used to choose the localization of the labels.
0092  */
0093 enum LabelPositionFlag {
0094     NoLabel = 0x0,
0095     LineStart = 0x1,
0096     LineCenter = 0x2,
0097     LineEnd = 0x4,
0098     IgnoreXMargin = 0x8,
0099     IgnoreYMargin = 0x10,
0100     FollowLine = 0x20
0101 };
0102 
0103 Q_DECLARE_FLAGS(LabelPositionFlags, LabelPositionFlag)
0104 
0105 /**
0106  * @brief This enum is used to choose the localization of the labels.
0107  */
0108 enum LabelLocalization {
0109     CustomAndNative,    ///< Custom and native labels
0110     Custom,             ///< Shows the name in the user's language
0111     Native              ///< Display the name in the official language and  
0112                         ///  glyphs of the labeled place. 
0113 };
0114 
0115 /**
0116  * @brief This enum is used to choose how the globe behaves while dragging.
0117  */
0118 enum DragLocation {
0119     KeepAxisVertically, ///< Keep planet axis vertically
0120     FollowMousePointer  ///< Follow mouse pointer exactly
0121 };
0122 
0123 /**
0124  * @brief This enum is used to choose how the globe behaves while dragging.
0125  */
0126 enum OnStartup {
0127     ShowHomeLocation,   ///< Show home location on startup
0128     LastLocationVisited ///< Show last location visited on quit
0129 };
0130 
0131 enum AltitudeMode {
0132     ClampToGround,      ///< Altitude always sticks to ground level
0133     RelativeToGround,   ///< Altitude is always given relative to ground level
0134     Absolute,            ///< Altitude is given relative to the sealevel
0135     RelativeToSeaFloor,  ///< Altitude is given relative to the sea floor
0136     ClampToSeaFloor      ///< Altitude always sticks to sea floor
0137 };
0138 
0139 enum Pole {
0140     AnyPole,             ///< Any pole
0141     NorthPole,           ///< Only North Pole
0142     SouthPole            ///< Only South Pole
0143 };
0144 
0145 enum TileType {
0146     TextureTileType,        ///< Tiles that consist of bitmap data
0147     VectorTileType          ///< Tiles that consist of vector data
0148 };
0149 
0150 /**
0151  * @brief This enum is used to describe the type of download
0152  */
0153 enum DownloadUsage {
0154     DownloadBulk,       ///< Bulk download, for example "File/Download region"
0155     DownloadBrowse      ///< Browsing mode, normal operation of Marble, like a web browser
0156 };
0157 
0158 /** 
0159  * @brief Describes possible flight mode (interpolation between source
0160  *        and target camera positions)
0161  */
0162 enum FlyToMode {
0163     Automatic, ///< A sane value is chosen automatically depending on animation settings and the action
0164     Instant, ///< Change camera position immediately (no interpolation)
0165     Linear, ///< Linear interpolation of lon, lat and distance to ground
0166     Jump ///< Linear interpolation of lon and lat, distance increases towards the middle point, then decreases    
0167 };
0168 
0169 /**
0170  * @brief Search mode: Global (worldwide) versus area (local, regional) search
0171  */
0172 enum SearchMode {
0173     GlobalSearch, ///< Search a whole planet
0174     AreaSearch ///< Search a certain region of a planet (e.g. visible region)
0175 };
0176 
0177 /**
0178  * @brief
0179  */
0180 enum RenderStatus {
0181     Complete, ///< All data is there and up to date
0182     WaitingForUpdate, ///< Rendering is based on complete, but outdated data, data update was requested
0183     WaitingForData, ///< Rendering is based on no or partial data, more data was requested (e.g. pending network queries)
0184     Incomplete ///< Data is missing and some error occurred when trying to retrieve it (e.g. network failure)
0185 };
0186 
0187 const int defaultLevelZeroColumns = 2;
0188 const int defaultLevelZeroRows = 1;
0189 
0190 // Conversion Metric / Imperial System: km vs. miles
0191 const qreal MI2KM = 1.609344;
0192 const qreal KM2MI = 1.0 / MI2KM;
0193 
0194 // Conversion Nautical / Imperial System: nm vs. km
0195 const qreal NM2KM = 1.852;
0196 const qreal KM2NM = 1.0 / NM2KM;
0197 const qreal NM2FT = 6080; // nm feet
0198 
0199 // Conversion Metric / Imperial System: meter vs. feet
0200 const qreal M2FT = 3.2808;
0201 const qreal FT2M = 1.0 / M2FT;
0202 
0203 // Conversion Metric / Imperial System: meter vs inch
0204 const qreal M2IN = 39.3701;
0205 const qreal IN2M = 1.0 / M2IN;
0206 
0207 // Interconversion between Imperial System: feet vs inch
0208 const qreal FT2IN = 12.0;
0209 
0210 // Conversion Metric / Imperial System: meter vs yard
0211 const qreal M2YD = 1.09361;
0212 const qreal YD2M = 1.0 / M2YD;
0213 
0214 // Conversion meter vs millimeter
0215 const qreal M2MM = 1000.0;
0216 const qreal MM2M = 1.0 / M2MM;
0217 
0218 // Conversion meter vs centimeter
0219 const qreal M2CM = 100.0;
0220 const qreal CM2M = 1.0 / M2CM;
0221 
0222 // Conversion degree vs. radians
0223 const qreal DEG2RAD = M_PI / 180.0;
0224 const qreal RAD2DEG = 180.0 / M_PI;
0225 
0226 // Conversion meter vs kilometer
0227 const qreal KM2METER = 1000.0;
0228 const qreal METER2KM = 1.0 / KM2METER;
0229 
0230 //Conversion hour vs minute
0231 const qreal HOUR2MIN = 60.0;
0232 const qreal MIN2HOUR = 1.0 / HOUR2MIN;
0233 
0234 //Conversion (time) minute vs second
0235 const qreal MIN2SEC = 60.0;
0236 const qreal SEC2MIN = 1.0 / MIN2SEC;
0237 
0238 //Conversion hour vs second
0239 const qreal HOUR2SEC = 3600.0;
0240 const qreal SEC2HOUR = 1.0 / HOUR2SEC;
0241 
0242 const qreal TWOPI = 2 * M_PI;
0243 
0244 // Version definitions to use with an external application (as digiKam)
0245 
0246 // String for about dialog and http user agent
0247 const QString MARBLE_VERSION_STRING = QString::fromLatin1( MARBLE_LIB_VERSION_STRING );
0248 
0249 // API Version id:
0250 // up until the 21.04 release, this was supposed to be 0xMMmmpp (major,minor,patch), but in reality it was stuck at version 0.27.0
0251 // now it is  ((major<<16)|(minor<<8)|(patch))
0252 #define MARBLE_VERSION MARBLE_LIB_VERSION
0253 
0254 static const char NOT_AVAILABLE[] = QT_TRANSLATE_NOOP("Marble", "not available");
0255 
0256 const int tileDigits = 6;
0257 
0258 // Average earth radius in m
0259 // Deprecated: Please use model()->planetRadius() instead.
0260 const qreal EARTH_RADIUS = 6378137.0;
0261 
0262 // Maximum level of base tiles
0263 const int maxBaseTileLevel = 4;
0264 
0265 // Default size (width and height) of tiles
0266 const unsigned int c_defaultTileSize = 675;
0267 
0268 class MarbleGlobalPrivate;
0269 class MarbleLocale;
0270 
0271 class  MARBLE_EXPORT MarbleGlobal
0272 {
0273  public:
0274     static MarbleGlobal * getInstance();
0275     ~MarbleGlobal();
0276 
0277     MarbleLocale * locale() const;
0278     
0279     enum Profile {
0280         Default = 0x0,
0281         SmallScreen = 0x1,
0282         HighResolution = 0x2
0283     };
0284     
0285     Q_DECLARE_FLAGS( Profiles, Profile )
0286 
0287     Profiles profiles() const;
0288     void setProfiles( Profiles profiles );
0289 
0290     /** @deprecated Profiles are detected automatically now. This only returns profiles() anymore */
0291     MARBLE_DEPRECATED static Profiles detectProfiles();
0292     
0293  private:
0294     MarbleGlobal();
0295 
0296     Q_DISABLE_COPY( MarbleGlobal )
0297     MarbleGlobalPrivate  * const d;
0298 };
0299 
0300 }
0301 
0302 Q_DECLARE_OPERATORS_FOR_FLAGS( Marble::TessellationFlags )
0303 Q_DECLARE_OPERATORS_FOR_FLAGS( Marble::LabelPositionFlags )
0304 Q_DECLARE_OPERATORS_FOR_FLAGS( Marble::MarbleGlobal::Profiles )
0305 
0306 #endif