diff --git a/CMakeLists.txt b/CMakeLists.txt index 8144a87665..f6735892f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,12 +22,13 @@ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # ######################################################################################### -cmake_minimum_required (VERSION 3.0) +cmake_minimum_required (VERSION 3.0 FATAL_ERROR) project (OpenSpace) message(STATUS "Generating OpenSpace project") set(OPENSPACE_BASE_DIR "${PROJECT_SOURCE_DIR}") +set(OPENSPACE_APPS_DIR "${OPENSPACE_BASE_DIR}/apps") set(OPENSPACE_EXT_DIR "${OPENSPACE_BASE_DIR}/ext") set(OPENSPACE_MODULE_DIR "${OPENSPACE_BASE_DIR}/modules") set(OPENSPACE_CMAKE_EXT_DIR "${OPENSPACE_BASE_DIR}/support/cmake") @@ -48,9 +49,9 @@ option(OPENSPACE_BUILD_GUI_APPLICATIONS "Build GUI Applications" OFF) include(src/CMakeLists.txt) -create_openspace_targets() -set_compile_settings() +create_openspace_target() add_external_dependencies() +handle_applications() if (MSVC) option(OPENSPACE_ENABLE_VLD "Enable the Visual Leak Detector" OFF) diff --git a/apps/Launcher/CMakeLists.txt b/apps/Launcher/CMakeLists.txt new file mode 100644 index 0000000000..2cf98ae128 --- /dev/null +++ b/apps/Launcher/CMakeLists.txt @@ -0,0 +1,64 @@ +######################################################################################### +# # +# 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. # +######################################################################################### + +set(APPLICATION_NAME Launcher) +set(APPLICATION_LINK_TO_OPENSPACE ON) + +set(SOURCE_FILES + ${OPENSPACE_APPS_DIR}/Launcher/main.cpp + ${OPENSPACE_APPS_DIR}/Launcher/mainwindow.cpp + ${OPENSPACE_APPS_DIR}/Launcher/shortcutwidget.cpp + ${OPENSPACE_APPS_DIR}/Launcher/syncwidget.cpp +) + +set(HEADER_FILES + ${OPENSPACE_APPS_DIR}/Launcher/mainwindow.h + ${OPENSPACE_APPS_DIR}/Launcher/shortcutwidget.h + ${OPENSPACE_APPS_DIR}/Launcher/syncwidget.h +) + +find_package(Qt5Widgets) +find_package(Qt5Network) + +qt5_wrap_cpp(MOC_FILES ${HEADER_FILES}) +qt5_add_resources(RESOURCE_FILES ${OPENSPACE_APPS_DIR}/Launcher/files.qrc) + +add_executable(${APPLICATION_NAME} MACOSX_BUNDLE + ${SOURCE_FILES} + ${HEADER_FILES} + ${MOC_FILES} + ${RESOURCE_FILES} +) + +target_link_libraries(${APPLICATION_NAME} + Qt5::Widgets + Qt5::Network +) + +if (APPLE) +INSTALL(CODE " + include(BundleUtilities) + fixup_bundle(\"/Users/alex/Development/OpenSpace/bin/openspace/Debug/Launcher.app/Contents/MacOS/Launcher\" \"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/plugins/platforms/libqcocoa.dylib\" \"\") + " COMPONENT Runtime) +endif () diff --git a/apps/Launcher/files.qrc b/apps/Launcher/files.qrc new file mode 100644 index 0000000000..5661c6a39f --- /dev/null +++ b/apps/Launcher/files.qrc @@ -0,0 +1,5 @@ + + + images/header.png + + diff --git a/apps/Launcher/images/header.png b/apps/Launcher/images/header.png new file mode 100644 index 0000000000..21ced755c8 Binary files /dev/null and b/apps/Launcher/images/header.png differ diff --git a/apps/Launcher/main.cpp b/apps/Launcher/main.cpp new file mode 100644 index 0000000000..b4c17f6d04 --- /dev/null +++ b/apps/Launcher/main.cpp @@ -0,0 +1,155 @@ +/***************************************************************************************** + * * + * 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 + +#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); + MainWindow window; + window.show(); + + return app.exec(); +} diff --git a/apps/Launcher/mainwindow.cpp b/apps/Launcher/mainwindow.cpp new file mode 100644 index 0000000000..138a083a13 --- /dev/null +++ b/apps/Launcher/mainwindow.cpp @@ -0,0 +1,457 @@ +/***************************************************************************************** + * * + * 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 "mainwindow.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + const QSize WindowSize = QSize(640, 480); + + const QString NewsURL = "http://openspace.itn.liu.se/news.txt"; + + const QString ModulesDirectory = "../data/scene"; // temporary ---abock + +#ifdef WIN32 + const QString OpenSpaceExecutable = "OpenSpace.exe"; +#else + const QString OpenSpaceExecutable = "OpenSpace"; +#endif +} + +MainWindow::MainWindow() + : QWidget(nullptr) + , _newsReply(nullptr) + , _informationWidget(nullptr) + , _scenes(nullptr) + , _shortcutWidget(nullptr) + , _syncWidget(nullptr) +{ + setFixedSize(WindowSize); + + QGridLayout* layout = new QGridLayout; + + QLabel* image = new QLabel; + QPixmap p = QPixmap(":/images/header.png"); + image->setPixmap(p.scaledToWidth(WindowSize.width())); + layout->addWidget(image, 0, 0, 1, 2); + + _informationWidget = new QTextEdit(this); + _informationWidget->setReadOnly(true); + layout->addWidget(_informationWidget, 1, 0, 2, 1); + + QWidget* container = new QWidget; + { + QGridLayout* layout = new QGridLayout; + + QLabel* shortcutLabel = new QLabel("Keyboard Shortcuts:"); + layout->addWidget(shortcutLabel, 0, 0); + QPushButton* shortcutButton = new QPushButton("Open..."); + QObject::connect(shortcutButton, SIGNAL(clicked(bool)), + this, SLOT(shortcutButtonPressed()) + ); + layout->addWidget(shortcutButton, 0, 1); + + QLabel* sceneSelectionLabel = new QLabel("Scenes:"); + layout->addWidget(sceneSelectionLabel, 1, 0); + _scenes = new QComboBox; + layout->addWidget(_scenes); + + container->setLayout(layout); + } + layout->addWidget(container, 1, 1); + + container = new QWidget; + { + QBoxLayout* layout = new QHBoxLayout; + + QPushButton* cancelButton = new QPushButton("Cancel"); + QObject::connect( + cancelButton, SIGNAL(clicked(bool)), + QApplication::instance(), SLOT(quit()) + ); + layout->addWidget(cancelButton); + + QPushButton* syncButton = new QPushButton("Sync"); + QObject::connect( + syncButton, SIGNAL(clicked(bool)), + this, SLOT(syncButtonPressed()) + ); + layout->addWidget(syncButton); + + QPushButton* startButton = new QPushButton("Start"); + QObject::connect( + startButton, SIGNAL(clicked(bool)), + this, SLOT(startButtonPressed()) + ); + layout->addWidget(startButton); + + container->setLayout(layout); + } + layout->addWidget(container, 2, 1); + + setLayout(layout); + + initialize(); +} + +MainWindow::~MainWindow() { + delete _informationWidget; +} + +void MainWindow::initialize() { + // Get the news information + QNetworkRequest request; + request.setUrl(QUrl(NewsURL)); + + _newsReply = _networkManager.get(request); + QObject::connect(_newsReply, SIGNAL(finished()), + this, SLOT(newsReadyRead()) + ); + QObject::connect(_newsReply, SIGNAL(error(QNetworkReply::NetworkError)), + this, SLOT(newsNetworkError()) + ); + + _shortcutWidget.hide(); + _syncWidget.hide(); + + QDir d(ModulesDirectory); + d.setFilter(QDir::Files); + + QFileInfoList list = d.entryInfoList(); + for (const QFileInfo& i : list) { + _sceneFiles.insert(i.fileName(), i.absoluteFilePath()); + _scenes->addItem(i.fileName()); + } +} + +void MainWindow::shortcutButtonPressed() { + _shortcutWidget.show(); +} + +void MainWindow::syncButtonPressed() { + QString currentScene = _scenes->currentText(); + _syncWidget.setSceneFile(_sceneFiles[currentScene]); + _syncWidget.show(); +} + +void MainWindow::startButtonPressed() { + QProcess* p = new QProcess(this); + p->start(OpenSpaceExecutable); +} + +void MainWindow::newsNetworkError() { + QString error = _newsReply->errorString(); + _informationWidget->setText(error); + _newsReply->deleteLater(); +} + +void MainWindow::newsReadyRead() { + QByteArray data = _newsReply->readAll(); + QString news = QString::fromLatin1(data); + _informationWidget->setText(news); + _newsReply->deleteLater(); +} + +//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 MessageTypePlayBookHongKang = 2; +// static const uint16_t MessageTypePlayBookLabel = 3; +// +// QByteArray data = _socket->readAll(); +// +// if (QString(data) == "Connected to SGCT!\r\n") +// return; +// if (QString(data) == "OK\r\n") +// return; +// +// QByteArray messageTypeData = data.left(2); +// union { +// uint16_t value; +// std::array data; +// } messageType; +// std::memcpy(messageType.data.data(), messageTypeData.data(), sizeof(uint16_t)); +// +// switch (messageType.value) { +// case MessageTypeStatus: +// 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 (_hasHongKangTimeline && _hasLabelTimeline) +// handleStatusMessage(data.mid(2)); +// break; +// } +// case MessageTypePlayBookHongKang: +// case MessageTypePlayBookLabel: +// { +// const char* payloadDebug = data.mid(2).data(); +// +// size_t beginning = 0; +// uint32_t size = readFromBuffer(data.mid(2).data(), beginning); +// +// //qDebug() << "Begin reading data"; +// while (_socket->waitForReadyRead() && data.size() < int(size)) { +// //qDebug() << "."; +// data = data.append(_socket->readAll()); +// //data = data.append(_socket->read(int(size) - data.size())); +// QThread::msleep(50); +// } +// //qDebug() << "Finished reading data. Handling playbook"; +// +// 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; +// } +// default: +// qDebug() << QString(data); +// } +// +//} +// +//void MainWindow::handleStatusMessage(QByteArray data) { +// const char* buffer = data.data(); +// +// union { +// double value; +// std::array buffer; +// } et; +// std::memmove(et.buffer.data(), buffer, sizeof(double)); +// +// std::vector timeString(24); +// std::memmove(timeString.data(), buffer + sizeof(double), 24); +// +// union { +// double value; +// std::array 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 instrumentsFromId(uint16_t instrumentId, std::map instrumentMap) { +// std::vector 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; +//} +// +//void MainWindow::handlePlaybook(QByteArray data) { +// char* buffer = data.data(); +// size_t currentReadLocation = 0; +// +// uint32_t totalData = readFromBuffer(buffer, currentReadLocation); +// +// uint8_t nTargets = readFromBuffer(buffer, currentReadLocation); +// qDebug() << "Targets: " << nTargets; +// std::map targetMap; +// for (uint8_t i = 0; i < nTargets; ++i) { +// uint8_t id = readFromBuffer(buffer, currentReadLocation); +// std::string value = readFromBuffer(buffer, currentReadLocation); +// qDebug() << QString::fromStdString(value); +// targetMap[id] = value; +// } +// +// uint8_t nInstruments = readFromBuffer(buffer, currentReadLocation); +// qDebug() << "Instruments: " << nInstruments; +// std::map instrumentMap; +// for (uint8_t i = 0; i < nInstruments; ++i) { +// uint16_t id = readFromBuffer(buffer, currentReadLocation); +// std::string value = readFromBuffer(buffer, currentReadLocation); +// qDebug() << QString::fromStdString(value); +// instrumentMap[id] = value; +// } +// +// uint32_t nImages = readFromBuffer(buffer, currentReadLocation); +// std::vector images; +// for (uint32_t i = 0; i < nImages; ++i) { +// Image image; +// image.beginning = readFromBuffer(buffer, currentReadLocation); +// image.ending = readFromBuffer(buffer, currentReadLocation); +// +// image.beginningString = readFromBuffer(buffer, currentReadLocation); +// image.endingString = readFromBuffer(buffer, currentReadLocation); +// +// uint8_t targetId = readFromBuffer(buffer, currentReadLocation); +// uint16_t instrumentId = readFromBuffer(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)); +// +//} +// +//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(); +//} diff --git a/apps/Launcher/mainwindow.h b/apps/Launcher/mainwindow.h new file mode 100644 index 0000000000..109bc4b0b4 --- /dev/null +++ b/apps/Launcher/mainwindow.h @@ -0,0 +1,108 @@ +/***************************************************************************************** + * * + * 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. * + ****************************************************************************************/ + +#ifndef __MAINWINDOW_H__ +#define __MAINWINDOW_H__ + +#include + +#include "shortcutwidget.h" +#include "syncwidget.h" + +#include +#include +#include +#include + +class QComboBox; +class QNetworkAccessManager; + +class MainWindow : public QWidget { +Q_OBJECT +public: + MainWindow(); + ~MainWindow(); + +private slots: + void shortcutButtonPressed(); + void syncButtonPressed(); + void startButtonPressed(); + + void newsNetworkError(); + void newsReadyRead(); + +private: + void initialize(); + + QNetworkReply* _newsReply; + + QTextEdit* _informationWidget; + + QComboBox* _scenes; + QMap _sceneFiles; + + ShortcutWidget _shortcutWidget; + SyncWidget _syncWidget; + + + QNetworkAccessManager _networkManager; +}; + +//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); +// void handlePlaybook(QByteArray data); +// +// void fullyConnected(); +// +//private: +// ConfigurationWidget* _configurationWidget; +// ControlWidget* _timeControlWidget; +// InformationWidget* _informationWidget; +// TimelineWidget* _timelineWidget; +// +// QTcpSocket* _socket; +// +// bool _hasHongKangTimeline = false; +// bool _hasLabelTimeline = false; +//}; + +#endif // __MAINWINDOW_H__ diff --git a/apps/Launcher/shortcutwidget.cpp b/apps/Launcher/shortcutwidget.cpp new file mode 100644 index 0000000000..899b60c82e --- /dev/null +++ b/apps/Launcher/shortcutwidget.cpp @@ -0,0 +1,29 @@ +/***************************************************************************************** + * * + * 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 "shortcutwidget.h" + +ShortcutWidget::ShortcutWidget(QWidget* parent) + : QWidget(parent) +{} diff --git a/apps/Launcher/shortcutwidget.h b/apps/Launcher/shortcutwidget.h new file mode 100644 index 0000000000..5a06a0d388 --- /dev/null +++ b/apps/Launcher/shortcutwidget.h @@ -0,0 +1,36 @@ +/***************************************************************************************** + * * + * 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. * + ****************************************************************************************/ + +#ifndef __SHORTCUTWIDGET_H__ +#define __SHORTCUTWIDGET_H__ + +#include + +class ShortcutWidget : public QWidget { +Q_OBJECT +public: + ShortcutWidget(QWidget* parent); +}; + +#endif // __SHORTCUTWIDGET_H__ diff --git a/apps/Launcher/syncwidget.cpp b/apps/Launcher/syncwidget.cpp new file mode 100644 index 0000000000..30babbe899 --- /dev/null +++ b/apps/Launcher/syncwidget.cpp @@ -0,0 +1,120 @@ +/***************************************************************************************** + * * + * 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 "syncwidget.h" + +#include +#include +#include + +#include +#include +#include + +namespace { +} + +SyncWidget::SyncWidget(QWidget* parent) + : QWidget(parent) +{ + setFixedSize(500, 500); + + ghoul::initialize(); + +} + +void SyncWidget::setSceneFile(QString scene) { + clear(); + + qDebug() << scene; + + ghoul::Dictionary sceneDictionary; + ghoul::lua::loadDictionaryFromFile( + scene.toStdString(), + sceneDictionary + ); + + ghoul::Dictionary modules; + bool success = sceneDictionary.getValue("Modules", modules); + qDebug() << success; + + QStringList modulesList; + for (int i = 1; i < modules.size(); ++i) { + std::string module = modules.value(std::to_string(i)); + modulesList.append(QString::fromStdString(module)); + } + qDebug() << modulesList; + + QDir sceneDir(scene); + sceneDir.cdUp(); + for (QString module : modulesList) { + QString moduleFile = sceneDir.absoluteFilePath(module + "/" + module + ".mod"); + QString dataFile = sceneDir.absoluteFilePath(module + "/" + module + ".data"); + + qDebug() << module; + qDebug() << moduleFile << QFileInfo(moduleFile).exists(); + qDebug() << dataFile << QFileInfo(dataFile).exists(); + + if (QFileInfo(dataFile).exists()) { + ghoul::Dictionary dataDictionary; + ghoul::lua::loadDictionaryFromFile(dataFile.toStdString(), dataDictionary); + + ghoul::Dictionary directFiles; + ghoul::Dictionary torrentFiles; + + bool found = dataDictionary.getValue("Files", directFiles); + if (found) { + QStringList files; + for (int i = 1; i < directFiles.size(); ++i) { + std::string f = directFiles.value(std::to_string(i)); + files.append(QString::fromStdString(f)); + } + handleDirectFiles(module, files); + } + + found = dataDictionary.getValue("Torrents", torrentFiles); + if (found) { + QStringList torrents; + for (int i = 1; i < torrentFiles.size(); ++i) { + std::string f = torrentFiles.value(std::to_string(i)); + torrents.append(QString::fromStdString(f)); + } + handleTorrentFiles(module, torrents); + } + } + } +} + +void SyncWidget::clear() { + + +} + +void SyncWidget::handleDirectFiles(QString module, QStringList files) { + qDebug() << files; +} + +void SyncWidget::handleTorrentFiles(QString module, QStringList torrents) { + qDebug() << torrents; +} diff --git a/apps/Launcher/syncwidget.h b/apps/Launcher/syncwidget.h new file mode 100644 index 0000000000..ef206914f4 --- /dev/null +++ b/apps/Launcher/syncwidget.h @@ -0,0 +1,42 @@ +/***************************************************************************************** + * * + * 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. * + ****************************************************************************************/ + +#ifndef __SYNCWIDGET_H__ +#define __SYNCWIDGET_H__ + +#include + +class SyncWidget : public QWidget { +public: + SyncWidget(QWidget* parent); + + void setSceneFile(QString scene); + +private: + void clear(); + void handleDirectFiles(QString module, QStringList files); + void handleTorrentFiles(QString module, QStringList torrents); +}; + +#endif // __SYNCWIDGET_H__ diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt new file mode 100644 index 0000000000..a49ee281e8 --- /dev/null +++ b/apps/OpenSpace/CMakeLists.txt @@ -0,0 +1,36 @@ +######################################################################################### +# # +# 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. # +######################################################################################### + +set(APPLICATION_NAME OpenSpace) +set(APPLICATION_LINK_TO_OPENSPACE ON) + +add_executable(${APPLICATION_NAME} ${OPENSPACE_APPS_DIR}/OpenSpace/main.cpp) +target_include_directories(${APPLICATION_NAME} PUBLIC ${OPENSPACE_BASE_DIR}/include) +target_link_libraries(${APPLICATION_NAME} libOpenSpace) + +if (MSVC) + set_target_properties(${APPLICATION_NAME} PROPERTIES LINK_FLAGS + "/NODEFAULTLIB:LIBCMTD.lib /NODEFAULTLIB:LIBCMT.lib" + ) +endif () diff --git a/src/main.cpp b/apps/OpenSpace/main.cpp similarity index 100% rename from src/main.cpp rename to apps/OpenSpace/main.cpp diff --git a/apps/TimelineView/CMakeLists.txt b/apps/TimelineView/CMakeLists.txt new file mode 100644 index 0000000000..284192421e --- /dev/null +++ b/apps/TimelineView/CMakeLists.txt @@ -0,0 +1,62 @@ +######################################################################################### +# # +# 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. # +######################################################################################### + +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/informationwidget.h + ${OPENSPACE_APPS_DIR}/TimelineView/controlwidget.h + ${OPENSPACE_APPS_DIR}/TimelineView/timelinewidget.h +) + +find_package(Qt5Widgets) +find_package(Qt5Network) + +qt5_wrap_cpp(MOC_FILES ${HEADER_FILES}) + +add_executable(${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(\"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/MacOS/TimelineView\" \"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/plugins/platforms/libqcocoa.dylib\" \"\") + " COMPONENT Runtime) +endif () diff --git a/gui/timelineview/common.h b/apps/TimelineView/common.h similarity index 100% rename from gui/timelineview/common.h rename to apps/TimelineView/common.h diff --git a/gui/timelineview/configurationwidget.cpp b/apps/TimelineView/configurationwidget.cpp similarity index 100% rename from gui/timelineview/configurationwidget.cpp rename to apps/TimelineView/configurationwidget.cpp diff --git a/gui/timelineview/configurationwidget.h b/apps/TimelineView/configurationwidget.h similarity index 100% rename from gui/timelineview/configurationwidget.h rename to apps/TimelineView/configurationwidget.h diff --git a/gui/timelineview/controlwidget.cpp b/apps/TimelineView/controlwidget.cpp similarity index 100% rename from gui/timelineview/controlwidget.cpp rename to apps/TimelineView/controlwidget.cpp diff --git a/gui/timelineview/controlwidget.h b/apps/TimelineView/controlwidget.h similarity index 100% rename from gui/timelineview/controlwidget.h rename to apps/TimelineView/controlwidget.h diff --git a/gui/timelineview/informationwidget.cpp b/apps/TimelineView/informationwidget.cpp similarity index 100% rename from gui/timelineview/informationwidget.cpp rename to apps/TimelineView/informationwidget.cpp diff --git a/gui/timelineview/informationwidget.h b/apps/TimelineView/informationwidget.h similarity index 100% rename from gui/timelineview/informationwidget.h rename to apps/TimelineView/informationwidget.h diff --git a/gui/timelineview/main.cpp b/apps/TimelineView/main.cpp similarity index 97% rename from gui/timelineview/main.cpp rename to apps/TimelineView/main.cpp index f864703957..463578f67e 100644 --- a/gui/timelineview/main.cpp +++ b/apps/TimelineView/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * 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 * @@ -149,8 +149,6 @@ int main(int argc, char** argv) { app.setStyleSheet(style); - std::string s = style.toStdString(); - MainWindow window; window.show(); diff --git a/gui/timelineview/mainwindow.cpp b/apps/TimelineView/mainwindow.cpp similarity index 99% rename from gui/timelineview/mainwindow.cpp rename to apps/TimelineView/mainwindow.cpp index 242f916a53..87c030c662 100644 --- a/gui/timelineview/mainwindow.cpp +++ b/apps/TimelineView/mainwindow.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * 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 * diff --git a/gui/timelineview/mainwindow.h b/apps/TimelineView/mainwindow.h similarity index 97% rename from gui/timelineview/mainwindow.h rename to apps/TimelineView/mainwindow.h index 23d85fec0b..c998082e39 100644 --- a/gui/timelineview/mainwindow.h +++ b/apps/TimelineView/mainwindow.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014 * + * 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 * diff --git a/gui/timelineview/timelinewidget.cpp b/apps/TimelineView/timelinewidget.cpp similarity index 100% rename from gui/timelineview/timelinewidget.cpp rename to apps/TimelineView/timelinewidget.cpp diff --git a/gui/timelineview/timelinewidget.h b/apps/TimelineView/timelinewidget.h similarity index 100% rename from gui/timelineview/timelinewidget.h rename to apps/TimelineView/timelinewidget.h diff --git a/ext/ghoul b/ext/ghoul index 712da50047..eb66778e0a 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 712da500477f762a443c09fd23198e93f3958a7a +Subproject commit eb66778e0aaf1809fff1a1476872594a24ac0ac3 diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt deleted file mode 100644 index bcaf2ef502..0000000000 --- a/gui/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) - -add_subdirectory(timelineview) \ No newline at end of file diff --git a/gui/timelineview/CMakeLists.txt b/gui/timelineview/CMakeLists.txt deleted file mode 100644 index 241d78d868..0000000000 --- a/gui/timelineview/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) - -project(TimelineView) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -find_package(Qt5Widgets) -find_package(Qt5Network) -if (APPLE) -add_executable(TimelineView MACOSX_BUNDLE main.cpp mainwindow.cpp configurationwidget.cpp informationwidget.cpp controlwidget.cpp timelinewidget.cpp) -else (APPLE) -add_executable(TimelineView main.cpp mainwindow.cpp configurationwidget.cpp informationwidget.cpp controlwidget.cpp timelinewidget.cpp) -endif () - -target_link_libraries(TimelineView Qt5::Widgets Qt5::Network) - -if (APPLE) -INSTALL(CODE " - include(BundleUtilities) - fixup_bundle(\"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/MacOS/TimelineView\" \"/Users/alex/Development/OpenSpace/bin/openspace/Debug/TimelineView.app/Contents/plugins/platforms/libqcocoa.dylib\" \"\") - " COMPONENT Runtime) -endif () diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h index f1f2e79754..e8aa0e0c52 100644 --- a/include/openspace/scripting/scriptengine.h +++ b/include/openspace/scripting/scriptengine.h @@ -92,7 +92,7 @@ private: lua_State* _state; std::set _registeredLibraries; - + //sync variables std::mutex _mutex; std::vector _queuedScripts; diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index a390bae9a2..7630c78c30 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -155,7 +155,7 @@ bool ModelGeometry::loadObj(const std::string& filename){ // file for the next run } else { - LINFO("Cache for Model'" << filename << "' not found"); + LINFO("Cache for Model '" << filename << "' not found"); } LINFO("Loading Model file '" << filename << "'"); bool success = loadModel(filename); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0e1b46fb41..5842a16686 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -84,10 +84,6 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/util/time_lua.inl ) -set(OPENSPACE_MAIN - ${OPENSPACE_BASE_DIR}/src/main.cpp -) - set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/abuffer/abuffer.h ${OPENSPACE_BASE_DIR}/include/openspace/abuffer/abufferdynamic.h diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 95c69e3f34..f22143dd57 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -157,7 +157,6 @@ bool OpenSpaceEngine::create( LogMgr.addLog(new ConsoleLog); LDEBUG("Initialize FileSystem"); - ghoul::filesystem::FileSystem::initialize(); #ifdef __APPLE__ ghoul::filesystem::File app(argv[0]); @@ -359,8 +358,11 @@ bool OpenSpaceEngine::initialize() { // Load a light and a monospaced font loadFonts(); + LINFO("Initializing GUI"); _gui->initialize(); + + LINFO("Finished initializing"); return true; } @@ -487,7 +489,6 @@ void OpenSpaceEngine::runSettingsScripts() { runScripts(scripts); } - void OpenSpaceEngine::loadFonts() { sgct_text::FontManager::FontPath local = sgct_text::FontManager::FontPath::FontPath_Local; @@ -569,8 +570,11 @@ gui::GUI* OpenSpaceEngine::gui() { } bool OpenSpaceEngine::initializeGL() { + LINFO("Initializing Rendering Engine"); bool success = _renderEngine->initializeGL(); + LINFO("Initializing OnScreen GUI GL"); _gui->initializeGL(); + LINFO("Finished initializing OpenGL"); return success; } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index d915d3d1bb..75e1f7ed9a 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -280,14 +280,17 @@ bool RenderEngine::initializeGL() { _mainCamera->setMaxFov(maxFov); } + LINFO("Initializing ABuffer"); _abuffer->initialize(); + LINFO("Initializing Log"); _log = new ScreenLog(); ghoul::logging::LogManager::ref().addLog(_log); + LINFO("Initializing Visualizer"); _visualizer = new ABufferVisualizer(); - // successful init + LINFO("Finished initializing GL"); return true; } diff --git a/support/cmake/support_macros.cmake b/support/cmake/support_macros.cmake index 1c538ad3fc..bf3a1d45c0 100644 --- a/support/cmake/support_macros.cmake +++ b/support/cmake/support_macros.cmake @@ -64,59 +64,51 @@ endfunction () -function (create_openspace_targets) +function (create_openspace_target) add_library(libOpenSpace STATIC ${OPENSPACE_HEADER} ${OPENSPACE_SOURCE}) target_include_directories(libOpenSpace PUBLIC ${OPENSPACE_BASE_DIR}/include) target_include_directories(libOpenSpace PUBLIC ${OPENSPACE_BASE_DIR}) target_include_directories(libOpenSpace PUBLIC ${CMAKE_BINARY_DIR}/_generated/include) - add_executable(OpenSpace ${OPENSPACE_MAIN}) - target_include_directories(OpenSpace PUBLIC ${OPENSPACE_BASE_DIR}/include) - target_link_libraries(OpenSpace libOpenSpace) + set_compile_settings(libOpenSpace) endfunction () -function (set_compile_settings) +function (set_compile_settings project) if (MSVC) - target_compile_options(libOpenSpace PUBLIC "/MP" "/wd4201" "/wd4127") + target_compile_options(${project} PUBLIC "/MP" "/wd4201" "/wd4127") if (OPENSPACE_WARNINGS_AS_ERRORS) - target_compile_options(libOpenSpace PUBLIC "/WX") - target_compile_options(OpenSpace PUBLIC "/WX") + target_compile_options(${project} PUBLIC "/WX") endif () - - set_target_properties(OpenSpace PROPERTIES LINK_FLAGS - "/NODEFAULTLIB:LIBCMTD.lib /NODEFAULTLIB:LIBCMT.lib" - ) elseif (APPLE) - target_compile_definitions(libOpenSpace PUBLIC "__APPLE__") + target_compile_definitions(${project} PUBLIC "__APPLE__") include (CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) mark_as_advanced(COMPILER_SUPPORTS_CXX11, COMPILER_SUPPORTS_CXX0X) if (COMPILER_SUPPORTS_CXX11) - target_compile_options(libOpenSpace PUBLIC "-std=c++11") + target_compile_options(${project} PUBLIC "-std=c++11") elseif (COMPILER_SUPPORTS_CXX0X) - target_compile_options(libOpenSpace PUBLIC "-std=c++0x") + target_compile_options(${project} PUBLIC "-std=c++0x") else () message(FATAL_ERROR "Compiler does not have C++11 support") endif () if (OPENSPACE_WARNINGS_AS_ERRORS) - target_compile_options(libOpenSpace PUBLIC "-Werror") - target_compile_options(OpenSpace PUBLIC "-Werror") + target_compile_options(${project} PUBLIC "-Werror") endif () - target_compile_options(libOpenSpace PUBLIC "-stdlib=libc++") + target_compile_options(${project} PUBLIC "-stdlib=libc++") - target_include_directories(libOpenSpace PUBLIC "/Developer/Headers/FlatCarbon") + target_include_directories(${project} PUBLIC "/Developer/Headers/FlatCarbon") find_library(COREFOUNDATION_LIBRARY CoreFoundation) find_library(CARBON_LIBRARY Carbon) find_library(COCOA_LIBRARY Carbon) find_library(APP_SERVICES_LIBRARY ApplicationServices) mark_as_advanced(CARBON_LIBRARY COCOA_LIBRARY APP_SERVICES_LIBRARY) - target_link_libraries(libOpenSpace + target_link_libraries(${project} ${CARBON_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COCOA_LIBRARY} @@ -128,20 +120,18 @@ function (set_compile_settings) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) mark_as_advanced(COMPILER_SUPPORTS_CXX11, COMPILER_SUPPORTS_CXX0X) if (COMPILER_SUPPORTS_CXX11) - target_compile_options(libOpenSpace PUBLIC "-std=c++11") + target_compile_options(${project} PUBLIC "-std=c++11") elseif (COMPILER_SUPPORTS_CXX0X) - target_compile_options(libOpenSpace PUBLIC "-std=c++0x") + target_compile_options(${project} PUBLIC "-std=c++0x") else () message(FATAL_ERROR "Compiler does not have C++11 support") endif () if (OPENSPACE_WARNINGS_AS_ERRORS) - target_compile_options(libOpenSpace PUBLIC "-Werror") - target_compile_options(OpenSpace PUBLIC "-Werror") + target_compile_options(${project} PUBLIC "-Werror") endif () - target_compile_options(libOpenSpace PUBLIC "-ggdb" "-Wall" "-Wno-long-long" "-pedantic" "-Wextra") - target_compile_options(OpenSpace PUBLIC "-ggdb" "-Wall" "-Wno-long-long" "-pedantic" "-Wextra") + target_compile_options(${project} PUBLIC "-ggdb" "-Wall" "-Wno-long-long" "-pedantic" "-Wextra") endif () endfunction () @@ -172,18 +162,96 @@ function (add_external_dependencies) find_package(Spice REQUIRED) target_include_directories(libOpenSpace SYSTEM PUBLIC ${SPICE_INCLUDE_DIRS}) target_link_libraries(libOpenSpace ${SPICE_LIBRARIES}) - endfunction () +function (handle_applications) + set(applications "") + set(applications_link_to_openspace "") + + file(GLOB appDirs RELATIVE ${OPENSPACE_APPS_DIR} ${OPENSPACE_APPS_DIR}/*) + list(REMOVE_ITEM appDirs ".DS_Store") # Removing the .DS_Store present on Mac + + set(DEFAULT_APPLICATIONS + "OpenSpace" + ) + mark_as_advanced(DEFAULT_APPLICATIONS) + + foreach (app ${appDirs}) + string(TOUPPER ${app} upper_app) + list (FIND DEFAULT_APPLICATIONS "${app}" _index) + if (${_index} GREATER -1) + # App is a default application + option(OPENSPACE_APPLICATION_${upper_app} "${app} Application" ON) + else () + option(OPENSPACE_APPLICATION_${upper_app} "${app} Application" OFF) + endif() + if (OPENSPACE_APPLICATION_${upper_app}) + unset(APPLICATION_NAME) + unset(APPLICATION_LINK_TO_OPENSPACE) + include(${OPENSPACE_APPS_DIR}/${app}/CMakeLists.txt) + set_compile_settings(${APPLICATION_NAME}) + + if (APPLICATION_LINK_TO_OPENSPACE) + get_property( + OPENSPACE_INCLUDE_DIR + TARGET libOpenSpace + PROPERTY INTERFACE_INCLUDE_DIRECTORIES + ) + target_include_directories(${APPLICATION_NAME} PUBLIC + "${OPENSPACE_BASE_DIR}" + ${OPENSPACE_INCLUDE_DIR} + ) + + get_property( + OPENSPACE_DEFINES + TARGET libOpenSpace + PROPERTY INTERFACE_COMPILE_DEFINITIONS + ) + target_compile_definitions(${APPLICATION_NAME} PUBLIC ${OPENSPACE_DEFINES}) + + target_link_libraries(${APPLICATION_NAME} Ghoul) + target_link_libraries(${APPLICATION_NAME} libOpenSpace) + endif () + + list(APPEND applications ${APPLICATION_NAME}) + list(APPEND applications_link_to_openspace ${APPLICATION_LINK_TO_OPENSPACE}) + unset(APPLICATION_NAME) + unset(APPLICATION_LINK_TO_OPENSPACE) + endif () + endforeach () + + + # option(OPENSPACE_APPLICATION_OPENSPACE "Main OpenSpace Application" ON) + # if (OPENSPACE_APPLICATION_OPENSPACE) + # include(${OPENSPACE_APPS_DIR}/OpenSpace/CMakeLists.txt) + # list(APPEND applications "OpenSpace") + # endif () + set(OPENSPACE_APPLICATIONS ${applications} PARENT_SCOPE) + set(OPENSPACE_APPLICATIONS_LINK_REQUEST ${applications_link_to_openspace} PARENT_SCOPE) + + message(STATUS "Applications:") + list(LENGTH applications len1) + math(EXPR len2 "${len1} - 1") + + foreach(val RANGE ${len2}) + list(GET applications ${val} val1) + list(GET applications_link_to_openspace ${val} val2) + message(STATUS "\t${val1} (Link: ${val2})") + endforeach() +endfunction() + + function (handle_option_vld) if (OPENSPACE_ENABLE_VLD) target_compile_definitions(libOpenSpace PUBLIC "OPENSPACE_ENABLE_VLD") target_link_libraries(libOpenSpace ${OPENSPACE_EXT_DIR}/vld/lib/vld.lib) target_include_directories(libOpenSpace PUBLIC ${OPENSPACE_EXT_DIR}/vld) - copy_files(OpenSpace "${OPENSPACE_EXT_DIR}/vld/bin/vld_x64.dll") + foreach (app ${OPENSPACE_APPLCATIONS}) + copy_files(${app} "${OPENSPACE_EXT_DIR}/vld/bin/vld_x64.dll") + endforeach () endif () endfunction () @@ -298,7 +366,10 @@ function (handle_internal_modules) set(MODULE_HEADERS "") set(MODULE_CLASSES "") - message(STATUS ${sortedModules}) + message(STATUS "Included modules:") + foreach (module ${sortedModules}) + message(STATUS "\t${module}") + endforeach () # Add subdirectories in the correct order foreach (module ${sortedModules}) @@ -306,7 +377,18 @@ function (handle_internal_modules) if (${optionName}) create_library_name(${module} libraryName) add_subdirectory(${OPENSPACE_MODULE_DIR}/${module}) - target_link_libraries(OpenSpace ${libraryName}) + + list(LENGTH OPENSPACE_APPLICATIONS len1) + math(EXPR len2 "${len1} - 1") + + foreach(val RANGE ${len2}) + list(GET OPENSPACE_APPLICATIONS ${val} val1) + list(GET OPENSPACE_APPLICATIONS_LINK_REQUEST ${val} val2) + if (${val2}) + target_link_libraries(${app} ${libraryName}) + endif () + endforeach() + target_link_libraries(libOpenSpace ${libraryName}) create_define_name(${module} defineName) target_compile_definitions(libOpenSpace PUBLIC "${defineName}")