• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • writers
  • kml
KmlScreenOverlayWriter.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2012 Mayank Madan <maddiemadan@gmail.com>
9 //
10 
11 #include "KmlScreenOverlayWriter.h"
12 
13 #include "GeoDataScreenOverlay.h"
14 #include "GeoDataTypes.h"
15 #include "GeoWriter.h"
16 #include "GeoTagWriter.h"
17 #include "KmlOverlayTagWriter.h"
18 #include "KmlElementDictionary.h"
19 
20 namespace Marble
21 {
22 static GeoTagWriterRegistrar s_writerLookAt(
23  GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataScreenOverlayType,
24  kml::kmlTag_nameSpace22 ),
25  new KmlScreenOverlayWriter );
26 
27 KmlScreenOverlayWriter::KmlScreenOverlayWriter() : KmlOverlayTagWriter( kml::kmlTag_ScreenOverlay )
28 {
29  // nothing to do
30 }
31 
32 
33 bool KmlScreenOverlayWriter::writeMid( const GeoNode *node, GeoWriter& writer ) const
34 {
35  const GeoDataScreenOverlay *screenOverlay = static_cast<const GeoDataScreenOverlay*>( node );
36  writeVec2( kml::kmlTag_overlayXY, screenOverlay->overlayXY(), writer );
37  writeVec2( kml::kmlTag_rotationXY, screenOverlay->rotationXY(), writer );
38  writeVec2( kml::kmlTag_screenXY, screenOverlay->screenXY(), writer );
39  writeVec2( kml::kmlTag_size, screenOverlay->size(), writer );
40  QString const rotation = QString::number(screenOverlay->rotation());
41  writer.writeOptionalElement( kml::kmlTag_rotation, rotation, "0" );
42  return true;
43 }
44 
45 void KmlScreenOverlayWriter::writeVec2( const QString &element, const GeoDataVec2 &vec2, GeoWriter &writer ) const
46 {
47  writer.writeStartElement( element );
48  writer.writeAttribute( "x", QString::number( vec2.x() ) );
49  writer.writeAttribute( "xunit", unitToString( vec2.xunit() ) );
50  writer.writeAttribute( "y", QString::number( vec2.y() ) );
51  writer.writeAttribute( "yunit", unitToString( vec2.yunit() ) );
52  writer.writeEndElement();
53 }
54 
55 QString KmlScreenOverlayWriter::unitToString( GeoDataVec2::Unit unit ) const
56 {
57  switch( unit ) {
58  case GeoDataVec2::Fraction: return "fraction";
59  case GeoDataVec2::Pixels: return "pixels";
60  case GeoDataVec2::InsetPixels: return "insetPixels";
61  }
62 
63  Q_ASSERT(false);
64  return "fraction";
65 }
66 
67 }
Marble::s_writerLookAt
static GeoTagWriterRegistrar s_writerLookAt(GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataGroundOverlayType, kml::kmlTag_nameSpace22), new KmlGroundOverlayWriter)
Marble::GeoDataScreenOverlay::screenXY
GeoDataVec2 screenXY() const
Definition: GeoDataScreenOverlay.cpp:78
Marble::GeoDataScreenOverlay::overlayXY
GeoDataVec2 overlayXY() const
Definition: GeoDataScreenOverlay.cpp:59
Marble::GeoWriter::writeOptionalElement
void writeOptionalElement(const QString &key, const QString &value, const QString &defaultValue=QString())
Convenience method to write value if value is not equal to defaultValue.
Definition: GeoWriter.cpp:98
Marble::GeoDataVec2::Fraction
Definition: GeoDataVec2.h:25
GeoTagWriter.h
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
Marble::GeoDataVec2::Unit
Unit
Definition: GeoDataVec2.h:25
Marble::GeoDataVec2::xunit
Unit xunit() const
Definition: GeoDataVec2.cpp:78
Marble::KmlOverlayTagWriter
Definition: KmlOverlayTagWriter.h:22
Marble::kml::kmlTag_nameSpace22
const char * kmlTag_nameSpace22
Definition: KmlElementDictionary.cpp:33
Marble::kml::kmlTag_ScreenOverlay
const char * kmlTag_ScreenOverlay
Definition: KmlElementDictionary.cpp:164
Marble::KmlScreenOverlayWriter::KmlScreenOverlayWriter
KmlScreenOverlayWriter()
Definition: KmlScreenOverlayWriter.cpp:27
GeoWriter.h
Marble::GeoDataTypes::GeoDataScreenOverlayType
const char * GeoDataScreenOverlayType
Definition: GeoDataTypes.cpp:79
Marble::GeoDataScreenOverlay::rotationXY
GeoDataVec2 rotationXY() const
Definition: GeoDataScreenOverlay.cpp:97
Marble::GeoDataScreenOverlay
Definition: GeoDataScreenOverlay.h:22
Marble::kml::kmlTag_rotationXY
const char * kmlTag_rotationXY
Definition: KmlElementDictionary.cpp:158
KmlElementDictionary.h
Marble::GeoWriter
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:28
Marble::kml::kmlTag_size
const char * kmlTag_size
Definition: KmlElementDictionary.cpp:170
Marble::GeoTagWriter::QualifiedName
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Definition: GeoTagWriter.h:48
Marble::GeoDataScreenOverlay::size
GeoDataVec2 size() const
Definition: GeoDataScreenOverlay.cpp:116
GeoDataScreenOverlay.h
Marble::GeoDataVec2
Definition: GeoDataVec2.h:22
Marble::GeoDataVec2::yunit
Unit yunit() const
Definition: GeoDataVec2.cpp:88
Marble::kml::kmlTag_screenXY
const char * kmlTag_screenXY
Definition: KmlElementDictionary.cpp:165
KmlScreenOverlayWriter.h
Marble::KmlScreenOverlayWriter::writeMid
bool writeMid(const GeoNode *node, GeoWriter &writer) const
Definition: KmlScreenOverlayWriter.cpp:33
Marble::kml::kmlTag_overlayXY
const char * kmlTag_overlayXY
Definition: KmlElementDictionary.cpp:139
KmlOverlayTagWriter.h
Marble::GeoDataScreenOverlay::rotation
qreal rotation() const
Definition: GeoDataScreenOverlay.cpp:135
GeoDataTypes.h
Marble::GeoDataVec2::InsetPixels
Definition: GeoDataVec2.h:25
Marble::GeoDataVec2::Pixels
Definition: GeoDataVec2.h:25
Marble::kml::kmlTag_rotation
const char * kmlTag_rotation
Definition: KmlElementDictionary.cpp:157
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal