void
KeySignatureDialog::regenerateKeyCombo()
{
    if (m_explanatoryLabel)
        m_explanatoryLabel->hide();

    m_ignoreComboChanges = true;
    QString currentText = m_keyCombo->currentText();
    Rosegarden::Key::KeyList keys(Rosegarden::Key::getKeys(m_key.isMinor()));
    m_keyCombo->clear();

    std::sort(keys.begin(), keys.end(), KeyNameComparator());
    bool textSet = false;

    for (Rosegarden::Key::KeyList::iterator i = keys.begin();
            i != keys.end(); ++i) {

        QString name(strtoqstr(i->getName()));
        int space = name.indexOf(' ');
        if (space > 0)
            name = name.left(space);

        // translation required; translation from QObject::tr to pull
        // translations from (generated) InstrumentStrings.cpp, must have "note
        // name" to distinguish from keyboard shortcut, even though this is a
        // key name
        // But m_key object needed to display the key pixmap can't be easily
        // obtained from a translated key name. That's why the untranslated key
        // name is now stored in the user data associated to each QComboBox
        // item.
        QVariant untranslatedName(name);
        m_keyCombo->addItem(QObject::tr(name.toStdString().c_str(), "note name"),
                            untranslatedName);

        if (m_valid && (*i == m_key)) {
            m_keyCombo->setCurrentIndex(m_keyCombo->count() - 1);
            textSet = true;
        }
    }

    if (!textSet) {
        m_keyCombo->setEditText(currentText);
    }
    m_ignoreComboChanges = false;
}
Exemple #2
0
void KSPlanet::calcEcliptic(double Tau, EclipticPosition &epret) const {
    double sum[6];
    OrbitDataColl odc;
    double Tpow[6];

    Tpow[0] = 1.0;
    for (int i=1; i<6; ++i) {
        Tpow[i] = Tpow[i-1] * Tau;
    }

    if ( ! odm.loadData( odc, untranslatedName() ) ) {
        epret.longitude = dms(0.0);
        epret.latitude  = dms(0.0);
        epret.radius    = 0.0;
        qWarning() << "Could not get data for '" << name() << "'" << endl;
        return;
    }

    //Ecliptic Longitude
    for (int i=0; i<6; ++i) {
        sum[i] = 0.0;
        for (int j = 0; j < odc.Lon[i].size(); ++j) {
            sum[i] += odc.Lon[i][j].A * cos( odc.Lon[i][j].B + odc.Lon[i][j].C*Tau );
            /*
            qDebug() << "sum[" << i <<"] =" << sum[i] <<
            	" A = " << odc.Lon[i][j].A << " B = " << odc.Lon[i][j].B <<
            	" C = " << odc.Lon[i][j].C << endl;
            	*/
        }
        sum[i] *= Tpow[i];
        //qDebug() << name() << " : sum[" << i << "] = " << sum[i];
    }

    epret.longitude.setRadians( sum[0] + sum[1] + sum[2] + sum[3] + sum[4] + sum[5] );
    epret.longitude.setD( epret.longitude.reduce().Degrees() );

    //Compute Ecliptic Latitude
    for (uint i=0; i<6; ++i) {
        sum[i] = 0.0;
        for (int j = 0; j < odc.Lat[i].size(); ++j) {
            sum[i] += odc.Lat[i][j].A * cos( odc.Lat[i][j].B + odc.Lat[i][j].C*Tau );
        }
        sum[i] *= Tpow[i];
    }


    epret.latitude.setRadians( sum[0] + sum[1] + sum[2] + sum[3] + sum[4] + sum[5] );

    //Compute Heliocentric Distance
    for (uint i=0; i<6; ++i) {
        sum[i] = 0.0;
        for (int j = 0; j < odc.Dst[i].size(); ++j) {
            sum[i] += odc.Dst[i][j].A * cos( odc.Dst[i][j].B + odc.Dst[i][j].C*Tau );
        }
        sum[i] *= Tpow[i];
    }

    epret.radius = sum[0] + sum[1] + sum[2] + sum[3] + sum[4] + sum[5];

    /*
    qDebug() << name() << " pre: Lat = " << epret.latitude.toDMSString() << " Long = " <<
    	epret.longitude.toDMSString() << " Dist = " << epret.radius << endl;
    */

}
Exemple #3
0
//we don't need the reference to the ODC, so just give it a junk variable
bool KSPlanet::loadData() {
    OrbitDataColl odc;
    return odm.loadData( odc, untranslatedName() );
}