24 #include <kfiledialog.h>
25 #include <kmessagebox.h>
38 QFrame(parentSplit), velocityFlag(0)
41 RA->setDegType(
false);
46 VLSR->setValidator(
new QDoubleValidator( VLSR ) );
47 VHelio->setValidator(
new QDoubleValidator( VHelio ) );
48 VGeo->setValidator(
new QDoubleValidator( VGeo ) );
49 VTopo->setValidator(
new QDoubleValidator( VTopo ) );
52 connect(Date, SIGNAL( dateTimeChanged(
const QDateTime & ) ),
53 this, SLOT( slotCompute() ) );
54 connect(NowButton, SIGNAL( clicked() ),
this, SLOT( slotNow() ) );
55 connect(LocationButton, SIGNAL( clicked() ),
this, SLOT( slotLocation() ) );
56 connect(ObjectButton, SIGNAL( clicked() ),
this, SLOT( slotFindObject() ) );
57 connect(RA, SIGNAL( editingFinished() ),
this, SLOT( slotCompute() ) );
58 connect(Dec, SIGNAL( editingFinished() ),
this, SLOT( slotCompute() ) );
59 connect(VLSR, SIGNAL( editingFinished() ),
this, SLOT( slotCompute() ) );
60 connect(VHelio, SIGNAL( editingFinished() ),
this, SLOT( slotCompute() ) );
61 connect(VGeo, SIGNAL( editingFinished() ),
this, SLOT( slotCompute() ) );
62 connect(VTopo, SIGNAL( editingFinished() ),
this, SLOT( slotCompute() ) );
64 connect(RunButtonBatch, SIGNAL(clicked()),
this, SLOT(slotRunBatch()));
72 void modCalcVlsr::initGeo(
void)
75 LocationButton->setText( geoPlace->
fullName() );
78 void modCalcVlsr::slotNow()
84 void modCalcVlsr::slotFindObject() {
86 if ( fd->exec() == QDialog::Accepted ) {
88 RA->showInHours( o->
ra0() );
89 Dec->showInDegrees( o->
dec0() );
94 void modCalcVlsr::slotLocation() {
97 if (
ld->exec() == QDialog::Accepted &&
ld ) {
101 LocationButton->setText( geoPlace->
fullName() );
109 void modCalcVlsr::slotCompute()
111 bool ok1(
false), ok2(
false);
112 SkyPoint sp( RA->createDms(
false, &ok1), Dec->createDms(
true, &ok2) );
113 if ( !ok1 || !ok2 )
return;
119 if ( sender()->objectName() ==
"VLSR" ) velocityFlag = 0;
120 if ( sender()->objectName() ==
"VHelio" ) velocityFlag = 1;
121 if ( sender()->objectName() ==
"VGeo" ) velocityFlag = 2;
122 if ( sender()->objectName() ==
"VTopo" ) velocityFlag = 3;
124 switch ( velocityFlag ) {
127 double vlsr = VLSR->text().toDouble();
128 double vhelio = sp.vHeliocentric( vlsr, dt.
djd() );
129 double vgeo = sp.vGeocentric( vhelio, dt.
djd() );
131 VHelio->setText( QString::number( vhelio ) );
132 VGeo->setText( QString::number( vgeo ) );
133 VTopo->setText( QString::number( sp.vTopocentric(vgeo, vst) ) );
139 double vhelio = VHelio->text().toDouble();
140 double vlsr = sp.vHelioToVlsr( vhelio, dt.
djd() );
141 double vgeo = sp.vGeocentric( vhelio, dt.
djd() );
143 VLSR->setText( QString::number( vlsr ) );
144 VGeo->setText( QString::number( vgeo ) );
145 VTopo->setText( QString::number( sp.vTopocentric(vgeo, vst) ) );
151 double vgeo = VGeo->text().toDouble();
152 double vhelio = sp.vGeoToVHelio( vgeo, dt.
djd() );
153 double vlsr = sp.vHelioToVlsr( vhelio, dt.
djd() );
155 VLSR->setText( QString::number( vlsr ) );
156 VHelio->setText( QString::number( vhelio ) );
157 VTopo->setText( QString::number( sp.vTopocentric(vgeo, vst) ) );
163 double vtopo = VTopo->text().toDouble();
164 double vgeo = sp.vTopoToVGeo( vtopo, vst );
165 double vhelio = sp.vGeoToVHelio( vgeo, dt.
djd() );
166 double vlsr = sp.vHelioToVlsr( vhelio, dt.
djd() );
168 VLSR->setText( QString::number( vlsr ) );
169 VHelio->setText( QString::number( vhelio ) );
170 VGeo->setText( QString::number( vgeo ) );
175 kDebug() << i18n(
"Error: do not know which velocity to use for input.");
180 void modCalcVlsr::slotUtChecked(){
181 if ( UTCheckBatch->isChecked() )
182 UTBoxBatch->setEnabled(
false );
184 UTBoxBatch->setEnabled(
true );
188 void modCalcVlsr::slotDateChecked(){
189 if ( DateCheckBatch->isChecked() )
190 DateBoxBatch->setEnabled(
false );
192 DateBoxBatch->setEnabled(
true );
196 void modCalcVlsr::slotRaChecked(){
197 if ( RACheckBatch->isChecked() ) {
198 RABoxBatch->setEnabled(
false );
201 RABoxBatch->setEnabled(
true );
205 void modCalcVlsr::slotDecChecked(){
206 if ( DecCheckBatch->isChecked() ) {
207 DecBoxBatch->setEnabled(
false );
210 DecBoxBatch->setEnabled(
true );
214 void modCalcVlsr::slotEpochChecked(){
215 if ( EpochCheckBatch->isChecked() )
216 EpochBoxBatch->setEnabled(
false );
218 EpochBoxBatch->setEnabled(
true );
221 void modCalcVlsr::slotLongChecked(){
222 if ( LongCheckBatch->isChecked() )
223 LongitudeBoxBatch->setEnabled(
false );
225 LongitudeBoxBatch->setEnabled(
true );
228 void modCalcVlsr::slotLatChecked(){
229 if ( LatCheckBatch->isChecked() )
230 LatitudeBoxBatch->setEnabled(
false );
232 LatitudeBoxBatch->setEnabled(
true );
236 void modCalcVlsr::slotHeightChecked(){
237 if ( ElevationCheckBatch->isChecked() )
238 ElevationBoxBatch->setEnabled(
false );
240 ElevationBoxBatch->setEnabled(
true );
244 void modCalcVlsr::slotVlsrChecked(){
245 if ( InputVelocityCheckBatch->isChecked() )
246 InputVelocityBoxBatch->setEnabled(
false );
248 InputVelocityBoxBatch->setEnabled(
true );
252 void modCalcVlsr::slotInputFile() {
253 QString inputFileName;
254 inputFileName = KFileDialog::getOpenFileName( );
255 InputFileBoxBatch->setUrl( inputFileName );
258 void modCalcVlsr::slotOutputFile() {
259 QString outputFileName;
260 outputFileName = KFileDialog::getSaveFileName( );
261 OutputFileBoxBatch->setUrl( outputFileName );
264 void modCalcVlsr::slotRunBatch() {
265 QString inputFileName;
267 inputFileName = InputFileBoxBatch->url().toLocalFile();
271 if ( QFile::exists(inputFileName) ) {
272 QFile
f( inputFileName );
273 if ( !
f.open( QIODevice::ReadOnly) ) {
274 QString message = i18n(
"Could not open file %1.",
f.fileName() );
275 KMessageBox::sorry( 0, message, i18n(
"Could Not Open File" ) );
276 inputFileName.clear();
282 processLines(istream);
286 QString message = i18n(
"Invalid file: %1", inputFileName );
287 KMessageBox::sorry( 0, message, i18n(
"Invalid file" ) );
288 inputFileName.clear();
289 InputFileBoxBatch->setUrl( inputFileName );
294 void modCalcVlsr::processLines(
QTextStream &istream ) {
299 QString outputFileName;
300 outputFileName = OutputFileBoxBatch->url().toLocalFile();
301 QFile fOut( outputFileName );
302 fOut.open(QIODevice::WriteOnly);
310 double sra, cra, sdc, cdc;
311 dms raB, decB, latB, longB;
313 double vhB, vgB, vtB, vlsrB, heightB;
319 while ( ! istream.atEnd() ) {
320 line = istream.readLine();
325 QStringList fields = line.split(
' ' );
331 if(UTCheckBatch->isChecked() ) {
332 utB = QTime::fromString( fields[i] );
335 utB = UTBoxBatch->time();
337 if ( AllRadioBatch->isChecked() )
338 ostream << KGlobal::locale()->formatTime( utB ) << space;
340 if(UTCheckBatch->isChecked() )
341 ostream << KGlobal::locale()->formatTime( utB ) << space;
345 if(DateCheckBatch->isChecked() ) {
346 dtB = QDate::fromString( fields[i] );
349 dtB = DateBoxBatch->date();
350 if ( AllRadioBatch->isChecked() )
351 ostream << KGlobal::locale()->formatDate( dtB, KLocale::LongDate ).append(space);
353 if(DateCheckBatch->isChecked() )
354 ostream << KGlobal::locale()->formatDate( dtB, KLocale::LongDate ).append(space);
358 if(RACheckBatch->isChecked() ) {
359 raB = dms::fromString( fields[i],
false);
362 raB = RABoxBatch->createDms(
false);
364 if ( AllRadioBatch->isChecked() )
365 ostream << raB.toHMSString() << space;
367 if(RACheckBatch->isChecked() )
368 ostream << raB.toHMSString() << space;
372 if(DecCheckBatch->isChecked() ) {
373 decB = dms::fromString( fields[i],
true);
376 decB = DecBoxBatch->createDms();
378 if ( AllRadioBatch->isChecked() )
379 ostream << decB.toDMSString() << space;
381 if(DecCheckBatch->isChecked() )
382 ostream << decB.toDMSString() << space;
386 if(EpochCheckBatch->isChecked() ) {
390 epoch0B = EpochBoxBatch->text();
392 if ( AllRadioBatch->isChecked() )
393 ostream << epoch0B << space;
395 if(EpochCheckBatch->isChecked() )
396 ostream << epoch0B << space;
400 if(InputVelocityCheckBatch->isChecked() ) {
401 vlsrB = fields[i].toDouble();
404 vlsrB = InputVelocityComboBatch->currentText().toDouble();
406 if ( AllRadioBatch->isChecked() )
407 ostream << vlsrB << space;
409 if(InputVelocityCheckBatch->isChecked() )
410 ostream << vlsrB << space;
414 if (LongCheckBatch->isChecked() ) {
415 longB = dms::fromString( fields[i],
true);
418 longB = LongitudeBoxBatch->createDms(
true);
420 if ( AllRadioBatch->isChecked() )
421 ostream << longB.toDMSString() << space;
423 if (LongCheckBatch->isChecked() )
424 ostream << longB.toDMSString() << space;
429 if (LatCheckBatch->isChecked() ) {
430 latB = dms::fromString( fields[i],
true);
433 latB = LatitudeBoxBatch->createDms(
true);
434 if ( AllRadioBatch->isChecked() )
435 ostream << latB.toDMSString() << space;
437 if (LatCheckBatch->isChecked() )
438 ostream << latB.toDMSString() << space;
442 if(ElevationCheckBatch->isChecked() ) {
443 heightB = fields[i].toDouble();
446 heightB = ElevationBoxBatch->text().toDouble();
448 if ( AllRadioBatch->isChecked() )
449 ostream << heightB << space;
451 if(ElevationCheckBatch->isChecked() )
452 ostream << heightB << space;
466 spB.
ra().SinCos(sra, cra);
467 spB.
dec().SinCos(sdc, cdc);
468 vtB = vgB - (vtopo[0]*cdc*cra + vtopo[1]*cdc*sra + vtopo[2]*sdc);
470 ostream << vhB << space << vgB << space << vtB << endl;
478 #include "modcalcvlsr.moc"
Dialog for changing the geographic location of the observer.
void TopocentricVelocity(double vtopo[], dms gt)
Computes the velocity in km/s of an observer on the surface of the Earth referred to a system whose o...
static KStarsData * Instance()
static KStars * Instance()
void setLat(dms l)
Set latitude according to dms argument.
bool setFromEpoch(double e)
Set the Date/Time from an epoch value, represented as a double.
void setLong(dms l)
Set longitude according to dms argument.
The sky coordinates of a point in the sky.
Contains all relevant information for specifying a location on Earth: City Name, State/Province name...
static KStarsDateTime currentDateTime(KDateTime::Spec ts=KDateTime::Spec::ClockTime())
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
An angle, stored as degrees, but expressible in many ways.
void setHeight(double hg)
Set elevation above sea level.
double vHeliocentric(double vlsr, long double jd)
Computes the radial velocity of a source referred to the solar system barycenter from the radial velo...
double vGeocentric(double vhelio, long double jd)
Computes the radial velocity of a source referred to the center of the earth from the radial velocity...
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.