Kstars

polarishourangle.cpp
1/*
2 SPDX-FileCopyrightText: 2015-2017 Pavel Mraz
3
4 SPDX-FileCopyrightText: 2017 Jasem Mutlaq
5
6 SPDX-License-Identifier: GPL-2.0-or-later
7*/
8
9#include "polarishourangle.h"
10
11#include "skyobject.h"
12#include "kstarsdata.h"
13#include "skymapcomposite.h"
14
15#include <QPainter>
16#include <QPen>
17
18float hbase = 24;
19float vangle = 15;
20
21PolarisHourAngle::PolarisHourAngle(QWidget *parent) :
22 QDialog(parent),
23 m_polarisHourAngle(0)
24{
25 setupUi(this);
26 setFixedHeight(size().height());
27
28 SkyObject *polaris = KStarsData::Instance()->skyComposite()->findByName(i18nc("star name", "Polaris"));
29 Q_ASSERT_X(polaris != nullptr, "PolarisHourAngle", "Unable to find Polaris!");
30 m_polaris = polaris->clone();
31
32 m_reticle12.reset(new QPixmap(":/images/reticle12.png"));
33 m_reticle24.reset(new QPixmap(":/images/reticle24.png"));
34
35 connect(dateTimeEdit, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(onTimeUpdated(QDateTime)));
36 connect(currentTimeB, &QPushButton::clicked, this, [this]() { dateTimeEdit->setDateTime(KStarsData::Instance()->lt()); });
37 connect(twelveHourR, SIGNAL(toggled(bool)), this, SLOT(update()));
38
39 dateTimeEdit->setDateTime(KStarsData::Instance()->lt());
40}
41
42void PolarisHourAngle::paintEvent(QPaintEvent *)
43{
44 QPainter p(this);
45 QPointF center = frame->rect().center();
46 double r1 = 175;
47
48 p.setRenderHint(QPainter::Antialiasing);
49 p.setRenderHint(QPainter::SmoothPixmapTransform);
50
51 p.drawPixmap(frame->pos(), twelveHourR->isChecked() ? *(m_reticle12.get()) : *(m_reticle24.get()));
52 p.setPen(Qt::yellow);
53 p.setBrush(Qt::white);
54 p.translate(frame->pos());
55
56// double angle = (24.0 - m_polarisHourAngle) * 15.0;
57 double angle = (hbase - m_polarisHourAngle) * vangle;
58 p.save();
59
60 p.translate(center);
61 p.rotate(angle);
62
63 QPolygon poly;
64
66 p.setBrush(p.pen().color());
67
68 poly << QPoint(0, r1);
69 poly << QPoint(10, -10);
70 poly << QPoint(5, -14);
71 poly << QPoint(-5, -14);
72 poly << QPoint(-10, -10);
73 poly << QPoint(0, r1);
74
75 p.drawPolygon(poly);
76
77 p.restore();
78}
79
80void PolarisHourAngle::onTimeUpdated(QDateTime newDateTime)
81{
82 KStarsDateTime lt(newDateTime);
83 KSNumbers num(lt.djd());
84 m_polaris->updateCoords(&num, false);
85 dms lst = KStarsData::Instance()->geo()->GSTtoLST(lt.gst());
86/*
87 m_polarisHourAngle = (lst.Degrees() - m_polaris->ra().Degrees())/15.0;
88 while (m_polarisHourAngle > 24)
89 m_polarisHourAngle -= 24;
90 while (m_polarisHourAngle < 0)
91 m_polarisHourAngle += 24;
92*/
93 m_polarisHourAngle = (lst.Degrees() - m_polaris->ra().Degrees())/vangle;
94 while (m_polarisHourAngle > hbase)
95 m_polarisHourAngle -= hbase;
96 while (m_polarisHourAngle < hbase)
97 m_polarisHourAngle += hbase;
98
99 labelPolarisHA->setText(dms(m_polarisHourAngle*vangle).toHMSString());
100 labelDate->setText(newDateTime.date().toString());
101 labelTime->setText(newDateTime.time().toString());
102
103 update();
104}
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
GeoLocation * geo()
Definition kstarsdata.h:230
SkyMapComposite * skyComposite()
Definition kstarsdata.h:166
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
virtual SkyObject * clone() const
Create copy of object.
Definition skyobject.cpp:50
const CachingDms & ra() const
Definition skypoint.h:263
virtual void updateCoords(const KSNumbers *num, bool includePlanets=true, const CachingDms *lat=nullptr, const CachingDms *LST=nullptr, bool forceRecompute=false)
Determine the current coordinates (RA, Dec) from the catalog coordinates (RA0, Dec0),...
Definition skypoint.cpp:582
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
const double & Degrees() const
Definition dms.h:141
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void update(Part *part, const QByteArray &data, qint64 dataSize)
void clicked(bool checked)
QString toString(QStringView format, QCalendar cal) const const
QDate date() const const
QTime time() const const
SquareCap
MiterJoin
SolidLine
QTextStream & center(QTextStream &stream)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QString toString(QStringView format) const const
void update()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.