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

Jason Harris kstars at 30doradus.org
Mon May 19 01:18:44 CEST 2008


SVN commit 809477 by harris:

Reorganizing initFocus():

+ Fix bug #162059: when leaving the program in Horizontal coordinates 
and not tracking on the sky, the initial position on next startup should 
be the same Alt/Az coordinates.  Fixed.

+ When leaving the program tracking on a star named "star", the initial 
position on the next startup should be that same star,  Fixed.

They seem like simple fixes, but it actually took quite a bit to fix 
these.  Another symptom of the bubble-gum-and-duct-tape nature of the 
startup code...

Is it worth trying to backport this fix to the 3.x codebase?  Are we 
going to have 3.5.10?

CCMAIL: kstars-devel at kde.org
BUG: 162059



 M  +14 -12    kstars.cpp  
 M  +3 -1      kstars.h  
 M  +8 -2      kstarsactions.cpp  
 M  +37 -28    kstarsinit.cpp  
 M  +15 -1     skycomponents/starcomponent.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/kstars.cpp #809476:809477
@@ -146,7 +146,7 @@
     }
 }
 
-void KStars::applyConfig() {
+void KStars::applyConfig( bool doApplyFocus ) {
     if ( Options::isTracking() ) {
         actionCollection()->action("track_object")->setText( i18n( "Stop &Tracking" ) );
         actionCollection()->action("track_object")->setIcon( KIcon("document-encrypt") );
@@ -192,19 +192,21 @@
     data()->setLocationFromOptions();
 
     //Focus
-    SkyObject *fo = data()->objectNamed( Options::focusObject() );
-    if ( fo && fo != map()->focusObject() ) {
-        map()->setClickedObject( fo );
-        map()->setClickedPoint( fo );
-        map()->slotCenter();
-    }
-
-    if ( ! fo ) {
-        SkyPoint fp( Options::focusRA(), Options::focusDec() );
-        if ( fp.ra()->Degrees() != map()->focus()->ra()->Degrees() || fp.dec()->Degrees() != map()->focus()->dec()->Degrees() ) {
-            map()->setClickedPoint( &fp );
+    if ( doApplyFocus ) {
+        SkyObject *fo = data()->objectNamed( Options::focusObject() );
+        if ( fo && fo != map()->focusObject() ) {
+            map()->setClickedObject( fo );
+            map()->setClickedPoint( fo );
             map()->slotCenter();
         }
+    
+        if ( ! fo ) {
+            SkyPoint fp( Options::focusRA(), Options::focusDec() );
+            if ( fp.ra()->Degrees() != map()->focus()->ra()->Degrees() || fp.dec()->Degrees() != map()->focus()->dec()->Degrees() ) {
+                map()->setClickedPoint( &fp );
+                map()->slotCenter();
+            }
+        }
     }
 }
 
--- trunk/KDE/kdeedu/kstars/kstars/kstars.h #809476:809477
@@ -128,8 +128,10 @@
     /**@short Apply config options throughout the program.
     	*In most cases, options are set in the "Options" object directly, 
     	*but for some things we have to manually react to config changes.
+        *@param doApplyFocus If true, then focus posiiton will be set 
+        *from config file
     	*/
-    void applyConfig();
+    void applyConfig( bool doApplyFocus = true );
 
 public Q_SLOTS:
     /**DBUS interface function.
--- trunk/KDE/kdeedu/kstars/kstars/kstarsactions.cpp #809476:809477
@@ -1058,9 +1058,15 @@
 void KStars::slotAboutToQuit()
 {
     //store focus values in Options
+    //If not trcking and using Alt/Az coords, stor the Alt/Az coordinates
     if( skymap && skymap->focus() && skymap->focus()->ra() ) {
-      Options::setFocusRA( skymap->focus()->ra()->Hours() );
-      Options::setFocusDec( skymap->focus()->dec()->Degrees() );
+        if ( Options::useAltAz && ! Options::isTracking() ) {
+            Options::setFocusRA( skymap->focus()->az()->Degrees() );
+            Options::setFocusDec( skymap->focus()->alt()->Degrees() );
+        } else {
+            Options::setFocusRA( skymap->focus()->ra()->Hours() );
+            Options::setFocusDec( skymap->focus()->dec()->Degrees() );
+        }
     }
 
     //Store Window geometry in Options object
--- trunk/KDE/kdeedu/kstars/kstars/kstarsinit.cpp #809476:809477
@@ -602,9 +602,6 @@
     //Initialize Observing List
     obsList = new ObservingList( this );
 
-    data()->setFullTimeUpdate();
-    updateTime();
-
     //Do not start the clock if "--paused" specified on the cmd line
     if ( StartClockRunning )
         data()->clock()->start();
@@ -613,11 +610,14 @@
     connect( data(), SIGNAL( clearCache() ), this,
              SLOT( clearCachedFindDialog() ) );
 
+    //Propagate config settings
+    applyConfig( false );
+
     //Initialize focus
     initFocus();
 
-    //Propagate config settings
-    applyConfig();
+    data()->setFullTimeUpdate();
+    updateTime();
 
     //show the window.  must be before kswizard and messageboxes
     show();
@@ -635,35 +635,44 @@
 }
 
 void KStars::initFocus() {
-    SkyPoint newPoint;
+    //Case 1: tracking on an object
+    if ( Options::isTracking() && Options::focusObject() != i18n("nothing") ) {
+        SkyObject *oFocus;
+        if ( Options::focusObject() == i18n("star") ) {
+            SkyPoint p( Options::focusRA(), Options::focusDec() );
+            double maxrad = 1.0;
 
-    if ( Options::focusRA() == 180.0 && Options::focusDec() == 45.0 ) {
-        newPoint.setAz( Options::focusRA() );
-        newPoint.setAlt( Options::focusDec() );
-        newPoint.HorizontalToEquatorial( LST(), geo()->lat() );
-    } else {
-        newPoint.set( Options::focusRA(), Options::focusDec() );
-        newPoint.EquatorialToHorizontal( LST(), geo()->lat() );
-    }
+            oFocus = data()->skyComposite()->starNearest( &p, maxrad );
+        } else {
+            oFocus = data()->objectNamed( Options::focusObject() );
+        }
 
-    //need to set focusObject before updateTime, otherwise tracking is set to false
-    if ( (Options::focusObject() != i18n( "star" ) ) &&
-            (Options::focusObject() != i18n( "nothing" ) ) )
-        map()->setFocusObject( data()->objectNamed( Options::focusObject() ) );
-
-    //if user was tracking last time, track on same object now.
-    if ( Options::isTracking() ) {
-        map()->setClickedObject( data()->objectNamed( Options::focusObject() ) );
-        if ( map()->clickedObject() ) {
-            map()->setFocusPoint( map()->clickedObject() );
-            map()->setFocusObject( map()->clickedObject() );
+        if ( oFocus ) {
+            map()->setFocusObject( oFocus );
+            map()->setClickedObject( oFocus );
+            map()->setFocusPoint( oFocus );
         } else {
-            map()->setFocusPoint( &newPoint );
+            kWarning() << "Cannot center on " 
+                       << Options::focusObject() 
+                       << ": no object found." << endl;
         }
+
+    //Case 2: not tracking, and using Alt/Az coords.  Set focus point using
+    //FocusRA as the Azimuth, and FocusDec as the Altitude
+    } else if ( ! Options::isTracking() && Options::useAltAz() ) {
+        SkyPoint pFocus;
+        pFocus.setAz( Options::focusRA() );
+        pFocus.setAlt( Options::focusDec() );
+        pFocus.HorizontalToEquatorial( LST(), geo()->lat() );
+        map()->setFocusPoint( &pFocus );
+
+    //Default: set focus point using FocusRA as the RA and 
+    //FocusDec as the Dec
     } else {
-        map()->setFocusPoint( &newPoint );
+        SkyPoint pFocus( Options::focusRA(), Options::focusDec() );
+        pFocus.EquatorialToHorizontal( LST(), geo()->lat() );
+        map()->setFocusPoint( &pFocus );
     }
-
     data()->setSnapNextFocus();
     map()->setDestination( map()->focusPoint() );
     map()->setFocus( map()->destination() );
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #809476:809477
@@ -76,6 +76,19 @@
     readLineNumbers();
     readData( Options::magLimitDrawStar() );
 
+    //adjust maglimit for ZoomLevel
+    float maglim = Options::magLimitDrawStar();
+    double lgmin = log10(MINZOOM);
+    double lgmax = log10(MAXZOOM);
+    double lgz = log10(Options::zoomFactor());
+
+    if ( lgz <= 0.75*lgmax )
+        maglim -= (Options::magLimitDrawStar() -
+                   Options::magLimitDrawStarZoomOut() ) *
+                  (0.75*lgmax - lgz)/(0.75*lgmax - lgmin);
+
+    m_zoomMagLimit = maglim;
+
     StarObject::initImages();
 }
 
@@ -185,13 +198,13 @@
 
     //shortcuts to inform whether to draw different objects
     bool hideFaintStars( checkSlewing && Options::hideStars() );
-    float maglim = Options::magLimitDrawStar();
     double hideStarsMag = Options::magLimitHideStar();
     rereadData();
 
     reindex( data->updateNum() );
 
     //adjust maglimit for ZoomLevel
+    float maglim = Options::magLimitDrawStar();
     double lgmin = log10(MINZOOM);
     double lgmax = log10(MAXZOOM);
     double lgz = log10(Options::zoomFactor());
@@ -482,6 +495,7 @@
 {
     StarObject *oBest = 0;
     MeshIterator region(m_skyMesh, OBJ_NEAREST_BUF);
+
     while ( region.hasNext() ) {
         StarList* starList = m_starIndex->at( region.next() );
         for (int i=0; i < starList->size(); ++i) {


More information about the Kstars-devel mailing list