Kstars

kstarsliteinit.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
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
14void 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
62void 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 }
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}
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
SkyObject * objectNamed(const QString &name)
Find object by name.
Q_INVOKABLE SimClock * clock()
Definition kstarsdata.h:218
SkyMapComposite * skyComposite()
Definition kstarsdata.h:166
void setSnapNextFocus(bool b=true)
Disable or re-enable the slewing animation for the next Focus change.
Definition kstarsdata.h:283
static KStarsDateTime currentDateTime()
void dataLoadFinished()
Sent when KStarsData finishes loading data.
Q_INVOKABLE void applyConfig(bool doApplyFocus=true)
currently sets color scheme from config
SkyMapLite * map() const
Definition kstarslite.h:80
void scaleChanged(float)
Emitted whenever TimeSpinBox in QML changes the scale.
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
KStarsData * data() const
Definition kstarslite.h:86
Q_SCRIPTABLE Q_NOREPLY void start()
DBUS function to start the SimClock.
Definition simclock.cpp:155
SkyObject * starNearest(SkyPoint *p, double &maxrad)
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
void forceUpdate()
Recalculates the positions of objects in the sky, and then repaints the sky map.
void setClickedObject(SkyObject *o)
Set the ClickedObject pointer to the argument.
void setFocusPoint(SkyPoint *f)
set the FocusPoint; the position that is to be the next Destination.
Definition skymaplite.h:204
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
void setFocus(SkyPoint *f)
sets the central focus point of the sky map.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
The sky coordinates of a point in the sky.
Definition skypoint.h:45
static const double altCrit
Critical height for atmospheric refraction corrections.
Definition skypoint.h:727
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 setAlt(dms alt)
Sets Alt, the Altitude.
Definition skypoint.h:194
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
void setAz(dms az)
Sets Az, the Azimuth.
Definition skypoint.h:230
QString i18n(const char *text, const TYPE &arg...)
GeoCoordinates geo(const QVariant &location)
QString toString(QStringView format, QCalendar cal) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QTextStream & endl(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:15:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.