Fix copyright header information

Remove TimelineView application
This commit is contained in:
Alexander Bock
2020-02-12 22:36:11 +01:00
parent 3355e85385
commit de24e81bda
27 changed files with 40 additions and 1768 deletions

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *

View File

@@ -1,63 +0,0 @@
##########################################################################################
# #
# OpenSpace #
# #
# Copyright (c) 2014-2020 #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy of this #
# software and associated documentation files (the "Software"), to deal in the Software #
# without restriction, including without limitation the rights to use, copy, modify, #
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to #
# permit persons to whom the Software is furnished to do so, subject to the following #
# conditions: #
# #
# The above copyright notice and this permission notice shall be included in all copies #
# or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, #
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A #
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT #
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF #
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE #
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #
##########################################################################################
include(${OPENSPACE_CMAKE_EXT_DIR}/application_definition.cmake)
set(APPLICATION_NAME TimelineView)
set(APPLICATION_LINK_TO_OPENSPACE OFF)
set(SOURCE_FILES
${OPENSPACE_APPS_DIR}/TimelineView/main.cpp
${OPENSPACE_APPS_DIR}/TimelineView/mainwindow.cpp
${OPENSPACE_APPS_DIR}/TimelineView/configurationwidget.cpp
${OPENSPACE_APPS_DIR}/TimelineView/informationwidget.cpp
${OPENSPACE_APPS_DIR}/TimelineView/controlwidget.cpp
${OPENSPACE_APPS_DIR}/TimelineView/timelinewidget.cpp
)
set(HEADER_FILES
${OPENSPACE_APPS_DIR}/TimelineView/mainwindow.h
${OPENSPACE_APPS_DIR}/TimelineView/configurationwidget.h
${OPENSPACE_APPS_DIR}/TimelineView/controlwidget.h
${OPENSPACE_APPS_DIR}/TimelineView/informationwidget.h
${OPENSPACE_APPS_DIR}/TimelineView/mainwindow.h
${OPENSPACE_APPS_DIR}/TimelineView/timelinewidget.h
)
find_package(Qt5Widgets)
find_package(Qt5Network)
set(MOC_FILES "")
qt5_wrap_cpp(MOC_FILES ${HEADER_FILES})
create_new_application(${APPLICATION_NAME} MACOSX_BUNDLE ${SOURCE_FILES} ${HEADER_FILES} ${MOC_FILES})
target_link_libraries(${APPLICATION_NAME} Qt5::Widgets Qt5::Network)
#if (APPLE)
# INSTALL(CODE "
# include(BundleUtilities)
# fixup_bundle(\"${application_path}/bin/openspace/Debug/Launcher.app/Contents/MacOS/Launcher\" \"${application_path}/bin/openspace/Debug/TimelineView.app/Contents/plugins/platforms/libqcocoa.dylib\" \"\")
# " COMPONENT Runtime)
#endif ()

View File

@@ -1,37 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_APP_TIMELINEVIEW___COMMON___H__
#define __OPENSPACE_APP_TIMELINEVIEW___COMMON___H__
struct Image {
double beginning;
double ending;
std::string beginningString;
std::string endingString;
std::string target;
std::vector<std::string> instruments;
};
#endif // __OPENSPACE_APP_TIMELINEVIEW___COMMON___H__

View File

@@ -1,86 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* 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 "configurationwidget.h"
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QTimer>
ConfigurationWidget::ConfigurationWidget(QWidget* parent)
: QWidget(parent)
, _ipAddress(new QLineEdit("localhost"))
, _port(new QLineEdit("20500"))
, _connect(new QPushButton("Connect"))
{
_connect->setObjectName("connection");
QGroupBox* box = new QGroupBox("Connection", this);
QGridLayout* layout = new QGridLayout;
layout->setVerticalSpacing(0);
{
QLabel* t = new QLabel("IP Address");
t->setObjectName("label");
layout->addWidget(t, 0, 0);
}
layout->addWidget(_ipAddress, 1, 0);
{
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() {
emit connect(_ipAddress->text(), _port->text());
}
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()));
}

