Commit 37a21a79 authored by Mohammed Nafees's avatar Mohammed Nafees Committed by Dennis Nienhüser
Browse files

KML ScreenOverlay reader.

BUG: 310578

Note: Dummy empty line inserted in geodata/CMakeLists.txt to have
cmake pick up the new files. If you still get an undefined reference
for KmlScreenOverlayTagHandler or similar, please invoke cmake
manually to have the GLOB calls execute again.
parent e5a28dac
......@@ -57,3 +57,4 @@ SET( geodata_SRCS
)
#add_subdirectory(geodata/data/tests)
//
// 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 Mohammed Nafees <nafees.technocool@gmail.com>
//
#include "GeoDataScreenOverlay.h"
#include "GeoDataTypes.h"
namespace Marble {
class GeoDataScreenOverlayPrivate
{
public:
GeoDataScreenOverlayPrivate();
GeoDataVec2 m_overlayXY;
GeoDataVec2 m_screenXY;
GeoDataVec2 m_rotationXY;
GeoDataVec2 m_size;
qreal m_rotation;
};
GeoDataScreenOverlayPrivate::GeoDataScreenOverlayPrivate() :
m_rotation(0.0)
{
}
GeoDataScreenOverlay::GeoDataScreenOverlay() :
d( new GeoDataScreenOverlayPrivate )
{
}
GeoDataScreenOverlay::GeoDataScreenOverlay( const Marble::GeoDataScreenOverlay &other ) :
GeoDataOverlay( other ), d( new GeoDataScreenOverlayPrivate( *other.d ) )
{
}
GeoDataScreenOverlay &GeoDataScreenOverlay::operator=( const GeoDataScreenOverlay &other )
{
*d = *other.d;
return *this;
}
GeoDataScreenOverlay::~GeoDataScreenOverlay()
{
delete d;
}
const char *GeoDataScreenOverlay::nodeType() const
{
return GeoDataTypes::GeoDataScreenOverlayType;
}
GeoDataVec2 GeoDataScreenOverlay::overlayXY() const
{
return d->m_overlayXY;
}
void GeoDataScreenOverlay::setOverlayXY(const GeoDataVec2 &vec2)
{
d->m_overlayXY = vec2;
}
void GeoDataScreenOverlay::setOverlayXY(const qreal &x, const qreal &y, const GeoDataVec2::Unit &xunit,
const GeoDataVec2::Unit &yunit)
{
d->m_screenXY.setX(x);
d->m_screenXY.setY(y);
d->m_screenXY.setXunits(xunit);
d->m_screenXY.setYunits(yunit);
}
GeoDataVec2 GeoDataScreenOverlay::screenXY() const
{
return d->m_screenXY;
}
void GeoDataScreenOverlay::setScreenXY(const GeoDataVec2 &vec2)
{
d->m_screenXY = vec2;
}
void GeoDataScreenOverlay::setScreenXY(const qreal &x, const qreal &y, const GeoDataVec2::Unit &xunit,
const GeoDataVec2::Unit &yunit)
{
d->m_screenXY.setX(x);
d->m_screenXY.setY(y);
d->m_screenXY.setXunits(xunit);
d->m_screenXY.setYunits(yunit);
}
GeoDataVec2 GeoDataScreenOverlay::rotationXY() const
{
return d->m_rotationXY;
}
void GeoDataScreenOverlay::setRotationXY(const GeoDataVec2 &vec2)
{
d->m_rotationXY = vec2;
}
void GeoDataScreenOverlay::setRotationXY(const qreal &x, const qreal &y, const GeoDataVec2::Unit &xunit,
const GeoDataVec2::Unit &yunit)
{
d->m_rotationXY.setX(x);
d->m_rotationXY.setY(y);
d->m_rotationXY.setXunits(xunit);
d->m_rotationXY.setYunits(yunit);
}
GeoDataVec2 GeoDataScreenOverlay::size() const
{
return d->m_size;
}
void GeoDataScreenOverlay::setSize(const GeoDataVec2 &vec2)
{
d->m_size = vec2;
}
void GeoDataScreenOverlay::setSize(const qreal &x, const qreal &y, const GeoDataVec2::Unit &xunit,
const GeoDataVec2::Unit &yunit)
{
d->m_size.setX(x);
d->m_size.setY(y);
d->m_size.setXunits(xunit);
d->m_size.setYunits(yunit);
}
qreal GeoDataScreenOverlay::rotation() const
{
return d->m_rotation;
}
void GeoDataScreenOverlay::setRotation(qreal rotation)
{
d->m_rotation = rotation;
}
}
//
// 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 Mohammed Nafees <nafees.technocool@gmail.com>
//
#ifndef GEODATASCREENOVERLAY_H
#define GEODATASCREENOVERLAY_H
#include "GeoDataOverlay.h"
#include "GeoDataVec2.h"
#include "MarbleGlobal.h"
namespace Marble {
class GeoDataScreenOverlayPrivate;
class GeoDataScreenOverlay: public GeoDataOverlay
{
public:
GeoDataScreenOverlay();
GeoDataScreenOverlay( const GeoDataScreenOverlay &other );
GeoDataScreenOverlay& operator=( const GeoDataScreenOverlay &other );
~GeoDataScreenOverlay();
/** Provides type information for downcasting a GeoNode */
virtual const char* nodeType() const;
GeoDataVec2 overlayXY() const;
void setOverlayXY( const GeoDataVec2 &vec2 );
void setOverlayXY( const qreal &x, const qreal &y, const GeoDataVec2::Unit &xunit, const GeoDataVec2::Unit &yunit );
GeoDataVec2 screenXY() const;
void setScreenXY( const GeoDataVec2 &vec2 );
void setScreenXY( const qreal &x, const qreal &y, const GeoDataVec2::Unit &xunit, const GeoDataVec2::Unit &yunit );
GeoDataVec2 rotationXY() const;
void setRotationXY( const GeoDataVec2 &vec2 );
void setRotationXY( const qreal &x, const qreal &y, const GeoDataVec2::Unit &xunit, const GeoDataVec2::Unit &yunit );
GeoDataVec2 size() const;
void setSize( const GeoDataVec2 &vec2 );
void setSize( const qreal &x, const qreal &y, const GeoDataVec2::Unit &xunit, const GeoDataVec2::Unit &yunit );
qreal rotation() const;
void setRotation( qreal rotation );
private:
GeoDataScreenOverlayPrivate* const d;
};
}
#endif
//
// 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 Mohammed Nafees <nafees.technocool@gmail.com>
//
#include "GeoDataVec2.h"
#include "MarbleDebug.h"
namespace Marble {
class GeoDataVec2Private
{
public:
GeoDataVec2Private();
GeoDataVec2::Unit m_xunit;
GeoDataVec2::Unit m_yunit;
GeoDataVec2::Unit parseUnits( const QString &value );
};
GeoDataVec2Private::GeoDataVec2Private() :
m_xunit(GeoDataVec2::Fraction), m_yunit(GeoDataVec2::Fraction)
{
}
GeoDataVec2::GeoDataVec2() :
d( new GeoDataVec2Private )
{
}
GeoDataVec2::GeoDataVec2(const qreal &x, const qreal &y, const QString &xunits, const QString &yunits) :
d( new GeoDataVec2Private )
{
setX( x );
setY( y );
d->m_xunit = d->parseUnits( xunits );
d->m_yunit = d->parseUnits( yunits );
}
GeoDataVec2::Unit GeoDataVec2Private::parseUnits( const QString &value )
{
if ( value == "fraction" ) {
return GeoDataVec2::Fraction;
} else if ( value == "pixels" ) {
return GeoDataVec2::Pixels;
} else if ( value == "insetPixels" ) {
return GeoDataVec2::InsetPixels;
} else {
mDebug() << "Warning: Unknown units value " << value << " - falling back to default 'fraction'";
return GeoDataVec2::Fraction;
}
}
GeoDataVec2::GeoDataVec2( const Marble::GeoDataVec2 &other ) :
QPointF(other), d( new GeoDataVec2Private( *other.d ) )
{
}
GeoDataVec2 &GeoDataVec2::operator=( const GeoDataVec2 &other )
{
QPointF::operator=(other);
*d = *other.d;
return *this;
}
GeoDataVec2::~GeoDataVec2()
{
delete d;
}
GeoDataVec2::Unit GeoDataVec2::xunit() const
{
return d->m_xunit;
}
void GeoDataVec2::setXunits(Unit xunit)
{
d->m_xunit = xunit;
}
GeoDataVec2::Unit GeoDataVec2::yunit() const
{
return d->m_yunit;
}
void GeoDataVec2::setYunits(Unit yunit)
{
d->m_yunit = yunit;
}
}
//
// 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 Mohammed Nafees <nafees.technocool@gmail.com>
//
#ifndef GEODATAVEC2_H
#define GEODATAVEC2_H
#include <QtCore/QPointF>
#include "MarbleGlobal.h"
namespace Marble {
class GeoDataVec2Private;
class GeoDataVec2 : public QPointF
{
public:
enum Unit {Fraction, Pixels, InsetPixels};
GeoDataVec2();
GeoDataVec2( const qreal &x, const qreal &y, const QString &xunit, const QString &yunit );
GeoDataVec2( const qreal &x, const qreal &y, const Unit &xunit, const Unit &yunit );
GeoDataVec2( const GeoDataVec2 &other );
GeoDataVec2& operator=( const GeoDataVec2 &other );
~GeoDataVec2();
Unit xunit() const;
void setXunits( Unit xunit );
Unit yunit() const;
void setYunits( Unit yunit );
private:
GeoDataVec2Private* const d;
};
}
#endif
......@@ -28,6 +28,7 @@
#include "GeoDataIconStyle.h"
#include "GeoDataGroundOverlay.h"
#include "GeoDataPhotoOverlay.h"
#include "GeoDataScreenOverlay.h"
#include "GeoParser.h"
namespace Marble
......@@ -52,6 +53,8 @@ GeoNode* KmlhrefTagHandler::parse( GeoParser& parser ) const
parentItem.nodeAs<GeoDataGroundOverlay>()->setIconFile( content );
} else if ( parentItem.is<GeoDataPhotoOverlay>() ) {
parentItem.nodeAs<GeoDataPhotoOverlay>()->setIconFile( content );
} else if ( parentItem.is<GeoDataScreenOverlay>() ) {
parentItem.nodeAs<GeoDataScreenOverlay>()->setIconFile( content );
}
#ifdef DEBUG_TAGS
mDebug() << "Parsed <" << kmlTag_href << "> containing: " << content
......
......@@ -27,6 +27,7 @@
#include "GeoDataIconStyle.h"
#include "GeoDataGroundOverlay.h"
#include "GeoDataPhotoOverlay.h"
#include "GeoDataScreenOverlay.h"
#include "GeoParser.h"
namespace Marble
......@@ -51,6 +52,8 @@ GeoNode* KmlIconTagHandler::parse( GeoParser& parser ) const
return parentItem.nodeAs<GeoDataGroundOverlay>();
} else if ( parentItem.represents( kmlTag_PhotoOverlay ) ) {
return parentItem.nodeAs<GeoDataPhotoOverlay>();
} else if ( parentItem.represents( kmlTag_ScreenOverlay ) ) {
return parentItem.nodeAs<GeoDataScreenOverlay>();
}
return 0;
}
......
//
// 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 Mohammed Nafees <nafees.technocool@gmail.com>
//
#include "KmlOverlayXYTagHandler.h"
#include "MarbleDebug.h"
#include "KmlElementDictionary.h"
#include "GeoDataScreenOverlay.h"
#include "GeoDataParser.h"
#include "MarbleGlobal.h"
namespace Marble
{
namespace kml
{
KML_DEFINE_TAG_HANDLER( overlayXY )
GeoNode* KmloverlayXYTagHandler::parse( GeoParser& parser ) const
{
Q_ASSERT( parser.isStartElement() && parser.isValidElement( kmlTag_overlayXY ) );
GeoStackItem parentItem = parser.parentElement();
#ifdef DEBUG_TAGS
mDebug() << "Parsed <" << kmlTag_overlayXY << ">"
<< " parent item name: " << parentItem.qualifiedName().first;
#endif
if (parentItem.represents( kmlTag_ScreenOverlay ))
{
GeoDataVec2 vec2(parser.attribute("x").trimmed().toFloat(),
parser.attribute("y").trimmed().toFloat(),
parser.attribute("xunits").trimmed(),
parser.attribute("yunits").trimmed());
parentItem.nodeAs<GeoDataScreenOverlay>()->setOverlayXY( vec2 );
}
return 0;
}
}
}
//
// 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 Mohammed Nafees <nafees.technocool@gmail.com>
//
#ifndef KMLOVERLAYXYTAGHANDLER_H
#define KMLOVERLAYXYTAGHANDLER_H
#include "GeoTagHandler.h"
namespace Marble
{
namespace kml
{
class KmloverlayXYTagHandler : public GeoTagHandler
{
public:
virtual GeoNode* parse(GeoParser&) const;
};
}
}
#endif
//
// 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 Mohammed Nafees <nafees.technocool@gmail.com>
//
#include "KmlRotationTagHandler.h"
#include "MarbleDebug.h"
#include "KmlElementDictionary.h"
#include "GeoDataScreenOverlay.h"
#include "GeoDataParser.h"
namespace Marble
{
namespace kml
{
KML_DEFINE_TAG_HANDLER( rotation )
GeoNode* KmlrotationTagHandler::parse( GeoParser& parser ) const
{
Q_ASSERT( parser.isStartElement() && parser.isValidElement( kmlTag_rotation ) );
GeoStackItem parentItem = parser.parentElement();
if (parentItem.represents( kmlTag_ScreenOverlay ))
{
qreal rotation = parser.readElementText().toFloat();
parentItem.nodeAs<GeoDataScreenOverlay>()->setRotation( rotation );
}
return 0;
}
}
}
//
// 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 Mohammed Nafees <nafees.technocool@gmail.com>
//
#ifndef KMLROTATIONTAGHANDLER_H
#define KMLROTATIONTAGHANDLER_H
#include "GeoTagHandler.h"
namespace Marble
{
namespace kml
{
class KmlrotationTagHandler : public GeoTagHandler
{
public:
virtual GeoNode* parse(GeoParser&) const;
};
}
}
#endif
//
// 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 Mohammed Nafees <nafees.technocool@gmail.com>
//
#include "KmlRotationXYTagHandler.h"
#include "MarbleDebug.h"
#include "KmlElementDictionary.h"
#include "GeoDataScreenOverlay.h"
#include "GeoDataParser.h"
namespace Marble
{
namespace kml
{
KML_DEFINE_TAG_HANDLER( rotationXY )
GeoNode* KmlrotationXYTagHandler::parse( GeoParser& parser ) const
{
Q_ASSERT( parser.isStartElement() && parser.isValidElement( kmlTag_rotationXY ) );
GeoStackItem parentItem = parser.parentElement();
if (parentItem.represents( kmlTag_ScreenOverlay ))
{
GeoDataVec2 vec2(parser.attribute("x").trimmed().toFloat(),
parser.attribute("y").trimmed().toFloat(),
parser.attribute("xunits").trimmed(),
parser.attribute("yunits").trimmed());
parentItem.nodeAs<GeoDataScreenOverlay>()->setRotationXY( vec2 );
}
return 0;
}
}
}
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can