mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-26 06:49:09 -06:00
Updated layout of timeline application
Added userdefined instrument names Added button to set focus to next target
This commit is contained in:
@@ -25,22 +25,36 @@
|
||||
#include "configurationwidget.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
ConfigurationWidget::ConfigurationWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
: QGroupBox("Connection", parent)
|
||||
, _ipAddress(new QLineEdit("localhost"))
|
||||
, _port(new QLineEdit("20500"))
|
||||
, _connect(new QPushButton("Connect"))
|
||||
{
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
layout->addWidget(_ipAddress, 0, 0);
|
||||
layout->addWidget(_port, 0, 1);
|
||||
layout->addWidget(_connect, 0, 2);
|
||||
layout->setVerticalSpacing(0);
|
||||
{
|
||||
QLabel* t = new QLabel("IP Address");
|
||||
layout->addWidget(t, 0, 0);
|
||||
}
|
||||
layout->addWidget(_ipAddress, 1, 0);
|
||||
|
||||
{
|
||||
QLabel* t = new QLabel("Port");
|
||||
layout->addWidget(t, 0, 1);
|
||||
}
|
||||
layout->addWidget(_port, 1, 1);
|
||||
layout->addWidget(_connect, 1, 2, 1, 1);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
QObject::connect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton()));
|
||||
|
||||
QTimer::singleShot(100, this, SLOT(onConnectButton()));
|
||||
}
|
||||
|
||||
void ConfigurationWidget::onConnectButton() {
|
||||
@@ -48,7 +62,17 @@ void ConfigurationWidget::onConnectButton() {
|
||||
}
|
||||
|
||||
void ConfigurationWidget::socketConnected() {
|
||||
_ipAddress->setEnabled(false);
|
||||
_port->setEnabled(false);
|
||||
_connect->setText("Disconnect");
|
||||
QObject::disconnect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton()));
|
||||
QObject::connect(_connect, SIGNAL(clicked()), this, SIGNAL(disconnect()));
|
||||
}
|
||||
|
||||
void ConfigurationWidget::socketDisconnected() {
|
||||
_ipAddress->setEnabled(true);
|
||||
_port->setEnabled(true);
|
||||
_connect->setText("Connect");
|
||||
QObject::disconnect(_connect, SIGNAL(clicked()), this, SIGNAL(disconnect()));
|
||||
QObject::connect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton()));
|
||||
}
|
||||
|
||||
@@ -25,11 +25,12 @@
|
||||
#ifndef __CONFIGURATIONWIDGET_H__
|
||||
#define __CONFIGURATIONWIDGET_H__
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGroupBox>
|
||||
//#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
class ConfigurationWidget : public QWidget {
|
||||
class ConfigurationWidget : public QGroupBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigurationWidget(QWidget* parent);
|
||||
@@ -39,6 +40,7 @@ public:
|
||||
|
||||
signals:
|
||||
void connect(QString host, QString port);
|
||||
void disconnect();
|
||||
|
||||
private slots:
|
||||
void onConnectButton();
|
||||
|
||||
@@ -24,12 +24,16 @@
|
||||
|
||||
#include "controlwidget.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QSlider>
|
||||
#include <QDebug>
|
||||
|
||||
namespace {
|
||||
struct ImportantDate {
|
||||
@@ -39,6 +43,7 @@ namespace {
|
||||
};
|
||||
|
||||
const ImportantDate ImportantDates[] = {
|
||||
{ "", "", "" },
|
||||
{ "2007-02-27T16:40:00.00", "JupiterProjection", "Jupiter" },
|
||||
{ "2015-07-14T10:10:00.00", "PlutoProjection", "Pluto" },
|
||||
{ "2015-07-14T10:50:00.00", "PlutoProjection", "Pluto" },
|
||||
@@ -73,11 +78,10 @@ ControlWidget::ControlWidget(QWidget* parent)
|
||||
, _setTime(new QComboBox)
|
||||
, _currentDelta(new QLabel("Current Delta"))
|
||||
, _setDelta(new QSlider(Qt::Horizontal))
|
||||
, _rewind(new QPushButton("<<"))
|
||||
, _pause(new QPushButton("||"))
|
||||
, _play(new QPushButton("|>"))
|
||||
, _forward(new QPushButton(">>"))
|
||||
, _focusNode(new QComboBox)
|
||||
, _setFocusToNextTarget(new QPushButton("Set Focus to the next Target"))
|
||||
{
|
||||
for (const ImportantDate& d : ImportantDates)
|
||||
_setTime->addItem(d.date);
|
||||
@@ -107,13 +111,6 @@ ControlWidget::ControlWidget(QWidget* parent)
|
||||
SLOT(onValueChange())
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
_rewind,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(onRewindButton())
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
_pause,
|
||||
SIGNAL(clicked()),
|
||||
@@ -129,31 +126,68 @@ ControlWidget::ControlWidget(QWidget* parent)
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
_forward,
|
||||
_setFocusToNextTarget,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(onForwardButton())
|
||||
SLOT(onFocusToTargetButton())
|
||||
);
|
||||
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout;
|
||||
|
||||
layout->addWidget(_currentTime, 0, 0);
|
||||
layout->addWidget(_setTime, 0, 1);
|
||||
layout->addWidget(_currentDelta, 1, 0);
|
||||
layout->addWidget(_setDelta, 2, 0, 1, 2);
|
||||
{
|
||||
QGroupBox* box = new QGroupBox("Time", this);
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
|
||||
QWidget* controlContainer = new QWidget;
|
||||
QHBoxLayout* controlContainerLayout = new QHBoxLayout;
|
||||
controlContainerLayout->addWidget(_rewind);
|
||||
controlContainerLayout->addWidget(_pause);
|
||||
controlContainerLayout->addWidget(_play);
|
||||
controlContainerLayout->addWidget(_forward);
|
||||
controlContainer->setLayout(controlContainerLayout);
|
||||
layout->addWidget(controlContainer, 3, 0, 1, 2);
|
||||
//layout->setRowStretch(1, 5);
|
||||
box->setLayout(layout);
|
||||
|
||||
layout->addWidget(_focusNode, 4, 0, 1, 2);
|
||||
{
|
||||
QLabel* l = new QLabel("Current Time (UTC):");
|
||||
layout->addWidget(l, 0, 0, Qt::AlignLeft);
|
||||
layout->addWidget(_currentTime, 0, 1, Qt::AlignRight);
|
||||
}
|
||||
{
|
||||
QLabel* l = new QLabel("Bookmarks:");
|
||||
layout->addWidget(l, 1, 0, Qt::AlignLeft);
|
||||
layout->addWidget(_setTime, 1, 1, Qt::AlignRight);
|
||||
}
|
||||
layout->addItem(new QSpacerItem(0, 7), 2, 0, 1, 2);
|
||||
{
|
||||
QLabel* l = new QLabel("Current Time Increment (seconds per second):");
|
||||
layout->addWidget(l, 3, 0, Qt::AlignLeft);
|
||||
layout->addWidget(_currentDelta, 3, 1, Qt::AlignRight);
|
||||
}
|
||||
|
||||
setLayout(layout);
|
||||
layout->addWidget(_setDelta, 4, 0, 1, 2);
|
||||
|
||||
|
||||
QWidget* controlContainer = new QWidget;
|
||||
QHBoxLayout* controlContainerLayout = new QHBoxLayout;
|
||||
controlContainerLayout->addWidget(_pause);
|
||||
controlContainerLayout->addWidget(_play);
|
||||
controlContainer->setLayout(controlContainerLayout);
|
||||
layout->addWidget(controlContainer, 5, 0, 1, 2);
|
||||
|
||||
mainLayout->addWidget(box);
|
||||
}
|
||||
|
||||
{
|
||||
QGroupBox* box = new QGroupBox("Focus");
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
box->setLayout(layout);
|
||||
|
||||
{
|
||||
QLabel* l = new QLabel("Set Focus:");
|
||||
layout->addWidget(l, 0, 0, Qt::AlignLeft);
|
||||
_focusNode->setMinimumWidth(200);
|
||||
layout->addWidget(_focusNode, 0, 1, Qt::AlignRight);
|
||||
}
|
||||
layout->addWidget(_setFocusToNextTarget, 1, 0, 1, 2);
|
||||
|
||||
mainLayout->addWidget(box);
|
||||
}
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void ControlWidget::update(QString currentTime, QString currentDelta) {
|
||||
@@ -179,11 +213,6 @@ void ControlWidget::onValueChange() {
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
|
||||
void ControlWidget::onRewindButton() {
|
||||
QString script = "openspace.time.setDeltaTime(-openspace.time.deltaTime());";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
|
||||
void ControlWidget::onPauseButton() {
|
||||
QString script = "openspace.time.setPause(true);";
|
||||
emit scriptActivity(script);
|
||||
@@ -194,22 +223,18 @@ void ControlWidget::onPlayButton() {
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
|
||||
void ControlWidget::onForwardButton() {
|
||||
QString script = "openspace.time.setDeltaTime(-openspace.time.deltaTime());";
|
||||
emit scriptActivity(script);
|
||||
|
||||
}
|
||||
|
||||
void ControlWidget::onDateChange() {
|
||||
int index = _setTime->currentIndex();
|
||||
QString date = ImportantDates[index].date;
|
||||
QString focus = ImportantDates[index].focus;
|
||||
QString coordinateSystem = ImportantDates[index].coordinateSystem;
|
||||
QString script =
|
||||
"openspace.time.setTime('" + date + "');\
|
||||
openspace.setOrigin('" + focus + "');\
|
||||
openspace.changeCoordinateSystem('" + coordinateSystem + "');";
|
||||
emit scriptActivity(script);
|
||||
if (index != 0) {
|
||||
QString date = ImportantDates[index].date;
|
||||
QString focus = ImportantDates[index].focus;
|
||||
QString coordinateSystem = ImportantDates[index].coordinateSystem;
|
||||
QString script =
|
||||
"openspace.time.setTime('" + date + "');\
|
||||
openspace.setOrigin('" + focus + "');\
|
||||
openspace.changeCoordinateSystem('" + coordinateSystem + "');";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlWidget::onFocusChange() {
|
||||
@@ -230,6 +255,19 @@ void ControlWidget::onFocusChange() {
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
|
||||
void ControlWidget::onFocusToTargetButton() {
|
||||
std::string target = reinterpret_cast<MainWindow*>(parent())->nextTarget();
|
||||
if (!target.empty()) {
|
||||
auto it = std::find_if(std::begin(FocusNodes), std::end(FocusNodes), [target](const FocusNode& n) { return n.guiName.toLower() == QString::fromStdString(target).toLower(); });
|
||||
if (it != std::end(FocusNodes)) {
|
||||
QString name = it->name;
|
||||
QString coordinateSystem = it->coordinateSystem;
|
||||
QString script = "openspace.setOrigin('" + name + "');openspace.changeCoordinateSystem('" + coordinateSystem + "');";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ControlWidget::socketConnected() {
|
||||
setDisabled(false);
|
||||
}
|
||||
@@ -237,3 +275,4 @@ void ControlWidget::socketConnected() {
|
||||
void ControlWidget::socketDisconnected() {
|
||||
setDisabled(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,21 +49,19 @@ private slots:
|
||||
void onValueChange();
|
||||
void onDateChange();
|
||||
void onFocusChange();
|
||||
void onRewindButton();
|
||||
void onPauseButton();
|
||||
void onPlayButton();
|
||||
void onForwardButton();
|
||||
void onFocusToTargetButton();
|
||||
|
||||
private:
|
||||
QLabel* _currentTime;
|
||||
QComboBox* _setTime;
|
||||
QLabel* _currentDelta;
|
||||
QSlider* _setDelta;
|
||||
QPushButton* _rewind;
|
||||
QPushButton* _pause;
|
||||
QPushButton* _play;
|
||||
QPushButton* _forward;
|
||||
QComboBox* _focusNode;
|
||||
QPushButton* _setFocusToNextTarget;
|
||||
};
|
||||
|
||||
#endif // __CONTROLWIDGET_H__
|
||||
|
||||
@@ -84,6 +84,10 @@ MainWindow::MainWindow()
|
||||
_configurationWidget, SIGNAL(connect(QString, QString)),
|
||||
this, SLOT(onConnect(QString, QString))
|
||||
);
|
||||
QObject::connect(
|
||||
_configurationWidget, SIGNAL(disconnect()),
|
||||
this, SLOT(onDisconnect())
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
_timeControlWidget, SIGNAL(scriptActivity(QString)),
|
||||
@@ -113,6 +117,10 @@ void MainWindow::onConnect(QString host, QString port) {
|
||||
_socket->connectToHost(host, port.toUInt());
|
||||
}
|
||||
|
||||
void MainWindow::onDisconnect() {
|
||||
delete _socket;
|
||||
_socket = nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::readTcpData() {
|
||||
static const uint16_t MessageTypeStatus = 0;
|
||||
@@ -268,3 +276,7 @@ void MainWindow::onSocketDisconnected() {
|
||||
_timelineWidget->socketDisconnected();
|
||||
}
|
||||
|
||||
std::string MainWindow::nextTarget() const {
|
||||
return _timelineWidget->nextTarget();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,14 @@ public:
|
||||
MainWindow();
|
||||
~MainWindow();
|
||||
|
||||
std::string nextTarget() const;
|
||||
|
||||
public slots:
|
||||
void sendScript(QString script);
|
||||
|
||||
private slots:
|
||||
void onConnect(QString host, QString port);
|
||||
void onDisconnect();
|
||||
|
||||
void onSocketConnected();
|
||||
void onSocketDisconnected();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "timelinewidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMap>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
|
||||
@@ -37,15 +38,6 @@ namespace {
|
||||
|
||||
static const int TextOffset = 5;
|
||||
|
||||
//const QColor targetColors[] = {
|
||||
// QColor(251, 180, 174),
|
||||
// QColor(179, 205, 227),
|
||||
// QColor(204, 235, 197),
|
||||
// QColor(222, 203, 228),
|
||||
// QColor(254, 217, 166),
|
||||
// QColor(255, 255, 204)
|
||||
//};
|
||||
|
||||
const QColor instrumentColors[] = {
|
||||
QColor(228, 26, 28),
|
||||
QColor(55, 126, 184),
|
||||
@@ -58,6 +50,20 @@ namespace {
|
||||
QColor(153, 153, 153),
|
||||
};
|
||||
|
||||
QMap<QString, QString> InstrumentConversion = {
|
||||
{ "NH_ALICE_AIRGLOW", "ALICE Airglow" },
|
||||
{ "NH_RALPH_LEISA", "RALPH LEISA" },
|
||||
{ "NH_RALPH_MVIC_NIR", "RALPH MVIC NIR" },
|
||||
{ "NH_ALICE_SOC", "ALICE SOC" },
|
||||
{ "NH_RALPH_MVIC_BLUE", "RALPH MVIC Blue" },
|
||||
{ "NH_RALPH_MVIC_PAN1" , "RALPH MVIC Pan1" },
|
||||
{ "NH_LORRI", "LORRI" },
|
||||
{ "NH_RALPH_MVIC_FT", "RALPH MVIC FT" },
|
||||
{ "NH_RALPH_MVIC_PAN2", "RALPH MVIC Pan2" },
|
||||
{ "NH_RALPH_MVIC_METHANE", "RALPH MVIC Methane" },
|
||||
{ "NH_RALPH_MVIC_RED", "RALPH MVIC Red" }
|
||||
};
|
||||
|
||||
const double etSpread = 100.0;
|
||||
}
|
||||
|
||||
@@ -180,7 +186,7 @@ void TimelineWidget::drawLegend(QPainter& painter, QRectF rect) {
|
||||
currentHorizontalPosition += BoxSize + Padding;
|
||||
|
||||
painter.setPen(QPen(Qt::black));
|
||||
painter.drawText(currentHorizontalPosition, currentVerticalPosition + BoxSize / 2 + TextOffset, QString::fromStdString(instrument));
|
||||
painter.drawText(currentHorizontalPosition, currentVerticalPosition + BoxSize / 2 + TextOffset, InstrumentConversion[QString::fromStdString(instrument)]);
|
||||
int textWidth = painter.boundingRect(QRect(), QString::fromStdString(instrument)).width();
|
||||
currentHorizontalPosition += std::max(textWidth, 25) + Padding;
|
||||
}
|
||||
@@ -258,3 +264,16 @@ void TimelineWidget::socketDisconnected() {
|
||||
_instruments.clear();
|
||||
_targets.clear();
|
||||
}
|
||||
|
||||
std::string TimelineWidget::nextTarget() const {
|
||||
auto it = std::lower_bound(_images.begin(), _images.end(), _currentTime.et, [](const Image& i, double et) { return i.beginning < et; });
|
||||
if (it != _images.end())
|
||||
return it->target;
|
||||
else
|
||||
return "";
|
||||
//for (const Image& i : _images) {
|
||||
// double imageTime = i.beginning;
|
||||
// double currentTime = _currentTime.et;
|
||||
// if ()
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
void socketConnected();
|
||||
void socketDisconnected();
|
||||
|
||||
std::string nextTarget() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event);
|
||||
void drawContent(QPainter& painter, QRectF rect);
|
||||
|
||||
Reference in New Issue
Block a user