View File

@@ -1,53 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_APP_TIMELINEVIEW___CONFIGURATIONWIDGET___H__
#define __OPENSPACE_APP_TIMELINEVIEW___CONFIGURATIONWIDGET___H__
#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
class ConfigurationWidget : public QWidget {
Q_OBJECT
public:
ConfigurationWidget(QWidget* parent);
void socketConnected();
void socketDisconnected();
signals:
void connect(QString host, QString port);
void disconnect();
private slots:
void onConnectButton();
private:
QLineEdit* _ipAddress;
QLineEdit* _port;
QPushButton* _connect;
};
#endif // __OPENSPACE_APP_TIMELINEVIEW___CONFIGURATIONWIDGET___H__

View File

@@ -1,319 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* 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 "controlwidget.h"
#include "mainwindow.h"
#include <QComboBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QSlider>
#include <math.h>
namespace {
struct ImportantDate {
QString date;
QString focus;
QString coordinateSystem;
};
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" },
{ "2015-07-14T11:22:00.00", "PlutoProjection", "Pluto" },
{ "2015-07-14T11:36:40.00", "PlutoProjection", "Pluto" },
{ "2015-07-14T11:48:43.00", "PlutoProjection", "Pluto" },
{ "2015-07-14T12:04:35.00", "PlutoProjection", "Pluto" },
{ "2015-07-14T15:02:46.00", "PlutoProjection", "Pluto" }
};
struct FocusNode {
QString guiName;
QString name;
QString coordinateSystem;
};
const FocusNode FocusNodes[] = {
{ "Earth", "Earth", "Sun" },
{ "Sun", "Sun", "Sun" },
{ "Pluto", "PlutoProjection", "Pluto" },
{ "Charon", "Charon", "Pluto" },
{ "Jupiter", "JupiterProjection", "Jupiter" },
{ "Nix", "Nix", "Pluto" },
{ "Kerberos", "Kerberos", "Pluto" },
{ "Hydra", "Hydra", "Pluto" },
};
}
ControlWidget::ControlWidget(QWidget* parent)
: QWidget(parent)
, _currentTime(new QLabel(""))
, _setTime(new QComboBox)
, _currentDelta(new QLabel(""))
, _setDelta(new QSlider(Qt::Horizontal))
, _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(
_setTime,
SIGNAL(currentIndexChanged(int)),
this,
SLOT(onDateChange())
);
for (const FocusNode& f : FocusNodes)
_focusNode->addItem(f.guiName);
QObject::connect(
_focusNode,
SIGNAL(currentIndexChanged(int)),
this,
SLOT(onFocusChange())
);
_setDelta->setMinimum(-100);
_setDelta->setMaximum(100);
_setDelta->setValue(0);
QObject::connect(
_setDelta,
SIGNAL(valueChanged(int)),
this,
SLOT(onValueChange())
);
QObject::connect(
_pause,
SIGNAL(clicked()),
this,
SLOT(onPauseButton())
);
QObject::connect(
_play,
SIGNAL(clicked()),
this,
SLOT(onPlayButton())
);
QObject::connect(
_setFocusToNextTarget,
SIGNAL(clicked()),
this,
SLOT(onFocusToTargetButton())
);
QObject::connect(
_setFocusToNewHorizons,
SIGNAL(clicked()),
this,
SLOT(onFocusToNewHorizonsButton())
);
QVBoxLayout* mainLayout = new QVBoxLayout;
{
QGroupBox* box = new QGroupBox("Time", this);
QGridLayout* layout = new QGridLayout;
//layout->setRowStretch(1, 5);
box->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);
}
void ControlWidget::onValueChange() {
float value = static_cast<float>(_setDelta->value());
float delta;
if (value < 0.f) {
value = -value;
float d = pow(3, value / 10) - 1.f;
delta = -d;
}
else {
float d = pow(3, value / 10) - 1.f;
delta = d;
}
QString script = "openspace.time.setDeltaTime(" + QString::number(delta) + ");";
emit scriptActivity(script);
}
void ControlWidget::onPauseButton() {
QString script = "openspace.time.setPause(true);";
emit scriptActivity(script);
}
void ControlWidget::onPlayButton() {
QString script = "openspace.time.setPause(false);";
emit scriptActivity(script);
}
void ControlWidget::onDateChange() {
int index = _setTime->currentIndex();
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.setPropertyValue('Interaction.origin', '" + focus + "');\
openspace.setPropertyValue('Interaction.coordinateSystem', '" +
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;
QString script = "openspace.setPropertyValue('Interaction.origin', '" + name +
"');openspace.setPropertyValue('Interaction.coordinateSystem', '" +
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.setPropertyValue('Interaction.origin', '" + name +
"');openspace.setPropertyValue('Interaction.coordinateSystem', '" +
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.setPropertyValue('Interaction.origin', 'NewHorizons');\
openspace.setPropertyValue('Interaction.coordinateSystem', '" + coordinateSystem +
"');";
emit scriptActivity(script);
}
void ControlWidget::socketConnected() {
setDisabled(false);
}
void ControlWidget::socketDisconnected() {
setDisabled(true);
}

View File

@@ -1,69 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__
#define __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__
#include <QWidget>
class QComboBox;
class QLabel;
class QPushButton;
class QSlider;
class ControlWidget : public QWidget {
Q_OBJECT
public:
ControlWidget(QWidget* parent);
void update(QString currentTime, QString currentDelta);
void socketConnected();
void socketDisconnected();
signals:
void scriptActivity(QString script);
private slots:
void onValueChange();
void onDateChange();
void onFocusChange();
void onPauseButton();
void onPlayButton();
void onFocusToTargetButton();
void onFocusToNewHorizonsButton();
private:
QLabel* _currentTime;
QComboBox* _setTime;
QLabel* _currentDelta;
QSlider* _setDelta;
QPushButton* _pause;
QPushButton* _play;
QComboBox* _focusNode;
QPushButton* _setFocusToNextTarget;
QPushButton* _setFocusToNewHorizons;
};
#endif // __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__

View File

@@ -1,50 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* 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 "informationwidget.h"
#include <QLayout>
#include <QTextEdit>
InformationWidget::InformationWidget(QWidget* parent)
: QTextEdit(parent)
{
setReadOnly(true);
}
void InformationWidget::socketConnected() {
setDisabled(false);
}
void InformationWidget::socketDisconnected() {
setDisabled(true);
}
void InformationWidget::logInformation(QString text) {
QString currentText = toPlainText();
currentText += text + "\n";
setPlainText(currentText);
}

View File

@@ -1,41 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__
#define __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__
#include <QTextEdit>
class InformationWidget : public QTextEdit {
Q_OBJECT
public:
InformationWidget(QWidget* parent);
void socketConnected();
void socketDisconnected();
public slots:
void logInformation(QString text);
};
#endif // __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__

View File

@@ -1,160 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* 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"
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;
/* the groove expands to the size of the slider by default. by giving it a height,
it has a fixed size */
height: 8px;
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;
/* handle is placed by default on the contents rect of the groove.
Expand outside the groove */
margin: -2px 0;
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);
MainWindow window;
window.show();
return app.exec();
}

View File

@@ -1,398 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* 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 "configurationwidget.h"
#include "controlwidget.h"
#include "informationwidget.h"
#include "timelinewidget.h"
#include <QGridLayout>
#include <QPushButton>
#include <QTextEdit>
#include <QThread>
#include <array>
#include <cstdint>
namespace {
QByteArray continuousData;
}
template <typename T>
T readFromBuffer(char* buffer, size_t& currentReadLocation) {
union {
T value;
std::array<char, sizeof(T)> data;
} b;
std::memmove(b.data.data(), buffer + currentReadLocation, sizeof(T));
currentReadLocation += sizeof(T);
return b.value;
}
template <>
std::string readFromBuffer(char* buffer, size_t& currentReadLocation) {
uint8_t size = readFromBuffer<uint8_t>(buffer, currentReadLocation);
std::string result(buffer + currentReadLocation, buffer + currentReadLocation + size);
currentReadLocation += size;
return result;
}
MainWindow::MainWindow()
: QWidget(nullptr)
, _configurationWidget(nullptr)
, _timeControlWidget(nullptr)
, _informationWidget(nullptr)
, _timelineWidget(nullptr)
, _socket(nullptr)
{
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;
layout->addWidget(_configurationWidget, 0, 0);
layout->addWidget(_timeControlWidget, 1, 0);
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)),
this, SLOT(sendScript(QString))
);
setLayout(layout);
_configurationWidget->socketDisconnected();
_timeControlWidget->socketDisconnected();
_informationWidget->socketDisconnected();
_timelineWidget->socketDisconnected();
}
MainWindow::~MainWindow() {
delete _socket;
}
void MainWindow::onConnect(QString host, QString port) {
delete _socket;
_socket = new QTcpSocket(this);
QObject::connect(_socket, SIGNAL(readyRead()), SLOT(readTcpData()));
QObject::connect(_socket, SIGNAL(connected()), SLOT(onSocketConnected()));
QObject::connect(_socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected()));
_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 MessageTypeMappingIdentifier = 1;
static const uint16_t MessageTypeInitialMessageFinished = 2;
static const uint16_t MessageTypePlayBookLabel = 3;
static const uint16_t MessageTypePlayBookHongKang = 4;
QByteArray data = continuousData.append(_socket->readAll());
// int d = data.size();
if (QString(data) == "Connected to SGCT!\r\n") {
continuousData.clear();
return;
}
if (QString(data) == "OK\r\n") {
continuousData.clear();
return;
}
if (data.size() != 42)
qDebug() << QString(data);
QByteArray messageTypeData = data.left(2);
union {
uint16_t value;
std::array<char, 2> data;
} messageType;
std::memcpy(messageType.data.data(), messageTypeData.data(), sizeof(uint16_t));
switch (messageType.value) {
case MessageTypeStatus:
break;
case MessageTypeMappingIdentifier:
qDebug() << "Mapping Identifier received";
printMapping(data.mid(2));
continuousData.clear();
break;
case MessageTypeInitialMessageFinished:
qDebug() << "InitialMessageFinished received";
break;
case MessageTypePlayBookHongKang:
qDebug() << "Hong Kang Playbook received";
break;
case MessageTypePlayBookLabel:
qDebug() << "Label Playbook received";
break;
default:
qDebug() << "Unknown message of type '" << messageType.value << "'";
}
switch (messageType.value) {
case MessageTypeStatus:
{
if (_isConnected)
handleStatusMessage(data.mid(2));
continuousData.clear();
break;
}
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);
//qDebug() << "Begin reading data";
while (_socket->waitForReadyRead() && data.size() < int(size)) {
//qDebug() << ".";
//_socket->read
//data = data.append(_socket->re)
data = data.append(_socket->readAll());
//data = data.append(_socket->read(int(size) - data.size()));
//QThread::msleep(50);
}
//qDebug() << "Finished reading data. Handling playbook";
continuousData = handlePlaybook(data.mid(2));
//qDebug() << "Finished handling playbook";
//if (messageType.value == MessageTypePlayBookHongKang)
// _hasHongKangTimeline = true;
//if (messageType.value == MessageTypePlayBookLabel)
// _hasLabelTimeline = true;
//if (_hasHongKangTimeline && _hasLabelTimeline) {
// fullyConnected();
//}
break;
}
case MessageTypeInitialMessageFinished:
_isConnected = true;
fullyConnected();
continuousData.clear();
break;
default:
qDebug() << QString(data);
}
}
void MainWindow::handleStatusMessage(QByteArray data) {
const char* buffer = data.data();
union {
double value;
std::array<char, 8> buffer;
} et;
std::memmove(et.buffer.data(), buffer, sizeof(double));
std::vector<char> timeString(24);
std::memmove(timeString.data(), buffer + sizeof(double), 24);
union {
double value;
std::array<char, 8> buffer;
} delta;
std::memmove(delta.buffer.data(), buffer + sizeof(double) + 24, sizeof(double));
_timeControlWidget->update(
QString::fromStdString(std::string(timeString.begin(), timeString.end())),
QString::number(delta.value)
);
_timelineWidget->setCurrentTime(
std::string(timeString.begin(), timeString.end()),
et.value
);
}
std::vector<std::string> instrumentsFromId(uint16_t instrumentId,
std::map<uint16_t, std::string> instrumentMap)
{
std::vector<std::string> results;
for (int i = 0; i < 16; ++i) {
uint16_t testValue = 1 << i;
if ((testValue & instrumentId) != 0) {
std::string t = instrumentMap.at(testValue);
if (t.empty()) {
qDebug() << "Empty instrument";
}
results.push_back(t);
}
}
return results;
}
QByteArray MainWindow::handlePlaybook(QByteArray data) {
char* buffer = data.data();
size_t currentReadLocation = 0;
uint32_t totalData = readFromBuffer<uint32_t>(buffer, currentReadLocation);
uint8_t nTargets = readFromBuffer<uint8_t>(buffer, currentReadLocation);
qDebug() << "Targets: " << nTargets;
std::map<uint8_t, std::string> targetMap;
for (uint8_t i = 0; i < nTargets; ++i) {
uint8_t id = readFromBuffer<uint8_t>(buffer, currentReadLocation);
std::string value = readFromBuffer<std::string>(buffer, currentReadLocation);
qDebug() << QString::fromStdString(value);
targetMap[id] = value;
}
uint8_t nInstruments = readFromBuffer<uint8_t>(buffer, currentReadLocation);
qDebug() << "Instruments: " << nInstruments;
std::map<uint16_t, std::string> instrumentMap;
for (uint8_t i = 0; i < nInstruments; ++i) {
uint16_t id = readFromBuffer<uint16_t>(buffer, currentReadLocation);
std::string value = readFromBuffer<std::string>(buffer, currentReadLocation);
qDebug() << QString::fromStdString(value);
instrumentMap[id] = value;
}
uint32_t nImages = readFromBuffer<uint32_t>(buffer, currentReadLocation);
std::vector<Image> images;
for (uint32_t i = 0; i < nImages; ++i) {
Image image;
image.beginning = readFromBuffer<double>(buffer, currentReadLocation);
image.ending = readFromBuffer<double>(buffer, currentReadLocation);
image.beginningString = readFromBuffer<std::string>(buffer, currentReadLocation);
image.endingString = readFromBuffer<std::string>(buffer, currentReadLocation);
uint8_t targetId = readFromBuffer<uint8_t>(buffer, currentReadLocation);
uint16_t instrumentId = readFromBuffer<uint16_t>(buffer, currentReadLocation);
image.target = targetMap[targetId];
image.instruments = instrumentsFromId(instrumentId, instrumentMap);
if (image.instruments.empty())
qDebug() << "Instruments were empty";
images.push_back(image);
}
_timelineWidget->setData(
std::move(images),
std::move(targetMap),
std::move(instrumentMap)
);
auto dataSize = data.size();
auto readSize = currentReadLocation;
auto extraBytes = dataSize - readSize;
if (extraBytes > 0) {
return data.mid(currentReadLocation);
}
else {
return QByteArray();
}
}
void MainWindow::sendScript(QString script) {
if (_socket) {
_socket->write(("0" + script + "\r\n").toLatin1());
//QByteArray data = (QString("0") + script).toLocal8Bit();
//qDebug() << data;
//_socket->write(data);
//QThread::msleep(25);
}
//_socket->write(("0" + script + "\r\n").toLatin1());
//_socket->write(("0" + script + "\0").toLatin1());
}
void MainWindow::onSocketConnected() {
_socket->write(QString("1\r\n").toLatin1());
//_socket->write(QString("1").toLatin1());
}
void MainWindow::onSocketDisconnected() {
_configurationWidget->socketDisconnected();
_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();
}
void MainWindow::printMapping(QByteArray data) {
char* buffer = data.data();
size_t currentReadPosition = 0;
uint16_t size = readFromBuffer<uint16_t>(buffer, currentReadPosition);
for (uint16_t i = 0; i < size; ++i) {
uint16_t identifier = readFromBuffer<uint16_t>(buffer, currentReadPosition);
std::string mapping = readFromBuffer<std::string>(buffer, currentReadPosition);
qDebug() << identifier << ": " << QString::fromStdString(mapping);
}
}

