diff --git a/src/lib/marble/HttpDownloadManager.h b/src/lib/marble/HttpDownloadManager.h index 007ef1173..48287df7c 100644 --- a/src/lib/marble/HttpDownloadManager.h +++ b/src/lib/marble/HttpDownloadManager.h @@ -1,118 +1,118 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2007 Torsten Rahn // Copyright 2007 Inge Wallin // Copyright 2009 Jens-Michael Hoffmann // // // The HttpDownloadManager manages http downloads. // #ifndef MARBLE_HTTPDOWNLOADMANAGER_H #define MARBLE_HTTPDOWNLOADMANAGER_H #include #include "MarbleGlobal.h" #include "marble_export.h" class QUrl; namespace Marble { class DownloadPolicy; class StoragePolicy; /** - * @Short This class manages scheduled downloads. - + * @short This class manages scheduled downloads. + * * The downloadmanager offers a maximum number of active jobs and a * limit for pending jobs. it also takes care that the job queue * won't be polluted by jobs that timed out already. * * @author Torsten Rahn */ class MARBLE_EXPORT HttpDownloadManager : public QObject { Q_OBJECT public: /** * Creates a new http download manager. * * @note HttpDownloadManager doesn't take ownership of @p policy. * * @param policy The storage policy for this manager. */ explicit HttpDownloadManager( StoragePolicy *policy ); /** * Destroys the http download manager. */ ~HttpDownloadManager() override; /** * Switches loading on/off, useful for offline mode. */ void setDownloadEnabled( const bool enable ); void addDownloadPolicy( const DownloadPolicy& ); static QByteArray userAgent(const QString &platform, const QString &plugin); public Q_SLOTS: /** * Adds a new job with a sourceUrl, destination file name and given id. */ void addJob( const QUrl& sourceUrl, const QString& destFilename, const QString &id, const DownloadUsage usage ); Q_SIGNALS: void downloadComplete( const QString&, const QString& ); /** * This signal is emitted if a file is downloaded and the data argument * contains the files content. The HttpDownloadManager takes care to save * it using the given storage policy. */ void downloadComplete( const QByteArray &data, const QString& initiatorId ); /** * Signal is emitted when a new job is added to the queue. */ void jobAdded(); /** * Signal is emitted when a job is removed from the queue. * The job might be completed or blacklisted. */ void jobRemoved(); /** * A job was queued, activated or removed (finished, failed) */ void progressChanged( int active, int queued ); private: Q_DISABLE_COPY( HttpDownloadManager ) class Private; Private * const d; Q_PRIVATE_SLOT( d, void finishJob( const QByteArray&, const QString&, const QString& id ) ) Q_PRIVATE_SLOT( d, void requeue() ) Q_PRIVATE_SLOT( d, void startRetryTimer() ) }; } #endif // MARBLE_HTTPDOWNLOADMANAGER_H diff --git a/src/lib/marble/LayerInterface.h b/src/lib/marble/LayerInterface.h index e69c2193e..014c06fc7 100644 --- a/src/lib/marble/LayerInterface.h +++ b/src/lib/marble/LayerInterface.h @@ -1,85 +1,85 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2008 Torsten Rahn // Copyright 2008 Inge Wallin // #ifndef MARBLE_LAYERINTERFACE_H #define MARBLE_LAYERINTERFACE_H #include "marble_export.h" #include class QStringList; class QString; namespace Marble { class RenderState; class GeoPainter; class GeoSceneLayer; class ViewportParams; class MARBLE_EXPORT LayerInterface { public: /** Destructor */ virtual ~LayerInterface(); /** * @brief Preferred level in the layer stack for the rendering * * Gives a preferred level in the existing layer stack where * the render() method of this plugin should get executed. - *. + * * Possible Values: * "NONE" * "STARS" * "BEHIND_TARGET" * "SURFACE" * "HOVERS_ABOVE_SURFACE" * "ATMOSPHERE" * "ORBIT" * "ALWAYS_ON_TOP" * "FLOAT_ITEM" * "USER_TOOLS" */ virtual QStringList renderPosition() const = 0; /** * @brief Renders the content provided by the layer on the viewport. * @param painter painter object allowing to paint on the map * @param viewport metadata, such as current projection, screen dimension, etc. * @param renderPos current render position * @param layer deprecated, always zero (NULL) * @return @c true Returns whether the rendering has been successful */ virtual bool render( GeoPainter *painter, ViewportParams *viewport, const QString &renderPos, GeoSceneLayer *layer ) = 0; /** * @brief Returns the z value of the layer (default: 0.0). If two layers are painted * at the same render position, the one with the higher z value is painted on top. * If both have the same z value, their paint order is undefined. */ virtual qreal zValue() const; virtual RenderState renderState() const; /** * @brief Returns a debug line for perfo/tracing issues */ virtual QString runtimeTrace() const; }; } // namespace Marble #endif diff --git a/src/lib/marble/MarbleMap.h b/src/lib/marble/MarbleMap.h index 8717390c2..e820a0ed3 100644 --- a/src/lib/marble/MarbleMap.h +++ b/src/lib/marble/MarbleMap.h @@ -1,809 +1,809 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2006-2008 Torsten Rahn // Copyright 2007 Inge Wallin // Copyright 2009 Jens-Michael Hoffmann // #ifndef MARBLE_MARBLEMAP_H #define MARBLE_MARBLEMAP_H /** @file * This file contains the headers for MarbleMap. * * @author Torsten Rahn * @author Inge Wallin */ #include "marble_export.h" #include "GeoDataCoordinates.h" // In geodata/data/ #include "GeoDataRelation.h" // Qt #include #include class QFont; class QString; namespace Marble { // MarbleMap class MarbleMapPrivate; // Marble class GeoDataLatLonAltBox; class GeoDataFeature; class MarbleModel; class ViewportParams; class GeoPainter; class LayerInterface; class RenderPlugin; class RenderState; class AbstractDataPlugin; class AbstractDataPluginItem; class AbstractFloatItem; class TextureLayer; class TileCoordsPyramid; class GeoSceneTextureTileDataset; class StyleBuilder; /** * @short A class that can paint a view of the earth. * * FIXME: Change this description when we are done. * * This class can paint a view of the earth or any other globe, * depending on which dataset is used. It can be used to show the * globe in a widget like MarbleWidget does, or on any other * QPaintDevice. * * The projection and other view parameters that control how MarbleMap * paints the map is given through the class ViewParams. If the * programmer wants to allow the user to control the map, he/she has * to provide a way for the user to interact with it. An example of * this can be seen in the class MarbleWidgetInputHandler, that lets * the user control a MarbleWidget that uses MarbleMap internally. * * The MarbleMap needs to be provided with a data model to * work. This model is contained in the MarbleModel class. The widget * can also construct its own model if none is given to the * constructor. This data model contains 3 separate datatypes: * tiles which provide the background, vectors which * provide things like country borders and coastlines and * placemarks which can show points of interest, such as * cities, mountain tops or the poles. * * @see MarbleWidget * @see MarbleModel */ class MARBLE_EXPORT MarbleMap : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.MarbleMap") public: friend class MarbleWidget; /** * @brief Construct a new MarbleMap. * * This constructor should be used when you will only use one * MarbleMap. The widget will create its own MarbleModel when * created. */ MarbleMap(); /** * @brief Construct a new MarbleMap. * @param model the data model for the widget. * * This constructor should be used when you plan to use more than * one MarbleMap for the same MarbleModel (not yet supported, * but will be soon). */ explicit MarbleMap( MarbleModel *model ); ~MarbleMap() override; /** * @brief Return the model that this view shows. */ MarbleModel *model() const; // Accessors to internal objects; ViewportParams *viewport(); const ViewportParams *viewport() const; /** * @brief Get the Projection used for the map * @return @c Spherical a Globe * @return @c Equirectangular a flat map * @return @c Mercator another flat map */ Projection projection() const; /** * @brief Get the ID of the current map theme * To ensure that a unique identifier is being used the theme does NOT * get represented by its name but the by relative location of the file * that specifies the theme: * * Example: * maptheme = "earth/bluemarble/bluemarble.dgml" */ QString mapThemeId() const; void setMapQualityForViewContext( MapQuality qualityForViewContext, ViewContext viewContext ); MapQuality mapQuality( ViewContext viewContext ) const; /** * @brief Return the current map quality. */ MapQuality mapQuality() const; void setViewContext( ViewContext viewContext ); ViewContext viewContext() const; void setSize( int width, int height ); void setSize( const QSize& size ); QSize size() const; int width() const; int height() const; /** * @brief Return the radius of the globe in pixels. */ int radius() const; int preferredRadiusCeil(int radius) const; int preferredRadiusFloor(int radius) const; int tileZoomLevel() const; /** * @brief return the minimum zoom value for the current map theme. */ int minimumZoom() const; /** * @brief return the minimum zoom value for the current map theme. */ int maximumZoom() const; bool discreteZoom() const; /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. * @param lon the lon coordinate of the requested pixel position * @param lat the lat coordinate of the requested pixel position * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( qreal lon, qreal lat, qreal& x, qreal& y ) const; /** * @brief Get the earth coordinates corresponding to a pixel in the map. * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the globe * @c false if the pixel (x, y) is outside the globe, i.e. in space. */ bool geoCoordinates( int x, int y, qreal& lon, qreal& lat, GeoDataCoordinates::Unit = GeoDataCoordinates::Degree ) const; /** * @brief Return the longitude of the center point. * @return The longitude of the center point in degree. */ qreal centerLongitude() const; /** * @brief Return the latitude of the center point. * @return The latitude of the center point in degree. */ qreal centerLatitude() const; qreal heading() const; /** * @since 0.26.0 */ bool hasFeatureAt(const QPoint&) const; QVector whichFeatureAt( const QPoint& ) const; /** * @brief Return the property value by name. * @return The property value (usually: visibility). */ bool propertyValue( const QString& name ) const; /** * @brief Return whether the overview map is visible. * @return The overview map visibility. */ bool showOverviewMap() const; /** * @brief Return whether the scale bar is visible. * @return The scale bar visibility. */ bool showScaleBar() const; /** * @brief Return whether the compass bar is visible. * @return The compass visibility. */ bool showCompass() const; /** * @brief Return whether the cloud cover is visible. * @return The cloud cover visibility. */ bool showClouds() const; /** * @brief Return whether the night shadow is visible. * @return visibility of night shadow */ bool showSunShading() const; /** * @brief Return whether the city lights are shown instead of the night shadow. * @return visibility of city lights */ bool showCityLights() const; /** * @brief Return whether the globe is locked to the sub solar point * @return if globe is locked to sub solar point */ bool isLockedToSubSolarPoint() const; /** * @brief Return whether the sun icon is shown in the sub solar point. * @return visibility of the sun icon in the sub solar point */ bool isSubSolarPointIconVisible() const; /** * @brief Return whether the atmospheric glow is visible. * @return The cloud cover visibility. */ bool showAtmosphere() const; /** * @brief Return whether the crosshairs are visible. * @return The crosshairs' visibility. */ bool showCrosshairs() const; /** * @brief Return whether the coordinate grid is visible. * @return The coordinate grid visibility. */ bool showGrid() const; /** * @brief Return whether the place marks are visible. * @return The place mark visibility. */ bool showPlaces() const; /** * @brief Return whether the city place marks are visible. * @return The city place mark visibility. */ bool showCities() const; /** * @brief Return whether the terrain place marks are visible. * @return The terrain place mark visibility. */ bool showTerrain() const; /** * @brief Return whether other places are visible. * @return The visibility of other places. */ bool showOtherPlaces() const; /** * @brief Return whether the relief is visible. * @return The relief visibility. */ bool showRelief() const; /** * @brief Return whether the ice layer is visible. * @return The ice layer visibility. */ bool showIceLayer() const; /** * @brief Return whether the borders are visible. * @return The border visibility. */ bool showBorders() const; /** * @brief Return whether the rivers are visible. * @return The rivers' visibility. */ bool showRivers() const; /** * @brief Return whether the lakes are visible. * @return The lakes' visibility. */ bool showLakes() const; /** * @brief Return whether the frame rate gets displayed. * @return the frame rates visibility */ bool showFrameRate() const; bool showBackground() const; GeoDataRelation::RelationTypes visibleRelationTypes() const; /** * @brief Returns the limit in kilobytes of the volatile (in RAM) tile cache. * @return the limit of volatile tile cache in kilobytes. */ quint64 volatileTileCacheLimit() const; /** * @brief Returns a list of all RenderPlugins in the model, this includes float items * @return the list of RenderPlugins */ QList renderPlugins() const; QList floatItems() const; /** * @brief Returns a list of all FloatItems in the model * @return the list of the floatItems */ AbstractFloatItem * floatItem( const QString &nameId ) const; /** * @brief Returns a list of all DataPlugins on the layer * @return the list of DataPlugins */ QList dataPlugins() const; /** * @brief Returns all widgets of dataPlugins on the position curpos */ QList whichItemAt( const QPoint& curpos ) const; AngleUnit defaultAngleUnit() const; QFont defaultFont() const; TextureLayer *textureLayer() const; /** * @brief Add a layer to be included in rendering. */ void addLayer( LayerInterface *layer ); /** * @brief Adds a texture sublayer * @return Returns a key that identifies the texture sublayer */ QString addTextureLayer(GeoSceneTextureTileDataset *texture); /** * @brief Removes a texture sublayer - * @param Key that was returned from corresponding addTextureLayer + * @param key a key that was returned from corresponding addTextureLayer */ void removeTextureLayer(const QString &key); /** * @brief Remove a layer from being included in rendering. */ void removeLayer( LayerInterface *layer ); RenderStatus renderStatus() const; RenderState renderState() const; /** * @since 0.26.0 */ const StyleBuilder* styleBuilder() const; public Q_SLOTS: /** * @brief Paint the map using a give painter. * @param painter The painter to use. * @param dirtyRect the rectangle that actually needs repainting. */ void paint( GeoPainter &painter, const QRect &dirtyRect ); /** * @brief Set the radius of the globe in pixels. * @param radius The new globe radius value in pixels. */ void setRadius( int radius ); void setHeading( qreal heading ); /** * @brief Rotate the view by the two angles phi and theta. * @param deltaLon an angle that specifies the change in terms of longitude * @param deltaLat an angle that specifies the change in terms of latitude * * This function rotates the view by two angles, * deltaLon ("theta") and deltaLat ("phi"). * If we start at (0, 0), the result will be the exact equivalent * of (lon, lat), otherwise the resulting angle will be the sum of * the previous position and the two offsets. */ void rotateBy(qreal deltaLon, qreal deltaLat); /** * @brief Center the view on a geographical point * @param lat an angle parallel to the latitude lines * +90(N) - -90(S) * @param lon an angle parallel to the longitude lines * +180(W) - -180(E) */ void centerOn( const qreal lon, const qreal lat ); /** * @brief Set the latitude for the center point * @param lat the new value for the latitude in degree */ void setCenterLatitude( qreal lat ); /** * @brief Set the longitude for the center point * @param lon the new value for the longitude in degree */ void setCenterLongitude( qreal lon ); /** * @brief Set the Projection used for the map * @param projection projection type (e.g. Spherical, Equirectangular, Mercator) */ void setProjection( Projection projection ); /** * @brief Set a new map theme * @param maptheme The ID of the new maptheme. To ensure that a unique * identifier is being used the theme does NOT get represented by its * name but the by relative location of the file that specifies the theme: * * Example: * maptheme = "earth/bluemarble/bluemarble.dgml" */ void setMapThemeId( const QString& maptheme ); /** * @brief Sets the value of a map theme property * @param value value of the property (usually: visibility) * * Later on we might add a "setPropertyType and a QVariant * if needed. */ void setPropertyValue( const QString& name, bool value ); /** * @brief Set whether the overview map overlay is visible * @param visible visibility of the overview map */ void setShowOverviewMap( bool visible ); /** * @brief Set whether the scale bar overlay is visible * @param visible visibility of the scale bar */ void setShowScaleBar( bool visible ); /** * @brief Set whether the compass overlay is visible * @param visible visibility of the compass */ void setShowCompass( bool visible ); /** * @brief Set whether the cloud cover is visible * @param visible visibility of the cloud cover */ void setShowClouds( bool visible ); /** * @brief Set whether the night shadow is visible. - * @param visibile visibility of shadow + * @param visible visibility of shadow */ void setShowSunShading( bool visible ); /** * @brief Set whether city lights instead of night shadow are visible. * @param visible visibility of city lights */ void setShowCityLights( bool visible ); /** * @brief Set the globe locked to the sub solar point * @param visible if globe is locked to the sub solar point */ void setLockToSubSolarPoint( bool visible ); /** * @brief Set whether the sun icon is shown in the sub solar point * @param visible if the sun icon is shown in the sub solar point */ void setSubSolarPointIconVisible( bool visible ); /** * @brief Set whether the is tile is visible * NOTE: This is part of the transitional debug API * and might be subject to changes until Marble 0.8 * @param visible visibility of the tile */ void setShowTileId( bool visible ); /** * @brief Set whether the atmospheric glow is visible * @param visible visibility of the atmospheric glow */ void setShowAtmosphere( bool visible ); /** * @brief Set whether the crosshairs are visible * @param visible visibility of the crosshairs */ void setShowCrosshairs( bool visible ); /** * @brief Set whether the coordinate grid overlay is visible * @param visible visibility of the coordinate grid */ void setShowGrid( bool visible ); /** * @brief Set whether the place mark overlay is visible * @param visible visibility of the place marks */ void setShowPlaces( bool visible ); /** * @brief Set whether the city place mark overlay is visible * @param visible visibility of the city place marks */ void setShowCities( bool visible ); /** * @brief Set whether the terrain place mark overlay is visible * @param visible visibility of the terrain place marks */ void setShowTerrain( bool visible ); /** * @brief Set whether the other places overlay is visible * @param visible visibility of other places */ void setShowOtherPlaces( bool visible ); /** * @brief Set whether the relief is visible * @param visible visibility of the relief */ void setShowRelief( bool visible ); /** * @brief Set whether the ice layer is visible * @param visible visibility of the ice layer */ void setShowIceLayer( bool visible ); /** * @brief Set whether the borders visible * @param visible visibility of the borders */ void setShowBorders( bool visible ); /** * @brief Set whether the rivers are visible * @param visible visibility of the rivers */ void setShowRivers( bool visible ); /** * @brief Set whether the lakes are visible * @param visible visibility of the lakes */ void setShowLakes( bool visible ); /** * @brief Set whether the frame rate gets shown * @param visible visibility of the frame rate */ void setShowFrameRate( bool visible ); void setShowRuntimeTrace( bool visible ); bool showRuntimeTrace() const; /** * @brief Set whether to enter the debug mode for * polygon node drawing * @param visible visibility of the node debug mode */ void setShowDebugPolygons( bool visible); bool showDebugPolygons() const; /** * @brief Set whether to enter the debug mode for * visualizing batch rendering * @param visible visibility of the batch rendering */ void setShowDebugBatchRender( bool visible); bool showDebugBatchRender() const; /** * @brief Set whether to enter the debug mode for * placemark drawing * @param visible visibility of the node debug mode */ void setShowDebugPlacemarks(bool visible); bool showDebugPlacemarks() const; /** * @brief Set whether to enter the debug mode for * level tags * @param visible visibility according to OSM level tags */ void setLevelTagDebugModeEnabled(bool visible); bool levelTagDebugModeEnabled() const; void setDebugLevelTag(int level); int debugLevelTag() const; void setShowBackground( bool visible ); void setVisibleRelationTypes(GeoDataRelation::RelationTypes relationTypes); /** * @brief used to notify about the position of the mouse click */ void notifyMouseClick( int x, int y ); void clearVolatileTileCache(); /** * @brief Set the limit of the volatile (in RAM) tile cache. - * @param bytes The limit in kilobytes. + * @param kiloBytes The limit in kilobytes. */ void setVolatileTileCacheLimit( quint64 kiloBytes ); void setDefaultAngleUnit( AngleUnit angleUnit ); void setDefaultFont( const QFont& font ); /** * @brief Reload the currently displayed map by reloading texture tiles * from the Internet. In the future this should be extended to all * kinds of data which is used in the map. */ void reload(); void downloadRegion( QVector const & ); void highlightRouteRelation(qint64 osmId, bool enabled); Q_SIGNALS: void tileLevelChanged( int level ); /** * @brief Signal that the theme has changed * @param theme Name of the new theme. */ void themeChanged( const QString& theme ); void projectionChanged( Projection ); void radiusChanged( int radius ); void mouseMoveGeoPosition( const QString& ); void mouseClickGeoPosition( qreal lon, qreal lat, GeoDataCoordinates::Unit ); void framesPerSecond( qreal fps ); /** * This signal is emitted when the repaint of the view was requested. * If available with the @p dirtyRegion which is the region the view will change in. * If dirtyRegion.isEmpty() returns true, the whole viewport has to be repainted. */ void repaintNeeded( const QRegion& dirtyRegion = QRegion() ); /** * This signal is emitted when the visible region of the map changes. This typically happens * when the user moves the map around or zooms. */ void visibleLatLonAltBoxChanged( const GeoDataLatLonAltBox& visibleLatLonAltBox ); /** * @brief This signal is emit when the settings of a plugin changed. */ void pluginSettingsChanged(); /** * @brief Signal that a render item has been initialized */ void renderPluginInitialized( RenderPlugin *renderPlugin ); /** * @brief Emitted when the layer rendering status has changed * @param status New render status */ void renderStatusChanged( RenderStatus status ); void renderStateChanged( const RenderState &state ); void highlightedPlacemarksChanged( qreal, qreal, GeoDataCoordinates::Unit ); void viewContextChanged(ViewContext viewContext); void visibleRelationTypesChanged(GeoDataRelation::RelationTypes relationTypes); protected: /** * @brief Enables custom drawing onto the MarbleMap straight after * @brief the globe and before all other layers have been rendered. * @param painter * * @deprecated implement LayerInterface and add it using @p addLayer() */ virtual void customPaint( GeoPainter *painter ); private: Q_PRIVATE_SLOT( d, void updateMapTheme() ) Q_PRIVATE_SLOT( d, void updateProperty( const QString &, bool ) ) Q_PRIVATE_SLOT( d, void setDocument(QString) ) Q_PRIVATE_SLOT( d, void updateTileLevel() ) Q_PRIVATE_SLOT(d, void addPlugins()) private: Q_DISABLE_COPY( MarbleMap ) MarbleMapPrivate * const d; friend class MarbleMapPrivate; class CustomPaintLayer; friend class CustomPaintLayer; }; } #endif diff --git a/src/lib/marble/MarbleModel.h b/src/lib/marble/MarbleModel.h index 81aac019f..8922eac0a 100644 --- a/src/lib/marble/MarbleModel.h +++ b/src/lib/marble/MarbleModel.h @@ -1,341 +1,341 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2005-2007 Torsten Rahn // Copyright 2007 Inge Wallin // Copyright 2010-2013 Bernhard Beschow // // // MarbleModel is the data store and index class for the MarbleWidget. // #ifndef MARBLE_MARBLEMODEL_H #define MARBLE_MARBLEMODEL_H /** @file * This file contains the headers for MarbleModel * * @author Torsten Rahn * @author Inge Wallin */ #include "marble_export.h" #include #include #include "MarbleGlobal.h" class QItemSelectionModel; class QAbstractItemModel; class QTextDocument; class QDateTime; namespace Marble { class GeoDataPlacemark; class GeoPainter; class MeasureTool; class PositionTracking; class HttpDownloadManager; class MarbleModelPrivate; class MarbleClock; class SunLocator; class TileCreator; class PluginManager; class GeoDataCoordinates; class GeoDataTreeModel; class GeoSceneDocument; class Planet; class RoutingManager; class BookmarkManager; class FileManager; class ElevationModel; /** * @short The data model (not based on QAbstractModel) for a MarbleWidget. * * This class provides a data storage and indexer that can be * displayed in a MarbleWidget. It contains 3 different datatypes: * tiles which provide the background, vectors which * provide things like country borders and coastlines and * placemarks which can show points of interest, such as * cities, mountain tops or the poles. * * The tiles provide the background of the image and can be for * instance height and depth fields, magnetic strength, topographic * data or anything else that is area based. * * The vectors provide things like country borders and * coastlines. They are stored in separate files and can be added or * removed at anytime. * * The placemarks contain points of interest, such as cities, * mountain tops or the poles. These are sorted by size (for cities) * and category (capitals, other important cities, less important * cities, etc) and are displayed with different color or shape like * square or round. * * @see MarbleWidget */ class MARBLE_EXPORT MarbleModel : public QObject { friend class MarbleModelPrivate; Q_OBJECT Q_PROPERTY( QString mapThemeId READ mapThemeId WRITE setMapThemeId NOTIFY themeChanged ) Q_PROPERTY( bool workOffline READ workOffline WRITE setWorkOffline NOTIFY workOfflineChanged ) public: /** * @brief Construct a new MarbleModel. * @param parent the parent widget */ explicit MarbleModel( QObject *parent = nullptr ); ~MarbleModel() override; /** * @brief Return the list of Placemarks as a QAbstractItemModel * * @return a list of all Placemarks in the MarbleModel. */ GeoDataTreeModel *treeModel(); const GeoDataTreeModel *treeModel() const; QAbstractItemModel *groundOverlayModel(); const QAbstractItemModel *groundOverlayModel() const; QAbstractItemModel *placemarkModel(); const QAbstractItemModel *placemarkModel() const; QItemSelectionModel *placemarkSelectionModel(); /** * @brief Return the name of the current map theme. * @return the identifier of the current MapTheme. * To ensure that a unique identifier is being used the theme does NOT * get represented by its name but the by relative location of the file * that specifies the theme: * * Example: * maptheme = "earth/bluemarble/bluemarble.dgml" */ QString mapThemeId() const; GeoSceneDocument *mapTheme(); const GeoSceneDocument *mapTheme() const; void setMapTheme( GeoSceneDocument * document ); /** * @brief Set a new map theme to use. * @param mapThemeId the identifier of the new map theme * * This function sets the map theme, i.e. combination of tile set * and color scheme to use. If the map theme is not previously * used, some basic tiles are created and a progress dialog is * shown. * * The ID of the new maptheme. To ensure that a unique * identifier is being used the theme does NOT get represented by its * name but the by relative location of the file that specifies the theme: * * Example: * maptheme = "earth/bluemarble/bluemarble.dgml" */ void setMapThemeId( const QString &mapThemeId ); /** * @brief get the home point * @param lon the longitude of the home point. * @param lat the latitude of the home point. * @param zoom the default zoom level of the home point. */ void home( qreal &lon, qreal &lat, int& zoom ) const; /** * @brief Set the home point * @param lon the longitude of the new home point. * @param lat the latitude of the new home point. * @param zoom the default zoom level for the new home point. */ void setHome( qreal lon, qreal lat, int zoom = 1050 ); /** * @brief Set the home point * @param homePoint the new home point. * @param zoom the default zoom level for the new home point. */ void setHome( const GeoDataCoordinates& homePoint, int zoom = 1050 ); /** * @brief Return the downloadmanager to load missing tiles * @return the HttpDownloadManager instance. */ HttpDownloadManager *downloadManager(); const HttpDownloadManager *downloadManager() const; /** * @brief Handle file loading into the treeModel * @param filename the file to load */ void addGeoDataFile( const QString& filename ); /** * @brief Handle raw data loading into the treeModel * @param data the raw data to load * @param key the name to remove this raw data later */ void addGeoDataString( const QString& data, const QString& key = QLatin1String("data") ); /** * @brief Remove the file or raw data from the treeModel * @param key either the file name or the key for raw data */ void removeGeoData( const QString& key ); FileManager *fileManager(); PositionTracking *positionTracking() const; qreal planetRadius() const; QString planetName() const; QString planetId() const; MarbleClock *clock(); const MarbleClock *clock() const; SunLocator *sunLocator(); const SunLocator *sunLocator() const; /** * @brief Returns the limit in kilobytes of the persistent (on hard disc) tile cache. * @return the limit of persistent tile cache in kilobytes. */ quint64 persistentTileCacheLimit() const; /** * @brief Returns the limit of the volatile (in RAM) tile cache. * @return the cache limit in kilobytes */ quint64 volatileTileCacheLimit() const; const PluginManager* pluginManager() const; PluginManager* pluginManager(); /** * @brief Returns the planet object for the current map. * @return the planet object for the current map */ const Planet *planet() const; RoutingManager* routingManager(); const RoutingManager* routingManager() const; void setClockDateTime( const QDateTime& datetime ); QDateTime clockDateTime() const; int clockSpeed() const; void setClockSpeed( int speed ); void setClockTimezone( int timeInSec ); int clockTimezone() const; /** * return instance of BookmarkManager */ BookmarkManager *bookmarkManager(); QTextDocument * legend(); /** * @brief Uses the given text document as the new content of the legend * Any previous legend content is overwritten. MarbleModel takes ownership * of the passed document. */ void setLegend( QTextDocument * document ); bool workOffline() const; void setWorkOffline( bool workOffline ); ElevationModel* elevationModel(); const ElevationModel* elevationModel() const; /** * Returns the placemark being tracked by this model or 0 if no * placemark is currently tracked. * @see setTrackedPlacemark(), trackedPlacemarkChanged() */ const GeoDataPlacemark *trackedPlacemark() const; public Q_SLOTS: void clearPersistentTileCache(); /** * @brief Set the limit of the persistent (on hard disc) tile cache. - * @param bytes The limit in kilobytes, 0 means no limit. + * @param kiloBytes The limit in kilobytes, 0 means no limit. */ void setPersistentTileCacheLimit( quint64 kiloBytes ); /** * @brief Change the placemark tracked by this model * @see trackedPlacemark(), trackedPlacemarkChanged() */ void setTrackedPlacemark( const GeoDataPlacemark *placemark ); void updateProperty( const QString &property, bool value ); Q_SIGNALS: /** * @brief Signal that the MarbleModel has started to create a new set of tiles. * @param */ void creatingTilesStart( TileCreator*, const QString& name, const QString& description ); /** * @brief Signal that the map theme has changed, and to which theme. * @param mapTheme the identifier of the new map theme. * @see mapTheme * @see setMapTheme */ void themeChanged( const QString &mapTheme ); void workOfflineChanged(); /** * @brief Emitted when the placemark tracked by this model has changed * @see setTrackedPlacemark(), trackedPlacemark() */ void trackedPlacemarkChanged( const GeoDataPlacemark *placemark ); /** @brief Emitted when the home location is changed * @see home(), setHome() */ void homeChanged( const GeoDataCoordinates &newHomePoint ); private: Q_DISABLE_COPY( MarbleModel ) Q_PRIVATE_SLOT( d, void assignFillColors( const QString &filePath ) ) void addDownloadPolicies( const GeoSceneDocument *mapTheme ); MarbleModelPrivate * const d; }; } #endif diff --git a/src/lib/marble/MarblePhysics.h b/src/lib/marble/MarblePhysics.h index 5fa1989dd..d1af5e4e6 100644 --- a/src/lib/marble/MarblePhysics.h +++ b/src/lib/marble/MarblePhysics.h @@ -1,64 +1,64 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2008 Torsten Rahn // #ifndef MARBLE_MARBLEPHYSICS_H #define MARBLE_MARBLEPHYSICS_H #include #include "MarbleGlobal.h" namespace Marble { class MarblePhysicsPrivate; class MarbleAbstractPresenter; class GeoDataLookAt; class MarblePhysics : public QObject { Q_OBJECT public: /** * @brief Constructor - * @param widget the MarbleWidget that is being animated + * @param presenter the MarbleWidget that is being animated */ explicit MarblePhysics( MarbleAbstractPresenter *presenter ); /** * @brief Destructor */ ~MarblePhysics() override; /** * @brief Initiate an animation to the target according to the given mode. * @param target camera position indicating the target of the animation * @param mode animation mode; @code Instant @endcode means no animation */ void flyTo( const GeoDataLookAt &target, FlyToMode mode = Instant ); private Q_SLOTS: void updateProgress(qreal progress); /** * @brief Switch to still mode when an animation is finished */ void startStillMode(); private: Q_DISABLE_COPY( MarblePhysics ) MarblePhysicsPrivate* d; }; } #endif diff --git a/src/lib/marble/MarbleWidget.h b/src/lib/marble/MarbleWidget.h index c0d995f2e..9ac84d086 100644 --- a/src/lib/marble/MarbleWidget.h +++ b/src/lib/marble/MarbleWidget.h @@ -1,1174 +1,1175 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2006-2008 Torsten Rahn // Copyright 2007 Inge Wallin // #ifndef MARBLE_MARBLEWIDGET_H #define MARBLE_MARBLEWIDGET_H /** @file * This file contains the headers for MarbleWidget. * * @author Torsten Rahn * @author Inge Wallin */ #include #include "GeoDataCoordinates.h" #include "MarbleGlobal.h" // types needed in all of marble. #include "marble_export.h" // Qt class QSettings; class QPixmap; namespace Marble { class AbstractDataPluginItem; class AbstractFloatItem; class GeoDataLatLonAltBox; class GeoDataLatLonBox; class GeoDataFeature; class GeoDataPlacemark; class GeoDataLookAt; class GeoPainter; class GeoSceneDocument; class LayerInterface; class MarbleModel; class MarbleWidgetPopupMenu; class MarbleWidgetInputHandler; class MarbleWidgetPrivate; class RenderPlugin; class RenderState; class RoutingLayer; class TextureLayer; class TileCoordsPyramid; class TileCreator; class ViewportParams; class PopupLayer; class StyleBuilder; /** * @short A widget class that displays a view of the earth. * * This widget displays a view of the earth or any other globe, * depending on which dataset is used. The user can navigate the * globe using either a control widget, e.g. the MarbleNavigator, or * the mouse. The mouse and keyboard control is done through a * MarbleWidgetInputHandler. Only some aspects of the widget can be * controlled by the mouse and/or keyboard. * * By clicking on the globe and moving the mouse, the position can be * changed. The user can also zoom by using the scroll wheel of the * mouse in the widget. The zoom value is not tied to any units, but * is an abstract value without any physical meaning. A value around * 1000 shows the full globe in a normal-sized window. Higher zoom * values give a more zoomed-in view. * * The MarbleWidget owns a data model to work. This model is contained * in the MarbleModel class, and it is painted by using a MarbleMap. * The widget takes care of creating the map and model. A MarbleModel * contains several datatypes, among them tiles which provide the * background, vectors which provide things like country * borders and coastlines and placemarks which can show points * of interest, such as cities, mountain tops or the poles. * * In addition to navigating with the mouse, you can also use it to * get information about items on the map. You can either click on a * placemark with the left mouse button or with the right mouse button * anywhere on the map. * * The left mouse button opens up a menu with all the placemarks * within a certain distance from the mouse pointer. When you choose * one item from the menu, Marble will open up a dialog window with * some information about the placemark and also try to connect to * Wikipedia to retrieve an article about it. If there is such an * article, you will get a mini-browser window with the article in a tab. * * @see MarbleNavigator * @see MarbleMap * @see MarbleModel */ class MARBLE_EXPORT MarbleWidget : public QWidget { Q_OBJECT #ifdef MARBLE_DBUS Q_CLASSINFO("D-Bus Interface", "org.kde.MarbleWidget") #endif Q_PROPERTY(int zoom READ zoom WRITE setZoom) Q_PROPERTY(QString mapThemeId READ mapThemeId WRITE setMapThemeId) Q_PROPERTY(int projection READ projection WRITE setProjection) Q_PROPERTY(qreal longitude READ centerLongitude WRITE setCenterLongitude) Q_PROPERTY(qreal latitude READ centerLatitude WRITE setCenterLatitude) Q_PROPERTY(bool showOverviewMap READ showOverviewMap WRITE setShowOverviewMap) Q_PROPERTY(bool showScaleBar READ showScaleBar WRITE setShowScaleBar) Q_PROPERTY(bool showCompass READ showCompass WRITE setShowCompass) Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid) Q_PROPERTY(bool showClouds READ showClouds WRITE setShowClouds) Q_PROPERTY(bool showSunShading READ showSunShading WRITE setShowSunShading) Q_PROPERTY(bool showCityLights READ showCityLights WRITE setShowCityLights) Q_PROPERTY(bool isLockedToSubSolarPoint READ isLockedToSubSolarPoint WRITE setLockToSubSolarPoint) Q_PROPERTY(bool isSubSolarPointIconVisible READ isSubSolarPointIconVisible WRITE setSubSolarPointIconVisible) Q_PROPERTY(bool showAtmosphere READ showAtmosphere WRITE setShowAtmosphere) Q_PROPERTY(bool showCrosshairs READ showCrosshairs WRITE setShowCrosshairs) Q_PROPERTY(bool showPlaces READ showPlaces WRITE setShowPlaces) Q_PROPERTY(bool showCities READ showCities WRITE setShowCities) Q_PROPERTY(bool showTerrain READ showTerrain WRITE setShowTerrain) Q_PROPERTY(bool showOtherPlaces READ showOtherPlaces WRITE setShowOtherPlaces) Q_PROPERTY(bool showRelief READ showRelief WRITE setShowRelief) Q_PROPERTY(bool showIceLayer READ showIceLayer WRITE setShowIceLayer) Q_PROPERTY(bool showBorders READ showBorders WRITE setShowBorders) Q_PROPERTY(bool showRivers READ showRivers WRITE setShowRivers) Q_PROPERTY(bool showLakes READ showLakes WRITE setShowLakes) Q_PROPERTY(ViewContext viewContext READ viewContext WRITE setViewContext NOTIFY viewContextChanged) Q_PROPERTY( RenderStatus renderStatus READ renderStatus NOTIFY renderStatusChanged ) Q_PROPERTY(quint64 volatileTileCacheLimit READ volatileTileCacheLimit WRITE setVolatileTileCacheLimit) public: /** * @brief Construct a new MarbleWidget. * @param parent the parent widget * * This constructor should be used when you will only use one * MarbleWidget. The widget will create its own MarbleModel when * created. */ explicit MarbleWidget( QWidget *parent = nullptr ); ~MarbleWidget() override; /// @name Access to helper objects //@{ /** * @brief Return the model that this view shows. */ MarbleModel *model(); const MarbleModel *model() const; ViewportParams *viewport(); const ViewportParams *viewport() const; MarbleWidgetPopupMenu *popupMenu(); /** * Returns the current input handler */ MarbleWidgetInputHandler *inputHandler() const; /** * @brief Set the input handler */ void setInputHandler( MarbleWidgetInputHandler *handler ); /** * @brief Returns a list of all RenderPlugins on the widget, this includes float items * @return the list of RenderPlugins */ QList renderPlugins() const; /** * @brief Returns a list of all FloatItems on the widget * @return the list of the floatItems */ QList floatItems() const; /** * @brief Returns the FloatItem with the given id * @return The pointer to the requested floatItem, * * If no item is found the null pointer is returned. */ AbstractFloatItem * floatItem( const QString &nameId ) const; /** * Reads the plugin settings from the passed QSettings. * You shouldn't use this in a KDE application as these use KConfig. Here you could * use MarblePart which is handling this automatically. * @param settings The QSettings object to be used. */ void readPluginSettings( QSettings& settings ); /** * Writes the plugin settings in the passed QSettings. * You shouldn't use this in a KDE application as these use KConfig. Here you could * use MarblePart which is handling this automatically. * @param settings The QSettings object to be used. */ void writePluginSettings( QSettings& settings ) const; /** * @brief Retrieve the view context (i.e. still or animated map) */ ViewContext viewContext() const; /** * @brief Get the GeoSceneDocument object of the current map theme */ GeoSceneDocument * mapTheme() const; /** * @brief Returns all widgets of dataPlugins on the position curpos */ QList whichItemAt( const QPoint& curpos ) const; /** * @brief Add a layer to be included in rendering. */ void addLayer( LayerInterface *layer ); /** * @brief Remove a layer from being included in rendering. */ void removeLayer( LayerInterface *layer ); RoutingLayer* routingLayer(); PopupLayer* popupLayer(); /** * @since 0.26.0 */ const StyleBuilder* styleBuilder() const; /** * @brief Get the Projection used for the map * @return @c Spherical a Globe * @return @c Equirectangular a flat map * @return @c Mercator another flat map */ Projection projection() const; // int projection() const; //@} /// @name Visible map area //@{ /** * @brief Get the ID of the current map theme * To ensure that a unique identifier is being used the theme does NOT * get represented by its name but the by relative location of the file * that specifies the theme: * * Example: * mapThemeId = "earth/bluemarble/bluemarble.dgml" */ QString mapThemeId() const; /** * @brief Return the projected region which describes the (shape of the) projected surface. */ QRegion mapRegion() const; /** * @brief Return the radius of the globe in pixels. */ int radius() const; /** * @brief Return the current zoom amount. */ int zoom() const; int tileZoomLevel() const; /** * @brief Return the current distance. */ qreal distance() const; /** * @brief Return the current distance string. */ QString distanceString() const; /** * @brief Return the minimum zoom value for the current map theme. */ int minimumZoom() const; /** * @brief Return the minimum zoom value for the current map theme. */ int maximumZoom() const; //@} /// @name Position management //@{ /** * @brief Get the screen coordinates corresponding to geographical coordinates in the widget. * @param lon the lon coordinate of the requested pixel position * @param lat the lat coordinate of the requested pixel position * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( qreal lon, qreal lat, qreal& x, qreal& y ) const; /** * @brief Get the earth coordinates corresponding to a pixel in the widget. * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the globe * @c false if the pixel (x, y) is outside the globe, i.e. in space. */ bool geoCoordinates( int x, int y, qreal& lon, qreal& lat, GeoDataCoordinates::Unit = GeoDataCoordinates::Degree ) const; /** * @brief Return the longitude of the center point. * @return The longitude of the center point in degree. */ qreal centerLongitude() const; /** * @brief Return the latitude of the center point. * @return The latitude of the center point in degree. */ qreal centerLatitude() const; qreal heading() const; /** * @brief Return how much the map will move if one of the move slots are called. * @return The move step. */ qreal moveStep() const; /** * @brief Return the lookAt */ GeoDataLookAt lookAt() const; /** * @return The current point of focus, e.g. the point that is not moved * when changing the zoom level. If not set, it defaults to the * center point. * @see centerLongitude centerLatitude setFocusPoint resetFocusPoint */ GeoDataCoordinates focusPoint() const; /** * @brief Change the point of focus, overridding any previously set focus point. * @param focusPoint New focus point * @see focusPoint resetFocusPoint */ void setFocusPoint( const GeoDataCoordinates &focusPoint ); /** * @brief Invalidate any focus point set with @ref setFocusPoint. * @see focusPoint setFocusPoint */ void resetFocusPoint(); /** * @brief Return the globe radius (pixel) for the given distance (km) */ qreal radiusFromDistance( qreal distance ) const; /** * @brief Return the distance (km) at the given globe radius (pixel) */ qreal distanceFromRadius( qreal radius ) const; /** * Returns the zoom value (no unit) corresponding to the given camera distance (km) */ qreal zoomFromDistance( qreal distance ) const; /** * Returns the distance (km) corresponding to the given zoom value */ qreal distanceFromZoom( qreal zoom ) const; //@} /// @name Placemark management //@{ QVector whichFeatureAt( const QPoint& ) const; //@} /// @name Float items and map appearance //@{ /** * @brief Return whether the overview map is visible. * @return The overview map visibility. */ bool showOverviewMap() const; /** * @brief Return whether the scale bar is visible. * @return The scale bar visibility. */ bool showScaleBar() const; /** * @brief Return whether the compass bar is visible. * @return The compass visibility. */ bool showCompass() const; /** * @brief Return whether the cloud cover is visible. * @return The cloud cover visibility. */ bool showClouds() const; /** * @brief Return whether the night shadow is visible. * @return visibility of night shadow */ bool showSunShading() const; /** * @brief Return whether the city lights are shown instead of the night shadow. * @return visibility of city lights */ bool showCityLights() const; /** * @brief Return whether the globe is locked to the sub solar point * @return if globe is locked to sub solar point */ bool isLockedToSubSolarPoint() const; /** * @brief Return whether the sun icon is shown in the sub solar point. * @return visibility of the sun icon in the sub solar point */ bool isSubSolarPointIconVisible() const; /** * @brief Return whether the atmospheric glow is visible. * @return The cloud cover visibility. */ bool showAtmosphere() const; /** * @brief Return whether the crosshairs are visible. * @return The crosshairs' visibility. */ bool showCrosshairs() const; /** * @brief Return whether the coordinate grid is visible. * @return The coordinate grid visibility. */ bool showGrid() const; /** * @brief Return whether the place marks are visible. * @return The place mark visibility. */ bool showPlaces() const; /** * @brief Return whether the city place marks are visible. * @return The city place mark visibility. */ bool showCities() const; /** * @brief Return whether the terrain place marks are visible. * @return The terrain place mark visibility. */ bool showTerrain() const; /** * @brief Return whether other places are visible. * @return The visibility of other places. */ bool showOtherPlaces() const; /** * @brief Return whether the relief is visible. * @return The relief visibility. */ bool showRelief() const; /** * @brief Return whether the ice layer is visible. * @return The ice layer visibility. */ bool showIceLayer() const; /** * @brief Return whether the borders are visible. * @return The border visibility. */ bool showBorders() const; /** * @brief Return whether the rivers are visible. * @return The rivers' visibility. */ bool showRivers() const; /** * @brief Return whether the lakes are visible. * @return The lakes' visibility. */ bool showLakes() const; /** * @brief Return whether the frame rate gets displayed. * @return the frame rates visibility */ bool showFrameRate() const; bool showBackground() const; /** * @brief Retrieve the map quality depending on the view context */ MapQuality mapQuality( ViewContext = Still ) const; /** * @brief Retrieve whether travels to a point should get animated */ bool animationsEnabled() const; AngleUnit defaultAngleUnit() const; void setDefaultAngleUnit( AngleUnit angleUnit ); QFont defaultFont() const; void setDefaultFont( const QFont& font ); //@} /// @name Tile management //@{ /** * @brief Returns the limit in kilobytes of the volatile (in RAM) tile cache. * @return the limit of volatile tile cache */ quint64 volatileTileCacheLimit() const; //@} /// @name Miscellaneous //@{ /** * @brief Return a QPixmap with the current contents of the widget. */ QPixmap mapScreenShot(); //@} /// @todo Enable this instead of the zoomView slot below for proper deprecation warnings /// around Marble 1.8 // @deprecated Please use setZoom //MARBLE_DEPRECATED( void zoomView( int zoom, FlyToMode mode = Instant ) ); /** * Summarized render status of the current map view * @see renderState */ RenderStatus renderStatus() const; /** * Detailed render status of the current map view */ RenderState renderState() const; /** * Toggle whether regions are highlighted when user selects them */ void setHighlightEnabled( bool enabled ); public Q_SLOTS: /// @name Position management slots //@{ /** * @brief Set the radius of the globe in pixels. * @param radius The new globe radius value in pixels. */ void setRadius( int radius ); /** * @brief Zoom the view to a certain zoomlevel * @param zoom the new zoom level. * * The zoom level is an abstract value without physical * interpretation. A zoom value around 1000 lets the viewer see * all of the earth in the default window. */ void setZoom( int zoom, FlyToMode mode = Instant ); /** * @deprecated To be removed soon. Please use setZoom instead. Same parameters. */ void zoomView( int zoom, FlyToMode mode = Instant ); /** * @brief Zoom the view by a certain step * @param zoomStep the difference between the old zoom and the new */ void zoomViewBy( int zoomStep, FlyToMode mode = Instant ); /** * @brief Zoom in by the amount zoomStep. */ void zoomIn( FlyToMode mode = Automatic ); /** * @brief Zoom out by the amount zoomStep. */ void zoomOut( FlyToMode mode = Automatic ); /** * @brief Set the distance of the observer to the globe in km. * @param distance The new distance in km. */ void setDistance( qreal distance ); /** * @brief Rotate the view by the two angles phi and theta. * @param deltaLon an angle that specifies the change in terms of longitude * @param deltaLat an angle that specifies the change in terms of latitude * * This function rotates the view by two angles, * deltaLon ("theta") and deltaLat ("phi"). * If we start at (0, 0), the result will be the exact equivalent * of (lon, lat), otherwise the resulting angle will be the sum of * the previous position and the two offsets. */ void rotateBy( const qreal deltaLon, const qreal deltaLat, FlyToMode mode = Instant ); /** * @brief Center the view on a geographical point * @param lat an angle in degrees parallel to the latitude lines * +90(N) - -90(S) * @param lon an angle in degrees parallel to the longitude lines * +180(W) - -180(E) */ void centerOn( const qreal lon, const qreal lat, bool animated = false ); /** * @brief Center the view on a point * This method centers the Marble map on the point described by the latitude * and longitude in the GeoDataCoordinate parameter @c point. It also zooms * the map to be at the elevation described by the altitude. If this is * not the desired functionality or you do not have an accurate altitude * then use @see centerOn(qreal, qreal, bool) * @param point the point in 3 dimensions above the globe to move the view * to. It will always be looking vertically down. */ void centerOn( const GeoDataCoordinates &point, bool animated = false ); /** * @brief Center the view on a bounding box so that it completely fills the viewport * This method not only centers on the center of the GeoDataLatLon box but it also * adjusts the zoom of the marble widget so that the LatLon box provided fills * the viewport. * @param box The GeoDataLatLonBox to zoom and move the MarbleWidget to. */ void centerOn( const GeoDataLatLonBox& box, bool animated = false ); /** * @brief Center the view on a placemark according to the following logic: * - if the placemark has a lookAt, zoom and center on that lookAt * - otherwise use the placemark geometry's latLonAltBox - * @param box The GeoDataPlacemark to zoom and move the MarbleWidget to. + * @param placemark The GeoDataPlacemark to zoom and move the MarbleWidget to. + * @param animated Whether the centering is animated. */ void centerOn( const GeoDataPlacemark& placemark, bool animated = false ); /** * @brief Set the latitude for the center point * @param lat the new value for the latitude in degree. * @param mode the FlyToMode that will be used. */ void setCenterLatitude( qreal lat, FlyToMode mode = Instant ); /** * @brief Set the longitude for the center point * @param lon the new value for the longitude in degree. * @param mode the FlyToMode that will be used. */ void setCenterLongitude( qreal lon, FlyToMode mode = Instant ); void setHeading( qreal heading ); /** * @brief Move left by the moveStep. */ void moveLeft( FlyToMode mode = Automatic ); /** * @brief Move right by the moveStep. */ void moveRight( FlyToMode mode = Automatic ); /** * @brief Move up by the moveStep. */ void moveUp( FlyToMode mode = Automatic ); /** * @brief Move down by the moveStep. */ void moveDown( FlyToMode mode = Automatic ); /** * @brief Center the view on the default start point with the default zoom. */ void goHome( FlyToMode mode = Automatic ); /** * @brief Change the camera position to the given position. * @param lookAt New camera position. Changing the camera position means * that both the current center position as well as the zoom value may change * @param mode Interpolation type for intermediate camera positions. Automatic * (default) chooses a suitable interpolation among Instant, Lenar and Jump. * Instant will directly set the new zoom and position values, while * Linear results in a linear interpolation of intermediate center coordinates * along the sphere and a linear interpolation of changes in the camera distance * to the ground. Finally, Jump will behave the same as Linear with regard to * the center position interpolation, but use a parabolic height increase * towards the middle point of the intermediate positions. This appears * like a jump of the camera. */ void flyTo( const GeoDataLookAt &lookAt, FlyToMode mode = Automatic ); //@} /// @name Float items and map appearance slots //@{ /** * @brief Set the Projection used for the map * @param projection projection type (e.g. Spherical, Equirectangular, Mercator) */ void setProjection( int projection ); void setProjection( Projection projection ); /** * @brief Set a new map theme * @param maptheme The ID of the new maptheme. To ensure that a unique * identifier is being used the theme does NOT get represented by its * name but the by relative location of the file that specifies the theme: * * Example: * maptheme = "earth/bluemarble/bluemarble.dgml" */ void setMapThemeId( const QString& maptheme ); /** * @brief Sets the value of a map theme property * @param value value of the property (usually: visibility) * * Later on we might add a "setPropertyType and a QVariant * if needed. */ void setPropertyValue( const QString& name, bool value ); /** * @brief Set whether the overview map overlay is visible * @param visible visibility of the overview map */ void setShowOverviewMap( bool visible ); /** * @brief Set whether the scale bar overlay is visible * @param visible visibility of the scale bar */ void setShowScaleBar( bool visible ); /** * @brief Set whether the compass overlay is visible * @param visible visibility of the compass */ void setShowCompass( bool visible ); /** * @brief Set whether the cloud cover is visible * @param visible visibility of the cloud cover */ void setShowClouds( bool visible ); /** * @brief Set whether the night shadow is visible. - * @param visibile visibility of shadow + * @param visible visibility of shadow */ void setShowSunShading( bool visible ); /** * @brief Set whether city lights instead of night shadow are visible. * @param visible visibility of city lights */ void setShowCityLights( bool visible ); /** * @brief Set the globe locked to the sub solar point * @param visible if globe is locked to the sub solar point */ void setLockToSubSolarPoint( bool visible ); /** * @brief Set whether the sun icon is shown in the sub solar point * @param visible if the sun icon is shown in the sub solar point */ void setSubSolarPointIconVisible( bool visible ); /** * @brief Set whether the atmospheric glow is visible * @param visible visibility of the atmospheric glow */ void setShowAtmosphere( bool visible ); /** * @brief Set whether the crosshairs are visible * @param visible visibility of the crosshairs */ void setShowCrosshairs( bool visible ); /** * @brief Set whether the coordinate grid overlay is visible * @param visible visibility of the coordinate grid */ void setShowGrid( bool visible ); /** * @brief Set whether the place mark overlay is visible * @param visible visibility of the place marks */ void setShowPlaces( bool visible ); /** * @brief Set whether the city place mark overlay is visible * @param visible visibility of the city place marks */ void setShowCities( bool visible ); /** * @brief Set whether the terrain place mark overlay is visible * @param visible visibility of the terrain place marks */ void setShowTerrain( bool visible ); /** * @brief Set whether the other places overlay is visible * @param visible visibility of other places */ void setShowOtherPlaces( bool visible ); /** * @brief Set whether the relief is visible * @param visible visibility of the relief */ void setShowRelief( bool visible ); /** * @brief Set whether the ice layer is visible * @param visible visibility of the ice layer */ void setShowIceLayer( bool visible ); /** * @brief Set whether the borders visible * @param visible visibility of the borders */ void setShowBorders( bool visible ); /** * @brief Set whether the rivers are visible * @param visible visibility of the rivers */ void setShowRivers( bool visible ); /** * @brief Set whether the lakes are visible * @param visible visibility of the lakes */ void setShowLakes( bool visible ); /** * @brief Set whether the frame rate gets shown * @param visible visibility of the frame rate */ void setShowFrameRate( bool visible ); void setShowBackground( bool visible ); /** * @brief Set whether the is tile is visible * NOTE: This is part of the transitional debug API * and might be subject to changes until Marble 0.8 * @param visible visibility of the tile */ void setShowTileId( bool visible ); /** * @brief Set whether the runtime tracing for layers gets shown * @param visible visibility of the runtime tracing */ void setShowRuntimeTrace( bool visible ); bool showRuntimeTrace() const; /** * @brief Set whether to enter the debug mode for * polygon node drawing * @param visible visibility of the node debug mode */ void setShowDebugPolygons( bool visible); bool showDebugPolygons() const; /** * @brief Set whether to enter the debug mode for * batch rendering * @param visible visibility of the batch rendering */ void setShowDebugBatchRender( bool visible); bool showDebugBatchRender() const; /** * @brief Set whether to enter the debug mode for * placemark drawing * @param visible visibility of the node debug mode */ void setShowDebugPlacemarks(bool visible); bool showDebugPlacemarks() const; /** * @brief Set whether to render according to OSM indoor level tags * @param visible visibility of entities (placemarks, buildings etc.) level-wise */ void setDebugLevelTags(bool visible); bool debugLevelTags() const; /** * @brief Set the level to debug * @param level the level to debug */ void setLevelToDebug(int level); int levelToDebug() const; /** * @brief Set the map quality for the specified view context. * * @param quality map quality for the specified view context * @param viewContext view context whose map quality should be set */ void setMapQualityForViewContext( MapQuality quality, ViewContext viewContext ); /** * @brief Set the view context (i.e. still or animated map) */ void setViewContext( ViewContext viewContext ); /** * @brief Set whether travels to a point should get animated */ void setAnimationsEnabled( bool enabled ); //@} /// @name Tile management slots //@{ void clearVolatileTileCache(); /** * @brief Set the limit of the volatile (in RAM) tile cache. - * @param kilobytes The limit in kilobytes. + * @param kiloBytes The limit in kilobytes. */ void setVolatileTileCacheLimit( quint64 kiloBytes ); /** * @brief A slot that is called when the model starts to create new tiles. * @param creator the tile creator object. * @param name the name of the created theme. * @param description a descriptive text that can be shown in a dialog. * @see creatingTilesProgress * * This function is connected to the models signal with the same * name. When the model needs to create a cache of tiles in * several different resolutions, it will emit creatingTilesStart * once with a name of the theme and a descriptive text. The * widget can then pop up a dialog to explain why there is a * delay. The model will then call creatingTilesProgress several * times until the parameter reaches 100 (100%), after which the * creation process is finished. After this there will be no more * calls to creatingTilesProgress, and the poup dialog can then be * closed. */ void creatingTilesStart( TileCreator *creator, const QString& name, const QString& description ); /** * @brief Re-download all visible tiles. */ void reloadMap(); void downloadRegion( QVector const & ); //@} /// @name Miscellaneous slots //@{ /** * @brief Used to notify about the position of the mouse click */ void notifyMouseClick( int x, int y ); void setSelection( const QRect& region ); void setInputEnabled( bool ); TextureLayer *textureLayer() const; //@} Q_SIGNALS: /** * @brief Signal that the zoom has changed, and to what. * @param zoom The new zoom value. * @see setZoom() */ void zoomChanged( int zoom ); void distanceChanged( const QString& distanceString ); void tileLevelChanged( int level ); void viewContextChanged(ViewContext newViewContext); /** * @brief Signal that the theme has changed * @param theme Name of the new theme. */ void themeChanged( const QString& theme ); void projectionChanged( Projection ); void mouseMoveGeoPosition( const QString& ); void mouseClickGeoPosition( qreal lon, qreal lat, GeoDataCoordinates::Unit ); void framesPerSecond( qreal fps ); /** * This signal is emit when a new rectangle region is selected over the map. * * @param boundingBox The geographical coordinates of the selected region */ void regionSelected(const GeoDataLatLonBox &boundingBox); /** * This signal is emit when the settings of a plugin changed. */ void pluginSettingsChanged(); /** * @brief Signal that a render item has been initialized */ void renderPluginInitialized( RenderPlugin *renderPlugin ); /** * This signal is emitted when the visible region of the map changes. This typically happens * when the user moves the map around or zooms. */ void visibleLatLonAltBoxChanged( const GeoDataLatLonAltBox& visibleLatLonAltBox ); /** * @brief Emitted when the layer rendering status has changed * @param status New render status */ void renderStatusChanged( RenderStatus status ); void renderStateChanged( const RenderState &state ); void highlightedPlacemarksChanged( qreal lon, qreal lat, GeoDataCoordinates::Unit unit ); protected: /** * @brief Reimplementation of the leaveEvent() function in QWidget. */ void leaveEvent( QEvent *event ) override; /** * @brief Reimplementation of the paintEvent() function in QWidget. */ void paintEvent( QPaintEvent *event ) override; /** * @brief Reimplementation of the resizeEvent() function in QWidget. */ void resizeEvent( QResizeEvent *event ) override; void connectNotify(const QMetaMethod &signal) override; void disconnectNotify(const QMetaMethod &signal) override; /** * @brief Reimplementation of the changeEvent() function in QWidget to * react to changes of the enabled state */ void changeEvent( QEvent * event ) override; /** * @brief Enables custom drawing onto the MarbleWidget straight after * @brief the globe and before all other layers has been rendered. * @param painter * * @deprecated implement LayerInterface and add it using @p addLayer() */ virtual void customPaint( GeoPainter *painter ); private: Q_PRIVATE_SLOT( d, void updateMapTheme() ) Q_PRIVATE_SLOT( d, void updateSystemBackgroundAttribute() ) private: Q_DISABLE_COPY( MarbleWidget ) MarbleWidgetPrivate * const d; friend class MarbleWidgetPrivate; class CustomPaintLayer; friend class CustomPaintLayer; friend class MarbleWidgetDefaultInputHandler; }; } #endif diff --git a/src/lib/marble/MarbleZip.cpp b/src/lib/marble/MarbleZip.cpp index 4a7945dd7..43e68a00b 100644 --- a/src/lib/marble/MarbleZip.cpp +++ b/src/lib/marble/MarbleZip.cpp @@ -1,1282 +1,1282 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // This file is based on qzip.cpp from Qt with the original license // below, taken from // http://code.qt.io/cgit/qt/qt.git/plain/src/gui/text/qzip.cpp /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** As a special exception, The Qt Company gives you certain additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #ifndef QT_NO_TEXTODFWRITER #include "MarbleZipReader.h" #include "MarbleZipWriter.h" #include #include #include #include #include #include #if defined(Q_OS_WIN) # undef S_IFREG # define S_IFREG 0100000 # ifndef S_IFDIR # define S_IFDIR 0040000 # endif # ifndef S_ISDIR # define S_ISDIR(x) ((x) & S_IFDIR) > 0 # endif # ifndef S_ISREG # define S_ISREG(x) ((x) & 0170000) == S_IFREG # endif # define S_IFLNK 020000 # define S_ISLNK(x) ((x) & S_IFLNK) > 0 # ifndef S_IRUSR # define S_IRUSR 0400 # endif # ifndef S_IWUSR # define S_IWUSR 0200 # endif # ifndef S_IXUSR # define S_IXUSR 0100 # endif # define S_IRGRP 0040 # define S_IWGRP 0020 # define S_IXGRP 0010 # define S_IROTH 0004 # define S_IWOTH 0002 # define S_IXOTH 0001 #endif #if 0 #define ZDEBUG qDebug #else #define ZDEBUG if (0) qDebug #endif namespace Marble { static inline uint readUInt(const uchar *data) { return (data[0]) + (data[1]<<8) + (data[2]<<16) + (data[3]<<24); } static inline ushort readUShort(const uchar *data) { return (data[0]) + (data[1]<<8); } static inline void writeUInt(uchar *data, uint i) { data[0] = i & 0xff; data[1] = (i>>8) & 0xff; data[2] = (i>>16) & 0xff; data[3] = (i>>24) & 0xff; } static inline void writeUShort(uchar *data, ushort i) { data[0] = i & 0xff; data[1] = (i>>8) & 0xff; } static inline void copyUInt(uchar *dest, const uchar *src) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; dest[3] = src[3]; } static inline void copyUShort(uchar *dest, const uchar *src) { dest[0] = src[0]; dest[1] = src[1]; } static void writeMSDosDate(uchar *dest, const QDateTime& dt) { if (dt.isValid()) { quint16 time = (dt.time().hour() << 11) // 5 bit hour | (dt.time().minute() << 5) // 6 bit minute | (dt.time().second() >> 1); // 5 bit double seconds dest[0] = time & 0xff; dest[1] = time >> 8; quint16 date = ((dt.date().year() - 1980) << 9) // 7 bit year 1980-based | (dt.date().month() << 5) // 4 bit month | (dt.date().day()); // 5 bit day dest[2] = char(date); dest[3] = char(date >> 8); } else { dest[0] = 0; dest[1] = 0; dest[2] = 0; dest[3] = 0; } } static quint32 permissionsToMode(QFile::Permissions perms) { quint32 mode = 0; if (perms & QFile::ReadOwner) mode |= S_IRUSR; if (perms & QFile::WriteOwner) mode |= S_IWUSR; if (perms & QFile::ExeOwner) mode |= S_IXUSR; if (perms & QFile::ReadUser) mode |= S_IRUSR; if (perms & QFile::WriteUser) mode |= S_IWUSR; if (perms & QFile::ExeUser) mode |= S_IXUSR; if (perms & QFile::ReadGroup) mode |= S_IRGRP; if (perms & QFile::WriteGroup) mode |= S_IWGRP; if (perms & QFile::ExeGroup) mode |= S_IXGRP; if (perms & QFile::ReadOther) mode |= S_IROTH; if (perms & QFile::WriteOther) mode |= S_IWOTH; if (perms & QFile::ExeOther) mode |= S_IXOTH; return mode; } static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen) { z_stream stream; int err; stream.next_in = (Bytef*)source; stream.avail_in = (uInt)sourceLen; if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; stream.next_out = dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; stream.zalloc = (alloc_func)nullptr; stream.zfree = (free_func)nullptr; err = inflateInit2(&stream, -MAX_WBITS); if (err != Z_OK) return err; err = inflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { inflateEnd(&stream); if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) return Z_DATA_ERROR; return err; } *destLen = stream.total_out; err = inflateEnd(&stream); return err; } static int deflate (Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen) { z_stream stream; int err; stream.next_in = (Bytef*)source; stream.avail_in = (uInt)sourceLen; stream.next_out = dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; stream.zalloc = (alloc_func)nullptr; stream.zfree = (free_func)nullptr; stream.opaque = (voidpf)nullptr; err = deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY); if (err != Z_OK) return err; err = deflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { deflateEnd(&stream); return err == Z_OK ? Z_BUF_ERROR : err; } *destLen = stream.total_out; err = deflateEnd(&stream); return err; } static QFile::Permissions modeToPermissions(quint32 mode) { QFile::Permissions ret; if (mode & S_IRUSR) ret |= QFile::ReadOwner; if (mode & S_IWUSR) ret |= QFile::WriteOwner; if (mode & S_IXUSR) ret |= QFile::ExeOwner; if (mode & S_IRUSR) ret |= QFile::ReadUser; if (mode & S_IWUSR) ret |= QFile::WriteUser; if (mode & S_IXUSR) ret |= QFile::ExeUser; if (mode & S_IRGRP) ret |= QFile::ReadGroup; if (mode & S_IWGRP) ret |= QFile::WriteGroup; if (mode & S_IXGRP) ret |= QFile::ExeGroup; if (mode & S_IROTH) ret |= QFile::ReadOther; if (mode & S_IWOTH) ret |= QFile::WriteOther; if (mode & S_IXOTH) ret |= QFile::ExeOther; return ret; } static QDateTime readMSDosDate(const uchar *src) { uint dosDate = readUInt(src); quint64 uDate; uDate = (quint64)(dosDate >> 16); uint tm_mday = (uDate & 0x1f); uint tm_mon = ((uDate & 0x1E0) >> 5); uint tm_year = (((uDate & 0x0FE00) >> 9) + 1980); uint tm_hour = ((dosDate & 0xF800) >> 11); uint tm_min = ((dosDate & 0x7E0) >> 5); uint tm_sec = ((dosDate & 0x1f) << 1); return QDateTime(QDate(tm_year, tm_mon, tm_mday), QTime(tm_hour, tm_min, tm_sec)); } struct LocalFileHeader { uchar signature[4]; // 0x04034b50 uchar version_needed[2]; uchar general_purpose_bits[2]; uchar compression_method[2]; uchar last_mod_file[4]; uchar crc_32[4]; uchar compressed_size[4]; uchar uncompressed_size[4]; uchar file_name_length[2]; uchar extra_field_length[2]; }; struct DataDescriptor { uchar crc_32[4]; uchar compressed_size[4]; uchar uncompressed_size[4]; }; struct CentralFileHeader { uchar signature[4]; // 0x02014b50 uchar version_made[2]; uchar version_needed[2]; uchar general_purpose_bits[2]; uchar compression_method[2]; uchar last_mod_file[4]; uchar crc_32[4]; uchar compressed_size[4]; uchar uncompressed_size[4]; uchar file_name_length[2]; uchar extra_field_length[2]; uchar file_comment_length[2]; uchar disk_start[2]; uchar internal_file_attributes[2]; uchar external_file_attributes[4]; uchar offset_local_header[4]; LocalFileHeader toLocalHeader() const; }; struct EndOfDirectory { uchar signature[4]; // 0x06054b50 uchar this_disk[2]; uchar start_of_directory_disk[2]; uchar num_dir_entries_this_disk[2]; uchar num_dir_entries[2]; uchar directory_size[4]; uchar dir_start_offset[4]; uchar comment_length[2]; }; struct FileHeader { CentralFileHeader h; QByteArray file_name; QByteArray extra_field; QByteArray file_comment; }; MarbleZipReader::FileInfo::FileInfo() : isDir(false), isFile(false), isSymLink(false), crc32(0), size(0) { } MarbleZipReader::FileInfo::~FileInfo() { } MarbleZipReader::FileInfo::FileInfo(const FileInfo &other) { operator=(other); } MarbleZipReader::FileInfo& MarbleZipReader::FileInfo::operator=(const FileInfo &other) { filePath = other.filePath; isDir = other.isDir; isFile = other.isFile; isSymLink = other.isSymLink; permissions = other.permissions; crc32 = other.crc32; size = other.size; lastModified = other.lastModified; return *this; } bool MarbleZipReader::FileInfo::isValid() const { return isDir || isFile || isSymLink; } class QZipPrivate { public: QZipPrivate(QIODevice *device, bool ownDev) : device(device), ownDevice(ownDev), dirtyFileTree(true), start_of_directory(0) { } ~QZipPrivate() { if (ownDevice) delete device; } void fillFileInfo(int index, MarbleZipReader::FileInfo &fileInfo) const; QIODevice *device; bool ownDevice; bool dirtyFileTree; QList fileHeaders; QByteArray comment; uint start_of_directory; }; void QZipPrivate::fillFileInfo(int index, MarbleZipReader::FileInfo &fileInfo) const { FileHeader header = fileHeaders.at(index); fileInfo.filePath = QString::fromLocal8Bit(header.file_name); const quint32 mode = (qFromLittleEndian(&header.h.external_file_attributes[0]) >> 16) & 0xFFFF; if (mode == 0) { fileInfo.isDir = false; fileInfo.isFile = true; fileInfo.isSymLink = false; fileInfo.permissions = QFile::ReadOwner; } else { fileInfo.isDir = S_ISDIR(mode); fileInfo.isFile = S_ISREG(mode); fileInfo.isSymLink = S_ISLNK(mode); fileInfo.permissions = modeToPermissions(mode); } fileInfo.crc32 = readUInt(header.h.crc_32); fileInfo.size = readUInt(header.h.uncompressed_size); fileInfo.lastModified = readMSDosDate(header.h.last_mod_file); } class MarbleZipReaderPrivate : public QZipPrivate { public: MarbleZipReaderPrivate(QIODevice *device, bool ownDev) : QZipPrivate(device, ownDev), status(MarbleZipReader::NoError) { } void scanFiles(); MarbleZipReader::Status status; }; class MarbleZipWriterPrivate : public QZipPrivate { public: MarbleZipWriterPrivate(QIODevice *device, bool ownDev) : QZipPrivate(device, ownDev), status(MarbleZipWriter::NoError), permissions(QFile::ReadOwner | QFile::WriteOwner), compressionPolicy(MarbleZipWriter::AlwaysCompress) { } MarbleZipWriter::Status status; QFile::Permissions permissions; MarbleZipWriter::CompressionPolicy compressionPolicy; enum EntryType { Directory, File, Symlink }; void addEntry(EntryType type, const QString &fileName, const QByteArray &contents); }; LocalFileHeader CentralFileHeader::toLocalHeader() const { LocalFileHeader h; writeUInt(h.signature, 0x04034b50); copyUShort(h.version_needed, version_needed); copyUShort(h.general_purpose_bits, general_purpose_bits); copyUShort(h.compression_method, compression_method); copyUInt(h.last_mod_file, last_mod_file); copyUInt(h.crc_32, crc_32); copyUInt(h.compressed_size, compressed_size); copyUInt(h.uncompressed_size, uncompressed_size); copyUShort(h.file_name_length, file_name_length); copyUShort(h.extra_field_length, extra_field_length); return h; } void MarbleZipReaderPrivate::scanFiles() { if (!dirtyFileTree) return; if (! (device->isOpen() || device->open(QIODevice::ReadOnly))) { status = MarbleZipReader::FileOpenError; return; } if ((device->openMode() & QIODevice::ReadOnly) == 0) { // only read the index from readable files. status = MarbleZipReader::FileReadError; return; } dirtyFileTree = false; uchar tmp[4]; device->read((char *)tmp, 4); if (readUInt(tmp) != 0x04034b50) { qWarning() << "QZip: not a zip file!"; return; } // find EndOfDirectory header int i = 0; int start_of_directory = -1; int num_dir_entries = 0; EndOfDirectory eod; while (start_of_directory == -1) { int pos = device->size() - sizeof(EndOfDirectory) - i; if (pos < 0 || i > 65535) { qWarning() << "QZip: EndOfDirectory not found"; return; } device->seek(pos); device->read((char *)&eod, sizeof(EndOfDirectory)); if (readUInt(eod.signature) == 0x06054b50) break; ++i; } // have the eod start_of_directory = readUInt(eod.dir_start_offset); num_dir_entries = readUShort(eod.num_dir_entries); ZDEBUG("start_of_directory at %d, num_dir_entries=%d", start_of_directory, num_dir_entries); int comment_length = readUShort(eod.comment_length); if (comment_length != i) qWarning() << "QZip: failed to parse zip file."; comment = device->read(qMin(comment_length, i)); device->seek(start_of_directory); for (i = 0; i < num_dir_entries; ++i) { FileHeader header; int read = device->read((char *) &header.h, sizeof(CentralFileHeader)); if (read < (int)sizeof(CentralFileHeader)) { qWarning() << "QZip: Failed to read complete header, index may be incomplete"; break; } if (readUInt(header.h.signature) != 0x02014b50) { qWarning() << "QZip: invalid header signature, index may be incomplete"; break; } int l = readUShort(header.h.file_name_length); header.file_name = device->read(l); if (header.file_name.length() != l) { qWarning() << "QZip: Failed to read filename from zip index, index may be incomplete"; break; } l = readUShort(header.h.extra_field_length); header.extra_field = device->read(l); if (header.extra_field.length() != l) { qWarning() << "QZip: Failed to read extra field in zip file, skipping file, index may be incomplete"; break; } l = readUShort(header.h.file_comment_length); header.file_comment = device->read(l); if (header.file_comment.length() != l) { qWarning() << "QZip: Failed to read file comment, index may be incomplete"; break; } ZDEBUG("found file '%s'", header.file_name.data()); fileHeaders.append(header); } } void MarbleZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const QByteArray &contents/*, QFile::Permissions permissions, QZip::Method m*/) { #ifndef NDEBUG static const char *entryTypes[] = { "directory", "file ", "symlink " }; ZDEBUG() << "adding" << entryTypes[type] <<":" << fileName.toUtf8().data() << (type == 2 ? QByteArray(" -> " + contents).constData() : ""); #endif if (! (device->isOpen() || device->open(QIODevice::WriteOnly))) { status = MarbleZipWriter::FileOpenError; return; } device->seek(start_of_directory); // don't compress small files MarbleZipWriter::CompressionPolicy compression = compressionPolicy; if (compressionPolicy == MarbleZipWriter::AutoCompress) { if (contents.length() < 64) compression = MarbleZipWriter::NeverCompress; else compression = MarbleZipWriter::AlwaysCompress; } FileHeader header; memset(&header.h, 0, sizeof(CentralFileHeader)); writeUInt(header.h.signature, 0x02014b50); writeUShort(header.h.version_needed, 0x14); writeUInt(header.h.uncompressed_size, contents.length()); writeMSDosDate(header.h.last_mod_file, QDateTime::currentDateTime()); QByteArray data = contents; if (compression == MarbleZipWriter::AlwaysCompress) { writeUShort(header.h.compression_method, 8); ulong len = contents.length(); // shamelessly copied form zlib len += (len >> 12) + (len >> 14) + 11; int res; do { data.resize(len); res = deflate((uchar*)data.data(), &len, (const uchar*)contents.constData(), contents.length()); switch (res) { case Z_OK: data.resize(len); break; case Z_MEM_ERROR: qWarning("QZip: Z_MEM_ERROR: Not enough memory to compress file, skipping"); data.resize(0); break; case Z_BUF_ERROR: len *= 2; break; } } while (res == Z_BUF_ERROR); } // TODO add a check if data.length() > contents.length(). Then try to store the original and revert the compression method to be uncompressed writeUInt(header.h.compressed_size, data.length()); uint crc_32 = ::crc32(0, nullptr, 0); crc_32 = ::crc32(crc_32, (const uchar *)contents.constData(), contents.length()); writeUInt(header.h.crc_32, crc_32); header.file_name = fileName.toLocal8Bit(); if (header.file_name.size() > 0xffff) { qWarning("QZip: Filename too long, chopping it to 65535 characters"); header.file_name = header.file_name.left(0xffff); } writeUShort(header.h.file_name_length, header.file_name.length()); //h.extra_field_length[2]; writeUShort(header.h.version_made, 3 << 8); //uchar internal_file_attributes[2]; //uchar external_file_attributes[4]; quint32 mode = permissionsToMode(permissions); switch (type) { case File: mode |= S_IFREG; break; case Directory: mode |= S_IFDIR; break; case Symlink: mode |= S_IFLNK; break; } writeUInt(header.h.external_file_attributes, mode << 16); writeUInt(header.h.offset_local_header, start_of_directory); fileHeaders.append(header); LocalFileHeader h = header.h.toLocalHeader(); device->write((const char *)&h, sizeof(LocalFileHeader)); device->write(header.file_name); device->write(data); start_of_directory = device->pos(); dirtyFileTree = true; } ////////////////////////////// Reader /*! \class QZipReader::FileInfo \internal Represents one entry in the zip table of contents. */ /*! \variable FileInfo::filePath The full filepath inside the archive. */ /*! \variable FileInfo::isDir A boolean type indicating if the entry is a directory. */ /*! \variable FileInfo::isFile A boolean type, if it is one this entry is a file. */ /*! \variable FileInfo::isSymLink A boolean type, if it is one this entry is symbolic link. */ /*! \variable FileInfo::permissions A list of flags for the permissions of this entry. */ /*! \variable FileInfo::crc32 The calculated checksum as a crc32 type. */ /*! \variable FileInfo::size The total size of the unpacked content. */ /*! \variable FileInfo::d \internal private pointer. */ /*! \class QZipReader \internal \since 4.5 \brief the QZipReader class provides a way to inspect the contents of a zip archive and extract individual files from it. QZipReader can be used to read a zip archive either from a file or from any device. An in-memory QBuffer for instance. The reader can be used to read which files are in the archive using fileInfoList() and entryInfoAt() but also to extract individual files using fileData() or even to extract all files in the archive using extractAll() */ /*! Create a new zip archive that operates on the \a fileName. The file will be opened with the \a mode. */ MarbleZipReader::MarbleZipReader(const QString &archive, QIODevice::OpenMode mode) { QScopedPointer f(new QFile(archive)); f->open(mode); MarbleZipReader::Status status; if (f->error() == QFile::NoError) status = NoError; else { if (f->error() == QFile::ReadError) status = FileReadError; else if (f->error() == QFile::OpenError) status = FileOpenError; else if (f->error() == QFile::PermissionsError) status = FilePermissionsError; else status = FileError; } d = new MarbleZipReaderPrivate(f.data(), /*ownDevice=*/true); f.take(); d->status = status; } /*! Create a new zip archive that operates on the archive found in \a device. You have to open the device previous to calling the constructor and only a device that is readable will be scanned for zip filecontent. */ MarbleZipReader::MarbleZipReader(QIODevice *device) : d(new MarbleZipReaderPrivate(device, /*ownDevice=*/false)) { Q_ASSERT(device); } /*! Desctructor */ MarbleZipReader::~MarbleZipReader() { close(); delete d; } /*! Returns device used for reading zip archive. */ QIODevice* MarbleZipReader::device() const { return d->device; } /*! Returns true if the user can read the file; otherwise returns false. */ bool MarbleZipReader::isReadable() const { return d->device->isReadable(); } /*! Returns true if the file exists; otherwise returns false. */ bool MarbleZipReader::exists() const { QFile *f = qobject_cast (d->device); if (f == nullptr) return true; return f->exists(); } /*! Returns the list of files the archive contains. */ QList MarbleZipReader::fileInfoList() const { d->scanFiles(); QList files; for (int i = 0; i < d->fileHeaders.size(); ++i) { MarbleZipReader::FileInfo fi; d->fillFileInfo(i, fi); files.append(fi); } return files; } /*! Return the number of items in the zip archive. */ int MarbleZipReader::count() const { d->scanFiles(); return d->fileHeaders.count(); } /*! Returns a FileInfo of an entry in the zipfile. The \a index is the index into the directory listing of the zipfile. Returns an invalid FileInfo if \a index is out of boundaries. \sa fileInfoList() */ MarbleZipReader::FileInfo MarbleZipReader::entryInfoAt(int index) const { d->scanFiles(); MarbleZipReader::FileInfo fi; if (index >= 0 && index < d->fileHeaders.count()) d->fillFileInfo(index, fi); return fi; } /*! Fetch the file contents from the zip archive and return the uncompressed bytes. */ QByteArray MarbleZipReader::fileData(const QString &fileName) const { d->scanFiles(); int i; for (i = 0; i < d->fileHeaders.size(); ++i) { if (QString::fromLocal8Bit(d->fileHeaders.at(i).file_name) == fileName) break; } if (i == d->fileHeaders.size()) return QByteArray(); FileHeader header = d->fileHeaders.at(i); int compressed_size = readUInt(header.h.compressed_size); int uncompressed_size = readUInt(header.h.uncompressed_size); int start = readUInt(header.h.offset_local_header); //qDebug("uncompressing file %d: local header at %d", i, start); d->device->seek(start); LocalFileHeader lh; d->device->read((char *)&lh, sizeof(LocalFileHeader)); uint skip = readUShort(lh.file_name_length) + readUShort(lh.extra_field_length); d->device->seek(d->device->pos() + skip); int compression_method = readUShort(lh.compression_method); //qDebug("file=%s: compressed_size=%d, uncompressed_size=%d", fileName.toLocal8Bit().data(), compressed_size, uncompressed_size); //qDebug("file at %lld", d->device->pos()); QByteArray compressed = d->device->read(compressed_size); if (compression_method == 0) { // no compression compressed.truncate(uncompressed_size); return compressed; } else if (compression_method == 8) { // Deflate //qDebug("compressed=%d", compressed.size()); compressed.truncate(compressed_size); QByteArray baunzip; ulong len = qMax(uncompressed_size, 1); int res; do { baunzip.resize(len); res = inflate((uchar*)baunzip.data(), &len, (uchar*)compressed.constData(), compressed_size); switch (res) { case Z_OK: if ((int)len != baunzip.size()) baunzip.resize(len); break; case Z_MEM_ERROR: qWarning("QZip: Z_MEM_ERROR: Not enough memory"); break; case Z_BUF_ERROR: len *= 2; break; case Z_DATA_ERROR: qWarning("QZip: Z_DATA_ERROR: Input data is corrupted"); break; } } while (res == Z_BUF_ERROR); return baunzip; } qWarning() << "QZip: Unknown compression method"; return QByteArray(); } /*! Extracts the full contents of the zip file into \a destinationDir on the local filesystem. In case writing or linking a file fails, the extraction will be aborted. */ bool MarbleZipReader::extractAll(const QString &destinationDir) const { QDir baseDir(destinationDir); // create directories first QList allFiles = fileInfoList(); for (const FileInfo& fi: allFiles) { const QString absPath = destinationDir + QDir::separator() + fi.filePath; if (fi.isDir) { if (!baseDir.mkpath(fi.filePath)) return false; if (!QFile::setPermissions(absPath, fi.permissions)) return false; } } // set up symlinks for (const FileInfo& fi: allFiles) { const QString absPath = destinationDir + QDir::separator() + fi.filePath; if (fi.isSymLink) { QString destination = QFile::decodeName(fileData(fi.filePath)); if (destination.isEmpty()) return false; QFileInfo linkFi(absPath); if (!QFile::exists(linkFi.absolutePath())) QDir::root().mkpath(linkFi.absolutePath()); if (!QFile::link(destination, absPath)) return false; /* cannot change permission of links if (!QFile::setPermissions(absPath, fi.permissions)) return false; */ } } for (const FileInfo& fi: allFiles) { const QString absPath = destinationDir + QDir::separator() + fi.filePath; if (fi.isFile) { QDir::root().mkpath(QFileInfo(absPath).dir().absolutePath()); QFile f(absPath); if (!f.open(QIODevice::WriteOnly)) return false; f.write(fileData(fi.filePath)); f.setPermissions(fi.permissions); f.close(); } } return true; } /*! \enum QZipReader::Status The following status values are possible: \value NoError No error occurred. \value FileReadError An error occurred when reading from the file. \value FileOpenError The file could not be opened. \value FilePermissionsError The file could not be accessed. \value FileError Another file error occurred. */ /*! Returns a status code indicating the first error that was met by QZipReader, or QZipReader::NoError if no error occurred. */ MarbleZipReader::Status MarbleZipReader::status() const { return d->status; } /*! Close the zip file. */ void MarbleZipReader::close() { d->device->close(); } ////////////////////////////// Writer /*! \class QZipWriter \internal \since 4.5 \brief the QZipWriter class provides a way to create a new zip archive. QZipWriter can be used to create a zip archive containing any number of files and directories. The files in the archive will be compressed in a way that is compatible with common zip reader applications. */ /*! Create a new zip archive that operates on the \a archive filename. The file will be opened with the \a mode. \sa isValid() */ MarbleZipWriter::MarbleZipWriter(const QString &fileName, QIODevice::OpenMode mode) { QScopedPointer f(new QFile(fileName)); f->open(mode); MarbleZipWriter::Status status; if (f->error() == QFile::NoError) status = MarbleZipWriter::NoError; else { if (f->error() == QFile::WriteError) status = MarbleZipWriter::FileWriteError; else if (f->error() == QFile::OpenError) status = MarbleZipWriter::FileOpenError; else if (f->error() == QFile::PermissionsError) status = MarbleZipWriter::FilePermissionsError; else status = MarbleZipWriter::FileError; } d = new MarbleZipWriterPrivate(f.data(), /*ownDevice=*/true); f.take(); d->status = status; } /*! Create a new zip archive that operates on the archive found in \a device. You have to open the device previous to calling the constructor and only a device that is readable will be scanned for zip filecontent. */ MarbleZipWriter::MarbleZipWriter(QIODevice *device) : d(new MarbleZipWriterPrivate(device, /*ownDevice=*/false)) { Q_ASSERT(device); } MarbleZipWriter::~MarbleZipWriter() { close(); delete d; } /*! Returns device used for writing zip archive. */ QIODevice* MarbleZipWriter::device() const { return d->device; } /*! Returns true if the user can write to the archive; otherwise returns false. */ bool MarbleZipWriter::isWritable() const { return d->device->isWritable(); } /*! Returns true if the file exists; otherwise returns false. */ bool MarbleZipWriter::exists() const { QFile *f = qobject_cast (d->device); if (f == nullptr) return true; return f->exists(); } /*! \enum QZipWriter::Status The following status values are possible: - \value NoError No error occurred. - \value FileWriteError An error occurred when writing to the device. - \value FileOpenError The file could not be opened. - \value FilePermissionsError The file could not be accessed. - \value FileError Another file error occurred. + \var NoError No error occurred. + \var FileWriteError An error occurred when writing to the device. + \var FileOpenError The file could not be opened. + \var FilePermissionsError The file could not be accessed. + \var FileError Another file error occurred. */ /*! Returns a status code indicating the first error that was met by QZipWriter, or QZipWriter::NoError if no error occurred. */ MarbleZipWriter::Status MarbleZipWriter::status() const { return d->status; } /*! \enum QZipWriter::CompressionPolicy - \value AlwaysCompress A file that is added is compressed. - \value NeverCompress A file that is added will be stored without changes. - \value AutoCompress A file that is added will be compressed only if that will give a smaller file. + \var AlwaysCompress A file that is added is compressed. + \var NeverCompress A file that is added will be stored without changes. + \var AutoCompress A file that is added will be compressed only if that will give a smaller file. */ /*! Sets the policy for compressing newly added files to the new \a policy. \note the default policy is AlwaysCompress \sa compressionPolicy() \sa addFile() */ void MarbleZipWriter::setCompressionPolicy(CompressionPolicy policy) { d->compressionPolicy = policy; } /*! Returns the currently set compression policy. \sa setCompressionPolicy() \sa addFile() */ MarbleZipWriter::CompressionPolicy MarbleZipWriter::compressionPolicy() const { return d->compressionPolicy; } /*! Sets the permissions that will be used for newly added files. \note the default permissions are QFile::ReadOwner | QFile::WriteOwner. \sa creationPermissions() \sa addFile() */ void MarbleZipWriter::setCreationPermissions(QFile::Permissions permissions) { d->permissions = permissions; } /*! Returns the currently set creation permissions. \sa setCreationPermissions() \sa addFile() */ QFile::Permissions MarbleZipWriter::creationPermissions() const { return d->permissions; } /*! Add a file to the archive with \a data as the file contents. The file will be stored in the archive using the \a fileName which includes the full path in the archive. The new file will get the file permissions based on the current creationPermissions and it will be compressed using the zip compression based on the current compression policy. \sa setCreationPermissions() \sa setCompressionPolicy() */ void MarbleZipWriter::addFile(const QString &fileName, const QByteArray &data) { d->addEntry(MarbleZipWriterPrivate::File, QDir::fromNativeSeparators(fileName), data); } /*! Add a file to the archive with \a device as the source of the contents. The contents returned from QIODevice::readAll() will be used as the filedata. The file will be stored in the archive using the \a fileName which includes the full path in the archive. */ void MarbleZipWriter::addFile(const QString &fileName, QIODevice *device) { Q_ASSERT(device); QIODevice::OpenMode mode = device->openMode(); bool opened = false; if ((mode & QIODevice::ReadOnly) == 0) { opened = true; if (! device->open(QIODevice::ReadOnly)) { d->status = FileOpenError; return; } } d->addEntry(MarbleZipWriterPrivate::File, QDir::fromNativeSeparators(fileName), device->readAll()); if (opened) device->close(); } /*! Create a new directory in the archive with the specified \a dirName and the \a permissions; */ void MarbleZipWriter::addDirectory(const QString &dirName) { QString name(QDir::fromNativeSeparators(dirName)); // separator is mandatory if (!name.endsWith(QLatin1Char('/'))) name.append(QLatin1Char('/')); d->addEntry(MarbleZipWriterPrivate::Directory, name, QByteArray()); } /*! Create a new symbolic link in the archive with the specified \a dirName and the \a permissions; A symbolic link contains the destination (relative) path and name. */ void MarbleZipWriter::addSymLink(const QString &fileName, const QString &destination) { d->addEntry(MarbleZipWriterPrivate::Symlink, QDir::fromNativeSeparators(fileName), QFile::encodeName(destination)); } /*! Closes the zip file. */ void MarbleZipWriter::close() { if (!(d->device->openMode() & QIODevice::WriteOnly)) { d->device->close(); return; } //qDebug("QZip::close writing directory, %d entries", d->fileHeaders.size()); d->device->seek(d->start_of_directory); // write new directory for (int i = 0; i < d->fileHeaders.size(); ++i) { const FileHeader &header = d->fileHeaders.at(i); d->device->write((const char *)&header.h, sizeof(CentralFileHeader)); d->device->write(header.file_name); d->device->write(header.extra_field); d->device->write(header.file_comment); } int dir_size = d->device->pos() - d->start_of_directory; // write end of directory EndOfDirectory eod; memset(&eod, 0, sizeof(EndOfDirectory)); writeUInt(eod.signature, 0x06054b50); //uchar this_disk[2]; //uchar start_of_directory_disk[2]; writeUShort(eod.num_dir_entries_this_disk, d->fileHeaders.size()); writeUShort(eod.num_dir_entries, d->fileHeaders.size()); writeUInt(eod.directory_size, dir_size); writeUInt(eod.dir_start_offset, d->start_of_directory); writeUShort(eod.comment_length, d->comment.length()); d->device->write((const char *)&eod, sizeof(EndOfDirectory)); d->device->write(d->comment); d->device->close(); } } #endif // QT_NO_TEXTODFWRITER diff --git a/src/lib/marble/RenderPluginInterface.h b/src/lib/marble/RenderPluginInterface.h index 6db35d026..2341336a6 100644 --- a/src/lib/marble/RenderPluginInterface.h +++ b/src/lib/marble/RenderPluginInterface.h @@ -1,73 +1,73 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2008 Torsten Rahn // Copyright 2008 Inge Wallin // #ifndef MARBLE_RENDERPLUGININTERFACE_H #define MARBLE_RENDERPLUGININTERFACE_H #include "PluginInterface.h" #include "LayerInterface.h" class QStringList; namespace Marble { class RenderPlugin; /** * @short The class that specifies the Marble layer interface of a plugin. * */ class RenderPluginInterface: public PluginInterface, public LayerInterface { public: ~RenderPluginInterface() override; virtual void initialize() = 0; virtual bool isInitialized() const = 0; /** * @brief Returns the name(s) of the backend that the plugin can render - *. + * * This method should return the name of the backend that the plugin * can render. The string has to be the same one that is given * for the attribute in the layer element of the DGML file that * backend is able to process. * Examples to replace available default backends would be "vector" or * "texture". To provide a completely new kind of functionality please * choose your own unique string. */ virtual QStringList backendTypes() const = 0; /** * @brief Return how the plugin settings should be used. * * FIXME: Document this - *. + * * Possible Values: * "ALWAYS" -- the plugin renders at the preferred position * no matter what got specified in the DGML file. * "SPECIFIED" -- renders only in case it got specified in the * DGML file. * "SPECIFIED_ALWAYS" -- In case it got specified in the DGML file * render according to the specification * otherwise choose the preferred position */ virtual QString renderPolicy() const = 0; }; } Q_DECLARE_INTERFACE( Marble::RenderPluginInterface, "org.kde.Marble.RenderPluginInterface/1.09" ) #endif diff --git a/src/lib/marble/StackedTileLoader.h b/src/lib/marble/StackedTileLoader.h index e018bdf18..224a63c90 100644 --- a/src/lib/marble/StackedTileLoader.h +++ b/src/lib/marble/StackedTileLoader.h @@ -1,149 +1,150 @@ /* * This file is part of the Marble Virtual Globe. * * Copyright 2005-2007 Torsten Rahn * Copyright 2007 Inge Wallin * Copyright 2009 Jens-Michael Hoffmann * Copyright 2010-2012 Bernhard Beschow * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MARBLE_STACKEDTILELOADER_H #define MARBLE_STACKEDTILELOADER_H #include #include "RenderState.h" class QImage; class QString; class QSize; namespace Marble { class GeoSceneAbstractTileProjection; class MergedLayerDecorator; class StackedTile; class TileId; class StackedTileLoaderPrivate; /** * @short Tile loading from a quad tree * * This class loads tiles into memory. For faster access * we keep the tileIDs and their respective pointers to * the tiles in a hashtable. * The class also contains convenience methods to remove entries * from the hashtable and to return more detailed properties * about each tile level and their tiles. * * @author Torsten Rahn **/ class StackedTileLoader : public QObject { Q_OBJECT public: /** * Creates a new tile loader. * - * @param downloadManager The download manager that shall be used to fetch - * the tiles from a remote resource. + * @param mergedLayerDecorator The decorator that shall be used to decorate + * the layer. + * @param parent The parent widget. */ explicit StackedTileLoader( MergedLayerDecorator *mergedLayerDecorator, QObject *parent = nullptr ); ~StackedTileLoader() override; int tileColumnCount( int level ) const; int tileRowCount( int level ) const; const GeoSceneAbstractTileProjection *tileProjection() const; QSize tileSize() const; /** * Loads a tile and returns it. * * @param stackedTileId The Id of the requested tile, containing the x and y coordinate * and the zoom level. */ const StackedTile* loadTile( TileId const &stackedTileId ); /** * Resets the internal tile hash. */ void resetTilehash(); /** * Cleans up the internal tile hash. * * Removes all superfluous tiles from the hash. */ void cleanupTilehash(); /** * @brief Returns the limit of the volatile (in RAM) cache. * @return the cache limit in kilobytes */ quint64 volatileCacheLimit() const; /** * @brief Reloads the tiles that are currently displayed. */ QList visibleTiles() const; /** * @brief Return the number of tiles in the cache. * @return number of tiles in cache */ int tileCount() const; /** * @brief Set the limit of the volatile (in RAM) cache. - * @param bytes The limit in kilobytes. + * @param kiloBytes The limit in kilobytes. */ void setVolatileCacheLimit( quint64 kiloBytes ); /** * Effectively triggers a reload of all tiles that are currently in use * and clears the tile cache in physical memory. */ void clear(); /** */ void updateTile(TileId const & tileId, QImage const &tileImage ); RenderState renderState() const; Q_SIGNALS: void tileLoaded( TileId const &tileId ); void cleared(); private: Q_DISABLE_COPY( StackedTileLoader ) friend class StackedTileLoaderPrivate; StackedTileLoaderPrivate* const d; }; } #endif diff --git a/src/lib/marble/StyleBuilder.h b/src/lib/marble/StyleBuilder.h index 62db6299d..0e6e43f93 100644 --- a/src/lib/marble/StyleBuilder.h +++ b/src/lib/marble/StyleBuilder.h @@ -1,104 +1,104 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2016 Dennis Nienhüser // #ifndef MARBLE_STYLEBUILDER_H #define MARBLE_STYLEBUILDER_H #include "marble_export.h" #include #include #include #include #include class QFont; class QColor; namespace Marble { class OsmPlacemarkData; class MARBLE_EXPORT StyleParameters { public: explicit StyleParameters(const GeoDataPlacemark *placemark_ = nullptr, int tileLevel = 0); const GeoDataPlacemark *placemark; int tileLevel; const GeoDataRelation *relation; }; class MARBLE_EXPORT StyleBuilder { public: typedef QPair OsmTag; StyleBuilder(); ~StyleBuilder(); /** * Return the label font of the placemark. */ QFont defaultFont() const; void setDefaultFont( const QFont& font ); QColor defaultLabelColor() const; void setDefaultLabelColor( const QColor& color ); GeoDataStyle::ConstPtr createStyle(const StyleParameters ¶meters) const; /** * @brief Returns the order in which the visual categories used in the theme shall be painted on the map. * @return order in which the visual categories shall be painted on the map */ QStringList renderOrder() const; void reset(); /** * @brief Returns the zoom level from which on the given visual category will be visible. - * @param category the visual category for which the minimum zoom level shall be returned + * @param placemark the placemark for which the minimum zoom level shall be returned * @return zoom level from which on the given visual category will be visible */ int minimumZoomLevel(const GeoDataPlacemark &placemark) const; static int minimumZoomLevel(const GeoDataPlacemark::GeoDataVisualCategory &visualCategory); static qint64 popularity(const GeoDataPlacemark* placemark); /** * @brief Returns the maximum zoom level in the theme. * @return maximum zoom level in the theme */ int maximumZoomLevel() const; static QString visualCategoryName(GeoDataPlacemark::GeoDataVisualCategory category); /** * @brief Mapping between osm key=value pairs and visual categories */ static QHash osmTagMapping(); static QStringList shopValues(); static QSet buildingTags(); static GeoDataPlacemark::GeoDataVisualCategory determineVisualCategory(const OsmPlacemarkData &osmData); private: Q_DISABLE_COPY(StyleBuilder) class Private; Private * const d; }; } #endif diff --git a/src/lib/marble/TemplateDocument.h b/src/lib/marble/TemplateDocument.h index 434424e0a..9bc6aa5e0 100644 --- a/src/lib/marble/TemplateDocument.h +++ b/src/lib/marble/TemplateDocument.h @@ -1,87 +1,87 @@ // // This file is part of the Marble Project. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2012 Illya Kovalevskyy // #ifndef MARBLE_TEMPLATEDOCUMENT_H #define MARBLE_TEMPLATEDOCUMENT_H #include class QString; namespace Marble { class TemplateDocumentPrivate; /** * @brief The Template Document * * The class represents a template engine for * Marble HTML/plain text. It allows to template big * documents with variables like %variable_name% or * to make includes like %!{include_name}% * * "Include" is a special type of template variables which * allows to include extra already templated text into the * template. E.g. %!{bootstrap}% will include bootstrap CSS * files into html file, where this include is called * * @see TemplateDocument() * */ class TemplateDocument { public: TemplateDocument(); explicit TemplateDocument(const QString &templateText); ~TemplateDocument(); /** * @brief Returns the current template value of @p key - * @param key template key (%%) + * @param key template key (\) * @return value of the template */ QString value(const QString &key) const; /** * @brief Change set template value into new one * @param key template key * @param value template value */ void setValue(const QString &key, const QString &value); /** * @brief Set template text * @param newTemplateText new template text */ void setTemplate(const QString &newTemplateText); /** * @brief Indexator for template values * @param key template value's index * @return reference for the item */ QString& operator[](const QString &key); /** * @brief Final proceed text * * @return ready text with all variables and includes processed */ QString finalText() const; private: Q_DISABLE_COPY(TemplateDocument) TemplateDocumentPrivate *d; }; } // namespace Marble #endif // MARBLE_TEMPLATEDOCUMENT_H diff --git a/src/lib/marble/geodata/data/GeoDataCoordinates.h b/src/lib/marble/geodata/data/GeoDataCoordinates.h index c59e9d78f..0c737281e 100644 --- a/src/lib/marble/geodata/data/GeoDataCoordinates.h +++ b/src/lib/marble/geodata/data/GeoDataCoordinates.h @@ -1,431 +1,431 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2006-2007 Torsten Rahn // Copyright 2007-2008 Inge Wallin // Copyright 2008 Patrick Spendrin // Copyright 2015 Alejandro Garcia Montoro // #ifndef MARBLE_GEODATACOORDINATES_H #define MARBLE_GEODATACOORDINATES_H #include #include #include #include "geodata_export.h" #include "MarbleGlobal.h" class QString; namespace Marble { class GeoDataCoordinatesPrivate; class Quaternion; /** * @short A 3d point representation * * GeoDataCoordinates is the simple representation of a single three * dimensional point. It can be used all through out marble as the data type * for three dimensional objects. it comprises of a Quaternion for speed issues. * This class was introduced to reflect the difference between a simple 3d point * and the GeoDataGeometry object containing such a point. The latter is a * GeoDataPoint and is simply derived from GeoDataCoordinates. * @see GeoDataPoint */ class GEODATA_EXPORT GeoDataCoordinates { Q_DECLARE_TR_FUNCTIONS(GeoDataCoordinates) public: /** * @brief enum used constructor to specify the units used * * Internally we always use radian for mathematical convenience. * However the Marble's interfaces to the outside should default * to degrees. */ enum Unit{ Radian, Degree }; /** * @brief enum used to specify the notation / numerical system * * For degrees there exist two notations: * "Decimal" (base-10) and the "Sexagesimal DMS" (base-60) which is * traditionally used in cartography. Decimal notation * uses floating point numbers to specify parts of a degree. The * Sexagesimal DMS notation uses integer based * Degrees-(Arc)Minutes-(Arc)Seconds to describe parts of a degree. */ enum Notation{ Decimal, ///< "Decimal" notation (base-10) DMS, ///< "Sexagesimal DMS" notation (base-60) DM, ///< "Sexagesimal DM" notation (base-60) UTM, Astro /// < "RA and DEC" notation (used for astronomical sky coordinates) }; /** * @brief The BearingType enum specifies where to measure the bearing * along great circle arcs * * When traveling along a great circle arc defined by the two points * A and B, the bearing varies along the arc. The "InitialBearing" bearing * corresponds to the bearing value at A, the "FinalBearing" bearing to that * at B. */ enum BearingType { InitialBearing, FinalBearing }; // Type definitions using Vector = QVector; using PtrVector = QVector; GeoDataCoordinates( const GeoDataCoordinates& other ); /** * @brief constructs an invalid instance * * Constructs an invalid instance such that calling isValid() * on it will return @code false @endcode. */ GeoDataCoordinates(); /** * @brief create a geocoordinate from longitude and latitude - * @param _lon longitude - * @param _lat latitude + * @param lon longitude + * @param lat latitude * @param alt altitude in meters (default: 0) - * @param _unit units that lon and lat get measured in + * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) - * @param _detail detail (default: 0) + * @param detail detail (default: 0) */ GeoDataCoordinates( qreal lon, qreal lat, qreal alt = 0, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian, int detail = 0 ); virtual ~GeoDataCoordinates(); /** * @brief Returns @code true @endcode if the coordinate is valid, @code false @endcode otherwise. * @return whether the coordinate is valid * * A coordinate is valid, if at least one component has been set and the last * assignment was not an invalid GeoDataCoordinates object. */ bool isValid() const; /** * @brief (re)set the coordinates in a GeoDataCoordinates object - * @param _lon longitude - * @param _lat latitude + * @param lon longitude + * @param lat latitude * @param alt altitude in meters (default: 0) - * @param _unit units that lon and lat get measured in + * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) */ void set( qreal lon, qreal lat, qreal alt = 0, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ); /** * @brief use this function to get the longitude and latitude with one * call - use the unit parameter to switch between Radian and DMS * @param lon longitude * @param lat latitude * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) */ void geoCoordinates(qreal& lon, qreal& lat, GeoDataCoordinates::Unit unit) const; void geoCoordinates(qreal& lon, qreal& lat) const; /** * @brief use this function to get the longitude, latitude and altitude * with one call - use the unit parameter to switch between Radian and DMS * @param lon longitude * @param lat latitude * @param alt altitude in meters * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) */ void geoCoordinates(qreal& lon, qreal& lat, qreal& alt, GeoDataCoordinates::Unit unit) const; void geoCoordinates(qreal& lon, qreal& lat, qreal& alt) const; /** * @brief set the longitude in a GeoDataCoordinates object - * @param _lon longitude - * @param _unit units that lon and lat get measured in + * @param lon longitude + * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) */ void setLongitude( qreal lon, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ); /** * @brief retrieves the longitude of the GeoDataCoordinates object * use the unit parameter to switch between Radian and DMS * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) * @return longitude */ qreal longitude(GeoDataCoordinates::Unit unit) const; qreal longitude() const; /** * @brief retrieves the latitude of the GeoDataCoordinates object * use the unit parameter to switch between Radian and DMS * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) * @return latitude */ qreal latitude( GeoDataCoordinates::Unit unit ) const; qreal latitude() const; /** * @brief set the longitude in a GeoDataCoordinates object - * @param _lat longitude - * @param _unit units that lon and lat get measured in + * @param lat longitude + * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) */ void setLatitude( qreal lat, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ); /** * @brief return the altitude of the Point in meters */ qreal altitude() const; /** * @brief set the altitude of the Point in meters * @param altitude altitude */ void setAltitude( const qreal altitude ); /** * @brief retrieves the UTM zone of the GeoDataCoordinates object. * If the point is located on one of the poles (latitude < 80S or * latitude > 84N) there is no UTM zone associated; in this case, * 0 is returned. * @return UTM zone. */ int utmZone() const; /** * @brief retrieves the UTM easting of the GeoDataCoordinates object, * in meters. * @return UTM easting */ qreal utmEasting() const; /** * @brief retrieves the UTM latitude band of the GeoDataCoordinates object * @return UTM latitude band */ QString utmLatitudeBand() const; /** * @brief retrieves the UTM northing of the GeoDataCoordinates object, * in meters * @return UTM northing */ qreal utmNorthing() const; /** * @brief return the detail flag * detail range: 0 for most important points, 5 for least important */ quint8 detail() const; /** * @brief set the detail flag - * @param det detail + * @param detail detail */ void setDetail(quint8 detail); /** * @brief Rotates one coordinate around another. * @param axis The coordinate that serves as a rotation axis * @param angle Rotation angle * @param unit Unit of the result * @return The coordinate rotated in anticlockwise direction */ GeoDataCoordinates rotateAround( const GeoDataCoordinates &axis, qreal angle, Unit unit = Radian ) const; /** * @brief Returns the bearing (true bearing, the angle between the line defined * by this point and the other and the prime meridian) * @param other The second point that, together with this point, defines a line * @param unit Unit of the result * @return The true bearing in the requested unit, not range normalized, * in clockwise direction, with the value 0 corresponding to north */ qreal bearing( const GeoDataCoordinates &other, Unit unit = Radian, BearingType type = InitialBearing ) const; /** * @brief Returns the coordinates of the resulting point after moving this point * according to the distance and bearing parameters * @param bearing the same as above * @param distance the distance on a unit sphere */ GeoDataCoordinates moveByBearing( qreal bearing, qreal distance ) const; /** * @brief return a Quaternion with the used coordinates */ const Quaternion &quaternion() const; /** * @brief slerp (spherical linear) interpolation between this coordinate and the given target coordinate * @param target Destination coordinate * @param t Fraction 0..1 to weight between this and target * @return Interpolated coordinate between this (t<=0.0) and target (t>=1.0) */ GeoDataCoordinates interpolate( const GeoDataCoordinates &target, double t ) const; /** * @brief squad (spherical and quadrangle) interpolation between b and c * @param before First base point * @param target Third base point (second interpolation point) * @param after Fourth base point * @param t Offset between b (t<=0) and c (t>=1) */ GeoDataCoordinates interpolate( const GeoDataCoordinates &before, const GeoDataCoordinates &target, const GeoDataCoordinates &after, double t ) const; /** * @brief return whether our coordinates represent a pole * This method can be used to check whether the coordinate equals one of * the poles. */ bool isPole( Pole = AnyPole ) const; /** * @brief This method calculates the shortest distance between two points on a sphere. * @brief See: http://en.wikipedia.org/wiki/Great-circle_distance */ qreal sphericalDistanceTo(const GeoDataCoordinates &other) const; /** * @brief return Notation of string representation */ static GeoDataCoordinates::Notation defaultNotation(); /** * @brief set the Notation of the string representation * @param notation Notation */ static void setDefaultNotation( GeoDataCoordinates::Notation notation ); /** * @brief normalize the longitude to always be -M_PI <= lon <= +M_PI (Radian). * @param lon longitude */ static qreal normalizeLon( qreal lon, GeoDataCoordinates::Unit = GeoDataCoordinates::Radian ); /** * @brief normalize latitude to always be in -M_PI / 2. <= lat <= +M_PI / 2 (Radian). * @param lat latitude */ static qreal normalizeLat( qreal lat, GeoDataCoordinates::Unit = GeoDataCoordinates::Radian ); /** * @brief normalize both longitude and latitude at the same time * This method normalizes both latitude and longitude, so that the * latitude and the longitude stay within the "usual" range. * NOTE: If the latitude exceeds M_PI/2 (+90.0 deg) or -M_PI/2 (-90.0 deg) * then this will be interpreted as a pole traversion where the point will * end up on the opposite side of the globe. Therefore the longitude will * change by M_PI (180 deg). * If you don't want this behaviour use both normalizeLat() and * normalizeLon() instead. * @param lon the longitude value * @param lat the latitude value */ static void normalizeLonLat( qreal &lon, qreal &lat, GeoDataCoordinates::Unit = GeoDataCoordinates::Radian ); /** * @brief try to parse the string into a coordinate pair * @param successful becomes true if the conversion succeeds * @return the geodatacoordinates */ static GeoDataCoordinates fromString( const QString &string, bool& successful ); /** * @brief return a string representation of the coordinate * this is a convenience function which uses the default notation */ QString toString() const; /** * @brief return a string with the notation given by notation * * @param notation set a notation different from the default one * @param precision set the number of digits below degrees. * The precision depends on the current notation: * For Decimal representation the precision is the number of * digits after the decimal point. * In DMS a precision of 1 or 2 shows the arc minutes; a precision * of 3 or 4 will show arc seconds. A precision beyond that will * increase the number of digits after the arc second decimal point. */ QString toString( GeoDataCoordinates::Notation notation, int precision = -1 ) const; static QString lonToString( qreal lon, GeoDataCoordinates::Notation notation, GeoDataCoordinates::Unit unit = Radian, int precision = -1, char format = 'f' ); /** * @brief return a string representation of longitude of the coordinate * convenience function that uses the default notation */ QString lonToString() const; static QString latToString( qreal lat, GeoDataCoordinates::Notation notation, GeoDataCoordinates::Unit unit = Radian, int precision = -1, char format = 'f' ); /** * @brief return a string representation of latitude of the coordinate * convenience function that uses the default notation */ QString latToString() const; bool operator==(const GeoDataCoordinates &other) const; bool operator!=(const GeoDataCoordinates &other) const; GeoDataCoordinates& operator=( const GeoDataCoordinates &other ); /** Serialize the contents of the feature to @p stream. */ void pack(QDataStream &stream) const; /** Unserialize the contents of the feature from @p stream. */ void unpack(QDataStream &stream); private: void detach(); GeoDataCoordinatesPrivate *d; static GeoDataCoordinates::Notation s_notation; static const GeoDataCoordinates null; }; GEODATA_EXPORT uint qHash(const GeoDataCoordinates& coordinates ); } Q_DECLARE_METATYPE( Marble::GeoDataCoordinates ) #endif diff --git a/src/lib/marble/geodata/data/GeoDataData.h b/src/lib/marble/geodata/data/GeoDataData.h index 2339aa123..6036df7ed 100644 --- a/src/lib/marble/geodata/data/GeoDataData.h +++ b/src/lib/marble/geodata/data/GeoDataData.h @@ -1,99 +1,99 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2010 Harshit Jain // #ifndef MARBLE_GEODATADATA_H #define MARBLE_GEODATADATA_H #include "GeoDataObject.h" #include "geodata_export.h" class QVariant; namespace Marble { class GeoDataDataPrivate; /** */ class GEODATA_EXPORT GeoDataData : public GeoDataObject { public: GeoDataData(); /** Convenience constructor that sets name and value directly */ GeoDataData( const QString &name, const QVariant &value ); GeoDataData( const GeoDataData& other ); bool operator==( const GeoDataData& other ) const; bool operator!=( const GeoDataData& other ) const; ~GeoDataData() override; /** * @brief assignment operator */ GeoDataData& operator=( const GeoDataData& other ); /// Provides type information for downcasting a GeoData const char* nodeType() const override; /** * @brief return a reference to the value of data; */ QVariant& valueRef(); const QVariant& valueRef() const; /** * @brief return the value of data */ QVariant value() const; /** * @brief set the value of data * @param value the value to be set */ void setValue( const QVariant& value ); /** * @brief return the name of data */ QString name() const; /** * @brief set the name of data * @param name the name to be set */ void setName( const QString& name ); /** * @brief return the displayName of data */ QString displayName() const; /** * @brief set the displayName of data - * @param value the displayName to be set + * @param displayName the displayName to be set */ void setDisplayName( const QString& displayName ); /// Serialize the contents of the feature to @p stream. void pack( QDataStream& stream ) const override; /// Unserialize the contents of the feature from @p stream. void unpack( QDataStream& stream ) override; private: GeoDataDataPrivate * const d; }; } #endif //MARBLE_GEODATADATA_H diff --git a/src/lib/marble/geodata/data/GeoDataDocument.h b/src/lib/marble/geodata/data/GeoDataDocument.h index eeab97e44..ce0561883 100644 --- a/src/lib/marble/geodata/data/GeoDataDocument.h +++ b/src/lib/marble/geodata/data/GeoDataDocument.h @@ -1,209 +1,209 @@ /* Copyright (C) 2007, 2008 Nikolas Zimmermann Copyright (C) 2007 Murad Tagirov Copyright (C) 2009 Patrick Spendrin This file is part of the KDE project This library is free software you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License aint with this library see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MARBLE_GEODATADOCUMENT_H #define MARBLE_GEODATADOCUMENT_H #include #include "geodata_export.h" #include "GeoDataContainer.h" #include "GeoDocument.h" #include "GeoDataStyle.h" namespace Marble { enum DocumentRole { UnknownDocument, MapDocument, UserDocument, TrackingDocument, BookmarkDocument, SearchResultDocument }; class GeoDataStyleMap; class GeoDataNetworkLinkControl; class GeoDataSchema; class GeoDataDocumentPrivate; /** * @short A container for Features, Styles and in the future Schemas. * * A GeoDataDocument is a container for features, styles, and * schemas. This element is required if your KML file uses schemas or * shared styles. It is recommended that all Styles be defined in a * Document, each with an id, and then later referenced by a * styleUrl for a given Feature or StyleMap. */ class GEODATA_EXPORT GeoDataDocument : public GeoDocument, public GeoDataContainer { public: GeoDataDocument(); GeoDataDocument( const GeoDataDocument& other ); ~GeoDataDocument() override; GeoDataDocument& operator=(const GeoDataDocument& other); bool operator==( const GeoDataDocument &other ) const; bool operator!=( const GeoDataDocument &other ) const; const char* nodeType() const override; GeoDataFeature * clone() const override; /// Provides type information for downcasting a GeoData bool isGeoDataDocument() const override { return true; } DocumentRole documentRole() const; void setDocumentRole( DocumentRole role ); QString property() const; void setProperty( const QString& property ); /** * @brief The filename of the document * * The filename of the document is used internally to identify the files. * it should never be empty as this could lead to potential collisions. * * @return The filename of this document */ QString fileName() const; /** * @brief Set a new file name for this document * @param value the new name */ void setFileName( const QString &value ); /** * @brief The URI relative paths should be resolved against */ QString baseUri() const; /** * @brief Change the URI for resolving relative paths. * See http://tools.ietf.org/html/rfc3986#section-5 */ void setBaseUri( const QString &baseUri ); /** * @brief the NetworkLinkControl of the file */ GeoDataNetworkLinkControl networkLinkControl() const; /** * @brief set the NetworkLinkControl of the file */ void setNetworkLinkControl( const GeoDataNetworkLinkControl &networkLinkControl ); /** * @brief Add a style to the style storage * @param style the new style */ void addStyle(const GeoDataStyle::Ptr &style); /** * @brief Add a style to the style storage - * @param style the new style + * @param styleId the new style */ void removeStyle( const QString& styleId ); /** * @brief Return a style in the style storage * @param styleId the id of the style */ GeoDataStyle::Ptr style( const QString& styleId ); GeoDataStyle::ConstPtr style( const QString& styleId ) const; /** * @brief dump a Vector of all styles */ QList styles(); QList styles() const; /** * @brief Add a stylemap to the stylemap storage * @param map the new stylemap */ void addStyleMap( const GeoDataStyleMap& map ); /** * @brief remove stylemap from storage * @param mapId the styleId of the styleMap to be removed */ void removeStyleMap( const QString& mapId ); /** * @brief Return a style in the style storage * @param styleId the id of the style */ GeoDataStyleMap& styleMap( const QString& styleId ); GeoDataStyleMap styleMap( const QString& styleId ) const; /** * @brief dump a Vector of all stylemaps */ QList styleMaps() const; /** * @brief Add a schema to simplemap storage * @param schema the new schema */ void addSchema( const GeoDataSchema& schema ); /** * @brief remove a schema from schema storage * @param schemaId the of schema to be removed */ void removeSchema( const QString& schemaId ); /** * @brief Returns a schema with id = schemaId form schema storage * @param schemaId The id of schema to be returned */ GeoDataSchema schema( const QString& schemaId ) const; GeoDataSchema &schema( const QString& schemaId ); /** * @brief dump a vector of all schemas */ QList schemas() const; // Serialize the Placemark to @p stream void pack( QDataStream& stream ) const override; // Unserialize the Placemark from @p stream void unpack( QDataStream& stream ) override; private: Q_DECLARE_PRIVATE(GeoDataDocument) }; } Q_DECLARE_METATYPE(Marble::GeoDataDocument*) #endif diff --git a/src/lib/marble/geodata/data/GeoDataExtendedData.h b/src/lib/marble/geodata/data/GeoDataExtendedData.h index e03590a19..8db500246 100644 --- a/src/lib/marble/geodata/data/GeoDataExtendedData.h +++ b/src/lib/marble/geodata/data/GeoDataExtendedData.h @@ -1,149 +1,149 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2010 Harshit Jain // Copyright 2011 Niko Sams // #ifndef MARBLE_GEODATAEXTENDEDDATA_H #define MARBLE_GEODATAEXTENDEDDATA_H #include "GeoDataObject.h" #include "geodata_export.h" #include namespace Marble { class GeoDataSimpleArrayData; class GeoDataSchemaData; class GeoDataData; class GeoDataExtendedDataPrivate; /** * @short a class which allows to add custom data to KML Feature. * - * @See GeoDataData + * @see GeoDataData */ class GEODATA_EXPORT GeoDataExtendedData : public GeoDataObject { public: GeoDataExtendedData(); GeoDataExtendedData( const GeoDataExtendedData& other ); ~GeoDataExtendedData() override; /// Provides type information for downcasting a GeoNode const char* nodeType() const override; /** * @brief assignment operator */ GeoDataExtendedData& operator=( const GeoDataExtendedData& other ); bool operator==( const GeoDataExtendedData& other ) const; bool operator!=( const GeoDataExtendedData& other ) const; /** * @brief return the value of GeoDataExtendedData associated with the given @p key */ GeoDataData value( const QString& key ) const; /** * @brief add a data object to the GeoDataExtendedData with the @p key */ void addValue( const GeoDataData& data ); /** * @since 0.26.0 */ void removeKey(const QString &key); /** * @brief return const Begin iterator for QHash */ QHash< QString, GeoDataData >::const_iterator constBegin( ) const; /** * @brief return const End iterator for QHash */ QHash< QString, GeoDataData >::const_iterator constEnd( ) const; /** * @brief return size of QHash */ int size( ) const; /** * @brief return whether QHash is empty or not */ bool isEmpty( ) const; /** * @brief Returns true if there exists a value for the given key */ bool contains( const QString &key ) const; /** * @brief return value of GeoDataExtendedData object associated with the given @p key as a modifiable reference */ GeoDataData& valueRef( const QString& key ) const; /** * @brief set SimpleArrayData for given @p key * * ExtendedData takes ownership of SimpleArrayData */ void setSimpleArrayData( const QString& key, GeoDataSimpleArrayData* values ); /** * @brief return SimpleArrayData for given @p key, 0 pointer if none is set */ GeoDataSimpleArrayData* simpleArrayData( const QString& key ) const; /** * @brief Adds a SchemaData @p schemaData element to schemaDataHash */ GeoDataSchemaData& schemaData( const QString& schemaUrl ) const; /** * @brief Adds a SchemaData @p schemaData element to schemaDataHash */ void addSchemaData( const GeoDataSchemaData& schemaData ); /** * @brief Removes a SchemaData element with schema url @p schemaUrl from schemaDataHash */ void removeSchemaData( const QString& schemaUrl ); /** * @brief Dump a vector containing all SchemaData element */ QList< GeoDataSchemaData > schemaDataList() const; /** * @brief Serialize the ExtendedData to a stream * @param stream the stream */ void pack( QDataStream& stream ) const override; /** * @brief Unserialize the ExtendedData from a stream * @param stream the stream */ void unpack( QDataStream& stream ) override; private: GeoDataExtendedDataPrivate * const d; }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataFeature.h b/src/lib/marble/geodata/data/GeoDataFeature.h index 3c0af48b8..cdb7b9d92 100644 --- a/src/lib/marble/geodata/data/GeoDataFeature.h +++ b/src/lib/marble/geodata/data/GeoDataFeature.h @@ -1,286 +1,286 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2007 Murad Tagirov // Copyright 2009 Patrick Spendrin // #ifndef MARBLE_GEODATAFEATURE_H #define MARBLE_GEODATAFEATURE_H #include "GeoDataObject.h" #include "geodata_export.h" namespace Marble { // forward define all features we can find. class GeoDataRegion; class GeoDataAbstractView; class GeoDataStyle; class GeoDataStyleMap; class GeoDataExtendedData; class GeoDataTimeSpan; class GeoDataTimeStamp; class GeoDataFeaturePrivate; class GeoDataSnippet; /** * @short A base class for all geodata features * * GeoDataFeature is the base class for most geodata classes that * correspond to places on a map. It is never instantiated by itself, * but is always used as part of a derived class. * * @see GeoDataPlacemark * @see GeoDataContainer */ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject { public: GeoDataFeature(); /// Create a new GeoDataFeature with @p name as its name. explicit GeoDataFeature( const QString& name ); GeoDataFeature( const GeoDataFeature& other ); ~GeoDataFeature() override; GeoDataFeature& operator=( const GeoDataFeature& other ); bool operator==(const GeoDataFeature &other) const; inline bool operator!=(const GeoDataFeature &other) const { return !(*this == other); } EnumFeatureId featureId() const; /** * @brief The name of the feature * * The name of the feature should be a short string. It is often * shown directly on the map and need therefore not take up much * space. * * @return The name of this feature */ QString name() const; /** * @brief Set a new name for this feature * @param value the new name */ void setName( const QString &value ); /** * @brief A short description of the feature. * * HTML markup is not supported. - * @TODO When the Snippet is not supplied, the first lines of description should be used. + * @todo When the Snippet is not supplied, the first lines of description should be used. * @return The name of this feature */ GeoDataSnippet snippet() const; /** * @brief Set a new name for this feature * @param value the new name */ void setSnippet( const GeoDataSnippet &value ); /// Return the address of the feature QString address() const; /// Set the address of this feature to @p value. void setAddress( const QString &value); /// Return the phone number of the feature QString phoneNumber() const; /// Set the phone number of this feature to @p value. void setPhoneNumber( const QString &value ); /// Return the text description of the feature. QString description() const; /// Set the description of this feature to @p value. void setDescription( const QString &value ); /** * @brief test if the description is CDATA or not * CDATA allows for special characters to be included in XML and also allows * for other XML formats to be embedded in the XML without interfering with * parser namespace. - * @return @true if the description should be treated as CDATA - * @false if the description is a plain string + * @return @c true if the description should be treated as CDATA + * @c false if the description is a plain string */ bool descriptionIsCDATA() const; /// Set the description to be CDATA See: @see descriptionIsCDATA() void setDescriptionCDATA( bool cdata ); /// Get the Abstract view of the feature const GeoDataAbstractView *abstractView() const; GeoDataAbstractView *abstractView(); /// Set the abstract view of the feature void setAbstractView( GeoDataAbstractView *abstractView ); /// Return the styleUrl of the feature. QString styleUrl() const; /// Set the styleUrl of this feature to @p value. void setStyleUrl( const QString &value ); /// Return whether this feature is visible or not bool isVisible() const; /// Return whether this feature is visible or not in the context of its parenting bool isGloballyVisible() const; /** * @brief Set a new value for visibility * @param value new value for the visibility * * This function sets the visibility, i.e. whether this feature * should be shown or not. This can be changed either from a GUI * or through some action of the program. */ void setVisible( bool value ); /** * Return the timespan of the feature. */ const GeoDataTimeSpan& timeSpan() const; GeoDataTimeSpan& timeSpan(); /** * Set the timespan of the feature. * @param timeSpan new of timespan. */ void setTimeSpan( const GeoDataTimeSpan &timeSpan ); /** * Return the timestamp of the feature. */ const GeoDataTimeStamp& timeStamp() const; GeoDataTimeStamp& timeStamp(); /** * Set the timestamp of the feature. * @param timeStamp new of the timestamp. */ void setTimeStamp( const GeoDataTimeStamp &timeStamp ); /** * Return the style assigned to the placemark, or a default style if none has been set */ QSharedPointer style() const; /** * Return the style assigned to the placemark with setStyle (can be 0) */ QSharedPointer customStyle() const; /** * Sets the style of the placemark. * @param style the new style to be used. */ void setStyle( const QSharedPointer &style ); /** * Return the ExtendedData assigned to the feature. */ GeoDataExtendedData& extendedData(); const GeoDataExtendedData& extendedData() const; /** * Sets the ExtendedData of the feature. * @param extendedData the new ExtendedData to be used. */ void setExtendedData( const GeoDataExtendedData& extendedData ); /** * Return the region assigned to the placemark. */ const GeoDataRegion& region() const; GeoDataRegion& region(); /** * @brief Sets the region of the placemark. * @param region new value for the region * * The feature is only shown when the region if active. */ void setRegion( const GeoDataRegion& region ); /** * Return the role of the placemark. * * FIXME: describe roles here! */ const QString role() const; /** * Sets the role of the placemark. * @param role the new role to be used. */ void setRole( const QString &role ); /** * @brief Return the popularity index of the placemark. * * The popularity index is a value which describes at which zoom * level the placemark will be shown. */ int zoomLevel() const; /** * Sets the popularity @p index of the placemark. * @param index the new index to be used. */ void setZoomLevel( int index ); /** * Return the popularity of the feature. */ qint64 popularity() const; /** * Sets the @p popularity of the feature. * @param popularity the new popularity value */ void setPopularity( qint64 popularity ); /** * Return a pointer to a GeoDataStyleMap object which represents the styleMap * of this feature. A styleMap is simply a QMap which can connect * two styles with a keyword. This can be used to have a highlighted and a * normal style. * @see GeoDataStyleMap */ const GeoDataStyleMap* styleMap() const; /** * Sets the styleMap of the feature */ void setStyleMap( const GeoDataStyleMap* map ); /// Duplicate into another equal instance virtual GeoDataFeature * clone() const = 0; /// Serialize the contents of the feature to @p stream. void pack( QDataStream& stream ) const override; /// Unserialize the contents of the feature from @p stream. void unpack( QDataStream& stream ) override; protected: // the d-pointer needs to be protected to be accessible from derived classes GeoDataFeaturePrivate* const d_ptr; explicit GeoDataFeature(GeoDataFeaturePrivate* dd); GeoDataFeature(const GeoDataFeature& other, GeoDataFeaturePrivate* dd); bool equals( const GeoDataFeature &other ) const; using GeoDataObject::equals; private: Q_DECLARE_PRIVATE(GeoDataFeature) }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataIconStyle.h b/src/lib/marble/geodata/data/GeoDataIconStyle.h index 7f88357c6..99f7cde2c 100644 --- a/src/lib/marble/geodata/data/GeoDataIconStyle.h +++ b/src/lib/marble/geodata/data/GeoDataIconStyle.h @@ -1,108 +1,108 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2007 Murad Tagirov // Copyright 2007 Inge Wallin // #ifndef MARBLE_GEODATAICONSTYLE_H #define MARBLE_GEODATAICONSTYLE_H #include "GeoDataColorStyle.h" #include "GeoDataHotSpot.h" #include "geodata_export.h" #include namespace Marble { class GeoDataIconStylePrivate; class RemoteIconLoader; // Limits for the user in case of scaling the icon too much static const QSize s_maximumIconSize = QSize( 100, 100 ); static const QSize s_minimumIconSize = QSize( 10, 10 ); /** */ class GEODATA_EXPORT GeoDataIconStyle : public GeoDataColorStyle { public: GeoDataIconStyle(); GeoDataIconStyle( const GeoDataIconStyle& other ); explicit GeoDataIconStyle( const QString& iconPath, const QPointF &hotSpot = QPointF( 0.5, 0.5 ) ); ~GeoDataIconStyle() override; GeoDataIconStyle& operator=( const GeoDataIconStyle& other ); bool operator==( const GeoDataIconStyle &other ) const; bool operator!=( const GeoDataIconStyle &other ) const; /// Provides type information for downcasting a GeoData const char* nodeType() const override; void setIcon( const QImage& icon ); QImage icon() const; /** * @brief Returns a scaled version of label icon * @return the scaled icon */ QImage scaledIcon() const; /** * @brief setIconPath Set the path to load the icon from. Any existing icon is invalidated. * @param filename Path to the icon to load. Can also be a virtual file system like qrc:/ */ void setIconPath( const QString& filename ); QString iconPath() const; void setHotSpot( const QPointF& hotSpot, GeoDataHotSpot::Units xunits, GeoDataHotSpot::Units yunits ); QPointF hotSpot( GeoDataHotSpot::Units& xunits, GeoDataHotSpot::Units& yunits ) const; /** * @brief setSize Change the size of @see icon(). A null size (0, 0) is treated as a request to keep * the original icon size. Otherwise the icon will be scaled to the given size. This is especially useful * for vector graphics like .svg or to keep the memory footprint low when loading large images. - * @param size Size in pixel that @see icon() should have. When the icon was previously set by @setIcon, + * @param size Size in pixel that @see icon() should have. When the icon was previously set by #setIcon, * it is resized unless a null size is passed. Otherwise icon() will be scaled to the given size. */ void setSize(const QSize &size, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio); /** * @brief size Returns the size @see icon() will have if it can be loaded from @see iconPath. * A null size (default) is returned to indicate that the original size of the icon is used. * @return size specified by @see setSize */ QSize size() const; void setScale(float scale); float scale() const; int heading() const; void setHeading( int heading ); RemoteIconLoader *remoteIconLoader() const; /* * Serializable methods */ void pack( QDataStream& stream ) const override; void unpack( QDataStream& stream ) override; private: GeoDataIconStylePrivate * const d; }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataLabelStyle.h b/src/lib/marble/geodata/data/GeoDataLabelStyle.h index b2e14952f..cc2c382f0 100644 --- a/src/lib/marble/geodata/data/GeoDataLabelStyle.h +++ b/src/lib/marble/geodata/data/GeoDataLabelStyle.h @@ -1,132 +1,132 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2007 Murad Tagirov // Copyright 2007 Inge Wallin // #ifndef MARBLE_GEODATALABELSTYLE_H #define MARBLE_GEODATALABELSTYLE_H #include "GeoDataColorStyle.h" #include "geodata_export.h" class QFont; namespace Marble { class GeoDataLabelStylePrivate; /** * @short specifies how the name of a GeoDataFeature is drawn * * A GeoDataLabelStyle specifies how the name of a * GeoDataFeature is drawn in the viewer. A custom color, color mode * (both inherited from GeoDataColorStyle, and scale for the label * (name) can be specified. */ class GEODATA_EXPORT GeoDataLabelStyle : public GeoDataColorStyle { public: enum Alignment{Corner, Center, Right /*, Left, Below */}; /// Construct a new GeoDataLabelStyle GeoDataLabelStyle(); GeoDataLabelStyle( const GeoDataLabelStyle& other ); /** * @brief Construct a new GeoDataLabelStyle * @param font the font to use when showing the name * @param color the color to use when showing the name @see GeoDataColorStyle */ GeoDataLabelStyle( const QFont &font, const QColor &color ); ~GeoDataLabelStyle() override; /** * @brief assignment operator */ GeoDataLabelStyle& operator=( const GeoDataLabelStyle& other ); bool operator==( const GeoDataLabelStyle &other ) const; bool operator!=( const GeoDataLabelStyle &other ) const; /// Provides type information for downcasting a GeoData const char* nodeType() const override; /** * @brief Set the scale of the label * @param scale the new scale */ void setScale(float scale); /** * @brief Return the current scale of the label * @return the current scale */ float scale() const; /** * @brief Set the alignment of the label - * @param int the alignment + * @param alignment the alignment */ void setAlignment ( GeoDataLabelStyle::Alignment alignment ); /** * @brief Return the alignment of the label * @return the current alignment */ GeoDataLabelStyle::Alignment alignment() const; /** * @brief Set the font of the label * @param font the new font */ void setFont( const QFont &font ); /** * @brief Return the current font of the label * @return the current font */ QFont font() const; /** * @brief Return the scaled font of the label * @return the scaled font */ QFont scaledFont() const; /** * @brief Return true if the text of the label should glow, false otherwise * @see setGlow */ bool glow() const; /** * @brief Enable or disable a glow effect around the text of the label. * * The default is false. * * Note that this is not a KML property. */ void setGlow( bool on ); /** * @brief Serialize the style to a stream. * @param stream the stream */ void pack( QDataStream& stream ) const override; /** * @brief Unserialize the style from a stream * @param stream the stream */ void unpack( QDataStream& stream ) override; private: GeoDataLabelStylePrivate * const d; }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataLineStyle.h b/src/lib/marble/geodata/data/GeoDataLineStyle.h index cb3612d60..dbd8d75c5 100644 --- a/src/lib/marble/geodata/data/GeoDataLineStyle.h +++ b/src/lib/marble/geodata/data/GeoDataLineStyle.h @@ -1,156 +1,156 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2008 Patrick Spendrin // #ifndef MARBLE_GEODATALINESTYLE_H #define MARBLE_GEODATALINESTYLE_H #include #include "GeoDataColorStyle.h" #include "geodata_export.h" namespace Marble { class GeoDataLineStylePrivate; /** * @short specifies the style how lines are drawn * * A GeoDataLineStyle specifies how the name of a * GeoDataFeature is drawn in the viewer. A custom color, color mode * (both inherited from GeoDataColorStyle) and width for the width * of the line. */ class GEODATA_EXPORT GeoDataLineStyle : public GeoDataColorStyle { public: /// Construct a new GeoDataLineStyle GeoDataLineStyle(); GeoDataLineStyle( const GeoDataLineStyle& other ); /** * @brief Construct a new GeoDataLineStyle * @param color the color to use when showing the name @see GeoDataColorStyle */ explicit GeoDataLineStyle( const QColor &color ); ~GeoDataLineStyle() override; /** * @brief assignment operator */ GeoDataLineStyle& operator=( const GeoDataLineStyle& other ); bool operator==( const GeoDataLineStyle &other ) const; bool operator!=( const GeoDataLineStyle &other ) const; /// Provides type information for downcasting a GeoData const char* nodeType() const override; /** * @brief Set the width of the line * @param width the new width */ void setWidth(float width); /** * @brief Return the current width of the line * @return the current width */ float width() const; /** * @brief Set the physical width of the line (in meters) - * @param width the new width + * @param realWidth the new width */ void setPhysicalWidth(float realWidth); /** * @brief Return the current physical width of the line * @return the current width */ float physicalWidth() const; /** * @brief Set whether the line has a cosmetic 1 pixel outline */ void setCosmeticOutline( bool enabled ); /** * @brief Return whether the line has a cosmetic 1 pixel outline */ bool cosmeticOutline() const; /** * @brief Set pen cap style * @param style cap style */ void setCapStyle( Qt::PenCapStyle style ); /** * @brief Return the current pen cap style * @return the current pen cap style */ Qt::PenCapStyle capStyle() const; /** * @brief Set pen cap style * @param style cap style */ void setPenStyle( Qt::PenStyle style ); /** * @brief Return the current pen cap style * @return the current pen cap style */ Qt::PenStyle penStyle() const; /** * @brief Set whether to draw the solid background * @param bool */ void setBackground( bool background ); /** * @brief Return true if background get drawn * @return */ bool background() const; /** * @brief Sets the dash pattern * @param pattern dash pattern */ void setDashPattern( const QVector& pattern ); /** * @brief Return the current dash pattern * @return the current dash pattern */ QVector dashPattern() const; /** * @brief Serialize the style to a stream. * @param stream the stream */ void pack( QDataStream& stream ) const override; /** * @brief Unserialize the style from a stream * @param stream the stream */ void unpack( QDataStream& stream ) override; private: GeoDataLineStylePrivate * const d; }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataLookAt.h b/src/lib/marble/geodata/data/GeoDataLookAt.h index 1f752219a..1cc521b64 100644 --- a/src/lib/marble/geodata/data/GeoDataLookAt.h +++ b/src/lib/marble/geodata/data/GeoDataLookAt.h @@ -1,124 +1,124 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2009 Gaurav Gupta <1989.gaurav@googlemail.com> // Copyright 2010 Bastian Holst // #ifndef MARBLE_GEODATALOOKAT_H #define MARBLE_GEODATALOOKAT_H #include "geodata_export.h" #include "GeoDataAbstractView.h" #include "GeoDataCoordinates.h" namespace Marble { class GeoDataLookAtPrivate; /** */ class GEODATA_EXPORT GeoDataLookAt : public GeoDataAbstractView { public: GeoDataLookAt(); GeoDataLookAt(const GeoDataLookAt& other); GeoDataLookAt& operator=(const GeoDataLookAt &other); bool operator==(const GeoDataLookAt &other) const; bool operator!=(const GeoDataLookAt &other) const; ~GeoDataLookAt() override; GeoDataAbstractView *copy() const override; /** * @brief set the altitude in a GeoDataLookAt object * @param altitude latitude * */ void setAltitude( qreal altitude); /** * @brief retrieves the altitude of the GeoDataLookAt object * @return latitude */ qreal altitude( ) const; /** * @brief set the latitude in a GeoDataLookAt object * @param latitude latitude * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) */ void setLatitude( qreal latitude,GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ); /** * @brief retrieves the latitude of the GeoDataLookAt object * use the unit parameter to switch between Radian and DMS * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) * @return latitude */ qreal latitude( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const; /** * @brief set the longitude in a GeoDataLookAt object * @param longitude longitude * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) */ void setLongitude( qreal longitude,GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ); /** * @brief retrieves the longitude of the GeoDataLookAt object * use the unit parameter to switch between Radian and DMS * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) * @return latitude */ qreal longitude( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const; /** * @brief retrieve the lat/lon/alt triple as a GeoDataCoordinates object * @return GeoDataCoordinates * @see longitude latitude altitude */ GeoDataCoordinates coordinates() const; /** * @brief Change the distance (in meters) between the camera and the object looked at * @see range */ void setRange( qreal range ); /** * @brief Retrieve the distance (in meters) between the camera and the object looked at * @see setRange */ qreal range() const; /** * @brief set the GeoDataCoordinates object - * @param GeoDataCoordinates + * @param coordinates GeoDataCoordinates * @see GeoDataCoordinates */ void setCoordinates( const GeoDataCoordinates& coordinates ); /// Provides type information for downcasting a GeoNode const char* nodeType() const override; void detach(); private: GeoDataLookAtPrivate *d; }; } Q_DECLARE_METATYPE( Marble::GeoDataLookAt ) #endif diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.h b/src/lib/marble/geodata/data/GeoDataPlacemark.h index fc9abb560..f97cdf753 100644 --- a/src/lib/marble/geodata/data/GeoDataPlacemark.h +++ b/src/lib/marble/geodata/data/GeoDataPlacemark.h @@ -1,713 +1,713 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2006-2007 Torsten Rahn // Copyright 2007 Inge Wallin // Copyright 2008-2009 Patrick Spendrin // #ifndef MARBLE_GEODATAPLACEMARK_H #define MARBLE_GEODATAPLACEMARK_H #include #include "GeoDataCoordinates.h" #include "GeoDataFeature.h" #include "geodata_export.h" class QXmlStreamWriter; namespace Marble { class GeoDataPlacemarkPrivate; class OsmPlacemarkData; class GeoDataLookAt; class GeoDataPolygon; class GeoDataGeometry; /** * @short a class representing a point of interest on the map * * This class represents a point of interest, e.g. a city or a * mountain. It is filled with data by the KML or GPX loader and the * PlacemarkModel makes use of it. * * A Placemark can have an associated geometry which will be rendered to the map * along with the placemark's point icon. If you would like to render more than * one geometry for any one placemark than use @see setGeometry() to set add a * @see MultiGeometry. * * This is more or less only a GeoDataFeature with a geographic * position and a country code attached to it. The country code is * not provided in a KML file. */ class GEODATA_EXPORT GeoDataPlacemark: public GeoDataFeature { public: /** * Create a new placemark. */ GeoDataPlacemark(); /** * Create a new placemark from existing placemark @p placemark */ GeoDataPlacemark( const GeoDataPlacemark& placemark ); /** * Create a new placemark with the given @p name. */ explicit GeoDataPlacemark( const QString &name ); /** * Delete the placemark */ ~GeoDataPlacemark() override; GeoDataPlacemark &operator=( const GeoDataPlacemark &other ); /** * Equality operators. */ bool operator==( const GeoDataPlacemark& other ) const; bool operator!=( const GeoDataPlacemark& other ) const; const char* nodeType() const override; GeoDataFeature * clone() const override; /** * @brief A categorization of a placemark as defined by ...FIXME. * There is an additional osm tag mapping to GeoDataVisualCategory * in OsmPlacemarkData */ enum GeoDataVisualCategory { None, Default, Unknown, // The order of the cities needs to stay fixed as the // algorithms rely on that. SmallCity, SmallCountyCapital, SmallStateCapital, SmallNationCapital, MediumCity, MediumCountyCapital, MediumStateCapital, MediumNationCapital, BigCity, BigCountyCapital, BigStateCapital, BigNationCapital, LargeCity, LargeCountyCapital, LargeStateCapital, LargeNationCapital, Nation, // Terrain Mountain, Volcano, Mons, // m Valley, // v Continent, Ocean, OtherTerrain, // o // Space Terrain Crater, // c Mare, // a // Places of Interest GeographicPole, MagneticPole, ShipWreck, AirPort, Observatory, // Military MilitaryDangerArea, // Runners OsmSite, Coordinate, // Planets MannedLandingSite, // h RoboticRover, // r UnmannedSoftLandingSite, // u UnmannedHardLandingSite, // i Bookmark, Satellite, /* * Start of OpenStreetMap categories */ PlaceCity, // please keep order (used in for loops) PlaceCityCapital, PlaceCityNationalCapital, PlaceSuburb, PlaceHamlet, PlaceLocality, PlaceTown, PlaceTownCapital, PlaceTownNationalCapital, PlaceVillage, PlaceVillageCapital, PlaceVillageNationalCapital, // please keep order (used in for loops) NaturalWater, NaturalReef, NaturalWood, NaturalBeach, NaturalWetland, NaturalGlacier, NaturalIceShelf, NaturalScrub, NaturalCliff, NaturalHeath, HighwayTrafficSignals, HighwayElevator, // OpenStreetMap highways HighwaySteps, // please keep order (used in for loops) HighwayUnknown, HighwayPath, HighwayFootway, HighwayTrack, HighwayPedestrian, HighwayCorridor, HighwayCycleway, HighwayService, HighwayRoad, HighwayResidential, HighwayLivingStreet, HighwayUnclassified, HighwayTertiaryLink, HighwayTertiary, HighwaySecondaryLink, HighwaySecondary, HighwayPrimaryLink, HighwayPrimary, HighwayRaceway, HighwayTrunkLink, HighwayTrunk, HighwayMotorwayLink, HighwayMotorway, // please keep order (used in for loops) //OSM building Building, // OpenStreetMap category Accommodation AccomodationCamping, AccomodationHostel, AccomodationHotel, AccomodationMotel, AccomodationYouthHostel, AccomodationGuestHouse, // OpenStreetMap category Education EducationCollege, EducationSchool, EducationUniversity, // OpenStreetMap category Food FoodBar, FoodBiergarten, FoodCafe, FoodFastFood, FoodPub, FoodRestaurant, // OpenStreetMap category Health HealthDentist, HealthDoctors, HealthHospital, HealthPharmacy, HealthVeterinary, // OpenStreetMap category Money MoneyAtm, MoneyBank, // OpenStreetMap category Amenity AmenityLibrary, AmenityKindergarten, ///< @since 0.26.0 AmenityEmbassy, AmenityEmergencyPhone, AmenityMountainRescue, AmenityCommunityCentre, AmenityCinema, AmenityFountain, AmenityNightClub, AmenityBench, AmenityCourtHouse, AmenityFireStation, AmenityHuntingStand, AmenityPolice, AmenityPostBox, AmenityPostOffice, AmenityPrison, AmenityRecycling, AmenityShelter, ///< @since 0.26.0 AmenityTelephone, AmenityTheatre, AmenityToilets, AmenityTownHall, AmenityWasteBasket, AmenityDrinkingWater, AmenityGraveyard, AmenityChargingStation, AmenityCarWash, AmenitySocialFacility, // OpenStreetMap category Barrier BarrierCityWall, BarrierGate, BarrierLiftGate, BarrierWall, NaturalPeak, NaturalVolcano, NaturalTree, NaturalCave, // OpenStreetMap category Shopping ShopBeverages, // please keep order (used in for loops) ShopHifi, ShopSupermarket, ShopAlcohol, ShopBakery, ShopButcher, ShopConfectionery, ShopConvenience, ShopGreengrocer, ShopSeafood, ShopDepartmentStore, ShopKiosk, ShopBag, ShopClothes, ShopFashion, ShopJewelry, ShopShoes, ShopVarietyStore, ShopBeauty, ShopChemist, ShopCosmetics, ShopHairdresser, ShopOptician, ShopPerfumery, ShopDoitYourself, ShopFlorist, ShopHardware, ShopFurniture, ShopElectronics, ShopMobilePhone, ShopBicycle, ShopCar, ShopCarRepair, ShopCarParts, ShopMotorcycle, ShopOutdoor, ShopSports, ShopCopy, ShopArt, ShopMusicalInstrument, ShopPhoto, ShopBook, ShopGift, ShopStationery, ShopLaundry, ShopPet, ShopToys, ShopTravelAgency, ShopDeli, ShopTobacco, ShopTea, ShopComputer, ShopGardenCentre, Shop, // please keep order (used in for loops) ManmadeBridge, ManmadeLighthouse, ManmadePier, ManmadeWaterTower, ManmadeWindMill, ManmadeCommunicationsTower, // OpenStreetMap category Tourist TourismArtwork, TourismAttraction, TourismInformation, TourismMuseum, TourismThemePark, TourismViewPoint, TourismZoo, TourismAlpineHut, TourismWildernessHut, // OpenStreetMap category Historic HistoricArchaeologicalSite, HistoricCastle, HistoricMemorial, HistoricMonument, HistoricRuins, // OpenStreetMap category Transport TransportAerodrome, TransportHelipad, TransportAirportTerminal, TransportAirportGate, ///< @since 0.26.0 TransportAirportRunway, ///< @since 0.26.0 TransportAirportTaxiway, ///< @since 0.26.0 TransportAirportApron, ///< @since 0.26.0 TransportBusStation, TransportBusStop, TransportCarShare, TransportFuel, TransportParking, TransportParkingSpace, TransportPlatform, TransportRentalBicycle, TransportRentalCar, TransportRentalSki, TransportTaxiRank, TransportTrainStation, TransportTramStop, TransportBicycleParking, TransportMotorcycleParking, TransportSubwayEntrance, TransportSpeedCamera, // OpenStreetMap category religion ReligionPlaceOfWorship, ReligionBahai, ReligionBuddhist, ReligionChristian, ReligionMuslim, ReligionHindu, ReligionJain, ReligionJewish, ReligionShinto, ReligionSikh, ReligionTaoist, // OpenStreetMap category Leisure LeisureGolfCourse, LeisureMarina, ///< @since 0.26.0 LeisureWaterPark, LeisurePark, LeisurePlayground, LeisurePitch, LeisureSportsCentre, LeisureStadium, LeisureTrack, LeisureSwimmingPool, LeisureMinigolfCourse, LanduseAllotments, LanduseBasin, LanduseCemetery, LanduseCommercial, LanduseConstruction, LanduseFarmland, LanduseFarmyard, LanduseGarages, LanduseGrass, LanduseIndustrial, LanduseLandfill, LanduseMeadow, LanduseMilitary, LanduseQuarry, LanduseRailway, LanduseReservoir, LanduseResidential, LanduseRetail, LanduseOrchard, LanduseVineyard, RailwayRail, // please keep order (used in for loops) RailwayNarrowGauge, RailwayTram, RailwayLightRail, RailwayAbandoned, RailwaySubway, RailwayPreserved, RailwayMiniature, RailwayConstruction, RailwayMonorail, RailwayFunicular, // please keep order (used in for loops) // OpenStreetMap category Power PowerTower, // OpenStreetMap category Aerialway AerialwayStation, AerialwayPylon, // node only // below please keep order (used in for loops) AerialwayCableCar, AerialwayGondola, AerialwayChairLift, AerialwayMixedLift, AerialwayDragLift, AerialwayTBar, AerialwayJBar, AerialwayPlatter, AerialwayRopeTow, AerialwayMagicCarpet, AerialwayZipLine, AerialwayGoods, // please keep order (used in for loops) // OpenStreetMap category Piste PisteDownhill, PisteNordic, PisteSkitour, PisteSled, PisteHike, PisteSleigh, PisteIceSkate, PisteSnowPark, PistePlayground, PisteSkiJump, // Waterways WaterwayCanal, // please keep order (used in for loops) WaterwayDitch, WaterwayDrain, WaterwayRiver, WaterwayWeir, WaterwayStream, // please keep order (used in for loops) CrossingSignals, // pedestrian vs highway crossing with traffic signals CrossingIsland, // pedestrian vs highway crossing with a traffic island CrossingZebra, // pedestrian vs highway zebra crossing CrossingRailway, // pedestrian or highway vs railway crossing //Admin level tags for depicting boundary AdminLevel1, // please keep order (used in for loops) AdminLevel2, AdminLevel3, AdminLevel4, AdminLevel5, AdminLevel6, AdminLevel7, AdminLevel8, AdminLevel9, AdminLevel10, AdminLevel11, // please keep order (used in for loops) BoundaryMaritime, IndoorDoor, IndoorWall, IndoorRoom, //Custom OSM Tags Landmass, UrbanArea, InternationalDateLine, Bathymetry, ///< @since 0.26.0 // Important: Make sure that this is always the last // item and just use it to specify the array size LastIndex }; /** * Return the symbol index of the placemark. */ GeoDataVisualCategory visualCategory() const; /** - * Sets the symbol @p index of the placemark. - * @param category the new category to be used. + * Sets the symbol @p category of the placemark. + * @param category the new category to be used. */ void setVisualCategory(GeoDataVisualCategory category); /** * Return the coordinates of the placemark at time @p dateTime as a GeoDataCoordinates * * The @p dateTime parameter should be used if the placemark geometry() is a * GeoDataTrack and thus contains several coordinates associated with a date and time. * * The @p iconAtCoordinates boolean is set to true if an icon should be drawn to * represent the placemark at these coordinates as described in * https://code.google.com/apis/kml/documentation/kmlreference.html#placemark, * it is set to false otherwise. * * @see GeoDataTrack::GeoDataTrack */ GeoDataCoordinates coordinate( const QDateTime &dateTime = QDateTime(), bool *iconAtCoordinates = nullptr ) const; /** * The geometry of the GeoDataPlacemark is to be rendered to the marble map * along with the icon at the coordinate associated with this Placemark. * @return a pointer to the current Geometry object */ GeoDataGeometry* geometry(); const GeoDataGeometry* geometry() const; /** * @brief displays the name of a place in the locale language of the user */ QString displayName() const; /** * @since 0.26.0 */ QString categoryName() const; /** * Return the coordinates of the placemark as @p longitude, * @p latitude and @p altitude. */ void coordinate( qreal &longitude, qreal &latitude, qreal &altitude ) const; /** * Quick, safe accessor to the placemark's OsmPlacemarkData stored within it's * ExtendedData. If the extendedData does not contain osmData, the function * inserts a default-constructed one, and returns a reference to it. */ OsmPlacemarkData &osmData(); const OsmPlacemarkData &osmData() const; void setOsmData( const OsmPlacemarkData &osmData ); bool hasOsmData() const; /** * @since 0.26.0 */ void clearOsmData(); /** * Set the coordinate of the placemark in @p longitude and * @p latitude. */ void setCoordinate( qreal longitude, qreal latitude, qreal altitude = 0, GeoDataCoordinates::Unit _unit = GeoDataCoordinates::Radian ); /** * Set the coordinate of the placemark with an @p GeoDataPoint. */ void setCoordinate( const GeoDataCoordinates &coordinate ); /** * Sets the current Geometry of this Placemark. @see geometry() and the class * overview for description of the geometry concept. The geometry can be set * to any @see GeoDataGeometry like @see GeoDataPoint,@see GeoDataLineString, * @see GeoDataLinearRing and @see GeoDataMultiGeometry */ void setGeometry( GeoDataGeometry *entry ); /** * Return the area size of the feature in square km. * * FIXME: Once we make Marble more area-aware we need to * move this into the GeoDataArea class which will get * inherited from GeoDataPlacemark (or GeoDataFeature). */ qreal area() const; /** * Set the area size of the feature in square km. */ void setArea( qreal area ); /** * Return the population of the placemark. */ qint64 population() const; /** * Sets the @p population of the placemark. * @param population the new population value */ void setPopulation( qint64 population ); /** * Return the state of the placemark. */ const QString state() const; /** * Set the state @p state of the placemark. */ void setState( const QString &state ); /** * Return the country code of the placemark. */ const QString countryCode() const; /** * Set the country @p code of the placemark. */ void setCountryCode( const QString &code ); /** * Returns whether balloon is visible or not */ bool isBalloonVisible() const; /** * Set visibility of the balloon */ void setBalloonVisible( bool visible ); /** * Serialize the Placemark to a data stream. This is a binary serialisation * and is deserialised using @see unpack() * @param stream the QDataStream to serialise object to. */ void pack( QDataStream& stream ) const override; /** * Serialise this Placemark to a XML stream writer @see QXmlStreamWriter in * the Qt documentation for more info. This will output the XML * representation of this Placemark. The default XML format is KML, to have * other formats supported you need to create a subclass and override this * method. * @param stream the XML Stream Reader to output to. */ virtual QXmlStreamWriter& pack( QXmlStreamWriter& stream ) const; virtual QXmlStreamWriter& operator <<( QXmlStreamWriter& stream ) const; /** * Deserialize the Placemark from a data stream. This has the opposite effect * from @see pack() * @param stream the QDataStream to deserialise from. */ void unpack( QDataStream& stream ) override; /** * Returns GeoDataLookAt object if lookAt is setup earlier * otherwise It will convert GeoDataCoordinates of Placemark * to GeoDataLookAt with range equals to altitude of * GeoDataCoordinate */ const GeoDataLookAt *lookAt() const; GeoDataLookAt *lookAt(); static bool placemarkLayoutOrderCompare(const GeoDataPlacemark *a, const GeoDataPlacemark* b); private: Q_DECLARE_PRIVATE(GeoDataPlacemark) }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataPoint.h b/src/lib/marble/geodata/data/GeoDataPoint.h index a6dd394f4..daadf5f45 100644 --- a/src/lib/marble/geodata/data/GeoDataPoint.h +++ b/src/lib/marble/geodata/data/GeoDataPoint.h @@ -1,103 +1,103 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2006-2007 Torsten Rahn // Copyright 2007 Inge Wallin // Copyright 2008 Patrick Spendrin // #ifndef MARBLE_GEODATAPOINT_H #define MARBLE_GEODATAPOINT_H #include #include #include #include "geodata_export.h" #include "GeoDataGeometry.h" #include "GeoDataCoordinates.h" namespace Marble { class GeoDataPointPrivate; /** * @short A Geometry object representing a 3d point * * GeoDataPoint is the GeoDataGeometry class representing a single three * dimensional point. It reflects the Point tag of KML spec and can be contained * in objects holding GeoDataGeometry objects. * Nevertheless GeoDataPoint shouldn't be used if you just want to store * 3d coordinates of a point that doesn't need to be inherited from GeoDataGeometry * In that case use GeoDataCoordinates instead which has nearly the same features * and is much more light weight. * Please consider this especially if you expect to have a high * amount of points e.g. for line strings, linear rings and polygons. * @see GeoDataCoordinates * @see GeoDataGeometry */ class GEODATA_EXPORT GeoDataPoint : public GeoDataGeometry { public: using Notation = GeoDataCoordinates::Notation; using Unit = GeoDataCoordinates::Unit; GeoDataPoint( const GeoDataPoint& other ); explicit GeoDataPoint( const GeoDataCoordinates& other ); GeoDataPoint(); /** * @brief create a geopoint from longitude and latitude - * @param _lon longitude - * @param _lat latitude + * @param lon longitude + * @param lat latitude * @param alt altitude (default: 0) - * @param _unit units that lon and lat get measured in + * @param unit units that lon and lat get measured in * (default for Radian: north pole at pi/2, southpole at -pi/2) */ GeoDataPoint( qreal lon, qreal lat, qreal alt = 0, GeoDataPoint::Unit _unit = GeoDataCoordinates::Radian ); ~GeoDataPoint() override; EnumGeometryId geometryId() const override; GeoDataGeometry *copy() const override; bool operator==( const GeoDataPoint &other ) const; bool operator!=( const GeoDataPoint &other ) const; void setCoordinates( const GeoDataCoordinates &coordinates ); const GeoDataCoordinates& coordinates() const; /// Provides type information for downcasting a GeoData const char* nodeType() const override; // Type definitions using Vector = QVector; // Serialize the Placemark to @p stream void pack( QDataStream& stream ) const override; // Unserialize the Placemark from @p stream void unpack( QDataStream& stream ) override; virtual void detach(); private: Q_DECLARE_PRIVATE(GeoDataPoint) }; } Q_DECLARE_METATYPE( Marble::GeoDataPoint ) #endif diff --git a/src/lib/marble/geodata/data/GeoDataSnippet.h b/src/lib/marble/geodata/data/GeoDataSnippet.h index 5ec88a3d0..f25178e7e 100644 --- a/src/lib/marble/geodata/data/GeoDataSnippet.h +++ b/src/lib/marble/geodata/data/GeoDataSnippet.h @@ -1,62 +1,65 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2013 Levente Kurusa // #ifndef MARBLE_GEODATASNIPPET_H #define MARBLE_GEODATASNIPPET_H #include #include "geodata_export.h" namespace Marble { class GEODATA_EXPORT GeoDataSnippet { public: /** - * Create a new snippet with the given @text text and @maxLines maximum of lines. + * Create a new snippet with the given @p text and @p maxLines maximum of lines. + * + * @param text the text + * @param maxLines the maximum nuber of lines */ explicit GeoDataSnippet( const QString &text = QString() , int maxLines = 0 ); /** * Check for equality/inequality between two GeoDataSnippets. */ bool operator==( const GeoDataSnippet &other ) const; bool operator!=( const GeoDataSnippet &other ) const; /** * Return the number of lines that should be displayed at maximum. The value * 0 (default) means "all" */ int maxLines() const; /** * Set the number of lines displayed at maximum. */ void setMaxLines( int lines ); /** * Returns the text that is associated with this snippet. */ QString text() const; /** * Set the text that the snippet will display. */ void setText( const QString &text ); private: QString m_text; // Text of the snippet int m_maxLines; // max of lines that are displayed }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataStyle.h b/src/lib/marble/geodata/data/GeoDataStyle.h index 17bc81acd..4a22a64e1 100644 --- a/src/lib/marble/geodata/data/GeoDataStyle.h +++ b/src/lib/marble/geodata/data/GeoDataStyle.h @@ -1,137 +1,137 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2007 Murad Tagirov // Copyright 2007 Inge Wallin // #ifndef MARBLE_GEODATASTYLE_H #define MARBLE_GEODATASTYLE_H #include "GeoDataStyleSelector.h" #include "geodata_export.h" #include #include class QFont; class QColor; namespace Marble { class GeoDataBalloonStyle; class GeoDataIconStyle; class GeoDataLabelStyle; class GeoDataLineStyle; class GeoDataListStyle; class GeoDataPolyStyle; class GeoDataStylePrivate; /** * @short an addressable style group * * A GeoDataStyle defines an addressable style group that can be * referenced by GeoDataStyleMaps and GeoDataFeatures. GeoDataStyles * affect how Geometry is presented in the 3D viewer (not yet * implemented) and how Features appear. Shared styles are collected * in a GeoDataDocument and must have an id defined for them so that * they can be referenced by the individual Features that use them. * * @see GeoDataIconStyle * @see GeoDataLabelStyle * @see GeoDataLineStyle * @see GeoDataPolyStyle * @see GeoDataBalloonStyle * @see GeoDataListStyle */ class GEODATA_EXPORT GeoDataStyle : public GeoDataStyleSelector { public: using Ptr = QSharedPointer; using ConstPtr = QSharedPointer; /// Construct a default style GeoDataStyle(); GeoDataStyle( const GeoDataStyle& other ); /** * @brief Construct a new style - * @param icon used to construct the icon style + * @param iconPath used to construct the icon style * @param font used to construct the label styles * @param color used to construct the label styles */ GeoDataStyle( const QString& iconPath, const QFont &font, const QColor &color ); ~GeoDataStyle() override; /// Provides type information for downcasting a GeoNode const char* nodeType() const override; /// set the icon style void setIconStyle( const GeoDataIconStyle& style ); /// Return the icon style of this style GeoDataIconStyle& iconStyle(); const GeoDataIconStyle& iconStyle() const; /// set the label style void setLabelStyle( const GeoDataLabelStyle& style ); /// Return the label style of this style GeoDataLabelStyle& labelStyle(); const GeoDataLabelStyle& labelStyle() const; /// set the line style void setLineStyle( const GeoDataLineStyle& style ); /// Return the label style of this style GeoDataLineStyle& lineStyle(); const GeoDataLineStyle& lineStyle() const; /// set the poly style void setPolyStyle( const GeoDataPolyStyle& style ); /// Return the label style of this style GeoDataPolyStyle& polyStyle(); const GeoDataPolyStyle& polyStyle() const; /// set the balloon style void setBalloonStyle( const GeoDataBalloonStyle& style ); /// Return the balloon style of this style GeoDataBalloonStyle& balloonStyle(); const GeoDataBalloonStyle& balloonStyle() const; /// set the list style void setListStyle( const GeoDataListStyle& style ); /// Return the list style of this style GeoDataListStyle& listStyle(); const GeoDataListStyle& listStyle() const; /** * @brief assignment operator * @param other the GeoDataStyle that gets duplicated */ GeoDataStyle& operator=( const GeoDataStyle& other ); bool operator==( const GeoDataStyle &other ) const; bool operator!=( const GeoDataStyle &other ) const; /** * @brief Serialize the style to a stream * @param stream the stream */ void pack( QDataStream& stream ) const override; /** * @brief Unserialize the style from a stream * @param stream the stream */ void unpack( QDataStream& stream ) override; private: GeoDataStylePrivate * const d; }; } Q_DECLARE_METATYPE( Marble::GeoDataStyle* ) Q_DECLARE_METATYPE( const Marble::GeoDataStyle* ) #endif diff --git a/src/lib/marble/geodata/data/GeoDataStyleMap.h b/src/lib/marble/geodata/data/GeoDataStyleMap.h index c1824bfb7..a45e0068d 100644 --- a/src/lib/marble/geodata/data/GeoDataStyleMap.h +++ b/src/lib/marble/geodata/data/GeoDataStyleMap.h @@ -1,87 +1,87 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2008 Patrick Spendrin // #ifndef MARBLE_GEODATASTYLEMAP_H #define MARBLE_GEODATASTYLEMAP_H #include #include #include "GeoDataStyleSelector.h" #include "geodata_export.h" namespace Marble { class GeoDataStyleMapPrivate; /** * @short a class to map different styles to one style * * A GeoDataStyleMap connects styles for highlighted and normal * context. Besides GeoDataStyleSelector it derives from * QMap. * - * @See GeoDataStyle - * @See GeoDataStyleSelector + * @see GeoDataStyle + * @see GeoDataStyleSelector */ class GEODATA_EXPORT GeoDataStyleMap : public GeoDataStyleSelector, public QMap { public: /// Provides type information for downcasting a GeoNode const char* nodeType() const override; /** * @brief return the last key */ QString lastKey() const; /** * @brief Set the last key * this property is needed to set an entry in the kml parser * after the parser has set the last key, it will read the value * and add both to this map * @param key the last key */ void setLastKey( const QString& key ); /** * @brief assignment operator * @param other the styleMap which gets duplicated. */ GeoDataStyleMap& operator=( const GeoDataStyleMap& other ); bool operator==( const GeoDataStyleMap &other ) const; bool operator!=( const GeoDataStyleMap &other ) const; /** * @brief Serialize the stylemap to a stream * @param stream the stream */ void pack( QDataStream& stream ) const override; /** * @brief Unserialize the stylemap from a stream * @param stream the stream */ void unpack( QDataStream& stream ) override; GeoDataStyleMap(); GeoDataStyleMap( const GeoDataStyleMap& other ); ~GeoDataStyleMap() override; private: GeoDataStyleMapPrivate * const d; }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataTimePrimitive.h b/src/lib/marble/geodata/data/GeoDataTimePrimitive.h index 5aaf4c792..8b4c3d565 100644 --- a/src/lib/marble/geodata/data/GeoDataTimePrimitive.h +++ b/src/lib/marble/geodata/data/GeoDataTimePrimitive.h @@ -1,61 +1,61 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2010 Harshit Jain // #ifndef MARBLE_GEODATATIMEPRIMITIVE_H #define MARBLE_GEODATATIMEPRIMITIVE_H #include "GeoDataObject.h" #include "geodata_export.h" namespace Marble { class GeoDataTimePrimitivePrivate; /** * @short a base class for the style classes * * A GeoDataTimePrimitive is a base class for the time classes TimeSpan * and TimeStamp classes. * - * @See GeoDataTimeSpan - * @See GeoDataTimeStamp + * @see GeoDataTimeSpan + * @see GeoDataTimeStamp */ class GEODATA_EXPORT GeoDataTimePrimitive : public GeoDataObject { public: /// Provides type information for downcasting a GeoNode const char* nodeType() const override; GeoDataTimePrimitive& operator=( const GeoDataTimePrimitive& other ); /** * @brief Serialize the styleselector to a stream * @param stream the stream */ void pack( QDataStream& stream ) const override; /** * @brief Unserialize the styleselector from a stream * @param stream the stream */ void unpack( QDataStream& stream ) override; GeoDataTimePrimitive(); GeoDataTimePrimitive( const GeoDataTimePrimitive& other ); ~GeoDataTimePrimitive() override; private: GeoDataTimePrimitivePrivate * const d; }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataTimeSpan.h b/src/lib/marble/geodata/data/GeoDataTimeSpan.h index e1bd9b395..5113ff72d 100644 --- a/src/lib/marble/geodata/data/GeoDataTimeSpan.h +++ b/src/lib/marble/geodata/data/GeoDataTimeSpan.h @@ -1,95 +1,95 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2010 Harshit Jain // #ifndef MARBLE_GEODATATIMESPAN_H #define MARBLE_GEODATATIMESPAN_H #include "GeoDataTimePrimitive.h" #include "geodata_export.h" namespace Marble { class GeoDataTimeStamp; class GeoDataTimeSpanPrivate; /** */ class GEODATA_EXPORT GeoDataTimeSpan : public GeoDataTimePrimitive { public: GeoDataTimeSpan(); GeoDataTimeSpan( const GeoDataTimeSpan& other ); ~GeoDataTimeSpan() override; /** * @brief assignment operator */ GeoDataTimeSpan& operator=( const GeoDataTimeSpan& other ); /** * @brief equality operators */ bool operator==( const GeoDataTimeSpan& other ) const; bool operator!=( const GeoDataTimeSpan& other ) const; /// Provides type information for downcasting a GeoNode const char* nodeType() const override; /** * @brief return the beginning instant of a timespan */ const GeoDataTimeStamp & begin() const; GeoDataTimeStamp & begin(); /** * @brief Set the beginning instant of a timespan * @param begin the beginning instant of a timespan */ void setBegin( const GeoDataTimeStamp& begin ); /** * @brief return the ending instant of a timespan */ const GeoDataTimeStamp & end() const; GeoDataTimeStamp & end(); /** * @brief Set the ending instant of a timespan - * @param begin the ending instant of a timespan + * @param end the ending instant of a timespan */ void setEnd( const GeoDataTimeStamp& end ); /** * @return True iff either of begin or end is valid, or if begin and end are both valid and begin is <= end */ bool isValid() const; /** * @brief Serialize the timespan to a stream * @param stream the stream */ void pack( QDataStream& stream ) const override; /** * @brief Unserialize the timespan from a stream * @param stream the stream */ void unpack( QDataStream& stream ) override; private: GeoDataTimeSpanPrivate * const d; }; } #endif //MARBLE_GEODATATIMESPAN_H diff --git a/src/lib/marble/geodata/scene/GeoSceneAbstractTileProjection.h b/src/lib/marble/geodata/scene/GeoSceneAbstractTileProjection.h index b45b4355e..55316b215 100644 --- a/src/lib/marble/geodata/scene/GeoSceneAbstractTileProjection.h +++ b/src/lib/marble/geodata/scene/GeoSceneAbstractTileProjection.h @@ -1,125 +1,125 @@ /* Copyright 2016 Friedrich W. H. Kossebau This file is part of the KDE project This library is free software you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License aint with this library see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MARBLE_GEOSCENEABSTRACTTILEPROJECTION_H #define MARBLE_GEOSCENEABSTRACTTILEPROJECTION_H #include "geodata_export.h" #include #include namespace Marble { class GeoSceneAbstractTileProjectionPrivate; class GeoDataLatLonBox; class TileId; /** * @short A base class for projections between tile indizes and geo coordinates in Marble. * * For map tiling with indizes in x and y dimensions and 1 or multiple zoomlevels. * The lowest zoomlevel is 0. */ class GEODATA_EXPORT GeoSceneAbstractTileProjection { public: enum Type { Equirectangular, Mercator }; /** * @brief Construct a new GeoSceneAbstractTileProjection. */ GeoSceneAbstractTileProjection(); virtual ~GeoSceneAbstractTileProjection(); public: virtual GeoSceneAbstractTileProjection::Type type() const = 0; /** * @return the number of tiles on level 0 in x dimension */ int levelZeroColumns() const; /** * @brief Sets the number of tiles on level 0 in x dimension * * @param levelZeroColumns new number of tiles on level 0 in x dimension * * Default value of the levelZeroColumns property is 1. */ void setLevelZeroColumns(int levelZeroColumns); /** * @return the number of tiles on level 0 in y dimension */ int levelZeroRows() const; /** * @brief Sets the number of tiles on level 0 in y dimension * - * @param levelZeroColumns new number of tiles on level 0 in y dimension + * @param levelZeroRows new number of tiles on level 0 in y dimension * * Default value of the levelZeroRows property is 1. */ void setLevelZeroRows(int levelZeroRows); /** * @brief Get the tile indexes which cover the given geographical box. * If @p latLonBox or @p zoomLevel have values out-of-bounds, the behaviour is undefined. * * @param latLonBox the geo coordinates of the requested tiles * @param zoomLevel the zoomlevel of the requested tiles * * @return range of tile indexes covering given geographical box at given zoom level */ virtual QRect tileIndexes(const GeoDataLatLonBox &latLonBox, int zoomLevel) const = 0; /** * @brief Get the boundary geo coordinates corresponding to a tile. * If @p x, @p y or @p zoomLevel have values out-of-bounds, the behaviour is undefined. * * @param zoomLevel the zoomlevel of the tile * @param x the x index of the tile * @param y the y index of the tile * * @return geographic bounding box covered by the given tile */ virtual GeoDataLatLonBox geoCoordinates(int zoomLevel, int x, int y) const = 0; /** * @brief Get the boundary geo coordinates corresponding to a tile. * If @p tildId has values out-of-bounds, the behaviour is undefined. * * @param tileId the id of the tile * * @return geographic bounding box covered by the given tile */ GeoDataLatLonBox geoCoordinates(const TileId &tileId) const; private: Q_DISABLE_COPY(GeoSceneAbstractTileProjection) const QScopedPointer d_ptr; }; } #endif diff --git a/src/lib/marble/geodata/scene/GeoSceneLayer.h b/src/lib/marble/geodata/scene/GeoSceneLayer.h index 1d1c536f3..7c35814c4 100644 --- a/src/lib/marble/geodata/scene/GeoSceneLayer.h +++ b/src/lib/marble/geodata/scene/GeoSceneLayer.h @@ -1,92 +1,92 @@ /* Copyright (C) 2008 Torsten Rahn This file is part of the KDE project This library is free software you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License aint with this library see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MARBLE_GEOSCENELAYER_H #define MARBLE_GEOSCENELAYER_H #include #include #include #include "GeoDocument.h" namespace Marble { class GeoSceneAbstractDataset; class GeoSceneFilter; class GeoSceneLayerPrivate; /** * @short Layer of a GeoScene document. */ class GEODATA_EXPORT GeoSceneLayer : public GeoNode { public: explicit GeoSceneLayer( const QString& name ); ~GeoSceneLayer() override; const char* nodeType() const override; /** - * @brief Add a section to the legend - * @param section the new section + * @brief Add a data set to the legend + * @param dataset the new data set */ void addDataset( GeoSceneAbstractDataset* ); const GeoSceneAbstractDataset * dataset( const QString& ) const; GeoSceneAbstractDataset * dataset( const QString& ); const GeoSceneAbstractDataset * groundDataset() const; GeoSceneAbstractDataset * groundDataset(); QVector datasets() const; QString name() const; QString backend() const; void setBackend( const QString& plugin ); /** * @brief returns whether the data is organized in quad tiles. */ bool isTiled() const; void setTiled( bool ); QString role() const; void setRole( const QString& type ); const GeoSceneFilter * filter() const; GeoSceneFilter * filter(); void addFilter( GeoSceneFilter * filter ); void removeFilter( GeoSceneFilter * filter ); private: Q_DISABLE_COPY( GeoSceneLayer ) GeoSceneLayerPrivate * const d; }; } #endif diff --git a/src/lib/marble/geodata/scene/GeoSceneMap.h b/src/lib/marble/geodata/scene/GeoSceneMap.h index 5794d0879..ff7666cd7 100644 --- a/src/lib/marble/geodata/scene/GeoSceneMap.h +++ b/src/lib/marble/geodata/scene/GeoSceneMap.h @@ -1,127 +1,127 @@ /* Copyright (C) 2008 Torsten Rahn This file is part of the KDE project This library is free software you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License aint with this library see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MARBLE_GEOSCENEMAP_H #define MARBLE_GEOSCENEMAP_H #include #include #include "GeoDocument.h" class QColor; class QString; namespace Marble { class GeoSceneLayer; class GeoSceneFilter; class GeoSceneMapPrivate; /** * @short Map layer structure of a GeoScene document. */ class GEODATA_EXPORT GeoSceneMap : public GeoNode { public: GeoSceneMap(); ~GeoSceneMap() override; const char* nodeType() const override; QColor backgroundColor() const; void setBackgroundColor( const QColor& ); QColor labelColor() const; void setLabelColor( const QColor& ); QColor highlightBrushColor() const; void setHighlightBrushColor( const QColor& ); QColor highlightPenColor() const; void setHighlightPenColor( const QColor& ); /** * @brief Add a new layer to the map - * @param section The new layer + * @param layer The new layer */ void addLayer( GeoSceneLayer* ); /** * @brief Return a layer by its name * @param name The name of the layer * @return A pointer to the layer request by its name */ GeoSceneLayer* layer( const QString& name ); const GeoSceneLayer* layer( const QString& name ) const; /** * @brief Return all layers * @return A vector that contains pointers to all available layers */ QVector layers() const; /** * @brief Add a new filter to the map - * @param section The new filter + * @param filter The new filter */ void addFilter( GeoSceneFilter* ); /** * @brief Return a filter by its name * @param name The name of the filter * @return A pointer to the filter request by its name */ GeoSceneFilter* filter( const QString& name ); /** * @brief Return all filters * @return A vector that contains pointers to all available filters */ QVector filters() const; /** * @brief Checks for valid layers that contain texture data * @return Whether a texture layer got created internally * * NOTE: The existence of the file(s) that contain the actual data * still needs to get checked at runtime! */ bool hasTextureLayers() const; /** * @brief Checks for valid layers that contain vector data * @return Whether a vector layer got created internally * * NOTE: The existence of the file(s) that contain the actual data * still needs to get checked at runtime! */ bool hasVectorLayers() const; private: Q_DISABLE_COPY( GeoSceneMap ) GeoSceneMapPrivate * const d; }; } #endif diff --git a/src/lib/marble/graphicsview/GeoGraphicsItem.cpp b/src/lib/marble/graphicsview/GeoGraphicsItem.cpp index 4f0f009a5..117c71231 100644 --- a/src/lib/marble/graphicsview/GeoGraphicsItem.cpp +++ b/src/lib/marble/graphicsview/GeoGraphicsItem.cpp @@ -1,227 +1,227 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2009 Bastian Holst // // Self #include "GeoGraphicsItem.h" #include "GeoGraphicsItem_p.h" #include "GeoDataPlacemark.h" // Qt #include "MarbleDebug.h" #include using namespace Marble; GeoGraphicsItem::GeoGraphicsItem( const GeoDataFeature *feature ) : d( new GeoGraphicsItemPrivate( feature ) ) { setFlag( ItemIsVisible, true ); } GeoGraphicsItem::~GeoGraphicsItem() { delete d; } bool GeoGraphicsItem::visible() const { return d->m_flags & ItemIsVisible; } void GeoGraphicsItem::setVisible( bool visible ) { setFlag( ItemIsVisible, visible ); } GeoGraphicsItem::GeoGraphicsItemFlags GeoGraphicsItem::flags() const { return d->m_flags; } void GeoGraphicsItem::setFlag( GeoGraphicsItemFlag flag, bool enabled ) { if( enabled ) { d->m_flags = d->m_flags | flag; } else { d->m_flags = d->m_flags & ~flag; } } void GeoGraphicsItem::setFlags( GeoGraphicsItemFlags flags ) { d->m_flags = flags; } const GeoDataFeature* GeoGraphicsItem::feature() const { return d->m_feature; } void GeoGraphicsItem::setHighlightStyle( const GeoDataStyle::ConstPtr &highlightStyle) { /** * Delete any previously set style - * and assign the new style @highlightStyle + * and assign the new style #highlightStyle */ d->m_highlightStyle = highlightStyle; } GeoDataStyle::ConstPtr GeoGraphicsItem::style() const { /** * m_isHighlight is set true when the item is * supposed to be colored highlighted */ if ( d->m_highlighted && d->m_highlightStyle ) { return d->m_highlightStyle; } if (!d->m_style) { if (const GeoDataPlacemark *placemark = geodata_cast(d->m_feature)) { auto styling = StyleParameters(placemark, d->m_renderContext.tileLevel()); for (auto relation: d->m_relations) { if (relation->isVisible()) { styling.relation = relation; break; } } d->m_style = d->m_styleBuilder->createStyle(styling); } else { d->m_style = d->m_feature->style(); } } return d->m_style; } void GeoGraphicsItem::setStyleBuilder(const StyleBuilder *styleBuilder) { d->m_styleBuilder = styleBuilder; } void GeoGraphicsItem::resetStyle() { d->m_style = GeoDataStyle::ConstPtr(); handleRelationUpdate(d->m_relations); } qreal GeoGraphicsItem::zValue() const { return d->m_zValue; } void GeoGraphicsItem::setZValue( qreal z ) { d->m_zValue = z; } void GeoGraphicsItem::setHighlighted( bool highlight ) { d->m_highlighted = highlight; } bool GeoGraphicsItem::isHighlighted() const { return d->m_highlighted; } QStringList GeoGraphicsItem::paintLayers() const { return d->m_paintLayers; } void GeoGraphicsItem::setPaintLayers(const QStringList &paintLayers) { d->m_paintLayers = paintLayers; } void GeoGraphicsItem::setRenderContext(const RenderContext &renderContext) { if (renderContext != d->m_renderContext) { d->m_renderContext = renderContext; d->m_style = GeoDataStyle::ConstPtr(); } } bool GeoGraphicsItem::contains(const QPoint &, const ViewportParams *) const { return false; } void GeoGraphicsItem::setRelations(const QSet &relations) { d->m_relations.clear(); std::copy(relations.begin(), relations.end(), std::back_inserter(d->m_relations)); std::sort(d->m_relations.begin(), d->m_relations.end(), [](const GeoDataRelation * a, const GeoDataRelation * b) { return *a < *b; }); d->m_style = GeoDataStyle::ConstPtr(); handleRelationUpdate(d->m_relations); } void GeoGraphicsItem::handleRelationUpdate(const QVector &) { // does nothing } int GeoGraphicsItem::minZoomLevel() const { return d->m_minZoomLevel; } void GeoGraphicsItem::setMinZoomLevel(int zoomLevel) { d->m_minZoomLevel = zoomLevel; } bool GeoGraphicsItem::zValueLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two) { return one->d->m_zValue < two->d->m_zValue; } bool GeoGraphicsItem::styleLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two) { return reinterpret_cast(one->d->m_style.data()) < reinterpret_cast(two->d->m_style.data()); } bool GeoGraphicsItem::zValueAndStyleLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two) { if (one->d->m_zValue == two->d->m_zValue) { return reinterpret_cast(one->d->m_style.data()) < reinterpret_cast(two->d->m_style.data()); } return one->d->m_zValue < two->d->m_zValue; } bool RenderContext::operator==(const RenderContext &other) const { return m_tileLevel == other.m_tileLevel; } bool RenderContext::operator!=(const RenderContext &other) const { return !operator==(other); } int RenderContext::tileLevel() const { return m_tileLevel; } RenderContext::RenderContext(int tileLevel) : m_tileLevel(tileLevel) { // nothing to do } diff --git a/src/lib/marble/graphicsview/GeoGraphicsItem.h b/src/lib/marble/graphicsview/GeoGraphicsItem.h index 02193d321..8a984b99a 100644 --- a/src/lib/marble/graphicsview/GeoGraphicsItem.h +++ b/src/lib/marble/graphicsview/GeoGraphicsItem.h @@ -1,174 +1,174 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2009 Bastian Holst // Copyright 2009 Andrew Manson // #ifndef MARBLE_GEOGRAPHICSITEM_H #define MARBLE_GEOGRAPHICSITEM_H // Marble #include "marble_export.h" #include "GeoDataStyle.h" class QString; namespace Marble { class GeoDataFeature; class GeoDataLatLonAltBox; class GeoDataCoordinates; class GeoGraphicsItemPrivate; class GeoPainter; class StyleBuilder; class ViewportParams; class GeoDataRelation; class RenderContext { public: bool operator==(const RenderContext &other) const; bool operator!=(const RenderContext &other) const; explicit RenderContext(int tileLevel = -1); int tileLevel() const; private: int m_tileLevel; }; class MARBLE_EXPORT GeoGraphicsItem { public: explicit GeoGraphicsItem( const GeoDataFeature *feature ); virtual ~GeoGraphicsItem(); enum GeoGraphicsItemFlag { NoOptions = 0x0, ItemIsMovable = 0x1, ItemIsSelectable = 0x2, ItemIsVisible = 0x4 }; Q_DECLARE_FLAGS(GeoGraphicsItemFlags, GeoGraphicsItemFlag) bool visible() const; void setVisible( bool visible ); /** * Get the GeoGraphicItemFlags value that describes which flags are set on * this item. @see QFlags */ GeoGraphicsItemFlags flags() const; /** * Set or unset a single flag * @param enabled sets if the flag is to be set or unset */ void setFlag( GeoGraphicsItemFlag flag, bool enabled = true ); /** * Replace all of the current flags. * @param flags is the new value for this item's flags. */ void setFlags( GeoGraphicsItemFlags flags ); /** * Returns the minim zoom level on which item will be active. */ int minZoomLevel() const; /** * Sets the minimum zoom level */ void setMinZoomLevel( int zoomLevel ); /** * Returns the placemark for that item. */ const GeoDataFeature* feature() const; /** * Returns the bounding box covered by the item. */ virtual const GeoDataLatLonAltBox &latLonAltBox() const = 0; /** * Returns the style of item. */ GeoDataStyle::ConstPtr style() const; /** * Set the style for the item. */ void setStyleBuilder(const StyleBuilder *styleBuilder); void resetStyle(); /** * Set the style which will be used when * placemark is highlighted. * GeoGraphicsItem takes ownership of the * passed style and deletes it when appropriate. */ void setHighlightStyle( const GeoDataStyle::ConstPtr &highlightStyle ); /** * Returns the z value of the item */ qreal zValue() const; /** * Set the z value of the item */ void setZValue( qreal z ); static bool zValueLessThan(GeoGraphicsItem* one, GeoGraphicsItem* two); static bool styleLessThan(GeoGraphicsItem* one, GeoGraphicsItem* two); static bool zValueAndStyleLessThan(GeoGraphicsItem* one, GeoGraphicsItem* two); /** * Paints the item using the given GeoPainter. * * Note that depending on the projection and zoom level, the item may be visible more than once, * which is taken care of by GeoPainter. */ virtual void paint(GeoPainter *painter, const ViewportParams *viewport, const QString &layer, int tileZoomLevel) = 0; void setHighlighted( bool highlight ); bool isHighlighted() const; QStringList paintLayers() const; void setPaintLayers(const QStringList &paintLayers); void setRenderContext(const RenderContext &renderContext); /** * @brief contains Returns true if the item contains the given coordinates - * @param coordinates * @param screenPosition + * @param viewport * @return */ virtual bool contains(const QPoint &screenPosition, const ViewportParams *viewport) const; void setRelations(const QSet &relations); protected: virtual void handleRelationUpdate(const QVector &relations); GeoGraphicsItemPrivate *const d; }; } // Namespace Marble Q_DECLARE_OPERATORS_FOR_FLAGS(Marble::GeoGraphicsItem::GeoGraphicsItemFlags) #endif diff --git a/src/lib/marble/graphicsview/ScreenGraphicsItem.h b/src/lib/marble/graphicsview/ScreenGraphicsItem.h index 75304f6f6..814e679b7 100644 --- a/src/lib/marble/graphicsview/ScreenGraphicsItem.h +++ b/src/lib/marble/graphicsview/ScreenGraphicsItem.h @@ -1,105 +1,105 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2009 Bastian Holst // #ifndef MARBLE_SCREENGRAPHICSITEM_H #define MARBLE_SCREENGRAPHICSITEM_H // Marble #include "MarbleGraphicsItem.h" #include "marble_export.h" // Qt #include namespace Marble { class ScreenGraphicsItemPrivate; class MARBLE_EXPORT ScreenGraphicsItem : public MarbleGraphicsItem { public: enum GraphicsItemFlag { ItemIsMovable = 0x1, ItemIsHideable = 0x2 }; Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) explicit ScreenGraphicsItem( MarbleGraphicsItem *parent = nullptr ); ~ScreenGraphicsItem() override; /** * @brief Set the position of the ScreenGraphicsItem - * @param pos Position + * @param position Position * * Positive x-coordinates are counted left-aligned from the left border of the parent item. * Negative x-coordinates are counted right-aligned from the right border of the parent item. * * Positive y-coordinates are counted top-aligned from the top border of the parent item. * Negative y-coordinates are counted right-aligned from the bottom border of the parent item. */ void setPosition( const QPointF& position ); /** * @brief Return the position of the ScreenGraphicsItem * * Positive x-coordinates are counted left-aligned from the left border of the parent item. * Negative x-coordinates are counted right-aligned from the right border of the parent item. * * Positive y-coordinates are counted top-aligned from the top border of the parent item. * Negative y-coordinates are counted right-aligned from the bottom border of the parent item. */ QPointF position() const; /** * @brief Return the positive position of the ScreenGraphicsItem * * All coordinates are counted positive and depend on the current viewport. * * Positive x-coordinates are counted left-aligned from the left border of the parent item. * Positive y-coordinates are counted top-aligned from the top border of the parent item. */ QPointF positivePosition() const; /** * @brief Return the absolute position of the ScreenGraphicsItem * * All coordinates are counted positive and depend on the current viewport. * * Positive x-coordinates are counted left-aligned from the left border of the map. * Positive y-coordinates are counted top-aligned from the top border of the map. * @since 0.26.0 */ QVector absolutePositions() const; /** * Returns the flags of the item. */ GraphicsItemFlags flags() const; /** * Sets the flags to flags. All flags in flags will be enabled and all other flags will * be disabled. By default all flags are disabled. */ void setFlags( GraphicsItemFlags flags ); protected: explicit ScreenGraphicsItem(ScreenGraphicsItemPrivate *dd); bool eventFilter( QObject *, QEvent * ) override; private: Q_DECLARE_PRIVATE(ScreenGraphicsItem) }; } // Namespace Marble #endif diff --git a/src/lib/marble/projections/AzimuthalEquidistantProjection.h b/src/lib/marble/projections/AzimuthalEquidistantProjection.h index eaef924bd..6dc624539 100644 --- a/src/lib/marble/projections/AzimuthalEquidistantProjection.h +++ b/src/lib/marble/projections/AzimuthalEquidistantProjection.h @@ -1,104 +1,104 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2013 Bernhard Beschow // #ifndef MARBLE_AZIMUTHALEQUIDISTANTPROJECTION_H #define MARBLE_AZIMUTHALEQUIDISTANTPROJECTION_H #include "AbstractProjection.h" #include "AzimuthalProjection.h" namespace Marble { class AzimuthalEquidistantProjectionPrivate; /** * @short A class to implement the spherical projection used by the "Globe" view. */ class AzimuthalEquidistantProjection : public AzimuthalProjection { // Not a QObject so far because we don't need to send signals. public: /** * @brief Construct a new AzimuthalEquidistantProjection. */ AzimuthalEquidistantProjection(); ~AzimuthalEquidistantProjection() override; /** * @brief Returns the user-visible name of the projection. */ QString name() const override; /** * @brief Returns a short user description of the projection * that can be used in tooltips or dialogs. */ QString description() const override; /** * @brief Returns an icon for the projection. */ QIcon icon() const override; qreal clippingRadius() const override; /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. - * @param lon the lon coordinate of the requested pixel position - * @param lat the lat coordinate of the requested pixel position + * @param coordinates the coordinates of the requested pixel position + * @param params the viewport parameters * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *params, qreal &x, qreal &y, bool &globeHidesPoint ) const override; bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams * viewport, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF& size, bool &globeHidesPoint ) const override; using AbstractProjection::screenCoordinates; /** * @brief Get the earth coordinates corresponding to a pixel in the map. * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the globe * @c false if the pixel (x, y) is outside the globe, i.e. in space. */ bool geoCoordinates( const int x, const int y, const ViewportParams *params, qreal& lon, qreal& lat, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const override; protected: explicit AzimuthalEquidistantProjection(AzimuthalEquidistantProjectionPrivate *dd ); private: Q_DECLARE_PRIVATE(AzimuthalEquidistantProjection) Q_DISABLE_COPY( AzimuthalEquidistantProjection ) }; } #endif diff --git a/src/lib/marble/projections/EquirectProjection.h b/src/lib/marble/projections/EquirectProjection.h index 01b5db852..ffcac5171 100644 --- a/src/lib/marble/projections/EquirectProjection.h +++ b/src/lib/marble/projections/EquirectProjection.h @@ -1,118 +1,118 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2007 Inge Wallin // Copyright 2007-2012 Torsten Rahn // #ifndef MARBLE_EQUIRECTPROJECTION_H #define MARBLE_EQUIRECTPROJECTION_H /** @file * This file contains the headers for EquirectProjection. * * @author Inge Wallin * @author Torsten Rahn */ #include "CylindricalProjection.h" namespace Marble { /** * @short A class to implement the Equirectangular projection used by the "Flat Map" view. */ class EquirectProjection : public CylindricalProjection { // Not a QObject so far because we don't need to send signals. public: /** * @brief Construct a new EquirectProjection. */ EquirectProjection(); ~EquirectProjection() override; /** * @brief Returns the user-visible name of the projection. */ QString name() const override; /** * @brief Returns a short user description of the projection * that can be used in tooltips or dialogs. */ QString description() const override; /** * @brief Returns an icon for the projection. */ QIcon icon() const override; qreal maxValidLat() const override; qreal minValidLat() const override; PreservationType preservationType() const override { return NoPreservation; } /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. - * @param lon the lon coordinate of the requested pixel position - * @param lat the lat coordinate of the requested pixel position + * @param coordinates the coordinates of the requested pixel position + * @param params the viewport parameters * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *params, qreal &x, qreal &y, bool &globeHidesPoint ) const override; bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *viewport, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF& size, bool &globeHidesPoint ) const override; using CylindricalProjection::screenCoordinates; /** * @brief Get the earth coordinates corresponding to a pixel in the map. * * If the pixel (x, y) is outside the globe, only @p lon will be calculated, * and lat will be unchanged. * * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the map * @c false if the pixel (x, y) is above or underneath the map */ bool geoCoordinates( const int x, const int y, const ViewportParams *params, qreal& lon, qreal& lat, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const override; GeoDataLatLonAltBox latLonAltBox( const QRect& screenRect, const ViewportParams *viewport ) const override; bool mapCoversViewport( const ViewportParams *viewport ) const override; private: Q_DISABLE_COPY( EquirectProjection ) }; } #endif diff --git a/src/lib/marble/projections/GnomonicProjection.h b/src/lib/marble/projections/GnomonicProjection.h index d8a60ce9a..9879d300e 100644 --- a/src/lib/marble/projections/GnomonicProjection.h +++ b/src/lib/marble/projections/GnomonicProjection.h @@ -1,103 +1,103 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2013 Bernhard Beschow // #ifndef MARBLE_GNOMONICPROJECTION_H #define MARBLE_GNOMONICPROJECTION_H #include "AbstractProjection.h" #include "AzimuthalProjection.h" namespace Marble { class GnomonicProjectionPrivate; /** * @short A class to implement the spherical projection used by the "Globe" view. */ class GnomonicProjection : public AzimuthalProjection { // Not a QObject so far because we don't need to send signals. public: /** * @brief Construct a new GnomonicProjection. */ GnomonicProjection(); ~GnomonicProjection() override; /** * @brief Returns the user-visible name of the projection. */ QString name() const override; /** * @brief Returns a short user description of the projection * that can be used in tooltips or dialogs. */ QString description() const override; /** * @brief Returns an icon for the projection. */ QIcon icon() const override; qreal clippingRadius() const override; /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. - * @param lon the lon coordinate of the requested pixel position - * @param lat the lat coordinate of the requested pixel position + * @param coordinates the coordinates of the requested pixel position + * @param params the viewport parameters * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *params, qreal &x, qreal &y, bool &globeHidesPoint ) const override; bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams * viewport, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF& size, bool &globeHidesPoint ) const override; using AbstractProjection::screenCoordinates; /** * @brief Get the earth coordinates corresponding to a pixel in the map. * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the globe * @c false if the pixel (x, y) is outside the globe, i.e. in space. */ bool geoCoordinates( const int x, const int y, const ViewportParams *params, qreal& lon, qreal& lat, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const override; protected: explicit GnomonicProjection(GnomonicProjectionPrivate *dd ); private: Q_DECLARE_PRIVATE(GnomonicProjection) Q_DISABLE_COPY( GnomonicProjection ) }; } #endif diff --git a/src/lib/marble/projections/LambertAzimuthalProjection.h b/src/lib/marble/projections/LambertAzimuthalProjection.h index 6d22349e1..5012aa4d3 100644 --- a/src/lib/marble/projections/LambertAzimuthalProjection.h +++ b/src/lib/marble/projections/LambertAzimuthalProjection.h @@ -1,103 +1,103 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2013 Bernhard Beschow // #ifndef MARBLE_LAMBERTAZIMUTHALPROJECTION_H #define MARBLE_LAMBERTAZIMUTHALPROJECTION_H #include "AbstractProjection.h" #include "AzimuthalProjection.h" namespace Marble { class LambertAzimuthalProjectionPrivate; /** * @short A class to implement the spherical projection used by the "Globe" view. */ class LambertAzimuthalProjection : public AzimuthalProjection { // Not a QObject so far because we don't need to send signals. public: /** * @brief Construct a new LambertAzimuthalProjection. */ LambertAzimuthalProjection(); ~LambertAzimuthalProjection() override; /** * @brief Returns the user-visible name of the projection. */ QString name() const override; /** * @brief Returns a short user description of the projection * that can be used in tooltips or dialogs. */ QString description() const override; /** * @brief Returns an icon for the projection. */ QIcon icon() const override; qreal clippingRadius() const override; /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. - * @param lon the lon coordinate of the requested pixel position - * @param lat the lat coordinate of the requested pixel position + * @param coordinates the coordinates of the requested pixel position + * @param params the viewport parameters * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *params, qreal &x, qreal &y, bool &globeHidesPoint ) const override; bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams * viewport, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF& size, bool &globeHidesPoint ) const override; using AbstractProjection::screenCoordinates; /** * @brief Get the earth coordinates corresponding to a pixel in the map. * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the globe * @c false if the pixel (x, y) is outside the globe, i.e. in space. */ bool geoCoordinates( const int x, const int y, const ViewportParams *params, qreal& lon, qreal& lat, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const override; protected: explicit LambertAzimuthalProjection(LambertAzimuthalProjectionPrivate *dd ); private: Q_DECLARE_PRIVATE(LambertAzimuthalProjection) Q_DISABLE_COPY( LambertAzimuthalProjection ) }; } #endif diff --git a/src/lib/marble/projections/MercatorProjection.h b/src/lib/marble/projections/MercatorProjection.h index 48323d229..efed532e2 100644 --- a/src/lib/marble/projections/MercatorProjection.h +++ b/src/lib/marble/projections/MercatorProjection.h @@ -1,120 +1,120 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2007 Inge Wallin // Copyright 2007-2012 Torsten Rahn // #ifndef MARBLE_MERCATORPROJECTION_H #define MARBLE_MERCATORPROJECTION_H /** @file * This file contains the headers for MercatorProjection. * * @author Inge Wallin * @author Torsten Rahn */ #include "CylindricalProjection.h" namespace Marble { /** * @short A class to implement the Mercator projection. */ class MercatorProjection : public CylindricalProjection { // Not a QObject so far because we don't need to send signals. public: /** * @brief Construct a new MercatorProjection. */ MercatorProjection(); ~MercatorProjection() override; /** * @brief Returns the user-visible name of the projection. */ QString name() const override; /** * @brief Returns a short user description of the projection * that can be used in tooltips or dialogs. */ QString description() const override; /** * @brief Returns an icon for the projection. */ QIcon icon() const override; qreal maxValidLat() const override; qreal minValidLat() const override; PreservationType preservationType() const override { return Conformal; } /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. - * @param lon the lon coordinate of the requested pixel position - * @param lat the lat coordinate of the requested pixel position + * @param coordinates the coordinates of the requested pixel position + * @param params the viewport parameters * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *params, qreal &x, qreal &y, bool &globeHidesPoint ) const override; bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams * viewport, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF& size, bool &globeHidesPoint ) const override; using CylindricalProjection::screenCoordinates; /** * @brief Get the earth coordinates corresponding to a pixel in the map. * * If the pixel (x, y) is outside the globe, only @p lon will be calculated, * and lat will be unchanged. * * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the globe * @c false if the pixel (x, y) is outside the globe, i.e. in space. */ bool geoCoordinates( const int x, const int y, const ViewportParams *params, qreal& lon, qreal& lat, GeoDataCoordinates::Unit = GeoDataCoordinates::Degree ) const override; GeoDataLatLonAltBox latLonAltBox( const QRect &screenRect, const ViewportParams *viewport ) const override; bool mapCoversViewport( const ViewportParams *viewport ) const override; private: mutable qreal m_lastCenterLat; mutable qreal m_lastCenterLatInv; Q_DISABLE_COPY( MercatorProjection ) }; } #endif diff --git a/src/lib/marble/projections/SphericalProjection.h b/src/lib/marble/projections/SphericalProjection.h index 792b472ba..bc8b40ddf 100644 --- a/src/lib/marble/projections/SphericalProjection.h +++ b/src/lib/marble/projections/SphericalProjection.h @@ -1,110 +1,110 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2007 Inge Wallin // Copyright 2007-2012 Torsten Rahn // #ifndef MARBLE_SPHERICALPROJECTION_H #define MARBLE_SPHERICALPROJECTION_H /** @file * This file contains the headers for SphericalProjection. * * @author Inge Wallin * @author Torsten Rahn */ #include "AbstractProjection.h" #include "AzimuthalProjection.h" namespace Marble { class SphericalProjectionPrivate; /** * @short A class to implement the spherical projection used by the "Globe" view. */ class SphericalProjection : public AzimuthalProjection { // Not a QObject so far because we don't need to send signals. public: /** * @brief Construct a new SphericalProjection. */ SphericalProjection(); ~SphericalProjection() override; /** * @brief Returns the user-visible name of the projection. */ QString name() const override; /** * @brief Returns a short user description of the projection * that can be used in tooltips or dialogs. */ QString description() const override; /** * @brief Returns an icon for the projection. */ QIcon icon() const override; /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. - * @param lon the lon coordinate of the requested pixel position - * @param lat the lat coordinate of the requested pixel position + * @param coordinates the coordinates of the requested pixel position + * @param params the viewport parameters * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *params, qreal &x, qreal &y, bool &globeHidesPoint ) const override; bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams * viewport, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF& size, bool &globeHidesPoint ) const override; using AbstractProjection::screenCoordinates; /** * @brief Get the earth coordinates corresponding to a pixel in the map. * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the globe * @c false if the pixel (x, y) is outside the globe, i.e. in space. */ bool geoCoordinates( const int x, const int y, const ViewportParams *params, qreal& lon, qreal& lat, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const override; protected: explicit SphericalProjection(SphericalProjectionPrivate *dd ); private: Q_DECLARE_PRIVATE(SphericalProjection) Q_DISABLE_COPY( SphericalProjection ) }; } #endif diff --git a/src/lib/marble/projections/StereographicProjection.h b/src/lib/marble/projections/StereographicProjection.h index f1960be2b..08020b02b 100644 --- a/src/lib/marble/projections/StereographicProjection.h +++ b/src/lib/marble/projections/StereographicProjection.h @@ -1,103 +1,103 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2013 Bernhard Beschow // #ifndef MARBLE_STEREOGRAPHICPROJECTION_H #define MARBLE_STEREOGRAPHICPROJECTION_H #include "AbstractProjection.h" #include "AzimuthalProjection.h" namespace Marble { class StereographicProjectionPrivate; /** * @short A class to implement the spherical projection used by the "Globe" view. */ class StereographicProjection : public AzimuthalProjection { // Not a QObject so far because we don't need to send signals. public: /** * @brief Construct a new StereographicProjection. */ StereographicProjection(); ~StereographicProjection() override; /** * @brief Returns the user-visible name of the projection. */ QString name() const override; /** * @brief Returns a short user description of the projection * that can be used in tooltips or dialogs. */ QString description() const override; /** * @brief Returns an icon for the projection. */ QIcon icon() const override; qreal clippingRadius() const override; /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. - * @param lon the lon coordinate of the requested pixel position - * @param lat the lat coordinate of the requested pixel position + * @param coordinates the coordinates of the requested pixel position + * @param params the viewport parameters * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *params, qreal &x, qreal &y, bool &globeHidesPoint ) const override; bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams * viewport, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF& size, bool &globeHidesPoint ) const override; using AbstractProjection::screenCoordinates; /** * @brief Get the earth coordinates corresponding to a pixel in the map. * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the globe * @c false if the pixel (x, y) is outside the globe, i.e. in space. */ bool geoCoordinates( const int x, const int y, const ViewportParams *params, qreal& lon, qreal& lat, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const override; protected: explicit StereographicProjection(StereographicProjectionPrivate *dd ); private: Q_DECLARE_PRIVATE(StereographicProjection) Q_DISABLE_COPY( StereographicProjection ) }; } #endif diff --git a/src/lib/marble/projections/VerticalPerspectiveProjection.h b/src/lib/marble/projections/VerticalPerspectiveProjection.h index b7ea3a9c3..2ec0764ae 100644 --- a/src/lib/marble/projections/VerticalPerspectiveProjection.h +++ b/src/lib/marble/projections/VerticalPerspectiveProjection.h @@ -1,103 +1,103 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2013 Bernhard Beschow // #ifndef MARBLE_VERTICALPERSPECTIVEPROJECTION_H #define MARBLE_VERTICALPERSPECTIVEPROJECTION_H #include "AbstractProjection.h" #include "AzimuthalProjection.h" namespace Marble { class VerticalPerspectiveProjectionPrivate; /** * @short A class to implement the spherical projection used by the "Globe" view. */ class VerticalPerspectiveProjection : public AzimuthalProjection { // Not a QObject so far because we don't need to send signals. public: /** * @brief Construct a new VerticalPerspectiveProjection. */ VerticalPerspectiveProjection(); ~VerticalPerspectiveProjection() override; /** * @brief Returns the user-visible name of the projection. */ QString name() const override; /** * @brief Returns a short user description of the projection * that can be used in tooltips or dialogs. */ QString description() const override; /** * @brief Returns an icon for the projection. */ QIcon icon() const override; qreal clippingRadius() const override; /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. - * @param lon the lon coordinate of the requested pixel position - * @param lat the lat coordinate of the requested pixel position + * @param coordinates the coordinates of the requested pixel position + * @param params the viewport parameters * @param x the x coordinate of the pixel is returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen */ bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *params, qreal &x, qreal &y, bool &globeHidesPoint ) const override; bool screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams * viewport, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF& size, bool &globeHidesPoint ) const override; using AbstractProjection::screenCoordinates; /** * @brief Get the earth coordinates corresponding to a pixel in the map. * @param x the x coordinate of the pixel * @param y the y coordinate of the pixel * @param lon the longitude angle is returned through this parameter * @param lat the latitude angle is returned through this parameter * @return @c true if the pixel (x, y) is within the globe * @c false if the pixel (x, y) is outside the globe, i.e. in space. */ bool geoCoordinates( const int x, const int y, const ViewportParams *params, qreal& lon, qreal& lat, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const override; protected: explicit VerticalPerspectiveProjection(VerticalPerspectiveProjectionPrivate *dd ); private: Q_DECLARE_PRIVATE(VerticalPerspectiveProjection) Q_DISABLE_COPY( VerticalPerspectiveProjection ) }; } #endif diff --git a/src/plugins/render/annotate/AreaAnnotation.h b/src/plugins/render/annotate/AreaAnnotation.h index c33dd1270..2543cf034 100644 --- a/src/plugins/render/annotate/AreaAnnotation.h +++ b/src/plugins/render/annotate/AreaAnnotation.h @@ -1,276 +1,278 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2009 Andrew Manson // Copyright 2013 Thibaut Gridel // Copyright 2014 Calin Cruceru // #ifndef AREAANNOTATION_H #define AREAANNOTATION_H #include #include "SceneGraphicsItem.h" #include "GeoDataCoordinates.h" namespace Marble { class PolylineNode; class MergingPolygonNodesAnimation; /** * @brief The AreaAnnotation class controls everything related to Polygons Editing Mode. * It includes polygons actions implementation and, at the same time, deals with painting * polygons on the map according to user's preference or to some particular states. */ class AreaAnnotation : public SceneGraphicsItem { friend class MergingPolygonNodesAnimation; public: explicit AreaAnnotation( GeoDataPlacemark *placemark ); ~AreaAnnotation() override; /** * @brief Paints the nodes on the screen and updates the regions which correspond * to each node using the given GeoPainter. */ void paint( GeoPainter *painter, const ViewportParams *viewport, const QString &layer, int tileZoomLevel ) override; /** * @brief Returns true if the given QPoint is contained by the current polygon. Note * that the return value depends on the state (e.g. in the AddingPolylineNodes state a * point is considered to be contained by the polygon if the virtual nodes or the * polygon's interior contain it, while in the Editing state, it is contained by the * polygon if either polygon's interior, the outer nodes or the inner nodes contain * it). */ bool containsPoint( const QPoint &point ) const override; /** * @brief It is used so far to remove the hover effect while being in the * AddingPolylineNodes state (@see SceneGraphicsItem::dealWithItemChange documentation). */ void dealWithItemChange( const SceneGraphicsItem *other ) override; /** * @brief Moves the whole polygon to the destination coordinates. */ void move( const GeoDataCoordinates &source, const GeoDataCoordinates &destination ) override; /** - * @brief Changes the busy state of the object according to @param enabled. It is mostly + * @brief Changes the busy state of the object according to @p enabled. It is mostly * used by Annotate Plugin to not send events to this object anymore but is different than * the focus property (you can have a focused polygon which does not accept events because * is busy). + * + * @param enabled the busy state of the object */ void setBusy( bool enabled ); /** * @brief Returns whether the annotation is 'busy' or not - this usually means that something * is being performed and it does not accept events anymore. */ bool isBusy() const; /** * @brief Iterates through all nodes which form the polygon's outer boundary as well * as all its inner boundaries and sets the IsSelected flag to false. */ void deselectAllNodes(); /** * @brief Iterates through all nodes which form the polygon's outer boundary as well * as all its inner boundaries and deletes the selected ones. */ void deleteAllSelectedNodes(); /** * @brief Deletes the last clicked node while being in the Editing state. */ void deleteClickedNode(); /** * @brief If the last clicked node is selected, set its IsSelected flag to false and * vice versa. */ void changeClickedNodeSelection(); /** * @brief Tests if there are any selected nodes. */ bool hasNodesSelected() const; /** * @brief Tests if the last clicked node is selected. */ bool clickedNodeIsSelected() const; /** * @brief Returns the animation to be handled by a QObject which can connect signals * and slots. */ QPointer animation(); /** * @brief Provides information for downcasting a SceneGraphicsItem. */ const char *graphicType() const override; protected: /** * @brief Protected methods which handle mouse events and are called by * SceneGraphicsItem::sceneEvent() (@see Template Method pattern). Each of these * event handlers are structured according to the state. */ bool mousePressEvent( QMouseEvent *event ) override; bool mouseMoveEvent( QMouseEvent *event ) override; bool mouseReleaseEvent( QMouseEvent *event ) override; /** * @brief Protected method which applies the Polygons modifications when changing * states. */ void dealWithStateChange( SceneGraphicsItem::ActionState previousState ) override; private: /** * @brief Returns true if the Polygon has a valid shape (so far, the only times when * it could have an invalid shape would be when deleting/merging nodes from its outer * boundary and it would not contains anymore all the nodes which form its inner * boundaries). */ bool isValidPolygon() const; /** * @brief It is called when the ::paint method is called for the first time. It * initializes the m_outerNodesList by creating the PolylineNodes. * @see updateRegions() method for more detailed explanation. */ void setupRegionsLists( GeoPainter *painter ); /** * @brief As briefly mentioned above, the PolylineNodes instances are not created at * each ::paint call, but only at its first call. Every time the ::paint method is * called after that, each node from the lists of PolylineNodes gets its setRegion() * method called. We need the GeoPainter for doing this because we have to get the * ellipse around the GeoDataCoordinates. */ void updateRegions( GeoPainter *painter ); /** * @brief It iterates through all nodes and paints them on the map. It takes into * consideration the active flags of each PolylineNode. */ void drawNodes( GeoPainter *painter ); /** * @brief The following functions test whether the given @p point is contained by * each list. * @return The QPair returned by innerNodeContains is extensively used * within the implementation and has the following interpretation: the node which * contains the given point is the '.second'h node from the '.first'h inner boundary. */ int outerNodeContains( const QPoint &point ) const; QPair innerNodeContains( const QPoint &point ) const; QPair virtualNodeContains( const QPoint &point ) const; int innerBoundsContain( const QPoint &point ) const; bool polygonContains( const QPoint &point ) const; /** * @brief It is called from processOnMove functions and deals with polygons * hovering. */ bool dealWithHovering( QMouseEvent *mouseEvent ); /** * @brief Each state has its corresponding event handler, since in each state the * item may behave differently. These are the event handlers for the Editing state. */ bool processEditingOnPress( QMouseEvent *mouseEvent ); bool processEditingOnMove( QMouseEvent *mouseEvent ); bool processEditingOnRelease( QMouseEvent *mouseEvent ); /** * @brief These are the event handlers for the AddingPolygonHole state. */ bool processAddingHoleOnPress( QMouseEvent *mouseEvent ); static bool processAddingHoleOnMove(QMouseEvent *mouseEvent); static bool processAddingHoleOnRelease(QMouseEvent *mouseEvent); /** * @brief These are the event handlers for the MergingPolylineNodes state. */ bool processMergingOnPress( QMouseEvent *mouseEvent ); bool processMergingOnMove( QMouseEvent *mouseEvent ); static bool processMergingOnRelease(QMouseEvent *mouseEvent); /** * @brief These are the event handlers for the AddingPolylineNodes state. */ bool processAddingNodesOnPress( QMouseEvent *mouseEvent ); bool processAddingNodesOnMove( QMouseEvent *mouseEvent ); bool processAddingNodesOnRelease( QMouseEvent *mouseEvent ); /** * @brief Since they are used in many functions, the size and color of nodes for each * state are static and have class scope. */ static const int regularDim; static const int selectedDim; static const int mergedDim; static const int hoveredDim; static const QColor regularColor; static const QColor mergedColor; const ViewportParams *m_viewport; bool m_regionsInitialized; bool m_busy; QVector m_outerNodesList; QVector m_outerVirtualNodes; QVector< QVector > m_innerNodesList; QVector< QVector > m_innerVirtualNodes; QVector m_boundariesList; // Used in the Editing state enum EditingInteractingObject { InteractingNothing, // e.g. when hovering InteractingNode, InteractingPolygon }; GeoDataCoordinates m_movedPointCoords; QPair m_clickedNodeIndexes; QPair m_hoveredNode; EditingInteractingObject m_interactingObj; // Used in Merging Nodes state QPair m_firstMergedNode; QPair m_secondMergedNode; QPointer m_animation; // Used in Adding Nodes state QPair m_virtualHovered; // It can have the following values: // -> -2 - means there is no node being adjusted; // -> -1 - means the node which is being adjusted is a node from polygon's // outer boundary (more exactly, the last; see below); // -> i - (i >= 0) means the node which is being adjusted is a node from // the i'th inner boundary (more exactly, the last one; see below). // Due to the way the node appending is done (by rotating the vector which // contains the coordinates), we can be sure that the node we want to adjust // is every time the last one. int m_adjustedNode; }; } #endif diff --git a/src/plugins/render/annotate/SceneGraphicsItem.h b/src/plugins/render/annotate/SceneGraphicsItem.h index 4c00ea712..e55e12daf 100644 --- a/src/plugins/render/annotate/SceneGraphicsItem.h +++ b/src/plugins/render/annotate/SceneGraphicsItem.h @@ -1,193 +1,195 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2009 Andrew Manson // Copyright 2013 Thibaut Gridel // Copyright 2014 Calin Cruceru // #ifndef SCENEGRAPHICSITEM_H #define SCENEGRAPHICSITEM_H #include #include "GeoGraphicsItem.h" namespace Marble { class GeoDataPlacemark; class GeoDataCoordinates; /** * @brief This is the base class for all scene graphics included within the * annotate plugin. It is not instantiated by itself but it is always used * as a part of a derived object. */ class SceneGraphicsItem : public GeoGraphicsItem { public: explicit SceneGraphicsItem( GeoDataPlacemark *placemark ); ~SceneGraphicsItem() override; enum ActionState { // General action states Editing, // Polygon specific DrawingPolygon, AddingPolygonHole, // Polygon/Placemark specific MergingNodes, AddingNodes, // Polyline specific DrawingPolyline }; /** * @brief Some events may lead to particular requests to the widget, so it is the * AnnotatePlugin which has to test whether there is any request from this polygon. */ enum MarbleWidgetRequest { NoRequest, // Polygon specific OuterInnerMergingWarning, InnerInnerMergingWarning, InvalidShapeWarning, ShowPolygonRmbMenu, ShowNodeRmbMenu, StartPolygonAnimation, RemovePolygonRequest, ChangeCursorPolygonNodeHover, ChangeCursorPolygonBodyHover, // Placemark specific ShowPlacemarkRmbMenu, ChangeCursorPlacemarkHover, // Polyline specific RemovePolylineRequest, ShowPolylineRmbMenu, StartPolylineAnimation, ChangeCursorPolylineNodeHover, ChangeCursorPolylineLineHover, // GroundOverlay specific ChangeCursorOverlayVerticalHover, ChangeCursorOverlayHorizontalHover, ChangeCursorOverlayBDiagHover, ChangeCursorOverlayFDiagHover, ChangeCursorOverlayBodyHover, ChangeCursorOverlayRotateHover }; /** * @copydoc */ const GeoDataLatLonAltBox &latLonAltBox() const override; /** * @brief Pure virtual method which is implemented by concrete scene graphic items * and returns true if the item contains the @p eventPos. */ virtual bool containsPoint( const QPoint &eventPos ) const = 0; /** * @brief Pure virtual method which is implemented by concrete scene graphic items * and deals with changes that occur when this item is no longer the item we interact * with (by means of mouse events - so far). */ virtual void dealWithItemChange( const SceneGraphicsItem *other ) = 0; /** * @brief Pure virtual method which is implemented by concrete scene graphic items * and deals with moving it from the @param source coordinates to the @param * destination coordinates. * FIXME: Maybe move this to the model classes since the classes derived from this * abstract class should only deal with painting and event handling. */ virtual void move( const GeoDataCoordinates &source, const GeoDataCoordinates &destination ) = 0; /** * @brief Returns the current state. */ ActionState state() const; /** * @brief Sets the ActionState of this item. This also calls dealWithStateChange() with * a parameter: the previous state. */ void setState( ActionState state ); /** * @brief Returns whether this item has the focus or not. */ bool hasFocus() const; /** - * @brief Sets the focus of this item according to the @param enabled. + * @brief Sets the focus of this item according to the @p enabled. + * + * @param enabled whether the item is to be focussed */ void setFocus( bool enabled ); /** * @brief Returns the widget request. */ MarbleWidgetRequest request() const; /** * @brief SceneGraphicItem class, when called from one of its derived classes' * constructors, takes as a parameter a pointer to the placemark of the graphic * element. * @return The pointer to the placemark mentioned above. */ const GeoDataPlacemark *placemark() const; GeoDataPlacemark *placemark(); /** * @brief This function is used to call the event distributer and makes use of * the re-implemented virtual functions which handle the mouse events. */ bool sceneEvent( QEvent *event ); /** * @brief It is used for downcasting a SceneGraphicItem. It returns a const char * which is the name of the element's class and is defined within the * SceneGraphicsTypes namespace. */ virtual const char *graphicType() const = 0; protected: /** * @brief Pure virtual functions which handle the mouse events, all of which are * re-implemented in every SceneGraphicItem derived classes. */ virtual bool mousePressEvent( QMouseEvent *event ) = 0; virtual bool mouseMoveEvent( QMouseEvent *event ) = 0; virtual bool mouseReleaseEvent( QMouseEvent *event ) = 0; virtual void dealWithStateChange( SceneGraphicsItem::ActionState previousState ) = 0; /** * @brief Sets the widget request. */ void setRequest( MarbleWidgetRequest request ); private: ActionState m_state; bool m_hasFocus; MarbleWidgetRequest m_request; GeoDataPlacemark *m_placemark; }; } #endif // SCENEGRAPHICSITEM_H diff --git a/src/plugins/render/foursquare/FoursquarePlugin.h b/src/plugins/render/foursquare/FoursquarePlugin.h index 780b3d21e..b806f2cf4 100644 --- a/src/plugins/render/foursquare/FoursquarePlugin.h +++ b/src/plugins/render/foursquare/FoursquarePlugin.h @@ -1,63 +1,63 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2012 Utku Aydın // #ifndef FOURSQUAREPLUGIN_H #define FOURSQUAREPLUGIN_H #include "AbstractDataPlugin.h" namespace Marble { class FoursquarePlugin : public AbstractDataPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.marble.FoursquarePlugin" ) Q_INTERFACES( Marble::RenderPluginInterface ) MARBLE_PLUGIN( FoursquarePlugin ) public: FoursquarePlugin(); explicit FoursquarePlugin( const MarbleModel *marbleModel ); void initialize() override; QString name() const override; QString guiString() const override; QString nameId() const override; QString version() const override; QString description() const override; QString copyrightYears() const override; QVector pluginAuthors() const override; QIcon icon() const override; /** * @brief Checks if there is an access token stored. */ Q_INVOKABLE bool isAuthenticated(); /** * @brief Stores the access token. - * @param url A dummy URL that has a fragment named access_token + * @param tokenUrl A dummy URL that has a fragment named access_token * @see https://developer.foursquare.com/overview/auth */ Q_INVOKABLE bool storeAccessToken(const QString &tokenUrl); }; } #endif // FOURSQUAREPLUGIN_H diff --git a/src/plugins/render/routing/AudioOutput.h b/src/plugins/render/routing/AudioOutput.h index d7d6c19c1..9e744d9ab 100644 --- a/src/plugins/render/routing/AudioOutput.h +++ b/src/plugins/render/routing/AudioOutput.h @@ -1,82 +1,83 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2011 Dennis Nienhüser // #ifndef MARBLE_AUDIOOUTPUT_H #define MARBLE_AUDIOOUTPUT_H #include namespace Marble { class Route; class AudioOutputPrivate; /** * Audio (mainly voice) output of driving instructions */ class AudioOutput : public QObject { Q_OBJECT public: /** Constructor */ explicit AudioOutput( QObject* parent = nullptr ); /** Destructor */ ~AudioOutput() override; /** * Generate an audible notification (if needed) after the position on the route has changed. * No notification will be generated if the turn point with the given index is too far away, * has been announced previously, if the output is @see setMuted or the needed sounds cannot * be found in the Marble data path. - * @param index The index of the next turn point - * @param distance The distance in meters to the next turn point - * @param turnType The turn type to execute at the next turn point + * @param route The route + * @param distanceManeuver The distance in meters to the next turn point + * @param distanceTarget The distance to the target + * @param deviated Whether the route is deviated */ void update( const Route &route, qreal distanceManeuver, qreal distanceTarget, bool deviated ); /** Toggle muting (neither sound nor voice output) */ void setMuted( bool muted ); bool isMuted() const; /** * Change the speaker to use. * @param speaker A directory name in audio/speakers in Marble's data path. This directory * is expected to contain ogg files containing the instructions: TurnLeft.ogg, RbExit3.ogg etc. * Disabled by setSoundEnabled(true) and overridden by setMuted(true). * @see setSoundEnabled * @see setMuted */ void setSpeaker( const QString &speaker ); QString speaker() const; /** * Toggle whether sound output is used instead of a speaker. Overridden by setMuted(true). * @see setMuted */ void setSoundEnabled( bool enabled ); bool isSoundEnabled() const; private: Q_PRIVATE_SLOT( d, void audioOutputFinished() ) Q_PRIVATE_SLOT( d, void playInstructions() ) AudioOutputPrivate * const d; }; } #endif // MARBLE_AUDIOOUTPUT_H diff --git a/src/plugins/render/stars/StarsPlugin.h b/src/plugins/render/stars/StarsPlugin.h index e2fe0bc75..858ff562e 100644 --- a/src/plugins/render/stars/StarsPlugin.h +++ b/src/plugins/render/stars/StarsPlugin.h @@ -1,324 +1,325 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2008 Torsten Rahn // // // This class is a stars plugin. // #ifndef MARBLESTARSPLUGIN_H #define MARBLESTARSPLUGIN_H #include #include #include #include #include #include "RenderPlugin.h" #include "Quaternion.h" #include "DialogConfigurationInterface.h" class QMenu; class QVariant; class SolarSystem; namespace Ui { class StarsConfigWidget; } namespace Marble { class StarPoint { public: StarPoint() {} /** * @brief create a starpoint from rectaszension and declination * @param rect rectaszension - * @param lat declination + * @param decl declination * @param mag magnitude * (default for Radian: north pole at pi/2, southpole at -pi/2) + * @param colorId color */ StarPoint(int id, qreal rect, qreal decl, qreal mag, int colorId) : m_id( id ), m_magnitude( mag ), m_colorId( colorId ) { m_q = Quaternion::fromSpherical( rect, decl ); } ~StarPoint() {} qreal magnitude() const { return m_magnitude; } const Quaternion &quaternion() const { return m_q; } int id() const { return m_id; } int colorId() const { return m_colorId; } private: int m_id; qreal m_magnitude; Quaternion m_q; int m_colorId; }; class DsoPoint { public: DsoPoint() {} /** * @brief create a dsopoint from rectaszension and declination * @param rect rectaszension * @param lat declination * @param mag * (default for Radian: north pole at pi/2, southpole at -pi/2) */ DsoPoint(const QString& id, qreal rect, qreal decl) { m_id = id; m_q = Quaternion::fromSpherical( rect, decl ); } QString id() const { return m_id; } const Quaternion &quaternion() const { return m_q; } private: QString m_id; Quaternion m_q; }; /** * @short The class that specifies the Marble layer interface of a plugin. * */ class Constellation; class StarsPlugin : public RenderPlugin, public DialogConfigurationInterface { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.marble.StarsPlugin") Q_INTERFACES(Marble::RenderPluginInterface) Q_INTERFACES( Marble::DialogConfigurationInterface ) MARBLE_PLUGIN(StarsPlugin) public: explicit StarsPlugin( const MarbleModel *marbleModel=nullptr ); ~StarsPlugin() override; QStringList backendTypes() const override; QString renderPolicy() const override; QStringList renderPosition() const override; RenderType renderType() const override; QString name() const override; QString guiString() const override; QString nameId() const override; QString version() const override; QString description() const override; QString copyrightYears() const override; QVector pluginAuthors() const override; QIcon icon() const override; void initialize() override; bool isInitialized() const override; bool render( GeoPainter *painter, ViewportParams *viewport, const QString& renderPos, GeoSceneLayer * layer = nullptr ) override; QDialog *configDialog() override; QHash settings() const override; void setSettings( const QHash &settings ) override; QString assembledConstellation(const QString &name); protected: bool eventFilter( QObject *object, QEvent *e ) override; private Q_SLOTS: void requestRepaint(); void toggleSunMoon(bool on); void togglePlanets(bool on); void toggleDsos(bool on); void toggleConstellations(bool on); void executeConfigDialog(); public Q_SLOTS: void readSettings(); void writeSettings(); void constellationGetColor(); void constellationLabelGetColor(); void dsoLabelGetColor(); void eclipticGetColor(); void celestialEquatorGetColor(); void celestialPoleGetColor(); private: template T readSetting( const QHash &settings, const QString &key, const T &defaultValue ) { if ( !settings.contains( key ) ) { return defaultValue; } return settings[key].value(); } QPixmap starPixmap(qreal mag, int colorId) const; void prepareNames(); QHash m_abbrHash; QHash m_nativeHash; int m_nameIndex; void renderPlanet(const QString &planetId, GeoPainter *painter, SolarSystem &sys, ViewportParams *viewport, qreal skyRadius, matrix &skyAxisMatrix) const; void createStarPixmaps(); void loadStars(); void loadConstellations(); void loadDsos(); QPointer m_configDialog; Ui::StarsConfigWidget *ui_configWidget; bool m_renderStars; bool m_renderConstellationLines; bool m_renderConstellationLabels; bool m_renderDsos; bool m_renderDsoLabels; bool m_renderSun; bool m_renderMoon; QMap m_renderPlanet; bool m_renderEcliptic; bool m_renderCelestialEquator; bool m_renderCelestialPole; bool m_starsLoaded; bool m_starPixmapsCreated; bool m_constellationsLoaded; bool m_dsosLoaded; bool m_zoomSunMoon; bool m_viewSolarSystemLabel; QVector m_stars; QPixmap m_pixmapSun; QPixmap m_pixmapMoon; QVector m_constellations; QVector m_dsos; QHash m_idHash; QImage m_dsoImage; int m_magnitudeLimit; int m_zoomCoefficient; QBrush m_constellationBrush; QBrush m_constellationLabelBrush; QBrush m_dsoLabelBrush; QBrush m_eclipticBrush; QBrush m_celestialEquatorBrush; QBrush m_celestialPoleBrush; QVector m_pixN1Stars; QVector m_pixP0Stars; QVector m_pixP1Stars; QVector m_pixP2Stars; QVector m_pixP3Stars; QVector m_pixP4Stars; QVector m_pixP5Stars; QVector m_pixP6Stars; QVector m_pixP7Stars; /* Context menu */ QPointer m_contextMenu; QAction* m_constellationsAction; QAction* m_sunMoonAction; QAction* m_planetsAction; QAction* m_dsoAction; bool m_doRender; }; class Constellation { public: Constellation() {} Constellation(StarsPlugin *plugin, const QString &name, const QString &stars) : m_plugin( plugin ), m_name( name ) { const QStringList starlist = stars.split(QLatin1Char(' ')); for (int i = 0; i < starlist.size(); ++i) { m_stars << starlist.at(i).toInt(); } } int size() const { return m_stars.size(); } int at(const int index) const { if (index < 0) { return -1; } if (index >= m_stars.size()) { return -1; } return m_stars.at(index); } QString name() const { return m_plugin->assembledConstellation(m_name); } private: StarsPlugin *m_plugin; QString m_name; QVector m_stars; }; } #endif // MARBLESTARSPLUGIN_H diff --git a/src/plugins/runner/osm/OsmRelation.cpp b/src/plugins/runner/osm/OsmRelation.cpp index c67ab5cd2..e719b7664 100644 --- a/src/plugins/runner/osm/OsmRelation.cpp +++ b/src/plugins/runner/osm/OsmRelation.cpp @@ -1,290 +1,290 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2015 Dennis Nienhüser // #include #include #include #include #include #include #include #include #include namespace Marble { OsmRelation::OsmMember::OsmMember() : reference(0) { // nothing to do } OsmPlacemarkData &OsmRelation::osmData() { return m_osmData; } const OsmPlacemarkData &OsmRelation::osmData() const { return m_osmData; } void OsmRelation::parseMember(const QXmlStreamAttributes &attributes) { addMember(attributes.value(QLatin1String("ref")).toLongLong(), attributes.value(QLatin1String("role")).toString(), attributes.value(QLatin1String("type")).toString()); } void OsmRelation::addMember(qint64 reference, const QString &role, const QString &type) { OsmMember member; member.reference = reference; member.role = role; member.type = type; m_members << member; } void OsmRelation::createMultipolygon(GeoDataDocument *document, OsmWays &ways, const OsmNodes &nodes, QSet &usedNodes, QSet &usedWays) const { if (!m_osmData.containsTag(QStringLiteral("type"), QStringLiteral("multipolygon"))) { return; } QStringList const outerRoles = QStringList() << QStringLiteral("outer") << QString(); QSet outerWays; QSet outerNodes; OsmRings const outer = rings(outerRoles, ways, nodes, outerNodes, outerWays); if (outer.isEmpty()) { return; } GeoDataPlacemark::GeoDataVisualCategory outerCategory = StyleBuilder::determineVisualCategory(m_osmData); if (outerCategory == GeoDataPlacemark::None) { // Try to determine the visual category from the relation members GeoDataPlacemark::GeoDataVisualCategory const firstCategory = StyleBuilder::determineVisualCategory(ways[*outerWays.begin()].osmData()); bool categoriesAreSame = true; for (auto wayId: outerWays) { GeoDataPlacemark::GeoDataVisualCategory const category = StyleBuilder::determineVisualCategory(ways[wayId].osmData()); if( category != firstCategory ) { categoriesAreSame = false; break; } } if( categoriesAreSame ) { outerCategory = firstCategory; } } for (auto wayId: outerWays) { Q_ASSERT(ways.contains(wayId)); GeoDataPlacemark::GeoDataVisualCategory const category = StyleBuilder::determineVisualCategory(ways[wayId].osmData()); if (category == GeoDataPlacemark::None || category == outerCategory) { // Schedule way for removal: It's a non-styled way only used to create the outer boundary in this polygon usedWays << wayId; } // else we keep it for(auto nodeId: ways[wayId].references()) { ways[wayId].osmData().addNodeReference(nodes[nodeId].coordinates(), nodes[nodeId].osmData()); } } QStringList const innerRoles = QStringList() << QStringLiteral("inner"); QSet innerWays; OsmRings const inner = rings(innerRoles, ways, nodes, usedNodes, innerWays); bool const hasMultipleOuterRings = outer.size() > 1; for (int i=0, n=outer.size(); isetOuterBoundary(outerRing.first); OsmPlacemarkData osmData = m_osmData; osmData.addMemberReference(-1, outerRing.second); int index = 0; for (auto const &innerRing: inner) { if (innerRing.first.isEmpty() || !outerRing.first.contains(innerRing.first.first())) { // Simple check to see if this inner ring is inside the outer ring continue; } if (StyleBuilder::determineVisualCategory(innerRing.second) == GeoDataPlacemark::None) { // Schedule way for removal: It's a non-styled way only used to create the inner boundary in this polygon usedWays << innerRing.second.id(); } polygon->appendInnerBoundary(innerRing.first); osmData.addMemberReference(index, innerRing.second); ++index; } if (outerCategory == GeoDataPlacemark::Bathymetry) { // In case of a bathymetry store elevation info since it is required during styling // The ele=* tag is present in the outermost way const QString ele = QStringLiteral("ele"); const OsmPlacemarkData &outerWayData = outerRing.second; auto tagIter = outerWayData.findTag(ele); if (tagIter != outerWayData.tagsEnd()) { osmData.addTag(ele, tagIter.value()); } } GeoDataPlacemark *placemark = new GeoDataPlacemark; placemark->setName(m_osmData.tagValue(QStringLiteral("name"))); placemark->setVisualCategory(outerCategory); placemark->setOsmData(osmData); placemark->setZoomLevel(StyleBuilder::minimumZoomLevel(outerCategory)); placemark->setPopularity(StyleBuilder::popularity(placemark)); placemark->setVisible(outerCategory != GeoDataPlacemark::None); placemark->setGeometry(polygon); if (hasMultipleOuterRings) { - /** @TODO Use a GeoDataMultiGeometry to keep the ID? */ + /** @todo Use a GeoDataMultiGeometry to keep the ID? */ osmData.setId(0); OsmObjectManager::initializeOsmData(placemark); } else { OsmObjectManager::registerId(osmData.id()); } usedNodes |= outerNodes; document->append(placemark); } } void OsmRelation::createRelation(GeoDataDocument *document, const QHash& placemarks) const { if (m_osmData.containsTag(QStringLiteral("type"), QStringLiteral("multipolygon"))) { return; } OsmPlacemarkData osmData = m_osmData; GeoDataRelation *relation = new GeoDataRelation; relation->setName(osmData.tagValue(QStringLiteral("name"))); if (relation->name().isEmpty()) { relation->setName(osmData.tagValue(QStringLiteral("ref"))); } relation->osmData() = osmData; for (auto const &member: m_members) { auto const iter = placemarks.find(member.reference); if (iter != placemarks.constEnd()) { relation->addMember(*iter, member.reference, member.role); } } if (relation->members().isEmpty()) { delete relation; return; } OsmObjectManager::registerId(osmData.id()); relation->setVisible(false); document->append(relation); } OsmRelation::OsmRings OsmRelation::rings(const QStringList &roles, const OsmWays &ways, const OsmNodes &nodes, QSet &usedNodes, QSet &usedWays) const { QSet currentWays; QSet currentNodes; QList roleMembers; for (auto const &member: m_members) { if (roles.contains(member.role)) { if (!ways.contains(member.reference)) { // A way is missing. Return nothing. return OsmRings(); } roleMembers << member.reference; } } OsmRings result; QList unclosedWays; for(auto wayId: roleMembers) { GeoDataLinearRing ring; OsmWay const & way = ways[wayId]; if (way.references().isEmpty()) { continue; } if (way.references().first() != way.references().last()) { unclosedWays.append(way); continue; } for(auto id: way.references()) { if (!nodes.contains(id)) { // A node is missing. Return nothing. return OsmRings(); } ring << nodes[id].coordinates(); } Q_ASSERT(ways.contains(wayId)); currentWays << wayId; result << OsmRing(GeoDataLinearRing(ring.optimized()), way.osmData()); } if( !unclosedWays.isEmpty() ) { //mDebug() << "Trying to merge non-trivial polygon boundary in relation " << m_osmData.id(); while( unclosedWays.length() > 0 ) { GeoDataLinearRing ring; qint64 firstReference = unclosedWays.first().references().first(); qint64 lastReference = firstReference; bool ok = true; while( ok ) { ok = false; for(int i = 0; i v = nextWay.references(); while( !v.isEmpty() ) { qint64 id = isReversed ? v.takeLast() : v.takeFirst(); if (!nodes.contains(id)) { // A node is missing. Return nothing. return OsmRings(); } if ( id != lastReference ) { ring << nodes[id].coordinates(); currentNodes << id; } } lastReference = isReversed ? nextWay.references().first() : nextWay.references().last(); Q_ASSERT(ways.contains(nextWay.osmData().id())); currentWays << nextWay.osmData().id(); unclosedWays.removeAt(i); ok = true; break; } else { ++i; } } } if(lastReference != firstReference) { return OsmRings(); } else { /** @todo Merge tags common to all rings into the new osm data? */ result << OsmRing(GeoDataLinearRing(ring.optimized()), OsmPlacemarkData()); } } } usedWays |= currentWays; usedNodes |= currentNodes; return result; } }