diff --git a/src/lib/marble/AbstractDataPluginModel.h b/src/lib/marble/AbstractDataPluginModel.h index 45a824289..0e9332ebc 100644 --- a/src/lib/marble/AbstractDataPluginModel.h +++ b/src/lib/marble/AbstractDataPluginModel.h @@ -1,189 +1,189 @@ // // 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_ABSTRACTDATAPLUGINMODEL_H #define MARBLE_ABSTRACTDATAPLUGINMODEL_H #include #include #include #include "marble_export.h" class QPoint; class QUrl; class QString; class QStringList; namespace Marble { class AbstractDataPluginModelPrivate; class AbstractDataPluginItem; class GeoDataLatLonAltBox; class MarbleModel; class ViewportParams; /** * @short An abstract data model (not based on QAbstractModel) for a AbstractDataPlugin. * * This class is an abstract model for a AbstractDataPlugin. * It provides the storage and selection of added items and it is also responsible for * downloading item data. * * The functions getAdditionalItems() and parseFile() have to be reimplemented in * a subclass. **/ class MARBLE_EXPORT AbstractDataPluginModel : public QObject { Q_OBJECT /** @todo FIXME Qt Quick segfaults if using the real class here instead of QObject */ Q_PROPERTY( QObject* favoritesModel READ favoritesModel CONSTANT ) public: explicit AbstractDataPluginModel( const QString& name, const MarbleModel *marbleModel, QObject *parent = nullptr ); ~AbstractDataPluginModel() override; const MarbleModel *marbleModel() const; /** * @brief Get the items on the viewport * Returns the currently downloaded images in the @p viewport. * The maximum number of images can be specified with @p number, * 0 means no limit. * @return The list of item with most important item first. */ QList items( const ViewportParams *viewport, qint32 number = 10 ); /** * @brief Get all items that contain the given point * Returns a list of all items that contain the point @p curpos */ QList whichItemAt( const QPoint& curpos ); /** * @brief Sets the settings for all items. * Sets the settings for all items before painting. This ensures that all items react on * changed settings. */ void setItemSettings(const QHash &itemSettings); virtual void setFavoriteItems( const QStringList& list ); QStringList favoriteItems() const; void setFavoriteItemsOnly( bool favoriteOnly ); bool isFavoriteItemsOnly() const; QObject* favoritesModel(); /** * Finds the item with @p id in the list. * @return The pointer to the item or (if no item has been found) 0 */ AbstractDataPluginItem *findItem( const QString& id ) const; /** * Testing the existence of the item @p id in the list */ bool itemExists( const QString& id ) const; public Q_SLOTS: /** * Adds the @p items to the list of initialized items. It checks if items with the same id are * already in the list and ignores and deletes them in this case. */ void addItemsToList( const QList &items ); /** * Convenience method to add one item to the list. See addItemsToList */ void addItemToList( AbstractDataPluginItem *item ); /** * Removes all items */ void clear(); protected: /** * Managing to get @p number additional items in @p box. This includes generating a url and * downloading the corresponding file. * This method has to be implemented in a subclass. **/ virtual void getAdditionalItems( const GeoDataLatLonAltBox& box, qint32 number = 10 ) = 0; /** * @brief Retrieve data for a specific item * @param id Item id of the item to retrieve */ virtual void getItem( const QString &id ); /** * Parse the @p file and generate items. The items will be added to the list or the method * starts additionally needed downloads. * This method has to be implemented in a subclass. **/ virtual void parseFile( const QByteArray& file ); /** * Downloads the file from @p url. @p item -> addDownloadedFile() will be called when the * download is finished. - * @param: The type of the download (to be specified by the subclasser) + * @param type The type of the download (to be specified by the subclasser) **/ void downloadItem( const QUrl& url, const QString& type, AbstractDataPluginItem *item ); /** * Download the description file from the @p url. */ void downloadDescriptionFile( const QUrl& url ); void registerItemProperties( const QMetaObject& item ); private Q_SLOTS: /** * @brief Get new items with getAdditionalItems if it is reasonable. */ void handleChangedViewport(); /** * @brief This method will assign downloaded files to the corresponding items * @param relativeUrlString The string containing the relative (to the downloader path) * url of the downloaded file. * @param id The id of the downloaded file */ void processFinishedJob( const QString& relativeUrlString, const QString& id ); /** * @brief Removes the item from the list. */ void removeItem( QObject *item ); void favoriteItemChanged( const QString& id, bool isFavorite ); void scheduleItemSort(); void themeChanged(); Q_SIGNALS: void itemsUpdated(); void favoriteItemsChanged( const QStringList& favoriteItems ); void favoriteItemsOnlyChanged(); private: AbstractDataPluginModelPrivate * const d; friend class AbstractDataPluginModelPrivate; }; } #endif diff --git a/src/lib/marble/BookmarkManager.h b/src/lib/marble/BookmarkManager.h index 7cdcef27e..a3e659fd7 100644 --- a/src/lib/marble/BookmarkManager.h +++ b/src/lib/marble/BookmarkManager.h @@ -1,138 +1,139 @@ // // 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 Gaurav Gupta <1989.gaurav@googlemail.com> // Copyright 2012 Thibaut Gridel // #ifndef MARBLE_BOOKMARKMANAGER_H #define MARBLE_BOOKMARKMANAGER_H #include #include #include "MarbleGlobal.h" class QString; namespace Marble { class BookmarkManagerPrivate; class GeoDataContainer; class GeoDataDocument; class GeoDataPlacemark; class GeoDataCoordinates; class GeoDataFolder; class GeoDataTreeModel; class StyleBuilder; /** * This class is responsible for loading the * book mark objects from the files and various * book mark operations */ class MARBLE_EXPORT BookmarkManager : public QObject { Q_OBJECT public: explicit BookmarkManager( GeoDataTreeModel *treeModel, QObject *parent = nullptr ); ~BookmarkManager() override; /** * @brief load bookmark file as GeoDataDocument and return true * if loaded successfully else false * @param relativeFilePath relative path of bookmark file */ bool loadFile( const QString &relativeFilePath ); /** * @brief return bookmark file path */ QString bookmarkFile() const; /** * @brief add bookmark in a folder * @param bookmark bookmark to be added * @param folder folder to add bookmark to */ void addBookmark( GeoDataContainer *folder, const GeoDataPlacemark &bookmark ) ; void updateBookmark( GeoDataPlacemark *bookmark ); void removeBookmark( GeoDataPlacemark *bookmark ); /** * @brief checks all the bookmarks in container recursively and returns * pointer to the one having the same coordinate as the provided */ GeoDataPlacemark* bookmarkAt(GeoDataContainer *container, const GeoDataCoordinates &coordinate); GeoDataDocument * document(); const GeoDataDocument * document() const; bool showBookmarks() const; /** * @brief return Vector of folders */ QVector folders() const; /** * @brief add a folder + * @param container geodata container * @param name name of folder to be created * @return pointer to the newly added folder */ GeoDataFolder* addNewBookmarkFolder( GeoDataContainer *container, const QString &name ); void renameBookmarkFolder( GeoDataFolder *folder, const QString &name ); void removeBookmarkFolder( GeoDataFolder *folder ); /** * @brief checks that there is at least one folder */ void ensureDefaultFolder(); /** * @brief remove all folders and bookmarks except default folder */ void removeAllBookmarks(); /** * @since 0.26.0 */ void setStyleBuilder(const StyleBuilder* styleBuilder); public Q_SLOTS: void setShowBookmarks( bool visible ); Q_SIGNALS: /** One or more bookmarks were added or removed */ void bookmarksChanged(); private: friend class BookmarkManagerDialog; /** * @brief updates bookmark file and return true if updated successfully */ bool updateBookmarkFile(); static GeoDataDocument* openFile( const QString& fileName ); BookmarkManagerPrivate* const d; }; } #endif diff --git a/src/lib/marble/FileStoragePolicy.h b/src/lib/marble/FileStoragePolicy.h index f83d9b36a..4c0ed8270 100644 --- a/src/lib/marble/FileStoragePolicy.h +++ b/src/lib/marble/FileStoragePolicy.h @@ -1,65 +1,66 @@ // // 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 Tobias Koenig // #ifndef MARBLE_FILESTORAGEPOLICY_H #define MARBLE_FILESTORAGEPOLICY_H #include "StoragePolicy.h" namespace Marble { class FileStoragePolicy : public StoragePolicy { Q_OBJECT public: /** * Creates a new file storage policy. * * @param dataDirectory The directory where the data should go to. + * @param parent The parent object. */ explicit FileStoragePolicy( const QString &dataDirectory = QString(), QObject *parent = nullptr ); /** * Destroys the cache storage policy. */ ~FileStoragePolicy() override; /** * Returns whether the @p fileName exists already. */ bool fileExists( const QString &fileName ) const override; /** * Updates the @p fileName with the given @p data. */ bool updateFile( const QString &fileName, const QByteArray &data ) override; /** * Clears the cache. */ void clearCache() override; /** * Returns the last error message. */ QString lastErrorMessage() const override; private: Q_DISABLE_COPY( FileStoragePolicy ) QString m_dataDirectory; QString m_errorMsg; }; } #endif diff --git a/src/lib/marble/GeoPainter.h b/src/lib/marble/GeoPainter.h index b5d7cd609..69405a532 100644 --- a/src/lib/marble/GeoPainter.h +++ b/src/lib/marble/GeoPainter.h @@ -1,530 +1,531 @@ // // 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-2009 Torsten Rahn // #ifndef MARBLE_GEOPAINTER_H #define MARBLE_GEOPAINTER_H #include "marble_export.h" // Marble #include "MarbleGlobal.h" #include "ClipPainter.h" #include class QImage; class QPaintDevice; class QRegion; class QString; namespace Marble { class ViewportParams; class GeoPainterPrivate; class GeoDataCoordinates; class GeoDataLineString; class GeoDataLinearRing; class GeoDataPoint; class GeoDataPolygon; /*! \class GeoPainter \brief A painter that allows to draw geometric primitives on the map. This class allows application developers to draw simple geometric shapes and objects onto the map. The API is modeled after the QPainter API. The GeoPainter provides a wide range of methods that are using geographic ("geodesic") coordinates to position the item. For example a point or the nodes of a polygon can fully be described in geographic coordinates. In all these cases the position of the object is specified in geographic coordinates. There are however some cases where there are two viable cases: \li the shape of the object could still use screen coordinates (like a label or an icon). \li Alternatively the shape of the object can get projected according to the current projection (e.g. a texture projected onto the spherical surface) If screen coordinates are used then e.g. width and height are assumed to be expressed in pixels, otherwise degrees are used. Painter transformations (e.g. translate) always happen in screen coordinates. Like in QPainter drawing objects onto a widget should always considered to be a volatile operation. This means that e.g. placemarks don't get added to the globe permanently. So the drawing needs to be done on every repaint to prevent that drawings will disappear during the next paint event. So if you want to add placemarks to your map widget permanently (i.e. you don't want to take care of repainting) then you need to use other solutions such as the KML import of the Marble framework or Marble's GeoGraphicsItems. \note By default the GeoPainter automatically filters geographical content in order to provide fast painting: \li Geographically positioned objects which are outside the viewport are not drawn at all. Parts of objects which are specified through geographic coordinates (like polygons, ellipses etc.) get cut off if they are not placed within the viewport. \li Objects which have a shape that is specified through geographic coordinates get filtered according to the viewport resolution: If the object is much smaller than a pixel then it won't get drawn at all. */ class MARBLE_EXPORT GeoPainter : public ClipPainter { public: enum Frame { NoOptions = 0x0, RoundFrame = 0x1 }; Q_DECLARE_FLAGS(Frames, Frame) /*! \brief Creates a new geo painter. To create a geo painter it's necessary to provide \a paintDevice as a canvas and the viewportParams to specify the map projection inside the viewport. */ GeoPainter( QPaintDevice * paintDevice, const ViewportParams *viewportParams, MapQuality mapQuality = NormalQuality ); /*! \brief Destroys the geo painter. */ ~GeoPainter(); /*! \brief Returns the map quality. \return The map quality that got assigned to the painter. */ MapQuality mapQuality() const; /*! \brief Draws a text annotation that points to a geodesic position. The annotation consists of a bubble with the specified \a text inside. By choosing an appropriate pen for the painter it's possible to change the color and line style of the bubble outline and the text. The brush chosen for the painter is used to paint the background of the bubble The optional parameters which describe the layout of the bubble are similar to those used by QPainter::drawRoundedRect(). Unlike in QPainter the rounded corners are not specified in percentage but in pixels to provide for optimal aesthetics. By choosing a positive or negative bubbleOffset it's possible to place the annotation on top, bottom, left or right of the annotated position. \param position The geodesic position \param text The text contained by the bubble \param bubbleSize The size of the bubble that holds the annotation text. A height of 0 can be used to have the height calculated automatically to fit the needed text height. \param bubbleOffsetX The x-axis offset between the annotated position and the "root" of the speech bubble's "arrow". \param bubbleOffsetY The y-axis offset between the annotated position and the "root" of the speech bubble's "arrow". \param xRnd Specifies the geometry of the rounded corners in pixels along the x-axis. \param yRnd Specifies the geometry of the rounded corners in pixels along the y-axis. \see GeoDataCoordinates */ void drawAnnotation( const GeoDataCoordinates & position, const QString & text, QSizeF bubbleSize = QSizeF( 130, 100 ), qreal bubbleOffsetX = -10, qreal bubbleOffsetY = -30, qreal xRnd = 5, qreal yRnd = 5 ); /*! \brief Draws a single point at a given geographic position. The point is drawn using the painter's pen color. \see GeoDataCoordinates */ void drawPoint ( const GeoDataCoordinates & position ); /*! \brief Creates a region for a given geographic position. A QRegion object is created that represents the area covered by GeoPainter::drawPoint( GeoDataCoordinates ). It can be used e.g. for input event handling of objects that have been painted using GeoPainter::drawPoint( GeoDataCoordinates ). The width allows to set the "stroke width" for the region. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen. \see GeoDataCoordinates */ QRegion regionFromPoint ( const GeoDataCoordinates & position, qreal strokeWidth = 3) const; /*! \brief Draws a single point at a given geographic position. The point is drawn using the painter's pen color. \see GeoDataPoint */ void drawPoint ( const GeoDataPoint & point ); /*! \brief Create a region for a given geographic position. A QRegion object is created that represents the area covered by GeoPainter::drawPoint( GeoDataPoint ). It can be used e.g. for input event handling of objects that have been painted using GeoPainter::drawPoint( GeoDataPoint ). The width allows to set the "stroke width" for the region. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen. */ QRegion regionFromPoint ( const GeoDataPoint & point, qreal strokeWidth = 3) const; /*! \brief Draws the given text at a given geographic position. The \a text is drawn starting at the given \a position using the painter's font property. The text rendering is performed in screen coordinates and is not subject to the current projection. An offset given in screenPixels can be provided via xOffset and yOffset in order to tweak the text position. By optionally adding a width, height and text options the text flow can be further influenced. */ void drawText ( const GeoDataCoordinates & position, const QString & text, qreal xOffset = 0.0, qreal yOffset = 0.0, qreal width = 0.0, qreal height = 0.0, const QTextOption & option = QTextOption() ); /*! \brief Draws an ellipse at the given position. The ellipse is placed with its center located at the given \a centerPosition. For the outline it uses the painter's pen and for the background the painter's brush. If \a isGeoProjected is true then the outline of the ellipse is drawn in geographic coordinates. In this case the \a width and the \a height are interpreted to be degrees. If \a isGeoProjected is false then the outline of the ellipse is drawn in screen coordinates. In this case the \a width and the \a height are interpreted to be pixels. \see GeoDataCoordinates */ void drawEllipse ( const GeoDataCoordinates & centerPosition, qreal width, qreal height, bool isGeoProjected = false ); /*! \brief Creates a region for an ellipse at a given position A QRegion object is created that represents the area covered by GeoPainter::drawEllipse(). As such it can be used e.g. for input event handling for objects that have been painted using GeoPainter::drawEllipse(). The \a strokeWidth allows to extrude the QRegion by half the amount of "stroke width" pixels. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen. \see GeoDataCoordinates */ QRegion regionFromEllipse ( const GeoDataCoordinates & centerPosition, qreal width, qreal height, bool isGeoProjected = false, qreal strokeWidth = 3 ) const; /*! \brief Draws an image at the given position. The image is placed with its center located at the given \a centerPosition. The image rendering is performed in screen coordinates and is not subject to the current projection. \see GeoDataCoordinates */ void drawImage ( const GeoDataCoordinates & centerPosition, const QImage & image /* , bool isGeoProjected = false */ ); /*! \brief Draws a pixmap at the given position. The pixmap is placed with its center located at the given \a centerPosition. The image rendering is performed in screen coordinates and is not subject to the current projection. \see GeoDataCoordinates */ void drawPixmap ( const GeoDataCoordinates & centerPosition, const QPixmap & pixmap /*, bool isGeoProjected = false */ ); /*! \brief Creates a region for a rectangle for a pixmap at a given position. A QRegion object is created that represents the area covered by GeoPainter::drawPixmap(). This can be used e.g. for input event handling for objects that have been painted using GeoPainter::drawPixmap(). The \a margin allows to extrude the QRegion by "margin" pixels on every side. \see GeoDataCoordinates */ QRegion regionFromPixmapRect(const GeoDataCoordinates ¢erCoordinates, int width, int height, int margin = 0) const; /*! \brief Helper method for safe and quick linestring conversion. In general drawPolyline() should be used instead. However in situations where the same linestring is supposed to be drawn multiple times it's a good idea to cache the screen polygons using this method. \see GeoDataLineString */ void polygonsFromLineString( const GeoDataLineString &lineString, QVector &polygons) const; /*! \brief Draws a given line string (a "polyline") with a label. The \a lineString is drawn using the current pen. It's possible to provide a \a labelText for the \a lineString. The text is rendered using the painter's font property. The position of the \a labelText can be specified using the \a labelPositionFlags. \see GeoDataLineString */ void drawPolyline ( const GeoDataLineString & lineString, const QString& labelText, LabelPositionFlags labelPositionFlags = LineCenter, const QColor& labelcolor = Qt::black); /*! \brief Draws Labels for a given set of screen polygons. In common cases the drawPolyline overload can be used instead. However in certain more complex cases this particular method might be helpful for further optimization. */ void drawLabelsForPolygons( const QVector &polygons, const QString& labelText, LabelPositionFlags labelPositionFlags, const QColor& labelColor ); /*! \brief Draws a given line string (a "polyline"). The \a lineString is drawn using the current pen. \see GeoDataLineString */ void drawPolyline(const GeoDataLineString & lineString); /*! \brief Creates a region for a given line string (a "polyline"). A QRegion object is created that represents the area covered by GeoPainter::drawPolyline( GeoDataLineString ). As such it can be used e.g. for input event handling for objects that have been painted using GeoPainter::drawPolyline( GeoDataLineString ). The \a strokeWidth allows to extrude the QRegion by half the amount of "stroke width" pixels. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen. \see GeoDataLineString */ QRegion regionFromPolyline ( const GeoDataLineString & lineString, qreal strokeWidth = 3 ) const; /*! \brief Draws a given linear ring (a "polygon without holes"). The outline of the \a linearRing is drawn using the current pen. The background is painted using the current brush of the painter. Like in QPainter::drawPolygon() the \a fillRule specifies the fill algorithm that is used to fill the polygon. \see GeoDataLinearRing */ void drawPolygon ( const GeoDataLinearRing & linearRing, Qt::FillRule fillRule = Qt::OddEvenFill ); /*! \brief Creates a region for a given linear ring (a "polygon without holes"). A QRegion object is created that represents the area covered by GeoPainter::drawPolygon( GeoDataLinearRing ). As such it can be used e.g. for input event handling for objects that have been painted using GeoPainter::drawPolygon( GeoDataLinearRing ). Like in drawPolygon() the \a fillRule specifies the fill algorithm that is used to fill the polygon. The \a strokeWidth allows to extrude the QRegion by half the amount of "stroke width" pixels. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen. For the polygon case a "cosmetic" strokeWidth of zero should provide the best performance. \see GeoDataLinearRing */ QRegion regionFromPolygon ( const GeoDataLinearRing & linearRing, Qt::FillRule fillRule, qreal strokeWidth = 3 ) const; /*! \brief Draws a given polygon (which may contain holes). The outline of the \a polygon is drawn using the current pen. The background is painted using the current brush of the painter. Like in QPainter::drawPolygon() the \a fillRule specifies the fill algorithm that is used to fill the polygon. \see GeoDataPolygon */ void drawPolygon ( const GeoDataPolygon & polygon, Qt::FillRule fillRule = Qt::OddEvenFill ); QVector createFillPolygons( const QVector & outerPolygons, const QVector & innerPolygons ) const; /*! \brief Draws a rectangle at the given position. The rectangle is placed with its center located at the given \a centerPosition. For the outline it uses the painter's pen and for the background the painter's brush. If \a isGeoProjected is true then the outline of the rectangle is drawn in geographic coordinates. In this case the \a width and the \a height are interpreted to be degrees. If \a isGeoProjected is false then the outline of the rectangle is drawn in screen coordinates. In this case the \a width and the \a height are interpreted to be pixels. \see GeoDataCoordinates */ void drawRect ( const GeoDataCoordinates & centerPosition, qreal width, qreal height, bool isGeoProjected = false ); /*! \brief Creates a region for a rectangle at a given position. A QRegion object is created that represents the area covered by GeoPainter::drawRect(). This can be used e.g. for input event handling for objects that have been painted using GeoPainter::drawRect(). The isGeoProjected parameter is used the same way as for GeoPainter::drawRect(). The \a strokeWidth allows to extrude the QRegion by half the amount of "stroke width" pixels. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen. This is especially true for small objects. \see GeoDataCoordinates */ QRegion regionFromRect ( const GeoDataCoordinates & centerPosition, qreal width, qreal height, bool isGeoProjected = false, qreal strokeWidth = 3 ) const; /*! \brief Draws a rectangle with rounded corners at the given position. The rectangle is placed with its center located at the given \a centerPosition. For the outline it uses the painter's pen and for the background the painter's brush. Unlike in QPainter::drawRoundedRect() the rounded corners are not specified in percentage but in pixels to provide for optimal aesthetics. + \param centerPosition Position of rectangle center \param width Width of the rectangle in pixels \param height Height of the rectangle in pixels \param xRnd Specifies the geometry of the rounded corners in pixels along the x-axis. \param yRnd Specifies the geometry of the rounded corners in pixels along the y-axis. \see GeoDataCoordinates */ void drawRoundedRect(const GeoDataCoordinates ¢erPosition, qreal width, qreal height, qreal xRnd = 25.0, qreal yRnd = 25.0); void drawTextFragment(const QPoint &position, const QString &text, const qreal fontSize, const QColor &color = Qt::black, const Frames &flags = nullptr); // Reenabling QPainter+ClipPainter methods. using QPainter::drawText; using QPainter::drawEllipse; using QPainter::drawImage; using QPainter::drawPixmap; using QPainter::drawPoint; using ClipPainter::drawPolyline; using ClipPainter::drawPolygon; using QPainter::drawRect; using QPainter::drawRoundedRect; private: Q_DISABLE_COPY( GeoPainter ) GeoPainterPrivate * const d; }; } #endif diff --git a/src/lib/marble/MarbleMap.h b/src/lib/marble/MarbleMap.h index e820a0ed3..dff0ea493 100644 --- a/src/lib/marble/MarbleMap.h +++ b/src/lib/marble/MarbleMap.h @@ -1,809 +1,811 @@ // // 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 + * @param unit the angle units * @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 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 name name of the 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 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 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 8922eac0a..975536fc1 100644 --- a/src/lib/marble/MarbleModel.h +++ b/src/lib/marble/MarbleModel.h @@ -1,341 +1,342 @@ // // 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 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 + * @param name name of the set + * @param description the set description */ 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/MarbleWidget.h b/src/lib/marble/MarbleWidget.h index 9ac84d086..5214b13c8 100644 --- a/src/lib/marble/MarbleWidget.h +++ b/src/lib/marble/MarbleWidget.h @@ -1,1175 +1,1176 @@ // // 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 + * @param unit the angle unit * @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 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 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. */ 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 43e68a00b..2a0a927a1 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: - \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. + NoError No error occurred. + FileWriteError An error occurred when writing to the device. + FileOpenError The file could not be opened. + FilePermissionsError The file could not be accessed. + 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 + CompressionPolicy - \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. + AlwaysCompress A file that is added is compressed. + NeverCompress A file that is added will be stored without changes. + 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/PopupItem.h b/src/lib/marble/PopupItem.h index 220dd3d88..6138ac79f 100644 --- a/src/lib/marble/PopupItem.h +++ b/src/lib/marble/PopupItem.h @@ -1,195 +1,196 @@ // // 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 Torsten Rahn // Copyright 2012 Mohammed Nafees // Copyright 2012 Illya Kovalevskyy // #ifndef POPUPITEM_H #define POPUPITEM_H #include #include #include "BillboardGraphicsItem.h" #ifdef MARBLE_NO_WEBKITWIDGETS #include "ui_NullWebPopupWidget.h" #else #include "ui_WebPopupWidget.h" #endif class QPainter; namespace Marble { /** * @brief The PopupItem Class * * This class represents graphics item for information bubble. * Mostly used by @see MapInfoDialog. * * It has nice API for QWebEngineView and methods for styling it. * */ class PopupItem : public QObject, public BillboardGraphicsItem { Q_OBJECT public: explicit PopupItem( QObject* parent = nullptr ); ~PopupItem() override; /** * @brief Print button visibility indicator * * There is a button in the header of item with print icon. * It used to print the content of QWebEngineView inside. * This method indicates visibility of this button. * * @see setPrintButtonVisible(); * * @return visibility of the print button */ bool isPrintButtonVisible() const; /** * @brief Sets visibility of the print button * * There is a button in the header of item with print icon. * It used to print the content of QWebEngineView inside * * This method sets visibility of this button. * * If @p display is `true`, button will be displayed, * otherwise - button won't be displayed * * @param display visibility of the print button */ void setPrintButtonVisible(bool display); /** * @brief Set URL for web window * * There is a small web browser inside. * It can show open websites. * * This method sets @p url for its window. * * @param url new url for web window */ void setUrl( const QUrl &url ); /** * @brief Set content of the popup * * There is a small web browser inside. It can show custom HTML. * This method sets custom @p html for its window * * @param html custom html for popup + * @param baseUrl base URL for popup */ void setContent( const QString &html, const QUrl & baseUrl = QUrl() ); /** * @brief Sets text color of the header * * Frame of the web browser is called bubble. Bubble has * a header - part of the bubble at the top. Usually * it contains the name of the page which can be set via * TITLE html tag in HTML document loaded. * This method sets text @p color of the header. * * @param color text color of the header */ void setTextColor( const QColor &color ); /** * @brief Sets background color of the bubble * * Frame of the web browser is called bubble. This method * sets background @p color of this bubble. * * @param color background color of the bubble */ void setBackgroundColor( const QColor &color ); bool eventFilter( QObject *, QEvent *e ) override; void clearHistory(); private Q_SLOTS: /** * @brief Marks cache as dirty and tells the world its need for repainting. */ void requestUpdate(); /** * @brief Print content of the web browser * * Popup Item has built-in mini-browser. This function * executes print dialog for printing its content. * */ void printContent() const; /** * @brief Updates Back Button (web surfing history) * * When you are browsing the site you may need to visit * the page, you have visited before (Go Back). * * For this action Popup Item has a button Go Back placed * in the left of the header. * * @note it's visible only if web surfing history is not clear or * you are not on its first page. * * @see goBack(); * */ void updateBackButton(); /** * @brief Go Back (web surfing history) * * This method moves you one step backwards in * web surfing history. * */ void goBack(); /** * @brief Opens clicked URL in external browser. * @param url URL to be opened in external browser */ void openUrl(const QUrl &url); protected: void paint( QPainter *painter ) override; Q_SIGNALS: void repaintNeeded(); void hide(); private: QPixmap pixmap( const QString &imageid ) const; static void colorize( QImage &img, const QColor &col ); QWidget* transform( QPoint &point ) const; QWidget *m_widget; Ui::WebPopupWidget m_ui; QString m_content; QColor m_textColor; QColor m_backColor; bool m_needMouseRelease; QUrl m_baseUrl; }; } #endif diff --git a/src/lib/marble/ViewportParams.h b/src/lib/marble/ViewportParams.h index 0595bf17f..5d99f839d 100644 --- a/src/lib/marble/ViewportParams.h +++ b/src/lib/marble/ViewportParams.h @@ -1,225 +1,226 @@ // // 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 2008 Jens-Michael Hoffmann // #ifndef MARBLE_VIEWPORTPARAMS_H #define MARBLE_VIEWPORTPARAMS_H /** @file * This file contains the headers for ViewportParams. * * @author Inge Wallin */ #include #include "GeoDataCoordinates.h" #include "Quaternion.h" #include "MarbleGlobal.h" #include "marble_export.h" class QPolygonF; class QPainterPath; namespace Marble { class GeoDataLatLonAltBox; class GeoDataLatLonBox; class GeoDataLineString; class AbstractProjection; class ViewportParamsPrivate; /** * @short A public class that controls what is visible in the viewport of a Marble map. * */ class MARBLE_EXPORT ViewportParams { public: ViewportParams( ); explicit ViewportParams( Projection projection, qreal centerLongitude = 0, qreal centerLatitude = 0, int radius = 2000, const QSize &size = QSize( 100, 100 ) ); ~ViewportParams(); // Getters and setters Projection projection() const; const AbstractProjection *currentProjection() const; void setProjection(Projection newProjection); int polarity() const; const GeoDataLatLonAltBox& viewLatLonAltBox() const; GeoDataLatLonAltBox latLonAltBox( const QRect &screenRect ) const; // Calculates an educated guess for the average angle in radians covered per pixel. // Given a certain resolution it doesn't make much sense // - to display an object that covers an angle that is smaller than that. // - to display two points as distinct points if they are separated by a // an angular distance that is smaller. Instead only one point should be shown. // So this method helps to filter out details. // It's somewhat related to http://en.wikipedia.org/wiki/Angular_resolution qreal angularResolution() const; // Determines whether a geographical feature is big enough so that it should // represent a single point on the screen already. // See angularResolution() bool resolves ( const GeoDataLatLonBox &latLonBox, qreal pixel = 2.0 ) const; bool resolves ( const GeoDataLatLonAltBox &latLonAltBox, qreal pixel = 2.0, qreal altitude = 10000.0 ) const; // Determines whether two points are located enough apart so that it makes // sense to display them as distinct points. If this is not the case // calculation and drawing of one point can be skipped as only a single // point will be displayed on the screen. bool resolves ( const GeoDataCoordinates &coord1, const GeoDataCoordinates &coord2 ) const; int radius() const; /** * @brief Change the radius of the planet * @param radius Size of the planet radius in pixel. Non-positive values are ignored. */ void setRadius(int radius); void centerOn( qreal lon, qreal lat ); void setHeading( qreal heading ); Quaternion planetAxis() const; const matrix &planetAxisMatrix() const; int width() const; int height() const; QSize size() const; void setWidth(int newWidth); void setHeight(int newHeight); void setSize(const QSize& newSize); qreal centerLongitude() const; qreal centerLatitude() const; /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. * @param lon the lon coordinate of the requested pixel position in radians * @param lat the lat coordinate of the requested pixel position in radians * @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 * * @see ViewportParams */ bool screenCoordinates( const qreal lon, const qreal lat, qreal &x, qreal &y ) const; /** * @brief Get the screen coordinates corresponding to geographical coordinates in the map. * * @param geopoint the point on earth, including altitude, that we want the coordinates for. * @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 * @param globeHidesPoint whether the point gets hidden on the far side of the earth * * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen * * @see ViewportParams */ bool screenCoordinates( const GeoDataCoordinates &geopoint, qreal &x, qreal &y, bool &globeHidesPoint ) const; // Will just call the virtual version with a dummy globeHidesPoint. bool screenCoordinates( const GeoDataCoordinates &geopoint, qreal &x, qreal &y ) const; /** * @brief Get the coordinates of screen points for geographical coordinates in the map. * * @param coordinates the point on earth, including altitude, that we want the coordinates for. * @param x the x coordinates of the pixels are returned through this parameter * @param y the y coordinate of the pixel is returned through this parameter * @param pointRepeatNum the amount of times that a single geographical point gets represented on the map + * @param size the size of the point * @param globeHidesPoint whether the point gets hidden on the far side of the earth * * @return @c true if the geographical coordinates are visible on the screen * @c false if the geographical coordinates are not visible on the screen * * @see ViewportParams */ bool screenCoordinates( const GeoDataCoordinates &coordinates, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF& size, bool &globeHidesPoint ) const; bool screenCoordinates( const GeoDataLineString &lineString, QVector &polygons ) 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 * @param unit the unit of the angles for lon and lat. * @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, qreal &lon, qreal &lat, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const; qreal heading() const; bool mapCoversViewport() const; QPainterPath mapShape() const; QRegion mapRegion() 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 centerCoordinates 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(); private: Q_DISABLE_COPY( ViewportParams ) ViewportParamsPrivate * const d; }; } #endif diff --git a/src/lib/marble/declarative/MarbleDeclarativeObject.h b/src/lib/marble/declarative/MarbleDeclarativeObject.h index 0a50ae407..fdaa1e458 100644 --- a/src/lib/marble/declarative/MarbleDeclarativeObject.h +++ b/src/lib/marble/declarative/MarbleDeclarativeObject.h @@ -1,59 +1,59 @@ // // 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 Dennis Nienhüser // #ifndef MARBLE_DECLARATIVE_OBJECT_H #define MARBLE_DECLARATIVE_OBJECT_H #include class MarbleDeclarativeObjectPrivate; /** * Provides access to global Marble related properties and methods * to QML (intended to be registered as a global QML object) */ class MarbleDeclarativeObject : public QObject { Q_OBJECT Q_PROPERTY(QString version READ version CONSTANT) public: explicit MarbleDeclarativeObject( QObject* parent = nullptr ); ~MarbleDeclarativeObject() override; /** Returns the Marble library version */ QString version() const; public Q_SLOTS: /** * @brief resolvePath Resolves files in the marble data path * @param path Relative path to a file installed in Marble's data path * @return The absolute path to the given file, or an empty string if the * relative path cannot be resolved - * @see #MarbleDirs + * @see MarbleDirs */ QString resolvePath( const QString &path ) const; /** * @brief canExecute Check whether a given program is found in the path * @param program The name of the program * @return Returns true iff the given program is found in one of * directories defined by the PATH environment variable (as reported by * QProcessEnvironment) and has the executable bit set */ bool canExecute( const QString &program ) const; private: MarbleDeclarativeObjectPrivate* const d; }; #endif diff --git a/src/lib/marble/geodata/data/GeoDataLineStyle.h b/src/lib/marble/geodata/data/GeoDataLineStyle.h index dbd8d75c5..04353c445 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 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 + * @param background @c true if the background should be solid */ 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/GeoDataOverlay.h b/src/lib/marble/geodata/data/GeoDataOverlay.h index a415552cd..4ad7d4260 100644 --- a/src/lib/marble/geodata/data/GeoDataOverlay.h +++ b/src/lib/marble/geodata/data/GeoDataOverlay.h @@ -1,76 +1,76 @@ // // 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 Dennis Nienhüser // #ifndef MARBLE_GEODATAOVERLAY_H #define MARBLE_GEODATAOVERLAY_H #include "geodata_export.h" #include "GeoDataFeature.h" class QColor; class QImage; namespace Marble { class GeoDataOverlayPrivate; /** */ class GEODATA_EXPORT GeoDataOverlay: public GeoDataFeature { public: /** Constructor */ GeoDataOverlay(); ~GeoDataOverlay() override; GeoDataOverlay( const GeoDataOverlay &other ); GeoDataOverlay& operator=( const GeoDataOverlay &other ); QColor color() const; void setColor( const QColor &color ); int drawOrder() const; void setDrawOrder( int order ); QImage icon() const; void setIcon( const QImage &icon ); void setIconFile( const QString &path ); QString iconFile() const; /** * Returns the #iconFile as an absolute filename. Relative files are * resolved relative to the directory of the GeoDataDocument this overlay - * is part of (see #fileName of #GeoDataDocument) + * is part of (@see fileName of GeoDataDocument) */ QString absoluteIconFile() const; protected: explicit GeoDataOverlay(GeoDataOverlayPrivate *priv); GeoDataOverlay(const GeoDataOverlay& other, GeoDataOverlayPrivate *priv); bool equals(const GeoDataOverlay &other) const; using GeoDataFeature::equals; private: Q_DECLARE_PRIVATE(GeoDataOverlay) }; } #endif diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.h b/src/lib/marble/geodata/data/GeoDataPlacemark.h index f97cdf753..b39dc9655 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 category of the placemark. - * @param category the new category to be used. + * @param index the new category to be used. */ - void setVisualCategory(GeoDataVisualCategory category); + void setVisualCategory(GeoDataVisualCategory index); /** * 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 daadf5f45..463f0d9f4 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 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/GeoDataStyleSelector.h b/src/lib/marble/geodata/data/GeoDataStyleSelector.h index 564f382ec..6bf96a9c7 100644 --- a/src/lib/marble/geodata/data/GeoDataStyleSelector.h +++ b/src/lib/marble/geodata/data/GeoDataStyleSelector.h @@ -1,72 +1,72 @@ // // 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_GEODATASTYLESELECTOR_H #define MARBLE_GEODATASTYLESELECTOR_H #include "GeoDataObject.h" #include "geodata_export.h" namespace Marble { class GeoDataStyleSelectorPrivate; /** * @short an abstract base class for the style classes * * A GeoDataStyleSelector is a base class for the style classes Style * and StyleMap classes. The StyleMap class selects a style based on * the current mode of a Placemark (highlighted or normal). An element * derived from StyleSelector is uniquely identified by its id and its * url. * - * @See GeoDataStyle - * @See GeoDataStyleMap + * @sa GeoDataStyle + * @sa GeoDataStyleMap */ class GEODATA_EXPORT GeoDataStyleSelector : public GeoDataObject { public: ~GeoDataStyleSelector() override; /** * @brief assignment operator */ GeoDataStyleSelector& operator=( const GeoDataStyleSelector& other ); bool operator==( const GeoDataStyleSelector &other ) const; bool operator!=( const GeoDataStyleSelector &other ) const; /** * @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; protected: GeoDataStyleSelector(); GeoDataStyleSelector( const GeoDataStyleSelector& other ); private: GeoDataStyleSelectorPrivate * const d; }; } #endif diff --git a/src/lib/marble/geodata/writer/GeoWriter.h b/src/lib/marble/geodata/writer/GeoWriter.h index 5f449e40c..35dcd27b9 100644 --- a/src/lib/marble/geodata/writer/GeoWriter.h +++ b/src/lib/marble/geodata/writer/GeoWriter.h @@ -1,96 +1,96 @@ // // 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 // #ifndef MARBLE_GEOWRITER_H #define MARBLE_GEOWRITER_H #include "marble_export.h" #include #include namespace Marble { class GeoNode; /** * @brief Standard Marble way of writing XML * This class is intended to be a standardised way of writing XML for marble. * It works with the GeoData classes and writes XML based on the type of output * format that the writer is currently working with. */ class MARBLE_EXPORT GeoWriter : public QXmlStreamWriter { public: GeoWriter(); /** * @brief The main API call to use the XML writer. * To use the XML writer you need to provide an IODevice to write the XML to * and a QList of GeoDataFeatures which contains the data you wish to write. * To define the type of XML document that is to be written you need to set * the current Document Type for this GeoWriter. See @see setDocumentType() */ bool write( QIODevice* device, const GeoNode *feature); /** * @brief Set the current document type. * The current Document Type defines which set of handlers are to be used * when writing the GeoDocument. This string should correspond with the * string used to register the required Tag Writers in @see GeoTagWriter */ void setDocumentType( const QString& documentType ); /** - * @brief Convenience method to write value with key prefixed format + * @brief Convenience method to write \value\ with key prefixed format * @p namespaceUri */ void writeElement( const QString &namespaceUri, const QString &key, const QString &value ); /** - * @brief Convenience method to write value + * @brief Convenience method to write \value\ * **/ void writeElement( const QString &key, const QString &value ); /** - * @brief Convenience method to write value if value is + * @brief Convenience method to write \value\ if value is * not equal to defaultValue. Otherwise, nothing is written. * **/ void writeOptionalElement(const QString &key, const QString &value , const QString &defaultValue = QString() ); /** * @brief writeOptionalAttribute Convenience method to write k=v attributes * if value is not equal to defaultValue */ void writeOptionalAttribute( const QString &key, const QString &value, const QString &defaultValue = QString() ); template void writeOptionalElement( const QString &key, const T &value , const T &defaultValue = T() ) { if ( value != defaultValue ) { writeElement( key, QVariant::fromValue( value ).toString() ); } } private: friend class GeoTagWriter; friend class GeoDataDocumentWriter; bool writeElement( const GeoNode* object ); private: QString m_documentType; }; } #endif diff --git a/src/lib/marble/geodata/writers/kml/KmlOsmPlacemarkDataTagWriter.h b/src/lib/marble/geodata/writers/kml/KmlOsmPlacemarkDataTagWriter.h index b42b94356..dc8792af4 100644 --- a/src/lib/marble/geodata/writers/kml/KmlOsmPlacemarkDataTagWriter.h +++ b/src/lib/marble/geodata/writers/kml/KmlOsmPlacemarkDataTagWriter.h @@ -1,70 +1,72 @@ // // 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 Marius-Valeriu Stanciu // #ifndef MARBLE_KMLOSMPLACEMARKDATATAGWRITER_H #define MARBLE_KMLOSMPLACEMARKDATATAGWRITER_H #include "GeoTagWriter.h" namespace Marble { class GeoDataFeature; class OsmPlacemarkData; class GeoDataGeometry; /** * @brief The KmlOsmPlacemarkDataTagWriter class is not a standard GeoTagWriter extension * because the osm data fields have to be written in relation to the placemark's geometry */ class KmlOsmPlacemarkDataTagWriter { public: /** * @brief write function writes a custom XML schema made to store * OsmPlacemarkData in a valid KML context * @see https://developers.google.com/kml/documentation/extendeddata#opaquedata * * The custom schema has the following structure ( most complex one, for polygons ): + *@code * * ... * * * * .. more tags * * //outer boundary * * * //nd #0 * * * //nd #1 * * ... more nds * * * //first inner boundary * ... * * ... more inner boundaries * * * * + *@endcode */ static bool write( const GeoDataFeature *feature, GeoWriter& writer ); static bool writeOsmData( const GeoDataGeometry *geometry, const OsmPlacemarkData &osmData, GeoWriter& writer ); }; } #endif diff --git a/src/lib/marble/graphicsview/GeoGraphicsItem.cpp b/src/lib/marble/graphicsview/GeoGraphicsItem.cpp index 117c71231..e984188e3 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/kdescendantsproxymodel.h b/src/lib/marble/kdescendantsproxymodel.h index 69b99a085..272085f54 100644 --- a/src/lib/marble/kdescendantsproxymodel.h +++ b/src/lib/marble/kdescendantsproxymodel.h @@ -1,214 +1,208 @@ /* Copyright (c) 2009 Stephen Kelly 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_KDESCENDANTSPROXYMODEL_H #define MARBLE_KDESCENDANTSPROXYMODEL_H #include #include "marble_export.h" // namespace added to avoid symbol clashes with KF5::ItemModels namespace Marble { class KDescendantsProxyModelPrivate; /** @brief Proxy Model for restructuring a Tree into a list. A KDescendantsProxyModel may be used to alter how the items in the tree are presented. Given a model which is represented as a tree: -\image html entitytreemodel.png "A plain EntityTreeModel in a view" - The KDescendantsProxyModel restructures the sourceModel to represent it as a flat list. @code // ... Create an entityTreeModel KDescendantsProxyModel *descProxy = new KDescendantsProxyModel(this); descProxy->setSourceModel(entityTree); view->setModel(descProxy); @endcode -\image html descendantentitiesproxymodel.png "A KDescendantsProxyModel." - KDescendantEntitiesProxyModel can also display the ancestors of the index in the source model as part of its display. @code // ... Create an entityTreeModel KDescendantsProxyModel *descProxy = new KDescendantsProxyModel(this); descProxy->setSourceModel(entityTree); // #### This is new descProxy->setDisplayAncestorData(true); descProxy->setDisplayAncestorSeparator(QString(" / ")); view->setModel(descProxy); @endcode -\image html descendantentitiesproxymodel-withansecnames.png "A KDescendantsProxyModel with ancestor names." - @since 4.6 @author Stephen Kelly */ class MARBLE_EXPORT KDescendantsProxyModel : public QAbstractProxyModel { Q_OBJECT public: /** * Creates a new descendant entities proxy model. * * @param parent The parent object. */ explicit KDescendantsProxyModel(QObject *parent = nullptr); /** * Destroys the descendant entities proxy model. */ ~KDescendantsProxyModel() override; /** * Sets the source @p model of the proxy. */ void setSourceModel(QAbstractItemModel *model) Q_DECL_OVERRIDE; #if 0 /** * @deprecated * * This method does nothing. */ void setRootIndex(const QModelIndex &index); #endif /** * Set whether to show ancestor data in the model. If @p display is true, then * a source model which is displayed as * * @code * -> "Item 0-0" (this is row-depth) * -> -> "Item 0-1" * -> -> "Item 1-1" * -> -> -> "Item 0-2" * -> -> -> "Item 1-2" * -> "Item 1-0" * @endcode * * will be displayed as * * @code * -> *Item 0-0" * -> "Item 0-0 / Item 0-1" * -> "Item 0-0 / Item 1-1" * -> "Item 0-0 / Item 1-1 / Item 0-2" * -> "Item 0-0 / Item 1-1 / Item 1-2" * -> "Item 1-0" * @endcode * * If @p display is false, the proxy will show * * @code * -> *Item 0-0" * -> "Item 0-1" * -> "Item 1-1" * -> "Item 0-2" * -> "Item 1-2" * -> "Item 1-0" * @endcode * * Default is false. */ void setDisplayAncestorData(bool display); /** * Whether ancestor data will be displayed. */ bool displayAncestorData() const; /** * Sets the ancestor @p separator used between data of ancestors. */ void setAncestorSeparator(const QString &separator); /** * Separator used between data of ancestors. */ QString ancestorSeparator() const; QModelIndex mapFromSource(const QModelIndex &sourceIndex) const Q_DECL_OVERRIDE; QModelIndex mapToSource(const QModelIndex &proxyIndex) const Q_DECL_OVERRIDE; Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE; QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE; QStringList mimeTypes() const Q_DECL_OVERRIDE; bool hasChildren(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; QModelIndex index(int, int, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; QModelIndex parent(const QModelIndex &) const Q_DECL_OVERRIDE; int columnCount(const QModelIndex &index = QModelIndex()) const Q_DECL_OVERRIDE; Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE; /** Reimplemented to match all descendants. */ QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap)) const Q_DECL_OVERRIDE; private: Q_DECLARE_PRIVATE(KDescendantsProxyModel) //@cond PRIVATE KDescendantsProxyModelPrivate *d_ptr; Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeInserted(const QModelIndex &, int, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsInserted(const QModelIndex &, int, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeRemoved(const QModelIndex &, int, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsRemoved(const QModelIndex &, int, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)) Q_PRIVATE_SLOT(d_func(), void sourceModelAboutToBeReset()) Q_PRIVATE_SLOT(d_func(), void sourceModelReset()) Q_PRIVATE_SLOT(d_func(), void sourceLayoutAboutToBeChanged()) Q_PRIVATE_SLOT(d_func(), void sourceLayoutChanged()) Q_PRIVATE_SLOT(d_func(), void sourceDataChanged(const QModelIndex &, const QModelIndex &)) Q_PRIVATE_SLOT(d_func(), void sourceModelDestroyed()) Q_PRIVATE_SLOT(d_func(), void processPendingParents()) // Make these private, they shouldn't be called by applications // virtual bool insertRows(int , int, const QModelIndex & = QModelIndex()); // virtual bool insertColumns(int, int, const QModelIndex & = QModelIndex()); // virtual bool removeRows(int, int, const QModelIndex & = QModelIndex()); // virtual bool removeColumns(int, int, const QModelIndex & = QModelIndex()); //@endcond }; } #endif diff --git a/src/lib/marble/osm/OsmPlacemarkData.h b/src/lib/marble/osm/OsmPlacemarkData.h index 8c6ee1c11..58fdaf0ed 100644 --- a/src/lib/marble/osm/OsmPlacemarkData.h +++ b/src/lib/marble/osm/OsmPlacemarkData.h @@ -1,235 +1,235 @@ // // 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 Marius-Valeriu Stanciu // #ifndef MARBLE_OSMPLACEMARKDATA_H #define MARBLE_OSMPLACEMARKDATA_H // Qt #include #include #include // Marble #include "GeoDataCoordinates.h" #include #include "GeoDocument.h" class QXmlStreamAttributes; namespace Marble { /** * This class is used to encapsulate the osm data fields kept within a placemark's extendedData. * It stores OSM server generated data: id, version, changeset, uid, visible, user, timestamp; - * It also stores a hash map of ( key-value mappings ) and a hash map of component osm + * It also stores a hash map of \ ( key-value mappings ) and a hash map of component osm * placemarks @see m_nodeReferences @see m_memberReferences * * The usual workflow with osmData goes as follows: * * Parsing stage: * The OsmParser parses tags (they have server-generated attributes), creates new placemarks and * assigns them new OsmPlacemarkData objects with all the needed information. * * Editing stage: * While editing placemarks that have OsmPlacemarkData, all relevant changes reflect on the * OsmPlacemarkData object as well, so as not to uncorrelate data from the actual placemarks. * * Writing stage: * The OsmObjectManager assigns OsmPlacemarkData objects to placemarks that do not have it * ( these are usually newly created placemarks within the editor, or placemarks loaded from * ".kml" files ). Placemarks that already have it, are simply written as-is. */ class MARBLE_EXPORT OsmPlacemarkData: public GeoNode { public: OsmPlacemarkData(); qint64 id() const; qint64 oid() const; QString version() const; QString changeset() const; QString uid() const; QString isVisible() const; QString user() const; QString timestamp() const; QString action() const; const char* nodeType() const override; void setId( qint64 id ); void setVersion( const QString& version ); void setChangeset( const QString& changeset ); void setUid( const QString& uid ); void setVisible( const QString& visible ); void setUser( const QString& user ); void setTimestamp( const QString& timestamp ); void setAction( const QString& action ); /** * @brief tagValue returns the value of the tag that has @p key as key * or an empty qstring if there is no such tag */ QString tagValue( const QString &key ) const; /** * @brief addTag this function inserts a string key=value mapping, - * equivalent to the osm core data + * equivalent to the \ osm core data * element */ void addTag( const QString& key, const QString& value ); /** * @brief removeTag removes the tag from the tag hash */ void removeTag( const QString& key ); /** * @brief containsTag returns true if the tag hash contains an entry with * the @p key as key and @p value as value */ bool containsTag( const QString& key, const QString& value ) const; /** * @brief containsTagKey returns true if the tag hash contains an entry with * the @p key as key */ bool containsTagKey( const QString& key ) const; /** * @brief tagValue returns a pointer to the tag that has @p key as key * or the end iterator if there is no such tag */ QHash::const_iterator findTag(const QString &key) const; /** * @brief iterators for the tags hash. */ QHash< QString, QString >::const_iterator tagsBegin() const; QHash< QString, QString >::const_iterator tagsEnd() const; /** * @brief this function returns the osmData associated with a nd */ OsmPlacemarkData &nodeReference( const GeoDataCoordinates& coordinates ); OsmPlacemarkData nodeReference( const GeoDataCoordinates& coordinates ) const; /** * @brief addRef this function inserts a GeoDataCoordinates = OsmPlacemarkData - * mapping into the reference hash, equivalent to the + * mapping into the reference hash, equivalent to the \ * osm core data element */ void addNodeReference( const GeoDataCoordinates& key, const OsmPlacemarkData &value ); void removeNodeReference( const GeoDataCoordinates& key ); bool containsNodeReference( const GeoDataCoordinates& key ) const; /** * @brief changeNodeReference is a convenience function that allows the quick change of * a node hash entry. This is generally used to update the osm data in case * nodes are being moved in the editor. */ void changeNodeReference( const GeoDataCoordinates& oldKey, const GeoDataCoordinates &newKey ); /** * @brief iterators for the reference hashes. */ QHash< GeoDataCoordinates, OsmPlacemarkData > & nodeReferences(); QHash< GeoDataCoordinates, OsmPlacemarkData >::const_iterator nodeReferencesBegin() const; QHash< GeoDataCoordinates, OsmPlacemarkData >::const_iterator nodeReferencesEnd() const; /** * @brief this function returns the osmData associated with a member boundary's index * -1 represents the outer boundary of a polygon, and 0,1,2... the inner boundaries, * in the order provided by polygon->innerBoundaries(); */ OsmPlacemarkData &memberReference( int key ); OsmPlacemarkData memberReference( int key ) const; /** * @brief addRef this function inserts a int = OsmplacemarkData - * mapping into the reference hash, equivalent to the osm + * mapping into the reference hash, equivalent to the osm \ * core data element * @see m_memberReferences */ void addMemberReference( int key, const OsmPlacemarkData &value ); void removeMemberReference( int key ); bool containsMemberReference( int key ) const; QHash< int, OsmPlacemarkData > & memberReferences(); QHash< int, OsmPlacemarkData >::const_iterator memberReferencesBegin() const; QHash< int, OsmPlacemarkData >::const_iterator memberReferencesEnd() const; /** * @brief addRelation calling this makes the osm placemark a member of the relation * with @p id as id, while having the role @p role */ void addRelation( qint64 id, const QString &role ); void removeRelation( qint64 id ); bool containsRelation( qint64 id ) const; QHash< qint64, QString >::const_iterator relationReferencesBegin() const; QHash< qint64, QString >::const_iterator relationReferencesEnd() const; /** * @brief isNull returns false if the osmData is loaded from a source * or true if its just default constructed */ bool isNull() const; /** * @brief isEmpty returns true if no attribute other than the id has been set */ bool isEmpty() const; /** * @brief fromParserAttributes is a convenience function that parses all osm-related * arguments of a tag * @return an OsmPlacemarkData object containing all the necessary data */ static OsmPlacemarkData fromParserAttributes( const QXmlStreamAttributes &attributes ); private: qint64 m_id; QHash m_tags; /** * @brief m_ndRefs is used to store a way's component nodes * ( It is empty for other placemark types ) */ QHash< GeoDataCoordinates, OsmPlacemarkData > m_nodeReferences; /** * @brief m_memberRefs is used to store a polygon's member boundaries * the key represents the index of the boundary within the polygon geometry: * -1 represents the outerBoundary, and 0,1,2... its innerBoundaries, in the * order provided by polygon->innerBoundaries() */ QHash m_memberReferences; /** * @brief m_relationReferences is used to store the relations the placemark is part of * and the role it has within them. * Eg. an entry ( "123", "stop" ) means that the parent placemark is a member of * the relation with id "123", while having the "stop" role */ QHash m_relationReferences; }; } // Makes qvariant_cast possible for OsmPlacemarkData objects Q_DECLARE_METATYPE( Marble::OsmPlacemarkData ) #endif diff --git a/src/plugins/render/annotate/SceneGraphicsItem.h b/src/plugins/render/annotate/SceneGraphicsItem.h index e55e12daf..9c37840b3 100644 --- a/src/plugins/render/annotate/SceneGraphicsItem.h +++ b/src/plugins/render/annotate/SceneGraphicsItem.h @@ -1,195 +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 @p enabled. * - * @param enabled whether the item is to be focussed + * @param enabled whether the item is to be focused */ 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/stars/StarsPlugin.h b/src/plugins/render/stars/StarsPlugin.h index 858ff562e..40d9246c7 100644 --- a/src/plugins/render/stars/StarsPlugin.h +++ b/src/plugins/render/stars/StarsPlugin.h @@ -1,325 +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 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 + * @brief create a dsopoint from right ascension and declination + * @param id point identifier + * @param rect right ascension + * @param decl declination * (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/render/weather/WeatherModel.h b/src/plugins/render/weather/WeatherModel.h index b4369872f..88f4828f1 100644 --- a/src/plugins/render/weather/WeatherModel.h +++ b/src/plugins/render/weather/WeatherModel.h @@ -1,74 +1,74 @@ // // 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 WEATHERMODEL_H #define WEATHERMODEL_H #include "AbstractDataPluginModel.h" #include "WeatherData.h" #include class QByteArray; class QTimer; namespace Marble { class AbstractWeatherService; class GeoDataLatLonAltBox; class MarbleWidget; class MarbleModel; class WeatherModel : public AbstractDataPluginModel { Q_OBJECT public: explicit WeatherModel( const MarbleModel *marbleModel, QObject *parent ); ~WeatherModel() override; void setUpdateInterval( quint32 hours ); void setFavoriteItems( const QStringList& list ) override; public Q_SLOTS: /** * Downloads the file from @p url. @p item -> addDownloadedFile() will be called when the * download is finished. Additionally initialized() items will be added to the item list * after the download. - * @param: The type of the download + * @param type The type of the download **/ void downloadItemData( const QUrl& url, const QString& type, AbstractDataPluginItem *item ); void downloadDescriptionFileRequested( const QUrl& url ); void setMarbleWidget(MarbleWidget *widget); Q_SIGNALS: void favoriteItemChanged( const QString& id, bool isFavorite ); protected: void getAdditionalItems( const GeoDataLatLonAltBox& box, qint32 number = 10 ) override; void getItem( const QString &id ) override; void parseFile( const QByteArray& file ) override; private: void addService( AbstractWeatherService *service ); QList m_services; QTimer *m_timer; }; } // namespace Marble #endif // WEATHERMODEL_H diff --git a/src/plugins/runner/osm/translators/OsmDocumentTagTranslator.h b/src/plugins/runner/osm/translators/OsmDocumentTagTranslator.h index 57250e1ad..9a4771390 100644 --- a/src/plugins/runner/osm/translators/OsmDocumentTagTranslator.h +++ b/src/plugins/runner/osm/translators/OsmDocumentTagTranslator.h @@ -1,42 +1,43 @@ // // 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 Stanciu Marius-Valeriu // #ifndef MARBLE_OSMDOCUMENTTAGTRANSLATOR_H #define MARBLE_OSMDOCUMENTTAGTRANSLATOR_H #include "GeoTagWriter.h" namespace Marble { /** This helper class organizes a GeoDataDocument to meet the following OSM standard structure: - +@code block of nodes: ( ...) 1st block of ways: ( ...) 2nd block of relations: ( ...) 3rd +@endcode See http://wiki.openstreetmap.org/wiki/OSM_XML#Contents */ class OsmDocumentTagTranslator : public GeoTagWriter { public: bool write( const GeoNode *node, GeoWriter& writer ) const override; }; } #endif diff --git a/src/plugins/runner/osm/writers/OsmTagTagWriter.h b/src/plugins/runner/osm/writers/OsmTagTagWriter.h index 5223d1a6b..685a77e2c 100644 --- a/src/plugins/runner/osm/writers/OsmTagTagWriter.h +++ b/src/plugins/runner/osm/writers/OsmTagTagWriter.h @@ -1,39 +1,39 @@ // // 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 Stanciu Marius-Valeriu // #ifndef MARBLE_OSMTAGTAGWRITER_H #define MARBLE_OSMTAGTAGWRITER_H #include namespace Marble { class OsmPlacemarkData; class GeoWriter; class OsmTagTagWriter { public: /** - * @brief writeTags writes multiple OSM + * @brief writeTags writes multiple OSM \ */ static void writeTags( const OsmPlacemarkData &osmData, GeoWriter& writer ); private: static QSet m_blacklist; }; } #endif