summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-08-25 11:36:22 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-08-25 11:36:22 (GMT)
commit3f74b17d5f79d761aecb4c999a8047da7d86ffd7 (patch)
tree444e32de9f33e561a3fcb309ee46ba3e5d795965
parent2ea4c3c71dcdc88f46367adbd727216be7e73041 (diff)
Add a solid (non-bitmap) colored star mode.
This is not as realistic as "Real colors" which uses bitmaps to give a realistic appearance, but might be useful especially for vectorized star chart export. This returns the "feature" provided by the previously existing bug. FEATURE:
-rw-r--r--kstars/kstars.kcfg4
-rw-r--r--kstars/options/opscolors.cpp1
-rw-r--r--kstars/skyqpainter.cpp17
-rw-r--r--kstars/skyqpainter.h2
4 files changed, 17 insertions, 7 deletions
diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
index b8cbde4..3b2013a 100644
--- a/kstars/kstars.kcfg
+++ b/kstars/kstars.kcfg
@@ -767,9 +767,9 @@
</entry>
<entry name="StarColorMode" type="UInt">
<label>Mode for rendering stars</label>
- <whatsthis>The method for rendering stars: 0="realistic colors"; 1="solid red"; 2="solid black"; 3="solid white"</whatsthis>
+ <whatsthis>The method for rendering stars: 0="realistic colors"; 1="solid red"; 2="solid black"; 3="solid white"; 4="solid real colors"</whatsthis>
<default>0</default>
- <max>3</max>
+ <max>4</max>
</entry>
<entry name="StarColorIntensity" type="UInt">
<label>Saturation level of star colors</label>
diff --git a/kstars/options/opscolors.cpp b/kstars/options/opscolors.cpp
index 93e0efa..4e6885f 100644
--- a/kstars/options/opscolors.cpp
+++ b/kstars/options/opscolors.cpp
@@ -86,6 +86,7 @@ OpsColors::OpsColors()
kcfg_StarColorMode->addItem( i18nc( "show stars as red circles", "Solid Red" ) );
kcfg_StarColorMode->addItem( i18nc( "show stars as black circles", "Solid Black" ) );
kcfg_StarColorMode->addItem( i18nc( "show stars as white circles", "Solid White" ) );
+ kcfg_StarColorMode->addItem( i18nc( "show stars as colored circles", "Solid Colors" ) );
kcfg_StarColorMode->setCurrentIndex( KStarsData::Instance()->colorScheme()->starColorMode() );
if ( KStarsData::Instance()->colorScheme()->starColorMode() != 0 ) //mode is not "Real Colors"
diff --git a/kstars/skyqpainter.cpp b/kstars/skyqpainter.cpp
index 02ff853..75f6b6d 100644
--- a/kstars/skyqpainter.cpp
+++ b/kstars/skyqpainter.cpp
@@ -77,6 +77,7 @@ namespace {
int SkyQPainter::starColorMode = 0;
QColor SkyQPainter::m_starColor = QColor();
+QMap<char, QColor> SkyQPainter::ColorMap = QMap<char, QColor>();
SkyQPainter::SkyQPainter( QPaintDevice *pd )
@@ -144,9 +145,9 @@ void SkyQPainter::setBrush(const QBrush& brush)
void SkyQPainter::initStarImages()
{
- QMap<char, QColor> ColorMap;
const int starColorIntensity = Options::starColorIntensity();
+ ColorMap.clear();
switch( Options::starColorMode() ) {
case 1: // Red stars.
m_starColor = Qt::red;
@@ -409,7 +410,7 @@ bool SkyQPainter::drawPointSource(SkyPoint* loc, float mag, char sp)
void SkyQPainter::drawPointSource(const QPointF& pos, float size, char sp)
{
int isize = qMin(static_cast<int>(size), 14);
- if( !m_vectorStars || ( starColorMode <=0 || starColorMode > 3 ) ) {
+ if( !m_vectorStars || starColorMode == 0 ) {
// Draw stars as bitmaps, either because we were asked to, or because we're painting real colors
QPixmap* im = imageCache[ harvardToIndex(sp) ][isize];
float offset = 0.5 * im->width();
@@ -417,8 +418,16 @@ void SkyQPainter::drawPointSource(const QPointF& pos, float size, char sp)
}
else {
// Draw stars as vectors, for better printing / SVG export etc.
- setPen( m_starColor );
- setBrush( m_starColor );
+ if ( starColorMode != 4 ) {
+ setPen( m_starColor );
+ setBrush( m_starColor );
+ }
+ else {
+ // Note: This is not efficient, but we use vector stars only when plotting SVG, not when drawing the skymap, so speed is not very important.
+ QColor c = ColorMap.value( sp, Qt::white );
+ setPen( c );
+ setBrush( c );
+ }
// Be consistent with old raster representation
if( size > 14 )
diff --git a/kstars/skyqpainter.h b/kstars/skyqpainter.h
index dda5cb0..c16cc04 100644
--- a/kstars/skyqpainter.h
+++ b/kstars/skyqpainter.h
@@ -99,7 +99,7 @@ private:
QSize m_size;
static int starColorMode;
static QColor m_starColor;
-
+ static QMap<char, QColor> ColorMap;
};
#endif