Work on Camera dialog

This commit is contained in:
Alexander Bock
2020-10-11 18:08:00 +02:00
parent 1d0dcec096
commit 28246460ac
11 changed files with 383 additions and 698 deletions

View File

@@ -41,8 +41,6 @@ set(HEADER_FILES
include/ostime.h
include/profileedit.h
include/properties.h
include/ui_assets.h
include/ui_camera.h
include/ui_deltatimes.h
include/ui_errordialog.h
include/ui_keybindings.h

View File

@@ -37,17 +37,17 @@ public:
/**
* Constructor for addedScripts class
*
* \param imported The #openspace::Profile object containing all data of the
* new or imported profile.
* \param profile The #openspace::Profile object containing all data of the
* new or imported profile.
* \param parent Pointer to parent Qt widget
*/
explicit AdditionalScripts(openspace::Profile* imported, QWidget* parent);
explicit AdditionalScripts(openspace::Profile* profile, QWidget* parent);
public slots:
private slots:
void parseScript();
private:
openspace::Profile* _imported;
openspace::Profile* _profile = nullptr;
QTextEdit* _textScripts = nullptr;
};

View File

@@ -41,14 +41,14 @@ public:
/**
* Constructor for assets class
*
* \param imported The #openspace::Profile object containing all data of the
* new or imported profile.
* \param profile The #openspace::Profile object containing all data of the
* new or imported profile.
* \param reportAssets A full summary of all assets and their respective paths in
* a text format unique to this application (more details are
* in class #assetTreeModel)
* \param parent Pointer to parent Qt widget
*/
explicit Assets(openspace::Profile* imported, const std::string reportAssets,
explicit Assets(openspace::Profile* profile, const std::string reportAssets,
QWidget* parent);
/**
@@ -58,12 +58,12 @@ public:
*/
QString createTextSummary();
public slots:
private slots:
void parseSelections();
void selected(const QModelIndex&);
private:
openspace::Profile* _imported;
openspace::Profile* _profile = nullptr;
AssetTreeModel _assetTreeModel;
QTreeView* _assetTree = nullptr;
QTextEdit* _summary = nullptr;

View File

@@ -27,66 +27,59 @@
#include <QDialog>
#include <openspace/scene/profile.h>
#include <QWidget>
#include <QLineEdit>
#include <QLabel>
#include <optional>
#include <variant>
namespace openspace { class Profile; }
QT_BEGIN_NAMESPACE
namespace Ui {
class camera;
}
QT_END_NAMESPACE
class camera: public QDialog
{
Q_OBJECT
public slots:
void cancel();
void approved();
void tabSelect(int);
class QLabel;
class QLineEdit;
class QTabWidget;
class Camera : public QDialog {
Q_OBJECT
public:
/**
* Constructor for camera gui class
*
* \param imported The #openspace::Profile object containing all data of the
* new or imported profile.
* \param profile The #openspace::Profile object containing all data of the
* new or imported profile.
* \param parent Pointer to parent Qt widget (optional)
*/
explicit camera(openspace::Profile* imported, QWidget *parent = nullptr);
explicit Camera(openspace::Profile* profile, QWidget* parent);
/**
* Destructor for camera gui class
*/
~camera();
enum class cameraTypeTab : int {
Nav = 0,
Geo
};
/**
* Handles keypress while the Qt dialog window is open
*
* \param evt #QKeyEvent object for the key press event
*/
void keyPressEvent(QKeyEvent *evt);
private slots:
void approved();
void tabSelect(int);
private:
bool isEmpty(QLineEdit* le);
bool isNumericalValue(QLineEdit* le);
bool inNumericalRange(QLineEdit* le, float min, float max);
void addErrorMsg(const QString& errorDescription);
bool areRequiredFormsFilledAndValid();
void setErrorTextFormat(QLabel* label, const QString& labelTxt, bool setErrorFormat);
bool isUpVectorValid();
QWidget* createNavStateWidget();
QWidget* createGeoWidget();
Ui::camera *ui;
QWidget* _parent;
openspace::Profile* _imported;
openspace::Profile::CameraType _data;
void addErrorMsg(QString errorDescription);
bool areRequiredFormsFilledAndValid();
openspace::Profile* _profile = nullptr;
QTabWidget* _tabWidget = nullptr;
struct {
QLineEdit* anchor = nullptr;
QLineEdit* aim = nullptr;
QLineEdit* refFrame = nullptr;
QLineEdit* positionX = nullptr;
QLineEdit* positionY = nullptr;
QLineEdit* positionZ = nullptr;
QLineEdit* upX = nullptr;
QLineEdit* upY = nullptr;
QLineEdit* upZ = nullptr;
QLineEdit* yaw = nullptr;
QLineEdit* pitch = nullptr;
} _navState;
struct {
QLineEdit* anchor = nullptr;
QLineEdit* latitude = nullptr;
QLineEdit* longitude = nullptr;
QLineEdit* altitude = nullptr;
} _geoState;
QLabel* _errorMsg = nullptr;
};
#endif // __OPENSPACE_UI_LAUNCHER___CAMERA___H__

View File

@@ -140,7 +140,7 @@ private:
ostime* _time;
AdditionalScripts* _addedScripts;
deltaTimes* _deltaTimes;
camera* _camera;
Camera* _camera;
markNodes* _markNodes;
openspace::Profile* _pData;
const std::string _reportedAssets;

View File

@@ -1,394 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_UI_LAUNCHER___UI_CAMERA___H__
#define __OPENSPACE_UI_LAUNCHER___UI_CAMERA___H__
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QFrame>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QTabWidget>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_camera
{
public:
QVBoxLayout *verticalLayout;
QFrame *line;
QTabWidget *tabWidget;
QWidget *tab;
QLabel *label_anchorNav;
QLineEdit *line_anchorNav;
QLabel *label_aim;
QLineEdit *line_aim;
QLabel *label_referenceFrame;
QLineEdit *line_referenceFrame;
QLabel *label_pos;
QLabel *label_posX;
QLineEdit *line_posX;
QLabel *label_posY;
QLineEdit *line_posY;
QLabel *label_posZ;
QLineEdit *line_posZ;
QLabel *label_up;
QLabel *label_upX;
QLineEdit *line_upX;
QLabel *label_upY;
QLineEdit *line_upY;
QLabel *label_upZ;
QLineEdit *line_upZ;
QLabel *label_yaw;
QLineEdit *line_yaw;
QLabel *label_pitch;
QLineEdit *line_pitch;
QWidget *tab_2;
QLabel *label_lat;
QLineEdit *line_lat;
QLabel *label_anchorGeo;
QLineEdit *line_anchorGeo;
QLabel *label_long;
QLineEdit *line_long;
QLabel *label_altitude;
QLineEdit *line_altitude;
QFrame *line_2;
QHBoxLayout *hLay_bottom_buttonBox;
QLabel *label_error;
QDialogButtonBox *buttonBox;
void setupUi(QDialog *camera)
{
if (camera->objectName().isEmpty())
camera->setObjectName(QString::fromUtf8("camera"));
camera->resize(600, 420);
camera->setMinimumSize(QSize(600, 420));
camera->setMaximumSize(QSize(600, 420));
verticalLayout = new QVBoxLayout(camera);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
line = new QFrame(camera);
line->setObjectName(QString::fromUtf8("line"));
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
verticalLayout->addWidget(line);
tabWidget = new QTabWidget(camera);
tabWidget->setObjectName(QString::fromUtf8("tabWidget"));
tabWidget->setMinimumSize(QSize(400, 300));
tabWidget->setMaximumSize(QSize(800, 400));
tab = new QWidget();
tab->setObjectName(QString::fromUtf8("tab"));
label_anchorNav = new QLabel(tab);
label_anchorNav->setObjectName(QString::fromUtf8("label_anchorNav"));
label_anchorNav->setGeometry(QRect(20, 20, 71, 17));
QFont font;
font.setFamily(QString::fromUtf8("Arial"));
font.setPointSize(12);
label_anchorNav->setFont(font);
line_anchorNav = new QLineEdit(tab);
line_anchorNav->setObjectName(QString::fromUtf8("line_anchorNav"));
line_anchorNav->setGeometry(QRect(90, 18, 411, 25));
line_anchorNav->setFont(font);
label_aim = new QLabel(tab);
label_aim->setObjectName(QString::fromUtf8("label_aim"));
label_aim->setGeometry(QRect(20, 60, 71, 17));
label_aim->setFont(font);
line_aim = new QLineEdit(tab);
line_aim->setObjectName(QString::fromUtf8("line_aim"));
line_aim->setGeometry(QRect(90, 60, 411, 25));
line_aim->setFont(font);
label_referenceFrame = new QLabel(tab);
label_referenceFrame->setObjectName(QString::fromUtf8("label_referenceFrame"));
label_referenceFrame->setGeometry(QRect(20, 100, 141, 17));
label_referenceFrame->setFont(font);
line_referenceFrame = new QLineEdit(tab);
line_referenceFrame->setObjectName(QString::fromUtf8("line_referenceFrame"));
line_referenceFrame->setGeometry(QRect(160, 100, 341, 25));
line_referenceFrame->setFont(font);
label_pos = new QLabel(tab);
label_pos->setObjectName(QString::fromUtf8("label_pos"));
label_pos->setGeometry(QRect(20, 152, 71, 17));
label_pos->setFont(font);
label_posX = new QLabel(tab);
label_posX->setObjectName(QString::fromUtf8("label_posX"));
label_posX->setGeometry(QRect(100, 152, 16, 17));
label_posX->setFont(font);
line_posX = new QLineEdit(tab);
line_posX->setObjectName(QString::fromUtf8("line_posX"));
line_posX->setGeometry(QRect(120, 152, 100, 25));
line_posX->setFont(font);
label_posY = new QLabel(tab);
label_posY->setObjectName(QString::fromUtf8("label_posY"));
label_posY->setGeometry(QRect(240, 152, 16, 17));
label_posY->setFont(font);
line_posY = new QLineEdit(tab);
line_posY->setObjectName(QString::fromUtf8("line_posY"));
line_posY->setGeometry(QRect(260, 152, 100, 25));
line_posY->setFont(font);
label_posZ = new QLabel(tab);
label_posZ->setObjectName(QString::fromUtf8("label_posZ"));
label_posZ->setGeometry(QRect(380, 152, 16, 17));
label_posZ->setFont(font);
line_posZ = new QLineEdit(tab);
line_posZ->setObjectName(QString::fromUtf8("line_posZ"));
line_posZ->setGeometry(QRect(400, 152, 100, 25));
line_posZ->setFont(font);
label_up = new QLabel(tab);
label_up->setObjectName(QString::fromUtf8("label_up"));
label_up->setGeometry(QRect(20, 192, 71, 17));
label_up->setFont(font);
label_upX = new QLabel(tab);
label_upX->setObjectName(QString::fromUtf8("label_upX"));
label_upX->setGeometry(QRect(100, 192, 16, 17));
label_upX->setFont(font);
line_upX = new QLineEdit(tab);
line_upX->setObjectName(QString::fromUtf8("line_upX"));
line_upX->setGeometry(QRect(120, 192, 100, 25));
line_upX->setFont(font);
label_upY = new QLabel(tab);
label_upY->setObjectName(QString::fromUtf8("label_upY"));
label_upY->setGeometry(QRect(240, 192, 16, 17));
label_upY->setFont(font);
line_upY = new QLineEdit(tab);
line_upY->setObjectName(QString::fromUtf8("line_upY"));
line_upY->setGeometry(QRect(260, 192, 100, 25));
line_upY->setFont(font);
label_upZ = new QLabel(tab);
label_upZ->setObjectName(QString::fromUtf8("label_upZ"));
label_upZ->setGeometry(QRect(380, 192, 16, 17));
label_upZ->setFont(font);
line_upZ = new QLineEdit(tab);
line_upZ->setObjectName(QString::fromUtf8("line_upZ"));
line_upZ->setGeometry(QRect(400, 192, 100, 25));
line_upZ->setFont(font);
label_yaw = new QLabel(tab);
label_yaw->setObjectName(QString::fromUtf8("label_yaw"));
label_yaw->setGeometry(QRect(20, 232, 91, 17));
label_yaw->setFont(font);
line_yaw = new QLineEdit(tab);
line_yaw->setObjectName(QString::fromUtf8("line_yaw"));
line_yaw->setGeometry(QRect(120, 232, 121, 25));
line_yaw->setFont(font);
label_pitch = new QLabel(tab);
label_pitch->setObjectName(QString::fromUtf8("label_pitch"));
label_pitch->setGeometry(QRect(20, 272, 91, 17));
label_pitch->setFont(font);
line_pitch = new QLineEdit(tab);
line_pitch->setObjectName(QString::fromUtf8("line_pitch"));
line_pitch->setGeometry(QRect(120, 272, 121, 25));
line_pitch->setFont(font);
tabWidget->addTab(tab, QString());
tab_2 = new QWidget();
tab_2->setObjectName(QString::fromUtf8("tab_2"));
tab_2->setMinimumSize(QSize(250, 0));
tab_2->setMaximumSize(QSize(600, 16777215));
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
label_anchorGeo = new QLabel(tab_2);
label_anchorGeo->setObjectName(QString::fromUtf8("label_anchorGeo"));
label_anchorGeo->setGeometry(QRect(20, 20, 100, 19));
sizePolicy.setHeightForWidth(label_anchorGeo->sizePolicy().hasHeightForWidth());
label_anchorGeo->setSizePolicy(sizePolicy);
label_anchorGeo->setMinimumSize(QSize(100, 0));
label_anchorGeo->setMaximumSize(QSize(100, 16777215));
label_anchorGeo->setFont(font);
line_anchorGeo = new QLineEdit(tab_2);
line_anchorGeo->setObjectName(QString::fromUtf8("line_anchorGeo"));
line_anchorGeo->setGeometry(QRect(120, 20, 300, 27));
line_anchorGeo->setMinimumSize(QSize(200, 0));
line_anchorGeo->setMaximumSize(QSize(600, 16777215));
line_anchorGeo->setFont(font);
label_lat = new QLabel(tab_2);
label_lat->setObjectName(QString::fromUtf8("label_lat"));
label_lat->setGeometry(QRect(20, 60, 110, 19));
sizePolicy.setHeightForWidth(label_lat->sizePolicy().hasHeightForWidth());
label_lat->setSizePolicy(sizePolicy);
label_lat->setMinimumSize(QSize(110, 0));
label_lat->setMaximumSize(QSize(120, 16777215));
label_lat->setFont(font);
line_lat = new QLineEdit(tab_2);
line_lat->setObjectName(QString::fromUtf8("line_lat"));
line_lat->setGeometry(QRect(120, 60, 200, 27));
line_lat->setMinimumSize(QSize(200, 0));
line_lat->setMaximumSize(QSize(600, 16777215));
line_lat->setFont(font);
label_long = new QLabel(tab_2);
label_long->setObjectName(QString::fromUtf8("label_long"));
label_long->setGeometry(QRect(20, 100, 110, 19));
sizePolicy.setHeightForWidth(label_long->sizePolicy().hasHeightForWidth());
label_long->setSizePolicy(sizePolicy);
label_long->setMinimumSize(QSize(110, 0));
label_long->setMaximumSize(QSize(120, 16777215));
label_long->setFont(font);
line_long = new QLineEdit(tab_2);
line_long->setObjectName(QString::fromUtf8("line_long"));
line_long->setGeometry(QRect(120, 100, 200, 27));
line_long->setFont(font);
label_altitude = new QLabel(tab_2);
label_altitude->setObjectName(QString::fromUtf8("label_altitude"));
label_altitude->setGeometry(QRect(20, 140, 110, 19));
sizePolicy.setHeightForWidth(label_altitude->sizePolicy().hasHeightForWidth());
label_altitude->setSizePolicy(sizePolicy);
label_altitude->setMinimumSize(QSize(110, 0));
label_altitude->setMaximumSize(QSize(120, 16777215));
label_altitude->setFont(font);
line_altitude = new QLineEdit(tab_2);
line_altitude->setObjectName(QString::fromUtf8("line_altitude"));
line_altitude->setGeometry(QRect(120, 140, 200, 27));
line_altitude->setFont(font);
tabWidget->addTab(tab_2, QString());
verticalLayout->addWidget(tabWidget);
line_2 = new QFrame(camera);
line_2->setObjectName(QString::fromUtf8("line_2"));
line_2->setFrameShape(QFrame::HLine);
line_2->setFrameShadow(QFrame::Sunken);
verticalLayout->addWidget(line_2);
hLay_bottom_buttonBox = new QHBoxLayout();
hLay_bottom_buttonBox->setObjectName(QString::fromUtf8("hLay_bottom_buttonBox"));
QFont fontE;
fontE.setFamily(QString::fromUtf8("Arial"));
label_error = new QLabel(camera);
label_error->setObjectName(QString::fromUtf8("label_error"));
QSizePolicy sizePolicy3(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy3.setHorizontalStretch(0);
sizePolicy3.setVerticalStretch(0);
sizePolicy3.setHeightForWidth(label_error->sizePolicy().hasHeightForWidth());
label_error->setSizePolicy(sizePolicy3);
label_error->setMinimumSize(QSize(400, 40));
label_error->setMaximumSize(QSize(800, 40));
label_error->setFont(fontE);
label_error->setWordWrap(true);
hLay_bottom_buttonBox->addWidget(label_error);
buttonBox = new QDialogButtonBox(camera);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
hLay_bottom_buttonBox->addWidget(buttonBox);
verticalLayout->addLayout(hLay_bottom_buttonBox);
retranslateUi(camera);
//QObject::connect(buttonBox, SIGNAL(accepted()), camera, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), camera, SLOT(reject()));
tabWidget->setCurrentIndex(1);
QMetaObject::connectSlotsByName(camera);
} // setupUi
void retranslateUi(QDialog *camera)
{
camera->setWindowTitle(QCoreApplication::translate("camera", "Set Camera Position", nullptr));
label_anchorNav->setText(QCoreApplication::translate("camera", "Anchor:", nullptr));
#if QT_CONFIG(tooltip)
line_anchorNav->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>Anchor camera to this node</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(whatsthis)
line_anchorNav->setWhatsThis(QString());
#endif // QT_CONFIG(whatsthis)
label_aim->setText(QCoreApplication::translate("camera", "Aim:", nullptr));
#if QT_CONFIG(tooltip)
line_aim->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>[OPTIONAL] If specified, camera will be aimed at this node while keeping the anchor node in the same view location</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_referenceFrame->setText(QCoreApplication::translate("camera", "Reference Frame:", nullptr));
#if QT_CONFIG(tooltip)
line_referenceFrame->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>[OPTIONAL] Camera location in reference to this frame</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_pos->setText(QCoreApplication::translate("camera", "Position:", nullptr));
label_posX->setText(QCoreApplication::translate("camera", "X", nullptr));
#if QT_CONFIG(tooltip)
line_posX->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>Camera position vector (x)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_posY->setText(QCoreApplication::translate("camera", "Y", nullptr));
#if QT_CONFIG(tooltip)
line_posY->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>Camera position vector (y)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_posZ->setText(QCoreApplication::translate("camera", "Z", nullptr));
#if QT_CONFIG(tooltip)
line_posZ->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>Camera position vector (z)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_up->setText(QCoreApplication::translate("camera", "Up:", nullptr));
label_upX->setText(QCoreApplication::translate("camera", "X", nullptr));
#if QT_CONFIG(tooltip)
line_upX->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>[OPTIONAL] Camera up vector (x)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_upY->setText(QCoreApplication::translate("camera", "Y", nullptr));
#if QT_CONFIG(tooltip)
line_upY->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>[OPTIONAL] Camera up vector (y)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_upZ->setText(QCoreApplication::translate("camera", "Z", nullptr));
#if QT_CONFIG(tooltip)
line_upZ->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>[OPTIONAL] Camera up vector (z)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_yaw->setText(QCoreApplication::translate("camera", "Yaw angle:", nullptr));
#if QT_CONFIG(tooltip)
line_yaw->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>[OPTIONAL] yaw angle +/- 360 degrees</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_pitch->setText(QCoreApplication::translate("camera", "Pitch angle:", nullptr));
#if QT_CONFIG(tooltip)
line_pitch->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>[OPTIONAL] pitch angle +/- 360 degrees</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
tabWidget->setTabText(tabWidget->indexOf(tab), QCoreApplication::translate("camera", "setNavigationState", nullptr));
label_lat->setText(QCoreApplication::translate("camera", "Latitude:", nullptr));
#if QT_CONFIG(tooltip)
line_lat->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>Latitude of camera focus point (+/- 90 degrees)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_anchorGeo->setText(QCoreApplication::translate("camera", "Anchor:", nullptr));
#if QT_CONFIG(tooltip)
line_anchorGeo->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>Anchor camera to this globe (planet/moon)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_long->setText(QCoreApplication::translate("camera", "Longitude:", nullptr));
#if QT_CONFIG(tooltip)
line_long->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>Longitude of camera focus point (+/- 180 degrees)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
label_altitude->setText(QCoreApplication::translate("camera", "Altitude:", nullptr));
#if QT_CONFIG(tooltip)
line_altitude->setToolTip(QCoreApplication::translate("camera", "<html><head/><body><p>[OPTIONAL] Altitude of camera (meters)</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
tabWidget->setTabText(tabWidget->indexOf(tab_2), QCoreApplication::translate("camera", "goToGeo", nullptr));
label_error->setText(QCoreApplication::translate("camera", "", nullptr));
} // retranslateUi
};
namespace Ui {
class camera: public Ui_camera {};
} // namespace Ui
QT_END_NAMESPACE
#endif // __OPENSPACE_UI_LAUNCHER___UI_CAMERA___H__

View File

@@ -5,9 +5,20 @@ QLabel#heading {
font-size: 12pt;
}
QLabel#error-message {
color: #dd1111;
}
/*
* Assets
*/
Assets QTreeView {
min-width: 40em;
}
/*
* Camera
*/
Camera QLabel#error-message {
min-width: 30em;
}

View File

@@ -31,9 +31,9 @@
#include <QTextEdit>
#include <QVBoxLayout>
AdditionalScripts::AdditionalScripts(openspace::Profile* imported, QWidget *parent)
AdditionalScripts::AdditionalScripts(openspace::Profile* profile, QWidget *parent)
: QDialog(parent)
, _imported(imported)
, _profile(profile)
{
setWindowTitle("Additional Scripts");
@@ -68,7 +68,7 @@ AdditionalScripts::AdditionalScripts(openspace::Profile* imported, QWidget *pare
layout->addWidget(buttons);
}
std::vector<std::string> scripts = imported->additionalScripts();
std::vector<std::string> scripts = _profile->additionalScripts();
std::string scpts = std::accumulate(
scripts.begin(), scripts.end(),
std::string(), [](std::string lhs, std::string rhs) { return lhs + rhs + '\n'; }
@@ -85,6 +85,6 @@ void AdditionalScripts::parseScript() {
getline(iss, s);
tmpMultilineStringToVector.push_back(s);
}
_imported->setAdditionalScripts(tmpMultilineStringToVector);
_profile->setAdditionalScripts(tmpMultilineStringToVector);
accept();
}

View File

@@ -115,10 +115,10 @@ namespace {
}
} // namespace
Assets::Assets(openspace::Profile* imported, const std::string reportAssets,
Assets::Assets(openspace::Profile* profile, const std::string reportAssets,
QWidget* parent)
: QDialog(parent)
, _imported(imported)
, _profile(profile)
{
setWindowTitle("Assets");
@@ -151,7 +151,7 @@ Assets::Assets(openspace::Profile* imported, const std::string reportAssets,
connect(_assetTree, &QTreeView::clicked, this, &Assets::selected);
for (const std::string& a : _imported->assets()) {
for (const std::string& a : _profile->assets()) {
QModelIndex parent = _assetTreeModel.index(-1, 0);
int nRows = _assetTreeModel.rowCount(parent);
traverseToFindFilesystemMatch(_assetTreeModel, parent, nRows, a);
@@ -214,13 +214,13 @@ QString Assets::createTextSummary() {
}
void Assets::parseSelections() {
_imported->clearAssets();
_profile->clearAssets();
std::vector<std::string> summaryPaths;
std::vector<AssetTreeItem*> summaryItems;
_assetTreeModel.getSelectedAssets(summaryPaths, summaryItems);
for (const std::string& sel : summaryPaths) {
_imported->addAsset(sel);
_profile->addAsset(sel);
}
accept();
}

View File

@@ -22,328 +22,405 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/scene/profile.h>
#include "camera.h"
#include "./ui_camera.h"
#include <openspace/scene/profile.h>
#include <QDialogButtonBox>
#include <QDoubleValidator>
#include <QFrame>
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QKeyEvent>
#include <QTabWidget>
template <class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
namespace {
constexpr const int CameraTypeNav = 0;
constexpr const int CameraTypeGeo = 1;
camera::camera(openspace::Profile* imported, QWidget *parent)
template <class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template <class... Ts> overloaded(Ts...)->overloaded<Ts...>;
bool inNumericalRange(QLineEdit* le, float min, float max) {
QString s = le->text();
bool validConversion = false;
float value = s.toFloat(&validConversion);
if (!validConversion) {
return false;
}
if (value < min || value > max) {
return false;
}
return true;
}
} // namespace
Camera::Camera(openspace::Profile* profile, QWidget *parent)
: QDialog(parent)
, ui(new Ui::camera)
, _imported(imported)
, _profile(profile)
{
ui->setupUi(this);
setWindowTitle("Set Camera Position");
if (_imported->camera().has_value()) {
_data = imported->camera().value();
QBoxLayout* layout = new QVBoxLayout(this);
_tabWidget = new QTabWidget;
connect(_tabWidget, &QTabWidget::tabBarClicked, this, &Camera::tabSelect);
_tabWidget->addTab(createNavStateWidget(), "Navigation State");
_tabWidget->addTab(createGeoWidget(), "Geo State");
layout->addWidget(_tabWidget);
{
QFrame* line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
layout->addWidget(line);
}
{
QWidget* footer = new QWidget;
QBoxLayout* footerLayout = new QHBoxLayout(footer);
_errorMsg = new QLabel;
_errorMsg->setObjectName("error-message");
_errorMsg->setWordWrap(true);
footerLayout->addWidget(_errorMsg);
QDialogButtonBox* buttons = new QDialogButtonBox;
buttons->setStandardButtons(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
connect(buttons, &QDialogButtonBox::accepted, this, &Camera::approved);
connect(buttons, &QDialogButtonBox::rejected, this, &Camera::reject);
footerLayout->addWidget(buttons);
layout->addWidget(footer);
}
if (_profile->camera().has_value()) {
openspace::Profile::CameraType type = _profile->camera().value();
std::visit(overloaded {
[&] (const openspace::Profile::CameraNavState& nav) {
ui->tabWidget->setCurrentIndex(static_cast<int>(cameraTypeTab::Nav));
ui->line_anchorNav->setText(QString(nav.anchor.c_str()));
ui->line_aim->setText(QString(nav.aim->c_str()));
ui->line_referenceFrame->setText(QString(nav.referenceFrame.c_str()));
ui->line_posX->setText(QString::number(nav.position.x));
ui->line_posY->setText(QString::number(nav.position.y));
ui->line_posZ->setText(QString::number(nav.position.z));
[this](const openspace::Profile::CameraNavState& nav) {
_tabWidget->setCurrentIndex(CameraTypeNav);
_navState.anchor->setText(QString::fromStdString(nav.anchor));
_navState.aim->setText(QString::fromStdString(*nav.aim));
_navState.refFrame->setText(QString::fromStdString(nav.referenceFrame));
_navState.positionX->setText(QString::number(nav.position.x));
_navState.positionY->setText(QString::number(nav.position.y));
_navState.positionZ->setText(QString::number(nav.position.z));
if (nav.up.has_value()) {
ui->line_upX->setText(QString::number(nav.up.value().x));
ui->line_upY->setText(QString::number(nav.up.value().y));
ui->line_upZ->setText(QString::number(nav.up.value().z));
_navState.upX->setText(QString::number(nav.up.value().x));
_navState.upY->setText(QString::number(nav.up.value().y));
_navState.upZ->setText(QString::number(nav.up.value().z));
}
else {
ui->line_upX->setText("");
ui->line_upY->setText("");
ui->line_upZ->setText("");
_navState.upX->clear();
_navState.upY->clear();
_navState.upZ->clear();
}
if (nav.yaw.has_value()) {
ui->line_yaw->setText(QString::number(nav.yaw.value()));
_navState.yaw->setText(QString::number(*nav.yaw));
}
else {
ui->line_yaw->setText("");
_navState.yaw->clear();
}
if (nav.pitch.has_value()) {
ui->line_pitch->setText(QString::number(nav.pitch.value()));
_navState.pitch->setText(QString::number(*nav.pitch));
}
else {
ui->line_pitch->setText("");
_navState.pitch->clear();
}
tabSelect(0);
tabSelect(CameraTypeNav);
},
[&] (const openspace::Profile::CameraGoToGeo& geo) {
ui->tabWidget->setCurrentIndex(static_cast<int>(cameraTypeTab::Geo));
ui->line_anchorGeo->setText(QString(geo.anchor.c_str()));
ui->line_lat->setText(QString::number(geo.latitude));
ui->line_long->setText(QString::number(geo.longitude));
[this](const openspace::Profile::CameraGoToGeo& geo) {
_tabWidget->setCurrentIndex(CameraTypeGeo);
_geoState.anchor->setText(QString::fromStdString(geo.anchor));
_geoState.latitude->setText(QString::number(geo.latitude));
_geoState.longitude->setText(QString::number(geo.longitude));
if (geo.altitude.has_value()) {
ui->line_altitude->setText(QString::number(geo.altitude.value()));
_geoState.altitude->setText(QString::number(*geo.altitude));
}
else {
ui->line_altitude->setText("");
_geoState.altitude->clear();
}
tabSelect(1);
tabSelect(CameraTypeGeo);
}
}, _data);
}, type);
}
else {
ui->tabWidget->setCurrentIndex(static_cast<int>(cameraTypeTab::Nav));
ui->line_anchorNav->setText("");
ui->line_aim->setText("");
ui->line_referenceFrame->setText("");
ui->line_posX->setText("");
ui->line_posY->setText("");
ui->line_posZ->setText("");
ui->line_upX->setText("");
ui->line_upY->setText("");
ui->line_upZ->setText("");
ui->line_yaw->setText("");
ui->line_pitch->setText("");
ui->line_anchorGeo->setText("");
ui->line_lat->setText("");
ui->line_long->setText("");
ui->line_altitude->setText("");
_tabWidget->setCurrentIndex(CameraTypeNav);
_navState.anchor->clear();
_navState.aim->clear();
_navState.refFrame->clear();
_navState.positionX->clear();
_navState.positionY->clear();
_navState.positionZ->clear();
_navState.upX->clear();
_navState.upY->clear();
_navState.upZ->clear();
_navState.yaw->clear();
_navState.pitch->clear();
_geoState.anchor->clear();
_geoState.latitude->clear();
_geoState.longitude->clear();
_geoState.altitude->clear();
}
}
QWidget* Camera::createNavStateWidget() {
QWidget* box = new QWidget;
QGridLayout* layout = new QGridLayout(box);
layout->addWidget(new QLabel("Anchor:"), 0, 0);
_navState.anchor = new QLineEdit;
_navState.anchor->setToolTip("Anchor camera to this node");
layout->addWidget(_navState.anchor, 0, 1);
layout->addWidget(new QLabel("Aim:"), 1, 0);
_navState.aim = new QLineEdit;
_navState.aim->setToolTip(
"[OPTIONAL] If specified, camera will be aimed at this node while keeping the "
"anchor node in the same view location"
);
layout->addWidget(_navState.aim, 1, 1);
layout->addWidget(new QLabel("Reference Frame:"), 2, 0);
_navState.refFrame = new QLineEdit;
_navState.refFrame->setToolTip("[OPTIONAL] Camera location in reference to this frame");
layout->addWidget(_navState.refFrame, 2, 1);
layout->addWidget(new QLabel("Position:"), 3, 0);
{
QWidget* posBox = new QWidget;
QBoxLayout* posLayout = new QHBoxLayout(posBox);
posLayout->setContentsMargins(0, 0, 0, 0);
posLayout->addWidget(new QLabel("X"));
_navState.positionX = new QLineEdit;
_navState.positionX->setValidator(new QDoubleValidator);
_navState.positionX->setToolTip("Camera position vector (x)");
posLayout->addWidget(_navState.positionX);
posLayout->addWidget(new QLabel("Y"));
_navState.positionY = new QLineEdit;
_navState.positionY->setValidator(new QDoubleValidator);
_navState.positionY->setToolTip("Camera position vector (y)");
posLayout->addWidget(_navState.positionY);
posLayout->addWidget(new QLabel("Z"));
_navState.positionZ = new QLineEdit;
_navState.positionZ->setValidator(new QDoubleValidator);
_navState.positionZ->setToolTip("Camera position vector (z)");
posLayout->addWidget(_navState.positionZ);
layout->addWidget(posBox, 3, 1);
}
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(approved()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(cancel()));
connect(ui->tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(tabSelect(int)));
}
layout->addWidget(new QLabel("Up:"), 4, 0);
{
QWidget* upBox = new QWidget;
QBoxLayout* upLayout = new QHBoxLayout(upBox);
upLayout->setContentsMargins(0, 0, 0, 0);
upLayout->addWidget(new QLabel("X"));
_navState.upX = new QLineEdit;
_navState.upX->setValidator(new QDoubleValidator);
_navState.upX->setToolTip("[OPTIONAL] Camera up vector (x)");
upLayout->addWidget(_navState.upX);
bool camera::isNumericalValue(QLineEdit* le) {
QString s = le->text();
bool validConversion = false;
s.toDouble(&validConversion);
return validConversion;
}
upLayout->addWidget(new QLabel("Y"));
_navState.upY = new QLineEdit;
_navState.upY->setValidator(new QDoubleValidator);
_navState.upY->setToolTip("[OPTIONAL] Camera up vector (y)");
upLayout->addWidget(_navState.upY);
bool camera::inNumericalRange(QLineEdit* le, float min, float max) {
QString s = le->text();
bool validConversion = false;
float value = s.toFloat(&validConversion);
if (!validConversion) {
return false;
upLayout->addWidget(new QLabel("Z"));
_navState.upZ = new QLineEdit;
_navState.upZ->setValidator(new QDoubleValidator);
_navState.upZ->setToolTip("[OPTIONAL] Camera up vector (z)");
upLayout->addWidget(_navState.upZ);
layout->addWidget(upBox, 4, 1);
}
if (value < min || value > max) {
return false;
}
return true;
layout->addWidget(new QLabel("Yaw angle:"), 5, 0);
_navState.yaw = new QLineEdit;
_navState.yaw->setValidator(new QDoubleValidator);
_navState.yaw->setToolTip("[OPTIONAL] yaw angle +/- 360 degrees");
layout->addWidget(_navState.yaw, 5, 1);
layout->addWidget(new QLabel("Pitch angle:"), 6, 0);
_navState.pitch = new QLineEdit;
_navState.pitch->setValidator(new QDoubleValidator);
_navState.pitch->setToolTip("[OPTIONAL] pitch angle +/- 360 degrees");
layout->addWidget(_navState.pitch, 6, 1);
return box;
}
bool camera::isEmpty(QLineEdit* textLine) {
return (textLine->text().length() == 0);
QWidget* Camera::createGeoWidget() {
QWidget* box = new QWidget;
QGridLayout* layout = new QGridLayout(box);
layout->addWidget(new QLabel("Anchor:"), 0, 0);
_geoState.anchor = new QLineEdit;
_geoState.anchor->setToolTip("Anchor camera to this globe (planet/moon)");
layout->addWidget(_geoState.anchor, 0, 1);
layout->addWidget(new QLabel("Latitude"), 1, 0);
_geoState.latitude = new QLineEdit;
_geoState.latitude->setValidator(new QDoubleValidator);
_geoState.latitude->setToolTip("Latitude of camera focus point (+/- 90 degrees)");
layout->addWidget(_geoState.latitude, 1, 1);
layout->addWidget(new QLabel("Longitude"), 2, 0);
_geoState.longitude = new QLineEdit;
_geoState.longitude->setValidator(new QDoubleValidator);
_geoState.longitude->setToolTip("Longitude of camera focus point (+/- 180 degrees)");
layout->addWidget(_geoState.longitude, 2, 1);
layout->addWidget(new QLabel("Altitude"), 3, 0);
_geoState.altitude = new QLineEdit;
_geoState.altitude->setValidator(new QDoubleValidator);
_geoState.altitude->setToolTip("[OPTIONAL] Altitude of camera (meters)");
//altitude->setPlaceholderText("optional");
layout->addWidget(_geoState.altitude, 3, 1);
return box;
}
camera::~camera() {
delete ui;
}
void camera::cancel() {
}
bool camera::areRequiredFormsFilledAndValid() {
bool Camera::areRequiredFormsFilledAndValid() {
bool allFormsOk = true;
ui->label_error->setText("");
_errorMsg->clear();
if (ui->tabWidget->currentIndex() == static_cast<int>(cameraTypeTab::Nav)) {
if (isEmpty(ui->line_anchorNav)) {
if (_tabWidget->currentIndex() == CameraTypeNav) {
if (_navState.anchor->text().isEmpty()) {
allFormsOk = false;
addErrorMsg("Anchor is empty");
}
if (isEmpty(ui->line_posX)) {
if (_navState.positionX->text().isEmpty()) {
allFormsOk = false;
addErrorMsg("Position X is empty");
}
else if (!isNumericalValue(ui->line_posX)) {
allFormsOk = false;
addErrorMsg("Position X is not a number");
}
if (isEmpty(ui->line_posY)) {
if (_navState.positionY->text().isEmpty()) {
allFormsOk = false;
addErrorMsg("Position Y is empty");
}
else if (!isNumericalValue(ui->line_posY)) {
allFormsOk = false;
addErrorMsg("Position Y is not a number");
}
if (isEmpty(ui->line_posZ)) {
if (_navState.positionZ->text().isEmpty()) {
allFormsOk = false;
addErrorMsg("Position Z is empty");
}
else if (!isNumericalValue(ui->line_posZ)) {
allFormsOk = false;
addErrorMsg("Position Z is not a number");
}
int upVectorCount = 0;
if (!isEmpty(ui->line_upX)) {
upVectorCount++;
if (!isNumericalValue(ui->line_upX)) {
allFormsOk = false;
addErrorMsg("Up X is not a number");
}
}
if (!isEmpty(ui->line_upY)) {
upVectorCount++;
if (!isNumericalValue(ui->line_upY)) {
allFormsOk = false;
addErrorMsg("Up Y is not a number");
}
}
if (!isEmpty(ui->line_upZ)) {
upVectorCount++;
if (!isNumericalValue(ui->line_upZ)) {
allFormsOk = false;
addErrorMsg("Up Z is not a number");
}
}
if (!(upVectorCount == 0 || upVectorCount == 3)) {
if (_navState.upX->text().isEmpty()) {
allFormsOk = false;
addErrorMsg("Up vector is incomplete");
addErrorMsg("Up X is empty");
}
if (!isEmpty(ui->line_yaw)) {
if (!isNumericalValue(ui->line_yaw)) {
allFormsOk = false;
addErrorMsg("Yaw value is not a number");
}
else if (!inNumericalRange(ui->line_yaw, -360.0, 360.0)) {
if (_navState.upY->text().isEmpty()) {
allFormsOk = false;
addErrorMsg("Up Y is empty");
}
if (_navState.upZ->text().isEmpty()) {
allFormsOk = false;
addErrorMsg("Up Z is empty");
}
if (!_navState.yaw->text().isEmpty()) {
if (!inNumericalRange(_navState.yaw, -360.0, 360.0)) {
allFormsOk = false;
addErrorMsg("Yaw value is not in +/- 360.0 range");
}
}
if (!isEmpty(ui->line_pitch)) {
if (!isNumericalValue(ui->line_pitch)) {
allFormsOk = false;
addErrorMsg("Pitch value is not a number");
}
else if (!inNumericalRange(ui->line_pitch, -360.0, 360.0)) {
if (!_navState.pitch->text().isEmpty()) {
if (!inNumericalRange(_navState.pitch, -360.0, 360.0)) {
allFormsOk = false;
addErrorMsg("Pitch value is not in +/- 360.0 range");
}
}
}
if (ui->tabWidget->currentIndex() == static_cast<int>(cameraTypeTab::Geo)) {
if (isEmpty(ui->line_anchorGeo)) {
if (_tabWidget->currentIndex() == CameraTypeGeo) {
if (_geoState.anchor->text().isEmpty()) {
allFormsOk = false;
addErrorMsg("Anchor is empty");
}
if (!isNumericalValue(ui->line_lat)) {
allFormsOk = false;
addErrorMsg("Latitude value is not a number");
}
else if (!inNumericalRange(ui->line_lat, -90.0, 90.0)) {
if (!inNumericalRange(_geoState.latitude, -90.0, 90.0)) {
allFormsOk = false;
addErrorMsg("Latitude value is not in +/- 90.0 range");
}
if (!isNumericalValue(ui->line_long)) {
allFormsOk = false;
addErrorMsg("Longitude value is not a number");
}
else if (!inNumericalRange(ui->line_long, -180.0, 180.0)) {
if (!inNumericalRange(_geoState.longitude, -180.0, 180.0)) {
allFormsOk = false;
addErrorMsg("Longitude value is not in +/- 180.0 range");
}
if (!isEmpty(ui->line_altitude)) {
if (!isNumericalValue(ui->line_altitude)) {
allFormsOk = false;
addErrorMsg("Altitude value is not a number");
}
}
}
return allFormsOk;
}
void camera::addErrorMsg(const QString& errorDescription) {
QString contents = ui->label_error->text();
void Camera::addErrorMsg(QString errorDescription) {
QString contents = _errorMsg->text();
if (contents.length() > 0) {
contents += ", ";
}
contents += errorDescription;
ui->label_error->setText("<font color='red'>" + contents + "</font>");
_errorMsg->setText(contents);
}
void camera::setErrorTextFormat(QLabel* label, const QString& labelTxt,
bool setErrorFormat)
{
QString formatText = "<font color='";
formatText += (setErrorFormat) ? "red" : "black";
formatText += "'>";
formatText += labelTxt;
formatText += "</font>";
label->setText(formatText);
}
void camera::approved() {
if (areRequiredFormsFilledAndValid()) {
if (ui->tabWidget->currentIndex() == static_cast<int>(cameraTypeTab::Nav)) {
openspace::Profile::CameraNavState nav;
nav.anchor = ui->line_anchorNav->text().toUtf8().constData();
nav.aim = ui->line_aim->text().toUtf8().constData();
nav.referenceFrame = ui->line_referenceFrame->text().toUtf8().constData();
nav.position.x = ui->line_posX->text().toDouble();
nav.position.y = ui->line_posY->text().toDouble();
nav.position.z = ui->line_posZ->text().toDouble();
if (isUpVectorValid()) {
glm::dvec3 u = {
ui->line_upX->text().toDouble(),
ui->line_upY->text().toDouble(),
ui->line_upZ->text().toDouble()
};
nav.up = u;
}
else {
nav.up = std::nullopt;
}
if (ui->line_yaw->text().length() > 0) {
nav.yaw = ui->line_yaw->text().toDouble();
}
else {
nav.yaw = std::nullopt;
}
if (ui->line_pitch->text().length() > 0) {
nav.pitch = ui->line_pitch->text().toDouble();
}
else {
nav.pitch = std::nullopt;
}
_data = nav;
}
else if (ui->tabWidget->currentIndex() == static_cast<int>(cameraTypeTab::Geo)) {
openspace::Profile::CameraGoToGeo geo;
geo.anchor = ui->line_anchorGeo->text().toUtf8().constData();
geo.latitude = ui->line_lat->text().toDouble();
geo.longitude = ui->line_long->text().toDouble();
if (ui->line_altitude->text().length() > 0) {
geo.altitude = ui->line_altitude->text().toDouble();
}
_data = geo;
}
_imported->setCamera(_data);
accept();
void Camera::approved() {
if (!areRequiredFormsFilledAndValid()) {
return;
}
if (_tabWidget->currentIndex() == CameraTypeNav) {
openspace::Profile::CameraNavState nav;
nav.anchor = _navState.anchor->text().toUtf8().constData();
nav.aim = _navState.aim->text().toUtf8().constData();
nav.referenceFrame = _navState.refFrame->text().toUtf8().constData();
nav.position.x = _navState.positionX->text().toDouble();
nav.position.y = _navState.positionY->text().toDouble();
nav.position.z = _navState.positionZ->text().toDouble();
if (!_navState.upX->text().isEmpty() &&
!_navState.upY->text().isEmpty() &&
!_navState.upZ->text().isEmpty())
{
glm::dvec3 u = {
_navState.upX->text().toDouble(),
_navState.upY->text().toDouble(),
_navState.upZ->text().toDouble()
};
nav.up = u;
}
else {
nav.up = std::nullopt;
}
if (!_navState.yaw->text().isEmpty()) {
nav.yaw = _navState.yaw->text().toDouble();
}
else {
nav.yaw = std::nullopt;
}
if (!_navState.pitch->text().isEmpty()) {
nav.pitch = _navState.pitch->text().toDouble();
}
else {
nav.pitch = std::nullopt;
}
_profile->setCamera(nav);
}
else if (_tabWidget->currentIndex() == CameraTypeGeo) {
openspace::Profile::CameraGoToGeo geo;
geo.anchor = _geoState.anchor->text().toUtf8().constData();
geo.latitude = _geoState.latitude->text().toDouble();
geo.longitude = _geoState.longitude->text().toDouble();
if (!_geoState.altitude->text().isEmpty()) {
geo.altitude = _geoState.altitude->text().toDouble();
}
_profile->setCamera(geo);
}
accept();
}
bool camera::isUpVectorValid() {
return (isNumericalValue(ui->line_upX)
&& isNumericalValue(ui->line_upY)
&& isNumericalValue(ui->line_upZ));
}
void Camera::tabSelect(int tabIndex) {
_errorMsg->clear();
void camera::tabSelect(int tabIndex) {
ui->label_error->setText("");
if (tabIndex == 0) {
ui->line_anchorNav->setFocus(Qt::OtherFocusReason);
_navState.anchor->setFocus(Qt::OtherFocusReason);
}
else if (tabIndex == 1) {
ui->line_anchorGeo->setFocus(Qt::OtherFocusReason);
_geoState.anchor->setFocus(Qt::OtherFocusReason);
}
else {
throw std::logic_error("Unknown tab index");
}
}
void camera::keyPressEvent(QKeyEvent *evt)
{
QDialog::keyPressEvent(evt);
}

View File

@@ -211,7 +211,7 @@ void ProfileEdit::openAddedScripts() {
void ProfileEdit::openCamera() {
ui->label_error->setText("");
if (_pData) {
_camera = new camera(_pData);
_camera = new Camera(_pData, this);
_camera->exec();
delete _camera;
}