本文整理汇总了C++中KStarsDateTime::setDJD方法的典型用法代码示例。如果您正苦于以下问题:C++ KStarsDateTime::setDJD方法的具体用法?C++ KStarsDateTime::setDJD怎么用?C++ KStarsDateTime::setDJD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KStarsDateTime
的用法示例。
在下文中一共展示了KStarsDateTime::setDJD方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotGoto
void ConjunctionsTool::slotGoto() {
int index = m_SortModel->mapToSource( OutputList->currentIndex() ).row(); // Get the number of the line
long double jd = outputJDList.value( index );
KStarsDateTime dt;
KStars *ks = KStars::Instance();
KStarsData *data = KStarsData::Instance();
SkyMap *map = ks->map();
// Show conjunction
data->setLocation( *geoPlace );
dt.setDJD( jd );
data->changeDateTime( dt );
map->setClickedObject( data->skyComposite()->findByName( m_Model->data( m_Model->index( index, 2 ) ).toString() ) );
map->setClickedPoint( map->clickedObject() );
map->slotCenter();
}
示例2: processLines
void modCalcJD::processLines( QTextStream &istream, int inputData ) {
QFile fOut( OutputFileBatch->url().toLocalFile() );
fOut.open(QIODevice::WriteOnly);
QTextStream ostream(&fOut);
QString line;
long double jd(0);
double mjd(0);
KStarsDateTime dt;
while ( ! istream.atEnd() ) {
line = istream.readLine();
line = line.trimmed();
QStringList data = line.split( ' ', QString::SkipEmptyParts );
if ( inputData == 0 ) { //Parse date & time
//Is the first field parseable as a date or date&time?
if ( data[0].length() > 10 )
dt = KStarsDateTime::fromString( data[0] );
else
dt = KStarsDateTime( QDate::fromString( data[0] ), QTime(0,0,0) );
//DEBUG
kDebug() << data[0];
if ( dt.isValid() ) kDebug() << dt.toString();
if ( dt.isValid() ) {
//Try to parse the second field as a time
if ( data.size() > 1 ) {
QString s = data[1];
if ( s.length() == 4 ) s = '0'+s;
QTime t = QTime::fromString( s );
if ( t.isValid() ) dt.setTime( t );
}
} else { //Did not parse the first field as a date; try it as a time
QTime t = QTime::fromString( data[0] );
if ( t.isValid() ) {
dt.setTime( t );
//Now try the second field as a date
if ( data.size() > 1 ) {
QDate d = QDate::fromString( data[1] );
if ( d.isValid() ) dt.setDate( d );
else dt.setDate( QDate::currentDate() );
}
}
}
if ( dt.isValid() ) {
//Compute JD and MJD
jd = dt.djd();
mjd = jd - MJD0;
}
} else if ( inputData == 1 ) {//Parse Julian day
bool ok(false);
jd = data[0].toDouble(&ok);
if ( ok ) {
dt.setDJD( jd );
mjd = jd - MJD0;
}
} else if ( inputData == 2 ) {//Parse Modified Julian day
bool ok(false);
mjd = data[0].toDouble(&ok);
if ( ok ) {
jd = mjd + MJD0;
dt.setDJD( jd );
}
}
//Write to output file
ostream << KGlobal::locale()->formatDateTime( dt, KLocale::LongDate ) << " "
<< QString::number( jd, 'f', 2 ) << " "
<< QString::number( mjd, 'f', 2 ) << endl;
}
fOut.close();
}