[Kstars-devel] [kstars] kstars: With QPainter, draw a line only if the two points are visible (to prevent random lines with gnomonic projection).

Jérôme SONRIER jsid at emor3j.fr.eu.org
Wed Feb 29 23:35:23 UTC 2012


Git commit 1e4ba1c87357ccfbd3bf7abe2ed9ed8f7e94a2e7 by Jérôme SONRIER.
Committed on 01/03/2012 at 00:35.
Pushed by jsonrier into branch 'master'.

With QPainter, draw a line only if the two points are visible (to prevent random lines with gnomonic projection).

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

M  +10   -8    kstars/skyqpainter.cpp

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

diff --git a/kstars/skyqpainter.cpp b/kstars/skyqpainter.cpp
index 2bd2c2f..43f06e8 100644
--- a/kstars/skyqpainter.cpp
+++ b/kstars/skyqpainter.cpp
@@ -226,26 +226,28 @@ void SkyQPainter::drawSkyPolyline(LineList* list, SkipList* skipList, LineListLa
 {
     SkyList *points = list->points();
     bool isVisible, isVisibleLast;
-    QPointF   oLast = m_proj->toScreen( points->first(), true, &isVisibleLast );
     // & with the result of checkVisibility to clip away things below horizon
     isVisibleLast &= m_proj->checkVisibility( points->first() );
-
+    QPointF   oLast = m_proj->toScreen( points->first(), true, &isVisibleLast );
+    
     QPointF oThis, oThis2;
     for ( int j = 1 ; j < points->size() ; j++ ) {
         SkyPoint* pThis = points->at( j );
-        oThis2 = oThis = m_proj->toScreen( pThis, true, &isVisible );
         // & with the result of checkVisibility to clip away things below horizon
         isVisible &= m_proj->checkVisibility(pThis);
+        oThis2 = oThis = m_proj->toScreen( pThis, true, &isVisible );
+        
         bool doSkip = false;
         if( skipList ) {
             doSkip = skipList->skip(j);
         }
-        //FIXME: check whether this works. (it doesn't)
+        
         if ( !doSkip ) {
-            if ( isVisible && isVisibleLast && label )
-                label->updateLabelCandidates(oThis.x(), oThis.y(), list, j);
-            if ( isVisible || isVisibleLast )
-                drawLine( oLast, oThis);
+            if ( isVisible && isVisibleLast ) {
+                drawLine( oLast, oThis );
+                if ( label )
+                    label->updateLabelCandidates( oThis.x(), oThis.y(), list, j );
+            }
         }
 
         oLast = oThis2;


More information about the Kstars-devel mailing list