void modCalcAzel::slotComputeCoords() { SkyPoint sp; double epoch0 = getEpoch( epochName->text() ); KStarsDateTime dt; dt.setFromEpoch( epoch0 ); long double jd = getDateTime().djd(); long double jd0 = dt.djd(); dms LST( getDateTime().gst().Degrees() + getLongitude().Degrees() ); if(radioApCoords->isChecked()) { sp = getEquCoords(); sp.apparentCoord(jd0, jd); dms lat(getLatitude()); sp.EquatorialToHorizontal( &LST, &lat ); showHorCoords( sp ); } else { sp = getHorCoords(); dms lat(getLatitude()); sp.HorizontalToEquatorial( &LST, &lat ); showEquCoords( sp ); } }
void modCalcAzel::showCurrentDateTime (void) { KStars *ks = (KStars*) parent()->parent()->parent(); KStarsDateTime dt = ks->data()->geo()->LTtoUT( KStarsDateTime::currentDateTime() ); datBox->setDate( dt.date() ); timBox->setTime( dt.time() ); dateBoxBatch->setDate( dt.date() ); utBoxBatch->setTime( dt.time() ); }
SkyPoint SkyPoint::timeTransformed( const SkyPoint *p, const KStarsDateTime &dt, const GeoLocation *geo, const double hour ) { Q_ASSERT( p ); if( !p ) return SkyPoint( NaN::d, NaN::d ); // Jasem 2015-08-24 Using correct procedure to find altitude SkyPoint sp = *p; // make a copy KStarsDateTime targetDateTime = dt.addSecs( hour * 3600.0 ); dms LST = geo->GSTtoLST( targetDateTime.gst() ); sp.EquatorialToHorizontal( &LST, geo->lat() ); return sp; }
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(); }
void modCalcAzel::showEpoch( const KStarsDateTime &dt ) { double epochN = dt.epoch(); // Localization // epochName->setText(KGlobal::locale()->formatNumber(epochN,3)); epochName->setText( KGlobal::locale()->formatNumber( epochN ) ); }
QTime SkyObject::transitTimeUT( const KStarsDateTime &dt, const GeoLocation *geo ) { dms LST = geo->GSTtoLST( dt.gst() ); //dSec is the number of seconds until the object transits. dms HourAngle = dms( LST.Degrees() - ra()->Degrees() ); int dSec = int( -3600.*HourAngle.Hours() ); //dt0 is the first guess at the transit time. KStarsDateTime dt0 = dt.addSecs( dSec ); //recompute object's position at UT0 and then find //transit time of this refined position SkyPoint sp = recomputeCoords( dt0, geo ); const dms *ram = sp.ra0(); HourAngle = dms ( LST.Degrees() - ram->Degrees() ); dSec = int( -3600.*HourAngle.Hours() ); return dt.addSecs( dSec ).time(); }
QTime SkyObject::riseSetTime( const KStarsDateTime &dt, const GeoLocation *geo, bool rst ) { //this object does not rise or set; return an invalid time if ( checkCircumpolar(geo->lat()) ) return QTime( 25, 0, 0 ); //First of all, if the object is below the horizon at date/time dt, adjust the time //to bring it above the horizon KStarsDateTime dt2 = dt; SkyPoint p = recomputeCoords( dt, geo ); p.EquatorialToHorizontal( &(geo->GSTtoLST( dt.gst() )), geo->lat() ); if ( p.alt()->Degrees() < 0.0 ) { if ( p.az()->Degrees() < 180.0 ) { //object has not risen yet dt2 = dt.addSecs( 12.*3600. ); } else { //object has already set dt2 = dt.addSecs( -12.*3600. ); } } return geo->UTtoLT( KStarsDateTime( dt2.date(), riseSetTimeUT( dt2, geo, rst ) ) ).time(); }
unsigned short MoonPhaseCalendar::computeMoonPhase( const KStarsDateTime &date ) { KSNumbers num( date.djd() ); KSPlanet earth( I18N_NOOP( "Earth" ), QString(), QColor( "white" ), 12756.28 /*diameter in km*/ ); earth.findPosition( &num ); m_Moon.findGeocentricPosition( &num, &earth ); m_Moon.findPhase(); return m_Moon.getIPhase(); }
SkyPoint SkyObject::recomputeCoords( const KStarsDateTime &dt, const GeoLocation *geo ) { //store current position SkyPoint original( ra(), dec() ); // compute coords for new time jd KSNumbers num( dt.djd() ); if ( isSolarSystem() && geo ) { dms LST = geo->GSTtoLST( dt.gst() ); updateCoords( &num, true, geo->lat(), &LST ); } else { updateCoords( &num ); } //the coordinates for the date dt: SkyPoint sp = SkyPoint( ra(), dec() ); // restore original coords setRA( original.ra()->Hours() ); setDec( original.dec()->Degrees() ); return sp; }
KStarsDateTime KStarsDateTime::fromString( const QString &s ) { //DEBUG qDebug() << "Date string: " << s; KStarsDateTime dtResult = QDateTime::fromString( s, Qt::TextDate ); if ( dtResult.isValid() ) return dtResult; dtResult = QDateTime::fromString( s, Qt::ISODate ); if ( dtResult.isValid() ) return dtResult; //dtResult = QDateTime::fromString( s, QDateTime::RFCDate ); dtResult = QDateTime::fromString( s, Qt::RFC2822Date ); if ( dtResult.isValid() ) return dtResult; qWarning() << i18n( "Could not parse Date/Time string: " ) << s ; qWarning() << i18n( "Valid date formats: " ) ; qWarning() << " 1950-02-25 ; 1950-02-25T05:30:00" ; qWarning() << " 25 Feb 1950 ; 25 Feb 1950 05:30:00" ; qWarning() << " Sat Feb 25 1950 ; Sat Feb 25 05:30:00 1950"; return KStarsDateTime( QDateTime() ); //invalid }
QTime SkyObject::auxRiseSetTimeUT( const KStarsDateTime &dt, const GeoLocation *geo, const dms *righta, const dms *decl, bool riseT) { dms LST = auxRiseSetTimeLST( geo->lat(), righta, decl, riseT ); return dt.GSTtoUT( geo->LSTtoGST( LST ) ); }
dms SkyObject::riseSetTimeLST( const KStarsDateTime &dt, const GeoLocation *geo, bool riseT ) { KStarsDateTime rst( dt.date(), riseSetTimeUT( dt, geo, riseT) ); return geo->GSTtoLST( rst.gst() ); }
void modCalcVlsr::slotCompute() { bool ok1(false), ok2(false); SkyPoint sp( RA->createDms(false, &ok1), Dec->createDms(true, &ok2) ); if ( !ok1 || !ok2 ) return; KStarsDateTime dt = Date->dateTime(); double vst[3]; geoPlace->TopocentricVelocity( vst, dt.gst() ); if ( sender()->objectName() == "VLSR" ) velocityFlag = 0; if ( sender()->objectName() == "VHelio" ) velocityFlag = 1; if ( sender()->objectName() == "VGeo" ) velocityFlag = 2; if ( sender()->objectName() == "VTopo" ) velocityFlag = 3; switch ( velocityFlag ) { case 0: //Hold VLSR constant, compute the others { double vlsr = VLSR->text().toDouble(); double vhelio = sp.vHeliocentric( vlsr, dt.djd() ); double vgeo = sp.vGeocentric( vhelio, dt.djd() ); VHelio->setText( QString::number( vhelio ) ); VGeo->setText( QString::number( vgeo ) ); VTopo->setText( QString::number( sp.vTopocentric(vgeo, vst) ) ); break; } case 1: //Hold VHelio constant, compute the others { double vhelio = VHelio->text().toDouble(); double vlsr = sp.vHelioToVlsr( vhelio, dt.djd() ); double vgeo = sp.vGeocentric( vhelio, dt.djd() ); VLSR->setText( QString::number( vlsr ) ); VGeo->setText( QString::number( vgeo ) ); VTopo->setText( QString::number( sp.vTopocentric(vgeo, vst) ) ); break; } case 2: //Hold VGeo constant, compute the others { double vgeo = VGeo->text().toDouble(); double vhelio = sp.vGeoToVHelio( vgeo, dt.djd() ); double vlsr = sp.vHelioToVlsr( vhelio, dt.djd() ); VLSR->setText( QString::number( vlsr ) ); VHelio->setText( QString::number( vhelio ) ); VTopo->setText( QString::number( sp.vTopocentric(vgeo, vst) ) ); break; } case 3: //Hold VTopo constant, compute the others { double vtopo = VTopo->text().toDouble(); double vgeo = sp.vTopoToVGeo( vtopo, vst ); double vhelio = sp.vGeoToVHelio( vgeo, dt.djd() ); double vlsr = sp.vHelioToVlsr( vhelio, dt.djd() ); VLSR->setText( QString::number( vlsr ) ); VHelio->setText( QString::number( vhelio ) ); VGeo->setText( QString::number( vgeo ) ); break; } default: //oops kDebug() << i18n("Error: do not know which velocity to use for input."); break; } }
int main(int argc, char *argv[]) { KAboutData aboutData( "kstars", 0, ki18n("KStars"), KSTARS_VERSION, ki18n(description), KAboutData::License_GPL, ki18n("(c) 2001-2012, The KStars Team"), ki18n(notice), "http://edu.kde.org/kstars"); aboutData.addAuthor(ki18n("Jason Harris"),KLocalizedString(), "*****@*****.**", "http://www.30doradus.org"); aboutData.addAuthor(ki18n("Jasem Mutlaq"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("James Bowlin"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Pablo de Vicente"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Thomas Kabelmann"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Heiko Evermann"),KLocalizedString(), "*****@*****.**", "http://www.evermann.de"); aboutData.addAuthor(ki18n("Carsten Niehaus"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Mark Hollomon"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Alexey Khudyakov"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Médéric Boquien"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Akarsh Simha"), KLocalizedString(), "*****@*****.**", "http://www.ph.utexas.edu/~asimha"); aboutData.addAuthor(ki18n("Jérôme Sonrier"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Prakash Mohan"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Victor Cărbune"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Henry de Valence"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Samikshan Bairagya"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Rafał Kułaga"), KLocalizedString(), "*****@*****.**"); aboutData.addAuthor(ki18n("Rishab Arora"), KLocalizedString(), "*****@*****.**"); aboutData.addCredit(ki18n("Valery Kharitonov"), ki18n("Converted labels containing technical terms to links to documentation") ); aboutData.addCredit(ki18n("Ana-Maria Constantin"), ki18n("Technical documentation on Astronomy and KStars") ); aboutData.addCredit(ki18n("Andrew Stepanenko"), ki18n("Guiding code based on lin_guider") ); aboutData.addCredit(ki18n("Nuno Pinheiro"), ki18n("Artwork") ); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineOptions options; options.add("!dump", ki18n( "Dump sky image to file" )); options.add("script ", ki18n( "Script to execute" )); options.add("width ", ki18n( "Width of sky image" ), "640"); options.add("height ", ki18n( "Height of sky image" ), "480"); options.add("filename ", ki18n( "Filename for sky image" ), "kstars.png"); options.add("date ", ki18n( "Date and time" )); options.add("!paused", ki18n( "Start with clock paused" )); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KApplication a; if ( args->isSet( "dump" ) ) { kDebug() << i18n( "Dumping sky image" ); //parse filename and image format const char* format = "PNG"; QString fname = args->getOption( "filename" ); QString ext = fname.mid( fname.lastIndexOf(".")+1 ); if ( ext.toLower() == "png" ) { format = "PNG"; } else if ( ext.toLower() == "jpg" || ext.toLower() == "jpeg" ) { format = "JPG"; } else if ( ext.toLower() == "gif" ) { format = "GIF"; } else if ( ext.toLower() == "pnm" ) { format = "PNM"; } else if ( ext.toLower() == "bmp" ) { format = "BMP"; } else { kWarning() << i18n( "Could not parse image format of %1; assuming PNG.", fname ) ; } //parse width and height bool ok(false); int w(0), h(0); w = args->getOption( "width" ).toInt( &ok ); if ( ok ) h = args->getOption( "height" ).toInt( &ok ); if ( !ok ) { kWarning() << "Unable to parse arguments: " ; kWarning() << "Width: " << args->getOption( "width" ) << " Height: " << args->getOption( "height" ) << endl; return 1; } KStarsData *dat = KStarsData::Create(); QObject::connect( dat, SIGNAL( progressText(QString) ), dat, SLOT( slotConsoleMessage(QString) ) ); dat->initialize(); //Set Geographic Location dat->setLocationFromOptions(); //Set color scheme dat->colorScheme()->loadFromConfig(); //set clock now that we have a location: //Check to see if user provided a date/time string. If not, use current CPU time QString datestring = args->getOption( "date" ); KStarsDateTime kdt; if ( ! datestring.isEmpty() ) { if ( datestring.contains( "-" ) ) { //assume ISODate format if ( datestring.contains( ":" ) ) { //also includes time kdt = KDateTime::fromString( datestring, KDateTime::ISODate ); } else { //string probably contains date only kdt.setDate( QDate::fromString( datestring, Qt::ISODate ) ); kdt.setTime( QTime( 0, 0, 0 ) ); } } else { //assume Text format for date string kdt = dat->geo()->LTtoUT( KDateTime::fromString( datestring, KDateTime::QtTextDate ) ); } if ( ! kdt.isValid() ) { kWarning() << i18n( "Using CPU date/time instead." ) ; kdt = KStarsDateTime::currentUtcDateTime(); } } else { kdt = KStarsDateTime::currentUtcDateTime(); } dat->clock()->setUTC( kdt ); KSNumbers num( dat->ut().djd() ); // dat->initGuides(&num); SkyMap *map = SkyMap::Create(); map->resize( w, h ); QPixmap sky( w, h ); dat->setFullTimeUpdate(); dat->updateTime(dat->geo(), map ); SkyPoint dest( Options::focusRA(), Options::focusDec() ); map->setDestination( dest ); map->destination()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() ); map->setFocus( map->destination() ); map->focus()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() ); //Execute the specified script QString scriptfile = args->getOption( "script" ); if ( ! scriptfile.isEmpty() ) { if ( dat->executeScript( scriptfile, map ) ) { std::cout << i18n( "Script executed." ).toUtf8().data() << std::endl; } else { kWarning() << i18n( "Could not execute script." ) ; } } qApp->processEvents(); map->setupProjector(); map->exportSkyImage( &sky ); qApp->processEvents(); if ( ! sky.save( fname, format ) ) kWarning() << i18n( "Unable to save image: %1 ", fname ) ; else kDebug() << i18n( "Saved to file: %1", fname ); delete map; delete dat; return 0; } //start up normally in GUI mode //Try to parse the given date string QString datestring = args->getOption( "date" ); //DEBUG kDebug() << "Date string: " << datestring; if ( ! datestring.isEmpty() && ! KStarsDateTime::fromString( datestring ).isValid() ) { kWarning() << i18n( "Using CPU date/time instead." ) ; datestring.clear(); } KStars::createInstance( true, ! args->isSet( "paused" ), datestring ); args->clear(); QObject::connect(kapp, SIGNAL(lastWindowClosed()), kapp, SLOT(quit())); return a.exec(); }
void modCalcAltAz::slotDateTimeChanged(const QDateTime &dt) { KStarsDateTime ut = geoPlace->LTtoUT( KStarsDateTime( dt ) ); LST = geoPlace->GSTtoLST( ut.gst() ); }
void modCalcAzel::processLines( QTextStream &istream ) { // we open the output file // QTextStream istream(&fIn); QString outputFileName; outputFileName = OutputLineEditBatch->text(); QFile fOut( outputFileName ); fOut.open(IO_WriteOnly); QTextStream ostream(&fOut); QString line; QString space = " "; int i = 0; long double jd0, jdf; dms LST; SkyPoint sp; dms raB, decB, latB, longB, azB, elB; double epoch0B; QTime utB; ExtDate dtB; while ( ! istream.eof() ) { line = istream.readLine(); line.stripWhiteSpace(); //Go through the line, looking for parameters QStringList fields = QStringList::split( " ", line ); i = 0; // Read Ut and write in ostream if corresponds if(utCheckBatch->isChecked() ) { utB = QTime::fromString( fields[i] ); i++; } else utB = utBoxBatch->time(); if ( allRadioBatch->isChecked() ) ostream << utB.toString() << space; else if(utCheckBatch->isChecked() ) ostream << utB.toString() << space; // Read date and write in ostream if corresponds if(dateCheckBatch->isChecked() ) { dtB = ExtDate::fromString( fields[i] ); i++; } else dtB = dateBoxBatch->date(); if ( allRadioBatch->isChecked() ) ostream << dtB.toString().append(space); else if(dateCheckBatch->isChecked() ) ostream << dtB.toString().append(space); // Read Longitude and write in ostream if corresponds if (longCheckBatch->isChecked() ) { longB = dms::fromString( fields[i],TRUE); i++; } else longB = longBoxBatch->createDms(TRUE); if ( allRadioBatch->isChecked() ) ostream << longB.toDMSString() << space; else if (longCheckBatch->isChecked() ) ostream << longB.toDMSString() << space; // Read Latitude if (latCheckBatch->isChecked() ) { latB = dms::fromString( fields[i], TRUE); i++; } else latB = latBoxBatch->createDms(TRUE); if ( allRadioBatch->isChecked() ) ostream << latB.toDMSString() << space; else if (latCheckBatch->isChecked() ) ostream << latB.toDMSString() << space; // Read Epoch and write in ostream if corresponds if(epochCheckBatch->isChecked() ) { epoch0B = fields[i].toDouble(); i++; } else epoch0B = getEpoch( epochBoxBatch->text() ); if ( allRadioBatch->isChecked() ) ostream << epoch0B << space; else if(epochCheckBatch->isChecked() ) ostream << epoch0B << space; // We make the first calculations KStarsDateTime dt; dt.setFromEpoch( epoch0B ); jdf = KStarsDateTime(dtB,utB).djd(); jd0 = dt.djd(); LST = KStarsDateTime(dtB,utB).gst().Degrees() + longB.Degrees(); // Equatorial coordinates are the input coords. if (!horInputCoords) { // Read RA and write in ostream if corresponds if(raCheckBatch->isChecked() ) { raB = dms::fromString( fields[i],FALSE); i++; } else raB = raBoxBatch->createDms(FALSE); if ( allRadioBatch->isChecked() ) ostream << raB.toHMSString() << space; else if(raCheckBatch->isChecked() ) ostream << raB.toHMSString() << space; // Read DEC and write in ostream if corresponds if(decCheckBatch->isChecked() ) { decB = dms::fromString( fields[i], TRUE); i++; } else decB = decBoxBatch->createDms(); if ( allRadioBatch->isChecked() ) ostream << decB.toDMSString() << space; else if(decCheckBatch->isChecked() ) ostream << decB.toDMSString() << space; sp = SkyPoint (raB, decB); sp.apparentCoord(jd0, jdf); sp.EquatorialToHorizontal( &LST, &latB ); ostream << sp.az()->toDMSString() << space << sp.alt()->toDMSString() << endl; // Input coords are horizontal coordinates } else { if(azCheckBatch->isChecked() ) { azB = dms::fromString( fields[i],FALSE); i++; } else azB = azBoxBatch->createDms(); if ( allRadioBatch->isChecked() ) ostream << azB.toHMSString() << space; else if(raCheckBatch->isChecked() ) ostream << azB.toHMSString() << space; // Read DEC and write in ostream if corresponds if(elCheckBatch->isChecked() ) { elB = dms::fromString( fields[i], TRUE); i++; } else elB = decBoxBatch->createDms(); if ( allRadioBatch->isChecked() ) ostream << elB.toDMSString() << space; else if(elCheckBatch->isChecked() ) ostream << elB.toDMSString() << space; sp.setAz(azB); sp.setAlt(elB); sp.HorizontalToEquatorial( &LST, &latB ); ostream << sp.ra()->toHMSString() << space << sp.dec()->toDMSString() << endl; } } fOut.close(); }
ConjunctionsTool::ConjunctionsTool(QWidget *parentSplit) : QFrame(parentSplit), Object1( 0 ), Object2( 0 ) { setupUi(this); KStarsData *kd = KStarsData::Instance(); KStarsDateTime dtStart ( KStarsDateTime::currentDateTime() ); KStarsDateTime dtStop ( dtStart.djd() + 365.24 ); // TODO: Refine //startDate -> setDateTime( dtStart.dateTime() ); //stopDate -> setDateTime( dtStop.dateTime() ); //TODO Check if this change works startDate -> setDateTime( dtStart ); stopDate -> setDateTime( dtStop ); geoPlace = kd -> geo(); LocationButton -> setText( geoPlace -> fullName() ); // Init filter type combobox FilterTypeComboBox->addItem( i18n ("Single Object...") ); FilterTypeComboBox->addItem( i18n ("Any") ); FilterTypeComboBox->addItem( i18n ("Stars") ); FilterTypeComboBox->addItem( i18n ("Solar System") ); FilterTypeComboBox->addItem( i18n ("Planets") ); FilterTypeComboBox->addItem( i18n ("Comets") ); FilterTypeComboBox->addItem( i18n ("Asteroids") ); FilterTypeComboBox->addItem( i18n ("Open Clusters") ); FilterTypeComboBox->addItem( i18n ("Globular Clusters") ); FilterTypeComboBox->addItem( i18n ("Gaseous Nebulae") ); FilterTypeComboBox->addItem( i18n ("Planetary Nebulae") ); FilterTypeComboBox->addItem( i18n ("Galaxies") ); pNames[KSPlanetBase::MERCURY] = i18n("Mercury"); pNames[KSPlanetBase::VENUS] = i18n("Venus"); pNames[KSPlanetBase::MARS] = i18n("Mars"); pNames[KSPlanetBase::JUPITER] = i18n("Jupiter"); pNames[KSPlanetBase::SATURN] = i18n("Saturn"); pNames[KSPlanetBase::URANUS] = i18n("Uranus"); pNames[KSPlanetBase::NEPTUNE] = i18n("Neptune"); //pNames[KSPlanetBase::PLUTO] = i18n("Pluto"); pNames[KSPlanetBase::SUN] = i18n("Sun"); pNames[KSPlanetBase::MOON] = i18n("Moon"); for ( int i=0; i<KSPlanetBase::UNKNOWN_PLANET; ++i ) { // Obj1ComboBox->insertItem( i, pNames[i] ); Obj2ComboBox->insertItem( i, pNames[i] ); } // Initialize the Maximum Separation box to 1 degree maxSeparationBox->setDegType( true ); maxSeparationBox->setDMS( "01 00 00.0" ); //Set up the Table Views m_Model = new QStandardItemModel( 0, 5, this ); m_Model->setHorizontalHeaderLabels( QStringList() << i18n( "Conjunction/Opposition" ) << i18n( "Date & Time (UT)" ) << i18n( "Object 1" ) << i18n( "Object 2" ) << i18n( "Separation" ) ); m_SortModel = new QSortFilterProxyModel( this ); m_SortModel->setSourceModel( m_Model ); OutputList->setModel( m_SortModel ); OutputList->setSortingEnabled(true); OutputList->horizontalHeader()->setStretchLastSection( true ); OutputList->horizontalHeader()->setSectionResizeMode( QHeaderView::Interactive ); OutputList->horizontalHeader()->resizeSection(2, 100); OutputList->horizontalHeader()->resizeSection(3, 100); OutputList->horizontalHeader()->resizeSection(4, 120); //is it bad way to fix default size of columns ? //FilterEdit->showClearButton = true; ClearFilterButton->setIcon( QIcon::fromTheme( "edit-clear" , QIcon(":/icons/breeze/default/edit-clear.svg") ) ); m_index = 0; // signals and slots connections connect(LocationButton, SIGNAL(clicked()), this, SLOT(slotLocation())); connect(Obj1FindButton, SIGNAL(clicked()), this, SLOT(slotFindObject())); connect(ComputeButton, SIGNAL(clicked()), this, SLOT(slotCompute())); connect( FilterTypeComboBox, SIGNAL( currentIndexChanged(int) ), SLOT( slotFilterType(int) ) ); connect( ClearButton, SIGNAL( clicked() ), this, SLOT( slotClear() ) ); connect( ExportButton, SIGNAL( clicked() ), this, SLOT( slotExport() ) ); connect( OutputList, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( slotGoto() ) ); connect( ClearFilterButton, SIGNAL( clicked() ), FilterEdit, SLOT( clear() ) ); connect( FilterEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotFilterReg( const QString & ) ) ); show(); }
KStarsDateTime::KStarsDateTime( const KStarsDateTime &kdt ) : QDateTime() { setDJD( kdt.djd() ); setUtcOffset(kdt.utcOffset()); }
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(); }
QTime SkyObject::transitTime( const KStarsDateTime &dt, const GeoLocation *geo ) { return geo->UTtoLT( KStarsDateTime( dt.date(), transitTimeUT( dt, geo ) ) ).time(); }
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 {
void DetailsTable::createCoordinatesTable(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo) { clearContents(); QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition(); // Set column width constraints QVector<QTextLength> constraints; constraints << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25); m_TableFormat.setColumnWidthConstraints(constraints); // Insert table & row containing table name QTextTable *table = cursor.insertTable(4, 4, m_TableFormat); table->mergeCells(0, 0, 1, 4); QTextBlockFormat centered; centered.setAlignment(Qt::AlignCenter); table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Coordinates"), m_TableTitleCharFormat); //Coordinates Section: //Don't use KLocale::formatNumber() for the epoch string, //because we don't want a thousands-place separator! QString sEpoch = QString::number(ut.epoch(), 'f', 1); //Replace the decimal point with localized decimal symbol sEpoch.replace('.', KGlobal::locale()->decimalSymbol()); table->cellAt(1, 0).firstCursorPosition().insertText(i18n("RA (%1):", sEpoch), m_ItemNameCharFormat); table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(1, 1).firstCursorPosition().insertText(obj->ra().toHMSString(), m_ItemValueCharFormat); table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Dec (%1):", sEpoch), m_ItemNameCharFormat); table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(2, 1).firstCursorPosition().insertText(obj->dec().toDMSString(), m_ItemValueCharFormat); table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Hour angle:"), m_ItemNameCharFormat); table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered); //Hour Angle can be negative, but dms HMS expressions cannot. //Here's a kludgy workaround: dms lst = geo->GSTtoLST(ut.gst()); dms ha(lst.Degrees() - obj->ra().Degrees()); QChar sgn('+'); if(ha.Hours() > 12.0) { ha.setH(24.0 - ha.Hours()); sgn = '-'; } table->cellAt(3, 1).firstCursorPosition().insertText(QString("%1%2").arg(sgn).arg(ha.toHMSString()), m_ItemValueCharFormat); table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Azimuth:"), m_ItemNameCharFormat); table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered); table->cellAt(1, 3).firstCursorPosition().insertText(obj->az().toDMSString(), m_ItemValueCharFormat); table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Altitude:"), m_ItemNameCharFormat); table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered); dms a; if(Options::useAltAz()) { a = obj->alt(); } else { a = obj->altRefracted(); } table->cellAt(2, 3).firstCursorPosition().insertText(a.toDMSString(), m_ItemValueCharFormat); table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Airmass:"), m_ItemNameCharFormat); table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered); //Airmass is approximated as the secant of the zenith distance, //equivalent to 1./sin(Alt). Beware of Inf at Alt=0! QString aMassStr; if(obj->alt().Degrees() > 0.0) { aMassStr = KGlobal::locale()->formatNumber(1./sin(obj->alt().radians() ), 2); } else { aMassStr = "--"; } table->cellAt(3, 3).firstCursorPosition().insertText(aMassStr, m_ItemValueCharFormat); // Restore the position and other time-dependent parameters obj->recomputeCoords(ut, geo); }
void DetailsTable::createRSTTAble(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo) { clearContents(); QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition(); QString rtValue, stValue; // Rise/Set time values QString azRValue, azSValue; // Rise/Set azimuth values //Prepare time/position variables QTime rt = obj->riseSetTime(ut, geo, true); //true = use rise time dms raz = obj->riseSetTimeAz(ut, geo, true); //true = use rise time //If transit time is before rise time, use transit time for tomorrow QTime tt = obj->transitTime(ut, geo); dms talt = obj->transitAltitude(ut, geo); if(tt < rt) { tt = obj->transitTime(ut.addDays(1), geo); talt = obj->transitAltitude(ut.addDays(1), geo); } //If set time is before rise time, use set time for tomorrow QTime st = obj->riseSetTime(ut, geo, false); //false = use set time dms saz = obj->riseSetTimeAz(ut, geo, false); //false = use set time if(st < rt) { st = obj->riseSetTime(ut.addDays(1), geo, false); //false = use set time saz = obj->riseSetTimeAz(ut.addDays( 1 ), geo, false); //false = use set time } if(rt.isValid()) { rtValue = QString().sprintf("%02d:%02d", rt.hour(), rt.minute()); stValue = QString().sprintf("%02d:%02d", st.hour(), st.minute()); azRValue = raz.toDMSString(); azSValue = saz.toDMSString(); } else { if(obj->alt().Degrees() > 0.0) { rtValue = i18n("Circumpolar"); stValue = i18n("Circumpolar"); } else { rtValue = i18n("Never rises"); stValue = i18n("Never rises"); } azRValue = i18nc("Not Applicable", "N/A"); azSValue = i18nc("Not Applicable", "N/A"); } // Set column width constraints QVector<QTextLength> constraints; constraints << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25); m_TableFormat.setColumnWidthConstraints(constraints); // Insert table & row containing table name QTextTable *table = cursor.insertTable(4, 4, m_TableFormat); table->mergeCells(0, 0, 1, 4); QTextBlockFormat centered; centered.setAlignment(Qt::AlignCenter); table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Rise/Set/Transit"), m_TableTitleCharFormat); // Insert cell names & values table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Rise time:"), m_ItemNameCharFormat); table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(1, 1).firstCursorPosition().insertText(rtValue, m_ItemValueCharFormat); table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Transit time:"), m_ItemNameCharFormat); table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(2, 1).firstCursorPosition().insertText(QString().sprintf("%02d:%02d", tt.hour(), tt.minute()), m_ItemValueCharFormat); table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Set time:"), m_ItemNameCharFormat); table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(3, 1).firstCursorPosition().insertText(stValue, m_ItemValueCharFormat); table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Azimuth at rise:"), m_ItemNameCharFormat); table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered); table->cellAt(1, 3).firstCursorPosition().insertText(azRValue, m_ItemValueCharFormat); table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Altitude at transit:"), m_ItemNameCharFormat); table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered); table->cellAt(2, 3).firstCursorPosition().insertText(talt.toDMSString(), m_ItemValueCharFormat); table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Azimuth at set:"), m_ItemNameCharFormat); table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered); table->cellAt(3, 3).firstCursorPosition().insertText(azSValue, m_ItemValueCharFormat); // Restore the position and other time-dependent parameters obj->recomputeCoords( ut, geo ); }
int main(int argc, char *argv[]) { #ifdef KSTARS_LITE QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QApplication app(argc, argv); #ifdef Q_OS_OSX //Note, this function will return true on OS X if the data directories are good to go. If not, quit with error code 1! if(!KSUtils::copyDataFolderFromAppBundleIfNeeded()){ KMessageBox::sorry(0, i18n("Sorry, without a KStars Data Directory, KStars cannot operate. Exiting program now.")); return 1; } #endif app.setApplicationVersion(KSTARS_VERSION); /** * enable high dpi support */ app.setAttribute(Qt::AA_UseHighDpiPixmaps, true); KLocalizedString::setApplicationDomain("kstars"); #ifndef KSTARS_LITE KCrash::initialize(); KAboutData aboutData( "kstars", i18n("KStars"), KSTARS_VERSION, i18n(description), KAboutLicense::GPL, "2001-" + QString::number(QDate::currentDate().year()) + i18n("(c), The KStars Team"), i18n(notice), "http://edu.kde.org/kstars"); aboutData.addAuthor(i18n("Jason Harris"), i18n("Original Author"), "*****@*****.**", "http://www.30doradus.org"); aboutData.addAuthor(i18n("Jasem Mutlaq"), i18n("Current Maintainer"), "*****@*****.**", "http://www.indilib.org"); // Active developers aboutData.addAuthor(i18n("Akarsh Simha"), QString(), "*****@*****.**", "http://www.ph.utexas.edu/~asimha"); aboutData.addAuthor(i18n("Artem Fedoskin"), i18n("KStars Lite"), "*****@*****.**"); aboutData.addAuthor(i18n("Robert Lancaster"), i18n("FITSViewer Improvements. KStars OSX Port"), "*****@*****.**"); // Inactive developers aboutData.addAuthor(i18n("James Bowlin"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Pablo de Vicente"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Thomas Kabelmann"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Heiko Evermann"),QString(), "*****@*****.**", "http://www.evermann.de"); aboutData.addAuthor(i18n("Carsten Niehaus"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Mark Hollomon"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Alexey Khudyakov"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Médéric Boquien"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Jérôme Sonrier"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Prakash Mohan"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Victor Cărbune"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Henry de Valence"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Samikshan Bairagya"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Rafał Kułaga"), QString(), "*****@*****.**"); aboutData.addAuthor(i18n("Rishab Arora"), QString(), "*****@*****.**"); // Contributors aboutData.addCredit(i18n("Valery Kharitonov"), i18n("Converted labels containing technical terms to links to documentation") ); aboutData.addCredit(i18n("Ana-Maria Constantin"), i18n("Technical documentation on Astronomy and KStars") ); aboutData.addCredit(i18n("Andrew Stepanenko"), i18n("Guiding code based on lin_guider") ); aboutData.addCredit(i18n("Nuno Pinheiro"), i18n("Artwork") ); aboutData.addCredit(i18n("Utkarsh Simha"), i18n("Improvements to observation plan execution, star hopper etc.") ); aboutData.addCredit(i18n("Daniel Holler"), i18n("Extensive testing and suggestions for Ekos/INDI.") ); aboutData.addCredit(i18n("Stephane Lucas"), i18n("Extensive testing and suggestions for Ekos Scheduler.") ); aboutData.addCredit(i18n("Yuri Fabirovsky"), i18n("Splash screen for both regular KStars and KStars Lite.") ); KAboutData::setApplicationData(aboutData); QCommandLineParser parser; aboutData.setupCommandLine(&parser); parser.setApplicationDescription(aboutData.shortDescription()); parser.addVersionOption(); parser.addHelpOption(); //parser.addHelpOption(INSERT_DESCRIPTION_HERE); parser.addOption(QCommandLineOption(QStringList() << "dump", i18n( "Dump sky image to file" ))); parser.addOption(QCommandLineOption(QStringList() << "script ", i18n( "Script to execute" ))); parser.addOption(QCommandLineOption(QStringList() << "width ", i18n( "Width of sky image" ), "640")); parser.addOption(QCommandLineOption(QStringList() << "height ", i18n( "Height of sky image" ), "480")); parser.addOption(QCommandLineOption(QStringList() << "filename ", i18n( "Filename for sky image" ), "kstars.png")); parser.addOption(QCommandLineOption(QStringList() << "date", i18n( "Date and time" ))); parser.addOption(QCommandLineOption(QStringList() << "paused", i18n( "Start with clock paused" ))); // urls to open parser.addPositionalArgument(QStringLiteral("urls"), i18n("FITS file(s) to open."), QStringLiteral("[urls...]")); parser.process(app); aboutData.processCommandLine(&parser); if ( parser.isSet( "dump" ) ) { qDebug() << "Dumping sky image"; //parse filename and image format const char* format = "PNG"; QString fname = parser.value( "filename" ); QString ext = fname.mid( fname.lastIndexOf(".")+1 ); if ( ext.toLower() == "png" ) { format = "PNG"; } else if ( ext.toLower() == "jpg" || ext.toLower() == "jpeg" ) { format = "JPG"; } else if ( ext.toLower() == "gif" ) { format = "GIF"; } else if ( ext.toLower() == "pnm" ) { format = "PNM"; } else if ( ext.toLower() == "bmp" ) { format = "BMP"; } else { qWarning() << i18n( "Could not parse image format of %1; assuming PNG.", fname ) ; } //parse width and height bool ok(false); int w(0), h(0); w = parser.value( "width" ).toInt( &ok ); if ( ok ) h = parser.value( "height" ).toInt( &ok ); if ( !ok ) { qWarning() << "Unable to parse arguments: " ; qWarning() << "Width: " << parser.value( "width" ) << " Height: " << parser.value( "height" ) << endl; return 1; } KStarsData *dat = KStarsData::Create(); QObject::connect( dat, SIGNAL( progressText(QString) ), dat, SLOT( slotConsoleMessage(QString) ) ); dat->initialize(); //Set Geographic Location dat->setLocationFromOptions(); //Set color scheme dat->colorScheme()->loadFromConfig(); //set clock now that we have a location: //Check to see if user provided a date/time string. If not, use current CPU time QString datestring = parser.value( "date" ); KStarsDateTime kdt; if ( ! datestring.isEmpty() ) { if ( datestring.contains( "-" ) ) { //assume ISODate format if ( datestring.contains( ":" ) ) { //also includes time //kdt = QDateTime::fromString( datestring, QDateTime::ISODate ); kdt = QDateTime::fromString( datestring, Qt::ISODate ); } else { //string probably contains date only //kdt.setDate( QDate::fromString( datestring, Qt::ISODate ) ); kdt.setDate( QDate::fromString( datestring, Qt::ISODate ) ); kdt.setTime( QTime( 0, 0, 0 ) ); } } else { //assume Text format for date string kdt = dat->geo()->LTtoUT( QDateTime::fromString( datestring, Qt::TextDate ) ); } if ( ! kdt.isValid() ) { qWarning() << i18n( "Using CPU date/time instead." ) ; kdt = KStarsDateTime::currentDateTimeUtc(); } } else { kdt = KStarsDateTime::currentDateTimeUtc(); } dat->clock()->setUTC( kdt ); SkyMap *map = SkyMap::Create(); map->resize( w, h ); QPixmap sky( w, h ); dat->setFullTimeUpdate(); dat->updateTime(dat->geo(), map ); SkyPoint dest( Options::focusRA(), Options::focusDec() ); map->setDestination( dest ); map->destination()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() ); map->setFocus( map->destination() ); map->focus()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() ); //Execute the specified script QString scriptfile = parser.value( "script" ); if ( ! scriptfile.isEmpty() ) { if ( dat->executeScript( scriptfile, map ) ) { std::cout << i18n( "Script executed." ).toUtf8().data() << std::endl; } else { qWarning() << i18n( "Could not execute script." ) ; } } qApp->processEvents(); map->setupProjector(); map->exportSkyImage( &sky ); qApp->processEvents(); if ( ! sky.save( fname, format ) ) qWarning() << "Unable to save image: " << fname; else qDebug() << "Saved to file: %1" << fname; delete map; delete dat; return 0; } //Try to parse the given date string QString datestring = parser.value( "date" ); if ( ! datestring.isEmpty() && ! KStarsDateTime::fromString( datestring ).isValid() ) { qWarning() << i18n( "Using CPU date/time instead." ) ; datestring.clear(); } #endif // Create writable data dir if it does not exist QDir writableDir; writableDir.mkdir(KSPaths::writableLocation(QStandardPaths::GenericDataLocation)); #ifndef KSTARS_LITE KStars::createInstance( true, ! parser.isSet( "paused" ), datestring ); // no session.. just start up normally const QStringList urls = parser.positionalArguments(); // take arguments if( ! urls.isEmpty() ) { foreach (const QString &url, urls) { const QUrl u = QUrl::fromUserInput(url, QDir::currentPath()); KStars::Instance()->openFITS(u); } }
QTime modCalcSidTime::computeLTtoST( QTime lt ) { KStarsDateTime utdt = geo->LTtoUT( KStarsDateTime( Date->date(), lt ) ); dms st = geo->GSTtoLST( utdt.gst() ); return QTime( st.hour(), st.minute(), st.second() ); }