From d977024a82ed9275e502bf148bc7d5ce6ac386d7 Mon Sep 17 00:00:00 2001 From: Joakim Kilby Date: Mon, 20 Apr 2015 10:40:01 +0200 Subject: [PATCH 1/5] Changed from absolute path into relative using ${OPENSPACE_DATA} --- src/util/imagesequencer2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/imagesequencer2.cpp b/src/util/imagesequencer2.cpp index a9e2e10567..573b648b4a 100644 --- a/src/util/imagesequencer2.cpp +++ b/src/util/imagesequencer2.cpp @@ -46,7 +46,7 @@ ImageSequencer2* ImageSequencer2::_instance = nullptr; ImageSequencer2::ImageSequencer2() : _hasData(false), -_defaultCaptureImage(absPath("C:/Users/michal/openspace/openspace-data/scene/common/textures/placeholder_blank.png")) +_defaultCaptureImage(absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder_blank.png")) {} From b6da465301b6164872fd3e2698f1688915d38718 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 20 Apr 2015 13:43:10 +0200 Subject: [PATCH 2/5] More changes regarding the absolute/relative paths --- src/util/hongkangparser.cpp | 2 +- src/util/imagesequencer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/hongkangparser.cpp b/src/util/hongkangparser.cpp index 8f700dce35..0628de37c3 100644 --- a/src/util/hongkangparser.cpp +++ b/src/util/hongkangparser.cpp @@ -45,7 +45,7 @@ namespace openspace { std::string spacecraft, ghoul::Dictionary translationDictionary, std::vector potentialTargets) : - _defaultCaptureImage(absPath("C:/Users/michal/openspace/openspace-data/scene/common/textures/placeholder_blank.png")) + _defaultCaptureImage(absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder_blank.png")) { _fileName = fileName; _spacecraft = spacecraft; diff --git a/src/util/imagesequencer.cpp b/src/util/imagesequencer.cpp index db2ee3c0b7..a2541beb9a 100644 --- a/src/util/imagesequencer.cpp +++ b/src/util/imagesequencer.cpp @@ -79,7 +79,7 @@ ImageSequencer::ImageSequencer() , _currentTime(-1.0) , _sequenceIDs(0) , _targetsAdded(false) - , _defaultCaptureImage(absPath("C:/Users/michal/openspace/openspace-data/scene/common/textures/placeholder_blank.png")) + , _defaultCaptureImage(absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder_blank.png")) {} From 411765ab4d77c1715fa967321971373172235957 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 21 Apr 2015 16:22:58 +0200 Subject: [PATCH 3/5] Added new files for GUI --- CMakeLists.txt | 3 +- gui/CMakeLists.txt | 3 +- gui/timelineview/CMakeLists.txt | 10 ++ gui/timelineview/configurationwidget.cpp | 43 ++++++++ gui/timelineview/configurationwidget.h | 45 ++++++++ gui/timelineview/informationwidget.cpp | 33 ++++++ gui/timelineview/informationwidget.h | 36 +++++++ gui/timelineview/main.cpp | 35 +++++++ gui/timelineview/mainwindow.cpp | 124 +++++++++++++++++++++++ gui/timelineview/mainwindow.h | 56 ++++++++++ gui/timelineview/timecontrolwidget.cpp | 62 ++++++++++++ gui/timelineview/timecontrolwidget.h | 51 ++++++++++ gui/timelineview/timelinewidget.cpp | 42 ++++++++ gui/timelineview/timelinewidget.h | 42 ++++++++ 14 files changed, 582 insertions(+), 3 deletions(-) create mode 100644 gui/timelineview/CMakeLists.txt create mode 100644 gui/timelineview/configurationwidget.cpp create mode 100644 gui/timelineview/configurationwidget.h create mode 100644 gui/timelineview/informationwidget.cpp create mode 100644 gui/timelineview/informationwidget.h create mode 100644 gui/timelineview/main.cpp create mode 100644 gui/timelineview/mainwindow.cpp create mode 100644 gui/timelineview/mainwindow.h create mode 100644 gui/timelineview/timecontrolwidget.cpp create mode 100644 gui/timelineview/timecontrolwidget.h create mode 100644 gui/timelineview/timelinewidget.cpp create mode 100644 gui/timelineview/timelinewidget.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9066fd76bc..85436e1070 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,8 +145,7 @@ endif () ######################################################################################### add_subdirectory(src) - -#add_subdirectory(gui) +add_subdirectory(gui) ######################################################################################### # File Fetch diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index e33b8eb266..1bb6b8c2c7 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -1,3 +1,4 @@ cmake_minimum_required(VERSION 2.8.11) -add_subdirectory(luascriptexternalcontrol) \ No newline at end of file +add_subdirectory(luascriptexternalcontrol) +add_subdirectory(timelineview) \ No newline at end of file diff --git a/gui/timelineview/CMakeLists.txt b/gui/timelineview/CMakeLists.txt new file mode 100644 index 0000000000..6fbd84d5bb --- /dev/null +++ b/gui/timelineview/CMakeLists.txt @@ -0,0 +1,10 @@ +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) +add_executable(TimelineView WIN32 main.cpp mainwindow.cpp configurationwidget.cpp informationwidget.cpp timecontrolwidget.cpp timelinewidget.cpp) +target_link_libraries(TimelineView Qt5::Widgets Qt5::Network) \ No newline at end of file diff --git a/gui/timelineview/configurationwidget.cpp b/gui/timelineview/configurationwidget.cpp new file mode 100644 index 0000000000..a678a2a14f --- /dev/null +++ b/gui/timelineview/configurationwidget.cpp @@ -0,0 +1,43 @@ +/***************************************************************************************** + * * + * 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 "configurationwidget.h" + +#include + +ConfigurationWidget::ConfigurationWidget(QWidget* parent) + : QWidget(parent) + , _ipAddress(new QLineEdit) + , _connect(new QPushButton("Connect")) + , _playbook(new QLineEdit) + , _load(new QPushButton("Load")) +{ + QGridLayout* layout = new QGridLayout; + layout->addWidget(_ipAddress, 0, 0); + layout->addWidget(_connect, 0, 1); + layout->addWidget(_playbook, 1, 0); + layout->addWidget(_load, 1, 1); + + setLayout(layout); +} diff --git a/gui/timelineview/configurationwidget.h b/gui/timelineview/configurationwidget.h new file mode 100644 index 0000000000..82c32a89c8 --- /dev/null +++ b/gui/timelineview/configurationwidget.h @@ -0,0 +1,45 @@ +/***************************************************************************************** + * * + * 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 __CONFIGURATIONWIDGET_H__ +#define __CONFIGURATIONWIDGET_H__ + +#include +#include +#include + +class ConfigurationWidget : public QWidget { +Q_OBJECT +public: + ConfigurationWidget(QWidget* parent); + +private: + QLineEdit* _ipAddress; + QPushButton* _connect; + + QLineEdit* _playbook; + QPushButton* _load; +}; + +#endif // __CONFIGURATIONWIDGET_H__ diff --git a/gui/timelineview/informationwidget.cpp b/gui/timelineview/informationwidget.cpp new file mode 100644 index 0000000000..f53147b510 --- /dev/null +++ b/gui/timelineview/informationwidget.cpp @@ -0,0 +1,33 @@ +/***************************************************************************************** + * * + * 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 "informationwidget.h" + +#include +#include + +InformationWidget::InformationWidget(QWidget* parent) + : QTextEdit(parent) +{ +} diff --git a/gui/timelineview/informationwidget.h b/gui/timelineview/informationwidget.h new file mode 100644 index 0000000000..b0f4df3aed --- /dev/null +++ b/gui/timelineview/informationwidget.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 __INFORMATIONWIDGET_H__ +#define __INFORMATIONWIDGET_H__ + +#include + +class InformationWidget : public QTextEdit { +Q_OBJECT +public: + InformationWidget(QWidget* parent); +}; + +#endif // __INFORMATIONWIDGET_H__ diff --git a/gui/timelineview/main.cpp b/gui/timelineview/main.cpp new file mode 100644 index 0000000000..e349172d9a --- /dev/null +++ b/gui/timelineview/main.cpp @@ -0,0 +1,35 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#include +#include "mainwindow.h" + +int main(int argc, char** argv) { + QApplication app(argc, argv); + + MainWindow window; + window.show(); + + return app.exec(); +} diff --git a/gui/timelineview/mainwindow.cpp b/gui/timelineview/mainwindow.cpp new file mode 100644 index 0000000000..4bb9ed8a53 --- /dev/null +++ b/gui/timelineview/mainwindow.cpp @@ -0,0 +1,124 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#include "mainwindow.h" + +#include "configurationwidget.h" +#include "timecontrolwidget.h" +#include "informationwidget.h" +#include "timelinewidget.h" + +#include +#include +#include + +MainWindow::MainWindow() + : QWidget(nullptr) + , _configurationWidget(nullptr) + , _timeControlWidget(nullptr) + , _informationWidget(nullptr) + , _timelineWidget(nullptr) + , _socket(nullptr) +{ + setWindowTitle("OpenSpace Timeline"); + + _configurationWidget = new ConfigurationWidget(this); + _timeControlWidget = new TimeControlWidget(this); + _informationWidget = new InformationWidget(this); + _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); + + + + + + //_ipAddress->setMinimumWidth(200); + //_ipAddress->setText("127.0.0.1"); + //layout->addWidget(_ipAddress, 0, 0); + + //QPushButton* connectButton = new QPushButton("Connect"); + //connect(connectButton, SIGNAL(clicked()), this, SLOT(onConnectButton())); + //connectButton->show(); + //layout->addWidget(connectButton, 0, 1); + + //_command->setMinimumWidth(200); + //layout->addWidget(_command, 1, 0); + + //QPushButton* sendButton = new QPushButton("Send"); + //sendButton->setDefault(true); + //connect(sendButton, SIGNAL(clicked()), this, SLOT(sendCommandButton())); + //layout->addWidget(sendButton, 1, 1); + + //layout->addWidget(_logWindow, 2, 0, 1, 2); + + setLayout(layout); +} + +MainWindow::~MainWindow() { + //delete _command; + //delete _socket; +} + +void MainWindow::readTcpData() { + // QByteArray data = _socket->readAll(); + + //if (_logWindow->toPlainText().isEmpty()) + // _logWindow->setText(data.data()); + //else + // _logWindow->setText(_logWindow->toPlainText() + "\n" + data.data()); +} + +void MainWindow::onConnectButton() { + //delete _socket; + // + //_socket = new QTcpSocket(this); + // connect( _socket, SIGNAL(readyRead()), SLOT(readTcpData()) ); + // _socket->connectToHost(_ipAddress->text(), 20500); + +} + +void MainWindow::sendCommandButton() { + //if (!_socket) { + // if (_logWindow->toPlainText().isEmpty()) + // _logWindow->setText("No connection found"); + // else + // _logWindow->setText(_logWindow->toPlainText() + "\n" + "No connection found"); + // return; + //} + + //QString command = _command->text(); + + //if (_logWindow->toPlainText().isEmpty()) + // _logWindow->setText(command); + //else + // _logWindow->setText(_logWindow->toPlainText() + "\n" + command); + + // + //_socket->write(("0" + command + "\r\n").toLatin1()); +} diff --git a/gui/timelineview/mainwindow.h b/gui/timelineview/mainwindow.h new file mode 100644 index 0000000000..e5c1984f72 --- /dev/null +++ b/gui/timelineview/mainwindow.h @@ -0,0 +1,56 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __MAINWINDOW_H__ +#define __MAINWINDOW_H__ + +#include +#include + +class ConfigurationWidget; +class TimeControlWidget; +class InformationWidget; +class TimelineWidget; + +class MainWindow : public QWidget { +Q_OBJECT +public: + MainWindow(); + ~MainWindow(); + +private slots: + void onConnectButton(); + void sendCommandButton(); + void readTcpData(); + +private: + ConfigurationWidget* _configurationWidget; + TimeControlWidget* _timeControlWidget; + InformationWidget* _informationWidget; + TimelineWidget* _timelineWidget; + + QTcpSocket* _socket; +}; + +#endif // __MAINWINDOW_H__ diff --git a/gui/timelineview/timecontrolwidget.cpp b/gui/timelineview/timecontrolwidget.cpp new file mode 100644 index 0000000000..a838b1dcfd --- /dev/null +++ b/gui/timelineview/timecontrolwidget.cpp @@ -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. * + ****************************************************************************************/ + +#include "timecontrolwidget.h" + +#include +#include +#include +#include +#include +#include + +TimeControlWidget::TimeControlWidget(QWidget* parent) + : QWidget(parent) + , _currentTime(new QLabel("Current Time")) + , _setTime(new QComboBox) + , _currentDelta(new QLabel("Current Delta")) + , _setDelta(new QSlider(Qt::Horizontal)) + , _rewind(new QPushButton("<<")) + , _pause(new QPushButton("||")) + , _play(new QPushButton("|>")) + , _forward(new QPushButton(">>")) +{ + QGridLayout* layout = new QGridLayout; + + layout->addWidget(_currentTime, 0, 0); + layout->addWidget(_setTime, 0, 1); + layout->addWidget(_currentDelta, 1, 0); + layout->addWidget(_setDelta, 2, 0, 1, 2); + + QWidget* controlContainer = new QWidget; + QHBoxLayout* controlContainerLayout = new QHBoxLayout; + controlContainerLayout->addWidget(_rewind); + controlContainerLayout->addWidget(_pause); + controlContainerLayout->addWidget(_play); + controlContainerLayout->addWidget(_forward); + controlContainer->setLayout(controlContainerLayout); + layout->addWidget(controlContainer, 3, 0, 1, 2); + + setLayout(layout); +} diff --git a/gui/timelineview/timecontrolwidget.h b/gui/timelineview/timecontrolwidget.h new file mode 100644 index 0000000000..66edc5586b --- /dev/null +++ b/gui/timelineview/timecontrolwidget.h @@ -0,0 +1,51 @@ +/***************************************************************************************** + * * + * 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 __TIMECONTROLWIDGET_H__ +#define __TIMECONTROLWIDGET_H__ + +#include + +class QComboBox; +class QLabel; +class QPushButton; +class QSlider; + +class TimeControlWidget : public QWidget { +Q_OBJECT +public: + TimeControlWidget(QWidget* parent); + +private: + QLabel* _currentTime; + QComboBox* _setTime; + QLabel* _currentDelta; + QSlider* _setDelta; + QPushButton* _rewind; + QPushButton* _pause; + QPushButton* _play; + QPushButton* _forward; +}; + +#endif // __TIMECONTROLWIDGET_H__ diff --git a/gui/timelineview/timelinewidget.cpp b/gui/timelineview/timelinewidget.cpp new file mode 100644 index 0000000000..7028482f30 --- /dev/null +++ b/gui/timelineview/timelinewidget.cpp @@ -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. * + ****************************************************************************************/ + +#include "timelinewidget.h" + +#include +#include + +TimelineWidget::TimelineWidget(QWidget* parent) + : QWidget(parent) +{ + setMinimumWidth(300); + setMinimumHeight(500); +} + +void TimelineWidget::paintEvent(QPaintEvent* event) { + QPainter painter(this); + + painter.setBrush(QBrush(Qt::white)); + painter.drawRect(contentsRect()); +} diff --git a/gui/timelineview/timelinewidget.h b/gui/timelineview/timelinewidget.h new file mode 100644 index 0000000000..def40ffe6c --- /dev/null +++ b/gui/timelineview/timelinewidget.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 __TIMELINEWIDGET_H__ +#define __TIMELINEWIDGET_H__ + +#include + +class QPaintEvent; + +class TimelineWidget : public QWidget { +Q_OBJECT +public: + TimelineWidget(QWidget* parent); + +protected: + void paintEvent(QPaintEvent* event); + +}; + +#endif // __TIMELINEWIDGET_H__ From 19417d87c891146bcc1445f80527516a42ef64c5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 22 Apr 2015 18:22:19 +0200 Subject: [PATCH 4/5] Moved networking functions into their own engine class --- include/openspace/engine/openspaceengine.h | 2 + include/openspace/network/networkengine.h | 43 ++++++++++ include/openspace/util/time.h | 2 +- src/CMakeLists.txt | 6 ++ src/engine/openspaceengine.cpp | 17 ++-- src/network/networkengine.cpp | 97 ++++++++++++++++++++++ 6 files changed, 154 insertions(+), 13 deletions(-) create mode 100644 include/openspace/network/networkengine.h create mode 100644 src/network/networkengine.cpp diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index e6ce8570a7..2beeafa486 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -40,6 +40,7 @@ namespace openspace { class ConfigurationManager; class LuaConsole; +class NetworkEngine; class GUI; class RenderEngine; class SyncBuffer; @@ -111,6 +112,7 @@ private: interaction::InteractionHandler* _interactionHandler; RenderEngine* _renderEngine; scripting::ScriptEngine* _scriptEngine; + NetworkEngine* _networkEngine; ghoul::cmdparser::CommandlineParser* _commandlineParser; LuaConsole* _console; gui::GUI* _gui; diff --git a/include/openspace/network/networkengine.h b/include/openspace/network/networkengine.h new file mode 100644 index 0000000000..1d0c03481a --- /dev/null +++ b/include/openspace/network/networkengine.h @@ -0,0 +1,43 @@ +/***************************************************************************************** + * * + * 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 __NETWORKENGINE_H__ +#define __NETWORKENGINE_H__ + +#include + +namespace openspace { + +class NetworkEngine { +public: + NetworkEngine() = default; + + bool handleMessage(const std::string& message); + + void sendStatusMessage(); +}; + +} // namespace openspace + +#endif // __NETWORKENGINE_H__ \ No newline at end of file diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index b02763709d..1814dee2db 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -51,7 +51,7 @@ namespace openspace { * equal to the frame time. */ - class SyncBuffer; +class SyncBuffer; class Time { public: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6976e276c2..5bfeb38af5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,6 +48,12 @@ file(GLOB ENGINE_HEADER ${HEADER_ROOT_DIR}/openspace/engine/*.h) set(OPENSPACE_HEADER ${OPENSPACE_HEADER} ${ENGINE_HEADER}) source_group(Engine FILES ${ENGINE_SOURCE} ${ENGINE_HEADER}) +file(GLOB NETWORK_SOURCE ${SOURCE_ROOT_DIR}/network/*.cpp) +set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${NETWORK_SOURCE}) +file(GLOB NETWORK_HEADER ${HEADER_ROOT_DIR}/openspace/network/*.h) +set(OPENSPACE_HEADER ${OPENSPACE_HEADER} ${NETWORK_HEADER}) +source_group(Network FILES ${NETWORK_SOURCE} ${NETWORK_HEADER}) + file(GLOB GUI_SOURCE ${SOURCE_ROOT_DIR}/gui/*.cpp) set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${GUI_SOURCE}) file(GLOB GUI_HEADER ${HEADER_ROOT_DIR}/openspace/gui/*.h) diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 132b43e705..4e169dc328 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -94,6 +95,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName) , _interactionHandler(new interaction::InteractionHandler) , _renderEngine(new RenderEngine) , _scriptEngine(new scripting::ScriptEngine) + , _networkEngine(new NetworkEngine) , _commandlineParser(new ghoul::cmdparser::CommandlineParser(programName, true)) , _console(new LuaConsole) , _gui(new gui::GUI) @@ -115,6 +117,7 @@ OpenSpaceEngine::~OpenSpaceEngine() { delete _interactionHandler; delete _renderEngine; delete _scriptEngine; + delete _networkEngine; delete _commandlineParser; delete _console; delete _gui; @@ -700,6 +703,7 @@ void OpenSpaceEngine::encode() { _syncBuffer->write(); } + _networkEngine->sendStatusMessage(); } void OpenSpaceEngine::decode() { @@ -709,7 +713,6 @@ void OpenSpaceEngine::decode() { Time::ref().deserialize(_syncBuffer); _scriptEngine->deserialize(_syncBuffer); _renderEngine->deserialize(_syncBuffer); - } } @@ -719,17 +722,7 @@ void OpenSpaceEngine::externalControlCallback(const char* receivedChars, if (size == 0) return; - // The first byte determines the type of message - const char type = receivedChars[0]; - switch (type) { - case '0': // LuaScript - { - std::string script = std::string(receivedChars + 1); - LINFO("Received Lua Script: '" << script << "'"); - //_scriptEngine->runScript(script); - _scriptEngine->queueScript(script); - } - } + _networkEngine->handleMessage(std::string(receivedChars)); } void OpenSpaceEngine::enableBarrier() { diff --git a/src/network/networkengine.cpp b/src/network/networkengine.cpp new file mode 100644 index 0000000000..1b0c0a2599 --- /dev/null +++ b/src/network/networkengine.cpp @@ -0,0 +1,97 @@ +/***************************************************************************************** + * * + * 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 +#include + +#include "sgct.h" + +namespace { + const std::string _loggerCat = "NetworkEngine"; + + const uint8_t MessageTypeStatus = 0; +} + +namespace openspace { + +bool NetworkEngine::handleMessage(const std::string& message) { + // The first byte determines the type of message + const char type = message[0]; + switch (type) { + case '0': // LuaScript + { + std::string script = message.substr(1); + //LINFO("Received Lua Script: '" << script << "'"); + OsEng.scriptEngine()->queueScript(script); + return true; + } + default: + LERROR("Unknown type '" << type << "'"); + return false; + } + +} + +void NetworkEngine::sendStatusMessage() { + if (!sgct::Engine::instance()->isExternalControlConnected()) + return; + // Protocols: + // 1 byte: type of message + // 8 bytes: time as a ET double + // 24 bytes: time as a UTC string + // 8 bytes: delta time as double + // Total: 41 + + uint16_t messageSize = 0; + + double time = Time::ref().currentTime(); + std::string timeString = Time::ref().currentTimeUTC(); + double delta = Time::ref().deltaTime(); + + messageSize += sizeof(uint8_t); + messageSize += sizeof(time); + messageSize += timeString.length(); + messageSize += sizeof(delta); + + //LINFO(delta); + + ghoul_assert(messageSize == 41, "Message size is not correct"); + + unsigned int currentLocation = 0; + std::vector buffer(messageSize); + + std::memcpy(buffer.data(), &MessageTypeStatus, sizeof(MessageTypeStatus)); + currentLocation += sizeof(MessageTypeStatus); + std::memmove(buffer.data() + currentLocation, &time, sizeof(time)); + currentLocation += sizeof(time); + std::memmove(buffer.data() + currentLocation, timeString.c_str(), timeString.length()); + currentLocation += timeString.length(); + std::memmove(buffer.data() + currentLocation, &delta, sizeof(delta)); + + sgct::Engine::instance()->sendMessageToExternalControl(buffer.data(), messageSize); +} + +} // namespace openspace From 07eaf6d7be570da22ba2c50cef850258e4e32244 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 22 Apr 2015 18:22:40 +0200 Subject: [PATCH 5/5] More work on Timelineview GUI application --- gui/timelineview/CMakeLists.txt | 2 +- gui/timelineview/configurationwidget.cpp | 17 +++- gui/timelineview/configurationwidget.h | 7 ++ gui/timelineview/mainwindow.cpp | 107 ++++++++++++----------- gui/timelineview/mainwindow.h | 10 ++- gui/timelineview/timecontrolwidget.cpp | 69 +++++++++++++++ gui/timelineview/timecontrolwidget.h | 14 +++ 7 files changed, 169 insertions(+), 57 deletions(-) diff --git a/gui/timelineview/CMakeLists.txt b/gui/timelineview/CMakeLists.txt index 6fbd84d5bb..86dd6b9a9c 100644 --- a/gui/timelineview/CMakeLists.txt +++ b/gui/timelineview/CMakeLists.txt @@ -6,5 +6,5 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Widgets) find_package(Qt5Network) -add_executable(TimelineView WIN32 main.cpp mainwindow.cpp configurationwidget.cpp informationwidget.cpp timecontrolwidget.cpp timelinewidget.cpp) +add_executable(TimelineView main.cpp mainwindow.cpp configurationwidget.cpp informationwidget.cpp timecontrolwidget.cpp timelinewidget.cpp) target_link_libraries(TimelineView Qt5::Widgets Qt5::Network) \ No newline at end of file diff --git a/gui/timelineview/configurationwidget.cpp b/gui/timelineview/configurationwidget.cpp index a678a2a14f..900a02d5c1 100644 --- a/gui/timelineview/configurationwidget.cpp +++ b/gui/timelineview/configurationwidget.cpp @@ -28,16 +28,25 @@ ConfigurationWidget::ConfigurationWidget(QWidget* parent) : QWidget(parent) - , _ipAddress(new QLineEdit) + , _ipAddress(new QLineEdit("localhost")) + , _port(new QLineEdit("20500")) , _connect(new QPushButton("Connect")) , _playbook(new QLineEdit) , _load(new QPushButton("Load")) { QGridLayout* layout = new QGridLayout; layout->addWidget(_ipAddress, 0, 0); - layout->addWidget(_connect, 0, 1); - layout->addWidget(_playbook, 1, 0); - layout->addWidget(_load, 1, 1); + layout->addWidget(_port, 0, 1); + layout->addWidget(_connect, 0, 2); + layout->addWidget(_playbook, 1, 0, 1, 2); + layout->addWidget(_load, 1, 2); setLayout(layout); + + QObject::connect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton())); + +} + +void ConfigurationWidget::onConnectButton() { + emit connect(_ipAddress->text(), _port->text()); } diff --git a/gui/timelineview/configurationwidget.h b/gui/timelineview/configurationwidget.h index 82c32a89c8..dfc305005b 100644 --- a/gui/timelineview/configurationwidget.h +++ b/gui/timelineview/configurationwidget.h @@ -34,8 +34,15 @@ Q_OBJECT public: ConfigurationWidget(QWidget* parent); +signals: + void connect(QString host, QString port); + +private slots: + void onConnectButton(); + private: QLineEdit* _ipAddress; + QLineEdit* _port; QPushButton* _connect; QLineEdit* _playbook; diff --git a/gui/timelineview/mainwindow.cpp b/gui/timelineview/mainwindow.cpp index 4bb9ed8a53..a6b2bb9b24 100644 --- a/gui/timelineview/mainwindow.cpp +++ b/gui/timelineview/mainwindow.cpp @@ -33,6 +33,9 @@ #include #include +#include +#include + MainWindow::MainWindow() : QWidget(nullptr) , _configurationWidget(nullptr) @@ -55,70 +58,74 @@ MainWindow::MainWindow() layout->addWidget(_timelineWidget, 0, 1, 3, 1); + QObject::connect( + _configurationWidget, SIGNAL(connect(QString, QString)), + this, SLOT(onConnect(QString, QString)) + ); + QObject::connect( + _timeControlWidget, SIGNAL(scriptActivity(QString)), + this, SLOT(sendScript(QString)) + ); - //_ipAddress->setMinimumWidth(200); - //_ipAddress->setText("127.0.0.1"); - //layout->addWidget(_ipAddress, 0, 0); - - //QPushButton* connectButton = new QPushButton("Connect"); - //connect(connectButton, SIGNAL(clicked()), this, SLOT(onConnectButton())); - //connectButton->show(); - //layout->addWidget(connectButton, 0, 1); - - //_command->setMinimumWidth(200); - //layout->addWidget(_command, 1, 0); - - //QPushButton* sendButton = new QPushButton("Send"); - //sendButton->setDefault(true); - //connect(sendButton, SIGNAL(clicked()), this, SLOT(sendCommandButton())); - //layout->addWidget(sendButton, 1, 1); - - //layout->addWidget(_logWindow, 2, 0, 1, 2); - setLayout(layout); } MainWindow::~MainWindow() { - //delete _command; - //delete _socket; + delete _socket; } +void MainWindow::onConnect(QString host, QString port) { + delete _socket; + + _socket = new QTcpSocket(this); + connect(_socket, SIGNAL(readyRead()), SLOT(readTcpData())); + _socket->connectToHost(host, port.toUInt()); +} + + void MainWindow::readTcpData() { - // QByteArray data = _socket->readAll(); + static const uint8_t MessageTypeStatus = 0; - //if (_logWindow->toPlainText().isEmpty()) - // _logWindow->setText(data.data()); - //else - // _logWindow->setText(_logWindow->toPlainText() + "\n" + data.data()); + QByteArray data = _socket->readAll(); + + if (QString(data) == "Connected to SGCT!\r\n") + return; + if (QString(data) == "OK\r\n") + return; + + uint8_t messageType = data[0]; + + if (messageType == MessageTypeStatus) + handleStatusMessage(data.mid(1)); + handleStatusMessage(data.right(data.length() - 1)); } -void MainWindow::onConnectButton() { - //delete _socket; - // - //_socket = new QTcpSocket(this); - // connect( _socket, SIGNAL(readyRead()), SLOT(readTcpData()) ); - // _socket->connectToHost(_ipAddress->text(), 20500); +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) + ); } -void MainWindow::sendCommandButton() { - //if (!_socket) { - // if (_logWindow->toPlainText().isEmpty()) - // _logWindow->setText("No connection found"); - // else - // _logWindow->setText(_logWindow->toPlainText() + "\n" + "No connection found"); - // return; - //} - - //QString command = _command->text(); - - //if (_logWindow->toPlainText().isEmpty()) - // _logWindow->setText(command); - //else - // _logWindow->setText(_logWindow->toPlainText() + "\n" + command); - - // - //_socket->write(("0" + command + "\r\n").toLatin1()); +void MainWindow::sendScript(QString script) { + _socket->write(("0" + script + "\r\n").toLatin1()); } diff --git a/gui/timelineview/mainwindow.h b/gui/timelineview/mainwindow.h index e5c1984f72..9fdd10b1d3 100644 --- a/gui/timelineview/mainwindow.h +++ b/gui/timelineview/mainwindow.h @@ -39,10 +39,16 @@ public: MainWindow(); ~MainWindow(); +public slots: + void sendScript(QString script); + private slots: - void onConnectButton(); - void sendCommandButton(); + void onConnect(QString host, QString port); + + //void onConnectButton(); + //void sendCommandButton(); void readTcpData(); + void handleStatusMessage(QByteArray data); private: ConfigurationWidget* _configurationWidget; diff --git a/gui/timelineview/timecontrolwidget.cpp b/gui/timelineview/timecontrolwidget.cpp index a838b1dcfd..c2693c7aae 100644 --- a/gui/timelineview/timecontrolwidget.cpp +++ b/gui/timelineview/timecontrolwidget.cpp @@ -42,6 +42,44 @@ TimeControlWidget::TimeControlWidget(QWidget* parent) , _play(new QPushButton("|>")) , _forward(new QPushButton(">>")) { + _setDelta->setMinimum(-100); + _setDelta->setMaximum(100); + _setDelta->setValue(0); + QObject::connect( + _setDelta, + SIGNAL(valueChanged(int)), + this, + SLOT(onValueChange()) + ); + + QObject::connect( + _rewind, + SIGNAL(clicked()), + this, + SLOT(onRewindButton()) + ); + + QObject::connect( + _pause, + SIGNAL(clicked()), + this, + SLOT(onPauseButton()) + ); + + QObject::connect( + _play, + SIGNAL(clicked()), + this, + SLOT(onPlayButton()) + ); + + QObject::connect( + _forward, + SIGNAL(clicked()), + this, + SLOT(onForwardButton()) + ); + QGridLayout* layout = new QGridLayout; layout->addWidget(_currentTime, 0, 0); @@ -60,3 +98,34 @@ TimeControlWidget::TimeControlWidget(QWidget* parent) setLayout(layout); } + +void TimeControlWidget::update(QString currentTime, QString currentDelta) { + _currentTime->setText(currentTime); + _currentDelta->setText(currentDelta); +} + +void TimeControlWidget::onValueChange() { + QString script = "openspace.time.setDeltaTime(" + QString::number(_setDelta->value()) + ");"; + emit scriptActivity(script); +} + +void TimeControlWidget::onRewindButton() { + QString script = "openspace.time.setDeltaTime(-openspace.time.deltaTime());"; + emit scriptActivity(script); +} + +void TimeControlWidget::onPauseButton() { + QString script = "openspace.time.setPause(true);"; + emit scriptActivity(script); +} + +void TimeControlWidget::onPlayButton() { + QString script = "openspace.time.setPause(false);"; + emit scriptActivity(script); +} + +void TimeControlWidget::onForwardButton() { + QString script = "openspace.time.setDeltaTime(-openspace.time.deltaTime());"; + emit scriptActivity(script); + +} diff --git a/gui/timelineview/timecontrolwidget.h b/gui/timelineview/timecontrolwidget.h index 66edc5586b..8265184cf3 100644 --- a/gui/timelineview/timecontrolwidget.h +++ b/gui/timelineview/timecontrolwidget.h @@ -37,6 +37,18 @@ Q_OBJECT public: TimeControlWidget(QWidget* parent); + void update(QString currentTime, QString currentDelta); + +signals: + void scriptActivity(QString script); + +private slots: + void onValueChange(); + void onRewindButton(); + void onPauseButton(); + void onPlayButton(); + void onForwardButton(); + private: QLabel* _currentTime; QComboBox* _setTime; @@ -46,6 +58,8 @@ private: QPushButton* _pause; QPushButton* _play; QPushButton* _forward; + + bool _stateNoNotification = false; }; #endif // __TIMECONTROLWIDGET_H__