Kstars

ecliptic.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 "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 
21 Ecliptic::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 
74 void 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 }
Ecliptic(SkyComposite *parent)
Constructor parent pointer to the parent SkyComposite object name is the name of the subclass.
Definition: ecliptic.cpp:21
long double djd() const
void drawLines(SkyPainter *skyp)
Draws all the lines in m_listList as simple lines in float mode.
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
void setDec0(dms d)
Sets Dec0, the catalog Declination.
Definition: skypoint.h:119
CachingDms * lst()
Definition: kstarsdata.h:223
virtual void setPen(const QPen &pen)=0
Set the pen of the painter.
void setPen(const QPen &pen)
sets the pen used for drawing labels on the sky.
Definition: skylabeler.cpp:197
void setRA0(dms r)
Sets RA0, the catalog Right Ascension.
Definition: skypoint.h:94
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
virtual void setH(const double &x)
Sets floating-point value of angle, in hours.
Definition: dms.h:210
bool selected() override
Definition: ecliptic.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 & dec() const
Definition: skypoint.h:269
const CachingDms * lat() const
Definition: geolocation.h:70
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
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
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
const KStarsDateTime & ut() const
Definition: kstarsdata.h:156
const CachingDms & ra() const
Definition: skypoint.h:263
const CachingDms * obliquity() const
Definition: ksnumbers.h:56
const double & Degrees() const
Definition: dms.h:141
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
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition: ecliptic.cpp:57
const dms reduce() const
return the equivalent angle between 0 and 360 degrees.
Definition: dms.cpp:251
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 Thu Aug 11 2022 03:59:58 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.