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();
67 drawLines(skyp);
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:74
CachingDms * lst()
Definition kstarsdata.h:226
ColorScheme * colorScheme()
Definition kstarsdata.h:174
const KStarsDateTime & ut() const
Definition kstarsdata.h:159
GeoLocation * geo()
Definition kstarsdata.h:232
long double djd() const
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
QPointF toScreen(const SkyPoint *o, bool oRefract=true, bool *onVisibleHemisphere=nullptr) const
This is exactly the same as toScreenVec but it returns a QPointF.
Definition projector.cpp:93
bool checkVisibility(const SkyPoint *p) const
Determine if the skypoint p is likely to be visible in the display window.
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.
const Projector * projector() const
Get the current projector.
Definition skymap.h:300
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
virtual void setPen(const QPen &pen)=0
Set the pen of the painter.
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
virtual void setH(const double &x)
Sets floating-point value of angle, in hours.
Definition dms.h:210
const dms reduce() const
return the equivalent angle between 0 and 360 degrees.
Definition dms.cpp:251
const double & Degrees() const
Definition dms.h:141
QString i18n(const char *text, const TYPE &arg...)
QString & setNum(double n, char format, int precision)
SolidLine
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.