• 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
  • graphicsitem
ScreenOverlayGraphicsItem.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 Mohammed Nafees <nafees.technocool@gmail.com>
9 // Copyright 2012 Dennis Nienhüser <earthwings@gentoo.org>
10 //
11 
12 #include "ScreenOverlayGraphicsItem.h"
13 
14 #include "ViewportParams.h"
15 
16 namespace Marble {
17 
18 ScreenOverlayGraphicsItem::ScreenOverlayGraphicsItem( const GeoDataScreenOverlay *screenOverlay ) :
19  m_screenOverlay( screenOverlay )
20 {
22  setSize( QSizeF( m_screenOverlay->size().x(), m_screenOverlay->size().y() ) );
23 
24  if ( !m_screenOverlay->icon().isNull() ) {
25  m_pixmap = QPixmap::fromImage( m_screenOverlay->icon().scaled( size().toSize() ) );
26  }
27 }
28 
29 const GeoDataScreenOverlay *ScreenOverlayGraphicsItem::screenOverlay() const
30 {
31  return m_screenOverlay;
32 }
33 
34 void ScreenOverlayGraphicsItem::setProjection( const ViewportParams *viewport )
35 {
36  ScreenGraphicsItem::setProjection( viewport );
38  setPosition( QPointF( pixelValue( m_screenOverlay->screenXY().xunit(),
39  viewport->width(),
40  size().width(),
41  m_screenOverlay->screenXY().x() ),
42  viewport->height()-pixelValue( m_screenOverlay->screenXY().yunit(),
43  viewport->height(),
44  size().height(),
45  m_screenOverlay->screenXY().y() ) ) );
46 }
47 
48 qreal ScreenOverlayGraphicsItem::pixelValue( GeoDataVec2::Unit unit, qreal screenSize, qreal imageSize, qreal value ) const
49 {
50  switch (unit) {
51  case GeoDataVec2::Pixels:
52  return imageSize;
53  break;
54  case GeoDataVec2::Fraction:
55  return value * screenSize;
56  break;
57  case GeoDataVec2::InsetPixels:
58  return screenSize - imageSize - value;
59  break;
60  }
61 
62  Q_ASSERT( false );
63  return 0.0;
64 }
65 
66 void ScreenOverlayGraphicsItem::paint( QPainter *painter )
67 {
68  if ( m_pixmap.isNull() ) {
69  painter->setBrush( m_screenOverlay->color() );
70  painter->drawRect( QRectF( QPointF( 0.0, 0.0 ), size() ) );
71  } else {
72  painter->drawPixmap( QPointF( 0.0, 0.0 ), m_pixmap );
73  }
74 }
75 
76 }
QPainter
Marble::GeoDataScreenOverlay::screenXY
GeoDataVec2 screenXY() const
Definition: GeoDataScreenOverlay.cpp:78
ScreenOverlayGraphicsItem.h
Marble::GeoDataVec2::Fraction
Definition: GeoDataVec2.h:25
Marble::MarbleGraphicsItem::setSize
void setSize(const QSizeF &size)
Set the size of the item.
Definition: MarbleGraphicsItem.cpp:197
Marble::GeoDataVec2::Unit
Unit
Definition: GeoDataVec2.h:25
Marble::GeoDataVec2::xunit
Unit xunit() const
Definition: GeoDataVec2.cpp:78
Marble::MarbleGraphicsItem::size
QSizeF size() const
Returns the size of the item.
Definition: MarbleGraphicsItem.cpp:136
Marble::GeoDataOverlay::color
QColor color() const
Definition: GeoDataOverlay.cpp:60
Marble::ScreenOverlayGraphicsItem::setProjection
void setProjection(const ViewportParams *viewport)
Definition: ScreenOverlayGraphicsItem.cpp:34
Marble::ViewportParams::height
int height() const
Definition: ViewportParams.cpp:255
Marble::GeoDataOverlay::icon
QImage icon() const
Definition: GeoDataOverlay.cpp:80
Marble::ScreenOverlayGraphicsItem::paint
virtual void paint(QPainter *painter)
Paints the item in item coordinates.
Definition: ScreenOverlayGraphicsItem.cpp:66
Marble::ViewportParams::width
int width() const
Definition: ViewportParams.cpp:250
Marble::imageSize
const QSize imageSize(28, 28)
Marble::GeoDataScreenOverlay
Definition: GeoDataScreenOverlay.h:22
Marble::GeoDataScreenOverlay::size
GeoDataVec2 size() const
Definition: GeoDataScreenOverlay.cpp:116
Marble::ViewportParams
A public class that controls what is visible in the viewport of a Marble map.
Definition: ViewportParams.h:44
Marble::GeoDataVec2::yunit
Unit yunit() const
Definition: GeoDataVec2.cpp:88
ViewportParams.h
This file contains the headers for ViewportParams.
Marble::ScreenOverlayGraphicsItem::ScreenOverlayGraphicsItem
ScreenOverlayGraphicsItem(const GeoDataScreenOverlay *screenOverlay)
Definition: ScreenOverlayGraphicsItem.cpp:18
Marble::ScreenGraphicsItem::setPosition
void setPosition(const QPointF &position)
Set the position of the ScreenGraphicsItem.
Definition: ScreenGraphicsItem.cpp:44
Marble::ScreenOverlayGraphicsItem::screenOverlay
const GeoDataScreenOverlay * screenOverlay() const
Definition: ScreenOverlayGraphicsItem.cpp:29
Marble::GeoDataVec2::InsetPixels
Definition: GeoDataVec2.h:25
Marble::GeoDataVec2::Pixels
Definition: GeoDataVec2.h:25
Marble::MarbleGraphicsItem::setProjection
virtual void setProjection(const ViewportParams *viewport)
Definition: MarbleGraphicsItem.cpp:267
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:52 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