Kstars

modcalceclipticcoords.cpp
1 /*
2  SPDX-FileCopyrightText: 2004 Pablo de Vicente <[email protected]>
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 
24 modCalcEclCoords::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 
45 void modCalcEclCoords::slotNow()
46 {
47  DateTime->setDateTime(KStarsDateTime::currentDateTime());
48  slotCompute();
49 }
50 
51 void 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 
62 void modCalcEclCoords::slotDateTimeChanged(const QDateTime &edt)
63 {
64  kdt = ((KStarsDateTime)edt);
65 }
66 
67 void 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 }
static KStarsDateTime currentDateTime()
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
long double djd() const
void findEcliptic(const CachingDms *Obliquity, dms &EcLong, dms &EcLat)
Determine the Ecliptic coordinates of the SkyPoint, given the Julian Date.
Definition: skypoint.cpp:187
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
QObject * sender() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const CachingDms & dec() const
Definition: skypoint.h:269
QTextStream & dec(QTextStream &stream)
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
void setupUi(QWidget *widget)
void show()
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
const CachingDms & ra() const
Definition: skypoint.h:263
Information about an object in the sky.
Definition: skyobject.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.