Kstars

equator.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 "equator.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
21Equator::Equator(SkyComposite *parent) : NoPrecessIndex(parent, i18n("Equator")), m_label(LineListIndex::name())
22{
23 KStarsData *data = KStarsData::Instance();
24 KSNumbers num(data->ut().djd());
25
26 const double eps = 0.1;
27 const double minRa = 0.0;
28 const double maxRa = 23.0;
29 const double dRa = 2.0;
30 const double dRa2 = .5 / 5.;
31
32 for (double ra = minRa; ra < maxRa; ra += dRa)
33 {
34 std::shared_ptr<LineList> lineList(new LineList());
35
36 for (double ra2 = ra; ra2 <= ra + dRa + eps; ra2 += dRa2)
37 {
38 std::shared_ptr<SkyPoint> o(new SkyPoint(ra2, 0.0));
39
40 o->EquatorialToHorizontal(data->lst(), data->geo()->lat());
41 lineList->append(std::move(o));
42 }
43 appendLine(lineList);
44 }
45}
46
48{
49 return Options::showEquator();
50}
51
53{
54 KStarsData *data = KStarsData::Instance();
55 QColor color(data->colorScheme()->colorNamed("EqColor"));
56 skyp->setPen(QPen(QBrush(color), 1, Qt::SolidLine));
57}
58
60{
61 if (!selected())
62 return;
63
64 m_label.reset();
66
67 KStarsData *data = KStarsData::Instance();
68 QColor color(data->colorScheme()->colorNamed("EqColor"));
69 SkyLabeler::Instance()->setPen(QPen(QBrush(color), 1, Qt::SolidLine));
70 m_label.draw();
71
72 drawCompassLabels();
73}
74
75void Equator::drawCompassLabels()
76{
77#ifndef KSTARS_LITE
78 QString label;
79
80 const Projector *proj = SkyMap::Instance()->projector();
81 KStarsData *data = KStarsData::Instance();
82 SkyLabeler *skyLabeler = SkyLabeler::Instance();
83 // Set proper color for labels
84 QColor color(data->colorScheme()->colorNamed("CompassColor"));
85 skyLabeler->setPen(QPen(QBrush(color), 1, Qt::SolidLine));
86
87 KSNumbers num(data->ut().djd());
88 for (int ra = 0; ra < 23; ra += 2)
89 {
90 SkyPoint o(ra, 0.0);
91 o.EquatorialToHorizontal(data->lst(), data->geo()->lat());
92 bool visible;
93 QPointF cpoint = proj->toScreen(&o, false, &visible);
94 if (visible && proj->checkVisibility(&o))
95 {
96 label.setNum(o.ra().hour());
97 skyLabeler->drawGuideLabel(cpoint, label, 0.0);
98 }
99 }
100#endif
101}
QColor colorNamed(const QString &name) const
Retrieve a color by name.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition equator.cpp:59
bool selected() override
Definition equator.cpp:47
Equator(SkyComposite *parent)
Constructor parent pointer to the parent SkyComposite object name is the name of the subclass.
Definition equator.cpp:21
void preDraw(SkyPainter *skyp) override
Gives the subclasses access to the top of the draw() method.
Definition equator.cpp:52
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
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 draw(SkyPainter *skyp) override
The top level draw routine.
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
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.