Kstars

horizontalcoordinategrid.cpp
1 /*
2  SPDX-FileCopyrightText: 2012 Jerome SONRIER <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "horizontalcoordinategrid.h"
8 
9 #include "kstarsdata.h"
10 #include "Options.h"
11 #include "linelist.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("Horizontal Coordinate Grid"))
21 {
22  //KStarsData *data = KStarsData::Instance();
23 
24  intro();
25 
26  double eps = 0.1;
27  double minAz = 0.0;
28  double maxAz = 359.0;
29  double dAz = 30.0;
30  double minAlt = -80.0;
31  double maxAlt = 90.0;
32  double dAlt = 20.0;
33  double dAlt2 = 4.0;
34  double dAz2 = 0.2;
35 
36  double max, alt, alt2, az, az2;
37 
38  std::shared_ptr<LineList> lineList;
39 
40  for (az = minAz; az < maxAz; az += dAz)
41  {
42  for (alt = -90.0; alt < maxAlt - eps; alt += dAlt)
43  {
44  lineList.reset(new LineList());
45  max = alt + dAlt;
46  if (max > 90.0)
47  max = 90.0;
48  for (alt2 = alt; alt2 <= max + eps; alt2 += dAlt2)
49  {
50  std::shared_ptr<SkyPoint> p(new SkyPoint());
51 
52  p->setAz(az);
53  p->setAlt(alt2);
54  //p->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
55  lineList->append(std::move(p));
56  }
57  appendLine(lineList);
58  }
59  }
60 
61  for (alt = minAlt; alt < maxAlt + eps; alt += dAlt)
62  {
63  // Do not paint the line on the horizon
64  if (alt < 0.1 && alt > -0.1)
65  continue;
66 
67  // Adjust point density
68  int nPoints = int(round(fabs(cos(alt * dms::PI / 180.0)) * dAz / dAz2));
69  if (nPoints < 5)
70  nPoints = 5;
71  double dAz3 = dAz / nPoints;
72 
73  for (az = minAz; az < maxAz + eps; az += dAz)
74  {
75  lineList.reset(new LineList());
76  for (az2 = az; az2 <= az + dAz + eps; az2 += dAz3)
77  {
78  std::shared_ptr<SkyPoint> p(new SkyPoint());
79 
80  p->setAz(az2);
81  p->setAlt(alt);
82  //p->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
83  lineList->append(std::move(p));
84  }
85  appendLine(lineList);
86  }
87  }
88  summary();
89 }
90 
92 {
93  if (Options::autoSelectGrid())
94  return (Options::useAltAz());
95  else
96 #ifndef KSTARS_LITE
97  return (Options::showHorizontalGrid() &&
98  !(Options::hideOnSlew() && Options::hideGrids() && SkyMap::IsSlewing()));
99 #else
100  return (Options::showHorizontalGrid() &&
101  !(Options::hideOnSlew() && Options::hideGrids() && SkyMapLite::IsSlewing()));
102 #endif
103 }
104 
106 {
107  KStarsData *data = KStarsData::Instance();
108  QColor color = data->colorScheme()->colorNamed("HorizontalGridColor");
109 
110  skyp->setPen(QPen(QBrush(color), 2, Qt::DotLine));
111 }
112 
114 {
115  KStarsData *data = KStarsData::Instance();
116 
117  for (int i = 0; i < listList().count(); i++)
118  {
119  for (int j = 0; j < listList().at(i)->points()->count(); j++)
120  {
121  listList().at(i)->points()->at(j)->HorizontalToEquatorial(data->lst(), data->geo()->lat());
122  }
123  }
124 }
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
void preDraw(SkyPainter *skyp) override
Gives the subclasses access to the top of the draw() method.
HorizontalCoordinateGrid(SkyComposite *parent)
Constructor Simply adds all of the coordinate grid circles (meridians and parallels) parent Pointer t...
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
void update(KSNumbers *) override
Update the sky position(s) of this component.
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.
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const CachingDms * lat() const
Definition: geolocation.h:70
const T & at(int i) const const
ColorScheme * colorScheme()
Definition: kstarsdata.h:171
GeoLocation * geo()
Definition: kstarsdata.h:229
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
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.
int count(const T &value) const const
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 Sun Aug 14 2022 04:13:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.