[Kstars-devel] KDE/kdeedu/kstars/kstars/skycomponents

Jérôme Sonrier jsid at emor3j.fr.eu.org
Sun Feb 27 03:02:04 CET 2011


SVN commit 1222886 by jsonrier:

Add labels for important points on the equator/ecliptic.

CCMAIL: kstars-devel at kde.org
CCBUG: 51299



 M  +33 -0     ecliptic.cpp  
 M  +1 -0      ecliptic.h  
 M  +28 -0     equator.cpp  
 M  +1 -0      equator.h  


--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/ecliptic.cpp #1222885:1222886
@@ -27,6 +27,7 @@
 #include "skylabeler.h"
 
 #include "skypainter.h"
+#include "projections/projector.h"
 
 Ecliptic::Ecliptic(SkyComposite *parent ) :
         LineListIndex( parent, i18n("Ecliptic") ),
@@ -74,4 +75,36 @@
     drawLines( skyp );
     SkyLabeler::Instance()->setPen( QPen( QBrush( color ), 1, Qt::SolidLine ) );
     m_label.draw();
+
+    drawCompassLabels();
 }
+
+void Ecliptic::drawCompassLabels() {
+    QPointF cpoint;
+    bool visible;
+    QString label;
+
+    const Projector *proj = SkyMap::Instance()->projector();
+    KStarsData *data = KStarsData::Instance();
+    SkyLabeler* skyLabeler = SkyLabeler::Instance();
+    
+    KSNumbers num( data->ut().djd() );
+    dms elat(0.0), elng(0.0);
+
+    for( int ra = 0; ra < 23; ra += 6 ) {
+        elng.setH( ra );
+        SkyPoint* o = new SkyPoint();
+        o->setFromEcliptic( num.obliquity(), &elng, &elat );
+        o->setRA0( o->ra().Hours() );
+        o->setDec0( o->dec().Degrees() );
+        o->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+        cpoint = proj->toScreen( o, false, &visible );
+        if ( proj->checkVisibility( o ) && visible ) {
+            if ( o->ra().Degrees() < 0 )
+                label.setNum( o->ra().Degrees() + 360 );
+            else
+                label.setNum( o->ra().Degrees() );
+            skyLabeler->drawGuideLabel( cpoint, label, 0.0 );
+        }
+    }
+}
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/ecliptic.h #1222885:1222886
@@ -39,6 +39,7 @@
     Ecliptic( SkyComposite *parent );
 
     virtual void draw( SkyPainter *skyp );
+    virtual void drawCompassLabels();
     virtual bool selected();
 
     virtual LineListLabel* label() { return &m_label; }
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/equator.cpp #1222885:1222886
@@ -27,6 +27,7 @@
 #include "skylabeler.h"
 
 #include "skypainter.h"
+#include "projections/projector.h"
 
 Equator::Equator(SkyComposite *parent ) :
         NoPrecessIndex( parent, i18n("Equator") ),
@@ -66,6 +67,8 @@
 
 void Equator::draw( SkyPainter *skyp )
 {
+    if ( ! selected() ) return;
+    
     m_label.reset();
     NoPrecessIndex::draw( skyp );
 
@@ -73,5 +76,30 @@
     QColor color( data->colorScheme()->colorNamed( "EqColor" ) );
     SkyLabeler::Instance()->setPen( QPen( QBrush( color ), 1, Qt::SolidLine ) );
     m_label.draw();
+
+    drawCompassLabels();
 }
 
+void Equator::drawCompassLabels() {
+    QPointF cpoint;
+    bool visible;
+    QString label;
+
+    const Projector *proj = SkyMap::Instance()->projector();
+    KStarsData *data = KStarsData::Instance();
+    SkyLabeler* skyLabeler = SkyLabeler::Instance();
+
+    KSNumbers num( data->ut().djd() );
+    dms elat(0.0), elng(0.0);
+
+    for( int ra = 0; ra < 23; ra += 2 ) {
+        elng.setH( ra );
+        SkyPoint* o = new SkyPoint( ra, 0.0 );
+        o->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+        cpoint = proj->toScreen( o, false, &visible );
+        if ( proj->checkVisibility( o ) && visible ) {
+            label.setNum( o->ra().hour() );
+            skyLabeler->drawGuideLabel( cpoint, label, 0.0 );
+        }
+    }
+}
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/equator.h #1222885:1222886
@@ -41,6 +41,7 @@
 
     virtual bool selected();
     virtual void draw( SkyPainter *skyp );
+    virtual void drawCompassLabels();
     virtual LineListLabel* label() {return &m_label;};
 
 protected:


More information about the Kstars-devel mailing list