Kstars

modcalcaltaz.cpp
1/*
2 SPDX-FileCopyrightText: 2002 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "modcalcaltaz.h"
8
9#include "geolocation.h"
10#include "kstars.h"
11#include "kstarsdata.h"
12#include "kstarsdatetime.h"
13#include "dialogs/finddialog.h"
14#include "dialogs/locationdialog.h"
15#include "skyobjects/skypoint.h"
16#include "widgets/dmsbox.h"
17
18#include <KLocalizedString>
19#include <KMessageBox>
20
21#include <QTextStream>
22#include <QFileDialog>
23
24modCalcAltAz::modCalcAltAz(QWidget *parentSplit) : QFrame(parentSplit)
25{
26 setupUi(this);
27
28 KStarsData *data = KStarsData::Instance();
29 RA->setUnits(dmsBox::HOURS);
30
31 //Initialize Date/Time and Location data
32 geoPlace = data->geo();
33 LocationButton->setText(geoPlace->fullName());
34
35 //Make sure slotDateTime() gets called, so that LST will be set
36 connect(DateTime, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(slotDateTimeChanged(QDateTime)));
37 DateTime->setDateTime(data->lt());
38
39 connect(NowButton, SIGNAL(clicked()), this, SLOT(slotNow()));
40 connect(LocationButton, SIGNAL(clicked()), this, SLOT(slotLocation()));
41 connect(ObjectButton, SIGNAL(clicked()), this, SLOT(slotObject()));
42
43 connect(RA, SIGNAL(editingFinished()), this, SLOT(slotCompute()));
44 connect(Dec, SIGNAL(editingFinished()), this, SLOT(slotCompute()));
45 connect(Az, SIGNAL(editingFinished()), this, SLOT(slotCompute()));
46 connect(Alt, SIGNAL(editingFinished()), this, SLOT(slotCompute()));
47
48 show();
49}
50
51void modCalcAltAz::slotNow()
52{
54 slotCompute();
55}
56
57void modCalcAltAz::slotLocation()
58{
60 if (ld->exec() == QDialog::Accepted)
61 {
62 GeoLocation *newGeo = ld->selectedCity();
63 if (newGeo)
64 {
65 geoPlace = newGeo;
66 LocationButton->setText(geoPlace->fullName());
67 slotCompute();
68 }
69 }
70 delete ld;
71}
72
73void modCalcAltAz::slotObject()
74{
75 if (FindDialog::Instance()->exec() == QDialog::Accepted)
76 {
77 SkyObject *o = FindDialog::Instance()->targetObject();
78 RA->show(o->ra());
79 Dec->show(o->dec());
80 slotCompute();
81 }
82}
83
84void modCalcAltAz::slotDateTimeChanged(const QDateTime &dt)
85{
86 KStarsDateTime ut = geoPlace->LTtoUT(KStarsDateTime(dt));
87 LST = geoPlace->GSTtoLST(ut.gst());
88}
89
90void modCalcAltAz::slotCompute()
91{
92 //Determine whether we are calculating Alt/Az coordinates from RA/Dec,
93 //or vice versa. We calculate Alt/Az by default, unless the signal
94 //was sent by changing the Az or Alt value.
95 if (sender()->objectName() == "Az" || sender()->objectName() == "Alt")
96 {
97 //Validate Az and Alt coordinates
98 bool ok(false);
99 dms alt;
100 dms az = Az->createDms(&ok);
101 if (ok)
102 alt = Alt->createDms(&ok);
103 if (ok)
104 {
105 SkyPoint sp;
106 sp.setAz(az);
107 sp.setAlt(alt);
108 sp.HorizontalToEquatorial(&LST, geoPlace->lat());
109 RA->show(sp.ra());
110 Dec->show(sp.dec());
111 }
112 }
113 else
114 {
115 //Validate RA and Dec coordinates
116 bool ok(false);
117 dms ra;
118 dms dec = Dec->createDms(&ok);
119 if (ok)
120 ra = RA->createDms(&ok);
121 if (ok)
122 {
123 SkyPoint sp(ra, dec);
124 sp.EquatorialToHorizontal(&LST, geoPlace->lat());
125 Az->show(sp.az());
126 Alt->show(sp.alt());
127 }
128 }
129}
SkyObject * targetObject()
Definition finddialog.h:53
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
QString fullName() const
const CachingDms * lat() const
Definition geolocation.h:70
KStarsData is the backbone of KStars.
Definition kstarsdata.h:74
const KStarsDateTime & lt() const
Definition kstarsdata.h:153
GeoLocation * geo()
Definition kstarsdata.h:232
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
static KStarsDateTime currentDateTime()
Dialog for changing the geographic location of the observer.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
The sky coordinates of a point in the sky.
Definition skypoint.h:45
const CachingDms & dec() const
Definition skypoint.h:269
const CachingDms & ra() const
Definition skypoint.h:263
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
Definition skypoint.cpp:77
const dms & az() const
Definition skypoint.h:275
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition skypoint.h:194
const dms & alt() const
Definition skypoint.h:281
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
Definition skypoint.cpp:143
void setAz(dms az)
Sets Az, the Azimuth.
Definition skypoint.h:230
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
QObject * sender() const const
QTextStream & dec(QTextStream &stream)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.