[Kstars-devel] KDE/kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Sun Jan 29 02:10:26 CET 2006
SVN commit 503406 by harris:
We no longer use stored pixmaps for stars; instead we draw colored
ellipses (with a white fill) directly onto the skymap.
CCMAIL: kstars-devel at kde.org
M +1 -1 Makefile.am
M +1 -7 skycomponents/customcatalogcomponent.cpp
M +6 -7 skycomponents/starcomponent.cpp
M +5 -8 skycomponents/starcomponent.h
M +42 -12 starobject.cpp
M +3 -6 starobject.h
D starpixmap.cpp
D starpixmap.h
--- trunk/KDE/kdeedu/kstars/kstars/Makefile.am #503405:503406
@@ -24,7 +24,7 @@
opsadvanced.cpp opscatalog.cpp opscolors.cpp \
opsguides.cpp opssolarsystem.cpp simclock.cpp skymap.cpp \
skymapdraw.cpp skymapevents.cpp skyobject.cpp skypoint.cpp \
- starobject.cpp starpixmap.cpp streamwg.cpp telescopewizardprocess.cpp telescopeprop.cpp \
+ starobject.cpp streamwg.cpp telescopewizardprocess.cpp telescopeprop.cpp \
timedialog.cpp timezonerule.cpp \
toggleaction.cpp thumbnailpicker.cpp thumbnaileditor.cpp \
Options.kcfgc kstarsinterface.skel simclockinterface.skel $(kstars_ui)
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/customcatalogcomponent.cpp #503405:503406
@@ -155,13 +155,7 @@
float sizeFactor = 2.0;
int size = int( sizeFactor*(zoomlim - mag) ) + 1;
if (size>23) size=23;
-//FIXME: We don't have access to the starpixmaps
-// if ( size ) {
-// QChar c = starobj->color();
-// QPixmap *spixmap = starpix->getPixmap( &c, size );
-// starobj->draw( psky, sky, spixmap, o.x(), o.y(), true, scale );
-// }
- starobj->draw( psky, o.x(), o.y(), size*scale );
+ starobj->draw( psky, o.x(), o.y(), size, Options::starColorMode(), Options::starColorIntensity(), true, scale );
} else {
//PA for Deep-Sky objects is 90 + PA because major axis is horizontal at PA=0
DeepSkyObject *dso = (DeepSkyObject*)obj;
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #503405:503406
@@ -29,20 +29,20 @@
#include "starobject.h"
StarComponent::StarComponent(SkyComponent *parent, bool (*visibleMethod)())
-: ListComponent(parent, visibleMethod), m_FaintMagnitude(-5.0), starFileReader(0)
+: ListComponent(parent, visibleMethod), starFileReader(0), m_FaintMagnitude(-5.0)
{
}
StarComponent::~StarComponent()
{
- delete starpix;
}
void StarComponent::init(KStarsData *data)
{
emitProgressText( i18n("Loading stars" ) );
- // load the pixmaps of stars
- starpix = new StarPixmap( data->colorScheme()->starColorMode(), data->colorScheme()->starColorIntensity() );
+
+ m_ColorMode = data->colorScheme()->starColorMode();
+ m_ColorIntensity = data->colorScheme()->starColorIntensity();
m_Data = data;
setFaintMagnitude( Options::magLimitDrawStar() );
@@ -88,9 +88,8 @@
if ( size > 0. )
{
- QChar c = curStar->color();
- QPixmap *spixmap = starpix->getPixmap( &c, int(size) );
- curStar->draw( psky, spixmap, o.x(), o.y(), true, scale );
+ curStar->draw( psky, o.x(), o.y(), size, starColorMode(),
+ starColorIntensity(), true, scale );
// now that we have drawn the star, we can display some extra info
//don't label unnamed stars with the generic "star" name
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starcomponent.h #503405:503406
@@ -29,7 +29,6 @@
#define NHIPFILES 127
#include "listcomponent.h"
-#include "../starpixmap.h"
class SkyComponent;
class KStars;
@@ -55,12 +54,12 @@
/**@return the current setting of the color mode for stars (0=real colors,
*1=solid red, 2=solid white or 3=solid black).
*/
- int starColorMode( void ) const { return starpix->mode(); }
+ int starColorMode( void ) const { return m_ColorMode; }
/**@short Set the color mode for stars (0=real colors, 1=solid red, 2=solid
*white or 3=solid black).
*/
- void setStarColorMode( int mode ) { starpix->setColorMode( mode ); }
+ void setStarColorMode( int mode ) { m_ColorMode = mode; }
/**@short Retrieve the color-intensity value for stars.
*
@@ -70,7 +69,7 @@
*the color-saturation level for star images.
*@return the current setting of the color intensity setting for stars.
*/
- int starColorIntensity( void ) const { return starpix->intensity(); }
+ int starColorIntensity( void ) const { return m_ColorIntensity; }
/**@short Sets the color-intensity value for stars.
*
@@ -79,7 +78,7 @@
*the relative thickness of this colored border, so it effectively adjusts
*the color-saturation level for star images.
*/
- void setStarColorIntensity( int value ) { starpix->setIntensity( value ); }
+ void setStarColorIntensity( int value ) { m_ColorIntensity = value; }
float faintMagnitude() const { return m_FaintMagnitude; }
void setFaintMagnitude( float newMagnitude );
@@ -123,11 +122,9 @@
void processStar( const QString &line );
KStarsData *m_Data;
-
- StarPixmap *starpix; // the pixmap of the stars
-
KSFileReader *starFileReader;
float m_FaintMagnitude;
+ int m_ColorMode, m_ColorIntensity;
};
#endif
--- trunk/KDE/kdeedu/kstars/kstars/starobject.cpp #503405:503406
@@ -223,21 +223,51 @@
return QString("");
}
-void StarObject::draw( QPainter &psky, QPixmap *starpix, float x, float y, bool /*showMultiple*/, double /*scale*/ ) {
- //Indicate multiple stars with a short horizontal line
- //(only draw this for stars larger than 3 pixels)
-//Commenting out for now...
-// if ( showMultiple && starpix->width() > 3 ) {
-// int lsize = int(3*starpix->width()/4); //size of half line segment
-// psky.drawLine( x - lsize, y, x + lsize, y );
-// }
+QColor StarObject::color() const {
+ QColor c( Qt::white );
+ switch ( SpType.at(0).toAscii() ) {
+ case 'O':
+ c.setRgb( 0, 0, 255 );
+ break;
+ case 'B':
+ c.setRgb( 0, 200, 255 );
+ break;
+ case 'A':
+ c.setRgb( 0, 255, 255 );
+ break;
+ case 'F':
+ c.setRgb( 200, 255, 100 );
+ break;
+ case 'G':
+ c.setRgb( 255, 255, 0 );
+ break;
+ case 'K':
+ c.setRgb( 255, 100, 0 );
+ break;
+ case 'M':
+ c.setRgb( 255, 0, 0 );
+ break;
+ }
- psky.drawPixmap( QPointF(x - 0.5*(starpix->width()), y - 0.5*(starpix->height()) ),
- *starpix, QRectF( starpix->rect() ) );
-
+ return c;
}
-void StarObject::draw( QPainter &psky, float x, float y, float size, bool /*drawMultiple*/ ) {
+void StarObject::draw( QPainter &psky, float x, float y, float size,
+ int scMode, int scIntensity, bool /*showMultiple*/, double /*scale*/ ) {
+
+ QColor fillColor( Qt::white );
+ if ( scMode == 1 ) fillColor = Qt::red;
+ if ( scMode == 2 ) fillColor = Qt::black;
+// psky.setBrush( QBrush( fillColor ) );
+ psky.setBrush( QBrush( Qt::white ) );
+
+ if ( scMode > 0 ) psky.setPen( QPen( fillColor ) );
+ else {
+ //Realistic colors
+ //line thickness controlled by scIntensity
+ psky.setPen( QPen( color(), 0.1*scIntensity ) );
+ }
+
psky.drawEllipse( QRectF( x - 0.5*size, y - 0.5*size, size, size ) );
}
--- trunk/KDE/kdeedu/kstars/kstars/starobject.h #503405:503406
@@ -100,9 +100,9 @@
/**
*Returns first character of Spectral Type string, which is used to
*select the temperature-color of the star.
- *@return first character of Spectral Type string
+ *@return color corresponding to Spectral Type
*/
- QChar color( void ) const { return SpType.at(0); }
+ QColor color( void ) const;
/**
*Returns entire spectral type string
@@ -200,11 +200,8 @@
// */
// double vperiod() const { return VPeriod; }
- void draw( QPainter &psky, QPixmap *starpix, float x, float y, bool drawMultiple=true, double scale=1.0 );
+ void draw( QPainter &psky, float x, float y, float size, int scMode, int scIntensity, bool drawMultiple=true, double scale=1.0 );
-//Alternate draw function without starpix
- void draw( QPainter &psky, float x, float y, float size, bool drawMultiple=true );
-
//overloaded from SkyObject
void drawLabel( QPainter &psky, float x, float y, double zoom, bool drawName, bool drawMag, double scale );
More information about the Kstars-devel
mailing list