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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • graphicsitem
GeoPolygonGraphicsItem.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 2011 Konstantin Oblaukhov <oblaukhov.konstantin@gmail.com>
9 //
10 
11 #include "GeoPolygonGraphicsItem.h"
12 
13 #include "GeoDataLinearRing.h"
14 #include "GeoDataPolygon.h"
15 #include "GeoPainter.h"
16 #include "ViewportParams.h"
17 #include "GeoDataStyle.h"
18 
19 namespace Marble
20 {
21 
22 GeoPolygonGraphicsItem::GeoPolygonGraphicsItem( const GeoDataFeature *feature, const GeoDataPolygon* polygon )
23  : GeoGraphicsItem( feature ),
24  m_polygon( polygon ),
25  m_ring( 0 )
26 {
27 }
28 
29 GeoPolygonGraphicsItem::GeoPolygonGraphicsItem( const GeoDataFeature *feature, const GeoDataLinearRing* ring )
30  : GeoGraphicsItem( feature ),
31  m_polygon( 0 ),
32  m_ring( ring )
33 {
34 }
35 
36 const GeoDataLatLonAltBox& GeoPolygonGraphicsItem::latLonAltBox() const
37 {
38  if( m_polygon ) {
39  return m_polygon->latLonAltBox();
40  } else if ( m_ring ) {
41  return m_ring->latLonAltBox();
42  } else {
43  return GeoGraphicsItem::latLonAltBox();
44  }
45 }
46 
47 void GeoPolygonGraphicsItem::paint( GeoPainter* painter, const ViewportParams* viewport )
48 {
49  Q_UNUSED( viewport );
50 
51  painter->save();
52 
53  if ( !style() ) {
54  painter->setPen( QPen() );
55  }
56  else {
57  QPen currentPen = painter->pen();
58 
59  if ( !style()->polyStyle().outline() ) {
60  currentPen.setColor( Qt::transparent );
61  }
62  else {
63  if ( currentPen.color() != style()->lineStyle().paintedColor() ||
64  currentPen.widthF() != style()->lineStyle().width() ) {
65  currentPen.setColor( style()->lineStyle().paintedColor() );
66  currentPen.setWidthF( style()->lineStyle().width() );
67  }
68 
69  if ( currentPen.capStyle() != style()->lineStyle().capStyle() )
70  currentPen.setCapStyle( style()->lineStyle().capStyle() );
71 
72  if ( currentPen.style() != style()->lineStyle().penStyle() )
73  currentPen.setStyle( style()->lineStyle().penStyle() );
74 
75  if ( painter->mapQuality() != Marble::HighQuality
76  && painter->mapQuality() != Marble::PrintQuality ) {
77  QColor penColor = currentPen.color();
78  penColor.setAlpha( 255 );
79  currentPen.setColor( penColor );
80  }
81  }
82 
83  if ( painter->pen() != currentPen )
84  painter->setPen( currentPen );
85 
86  if ( !style()->polyStyle().fill() ) {
87  if ( painter->brush().color() != Qt::transparent )
88  painter->setBrush( QColor( Qt::transparent ) );
89  }
90  else {
91  if ( painter->brush().color() != style()->polyStyle().paintedColor() ) {
92  painter->setBrush( style()->polyStyle().paintedColor() );
93  }
94  }
95  }
96 
97  if ( m_polygon ) {
98  painter->drawPolygon( *m_polygon );
99  } else if ( m_ring ) {
100  painter->drawPolygon( *m_ring );
101  }
102 
103  painter->restore();
104 }
105 
106 }
Marble::GeoDataLineStyle::capStyle
Qt::PenCapStyle capStyle() const
Return the current pen cap style.
Definition: GeoDataLineStyle.cpp:115
QPen::style
Qt::PenStyle style() const
QPen::setStyle
void setStyle(Qt::PenStyle style)
Marble::GeoPainter::drawPolygon
void drawPolygon(const GeoDataLinearRing &linearRing, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws a given linear ring (a "polygon without holes").
Definition: GeoPainter.cpp:560
Marble::GeoGraphicsItem::style
const GeoDataStyle * style() const
Returns the style of item.
Definition: GeoGraphicsItem.cpp:82
Marble::GeoDataLinearRing
A LinearRing that allows to store a closed, contiguous set of line segments.
Definition: GeoDataLinearRing.h:68
Marble::GeoPolygonGraphicsItem::GeoPolygonGraphicsItem
GeoPolygonGraphicsItem(const GeoDataFeature *feature, const GeoDataPolygon *polygon)
Definition: GeoPolygonGraphicsItem.cpp:22
GeoPolygonGraphicsItem.h
GeoDataPolygon.h
Marble::GeoDataLineStyle::penStyle
Qt::PenStyle penStyle() const
Return the current pen cap style.
Definition: GeoDataLineStyle.cpp:125
Marble::GeoPainter
A painter that allows to draw geometric primitives on the map.
Definition: GeoPainter.h:98
Marble::GeoDataStyle::polyStyle
GeoDataPolyStyle & polyStyle()
Return the label style of this style.
Definition: GeoDataStyle.cpp:153
Marble::GeoPolygonGraphicsItem::m_ring
const GeoDataLinearRing *const m_ring
Definition: GeoPolygonGraphicsItem.h:35
GeoDataStyle.h
QPainter::save
void save()
Marble::GeoGraphicsItem
Definition: GeoGraphicsItem.h:30
QColor::setAlpha
void setAlpha(int alpha)
Marble::PrintQuality
Print quality.
Definition: MarbleGlobal.h:87
Marble::GeoDataStyle::lineStyle
GeoDataLineStyle & lineStyle()
Return the label style of this style.
Definition: GeoDataStyle.cpp:143
Marble::GeoGraphicsItem::latLonAltBox
virtual const GeoDataLatLonAltBox & latLonAltBox() const
Returns the bounding box covered by the item.
Definition: GeoGraphicsItem.cpp:67
Marble::GeoDataLineStyle::width
float width() const
Return the current width of the line.
Definition: GeoDataLineStyle.cpp:100
QBrush::color
const QColor & color() const
QPen::setCapStyle
void setCapStyle(Qt::PenCapStyle style)
Marble::GeoPolygonGraphicsItem::latLonAltBox
virtual const GeoDataLatLonAltBox & latLonAltBox() const
Returns the bounding box covered by the item.
Definition: GeoPolygonGraphicsItem.cpp:36
QPen::color
QColor color() const
Marble::GeoDataPolygon::latLonAltBox
virtual const GeoDataLatLonAltBox & latLonAltBox() const
Returns the smallest latLonAltBox that contains the Polygon.
Definition: GeoDataPolygon.cpp:118
QPainter::setPen
void setPen(const QColor &color)
Marble::GeoDataPolygon
A polygon that can have "holes".
Definition: GeoDataPolygon.h:81
QPen::setWidthF
void setWidthF(qreal width)
QPainter::setBrush
void setBrush(const QBrush &brush)
QColor
GeoPainter.h
QPen::setColor
void setColor(const QColor &color)
Marble::ViewportParams
A public class that controls what is visible in the viewport of a Marble map.
Definition: ViewportParams.h:44
QPainter::brush
const QBrush & brush() const
GeoDataLinearRing.h
ViewportParams.h
This file contains the headers for ViewportParams.
QPainter::restore
void restore()
Marble::HighQuality
High quality (e.g. antialiasing for lines)
Definition: MarbleGlobal.h:86
QPen::capStyle
Qt::PenCapStyle capStyle() const
Marble::GeoDataFeature
A base class for all geodata features.
Definition: GeoDataFeature.h:57
QPen::widthF
qreal widthF() const
Marble::GeoPolygonGraphicsItem::paint
virtual void paint(GeoPainter *painter, const ViewportParams *viewport)
Paints the item using the given GeoPainter.
Definition: GeoPolygonGraphicsItem.cpp:47
QPen
Marble::GeoPainter::mapQuality
MapQuality mapQuality() const
Returns the map quality.
Definition: GeoPainter.cpp:191
QPainter::pen
const QPen & pen() const
Marble::GeoDataLatLonAltBox
A class that defines a 3D bounding box for geographic data.
Definition: GeoDataLatLonAltBox.h:49
Marble::GeoDataLineString::latLonAltBox
virtual const GeoDataLatLonAltBox & latLonAltBox() const
Returns the smallest latLonAltBox that contains the LineString.
Definition: GeoDataLineString.cpp:580
Marble::GeoPolygonGraphicsItem::m_polygon
const GeoDataPolygon *const m_polygon
Definition: GeoPolygonGraphicsItem.h:34
Marble::GeoDataColorStyle::paintedColor
QColor paintedColor() const
Returns the color that should be painted: Either color() or a randomized version of it...
Definition: GeoDataColorStyle.cpp:103
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 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
  • 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