[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [marble] src/plugins/render/stars: - Don't render parts of the stars plugin in flat projection
From: Torsten Rahn <rahn () kde ! org>
Date: 2013-01-06 8:56:48
Message-ID: 20130106085648.8B6D9A6091 () git ! kde ! org
[Download RAW message or body]
Git commit 6db1d7cd6a4cb58d0f0eff24417561afff0d05f8 by Torsten Rahn.
Committed on 06/01/2013 at 09:55.
Pushed by rahn into branch 'master'.
- Don't render parts of the stars plugin in flat projection
- Don't render one of the poles if it's behind the observer.
M +90 -89 src/plugins/render/stars/StarsPlugin.cpp
http://commits.kde.org/marble/6db1d7cd6a4cb58d0f0eff24417561afff0d05f8
diff --git a/src/plugins/render/stars/StarsPlugin.cpp \
b/src/plugins/render/stars/StarsPlugin.cpp index 03cdcaa..764c2da 100644
--- a/src/plugins/render/stars/StarsPlugin.cpp
+++ b/src/plugins/render/stars/StarsPlugin.cpp
@@ -995,17 +995,6 @@ bool StarsPlugin::render( GeoPainter *painter, ViewportParams \
*viewport, return true;
}
- // List of Pens used to draw the sky
- QPen polesPen( m_celestialPoleBrush, 2, Qt::SolidLine );
- QPen constellationPenSolid( m_constellationBrush, 1, Qt::SolidLine );
- QPen constellationPenDash( m_constellationBrush, 1, Qt::DashLine );
- QPen constellationLabelPen( m_constellationLabelBrush, 1, Qt::SolidLine );
- QPen eclipticPen( m_eclipticBrush, 1, Qt::DotLine );
- QPen equatorPen( m_celestialEquatorBrush, 1, Qt::DotLine );
- QPen dsoLabelPen (m_dsoLabelBrush, 1, Qt::SolidLine);
- QBrush starBrush( Qt::white );
-
-
painter->save();
painter->autoMapQuality();
@@ -1018,117 +1007,129 @@ bool StarsPlugin::render( GeoPainter *painter, \
ViewportParams *viewport, const qreal centerLon = viewport->centerLongitude();
const qreal centerLat = viewport->centerLatitude();
- const Quaternion skyAxis = Quaternion::fromEuler( -centerLat , centerLon + \
skyRotationAngle, 0.0 );
- matrix skyAxisMatrix;
- skyAxis.inverse().toMatrix( skyAxisMatrix );
+ const qreal skyRadius = 0.6 * sqrt( ( qreal )viewport->width() * \
viewport->width() + viewport->height() * viewport->height() );
- const qreal skyRadius = 0.6 * sqrt( ( qreal )viewport->width() * \
viewport->width() + viewport->height() * viewport->height() ); + const bool \
renderStars = !viewport->mapCoversViewport() && viewport->projection() == Spherical; \
+ if ( renderStars ) {
+
+ // Delayed initialization:
+ // Load the star database only if the sky is actually being painted...
+ if ( !m_starsLoaded ) {
+ loadStars();
+ m_starsLoaded = true;
+ }
- if ( m_renderCelestialPole ) {
+ if ( !m_constellationsLoaded ) {
+ loadConstellations();
+ m_constellationsLoaded = true;
+ }
- polesPen.setWidth( 2 );
- painter->setPen( polesPen );
+ if ( !m_dsosLoaded ) {
+ loadDsos();
+ m_dsosLoaded = true;
+ }
+ int x, y;
Quaternion qpos;
- qpos = Quaternion::fromSpherical( 0, 90 * DEG2RAD );
- qpos.rotateAroundAxis( skyAxisMatrix );
-
- int x1, y1;
- x1 = ( int )( viewport->width() / 2 + skyRadius * qpos.v[Q_X] );
- y1 = ( int )( viewport->height() / 2 - skyRadius * qpos.v[Q_Y] );
- painter->drawLine( x1, y1, x1+10, y1 );
- painter->drawLine( x1+5, y1-5, x1+5, y1+5 );
- painter->drawText( x1+8, y1+12, "NP" );
- x1 = ( int )( viewport->width() / 2 - skyRadius * qpos.v[Q_X] );
- y1 = ( int )( viewport->height() / 2 + skyRadius * qpos.v[Q_Y] );
- painter->drawLine( x1, y1, x1+10, y1 );
- painter->drawLine( x1+5, y1-5, x1+5, y1+5 );
- painter->drawText( x1+8, y1+12, "SP" );
- }
-
+ const qreal earthRadius = viewport->radius();
- if ( m_renderEcliptic || m_renderCelestialEquator) {
+ // List of Pens used to draw the sky
+ QPen polesPen( m_celestialPoleBrush, 2, Qt::SolidLine );
+ QPen constellationPenSolid( m_constellationBrush, 1, Qt::SolidLine );
+ QPen constellationPenDash( m_constellationBrush, 1, Qt::DashLine );
+ QPen constellationLabelPen( m_constellationLabelBrush, 1, Qt::SolidLine );
+ QPen eclipticPen( m_eclipticBrush, 1, Qt::DotLine );
+ QPen equatorPen( m_celestialEquatorBrush, 1, Qt::DotLine );
+ QPen dsoLabelPen (m_dsoLabelBrush, 1, Qt::SolidLine);
+ QBrush starBrush( Qt::white );
- const qreal skyRadius = 0.6 * sqrt( ( qreal )viewport->width() * \
viewport->width() + viewport->height() * viewport->height() );
const Quaternion skyAxis = Quaternion::fromEuler( -centerLat , centerLon + \
skyRotationAngle, 0.0 ); matrix skyAxisMatrix;
skyAxis.inverse().toMatrix( skyAxisMatrix );
- const Quaternion eclipticAxis = Quaternion::fromEuler( 0.0, 0.0, -23.5 * \
DEG2RAD );
- matrix eclipticAxisMatrix;
- (eclipticAxis * skyAxis).inverse().toMatrix( eclipticAxisMatrix );
+ if ( m_renderCelestialPole ) {
+ polesPen.setWidth( 2 );
+ painter->setPen( polesPen );
- int previousX = -1;
- int previousY = -1;
+ int x1, y1;
- if( m_renderEcliptic ) {
- painter->setPen(eclipticPen);
- for ( int i = 0; i <= 36; ++i) {
- Quaternion qpos;
- qpos = Quaternion::fromSpherical( i * 10 * DEG2RAD, 0 );
- qpos.rotateAroundAxis( eclipticAxisMatrix );
+ Quaternion qpos1;
+ qpos1 = Quaternion::fromSpherical( 0, 90 * DEG2RAD );
+ qpos1.rotateAroundAxis( skyAxisMatrix );
- int x = ( int )( viewport->width() / 2 + skyRadius * qpos.v[Q_X] );
- int y = ( int )( viewport->height() / 2 - skyRadius * qpos.v[Q_Y] );
-
- if ( qpos.v[Q_Z] < 0 && previousX >= 0 ) \
painter->drawLine(previousX, previousY, x, y); + if ( qpos.v[Q_Z] < 0 ) {
+ x1 = ( int )( viewport->width() / 2 + skyRadius * qpos1.v[Q_X] );
+ y1 = ( int )( viewport->height() / 2 - skyRadius * qpos1.v[Q_Y] );
+ painter->drawLine( x1, y1, x1+10, y1 );
+ painter->drawLine( x1+5, y1-5, x1+5, y1+5 );
+ painter->drawText( x1+8, y1+12, "NP" );
+ }
- previousX = x;
- previousY = y;
+ Quaternion qpos2;
+ qpos2 = Quaternion::fromSpherical( 0, -90 * DEG2RAD );
+ qpos2.rotateAroundAxis( skyAxisMatrix );
+ if ( qpos2.v[Q_Z] < 0 ) {
+ x1 = ( int )( viewport->width() / 2 + skyRadius * qpos2.v[Q_X] );
+ y1 = ( int )( viewport->height() / 2 - skyRadius * qpos2.v[Q_Y] );
+ painter->drawLine( x1, y1, x1+10, y1 );
+ painter->drawLine( x1+5, y1-5, x1+5, y1+5 );
+ painter->drawText( x1+8, y1+12, "SP" );
}
}
- previousX = -1;
- previousY = -1;
- if( m_renderCelestialEquator ) {
- painter->setPen(equatorPen);
- for ( int i = 0; i <= 36; ++i) {
- Quaternion qpos;
- qpos = Quaternion::fromSpherical( i * 10 * DEG2RAD, 0 );
- qpos.rotateAroundAxis( skyAxisMatrix );
- int x = ( int )( viewport->width() / 2 + skyRadius * qpos.v[Q_X] );
- int y = ( int )( viewport->height() / 2 - skyRadius * qpos.v[Q_Y] );
+ if ( m_renderEcliptic || m_renderCelestialEquator) {
- if ( qpos.v[Q_Z] < 0 && previousX > 0 ) painter->drawLine(previousX, \
previousY, x, y); + const Quaternion eclipticAxis = Quaternion::fromEuler( \
0.0, 0.0, -23.5 * DEG2RAD ); + matrix eclipticAxisMatrix;
+ (eclipticAxis * skyAxis).inverse().toMatrix( eclipticAxisMatrix );
- previousX = x;
- previousY = y;
- }
- }
- }
+ int previousX = -1;
+ int previousY = -1;
- const bool renderStars = !viewport->mapCoversViewport() && \
viewport->projection() == Spherical; + if( m_renderEcliptic ) {
+ painter->setPen(eclipticPen);
+ for ( int i = 0; i <= 36; ++i) {
+ Quaternion qpos;
+ qpos = Quaternion::fromSpherical( i * 10 * DEG2RAD, 0 );
+ qpos.rotateAroundAxis( eclipticAxisMatrix );
- if ( renderStars ) {
- // Delayed initialization:
- // Load the star database only if the sky is actually being painted...
- if ( !m_starsLoaded ) {
- loadStars();
- m_starsLoaded = true;
- }
+ int x = ( int )( viewport->width() / 2 + skyRadius * \
qpos.v[Q_X] ); + int y = ( int )( viewport->height() / 2 - \
skyRadius * qpos.v[Q_Y] );
- if ( !m_constellationsLoaded ) {
- loadConstellations();
- m_constellationsLoaded = true;
- }
+ if ( qpos.v[Q_Z] < 0 && previousX >= 0 ) \
painter->drawLine(previousX, previousY, x, y);
- if ( !m_dsosLoaded ) {
- loadDsos();
- m_dsosLoaded = true;
- }
+ previousX = x;
+ previousY = y;
+ }
+ }
- int x, y;
- Quaternion qpos;
+ previousX = -1;
+ previousY = -1;
- const qreal skyRadius = 0.6 * sqrt( ( qreal )viewport->width() * \
viewport->width() + viewport->height() * viewport->height() );
- const qreal earthRadius = viewport->radius();
+ if( m_renderCelestialEquator ) {
+ painter->setPen(equatorPen);
+ for ( int i = 0; i <= 36; ++i) {
+ Quaternion qpos;
+ qpos = Quaternion::fromSpherical( i * 10 * DEG2RAD, 0 );
+ qpos.rotateAroundAxis( skyAxisMatrix );
+
+ int x = ( int )( viewport->width() / 2 + skyRadius * \
qpos.v[Q_X] ); + int y = ( int )( viewport->height() / 2 - \
skyRadius * qpos.v[Q_Y] ); +
+ if ( qpos.v[Q_Z] < 0 && previousX > 0 ) \
painter->drawLine(previousX, previousY, x, y); +
+ previousX = x;
+ previousY = y;
+ }
+ }
+ }
if ( m_renderDsos ) {
painter->setPen(dsoLabelPen);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic