~ubuntu-branches/ubuntu/precise/kstars/precise-proposed

« back to all changes in this revision

Viewing changes to kstars/skyqpainter.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-16 13:14:42 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111216131442-dfrjlt6pests9qu1
Tags: 4:4.7.90-0ubuntu1
New upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "skyobjects/ksasteroid.h"
38
38
#include "skyobjects/trailobject.h"
39
39
#include "skyobjects/satellite.h"
 
40
#include "skyobjects/supernova.h"
40
41
 
41
42
#include "projections/projector.h"
42
43
#include "ksutils.h"
372
373
    QPointF pos = m_proj->toScreen(obj, true, &visible);
373
374
    if( !visible || !m_proj->onScreen(pos) ) return false;
374
375
 
 
376
    // if size is 0.0 set it to 1.0, this are normally stars (type 0 and 1)
 
377
    // if we use size 0.0 the star wouldn't be drawn
 
378
    float majorAxis = obj->a();
 
379
    if ( majorAxis == 0.0 ) {   majorAxis = 1.0; }
 
380
 
 
381
    float size = majorAxis * dms::PI * Options::zoomFactor() / 10800.0;
 
382
 
375
383
    //FIXME: this is probably incorrect
376
384
    float positionAngle = m_proj->findPA( obj, pos.x(), pos.y() );
377
385
 
380
388
        drawDeepSkyImage(pos, obj, positionAngle);
381
389
 
382
390
    //Draw Symbol
383
 
    drawDeepSkySymbol(pos, obj, positionAngle);
 
391
    drawDeepSkySymbol(pos, obj->type(), size, obj->e(), positionAngle);
 
392
 
384
393
    return true;
385
394
}
386
395
 
400
409
}
401
410
 
402
411
//FIXME: Do we really need two versions of all of this code? (int/float)
403
 
void SkyQPainter::drawDeepSkySymbol(const QPointF& pos, DeepSkyObject* obj, float positionAngle)
 
