summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-08-25 10:49:41 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-08-25 10:49:41 (GMT)
commit2ea4c3c71dcdc88f46367adbd727216be7e73041 (patch)
tree57dd8eab96c746ccf6fc01f9c12b5ef7082134d4
parentb8bc83de4b36164dc15f142dca2d14f97288c9dd (diff)
Fix bug: White stars must result in white stars.
1. White stars should produce white stars. They produced solid colored stars due to a missing break; statement. 2. Refactor code and simplify it. (WARNING: Have not tested SVG export).
-rw-r--r--kstars/skyqpainter.cpp56
-rw-r--r--kstars/skyqpainter.h1
2 files changed, 19 insertions, 38 deletions
diff --git a/kstars/skyqpainter.cpp b/kstars/skyqpainter.cpp
index 3e6cd41..02ff853 100644
--- a/kstars/skyqpainter.cpp
+++ b/kstars/skyqpainter.cpp
@@ -76,6 +76,7 @@ namespace {
}
int SkyQPainter::starColorMode = 0;
+QColor SkyQPainter::m_starColor = QColor();
SkyQPainter::SkyQPainter( QPaintDevice *pd )
@@ -148,33 +149,17 @@ void SkyQPainter::initStarImages()
switch( Options::starColorMode() ) {
case 1: // Red stars.
- ColorMap.insert( 'O', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'B', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'A', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'F', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'G', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'K', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'M', QColor::fromRgb( 255, 0, 0 ) );
+ m_starColor = Qt::red;
break;
case 2: // Black stars.
- ColorMap.insert( 'O', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'B', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'A', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'F', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'G', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'K', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'M', QColor::fromRgb( 0, 0, 0 ) );
+ m_starColor = Qt::black;
break;
case 3: // White stars
- ColorMap.insert( 'O', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'B', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'A', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'F', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'G', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'K', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'M', QColor::fromRgb( 255, 255, 255 ) );
+ m_starColor = Qt::white;
+ break;
case 0: // Real color
default: // And use real color for everything else
+ m_starColor = QColor();
ColorMap.insert( 'O', QColor::fromRgb( 0, 0, 255 ) );
ColorMap.insert( 'B', QColor::fromRgb( 0, 200, 255 ) );
ColorMap.insert( 'A', QColor::fromRgb( 0, 255, 255 ) );
@@ -182,6 +167,16 @@ void SkyQPainter::initStarImages()
ColorMap.insert( 'G', QColor::fromRgb( 255, 255, 0 ) );
ColorMap.insert( 'K', QColor::fromRgb( 255, 100, 0 ) );
ColorMap.insert( 'M', QColor::fromRgb( 255, 0, 0 ) );
+ break;
+ }
+ if ( ColorMap.isEmpty() ) {
+ ColorMap.insert( 'O', m_starColor );
+ ColorMap.insert( 'B', m_starColor );
+ ColorMap.insert( 'A', m_starColor );
+ ColorMap.insert( 'F', m_starColor );
+ ColorMap.insert( 'G', m_starColor );
+ ColorMap.insert( 'K', m_starColor );
+ ColorMap.insert( 'M', m_starColor );
}
foreach( char color, ColorMap.keys() ) {
@@ -422,22 +417,8 @@ void SkyQPainter::drawPointSource(const QPointF& pos, float size, char sp)
}
else {
// Draw stars as vectors, for better printing / SVG export etc.
- static QColor color; // FIXME: This slows down things a bit, but we won't care because we're not painting the SkyMap this way anyway.
- switch( Options::starColorMode() ) {
- case 1:
- color = QColor::fromRgb(255, 0, 0);
- break;
- case 2:
- color = QColor::fromRgb(0, 0, 0);
- break;
- case 3:
- color = QColor::fromRgb(255, 255, 255);
- break;
- default:
- Q_ASSERT( false );
- }
- setPen( color );
- setBrush( color );
+ setPen( m_starColor );
+ setBrush( m_starColor );
// Be consistent with old raster representation
if( size > 14 )
@@ -842,4 +823,3 @@ bool SkyQPainter::drawSupernova(Supernova* sup)
drawLine ( QPoint( pos.x (), pos.y() - 2.0 ), QPoint( pos.x(), pos.y() + 2.0 ) );
return true;
}
-
diff --git a/kstars/skyqpainter.h b/kstars/skyqpainter.h
index cc2595c..dda5cb0 100644
--- a/kstars/skyqpainter.h
+++ b/kstars/skyqpainter.h
@@ -98,6 +98,7 @@ private:
bool m_vectorStars;
QSize m_size;
static int starColorMode;
+ static QColor m_starColor;
};