27 using namespace Marble;
29 QAtomicInt VectorComposer::refCounter( 0 );
30 PntMap *VectorComposer::s_coastLines( 0 );
31 PntMap *VectorComposer::s_islands( 0 );
32 PntMap *VectorComposer::s_lakeislands( 0 );
33 PntMap *VectorComposer::s_lakes( 0 );
34 PntMap *VectorComposer::s_glaciers( 0 );
35 PntMap *VectorComposer::s_rivers( 0 );
36 PntMap *VectorComposer::s_countries( 0 );
37 PntMap *VectorComposer::s_usaStates( 0 );
38 PntMap *VectorComposer::s_dateLine( 0 );
39 bool VectorComposer::s_coastLinesLoaded(
false );
40 bool VectorComposer::s_overlaysLoaded(
false );
45 m_oceanPen( QPen( Qt::NoPen ) ),
46 m_oceanBrush( QBrush( QColor( 153, 179, 204 ) ) ),
47 m_landPen( QPen( Qt::NoPen ) ),
48 m_landBrush( QBrush( QColor( 242, 239, 233 ) ) ),
49 m_textureLandPen( QPen( Qt::NoPen ) ),
50 m_textureLandBrush( QBrush( QColor( 255, 0, 0 ) ) ),
51 m_textureGlacierBrush( QBrush( QColor( 0, 255, 0 ) ) ),
52 m_textureLakeBrush( QBrush( QColor( 0, 0, 0 ) ) ),
53 m_dateLineBrush( QBrush( Qt::NoBrush ) )
55 #if QT_VERSION < 0x050000
56 if ( refCounter == 0 ) {
58 if ( refCounter.load() == 0 ) {
60 s_coastLinesLoaded =
false;
61 s_overlaysLoaded =
false;
63 s_coastLines =
new PntMap();
65 s_lakeislands =
new PntMap();
69 s_countries =
new PntMap();
70 s_usaStates =
new PntMap();
75 m_textureBorderPen.setStyle( Qt::SolidLine );
76 m_textureBorderPen.setColor( QColor( 0, 255, 0 ) );
77 m_dateLinePen.setStyle( Qt::DashLine );
78 m_dateLinePen.setColor( QColor( 0, 0, 0 ) );
80 connect( s_coastLines, SIGNAL(initialized()), SIGNAL(
datasetLoaded()) );
81 connect( s_islands, SIGNAL(initialized()), SIGNAL(
datasetLoaded()) );
82 connect( s_lakeislands, SIGNAL(initialized()), SIGNAL(
datasetLoaded()) );
83 connect( s_lakes, SIGNAL(initialized()), SIGNAL(
datasetLoaded()) );
84 connect( s_glaciers, SIGNAL(initialized()), SIGNAL(
datasetLoaded()) );
85 connect( s_rivers, SIGNAL(initialized()), SIGNAL(
datasetLoaded()) );
86 connect( s_countries, SIGNAL(initialized()), SIGNAL(
datasetLoaded()) );
87 connect( s_usaStates, SIGNAL(initialized()), SIGNAL(
datasetLoaded()) );
88 connect( s_dateLine, SIGNAL(initialized()), SIGNAL(
datasetLoaded()) );
96 #if QT_VERSION < 0x050000
97 if (refCounter == 0) {
99 if (refCounter.load() == 0) {
107 delete s_lakeislands;
111 s_coastLinesLoaded =
false;
112 s_overlaysLoaded =
false;
116 void VectorComposer::loadCoastlines()
118 if ( s_coastLinesLoaded ) {
121 s_coastLinesLoaded =
true;
135 void VectorComposer::loadOverlays()
137 if ( s_overlaysLoaded ) {
140 s_overlaysLoaded =
true;
159 m_showWaterBodies = show;
174 m_showCoastLines = show;
184 m_showBorders = show;
197 painter->setPen( m_textureLandPen );
198 painter->setBrush( m_textureLandBrush );
206 painter->setPen( m_textureLandPen );
207 painter->setBrush( m_textureLandBrush );
210 if ( m_showWaterBodies && m_showLakes ) {
216 painter->setPen( Qt::NoPen );
217 painter->setBrush( m_textureLakeBrush );
221 painter->setPen( Qt::NoPen );
222 painter->setBrush( m_textureLandBrush );
231 painter->setPen( Qt::NoPen );
232 painter->setBrush( m_textureGlacierBrush );
248 painter->setRenderHint( QPainter::Antialiasing, antialiased );
251 painter->setPen( m_oceanPen );
252 painter->setBrush( m_oceanBrush );
253 painter->drawPath( viewport->
mapShape() );
259 if ( m_showCoastLines ) {
260 painter->setPen( m_landPen );
261 painter->setBrush( Qt::NoBrush );
265 painter->setPen( Qt::NoPen );
266 painter->setBrush( m_landBrush );
278 if ( m_showCoastLines ) {
279 painter->setPen( m_landPen );
280 painter->setBrush( Qt::NoBrush );
284 painter->setPen( Qt::NoPen );
285 painter->setBrush( m_landBrush );
290 if ( ( m_showWaterBodies && m_showLakes ) || m_showCoastLines ) {
296 painter->setPen( m_lakePen );
297 painter->setBrush( m_lakeBrush );
301 painter->setBrush( m_landBrush );
314 painter->setRenderHint( QPainter::Antialiasing, antialiased );
317 if ( m_showCoastLines ) {
325 painter->setPen( m_landPen );
326 painter->setBrush( Qt::NoBrush );
333 painter->setPen( m_landPen );
334 painter->setBrush( Qt::NoBrush );
342 painter->setPen( m_landPen );
343 painter->setBrush( Qt::NoBrush );
350 if ( m_showWaterBodies && m_showRivers ) {
357 painter->setPen( m_riverPen );
358 painter->setBrush( m_riverBrush );
362 if ( m_showBorders ) {
373 int radius = viewport->
radius();
374 qreal penWidth = (double)(radius) / 400.0;
375 if ( radius < 400.0 ) penWidth = 1.0;
376 if ( radius > 800.0 ) penWidth = 1.75;
377 if ( m_showCoastLines ) penWidth = 1.0;
379 QPen countryPen( m_countryPen);
380 countryPen.setWidthF( penWidth );
381 QColor penColor = m_countryPen.color();
383 QPen borderDashPen( Qt::black );
384 painter->setBrush( m_countryBrush );
389 countryPen.setColor( penColor );
390 painter->setPen( countryPen );
396 if ( !m_showCoastLines ) {
397 borderDashPen.setDashPattern( QVector<qreal>() << 1 << 5 );
398 borderDashPen.setWidthF( penWidth * 0.5 );
399 painter->setPen( borderDashPen );
407 if ( !m_showCoastLines ) {
408 countryPen.setWidthF( 1.0 );
409 countryPen.setColor( penColor.darker(115) );
411 painter->setPen( countryPen );
420 QPen statePen( m_statePen);
423 statePen.setStyle( Qt::SolidLine );
425 painter->setPen( statePen );
426 painter->setBrush( m_stateBrush );
434 QPen dateLinePen( m_dateLinePen);
437 dateLinePen.setStyle( Qt::SolidLine );
439 painter->setPen( dateLinePen );
440 painter->setBrush( m_dateLineBrush );
447 #include "VectorComposer.moc"
void load(const QString &)
void setShowLakes(bool show)
static QString path(const QString &relativePath)
virtual ~VectorComposer()
A painter that allows to draw geometric primitives on the map.
void setzPointLimit(const qreal zPointLimit)
void drawTextureMap(GeoPainter *painter, const ViewportParams *viewport)
Low resolution (e.g. interlaced)
void setShowBorders(bool show)
void paintBaseVectorMap(GeoPainter *, const ViewportParams *)
A public class that controls what is visible in the viewport of a Marble map.
void setShowWaterBodies(bool show)
VectorComposer(QObject *parent=0)
This file contains the headers for ViewportParams.
QPainterPath mapShape() const
void setShowCoastLines(bool show)
Only a wire representation is drawn.
void paintMap(GeoPainter *painter)
Paint the background, i.e.
High quality (e.g. antialiasing for lines)
void createFromPntMap(const PntMap *, const ViewportParams *viewport)
void setShowIce(bool show)
void setShowRivers(bool show)
void paintVectorMap(GeoPainter *, const ViewportParams *)
MapQuality mapQuality() const
Returns the map quality.
QDebug mDebug()
a function to replace qDebug() in Marble library code
void setzBoundingBoxLimit(const qreal zBoundingBoxLimit)