Commit f2e080d3 authored by Akarsh Simha's avatar Akarsh Simha

Fix behavior of DBus method setRaDec, provide a new DBus method setRaDecJ2000,...

Fix behavior of DBus method setRaDec, provide a new DBus method setRaDecJ2000, and support refraction-corrected altitudes in DBus method setAltAz

This commit does three things:

1. Fix a mysterious behavior in setRaDec, which "overcorrected" for
   atmospheric refraction in some buggy way. Unlike
   SkyMap::setDestination, SkyMap::setClickedPoint does not seem to
   suffer this atmospheric refraction issue -- so using
   SkyMap::setClickedPoint instead of SkyMap::setDestination in the
   DBus method setRaDec and then calling SkyMap::slotCenter works! We
   largely use setClickedPoint to set the center of the star map
   almost everywhere across KStars (if my memory serves me right), so
   this is not a bad workaround.

   KStars::setRaDec now replicates the behavior of typing the same
   RA/Dec values in the Focus Dialog, as far as I can tell.

   However, this does not fix the behavior of SkyMap::setDestination,
   and why SkyMap::setDestination has this behavior is still to be
   investigated.

2. A similar change to the above is also applied to DBus method
   org.kde.kstars.setAltAz, whereby it now replicates the behavior of
   the focus dialog.

3. The behavior of the focus dialog ("Set Coordinates Manually") in
   setting Alt/Az coordinates manually is to assume that the supplied
   altitude is the true (i.e. before refraction) altitude. Which means
   that, if you enter an altitude of e.g. 5 degrees, the position
   centered will actually have apparent altitude > 5 degrees when
   refraction corrections are enabled.

   This same behavior is reflected in org.kde.kstars.setAltAz
   now. However, there may be reason to center using the refracted
   coordinates instead. For that, we now support an optional bool
   argument altIsRefracted to the DBus interface method
   KStars::setAltAz, that when set to true, will "do the best we can"
   to interpret the given altitude as the _apparent_ altitude of the
   center.

Finally, a bit of an administrative / logistical note: This is my
first commit after a long time. I am no longer a PhD student, and am
employed in California. Unlike in many other parts of the US,
California state law allows me to hold copyright on code written in my
personal time and on my personal equipment, as long as there is no
conflict of interest with the goals of my employment. I wish to indeed
explicitly clarify that these and future contributions that I make to
KStars are made in my personal capacity, with my personally-owned
equipment and personally-paid internet connection, and I am not
conveying any rights to any intellectual property of any third
parties.
parent 4594c3d6
......@@ -234,12 +234,20 @@ class KStars : public KXmlGuiWindow
*/
Q_SCRIPTABLE Q_NOREPLY void setRaDec(double ra, double dec);
/** DBUS interface function.
* Set focus to given J2000.0 Ra/Dec coordinates
* @param ra the J2000.0 Right Ascension coordinate for the focus (in Hours)
* @param dec the J2000.0 Declination coordinate for the focus (in Degrees)
*/
Q_SCRIPTABLE Q_NOREPLY void setRaDecJ2000(double ra0, double dec0);
/** DBUS interface function.
* Set focus to given Alt/Az coordinates.
* @param alt the Altitude coordinate for the focus (in Degrees)
* @param az the Azimuth coordinate for the focus (in Degrees)
* @param altIsRefracted If set to true, the altitude is interpreted as if it were corrected for atmospheric refraction (i.e. the altitude is an apparent altitude)
*/
Q_SCRIPTABLE Q_NOREPLY void setAltAz(double alt, double az);
Q_SCRIPTABLE Q_NOREPLY void setAltAz(double alt, double az, bool altIsRefracted=false);
/** DBUS interface function.
* Point in the direction described by the string argument.
......
......@@ -52,12 +52,33 @@
void KStars::setRaDec(double ra, double dec)
{
SkyPoint p(ra, dec);
map()->setDestination(p);
map()->setClickedPoint(&p);
map()->slotCenter();
}
void KStars::setAltAz(double alt, double az)
void KStars::setRaDecJ2000(double ra0, double dec0)
{
map()->setDestinationAltAz(dms(alt), dms(az));
SkyPoint p;
p.setRA0(ra0);
p.setDec0(dec0);
p.updateCoordsNow(data()->updateNum());
map()->setClickedPoint(&p);
map()->slotCenter();
}
void KStars::setAltAz(double alt, double az, bool altIsRefracted)
{
SkyPoint p;
if (altIsRefracted) {
// This is not ideal, because unrefract and refract are not exact inverses
// of each other due to numerics. But this is the best we have :-)
alt = SkyPoint::unrefract(alt);
}
p.setAlt(alt);
p.setAz(az);
p.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
map()->setClickedPoint(&p);
map()->slotCenter();
}
void KStars::lookTowards(const QString &direction)
......
......@@ -6,9 +6,20 @@
<arg name="dec" type="d" direction="in"/>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="setRaDecJ2000">
<arg name="ra0" type="d" direction="in"/>
<arg name="dec0" type="d" direction="in"/>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="setAltAz">
<arg name="alt" type="d" direction="in"/>
<arg name="az" type="d" direction="in"/>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="setAltAz">
<arg name="alt" type="d" direction="in"/>
<arg name="az" type="d" direction="in"/>
<arg name="altIsRefracted" type="bool" direction="in"/>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="lookTowards">
......
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