Kstars

modcalceclipticcoords.cpp
1/*
2 SPDX-FileCopyrightText: 2004 Pablo de Vicente <vicente@oan.es>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "modcalceclipticcoords.h"
8
9#include "dms.h"
10#include "ksnumbers.h"
11#include "kstars.h"
12#include "kstarsdata.h"
13#include "dialogs/finddialog.h"
14#include "skyobjects/skypoint.h"
15#include "widgets/dmsbox.h"
16
17#include <KLocalizedString>
18#include <KMessageBox>
19#include <KUrlRequester>
20
21#include <QTextStream>
22#include <QFileDialog>
23
24modCalcEclCoords::modCalcEclCoords(QWidget *parentSplit) : QFrame(parentSplit)
25{
26 setupUi(this);
27 RA->setUnits(dmsBox::HOURS);
28
29 //Initialize Date/Time and Location data
30 DateTime->setDateTime(KStarsData::Instance()->lt());
31 kdt = KStarsDateTime(DateTime->dateTime());
32
33 connect(NowButton, SIGNAL(clicked()), this, SLOT(slotNow()));
34 connect(ObjectButton, SIGNAL(clicked()), this, SLOT(slotObject()));
35 connect(DateTime, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(slotDateTimeChanged(QDateTime)));
36
37 connect(RA, SIGNAL(editingFinished()), this, SLOT(slotCompute()));
38 connect(Dec, SIGNAL(editingFinished()), this, SLOT(slotCompute()));
39 connect(EcLong, SIGNAL(editingFinished()), this, SLOT(slotCompute()));
40 connect(EcLat, SIGNAL(editingFinished()), this, SLOT(slotCompute()));
41
42 this->show();
43}
44
45void modCalcEclCoords::slotNow()
46{
48 slotCompute();
49}
50
51void modCalcEclCoords::slotObject()
52{
53 if (FindDialog::Instance()->exec() == QDialog::Accepted)
54 {
55 SkyObject *o = FindDialog::Instance()->targetObject();
56 RA->show(o->ra());
57 Dec->show(o->dec());
58 slotCompute();
59 }
60}
61
62void modCalcEclCoords::slotDateTimeChanged(const QDateTime &edt)
63{
64 kdt = ((KStarsDateTime)edt);
65}
66
67void modCalcEclCoords::slotCompute(void)
68{
69 KSNumbers num(kdt.djd());
70
71 //Determine whether we are calculating ecliptic coordinates from equatorial,
72 //or vice versa. We calculate ecliptic by default, unless the signal
73 //was sent by changing the EcLong or EcLat value.
74 if (sender()->objectName() == "EcLong" || sender()->objectName() == "EcLat")
75 {
76 //Validate ecliptic coordinates
77 bool ok(false);
78 dms elat;
79 dms elong = EcLong->createDms(&ok);
80 if (ok)
81 elat = EcLat->createDms(&ok);
82 if (ok)
83 {
84 SkyPoint sp;
85 sp.setFromEcliptic(num.obliquity(), elong, elat);
86 RA->show(sp.ra());
87 Dec->show(sp.dec());
88 }
89 }
90 else
91 {
92 //Validate RA and Dec coordinates
93 bool ok(false);
94 dms ra;
95 dms dec = Dec->createDms(&ok);
96 if (ok)
97 ra = RA->createDms(&ok);
98 if (ok)
99 {
100 SkyPoint sp(ra, dec);
101 dms elong, elat;
102 sp.findEcliptic(num.obliquity(), elong, elat);
103 EcLong->show(elong);
104 EcLat->show(elat);
105 }
106 }
107}
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
static KStarsDateTime currentDateTime()
long double djd() const
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 findEcliptic(const CachingDms *Obliquity, dms &EcLong, dms &EcLat)
Determine the Ecliptic coordinates of the SkyPoint, given the Julian Date.
Definition skypoint.cpp:187
void setFromEcliptic(const CachingDms *Obliquity, const dms &EcLong, const dms &EcLat)
Set the current (RA, Dec) coordinates of the SkyPoint, given pointers to its Ecliptic (Long,...
Definition skypoint.cpp:201
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 Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.