View File

@@ -1,74 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__
#define __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__
#include <QWidget>
#include <QTcpSocket>
#include "common.h"
class ConfigurationWidget;
class ControlWidget;
class InformationWidget;
class TimelineWidget;
class MainWindow : public QWidget {
Q_OBJECT
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 readTcpData();
void handleStatusMessage(QByteArray data);
QByteArray handlePlaybook(QByteArray data);
void printMapping(QByteArray data);
void fullyConnected();
private:
ConfigurationWidget* _configurationWidget;
ControlWidget* _timeControlWidget;
InformationWidget* _informationWidget;
TimelineWidget* _timelineWidget;
QTcpSocket* _socket;
bool _isConnected = false;
};
#endif // __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__

View File

@@ -1,304 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* 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 "timelinewidget.h"
#include <QDebug>
#include <QMap>
#include <QPainter>
#include <QPaintEvent>
#include <iostream>
#include <set>
namespace {
static const int LegendHeight = 105;
static const int TimeWidth = 200;
static const int TextOffset = 5;
QMap<QString, QColor> InstrumentColors = {
{ "NH_ALICE_AIRGLOW", QColor(40, 130, 200) },
{ "NH_ALICE_SOC", QColor(49, 234, 219) },
{ "NH_RALPH_LEISA", QColor(139, 86, 152) },
{ "NH_RALPH_MVIC_NIR", QColor(100, 14, 14) },
{ "NH_RALPH_MVIC_METHANE", QColor(211, 154, 31) },
{ "NH_RALPH_MVIC_RED", QColor(175, 18, 18) },
{ "NH_RALPH_MVIC_BLUE", QColor(84, 79, 149) },
{ "NH_LORRI", QColor(149, 219, 32) },
{ "NH_REX", QColor(35, 185, 125) },
{ "NH_RALPH_MVIC_PAN1", QColor(203, 153, 200) },
{ "NH_RALPH_MVIC_FT", QColor(242, 101, 74) },
{ "NH_RALPH_MVIC_PAN2", QColor(180, 180, 140) }
};
//{ "NH_ALICE_AIRGLOW", QColor(82, 145, 57) },
//{ "NH_ALICE_SOC", QColor(241, 231, 48) },
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;
}
TimelineWidget::TimelineWidget(QWidget* parent)
: QWidget(parent)
, _currentTime{"", 0.0}
{
setMinimumWidth(600);
setMinimumHeight(600);
}
void TimelineWidget::paintEvent(QPaintEvent* event) {
QPainter painter(this);
QRectF fullRect = contentsRect();
QRectF contentRect(0, 0, fullRect.width() - 1, fullRect.height() - LegendHeight);
QRectF legendRect(
0,
fullRect.bottom() - LegendHeight,
fullRect.right(),
fullRect.bottom()
);
painter.save();
drawContent(painter, contentRect);
painter.restore();
painter.save();
painter.translate(0, fullRect.height() - LegendHeight);
drawLegend(painter, QRectF(legendRect));
painter.restore();
}
void TimelineWidget::setData(std::vector<Image> images,
std::map<uint8_t, std::string> targetMap,
std::map<uint16_t, std::string> instrumentMap)
{
_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.insert(targetMap.begin(), targetMap.end());
_instrumentMap.insert(instrumentMap.begin(), instrumentMap.end());
_instruments.clear();
std::set<std::string> instruments;
for (auto p : _instrumentMap)
instruments.insert(p.second);
std::copy(instruments.begin(), instruments.end(), std::back_inserter(_instruments));
_targets.clear();
std::set<std::string> targets;
for (auto p : _targetMap)
targets.insert(p.second);
std::copy(targets.begin(), targets.end(), std::back_inserter(_targets));
repaint();
}
void TimelineWidget::drawContent(QPainter& painter, QRectF rect) {
QRectF timelineRect(0, 0, rect.width() - TimeWidth, rect.height());
QRectF dateRect(rect.width() - TimeWidth, 0, TimeWidth, rect.height());
// Draw background
//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;
std::vector<Image*> images;
for (Image& i : _images) {
if (i.beginning <= upperTime && i.ending >= lowerTime)
images.push_back(&i);
}
drawImages(painter, timelineRect, images, lowerTime, upperTime);
// Draw current time
painter.setBrush(QBrush(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)
);
}
void TimelineWidget::drawLegend(QPainter& painter, QRectF rect) {
static const int Padding = 5;
static const int BoxSize = 20;
int currentHorizontalPosition = Padding;
int currentVerticalPosition = Padding + BoxSize + Padding;
// Draw Targets
// Draw Instruments
for (int i = 0; i < _instruments.size(); ++i) {
if (i == _instruments.size() / 3 || i == _instruments.size() * 2 / 3) {
currentVerticalPosition += BoxSize + Padding;
currentHorizontalPosition = Padding;
}
const std::string& instrument = _instruments[i];
;
painter.setBrush(QBrush(InstrumentColors[QString::fromStdString(instrument)]));
painter.setPen(QPen(InstrumentColors[QString::fromStdString(instrument)]));
painter.drawRect(
currentHorizontalPosition,
currentVerticalPosition,
BoxSize,
BoxSize
);
currentHorizontalPosition += BoxSize + Padding;
painter.setPen(QPen(QColor(200, 200, 200)));
//painter.setPen(QPen(Qt::black));
painter.drawText(
currentHorizontalPosition,
currentVerticalPosition + BoxSize / 2 + TextOffset,
InstrumentConversion[QString::fromStdString(instrument)]
);
currentHorizontalPosition += 125;
}
}
void TimelineWidget::setCurrentTime(std::string currentTime, double et) {
_currentTime.time = std::move(currentTime);
_currentTime.et = std::move(et);
repaint();
}
void TimelineWidget::drawImages(
QPainter& painter,
QRectF timelineRect,
std::vector<Image*> images,
double minimumTime, double maximumTime)
{
std::set<std::string> instrumentSet;
for (Image* i : images) {
for (std::string instrument : i->instruments) {
instrumentSet.insert(instrument);
}
}
std::map<std::string, int> instruments;
for (auto it = instrumentSet.begin(); it != instrumentSet.end(); ++it)
instruments[*it] = std::distance(instrumentSet.begin(), it);
for (Image* i : images) {
double tBeg = (i->beginning - minimumTime) / (maximumTime - minimumTime);
tBeg = std::max(tBeg, 0.0);
double tEnd = (i->ending - minimumTime) / (maximumTime - minimumTime);
tEnd = std::min(tEnd, 1.0);
int loc = timelineRect.top() + timelineRect.height() * tBeg;
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);
for (std::string instrument : i->instruments) {
auto it = std::find(_instruments.begin(), _instruments.end(), instrument);
if (it == _instruments.end()) {
qDebug() << "Instrument not found";
}
painter.setBrush(
QBrush(InstrumentColors[QString::fromStdString(instrument)])
);
double width = timelineRect.width() / instruments.size();
double pos = instruments[instrument] * width;
painter.drawRect(pos, loc, width, height);
}
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);
}
}
}
void TimelineWidget::socketConnected() {
setDisabled(false);
}
void TimelineWidget::socketDisconnected() {
setDisabled(true);
_images.clear();
_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 "";
}
}

