parent
0acc4fed67
commit
82ef4e3b95
|
@ -383,6 +383,7 @@ QTAPP_SOURCES = \
|
|||
src/celestia/qt/qtinfopanel.cpp \
|
||||
src/celestia/qt/qteventfinder.cpp \
|
||||
src/celestia/qt/qtsettimedialog.cpp \
|
||||
src/celestia/qt/qtgotoobjectdialog.cpp \
|
||||
src/celestia/qt/xbel.cpp
|
||||
|
||||
QTAPP_HEADERS = \
|
||||
|
@ -400,6 +401,7 @@ QTAPP_HEADERS = \
|
|||
src/celestia/qt/qtinfopanel.h \
|
||||
src/celestia/qt/qteventfinder.h \
|
||||
src/celestia/qt/qtsettimedialog.h \
|
||||
src/celestia/qt/qtgotoobjectdialog.h \
|
||||
src/celestia/qt/xbel.h
|
||||
|
||||
# Third party libraries
|
||||
|
@ -493,7 +495,8 @@ FORMS = \
|
|||
src/celestia/qt/addbookmark.ui \
|
||||
src/celestia/qt/newbookmarkfolder.ui \
|
||||
src/celestia/qt/organizebookmarks.ui \
|
||||
src/celestia/qt/preferences.ui
|
||||
src/celestia/qt/preferences.ui \
|
||||
src/celestia/qt/gotoobjectdialog.ui
|
||||
|
||||
|
||||
UI_HEADERS_DIR = src/celestia/qt/ui
|
||||
|
|
|
@ -0,0 +1,238 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>gotoObjectDialog</class>
|
||||
<widget class="QDialog" name="gotoObjectDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>352</width>
|
||||
<height>261</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>212</y>
|
||||
<width>331</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>6</y>
|
||||
<width>331</width>
|
||||
<height>201</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Object name:</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="objectName"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="latitude"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Longitude:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="longitude"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Distance:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="distance"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Latitude:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="kmButton">
|
||||
<property name="text">
|
||||
<string>km</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radiiButton">
|
||||
<property name="text">
|
||||
<string>radii</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="auButton">
|
||||
<property name="text">
|
||||
<string>au</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>gotoObjectDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>gotoObjectDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -55,6 +55,7 @@
|
|||
#include "qtinfopanel.h"
|
||||
#include "qteventfinder.h"
|
||||
#include "qtsettimedialog.h"
|
||||
#include "qtgotoobjectdialog.h"
|
||||
//#include "qtvideocapturedialog.h"
|
||||
#include "celestia/scriptmenu.h"
|
||||
#include "celestia/url.h"
|
||||
|
@ -850,6 +851,13 @@ void CelestiaAppWindow::gotoSelection()
|
|||
}
|
||||
|
||||
|
||||
void CelestiaAppWindow::gotoObject()
|
||||
{
|
||||
GoToObjectDialog dlg(this, m_appCore);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
|
||||
void CelestiaAppWindow::slotPreferences()
|
||||
{
|
||||
PreferencesDialog dlg(this, m_appCore);
|
||||
|
@ -1210,8 +1218,6 @@ void CelestiaAppWindow::createMenus()
|
|||
connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
|
||||
fileMenu->addAction(quitAct);
|
||||
|
||||
|
||||
|
||||
/****** Navigation menu ******/
|
||||
navMenu = menuBar()->addMenu(_("&Navigation"));
|
||||
|
||||
|
@ -1227,6 +1233,9 @@ void CelestiaAppWindow::createMenus()
|
|||
connect(gotoAct, SIGNAL(triggered()), this, SLOT(gotoSelection()));
|
||||
navMenu->addAction(gotoAct);
|
||||
|
||||
QAction* gotoObjAct = new QAction(QIcon(":/icons/go-jump.png"), _("Goto Object..."), this);
|
||||
connect(gotoObjAct, SIGNAL(triggered()), this, SLOT(gotoObject()));
|
||||
navMenu->addAction(gotoObjAct);
|
||||
|
||||
/****** Time menu ******/
|
||||
timeMenu = menuBar()->addMenu(_("&Time"));
|
||||
|
|
|
@ -69,6 +69,7 @@ class CelestiaAppWindow : public QMainWindow
|
|||
|
||||
void centerSelection();
|
||||
void gotoSelection();
|
||||
void gotoObject();
|
||||
void selectSun();
|
||||
|
||||
void slotPreferences();
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
#include <QPushButton>
|
||||
#include <QLocale>
|
||||
#include "qtgotoobjectdialog.h"
|
||||
#include "ui_gotoobjectdialog.h"
|
||||
#include <celestia/celestiacore.h>
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
GoToObjectDialog::GoToObjectDialog(QWidget *parent, CelestiaCore* _appCore) :
|
||||
QDialog(parent),
|
||||
appCore(_appCore)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
Simulation *simulation = appCore->getSimulation();
|
||||
Body *body = simulation->getSelection().body();
|
||||
|
||||
if (body == nullptr)
|
||||
{
|
||||
// Disable OK button if we don't have any object selected
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set up the values */
|
||||
double distance, longitude, latitude;
|
||||
simulation->getSelectionLongLat(distance, longitude, latitude);
|
||||
|
||||
distance -= body->getRadius();
|
||||
ui.distance->setText(QString("%L1").arg(distance, 0, 'f', 1));
|
||||
ui.longitude->setText(QString("%L1").arg(longitude, 0, 'f', 5));
|
||||
ui.latitude->setText(QString("%L1").arg(latitude, 0, 'f', 5));
|
||||
|
||||
ui.objectName->setText(QString::fromStdString(body->getName()));
|
||||
|
||||
ui.kmButton->setChecked(true);
|
||||
}
|
||||
|
||||
void GoToObjectDialog::on_buttonBox_accepted()
|
||||
{
|
||||
QString objectName = ui.objectName->text();
|
||||
|
||||
Simulation *simulation = appCore->getSimulation();
|
||||
Selection sel = simulation->findObjectFromPath(objectName.toStdString());
|
||||
|
||||
simulation->setSelection(sel);
|
||||
simulation->follow();
|
||||
|
||||
bool ok;
|
||||
QLocale locale;
|
||||
double distance = locale.toDouble(ui.distance->text(), &ok);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
if (ui.auButton->isChecked())
|
||||
distance = astro::AUtoKilometers(distance);
|
||||
else if (ui.radiiButton->isChecked())
|
||||
distance *= sel.radius();
|
||||
|
||||
distance += (float) sel.radius();
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = sel.radius() * 5.0f;
|
||||
}
|
||||
|
||||
double latitude;
|
||||
double longitude = locale.toDouble(ui.longitude->text(), &ok);
|
||||
|
||||
if (ok)
|
||||
latitude = locale.toDouble(ui.latitude->text(), &ok);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
simulation->gotoSelectionLongLat(5.0,
|
||||
distance,
|
||||
degToRad(longitude),
|
||||
degToRad(latitude),
|
||||
Vector3f::UnitY());
|
||||
}
|
||||
else
|
||||
{
|
||||
simulation->gotoSelection(5.0,
|
||||
distance,
|
||||
Vector3f::UnitY(),
|
||||
ObserverFrame::ObserverLocal);
|
||||
}
|
||||
}
|
||||
|
||||
void GoToObjectDialog::on_objectName_textChanged(const QString &objectName)
|
||||
{
|
||||
QPushButton *okButton = ui.buttonBox->button(QDialogButtonBox::Ok);
|
||||
|
||||
if (objectName.isEmpty())
|
||||
{
|
||||
okButton->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Enable OK button only if we have found the object
|
||||
Selection sel = appCore->getSimulation()->findObjectFromPath(objectName.toStdString());
|
||||
okButton->setEnabled(!sel.empty());
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_gotoobjectdialog.h"
|
||||
|
||||
class CelestiaCore;
|
||||
|
||||
class GoToObjectDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GoToObjectDialog(QWidget *parent, CelestiaCore* appCore);
|
||||
~GoToObjectDialog() = default;
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_objectName_textChanged(const QString &);
|
||||
|
||||
private:
|
||||
Ui_gotoObjectDialog ui;
|
||||
|
||||
CelestiaCore *appCore;
|
||||
};
|
Loading…
Reference in New Issue