Kstars

equator.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 James B. Bowlin <[email protected]>
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 
21 Equator::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 
75 void 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 }
long double djd() const
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
CachingDms * lst()
Definition: kstarsdata.h:223
virtual void setPen(const QPen &pen)=0
Set the pen of the painter.
Equator(SkyComposite *parent)
Constructor parent pointer to the parent SkyComposite object name is the name of the subclass.
Definition: equator.cpp:21
void setPen(const QPen &pen)
sets the pen used for drawing labels on the sky.
Definition: skylabeler.cpp:197
void preDraw(SkyPainter *skyp) override
Gives the subclasses access to the top of the draw() method.
Definition: equator.cpp:52
QString i18n(const char *text, const TYPE &arg...)
QString & setNum(short n, int base)
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const CachingDms * lat() const
Definition: geolocation.h:70
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition: equator.cpp:59
bool drawGuideLabel(QPointF &o, const QString &text, double angle)
Tries to draw the text at the position and angle specified.
Definition: skylabeler.cpp:112
ColorScheme * colorScheme()
Definition: kstarsdata.h:171
GeoLocation * geo()
Definition: kstarsdata.h:229
bool selected() override
Definition: equator.cpp:47
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
void draw(SkyPainter *skyp) override
The top level draw routine.
const KStarsDateTime & ut() const
Definition: kstarsdata.h:156
void appendLine(const std::shared_ptr< LineList > &lineList)
Typically called from within a subclasses constructors.
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
const Projector * projector() const
Get the current projector.
Definition: skymap.h:299
SolidLine
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Definition: colorscheme.cpp:86
bool checkVisibility(const SkyPoint *p) const
Determine if the skypoint p is likely to be visible in the display window.
Definition: projector.cpp:183
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 8 2022 04:13:20 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.