20 #include <QTextStream>
24 #include <kfiledialog.h>
25 #include <kmessagebox.h>
39 RACat->setDegType(
false);
40 DecCat->setDegType(
true);
42 connect( ObjectButton, SIGNAL( clicked() ),
this, SLOT( slotObject() ) );
43 connect( NowButton, SIGNAL( clicked() ),
this, SLOT( showCurrentTime() ) );
44 connect( RACat, SIGNAL( editingFinished() ),
this, SLOT( slotCompute() ) );
45 connect( DecCat, SIGNAL( editingFinished() ),
this, SLOT( slotCompute() ) );
46 connect( UT, SIGNAL( timeChanged(
const QTime & ) ),
this, SLOT( slotCompute() ) );
47 connect( Date, SIGNAL( dateChanged(
const QDate & ) ),
this, SLOT( slotCompute() ) );
49 connect( utCheckBatch, SIGNAL(clicked()),
this, SLOT(slotUtCheckedBatch()) );
50 connect( dateCheckBatch, SIGNAL(clicked()),
this, SLOT(slotDateCheckedBatch()) );
51 connect( raCheckBatch, SIGNAL(clicked()),
this, SLOT(slotRaCheckedBatch()) );
52 connect( decCheckBatch, SIGNAL(clicked()),
this, SLOT(slotDecCheckedBatch()) );
53 connect( epochCheckBatch, SIGNAL(clicked()),
this, SLOT(slotEpochCheckedBatch()) );
54 connect( runButtonBatch, SIGNAL(clicked()),
this, SLOT(slotRunBatch()) );
62 void modCalcApCoord::showCurrentTime (
void)
65 Date->setDate( dt.date() );
66 UT->setTime( dt.time() );
67 EpochTarget->setText( QString::number( dt.epoch(),
'f', 3 ) );
70 void modCalcApCoord::slotCompute(){
72 long double jd = dt.
djd();
74 dt.setFromEpoch( EpochCat->value() );
75 long double jd0 = dt.djd();
77 SkyPoint sp( RACat->createDms(
false), DecCat->createDms() );
80 RA->setText( sp.ra().toHMSString() );
81 Dec->setText( sp.dec().toDMSString() );
84 void modCalcApCoord::slotObject() {
85 QPointer<FindDialog> fd =
new FindDialog(
this );
86 if ( fd->exec() == QDialog::Accepted ) {
88 RACat->showInHours( o->
ra0() );
89 DecCat->showInDegrees( o->
dec0() );
90 EpochCat->setValue( 2000.0 );
97 void modCalcApCoord::slotUtCheckedBatch(){
98 if ( utCheckBatch->isChecked() )
99 utBoxBatch->setEnabled(
false );
101 utBoxBatch->setEnabled(
true );
105 void modCalcApCoord::slotDateCheckedBatch(){
107 if ( dateCheckBatch->isChecked() )
108 dateBoxBatch->setEnabled(
false );
110 dateBoxBatch->setEnabled(
true );
114 void modCalcApCoord::slotRaCheckedBatch(){
116 if ( raCheckBatch->isChecked() )
117 raBoxBatch->setEnabled(
false );
119 raBoxBatch->setEnabled(
true );
123 void modCalcApCoord::slotDecCheckedBatch(){
125 if ( decCheckBatch->isChecked() )
126 decBoxBatch->setEnabled(
false );
128 decBoxBatch->setEnabled(
true );
132 void modCalcApCoord::slotEpochCheckedBatch(){
134 if ( epochCheckBatch->isChecked() )
135 epochBoxBatch->setEnabled(
false );
137 epochBoxBatch->setEnabled(
true );
141 void modCalcApCoord::slotRunBatch() {
143 QString inputFileName = InputLineEditBatch->url().toLocalFile();
147 if ( QFile::exists(inputFileName) ) {
148 QFile
f( inputFileName );
149 if ( !
f.open( QIODevice::ReadOnly) ) {
150 QString message = i18n(
"Could not open file %1.",
f.fileName() );
151 KMessageBox::sorry( 0, message, i18n(
"Could Not Open File" ) );
152 inputFileName.clear();
162 QString message = i18n(
"Invalid file: %1", inputFileName );
163 KMessageBox::sorry( 0, message, i18n(
"Invalid file" ) );
164 inputFileName.clear();
165 InputLineEditBatch->setText( inputFileName );
176 QString outputFileName;
177 outputFileName = OutputLineEditBatch->text();
178 QFile fOut( outputFileName );
179 fOut.open(QIODevice::WriteOnly);
192 while ( ! istream.atEnd() ) {
193 line = istream.readLine();
198 QStringList fields = line.split(
' ' );
204 if(utCheckBatch->isChecked() ) {
205 utB = QTime::fromString( fields[i] );
208 utB = utBoxBatch->time();
210 if ( allRadioBatch->isChecked() )
211 ostream << KGlobal::locale()->formatTime( utB ) << space;
213 if(utCheckBatch->isChecked() )
214 ostream << KGlobal::locale()->formatTime( utB ) << space;
218 if(dateCheckBatch->isChecked() ) {
219 dtB = QDate::fromString( fields[i] );
222 dtB = dateBoxBatch->date();
224 if ( allRadioBatch->isChecked() )
225 ostream << KGlobal::locale()->formatDate( dtB, KLocale::LongDate ).append(space);
227 if(dateCheckBatch->isChecked() )
228 ostream << KGlobal::locale()->formatDate( dtB, KLocale::LongDate ).append(space);
232 if(raCheckBatch->isChecked() ) {
233 raB = dms::fromString( fields[i],
false);
236 raB = raBoxBatch->createDms(
false);
238 if ( allRadioBatch->isChecked() )
239 ostream << raB.toHMSString() << space;
241 if(raCheckBatch->isChecked() )
242 ostream << raB.toHMSString() << space;
246 if(decCheckBatch->isChecked() ) {
247 decB = dms::fromString( fields[i],
true);
250 decB = decBoxBatch->createDms();
252 if ( allRadioBatch->isChecked() )
253 ostream << decB.toDMSString() << space;
255 if(decCheckBatch->isChecked() )
256 ostream << decB.toHMSString() << space;
260 if(epochCheckBatch->isChecked() ) {
264 epoch0B = epochBoxBatch->text();
266 if ( allRadioBatch->isChecked() )
269 if(decCheckBatch->isChecked() )
279 ostream << sp.
ra().toHMSString() << sp.
dec().toDMSString() << endl;
285 #include "modcalcapcoord.moc"
void apparentCoord(long double jd0, long double jdf)
Computes the apparent coordinates for this SkyPoint for any epoch, accounting for the effects of prec...
~modCalcApCoord()
Destructor.
void processLines(QTextStream &istream)
Process Lines.
bool setFromEpoch(double e)
Set the Date/Time from an epoch value, represented as a double.
The sky coordinates of a point in the sky.
static KStarsDateTime currentDateTime(KDateTime::Spec ts=KDateTime::Spec::ClockTime())
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
Dialog window for finding SkyObjects by name.
An angle, stored as degrees, but expressible in many ways.
modCalcApCoord(QWidget *p)
Constructor.
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.