Kstars

kstars.cpp
1/*
2 SPDX-FileCopyrightText: 2001 Jason Harris <jharris@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "kstars.h"
8
9#include "config-kstars.h"
10#include "version.h"
11
12#include "fov.h"
13#include "kactionmenu.h"
14#include "kstarsadaptor.h"
15#include "kstarsdata.h"
16#include "kstarssplash.h"
17#include "observinglist.h"
18#include "Options.h"
19#include "skymap.h"
20#include "skyqpainter.h"
21#include "texturemanager.h"
22#include "dialogs/finddialog.h"
23#include "dialogs/exportimagedialog.h"
24#include "skycomponents/starblockfactory.h"
25#ifdef HAVE_INDI
26#include "ekos/manager.h"
27#include "indi/drivermanager.h"
28#include "indi/guimanager.h"
29#include "indi/indilistener.h"
30#endif
31
32#ifdef HAVE_CFITSIO
33#include "fitsviewer/fitsviewer.h"
34#endif
35
36#include <KActionCollection>
37#include <KToolBar>
38
39#ifdef Q_OS_WIN
40#include <QProcess>
41#endif
42#include <QStatusBar>
43#include <QMenu>
44
45#include <kstars_debug.h>
46
47KStars *KStars::pinstance = nullptr;
48bool KStars::Closing = false;
49
50KStars::KStars(bool doSplash, bool clockrun, const QString &startdate)
51 : KXmlGuiWindow(), StartClockRunning(clockrun), StartDateString(startdate)
52{
53 // FIXME Hack to set RTL direction for Arabic
54 // This is not a solution. It seems qtbase_ar.qm needs to take care of this?
55 // qttranslations5-l10n does not contain qtbase_ar.qm
56 // It seems qtbase_ar.ts does not exist for Qt 5.9 at all and needs to be translated.
57 // https://wiki.qt.io/Qt_Localization
58 if (i18n("Sky") == "السماء")
60
61 setWindowTitle(i18nc("@title:window", "KStars"));
62
63 // Set thread stack size to 32MB
65
66 // Initialize logging settings
67 if (Options::disableLogging())
69 else if (Options::logToFile())
71 else
73
75
76 qCInfo(KSTARS) << "Welcome to KStars" << KSTARS_VERSION << KSTARS_BUILD_RELEASE;
77 qCInfo(KSTARS) << "Build:" << KSTARS_BUILD_TS;
78 qCInfo(KSTARS) << "OS:" << QSysInfo::productType();
79 qCInfo(KSTARS) << "API:" << QSysInfo::buildAbi();
80 qCInfo(KSTARS) << "Arch:" << QSysInfo::currentCpuArchitecture();
81 qCInfo(KSTARS) << "Kernel Type:" << QSysInfo::kernelType();
82 qCInfo(KSTARS) << "Kernel Version:" << QSysInfo::kernelVersion();
83 qCInfo(KSTARS) << "Qt Version:" << QT_VERSION_STR;
84
85 new KstarsAdaptor(
86 this); // NOTE the weird case convention, which cannot be changed as the file is generated by the moc.
87
88#ifdef Q_OS_MACOS
89
90 QString vlcPlugins = QDir(QCoreApplication::applicationDirPath() + "/../PlugIns/vlc").absolutePath();
91 qputenv("VLC_PLUGIN_PATH", vlcPlugins.toLatin1());
92 QString phonon_backend_path = QDir(QCoreApplication::applicationDirPath() +
93 "/../PlugIns/phonon4qt5_backend/phonon_vlc.so").absolutePath();
94 qputenv("PHONON_BACKEND", phonon_backend_path.toLatin1());
95
97 QString path = env.value("PATH", "");
98 env.insert("PATH", "/usr/bin:/usr/local/bin:\"" + QCoreApplication::applicationDirPath() + "\":" + path);
99
100 QProcess dbusCheck;
101 dbusCheck.setProcessEnvironment(env);
102
103 QString pluginsDir = QDir(QCoreApplication::applicationDirPath() + "/../PlugIns").absolutePath();
104 QString dbusPlist = pluginsDir + "/dbus/org.freedesktop.dbus-kstars.plist";
105 QFile file(dbusPlist);
106 if (file.open(QIODevice::ReadOnly))
107 {
108 QTextStream in(&file);
109 QString pListText = in.readAll();
110 file.close();
111 int programArgsLeft = pListText.indexOf("<key>ProgramArguments</key>");
112 int programArgsRight = pListText.indexOf("</array>", programArgsLeft) + 8 - programArgsLeft;
113 QString currentProgramArgs = pListText.mid(programArgsLeft, programArgsRight);
114 QString newProgramArguments = ""
115 "<key>ProgramArguments</key>\n"
116 " <array>\n"
117 " <string>" +
119 "/dbus-daemon</string>\n"
120 " <string>--nofork</string>\n"
121 " <string>--config-file=" +
122 pluginsDir +
123 "/dbus/kstars.conf</string>\n"
124 " </array>";
125 pListText.replace(currentProgramArgs, newProgramArguments);
126 if (file.open(QIODevice::WriteOnly))
127 {
128 QTextStream stream(&file);
129 stream << pListText;
130 file.close();
131
132 dbusCheck.start("chmod 775 " + dbusPlist);
133 dbusCheck.waitForFinished();
134 dbusCheck.start("launchctl load -w \"" + dbusPlist + "\"");
135 dbusCheck.waitForFinished();
136 qDebug("Starting DBus");
137 }
138 else
139 {
140 qDebug("DBus File Write Error");
141 }
142 }
143 else
144 {
145 qDebug("DBus File Read Error");
146 }
147#endif
148
151
152#ifdef HAVE_CFITSIO
153 m_GenericFITSViewer.clear();
154#endif
155
156 // Set pinstance to yourself
157 pinstance = this;
158
159 connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
160
161 //Initialize QActionGroups
162 projectionGroup = new QActionGroup(this);
163 cschemeGroup = new QActionGroup(this);
164 hipsGroup = new QActionGroup(this);
165 telescopeGroup = new QActionGroup(this);
166 telescopeGroup->setExclusive(false);
167 domeGroup = new QActionGroup(this);
168 domeGroup->setExclusive(false);
169 viewsGroup = new QActionGroup(this);
170 skymapOrientationGroup = new QActionGroup(this);
171 erectObserverCorrectionGroup = new QActionGroup(this);
172
173 m_KStarsData = KStarsData::Create();
174 Q_ASSERT(m_KStarsData);
175 //Set Geographic Location from Options
176 m_KStarsData->setLocationFromOptions();
177
178 //Initialize Time and Date
179 bool datetimeSet = false;
180 if (StartDateString.isEmpty() == false)
181 {
182 KStarsDateTime startDate = KStarsDateTime::fromString(StartDateString);
183 if (startDate.isValid())
184 data()->changeDateTime(data()->geo()->LTtoUT(startDate));
185 else
186 data()->changeDateTime(KStarsDateTime::currentDateTimeUtc());
187
188 datetimeSet = true;
189 }
190 // JM 2016-11-15: Not need to set it again as it was initialized in the ctor of SimClock
191 /*
192 else
193 data()->changeDateTime( KStarsDateTime::currentDateTimeUtc() );
194 */
195
196 // If we are starting paused (--paused is not in the command line) change datetime in data
197 if (StartClockRunning == false)
198 {
199 qCInfo(KSTARS) << "KStars is started in paused state.";
200 if (datetimeSet == false)
201 data()->changeDateTime(KStarsDateTime::currentDateTimeUtc());
202 }
203
204 // Setup splash screen
205 KStarsSplash *splash = nullptr;
206 if (doSplash)
207 {
208 splash = new KStarsSplash(nullptr);
209 connect(m_KStarsData, SIGNAL(progressText(QString)), splash, SLOT(setMessage(QString)));
210 splash->show();
211 }
212 else
213 {
214 connect(m_KStarsData, SIGNAL(progressText(QString)), m_KStarsData, SLOT(slotConsoleMessage(QString)));
215 }
216
217 /*
218 //set up Dark color scheme for application windows
219 DarkPalette = QPalette(QColor("black"), QColor("black"));
220 DarkPalette.setColor(QPalette::Inactive, QPalette::WindowText, QColor("red"));
221 DarkPalette.setColor(QPalette::Normal, QPalette::WindowText, QColor("red"));
222 DarkPalette.setColor(QPalette::Normal, QPalette::Base, QColor("black"));
223 DarkPalette.setColor(QPalette::Normal, QPalette::Text, QColor(238, 0, 0));
224 DarkPalette.setColor(QPalette::Normal, QPalette::Highlight, QColor(238, 0, 0));
225 DarkPalette.setColor(QPalette::Normal, QPalette::HighlightedText, QColor("black"));
226 DarkPalette.setColor(QPalette::Inactive, QPalette::Text, QColor(238, 0, 0));
227 DarkPalette.setColor(QPalette::Inactive, QPalette::Base, QColor(30, 10, 10));
228 //store original color scheme
229 OriginalPalette = QApplication::palette();
230 */
231
232 //Initialize data. When initialization is complete, it will run dataInitFinished()
233 if (!m_KStarsData->initialize())
234 return;
235 delete splash;
236 datainitFinished();
237}
238
239KStars *KStars::createInstance(bool doSplash, bool clockrun, const QString &startdate)
240{
241 delete pinstance;
242 // pinstance is set directly in constructor.
243 new KStars(doSplash, clockrun, startdate);
244 Q_ASSERT(pinstance && "pinstance must be non NULL");
245 return pinstance;
246}
247
249{
251 Q_ASSERT(pinstance);
252 pinstance = nullptr;
253#ifdef PROFILE_COORDINATE_CONVERSION
254 qDebug() << Q_FUNC_INFO << "Spent " << SkyPoint::cpuTime_EqToHz << " seconds in " << SkyPoint::eqToHzCalls
255 << " calls to SkyPoint::EquatorialToHorizontal, for an average of "
256 << 1000. * (SkyPoint::cpuTime_EqToHz / SkyPoint::eqToHzCalls) << " ms per call";
257#endif
258
259#ifdef COUNT_DMS_SINCOS_CALLS
260 qDebug() << Q_FUNC_INFO << "Constructed " << dms::dms_constructor_calls << " dms objects, of which " <<
261 dms::dms_with_sincos_called
262 << " had trigonometric functions called on them = "
263 << (float(dms::dms_with_sincos_called) / float(dms::dms_constructor_calls)) * 100. << "%";
264 qDebug() << Q_FUNC_INFO << "Of the " << dms::trig_function_calls << " calls to sin/cos/sincos on dms objects, "
265 << dms::redundant_trig_function_calls << " were redundant = "
266 << ((float(dms::redundant_trig_function_calls) / float(dms::trig_function_calls)) * 100.) << "%";
267 qDebug() << Q_FUNC_INFO << "We had " << CachingDms::cachingdms_bad_uses << " bad uses of CachingDms in all, compared to "
268 << CachingDms::cachingdms_constructor_calls << " constructed CachingDms objects = "
269 << (float(CachingDms::cachingdms_bad_uses) / float(CachingDms::cachingdms_constructor_calls)) * 100.
270 << "% bad uses";
271#endif
272}
273
275{
276 delete m_KStarsData;
277 m_KStarsData = nullptr;
278 delete StarBlockFactory::Instance();
282
283#ifdef HAVE_INDI
284 GUIManager::release();
285 Ekos::Manager::release();
286 DriverManager::release();
287#endif
288
291}
292
294{
295#if 0
296 if (m_FindDialog) // dialog is cached
297 {
298 /** Delete findDialog only if it is not opened */
299 if (m_FindDialog->isHidden())
300 {
301 delete m_FindDialog;
302 m_FindDialog = nullptr;
303 DialogIsObsolete = false;
304 }
305 else
306 DialogIsObsolete = true; // dialog was opened so it could not deleted
307 }
308#endif
309}
310
311void KStars::applyConfig(bool doApplyFocus)
312{
313 if (Options::isTracking())
314 {
315 actionCollection()->action("track_object")->setText(i18n("Stop &Tracking"));
317 ->action("track_object")
318 ->setIcon(QIcon::fromTheme("document-encrypt"));
319 }
320
322 ->action("coordsys")
323 ->setText(Options::useAltAz() ? i18n("Switch to Star Globe View (Equatorial &Coordinates)") :
324 i18n("Switch to Horizontal View (Horizontal &Coordinates)"));
325
326 actionCollection()->action("show_time_box")->setChecked(Options::showTimeBox());
327 actionCollection()->action("show_location_box")->setChecked(Options::showGeoBox());
328 actionCollection()->action("show_focus_box")->setChecked(Options::showFocusBox());
329 actionCollection()->action("show_statusBar")->setChecked(Options::showStatusBar());
330 actionCollection()->action("show_sbAzAlt")->setChecked(Options::showAltAzField());
331 actionCollection()->action("show_sbRADec")->setChecked(Options::showRADecField());
332 actionCollection()->action("show_sbJ2000RADec")->setChecked(Options::showJ2000RADecField());
333 actionCollection()->action("show_stars")->setChecked(Options::showStars());
334 actionCollection()->action("show_deepsky")->setChecked(Options::showDeepSky());
335 actionCollection()->action("show_planets")->setChecked(Options::showSolarSystem());
336 actionCollection()->action("show_clines")->setChecked(Options::showCLines());
337 actionCollection()->action("show_constellationart")->setChecked(Options::showConstellationArt());
338 actionCollection()->action("show_cnames")->setChecked(Options::showCNames());
339 actionCollection()->action("show_cbounds")->setChecked(Options::showCBounds());
340 actionCollection()->action("show_mw")->setChecked(Options::showMilkyWay());
341 actionCollection()->action("show_equatorial_grid")->setChecked(Options::showEquatorialGrid());
342 actionCollection()->action("show_horizontal_grid")->setChecked(Options::showHorizontalGrid());
343 actionCollection()->action("show_horizon")->setChecked(Options::showGround());
344 actionCollection()->action("simulate_daytime")->setChecked(Options::simulateDaytime());
345 actionCollection()->action("show_flags")->setChecked(Options::showFlags());
346 actionCollection()->action("show_supernovae")->setChecked(Options::showSupernovae());
347 actionCollection()->action("show_satellites")->setChecked(Options::showSatellites());
348 erectObserverCorrectionGroup->setEnabled(Options::useAltAz());
349 actionCollection()->action("erect_observer_correction_off")->setChecked(Options::erectObserverCorrection() == 0);
350 actionCollection()->action("erect_observer_correction_left")->setChecked(Options::erectObserverCorrection() == 1);
351 actionCollection()->action("erect_observer_correction_right")->setChecked(Options::erectObserverCorrection() == 2);
352 actionCollection()->action("mirror_skymap")->setChecked(Options::mirrorSkyMap());
353 statusBar()->setVisible(Options::showStatusBar());
354
355 //color scheme
356 m_KStarsData->colorScheme()->loadFromConfig();
357 //QApplication::setPalette(Options::darkAppColors() ? DarkPalette : OriginalPalette);
358 /**
359 //Note: This uses style sheets to set the dark colors, this should be cross platform. Palettes have a different behavior on OS X and Windows as opposed to Linux.
360 //It might be a good idea to use stylesheets in the future instead of palettes but this will work for now for OS X.
361 //This is also in KStarsDbus.cpp. If you change it, change it in BOTH places.
362 @code
363 #ifdef Q_OS_MACOS
364 if (Options::darkAppColors())
365 qApp->setStyleSheet(
366 "QWidget { background-color: black; color:red; "
367 "selection-background-color:rgb(30,30,30);selection-color:white}"
368 "QToolBar { border:none }"
369 "QTabBar::tab:selected { background-color:rgb(50,50,50) }"
370 "QTabBar::tab:!selected { background-color:rgb(30,30,30) }"
371 "QPushButton { background-color:rgb(50,50,50);border-width:1px; border-style:solid;border-color:black}"
372 "QPushButton::disabled { background-color:rgb(10,10,10);border-width:1px; "
373 "border-style:solid;border-color:black }"
374 "QToolButton:Checked { background-color:rgb(30,30,30); border:none }"
375 "QComboBox { background-color:rgb(30,30,30); }"
376 "QComboBox::disabled { background-color:rgb(10,10,10) }"
377 "QScrollBar::handle { background: rgb(30,30,30) }"
378 "QSpinBox { border-width: 1px; border-style:solid; border-color:rgb(30,30,30) }"
379 "QDoubleSpinBox { border-width:1px; border-style:solid; border-color:rgb(30,30,30) }"
380 "QLineEdit { border-width: 1px; border-style: solid; border-color:rgb(30,30,30) }"
381 "QCheckBox::indicator:unchecked { background-color:rgb(30,30,30);border-width:1px; "
382 "border-style:solid;border-color:black }"
383 "QCheckBox::indicator:checked { background-color:red;border-width:1px; "
384 "border-style:solid;border-color:black }"
385 "QRadioButton::indicator:unchecked { background-color:rgb(30,30,30) }"
386 "QRadioButton::indicator:checked { background-color:red }"
387 "QRoundProgressBar { alternate-background-color:black }"
388 "QDateTimeEdit {background-color:rgb(30,30,30); border-width: 1px; border-style:solid; "
389 "border-color:rgb(30,30,30) }"
390 "QHeaderView { color:red;background-color:black }"
391 "QHeaderView::Section { background-color:rgb(30,30,30) }"
392 "QTableCornerButton::section{ background-color:rgb(30,30,30) }"
393 "");
394 else
395 qApp->setStyleSheet("");
396 #endif
397 @endcode
398 **/
399
400 //Set toolbar options from config file
401 toolBar("kstarsToolBar")->applySettings(KSharedConfig::openConfig()->group("MainToolBar"));
402 toolBar("viewToolBar")->applySettings(KSharedConfig::openConfig()->group("ViewToolBar"));
403
404 //Geographic location
406
407 //Focus
408 if (doApplyFocus)
409 {
410 SkyObject *fo = data()->objectNamed(Options::focusObject());
411 if (fo && fo != map()->focusObject())
412 {
413 map()->setClickedObject(fo);
414 map()->setClickedPoint(fo);
415 map()->slotCenter();
416 }
417
418 if (!fo)
419 {
420 SkyPoint fp(Options::focusRA(), Options::focusDec());
421 if (fp.ra().Degrees() != map()->focus()->ra().Degrees() ||
422 fp.dec().Degrees() != map()->focus()->dec().Degrees())
423 {
424 map()->setClickedPoint(&fp);
425 map()->slotCenter();
426 }
427 }
428 }
429}
430
431void KStars::showImgExportDialog()
432{
433 if (m_ExportImageDialog)
434 m_ExportImageDialog->show();
435}
436
437void KStars::syncFOVActions()
438{
439 foreach (QAction *action, fovActionMenu->menu()->actions())
440 {
441 if (action->text().isEmpty())
442 {
443 continue;
444 }
445
446 if (Options::fOVNames().contains(action->text().remove(0, 1)))
447 {
448 action->setChecked(true);
449 }
450 else
451 {
452 action->setChecked(false);
453 }
454 }
455}
456
457void KStars::hideAllFovExceptFirst()
458{
459 // When there is only one visible FOV symbol, we don't need to do anything
460 // Also, don't do anything if there are no available FOV symbols.
461 if (data()->visibleFOVs.size() == 1 || data()->availFOVs.isEmpty())
462 {
463 return;
464 }
465 else
466 {
467 // If there are no visible FOVs, select first available
468 if (data()->visibleFOVs.isEmpty())
469 {
470 Q_ASSERT(!data()->availFOVs.isEmpty());
471 Options::setFOVNames(QStringList(data()->availFOVs.first()->name()));
472 }
473 else
474 {
475 Options::setFOVNames(QStringList(data()->visibleFOVs.first()->name()));
476 }
477
478 // Sync FOV and update skymap
479 data()->syncFOV();
480 syncFOVActions();
481 map()->update(); // SkyMap::forceUpdate() is not required, as FOVs are drawn as overlays
482 }
483}
484
485void KStars::selectNextFov()
486{
487 if (data()->getVisibleFOVs().isEmpty())
488 return;
489
490 Q_ASSERT(!data()
491 ->getAvailableFOVs()
492 .isEmpty()); // The available FOVs had better not be empty if the visible ones are not.
493
494 FOV *currentFov = data()->getVisibleFOVs().first();
495 int currentIdx = data()->availFOVs.indexOf(currentFov);
496
497 // If current FOV is not the available FOV list or there is only 1 FOV available, then return
498 if (currentIdx == -1 || data()->availFOVs.size() < 2)
499 {
500 return;
501 }
502
503 QStringList nextFovName;
504 if (currentIdx == data()->availFOVs.size() - 1)
505 {
506 nextFovName << data()->availFOVs.first()->name();
507 }
508 else
509 {
510 nextFovName << data()->availFOVs.at(currentIdx + 1)->name();
511 }
512
513 Options::setFOVNames(nextFovName);
514 data()->syncFOV();
515 syncFOVActions();
516 currentFov = data()->getVisibleFOVs().first();
517 zoom(map()->width() / (3 * std::max(currentFov->sizeX(), currentFov->sizeY()) * dms::DegToRad / 60.0));
518 map()->update();
519}
520
521void KStars::selectPreviousFov()
522{
523 if (data()->getVisibleFOVs().isEmpty())
524 return;
525
526 Q_ASSERT(!data()
527 ->getAvailableFOVs()
528 .isEmpty()); // The available FOVs had better not be empty if the visible ones are not.
529
530 FOV *currentFov = data()->getVisibleFOVs().first();
531 int currentIdx = data()->availFOVs.indexOf(currentFov);
532
533 // If current FOV is not the available FOV list or there is only 1 FOV available, then return
534 if (currentIdx == -1 || data()->availFOVs.size() < 2)
535 {
536 return;
537 }
538
539 QStringList prevFovName;
540 if (currentIdx == 0)
541 {
542 prevFovName << data()->availFOVs.last()->name();
543 }
544 else
545 {
546 prevFovName << data()->availFOVs.at(currentIdx - 1)->name();
547 }
548
549 Options::setFOVNames(prevFovName);
550 data()->syncFOV();
551 syncFOVActions();
552
553 currentFov = data()->getVisibleFOVs().first();
554 zoom(map()->width() / (3 * std::max(currentFov->sizeX(), currentFov->sizeY()) * dms::DegToRad / 60.0));
555 map()->update();
556}
557
558void KStars::selectNextView()
559{
560 QList<QAction*> actions = viewsGroup->actions();
561 int currentIndex = actions.indexOf(viewsGroup->checkedAction());
562 int newIndex = currentIndex + 1;
563 if (newIndex == actions.count() - 1)
564 {
565 newIndex++; // Skip "Arbitrary"
566 }
567 actions[newIndex % actions.count()]->activate(QAction::Trigger);
568 map()->slotDisplayFadingText(actions[newIndex % actions.count()]->data().toString());
569}
570
571void KStars::selectPreviousView()
572{
573 QList<QAction*> actions = viewsGroup->actions();
574 int currentIndex = actions.indexOf(viewsGroup->checkedAction());
575 int newIndex = currentIndex - 1;
576 if (currentIndex <= 0)
577 {
578 newIndex = actions.count() - 2; // Skip "Arbitrary"
579 }
580 actions[newIndex]->activate(QAction::Trigger);
581 map()->slotDisplayFadingText(actions[newIndex]->data().toString());
582}
583
584//FIXME Port to QML2
585//#if 0
586void KStars::showWISettingsUI()
587{
589}
590//#endif
591
592void KStars::updateTime(const bool automaticDSTchange)
593{
594 // Due to frequently use of this function save data and map pointers for speedup.
595 // Save options and geo() to a pointer would not speedup because most of time options
596 // and geo will accessed only one time.
597 KStarsData *Data = data();
598 // dms oldLST( Data->lst()->Degrees() );
599
600 Data->updateTime(Data->geo(), automaticDSTchange);
601
602 //We do this outside of kstarsdata just to get the coordinates
603 //displayed in the infobox to update every second.
604 // if ( !Options::isTracking() && LST()->Degrees() > oldLST.Degrees() ) {
605 // int nSec = int( 3600.*( LST()->Hours() - oldLST.Hours() ) );
606 // Map->focus()->setRA( Map->focus()->ra().Hours() + double( nSec )/3600. );
607 // if ( Options::useAltAz() ) Map->focus()->EquatorialToHorizontal( LST(), geo()->lat() );
608 // Map->showFocusCoords();
609 // }
610
611 //If time is accelerated beyond slewTimescale, then the clock's timer is stopped,
612 //so that it can be ticked manually after each update, in order to make each time
613 //step exactly equal to the timeScale setting.
614 //Wrap the call to manualTick() in a singleshot timer so that it doesn't get called until
615 //the skymap has been completely updated.
616 if (Data->clock()->isManualMode() && Data->clock()->isActive())
617 {
618 // Jasem 2017-11-13: Time for each update varies.
619 // Ideally we want to advance the simulation clock by
620 // the current clock scale (e.g. 1 hour) every 1 second
621 // of real time. However, the sky map update, depending on calculations and
622 // drawing of objects, takes variable time to complete.
623 //QTimer::singleShot(0, Data->clock(), SLOT(manualTick()));
624 QTimer::singleShot(1000, Data->clock(), SLOT(manualTick()));
625 }
626}
627
628#ifdef HAVE_CFITSIO
629const QSharedPointer<FITSViewer> &KStars::createFITSViewer()
630{
631 if (Options::singleWindowCapturedFITS())
632 return KStars::Instance()->genericFITSViewer();
633 else
634 {
635 QSharedPointer<FITSViewer> newFITSViewer(new FITSViewer(Options::independentWindowFITS() ? nullptr : KStars::Instance()),
637 m_FITSViewers.append(newFITSViewer);
638 connect(newFITSViewer.get(), &FITSViewer::terminated, this, [this]()
639 {
640 auto rawPointer = dynamic_cast<FITSViewer*>(sender());
641 m_FITSViewers.erase(std::remove_if(m_FITSViewers.begin(), m_FITSViewers.end(), [rawPointer](auto & viewer)
642 {
643 return viewer.get() == rawPointer;
644 }));
645 });
646 return m_FITSViewers.constLast();
647 }
648}
649
650const QSharedPointer<FITSViewer> &KStars::genericFITSViewer()
651{
652 if (m_GenericFITSViewer.isNull())
653 {
654 m_GenericFITSViewer.reset(new FITSViewer(Options::independentWindowFITS() ? nullptr : this), &QObject::deleteLater);
655 connect(m_GenericFITSViewer.get(), &FITSViewer::terminated, this, [this]()
656 {
657 m_FITSViewers.removeOne(m_GenericFITSViewer);
658 m_GenericFITSViewer.clear();
659 });
660 m_FITSViewers.append(m_GenericFITSViewer);
661 }
662
663 return m_GenericFITSViewer;
664}
665
666void KStars::clearAllViewers()
667{
668 for (auto &fv : m_FITSViewers)
669 fv->close();
670
671 m_FITSViewers.clear();
672}
673#endif
674
675void KStars::closeEvent(QCloseEvent *event)
676{
677 KStars::Closing = true;
679 slotAboutToQuit();
680}
void loadFromConfig()
Read color-scheme data from the Config object.
Primary window to view monochrome and color FITS images.
Definition fitsviewer.h:54
static void releaseCache()
Release the FOV cache.
Definition fov.cpp:154
A simple class encapsulating a Field-of-View symbol.
Definition fov.h:28
Q_INVOKABLE QAction * action(const QString &name) const
KToolBar * toolBar(const QString &name=QString())
static void UseDefault()
Use the default logging mechanism.
Definition ksutils.cpp:1023
static void SyncFilterRules()
SyncFilterRules Sync QtLogging filter rules from Options.
Definition ksutils.cpp:1035
static void Disable()
Disable logging.
Definition ksutils.cpp:1028
static void UseFile()
Store all logs into the specified file.
Definition ksutils.cpp:926
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
KStarsData is the backbone of KStars.
Definition kstarsdata.h:74
void updateTime(GeoLocation *geo, const bool automaticDSTchange=true)
Update the Simulation Clock.
SkyObject * objectNamed(const QString &name)
Find object by name.
ColorScheme * colorScheme()
Definition kstarsdata.h:174
void syncFOV()
Synchronize list of visible FOVs and list of selected FOVs in Options.
Q_INVOKABLE SimClock * clock()
Definition kstarsdata.h:220
GeoLocation * geo()
Definition kstarsdata.h:232
void setLocationFromOptions()
Set the GeoLocation according to the values stored in the configuration file.
const QList< FOV * > getVisibleFOVs() const
Definition kstarsdata.h:308
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
static KStarsDateTime fromString(const QString &s)
static KStarsDateTime currentDateTimeUtc()
The KStars Splash Screen.
This is the main window for KStars.
Definition kstars.h:89
SkyMap * map() const
Definition kstars.h:139
void applyConfig(bool doApplyFocus=true)
Apply config options throughout the program.
Definition kstars.cpp:311
static KStars * Instance()
Definition kstars.h:121
~KStars() override
Destructor.
Definition kstars.cpp:248
KStarsData * data() const
Definition kstars.h:133
static KStars * createInstance(bool doSplash, bool clockrunning=true, const QString &startDateString=QString())
Create an instance of this class.
Definition kstars.cpp:239
void clearCachedFindDialog()
Delete FindDialog because ObjNames list has changed in KStarsData due to reloading star data.
Definition kstars.cpp:293
void releaseResources()
Syncs config file.
Definition kstars.cpp:274
void slotWISettings()
action slot: open What's Interesting settings window
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition kstars.cpp:592
static bool Closing
Set to true when the application is being closed.
Definition kstars.h:857
Q_SCRIPTABLE Q_NOREPLY void zoom(double z)
DBUS interface function.
void applySettings(const KConfigGroup &cg)
virtual KActionCollection * actionCollection() const
virtual QAction * action(const QDomElement &element) const
bool event(QEvent *event) override
Q_INVOKABLE bool isActive()
Whether the clock is active or not is a bit complicated by the introduction of "manual mode".
Definition simclock.cpp:128
bool isManualMode() const
Manual Mode is a new (04/2002) addition to the SimClock.
Definition simclock.h:69
void setClickedPoint(const SkyPoint *f)
Set the ClickedPoint to the skypoint given as an argument.
Definition skymap.cpp:1021
void setClickedObject(SkyObject *o)
Set the ClickedObject pointer to the argument.
Definition skymap.cpp:366
void slotDisplayFadingText(const QString &text)
Render a fading text label on the screen to flash information.
Definition skymap.cpp:1386
void slotCenter()
Center the display at the point ClickedPoint.
Definition skymap.cpp:380
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
const CachingDms & dec() const
Definition skypoint.h:269
const CachingDms & ra() const
Definition skypoint.h:263
static void releaseImageCache()
Release the image cache.
static void Release()
Release the instance of TextureManager.
const double & Degrees() const
Definition dms.h:141
static constexpr double DegToRad
DegToRad is a const static member equal to the number of radians in one degree (dms::PI/180....
Definition dms.h:390
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
GeoCoordinates geo(const QVariant &location)
QString path(const QString &relativePath)
void setChecked(bool)
void setIcon(const QIcon &icon)
QMenu * menu() const const
void setText(const QString &text)
QList< QAction * > actions() const const
QAction * checkedAction() const const
void setEnabled(bool)
QString applicationDirPath()
bool isValid() const const
bool registerObject(const QString &path, QObject *object, RegisterOptions options)
bool registerService(const QString &serviceName)
QDBusConnection sessionBus()
QString absolutePath() const const
QIcon fromTheme(const QString &name)
const_reference at(qsizetype i) const const
qsizetype count() const const
pointer data()
T & first()
qsizetype indexOf(const AT &value, qsizetype from) const const
T & last()
QStatusBar * statusBar() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
void setProcessEnvironment(const QProcessEnvironment &environment)
void start(OpenMode mode)
bool waitForFinished(int msecs)
void insert(const QProcessEnvironment &e)
QProcessEnvironment systemEnvironment()
QString value(const QString &name, const QString &defaultValue) const const
void removeDatabase(const QString &connectionName)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
QString mid(qsizetype position, qsizetype n) const const
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QByteArray toLatin1() const const
QString buildAbi()
QString currentCpuArchitecture()
QString kernelType()
QString kernelVersion()
QString productType()
RightToLeft
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QThreadPool * globalInstance()
void setStackSize(uint stackSize)
QList< QAction * > actions() const const
virtual void closeEvent(QCloseEvent *event)
void setLayoutDirection(Qt::LayoutDirection direction)
void show()
void update()
virtual void setVisible(bool visible)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.