コード例 #1
0
void KStarsData::updateTime( GeoLocation *geo, SkyMap *skymap, const bool automaticDSTchange ) {
    // sync LTime with the simulation clock
    LTime = geo->UTtoLT( ut() );
    syncLST();

    //Only check DST if (1) TZrule is not the empty rule, and (2) if we have crossed
    //the DST change date/time.
    if ( !geo->tzrule()->isEmptyRule() ) {
        if ( TimeRunsForward ) {
            // timedirection is forward
            // DST change happens if current date is bigger than next calculated dst change
            if ( ut() > NextDSTChange ) resetToNewDST(geo, automaticDSTchange);
        } else {
            // timedirection is backward
            // DST change happens if current date is smaller than next calculated dst change
            if ( ut() < NextDSTChange ) resetToNewDST(geo, automaticDSTchange);
        }
    }

    KSNumbers num( ut().djd() );

    if ( fabs( ut().djd() - LastNumUpdate.djd() ) > 1.0 ) {
        LastNumUpdate = ut().djd();
        m_preUpdateNumID++;
        m_preUpdateNum = KSNumbers( num );
        skyComposite()->update( &num );
    }

    if ( fabs( ut().djd() - LastPlanetUpdate.djd() ) > 0.01 ) {
        LastPlanetUpdate = ut().djd();
        skyComposite()->updatePlanets( &num );
    }

    // Moon moves ~30 arcmin/hr, so update its position every minute.
    if ( fabs( ut().djd() - LastMoonUpdate.djd() ) > 0.00069444 ) {
        LastMoonUpdate = ut();
        skyComposite()->updateMoons( &num );
    }

    //Update Alt/Az coordinates.  Timescale varies with zoom level
    //If Clock is in Manual Mode, always update. (?)
    if ( fabs( ut().djd() - LastSkyUpdate.djd() ) > 0.1/Options::zoomFactor() || clock()->isManualMode() ) {
        LastSkyUpdate = ut();
        m_preUpdateID++;
        skyComposite()->update(); //omit KSNumbers arg == just update Alt/Az coords

        //Update focus
        skymap->updateFocus();

        if ( clock()->isManualMode() )
            QTimer::singleShot( 0, skymap, SLOT( forceUpdateNow() ) );
        else
            skymap->forceUpdate();
    }
}
コード例 #2
0
ファイル: conjunctions.cpp プロジェクト: KDE/kstars
void ConjunctionsTool::slotCompute (void)
{
    KStarsDateTime dtStart = startDate -> dateTime();   // Start date
    KStarsDateTime dtStop = stopDate -> dateTime();     // Stop date
    long double startJD = dtStart.djd();                // Start julian day
    long double stopJD = dtStop.djd();                  // Stop julian day
    bool opposition = false;                            // true=opposition, false=conjunction
    if( Opposition->currentIndex() ) opposition = true;
    QStringList objects;                                // List of sky object used as Object1
    KStarsData *data = KStarsData::Instance();
    int progress = 0;

    // Check if we have a valid angle in maxSeparationBox
    dms maxSeparation( 0.0 );
    bool ok;
    maxSeparation = maxSeparationBox->createDms( true, &ok );

    if( !ok ) {
        KMessageBox::sorry( 0, i18n("Maximum separation entered is not a valid angle. Use the What's this help feature for information on how to enter a valid angle") );
        return;
    }

    // Check if Object1 and Object2 are set
    if( FilterTypeComboBox->currentIndex() == 0 && !Object1 ) {
        KMessageBox::sorry( 0, i18n("Please select an object to check conjunctions with, by clicking on the \'Find Object\' button.") );
        return;
    }
    Object2 = KSPlanetBase::createPlanet( Obj2ComboBox->currentIndex() );
    if( FilterTypeComboBox->currentIndex() == 0 && Object1->name() == Object2->name() ) {
        // FIXME: Must free the created Objects
        KMessageBox::sorry( 0 , i18n("Please select two different objects to check conjunctions with.") );
        return;
    }

    // Init KSConjunct object
    KSConjunct ksc;
    connect( &ksc, SIGNAL(madeProgress(int)), this, SLOT(showProgress(int)) );
    ksc.setGeoLocation( geoPlace );

    switch ( FilterTypeComboBox->currentIndex() ) {
    case 1: // All object types
        foreach( int type, data->skyComposite()->objectNames().keys() )
            objects += data->skyComposite()->objectNames( type );
        break;
    case 2: // Stars
        objects += data->skyComposite()->objectNames( SkyObject::STAR );
        objects += data->skyComposite()->objectNames( SkyObject::CATALOG_STAR );
        break;
    case 3: // Solar system
        objects += data->skyComposite()->objectNames( SkyObject::PLANET );
        objects += data->skyComposite()->objectNames( SkyObject::COMET );
        objects += data->skyComposite()->objectNames( SkyObject::ASTEROID );
        objects += data->skyComposite()->objectNames( SkyObject::MOON );
        objects += i18n("Sun");
        // Remove Object2  planet
        objects.removeAll( Object2->name() );
        break;
    case 4: // Planet
        objects += data->skyComposite()->objectNames( SkyObject::PLANET );
        // Remove Object2  planet
        objects.removeAll( Object2->name() );
        break;
    case 5: // Comet
        objects += data->skyComposite()->objectNames( SkyObject::COMET );
        break;
    case 6: // Ateroid
        objects += data->skyComposite()->objectNames( SkyObject::ASTEROID );
        break;
    case 7: // Open Clusters
        objects = data->skyComposite()->objectNames( SkyObject::OPEN_CLUSTER );
        break;
    case 8: // Open Clusters
        objects = data->skyComposite()->objectNames( SkyObject::GLOBULAR_CLUSTER );
        break;
    case 9: // Gaseous nebulae
        objects = data->skyComposite()->objectNames( SkyObject::GASEOUS_NEBULA );
        break;
    case 10: // Planetary nebula
        objects = data->skyComposite()->objectNames( SkyObject::PLANETARY_NEBULA );
        break;
    case 11: // Galaxies
        objects = data->skyComposite()->objectNames( SkyObject::GALAXY );
        break;
    }

    // Remove all Jupiter and Saturn moons
    // KStars crash if we compute a conjunction between a planet and one of this moon
    if ( FilterTypeComboBox->currentIndex() == 1 ||
            FilterTypeComboBox->currentIndex() == 3 ||
            FilterTypeComboBox->currentIndex() == 6 ) {
        objects.removeAll( "Io" );
        objects.removeAll( "Europa" );
        objects.removeAll( "Ganymede" );
        objects.removeAll( "Callisto" );
        objects.removeAll( "Mimas" );
        objects.removeAll( "Enceladus" );
        objects.removeAll( "Tethys" );
        objects.removeAll( "Dione" );
        objects.removeAll( "Rhea" );
        objects.removeAll( "Titan" );
        objects.removeAll( "Hyperion" );
        objects.removeAll( "Iapetus" );
    }

    if ( FilterTypeComboBox->currentIndex() != 0 ) {
        // Show a progress dialog while processing
        QProgressDialog progressDlg( i18n( "Compute conjunction..." ), i18n( "Abort" ), 0, objects.count(), this);
        progressDlg.setWindowModality( Qt::WindowModal );
        progressDlg.setValue( 0 );

        foreach( QString object, objects ) {
            // If the user click on the 'cancel' button
            if ( progressDlg.wasCanceled() )
                break;

            // Update progress dialog
            ++progress;
            progressDlg.setValue( progress );
            progressDlg.setLabelText( i18n( "Compute conjunction between %1 and %2", Object2->name(), object ) );

            // Compute conjuction
            Object1 = data->skyComposite()->findByName( object );
            showConjunctions( ksc.findClosestApproach(*Object1, *Object2, startJD, stopJD, maxSeparation, opposition), object, Object2->name() );
        }

        progressDlg.setValue( objects.count() );
    } else {