Kstars

ecliptic.cpp
1/*
2 SPDX-FileCopyrightText: 2007 James B. Bowlin <bowlin@mindspring.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "ecliptic.h"
8
9#include "kstarsdata.h"
10#include "linelist.h"
11#include "Options.h"
12#include "skylabeler.h"
13#ifdef KSTARS_LITE
14#include "skymaplite.h"
15#else
16#include "skymap.h"
17#endif
18#include "skypainter.h"
19#include "projections/projector.h"
20
21Ecliptic::Ecliptic(SkyComposite *parent) : LineListIndex(parent, i18n("Ecliptic")), m_label(name())
22{
23 KStarsData *data = KStarsData::Instance();
24 KSNumbers num(data->ut().djd());
25 dms elat(0.0), elng(0.0);
26
27 const double eps = 0.1;
28 const double minRa = 0.0;
29 const double maxRa = 23.0;
30 const double dRa = 2.0;
31 const double dRa2 = 2. / 5.;
32
33 for (double ra = minRa; ra < maxRa; ra += dRa)
34 {
35 std::shared_ptr<LineList> lineList(new LineList());
36
37 for (double ra2 = ra; ra2 <= ra + dRa + eps; ra2 += dRa2)
38 {
39 std::shared_ptr<SkyPoint> o(new SkyPoint());
40
41 elng.setH(ra2);
42 o->setFromEcliptic(num.obliquity(), elng, elat);
43 o->setRA0(o->ra().Hours());
44 o->setDec0(o->dec().Degrees());
45 o->EquatorialToHorizontal(data->lst(), data->geo()->lat());
46 lineList->append(std::move(o));
47 }
48 appendLine(lineList);
49 }
50}
51
53{
54 return Options::showEcliptic();
55}
56
58{
59 if (!selected())
60 return;
61
62 KStarsData *data = KStarsData::Instance();
63 QColor color(data->colorScheme()->colorNamed("EclColor"));
64 skyp->setPen(QPen(QBrush(color), 1, Qt::SolidLine));
65
66 m_label.reset();
68 SkyLabeler::Instance()->setPen(QPen(QBrush(color), 1, Qt::SolidLine));
69 m_label.draw();
70
71 drawCompassLabels();
72}
73
74void Ecliptic::drawCompassLabels()
75{
76#ifndef KSTARS_LITE
77 const Projector *proj = SkyMap::Instance()->projector();
78 KStarsData *data = KStarsData::Instance();
79 SkyLabeler *skyLabeler = SkyLabeler::Instance();
80 // Set proper color for labels
81 QColor color(data->colorScheme()->colorNamed("CompassColor"));
82 skyLabeler->setPen(QPen(QBrush(color), 1, Qt::SolidLine));
83
84 KSNumbers num(data->ut().djd());
85 dms elat(0.0), elng(0.0);
86 QString label;
87 for (int ra = 0; ra < 23; ra += 6)
88 {
89 elng.setH(ra);
90 SkyPoint o;
91 o.setFromEcliptic(num.obliquity(), elng, elat);
92 o.setRA0(o.ra());
93 o.setDec0(o.dec());
94 o.EquatorialToHorizontal(data->lst(), data->geo()->lat());
95 bool visible;
96 QPointF cpoint = proj->toScreen(&o, false, &visible);
97 if (visible && proj->checkVisibility(&o))
98 {
99 label.setNum(o.ra().reduce().Degrees());
100 skyLabeler->drawGuideLabel(cpoint, label, 0.0);
101 }
102 }
103#endif
104}
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Ecliptic(SkyComposite *parent)
Constructor parent pointer to the parent SkyComposite object name is the name of the subclass.
Definition ecliptic.cpp:21
bool selected() override
Definition ecliptic.cpp:52
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition ecliptic.cpp:57
const CachingDms * lat() const
Definition geolocation.h:70
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
const CachingDms * obliquity() const
Definition ksnumbers.h:56
KStarsData is the backbone of KStars.
Definition kstarsdata.h:72
CachingDms * lst()
Definition kstarsdata.h:224
ColorScheme * colorScheme()
Definition kstarsdata.h:172
const KStarsDateTime & ut() const
Definition kstarsdata.h:157
GeoLocation * geo()
Definition kstarsdata.h:230
Contains almost all the code needed for indexing and drawing and clipping lines and polygons.
void drawLines(SkyPainter *skyp)
Draws all the lines in m_listList as simple lines in float mode.
void appendLine(const std::shared_ptr< LineList > &lineList)
Typically called from within a subclasses constructors.
A simple data container used by LineListIndex.
Definition linelist.h:25
The Projector class is the primary class that serves as an interface to handle projections.
Definition projector.h:58
SkyComposite is a kind of container class for SkyComponent objects.
The purpose of this class is to prevent labels from overlapping.
Definition skylabeler.h:99
bool drawGuideLabel(QPointF &o, const QString &text, double angle)
Tries to draw the text at the position and angle specified.
void setPen(const QPen &pen)
sets the pen used for drawing labels on the sky.
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
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 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 EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
Definition skypoint.cpp:77
void setRA0(dms r)
Sets RA0, the catalog Right Ascension.
Definition skypoint.h:94
void setDec0(dms d)
Sets Dec0, the catalog Declination.
Definition skypoint.h:119
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
QString i18n(const char *text, const TYPE &arg...)
QString & setNum(short n, int base)
SolidLine
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:45:35 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.