ConstellationNamesComponent::ConstellationNamesComponent(SkyComposite *parent, CultureList* cultures )
        : ListComponent(parent )
{
    uint i = 0;
    bool culture = false;
    KSFileReader fileReader;
    QString cultureName;

    if ( ! fileReader.open( "cnames.dat" ) )
        return;

    emitProgressText( i18n("Loading constellation names" ) );
    
    localCNames = Options::useLocalConstellNames();

    while ( fileReader.hasMoreLines() ) {
        QString line, name, abbrev;
        int rah, ram, ras, dd, dm, ds;
        QChar sgn, mode;

        line = fileReader.readLine();

        mode = line.at( 0 );
        if ( mode == 'C') {
            cultureName = line.mid( 2 ).trimmed();
            culture     = cultureName == cultures->current();
            i++;
            continue;
        }

        if ( culture ) {
            rah = line.mid( 0, 2 ).toInt();
            ram = line.mid( 2, 2 ).toInt();
            ras = line.mid( 4, 2 ).toInt();

            sgn = line.at( 6 );
            dd = line.mid( 7, 2 ).toInt();
            dm = line.mid( 9, 2 ).toInt();
            ds = line.mid( 11, 2 ).toInt();

            abbrev = line.mid( 13, 3 );
            name  = line.mid( 17 ).trimmed();

            if( Options::useLocalConstellNames() )
                name = i18nc( "Constellation name (optional)", name.toLocal8Bit().data() );

            dms r; r.setH( rah, ram, ras );
            dms d( dd, dm,  ds );

            if ( sgn == '-' )
                d.setD( -1.0*d.Degrees() );

            SkyObject *o = new SkyObject( SkyObject::CONSTELLATION, r, d, 0.0, name, abbrev );
            m_ObjectList.append( o );

            //Add name to the list of object names
            objectNames(SkyObject::CONSTELLATION).append( name );
        }
    }
}
SatellitesComponent::SatellitesComponent( SkyComposite *parent ) :
    SkyComponent( parent )
{
    KSFileReader fileReader;
    QString line;
    QStringList group_infos;
    
    if ( ! fileReader.open( "satellites.dat" ) ) return;

    emitProgressText( i18n("Loading satellites" ) );
    

    while ( fileReader.hasMoreLines() ) {
        line = fileReader.readLine();
        if ( line.trimmed().isEmpty() || line.at( 0 ) == '#' )
            continue;
        group_infos = line.split( ';' );
        m_groups.append( new SatelliteGroup( group_infos.at( 0 ), group_infos.at( 1 ), QUrl( group_infos.at( 2 ) ) ) );
    }

    objectNames(SkyObject::SATELLITE).clear();

    foreach( SatelliteGroup *group, m_groups )
    {
        for ( int i=0; i<group->size(); i++ )
        {
            Satellite *sat = group->at( i );
            if ( sat->selected() && nameHash.contains(sat->name().toLower()) == false)
            {
                objectNames(SkyObject::SATELLITE).append(sat->name());
                nameHash[sat->name().toLower()] = sat;
            }
        }
    }
}
Beispiel #3
0
StarComponent::StarComponent(SkyComposite *parent )
    : ListComponent(parent), m_reindexNum(J2000), m_FaintMagnitude(-5.0),
      starsLoaded(false), focusStar(NULL)
{
    m_skyMesh = SkyMesh::Instance();
    m_StarBlockFactory = StarBlockFactory::Instance();

    m_starIndex = new StarIndex();
    for (int i = 0; i < m_skyMesh->size(); i++)
        m_starIndex->append( new StarList() );
    m_highPMStars.append( new HighPMStarList( 840.0 ) );
    m_highPMStars.append( new HighPMStarList( 304.0 ) );
    m_reindexInterval = StarObject::reindexInterval( 304.0 );

    m_zoomMagLimit = 0.0;

    for ( int i = 0; i <= MAX_LINENUMBER_MAG; i++ )
        m_labelList[ i ] = new LabelList;

    // Actually load data
    emitProgressText( i18n("Loading stars" ) );
    loadStaticData();
    // Load any deep star catalogs that are available
    loadDeepStarCatalogs();
    SkyQPainter::initStarImages();
}
SolarSystemComposite::SolarSystemComposite(SkyComposite *parent ) :
    SkyComposite(parent)
{
    emitProgressText( i18n("Loading solar system" ) );
    m_Earth = new KSPlanet( I18N_NOOP( "Earth" ), QString(), QColor( "white" ), 12756.28 /*diameter in km*/ );

    m_Sun = new KSSun();
    addComponent( new SolarSystemSingleComponent( this, m_Sun, Options::showSun ) );
    m_Moon = new KSMoon();
    addComponent( new SolarSystemSingleComponent( this, m_Moon, Options::showMoon ) );
    addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::MERCURY ), Options::showMercury ) );
    addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::VENUS ), Options::showVenus ) );
    addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::MARS ), Options::showMars ) );
    SolarSystemSingleComponent *jup = new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::JUPITER ), Options::showJupiter );
    addComponent( jup );
    m_JupiterMoons = new PlanetMoonsComponent( this, jup, KSPlanetBase::JUPITER);
    addComponent( m_JupiterMoons );
    SolarSystemSingleComponent *sat = new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::SATURN ), Options::showSaturn );
    addComponent( sat );
    addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::URANUS ), Options::showUranus ) );
    addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::NEPTUNE ), Options::showNeptune ) );
    addComponent( new SolarSystemSingleComponent( this, new KSPluto(), Options::showPluto ) );

    addComponent( m_AsteroidsComponent = new AsteroidsComponent( this  ));
    addComponent( m_CometsComponent    = new CometsComponent( this ));
}
HorizonComponent::HorizonComponent(SkyComposite *parent )
        : PointListComponent( parent )
{
    KStarsData *data = KStarsData::Instance();
    emitProgressText( i18n("Creating horizon" ) );

    //Define Horizon
    for ( unsigned int i=0; i<NCIRCLE; ++i ) {
        SkyPoint *o = new SkyPoint();
        o->setAz( i*360./NCIRCLE );
        o->setAlt( 0.0 );

        o->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
        pointList().append( o );
    }
}
SatellitesComponent::SatellitesComponent( SkyComposite *parent ) :
    SkyComponent( parent )
{
    KSFileReader fileReader;
    QString line;
    QStringList group_infos;
    
    if ( ! fileReader.open( "satellites.dat" ) ) return;

    emitProgressText( i18n("Loading satellites" ) );
    

    while ( fileReader.hasMoreLines() ) {
        line = fileReader.readLine();
        if ( line.trimmed().isEmpty() || line.at( 0 ) == '#' )
            continue;
        group_infos = line.split( ";" );
        m_groups.append( new SatelliteGroup( group_infos.at( 0 ), group_infos.at( 1 ), KUrl( group_infos.at( 2 ) ) ) );
    }
}
void CatalogComponent::loadData() {
    emitProgressText( i18n("Loading custom catalog: %1", m_catName ) );

    QList < QPair <int, QString> > names;

    KStarsData::Instance()->catalogdb()->GetAllObjects(m_catName,
                                                       m_ObjectList,
                                                       names,
                                                       this);
    for (int iter = 0; iter < names.size(); iter++) {
        if (names.at(iter).first <= SkyObject::TYPE_UNKNOWN) {
            if (!objectNames(names.at(iter).first).contains(names.at(iter).second))
                objectNames(names.at(iter).first).append(names.at(iter).second);
        }
    }

    CatalogData loaded_catalog_data;
    KStarsData::Instance()->catalogdb()->GetCatalogData(m_catName, loaded_catalog_data);
    m_catPrefix = loaded_catalog_data.prefix;
    m_catColor = loaded_catalog_data.color;
    m_catFluxFreq = loaded_catalog_data.fluxfreq;
    m_catFluxUnit = loaded_catalog_data.fluxunit;
    m_catEpoch = loaded_catalog_data.epoch;
}
/*
 * @short Initialize the comets list.
 * Reads in the comets data from the comets.dat file.
 *
 * Populate the list of Comets from the data file.
 * The data file is a CSV file with the following columns :
 * @li 1 full name [string]
 * @li 2 modified julian day of orbital elements [int]
 * @li 3 perihelion distance in AU [double]
 * @li 4 eccentricity of orbit [double]
 * @li 5 inclination angle of orbit in degrees [double]
 * @li 6 argument of perihelion in degrees [double]
 * @li 7 longitude of the ascending node in degrees [double]
 * @li 8 time of perihelion passage (YYYYMMDD.DDD) [double]
 * @li 9 orbit solution ID [string]
 * @li 10 Near-Earth Object (NEO) flag [bool]
 * @li 11 comet total magnitude parameter [float]
 * @li 12 comet nuclear magnitude parameter [float]
 * @li 13 object diameter (from equivalent sphere) [float]
 * @li 14 object bi/tri-axial ellipsoid dimensions [string]
 * @li 15 geometric albedo [float]
 * @li 16 rotation period [float]
 * @li 17 orbital period [float]
 * @li 18 earth minimum orbit intersection distance [double]
 * @li 19 orbit classification [string]
 * @li 20 comet total magnitude slope parameter
 * @li 21 comet nuclear magnitude slope parameter
 * @note See KSComet constructor for more details.
 */