View File

@@ -1,72 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_APP_TIMELINEVIEW___TIMELINEWIDGET___H__
#define __OPENSPACE_APP_TIMELINEVIEW___TIMELINEWIDGET___H__
#include <QWidget>
#include "common.h"
#include <stdint.h>
#include <map>
#include <vector>
class QPaintEvent;
class TimelineWidget : public QWidget {
Q_OBJECT
public:
TimelineWidget(QWidget* parent);
void setData(std::vector<Image> images, std::map<uint8_t, std::string> targetMap,
std::map<uint16_t, std::string> instrumentMap);
void setCurrentTime(std::string currentTime, double et);
void socketConnected();
void socketDisconnected();
std::string nextTarget() const;
protected:
void paintEvent(QPaintEvent* event);
void drawContent(QPainter& painter, QRectF rect);
void drawLegend(QPainter& painter, QRectF rect);
void drawImages(QPainter& painter, QRectF timelineRect, std::vector<Image*> images,
double minimumTime, double maximumTime);
private:
std::vector<Image> _images;
std::map<uint8_t, std::string> _targetMap;
std::map<uint16_t, std::string> _instrumentMap;
std::vector<std::string> _targets;
std::vector<std::string> _instruments;
struct {
std::string time;
double et;
} _currentTime;
};
#endif // __OPENSPACE_APP_TIMELINEVIEW___TIMELINEWIDGET___H__

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *

