[Kstars-devel] KDE/kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Fri Apr 25 03:39:59 CEST 2008
SVN commit 800859 by harris:
Fix for printing: scale star image size for the printer device.
CCMAIL: kstars-devel at kde.org
M +1 -1 skycomponents/starcomponent.cpp
M +5 -1 skymapdraw.cpp
M +16 -36 starobject.cpp
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #800858:800859
@@ -246,7 +246,7 @@
QPointF o = map->toScreen( curStar );
if ( ! map->onScreen( o ) ) continue;
- float size = map->scale() * ( sizeFactor*( maglim - mag ) / maglim ) + 1.;
+ float size = ( sizeFactor*( maglim - mag ) / maglim ) + 1.;
if ( size <= 0. ) continue;
curStar->draw( psky, o.x(), o.y(), size, (starColorMode()==0),
--- trunk/KDE/kdeedu/kstars/kstars/skymapdraw.cpp #800858:800859
@@ -572,6 +572,10 @@
double yscale = double(p.device()->height()) / double(height());
m_Scale = (xscale < yscale) ? xscale : yscale;
+ //Now that we have changed the map scale, we need to re-run
+ //StarObject::initImages() to get scaled pixmaps
+ StarObject::initImages();
+
int pdWidth = int( m_Scale * width() );
int pdHeight = int( m_Scale * height() );
int x1 = int( 0.5*(p.device()->width() - pdWidth) );
@@ -610,5 +614,5 @@
//at high zoom, double FOV for guide lines so they don't disappear.
guideFOV = fov();
guideXRange = XRange;
-if ( Options::zoomFactor() > 10.*MINZOOM ) { guideFOV *= 2.0; guideXRange *= 2.0; }
+ if ( Options::zoomFactor() > 10.*MINZOOM ) { guideFOV *= 2.0; guideXRange *= 2.0; }
}
--- trunk/KDE/kdeedu/kstars/kstars/starobject.cpp #800858:800859
@@ -106,6 +106,10 @@
}
void StarObject::initImages() {
+ SkyMap *map = SkyMap::Instance();
+ double scale = 1.0;
+ if ( map && map->scale() > 1.0 ) scale = map->scale();
+
if ( Options::starColorMode() == 0 ) { //Real colors
ColorMap.insert( "O", QColor::fromRgb( 0, 0, 255 ) );
ColorMap.insert( "B", QColor::fromRgb( 0, 200, 255 ) );
@@ -142,7 +146,7 @@
foreach ( const QString &color, ColorMap.keys() ) {
QString imKey = color+"14";
- QPixmap BigImage( 14, 14 );
+ QPixmap BigImage( int(14*scale), int(14*scale) );
BigImage.fill( Qt::transparent );
QPainter p;
@@ -150,9 +154,9 @@
p.setRenderHint(QPainter::Antialiasing, true );
//Set the width of the pen according to starColorIntensity()
- float w=2.0;
+ float w=2.0*scale;
if ( Options::starColorMode() == 0 ) {
- w = 2.0*float(Options::starColorIntensity())/4.0;
+ w = w*float(Options::starColorIntensity())/4.0;
}
p.setPen( QPen(ColorMap[color], w) );
@@ -162,13 +166,13 @@
p.setBrush( p.pen().color() );
}
- p.drawEllipse( QRect( 2, 2, 10, 10 ) );
+ p.drawEllipse( QRectF( 2*scale, 2*scale, 10*scale, 10*scale ) );
p.end();
StarImage.insert( imKey, BigImage );
for ( int size = 13; size > 0; size-- ) {
imKey = color+QString("%1").arg(size);
- StarImage.insert( imKey, BigImage.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
+ StarImage.insert( imKey, BigImage.scaled( size*scale, size*scale, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
}
}
}
@@ -394,39 +398,15 @@
void StarObject::draw( QPainter &psky, float x, float y, float size,
bool useRealColors, int scIntensity, bool /*showMultiple*/ ) {
-//REMOVE
-// if ( useRealColors ) {
- //Realistic colors
- //Stars rendered as a white core with a colored ring.
- //With antialiasing, we can just set the ring thickness to 0.1*scIntensity
- //However, this won't work without antialiasing, because the ring thickness
- //cant be <1 in this case. So we desaturate the pen color instead
+ int isize = int(size);
+ if ( isize >= 14 ) {
+ isize = 14;
+ }
-// if ( Options::useAntialias() )
-// psky.setPen( QPen( color(), 0.1*scIntensity ) );
-// else {
-// psky.setPen( QPen( color(), 1 ) );
-// }
-// }
-//END_REMOVE
+ QString imKey = SpType.at(0)+QString("%1").arg(isize);
+ float offset = 0.5*StarImage[imKey].width();
+ psky.drawPixmap( QPointF(x-offset, y-offset), StarImage[imKey] );
- int isize = int(size);
- if ( isize >= 14 ) {
-// kDebug() << "Star too big: " << size << endl;
- isize = 14;
- }
-
- float offset = 0.5*float(isize);
- QString imKey = SpType.at(0)+QString("%1").arg(isize);
- psky.drawPixmap( QPointF(x-offset, y-offset), StarImage[imKey] );
-
-//REMOVE
-// if ( Options::useAntialias() )
-// psky.drawEllipse( QRectF( x - 0.5*size, y - 0.5*size, size, size ) );
-// else
-// psky.drawEllipse( QRect( int(x - 0.5*size), int(y - 0.5*size), int(size), int(size) ) );
-//END_REMOVE
-
}
// The two routines below seem overly complicated but at least they are doing
More information about the Kstars-devel
mailing list