[Marble-commits] KDE/kdeedu/marble/src/plugins/render/graticule
Torsten Rahn
tackat at kde.org
Sun Jul 26 11:54:17 CEST 2009
SVN commit 1002524 by rahn:
- Starting to improve the coordinate grid a bit ...
M +55 -45 GraticulePlugin.cpp
M +15 -1 GraticulePlugin.h
--- trunk/KDE/kdeedu/marble/src/plugins/render/graticule/GraticulePlugin.cpp #1002523:1002524
@@ -68,6 +68,10 @@
{
// Initialize range maps that map the zoom to the number of coordinate grid lines.
initLineMaps( GeoDataCoordinates::defaultNotation() );
+ m_majorCirclePen = QPen( QColor( Qt::yellow ) );
+ m_minorCirclePen = QPen( QColor( Qt::white ) );
+ m_shadowPen = QPen( Qt::NoPen );
+// m_shadowPen = QPen( QColor( 0, 0, 0, 128 ) );
}
bool GraticulePlugin::isInitialized () const
@@ -93,19 +97,6 @@
initLineMaps( GeoDataCoordinates::defaultNotation() );
}
- GeoDataLatLonAltBox viewLatLonAltBox = viewport->viewLatLonAltBox();
-
-/*
- // TESTCASE
- for ( int i = -90; i < 90 ; i+=3 ){
- renderLatitudeCircle( painter, i, viewLatLonAltBox );
- }
-
- for ( int i = -180; i < 180.0 ; i+=3 ){
- renderLongitudeHalfCircle( painter, i, viewLatLonAltBox );
- }
-*/
-
// Setting the label font for the coordinate lines.
#ifdef Q_OS_MACX
int defaultFontSize = 10;
@@ -115,24 +106,41 @@
QFont gridFont("Sans Serif");
gridFont.setPointSize( defaultFontSize );
+ gridFont.setBold( true );
- QFont prominentLineFont = gridFont;
- prominentLineFont.setBold( true );
- painter->setFont( prominentLineFont );
+ painter->setFont( gridFont );
+ if ( m_shadowPen != Qt::NoPen ) {
+ painter->translate( +1.0, +1.0 );
+ renderGrid( painter, viewport, m_shadowPen, m_shadowPen );
+ painter->translate( -1.0, -1.0 );
+ }
+ renderGrid( painter, viewport, m_majorCirclePen, m_minorCirclePen );
+
+ painter->restore();
+
+ return true;
+}
+
+void GraticulePlugin::renderGrid( GeoPainter *painter, ViewportParams *viewport,
+ const QPen& majorCirclePen,
+ const QPen& minorCirclePen )
+{
// Render the normal grid
- painter->setPen( QColor( Qt::white ) );
-// painter->setPen( QPen( QBrush( Qt::white ), 0.75 ) );
+ painter->setPen( minorCirclePen );
+ // painter->setPen( QPen( QBrush( Qt::white ), 0.75 ) );
// calculate the angular distance between coordinate lines of the normal grid
qreal normalDegreeStep = 360.0 / m_normalLineMap.lowerBound(viewport->radius()).value();
- renderLongitudeLines( painter, viewLatLonAltBox,
- normalDegreeStep, normalDegreeStep,
- Marble::LineStart | Marble::IgnoreXMargin );
+ GeoDataLatLonAltBox viewLatLonAltBox = viewport->viewLatLonAltBox();
+
+ renderLongitudeLines( painter, viewLatLonAltBox,
+ normalDegreeStep, normalDegreeStep,
+ Marble::LineStart | Marble::IgnoreXMargin );
renderLatitudeLines( painter, viewLatLonAltBox, normalDegreeStep,
- Marble::LineStart | Marble::IgnoreYMargin );
+ Marble::LineStart | Marble::IgnoreYMargin );
// Render some non-cut off longitude lines ..
renderLongitudeLine( painter, 90.0, viewLatLonAltBox );
@@ -140,20 +148,26 @@
// Render the bold grid
-// painter->setPen( QPen( QBrush( Qt::white ), 2.0 ) );
+ if ( painter->mapQuality() == Marble::High
+ || painter->mapQuality() == Marble::Print ) {
- // calculate the angular distance between coordinate lines of the bold grid
- qreal boldDegreeStep = 360.0 / m_boldLineMap.lowerBound(viewport->radius()).value();
+ QPen boldPen = minorCirclePen;
+ boldPen.setWidthF( 1.5 );
+ painter->setPen( boldPen );
+
+ // calculate the angular distance between coordinate lines of the bold grid
+ qreal boldDegreeStep = 360.0 / m_boldLineMap.lowerBound(viewport->radius()).value();
- renderLongitudeLines( painter, viewLatLonAltBox,
- boldDegreeStep, normalDegreeStep,
- Marble::NoLabel
- );
- renderLatitudeLines( painter, viewLatLonAltBox, boldDegreeStep,
- Marble::NoLabel );
+ renderLongitudeLines( painter, viewLatLonAltBox,
+ boldDegreeStep, normalDegreeStep,
+ Marble::NoLabel
+ );
+ renderLatitudeLines( painter, viewLatLonAltBox, boldDegreeStep,
+ Marble::NoLabel );
+ }
+
+ painter->setPen( majorCirclePen );
- painter->setPen( QColor( Qt::yellow ) );
-
// Render the equator
renderLatitudeLine( painter, 0.0, viewLatLonAltBox, tr( "Equator" ) );
@@ -161,26 +175,22 @@
renderLongitudeLine( painter, 0.0, viewLatLonAltBox, 0.0, tr( "Prime Meridian" ) );
renderLongitudeLine( painter, 180.0, viewLatLonAltBox, 0.0, tr( "Antimeridian" ) );
- QPen graticulePen = painter->pen();
- graticulePen.setStyle( Qt::DotLine );
- painter->setPen( graticulePen );
+ QPen tropicsPen = majorCirclePen;
+ tropicsPen.setStyle( Qt::DotLine );
+ painter->setPen( tropicsPen );
// Determine the planet's axial tilt
qreal axialTilt = RAD2DEG * dataFacade()->planet()->epsilon();
if ( axialTilt > 0 ) {
// Render the tropics
- renderLatitudeLine( painter, +axialTilt, viewLatLonAltBox, tr( "Tropic of Cancer" ) );
- renderLatitudeLine( painter, -axialTilt, viewLatLonAltBox, tr( "Tropic of Capricorn" ) );
+ renderLatitudeLine( painter, +axialTilt, viewLatLonAltBox, tr( "Tropic of Cancer" ) );
+ renderLatitudeLine( painter, -axialTilt, viewLatLonAltBox, tr( "Tropic of Capricorn" ) );
// Render the arctics
- renderLatitudeLine( painter, +90.0 - axialTilt, viewLatLonAltBox, tr( "Arctic Circle" ) );
- renderLatitudeLine( painter, -90.0 + axialTilt, viewLatLonAltBox, tr( "Antarctic Circle" ) );
- }
-
- painter->restore();
-
- return true;
+ renderLatitudeLine( painter, +90.0 - axialTilt, viewLatLonAltBox, tr( "Arctic Circle" ) );
+ renderLatitudeLine( painter, -90.0 + axialTilt, viewLatLonAltBox, tr( "Antarctic Circle" ) );
+ }
}
void GraticulePlugin::renderLatitudeLine( GeoPainter *painter, qreal latitude,
--- trunk/KDE/kdeedu/marble/src/plugins/render/graticule/GraticulePlugin.h #1002523:1002524
@@ -18,6 +18,7 @@
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtCore/QVector>
+#include <QtGui/QPen>
#include "RenderPlugin.h"
@@ -68,7 +69,16 @@
bool render( GeoPainter *painter, ViewportParams *viewport, const QString& renderPos, GeoSceneLayer * layer = 0 );
private:
- /**
+ /**
+ * @brief Renders the coordinate grid within the defined view bounding box.
+ * @param painter the painter used to draw the grid
+ * @param viewport the viewport
+ */
+ void renderGrid( GeoPainter *painter, ViewportParams *viewport,
+ const QPen& majorCirclePen,
+ const QPen& minorCirclePen );
+
+ /**
* @brief Renders a latitude line within the defined view bounding box.
* @param painter the painter used to draw the latitude line
* @param latitude the latitude of the coordinate line measured in degree .
@@ -136,6 +146,10 @@
// Maps the zoom factor to the amount of lines per 360 deg
QMap<qreal,qreal> m_boldLineMap;
QMap<qreal,qreal> m_normalLineMap;
+
+ QPen m_majorCirclePen;
+ QPen m_minorCirclePen;
+ QPen m_shadowPen;
};
}
More information about the Marble-commits
mailing list