File indexing completed on 2025-04-20 09:32:20
0001 /* 0002 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "kstarslite.h" 0007 #include "skymaplite.h" 0008 #include "kstarsdata.h" 0009 0010 #include "skycomponents/skymapcomposite.h" 0011 0012 #include "Options.h" 0013 0014 void KStarsLite::datainitFinished() 0015 { 0016 //Time-related connections 0017 connect(data()->clock(), SIGNAL(timeAdvanced()), this, SLOT(updateTime())); 0018 connect(data()->clock(), SIGNAL(timeChanged()), this, SLOT(updateTime())); 0019 0020 //Add GUI elements to main window 0021 //buildGUI(); 0022 0023 connect(data()->clock(), SIGNAL(scaleChanged(float)), map(), SLOT(slotClockSlewing())); 0024 0025 connect(data(), SIGNAL(skyUpdate(bool)), map(), SLOT(forceUpdateNow())); 0026 connect(this, SIGNAL(scaleChanged(float)), data(), SLOT(setTimeDirection(float))); 0027 connect(this, SIGNAL(scaleChanged(float)), data()->clock(), SLOT(setClockScale(float))); 0028 //connect( this, SIGNAL(scaleChanged(float)), map(), SLOT(setFocus()) ); Why did we need this connection in KStars? 0029 0030 //Do not start the clock if "--paused" specified on the cmd line 0031 if (StartClockRunning) 0032 data()->clock()->start(); 0033 0034 //Propagate config settings 0035 applyConfig(false); 0036 0037 //Initialize focus 0038 initFocus(); 0039 0040 data()->setFullTimeUpdate(); 0041 updateTime(); 0042 0043 //If this is the first startup, show the wizard 0044 if (Options::runStartupWizard()) 0045 { 0046 } 0047 0048 //DEBUG 0049 qDebug() << "The current Date/Time is: " << KStarsDateTime::currentDateTime().toString(); 0050 0051 //Notify Splash in QML and LocationDialogLite that loading of data is finished 0052 dataLoadFinished(); 0053 map()->forceUpdate(); 0054 0055 //Default options 0056 Options::setShowEquator(true); 0057 Options::setShowHorizon(true); 0058 Options::setShowEcliptic(true); 0059 Options::setAutoSelectGrid(false); 0060 } 0061 0062 void KStarsLite::initFocus() 0063 { 0064 //Case 1: tracking on an object 0065 if (Options::isTracking() && Options::focusObject() != i18n("nothing")) 0066 { 0067 SkyObject *oFocus; 0068 if (Options::focusObject() == i18n("star")) 0069 { 0070 SkyPoint p(Options::focusRA(), Options::focusDec()); 0071 double maxrad = 1.0; 0072 0073 oFocus = data()->skyComposite()->starNearest(&p, maxrad); 0074 } 0075 else 0076 { 0077 oFocus = data()->objectNamed(Options::focusObject()); 0078 } 0079 0080 if (oFocus) 0081 { 0082 map()->setFocusObject(oFocus); 0083 map()->setClickedObject(oFocus); 0084 map()->setFocusPoint(oFocus); 0085 } 0086 else 0087 { 0088 qWarning() << "Cannot center on " << Options::focusObject() << ": no object found." << endl; 0089 } 0090 0091 //Case 2: not tracking, and using Alt/Az coords. Set focus point using 0092 //FocusRA as the Azimuth, and FocusDec as the Altitude 0093 } 0094 else if (!Options::isTracking() && Options::useAltAz()) 0095 { 0096 SkyPoint pFocus; 0097 pFocus.setAz(Options::focusRA()); 0098 pFocus.setAlt(Options::focusDec()); 0099 pFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat()); 0100 map()->setFocusPoint(&pFocus); 0101 0102 //Default: set focus point using FocusRA as the RA and 0103 //FocusDec as the Dec 0104 } 0105 else 0106 { 0107 SkyPoint pFocus(Options::focusRA(), Options::focusDec()); 0108 pFocus.EquatorialToHorizontal(data()->lst(), data()->geo()->lat()); 0109 map()->setFocusPoint(&pFocus); 0110 } 0111 data()->setSnapNextFocus(); 0112 map()->setDestination(*map()->focusPoint()); 0113 map()->setFocus(map()->destination()); 0114 0115 //map()->showFocusCoords(); 0116 0117 //Check whether initial position is below the horizon. 0118 if (Options::useAltAz() && Options::showGround() && map()->focus()->alt().Degrees() <= SkyPoint::altCrit) 0119 { 0120 QString caption = i18n("Initial Position is Below Horizon"); 0121 QString message = 0122 i18n("The initial position is below the horizon.\nWould you like to reset to the default position?"); 0123 map()->setClickedObject(nullptr); 0124 map()->setFocusObject(nullptr); 0125 Options::setIsTracking(false); 0126 0127 data()->setSnapNextFocus(true); 0128 0129 SkyPoint DefaultFocus; 0130 DefaultFocus.setAz(180.0); 0131 DefaultFocus.setAlt(45.0); 0132 DefaultFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat()); 0133 map()->setDestination(DefaultFocus); 0134 } 0135 0136 //If there is a focusObject() and it is a SS body, add a temporary Trail 0137 /*if ( map()->focusObject() && map()->focusObject()->isSolarSystem() 0138 && Options::useAutoTrail() ) { 0139 ((KSPlanetBase*)map()->focusObject())->addToTrail(); 0140 data()->temporaryTrail = true; 0141 }*/ 0142 }