void CometsComponent::loadData() {
    QString name, orbit_id, orbit_class, dimensions;
    bool neo;
    int mJD;
    double q, e, dble_i, dble_w, dble_N, Tp, earth_moid;
    long double JD;
    float M1, M2, K1, K2, diameter, albedo, rot_period, period;

    emitProgressText(i18n("Loading comets"));
    objectNames(SkyObject::COMET).clear();

    QList< QPair<QString, KSParser::DataTypes> > sequence;
    sequence.append(qMakePair(QString("full name"), KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("epoch_mjd"), KSParser::D_INT));
    sequence.append(qMakePair(QString("q"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("e"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("i"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("w"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("om"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("tp_calc"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("orbit_id"), KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("neo"), KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("M1"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("M2"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("diameter"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("extent"), KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("albedo"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("rot_period"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("per_y"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("moid"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("class"), KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("H"), KSParser::D_SKIP));
    sequence.append(qMakePair(QString("G"), KSParser::D_SKIP));

    QString file_name = QStandardPaths::locate(QStandardPaths::DataLocation, QString("comets.dat") );
    KSParser cometParser(file_name, '#', sequence);

    QHash<QString, QVariant> row_content;
    while (cometParser.HasNextRow()){
        KSComet *com = 0;
        row_content = cometParser.ReadNextRow();
        name   = row_content["full name"].toString();
        name   = name.trimmed();
        mJD    = row_content["epoch_mjd"].toInt();
        q    = row_content["q"].toDouble();
        e    = row_content["e"].toDouble();
        dble_i = row_content["i"].toDouble();
        dble_w = row_content["w"].toDouble();
        dble_N = row_content["om"].toDouble();
        Tp     = row_content["tp_calc"].toDouble();
        orbit_id = row_content["orbit_id"].toString();
        neo = row_content["neo"] == "Y";

        if(row_content["M1"].toFloat()==0.0)
            M1 = 101.0;
        else
            M1 = row_content["M1"].toFloat();

        if(row_content["M2"].toFloat()==0.0)
            M2 = 101.0;
        else
            M2 = row_content["M2"].toFloat();

        diameter = row_content["diameter"].toFloat();
        dimensions = row_content["extent"].toString();
        albedo  = row_content["albedo"].toFloat();
        rot_period = row_content["rot_period"].toFloat();
        period  = row_content["per_y"].toFloat();
        earth_moid  = row_content["moid"].toDouble();
        orbit_class = row_content["class"].toString();
        K1 = row_content["H"].toFloat();
        K2 = row_content["G"].toFloat();

        JD = static_cast<double>( mJD ) + 2400000.5;

        com = new KSComet( name, QString(), JD, q, e,
                           dms( dble_i ), dms( dble_w ),
                           dms( dble_N ), Tp, M1, M2,
                           K1, K2 );
        com->setOrbitID( orbit_id );
        com->setNEO( neo );
        com->setDiameter( diameter );
        com->setDimensions( dimensions );
        com->setAlbedo( albedo );
        com->setRotationPeriod( rot_period );
        com->setPeriod( period );
        com->setEarthMOID( earth_moid );
        com->setOrbitClass( orbit_class );
        com->setAngularSize( 0.005 );
        m_ObjectList.append( com );

        // Add *short* name to the list of object names
        objectNames( SkyObject::COMET ).append( com->name() );
    }
}
/*
 *@short Initialize the asteroids list.
 *Reads in the asteroids data from the asteroids.dat file.
 *
 * The data file is a CSV file with the following columns :
 * @li 1 full name [string]
 * @li 2 Modified Julian Day of orbital elements [int]
 * @li 3 perihelion distance in AU [double]
 * @li 4 semi-major axis
 * @li 5 eccentricity of orbit [double]
 * @li 6 inclination angle of orbit in degrees [double]
 * @li 7 argument of perihelion in degrees [double]
 * @li 8 longitude of the ascending node in degrees [double]
 * @li 9 mean anomaly
 * @li 10 time of perihelion passage (YYYYMMDD.DDD) [double]
 * @li 11 orbit solution ID [string]
 * @li 12 absolute magnitude [float]
 * @li 13 slope parameter [float]
 * @li 14 Near-Earth Object (NEO) flag [bool]
 * @li 15 comet total magnitude parameter [float] (we should remove this column)
 * @li 16 comet nuclear magnitude parameter [float] (we should remove this column)
 * @li 17 object diameter (from equivalent sphere) [float]
 * @li 18 object bi/tri-axial ellipsoid dimensions [string]
 * @li 19 geometric albedo [float]
 * @li 20 rotation period [float]
 * @li 21 orbital period [float]
 * @li 22 earth minimum orbit intersection distance [double]
 * @li 23 orbit classification [string]
 */
void AsteroidsComponent::loadData() {
    QString line, name, full_name, orbit_id, orbit_class, dimensions;
    QStringList fields;
    int mJD;
    double q, a, e, dble_i, dble_w, dble_N, dble_M, H, G, earth_moid;
    long double JD;
    float diameter, albedo, rot_period, period;
    bool ok, neo;

    emitProgressText( i18n("Loading asteroids") );

    // Clear lists
    m_ObjectList.clear();
    objectNames( SkyObject::ASTEROID ).clear();

    QList< QPair<QString, KSParser::DataTypes> > sequence;
    sequence.append(qMakePair(QString("full name"), KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("epoch_mjd"), KSParser::D_INT));
    sequence.append(qMakePair(QString("q"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("a"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("e"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("i"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("w"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("om"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("ma"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("tp_calc"), KSParser::D_SKIP));
    sequence.append(qMakePair(QString("orbit_id"), KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("H"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("G"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("neo"), KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("tp_calc"), KSParser::D_SKIP));
    sequence.append(qMakePair(QString("M2"), KSParser::D_SKIP));
    sequence.append(qMakePair(QString("diameter"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("extent"), KSParser::D_QSTRING));
    sequence.append(qMakePair(QString("albedo"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("rot_period"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("per_y"), KSParser::D_FLOAT));
    sequence.append(qMakePair(QString("moid"), KSParser::D_DOUBLE));
    sequence.append(qMakePair(QString("class"), KSParser::D_QSTRING));

    QString file_name = KStandardDirs::locate( "appdata",
                                               QString("asteroids.dat") );
    KSParser asteroid_parser(file_name, '#', sequence);

    QHash<QString, QVariant> row_content;
    while (asteroid_parser.HasNextRow()){
        row_content = asteroid_parser.ReadNextRow();
        full_name = row_content["full name"].toString();
        full_name = full_name.trimmed();
        int catN  = full_name.section(" ", 0, 0).toInt();
        name = full_name.section(" ", 1, -1);
        mJD  = row_content["epoch_mjd"].toInt();
        q    = row_content["q"].toDouble();
        a    = row_content["a"].toDouble();
        e    = row_content["e"].toDouble();
        dble_i = row_content["i"].toDouble();
        dble_w = row_content["w"].toDouble();
        dble_N = row_content["om"].toDouble();
        dble_M = row_content["ma"].toDouble();
        orbit_id = row_content["orbit_id"].toString();
        H   = row_content["H"].toDouble();
        G   = row_content["G"].toDouble();
        neo = row_content["neo"].toString() == "Y";
        diameter = row_content["diameter"].toFloat();
        dimensions = row_content["extent"].toString();
        albedo  = row_content["albedo"].toFloat();
        rot_period = row_content["rot_period"].toFloat();
        period  = row_content["per_y"].toFloat();
        earth_moid  = row_content["moid"].toDouble();
        orbit_class = row_content["class"].toString();

        JD = static_cast<double>(mJD) + 2400000.5;

        KSAsteroid *new_asteroid = new KSAsteroid( catN, name, QString(), JD,
                                          a, e,
                                          dms(dble_i), dms(dble_w),
                                          dms(dble_N), dms(dble_M),
                                          H, G );
        new_asteroid->setPerihelion(q);
        new_asteroid->setOrbitID(orbit_id);
        new_asteroid->setNEO(neo);
        new_asteroid->setDiameter(diameter);
        new_asteroid->setDimensions(dimensions);
        new_asteroid->setAlbedo(albedo);
        new_asteroid->setRotationPeriod(rot_period);
        new_asteroid->setPeriod(period);
        new_asteroid->setEarthMOID(earth_moid);
        new_asteroid->setOrbitClass(orbit_class);
        new_asteroid->setAngularSize(0.005);
        m_ObjectList.append(new_asteroid);

        // Add name to the list of object names
        objectNames(SkyObject::ASTEROID).append(name);
    }
}