7#include "mounttargetwidget.h"
8#include "kstarsdatetime.h"
11#include "ekos/manager.h"
12#include "dialogs/finddialog.h"
15#define HOR_BUTTON_ID 1
20MountTargetWidget::MountTargetWidget(
QWidget *parent)
26 targetRATextObject->setUnits(dmsBox::HOURS);
27 coordinateButtonGroup->setId(equatorialCheckObject, EQ_BUTTON_ID);
28 coordinateButtonGroup->setId(horizontalCheckObject, HOR_BUTTON_ID);
29 coordinateButtonGroup->setId(haEquatorialCheckObject, HA_BUTTON_ID);
32 updateTargetDisplay(
id);
47bool MountTargetWidget::processCoords(
dms &ra,
dms &de)
50 if (currentTarget.isNull())
53 ra = currentTarget->ra();
54 de = currentTarget->dec();
59void MountTargetWidget::setTargetPosition(
SkyPoint *target)
62 updateJ2000Coordinates(target);
63 currentTarget.reset(target);
64 updateTargetDisplay();
67void MountTargetWidget::setTargetName(
const QString &name)
69 targetTextObject->setText(name);
81 targetCoord.EquatorialToHorizontal(KStarsData::Instance()->lst(),
82 KStarsData::Instance()->
geo()->lat());
84 targetRATextObject->setProperty(
"text", targetCoord.alt().toDMSString());
85 targetDETextObject->setProperty(
"text", targetCoord.az().toDMSString());
90bool MountTargetWidget::raDecToHaDec(
QString qsRA)
97 dms lst = KStarsData::Instance()->
geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst());
99 dms HA = (lst - RA +
dms(360.0)).reduce();
102 if (HA.
Hours() > 12.0)
108 targetRATextObject->setProperty(
"text",
QString(
"%1%2").arg(sgn).arg(HA.
toHMSString()));
121 targetCoord.
setAz(Az);
127 targetRATextObject->setProperty(
"text", targetCoord.
ra().
toHMSString());
128 targetDETextObject->setProperty(
"text", targetCoord.
dec().
toDMSString());
141 targetCoord.
setAz(Az);
144 dms lst = KStarsData::Instance()->
geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst());
151 if (HA.
Hours() > 12.0)
157 targetRATextObject->setProperty(
"text",
QString(
"%1%2").arg(sgn).arg(HA.
toHMSString()));
158 targetDETextObject->setProperty(
"text", targetCoord.
dec().
toDMSString());
163bool MountTargetWidget::haDecToRaDec(
QString qsHA)
170 dms lst = KStarsData::Instance()->
geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst());
171 dms RA = (lst - HA +
dms(360.0)).reduce();
173 targetRATextObject->setProperty(
"text", RA.
toHMSString());
185 dms lst = KStarsData::Instance()->
geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst());
186 dms RA = (lst - HA +
dms(360.0)).reduce();
189 targetCoord.
setRA(RA);
194 targetRATextObject->setProperty(
"text", targetCoord.
alt().
toDMSString());
195 targetDETextObject->setProperty(
"text", targetCoord.
az().
toDMSString());
200void MountTargetWidget::setJ2000Enabled(
bool enabled)
203 updateTargetDisplay();
206void MountTargetWidget::processSlew()
209 if (processCoords(ra, de))
213void MountTargetWidget::processSync()
216 if (processCoords(ra, de))
220void MountTargetWidget::findTarget()
222 if (FindDialog::Instance()->execWithParent(Ekos::Manager::Instance()) ==
QDialog::Accepted)
225 if (
object !=
nullptr)
227 auto const data = KStarsData::Instance();
228 auto o =
object->clone();
229 o->updateCoords(data->updateNum(),
true, data->geo()->lat(), data->lst(),
false);
230 o->EquatorialToHorizontal(KStarsData::Instance()->lst(), KStarsData::Instance()->
geo()->lat());
232 equatorialCheckObject->setProperty(
"checked",
true);
234 targetTextObject->setProperty(
"text", o->name());
235 currentTarget.reset(o);
236 updateTargetDisplay();
242void MountTargetWidget::updateTargetDisplay(
int id,
SkyPoint *target)
245 if (target ==
nullptr)
246 target = currentTarget.get();
248 id = coordinateButtonGroup->checkedId();
253 targetRALabel->setText(
"AL:");
254 targetDECLabel->setText(
"AZ:");
255 targetRATextObject->setUnits(dmsBox::DEGREES);
256 if (target !=
nullptr)
263 targetRALabel->setText(
"HA:");
264 targetDECLabel->setText(
"DE:");
265 targetRATextObject->setUnits(dmsBox::HOURS);
266 if (target !=
nullptr)
268 dms lst = KStarsData::Instance()->
geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst());
272 if (HA.
Hours() > 12.0)
278 targetRATextObject->setProperty(
"text",
QString(
"%1%2").arg(sgn).arg(HA.
toHMSString()));
283 targetRALabel->setText(
"RA:");
284 targetDECLabel->setText(
"DE:");
285 targetRATextObject->setUnits(dmsBox::HOURS);
286 if (target !=
nullptr)
306bool MountTargetWidget::updateTarget()
308 bool raOK =
false, deOK =
false;
310 if (horizontalCheckObject->property(
"checked").toBool())
312 dms at = targetRATextObject->createDms(&raOK);
313 dms az = targetDETextObject->createDms(&deOK);
314 if (raOK ==
false || deOK ==
false)
318 currentCoords->
setAz(az);
319 currentCoords->
setAlt(at);
322 updateJ2000Coordinates(currentCoords,
true,
false);
324 else if (haEquatorialCheckObject->property(
"checked").toBool())
326 dms de = targetDETextObject->createDms(&deOK);
327 dms ha = targetRATextObject->createDms(&raOK);
328 if (raOK ==
false || deOK ==
false)
332 currentCoords->
setDec(de);
333 dms lst = KStarsData::Instance()->
geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst());
334 currentCoords->
setRA((lst - ha +
dms(360.0)).reduce());
336 updateJ2000Coordinates(currentCoords);
340 dms ra = targetRATextObject->createDms(&raOK);
341 dms de = targetDETextObject->createDms(&deOK);
342 if (raOK ==
false || deOK ==
false)
349 currentCoords->
setRA0(ra);
356 currentCoords->
setRA(ra);
357 currentCoords->
setDec(de);
359 updateJ2000Coordinates(currentCoords);
364 currentTarget.reset(currentCoords);
365 updateTargetDisplay();
369void MountTargetWidget::updateJ2000Coordinates(
SkyPoint * coords,
bool updateJ2000,
bool updateHorizontal)
372 if (coords ==
nullptr)
379 coords->
setRA0(J2000Coord.ra());
380 coords->
setDec0(J2000Coord.dec());
383 if (updateHorizontal)
SkyObject * targetObject()
static KStars * Instance()
The sky coordinates of a point in the sky.
void apparentCoord(long double jd0, long double jdf)
Computes the apparent coordinates for this SkyPoint for any epoch, accounting for the effects of prec...
const CachingDms & dec() const
const CachingDms & ra0() const
void setDec(dms d)
Sets Dec, the current Declination.
void setRA(dms &r)
Sets RA, the current Right Ascension.
const CachingDms & ra() const
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
void setRA0(dms r)
Sets RA0, the catalog Right Ascension.
void setAlt(dms alt)
Sets Alt, the Altitude.
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
void setAz(dms az)
Sets Az, the Azimuth.
const CachingDms & dec0() const
void setDec0(dms d)
Sets Dec0, the catalog Declination.
An angle, stored as degrees, but expressible in many ways.
virtual void setH(const double &x)
Sets floating-point value of angle, in hours.
const dms reduce() const
return the equivalent angle between 0 and 360 degrees.
virtual bool setFromString(const QString &s, bool isDeg=true)
Attempt to parse the string argument as a dms value, and set the dms object accordingly.
const QString toDMSString(const bool forceSign=false, const bool machineReadable=false, const bool highPrecision=false) const
const QString toHMSString(const bool machineReadable=false, const bool highPrecision=false) const
const double & Degrees() const
Ekos is an advanced Astrophotography tool for Linux.
GeoCoordinates geo(const QVariant &location)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)