[Kstars-devel] [kstars] kstars: Fixing star color intensity setting in OpenGL mode.

Akarsh Simha akarshsimha at gmail.com
Sat Jun 30 10:58:47 UTC 2012


Git commit 1fffabb287ed6974f5c31863986a674420bae48e by Akarsh Simha.
Committed on 30/06/2012 at 12:41.
Pushed by asimha into branch 'master'.

Fixing star color intensity setting in OpenGL mode.

While it is implemented by having a full palette cached in QPainter
mode, it is implemented by converting from RGB to HSV, readjusting the
saturation, and converting back in the OpenGL mode. Looks better to
me.

Also adding a FIXME for later on randomly-stumbled-upon code in
StarObject.

BUG
CCMAIL: kstars-devel at kde.org, hdevalence at gmail.com

M  +21   -8    kstars/skyglpainter.cpp
M  +1    -1    kstars/skyobjects/starobject.cpp

http://commits.kde.org/kstars/1fffabb287ed6974f5c31863986a674420bae48e

diff --git a/kstars/skyglpainter.cpp b/kstars/skyglpainter.cpp
index da60df6..0db6d66 100644
--- a/kstars/skyglpainter.cpp
+++ b/kstars/skyglpainter.cpp
@@ -152,16 +152,29 @@ bool SkyGLPainter::addItem(SkyPoint* p, int type, float width, char sp)
         }
     }
     else {
+        QColor starColor;
+
+        // Set RGB values into QColor
         switch(sp) {
-        case 'o': case 'O': c = Vector3f( 153./255., 153./255., 255./255.); break;
-        case 'b': case 'B': c = Vector3f( 151./255., 233./255., 255./255.); break;
-        case 'a': case 'A': c = Vector3f( 153./255., 255./255., 255./255.); break;
-        case 'f': case 'F': c = Vector3f( 219./255., 255./255., 135./255.); break;
-        case 'g': case 'G': c = Vector3f( 255./255., 255./255., 153./255.); break;
-        case 'k': case 'K': c = Vector3f( 255./255., 193./255., 153./255.); break;
-        case 'm': case 'M': c = Vector3f( 255./255., 153./255., 153./255.); break;
-        case 'x':           c = Vector3f( m_pen[0], m_pen[1], m_pen[2]   ); break;
+        case 'o': case 'O': starColor.setRgb( 153, 153, 255); break;
+        case 'b': case 'B': starColor.setRgb( 151, 233, 255); break;
+        case 'a': case 'A': starColor.setRgb( 153, 255, 255); break;
+        case 'f': case 'F': starColor.setRgb( 219, 255, 135); break;
+        case 'g': case 'G': starColor.setRgb( 255, 255, 153); break;
+        case 'k': case 'K': starColor.setRgb( 255, 193, 153); break;
+        case 'm': case 'M': starColor.setRgb( 255, 153, 153); break;
+        case 'x':           starColor.setRgb( m_pen[0] * 255, m_pen[1] * 255, m_pen[2] *255 ); break;
         }
+
+        // Convert to HSV space using QColor's methods and adjust saturation.
+        int h, s, v;
+        starColor.getHsv( &h, &s, &v );
+        s = ( Options::starColorIntensity() / 10. ) * 200.; // Rewrite the saturation based on the star color intensity setting, 200 is the hard-wired max saturation, just to approximately match up with QPainter mode.
+        starColor.setHsv( h, s, v );
+
+        // Get RGB ratios and put them in 'c'
+        c = Vector3f( starColor.redF(), starColor.greenF(), starColor.blueF() );
+
     }
     for(int j = 0; j < 6; ++j) {
         m_color[type][i+j] = c;
diff --git a/kstars/skyobjects/starobject.cpp b/kstars/skyobjects/starobject.cpp
index ae0801d..89a78d6 100644
--- a/kstars/skyobjects/starobject.cpp
+++ b/kstars/skyobjects/starobject.cpp
@@ -386,7 +386,7 @@ QString StarObject::greekLetter( bool gchar ) const {
     return letter;
 }
 
-QString StarObject::constell() const {
+QString StarObject::constell() const { // FIXME: Move this somewhere else, make this static, and give it a better name. Mostly for code cleanliness. Also, try to put it in a DB.
     QString code = name2().mid(4,3);
     if ( code == "And" ) return QString("Andromedae");
     if ( code == "Ant" ) return QString("Antliae");


More information about the Kstars-devel mailing list