mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-13 17:09:05 -05:00
Merge branch 'feature/timelinegui' into develop
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) {
|
||||
@@ -164,23 +198,18 @@ void ControlWidget::update(QString currentTime, QString currentDelta) {
|
||||
void ControlWidget::onValueChange() {
|
||||
float value = static_cast<float>(_setDelta->value());
|
||||
|
||||
int delta;
|
||||
float delta;
|
||||
if (value < 0.f) {
|
||||
value = -value;
|
||||
float d = std::pow(2, value / 10);
|
||||
delta = static_cast<int>(-d);
|
||||
float d = std::pow(2, value / 10) - 1.f;
|
||||
delta = -d;
|
||||
}
|
||||
else {
|
||||
float d = std::pow(2, value / 10);
|
||||
delta = static_cast<int>(d);
|
||||
float d = std::pow(2, value / 10) - 1.f;
|
||||
delta = d;
|
||||
}
|
||||
|
||||
QString script = "openspace.time.setDeltaTime(" + QString::number(delta) + ");";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
|
||||
void ControlWidget::onRewindButton() {
|
||||
QString script = "openspace.time.setDeltaTime(-openspace.time.deltaTime());";
|
||||
QString script = "openspace.time.setDeltaTime(" + QString::number(delta) + ");";
|
||||
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__
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
InformationWidget::InformationWidget(QWidget* parent)
|
||||
: QTextEdit(parent)
|
||||
{
|
||||
setReadOnly(true);
|
||||
}
|
||||
|
||||
void InformationWidget::socketConnected() {
|
||||
@@ -39,3 +40,11 @@ void InformationWidget::socketConnected() {
|
||||
void InformationWidget::socketDisconnected() {
|
||||
setDisabled(true);
|
||||
}
|
||||
|
||||
void InformationWidget::logInformation(QString text) {
|
||||
QString currentText = toPlainText();
|
||||
|
||||
currentText += text + "\n";
|
||||
|
||||
setPlainText(currentText);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ public:
|
||||
InformationWidget(QWidget* parent);
|
||||
void socketConnected();
|
||||
void socketDisconnected();
|
||||
|
||||
public slots:
|
||||
void logInformation(QString text);
|
||||
};
|
||||
|
||||
#endif // __INFORMATIONWIDGET_H__
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QThread>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
@@ -84,6 +85,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,10 +118,15 @@ 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;
|
||||
static const uint16_t MessageTypePlayBook = 2;
|
||||
static const uint16_t MessageTypePlayBookHongKang = 2;
|
||||
static const uint16_t MessageTypePlayBookLabel = 3;
|
||||
|
||||
QByteArray data = _socket->readAll();
|
||||
|
||||
@@ -139,7 +149,8 @@ void MainWindow::readTcpData() {
|
||||
case MessageTypeStatus:
|
||||
handleStatusMessage(data.mid(2));
|
||||
break;
|
||||
case MessageTypePlayBook:
|
||||
case MessageTypePlayBookHongKang:
|
||||
case MessageTypePlayBookLabel:
|
||||
{
|
||||
const char* payloadDebug = data.mid(2).data();
|
||||
|
||||
@@ -147,15 +158,26 @@ void MainWindow::readTcpData() {
|
||||
uint32_t size = readFromBuffer<uint32_t>(data.mid(2).data(), beginning);
|
||||
|
||||
while (_socket->waitForReadyRead() && data.size() < size) {
|
||||
//while (data.size() < size) {
|
||||
data = data.append(_socket->readAll());
|
||||
QThread::msleep(50);
|
||||
}
|
||||
handlePlaybook(data.mid(2));
|
||||
|
||||
if (messageType.value == MessageTypePlayBookHongKang)
|
||||
_hasHongKangTimeline = true;
|
||||
if (messageType.value == MessageTypePlayBookLabel)
|
||||
_hasLabelTimeline = true;
|
||||
|
||||
if (_hasHongKangTimeline && _hasLabelTimeline) {
|
||||
fullyConnected();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qDebug() << "Unknown message of type '" << messageType.value << "'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::handleStatusMessage(QByteArray data) {
|
||||
@@ -244,10 +266,6 @@ void MainWindow::handlePlaybook(QByteArray data) {
|
||||
|
||||
_timelineWidget->setData(std::move(images), std::move(targetMap), std::move(instrumentMap));
|
||||
|
||||
_configurationWidget->socketConnected();
|
||||
_timeControlWidget->socketConnected();
|
||||
_informationWidget->socketConnected();
|
||||
_timelineWidget->socketConnected();
|
||||
}
|
||||
|
||||
void MainWindow::sendScript(QString script) {
|
||||
@@ -257,6 +275,7 @@ void MainWindow::sendScript(QString script) {
|
||||
|
||||
void MainWindow::onSocketConnected() {
|
||||
_socket->write(QString("1\r\n").toLatin1());
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::onSocketDisconnected() {
|
||||
@@ -264,5 +283,19 @@ void MainWindow::onSocketDisconnected() {
|
||||
_timeControlWidget->socketDisconnected();
|
||||
_informationWidget->socketDisconnected();
|
||||
_timelineWidget->socketDisconnected();
|
||||
|
||||
_informationWidget->logInformation("Disconnected.");
|
||||
}
|
||||
|
||||
std::string MainWindow::nextTarget() const {
|
||||
return _timelineWidget->nextTarget();
|
||||
}
|
||||
|
||||
void MainWindow::fullyConnected() {
|
||||
_informationWidget->logInformation("Connected to " + _socket->peerName() + " on port " + QString::number(_socket->peerPort()) + ".");
|
||||
|
||||
_configurationWidget->socketConnected();
|
||||
_timeControlWidget->socketConnected();
|
||||
_informationWidget->socketConnected();
|
||||
_timelineWidget->socketConnected();
|
||||
}
|
||||
|
||||
@@ -41,21 +41,24 @@ 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();
|
||||
|
||||
//void onConnectButton();
|
||||
//void sendCommandButton();
|
||||
void readTcpData();
|
||||
void handleStatusMessage(QByteArray data);
|
||||
void handlePlaybook(QByteArray data);
|
||||
|
||||
void fullyConnected();
|
||||
|
||||
private:
|
||||
ConfigurationWidget* _configurationWidget;
|
||||
ControlWidget* _timeControlWidget;
|
||||
@@ -63,6 +66,9 @@ private:
|
||||
TimelineWidget* _timelineWidget;
|
||||
|
||||
QTcpSocket* _socket;
|
||||
|
||||
bool _hasHongKangTimeline = false;
|
||||
bool _hasLabelTimeline = false;
|
||||
};
|
||||
|
||||
#endif // __MAINWINDOW_H__
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "timelinewidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMap>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
|
||||
@@ -37,25 +38,55 @@ 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),
|
||||
QColor(77, 175, 74),
|
||||
QColor(152, 78, 163),
|
||||
QColor(255, 127, 0),
|
||||
QColor(255, 255, 51),
|
||||
QColor(166, 86, 40),
|
||||
QColor(247, 129, 191),
|
||||
QColor(153, 153, 153),
|
||||
QColor(242, 101, 74),
|
||||
QColor(175, 18, 18),
|
||||
QColor(211, 154, 31),
|
||||
QColor(241, 231, 48),
|
||||
QColor(149, 219, 32),
|
||||
QColor(49, 234, 219),
|
||||
QColor(49, 155, 234),
|
||||
QColor(139, 86, 152),
|
||||
QColor(84, 79, 149),
|
||||
QColor(203, 153, 200),
|
||||
QColor(82, 145, 57)
|
||||
|
||||
//QColor(166, 206, 227),
|
||||
//QColor(31, 120, 180),
|
||||
//QColor(178, 223, 138),
|
||||
//QColor(51, 160, 44),
|
||||
//QColor(251, 154, 153),
|
||||
//QColor(227, 26, 28),
|
||||
//QColor(253, 191, 111),
|
||||
//QColor(255, 127, 0),
|
||||
//QColor(202, 178, 214),
|
||||
//QColor(106, 61, 154),
|
||||
//QColor(255, 255, 153),
|
||||
|
||||
|
||||
//QColor(228, 26, 28),
|
||||
//QColor(55, 126, 184),
|
||||
//QColor(77, 175, 74),
|
||||
//QColor(152, 78, 163),
|
||||
//QColor(255, 127, 0),
|
||||
//QColor(255, 255, 51),
|
||||
//QColor(166, 86, 40),
|
||||
//QColor(247, 129, 191),
|
||||
//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;
|
||||
@@ -86,12 +117,12 @@ void TimelineWidget::paintEvent(QPaintEvent* event) {
|
||||
}
|
||||
|
||||
void TimelineWidget::setData(std::vector<Image> images, std::map<uint8_t, std::string> targetMap, std::map<uint16_t, std::string> instrumentMap) {
|
||||
_images = std::move(images);
|
||||
_images.insert(_images.end(), images.begin(), images.end());
|
||||
|
||||
std::sort(_images.begin(), _images.end(), [](const Image& a, const Image& b) { return a.beginning < b.beginning; });
|
||||
|
||||
_targetMap = std::move(targetMap);
|
||||
_instrumentMap = std::move(instrumentMap);
|
||||
_targetMap.insert(targetMap.begin(), targetMap.end());
|
||||
_instrumentMap.insert(instrumentMap.begin(), instrumentMap.end());
|
||||
|
||||
_instruments.clear();
|
||||
std::set<std::string> instruments;
|
||||
@@ -180,7 +211,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 +289,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);
|
||||
|
||||
@@ -22,48 +22,52 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
|
||||
#ifndef __SEQUENCEPARSER_H__
|
||||
#define __SEQUENCEPARSER_H__
|
||||
#include <openspace/util/decoder.h>
|
||||
|
||||
#include <openspace/network/networkengine.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
struct Image{
|
||||
double startTime;
|
||||
double stopTime;
|
||||
std::string path;
|
||||
std::vector<std::string> activeInstruments;
|
||||
std::string target;
|
||||
bool projected;
|
||||
};
|
||||
struct TimeRange{
|
||||
TimeRange() : _min(-1), _max(-1){};
|
||||
void setRange(double val){
|
||||
if (_min > val) _min = val;
|
||||
if (_max < val) _max = val;
|
||||
};
|
||||
bool inRange(double min, double max){
|
||||
return (min >= _min && max <= _max);
|
||||
}
|
||||
bool inRange(double val){
|
||||
return (val >= _min && val <= _max);
|
||||
}
|
||||
double _min;
|
||||
double _max;
|
||||
};
|
||||
struct ImageSubset{
|
||||
TimeRange _range;
|
||||
std::vector < Image > _subset;
|
||||
};
|
||||
|
||||
class Decoder;
|
||||
|
||||
struct Image {
|
||||
double startTime;
|
||||
double stopTime;
|
||||
std::string path;
|
||||
std::vector<std::string> activeInstruments;
|
||||
std::string target;
|
||||
bool projected;
|
||||
};
|
||||
|
||||
struct TimeRange {
|
||||
TimeRange() : _min(-1), _max(-1){};
|
||||
void setRange(double val){
|
||||
if (_min > val) _min = val;
|
||||
if (_max < val) _max = val;
|
||||
};
|
||||
bool inRange(double min, double max){
|
||||
return (min >= _min && max <= _max);
|
||||
}
|
||||
bool inRange(double val){
|
||||
return (val >= _min && val <= _max);
|
||||
}
|
||||
double _min;
|
||||
double _max;
|
||||
};
|
||||
|
||||
struct ImageSubset {
|
||||
TimeRange _range;
|
||||
std::vector<Image> _subset;
|
||||
};
|
||||
|
||||
class SequenceParser {
|
||||
public:
|
||||
virtual void create() = 0;
|
||||
virtual void create() = 0;
|
||||
virtual std::map<std::string, ImageSubset> getSubsetMap() final;
|
||||
virtual std::vector<std::pair<std::string, TimeRange>> getIstrumentTimes() final;
|
||||
virtual std::vector<std::pair<double, std::string>> getTargetTimes() final;
|
||||
@@ -71,13 +75,16 @@ public:
|
||||
virtual std::vector<double> getCaptureProgression() final;
|
||||
|
||||
protected:
|
||||
void sendPlaybookInformation();
|
||||
void sendPlaybookInformation(const std::string& name);
|
||||
|
||||
std::map<std::string, ImageSubset> _subsetMap;
|
||||
std::vector<std::pair<std::string, TimeRange>> _instrumentTimes;
|
||||
std::vector<std::pair<double, std::string>> _targetTimes;
|
||||
std::vector<double> _captureProgression;
|
||||
|
||||
NetworkEngine::MessageIdentifier _messageIdentifier;
|
||||
};
|
||||
}
|
||||
#endif //__SEQUENCEPARSER_H__
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif //__SEQUENCEPARSER_H__
|
||||
|
||||
@@ -31,7 +31,7 @@ return {
|
||||
LogLevel = "Debug",
|
||||
ImmediateFlush = true,
|
||||
Logs = {
|
||||
-- { Type = "HTML", FileName = "${BASE_PATH}/log.html", Append = false }
|
||||
{ Type = "HTML", FileName = "${BASE_PATH}/log.html", Append = false }
|
||||
}
|
||||
},
|
||||
LuaDocumentationFile = {
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace {
|
||||
const std::string _loggerCat = "HongKangParser";
|
||||
const std::string keyTranslation = "DataInputTranslation";
|
||||
|
||||
const std::string PlaybookIdentifierName = "Playbook";
|
||||
const std::string PlaybookIdentifierName = "HongKang";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -251,7 +251,7 @@ void HongKangParser::create(){
|
||||
}
|
||||
}
|
||||
|
||||
sendPlaybookInformation();
|
||||
sendPlaybookInformation(PlaybookIdentifierName);
|
||||
|
||||
//std::ofstream myfile;
|
||||
//myfile.open("HongKangOutput.txt");
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <ghoul/filesystem/directory.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <ghoul/filesystem/cachemanager.h>
|
||||
#include <openspace/util/decoder.h>
|
||||
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <fstream>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <ghoul/filesystem/directory.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/decoder.h>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <iomanip>
|
||||
@@ -38,6 +39,8 @@ namespace {
|
||||
const std::string _loggerCat = "LabelParser";
|
||||
const std::string keySpecs = "Read";
|
||||
const std::string keyConvert = "Convert";
|
||||
|
||||
const std::string PlaybookIdentifierName = "LabelParser";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -272,6 +275,7 @@ void LabelParser::create(){
|
||||
}
|
||||
//myfile.close();
|
||||
|
||||
sendPlaybookInformation(PlaybookIdentifierName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#include <openspace/util/sequenceparser.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/network/networkengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/decoder.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SequenceParser";
|
||||
@@ -73,8 +73,9 @@ void writeToBuffer<std::string>(std::vector<char>& buffer, size_t& currentWriteL
|
||||
currentWriteLocation += length;
|
||||
}
|
||||
|
||||
void SequenceParser::sendPlaybookInformation() {
|
||||
static const NetworkEngine::MessageIdentifier PlaybookIdentifier = OsEng.networkEngine()->identifier(PlaybookIdentifierName);
|
||||
void SequenceParser::sendPlaybookInformation(const std::string& name) {
|
||||
std::string fullName = PlaybookIdentifierName + "_" + name;
|
||||
_messageIdentifier = OsEng.networkEngine()->identifier(fullName);
|
||||
|
||||
std::vector<char> buffer(1024);
|
||||
size_t currentWriteLocation = 0;
|
||||
@@ -164,7 +165,7 @@ void SequenceParser::sendPlaybookInformation() {
|
||||
buffer.resize(currentWriteLocation);
|
||||
|
||||
//OsEng.networkEngine()->publishMessage(PlaybookIdentifier, buffer);
|
||||
OsEng.networkEngine()->setInitialConnectionMessage(PlaybookIdentifier, buffer);
|
||||
OsEng.networkEngine()->setInitialConnectionMessage(_messageIdentifier, buffer);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user