View File

@@ -1,26 +1,26 @@
/****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
/****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/space/rendering/renderablesmallbody.h>

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
@@ -21,8 +21,9 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_SPACE___GENERATERDEBRISVOLUMETASK___H__
#define __OPENSPACE_MODULE_SPACE___GENERATERDEBRISVOLUMETASK___H__
#ifndef __OPENSPACE_MODULE_SPACE___GENERATEDEBRISVOLUMETASK___H__
#define __OPENSPACE_MODULE_SPACE___GENERATEDEBRISVOLUMETASK___H__
#include <openspace/util/task.h>
#include <openspace/util/time.h>
@@ -69,11 +70,8 @@ private:
// not sure if it should be local function or hidden function.
//std::vector<KeplerParameters> readTLEFile(const std::string& filename);
};
} // namespace volume
} // namespace openspace

View File

@@ -2,7 +2,7 @@
* *
* OpenSpace *
* *
* Copyright (c) 2014-2019 *
* Copyright (c) 2014-2020 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *

View File

@@ -3,7 +3,7 @@
"""
OpenSpace
Copyright (c) 2014-2018
Copyright (c) 2014-2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
@@ -59,7 +59,7 @@ import os
import re
import sys
current_year = '2019'
current_year = '2020'
is_strict_mode = False
is_silent_mode = False

View File

@@ -1,7 +1,7 @@
"""
OpenSpace
Copyright (c) 2014-2018
Copyright (c) 2014-2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software

View File

@@ -1,7 +1,7 @@
"""
OpenSpace
Copyright (c) 2014-2018
Copyright (c) 2014-2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software

View File

@@ -1,7 +1,7 @@
"""
OpenSpace
Copyright (c) 2014-2018
Copyright (c) 2014-2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software

View File

@@ -1,7 +1,7 @@
"""
OpenSpace
Copyright (c) 2014-2018
Copyright (c) 2014-2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software