kstarsliteinit.cpp 4.49 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#include "kstarslite.h"
#include "skymaplite.h"
#include "kstarsdata.h"

#include "skycomponents/skymapcomposite.h"

#include "Options.h"

void KStarsLite::datainitFinished() {
    //Time-related connections
    connect( data()->clock(), SIGNAL( timeAdvanced() ),
             this, SLOT( updateTime() ) );
    connect( data()->clock(), SIGNAL( timeChanged() ),
             this, SLOT( updateTime() ) );

    //Add GUI elements to main window
    //buildGUI();

    connect( data()->clock(), SIGNAL( scaleChanged( float ) ),
             map(), SLOT( slotClockSlewing() ) );

    connect( data(),   SIGNAL(skyUpdate(bool)),            map(),  SLOT( forceUpdateNow() ) );
23 24
    connect( this, SIGNAL( scaleChanged(float) ), data(), SLOT( setTimeDirection( float ) ) );
    connect( this, SIGNAL( scaleChanged(float) ), data()->clock(), SLOT( setClockScale( float )) );
25
    //connect( this, SIGNAL( scaleChanged(float) ), map(),  SLOT( setFocus() ) ); Why did we need this connection in KStars?
26 27 28 29 30

    //Do not start the clock if "--paused" specified on the cmd line
    if ( StartClockRunning ) data()->clock()->start();

    //Propagate config settings
31
    applyConfig( false );
32 33 34 35 36 37 38 39 40 41 42 43 44 45

    //Initialize focus
    initFocus();

    data()->setFullTimeUpdate();
    updateTime();

    //If this is the first startup, show the wizard
    if ( Options::runStartupWizard() ) {
    }

    //DEBUG
    qDebug() << "The current Date/Time is: " << KStarsDateTime::currentDateTime().toString();

46
    //Notify Splash in QML and LocationDialogLite that loading of data is finished
47
    dataLoadFinished();
48
    map()->forceUpdate();
49 50 51 52 53 54

    //Default options
    Options::setShowEquator(true);
    Options::setShowHorizon(true);
    Options::setShowEcliptic(true);
    Options::setAutoSelectGrid(false);
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
}

void KStarsLite::initFocus() {
    //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;

            oFocus = data()->skyComposite()->starNearest( &p, maxrad );
        } else {
            oFocus = data()->objectNamed( Options::focusObject() );
        }

        if ( oFocus ) {
            map()->setFocusObject( oFocus );
            map()->setClickedObject( oFocus );
            map()->setFocusPoint( oFocus );
        } else {
            qWarning() << "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( data()->lst(), data()->geo()->lat() );
        map()->setFocusPoint( &pFocus );

        //Default: set focus point using FocusRA as the RA and
        //FocusDec as the Dec
    } else {
        SkyPoint pFocus( Options::focusRA(), Options::focusDec() );
        pFocus.EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
        map()->setFocusPoint( &pFocus );
    }
    data()->setSnapNextFocus();
    map()->setDestination( *map()->focusPoint() );
    map()->setFocus( map()->destination() );

    //map()->showFocusCoords();

    //Check whether initial position is below the horizon.
    if ( Options::useAltAz() && Options::showGround() &&
         map()->focus()->alt().Degrees() < -1.0 ) {
        QString caption = i18n( "Initial Position is Below Horizon" );
        QString message = i18n( "The initial position is below the horizon.\nWould you like to reset to the default position?" );
        map()->setClickedObject( NULL );
        map()->setFocusObject( NULL );
        Options::setIsTracking( false );

        data()->setSnapNextFocus(true);

        SkyPoint DefaultFocus;
        DefaultFocus.setAz( 180.0 );
        DefaultFocus.setAlt( 45.0 );
        DefaultFocus.HorizontalToEquatorial( data()->lst(), data()->geo()->lat() );
        map()->setDestination( DefaultFocus );
    }

//If there is a focusObject() and it is a SS body, add a temporary Trail
/*if ( map()->focusObject() && map()->focusObject()->isSolarSystem()
            && Options::useAutoTrail() ) {
        ((KSPlanetBase*)map()->focusObject())->addToTrail();
        data()->temporaryTrail = true;
    }*/
}