Kstars

equatorialcoordinategrid.cpp
1 /*
2  SPDX-FileCopyrightText: 2012 Jerome SONRIER <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "equatorialcoordinategrid.h"
8 
9 #include "kstarsdata.h"
10 #include "linelist.h"
11 #include "Options.h"
12 #ifdef KSTARS_LITE
13 #include "skymaplite.h"
14 #else
15 #include "skymap.h"
16 #endif
17 #include "skypainter.h"
18 
20  : CoordinateGrid(parent, i18n("Equatorial Coordinate Grid"))
21 {
22  KStarsData *data = KStarsData::Instance();
23 
24  intro();
25 
26  double eps = 0.1;
27  double minRa = 0.0;
28  double maxRa = 23.0;
29  double dRa = 2.0;
30  double minDec = -80.0;
31  double maxDec = 90.0;
32  double dDec = 20.0;
33  double dDec2 = 4.0;
34  double dRa2 = 0.2;
35 
36  double max, dec, dec2, ra, ra2;
37 
38  std::shared_ptr<LineList> lineList;
39 
40  for (ra = minRa; ra < maxRa; ra += dRa)
41  {
42  for (dec = -90.0; dec < maxDec - eps; dec += dDec)
43  {
44  lineList.reset(new LineList());
45  max = dec + dDec;
46  if (max > 90.0)
47  max = 90.0;
48  for (dec2 = dec; dec2 <= max + eps; dec2 += dDec2)
49  {
50  std::shared_ptr<SkyPoint> p(new SkyPoint(ra, dec2));
51 
52  p->EquatorialToHorizontal(data->lst(), data->geo()->lat());
53  lineList->append(p);
54  }
55  appendLine(lineList);
56  }
57  }
58 
59  for (dec = minDec; dec < maxDec + eps; dec += dDec)
60  {
61  // Do not paint the line on the equator
62  if (dec < 0.1 && dec > -0.1)
63  continue;
64 
65  // Adjust point density
66  int nPoints = int(round(fabs(cos(dec * dms::PI / 180.0)) * dRa / dRa2));
67  if (nPoints < 5)
68  nPoints = 5;
69  double dRa3 = dRa / nPoints;
70 
71  for (ra = minRa; ra < maxRa + eps; ra += dRa)
72  {
73  lineList.reset(new LineList());
74  for (ra2 = ra; ra2 <= ra + dRa + eps; ra2 += dRa3)
75  {
76  std::shared_ptr<SkyPoint> p(new SkyPoint(ra2, dec));
77 
78  p->EquatorialToHorizontal(data->lst(), data->geo()->lat());
79  lineList->append(p);
80  }
81  appendLine(lineList);
82  }
83  }
84  summary();
85 }
86 
88 {
89  if (Options::autoSelectGrid())
90  return (!Options::useAltAz());
91  else
92 #ifndef KSTARS_LITE
93  return (Options::showEquatorialGrid() &&
94  !(Options::hideOnSlew() && Options::hideGrids() && SkyMap::IsSlewing()));
95 #else
96  return (Options::showEquatorialGrid() &&
97  !(Options::hideOnSlew() && Options::hideGrids() && SkyMapLite::IsSlewing()));
98 #endif
99 }
100 
102 {
103  KStarsData *data = KStarsData::Instance();
104  QColor color = data->colorScheme()->colorNamed("EquatorialGridColor");
105  skyp->setPen(QPen(QBrush(color), 1, Qt::DotLine));
106 }
static constexpr double PI
PI is a const static member; it's public so that it can be used anywhere, as long as dms....
Definition: dms.h:380
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.
QString i18n(const char *text, const TYPE &arg...)
void summary()
prints out some summary statistics if the skyMesh debug is greater than 1.
const CachingDms * lat() const
Definition: geolocation.h:70
ColorScheme * colorScheme()
Definition: kstarsdata.h:171
GeoLocation * geo()
Definition: kstarsdata.h:229
void reset()
void preDraw(SkyPainter *skyp) override
Gives the subclasses access to the top of the draw() method.
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
EquatorialCoordinateGrid(SkyComposite *parent)
Constructor Simply adds all of the equatorial coordinate grid circles (meridians and parallels) paren...
void intro()
displays a message that we are loading m_name.
void appendLine(const std::shared_ptr< LineList > &lineList)
Typically called from within a subclasses constructors.
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Definition: colorscheme.cpp:86
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.