19 #include "modcalcangdist.moc"
21 #include <QTextStream>
24 #include <kfiledialog.h>
25 #include <kmessagebox.h>
37 FirstRA->setDegType(
false);
38 SecondRA->setDegType(
false);
44 connect( FirstRA, SIGNAL(textEdited(QString)),
this, SLOT(
slotResetTitle()) );
45 connect( FirstDec, SIGNAL(textEdited(QString)),
this, SLOT(
slotResetTitle()) );
46 connect( SecondRA, SIGNAL(textEdited(QString)),
this, SLOT(
slotResetTitle()) );
47 connect( SecondDec, SIGNAL(textEdited(QString)),
this, SLOT(
slotResetTitle()) );
48 connect( FirstObjectButton, SIGNAL(clicked()),
this, SLOT(
slotObjectButton()) );
49 connect( SecondObjectButton, SIGNAL(clicked()),
this, SLOT(
slotObjectButton()) );
50 connect( runButtonBatch, SIGNAL(clicked()),
this, SLOT(
slotRunBatch()) );
60 dms raCoord, decCoord;
80 sp0 = getCoords(FirstRA, FirstDec, &ok);
83 sp1 = getCoords(SecondRA, SecondDec, &ok);
88 AngDist->setText(
" .... " );
92 QPointer<FindDialog> fd =
new FindDialog(
this );
93 if ( fd->exec() == QDialog::Accepted ) {
95 if ( sender()->objectName() == QString(
"FirstObjectButton") ) {
96 FirstRA->showInHours( o->
ra() );
97 FirstDec->showInDegrees( o->
dec() );
98 FirstPositionBox->setTitle( i18n(
"First position: %1", o->
name()) );
100 SecondRA->showInHours( o->
ra() );
101 SecondDec->showInDegrees( o->
dec() );
102 SecondPositionBox->setTitle( i18n(
"Second position: %1", o->
name()) );
111 QString name = sender()->objectName();
112 if ( name.contains(
"First" ) )
113 FirstPositionBox->setTitle( i18n(
"First position") );
115 SecondPositionBox->setTitle( i18n(
"Second position") );
120 QString inputFileName = InputLineEditBatch->url().toLocalFile();
124 if ( QFile::exists(inputFileName) ) {
125 QFile
f( inputFileName );
126 if ( !f.open( QIODevice::ReadOnly) ) {
127 QString message = i18n(
"Could not open file %1.", f.fileName() );
128 KMessageBox::sorry( 0, message, i18n(
"Could Not Open File" ) );
129 inputFileName.clear();
135 processLines(istream);
139 QString message = i18n(
"Invalid file: %1", inputFileName );
140 KMessageBox::sorry( 0, message, i18n(
"Invalid file" ) );
141 inputFileName.clear();
142 InputLineEditBatch->setText( inputFileName );
148 void modCalcAngDist::processLines(
QTextStream &istream ) {
153 QString outputFileName;
154 outputFileName = OutputLineEditBatch->text();
155 QFile fOut( outputFileName );
156 fOut.open(QIODevice::WriteOnly);
163 dms ra0B, dec0B, ra1B, dec1B, dist;
165 while ( ! istream.atEnd() ) {
166 line = istream.readLine();
171 QStringList fields = line.split(
' ' );
177 if(ra0CheckBatch->isChecked() ) {
178 ra0B = dms::fromString( fields[i],
false);
181 ra0B = ra0BoxBatch->createDms(
false);
183 if ( allRadioBatch->isChecked() )
184 ostream << ra0B.toHMSString() << space;
186 if(ra0CheckBatch->isChecked() )
187 ostream << ra0B.toHMSString() << space;
191 if(dec0CheckBatch->isChecked() ) {
192 dec0B = dms::fromString( fields[i],
true);
195 dec0B = dec0BoxBatch->createDms();
197 if ( allRadioBatch->isChecked() )
198 ostream << dec0B.toDMSString() << space;
200 if(dec0CheckBatch->isChecked() )
201 ostream << dec0B.toDMSString() << space;
205 if(ra1CheckBatch->isChecked() ) {
206 ra1B = dms::fromString( fields[i],
false);
209 ra1B = ra1BoxBatch->createDms(
false);
211 if ( allRadioBatch->isChecked() )
212 ostream << ra1B.toHMSString() << space;
214 if(ra1CheckBatch->isChecked() )
215 ostream << ra1B.toHMSString() << space;
219 if(dec1CheckBatch->isChecked() ) {
220 dec1B = dms::fromString( fields[i],
true);
223 dec1B = dec1BoxBatch->createDms();
225 if ( allRadioBatch->isChecked() )
226 ostream << dec1B.toDMSString() << space;
228 if(dec1CheckBatch->isChecked() )
229 ostream << dec1B.toDMSString() << space;
235 ostream << dist.toDMSString() << endl;
void slotValidatePositions()
dms createDms(bool deg=true, bool *ok=0)
Parse the text in the dmsBox as an angle.
The sky coordinates of a point in the sky.
~modCalcAngDist()
Destructor.
Dialog window for finding SkyObjects by name.
An angle, stored as degrees, but expressible in many ways.
A KLineEdit which is capable of displaying and parsing angle values flexibly and robustly.
modCalcAngDist(QWidget *p)
Constructor.
virtual QString name(void) const
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.
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=0) const
Computes the angular distance between two SkyObjects.