From 70255cd7618eaf66834645fcf684d062e54afd50 Mon Sep 17 00:00:00 2001 From: dave-kaye <91984396+dave-kaye@users.noreply.github.com> Date: Wed, 11 Oct 2023 04:00:15 -0500 Subject: [PATCH] [qt] - Add tour guide Add the tour guide function to the Navigation menu of the Qt interface. This matches existing setups of win32 and GTK. --- src/celestia/qt/CelestiaQtCommon.cmake | 2 + src/celestia/qt/data/tour.png | Bin 0 -> 4384 bytes src/celestia/qt/icons.qrc | 3 +- src/celestia/qt/qtappwin.cpp | 18 +++ src/celestia/qt/qtappwin.h | 2 + src/celestia/qt/qttourguide.cpp | 98 +++++++++++++++++ src/celestia/qt/qttourguide.h | 40 +++++++ src/celestia/qt/tourguide.ui | 146 +++++++++++++++++++++++++ 8 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 src/celestia/qt/data/tour.png create mode 100644 src/celestia/qt/qttourguide.cpp create mode 100644 src/celestia/qt/qttourguide.h create mode 100644 src/celestia/qt/tourguide.ui diff --git a/src/celestia/qt/CelestiaQtCommon.cmake b/src/celestia/qt/CelestiaQtCommon.cmake index 25359507ea..cc2da2415b 100644 --- a/src/celestia/qt/CelestiaQtCommon.cmake +++ b/src/celestia/qt/CelestiaQtCommon.cmake @@ -21,6 +21,7 @@ function(GetQtSources UseWayland) qtsettimedialog.cpp qtsolarsystembrowser.cpp qttimetoolbar.cpp + qttourguide.cpp xbel.cpp ) @@ -43,6 +44,7 @@ function(GetQtSources UseWayland) qtsettimedialog.h qtsolarsystembrowser.h qttimetoolbar.h + qttourguide.h xbel.h ) diff --git a/src/celestia/qt/data/tour.png b/src/celestia/qt/data/tour.png new file mode 100644 index 0000000000000000000000000000000000000000..a81ec6f1055e50e6c6229c3273ae179033c7f0d3 GIT binary patch literal 4384 zcmV+*5#R2KP)dQ@0+Qek%> zaB^>EX>4U6ba`-PAZ2)IW&i+q+O3#ravQM`h5zFeIl^FRG;ka&jjG%r$IsV8QkG=J zl9Py*hBX{w>9_QQgZ=BDC;Wq-)Jh9QwA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b8ebS2;l?BD3)weI!tYScFSy>bo7H$FRx;CSL@e;|+J(?+UKa~=tM1qH0 z-XWnDhl5RK3!faz!o$O3#5H^Q@?~OTVon0D0Ag1HV}T8Ts_jNxodqFmtMB;ftJU7* z8R~J}wVOqY7L6FZtgMWfn3xi?+595VIMjCh=2}npLx$O*vXqPrgM)*I4J?WxIXOAR z#l@X+I2_B`OKv0tT!(vlyWLJ^W+n*<2^l~%U>+!bpn=2*kXKYxpjNAg1YTcX&;I0O zvJW0K0q=Kx?ftF(dV!z9$)zZC*@`)N=gut; zOu$P(Jn$iK;7DD4M!Bi;q2Dt%V->}-L#-NF+v&rBWnCR|DQsN|3-15K@e+X(HxzZX zjn>V;gC5_=x^6VCpD}tA04Hl|Mc~k|2mpzFIwcUHfe4M*^rc{(E^MNvFR8z6ZU*2| zLn8-j^hbf>p%RdYdvO9*3=+4YA8-IevB_-tt4cIIs zv44=4d_sI8I_ri~dOcIHpogs$_#OBe$Pkix<-E7{Kk4x!S~B1?P}au$PvD-AG`NC2 atMw1U#^uPGX1kOC0000data/clip_paste.png data/picture_copy.png data/split-cycle.png +data/tour.png - \ No newline at end of file + diff --git a/src/celestia/qt/qtappwin.cpp b/src/celestia/qt/qtappwin.cpp index 859a94cfa6..9260823528 100644 --- a/src/celestia/qt/qtappwin.cpp +++ b/src/celestia/qt/qtappwin.cpp @@ -98,6 +98,7 @@ #include "qtsettimedialog.h" #include "qtsolarsystembrowser.h" #include "qttimetoolbar.h" +#include "qttourguide.h" #ifndef CONFIG_DATA_DIR #define CONFIG_DATA_DIR "./" @@ -863,6 +864,15 @@ CelestiaAppWindow::gotoObject() } +void +CelestiaAppWindow::tourGuide() +{ + // use show() to display dialog in non-modal format since exec() is automatically modal + TourGuideDialog *tourDialog = new TourGuideDialog(this, m_appCore); + tourDialog->show(); +} + + void CelestiaAppWindow::slotPreferences() { @@ -1448,6 +1458,14 @@ CelestiaAppWindow::createMenus() connect(gotoObjAct, SIGNAL(triggered()), this, SLOT(gotoObject())); navMenu->addAction(gotoObjAct); + navMenu->addSeparator(); + + QAction *tourAct = new QAction(QIcon(":/icons/tour.png"), _("Tour Guide"), this); + connect(tourAct, SIGNAL(triggered()), this, SLOT(tourGuide())); + navMenu->addAction(tourAct); + + navMenu->addSeparator(); + QAction *copyAction = new QAction(QIcon(":/icons/clip_copy.png"), _("Copy URL / console text"), this); copyAction->setShortcut(QString("Ctrl+C")); connect(copyAction, &QAction::triggered, this, &CelestiaAppWindow::copyTextOrURL); diff --git a/src/celestia/qt/qtappwin.h b/src/celestia/qt/qtappwin.h index daa8e38a5f..5f7ca389ee 100644 --- a/src/celestia/qt/qtappwin.h +++ b/src/celestia/qt/qtappwin.h @@ -40,6 +40,7 @@ class EventFinder; class InfoPanel; class PreferencesDialog; class TimeToolBar; +class TourGuideDialog; class CelestiaAppWindow : public QMainWindow, public CelestiaCore::ContextMenuHandler { @@ -80,6 +81,7 @@ private slots: void gotoSelection(); void gotoObject(); void selectSun(); + void tourGuide(); void slotPreferences(); diff --git a/src/celestia/qt/qttourguide.cpp b/src/celestia/qt/qttourguide.cpp new file mode 100644 index 0000000000..834026a655 --- /dev/null +++ b/src/celestia/qt/qttourguide.cpp @@ -0,0 +1,98 @@ +// qttourguide.cpp +// +// Copyright (C) 2023, the Celestia Development Team +// +// Celestia dialog to activate tour guide. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + + +#include "qttourguide.h" + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + + + +TourGuideDialog::TourGuideDialog(QWidget *parent, CelestiaCore *appCore) : + QDialog(parent), + appCore(appCore) +{ + ui.setupUi(this); + + destinations = appCore->getDestinations(); + bool hasDestinations = false; + if (destinations != nullptr) + { + for (const Destination *dest : *destinations) + { + if (dest == nullptr) + continue; + hasDestinations = true; + ui.selectionComboBox->addItem(QString::fromStdString(dest->name)); + } + + if (hasDestinations) + { + auto dest = (*destinations)[0]; + ui.selectionDescription->setText(QString::fromStdString(dest->description)); + } + } + + if ((destinations == nullptr) || !hasDestinations) + { + ui.selectionDescription->setText(_("No guide destinations were found.")); + ui.gotoButton->setEnabled(false); + ui.selectionComboBox->setEnabled(false); + } + + connect(ui.selectionComboBox, SIGNAL(currentIndexChanged(int)), SLOT(slotSelectionChanged())); + connect(ui.gotoButton, SIGNAL(clicked(bool)), SLOT(slotGotoSelection())); + this->setAttribute(Qt::WA_DeleteOnClose, true); +} + + +void +TourGuideDialog::slotSelectionChanged() +{ + int index = ui.selectionComboBox->currentIndex(); + auto dest = (*destinations)[index]; + ui.selectionDescription->setText(QString::fromStdString(dest->description)); +} + + +void +TourGuideDialog::slotGotoSelection() +{ + Simulation *simulation = appCore->getSimulation(); + + int index = ui.selectionComboBox->currentIndex(); + auto dest = (*destinations)[index]; + + Selection sel = simulation->findObjectFromPath(dest->target); + + double distance = dest->distance; + if (distance <= sel.radius()) + distance = sel.radius() * 5.0; + + simulation->setSelection(sel); + simulation->follow(); + simulation->gotoSelection(5.0, distance, Eigen::Vector3f::UnitY(), ObserverFrame::ObserverLocal); +} diff --git a/src/celestia/qt/qttourguide.h b/src/celestia/qt/qttourguide.h new file mode 100644 index 0000000000..e947502a99 --- /dev/null +++ b/src/celestia/qt/qttourguide.h @@ -0,0 +1,40 @@ +// qttourguide.h +// +// Copyright (C) 2023, the Celestia Development Team +// +// Celestia dialog to activate tour guide. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +#pragma once + +#include +#include +#include + +#include "ui_tourguide.h" + +class QWidget; + +class CelestiaCore; + +class TourGuideDialog : public QDialog +{ + Q_OBJECT + +public: + TourGuideDialog(QWidget *parent, CelestiaCore *appCore); + ~TourGuideDialog() = default; + +private slots: + void slotSelectionChanged(); + void slotGotoSelection(); + +private: + Ui_tourGuideDialog ui; + CelestiaCore *appCore; + const DestinationList *destinations{ nullptr }; +}; diff --git a/src/celestia/qt/tourguide.ui b/src/celestia/qt/tourguide.ui new file mode 100644 index 0000000000..ba39c8a786 --- /dev/null +++ b/src/celestia/qt/tourguide.ui @@ -0,0 +1,146 @@ + + tourGuideDialog + + + + 0 + 0 + 464 + 444 + + + + + 0 + 0 + + + + Tour Guide + + + + + 13 + 390 + 431 + 39 + + + + QDialogButtonBox::Close + + + + + + 9 + 19 + 441 + 361 + + + + + + + + + Select your destination: + + + + + + + QComboBox::AdjustToContentsOnFirstShow + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Go To + + + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + buttonBox + accepted() + tourGuideDialog + accept() + + + 407 + 471 + + + 8 + 445 + + + + + buttonBox + rejected() + tourGuideDialog + close() + + + 228 + 409 + + + 231 + 221 + + + + +