mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 09:59:44 -05:00
Merge branch 'develop' into trailmods
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
add_subdirectory(luascriptexternalcontrol)
|
||||
add_subdirectory(timelineview)
|
||||
@@ -1,10 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
project(LuascriptExternalControl)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
find_package(Qt5Widgets)
|
||||
find_package(Qt5Network)
|
||||
add_executable(LuascriptExternalControl WIN32 main.cpp mainwindow.cpp)
|
||||
target_link_libraries(LuascriptExternalControl Qt5::Widgets Qt5::Network)
|
||||
@@ -1,35 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
MainWidget window;
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
|
||||
MainWidget::MainWidget()
|
||||
: _ipAddress(new QLineEdit)
|
||||
, _command(new QLineEdit)
|
||||
, _logWindow(new QTextEdit)
|
||||
, _socket(nullptr)
|
||||
{
|
||||
setWindowTitle("OpenSpace LuaScripting GUI");
|
||||
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
_ipAddress->setMinimumWidth(200);
|
||||
_ipAddress->setText("127.0.0.1");
|
||||
layout->addWidget(_ipAddress, 0, 0);
|
||||
|
||||
QPushButton* connectButton = new QPushButton("Connect");
|
||||
connect(connectButton, SIGNAL(clicked()), this, SLOT(onConnectButton()));
|
||||
connectButton->show();
|
||||
layout->addWidget(connectButton, 0, 1);
|
||||
|
||||
_command->setMinimumWidth(200);
|
||||
layout->addWidget(_command, 1, 0);
|
||||
|
||||
QPushButton* sendButton = new QPushButton("Send");
|
||||
sendButton->setDefault(true);
|
||||
connect(sendButton, SIGNAL(clicked()), this, SLOT(sendCommandButton()));
|
||||
layout->addWidget(sendButton, 1, 1);
|
||||
|
||||
layout->addWidget(_logWindow, 2, 0, 1, 2);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
MainWidget::~MainWidget() {
|
||||
delete _command;
|
||||
delete _socket;
|
||||
}
|
||||
|
||||
void MainWidget::readTcpData() {
|
||||
QByteArray data = _socket->readAll();
|
||||
|
||||
if (_logWindow->toPlainText().isEmpty())
|
||||
_logWindow->setText(data.data());
|
||||
else
|
||||
_logWindow->setText(_logWindow->toPlainText() + "\n" + data.data());
|
||||
}
|
||||
|
||||
void MainWidget::onConnectButton() {
|
||||
delete _socket;
|
||||
|
||||
_socket = new QTcpSocket(this);
|
||||
connect( _socket, SIGNAL(readyRead()), SLOT(readTcpData()) );
|
||||
_socket->connectToHost(_ipAddress->text(), 20500);
|
||||
|
||||
}
|
||||
|
||||
void MainWidget::sendCommandButton() {
|
||||
if (!_socket) {
|
||||
if (_logWindow->toPlainText().isEmpty())
|
||||
_logWindow->setText("No connection found");
|
||||
else
|
||||
_logWindow->setText(_logWindow->toPlainText() + "\n" + "No connection found");
|
||||
return;
|
||||
}
|
||||
|
||||
QString command = _command->text();
|
||||
|
||||
if (_logWindow->toPlainText().isEmpty())
|
||||
_logWindow->setText(command);
|
||||
else
|
||||
_logWindow->setText(_logWindow->toPlainText() + "\n" + command);
|
||||
|
||||
|
||||
_socket->write(("0" + command + "\r\n").toLatin1());
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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 __MAINWINDOW_H__
|
||||
#define __MAINWINDOW_H__
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QTcpSocket>
|
||||
#include <QTextEdit>
|
||||
|
||||
class MainWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWidget();
|
||||
~MainWidget();
|
||||
|
||||
private slots:
|
||||
void onConnectButton();
|
||||
void sendCommandButton();
|
||||
void readTcpData();
|
||||
|
||||
private:
|
||||
QLineEdit* _ipAddress;
|
||||
QLineEdit* _command;
|
||||
QTextEdit* _logWindow;
|
||||
|
||||
QTcpSocket* _socket;
|
||||
|
||||
|
||||
//
|
||||
//private slots:
|
||||
// void on__connectButton_clicked();
|
||||
// void on__statsCheckBox_toggled(bool checked);
|
||||
// void readTcpData();
|
||||
// void on__graphCheckBox_toggled(bool checked);
|
||||
// void on__renderComboBox_currentIndexChanged(const QString &arg1);
|
||||
//
|
||||
//private:
|
||||
// qint64 sendToSGCT(QByteArray data);
|
||||
//
|
||||
// Ui::MainWindow *ui;
|
||||
// QTcpSocket* _sgctSocket;
|
||||
};
|
||||
|
||||
#endif // __MAINWINDOW_H__
|
||||
@@ -7,4 +7,5 @@ set(CMAKE_AUTOMOC ON)
|
||||
find_package(Qt5Widgets)
|
||||
find_package(Qt5Network)
|
||||
add_executable(TimelineView main.cpp mainwindow.cpp configurationwidget.cpp informationwidget.cpp controlwidget.cpp timelinewidget.cpp)
|
||||
#add_executable(TimelineView WIN32 main.cpp mainwindow.cpp configurationwidget.cpp informationwidget.cpp controlwidget.cpp timelinewidget.cpp)
|
||||
target_link_libraries(TimelineView Qt5::Widgets Qt5::Network)
|
||||
@@ -25,6 +25,9 @@
|
||||
#include "configurationwidget.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
|
||||
ConfigurationWidget::ConfigurationWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@@ -32,15 +35,34 @@ ConfigurationWidget::ConfigurationWidget(QWidget* parent)
|
||||
, _port(new QLineEdit("20500"))
|
||||
, _connect(new QPushButton("Connect"))
|
||||
{
|
||||
_connect->setObjectName("connection");
|
||||
QGroupBox* box = new QGroupBox("Connection", this);
|
||||
|
||||
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");
|
||||
t->setObjectName("label");
|
||||
layout->addWidget(t, 0, 0);
|
||||
}
|
||||
layout->addWidget(_ipAddress, 1, 0);
|
||||
|
||||
setLayout(layout);
|
||||
{
|
||||
QLabel* t = new QLabel("Port");
|
||||
t->setObjectName("label");
|
||||
layout->addWidget(t, 0, 1);
|
||||
}
|
||||
layout->addWidget(_port, 1, 1);
|
||||
layout->addWidget(_connect, 1, 2, 1, 1);
|
||||
|
||||
box->setLayout(layout);
|
||||
|
||||
QHBoxLayout* l = new QHBoxLayout;
|
||||
l->addWidget(box);
|
||||
setLayout(l);
|
||||
QObject::connect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton()));
|
||||
|
||||
QTimer::singleShot(100, this, SLOT(onConnectButton()));
|
||||
}
|
||||
|
||||
void ConfigurationWidget::onConnectButton() {
|
||||
@@ -48,7 +70,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()));
|
||||
}
|
||||
|
||||
@@ -39,6 +39,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" },
|
||||
@@ -60,7 +65,6 @@ namespace {
|
||||
{ "Pluto", "PlutoProjection", "Pluto" },
|
||||
{ "Charon", "Charon", "Pluto" },
|
||||
{ "Jupiter", "JupiterProjection", "Jupiter" },
|
||||
{ "New Horizons", "NewHorizons", "" },
|
||||
{ "Nix", "Nix", "Pluto" },
|
||||
{ "Kerberos", "Kerberos", "Pluto" },
|
||||
{ "Hydra", "Hydra", "Pluto" },
|
||||
@@ -69,16 +73,22 @@ namespace {
|
||||
|
||||
ControlWidget::ControlWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, _currentTime(new QLabel("Current Time"))
|
||||
, _currentTime(new QLabel(""))
|
||||
, _setTime(new QComboBox)
|
||||
, _currentDelta(new QLabel("Current Delta"))
|
||||
, _currentDelta(new QLabel(""))
|
||||
, _setDelta(new QSlider(Qt::Horizontal))
|
||||
, _rewind(new QPushButton("<<"))
|
||||
, _pause(new QPushButton("||"))
|
||||
, _play(new QPushButton("|>"))
|
||||
, _forward(new QPushButton(">>"))
|
||||
, _pause(new QPushButton("Pause"))
|
||||
, _play(new QPushButton("Play"))
|
||||
, _focusNode(new QComboBox)
|
||||
, _setFocusToNextTarget(new QPushButton("Set Focus to the next Target"))
|
||||
, _setFocusToNewHorizons(new QPushButton("Set Focus to New Horizons"))
|
||||
{
|
||||
_pause->setObjectName("pause");
|
||||
_play->setObjectName("play");
|
||||
|
||||
_currentTime->setObjectName("value");
|
||||
_currentDelta->setObjectName("value");
|
||||
|
||||
for (const ImportantDate& d : ImportantDates)
|
||||
_setTime->addItem(d.date);
|
||||
QObject::connect(
|
||||
@@ -107,13 +117,6 @@ ControlWidget::ControlWidget(QWidget* parent)
|
||||
SLOT(onValueChange())
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
_rewind,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(onRewindButton())
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
_pause,
|
||||
SIGNAL(clicked()),
|
||||
@@ -129,34 +132,86 @@ ControlWidget::ControlWidget(QWidget* parent)
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
_forward,
|
||||
_setFocusToNextTarget,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(onForwardButton())
|
||||
SLOT(onFocusToTargetButton())
|
||||
);
|
||||
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
QObject::connect(
|
||||
_setFocusToNewHorizons,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(onFocusToNewHorizonsButton())
|
||||
);
|
||||
|
||||
layout->addWidget(_currentTime, 0, 0);
|
||||
layout->addWidget(_setTime, 0, 1);
|
||||
layout->addWidget(_currentDelta, 1, 0);
|
||||
layout->addWidget(_setDelta, 2, 0, 1, 2);
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout;
|
||||
|
||||
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);
|
||||
{
|
||||
QGroupBox* box = new QGroupBox("Time", this);
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
|
||||
layout->addWidget(_focusNode, 4, 0, 1, 2);
|
||||
//layout->setRowStretch(1, 5);
|
||||
box->setLayout(layout);
|
||||
|
||||
setLayout(layout);
|
||||
{
|
||||
QLabel* l = new QLabel("Current Time (UTC):");
|
||||
l->setObjectName("label");
|
||||
layout->addWidget(l, 0, 0, Qt::AlignLeft);
|
||||
layout->addWidget(_currentTime, 0, 1, Qt::AlignRight);
|
||||
}
|
||||
{
|
||||
QLabel* l = new QLabel("Bookmarked Times:");
|
||||
l->setObjectName("label");
|
||||
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\n(seconds per second):");
|
||||
l->setObjectName("label");
|
||||
layout->addWidget(l, 3, 0, Qt::AlignLeft);
|
||||
layout->addWidget(_currentDelta, 3, 1, Qt::AlignRight);
|
||||
}
|
||||
|
||||
_setDelta->setObjectName("background");
|
||||
layout->addWidget(_setDelta, 4, 0, 1, 2);
|
||||
|
||||
|
||||
QWidget* controlContainer = new QWidget;
|
||||
controlContainer->setObjectName("background");
|
||||
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:");
|
||||
l->setObjectName("label");
|
||||
layout->addWidget(l, 0, 0, Qt::AlignLeft);
|
||||
_focusNode->setMinimumWidth(200);
|
||||
layout->addWidget(_focusNode, 0, 1, Qt::AlignRight);
|
||||
}
|
||||
layout->addWidget(_setFocusToNextTarget, 1, 0, 1, 2);
|
||||
layout->addWidget(_setFocusToNewHorizons, 2, 0, 1, 2);
|
||||
|
||||
mainLayout->addWidget(box);
|
||||
}
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void ControlWidget::update(QString currentTime, QString currentDelta) {
|
||||
currentTime.replace("T", " ");
|
||||
_currentTime->setText(currentTime);
|
||||
_currentDelta->setText(currentDelta);
|
||||
}
|
||||
@@ -164,23 +219,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(3, value / 10) - 1.f;
|
||||
delta = -d;
|
||||
}
|
||||
else {
|
||||
float d = std::pow(2, value / 10);
|
||||
delta = static_cast<int>(d);
|
||||
float d = std::pow(3, 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,42 +244,59 @@ 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);
|
||||
}
|
||||
_setTime->blockSignals(true);
|
||||
_setTime->setCurrentIndex(0);
|
||||
_setTime->blockSignals(false);
|
||||
}
|
||||
|
||||
void ControlWidget::onFocusChange() {
|
||||
int index = _focusNode->currentIndex();
|
||||
QString name = FocusNodes[index].name;
|
||||
QString coordinateSystem = FocusNodes[index].coordinateSystem;
|
||||
if (coordinateSystem.isEmpty()) {
|
||||
int date = _currentTime->text().left(4).toInt();
|
||||
if (date < 2008)
|
||||
coordinateSystem = "Jupiter";
|
||||
else if (date < 2014)
|
||||
coordinateSystem = "Sun";
|
||||
else
|
||||
coordinateSystem = "Pluto";
|
||||
|
||||
}
|
||||
QString script = "openspace.setOrigin('" + name + "');openspace.changeCoordinateSystem('" + coordinateSystem + "');";
|
||||
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::onFocusToNewHorizonsButton() {
|
||||
QString coordinateSystem;
|
||||
int date = _currentTime->text().left(4).toInt();
|
||||
if (date < 2008)
|
||||
coordinateSystem = "Jupiter";
|
||||
else if (date < 2014)
|
||||
coordinateSystem = "Sun";
|
||||
else
|
||||
coordinateSystem = "Pluto";
|
||||
|
||||
|
||||
QString script = "openspace.setOrigin('NewHorizons');openspace.changeCoordinateSystem('" + coordinateSystem + "');";
|
||||
emit scriptActivity(script);
|
||||
}
|
||||
|
||||
void ControlWidget::socketConnected() {
|
||||
setDisabled(false);
|
||||
}
|
||||
@@ -237,3 +304,4 @@ void ControlWidget::socketConnected() {
|
||||
void ControlWidget::socketDisconnected() {
|
||||
setDisabled(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,21 +49,21 @@ private slots:
|
||||
void onValueChange();
|
||||
void onDateChange();
|
||||
void onFocusChange();
|
||||
void onRewindButton();
|
||||
void onPauseButton();
|
||||
void onPlayButton();
|
||||
void onForwardButton();
|
||||
void onFocusToTargetButton();
|
||||
void onFocusToNewHorizonsButton();
|
||||
|
||||
private:
|
||||
QLabel* _currentTime;
|
||||
QComboBox* _setTime;
|
||||
QLabel* _currentDelta;
|
||||
QSlider* _setDelta;
|
||||
QPushButton* _rewind;
|
||||
QPushButton* _pause;
|
||||
QPushButton* _play;
|
||||
QPushButton* _forward;
|
||||
QComboBox* _focusNode;
|
||||
QPushButton* _setFocusToNextTarget;
|
||||
QPushButton* _setFocusToNewHorizons;
|
||||
};
|
||||
|
||||
#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__
|
||||
|
||||
@@ -23,11 +23,134 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
static const QString style = R"style(
|
||||
QWidget {
|
||||
background-color: rgb(80, 80, 80);
|
||||
font-family: Helvetica;
|
||||
}
|
||||
|
||||
QGroupBox {
|
||||
background-color: qlineargradient(
|
||||
x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #858585,
|
||||
stop: 1 #959595);
|
||||
border: 2px solid gray;
|
||||
border-radius: 5px;
|
||||
margin-top: 4ex;
|
||||
font-size: bold 12px;
|
||||
}
|
||||
|
||||
QGroupBox::title {
|
||||
background-color: #E0E0E0;
|
||||
border: 2px solid gray;
|
||||
border-radius: 5px;
|
||||
subcontrol-origin: margin;
|
||||
subcontrol-position: top center;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
QLineEdit {
|
||||
color: lightgray;
|
||||
}
|
||||
|
||||
QSlider::groove:horizontal {
|
||||
border: 1px solid #999999;
|
||||
height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
|
||||
background: qlineargradient(
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #c4c4c4,
|
||||
stop:0.5 #555555,
|
||||
stop:1 #c4c4c4
|
||||
);
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
QSlider::handle:horizontal {
|
||||
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
|
||||
border: 1px solid #5c5c5c;
|
||||
width: 18px;
|
||||
margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
background-color: lightgray;
|
||||
border-style: outset;
|
||||
border-width: 0.5px;
|
||||
border-radius: 5px;
|
||||
border-color: black;
|
||||
font: bold 12px;
|
||||
min-width: 10em;
|
||||
}
|
||||
|
||||
QPushButton#connection {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
QPushButton#connection:pressed {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
|
||||
QPushButton#pause, QPushButton#play {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
QPushButton#pause:pressed, QPushButton#play:pressed, QPushButton:pressed {
|
||||
background-color: darkgray;
|
||||
border-style: inset;
|
||||
}
|
||||
|
||||
QCombobox {
|
||||
border: 1px solid gray;
|
||||
border-radius: 3px;
|
||||
padding: 1px 18px 1px 3px;
|
||||
min-width: 6em;
|
||||
}
|
||||
|
||||
QComboBox:editable {
|
||||
background: lightgrey;
|
||||
}
|
||||
|
||||
QComboBox QAbstractItemView {
|
||||
border: 2px solid darkgray;
|
||||
border-radius: 5px;
|
||||
background-color: #a8a8a8;
|
||||
selection-background-color: #a8a8a8;
|
||||
}
|
||||
|
||||
QLabel#label {
|
||||
font-size: 13px;
|
||||
background-color: transparent;
|
||||
font-variant: small-caps;
|
||||
}
|
||||
|
||||
QLabel#value {
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QWidget#background {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QTextEdit {
|
||||
font-family: monospace;
|
||||
}
|
||||
)style";
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
app.setStyleSheet(style);
|
||||
|
||||
std::string s = style.toStdString();
|
||||
|
||||
MainWindow window;
|
||||
window.show();
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QThread>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
@@ -56,8 +57,6 @@ std::string readFromBuffer(char* buffer, size_t& currentReadLocation) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: QWidget(nullptr)
|
||||
, _configurationWidget(nullptr)
|
||||
@@ -69,8 +68,11 @@ MainWindow::MainWindow()
|
||||
setWindowTitle("OpenSpace Timeline");
|
||||
|
||||
_configurationWidget = new ConfigurationWidget(this);
|
||||
_configurationWidget->setMinimumWidth(350);
|
||||
_timeControlWidget = new ControlWidget(this);
|
||||
_timeControlWidget->setMinimumWidth(350);
|
||||
_informationWidget = new InformationWidget(this);
|
||||
_informationWidget->setMinimumWidth(350);
|
||||
_timelineWidget = new TimelineWidget(this);
|
||||
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
@@ -79,11 +81,17 @@ MainWindow::MainWindow()
|
||||
layout->addWidget(_informationWidget, 2, 0);
|
||||
layout->addWidget(_timelineWidget, 0, 1, 3, 1);
|
||||
|
||||
layout->setColumnStretch(1, 5);
|
||||
|
||||
|
||||
QObject::connect(
|
||||
_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 +121,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();
|
||||
|
||||
@@ -137,25 +150,40 @@ void MainWindow::readTcpData() {
|
||||
|
||||
switch (messageType.value) {
|
||||
case MessageTypeStatus:
|
||||
handleStatusMessage(data.mid(2));
|
||||
{
|
||||
if (_hasHongKangTimeline && _hasLabelTimeline)
|
||||
handleStatusMessage(data.mid(2));
|
||||
break;
|
||||
case MessageTypePlayBook:
|
||||
}
|
||||
case MessageTypePlayBookHongKang:
|
||||
case MessageTypePlayBookLabel:
|
||||
{
|
||||
const char* payloadDebug = data.mid(2).data();
|
||||
|
||||
size_t beginning = 0;
|
||||
uint32_t size = readFromBuffer<uint32_t>(data.mid(2).data(), beginning);
|
||||
|
||||
while (_socket->waitForReadyRead() && data.size() < size) {
|
||||
//while (data.size() < size) {
|
||||
while (_socket->waitForReadyRead() && data.size() < int(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 +272,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 +281,7 @@ void MainWindow::sendScript(QString script) {
|
||||
|
||||
void MainWindow::onSocketConnected() {
|
||||
_socket->write(QString("1\r\n").toLatin1());
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::onSocketDisconnected() {
|
||||
@@ -264,5 +289,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,34 @@ 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(35, 185, 125)
|
||||
};
|
||||
|
||||
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" },
|
||||
{ "NH_REX", "REX" }
|
||||
};
|
||||
|
||||
const double etSpread = 100.0;
|
||||
@@ -86,12 +96,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;
|
||||
@@ -113,8 +123,9 @@ void TimelineWidget::drawContent(QPainter& painter, QRectF rect) {
|
||||
QRectF dateRect(rect.width() - TimeWidth, 0, TimeWidth, rect.height());
|
||||
|
||||
// Draw background
|
||||
painter.setBrush(QBrush(Qt::white)); painter.drawRect(timelineRect);
|
||||
painter.setBrush(QBrush(Qt::gray)); painter.drawRect(dateRect);
|
||||
//painter.setBrush(QBrush(Qt::lightGray)); painter.drawRect(timelineRect);
|
||||
painter.setBrush(QBrush(QColor(85, 85, 85))); painter.drawRect(timelineRect);
|
||||
painter.setBrush(QBrush(QColor(165, 165, 165))); painter.drawRect(dateRect);
|
||||
|
||||
const double lowerTime = _currentTime.et - etSpread;
|
||||
const double upperTime = _currentTime.et + etSpread;
|
||||
@@ -125,18 +136,12 @@ void TimelineWidget::drawContent(QPainter& painter, QRectF rect) {
|
||||
images.push_back(&i);
|
||||
}
|
||||
|
||||
|
||||
//std::vector<Image>::const_iterator lower = std::lower_bound(_images.begin(), _images.end(), lowerTime, [](const Image& i, double time) { return i.beginning < time; });
|
||||
//std::vector<Image>::const_iterator upper = std::lower_bound(_images.begin(), _images.end(), upperTime, [](const Image& i, double time) { return i.ending < time; });
|
||||
//if (lower != _images.end() && upper != _images.end())
|
||||
// drawImages(painter, timelineRect, std::vector<Image>(lower, upper), lowerTime, upperTime);
|
||||
|
||||
drawImages(painter, timelineRect, images, lowerTime, upperTime);
|
||||
|
||||
|
||||
// Draw current time
|
||||
painter.setBrush(QBrush(Qt::black));
|
||||
painter.setPen(QPen(Qt::black));
|
||||
painter.setPen(QPen(Qt::black, 2));
|
||||
painter.drawLine(QPointF(0, timelineRect.height() / 2), QPointF(timelineRect.width(), timelineRect.height() / 2));
|
||||
painter.drawText(timelineRect.width(), timelineRect.height() / 2 + TextOffset, QString::fromStdString(_currentTime.time));
|
||||
}
|
||||
@@ -149,18 +154,6 @@ void TimelineWidget::drawLegend(QPainter& painter, QRectF rect) {
|
||||
// Draw Targets
|
||||
int currentHorizontalPosition = Padding;
|
||||
int currentVerticalPosition = Padding;
|
||||
//for (int i = 0; i < _targets.size(); ++i) {
|
||||
|
||||
// const std::string& target = _targets[i];
|
||||
//
|
||||
// painter.setBrush(QBrush(targetColors[i]));
|
||||
// painter.drawRect(currentHorizontalPosition, currentVerticalPosition, BoxSize, BoxSize);
|
||||
// currentHorizontalPosition += BoxSize + Padding;
|
||||
|
||||
// painter.drawText(currentHorizontalPosition, currentVerticalPosition + BoxSize / 2 + TextOffset, QString::fromStdString(target));
|
||||
// int textWidth = painter.boundingRect(QRect(), QString::fromStdString(target)).width();
|
||||
// currentHorizontalPosition += std::max(textWidth, 25) + Padding;
|
||||
//}
|
||||
|
||||
// Draw Instruments
|
||||
currentHorizontalPosition = Padding;
|
||||
@@ -173,16 +166,17 @@ void TimelineWidget::drawLegend(QPainter& painter, QRectF rect) {
|
||||
|
||||
const std::string& instrument = _instruments[i];
|
||||
|
||||
//painter.setBrush(QBrush(instrumentColors[i]));
|
||||
painter.setBrush(QBrush(instrumentColors[i]));
|
||||
painter.setPen(QPen(instrumentColors[i]));
|
||||
painter.drawRect(currentHorizontalPosition, currentVerticalPosition, BoxSize, BoxSize);
|
||||
currentHorizontalPosition += BoxSize + Padding;
|
||||
|
||||
painter.setPen(QPen(Qt::black));
|
||||
painter.drawText(currentHorizontalPosition, currentVerticalPosition + BoxSize / 2 + TextOffset, QString::fromStdString(instrument));
|
||||
painter.setPen(QPen(QColor(200, 200, 200)));
|
||||
//painter.setPen(QPen(Qt::black));
|
||||
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;
|
||||
//currentHorizontalPosition += std::max(textWidth, 25) + Padding;
|
||||
currentHorizontalPosition += 125;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,11 +215,13 @@ void TimelineWidget::drawImages(
|
||||
int height = (timelineRect.top() + timelineRect.height() * tEnd) - loc;
|
||||
height = std::max(height, 5);
|
||||
|
||||
if (loc + height > timelineRect.height())
|
||||
height = timelineRect.height() - loc;
|
||||
|
||||
std::string target = i->target;
|
||||
auto it = std::find(_targets.begin(), _targets.end(), target);
|
||||
int iTarget = std::distance(_targets.begin(), it);
|
||||
|
||||
//std::vector<QColor> colors;
|
||||
for (std::string instrument : i->instruments) {
|
||||
auto it = std::find(_instruments.begin(), _instruments.end(), instrument);
|
||||
if (it == _instruments.end())
|
||||
@@ -240,11 +236,13 @@ void TimelineWidget::drawImages(
|
||||
painter.drawRect(pos, loc, width, height);
|
||||
}
|
||||
|
||||
painter.setBrush(QBrush(Qt::black));
|
||||
painter.setPen(QPen(Qt::black));
|
||||
QString line = QString::fromStdString(i->beginningString) + QString(" (") + QString::fromStdString(i->target) + QString(")");
|
||||
if (height >= 5) {
|
||||
painter.setBrush(QBrush(Qt::black));
|
||||
painter.setPen(QPen(Qt::black));
|
||||
QString line = QString::fromStdString(i->beginningString) + QString(" (") + QString::fromStdString(i->target) + QString(")");
|
||||
|
||||
painter.drawText(timelineRect.width(), loc + height / 2 + TextOffset, line);
|
||||
painter.drawText(timelineRect.width(), loc + height / 2 + TextOffset, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,3 +256,11 @@ 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 "";
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
void socketConnected();
|
||||
void socketDisconnected();
|
||||
|
||||
std::string nextTarget() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event);
|
||||
void drawContent(QPainter& painter, QRectF rect);
|
||||
|
||||
@@ -33,54 +33,44 @@
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
class HongKangParser : public SequenceParser{
|
||||
public:
|
||||
HongKangParser();
|
||||
HongKangParser(const std::string& fileName,
|
||||
std::string spacecraft,
|
||||
ghoul::Dictionary dictionary,
|
||||
std::vector<std::string> potentialTargets);
|
||||
virtual void create();
|
||||
virtual std::map<std::string, ImageSubset> getSubsetMap();
|
||||
virtual std::vector<std::pair<std::string, TimeRange>> getIstrumentTimes();
|
||||
virtual std::vector<std::pair<double, std::string>> getTargetTimes();
|
||||
|
||||
// temporary need to figure this out
|
||||
virtual std::map<std::string, Decoder*> getTranslation(){ return _fileTranslation; };
|
||||
virtual std::vector<double> getCaptureProgression();
|
||||
class HongKangParser : public SequenceParser {
|
||||
public:
|
||||
HongKangParser();
|
||||
HongKangParser(const std::string& fileName,
|
||||
std::string spacecraft,
|
||||
ghoul::Dictionary dictionary,
|
||||
std::vector<std::string> potentialTargets);
|
||||
virtual void create();
|
||||
|
||||
private:
|
||||
double getMetFromET(double et);
|
||||
double getETfromMet(std::string timestr);
|
||||
double getETfromMet(double met);
|
||||
// temporary need to figure this out
|
||||
virtual std::map<std::string, Decoder*> getTranslation(){ return _fileTranslation; };
|
||||
|
||||
void createImage(Image& image,
|
||||
double startTime,
|
||||
double stopTime,
|
||||
std::vector<std::string> instr,
|
||||
std::string targ,
|
||||
std::string pot);
|
||||
private:
|
||||
double getMetFromET(double et);
|
||||
double getETfromMet(std::string timestr);
|
||||
double getETfromMet(double met);
|
||||
|
||||
bool augmentWithSpice(Image& image,
|
||||
std::string spacecraft,
|
||||
std::vector<std::string> payload,
|
||||
std::vector<std::string> potentialTargets);
|
||||
void sendPlaybookInformation();
|
||||
void createImage(Image& image,
|
||||
double startTime,
|
||||
double stopTime,
|
||||
std::vector<std::string> instr,
|
||||
std::string targ,
|
||||
std::string pot);
|
||||
|
||||
std::string _defaultCaptureImage;
|
||||
double _metRef = 299180517;
|
||||
bool augmentWithSpice(Image& image,
|
||||
std::string spacecraft,
|
||||
std::vector<std::string> payload,
|
||||
std::vector<std::string> potentialTargets);
|
||||
|
||||
std::string _fileName;
|
||||
std::string _spacecraft;
|
||||
std::map<std::string, Decoder*> _fileTranslation;
|
||||
std::vector<std::string> _potentialTargets;
|
||||
std::string _defaultCaptureImage;
|
||||
double _metRef = 299180517;
|
||||
|
||||
//returnable
|
||||
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;
|
||||
};
|
||||
std::string _fileName;
|
||||
std::string _spacecraft;
|
||||
std::map<std::string, Decoder*> _fileTranslation;
|
||||
std::vector<std::string> _potentialTargets;
|
||||
};
|
||||
|
||||
}
|
||||
#endif //__HONGKANGPARSER_H__
|
||||
@@ -38,13 +38,9 @@ public:
|
||||
LabelParser(const std::string& fileName,
|
||||
ghoul::Dictionary translationDictionary);
|
||||
virtual void create();
|
||||
virtual std::map<std::string, ImageSubset> getSubsetMap();
|
||||
virtual std::vector<std::pair<std::string, TimeRange>> getIstrumentTimes();
|
||||
virtual std::vector<std::pair<double, std::string>> getTargetTimes();
|
||||
|
||||
// temporary need to figure this out
|
||||
std::map<std::string, Decoder*> getTranslation(){ return _fileTranslation; };
|
||||
virtual std::vector<double> getCaptureProgression(){ return _captureProgression; };
|
||||
|
||||
private:
|
||||
void createImage(Image& image,
|
||||
@@ -67,13 +63,6 @@ private:
|
||||
std::map<std::string, Decoder*> _fileTranslation;
|
||||
std::vector<std::string> _specsOfInterest;
|
||||
|
||||
//returnable
|
||||
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;
|
||||
|
||||
|
||||
std::string _target;
|
||||
std::string _instrumentID;
|
||||
std::string _instrumentHostID;
|
||||
|
||||
@@ -22,53 +22,69 @@
|
||||
* 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 SequenceParser{
|
||||
public:
|
||||
virtual void create() = 0;
|
||||
virtual std::map<std::string, ImageSubset> getSubsetMap() = 0;
|
||||
virtual std::vector<std::pair<std::string, TimeRange>> getIstrumentTimes() = 0;
|
||||
virtual std::vector<std::pair<double, std::string>> getTargetTimes() = 0;
|
||||
virtual std::map<std::string, Decoder*> getTranslation() = 0;
|
||||
virtual std::vector<double> getCaptureProgression() = 0;
|
||||
class Decoder;
|
||||
|
||||
struct Image {
|
||||
double startTime;
|
||||
double stopTime;
|
||||
std::string path;
|
||||
std::vector<std::string> activeInstruments;
|
||||
std::string target;
|
||||
bool projected;
|
||||
};
|
||||
}
|
||||
#endif //__SEQUENCEPARSER_H__
|
||||
|
||||
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 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;
|
||||
virtual std::map<std::string, Decoder*> getTranslation() = 0;
|
||||
virtual std::vector<double> getCaptureProgression() final;
|
||||
|
||||
protected:
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif //__SEQUENCEPARSER_H__
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
#define OPENSPACE_VERSION_MAJOR 0
|
||||
#define OPENSPACE_VERSION_MINOR 1
|
||||
#define OPENSPACE_VERSION_REVISION 0
|
||||
#define OPENSPACE_VERSION_STRING "prerelease-4"
|
||||
#define OPENSPACE_VERSION_STRING "prerelease-5"
|
||||
|
||||
+1
-1
Submodule openspace-data updated: 15254d339b...acddeaf905
+1
-1
@@ -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 = {
|
||||
|
||||
+28
-161
@@ -28,8 +28,6 @@
|
||||
#include <ghoul/filesystem/directory.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/network/networkengine.h>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <iomanip>
|
||||
@@ -42,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 {
|
||||
@@ -253,37 +251,37 @@ void HongKangParser::create(){
|
||||
}
|
||||
}
|
||||
|
||||
sendPlaybookInformation();
|
||||
sendPlaybookInformation(PlaybookIdentifierName);
|
||||
|
||||
std::ofstream myfile;
|
||||
myfile.open("HongKangOutput.txt");
|
||||
//std::ofstream myfile;
|
||||
//myfile.open("HongKangOutput.txt");
|
||||
|
||||
//print all
|
||||
for (auto target : _subsetMap){
|
||||
std::string min, max;
|
||||
SpiceManager::ref().getDateFromET(target.second._range._min, min);
|
||||
SpiceManager::ref().getDateFromET(target.second._range._max, max);
|
||||
////print all
|
||||
//for (auto target : _subsetMap){
|
||||
// std::string min, max;
|
||||
// SpiceManager::ref().getDateFromET(target.second._range._min, min);
|
||||
// SpiceManager::ref().getDateFromET(target.second._range._max, max);
|
||||
|
||||
myfile << std::endl;
|
||||
for (auto image : target.second._subset){
|
||||
std::string time_beg;
|
||||
std::string time_end;
|
||||
SpiceManager::ref().getDateFromET(image.startTime, time_beg);
|
||||
SpiceManager::ref().getDateFromET(image.stopTime, time_end);
|
||||
// myfile << std::endl;
|
||||
// for (auto image : target.second._subset){
|
||||
// std::string time_beg;
|
||||
// std::string time_end;
|
||||
// SpiceManager::ref().getDateFromET(image.startTime, time_beg);
|
||||
// SpiceManager::ref().getDateFromET(image.stopTime, time_end);
|
||||
|
||||
myfile << std::fixed
|
||||
<< std::setw(10) << time_beg
|
||||
<< std::setw(10) << time_end
|
||||
<< std::setw(10) << (int)getMetFromET(image.startTime)
|
||||
<< std::setw(10) << image.target << std::setw(10);
|
||||
for (auto instrument : image.activeInstruments){
|
||||
myfile << " " << instrument;
|
||||
}
|
||||
myfile << std::endl;
|
||||
}
|
||||
}
|
||||
myfile.close();
|
||||
|
||||
// myfile << std::fixed
|
||||
// << std::setw(10) << time_beg
|
||||
// << std::setw(10) << time_end
|
||||
// << std::setw(10) << (int)getMetFromET(image.startTime)
|
||||
// << std::setw(10) << image.target << std::setw(10);
|
||||
// for (auto instrument : image.activeInstruments){
|
||||
// myfile << " " << instrument;
|
||||
// }
|
||||
// myfile << std::endl;
|
||||
// }
|
||||
//}
|
||||
//myfile.close();
|
||||
//
|
||||
}
|
||||
|
||||
bool HongKangParser::augmentWithSpice(Image& image,
|
||||
@@ -367,136 +365,5 @@ double HongKangParser::getMetFromET(double et){
|
||||
return met;
|
||||
}
|
||||
|
||||
std::map<std::string, ImageSubset> HongKangParser::getSubsetMap(){
|
||||
return _subsetMap;
|
||||
}
|
||||
std::vector<std::pair<std::string, TimeRange>> HongKangParser::getIstrumentTimes(){
|
||||
return _instrumentTimes;
|
||||
}
|
||||
std::vector<std::pair<double, std::string>> HongKangParser::getTargetTimes(){
|
||||
return _targetTimes;
|
||||
}
|
||||
std::vector<double> HongKangParser::getCaptureProgression(){
|
||||
return _captureProgression;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
void writeToBuffer(std::vector<char>& buffer, size_t& currentWriteLocation, T value) {
|
||||
if ((currentWriteLocation + sizeof(T)) > buffer.size())
|
||||
buffer.resize(2 * buffer.size());
|
||||
|
||||
std::memmove(buffer.data() + currentWriteLocation, reinterpret_cast<const void*>(&value), sizeof(T));
|
||||
currentWriteLocation += sizeof(T);
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
void writeToBuffer<std::string>(std::vector<char>& buffer, size_t& currentWriteLocation, std::string value) {
|
||||
if ((currentWriteLocation + sizeof(uint8_t) + value.size()) > buffer.size())
|
||||
buffer.resize(2 * buffer.size());
|
||||
|
||||
uint8_t length = value.size();
|
||||
std::memcpy(buffer.data() + currentWriteLocation, &length, sizeof(uint8_t));
|
||||
currentWriteLocation += sizeof(uint8_t);
|
||||
|
||||
std::memmove(buffer.data() + currentWriteLocation, value.data(), length);
|
||||
currentWriteLocation += length;
|
||||
}
|
||||
|
||||
|
||||
void HongKangParser::sendPlaybookInformation() {
|
||||
static const NetworkEngine::MessageIdentifier PlaybookIdentifier = OsEng.networkEngine()->identifier(PlaybookIdentifierName);
|
||||
|
||||
std::vector<char> buffer(1024);
|
||||
size_t currentWriteLocation = 0;
|
||||
|
||||
// Protocol:
|
||||
// 4 bytes: Total number of bytes sent
|
||||
// 1 byte : Number of Targets (i)
|
||||
// i times: 1 byte (id), 1 byte (length j of name), j bytes (name)
|
||||
// 1 byte : Number of Instruments (i)
|
||||
// i times: 1 byte (id), 1 byte (length j of name), j bytes (name)
|
||||
// 4 byte: Number (n) of images
|
||||
// n times: 8 byte (beginning time), 8 byte (ending time), 1 byte (target id), 2 byte (instrument id)
|
||||
|
||||
std::map<std::string, uint8_t> targetMap;
|
||||
uint8_t currentTargetId = 0;
|
||||
for (auto target : _subsetMap) {
|
||||
if (targetMap.find(target.first) == targetMap.end())
|
||||
targetMap[target.first] = currentTargetId++;
|
||||
}
|
||||
|
||||
std::map<std::string, uint16_t> instrumentMap;
|
||||
uint16_t currentInstrumentId = 1;
|
||||
for (auto target : _subsetMap) {
|
||||
for (auto image : target.second._subset) {
|
||||
for (auto instrument : image.activeInstruments) {
|
||||
if (instrumentMap.find(instrument) == instrumentMap.end()) {
|
||||
instrumentMap[instrument] = currentInstrumentId;
|
||||
currentInstrumentId = currentInstrumentId << 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeToBuffer(buffer, currentWriteLocation, uint8_t(targetMap.size()));
|
||||
for (const std::pair<std::string, uint8_t>& p : targetMap) {
|
||||
writeToBuffer(buffer, currentWriteLocation, p.second);
|
||||
writeToBuffer(buffer, currentWriteLocation, p.first);
|
||||
}
|
||||
|
||||
writeToBuffer(buffer, currentWriteLocation, uint8_t(instrumentMap.size()));
|
||||
for (const std::pair<std::string, uint16_t>& p : instrumentMap) {
|
||||
writeToBuffer(buffer, currentWriteLocation, p.second);
|
||||
writeToBuffer(buffer, currentWriteLocation, p.first);
|
||||
}
|
||||
|
||||
uint32_t allImages = 0;
|
||||
for (auto target : _subsetMap)
|
||||
allImages += target.second._subset.size();
|
||||
writeToBuffer(buffer, currentWriteLocation, allImages);
|
||||
|
||||
for (auto target : _subsetMap){
|
||||
for (auto image : target.second._subset){
|
||||
writeToBuffer(buffer, currentWriteLocation, image.startTime);
|
||||
writeToBuffer(buffer, currentWriteLocation, image.stopTime);
|
||||
|
||||
std::string timeBegin;
|
||||
std::string timeEnd;
|
||||
SpiceManager::ref().getDateFromET(image.startTime, timeBegin);
|
||||
SpiceManager::ref().getDateFromET(image.stopTime, timeEnd);
|
||||
|
||||
writeToBuffer(buffer, currentWriteLocation, timeBegin);
|
||||
writeToBuffer(buffer, currentWriteLocation, timeEnd);
|
||||
|
||||
uint8_t targetId = targetMap[target.first];
|
||||
writeToBuffer(buffer, currentWriteLocation, targetId);
|
||||
uint16_t totalInstrumentId = 0;
|
||||
if (image.activeInstruments.empty()) {
|
||||
LERROR("Image had no active instruments");
|
||||
}
|
||||
|
||||
for (auto instrument : image.activeInstruments) {
|
||||
uint16_t thisInstrumentId = instrumentMap[instrument];
|
||||
totalInstrumentId |= thisInstrumentId;
|
||||
}
|
||||
writeToBuffer(buffer, currentWriteLocation, totalInstrumentId);
|
||||
}
|
||||
}
|
||||
|
||||
union {
|
||||
uint32_t value;
|
||||
std::array<char, sizeof(uint32_t)> data;
|
||||
} sizeBuffer;
|
||||
sizeBuffer.value = currentWriteLocation;
|
||||
buffer.insert(buffer.begin(), sizeBuffer.data.begin(), sizeBuffer.data.end());
|
||||
currentWriteLocation += sizeof(uint32_t);
|
||||
|
||||
buffer.resize(currentWriteLocation);
|
||||
|
||||
//OsEng.networkEngine()->publishMessage(PlaybookIdentifier, buffer);
|
||||
OsEng.networkEngine()->setInitialConnectionMessage(PlaybookIdentifier, buffer);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
+29
-33
@@ -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 {
|
||||
@@ -240,36 +243,39 @@ void LabelParser::create(){
|
||||
}
|
||||
}
|
||||
|
||||
std::ofstream myfile;
|
||||
myfile.open("LabelFileOutput.txt");
|
||||
//sendPlaybookInformation();
|
||||
|
||||
//print all
|
||||
//std::ofstream myfile;
|
||||
//myfile.open("LabelFileOutput.txt");
|
||||
|
||||
////print all
|
||||
for (auto target : _subsetMap){
|
||||
_instrumentTimes.push_back(std::make_pair(lblName, _subsetMap[target.first]._range));
|
||||
std::string min, max;
|
||||
SpiceManager::ref().getDateFromET(target.second._range._min, min);
|
||||
SpiceManager::ref().getDateFromET(target.second._range._max, max);
|
||||
// std::string min, max;
|
||||
// SpiceManager::ref().getDateFromET(target.second._range._min, min);
|
||||
// SpiceManager::ref().getDateFromET(target.second._range._max, max);
|
||||
|
||||
myfile << std::endl;
|
||||
for (auto image : target.second._subset){
|
||||
std::string time_beg;
|
||||
std::string time_end;
|
||||
SpiceManager::ref().getDateFromET(image.startTime, time_beg);
|
||||
SpiceManager::ref().getDateFromET(image.stopTime, time_end);
|
||||
// myfile << std::endl;
|
||||
// for (auto image : target.second._subset){
|
||||
// std::string time_beg;
|
||||
// std::string time_end;
|
||||
// SpiceManager::ref().getDateFromET(image.startTime, time_beg);
|
||||
// SpiceManager::ref().getDateFromET(image.stopTime, time_end);
|
||||
|
||||
myfile << std::fixed
|
||||
<< " " << time_beg
|
||||
<< "-->" << time_end
|
||||
<< " [ " << image.startTime
|
||||
<< " ] " << image.target << std::setw(10);
|
||||
for (auto instrument : image.activeInstruments){
|
||||
myfile << " " << instrument;
|
||||
}
|
||||
myfile << std::endl;
|
||||
}
|
||||
// myfile << std::fixed
|
||||
// << " " << time_beg
|
||||
// << "-->" << time_end
|
||||
// << " [ " << image.startTime
|
||||
// << " ] " << image.target << std::setw(10);
|
||||
// for (auto instrument : image.activeInstruments){
|
||||
// myfile << " " << instrument;
|
||||
// }
|
||||
// myfile << std::endl;
|
||||
// }
|
||||
}
|
||||
myfile.close();
|
||||
//myfile.close();
|
||||
|
||||
sendPlaybookInformation(PlaybookIdentifierName);
|
||||
|
||||
}
|
||||
|
||||
@@ -284,14 +290,4 @@ void LabelParser::createImage(Image& image, double startTime, double stopTime, s
|
||||
image.projected = false;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, ImageSubset> LabelParser::getSubsetMap(){
|
||||
return _subsetMap;
|
||||
}
|
||||
std::vector<std::pair<std::string, TimeRange>> LabelParser::getIstrumentTimes(){
|
||||
return _instrumentTimes;
|
||||
}
|
||||
std::vector<std::pair<double, std::string>> LabelParser::getTargetTimes(){
|
||||
return _targetTimes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/util/sequenceparser.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/decoder.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SequenceParser";
|
||||
const std::string keyTranslation = "DataInputTranslation";
|
||||
|
||||
const std::string PlaybookIdentifierName = "Playbook";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
std::map<std::string, ImageSubset> SequenceParser::getSubsetMap(){
|
||||
return _subsetMap;
|
||||
}
|
||||
std::vector<std::pair<std::string, TimeRange>> SequenceParser::getIstrumentTimes(){
|
||||
return _instrumentTimes;
|
||||
}
|
||||
std::vector<std::pair<double, std::string>> SequenceParser::getTargetTimes(){
|
||||
return _targetTimes;
|
||||
}
|
||||
std::vector<double> SequenceParser::getCaptureProgression(){
|
||||
return _captureProgression;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
void writeToBuffer(std::vector<char>& buffer, size_t& currentWriteLocation, T value) {
|
||||
if ((currentWriteLocation + sizeof(T)) > buffer.size())
|
||||
buffer.resize(2 * buffer.size());
|
||||
|
||||
std::memmove(buffer.data() + currentWriteLocation, reinterpret_cast<const void*>(&value), sizeof(T));
|
||||
currentWriteLocation += sizeof(T);
|
||||
}
|
||||
|
||||
template <>
|
||||
void writeToBuffer<std::string>(std::vector<char>& buffer, size_t& currentWriteLocation, std::string value) {
|
||||
if ((currentWriteLocation + sizeof(uint8_t) + value.size()) > buffer.size())
|
||||
buffer.resize(2 * buffer.size());
|
||||
|
||||
uint8_t length = value.size();
|
||||
std::memcpy(buffer.data() + currentWriteLocation, &length, sizeof(uint8_t));
|
||||
currentWriteLocation += sizeof(uint8_t);
|
||||
|
||||
std::memmove(buffer.data() + currentWriteLocation, value.data(), length);
|
||||
currentWriteLocation += length;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// Protocol:
|
||||
// 4 bytes: Total number of bytes sent
|
||||
// 1 byte : Number of Targets (i)
|
||||
// i times: 1 byte (id), 1 byte (length j of name), j bytes (name)
|
||||
// 1 byte : Number of Instruments (i)
|
||||
// i times: 1 byte (id), 1 byte (length j of name), j bytes (name)
|
||||
// 4 byte: Number (n) of images
|
||||
// n times: 8 byte (beginning time), 8 byte (ending time), 1 byte (target id), 2 byte (instrument id)
|
||||
|
||||
std::map<std::string, uint8_t> targetMap;
|
||||
uint8_t currentTargetId = 0;
|
||||
for (auto target : _subsetMap) {
|
||||
if (targetMap.find(target.first) == targetMap.end())
|
||||
targetMap[target.first] = currentTargetId++;
|
||||
}
|
||||
|
||||
std::map<std::string, uint16_t> instrumentMap;
|
||||
uint16_t currentInstrumentId = 1;
|
||||
for (auto target : _subsetMap) {
|
||||
for (auto image : target.second._subset) {
|
||||
for (auto instrument : image.activeInstruments) {
|
||||
if (instrumentMap.find(instrument) == instrumentMap.end()) {
|
||||
instrumentMap[instrument] = currentInstrumentId;
|
||||
currentInstrumentId = currentInstrumentId << 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeToBuffer(buffer, currentWriteLocation, uint8_t(targetMap.size()));
|
||||
for (const std::pair<std::string, uint8_t>& p : targetMap) {
|
||||
writeToBuffer(buffer, currentWriteLocation, p.second);
|
||||
writeToBuffer(buffer, currentWriteLocation, p.first);
|
||||
}
|
||||
|
||||
writeToBuffer(buffer, currentWriteLocation, uint8_t(instrumentMap.size()));
|
||||
for (const std::pair<std::string, uint16_t>& p : instrumentMap) {
|
||||
writeToBuffer(buffer, currentWriteLocation, p.second);
|
||||
writeToBuffer(buffer, currentWriteLocation, p.first);
|
||||
}
|
||||
|
||||
uint32_t allImages = 0;
|
||||
for (auto target : _subsetMap)
|
||||
allImages += target.second._subset.size();
|
||||
writeToBuffer(buffer, currentWriteLocation, allImages);
|
||||
|
||||
for (auto target : _subsetMap){
|
||||
for (auto image : target.second._subset){
|
||||
writeToBuffer(buffer, currentWriteLocation, image.startTime);
|
||||
writeToBuffer(buffer, currentWriteLocation, image.stopTime);
|
||||
|
||||
std::string timeBegin;
|
||||
std::string timeEnd;
|
||||
SpiceManager::ref().getDateFromET(image.startTime, timeBegin);
|
||||
SpiceManager::ref().getDateFromET(image.stopTime, timeEnd);
|
||||
|
||||
writeToBuffer(buffer, currentWriteLocation, timeBegin);
|
||||
writeToBuffer(buffer, currentWriteLocation, timeEnd);
|
||||
|
||||
uint8_t targetId = targetMap[target.first];
|
||||
writeToBuffer(buffer, currentWriteLocation, targetId);
|
||||
uint16_t totalInstrumentId = 0;
|
||||
if (image.activeInstruments.empty()) {
|
||||
LERROR("Image had no active instruments");
|
||||
}
|
||||
|
||||
for (auto instrument : image.activeInstruments) {
|
||||
uint16_t thisInstrumentId = instrumentMap[instrument];
|
||||
totalInstrumentId |= thisInstrumentId;
|
||||
}
|
||||
writeToBuffer(buffer, currentWriteLocation, totalInstrumentId);
|
||||
}
|
||||
}
|
||||
|
||||
union {
|
||||
uint32_t value;
|
||||
std::array<char, sizeof(uint32_t)> data;
|
||||
} sizeBuffer;
|
||||
sizeBuffer.value = currentWriteLocation;
|
||||
buffer.insert(buffer.begin(), sizeBuffer.data.begin(), sizeBuffer.data.end());
|
||||
currentWriteLocation += sizeof(uint32_t);
|
||||
|
||||
buffer.resize(currentWriteLocation);
|
||||
|
||||
//OsEng.networkEngine()->publishMessage(PlaybookIdentifier, buffer);
|
||||
OsEng.networkEngine()->setInitialConnectionMessage(_messageIdentifier, buffer);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user