Kstars

kstarsactions.cpp
1 /*
2  SPDX-FileCopyrightText: 2002 Jason Harris <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 // This file contains function definitions for Actions declared in kstars.h
8 
9 #include "kstars.h"
10 
11 #include "imageexporter.h"
12 #include "kstarsdata.h"
13 #include "kstars_debug.h"
14 #include "ksnotification.h"
15 #include "kswizard.h"
16 #include "Options.h"
17 #include "skymap.h"
18 #include "texturemanager.h"
19 #include "dialogs/exportimagedialog.h"
20 #include "dialogs/finddialog.h"
21 #include "dialogs/focusdialog.h"
22 #include "dialogs/fovdialog.h"
23 #include "dialogs/locationdialog.h"
24 #include "dialogs/timedialog.h"
25 #include "dialogs/catalogsdbui.h"
26 #include "oal/execute.h"
27 #include "oal/equipmentwriter.h"
28 #include "oal/observeradd.h"
29 #include "options/opsadvanced.h"
30 #include "options/opscatalog.h"
31 #include "options/opscolors.h"
32 #include "options/opsguides.h"
33 #include "options/opsterrain.h"
34 #include "options/opsdeveloper.h"
35 #include "options/opssatellites.h"
36 #include "options/opssolarsystem.h"
37 #include "options/opssupernovae.h"
38 #include "printing/printingwizard.h"
39 #include "projections/projector.h"
40 #include "skycomponents/asteroidscomponent.h"
41 #include "skycomponents/cometscomponent.h"
42 #include "skycomponents/satellitescomponent.h"
43 #include "skycomponents/skymapcomposite.h"
44 #include "skycomponents/solarsystemcomposite.h"
45 #include "skycomponents/supernovaecomponent.h"
46 #include "skycomponents/catalogscomponent.h"
47 #include "skycomponents/mosaiccomponent.h"
48 #ifdef HAVE_INDI
49 #include "skyobjects/mosaictiles.h"
50 #endif
51 #include "tools/altvstime.h"
52 #include "tools/astrocalc.h"
53 #include "tools/eyepiecefield.h"
54 #include "tools/flagmanager.h"
55 #include "tools/horizonmanager.h"
56 #include "tools/observinglist.h"
57 #include "tools/planetviewer.h"
58 #include "tools/jmoontool.h"
59 #include "tools/scriptbuilder.h"
60 #include "tools/skycalendar.h"
61 #include "tools/wutdialog.h"
62 #include "tools/polarishourangle.h"
63 #include "tools/whatsinteresting/wiequipsettings.h"
64 #include "tools/whatsinteresting/wilpsettings.h"
65 #include "tools/whatsinteresting/wiview.h"
66 #include "hips/hipsmanager.h"
67 #include "catalogsdb.h"
68 #ifdef HAVE_INDI
69 #include <basedevice.h>
70 //#include "indi/telescopewizardprocess.h"
71 #include "indi/opsindi.h"
72 #include "indi/drivermanager.h"
73 #include "indi/guimanager.h"
74 #include "indi/indilistener.h"
75 #endif
76 
77 #ifdef HAVE_CFITSIO
78 #include "fitsviewer/fitsviewer.h"
79 #include "fitsviewer/opsfits.h"
80 #ifdef HAVE_INDI
81 #include "ekos/manager.h"
82 #include "ekos/scheduler/framingassistantui.h"
83 #include "ekos/opsekos.h"
84 #endif
85 #endif
86 
87 #include "xplanet/opsxplanet.h"
88 
89 #ifdef HAVE_NOTIFYCONFIG
90 #include <KNotifyConfigWidget>
91 #endif
92 #include <KActionCollection>
93 #include <KActionMenu>
94 #include <KTipDialog>
95 #include <KToggleAction>
96 #include <kns3/downloaddialog.h>
97 
98 #include <QQuickWindow>
99 #include <QQuickView>
100 
101 #ifdef _WIN32
102 #include <windows.h>
103 #undef interface
104 #endif
105 #include <sys/stat.h>
106 
107 /** ViewToolBar Action. All of the viewToolBar buttons are connected to this slot. **/
108 
109 void KStars::slotViewToolBar()
110 {
112  KConfigDialog *kcd = KConfigDialog::exists("settings");
113 
114  if (a == actionCollection()->action("show_stars"))
115  {
116  Options::setShowStars(a->isChecked());
117  if (kcd)
118  {
119  opcatalog->kcfg_ShowStars->setChecked(a->isChecked());
120  }
121  }
122  else if (a == actionCollection()->action("show_deepsky"))
123  {
124  Options::setShowDeepSky(a->isChecked());
125  if (kcd)
126  {
127  opcatalog->kcfg_ShowDeepSky->setChecked(a->isChecked());
128  }
129  }
130  else if (a == actionCollection()->action("show_planets"))
131  {
132  Options::setShowSolarSystem(a->isChecked());
133  if (kcd)
134  {
135  opsolsys->kcfg_ShowSolarSystem->setChecked(a->isChecked());
136  }
137  }
138  else if (a == actionCollection()->action("show_clines"))
139  {
140  Options::setShowCLines(a->isChecked());
141  if (kcd)
142  {
143  opguides->kcfg_ShowCLines->setChecked(a->isChecked());
144  }
145  }
146  else if (a == actionCollection()->action("show_cnames"))
147  {
148  Options::setShowCNames(a->isChecked());
149  if (kcd)
150  {
151  opguides->kcfg_ShowCNames->setChecked(a->isChecked());
152  }
153  }
154  else if (a == actionCollection()->action("show_cbounds"))
155  {
156  Options::setShowCBounds(a->isChecked());
157  if (kcd)
158  {
159  opguides->kcfg_ShowCBounds->setChecked(a->isChecked());
160  }
161  }
162  else if (a == actionCollection()->action("show_constellationart"))
163  {
164  Options::setShowConstellationArt(a->isChecked());
165  if (kcd)
166  {
167  opguides->kcfg_ShowConstellationArt->setChecked(a->isChecked());
168  }
169  }
170  else if (a == actionCollection()->action("show_mw"))
171  {
172  Options::setShowMilkyWay(a->isChecked());
173  if (kcd)
174  {
175  opguides->kcfg_ShowMilkyWay->setChecked(a->isChecked());
176  }
177  }
178  else if (a == actionCollection()->action("show_equatorial_grid"))
179  {
180  // if autoSelectGrid is selected and the user clicked the
181  // show_equatorial_grid button, he probably wants us to disable
182  // the autoSelectGrid and display the equatorial grid.
183  Options::setAutoSelectGrid(false);
184  Options::setShowEquatorialGrid(a->isChecked());
185  if (kcd)
186  {
187  opguides->kcfg_ShowEquatorialGrid->setChecked(a->isChecked());
188  opguides->kcfg_AutoSelectGrid->setChecked(false);
189  }
190  }
191  else if (a == actionCollection()->action("show_horizontal_grid"))
192  {
193  Options::setAutoSelectGrid(false);
194  Options::setShowHorizontalGrid(a->isChecked());
195  if (kcd)
196  {
197  opguides->kcfg_ShowHorizontalGrid->setChecked(a->isChecked());
198  opguides->kcfg_AutoSelectGrid->setChecked(false);
199  }
200  }
201  else if (a == actionCollection()->action("show_horizon"))
202  {
203  Options::setShowGround(a->isChecked());
204  if (!a->isChecked() && Options::useRefraction())
205  {
206  QString caption = i18n("Refraction effects disabled");
207  QString message = i18n("When the horizon is switched off, refraction effects "
208  "are temporarily disabled.");
209 
210  KMessageBox::information(this, message, caption, "dag_refract_hide_ground");
211  }
212  if (kcd)
213  {
214  opguides->kcfg_ShowGround->setChecked(a->isChecked());
215  }
216  }
217  else if (a == actionCollection()->action("show_flags"))
218  {
219  Options::setShowFlags(a->isChecked());
220  if (kcd)
221  {
222  opguides->kcfg_ShowFlags->setChecked(a->isChecked());
223  }
224  }
225  else if (a == actionCollection()->action("show_satellites"))
226  {
227  Options::setShowSatellites(a->isChecked());
228  if (kcd)
229  {
230  opssatellites->kcfg_ShowSatellites->setChecked(a->isChecked());
231  }
232  }
233  else if (a == actionCollection()->action("show_supernovae"))
234  {
235  Options::setShowSupernovae(a->isChecked());
236  if (kcd)
237  {
238  opssupernovae->kcfg_ShowSupernovae->setChecked(a->isChecked());
239  }
240  }
241 
242  // update time for all objects because they might be not initialized
243  // it's needed when using horizontal coordinates
244  data()->setFullTimeUpdate();
245  updateTime();
246 
247  map()->forceUpdate();
248 }
249 
250 void KStars::slotINDIToolBar()
251 {
252 #ifdef HAVE_INDI
253  KToggleAction *a = qobject_cast<KToggleAction *>(sender());
254 
255  if (a == actionCollection()->action("show_control_panel"))
256  {
257  if (a->isChecked())
258  {
259  GUIManager::Instance()->raise();
260  GUIManager::Instance()->activateWindow();
261  GUIManager::Instance()->showNormal();
262  }
263  else
264  GUIManager::Instance()->hide();
265  }
266  else if (a == actionCollection()->action("show_ekos"))
267  {
268  if (a->isChecked())
269  {
270  Ekos::Manager::Instance()->raise();
271  Ekos::Manager::Instance()->activateWindow();
272  Ekos::Manager::Instance()->showNormal();
273  }
274  else
275  Ekos::Manager::Instance()->hide();
276  }
277  else if (a == actionCollection()->action("lock_telescope"))
278  {
279  for (auto &oneDevice : INDIListener::Instance()->getDevices())
280  {
281  if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE))
282  continue;
283 
284  if (oneDevice->isConnected() == false)
285  {
286  KSNotification::error(i18n("Mount %1 is offline. Please connect and retry again.", oneDevice->getDeviceName()));
287  return;
288  }
289 
290  auto mount = dynamic_cast<ISD::Mount *>(oneDevice->getConcreteDevice(INDI::BaseDevice::TELESCOPE_INTERFACE));
291  if (!mount)
292  continue;
293 
294  if (a->isChecked())
295  mount->centerLock();
296  else
297  mount->centerUnlock();
298  return;
299  }
300 
301  KSNotification::sorry(i18n("No connected mounts found."));
302  return;
303  }
304  else if (a == actionCollection()->action("show_fits_viewer"))
305  {
306  if (m_FITSViewers.isEmpty())
307  {
308  a->setEnabled(false);
309  return;
310  }
311 
312  if (a->isChecked())
313  {
314  for (auto &view : m_FITSViewers)
315  {
316  if (view->getTabs().empty() == false)
317  {
318  view->raise();
319  view->activateWindow();
320  view->showNormal();
321  }
322  }
323  }
324  else
325  {
326  for (auto &view : m_FITSViewers)
327  {
328  view->hide();
329  }
330  }
331  }
332  else if (a == actionCollection()->action("show_mount_box"))
333  {
334  Ekos::Manager::Instance()->mountModule()->toggleMountToolBox();
335  }
336  else if (a == actionCollection()->action("show_sensor_fov"))
337  {
338  Options::setShowSensorFOV(a->isChecked());
339  for (auto &oneFOV : data()->getTransientFOVs())
340  {
341  if (oneFOV->objectName() == "sensor_fov")
342  oneFOV->setProperty("visible", a->isChecked());
343  }
344  }
345  else if (a == actionCollection()->action("show_mosaic_panel"))
346  {
347  Options::setShowMosaicPanel(a->isChecked());
348  // TODO
349  // If scheduler is not running, then we should also show the Mosaic Planner dialog.
350  auto scheduler = Ekos::Manager::Instance()->schedulerModule();
351  if (a->isChecked() && scheduler && scheduler->status() != Ekos::SCHEDULER_RUNNING)
352  {
353  // Only create if we don't have an instance already
354  if (findChild<Ekos::FramingAssistantUI *>("FramingAssistant") == nullptr)
355  {
356  Ekos::FramingAssistantUI *assistant = new Ekos::FramingAssistantUI();
357  assistant->setAttribute(Qt::WA_DeleteOnClose, true);
358  assistant->show();
359  }
360  }
361  }
362 
363 #endif
364 }
365 
367 {
368  telescopeGroup->setEnabled(enable);
369  if (enable == false)
370  {
371  for (QAction *a : telescopeGroup->actions())
372  {
373  a->setChecked(false);
374  }
375  }
376 }
377 
378 void KStars::slotSetDomeEnabled(bool enable)
379 {
380  domeGroup->setEnabled(enable);
381  if (enable == false)
382  {
383  for (QAction *a : domeGroup->actions())
384  {
385  a->setChecked(false);
386  }
387  }
388 }
389 
390 /** Major Dialog Window Actions **/
391 
392 void KStars::slotCalculator()
393 {
394  if (!m_AstroCalc)
395  m_AstroCalc = new AstroCalc(this);
396  m_AstroCalc->show();
397 }
398 
400 {
401  QPointer<KSWizard> wizard = new KSWizard(this);
402  if (wizard->exec() == QDialog::Accepted)
403  {
404  Options::setRunStartupWizard(false); //don't run on startup next time
405  if (wizard->geo())
406  updateLocationFromWizard(*(wizard->geo()));
407  }
408 }
409 
410 void KStars::updateLocationFromWizard(const GeoLocation &geo)
411 {
412  data()->setLocation(geo);
413  // adjust local time to keep UT the same.
414  // create new LT without DST offset
415  KStarsDateTime ltime = data()->geo()->UTtoLT(data()->ut());
416 
417  // reset timezonerule to compute next dst change
418  data()->geo()->tzrule()->reset_with_ltime(ltime, data()->geo()->TZ0(),
419  data()->isTimeRunningForward());
420 
421  // reset next dst change time
422  data()->setNextDSTChange(data()->geo()->tzrule()->nextDSTChange());
423 
424  // reset local sideral time
425  data()->syncLST();
426 
427  // Make sure Numbers, Moon, planets, and sky objects are updated immediately
428  data()->setFullTimeUpdate();
429 
430  // If the sky is in Horizontal mode and not tracking, reset focus such that
431  // Alt/Az remain constant.
432  if (!Options::isTracking() && Options::useAltAz())
433  {
434  map()->focus()->HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
435  }
436 
437  // recalculate new times and objects
438  data()->setSnapNextFocus();
439  updateTime();
440 }
441 
442 void KStars::slotDownload()
443 {
444  KSNotification::event(
445  QLatin1String("KnownIssue"),
446  i18n("Due to a known issue in the kde frameworks, "
447  "updating already downloaded items is currently not possible. <br> "
448  "Please uninstall and reinstall them to update."));
449 
450  // 2017-07-04: Explicitly load kstars.knsrc from resources file
451  auto dlg = std::make_unique<KNS3::DownloadDialog>(":/kconfig/kstars.knsrc", this);
452 
453  if (!dlg)
454  return;
455 
456  dlg->exec();
457 
458  // Get the list of all the installed entries.
459  const auto changed_entries = dlg->changedEntries();
460 
461  CatalogsDB::DBManager manager{ CatalogsDB::dso_db_path() };
462  for (const KNS3::Entry &entry : changed_entries)
463  {
464  if (entry.category() != "dso")
465  continue;
466  const auto id = entry.id().toInt();
467 
468  if (entry.status() == KNS3::Entry::Installed)
469  for (const QString &name : entry.installedFiles())
470  {
471  if (name.endsWith(CatalogsDB::db_file_extension))
472  {
473  const auto meta{ CatalogsDB::read_catalog_meta_from_file(name) };
474 
475  if (!meta.first)
476  {
478  this, i18n("Error"),
479  i18n("The catalog \"%1\" is corrupt.", entry.name()));
480  continue;
481  }
482 
483  if (meta.second.id != id)
484  {
486  this, i18n("Error"),
487  i18n("The catalog \"%1\" is corrupt.<br>Expected id=%2 but "
488  "got id=%3",
489  entry.name(), id, meta.second.id));
490  continue;
491  }
492 
493  const auto success{ manager.import_catalog(name, true) };
494  if (!success.first)
496  this, i18n("Error"),
497  i18n("Could not import the catalog \"%1\"<br>%2",
498  entry.name(), success.second));
499  }
500  }
501 
502  if (entry.status() == KNS3::Entry::Deleted)
503  {
504  manager.remove_catalog(id);
505  }
506  }
507 
509  KStars::Instance()->data()->skyComposite()->reloadDeepSky();
513 }
514 
515 void KStars::slotAVT()
516 {
517  if (!m_AltVsTime)
518  m_AltVsTime = new AltVsTime(this);
519  m_AltVsTime->show();
520 }
521 
522 void KStars::slotWUT()
523 {
524  if (!m_WUTDialog)
525  m_WUTDialog = new WUTDialog(this);
526  m_WUTDialog->show();
527 }
528 
529 //FIXME Port to QML2
530 //#if 0
532 {
533  if (!m_WIView)
535  if (m_WIView && !m_wiDock->isVisible())
537 
538  if (KConfigDialog::showDialog("wisettings"))
539  {
540  m_WIEquipmentSettings->populateScopeListWidget();
541  return;
542  }
543 
544  KConfigDialog *dialog = new KConfigDialog(this, "wisettings", Options::self());
545 
546  connect(dialog, SIGNAL(settingsChanged(QString)), this,
547  SLOT(slotApplyWIConfigChanges()));
548 
549  m_WISettings = new WILPSettings(this);
550  m_WIEquipmentSettings = new WIEquipSettings();
551  dialog->addPage(m_WISettings, i18n("Light Pollution Settings"));
552  dialog->addPage(m_WIEquipmentSettings,
553  i18n("Equipment Settings - Equipment Type and Parameters"));
554  dialog->exec();
555  if (m_WIEquipmentSettings)
556  m_WIEquipmentSettings->setAperture(); //Something isn't working with this!
557 }
558 
560 {
561  if (KStars::Closing)
562  return;
563 
564  if (!m_WIView)
565  {
566  m_WIView = new WIView(nullptr);
567  m_wiDock = new QDockWidget(this);
568  m_wiDock->setStyleSheet("QDockWidget::title{background-color:black;}");
569  m_wiDock->setObjectName("What's Interesting");
571  QWidget *container = QWidget::createWindowContainer(m_WIView->getWIBaseView());
572  m_wiDock->setWidget(container);
573  m_wiDock->setMinimumWidth(400);
575  connect(m_wiDock, SIGNAL(visibilityChanged(bool)),
576  actionCollection()->action("show_whatsinteresting"),
577  SLOT(setChecked(bool)));
578  m_wiDock->setVisible(true);
579  }
580  else
581  {
582  m_wiDock->setVisible(!m_wiDock->isVisible());
583  }
584 }
585 
586 void KStars::slotCalendar()
587 {
588  if (!m_SkyCalendar)
589  m_SkyCalendar = new SkyCalendar(this);
590  m_SkyCalendar->show();
591 }
592 
593 void KStars::slotGlossary()
594 {
595  // GlossaryDialog *dlg = new GlossaryDialog( this, true );
596  // QString glossaryfile =data()->stdDirs->findResource( "data", "kstars/glossary.xml" );
597  // QUrl u = glossaryfile;
598  // Glossary *g = new Glossary( u );
599  // g->setName( i18n( "Knowledge" ) );
600  // dlg->addGlossary( g );
601  // dlg->show();
602 }
603 
604 void KStars::slotScriptBuilder()
605 {
606  if (!m_ScriptBuilder)
607  m_ScriptBuilder = new ScriptBuilder(this);
608  m_ScriptBuilder->show();
609 }
610 
611 void KStars::slotSolarSystem()
612 {
613  if (!m_PlanetViewer)
614  m_PlanetViewer = new PlanetViewer(this);
615  m_PlanetViewer->show();
616 }
617 
618 void KStars::slotJMoonTool()
619 {
620  if (!m_JMoonTool)
621  m_JMoonTool = new JMoonTool(this);
622  m_JMoonTool->show();
623 }
624 
625 void KStars::slotMoonPhaseTool()
626 {
627  //FIXME Port to KF5
628  //if( ! mpt ) mpt = new MoonPhaseTool( this );
629  //mpt->show();
630 }
631 
633 {
634  if (!m_FlagManager)
635  m_FlagManager = new FlagManager(this);
636  m_FlagManager->show();
637 }
638 
639 #if 0
640 void KStars::slotTelescopeWizard()
641 {
642 #ifdef HAVE_INDI
643 #ifndef Q_OS_WIN
644 
645  QString indiServerDir = Options::indiServer();
646 
647 #ifdef Q_OS_OSX
648  if (Options::indiServerIsInternal())
649  indiServerDir = QCoreApplication::applicationDirPath();
650  else
651  indiServerDir = QFileInfo(Options::indiServer()).dir().path();
652 #endif
653 
654  QStringList paths;
655  paths << "/usr/bin"
656  << "/usr/local/bin" << indiServerDir;
657 
658  if (QStandardPaths::findExecutable("indiserver").isEmpty())
659  {
660  if (QStandardPaths::findExecutable("indiserver", paths).isEmpty())
661  {
662  KSNotification::error(i18n("Unable to find INDI server. Please make sure the package that provides "
663  "the 'indiserver' binary is installed."));
664  return;
665  }
666  }
667 #endif
668 
669  QPointer<telescopeWizardProcess> twiz = new telescopeWizardProcess(this);
670  twiz->exec();
671  delete twiz;
672 #endif
673 }
674 #endif
675 
676 void KStars::slotINDIPanel()
677 {
678 #ifdef HAVE_INDI
679 #ifndef Q_OS_WIN
680 
681  QString indiServerDir = Options::indiServer();
682 
683 #ifdef Q_OS_OSX
684  if (Options::indiServerIsInternal())
685  indiServerDir = QCoreApplication::applicationDirPath();
686  else
687  indiServerDir = QFileInfo(Options::indiServer()).dir().path();
688 #endif
689 
690  QStringList paths;
691  paths << "/usr/bin"
692  << "/usr/local/bin" << indiServerDir;
693 
694  if (QStandardPaths::findExecutable("indiserver").isEmpty())
695  {
696  if (QStandardPaths::findExecutable("indiserver", paths).isEmpty())
697  {
698  KSNotification::error(i18n(
699  "Unable to find INDI server. Please make sure the package that provides "
700  "the 'indiserver' binary is installed."));
701  return;
702  }
703  }
704 #endif
705  GUIManager::Instance()->updateStatus(true);
706 #endif
707 }
708 
709 void KStars::slotINDIDriver()
710 {
711 #ifdef HAVE_INDI
712 #ifndef Q_OS_WIN
713 
715  nullptr,
716  i18n("INDI Device Manager should only be used by advanced technical users. "
717  "It cannot be used with Ekos. Do you still want to open INDI device "
718  "manager?"),
719  i18n("INDI Device Manager"), KStandardGuiItem::cont(),
721  "indi_device_manager_warning") == KMessageBox::Cancel)
722  return;
723 
724  QString indiServerDir = Options::indiServer();
725 
726 #ifdef Q_OS_OSX
727  if (Options::indiServerIsInternal())
728  indiServerDir = QCoreApplication::applicationDirPath();
729  else
730  indiServerDir = QFileInfo(Options::indiServer()).dir().path();
731 #endif
732 
733  QStringList paths;
734  paths << "/usr/bin"
735  << "/usr/local/bin" << indiServerDir;
736 
737  if (QStandardPaths::findExecutable("indiserver").isEmpty())
738  {
739  if (QStandardPaths::findExecutable("indiserver", paths).isEmpty())
740  {
741  KSNotification::error(i18n(
742  "Unable to find INDI server. Please make sure the package that provides "
743  "the 'indiserver' binary is installed."));
744  return;
745  }
746  }
747 #endif
748 
749  DriverManager::Instance()->raise();
750  DriverManager::Instance()->activateWindow();
751  DriverManager::Instance()->showNormal();
752 
753 #endif
754 }
755 
756 void KStars::slotEkos()
757 {
758 #ifdef HAVE_CFITSIO
759 #ifdef HAVE_INDI
760 
761 #ifndef Q_OS_WIN
762 
763  QString indiServerDir = Options::indiServer();
764 
765 #ifdef Q_OS_OSX
766  if (Options::indiServerIsInternal())
767  indiServerDir = QCoreApplication::applicationDirPath();
768  else
769  indiServerDir = QFileInfo(Options::indiServer()).dir().path();
770 #endif
771 
772  QStringList paths;
773  paths << "/usr/bin"
774  << "/usr/local/bin" << indiServerDir;
775 
776  if (QStandardPaths::findExecutable("indiserver").isEmpty())
777  {
778  if (QStandardPaths::findExecutable("indiserver", paths).isEmpty())
779  {
780  KSNotification::error(i18n(
781  "Unable to find INDI server. Please make sure the package that provides "
782  "the 'indiserver' binary is installed."));
783  return;
784  }
785  }
786 #endif
787 
788  if (Ekos::Manager::Instance()->isVisible() &&
789  Ekos::Manager::Instance()->isActiveWindow())
790  {
791  Ekos::Manager::Instance()->hide();
792  }
793  else
794  {
795  Ekos::Manager::Instance()->raise();
796  Ekos::Manager::Instance()->activateWindow();
797  Ekos::Manager::Instance()->showNormal();
798  }
799 
800 #endif
801 #endif
802 }
803 
804 void KStars::slotINDITelescopeTrack()
805 {
806 #ifdef HAVE_INDI
807  if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr)
808  return;
809 
810  for (auto &oneDevice : INDIListener::Instance()->getDevices())
811  {
812  if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE))
813  continue;
814 
815  auto mount = dynamic_cast<ISD::Mount *>(oneDevice->getConcreteDevice(INDI::BaseDevice::TELESCOPE_INTERFACE));
816  if (!mount || mount->isConnected() == false)
817  continue;
818 
819  KToggleAction *a = qobject_cast<KToggleAction *>(sender());
820 
821  if (a != nullptr)
822  {
823  mount->setTrackEnabled(a->isChecked());
824  return;
825  }
826  }
827 #endif
828 }
829 
830 void KStars::slotINDITelescopeSlew(bool focused_object)
831 {
832 #ifdef HAVE_INDI
833  if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr)
834  return;
835 
836  for (auto &oneDevice : INDIListener::Instance()->getDevices())
837  {
838  if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE))
839  continue;
840 
841  auto mount = dynamic_cast<ISD::Mount *>(oneDevice->getConcreteDevice(INDI::BaseDevice::TELESCOPE_INTERFACE));
842  if (!mount || mount->isConnected() == false)
843  continue;
844  if (focused_object)
845  {
846  if (m_SkyMap->focusObject() != nullptr)
847  mount->Slew(m_SkyMap->focusObject());
848  }
849  else
850  mount->Slew(m_SkyMap->mousePoint());
851 
852  return;
853  }
854 #else
855  Q_UNUSED(focused_object)
856 #endif
857 }
858 
859 void KStars::slotINDITelescopeSlewMousePointer()
860 {
861 #ifdef HAVE_INDI
862  slotINDITelescopeSlew(false);
863 #endif
864 }
865 
866 void KStars::slotINDITelescopeSync(bool focused_object)
867 {
868 #ifdef HAVE_INDI
869  if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr)
870  return;
871 
872  for (auto &oneDevice : INDIListener::Instance()->getDevices())
873  {
874  if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE))
875  continue;
876 
877  auto mount = dynamic_cast<ISD::Mount *>(oneDevice->getConcreteDevice(INDI::BaseDevice::TELESCOPE_INTERFACE));
878  if (!mount || mount->isConnected() == false)
879  continue;
880 
881  if (focused_object)
882  {
883  if (m_SkyMap->focusObject() != nullptr)
884  mount->Sync(m_SkyMap->focusObject());
885  }
886  else
887  mount->Sync(m_SkyMap->mousePoint());
888 
889  return;
890  }
891 #else
892  Q_UNUSED(focused_object)
893 #endif
894 }
895 
896 void KStars::slotINDITelescopeSyncMousePointer()
897 {
898 #ifdef HAVE_INDI
899  slotINDITelescopeSync(false);
900 #endif
901 }
902 
903 void KStars::slotINDITelescopeAbort()
904 {
905 #ifdef HAVE_INDI
906  if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr)
907  return;
908 
909  for (auto &oneDevice : INDIListener::Instance()->getDevices())
910  {
911  if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE))
912  continue;
913 
914  auto mount = dynamic_cast<ISD::Mount *>(oneDevice->getConcreteDevice(INDI::BaseDevice::TELESCOPE_INTERFACE));
915  if (!mount || mount->isConnected() == false)
916  continue;
917 
918  mount->Abort();
919  return;
920  }
921 #endif
922 }
923 
924 void KStars::slotINDITelescopePark()
925 {
926 #ifdef HAVE_INDI
927  if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr)
928  return;
929 
930  for (auto &oneDevice : INDIListener::Instance()->getDevices())
931  {
932  if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE))
933  continue;
934 
935  auto mount = dynamic_cast<ISD::Mount *>(oneDevice->getConcreteDevice(INDI::BaseDevice::TELESCOPE_INTERFACE));
936  if (!mount || mount->isConnected() == false || mount->canPark() == false)
937  continue;
938 
939  mount->Park();
940  return;
941  }
942 #endif
943 }
944 
945 void KStars::slotINDITelescopeUnpark()
946 {
947 #ifdef HAVE_INDI
948  if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr)
949  return;
950 
951  for (auto &oneDevice : INDIListener::Instance()->getDevices())
952  {
953  if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE))
954  continue;
955 
956  auto mount = dynamic_cast<ISD::Mount *>(oneDevice->getConcreteDevice(INDI::BaseDevice::TELESCOPE_INTERFACE));
957  if (!mount || mount->isConnected() == false || mount->canPark() == false)
958  continue;
959 
960  mount->UnPark();
961  return;
962  }
963 #endif
964 }
965 
966 void KStars::slotINDIDomePark()
967 {
968 #ifdef HAVE_INDI
969  if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr)
970  return;
971 
972  for (auto &oneDevice : INDIListener::Instance()->getDevices())
973  {
974  if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::DOME_INTERFACE))
975  continue;
976 
977  auto dome = dynamic_cast<ISD::Dome *>(oneDevice->getConcreteDevice(INDI::BaseDevice::DOME_INTERFACE));
978  if (!dome || dome->isConnected() == false)
979  continue;
980  if (dome->canPark())
981  {
982  dome->Park();
983  return;
984  }
985  }
986 #endif
987 }
988 
989 void KStars::slotINDIDomeUnpark()
990 {
991 #ifdef HAVE_INDI
992  if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr)
993  return;
994 
995  for (auto &oneDevice : INDIListener::Instance()->getDevices())
996  {
997  if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::DOME_INTERFACE))
998  continue;
999 
1000  auto dome = dynamic_cast<ISD::Dome *>(oneDevice->getConcreteDevice(INDI::BaseDevice::DOME_INTERFACE));
1001  if (!dome || dome->isConnected() == false)
1002  continue;
1003  if (dome->canPark())
1004  {
1005  dome->UnPark();
1006  return;
1007  }
1008  }
1009 #endif
1010 }
1011 
1013 {
1014  QPointer<LocationDialog> locationdialog = new LocationDialog(this);
1015  if (locationdialog->exec() == QDialog::Accepted)
1016  {
1017  GeoLocation *newLocation = locationdialog->selectedCity();
1018  if (newLocation)
1019  {
1020  // set new location in options
1021  data()->setLocation(*newLocation);
1022 
1023  // adjust local time to keep UT the same.
1024  // create new LT without DST offset
1025  KStarsDateTime ltime = newLocation->UTtoLT(data()->ut());
1026 
1027  // reset timezonerule to compute next dst change
1028  newLocation->tzrule()->reset_with_ltime(ltime, newLocation->TZ0(),
1029  data()->isTimeRunningForward());
1030 
1031  // reset next dst change time
1032  data()->setNextDSTChange(newLocation->tzrule()->nextDSTChange());
1033 
1034  // reset local sideral time
1035  data()->syncLST();
1036 
1037  // Make sure Numbers, Moon, planets, and sky objects are updated immediately
1038  data()->setFullTimeUpdate();
1039 
1040  // If the sky is in Horizontal mode and not tracking, reset focus such that
1041  // Alt/Az remain constant.
1042  if (!Options::isTracking() && Options::useAltAz())
1043  {
1044  map()->focus()->HorizontalToEquatorial(data()->lst(),
1045  data()->geo()->lat());
1046  }
1047 
1048  // recalculate new times and objects
1049  data()->setSnapNextFocus();
1050  updateTime();
1051  }
1052  }
1053  delete locationdialog;
1054 }
1055 
1056 void KStars::slotViewOps()
1057 {
1058  // An instance of your dialog could be already created and could be cached,
1059  // in which case you want to display the cached dialog instead of creating
1060  // another one
1061  prepareOps()->show();
1062 }
1063 
1064 KConfigDialog *KStars::prepareOps()
1065 {
1066  KConfigDialog *dialog = KConfigDialog::exists("settings");
1067  if (nullptr != dialog)
1068  return dialog;
1069 
1070  // KConfigDialog didn't find an instance of this dialog, so lets create it :
1071  dialog = new KConfigDialog(this, "settings", Options::self());
1072 
1073  // For some reason the dialog does not resize to contents
1074  // so we set initial 'resonable' size here. Any better way to do this?
1075  dialog->resize(800, 600);
1076 #ifdef Q_OS_OSX
1078 #endif
1079 
1080  connect(dialog, SIGNAL(settingsChanged(QString)), this,
1081  SLOT(slotApplyConfigChanges()));
1082 
1083  opcatalog = new OpsCatalog();
1084  opguides = new OpsGuides();
1085  opterrain = new OpsTerrain();
1086  opsdeveloper = new OpsDeveloper();
1087  opsolsys = new OpsSolarSystem();
1088  opssatellites = new OpsSatellites();
1089  opssupernovae = new OpsSupernovae();
1090  opcolors = new OpsColors();
1091  opadvanced = new OpsAdvanced();
1092 
1093  KPageWidgetItem *page;
1094 
1095  page = dialog->addPage(opcatalog, i18n("Catalogs"), "kstars_catalog");
1096  page->setIcon(QIcon::fromTheme("kstars_catalog"));
1097 
1098  page = dialog->addPage(opsolsys, i18n("Solar System"), "kstars_solarsystem");
1099  page->setIcon(QIcon::fromTheme("kstars_solarsystem"));
1100 
1101  page = dialog->addPage(opssatellites, i18n("Satellites"), "kstars_satellites");
1102  page->setIcon(QIcon::fromTheme("kstars_satellites"));
1103 
1104  page = dialog->addPage(opssupernovae, i18n("Supernovae"), "kstars_supernovae");
1105  page->setIcon(QIcon::fromTheme("kstars_supernovae"));
1106 
1107  page = dialog->addPage(opguides, i18n("Guides"), "kstars_guides");
1108  page->setIcon(QIcon::fromTheme("kstars_guides"));
1109 
1110  page = dialog->addPage(opterrain, i18n("Terrain"), "kstars_terrain");
1111  page->setIcon(QIcon::fromTheme("kstars_terrain", QIcon(":/icons/kstars_terrain.png")));
1112 
1113 
1114  page = dialog->addPage(opcolors, i18n("Colors"), "kstars_colors");
1115  page->setIcon(QIcon::fromTheme("kstars_colors"));
1116 
1117 #ifdef HAVE_CFITSIO
1118  opsfits = new OpsFITS();
1119  page = dialog->addPage(opsfits, i18n("FITS"), "kstars_fitsviewer");
1120  page->setIcon(QIcon::fromTheme("kstars_fitsviewer"));
1121 #endif
1122 
1123 #ifdef HAVE_INDI
1124  opsindi = new OpsINDI();
1125  page = dialog->addPage(opsindi, i18n("INDI"), "kstars_indi");
1126  page->setIcon(QIcon::fromTheme("kstars_indi"));
1127 #ifdef HAVE_CFITSIO
1128  opsekos = new OpsEkos();
1129  KPageWidgetItem *ekosOption = dialog->addPage(opsekos, i18n("Ekos"), "kstars_ekos");
1130  ekosOption->setIcon(QIcon::fromTheme("kstars_ekos"));
1131  if (m_EkosManager)
1132  m_EkosManager->setOptionsWidget(ekosOption);
1133 #endif
1134 
1135 #endif
1136 
1137  opsxplanet = new OpsXplanet(this);
1138  page = dialog->addPage(opsxplanet, i18n("Xplanet"), "kstars_xplanet");
1139  page->setIcon(QIcon::fromTheme("kstars_xplanet"));
1140 
1141  page = dialog->addPage(opadvanced, i18n("Advanced"), "kstars_advanced");
1142  page->setIcon(QIcon::fromTheme("kstars_advanced"));
1143 
1144  page = dialog->addPage(opsdeveloper, i18n("Developer"), "kstars_developer");
1145  page->setIcon(QIcon::fromTheme("kstars_developer", QIcon(":/icons/kstars_developer.png")));
1146 
1147 #ifdef Q_OS_OSX // This is because KHelpClient doesn't seem to be working right on MacOS
1150  {
1151  KStars::Instance()->appHelpActivated();
1152  });
1153 #endif
1154 
1155  return dialog;
1156 }
1157 
1159 {
1160  opterrain->syncOptions();
1161  actionCollection()->action("toggle_terrain")
1162  ->setText(Options::showTerrain() ? i18n("Hide Terrain") : i18n("Show Terrain"));
1163 }
1164 
1166 {
1167  Options::self()->save();
1168 
1169  applyConfig();
1170 
1171  //data()->setFullTimeUpdate();
1172  //map()->forceUpdate();
1173 }
1174 
1176 {
1177  Options::self()->save();
1178  applyConfig();
1179  m_WIView->updateObservingConditions();
1180  m_WIView->onReloadIconClicked();
1181 }
1182 
1183 void KStars::slotSetTime()
1184 {
1185  QPointer<TimeDialog> timedialog = new TimeDialog(data()->lt(), data()->geo(), this);
1186 
1187  if (timedialog->exec() == QDialog::Accepted)
1188  {
1189  data()->changeDateTime(data()->geo()->LTtoUT(timedialog->selectedDateTime()));
1190 
1191  if (Options::useAltAz())
1192  {
1193  if (map()->focusObject())
1194  {
1195  map()->focusObject()->EquatorialToHorizontal(data()->lst(),
1196  data()->geo()->lat());
1197  map()->setFocus(map()->focusObject());
1198  }
1199  else
1200  map()->focus()->HorizontalToEquatorial(data()->lst(),
1201  data()->geo()->lat());
1202  }
1203 
1204  map()->forceUpdateNow();
1205 
1206  //If focusObject has a Planet Trail, clear it and start anew.
1207  KSPlanetBase *planet = dynamic_cast<KSPlanetBase *>(map()->focusObject());
1208  if (planet && planet->hasTrail())
1209  {
1210  planet->clearTrail();
1211  planet->addToTrail();
1212  }
1213  }
1214  delete timedialog;
1215 }
1216 
1217 //Set Time to CPU clock
1219 {
1221 
1222  if (Options::useAltAz())
1223  {
1224  if (map()->focusObject())
1225  {
1226  map()->focusObject()->EquatorialToHorizontal(data()->lst(),
1227  data()->geo()->lat());
1228  map()->setFocus(map()->focusObject());
1229  }
1230  else
1231  map()->focus()->HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
1232  }
1233 
1234  map()->forceUpdateNow();
1235 
1236  //If focusObject has a Planet Trail, clear it and start anew.
1237  KSPlanetBase *planet = dynamic_cast<KSPlanetBase *>(map()->focusObject());
1238  if (planet && planet->hasTrail())
1239  {
1240  planet->clearTrail();
1241  planet->addToTrail();
1242  }
1243 }
1244 
1245 void KStars::slotFind()
1246 {
1247  //clearCachedFindDialog();
1248  SkyObject *targetObject = nullptr;
1249  if (FindDialog::Instance()->exec() == QDialog::Accepted &&
1250  (targetObject = FindDialog::Instance()->targetObject()))
1251  {
1252  map()->setClickedObject(targetObject);
1253  map()->setClickedPoint(map()->clickedObject());
1254  map()->slotCenter();
1255  }
1256 
1257  // check if data has changed while dialog was open
1258  //if (DialogIsObsolete)
1259  // clearCachedFindDialog();
1260 }
1261 
1262 void KStars::slotOpenFITS()
1263 {
1264 #ifdef HAVE_CFITSIO
1265 
1266  static QUrl path = QUrl::fromLocalFile(QDir::homePath());
1267  QUrl fileURL =
1268  QFileDialog::getOpenFileUrl(KStars::Instance(), i18nc("@title:window", "Open Image"), path,
1269  "Images (*.fits *.fits.fz *.fit *.fts "
1270  "*.jpg *.jpeg *.png *.gif *.bmp "
1271  "*.cr2 *.cr3 *.crw *.nef *.raf *.dng *.arw *.orf)");
1272  if (fileURL.isEmpty())
1273  return;
1274 
1275  // Remember last directory
1276  path.setUrl(fileURL.url(QUrl::RemoveFilename));
1277 
1278  QPointer<FITSViewer> fv = createFITSViewer();
1279  connect(fv, &FITSViewer::failed, [ &, fv](const QString & errorMessage)
1280  {
1281  KSNotification::error(errorMessage, i18n("Open FITS"), 10);
1282  fv->close();
1283  });
1284 
1285  fv->loadFile(fileURL, FITS_NORMAL, FITS_NONE, QString());
1286 #endif
1287 }
1288 
1289 void KStars::slotExportImage()
1290 {
1291  //TODO Check this
1292  //For remote files, this returns
1293  //QFileInfo::absolutePath: QFileInfo::absolutePath: Constructed with empty filename
1294  //As of 2014-07-19
1295  //QUrl fileURL = KFileDialog::getSaveUrl( QDir::homePath(), "image/png image/jpeg image/gif image/x-portable-pixmap image/bmp image/svg+xml" );
1296  QUrl fileURL =
1297  QFileDialog::getSaveFileUrl(KStars::Instance(), i18nc("@title:window", "Export Image"), QUrl(),
1298  "Images (*.png *.jpeg *.gif *.bmp *.svg)");
1299 
1300  //User cancelled file selection dialog - abort image export
1301  if (fileURL.isEmpty())
1302  {
1303  return;
1304  }
1305 
1306  //Warn user if file exists!
1307  if (QFile::exists(fileURL.toLocalFile()))
1308  {
1310  parentWidget(),
1311  i18n("A file named \"%1\" already exists. Overwrite it?", fileURL.fileName()),
1312  i18n("Overwrite File?"), KStandardGuiItem::overwrite());
1313  if (r == KMessageBox::Cancel)
1314  return;
1315  }
1316 
1317  // execute image export dialog
1318 
1319  // Note: We don't let ExportImageDialog create its own ImageExporter because we want legend settings etc to be remembered between UI use and DBus scripting interface use.
1320  //if ( !m_ImageExporter )
1321  //m_ImageExporter = new ImageExporter( this );
1322 
1323  if (!m_ExportImageDialog)
1324  {
1325  m_ExportImageDialog = new ExportImageDialog(
1326  fileURL.toLocalFile(), QSize(map()->width(), map()->height()),
1327  KStarsData::Instance()->imageExporter());
1328  }
1329  else
1330  {
1331  m_ExportImageDialog->setOutputUrl(fileURL.toLocalFile());
1332  m_ExportImageDialog->setOutputSize(QSize(map()->width(), map()->height()));
1333  }
1334 
1335  m_ExportImageDialog->show();
1336 }
1337 
1338 void KStars::slotRunScript()
1339 {
1342  "*.kstars|" +
1343  i18nc("Filter by file type: KStars Scripts.", "KStars Scripts (*.kstars)"));
1344  QFile f;
1345  //QString fname;
1346 
1347  if (fileURL.isValid())
1348  {
1349  if (fileURL.isLocalFile() == false)
1350  {
1351  KSNotification::sorry(i18n("Executing remote scripts is not supported."));
1352  return;
1353  }
1354 
1355  f.setFileName(fileURL.toLocalFile());
1356 
1357  if (!f.open(QIODevice::ReadOnly))
1358  {
1359  QString message = i18n("Could not open file %1", f.fileName());
1360  KSNotification::sorry(message, i18n("Could Not Open File"));
1361  return;
1362  }
1363 
1364  QTextStream istream(&f);
1365  QString line;
1366  bool fileOK(true);
1367 
1368  while (!istream.atEnd())
1369  {
1370  line = istream.readLine();
1371  if (line.at(0) != '#' && line.left(9) != "dbus-send")
1372  {
1373  fileOK = false;
1374  break;
1375  }
1376  }
1377 
1378  if (!fileOK)
1379  {
1380  int answer;
1382  nullptr,
1383  i18n(
1384  "The selected script contains unrecognized elements, "
1385  "indicating that it was not created using the KStars script builder. "
1386  "This script may not function properly, and it may even contain "
1387  "malicious code. "
1388  "Would you like to execute it anyway?"),
1389  i18n("Script Validation Failed"), KGuiItem(i18n("Run Nevertheless")),
1390  KStandardGuiItem::cancel(), "daExecuteScript");
1391  if (answer == KMessageBox::Cancel)
1392  return;
1393  }
1394 
1395  //Add statusbar message that script is running
1396  statusBar()->showMessage(i18n("Running script: %1", fileURL.fileName()));
1397 
1398  // 2017-09-19: Jasem
1399  // FIXME This is a hack and does not work on non-Linux systems
1400  // The Script Builder should generate files that can run cross-platform
1401  QProcess p;
1402  QStringList arguments;
1403  p.start(f.fileName(), arguments);
1404  if (!p.waitForStarted())
1405  return;
1406 
1407  while (!p.waitForFinished(10))
1408  {
1409  qApp->processEvents(); //otherwise tempfile may get deleted before script completes.
1410  if (p.state() != QProcess::Running)
1411  break;
1412  }
1413 
1414  statusBar()->showMessage(i18n("Script finished."), 0);
1415  }
1416 }
1417 
1418 void KStars::slotPrint()
1419 {
1420  bool switchColors(false);
1421 
1422  //Suggest Chart color scheme
1423  if (data()->colorScheme()->colorNamed("SkyColor") != QColor(255, 255, 255))
1424  {
1425  QString message =
1426  i18n("You can save printer ink by using the \"Star Chart\" "
1427  "color scheme, which uses a white background. Would you like to "
1428  "temporarily switch to the Star Chart color scheme for printing?");
1429 
1430  int answer = KMessageBox::questionYesNoCancel(
1431  nullptr, message, i18n("Switch to Star Chart Colors?"),
1432  KGuiItem(i18n("Switch Color Scheme")), KGuiItem(i18n("Do Not Switch")),
1433  KStandardGuiItem::cancel(), "askAgainPrintColors");
1434 
1435  if (answer == KMessageBox::Cancel)
1436  return;
1437  if (answer == KMessageBox::Yes)
1438  switchColors = true;
1439  }
1440 
1441  printImage(true, switchColors);
1442 }
1443 
1444 void KStars::slotPrintingWizard()
1445 {
1446  if (m_PrintingWizard)
1447  {
1448  delete m_PrintingWizard;
1449  }
1450 
1451  m_PrintingWizard = new PrintingWizard(this);
1452  m_PrintingWizard->show();
1453 }
1454 
1455 void KStars::slotToggleTimer()
1456 {
1457  if (data()->clock()->isActive())
1458  {
1459  data()->clock()->stop();
1460  updateTime();
1461  }
1462  else
1463  {
1464  if (fabs(data()->clock()->scale()) > Options::slewTimeScale())
1465  data()->clock()->setManualMode(true);
1466  data()->clock()->start();
1467  if (data()->clock()->isManualMode())
1468  map()->forceUpdate();
1469  }
1470 
1471  // Update clock state in options
1472  Options::setRunClock(data()->clock()->isActive());
1473 }
1474 
1475 void KStars::slotStepForward()
1476 {
1477  if (data()->clock()->isActive())
1478  data()->clock()->stop();
1479  data()->clock()->manualTick(true);
1480  map()->forceUpdate();
1481 }
1482 
1483 void KStars::slotStepBackward()
1484 {
1485  if (data()->clock()->isActive())
1486  data()->clock()->stop();
1487  data()->clock()->manualTick(true, true);
1488  map()->forceUpdate();
1489 }
1490 
1491 //Pointing
1492 void KStars::slotPointFocus()
1493 {
1494  // In the following cases, we set slewing=true in order to disengage tracking
1495  map()->stopTracking();
1496 
1497  if (sender() == actionCollection()->action("zenith"))
1498  map()->setDestinationAltAz(dms(90.0), map()->focus()->az(),
1499  Options::useRefraction());
1500  else if (sender() == actionCollection()->action("north"))
1501  map()->setDestinationAltAz(dms(15.0), dms(0.0001), Options::useRefraction());
1502  else if (sender() == actionCollection()->action("east"))
1503  map()->setDestinationAltAz(dms(15.0), dms(90.0), Options::useRefraction());
1504  else if (sender() == actionCollection()->action("south"))
1505  map()->setDestinationAltAz(dms(15.0), dms(180.0), Options::useRefraction());
1506  else if (sender() == actionCollection()->action("west"))
1507  map()->setDestinationAltAz(dms(15.0), dms(270.0), Options::useRefraction());
1508 }
1509 
1511 {
1512  if (Options::isTracking())
1513  {
1514  Options::setIsTracking(false);
1515  actionCollection()->action("track_object")->setText(i18n("Engage &Tracking"));
1517  ->action("track_object")
1518  ->setIcon(QIcon::fromTheme("document-decrypt"));
1519 
1520  KSPlanetBase *planet = dynamic_cast<KSPlanetBase *>(map()->focusObject());
1521  if (planet && data()->temporaryTrail)
1522  {
1523  planet->clearTrail();
1524  data()->temporaryTrail = false;
1525  }
1526 
1527  map()->setClickedObject(nullptr);
1528  map()->setFocusObject(nullptr); //no longer tracking focusObject
1529  map()->setFocusPoint(nullptr);
1530  }
1531  else
1532  {
1533  map()->setClickedPoint(map()->focus());
1534  map()->setClickedObject(nullptr);
1535  map()->setFocusObject(nullptr); //no longer tracking focusObject
1536  map()->setFocusPoint(map()->clickedPoint());
1537  Options::setIsTracking(true);
1538  actionCollection()->action("track_object")->setText(i18n("Stop &Tracking"));
1540  ->action("track_object")
1541  ->setIcon(QIcon::fromTheme("document-encrypt"));
1542  }
1543 
1544  map()->forceUpdate();
1545 }
1546 
1547 void KStars::slotManualFocus()
1548 {
1549  QPointer<FocusDialog> focusDialog = new FocusDialog();
1550 
1551  // JM 2019-09-04: Should default to RA/DE always
1552  // if (Options::useAltAz())
1553  // focusDialog->activateAzAltPage();
1554 
1555  if (focusDialog->exec() == QDialog::Accepted)
1556  {
1557  //If the requested position is very near the pole, we need to point first
1558  //to an intermediate location just below the pole in order to get the longitudinal
1559  //position (RA/Az) right.
1560 
1561  // Do not access (RA0, Dec0) of focusDialog->point() as it can be of unknown epoch.
1562  // (RA, Dec) should be synced to JNow
1563  // -- asimha (2020-07-06)
1564  double realAlt(focusDialog->point()->alt().Degrees());
1565  double realDec(focusDialog->point()->dec().Degrees());
1566  if (Options::useAltAz() && realAlt > 89.0)
1567  {
1568  focusDialog->point()->setAlt(89.0);
1569  focusDialog->point()->HorizontalToEquatorial(data()->lst(),
1570  data()->geo()->lat());
1571  }
1572  if (!Options::useAltAz() && realDec > 89.0)
1573  {
1574  focusDialog->point()->setDec(89.0);
1575  focusDialog->point()->EquatorialToHorizontal(data()->lst(),
1576  data()->geo()->lat());
1577  }
1578 
1579  map()->setClickedPoint(focusDialog->point());
1580 
1581  if (Options::isTracking())
1582  slotTrack();
1583 
1584  map()->slotCenter();
1585 
1586  //The slew takes some time to complete, and this often causes the final focus point to be slightly
1587  //offset from the user's requested coordinates (because EquatorialToHorizontal() is called
1588  //throughout the process, which depends on the sidereal time). So we now "polish" the final
1589  //position by resetting the final focus to the focusDialog point.
1590  //
1591  //Also, if the requested position was within 1 degree of the coordinate pole, this will
1592  //automatically correct the final pointing from the intermediate offset position to the final position
1593  data()->setSnapNextFocus();
1594  if (Options::useAltAz())
1595  {
1596  // N.B. We have applied unrefract() in focusDialog
1597  map()->setDestinationAltAz(focusDialog->point()->alt(),
1598  focusDialog->point()->az(), false);
1599  }
1600  else
1601  {
1602  map()->setDestination(focusDialog->point()->ra(),
1603  focusDialog->point()->dec());
1604  }
1605 
1606  //Now, if the requested point was near a pole, we need to reset the Alt/Dec of the focus.
1607  if (Options::useAltAz() && realAlt > 89.0)
1608  map()->focus()->setAlt(realAlt);
1609  if (!Options::useAltAz() && realDec > 89.0)
1610  map()->focus()->setDec(realAlt);
1611 
1612  //Don't track if we set Alt/Az coordinates. This way, Alt/Az remain constant.
1613  if (focusDialog->usedAltAz())
1614  map()->stopTracking();
1615  }
1616  delete focusDialog;
1617 }
1618 
1620 {
1621  // Enable/disable actions
1622  actionCollection()->action("zoom_out")->setEnabled(Options::zoomFactor() > MINZOOM);
1623  actionCollection()->action("zoom_in")->setEnabled(Options::zoomFactor() < MAXZOOM);
1624  // Update status bar
1625  map()
1626  ->setupProjector(); // this needs to be run redundantly, so that the FOV returned below is up-to-date.
1627  float fov = map()->projector()->fov();
1628  KLocalizedString fovi18nstring =
1629  ki18nc("approximate field of view", "Approximate FOV: %1 degrees");
1630  if (fov < 1.0)
1631  {
1632  fov = fov * 60.0;
1633  fovi18nstring =
1634  ki18nc("approximate field of view", "Approximate FOV: %1 arcminutes");
1635  }
1636  if (fov < 1.0)
1637  {
1638  fov = fov * 60.0;
1639  fovi18nstring =
1640  ki18nc("approximate field of view", "Approximate FOV: %1 arcseconds");
1641  }
1642  QString fovstring = fovi18nstring.subs(QString::number(fov, 'f', 1)).toString();
1643 
1644  statusBar()->showMessage(fovstring, 0);
1645 }
1646 
1648 {
1649  bool ok;
1650  double currentAngle = map()->width() / (Options::zoomFactor() * dms::DegToRad);
1651  double minAngle = map()->width() / (MAXZOOM * dms::DegToRad);
1652  double maxAngle = map()->width() / (MINZOOM * dms::DegToRad);
1653 
1654  double angSize = QInputDialog::getDouble(
1655  nullptr,
1656  i18nc("The user should enter an angle for the field-of-view of the display",
1657  "Enter Desired Field-of-View Angle"),
1658  i18n("Enter a field-of-view angle in degrees: "), currentAngle, minAngle,
1659  maxAngle, 1, &ok);
1660 
1661  if (ok)
1662  {
1663  map()->setZoomFactor(map()->width() / (angSize * dms::DegToRad));
1664  }
1665 }
1666 
1667 void KStars::slotCoordSys()
1668 {
1669  if (Options::useAltAz())
1670  {
1671  Options::setUseAltAz(false);
1672  if (Options::useRefraction())
1673  {
1674  if (map()->focusObject()) //simply update focus to focusObject's position
1675  map()->setFocus(map()->focusObject());
1676  else //need to recompute focus for unrefracted position
1677  {
1678  // FIXME: Changed focus()->alt() to be unrefracted by convention; is this still necessary? -- asimha 2020/07/05
1679  map()->setFocusAltAz(map()->focus()->alt(), map()->focus()->az());
1680  map()->focus()->HorizontalToEquatorial(data()->lst(),
1681  data()->geo()->lat());
1682  }
1683  }
1685  ->action("coordsys")
1686  ->setText(i18n("Switch to Horizonal View (Horizontal &Coordinates)"));
1687  }
1688  else
1689  {
1690  Options::setUseAltAz(true);
1691  if (Options::useRefraction())
1692  {
1693  // FIXME: Changed focus()->alt() to be unrefracted by convention; is this still necessary? -- asimha 2020/07/05
1694  map()->setFocusAltAz(map()->focus()->alt(), map()->focus()->az());
1695  }
1697  ->action("coordsys")
1698  ->setText(i18n("Switch to Star Globe View (Equatorial &Coordinates)"));
1699  }
1700  map()->forceUpdate();
1701 }
1702 
1703 void KStars::slotMapProjection()
1704 {
1705  if (sender() == actionCollection()->action("project_lambert"))
1706  Options::setProjection(Projector::Lambert);
1707  if (sender() == actionCollection()->action("project_azequidistant"))
1708  Options::setProjection(Projector::AzimuthalEquidistant);
1709  if (sender() == actionCollection()->action("project_orthographic"))
1710  Options::setProjection(Projector::Orthographic);
1711  if (sender() == actionCollection()->action("project_equirectangular"))
1712  Options::setProjection(Projector::Equirectangular);
1713  if (sender() == actionCollection()->action("project_stereographic"))
1714  Options::setProjection(Projector::Stereographic);
1715  if (sender() == actionCollection()->action("project_gnomonic"))
1716  Options::setProjection(Projector::Gnomonic);
1717 
1718  //DEBUG
1719  qCDebug(KSTARS) << "Projection system: " << Options::projection();
1720 
1721  m_SkyMap->forceUpdate();
1722 }
1723 
1724 //Settings Menu:
1725 void KStars::slotColorScheme()
1726 {
1728 }
1729 
1730 void KStars::slotTargetSymbol(bool flag)
1731 {
1732  qDebug() << Q_FUNC_INFO << QString("slotTargetSymbol: %1 %2").arg(sender()->objectName()).arg(flag);
1733 
1734  QStringList names = Options::fOVNames();
1735  if (flag)
1736  {
1737  // Add FOV to list
1738  names.append(sender()->objectName());
1739  }
1740  else
1741  {
1742  // Remove FOV from list
1743  int ix = names.indexOf(sender()->objectName());
1744  if (ix >= 0)
1745  names.removeAt(ix);
1746  }
1747  Options::setFOVNames(names);
1748 
1749  // Sync visibleFOVs with fovNames
1750  data()->syncFOV();
1751 
1752  map()->forceUpdate();
1753 }
1754 
1755 void KStars::slotHIPSSource()
1756 {
1757  QAction *selectedAction = qobject_cast<QAction *>(sender());
1758  Q_ASSERT(selectedAction != nullptr);
1759 
1760  QString selectedSource = selectedAction->text().remove('&');
1761 
1762  // selectedSource could be translated, while we need to send only Latin "None"
1763  // to Hips manager.
1764  if (selectedSource == i18n("None"))
1765  HIPSManager::Instance()->setCurrentSource("None");
1766  else
1767  HIPSManager::Instance()->setCurrentSource(selectedSource);
1768 
1769  map()->forceUpdate();
1770 }
1771 
1772 void KStars::slotFOVEdit()
1773 {
1774  QPointer<FOVDialog> fovdlg = new FOVDialog(this);
1775  if (fovdlg->exec() == QDialog::Accepted)
1776  {
1777  FOVManager::save();
1778  repopulateFOV();
1779  }
1780  delete fovdlg;
1781 }
1782 
1783 void KStars::slotObsList()
1784 {
1785  m_KStarsData->observingList()->show();
1786 }
1787 
1788 void KStars::slotEquipmentWriter()
1789 {
1790  QPointer<EquipmentWriter> equipmentdlg = new EquipmentWriter();
1791  equipmentdlg->loadEquipment();
1792  equipmentdlg->exec();
1793  delete equipmentdlg;
1794 }
1795 
1796 void KStars::slotObserverManager()
1797 {
1798  QPointer<ObserverAdd> m_observerAdd = new ObserverAdd();
1799  m_observerAdd->exec();
1800  delete m_observerAdd;
1801 }
1802 
1803 void KStars::slotHorizonManager()
1804 {
1805  if (!m_HorizonManager)
1806  {
1807  m_HorizonManager = new HorizonManager(this);
1808  connect(m_SkyMap, SIGNAL(positionClicked(SkyPoint *)), m_HorizonManager,
1809  SLOT(addSkyPoint(SkyPoint *)));
1810  }
1811 
1812  m_HorizonManager->show();
1813 }
1814 
1815 void KStars::slotEyepieceView(SkyPoint *sp, const QString &imagePath)
1816 {
1817  if (!m_EyepieceView)
1818  m_EyepieceView = new EyepieceField(this);
1819 
1820  // FIXME: Move FOV choice into the Eyepiece View tool itself.
1821  bool ok = true;
1822  const FOV *fov = nullptr;
1823  if (!data()->getAvailableFOVs().isEmpty())
1824  {
1825  // Ask the user to choose from a list of available FOVs.
1826  //int index;
1827  const FOV *f;
1828  QMap<QString, const FOV *> nameToFovMap;
1829  foreach (f, data()->getAvailableFOVs())
1830  {
1831  nameToFovMap.insert(f->name(), f);
1832  }
1833  nameToFovMap.insert(i18n("Attempt to determine from image"), nullptr);
1834  fov = nameToFovMap[QInputDialog::getItem(
1835  this, i18n("Eyepiece View: Choose a field-of-view"),
1836  i18n("FOV to render eyepiece view for:"), nameToFovMap.keys(), 0, false,
1837  &ok)];
1838  }
1839  if (ok)
1840  m_EyepieceView->showEyepieceField(sp, fov, imagePath);
1841 }
1842 
1843 void KStars::slotExecute()
1844 {
1845  KStarsData::Instance()->executeSession()->init();
1846  KStarsData::Instance()->executeSession()->show();
1847 }
1848 
1849 void KStars::slotPolarisHourAngle()
1850 {
1851  QPointer<PolarisHourAngle> pHourAngle = new PolarisHourAngle(this);
1852  pHourAngle->exec();
1853 }
1854 
1855 //Help Menu
1856 void KStars::slotTipOfDay()
1857 {
1858  KTipDialog::showTip(this, "kstars/tips", true);
1859 }
1860 
1861 // Toggle to and from full screen mode
1862 void KStars::slotFullScreen()
1863 {
1864  if (topLevelWidget()->isFullScreen())
1865  {
1867  ~Qt::WindowFullScreen); // reset
1868  }
1869  else
1870  {
1872  Qt::WindowFullScreen); // set
1873  }
1874 }
1875 
1876 // Toggle to and from full screen mode
1877 void KStars::slotTerrain()
1878 {
1879  Options::setShowTerrain(!Options::showTerrain());
1880  actionCollection()->action("toggle_terrain")
1881  ->setText(Options::showTerrain() ? i18n("Hide Terrain") : i18n("Show Terrain"));
1883 }
1884 
1886 {
1887  //Exclude object with temporary trail
1888  SkyObject *exOb(nullptr);
1889  if (map()->focusObject() && map()->focusObject()->isSolarSystem() &&
1890  data()->temporaryTrail)
1891  {
1892  exOb = map()->focusObject();
1893  }
1894 
1896 
1897  map()->forceUpdate();
1898 }
1899 
1900 //toggle display of GUI Items on/off
1901 void KStars::slotShowGUIItem(bool show)
1902 {
1903  //Toolbars
1904  if (sender() == actionCollection()->action("show_statusBar"))
1905  {
1906  Options::setShowStatusBar(show);
1908  }
1909 
1910  if (sender() == actionCollection()->action("show_sbAzAlt"))
1911  {
1912  Options::setShowAltAzField(show);
1913  AltAzField.setHidden(!show);
1914  }
1915 
1916  if (sender() == actionCollection()->action("show_sbRADec"))
1917  {
1918  Options::setShowRADecField(show);
1919  RADecField.setHidden(!show);
1920  }
1921 
1922  if (sender() == actionCollection()->action("show_sbJ2000RADec"))
1923  {
1924  Options::setShowJ2000RADecField(show);
1925  J2000RADecField.setHidden(!show);
1926  }
1927 }
1928 void KStars::addColorMenuItem(QString name, const QString &actionName)
1929 {
1930  KToggleAction *kta = actionCollection()->add<KToggleAction>(actionName);
1931  const QString filename = QString(actionName).mid(3) + ".colors";
1932  kta->setText(name);
1933  kta->setObjectName(filename);
1934  kta->setActionGroup(cschemeGroup);
1935 
1936  colorActionMenu->addAction(kta);
1937 
1938  KConfigGroup cg = KSharedConfig::openConfig()->group("Colors");
1939  if (actionName.mid(3) ==
1940  cg.readEntry("ColorSchemeFile", "moonless-night.colors").remove(".colors"))
1941  {
1942  kta->setChecked(true);
1943  }
1944 
1945  //use mid(3) to exclude the leading "cs_" prefix from the action name
1946  data()->add_color_scheme(filename, name.replace("&", ""));
1947  connect(kta, SIGNAL(toggled(bool)), this, SLOT(slotColorScheme()));
1948 }
1949 
1950 void KStars::removeColorMenuItem(const QString &actionName)
1951 {
1952  qCDebug(KSTARS) << "removing " << actionName;
1953  colorActionMenu->removeAction(actionCollection()->action(actionName));
1954 }
1955 
1956 void KStars::slotAboutToQuit()
1957 {
1958  if (m_SkyMap == nullptr)
1959  return;
1960 
1961 #ifdef HAVE_INDI
1962  DriverManager::Instance()->disconnectClients();
1963  INDIListener::Instance()->disconnect();
1964  GUIManager::Instance()->disconnect();
1965 #endif
1966 
1967  // Delete skymap. This required to run destructors and save
1968  // current state in the option.
1969  delete m_SkyMap;
1970  m_SkyMap = nullptr;
1971 
1972  //Store Window geometry in Options object
1973  Options::setWindowWidth(width());
1974  Options::setWindowHeight(height());
1975 
1976  //explicitly save the colorscheme data to the config file
1977  data()->colorScheme()->saveToConfig();
1978 
1979  //synch the config file with the Config object
1980  writeConfig();
1981 
1982  //Terminate Child Processes if on OS X
1983 #ifdef Q_OS_OSX
1984  QProcess *quit = new QProcess(this);
1985  quit->start("killall kdeinit5");
1986  quit->waitForFinished(1000);
1987  quit->start("killall klauncher");
1988  quit->waitForFinished(1000);
1989  quit->start("killall kioslave");
1990  quit->waitForFinished(1000);
1991  quit->start("killall kio_http_cache_cleaner");
1992  quit->waitForFinished(1000);
1993  delete quit;
1994 #endif
1995 }
1996 
1998 {
1999  if (Options::showAltAzField())
2000  {
2001  dms a = p->alt();
2002  if (Options::useAltAz())
2003  a = p->altRefracted();
2004  QString s =
2005  QString("%1, %2").arg(p->az().toDMSString(true), //true: force +/- symbol
2006  a.toDMSString(true)); //true: force +/- symbol
2007  //statusBar()->changeItem( s, 1 );
2008  AltAzField.setText(s);
2009  }
2010  if (Options::showRADecField())
2011  {
2012  KStarsDateTime lastUpdate;
2013  lastUpdate.setDJD(KStarsData::Instance()->updateNum()->getJD());
2014  QString sEpoch = QString::number(lastUpdate.epoch(), 'f', 1);
2015  QString s = QString("%1, %2 (J%3)")
2016  .arg(p->ra().toHMSString(), p->dec().toDMSString(true),
2017  sEpoch); //true: force +/- symbol
2018  //statusBar()->changeItem( s, 2 );
2019  RADecField.setText(s);
2020  }
2021 
2022  if (Options::showJ2000RADecField())
2023  {
2024  SkyPoint p0;
2025  //p0 = p->deprecess(KStarsData::Instance()->updateNum()); // deprecess to update RA0/Dec0 from RA/Dec
2026  p0 = p->catalogueCoord(KStarsData::Instance()->updateNum()->julianDay());
2027  QString s = QString("%1, %2 (J2000)")
2028  .arg(p0.ra().toHMSString(),
2029  p0.dec().toDMSString(true)); //true: force +/- symbol
2030  //statusBar()->changeItem( s, 2 );
2031  J2000RADecField.setText(s);
2032  }
2033 }
2034 
2035 void KStars::slotUpdateComets(bool isAutoUpdate)
2036 {
2037  data()->skyComposite()->solarSystemComposite()->cometsComponent()->updateDataFile(
2038  isAutoUpdate);
2039 }
2040 
2041 void KStars::slotUpdateAsteroids(bool isAutoUpdate)
2042 {
2043  data()->skyComposite()->solarSystemComposite()->asteroidsComponent()->updateDataFile(
2044  isAutoUpdate);
2045 }
2046 
2047 void KStars::slotUpdateSupernovae()
2048 {
2049  data()->skyComposite()->supernovaeComponent()->slotTriggerDataFileUpdate();
2050 }
2051 
2052 void KStars::slotUpdateSatellites()
2053 {
2054  data()->skyComposite()->satellites()->updateTLEs();
2055 }
2056 
2057 void KStars::slotConfigureNotifications()
2058 {
2059 #ifdef HAVE_NOTIFYCONFIG
2061 #endif
2062 }
2064 {
2065  auto *ui = new CatalogsDBUI{ this, CatalogsDB::dso_db_path() };
2066  ui->show();
2067  connect(ui, &QDialog::finished, this, [&](const auto)
2068  {
2069  KStars::Instance()->data()->skyComposite()->catalogsComponent()->dropCache();
2070  });
2071 }
void start(const QString &program, const QStringList &arguments, QIODevice::OpenMode mode)
QProcess::ProcessState state() const const
void append(const T &value)
const dms & alt() const
Definition: skypoint.h:281
void setEnabled(bool)
static void clearTrailsExcept(SkyObject *o)
Remove trail for all objects but one which is passed as parameter.
Definition: trailobject.cpp:86
Definition: fov.h:27
QString readEntry(const char *key, const char *aDefault=nullptr) const
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
QUrl getOpenFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes)
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition: kstars.cpp:567
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const
QAction * action(const QString &name) const
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition: skypoint.h:194
QWidget * createWindowContainer(QWindow *window, QWidget *parent, Qt::WindowFlags flags)
QWidget * topLevelWidget() const const
void setDestinationAltAz(const dms &alt, const dms &az, bool altIsRefracted)
sets the destination point of the sky map, using its alt/az coordinates.
Definition: skymap.cpp:980
void forceUpdateNow()
Convenience function; simply calls forceUpdate(true).
Definition: skymap.h:377
void setLocation(const GeoLocation &l)
Set the GeoLocation according to the argument.
Definition: kstarsdata.cpp:403
void setText(const QString &)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
QString number(int n, int base)
void slotSetDomeEnabled(bool enable)
slotSetDomeEnabled call when dome comes online or goes offline.
void addAction(QAction *action)
KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text)
void slotFlagManager()
action slot: open Flag Manager
Class representing Printing Wizard for KStars printed documents (currently only finder charts).
ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &title=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
bool waitForFinished(int msecs)
QString getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &items, int current, bool editable, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
void setAllowedAreas(Qt::DockWidgetAreas areas)
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
void slotSetTelescopeEnabled(bool enable)
slotSetTelescopeEnabled call when telescope comes online or goes offline.
void setZoomFactor(double factor)
@ Set zoom factor.
Definition: skymap.cpp:1176
void slotSetTimeToNow()
action slot: sync kstars clock to system time
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:385
void slotToggleWIView()
action slot: toggle What's Interesting window
void setClickedPoint(const SkyPoint *f)
Set the ClickedPoint to the skypoint given as an argument.
Definition: skymap.cpp:996
double TZ0() const
Definition: geolocation.h:136
QString url(QUrl::FormattingOptions options) const const
void clicked(bool checked)
QIcon fromTheme(const QString &name)
void slotApplyConfigChanges()
Apply new settings and redraw skymap.
QObject * sender() const const
Manages the QML user interface for What's Interesting. WIView is used to display the QML UI using a Q...
Definition: wiview.h:32
SkyMap * map() const
Definition: kstars.h:143
QString applicationDirPath()
static KStarsDateTime currentDateTimeUtc()
void slotDSOCatalogGUI()
Show the DSO Catalog Management GUI.
TimeZoneRule * tzrule()
Definition: geolocation.h:150
void setStyleSheet(const QString &styleSheet)
Manages the catalog database and provides an interface to provide an interface to query and modify th...
Definition: catalogsdb.h:181
static bool showDialog(const QString &name)
QString homePath()
QString toString() const
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
Definition: kstarsdata.cpp:313
QString caption()
bool exists() const const
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 setWidget(QWidget *widget)
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
Definition: skymap.cpp:336
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Qt::WindowStates windowState() const const
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
void addToTrail(const QString &label=QString())
adds a point to the planet's trail
Definition: trailobject.cpp:60
const QString toHMSString(const bool machineReadable=false, const bool highPrecision=false) const
Definition: dms.cpp:370
void slotSetZoom()
action slot: Allow user to specify a field-of-view angle for the display window in degrees,...
dms altRefracted() const
Definition: skypoint.cpp:1050
void removeAt(int i)
void hide()
static KStars * Instance()
Definition: kstars.h:125
QString findExecutable(const QString &executableName, const QStringList &paths)
KGuiItem cancel()
void setIcon(const QIcon &icon)
void showMessage(const QString &message, int timeout)
bool isFullScreen() const const
bool isValid() const const
QMap::iterator insert(const Key &key, const T &value)
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
Definition: skymap.cpp:968
KIOCORE_EXPORT SimpleJob * mount(bool ro, const QByteArray &fstype, const QString &dev, const QString &point, JobFlags flags=DefaultFlags)
bool isVisible() const const
static bool save()
Write list of FOVs to "fov.dat".
Definition: fov.cpp:49
void setIcon(const QIcon &icon)
Renders the view through the eyepiece of various telescope types.
Definition: eyepiecefield.h:36
void updateObservingConditions()
Definition: wiview.cpp:215
void setHidden(bool hidden)
void changeDateTime(const KStarsDateTime &newDate)
Change the current simulation date/time to the KStarsDateTime argument.
Definition: kstarsdata.cpp:327
This is the base class for the KStars astronomical calculator.
Definition: astrocalc.h:25
void clearTrail()
clear the Trail
Definition: trailobject.cpp:79
QString i18n(const char *text, const TYPE &arg...)
double epoch() const
This is (approximately) the year expressed as a floating-point value.
const QString toDMSString(const bool forceSign=false, const bool machineReadable=false, const bool highPrecision=false) const
Definition: dms.cpp:279
void setWindowFlags(Qt::WindowFlags type)
const CachingDms & dec() const
Definition: skypoint.h:269
bool isEmpty() const const
void syncOps()
Sync Options to GUI, if any.
QList< QAction * > actions() const const
Q_SCRIPTABLE Q_NOREPLY void loadColorScheme(const QString &name)
DBUS interface function.
Definition: kstarsdbus.cpp:607
SkyPoint * focus()
Retrieve the Focus point; the position on the sky at the center of the skymap.
Definition: skymap.h:122
ActionType * add(const QString &name, const QObject *receiver=nullptr, const char *member=nullptr)
RemoveFilename
void setActionGroup(QActionGroup *group)
KPageWidgetItem * addPage(QWidget *page, const QString &itemName, const QString &pixmapName=QString(), const QString &header=QString(), bool manage=true)
ColorScheme * colorScheme()
Definition: kstarsdata.h:171
QUrl getSaveFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes)
QUrl fromLocalFile(const QString &localFile)
QString fileName(QUrl::ComponentFormattingOptions options) const const
GeoLocation * geo()
Definition: kstarsdata.h:229
void showNormal()
bool waitForStarted(int msecs)
void setupProjector()
Call to set up the projector before a draw cycle.
Definition: skymap.cpp:1212
void slotShowPositionBar(SkyPoint *)
Display position in the status bar.
void slotWizard()
action slot: open KStars startup wizard
void activateWindow()
void setWindowState(Qt::WindowStates windowState)
void setFocusPoint(SkyPoint *f)
set the FocusPoint; the position that is to be the next Destination.
Definition: skymap.h:203
Q_INVOKABLE SimClock * clock()
Definition: kstarsdata.h:217
void setText(const QString &text)
void setClickedObject(SkyObject *o)
Set the ClickedObject pointer to the argument.
Definition: skymap.cpp:331
int toInt(bool *ok, int base) const const
Display the positions of Jupiter's moons as a function of time.
Definition: jmoontool.h:23
WindowFullScreen
QString toLocalFile() const const
virtual int exec()
static KConfigDialog * exists(const QString &name)
KLocalizedString subs(const KLocalizedString &a, int fieldWidth=0, QChar fillChar=QLatin1Char(' ')) const
GeoCoordinates geo(const QVariant &location)
void slotZoomChanged()
Called when zoom level is changed.
int indexOf(QStringView str, int from) const const
static KNotifyConfigWidget * configure(QWidget *parent=nullptr, const QString &appname=QString())
void setFocus(SkyPoint *f)
sets the central focus point of the sky map.
Definition: skymap.cpp:942
void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget)
QString path() const const
void slotApplyWIConfigChanges()
Apply new settings for WI.
void saveToConfig()
Save color-scheme data to the Config object.
Q_SCRIPTABLE Q_NOREPLY void stop()
DBUS function to stop the SimClock.
Definition: simclock.cpp:104
Q_SCRIPTABLE Q_NOREPLY void writeConfig()
DBUS interface function.
Definition: kstarsdbus.cpp:367
QString & replace(int position, int n, QChar after)
void onReloadIconClicked()
public slot - Reload list of visible sky-objects.
Definition: wiview.cpp:389
void slotCenter()
Center the display at the point ClickedPoint.
Definition: skymap.cpp:345
QString & remove(int position, int n)
QStatusBar * statusBar() const const
void show()
SkyMapComposite * skyComposite()
Definition: kstarsdata.h:165
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
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 updateTLEs()
Download new TLE files.
void resize(int w, int h)
void slotTriggerDataFileUpdate()
This initiates updating of the data file.
static bool Closing
Set to true when the application is being closed.
Definition: kstars.h:830
void slotTrack()
action slot: Toggle whether kstars is tracking current position
QAction * action(const char *name) const
void setUrl(const QString &url, QUrl::ParsingMode parsingMode)
Dialog for adjusting the Time and Date.
Definition: timedialog.h:37
virtual KActionCollection * actionCollection() const
const CachingDms & ra() const
Definition: skypoint.h:263
void setEnabled(bool)
QList< Key > keys() const const
SkyObject * focusObject() const
Retrieve the object which is centered in the sky map.
Definition: skymap.h:261
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
void setManualMode(bool on=true)
Sets Manual Mode on/off according to the bool argument.
Definition: simclock.cpp:61
void raise()
QString left(int n) const const
double fov() const
Return the FOV of this projection.
Definition: projector.cpp:88
double getDouble(QWidget *parent, const QString &title, const QString &label, double value, double min, double max, int decimals, bool *ok, Qt::WindowFlags flags, double step)
bool hasTrail() const
Definition: trailobject.h:36
void setObjectName(const QString &name)
QString name(StandardShortcut id)
bool isLocalFile() const const
SkyPoint * mousePoint()
Retrieve the mouse pointer position.
Definition: skymap.h:226
void setDec(dms d)
Sets Dec, the current Declination.
Definition: skypoint.h:169
RightDockWidgetArea
const QChar at(int position) const const
A simple UI to manage downloaded and custom Catalogs.
Definition: catalogsdbui.h:26
Q_SCRIPTABLE Q_NOREPLY void printImage(bool usePrintDialog, bool useChartColors)
DBUS interface function.
Definition: kstarsdbus.cpp:978
KGuiItem cont()
static void showTip(const QString &tipFile=QString(), bool force=false)
void showEyepieceField(SkyPoint *sp, FOV const *const fov=nullptr, const QString &imagePath=QString())
Show the eyepiece field dialog.
void manualTick(bool force=false, bool backward=false)
Equivalent of tick() for manual mode.
Definition: simclock.cpp:83
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void add_color_scheme(const QString &filename, const QString &name)
Register a color scheme with filename and name.
Definition: kstarsdata.h:204
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 slotWISettings()
action slot: open What's Interesting settings window
void removeColorMenuItem(const QString &actionName)
Remove an item from the color-scheme action manu.
void addColorMenuItem(QString name, const QString &actionName)
Add an item to the color-scheme action manu.
KStarsData * data() const
Definition: kstars.h:137
void setMinimumWidth(int minw)
ButtonCode questionYesNoCancel(QWidget *parent, const QString &text, const QString &title=QString(), const KGuiItem &buttonYes=KStandardGuiItem::yes(), const KGuiItem &buttonNo=KStandardGuiItem::no(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
void information(QWidget *parent, const QString &text, const QString &title=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
void forceUpdate(bool now=false)
Recalculates the positions of objects in the sky, and then repaints the sky map.
Definition: skymap.cpp:1186
void syncFOV()
Synchronize list of visible FOVs and list of selected FOVs in Options.
const Projector * projector() const
Get the current projector.
Definition: skymap.h:299
void reset_with_ltime(KStarsDateTime &ltime, const double TZoffset, const bool time_runs_forward, const bool automaticDSTchange=false)
Recalculate next dst change and if DST is active by a given local time with timezone offset and time ...
void setNextDSTChange(const KStarsDateTime &dt)
Set the NextDSTChange member.
Definition: kstarsdata.h:109
void setFocusAltAz(const dms &alt, const dms &az)
sets the focus point of the sky map, using its alt/az coordinates
Definition: skymap.cpp:956
bool isChecked() const const
QPushButton * button(QDialogButtonBox::StandardButton which) const
QString mid(int position, int n) const const
void slotClearAllTrails()
Remove all trails which may have been added to solar system bodies.
void slotGeoLocator()
action slot: open dialog for selecting a new geographic location
KGuiItem overwrite()
void dropCache()
Clear the internal cache and effectively reload all objects from the database.
QWidget * parentWidget() const const
Information about an object in the sky.
Definition: skyobject.h:41
void applyConfig(bool doApplyFocus=true)
Apply config options throughout the program.
Definition: kstars.cpp:323
QMessageBox::StandardButton critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
QString message
void slotEyepieceView(SkyPoint *sp, const QString &imagePath=QString())
Show the eyepiece view tool.
WA_DeleteOnClose
void finished(int result)
void syncLST()
Sync the LST with the simulation clock.
Definition: kstarsdata.cpp:322
SkyPoint catalogueCoord(long double jdf)
Computes the J2000.0 catalogue coordinates for this SkyPoint using the epoch removing aberration,...
Definition: skypoint.cpp:710
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
Relevant data about an observing location on Earth.
Definition: geolocation.h:27
KStarsDateTime nextDSTChange() const
Definition: timezonerule.h:95
QDir dir() const const
void setDJD(long double jd)
Assign the static_cast<long double> Julian Day value, which includes the time of day encoded in the f...
static void discoverTextureDirs()
Clear the cache and discover the directories to load textures from.
const dms & az() const
Definition: skypoint.h:275
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Aug 14 2022 04:13:57 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.