Commit 63a793e5 authored by Pablo de Vicente's avatar Pablo de Vicente
Browse files

Modified the calculator's horizontal coordinates module (this was added to

the wish list by Jasem ..:-) )

Now it is possible to select the input coordinates and perform transformations
of coordinates from catalog coordinates (or also from apparent
coordinates) to horizontal coordinates or the other way round, from horizontal
coordinates to apparent coordinates. If we go from horizontal coords to
equatorial apparent coordinates the epoch is considered to be the one
defined by the date and time in the upper group box. There is implementation
to choose another epoch. That is, I do not allow to go from horizontal
coordinates to a reference epoch like J2000 or 1950. If you need to do that,
you may choose the date and time in the upper group box for January 1st 2000
and you will get coordinates which are very similar the catalog ones for J2000.

I have also removed the epochToJd function since this function is already
defined in KSUtils so that it can be used from different calculator modules.

CCMAIL: kstars-devel@kde.org

svn path=/trunk/kdeedu/kstars/; revision=290010
parent 9562237b
......@@ -26,6 +26,8 @@
#include "kstars.h"
#include <qdatetimeedit.h>
#include <qradiobutton.h>
#include <qstring.h>
modCalcAzel::modCalcAzel(QWidget *parentSplit, const char *name) : modCalcAzelDlg (parentSplit,name) {
......@@ -52,6 +54,21 @@ SkyPoint modCalcAzel::getEquCoords (void)
return sp;
}
SkyPoint modCalcAzel::getHorCoords (void)
{
dms azCoord, elCoord;
azCoord = azBox->createDms();
elCoord = elBox->createDms();
SkyPoint sp = SkyPoint();
sp.setAz(azCoord);
sp.setAlt(elCoord);
return sp;
}
void modCalcAzel::showCurrentDateTime (void)
{
......@@ -133,19 +150,21 @@ void modCalcAzel::showHorCoords ( SkyPoint sp )
}
long double modCalcAzel::epochToJd (double epoch)
void modCalcAzel::showEquCoords ( SkyPoint sp, long double jd )
{
raBox->show( sp.ra(), FALSE );
decBox->show( sp.dec() );
showEpoch(jd);
}
double yearsTo2000 = 2000.0 - epoch;
if (epoch == 1950.0) {
return 2433282.4235;
} else if ( epoch == 2000.0 ) {
return J2000;
} else {
return ( J2000 - yearsTo2000 * 365.2425 );
}
void modCalcAzel::showEpoch ( long double jd )
{
double epochN = 0.;
epochN = KSUtils::JdToEpoch(jd);
// Localization
// epochName->setText(KGlobal::locale()->formatNumber(epochN,3));
epochName->setText( QString("%1").arg(epochN, 0, 'f', 2));
}
void modCalcAzel::slotClearCoords()
......@@ -167,17 +186,27 @@ void modCalcAzel::slotComputeCoords()
long double jd = computeJdFromCalendar();
double epoch0 = getEpoch( epochName->text() );
long double jd0 = epochToJd ( epoch0 );
long double jd0 = KSUtils::epochToJd ( epoch0 );
dms lgt = getLongitude();
dms LST = KSUtils::UTtoLST( getQDateTime(), &lgt );
SkyPoint sp;
sp = getEquCoords();
sp.apparentCoord(jd0, jd);
dms lat(getLatitude());
sp.EquatorialToHorizontal( &LST, &lat );
showHorCoords( sp );
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, jd );
}
}
......@@ -49,28 +49,53 @@ public slots:
private:
/**@returns a SkyPoint constructed from the coordinates in the RA and Dec dmsBoxes. */
/**@returns a SkyPoint constructed from the coordinates in the
* RA and Dec dmsBoxes. */
SkyPoint getEquCoords(void);
/**Fill the Time and Date fields with the current values from the CPU clock. */
/**@returns a SkyPoint constructed from the coordinates in the
* Az and El dmsBoxes. */
SkyPoint getHorCoords(void);
/**Fill the Time and Date fields with the current values from the
* CPU clock. */
void showCurrentDateTime(void);
/**@returns a QDateTime constructed from the Time and Date fields. */
/**@returns a QDateTime constructed from the Time and Date fields. */
QDateTime getQDateTime (void);
/**Convert the Time and Date to a Julian Day. */
/**Convert the Time and Date to a Julian Day. */
long double computeJdFromCalendar (void);
/**Parse the string argument as a double */
/**Parse the string argument as a double
* @param eName String from which the epoch is to be constructed
* once it is converted to a double
*/
double getEpoch (QString eName);
long double epochToJd (double epoch);
/**Fill the Az and El dmsBoxes with values of the SkyPoint argument. */
/**Fill the Az and El dmsBoxes with values of the SkyPoint argument.
* @param sp SkypPoint object which contains the coordinates to
* be displayed */
void showHorCoords ( SkyPoint sp );
/**Fill the Az and El dmsBoxes with values of the SkyPoint argument.
* @param sp SkypPoint object which contains the coordinates to
* be displayed
* @param jd Julian day for which the conversion has been performed
* The epoch is constructed for that day
*/
void showEquCoords ( SkyPoint sp, long double jd );
/**Fills the epoch box with the value corresponding to a julian day
* @param jd Julian day for which the conversion has been performed
* The epoch is constructed for that day
*/
void showEpoch (long double jd);
/* Creates a dms object from the latitude box */
dms getLatitude (void);
/* Creates a dms object from the longitude box */
dms getLongitude (void);
void initGeo(void);
......
<!DOCTYPE UI><UI version="3.1.2" stdsetdef="1">
<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
<class>modCalcAzelDlg</class>
<widget class="QWidget">
<property name="name">
......@@ -12,7 +12,7 @@
<x>0</x>
<y>0</y>
<width>473</width>
<height>392</height>
<height>394</height>
</rect>
</property>
<property name="caption">
......@@ -130,6 +130,38 @@
</widget>
</hbox>
</widget>
<widget class="QButtonGroup">
<property name="name">
<cstring>buttonGroup4_2</cstring>
</property>
<property name="title">
<string>Select Input</string>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QRadioButton">
<property name="name">
<cstring>radioApCoords</cstring>
</property>
<property name="text">
<string>Apparent coordinates</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>radioHorCoords</cstring>
</property>
<property name="text">
<string>Horizontal coordinates</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>Layout10</cstring>
......@@ -338,7 +370,7 @@
<property name="sizeHint">
<size>
<width>20</width>
<height>40</height>
<height>80</height>
</size>
</property>
</spacer>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment