Kstars

kstarsliteinit.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3  SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #include "kstarslite.h"
7 #include "skymaplite.h"
8 #include "kstarsdata.h"
9 
10 #include "skycomponents/skymapcomposite.h"
11 
12 #include "Options.h"
13 
14 void KStarsLite::datainitFinished()
15 {
16  //Time-related connections
17  connect(data()->clock(), SIGNAL(timeAdvanced()), this, SLOT(updateTime()));
18  connect(data()->clock(), SIGNAL(timeChanged()), this, SLOT(updateTime()));
19 
20  //Add GUI elements to main window
21  //buildGUI();
22 
23  connect(data()->clock(), SIGNAL(scaleChanged(float)), map(), SLOT(slotClockSlewing()));
24 
25  connect(data(), SIGNAL(skyUpdate(bool)), map(), SLOT(forceUpdateNow()));
26  connect(this, SIGNAL(scaleChanged(float)), data(), SLOT(setTimeDirection(float)));
27  connect(this, SIGNAL(scaleChanged(float)), data()->clock(), SLOT(setClockScale(float)));
28  //connect( this, SIGNAL(scaleChanged(float)), map(), SLOT(setFocus()) ); Why did we need this connection in KStars?
29 
30  //Do not start the clock if "--paused" specified on the cmd line
31  if (StartClockRunning)
32  data()->clock()->start();
33 
34  //Propagate config settings
35  applyConfig(false);
36 
37  //Initialize focus
38  initFocus();
39 
41  updateTime();
42 
43  //If this is the first startup, show the wizard
44  if (Options::runStartupWizard())
45  {
46  }
47 
48  //DEBUG
49  qDebug() << "The current Date/Time is: " << KStarsDateTime::currentDateTime().toString();
50 
51  //Notify Splash in QML and LocationDialogLite that loading of data is finished
53  map()->forceUpdate();
54 
55  //Default options
56  Options::setShowEquator(true);
57  Options::setShowHorizon(true);
58  Options::setShowEcliptic(true);
59  Options::setAutoSelectGrid(false);
60 }
61 
62 void KStarsLite::initFocus()
63 {
64  //Case 1: tracking on an object
65  if (Options::isTracking() && Options::focusObject() != i18n("nothing"))
66  {
67  SkyObject *oFocus;
68  if (Options::focusObject() == i18n("star"))
69  {
70  SkyPoint p(Options::focusRA(), Options::focusDec());
71  double maxrad = 1.0;
72 
73  oFocus = data()->skyComposite()->starNearest(&p, maxrad);
74  }
75  else
76  {
77  oFocus = data()->objectNamed(Options::focusObject());
78  }
79 
80  if (oFocus)
81  {
82  map()->setFocusObject(oFocus);
83  map()->setClickedObject(oFocus);
84  map()->setFocusPoint(oFocus);
85  }
86  else
87  {
88  qWarning() << "Cannot center on " << Options::focusObject() << ": no object found." << endl;
89  }
90 
91  //Case 2: not tracking, and using Alt/Az coords. Set focus point using
92  //FocusRA as the Azimuth, and FocusDec as the Altitude
93  }
94  else if (!Options::isTracking() && Options::useAltAz())
95  {
96  SkyPoint pFocus;
97  pFocus.setAz(Options::focusRA());
98  pFocus.setAlt(Options::focusDec());
99  pFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
100  map()->setFocusPoint(&pFocus);
101 
102  //Default: set focus point using FocusRA as the RA and
103  //FocusDec as the Dec
104  }
105  else
106  {
107  SkyPoint pFocus(Options::focusRA(), Options::focusDec());
108  pFocus.EquatorialToHorizontal(data()->lst(), data()->geo()->lat());
109  map()->setFocusPoint(&pFocus);
110  }
111  data()->setSnapNextFocus();
112  map()->setDestination(*map()->focusPoint());
113  map()->setFocus(map()->destination());
114 
115  //map()->showFocusCoords();
116 
117  //Check whether initial position is below the horizon.
118  if (Options::useAltAz() && Options::showGround() && map()->focus()->alt().Degrees() <= SkyPoint::altCrit)
119  {
120  QString caption = i18n("Initial Position is Below Horizon");
121  QString message =
122  i18n("The initial position is below the horizon.\nWould you like to reset to the default position?");
123  map()->setClickedObject(nullptr);
124  map()->setFocusObject(nullptr);
125  Options::setIsTracking(false);
126 
127  data()->setSnapNextFocus(true);
128 
129  SkyPoint DefaultFocus;
130  DefaultFocus.setAz(180.0);
131  DefaultFocus.setAlt(45.0);
132  DefaultFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
133  map()->setDestination(DefaultFocus);
134  }
135 
136  //If there is a focusObject() and it is a SS body, add a temporary Trail
137  /*if ( map()->focusObject() && map()->focusObject()->isSolarSystem()
138  && Options::useAutoTrail() ) {
139  ((KSPlanetBase*)map()->focusObject())->addToTrail();
140  data()->temporaryTrail = true;
141  }*/
142 }
static KStarsDateTime currentDateTime()
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition: skypoint.h:194
void setFocus(SkyPoint *f)
sets the central focus point of the sky map.
Definition: skymaplite.cpp:252
QTextStream & endl(QTextStream &stream)
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
KStarsData * data() const
Definition: kstarslite.h:86
SkyObject * objectNamed(const QString &name)
Find object by name.
Definition: kstarsdata.cpp:429
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
Definition: skymaplite.cpp:278
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
Definition: kstarsdata.cpp:313
void dataLoadFinished()
Sent when KStarsData finishes loading data.
QString caption()
void scaleChanged(float)
Emitted whenever TimeSpinBox in QML changes the scale.
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
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition: kstarslite.cpp:234
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
SkyMapLite * map() const
Definition: kstarslite.h:80
QString i18n(const char *text, const TYPE &arg...)
Q_INVOKABLE SimClock * clock()
Definition: kstarsdata.h:217
GeoCoordinates geo(const QVariant &location)
static const double altCrit
Critical height for atmospheric refraction corrections.
Definition: skypoint.h:718
void setFocusPoint(SkyPoint *f)
set the FocusPoint; the position that is to be the next Destination.
Definition: skymaplite.h:204
SkyMapComposite * skyComposite()
Definition: kstarsdata.h:165
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
Definition: skymaplite.cpp:318
void setSnapNextFocus(bool b=true)
Disable or re-enable the slewing animation for the next Focus change.
Definition: kstarsdata.h:282
Q_SCRIPTABLE Q_NOREPLY void start()
DBUS function to start the SimClock.
Definition: simclock.cpp:120
void forceUpdate()
Recalculates the positions of objects in the sky, and then repaints the sky map.
Definition: skymaplite.cpp:639
void setAz(dms az)
Sets Az, the Azimuth.
Definition: skypoint.h:230
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
Definition: skypoint.cpp:143
QString toString(Qt::DateFormat format) const const
SkyObject * starNearest(SkyPoint *p, double &maxrad)
Information about an object in the sky.
Definition: skyobject.h:41
QString message
void setClickedObject(SkyObject *o)
Set the ClickedObject pointer to the argument.
Definition: skymaplite.cpp:312
Q_INVOKABLE void applyConfig(bool doApplyFocus=true)
currently sets color scheme from config
Definition: kstarslite.cpp:390
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.