412
void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, float e, float positionAngle)
404
413
{
405
414
    float x = pos.x();
406
415
    float y = pos.y();
407
416
    float zoom = Options::zoomFactor();
408
 
    // if size is 0.0 set it to 1.0, this are normally stars (type 0 and 1)
409
 
    // if we use size 0.0 the star wouldn't be drawn
410
 
    float majorAxis = obj->a();
411
 
    if ( majorAxis == 0.0 ) {   majorAxis = 1.0; }
412
417
 
413
 
    float size = majorAxis * dms::PI * zoom / 10800.0;
414
418
    int isize = int(size);
415
419
 
416
420
    float dx1 = -0.5*size;
417
421
    float dx2 =  0.5*size;
418
 
    float dy1 = -1.0*obj->e()*size/2.;
419
 
    float dy2 = obj->e()*size/2.;
 
422
    float dy1 = -1.0*e*size/2.;
 
423
    float dy2 = e*size/2.;
420
424
    float x1 = x + dx1;
421
425
    float x2 = x + dx2;
422
426
    float y1 = y + dy1;
424
428
 
425
429
    float dxa = -size/4.;
426
430
    float dxb =  size/4.;
427
 
    float dya = -1.0*obj->e()*size/4.;
428
 
    float dyb = obj->e()*size/4.;
 
431
    float dya = -1.0*e*size/4.;
 
432
    float dyb = e*size/4.;
429
433
    float xa = x + dxa;
430
434
    float xb = x + dxb;
431
435
    float ya = y + dya;
435
439
 
436
440
    QBrush tempBrush;
437
441
 
438
 
    switch ( obj->type() ) {
 
442
    switch ( type ) {
439
443
    case 0:
440
444
    case 1: //catalog star
441
445
        //Some NGC/IC objects are stars...changed their type to 1 (was double star)
486
490
        rotate( positionAngle );  //rotate the coordinate system
487
491
 
488
492
        if ( Options::useAntialias() ) {
489
 
            drawEllipse( QRectF(dx1, dy1, size, obj->e()*size) );
 
493
            drawEllipse( QRectF(dx1, dy1, size, e*size) );
490
494
            drawLine( QPointF(0., dy1), QPointF(0., dy2) );
491
495
            drawLine( QPointF(dx1, 0.), QPointF(dx2, 0.) );
492
496
            restore(); //reset coordinate system
493
497
        } else {
494
498
            int idx1 = int(dx1); int idy1 = int(dy1);
495
499
            int idx2 = int(dx2); int idy2 = int(dy2);
496
 
            drawEllipse( QRect(idx1, idy1, isize, int(obj->e()*size)) );
 
500
            drawEllipse( QRect(idx1, idy1, isize, int(e*size)) );
497
501
            drawLine( QPoint(0, idy1), QPoint(0, idy2) );
498
502
            drawLine( QPoint(idx1, 0), QPoint(idx2, 0) );
499
503
            restore(); //reset coordinate system
529
533
        rotate( positionAngle );  //rotate the coordinate system
530
534
 
531
535
        if ( Options::useAntialias() ) {
532
 
            drawEllipse( QRectF(dx1, dy1, size, obj->e()*size) );
533
 
            drawLine( QPointF(0., dy1), QPointF(0., dy1 - obj->e()*size/2. ) );
534
 
            drawLine( QPointF(0., dy2), QPointF(0., dy2 + obj->e()*size/2. ) );
 
536
            drawEllipse( QRectF(dx1, dy1, size, e*size) );
 
537
            drawLine( QPointF(0., dy1), QPointF(0., dy1 - e*size/2. ) );
 
538
            drawLine( QPointF(0., dy2), QPointF(0., dy2 + e*size/2. ) );
535
539
            drawLine( QPointF(dx1, 0.), QPointF(dx1 - size/2., 0.) );
536
540
            drawLine( QPointF(dx2, 0.), QPointF(dx2 + size/2., 0.) );
537
541
        } else {
538
542
            int idx1 = int(dx1); int idy1 = int(dy1);
539
543
            int idx2 = int(dx2); int idy2 = int(dy2);
540
 
            drawEllipse( QRect( idx1, idy1, isize, int(obj->e()*size) ) );
541
 
            drawLine( QPoint(0, idy1), QPoint(0, idy1 - int(obj->e()*size/2) ) );
542
 
            drawLine( QPoint(0, idy2), QPoint(0, idy2 + int(obj->e()*size/2) ) );
 
544
            drawEllipse( QRect( idx1, idy1, isize, int(e*size) ) );
 
545
            drawLine( QPoint(0, idy1), QPoint(0, idy1 - int(e*size/2) ) );
 
546
            drawLine( QPoint(0, idy2), QPoint(0, idy2 + int(e*size/2) ) );
543
547
            drawLine( QPoint(idx1, 0), QPoint(idx1 - int(size/2), 0) );
544
548
            drawLine( QPoint(idx2, 0), QPoint(idx2 + int(size/2), 0) );
545
549
        }
578
582
            rotate( positionAngle );  //rotate the coordinate system
579
583
 
580
584
            if ( Options::useAntialias() ) {
581
 
                drawEllipse( QRectF(dx1, dy1, size, obj->e()*size) );
 
585
                drawEllipse( QRectF(dx1, dy1, size, e*size) );
582
586
            } else {
583
587
                int idx1 = int(dx1); int idy1 = int(dy1);
584
 
                drawEllipse( QRect(idx1, idy1, isize, int(obj->e()*size)) );
 
588
                drawEllipse( QRect(idx1, idy1, isize, int(e*size)) );
585
589
            }
586
590
 
587
591
            restore(); //reset coordinate system
732
736
    if ( Options::showSatellitesLabels() )
733
737
        data->skyComposite()->satellites()->drawLabel( sat, pos );
734
738
}
 
739
 
 
740
bool SkyQPainter::drawSupernova(Supernova* sup)
 
741
{
 
742
    KStarsData *data = KStarsData::Instance();
 
743
    if( !m_proj->checkVisibility(sup) ){ return false; }
 
744
 
 
745
    bool visible = false;
 
746
    QPointF pos = m_proj->toScreen(sup,true,&visible);
 
747
    //kDebug()<<"sup->ra() = "<<(sup->ra()).toHMSString()<<"sup->dec() = "<<sup->dec().toDMSString();
 
748
    //kDebug()<<"pos = "<<pos<<"m_proj->onScreen(pos) = "<<m_proj->onScreen(pos);
 
749
    if( !visible || !m_proj->onScreen(pos) ) return false;
 
750
 
 
751
    setPen( data->colorScheme()->colorNamed("SupernovaColor") );
 
752
    //kDebug()<<"Here"<<endl;
 
753
    drawLine ( QPoint( pos.x () - 2.0, pos.y() ), QPoint( pos.x() + 2.0, pos.y() ) );
 
754
    drawLine ( QPoint( pos.x (), pos.y() - 2.0 ), QPoint( pos.x(), pos.y() + 2.0 ) );
 
755
    return true;
 
756
}
 
757