File indexing completed on 2024-05-12 03:50:17

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2009 Torsten Rahn <tackat@kde.org>
0004 //
0005 
0006 
0007 #ifndef MARBLE_GEODATAREGION_H
0008 #define MARBLE_GEODATAREGION_H
0009 
0010 #include "GeoDataObject.h"
0011 
0012 namespace Marble
0013 {
0014 
0015 class GeoDataFeature;
0016 class GeoDataLatLonAltBox;
0017 class GeoDataLod;
0018 class GeoDataRegionPrivate;
0019 
0020 /*!
0021     \class GeoDataRegion
0022     \brief GeoDataRegion describes the visibility and extent of a feature.
0023 
0024     GeoDataRegion is a tool class that implements the Region tag/class
0025     of the Open Geospatial Consortium standard KML 2.2.
0026 
0027     GeoDataRegion provides all aspects that can be taken into account to find
0028     out whether a GeoDataFeature (or a GeoDataLink) is visible on the map:
0029 
0030     \li On one hand GeoDataRegion owns a GeoDataLatLon(Alt)Box object.
0031         GeoDataLatLon(Alt)Box is a bounding box in geodesic coordinates.
0032         As such GeoDataLatLon(Alt)Box allows to determine whether the feature is
0033         located inside the area that the observer/camera is looking at
0034         ("viewLatLonAltBox").
0035     \li Additionally GeoDataRegion has got a GeoDataLod ("Level of Detail")
0036         object. GeoDataLod describes the least and maximum size on the
0037         screen that is required to consider a feature to be active.
0038 
0039      A feature is visible if it's active and if its latLonAltBox covers the area
0040      that is being looked at by the observer.
0041 */
0042 
0043 class GEODATA_EXPORT GeoDataRegion : public GeoDataObject
0044 {
0045 
0046   public:
0047 /*!
0048     \brief Creates a new GeoDataRegion object that is not assigned to a \a feature.
0049     Naturally it's recommended to assign a feature or a link to the region (and
0050     therefore it's recommended to use one of the other constructors instead).
0051     This constructor allows to create a stand alone region which can get
0052     assigned to the feature or link later on.
0053 */
0054     GeoDataRegion();
0055 
0056 /*!
0057     \brief Creates a new GeoDataRegion as a copy of \p other.
0058 */
0059     GeoDataRegion( const GeoDataRegion& other );
0060     
0061 /*!
0062     \brief Creates a new GeoDataRegion object that is associated to a \a feature.
0063     In the model the feature represents the parent object of the region.
0064 */
0065     explicit GeoDataRegion( GeoDataFeature * feature );
0066 
0067     
0068 /*!
0069     \brief Destroys a Region object.
0070 */
0071     ~GeoDataRegion() override;
0072 
0073     
0074 /*!
0075     \brief Provides type information for downcasting a GeoNode
0076 */
0077     const char* nodeType() const override;
0078 
0079     bool operator==( const GeoDataRegion &other ) const;
0080     bool operator!=( const GeoDataRegion &other ) const;
0081     
0082 /*!
0083     \brief Returns a geodesic bounding box ("latLonAltBox") of the region.
0084     Returns a geodesic bounding box that describes the extent of a feature or
0085     a link.
0086     If no latLonAltBox has been set then a GeoDataLatLonAltBox object
0087     will be calculated automatically: If the associated parent object is
0088     a feature then the geometry that might be associated to the feature
0089     will be used to calculate the GeoDataLatLonAltBox. Otherwise the
0090     coordinate will be used to create a GeoDataLatLonAltBox (in case that
0091     there is no geometry assigned to the feature or if the parent object of the
0092     region is a GeoDataLink).
0093 */
0094     const GeoDataLatLonAltBox& latLonAltBox() const;
0095 
0096     
0097 /*!
0098     \brief Sets the \a latLonAltBox of the region.
0099     Sets the geodesic bounding box that describes the extent of a feature or
0100     a link.
0101 */
0102     void setLatLonAltBox( const GeoDataLatLonAltBox& latLonAltBox );
0103 
0104 
0105 /*!
0106     \brief Returns the region's level of detail.
0107     The level of detail is returned as a \a lod object. 
0108     If no \a lod has been set then a GeoDataLod object with default values
0109     is being returned.
0110 */
0111     GeoDataLod& lod() const;
0112 
0113     
0114 /*!
0115     \brief Sets a region's level of detail.
0116     The level of detail is set as a \a lod object.
0117 */
0118     void setLod( const GeoDataLod& lod );
0119 
0120 
0121     // Serialization
0122 /*!
0123     \brief Serialize the Region to a stream.
0124     \param stream the stream.
0125 */
0126     void pack( QDataStream& stream ) const override;
0127 
0128 
0129 /*!
0130     \brief Unserialize the Region from a stream.
0131     \param stream the stream.
0132 */
0133     void unpack( QDataStream& stream ) override;
0134 
0135     GeoDataRegion &operator=( const GeoDataRegion& other );
0136 
0137  private:
0138     void swap( GeoDataRegion & other );
0139     GeoDataRegionPrivate  *d;
0140 };
0141 
0142 }
0143 
0144 #endif