From e54aff1414bcda12c223a0ab59aa75f149a4b940 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 18:53:37 -0700 Subject: [PATCH 01/93] Initial working sgct editor window prototype --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 10 ++ .../ext/launcher/include/launcherwindow.h | 6 +- .../launcher/include/sgctedit/mainwindow.h | 33 +++++ .../launcher/include/sgctedit/monitorbox.h | 73 +++++++++++ .../launcher/include/sgctedit/windowcontrol.h | 73 +++++++++++ .../ext/launcher/src/launcherwindow.cpp | 75 ++++++++--- .../ext/launcher/src/sgctedit/main.cpp | 73 +++++++++++ .../ext/launcher/src/sgctedit/mainwindow.cpp | 61 +++++++++ .../ext/launcher/src/sgctedit/monitorbox.cpp | 123 ++++++++++++++++++ .../launcher/src/sgctedit/windowcontrol.cpp | 61 +++++++++ apps/OpenSpace/main.cpp | 1 + 11 files changed, 568 insertions(+), 21 deletions(-) create mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/mainwindow.h create mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h create mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/mainwindow.cpp create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index 39035ff4b8..b2df7408b6 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -42,6 +42,9 @@ set(HEADER_FILES include/profile/timedialog.h include/profile/profileedit.h include/profile/propertiesdialog.h + include/sgctedit/mainwindow.h + include/sgctedit/monitorbox.h + include/sgctedit/windowcontrol.h ) set(SOURCE_FILES @@ -62,6 +65,10 @@ set(SOURCE_FILES src/profile/timedialog.cpp src/profile/profileedit.cpp src/profile/propertiesdialog.cpp + src/sgctedit/main.cpp + src/sgctedit/mainwindow.cpp + src/sgctedit/monitorbox.cpp + src/sgctedit/windowcontrol.cpp ) set(HEADER_SOURCE @@ -79,6 +86,9 @@ set(HEADER_SOURCE include/profile/timedialog.h include/profile/profileedit.h include/profile/propertiesdialog.h + include/sgctedit/mainwindow.h + include/sgctedit/monitorbox.h + include/sgctedit/windowcontrol.h ) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Widgets REQUIRED) diff --git a/apps/OpenSpace/ext/launcher/include/launcherwindow.h b/apps/OpenSpace/ext/launcher/include/launcherwindow.h index c75c474038..83ac6854f5 100644 --- a/apps/OpenSpace/ext/launcher/include/launcherwindow.h +++ b/apps/OpenSpace/ext/launcher/include/launcherwindow.h @@ -25,9 +25,11 @@ #ifndef __OPENSPACE_UI_LAUNCHER___LAUNCHERWINDOW___H__ #define __OPENSPACE_UI_LAUNCHER___LAUNCHERWINDOW___H__ +#include #include #include +#include "sgctedit/sgctedit.h" #include namespace openspace::configuration { struct Configuration; } @@ -49,7 +51,7 @@ public: * \param parentItem The parent that contains this (and possibly other) children * in the tree structure. */ - LauncherWindow(bool profileEnabled, + LauncherWindow(QApplication& qtApp, bool profileEnabled, const openspace::configuration::Configuration& globalConfig, bool sgctConfigEnabled, std::string sgctConfigName, QWidget* parent); @@ -82,6 +84,7 @@ private: void setBackgroundImage(const std::string& syncPath); void openProfileEditor(const std::string& profile, bool isUserProfile); + void openWindowEditor(); void populateProfilesList(std::string preset); void populateWindowConfigsList(std::string preset); @@ -98,6 +101,7 @@ private: int _userConfigCount = 0; const std::string _sgctConfigName; + QApplication& _qApp; QComboBox* _profileBox = nullptr; QComboBox* _windowConfigBox = nullptr; QLabel* _backgroundImage = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/mainwindow.h b/apps/OpenSpace/ext/launcher/include/sgctedit/mainwindow.h new file mode 100644 index 0000000000..5ed6c7141c --- /dev/null +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/mainwindow.h @@ -0,0 +1,33 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include + +#include + +#include +#include "monitorbox.h" + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + QPushButton* button_; + QTextBrowser* textBrowser_; +/* + QBoxLayout* _layout; + QBoxLayout* _monitorAreaLayout; + std::vector _monitorBoxes = {nullptr, nullptr}; + QPushButton* _addSecondMonitor; +*/ +}; +#endif // MAINWINDOW_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h new file mode 100644 index 0000000000..414712ff83 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -0,0 +1,73 @@ +#ifndef MONITORBOX_H +#define MONITORBOX_H + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +struct ConfigResolution +{ + ConfigResolution(float width, float height) { + _width = width; + _height = height; + } + float _width; + float _height; + + ConfigResolution& operator=(ConfigResolution& rhs) { + _width = rhs._width; + _height = rhs._height; + return *this; + } +}; + +class MonitorBox : public QWidget +{ + Q_OBJECT + +public: + explicit MonitorBox(QLineEdit* size_text_x, QLineEdit* size_text_y, + QWidget *parent = nullptr); + ~MonitorBox(); + void setMonitorResolution(ConfigResolution r); + void setNumWindows(int nWindows); + int numWindows(); + void setWindowSize(int index, ConfigResolution r, ConfigResolution offset); + ConfigResolution windowSize(int index); + +protected: + void paintEvent(QPaintEvent *event) override; + +private slots: + void onSizeXChanged(const QString& newText); + void onSizeYChanged(const QString& newText); + +private: + void redrawMonitor(ConfigResolution); + void redrawWindow(ConfigResolution); + + QLineEdit* _size_x = nullptr; + QLineEdit* _size_y = nullptr; + + ConfigResolution _monitorDimensions; + + std::vector _windowResolutions; + QRectF _monitorRect; + std::vector _windowRect; + float _monitorScaleFactor = 1.0; + float _offset[2] = {10.0, 10.0}; + + float _marginFractionOfWidgetSize = 0.025; + ConfigResolution _monitorWidgetSize; + int _nWindows = 1; +}; + +#endif // MONITORBOX_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h new file mode 100644 index 0000000000..d91d0f9243 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -0,0 +1,73 @@ +#ifndef WINDOWCONTROL_H +#define WINDOWCONTROL_H + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +struct ConfigResolution +{ + ConfigResolution(float width, float height) { + _width = width; + _height = height; + } + float _width; + float _height; + + ConfigResolution& operator=(ConfigResolution& rhs) { + _width = rhs._width; + _height = rhs._height; + return *this; + } +}; + +class WindowControl : public QWidget +{ + Q_OBJECT + +public: + explicit WindowControl(QLineEdit* size_text_x, QLineEdit* size_text_y, + QWidget *parent = nullptr); + ~WindowControl(); + void setMonitorResolution(ConfigResolution r); + void setNumWindows(int nWindows); + int numWindows(); + void setWindowSize(int index, ConfigResolution r, ConfigResolution offset); + ConfigResolution windowSize(int index); + +protected: + void paintEvent(QPaintEvent *event) override; + +private slots: + void onSizeXChanged(const QString& newText); + void onSizeYChanged(const QString& newText); + +private: + void redrawMonitor(ConfigResolution); + void redrawWindow(ConfigResolution); + + QLineEdit* _size_x = nullptr; + QLineEdit* _size_y = nullptr; + + ConfigResolution _monitorDimensions; + + std::vector _windowResolutions; + QRectF _monitorRect; + std::vector _windowRect; + float _monitorScaleFactor = 1.0; + float _offset[2] = {10.0, 10.0}; + + float _marginFractionOfWidgetSize = 0.025; + ConfigResolution _monitorWidgetSize; + int _nWindows = 1; +}; + +#endif // WINDOWCONTROL_H diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 650437baf5..36bafd2c7d 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -61,18 +61,24 @@ namespace { constexpr const QRect ProfileBox( LeftRuler, TopRuler + 110, ItemWidth, ItemHeight ); - constexpr const QRect OptionsLabel(LeftRuler, TopRuler + 180, 151, 24); + constexpr const QRect NewProfileButton( + LeftRuler + 140, TopRuler + 180, SmallItemWidth, SmallItemHeight + ); + constexpr const QRect EditProfileButton( + LeftRuler, TopRuler + 180, SmallItemWidth, SmallItemHeight + ); + constexpr const QRect OptionsLabel(LeftRuler, TopRuler + 230, 151, 24); constexpr const QRect WindowConfigBox( - LeftRuler, TopRuler + 210, ItemWidth, ItemHeight + LeftRuler, TopRuler + 260, ItemWidth, ItemHeight + ); + constexpr const QRect NewWindowButton( + LeftRuler + 140, TopRuler + 330, SmallItemWidth, SmallItemHeight + ); + constexpr const QRect EditWindowButton( + LeftRuler, TopRuler + 330, SmallItemWidth, SmallItemHeight ); constexpr const QRect StartButton( - LeftRuler, TopRuler + 290, ItemWidth, ItemHeight - ); - constexpr const QRect NewButton( - LeftRuler + 140, TopRuler + 380, SmallItemWidth, SmallItemHeight - ); - constexpr const QRect EditButton( - LeftRuler, TopRuler + 380, SmallItemWidth, SmallItemHeight + LeftRuler, TopRuler + 400, ItemWidth, ItemHeight ); } // geometry @@ -138,11 +144,13 @@ namespace { using namespace openspace; -LauncherWindow::LauncherWindow(bool profileEnabled, +LauncherWindow::LauncherWindow(QApplication& qtApp, + bool profileEnabled, const configuration::Configuration& globalConfig, bool sgctConfigEnabled, std::string sgctConfigName, QWidget* parent) : QMainWindow(parent) + , _qApp(qtApp) , _assetPath(absPath(globalConfig.pathTokens.at("ASSETS")).string() + '/') , _userAssetPath(absPath(globalConfig.pathTokens.at("USER_ASSETS")).string() + '/') , _configPath(absPath(globalConfig.pathTokens.at("CONFIG")).string() + '/') @@ -248,20 +256,20 @@ QWidget* LauncherWindow::createCentralWidget() { startButton->setGeometry(geometry::StartButton); startButton->setCursor(Qt::PointingHandCursor); - QPushButton* newButton = new QPushButton("New", centralWidget); + QPushButton* newProfileButton = new QPushButton("New", centralWidget); connect( - newButton, &QPushButton::released, + newProfileButton, &QPushButton::released, [this]() { openProfileEditor("", true); } ); - newButton->setObjectName("small"); - newButton->setGeometry(geometry::NewButton); - newButton->setCursor(Qt::PointingHandCursor); + newProfileButton->setObjectName("small"); + newProfileButton->setGeometry(geometry::NewProfileButton); + newProfileButton->setCursor(Qt::PointingHandCursor); - QPushButton* editButton = new QPushButton("Edit", centralWidget); + QPushButton* editProfileButton = new QPushButton("Edit", centralWidget); connect( - editButton, &QPushButton::released, + editProfileButton, &QPushButton::released, [this]() { const std::string selection = _profileBox->currentText().toStdString(); int selectedIndex = _profileBox->currentIndex(); @@ -269,9 +277,31 @@ QWidget* LauncherWindow::createCentralWidget() { openProfileEditor(selection, isUserProfile); } ); - editButton->setObjectName("small"); - editButton->setGeometry(geometry::EditButton); - editButton->setCursor(Qt::PointingHandCursor); + editProfileButton->setObjectName("small"); + editProfileButton->setGeometry(geometry::EditProfileButton); + editProfileButton->setCursor(Qt::PointingHandCursor); + + QPushButton* newWindowButton = new QPushButton("New", centralWidget); + connect( + newWindowButton, &QPushButton::released, + [this]() { + openWindowEditor(); + } + ); + newWindowButton->setObjectName("small"); + newWindowButton->setGeometry(geometry::NewWindowButton); + newWindowButton->setCursor(Qt::PointingHandCursor); + + QPushButton* editWindowButton = new QPushButton("Edit", centralWidget); + connect( + editWindowButton, &QPushButton::released, + [this]() { + openWindowEditor(); + } + ); + editWindowButton->setObjectName("small"); + editWindowButton->setGeometry(geometry::EditWindowButton); + editWindowButton->setCursor(Qt::PointingHandCursor); return centralWidget; } @@ -468,6 +498,11 @@ void LauncherWindow::openProfileEditor(const std::string& profile, const bool is } } +void LauncherWindow::openWindowEditor() { + SgctEdit editor(this, _qApp); + editor.exec(); +} + bool LauncherWindow::wasLaunchSelected() const { return _shouldLaunch; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp new file mode 100644 index 0000000000..edf36fcaed --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -0,0 +1,73 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "include/monitorbox.h" + + +int main(int argc, char *argv[ ]) +{ + QApplication app(argc, argv); + QMainWindow win(nullptr); + QWidget* centralWidget = new QWidget; + win.setCentralWidget(centralWidget); + + QComboBox* monitorResolutionCombo = new QComboBox(centralWidget); + monitorResolutionCombo->setObjectName("monitorResolution"); + QStringList monitorResolutionTypes = { "640x480", "1280x720", "1920x1080", + "1920x1200", "2560x1440", "2048x1080", "3440x1440", "3840x2160", "7680x4320", + "custom" }; + monitorResolutionCombo->addItems(monitorResolutionTypes); + + QPushButton* toggleNumMonitorsButton + = new QPushButton("Add 2nd Window", centralWidget); + toggleNumMonitorsButton->setObjectName("toggleNumMonitors"); + + QLabel* label_size = new QLabel(centralWidget); + QLabel* label_delim = new QLabel(centralWidget); + QLineEdit* size_x = new QLineEdit("900", centralWidget); + QLineEdit* size_y = new QLineEdit("500", centralWidget); + QIntValidator* _validatorSize_x = new QIntValidator(10, 1920); + QIntValidator* _validatorSize_y = new QIntValidator(10, 1080); + size_x->setValidator(_validatorSize_x); + size_y->setValidator(_validatorSize_y); + MonitorBox* monBox = new MonitorBox(size_x, size_y, centralWidget); + QBoxLayout* layout = new QVBoxLayout(centralWidget); + layout->addWidget(monBox); + layout->addWidget(toggleNumMonitorsButton); + layout->addWidget(monitorResolutionCombo); + QBoxLayout* sizeLayout = new QHBoxLayout(centralWidget); + sizeLayout->addWidget(label_size); + sizeLayout->addWidget(size_x); + sizeLayout->addWidget(label_delim); + sizeLayout->addWidget(size_y); + layout->addLayout(sizeLayout); + + label_size->setText("Size:"); + label_delim->setText(" x "); + + win.setWindowTitle("Test Qt14"); + + int windowSize_x = std::stoi(size_x->text().toStdString()); + int windowSize_y = std::stoi(size_y->text().toStdString()); + monBox->setMonitorResolution({1920, 1080}); + monBox->setNumWindows(1); + monBox->setWindowSize(0, {windowSize_x, 600}, {20, 10}); + monBox->setWindowSize(1, {400, 400}, {1020, 610}); + + win.show(); + app.exec(); + + delete centralWidget; + delete monitorResolutionCombo; + delete toggleNumMonitorsButton; + delete monBox; + delete layout; +} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/mainwindow.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/mainwindow.cpp new file mode 100644 index 0000000000..f55034f2e3 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/mainwindow.cpp @@ -0,0 +1,61 @@ +#include "mainwindow.h" +#include "monitorbox.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + button_ = new QPushButton(tr("Push Me!")); + textBrowser_ = new QTextBrowser(); + + QGridLayout *mainLayout = new QGridLayout; + mainLayout->addWidget(button_,0,0); + mainLayout->addWidget(textBrowser_,1,0); + setLayout(mainLayout); + setWindowTitle(tr("Connecting buttons to processes..")); + +/* _layout = new QVBoxLayout(); + QBoxLayout* _monitorAreaLayout = new QHBoxLayout(); + + QGridLayout* container = new QGridLayout; + container->setColumnStretch(1, 1); + + _addSecondMonitor = new QPushButton("Add Monitor"); + container->addWidget(_addSecondMonitor); + + QLabel* dummyLabel = new QLabel("WTF?"); + container->addWidget(dummyLabel); + + _monitorBoxes[0] = new MonitorBox(this); + _monitorBoxes[0]->setMonitorResolution({1920, 1080}); + _monitorBoxes[0]->setNumWindows(2); + _monitorBoxes[0]->setWindowSize(0, {1000, 600}, {20, 10}); + _monitorBoxes[0]->setWindowSize(1, {400, 400}, {1020, 610}); + + _monitorAreaLayout->addWidget(_monitorBoxes[0]); + //_layout->addLayout(_monitorAreaLayout); + _layout->addWidget(_addSecondMonitor); + _layout->addWidget(dummyLabel); + //_layout->addStretch(1); + //_layout->addLayout(container); + //_layout->addStretch(1); +*/ +} + +MainWindow::~MainWindow() +{ + delete button_; + delete textBrowser_; +/* + if (_monitorAreaLayout) + delete _monitorAreaLayout; + for (MonitorBox* mb : _monitorBoxes) { + if (mb) + delete mb; + } + if (_addSecondMonitor) + delete _addSecondMonitor; + if (_layout) + delete _layout; +*/ +} + diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp new file mode 100644 index 0000000000..7c6f4f1ce9 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -0,0 +1,123 @@ +#include "mainwindow.h" +#include "monitorbox.h" + +MonitorBox::MonitorBox(QLineEdit* size_text_x, QLineEdit* size_text_y, QWidget *parent) + : QWidget(parent) + , _monitorWidgetSize({300.0, 300.0}) + , _monitorDimensions(_monitorWidgetSize._width * (1.0 - _marginFractionOfWidgetSize * 2.0), + _monitorWidgetSize._height * (1.0 - _marginFractionOfWidgetSize * 2.0)) + , _size_x(size_text_x) + , _size_y(size_text_y) +{ + setFixedSize(_monitorWidgetSize._width, _monitorWidgetSize._height); + + _monitorRect = { + _monitorWidgetSize._width * _marginFractionOfWidgetSize, + _monitorWidgetSize._height * _marginFractionOfWidgetSize, + _monitorWidgetSize._width * (1.0 - _marginFractionOfWidgetSize * 2.0), + _monitorWidgetSize._height * (1.0 - _marginFractionOfWidgetSize * 2.0) + }; + + connect(_size_x, SIGNAL(textChanged(const QString&)), this, + SLOT(onSizeXChanged(const QString&))); + connect(_size_y, SIGNAL(textChanged(const QString&)), this, + SLOT(onSizeYChanged(const QString&))); +} + +MonitorBox::~MonitorBox() +{ } + +void MonitorBox::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainter painter(this); + QPen pen = painter.pen(); + painter.setPen(pen); + painter.setPen(Qt::black); + painter.drawRect(_monitorRect); + painter.setPen(Qt::blue); + for (QRectF w : _windowRect) { + painter.drawRect(w); + } +} + +void MonitorBox::onSizeXChanged(const QString& newText) { + ConfigResolution offset(50, 50); + std::string x = newText.toStdString(); + if (!x.empty()) { + _windowResolutions[0]._width = std::stoi(x); + } + setWindowSize(0, _windowResolutions[0], offset); +} + +void MonitorBox::onSizeYChanged(const QString& newText) { + ConfigResolution size(0, 400); + ConfigResolution offset(50, 50); + std::string y = newText.toStdString(); + if (!y.empty()) { + _windowResolutions[0]._height = std::stoi(y); + } + setWindowSize(0, _windowResolutions[0], offset); +} + +void MonitorBox::setMonitorResolution(ConfigResolution r) { + _monitorDimensions = r; + float aspectRatio = r._width / r._height; + float margin = _monitorWidgetSize._width * _marginFractionOfWidgetSize; + if (aspectRatio >= 1.0) { + float newWidth = _monitorWidgetSize._width + * (1.0 - _marginFractionOfWidgetSize * 2.0); + _monitorScaleFactor = newWidth / static_cast(r._width); + float newHeight = newWidth / aspectRatio; + _monitorRect = { + margin, + margin + (_monitorWidgetSize._height - newHeight) / 2.0, + newWidth, + newHeight + }; + } + else { + float newHeight = _monitorWidgetSize._height + * (1.0 - _marginFractionOfWidgetSize * 2.0); + _monitorScaleFactor = newHeight / static_cast(r._height); + float newWidth = newHeight * aspectRatio; + _monitorRect = { + margin + (_monitorWidgetSize._width - newWidth) / 2.0, + margin, + newWidth, + newHeight + }; + } + this->update(); +} + +void MonitorBox::setNumWindows(int nWindows) { + if (nWindows >= 1 && nWindows <= 2) { + _nWindows = nWindows; + while (_windowResolutions.size() < _nWindows) { + _windowResolutions.push_back({0, 0}); + _windowRect.push_back({0, 0, 0, 0}); + } + if (_windowResolutions.size() > _nWindows) { + _windowResolutions.pop_back(); + _windowRect.pop_back(); + } + } +} + +int MonitorBox::numWindows() { + return _nWindows; +} + +void MonitorBox::setWindowSize(int index, ConfigResolution r, ConfigResolution offset) { + if (index <= _nWindows - 1) { + _windowResolutions[index] = r; + } + _windowRect[index] = { + _monitorRect.topLeft().x() + offset._width * _monitorScaleFactor, + _monitorRect.topLeft().y() + offset._height * _monitorScaleFactor, + r._width * _monitorScaleFactor, + r._height * _monitorScaleFactor + }; + this->update(); +} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp new file mode 100644 index 0000000000..f55034f2e3 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -0,0 +1,61 @@ +#include "mainwindow.h" +#include "monitorbox.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + button_ = new QPushButton(tr("Push Me!")); + textBrowser_ = new QTextBrowser(); + + QGridLayout *mainLayout = new QGridLayout; + mainLayout->addWidget(button_,0,0); + mainLayout->addWidget(textBrowser_,1,0); + setLayout(mainLayout); + setWindowTitle(tr("Connecting buttons to processes..")); + +/* _layout = new QVBoxLayout(); + QBoxLayout* _monitorAreaLayout = new QHBoxLayout(); + + QGridLayout* container = new QGridLayout; + container->setColumnStretch(1, 1); + + _addSecondMonitor = new QPushButton("Add Monitor"); + container->addWidget(_addSecondMonitor); + + QLabel* dummyLabel = new QLabel("WTF?"); + container->addWidget(dummyLabel); + + _monitorBoxes[0] = new MonitorBox(this); + _monitorBoxes[0]->setMonitorResolution({1920, 1080}); + _monitorBoxes[0]->setNumWindows(2); + _monitorBoxes[0]->setWindowSize(0, {1000, 600}, {20, 10}); + _monitorBoxes[0]->setWindowSize(1, {400, 400}, {1020, 610}); + + _monitorAreaLayout->addWidget(_monitorBoxes[0]); + //_layout->addLayout(_monitorAreaLayout); + _layout->addWidget(_addSecondMonitor); + _layout->addWidget(dummyLabel); + //_layout->addStretch(1); + //_layout->addLayout(container); + //_layout->addStretch(1); +*/ +} + +MainWindow::~MainWindow() +{ + delete button_; + delete textBrowser_; +/* + if (_monitorAreaLayout) + delete _monitorAreaLayout; + for (MonitorBox* mb : _monitorBoxes) { + if (mb) + delete mb; + } + if (_addSecondMonitor) + delete _addSecondMonitor; + if (_layout) + delete _layout; +*/ +} + diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 480b153cac..a0bd783d19 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -1192,6 +1192,7 @@ int main(int argc, char* argv[]) { #endif // __APPLE__ LauncherWindow win( + app, !hasProfile, *global::configuration, !hasSGCTConfig, From ce1851b05ebd840d275cab60d9fd24ba7e6e02d6 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 18:56:22 -0700 Subject: [PATCH 02/93] Before moving to a new Display class --- .../launcher/include/sgctedit/monitorbox.h | 33 ++-- .../launcher/include/sgctedit/windowcontrol.h | 53 +++---- .../ext/launcher/src/sgctedit/main.cpp | 36 ++--- .../ext/launcher/src/sgctedit/monitorbox.cpp | 129 +++++++--------- .../launcher/src/sgctedit/windowcontrol.cpp | 144 +++++++++++------- 5 files changed, 196 insertions(+), 199 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 414712ff83..fba57cda31 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -12,6 +12,8 @@ #include #include +#include "windowcontrol.h" + struct ConfigResolution { @@ -34,22 +36,20 @@ class MonitorBox : public QWidget Q_OBJECT public: - explicit MonitorBox(QLineEdit* size_text_x, QLineEdit* size_text_y, + explicit MonitorBox(QRect widgetDims, QRect monitorResolution, QWidget *parent = nullptr); ~MonitorBox(); - void setMonitorResolution(ConfigResolution r); - void setNumWindows(int nWindows); + void mapMonitorResolutionToWidgetCoordinates(QRect r); + void mapWindowResolutionToWidgetCoordinates(unsigned int index, const QRectF& w); + void setResolution(QRect& res); int numWindows(); - void setWindowSize(int index, ConfigResolution r, ConfigResolution offset); - ConfigResolution windowSize(int index); + void windowDimensionsChanged(unsigned int index, const QRectF& newDimensions); +// float monitorScaleFactor(); + void addWindowControl(WindowControl* wCtrl); protected: void paintEvent(QPaintEvent *event) override; -private slots: - void onSizeXChanged(const QString& newText); - void onSizeYChanged(const QString& newText); - private: void redrawMonitor(ConfigResolution); void redrawWindow(ConfigResolution); @@ -57,17 +57,22 @@ private: QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; - ConfigResolution _monitorDimensions; + QRect _monitorResolution; + QRectF _monitorDimensionsScaled; + std::vector _windowControl; std::vector _windowResolutions; - QRectF _monitorRect; - std::vector _windowRect; + QRectF _monitorRendering; + std::vector _windowRendering; float _monitorScaleFactor = 1.0; float _offset[2] = {10.0, 10.0}; float _marginFractionOfWidgetSize = 0.025; - ConfigResolution _monitorWidgetSize; - int _nWindows = 1; + QRectF _monitorWidgetSize; + QRectF _monitorBoundaryRect; + float _marginWidget = 5.0; + + unsigned int _nWindows = 0; }; #endif // MONITORBOX_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index d91d0f9243..83b092e089 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -13,61 +13,44 @@ #include -struct ConfigResolution -{ - ConfigResolution(float width, float height) { - _width = width; - _height = height; - } - float _width; - float _height; - - ConfigResolution& operator=(ConfigResolution& rhs) { - _width = rhs._width; - _height = rhs._height; - return *this; - } -}; - class WindowControl : public QWidget { Q_OBJECT public: - explicit WindowControl(QLineEdit* size_text_x, QLineEdit* size_text_y, + explicit WindowControl(unsigned int windowIndex, QRect& widgetDims, QRect& monitorDims, QWidget *parent = nullptr); ~WindowControl(); - void setMonitorResolution(ConfigResolution r); - void setNumWindows(int nWindows); - int numWindows(); - void setWindowSize(int index, ConfigResolution r, ConfigResolution offset); - ConfigResolution windowSize(int index); - -protected: - void paintEvent(QPaintEvent *event) override; + void setDimensions(const QRect& dimensions); + void setWindowScaleFactor(float scaleFactor); + void setWindowChangeCallback(std::function cb); + QRect* dimensions(); + QLineEdit* lineEditSizeWidth(); + QLineEdit* lineEditSizeHeight(); + QLineEdit* lineEditSizeOffsetX(); + QLineEdit* lineEditSizeOffsetY(); private slots: void onSizeXChanged(const QString& newText); void onSizeYChanged(const QString& newText); private: - void redrawMonitor(ConfigResolution); - void redrawWindow(ConfigResolution); + void updateScaledWindowDimensions(); + std::function _windowChangeCallback; QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; + QLineEdit* _offset_x = nullptr; + QLineEdit* _offset_y = nullptr; - ConfigResolution _monitorDimensions; - - std::vector _windowResolutions; - QRectF _monitorRect; - std::vector _windowRect; + QRect _monitorResolution; + QRectF _monitorDimsScaled; + QRect _windowDims; + QRectF _windowDimsScaled; float _monitorScaleFactor = 1.0; - float _offset[2] = {10.0, 10.0}; + int _index = 0; float _marginFractionOfWidgetSize = 0.025; - ConfigResolution _monitorWidgetSize; - int _nWindows = 1; }; #endif // WINDOWCONTROL_H diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index edf36fcaed..be6c383b14 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -10,7 +10,11 @@ #include #include "include/monitorbox.h" +#include "include/windowcontrol.h" +void windowResizedCallback(unsigned int windowIndex, const QRectF& newDims) { + +} int main(int argc, char *argv[ ]) { @@ -19,30 +23,25 @@ int main(int argc, char *argv[ ]) QWidget* centralWidget = new QWidget; win.setCentralWidget(centralWidget); - QComboBox* monitorResolutionCombo = new QComboBox(centralWidget); - monitorResolutionCombo->setObjectName("monitorResolution"); - QStringList monitorResolutionTypes = { "640x480", "1280x720", "1920x1080", - "1920x1200", "2560x1440", "2048x1080", "3440x1440", "3840x2160", "7680x4320", - "custom" }; - monitorResolutionCombo->addItems(monitorResolutionTypes); - + unsigned int monitorResolution[2] = {1920, 1080}; QPushButton* toggleNumMonitorsButton = new QPushButton("Add 2nd Window", centralWidget); toggleNumMonitorsButton->setObjectName("toggleNumMonitors"); QLabel* label_size = new QLabel(centralWidget); QLabel* label_delim = new QLabel(centralWidget); - QLineEdit* size_x = new QLineEdit("900", centralWidget); - QLineEdit* size_y = new QLineEdit("500", centralWidget); - QIntValidator* _validatorSize_x = new QIntValidator(10, 1920); - QIntValidator* _validatorSize_y = new QIntValidator(10, 1080); - size_x->setValidator(_validatorSize_x); - size_y->setValidator(_validatorSize_y); - MonitorBox* monBox = new MonitorBox(size_x, size_y, centralWidget); + + QRect widgetDims(400, 400, 0, 0); + QRect monitorRes(monitorResolution[0], monitorResolution[1], 0, 0); + WindowControl wCtrl(0, widgetDims, monitorRes, centralWidget); + MonitorBox* monBox = new MonitorBox(widgetDims, monitorRes, centralWidget); + monBox->addWindowControl(&wCtrl); + QLineEdit* size_x = wCtrl.lineEditSizeWidth(); + QLineEdit* size_y = wCtrl.lineEditSizeHeight(); + QBoxLayout* layout = new QVBoxLayout(centralWidget); layout->addWidget(monBox); layout->addWidget(toggleNumMonitorsButton); - layout->addWidget(monitorResolutionCombo); QBoxLayout* sizeLayout = new QHBoxLayout(centralWidget); sizeLayout->addWidget(label_size); sizeLayout->addWidget(size_x); @@ -57,16 +56,13 @@ int main(int argc, char *argv[ ]) int windowSize_x = std::stoi(size_x->text().toStdString()); int windowSize_y = std::stoi(size_y->text().toStdString()); - monBox->setMonitorResolution({1920, 1080}); - monBox->setNumWindows(1); - monBox->setWindowSize(0, {windowSize_x, 600}, {20, 10}); - monBox->setWindowSize(1, {400, 400}, {1020, 610}); + QRect defaultMonitorResolution(monitorResolution[0], monitorResolution[1], 0, 0); + monBox->setResolution(defaultMonitorResolution); win.show(); app.exec(); delete centralWidget; - delete monitorResolutionCombo; delete toggleNumMonitorsButton; delete monBox; delete layout; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 7c6f4f1ce9..c7b64ce9a3 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -1,89 +1,70 @@ #include "mainwindow.h" #include "monitorbox.h" -MonitorBox::MonitorBox(QLineEdit* size_text_x, QLineEdit* size_text_y, QWidget *parent) - : QWidget(parent) - , _monitorWidgetSize({300.0, 300.0}) - , _monitorDimensions(_monitorWidgetSize._width * (1.0 - _marginFractionOfWidgetSize * 2.0), - _monitorWidgetSize._height * (1.0 - _marginFractionOfWidgetSize * 2.0)) - , _size_x(size_text_x) - , _size_y(size_text_y) + + +MonitorBox::MonitorBox(QRect widgetDims, QRect monitorResolution, QWidget *parent) + : QWidget(parent) + , _monitorWidgetSize(widgetDims) { - setFixedSize(_monitorWidgetSize._width, _monitorWidgetSize._height); - - _monitorRect = { - _monitorWidgetSize._width * _marginFractionOfWidgetSize, - _monitorWidgetSize._height * _marginFractionOfWidgetSize, - _monitorWidgetSize._width * (1.0 - _marginFractionOfWidgetSize * 2.0), - _monitorWidgetSize._height * (1.0 - _marginFractionOfWidgetSize * 2.0) - }; - - connect(_size_x, SIGNAL(textChanged(const QString&)), this, - SLOT(onSizeXChanged(const QString&))); - connect(_size_y, SIGNAL(textChanged(const QString&)), this, - SLOT(onSizeYChanged(const QString&))); + mapMonitorResolutionToWidgetCoordinates(monitorResolution); } MonitorBox::~MonitorBox() { } +void MonitorBox::addWindowControl(WindowControl* wCtrl) { + if (_nWindows < 2) { + _windowControl.push_back(wCtrl); + _windowControl.back()->setWindowChangeCallback(windowDimensionsChanged); + _nWindows++; + } +} + void MonitorBox::paintEvent(QPaintEvent *event) { Q_UNUSED(event); QPainter painter(this); QPen pen = painter.pen(); painter.setPen(pen); + //Draw monitor outline painter.setPen(Qt::black); - painter.drawRect(_monitorRect); + painter.drawRect(_monitorDimensionsScaled); + //Draw window(s) painter.setPen(Qt::blue); - for (QRectF w : _windowRect) { - painter.drawRect(w); + for (QRectF* w : _windowRendering) { + painter.drawRect(*w); } } -void MonitorBox::onSizeXChanged(const QString& newText) { - ConfigResolution offset(50, 50); - std::string x = newText.toStdString(); - if (!x.empty()) { - _windowResolutions[0]._width = std::stoi(x); - } - setWindowSize(0, _windowResolutions[0], offset); +void MonitorBox::windowDimensionsChanged(unsigned int index, const QRectF& newDimensions) { + mapWindowResolutionToWidgetCoordinates(index, newDimensions); } -void MonitorBox::onSizeYChanged(const QString& newText) { - ConfigResolution size(0, 400); - ConfigResolution offset(50, 50); - std::string y = newText.toStdString(); - if (!y.empty()) { - _windowResolutions[0]._height = std::stoi(y); - } - setWindowSize(0, _windowResolutions[0], offset); -} - -void MonitorBox::setMonitorResolution(ConfigResolution r) { - _monitorDimensions = r; - float aspectRatio = r._width / r._height; - float margin = _monitorWidgetSize._width * _marginFractionOfWidgetSize; +void MonitorBox::mapMonitorResolutionToWidgetCoordinates(QRect r) { +// _monitorResolution = r; + float aspectRatio = r.width() / r.height(); + _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; if (aspectRatio >= 1.0) { - float newWidth = _monitorWidgetSize._width + float newWidth = _monitorWidgetSize.width() * (1.0 - _marginFractionOfWidgetSize * 2.0); - _monitorScaleFactor = newWidth / static_cast(r._width); + _monitorScaleFactor = newWidth / static_cast(r.width()); float newHeight = newWidth / aspectRatio; - _monitorRect = { - margin, - margin + (_monitorWidgetSize._height - newHeight) / 2.0, + _monitorRendering = { + _marginWidget, + _marginWidget + (_monitorWidgetSize.height() - newHeight) / 2.0, newWidth, newHeight }; } else { - float newHeight = _monitorWidgetSize._height + float newHeight = _monitorWidgetSize.height() * (1.0 - _marginFractionOfWidgetSize * 2.0); - _monitorScaleFactor = newHeight / static_cast(r._height); + _monitorScaleFactor = newHeight / static_cast(r.height()); float newWidth = newHeight * aspectRatio; - _monitorRect = { - margin + (_monitorWidgetSize._width - newWidth) / 2.0, - margin, + _monitorRendering = { + _marginWidget + (_monitorWidgetSize.width() - newWidth) / 2.0, + _marginWidget, newWidth, newHeight }; @@ -91,33 +72,29 @@ void MonitorBox::setMonitorResolution(ConfigResolution r) { this->update(); } -void MonitorBox::setNumWindows(int nWindows) { - if (nWindows >= 1 && nWindows <= 2) { - _nWindows = nWindows; - while (_windowResolutions.size() < _nWindows) { - _windowResolutions.push_back({0, 0}); - _windowRect.push_back({0, 0, 0, 0}); - } - if (_windowResolutions.size() > _nWindows) { - _windowResolutions.pop_back(); - _windowRect.pop_back(); +void MonitorBox::setResolution(QRect& res) { + _monitorResolution = res; +} + +void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int index, const QRectF& w) { + if (index < _windowRendering.size() ) { + if (_windowRendering[index]) { + *_windowRendering[index] = { + _marginWidget + _monitorBoundaryRect.topLeft().x() + w.left() * _monitorScaleFactor, + _marginWidget + _monitorBoundaryRect.topLeft().y() + w.top() * _monitorScaleFactor, + w.width() * _monitorScaleFactor, + w.height() * _monitorScaleFactor + }; } +// _windowRendering[index] = w * _monitorScaleFactor; } } +//float MonitorBox::monitorScaleFactor() { +// return _monitorScaleFactor; +//} + int MonitorBox::numWindows() { return _nWindows; } -void MonitorBox::setWindowSize(int index, ConfigResolution r, ConfigResolution offset) { - if (index <= _nWindows - 1) { - _windowResolutions[index] = r; - } - _windowRect[index] = { - _monitorRect.topLeft().x() + offset._width * _monitorScaleFactor, - _monitorRect.topLeft().y() + offset._height * _monitorScaleFactor, - r._width * _monitorScaleFactor, - r._height * _monitorScaleFactor - }; - this->update(); -} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index f55034f2e3..5c0f1f76ee 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -1,61 +1,97 @@ #include "mainwindow.h" #include "monitorbox.h" -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) +WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, + QRect& monitorResolution, QWidget *parent) + : _index(windowIndex) + , _monitorResolution(monitorResolution) + , QWidget(parent) { - button_ = new QPushButton(tr("Push Me!")); - textBrowser_ = new QTextBrowser(); - - QGridLayout *mainLayout = new QGridLayout; - mainLayout->addWidget(button_,0,0); - mainLayout->addWidget(textBrowser_,1,0); - setLayout(mainLayout); - setWindowTitle(tr("Connecting buttons to processes..")); - -/* _layout = new QVBoxLayout(); - QBoxLayout* _monitorAreaLayout = new QHBoxLayout(); - - QGridLayout* container = new QGridLayout; - container->setColumnStretch(1, 1); - - _addSecondMonitor = new QPushButton("Add Monitor"); - container->addWidget(_addSecondMonitor); - - QLabel* dummyLabel = new QLabel("WTF?"); - container->addWidget(dummyLabel); - - _monitorBoxes[0] = new MonitorBox(this); - _monitorBoxes[0]->setMonitorResolution({1920, 1080}); - _monitorBoxes[0]->setNumWindows(2); - _monitorBoxes[0]->setWindowSize(0, {1000, 600}, {20, 10}); - _monitorBoxes[0]->setWindowSize(1, {400, 400}, {1020, 610}); - - _monitorAreaLayout->addWidget(_monitorBoxes[0]); - //_layout->addLayout(_monitorAreaLayout); - _layout->addWidget(_addSecondMonitor); - _layout->addWidget(dummyLabel); - //_layout->addStretch(1); - //_layout->addLayout(container); - //_layout->addStretch(1); -*/ -} - -MainWindow::~MainWindow() -{ - delete button_; - delete textBrowser_; -/* - if (_monitorAreaLayout) - delete _monitorAreaLayout; - for (MonitorBox* mb : _monitorBoxes) { - if (mb) - delete mb; + if (windowIndex == 0) { + _size_x = new QLineEdit("800", parent); + _size_y = new QLineEdit("600", parent); + _offset_x = new QLineEdit("50", parent); + _offset_y = new QLineEdit("50", parent); } - if (_addSecondMonitor) - delete _addSecondMonitor; - if (_layout) - delete _layout; -*/ + else { + _size_x = new QLineEdit("640", parent); + _size_y = new QLineEdit("480", parent); + _offset_x = new QLineEdit("900", parent); + _offset_y = new QLineEdit("400", parent); + } + QIntValidator* _validatorSize_x = new QIntValidator(10, _monitorResolution.width()); + QIntValidator* _validatorSize_y = new QIntValidator(10, _monitorResolution.height()); + QIntValidator* _validatorOffset_x = new QIntValidator(10, _monitorResolution.width() - 10); + QIntValidator* _validatorOffset_y = new QIntValidator(10, _monitorResolution.height() - 10); + + _size_x->setValidator(_validatorSize_x); + _size_y->setValidator(_validatorSize_y); + _offset_x->setValidator(_validatorSize_y); + _offset_y->setValidator(_validatorSize_y); + + connect(_size_x, SIGNAL(textChanged(const QString&)), this, + SLOT(onSizeXChanged(const QString&))); + connect(_size_y, SIGNAL(textChanged(const QString&)), this, + SLOT(onSizeYChanged(const QString&))); +} + +void WindowControl::onSizeXChanged(const QString& newText) { + std::string x = newText.toStdString(); + if (!x.empty()) { + _windowDims.setWidth(std::stoi(x)); + } + if (_windowChangeCallback) { + _windowChangeCallback(_index, _windowDims); + } +} + +void WindowControl::onSizeYChanged(const QString& newText) { + std::string y = newText.toStdString(); + if (!y.empty()) { + _windowDims.setHeight(std::stoi(y)); + } + if (_windowChangeCallback) { + _windowChangeCallback(_index, _windowDims); + } +} + +void WindowControl::setDimensions(const QRect& dimensions) { + _windowDims = dimensions; +} + +void WindowControl::setWindowChangeCallback(std::function cb) { + _windowChangeCallback = cb; +} + +void WindowControl::setWindowScaleFactor(float scaleFactor) { + _monitorScaleFactor = scaleFactor; +} + +QRect* WindowControl::dimensions() { + return &_windowDims; +} + +QLineEdit* WindowControl::lineEditSizeWidth() { + return _size_x; +} + +QLineEdit* WindowControl::lineEditSizeHeight() { + return _size_y; +} + +QLineEdit* WindowControl::lineEditSizeOffsetX() { + return _offset_x; +} + +QLineEdit* WindowControl::lineEditSizeOffsetY() { + return _offset_y; +} + +WindowControl::~WindowControl() +{ + delete _size_x; + delete _size_y; + delete _offset_x; + delete _offset_y; } From 47dafc6cee9caedd470dc6ecbb45518cfa42daf6 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:00:37 -0700 Subject: [PATCH 03/93] Working version after separating components into separate classes --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 6 +- .../ext/launcher/include/sgctedit/display.h | 42 +++++++++ .../launcher/include/sgctedit/mainwindow.h | 33 ------- .../launcher/include/sgctedit/monitorbox.h | 25 +---- .../launcher/include/sgctedit/windowcontrol.h | 11 ++- .../ext/launcher/src/sgctedit/display.cpp | 92 +++++++++++++++++++ .../ext/launcher/src/sgctedit/main.cpp | 49 +--------- .../ext/launcher/src/sgctedit/mainwindow.cpp | 61 ------------ .../ext/launcher/src/sgctedit/monitorbox.cpp | 57 ++++++------ .../launcher/src/sgctedit/windowcontrol.cpp | 41 +++++---- 10 files changed, 198 insertions(+), 219 deletions(-) create mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/display.h delete mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/mainwindow.h create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp delete mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/mainwindow.cpp diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index b2df7408b6..b2f9fae3b8 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -42,7 +42,7 @@ set(HEADER_FILES include/profile/timedialog.h include/profile/profileedit.h include/profile/propertiesdialog.h - include/sgctedit/mainwindow.h + include/sgctedit/display.h include/sgctedit/monitorbox.h include/sgctedit/windowcontrol.h ) @@ -65,8 +65,8 @@ set(SOURCE_FILES src/profile/timedialog.cpp src/profile/profileedit.cpp src/profile/propertiesdialog.cpp + src/sgctedit/display.cpp src/sgctedit/main.cpp - src/sgctedit/mainwindow.cpp src/sgctedit/monitorbox.cpp src/sgctedit/windowcontrol.cpp ) @@ -86,7 +86,7 @@ set(HEADER_SOURCE include/profile/timedialog.h include/profile/profileedit.h include/profile/propertiesdialog.h - include/sgctedit/mainwindow.h + include/sgctedit/display.h include/sgctedit/monitorbox.h include/sgctedit/windowcontrol.h ) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h new file mode 100644 index 0000000000..11f9c3f2a1 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -0,0 +1,42 @@ +#ifndef DISPLAY_H +#define DISPLAY_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "windowcontrol.h" +#include "monitorbox.h" + + +class Display : public QWidget +{ + Q_OBJECT + +public: + explicit Display(); + ~Display(); + static void windowResizedCallback(unsigned int windowIndex, const QRectF& newDims); + +private: + void addWindowControl(); + unsigned int _monitorResolution[2] = {1920, 1080}; + QRect _monitorRes = {0, 0, _monitorResolution[0], _monitorResolution[1]}; + QRect _widgetDims = {0, 0, 400, 400}; + std::vector _windowControl; + unsigned int _nWindows = 0; + QPushButton* _toggleNumMonitorsButton = nullptr; + MonitorBox* _monBox = nullptr; + QBoxLayout* _layout = nullptr; +}; + +#endif // DISPLAY_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/mainwindow.h b/apps/OpenSpace/ext/launcher/include/sgctedit/mainwindow.h deleted file mode 100644 index 5ed6c7141c..0000000000 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/mainwindow.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include - -#include - -#include -#include "monitorbox.h" - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - QPushButton* button_; - QTextBrowser* textBrowser_; -/* - QBoxLayout* _layout; - QBoxLayout* _monitorAreaLayout; - std::vector _monitorBoxes = {nullptr, nullptr}; - QPushButton* _addSecondMonitor; -*/ -}; -#endif // MAINWINDOW_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index fba57cda31..ee5492846c 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -15,22 +15,6 @@ #include "windowcontrol.h" -struct ConfigResolution -{ - ConfigResolution(float width, float height) { - _width = width; - _height = height; - } - float _width; - float _height; - - ConfigResolution& operator=(ConfigResolution& rhs) { - _width = rhs._width; - _height = rhs._height; - return *this; - } -}; - class MonitorBox : public QWidget { Q_OBJECT @@ -43,7 +27,7 @@ public: void mapWindowResolutionToWidgetCoordinates(unsigned int index, const QRectF& w); void setResolution(QRect& res); int numWindows(); - void windowDimensionsChanged(unsigned int index, const QRectF& newDimensions); + void windowDimensionsChanged(unsigned int index, const QRectF newDimensions); // float monitorScaleFactor(); void addWindowControl(WindowControl* wCtrl); @@ -51,18 +35,13 @@ protected: void paintEvent(QPaintEvent *event) override; private: - void redrawMonitor(ConfigResolution); - void redrawWindow(ConfigResolution); - QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; QRect _monitorResolution; QRectF _monitorDimensionsScaled; - std::vector _windowControl; - std::vector _windowResolutions; - QRectF _monitorRendering; + std::vector _windowResolutions; std::vector _windowRendering; float _monitorScaleFactor = 1.0; float _offset[2] = {10.0, 10.0}; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 83b092e089..0845568a65 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -21,10 +21,10 @@ public: explicit WindowControl(unsigned int windowIndex, QRect& widgetDims, QRect& monitorDims, QWidget *parent = nullptr); ~WindowControl(); - void setDimensions(const QRect& dimensions); + void setDimensions(const QRectF& dimensions); void setWindowScaleFactor(float scaleFactor); void setWindowChangeCallback(std::function cb); - QRect* dimensions(); + QRectF& dimensions(); QLineEdit* lineEditSizeWidth(); QLineEdit* lineEditSizeHeight(); QLineEdit* lineEditSizeOffsetX(); @@ -37,7 +37,10 @@ private slots: private: void updateScaledWindowDimensions(); std::function _windowChangeCallback; - + QRectF defaultWindowSizes[2] = { + {50.0, 50.0, 800.0, 600.0}, + {900.0, 400.0, 640.0, 480.0} + }; QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; QLineEdit* _offset_x = nullptr; @@ -45,7 +48,7 @@ private: QRect _monitorResolution; QRectF _monitorDimsScaled; - QRect _windowDims; + QRectF _windowDims; QRectF _windowDimsScaled; float _monitorScaleFactor = 1.0; int _index = 0; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp new file mode 100644 index 0000000000..ead9b4c222 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "include/monitorbox.h" +#include "include/windowcontrol.h" +#include "include/display.h" + + +Display::Display() +{ + _toggleNumMonitorsButton = new QPushButton("Add 2nd Window", this); + _toggleNumMonitorsButton->setObjectName("toggleNumMonitors"); + + //WindowControl wCtrl(0, _widgetDims, _monitorRes, this); + _monBox = new MonitorBox(_widgetDims, _monitorRes, this); + addWindowControl(); + QLineEdit* size_x = _windowControl.back()->lineEditSizeWidth(); + QLineEdit* size_y = _windowControl.back()->lineEditSizeHeight(); + QLineEdit* offset_x = _windowControl.back()->lineEditSizeOffsetX(); + QLineEdit* offset_y = _windowControl.back()->lineEditSizeOffsetY(); + + _layout = new QVBoxLayout(this); + _layout->addWidget(_monBox); + _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + _monBox->setFixedSize(300, 300); + _layout->addWidget(_toggleNumMonitorsButton); + + QLabel* label_size = new QLabel(this); + QLabel* label_delim = new QLabel(this); + QBoxLayout* sizeLayout = new QHBoxLayout(this); + sizeLayout->addWidget(label_size); + sizeLayout->addWidget(size_x); + sizeLayout->addWidget(label_delim); + sizeLayout->addWidget(size_y); + _layout->addLayout(sizeLayout); + + QLabel* label_offset = new QLabel(this); + QLabel* label_comma = new QLabel(this); + QBoxLayout* offsetLayout = new QHBoxLayout(this); + offsetLayout->addWidget(label_offset); + offsetLayout->addWidget(offset_x); + offsetLayout->addWidget(label_comma); + offsetLayout->addWidget(offset_y); + _layout->addLayout(offsetLayout); + + this->setLayout(_layout); + label_size->setText("Size:"); + label_delim->setText(" x "); + label_offset->setText("Offset:"); + label_comma->setText(" , "); + + int windowSize_x = std::stoi(size_x->text().toStdString()); + int windowSize_y = std::stoi(size_y->text().toStdString()); + QRect defaultMonitorResolution(_monitorResolution[0], _monitorResolution[1], 0, 0); + _monBox->setResolution(defaultMonitorResolution); +} + +Display::~Display() { + delete _toggleNumMonitorsButton; + delete _monBox; + delete _layout; +} + +void Display::windowResizedCallback(unsigned int windowIndex, const QRectF& newDims) { + +} + + +void Display::addWindowControl() { + if (_nWindows < 2) { + _windowControl.push_back( + new WindowControl( + _nWindows, + _widgetDims, + _monitorRes, + this + ) + ); + _windowControl.back()->setWindowChangeCallback(windowResizedCallback); + _monBox->mapWindowResolutionToWidgetCoordinates(_nWindows, + _windowControl.back()->dimensions()); + _nWindows++; + } +} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index be6c383b14..e59624e05f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -9,61 +9,20 @@ #include #include +#include "include/display.h" #include "include/monitorbox.h" #include "include/windowcontrol.h" -void windowResizedCallback(unsigned int windowIndex, const QRectF& newDims) { - -} int main(int argc, char *argv[ ]) { QApplication app(argc, argv); QMainWindow win(nullptr); - QWidget* centralWidget = new QWidget; - win.setCentralWidget(centralWidget); - - unsigned int monitorResolution[2] = {1920, 1080}; - QPushButton* toggleNumMonitorsButton - = new QPushButton("Add 2nd Window", centralWidget); - toggleNumMonitorsButton->setObjectName("toggleNumMonitors"); - - QLabel* label_size = new QLabel(centralWidget); - QLabel* label_delim = new QLabel(centralWidget); - - QRect widgetDims(400, 400, 0, 0); - QRect monitorRes(monitorResolution[0], monitorResolution[1], 0, 0); - WindowControl wCtrl(0, widgetDims, monitorRes, centralWidget); - MonitorBox* monBox = new MonitorBox(widgetDims, monitorRes, centralWidget); - monBox->addWindowControl(&wCtrl); - QLineEdit* size_x = wCtrl.lineEditSizeWidth(); - QLineEdit* size_y = wCtrl.lineEditSizeHeight(); - - QBoxLayout* layout = new QVBoxLayout(centralWidget); - layout->addWidget(monBox); - layout->addWidget(toggleNumMonitorsButton); - QBoxLayout* sizeLayout = new QHBoxLayout(centralWidget); - sizeLayout->addWidget(label_size); - sizeLayout->addWidget(size_x); - sizeLayout->addWidget(label_delim); - sizeLayout->addWidget(size_y); - layout->addLayout(sizeLayout); - - label_size->setText("Size:"); - label_delim->setText(" x "); - + Display* displayWidget = new Display(); + win.setCentralWidget(displayWidget); win.setWindowTitle("Test Qt14"); - - int windowSize_x = std::stoi(size_x->text().toStdString()); - int windowSize_y = std::stoi(size_y->text().toStdString()); - QRect defaultMonitorResolution(monitorResolution[0], monitorResolution[1], 0, 0); - monBox->setResolution(defaultMonitorResolution); - win.show(); app.exec(); - delete centralWidget; - delete toggleNumMonitorsButton; - delete monBox; - delete layout; + delete displayWidget; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/mainwindow.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/mainwindow.cpp deleted file mode 100644 index f55034f2e3..0000000000 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/mainwindow.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "mainwindow.h" -#include "monitorbox.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - button_ = new QPushButton(tr("Push Me!")); - textBrowser_ = new QTextBrowser(); - - QGridLayout *mainLayout = new QGridLayout; - mainLayout->addWidget(button_,0,0); - mainLayout->addWidget(textBrowser_,1,0); - setLayout(mainLayout); - setWindowTitle(tr("Connecting buttons to processes..")); - -/* _layout = new QVBoxLayout(); - QBoxLayout* _monitorAreaLayout = new QHBoxLayout(); - - QGridLayout* container = new QGridLayout; - container->setColumnStretch(1, 1); - - _addSecondMonitor = new QPushButton("Add Monitor"); - container->addWidget(_addSecondMonitor); - - QLabel* dummyLabel = new QLabel("WTF?"); - container->addWidget(dummyLabel); - - _monitorBoxes[0] = new MonitorBox(this); - _monitorBoxes[0]->setMonitorResolution({1920, 1080}); - _monitorBoxes[0]->setNumWindows(2); - _monitorBoxes[0]->setWindowSize(0, {1000, 600}, {20, 10}); - _monitorBoxes[0]->setWindowSize(1, {400, 400}, {1020, 610}); - - _monitorAreaLayout->addWidget(_monitorBoxes[0]); - //_layout->addLayout(_monitorAreaLayout); - _layout->addWidget(_addSecondMonitor); - _layout->addWidget(dummyLabel); - //_layout->addStretch(1); - //_layout->addLayout(container); - //_layout->addStretch(1); -*/ -} - -MainWindow::~MainWindow() -{ - delete button_; - delete textBrowser_; -/* - if (_monitorAreaLayout) - delete _monitorAreaLayout; - for (MonitorBox* mb : _monitorBoxes) { - if (mb) - delete mb; - } - if (_addSecondMonitor) - delete _addSecondMonitor; - if (_layout) - delete _layout; -*/ -} - diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index c7b64ce9a3..9174580a17 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -1,4 +1,3 @@ -#include "mainwindow.h" #include "monitorbox.h" @@ -11,13 +10,10 @@ MonitorBox::MonitorBox(QRect widgetDims, QRect monitorResolution, QWidget *paren } MonitorBox::~MonitorBox() -{ } - -void MonitorBox::addWindowControl(WindowControl* wCtrl) { - if (_nWindows < 2) { - _windowControl.push_back(wCtrl); - _windowControl.back()->setWindowChangeCallback(windowDimensionsChanged); - _nWindows++; +{ + while (_windowRendering.size() > 0) { + delete _windowRendering.back(); + _windowRendering.pop_back(); } } @@ -27,6 +23,9 @@ void MonitorBox::paintEvent(QPaintEvent *event) QPainter painter(this); QPen pen = painter.pen(); painter.setPen(pen); + //Draw border + painter.setPen(Qt::gray); + painter.drawRoundedRect(0,5,width()-5, height()-7,3,3); //Draw monitor outline painter.setPen(Qt::black); painter.drawRect(_monitorDimensionsScaled); @@ -37,20 +36,21 @@ void MonitorBox::paintEvent(QPaintEvent *event) } } -void MonitorBox::windowDimensionsChanged(unsigned int index, const QRectF& newDimensions) { +void MonitorBox::windowDimensionsChanged(unsigned int index, const QRectF newDimensions) { mapWindowResolutionToWidgetCoordinates(index, newDimensions); } void MonitorBox::mapMonitorResolutionToWidgetCoordinates(QRect r) { // _monitorResolution = r; - float aspectRatio = r.width() / r.height(); + float aspectRatio = static_cast(r.width()) / + static_cast(r.height()); _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; if (aspectRatio >= 1.0) { float newWidth = _monitorWidgetSize.width() * (1.0 - _marginFractionOfWidgetSize * 2.0); _monitorScaleFactor = newWidth / static_cast(r.width()); float newHeight = newWidth / aspectRatio; - _monitorRendering = { + _monitorDimensionsScaled = { _marginWidget, _marginWidget + (_monitorWidgetSize.height() - newHeight) / 2.0, newWidth, @@ -62,7 +62,7 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates(QRect r) { * (1.0 - _marginFractionOfWidgetSize * 2.0); _monitorScaleFactor = newHeight / static_cast(r.height()); float newWidth = newHeight * aspectRatio; - _monitorRendering = { + _monitorDimensionsScaled = { _marginWidget + (_monitorWidgetSize.width() - newWidth) / 2.0, _marginWidget, newWidth, @@ -77,24 +77,21 @@ void MonitorBox::setResolution(QRect& res) { } void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int index, const QRectF& w) { - if (index < _windowRendering.size() ) { - if (_windowRendering[index]) { - *_windowRendering[index] = { - _marginWidget + _monitorBoundaryRect.topLeft().x() + w.left() * _monitorScaleFactor, - _marginWidget + _monitorBoundaryRect.topLeft().y() + w.top() * _monitorScaleFactor, - w.width() * _monitorScaleFactor, - w.height() * _monitorScaleFactor - }; - } -// _windowRendering[index] = w * _monitorScaleFactor; + if (index > 1) { + return; } -} - -//float MonitorBox::monitorScaleFactor() { -// return _monitorScaleFactor; -//} - -int MonitorBox::numWindows() { - return _nWindows; + while ((index + 1) > _windowRendering.size()) { + _windowRendering.push_back(new QRectF()); + } + if (_windowRendering[index]) { + QRectF wF = w; + *_windowRendering[index] = { + _marginWidget + _monitorBoundaryRect.topLeft().x() + wF.left() * _monitorScaleFactor, + _marginWidget + _monitorBoundaryRect.topLeft().y() + wF.top() * _monitorScaleFactor, + wF.width() * _monitorScaleFactor, + wF.height() * _monitorScaleFactor + }; + } +// _windowRendering[index] = w * _monitorScaleFactor; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 5c0f1f76ee..c0b952b120 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -1,5 +1,5 @@ -#include "mainwindow.h" #include "monitorbox.h" +#include "windowcontrol.h" WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, QRect& monitorResolution, QWidget *parent) @@ -7,22 +7,23 @@ WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, , _monitorResolution(monitorResolution) , QWidget(parent) { - if (windowIndex == 0) { - _size_x = new QLineEdit("800", parent); - _size_y = new QLineEdit("600", parent); - _offset_x = new QLineEdit("50", parent); - _offset_y = new QLineEdit("50", parent); - } - else { - _size_x = new QLineEdit("640", parent); - _size_y = new QLineEdit("480", parent); - _offset_x = new QLineEdit("900", parent); - _offset_y = new QLineEdit("400", parent); - } - QIntValidator* _validatorSize_x = new QIntValidator(10, _monitorResolution.width()); - QIntValidator* _validatorSize_y = new QIntValidator(10, _monitorResolution.height()); - QIntValidator* _validatorOffset_x = new QIntValidator(10, _monitorResolution.width() - 10); - QIntValidator* _validatorOffset_y = new QIntValidator(10, _monitorResolution.height() - 10); + _windowDims = defaultWindowSizes[windowIndex]; + _size_x = new QLineEdit( + QString::fromUtf8(std::to_string(int(_windowDims.width())).c_str()), parent); + _size_y = new QLineEdit( + QString::fromUtf8(std::to_string(int(_windowDims.height())).c_str()), parent); + _offset_x = new QLineEdit( + QString::fromUtf8(std::to_string(int(_windowDims.x())).c_str()), parent); + _offset_y = new QLineEdit( + QString::fromUtf8(std::to_string(int(_windowDims.y())).c_str()), parent); + QIntValidator* _validatorSize_x + = new QIntValidator(10, _monitorResolution.width()); + QIntValidator* _validatorSize_y + = new QIntValidator(10, _monitorResolution.height()); + QIntValidator* _validatorOffset_x + = new QIntValidator(10, _monitorResolution.width() - 10); + QIntValidator* _validatorOffset_y + = new QIntValidator(10, _monitorResolution.height() - 10); _size_x->setValidator(_validatorSize_x); _size_y->setValidator(_validatorSize_y); @@ -55,7 +56,7 @@ void WindowControl::onSizeYChanged(const QString& newText) { } } -void WindowControl::setDimensions(const QRect& dimensions) { +void WindowControl::setDimensions(const QRectF& dimensions) { _windowDims = dimensions; } @@ -67,8 +68,8 @@ void WindowControl::setWindowScaleFactor(float scaleFactor) { _monitorScaleFactor = scaleFactor; } -QRect* WindowControl::dimensions() { - return &_windowDims; +QRectF& WindowControl::dimensions() { + return _windowDims; } QLineEdit* WindowControl::lineEditSizeWidth() { From 52c6cadc0f4234d17ef10cd33e63f6b408794a01 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:03:01 -0700 Subject: [PATCH 04/93] Working version for one window --- .../ext/launcher/include/sgctedit/display.h | 2 +- .../launcher/include/sgctedit/windowcontrol.h | 2 + .../ext/launcher/src/sgctedit/display.cpp | 39 ++++++++++++------- .../ext/launcher/src/sgctedit/monitorbox.cpp | 8 ++-- .../launcher/src/sgctedit/windowcontrol.cpp | 29 ++++++++++++++ 5 files changed, 60 insertions(+), 20 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 11f9c3f2a1..bec94703e2 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -25,7 +25,6 @@ class Display : public QWidget public: explicit Display(); ~Display(); - static void windowResizedCallback(unsigned int windowIndex, const QRectF& newDims); private: void addWindowControl(); @@ -34,6 +33,7 @@ private: QRect _widgetDims = {0, 0, 400, 400}; std::vector _windowControl; unsigned int _nWindows = 0; + int _lineEditWidthFixed = 80; QPushButton* _toggleNumMonitorsButton = nullptr; MonitorBox* _monBox = nullptr; QBoxLayout* _layout = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 0845568a65..948078b971 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -33,6 +33,8 @@ public: private slots: void onSizeXChanged(const QString& newText); void onSizeYChanged(const QString& newText); + void onOffsetXChanged(const QString& newText); + void onOffsetYChanged(const QString& newText); private: void updateScaledWindowDimensions(); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index ead9b4c222..034db434b4 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -22,40 +22,50 @@ Display::Display() //WindowControl wCtrl(0, _widgetDims, _monitorRes, this); _monBox = new MonitorBox(_widgetDims, _monitorRes, this); addWindowControl(); - QLineEdit* size_x = _windowControl.back()->lineEditSizeWidth(); - QLineEdit* size_y = _windowControl.back()->lineEditSizeHeight(); - QLineEdit* offset_x = _windowControl.back()->lineEditSizeOffsetX(); - QLineEdit* offset_y = _windowControl.back()->lineEditSizeOffsetY(); _layout = new QVBoxLayout(this); _layout->addWidget(_monBox); _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - _monBox->setFixedSize(300, 300); + _monBox->setFixedSize(400, 400); _layout->addWidget(_toggleNumMonitorsButton); + QLineEdit* size_x = _windowControl.back()->lineEditSizeWidth(); + QLineEdit* size_y = _windowControl.back()->lineEditSizeHeight(); + size_x->setFixedWidth(_lineEditWidthFixed); + size_y->setFixedWidth(_lineEditWidthFixed); QLabel* label_size = new QLabel(this); QLabel* label_delim = new QLabel(this); QBoxLayout* sizeLayout = new QHBoxLayout(this); + sizeLayout->addStretch(1); sizeLayout->addWidget(label_size); + label_size->setFixedWidth(80); + label_size->setText("Size:"); sizeLayout->addWidget(size_x); sizeLayout->addWidget(label_delim); sizeLayout->addWidget(size_y); + sizeLayout->addStretch(1); + label_delim->setText(" x "); _layout->addLayout(sizeLayout); + QLineEdit* offset_x = _windowControl.back()->lineEditSizeOffsetX(); + QLineEdit* offset_y = _windowControl.back()->lineEditSizeOffsetY(); + offset_x->setFixedWidth(_lineEditWidthFixed); + offset_y->setFixedWidth(_lineEditWidthFixed); QLabel* label_offset = new QLabel(this); QLabel* label_comma = new QLabel(this); QBoxLayout* offsetLayout = new QHBoxLayout(this); + offsetLayout->addStretch(1); offsetLayout->addWidget(label_offset); + label_offset->setFixedWidth(80); + label_offset->setText("Offset:"); offsetLayout->addWidget(offset_x); offsetLayout->addWidget(label_comma); offsetLayout->addWidget(offset_y); + offsetLayout->addStretch(1); + label_comma->setText(" , "); _layout->addLayout(offsetLayout); this->setLayout(_layout); - label_size->setText("Size:"); - label_delim->setText(" x "); - label_offset->setText("Offset:"); - label_comma->setText(" , "); int windowSize_x = std::stoi(size_x->text().toStdString()); int windowSize_y = std::stoi(size_y->text().toStdString()); @@ -69,11 +79,6 @@ Display::~Display() { delete _layout; } -void Display::windowResizedCallback(unsigned int windowIndex, const QRectF& newDims) { - -} - - void Display::addWindowControl() { if (_nWindows < 2) { _windowControl.push_back( @@ -84,7 +89,11 @@ void Display::addWindowControl() { this ) ); - _windowControl.back()->setWindowChangeCallback(windowResizedCallback); + _windowControl.back()->setWindowChangeCallback( + [this](unsigned int windowIndex, const QRectF& newDims) { + _monBox->windowDimensionsChanged(windowIndex, newDims); + } + ); _monBox->mapWindowResolutionToWidgetCoordinates(_nWindows, _windowControl.back()->dimensions()); _nWindows++; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 9174580a17..6cbea1ed0f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -25,7 +25,7 @@ void MonitorBox::paintEvent(QPaintEvent *event) painter.setPen(pen); //Draw border painter.setPen(Qt::gray); - painter.drawRoundedRect(0,5,width()-5, height()-7,3,3); + painter.drawRoundedRect(0, 0, width() - 1, height() - 1, 10, 10); //Draw monitor outline painter.setPen(Qt::black); painter.drawRect(_monitorDimensionsScaled); @@ -86,12 +86,12 @@ void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int index, cons if (_windowRendering[index]) { QRectF wF = w; *_windowRendering[index] = { - _marginWidget + _monitorBoundaryRect.topLeft().x() + wF.left() * _monitorScaleFactor, - _marginWidget + _monitorBoundaryRect.topLeft().y() + wF.top() * _monitorScaleFactor, + _monitorDimensionsScaled.x() + wF.left() * _monitorScaleFactor, + _monitorDimensionsScaled.y() + wF.top() * _monitorScaleFactor, wF.width() * _monitorScaleFactor, wF.height() * _monitorScaleFactor }; } -// _windowRendering[index] = w * _monitorScaleFactor; + this->update(); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index c0b952b120..acf177bf75 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -1,3 +1,4 @@ +#include "display.h" #include "monitorbox.h" #include "windowcontrol.h" @@ -34,6 +35,10 @@ WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, SLOT(onSizeXChanged(const QString&))); connect(_size_y, SIGNAL(textChanged(const QString&)), this, SLOT(onSizeYChanged(const QString&))); + connect(_offset_x, SIGNAL(textChanged(const QString&)), this, + SLOT(onOffsetXChanged(const QString&))); + connect(_offset_y, SIGNAL(textChanged(const QString&)), this, + SLOT(onOffsetYChanged(const QString&))); } void WindowControl::onSizeXChanged(const QString& newText) { @@ -56,6 +61,30 @@ void WindowControl::onSizeYChanged(const QString& newText) { } } +void WindowControl::onOffsetXChanged(const QString& newText) { + std::string xOffset = newText.toStdString(); + float prevWidth = _windowDims.width(); + if (!xOffset.empty()) { + _windowDims.setX(std::stoi(xOffset)); + _windowDims.setWidth(prevWidth); + } + if (_windowChangeCallback) { + _windowChangeCallback(_index, _windowDims); + } +} + +void WindowControl::onOffsetYChanged(const QString& newText) { + std::string yOffset = newText.toStdString(); + float prevHeight = _windowDims.height(); + if (!yOffset.empty()) { + _windowDims.setY(std::stoi(yOffset)); + _windowDims.setHeight(prevHeight); + } + if (_windowChangeCallback) { + _windowChangeCallback(_index, _windowDims); + } +} + void WindowControl::setDimensions(const QRectF& dimensions) { _windowDims = dimensions; } From 5bf88f5510e2d2aa71e29c65cf809a7b0296a409 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:04:04 -0700 Subject: [PATCH 05/93] Working version before going to supporting 2 WindowControl instances --- .../ext/launcher/include/sgctedit/display.h | 27 +++ .../launcher/include/sgctedit/windowcontrol.h | 11 +- .../ext/launcher/src/sgctedit/display.cpp | 165 ++++++++++++------ .../ext/launcher/src/sgctedit/monitorbox.cpp | 4 +- .../launcher/src/sgctedit/windowcontrol.cpp | 22 ++- 5 files changed, 169 insertions(+), 60 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index bec94703e2..83bcf0522e 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -1,13 +1,17 @@ #ifndef DISPLAY_H #define DISPLAY_H +#include +#include #include +#include #include #include #include #include #include #include +#include #include #include @@ -26,8 +30,12 @@ public: explicit Display(); ~Display(); +private slots: + void toggleWindows(); + private: void addWindowControl(); + void initializeLayout(); unsigned int _monitorResolution[2] = {1920, 1080}; QRect _monitorRes = {0, 0, _monitorResolution[0], _monitorResolution[1]}; QRect _widgetDims = {0, 0, 400, 400}; @@ -37,6 +45,25 @@ private: QPushButton* _toggleNumMonitorsButton = nullptr; MonitorBox* _monBox = nullptr; QBoxLayout* _layout = nullptr; + QBoxLayout* _layoutMonButton = nullptr; + QLabel* _labelSize = nullptr; + QLabel* _labelDelim = nullptr; + QBoxLayout* _layoutSize = nullptr; + QLineEdit* _lineSizeX = nullptr; + QLineEdit* _lineSizeY = nullptr; + QLineEdit* _lineOffsetX = nullptr; + QLineEdit* _lineOffsetY = nullptr; + QLabel* _labelOffset = nullptr; + QLabel* _labelComma = nullptr; + QBoxLayout* _layoutOffset = nullptr; + QCheckBox* _optFullscreen = nullptr; + QCheckBox* _optVsync = nullptr; + QCheckBox* _optWebGui = nullptr; + QCheckBox* _optSpoutOutput = nullptr; + QBoxLayout* _layoutCBoxFullscreen = nullptr; + QBoxLayout* _layoutCBoxVsync = nullptr; + QBoxLayout* _layoutCBoxWebGui = nullptr; + QBoxLayout* _layoutCBoxSpoutOutput = nullptr; }; #endif // DISPLAY_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 948078b971..ddba7ca0d3 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -1,6 +1,7 @@ #ifndef WINDOWCONTROL_H #define WINDOWCONTROL_H +#include #include #include #include @@ -29,6 +30,10 @@ public: QLineEdit* lineEditSizeHeight(); QLineEdit* lineEditSizeOffsetX(); QLineEdit* lineEditSizeOffsetY(); + QCheckBox* checkBoxFullscreen(); + QCheckBox* checkBoxVsync(); + QCheckBox* checkBoxWebGui(); + QCheckBox* checkBoxSpoutOutput(); private slots: void onSizeXChanged(const QString& newText); @@ -48,12 +53,16 @@ private: QLineEdit* _offset_x = nullptr; QLineEdit* _offset_y = nullptr; + int _index = 0; QRect _monitorResolution; QRectF _monitorDimsScaled; QRectF _windowDims; QRectF _windowDimsScaled; float _monitorScaleFactor = 1.0; - int _index = 0; + QCheckBox* _checkBoxFullscreen = nullptr; + QCheckBox* _checkBoxVsync = nullptr; + QCheckBox* _checkBoxWebGui = nullptr; + QCheckBox* _checkBoxSpoutOutput = nullptr; float _marginFractionOfWidgetSize = 0.025; }; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 034db434b4..4e380d6a55 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -1,11 +1,4 @@ #include -#include -#include -#include -#include -#include -#include -#include #include #include @@ -22,61 +15,121 @@ Display::Display() //WindowControl wCtrl(0, _widgetDims, _monitorRes, this); _monBox = new MonitorBox(_widgetDims, _monitorRes, this); addWindowControl(); + initializeLayout(); - _layout = new QVBoxLayout(this); - _layout->addWidget(_monBox); - _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - _monBox->setFixedSize(400, 400); - _layout->addWidget(_toggleNumMonitorsButton); - - QLineEdit* size_x = _windowControl.back()->lineEditSizeWidth(); - QLineEdit* size_y = _windowControl.back()->lineEditSizeHeight(); - size_x->setFixedWidth(_lineEditWidthFixed); - size_y->setFixedWidth(_lineEditWidthFixed); - QLabel* label_size = new QLabel(this); - QLabel* label_delim = new QLabel(this); - QBoxLayout* sizeLayout = new QHBoxLayout(this); - sizeLayout->addStretch(1); - sizeLayout->addWidget(label_size); - label_size->setFixedWidth(80); - label_size->setText("Size:"); - sizeLayout->addWidget(size_x); - sizeLayout->addWidget(label_delim); - sizeLayout->addWidget(size_y); - sizeLayout->addStretch(1); - label_delim->setText(" x "); - _layout->addLayout(sizeLayout); - - QLineEdit* offset_x = _windowControl.back()->lineEditSizeOffsetX(); - QLineEdit* offset_y = _windowControl.back()->lineEditSizeOffsetY(); - offset_x->setFixedWidth(_lineEditWidthFixed); - offset_y->setFixedWidth(_lineEditWidthFixed); - QLabel* label_offset = new QLabel(this); - QLabel* label_comma = new QLabel(this); - QBoxLayout* offsetLayout = new QHBoxLayout(this); - offsetLayout->addStretch(1); - offsetLayout->addWidget(label_offset); - label_offset->setFixedWidth(80); - label_offset->setText("Offset:"); - offsetLayout->addWidget(offset_x); - offsetLayout->addWidget(label_comma); - offsetLayout->addWidget(offset_y); - offsetLayout->addStretch(1); - label_comma->setText(" , "); - _layout->addLayout(offsetLayout); - - this->setLayout(_layout); - - int windowSize_x = std::stoi(size_x->text().toStdString()); - int windowSize_y = std::stoi(size_y->text().toStdString()); - QRect defaultMonitorResolution(_monitorResolution[0], _monitorResolution[1], 0, 0); - _monBox->setResolution(defaultMonitorResolution); + connect(_toggleNumMonitorsButton, SIGNAL(released()), this, + SLOT(toggleWindows())); } Display::~Display() { delete _toggleNumMonitorsButton; delete _monBox; - delete _layout; + delete _layoutMonButton; + delete _labelSize; + delete _labelDelim; + delete _layoutSize; + delete _labelOffset; + delete _labelComma; + delete _layoutOffset; + delete _optFullscreen; + delete _optVsync; + delete _optWebGui; + delete _optSpoutOutput; + delete _layoutCBoxFullscreen; + delete _layoutCBoxVsync; + delete _layoutCBoxWebGui; + delete _layoutCBoxSpoutOutput; +} + +void Display::initializeLayout() { + _layout = new QVBoxLayout(this); + _layout->addWidget(_monBox); + _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + _monBox->setFixedSize(400, 400); + _layoutMonButton = new QHBoxLayout(this); + _layoutMonButton->addStretch(1); + _layoutMonButton->addWidget(_toggleNumMonitorsButton); + _layoutMonButton->addStretch(1); + _layout->addLayout(_layoutMonButton); + + _layoutWindowCtrl = new QHBoxLayout(this); + //////////Move the rest of the layout in this func to WindowControl class, + // with _layoutWindowCtrl as parent layout + + //Window size + _lineSizeX = _windowControl.back()->lineEditSizeWidth(); + _lineSizeY = _windowControl.back()->lineEditSizeHeight(); + _lineSizeX->setFixedWidth(_lineEditWidthFixed); + _lineSizeY->setFixedWidth(_lineEditWidthFixed); + _labelSize = new QLabel(this); + _labelDelim = new QLabel(this); + _layoutSize = new QHBoxLayout(this); + _layoutSize->addStretch(1); + _layoutSize->addWidget(_labelSize); + _labelSize->setFixedWidth(60); + _labelSize->setText("Size:"); + _layoutSize->addWidget(_lineSizeX); + _layoutSize->addWidget(_labelDelim); + _layoutSize->addWidget(_lineSizeY); + _layoutSize->addStretch(1); + _labelDelim->setText(" x "); + _layout->addLayout(_layoutSize); + + //Window offset + _lineOffsetX = _windowControl.back()->lineEditSizeOffsetX(); + _lineOffsetY = _windowControl.back()->lineEditSizeOffsetY(); + _lineOffsetX->setFixedWidth(_lineEditWidthFixed); + _lineOffsetY->setFixedWidth(_lineEditWidthFixed); + _labelOffset = new QLabel(this); + _labelComma = new QLabel(this); + _layoutOffset = new QHBoxLayout(this); + _layoutOffset->addStretch(1); + _layoutOffset->addWidget(_labelOffset); + _labelOffset->setFixedWidth(60); + _labelOffset->setText("Offset:"); + _layoutOffset->addWidget(_lineOffsetX); + _layoutOffset->addWidget(_labelComma); + _layoutOffset->addWidget(_lineOffsetY); + _layoutOffset->addStretch(1); + _labelComma->setText(" , "); + _layout->addLayout(_layoutOffset); + + //Window options + _optFullscreen = _windowControl.back()->checkBoxFullscreen(); + _layoutCBoxFullscreen = new QHBoxLayout(this); + _layoutCBoxFullscreen->addStretch(1); + _layoutCBoxFullscreen->addWidget(_optFullscreen); + _layoutCBoxFullscreen->addStretch(1); + _layout->addLayout(_layoutCBoxFullscreen); + _optVsync = _windowControl.back()->checkBoxVsync(); + _layoutCBoxVsync= new QHBoxLayout(this); + _layoutCBoxVsync->addStretch(1); + _layoutCBoxVsync->addWidget(_optVsync); + _layoutCBoxVsync->addStretch(1); + _layout->addLayout(_layoutCBoxVsync); + _optWebGui = _windowControl.back()->checkBoxWebGui(); + _layoutCBoxWebGui= new QHBoxLayout(this); + _layoutCBoxWebGui->addStretch(1); + _layoutCBoxWebGui->addWidget(_optWebGui); + _layoutCBoxWebGui->addStretch(1); + _layout->addLayout(_layoutCBoxWebGui); + _optSpoutOutput = _windowControl.back()->checkBoxSpoutOutput(); + _layoutCBoxSpoutOutput= new QHBoxLayout(this); + _layoutCBoxSpoutOutput->addStretch(1); + _layoutCBoxSpoutOutput->addWidget(_optSpoutOutput); + _layoutCBoxSpoutOutput->addStretch(1); + _layout->addLayout(_layoutCBoxSpoutOutput); + + this->setLayout(_layout); + + int windowSize_x = std::stoi(_lineSizeX->text().toStdString()); + int windowSize_y = std::stoi(_lineSizeY->text().toStdString()); + QRect defaultMonitorResolution(_monitorResolution[0], _monitorResolution[1], 0, 0); + _monBox->setResolution(defaultMonitorResolution); +} + +void Display::toggleWindows() { + std::cout << "Toggle." << std::endl; } void Display::addWindowControl() { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 6cbea1ed0f..41e083342b 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -24,10 +24,10 @@ void MonitorBox::paintEvent(QPaintEvent *event) QPen pen = painter.pen(); painter.setPen(pen); //Draw border - painter.setPen(Qt::gray); + painter.setPen(QPen(Qt::gray, 4)); painter.drawRoundedRect(0, 0, width() - 1, height() - 1, 10, 10); //Draw monitor outline - painter.setPen(Qt::black); + painter.setPen(QPen(Qt::black, 2)); painter.drawRect(_monitorDimensionsScaled); //Draw window(s) painter.setPen(Qt::blue); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index acf177bf75..b1378d5c46 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -25,12 +25,16 @@ WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, = new QIntValidator(10, _monitorResolution.width() - 10); QIntValidator* _validatorOffset_y = new QIntValidator(10, _monitorResolution.height() - 10); - _size_x->setValidator(_validatorSize_x); _size_y->setValidator(_validatorSize_y); _offset_x->setValidator(_validatorSize_y); _offset_y->setValidator(_validatorSize_y); + _checkBoxFullscreen = new QCheckBox("Fullscreen", this); + _checkBoxVsync = new QCheckBox("VSync", this); + _checkBoxWebGui = new QCheckBox("WebGUI here", this); + _checkBoxSpoutOutput = new QCheckBox("Spout Output", this); + connect(_size_x, SIGNAL(textChanged(const QString&)), this, SLOT(onSizeXChanged(const QString&))); connect(_size_y, SIGNAL(textChanged(const QString&)), this, @@ -117,6 +121,22 @@ QLineEdit* WindowControl::lineEditSizeOffsetY() { return _offset_y; } +QCheckBox* WindowControl::checkBoxFullscreen() { + return _checkBoxFullscreen; +} + +QCheckBox* WindowControl::checkBoxVsync() { + return _checkBoxVsync; +} + +QCheckBox* WindowControl::checkBoxWebGui() { + return _checkBoxWebGui; +} + +QCheckBox* WindowControl::checkBoxSpoutOutput() { + return _checkBoxSpoutOutput; +} + WindowControl::~WindowControl() { delete _size_x; From a78df81d73128ea596e7c50d125d5c5dedce5afc Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:05:44 -0700 Subject: [PATCH 06/93] Removing a premature line to get to a working version before upcoming changes --- apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 4e380d6a55..2779b65d54 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -52,7 +52,7 @@ void Display::initializeLayout() { _layoutMonButton->addStretch(1); _layout->addLayout(_layoutMonButton); - _layoutWindowCtrl = new QHBoxLayout(this); + //_layoutWindowCtrl = new QHBoxLayout(this); //////////Move the rest of the layout in this func to WindowControl class, // with _layoutWindowCtrl as parent layout From 31ae9267dc239aae8ad3a8bb87543b2cccab7ae1 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:06:45 -0700 Subject: [PATCH 07/93] Rough but working version with 2 windows --- .../ext/launcher/include/sgctedit/display.h | 28 +---- .../launcher/include/sgctedit/monitorbox.h | 1 + .../launcher/include/sgctedit/windowcontrol.h | 31 ++++- .../ext/launcher/src/sgctedit/display.cpp | 115 +++++------------- .../ext/launcher/src/sgctedit/monitorbox.cpp | 7 ++ .../launcher/src/sgctedit/windowcontrol.cpp | 82 +++++++++++++ 6 files changed, 154 insertions(+), 110 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 83bcf0522e..70abc5c4ab 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -35,35 +35,19 @@ private slots: private: void addWindowControl(); - void initializeLayout(); + void removeWindowControl(); + void initializeLayout(unsigned int windowIndex, WindowControl* winCtrl); unsigned int _monitorResolution[2] = {1920, 1080}; QRect _monitorRes = {0, 0, _monitorResolution[0], _monitorResolution[1]}; QRect _widgetDims = {0, 0, 400, 400}; std::vector _windowControl; unsigned int _nWindows = 0; - int _lineEditWidthFixed = 80; QPushButton* _toggleNumMonitorsButton = nullptr; MonitorBox* _monBox = nullptr; - QBoxLayout* _layout = nullptr; - QBoxLayout* _layoutMonButton = nullptr; - QLabel* _labelSize = nullptr; - QLabel* _labelDelim = nullptr; - QBoxLayout* _layoutSize = nullptr; - QLineEdit* _lineSizeX = nullptr; - QLineEdit* _lineSizeY = nullptr; - QLineEdit* _lineOffsetX = nullptr; - QLineEdit* _lineOffsetY = nullptr; - QLabel* _labelOffset = nullptr; - QLabel* _labelComma = nullptr; - QBoxLayout* _layoutOffset = nullptr; - QCheckBox* _optFullscreen = nullptr; - QCheckBox* _optVsync = nullptr; - QCheckBox* _optWebGui = nullptr; - QCheckBox* _optSpoutOutput = nullptr; - QBoxLayout* _layoutCBoxFullscreen = nullptr; - QBoxLayout* _layoutCBoxVsync = nullptr; - QBoxLayout* _layoutCBoxWebGui = nullptr; - QBoxLayout* _layoutCBoxSpoutOutput = nullptr; + QVBoxLayout* _layout = nullptr; + QHBoxLayout* _layoutMonButton = nullptr; + QHBoxLayout* _layoutWindows = nullptr; + QFrame* _borderFrame = nullptr; }; #endif // DISPLAY_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index ee5492846c..332972136b 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -30,6 +30,7 @@ public: void windowDimensionsChanged(unsigned int index, const QRectF newDimensions); // float monitorScaleFactor(); void addWindowControl(WindowControl* wCtrl); + void removeAdditionalWindowDimensions(); protected: void paintEvent(QPaintEvent *event) override; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index ddba7ca0d3..ac14c67ff7 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -2,7 +2,10 @@ #define WINDOWCONTROL_H #include +#include #include +#include +#include #include #include #include @@ -25,6 +28,7 @@ public: void setDimensions(const QRectF& dimensions); void setWindowScaleFactor(float scaleFactor); void setWindowChangeCallback(std::function cb); + void initializeLayout(QWidget* parentWidget, QHBoxLayout* layout); QRectF& dimensions(); QLineEdit* lineEditSizeWidth(); QLineEdit* lineEditSizeHeight(); @@ -48,12 +52,18 @@ private: {50.0, 50.0, 800.0, 600.0}, {900.0, 400.0, 640.0, 480.0} }; + int _lineEditWidthFixed = 80; + float _marginFractionOfWidgetSize = 0.025; + int _index = 0; + + QVBoxLayout* _layoutWindowCtrl; + QVBoxLayout* _layoutFullWindow; + QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; QLineEdit* _offset_x = nullptr; QLineEdit* _offset_y = nullptr; - int _index = 0; QRect _monitorResolution; QRectF _monitorDimsScaled; QRectF _windowDims; @@ -64,7 +74,24 @@ private: QCheckBox* _checkBoxWebGui = nullptr; QCheckBox* _checkBoxSpoutOutput = nullptr; - float _marginFractionOfWidgetSize = 0.025; + QLabel* _labelSize = nullptr; + QLabel* _labelDelim = nullptr; + QHBoxLayout* _layoutSize = nullptr; +// QLineEdit* _lineSizeX = nullptr; +// QLineEdit* _lineSizeY = nullptr; +// QLineEdit* _lineOffsetX = nullptr; +// QLineEdit* _lineOffsetY = nullptr; + QLabel* _labelOffset = nullptr; + QLabel* _labelComma = nullptr; + QHBoxLayout* _layoutOffset = nullptr; +// QCheckBox* _optFullscreen = nullptr; +// QCheckBox* _optVsync = nullptr; +// QCheckBox* _optWebGui = nullptr; +// QCheckBox* _optSpoutOutput = nullptr; + QHBoxLayout* _layoutCBoxFullscreen = nullptr; + QHBoxLayout* _layoutCBoxVsync = nullptr; + QHBoxLayout* _layoutCBoxWebGui = nullptr; + QHBoxLayout* _layoutCBoxSpoutOutput = nullptr; }; #endif // WINDOWCONTROL_H diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 2779b65d54..63ad1b9734 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -15,7 +15,7 @@ Display::Display() //WindowControl wCtrl(0, _widgetDims, _monitorRes, this); _monBox = new MonitorBox(_widgetDims, _monitorRes, this); addWindowControl(); - initializeLayout(); + initializeLayout(0, _windowControl[0]); connect(_toggleNumMonitorsButton, SIGNAL(released()), this, SLOT(toggleWindows())); @@ -25,23 +25,11 @@ Display::~Display() { delete _toggleNumMonitorsButton; delete _monBox; delete _layoutMonButton; - delete _labelSize; - delete _labelDelim; - delete _layoutSize; - delete _labelOffset; - delete _labelComma; - delete _layoutOffset; - delete _optFullscreen; - delete _optVsync; - delete _optWebGui; - delete _optSpoutOutput; - delete _layoutCBoxFullscreen; - delete _layoutCBoxVsync; - delete _layoutCBoxWebGui; - delete _layoutCBoxSpoutOutput; + delete _layoutWindows; + delete _layout; } -void Display::initializeLayout() { +void Display::initializeLayout(unsigned int windowIndex, WindowControl* winCtrl) { _layout = new QVBoxLayout(this); _layout->addWidget(_monBox); _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -51,85 +39,31 @@ void Display::initializeLayout() { _layoutMonButton->addWidget(_toggleNumMonitorsButton); _layoutMonButton->addStretch(1); _layout->addLayout(_layoutMonButton); + _layoutWindows = new QHBoxLayout(this); - //_layoutWindowCtrl = new QHBoxLayout(this); - //////////Move the rest of the layout in this func to WindowControl class, - // with _layoutWindowCtrl as parent layout - - //Window size - _lineSizeX = _windowControl.back()->lineEditSizeWidth(); - _lineSizeY = _windowControl.back()->lineEditSizeHeight(); - _lineSizeX->setFixedWidth(_lineEditWidthFixed); - _lineSizeY->setFixedWidth(_lineEditWidthFixed); - _labelSize = new QLabel(this); - _labelDelim = new QLabel(this); - _layoutSize = new QHBoxLayout(this); - _layoutSize->addStretch(1); - _layoutSize->addWidget(_labelSize); - _labelSize->setFixedWidth(60); - _labelSize->setText("Size:"); - _layoutSize->addWidget(_lineSizeX); - _layoutSize->addWidget(_labelDelim); - _layoutSize->addWidget(_lineSizeY); - _layoutSize->addStretch(1); - _labelDelim->setText(" x "); - _layout->addLayout(_layoutSize); - - //Window offset - _lineOffsetX = _windowControl.back()->lineEditSizeOffsetX(); - _lineOffsetY = _windowControl.back()->lineEditSizeOffsetY(); - _lineOffsetX->setFixedWidth(_lineEditWidthFixed); - _lineOffsetY->setFixedWidth(_lineEditWidthFixed); - _labelOffset = new QLabel(this); - _labelComma = new QLabel(this); - _layoutOffset = new QHBoxLayout(this); - _layoutOffset->addStretch(1); - _layoutOffset->addWidget(_labelOffset); - _labelOffset->setFixedWidth(60); - _labelOffset->setText("Offset:"); - _layoutOffset->addWidget(_lineOffsetX); - _layoutOffset->addWidget(_labelComma); - _layoutOffset->addWidget(_lineOffsetY); - _layoutOffset->addStretch(1); - _labelComma->setText(" , "); - _layout->addLayout(_layoutOffset); - - //Window options - _optFullscreen = _windowControl.back()->checkBoxFullscreen(); - _layoutCBoxFullscreen = new QHBoxLayout(this); - _layoutCBoxFullscreen->addStretch(1); - _layoutCBoxFullscreen->addWidget(_optFullscreen); - _layoutCBoxFullscreen->addStretch(1); - _layout->addLayout(_layoutCBoxFullscreen); - _optVsync = _windowControl.back()->checkBoxVsync(); - _layoutCBoxVsync= new QHBoxLayout(this); - _layoutCBoxVsync->addStretch(1); - _layoutCBoxVsync->addWidget(_optVsync); - _layoutCBoxVsync->addStretch(1); - _layout->addLayout(_layoutCBoxVsync); - _optWebGui = _windowControl.back()->checkBoxWebGui(); - _layoutCBoxWebGui= new QHBoxLayout(this); - _layoutCBoxWebGui->addStretch(1); - _layoutCBoxWebGui->addWidget(_optWebGui); - _layoutCBoxWebGui->addStretch(1); - _layout->addLayout(_layoutCBoxWebGui); - _optSpoutOutput = _windowControl.back()->checkBoxSpoutOutput(); - _layoutCBoxSpoutOutput= new QHBoxLayout(this); - _layoutCBoxSpoutOutput->addStretch(1); - _layoutCBoxSpoutOutput->addWidget(_optSpoutOutput); - _layoutCBoxSpoutOutput->addStretch(1); - _layout->addLayout(_layoutCBoxSpoutOutput); + winCtrl->initializeLayout(this, _layoutWindows); + _layout->addLayout(_layoutWindows); this->setLayout(_layout); - int windowSize_x = std::stoi(_lineSizeX->text().toStdString()); - int windowSize_y = std::stoi(_lineSizeY->text().toStdString()); QRect defaultMonitorResolution(_monitorResolution[0], _monitorResolution[1], 0, 0); _monBox->setResolution(defaultMonitorResolution); } void Display::toggleWindows() { - std::cout << "Toggle." << std::endl; + if (_nWindows == 1) { + addWindowControl(); + _borderFrame = new QFrame; + _borderFrame->setFrameShape(QFrame::VLine); + _layoutWindows->addWidget(_borderFrame); + _windowControl.back()->initializeLayout(this, _layoutWindows); + _toggleNumMonitorsButton->setText("Remove 2nd window"); + } + else if (_nWindows == 2) { + removeWindowControl(); + delete _borderFrame; + _toggleNumMonitorsButton->setText("Add 2nd window"); + } } void Display::addWindowControl() { @@ -152,3 +86,12 @@ void Display::addWindowControl() { _nWindows++; } } + +void Display::removeWindowControl() { + if (_nWindows == 2) { + delete _windowControl.back(); + _windowControl.pop_back(); + _monBox->removeAdditionalWindowDimensions(); + _nWindows--; + } +} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 41e083342b..ecc7f99301 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -95,3 +95,10 @@ void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int index, cons this->update(); } +void MonitorBox::removeAdditionalWindowDimensions() { + if (_windowRendering.size() > 1) { + delete _windowRendering.back(); + _windowRendering.pop_back(); + } +} + diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index b1378d5c46..dc0acab09b 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -45,6 +45,73 @@ WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, SLOT(onOffsetYChanged(const QString&))); } +void WindowControl::initializeLayout(QWidget* parentWidget, QHBoxLayout* layout) { + _layoutFullWindow = new QVBoxLayout(parentWidget); + //Window size + _layoutWindowCtrl = new QVBoxLayout(parentWidget); +// _size_x = _windowControl.back()->lineEditSizeWidth(); +// _size_y = _windowControl.back()->lineEditSizeHeight(); + _size_x->setFixedWidth(_lineEditWidthFixed); + _size_y->setFixedWidth(_lineEditWidthFixed); + _labelSize = new QLabel(this); + _labelDelim = new QLabel(this); + _layoutSize = new QHBoxLayout(parentWidget); + _layoutSize->addStretch(1); + _layoutSize->addWidget(_labelSize); + _labelSize->setFixedWidth(60); + _labelSize->setText("Size:"); + _layoutSize->addWidget(_size_x); + _layoutSize->addWidget(_labelDelim); + _layoutSize->addWidget(_size_y); + _layoutSize->addStretch(1); + _labelDelim->setText(" x "); + _layoutWindowCtrl->addLayout(_layoutSize); + + //Window offset +// _lineOffsetX = _windowControl.back()->lineEditSizeOffsetX(); +// _lineOffsetY = _windowControl.back()->lineEditSizeOffsetY(); + _offset_x->setFixedWidth(_lineEditWidthFixed); + _offset_y->setFixedWidth(_lineEditWidthFixed); + _labelOffset = new QLabel(this); + _labelComma = new QLabel(this); + _layoutOffset = new QHBoxLayout(parentWidget); + _layoutOffset->addStretch(1); + _layoutOffset->addWidget(_labelOffset); + _labelOffset->setFixedWidth(60); + _labelOffset->setText("Offset:"); + _layoutOffset->addWidget(_offset_x); + _layoutOffset->addWidget(_labelComma); + _layoutOffset->addWidget(_offset_y); + _layoutOffset->addStretch(1); + _labelComma->setText(" , "); + _layoutWindowCtrl->addLayout(_layoutOffset); + + //Window options + _layoutCBoxFullscreen = new QHBoxLayout(parentWidget); + _layoutCBoxFullscreen->addStretch(1); + _layoutCBoxFullscreen->addWidget(_checkBoxFullscreen); + _layoutCBoxFullscreen->addStretch(1); + _layoutWindowCtrl->addLayout(_layoutCBoxFullscreen); + _layoutCBoxVsync= new QHBoxLayout(parentWidget); + _layoutCBoxVsync->addStretch(1); + _layoutCBoxVsync->addWidget(_checkBoxVsync); + _layoutCBoxVsync->addStretch(1); + _layoutWindowCtrl->addLayout(_layoutCBoxVsync); + _layoutCBoxWebGui= new QHBoxLayout(parentWidget); + _layoutCBoxWebGui->addStretch(1); + _layoutCBoxWebGui->addWidget(_checkBoxWebGui); + _layoutCBoxWebGui->addStretch(1); + _layoutWindowCtrl->addLayout(_layoutCBoxWebGui); + _layoutCBoxSpoutOutput= new QHBoxLayout(parentWidget); + _layoutCBoxSpoutOutput->addStretch(1); + _layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); + _layoutCBoxSpoutOutput->addStretch(1); + _layoutWindowCtrl->addLayout(_layoutCBoxSpoutOutput); + + _layoutFullWindow->addLayout(_layoutWindowCtrl); + layout->addLayout(_layoutFullWindow); +} + void WindowControl::onSizeXChanged(const QString& newText) { std::string x = newText.toStdString(); if (!x.empty()) { @@ -143,5 +210,20 @@ WindowControl::~WindowControl() delete _size_y; delete _offset_x; delete _offset_y; + delete _labelSize; + delete _labelDelim; + delete _layoutSize; + delete _labelOffset; + delete _labelComma; + delete _layoutOffset; + delete _checkBoxFullscreen; + delete _checkBoxVsync; + delete _checkBoxWebGui; + delete _checkBoxSpoutOutput; + delete _layoutCBoxFullscreen; + delete _layoutCBoxVsync; + delete _layoutCBoxWebGui; + delete _layoutCBoxSpoutOutput; + delete _layoutWindowCtrl; } From fdf56ef99496641ffa2ad7e112c303f1b2707fc7 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:07:57 -0700 Subject: [PATCH 08/93] Working version with dual windows --- .../ext/launcher/include/sgctedit/display.h | 9 ++- .../launcher/include/sgctedit/monitorbox.h | 2 +- .../launcher/include/sgctedit/windowcontrol.h | 10 +-- .../ext/launcher/src/sgctedit/display.cpp | 64 +++++++++++-------- .../ext/launcher/src/sgctedit/monitorbox.cpp | 14 +++- .../launcher/src/sgctedit/windowcontrol.cpp | 8 +-- 6 files changed, 60 insertions(+), 47 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 70abc5c4ab..d63571240a 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -36,17 +36,22 @@ private slots: private: void addWindowControl(); void removeWindowControl(); - void initializeLayout(unsigned int windowIndex, WindowControl* winCtrl); + void initializeLayout(); + void hideSecondWindow(); + void showSecondWindow(); unsigned int _monitorResolution[2] = {1920, 1080}; QRect _monitorRes = {0, 0, _monitorResolution[0], _monitorResolution[1]}; QRect _widgetDims = {0, 0, 400, 400}; std::vector _windowControl; - unsigned int _nWindows = 0; + unsigned int _nWindowsAllocated = 0; + unsigned int _nWindowsDisplayed = 0; QPushButton* _toggleNumMonitorsButton = nullptr; MonitorBox* _monBox = nullptr; QVBoxLayout* _layout = nullptr; QHBoxLayout* _layoutMonButton = nullptr; QHBoxLayout* _layoutWindows = nullptr; + std::vector _winCtrlLayouts; + std::vector _layoutWindowWrappers; QFrame* _borderFrame = nullptr; }; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 332972136b..79331895cf 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -26,9 +26,9 @@ public: void mapMonitorResolutionToWidgetCoordinates(QRect r); void mapWindowResolutionToWidgetCoordinates(unsigned int index, const QRectF& w); void setResolution(QRect& res); + void setNumWindowsDisplayed(unsigned int nWindows); int numWindows(); void windowDimensionsChanged(unsigned int index, const QRectF newDimensions); -// float monitorScaleFactor(); void addWindowControl(WindowControl* wCtrl); void removeAdditionalWindowDimensions(); diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index ac14c67ff7..82358519aa 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -28,7 +28,7 @@ public: void setDimensions(const QRectF& dimensions); void setWindowScaleFactor(float scaleFactor); void setWindowChangeCallback(std::function cb); - void initializeLayout(QWidget* parentWidget, QHBoxLayout* layout); + QVBoxLayout* initializeLayout(QWidget* parentWidget/*, QHBoxLayout* layout*/); QRectF& dimensions(); QLineEdit* lineEditSizeWidth(); QLineEdit* lineEditSizeHeight(); @@ -77,17 +77,9 @@ private: QLabel* _labelSize = nullptr; QLabel* _labelDelim = nullptr; QHBoxLayout* _layoutSize = nullptr; -// QLineEdit* _lineSizeX = nullptr; -// QLineEdit* _lineSizeY = nullptr; -// QLineEdit* _lineOffsetX = nullptr; -// QLineEdit* _lineOffsetY = nullptr; QLabel* _labelOffset = nullptr; QLabel* _labelComma = nullptr; QHBoxLayout* _layoutOffset = nullptr; -// QCheckBox* _optFullscreen = nullptr; -// QCheckBox* _optVsync = nullptr; -// QCheckBox* _optWebGui = nullptr; -// QCheckBox* _optSpoutOutput = nullptr; QHBoxLayout* _layoutCBoxFullscreen = nullptr; QHBoxLayout* _layoutCBoxVsync = nullptr; QHBoxLayout* _layoutCBoxWebGui = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 63ad1b9734..898d4117b0 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -12,10 +12,11 @@ Display::Display() _toggleNumMonitorsButton = new QPushButton("Add 2nd Window", this); _toggleNumMonitorsButton->setObjectName("toggleNumMonitors"); - //WindowControl wCtrl(0, _widgetDims, _monitorRes, this); _monBox = new MonitorBox(_widgetDims, _monitorRes, this); + //Add 2 window controls addWindowControl(); - initializeLayout(0, _windowControl[0]); + addWindowControl(); + initializeLayout(); connect(_toggleNumMonitorsButton, SIGNAL(released()), this, SLOT(toggleWindows())); @@ -29,7 +30,7 @@ Display::~Display() { delete _layout; } -void Display::initializeLayout(unsigned int windowIndex, WindowControl* winCtrl) { +void Display::initializeLayout() { _layout = new QVBoxLayout(this); _layout->addWidget(_monBox); _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -41,7 +42,18 @@ void Display::initializeLayout(unsigned int windowIndex, WindowControl* winCtrl) _layout->addLayout(_layoutMonButton); _layoutWindows = new QHBoxLayout(this); - winCtrl->initializeLayout(this, _layoutWindows); + _winCtrlLayouts.push_back(_windowControl[0]->initializeLayout(this)); + _layoutWindowWrappers.push_back(new QWidget()); + _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); + _layoutWindows->addWidget(_layoutWindowWrappers.back()); + _borderFrame = new QFrame; + _borderFrame->setFrameShape(QFrame::VLine); + _layoutWindows->addWidget(_borderFrame); + _winCtrlLayouts.push_back(_windowControl[1]->initializeLayout(this)); + _layoutWindowWrappers.push_back(new QWidget()); + _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); + _layoutWindows->addWidget(_layoutWindowWrappers.back()); + hideSecondWindow(); _layout->addLayout(_layoutWindows); this->setLayout(_layout); @@ -51,26 +63,35 @@ void Display::initializeLayout(unsigned int windowIndex, WindowControl* winCtrl) } void Display::toggleWindows() { - if (_nWindows == 1) { - addWindowControl(); - _borderFrame = new QFrame; - _borderFrame->setFrameShape(QFrame::VLine); - _layoutWindows->addWidget(_borderFrame); - _windowControl.back()->initializeLayout(this, _layoutWindows); + if (_nWindowsDisplayed == 1) { _toggleNumMonitorsButton->setText("Remove 2nd window"); + showSecondWindow(); } - else if (_nWindows == 2) { - removeWindowControl(); - delete _borderFrame; + else if (_nWindowsDisplayed == 2) { _toggleNumMonitorsButton->setText("Add 2nd window"); + hideSecondWindow(); } } +void Display::hideSecondWindow() { + _borderFrame->setVisible(false); + _layoutWindowWrappers[1]->setVisible(false); + _nWindowsDisplayed = 1; + _monBox->setNumWindowsDisplayed(_nWindowsDisplayed); +} + +void Display::showSecondWindow() { + _borderFrame->setVisible(true); + _layoutWindowWrappers[1]->setVisible(true); + _nWindowsDisplayed = 2; + _monBox->setNumWindowsDisplayed(_nWindowsDisplayed); +} + void Display::addWindowControl() { - if (_nWindows < 2) { + if (_nWindowsAllocated < 2) { _windowControl.push_back( new WindowControl( - _nWindows, + _nWindowsAllocated, _widgetDims, _monitorRes, this @@ -81,17 +102,8 @@ void Display::addWindowControl() { _monBox->windowDimensionsChanged(windowIndex, newDims); } ); - _monBox->mapWindowResolutionToWidgetCoordinates(_nWindows, + _monBox->mapWindowResolutionToWidgetCoordinates(_nWindowsAllocated, _windowControl.back()->dimensions()); - _nWindows++; - } -} - -void Display::removeWindowControl() { - if (_nWindows == 2) { - delete _windowControl.back(); - _windowControl.pop_back(); - _monBox->removeAdditionalWindowDimensions(); - _nWindows--; + _nWindowsAllocated++; } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index ecc7f99301..1f21f9470e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -31,8 +31,10 @@ void MonitorBox::paintEvent(QPaintEvent *event) painter.drawRect(_monitorDimensionsScaled); //Draw window(s) painter.setPen(Qt::blue); - for (QRectF* w : _windowRendering) { - painter.drawRect(*w); + for (unsigned int i = 0; i < _nWindows; ++i) { + if (i <= _windowRendering.size()) { + painter.drawRect(*_windowRendering[i]); + } } } @@ -41,7 +43,6 @@ void MonitorBox::windowDimensionsChanged(unsigned int index, const QRectF newDim } void MonitorBox::mapMonitorResolutionToWidgetCoordinates(QRect r) { -// _monitorResolution = r; float aspectRatio = static_cast(r.width()) / static_cast(r.height()); _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; @@ -76,6 +77,13 @@ void MonitorBox::setResolution(QRect& res) { _monitorResolution = res; } +void MonitorBox::setNumWindowsDisplayed(unsigned int nWindows) { + if (_nWindows != nWindows) { + _nWindows = nWindows; + this->update(); + } +} + void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int index, const QRectF& w) { if (index > 1) { return; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index dc0acab09b..fc43503776 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -45,12 +45,10 @@ WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, SLOT(onOffsetYChanged(const QString&))); } -void WindowControl::initializeLayout(QWidget* parentWidget, QHBoxLayout* layout) { +QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayout* layout*/) { _layoutFullWindow = new QVBoxLayout(parentWidget); //Window size _layoutWindowCtrl = new QVBoxLayout(parentWidget); -// _size_x = _windowControl.back()->lineEditSizeWidth(); -// _size_y = _windowControl.back()->lineEditSizeHeight(); _size_x->setFixedWidth(_lineEditWidthFixed); _size_y->setFixedWidth(_lineEditWidthFixed); _labelSize = new QLabel(this); @@ -68,8 +66,6 @@ void WindowControl::initializeLayout(QWidget* parentWidget, QHBoxLayout* layout) _layoutWindowCtrl->addLayout(_layoutSize); //Window offset -// _lineOffsetX = _windowControl.back()->lineEditSizeOffsetX(); -// _lineOffsetY = _windowControl.back()->lineEditSizeOffsetY(); _offset_x->setFixedWidth(_lineEditWidthFixed); _offset_y->setFixedWidth(_lineEditWidthFixed); _labelOffset = new QLabel(this); @@ -109,7 +105,7 @@ void WindowControl::initializeLayout(QWidget* parentWidget, QHBoxLayout* layout) _layoutWindowCtrl->addLayout(_layoutCBoxSpoutOutput); _layoutFullWindow->addLayout(_layoutWindowCtrl); - layout->addLayout(_layoutFullWindow); + return _layoutFullWindow; } void WindowControl::onSizeXChanged(const QString& newText) { From 3a61bd601b3ba9b3c46a3656f458f4204dbab372 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:09:24 -0700 Subject: [PATCH 09/93] Display layout improvements --- .../ext/launcher/include/sgctedit/display.h | 1 + .../launcher/include/sgctedit/windowcontrol.h | 5 ++- .../ext/launcher/src/sgctedit/display.cpp | 13 +++++- .../launcher/src/sgctedit/windowcontrol.cpp | 43 +++++++++++++------ 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index d63571240a..ac8c4e451e 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -48,6 +48,7 @@ private: QPushButton* _toggleNumMonitorsButton = nullptr; MonitorBox* _monBox = nullptr; QVBoxLayout* _layout = nullptr; + QHBoxLayout* _layoutMonBox = nullptr; QHBoxLayout* _layoutMonButton = nullptr; QHBoxLayout* _layoutWindows = nullptr; std::vector _winCtrlLayouts; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 82358519aa..fa0ef765b8 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -28,6 +28,7 @@ public: void setDimensions(const QRectF& dimensions); void setWindowScaleFactor(float scaleFactor); void setWindowChangeCallback(std::function cb); + void cleanupLayouts(); QVBoxLayout* initializeLayout(QWidget* parentWidget/*, QHBoxLayout* layout*/); QRectF& dimensions(); QLineEdit* lineEditSizeWidth(); @@ -52,7 +53,7 @@ private: {50.0, 50.0, 800.0, 600.0}, {900.0, 400.0, 640.0, 480.0} }; - int _lineEditWidthFixed = 80; + int _lineEditWidthFixed = 50; float _marginFractionOfWidgetSize = 0.025; int _index = 0; @@ -80,6 +81,8 @@ private: QLabel* _labelOffset = nullptr; QLabel* _labelComma = nullptr; QHBoxLayout* _layoutOffset = nullptr; + QHBoxLayout* _layoutCheckboxesFull1 = nullptr; + QVBoxLayout* _layoutCheckboxesFull2 = nullptr; QHBoxLayout* _layoutCBoxFullscreen = nullptr; QHBoxLayout* _layoutCBoxVsync = nullptr; QHBoxLayout* _layoutCBoxWebGui = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 898d4117b0..76797c81cd 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -25,6 +25,7 @@ Display::Display() Display::~Display() { delete _toggleNumMonitorsButton; delete _monBox; + delete _layoutMonBox; delete _layoutMonButton; delete _layoutWindows; delete _layout; @@ -32,7 +33,12 @@ Display::~Display() { void Display::initializeLayout() { _layout = new QVBoxLayout(this); - _layout->addWidget(_monBox); + _layoutMonBox = new QHBoxLayout(this); + _layoutMonBox->addStretch(1); + //_layout->addWidget(_monBox); + _layoutMonBox->addWidget(_monBox); + _layoutMonBox->addStretch(1); + _layout->addLayout(_layoutMonBox); _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _monBox->setFixedSize(400, 400); _layoutMonButton = new QHBoxLayout(this); @@ -60,6 +66,10 @@ void Display::initializeLayout() { QRect defaultMonitorResolution(_monitorResolution[0], _monitorResolution[1], 0, 0); _monBox->setResolution(defaultMonitorResolution); + + for (WindowControl* w : _windowControl) { + w->cleanupLayouts(); + } } void Display::toggleWindows() { @@ -70,6 +80,7 @@ void Display::toggleWindows() { else if (_nWindowsDisplayed == 2) { _toggleNumMonitorsButton->setText("Add 2nd window"); hideSecondWindow(); + int minWidth = minimumWidth(); } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index fc43503776..979e990e32 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -56,13 +56,13 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _layoutSize = new QHBoxLayout(parentWidget); _layoutSize->addStretch(1); _layoutSize->addWidget(_labelSize); - _labelSize->setFixedWidth(60); + //_labelSize->setFixedWidth(50); _labelSize->setText("Size:"); _layoutSize->addWidget(_size_x); _layoutSize->addWidget(_labelDelim); _layoutSize->addWidget(_size_y); _layoutSize->addStretch(1); - _labelDelim->setText(" x "); + _labelDelim->setText("x"); _layoutWindowCtrl->addLayout(_layoutSize); //Window offset @@ -73,41 +73,58 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _layoutOffset = new QHBoxLayout(parentWidget); _layoutOffset->addStretch(1); _layoutOffset->addWidget(_labelOffset); - _labelOffset->setFixedWidth(60); + //_labelOffset->setFixedWidth(50); _labelOffset->setText("Offset:"); _layoutOffset->addWidget(_offset_x); _layoutOffset->addWidget(_labelComma); _layoutOffset->addWidget(_offset_y); _layoutOffset->addStretch(1); - _labelComma->setText(" , "); + _labelComma->setText(","); _layoutWindowCtrl->addLayout(_layoutOffset); //Window options + _layoutCheckboxesFull1 = new QHBoxLayout(parentWidget); + _layoutCheckboxesFull2 = new QVBoxLayout(parentWidget); + _layoutCheckboxesFull1->addStretch(1); _layoutCBoxFullscreen = new QHBoxLayout(parentWidget); - _layoutCBoxFullscreen->addStretch(1); + //_layoutCBoxFullscreen->addStretch(1); _layoutCBoxFullscreen->addWidget(_checkBoxFullscreen); _layoutCBoxFullscreen->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutCBoxFullscreen); + _layoutCheckboxesFull2->addLayout(_layoutCBoxFullscreen); _layoutCBoxVsync= new QHBoxLayout(parentWidget); - _layoutCBoxVsync->addStretch(1); + //_layoutCBoxVsync->addStretch(1); _layoutCBoxVsync->addWidget(_checkBoxVsync); _layoutCBoxVsync->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutCBoxVsync); + _layoutCheckboxesFull2->addLayout(_layoutCBoxVsync); _layoutCBoxWebGui= new QHBoxLayout(parentWidget); - _layoutCBoxWebGui->addStretch(1); + //_layoutCBoxWebGui->addStretch(1); _layoutCBoxWebGui->addWidget(_checkBoxWebGui); _layoutCBoxWebGui->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutCBoxWebGui); + _layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); _layoutCBoxSpoutOutput= new QHBoxLayout(parentWidget); - _layoutCBoxSpoutOutput->addStretch(1); + //_layoutCBoxSpoutOutput->addStretch(1); _layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); _layoutCBoxSpoutOutput->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutCBoxSpoutOutput); + _layoutCheckboxesFull2->addLayout(_layoutCBoxSpoutOutput); + _layoutCheckboxesFull1->addLayout(_layoutCheckboxesFull2); + _layoutCheckboxesFull1->addStretch(1); + _layoutWindowCtrl->addLayout(_layoutCheckboxesFull1); _layoutFullWindow->addLayout(_layoutWindowCtrl); + return _layoutFullWindow; } +void WindowControl::cleanupLayouts() { + int labelSize1 = _labelSize->width(); + int labelSize2 = _labelOffset->width(); +std::cout << "label1 = " << std::to_string(labelSize1) << std::endl; +std::cout << "label2 = " << std::to_string(labelSize2) << std::endl; + int labelWidthStandard = std::max(labelSize1, labelSize2); + _labelSize->setFixedWidth(labelWidthStandard); + _labelOffset->setFixedWidth(labelWidthStandard); +} + void WindowControl::onSizeXChanged(const QString& newText) { std::string x = newText.toStdString(); if (!x.empty()) { @@ -220,6 +237,8 @@ WindowControl::~WindowControl() delete _layoutCBoxVsync; delete _layoutCBoxWebGui; delete _layoutCBoxSpoutOutput; + delete _layoutCheckboxesFull2; + delete _layoutCheckboxesFull1; delete _layoutWindowCtrl; } From 3c82938c8975dcf22f32aa3db4847cf08705eddf Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:10:36 -0700 Subject: [PATCH 10/93] Temporary code for detecting monitor resolution(s) --- .../ext/launcher/src/sgctedit/main.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index e59624e05f..80f55d93d3 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -1,12 +1,13 @@ #include #include #include -#include -#include #include +#include #include #include -#include +#include +#include +#include #include #include "include/display.h" @@ -17,6 +18,18 @@ int main(int argc, char *argv[ ]) { QApplication app(argc, argv); + + //Temporary code for monitor detection + QList screenList = app.screens(); + for (QScreen* s : screenList) { + std::cout << "Monitor "; + std::cout << s->size().width() << "x" << s->size().height(); + std::cout << std::endl; + } + QScreen* screen = app.primaryScreen(); + QRect screenGeometry = screen->geometry(); + //End code for monitor detection + QMainWindow win(nullptr); Display* displayWidget = new Display(); win.setCentralWidget(displayWidget); From b9fdc564439a45c6ed8de55e61ba70d2fc6000aa Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:14:04 -0700 Subject: [PATCH 11/93] Draft with all controls added --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 9 ++ .../ext/launcher/include/sgctedit/display.h | 8 +- .../launcher/include/sgctedit/monitorbox.h | 8 +- .../launcher/include/sgctedit/orientation.h | 37 ++++++ .../include/sgctedit/orientationdialog.h | 54 ++++++++ .../include/sgctedit/projectiondialog.h | 54 ++++++++ .../launcher/include/sgctedit/windowcontrol.h | 37 +++++- .../ext/launcher/src/sgctedit/display.cpp | 38 +++--- .../ext/launcher/src/sgctedit/main.cpp | 75 +++++++++-- .../ext/launcher/src/sgctedit/monitorbox.cpp | 6 +- .../ext/launcher/src/sgctedit/orientation.cpp | 26 ++++ .../src/sgctedit/orientationdialog.cpp | 90 ++++++++++++++ .../src/sgctedit/projectiondialog.cpp | 87 +++++++++++++ .../launcher/src/sgctedit/windowcontrol.cpp | 116 +++++++++++++++++- 14 files changed, 602 insertions(+), 43 deletions(-) create mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h create mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h create mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/projectiondialog.h create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/projectiondialog.cpp diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index b2f9fae3b8..c5d157441e 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -44,6 +44,9 @@ set(HEADER_FILES include/profile/propertiesdialog.h include/sgctedit/display.h include/sgctedit/monitorbox.h + include/sgctedit/orientation.h + include/sgctedit/orientationdialog.h + include/sgctedit/projectiondialog.h include/sgctedit/windowcontrol.h ) @@ -68,6 +71,9 @@ set(SOURCE_FILES src/sgctedit/display.cpp src/sgctedit/main.cpp src/sgctedit/monitorbox.cpp + src/sgctedit/orientation.cpp + src/sgctedit/orientationdialog.cpp + src/sgctedit/projectiondialog.cpp src/sgctedit/windowcontrol.cpp ) @@ -88,6 +94,9 @@ set(HEADER_SOURCE include/profile/propertiesdialog.h include/sgctedit/display.h include/sgctedit/monitorbox.h + include/sgctedit/orientation.h + include/sgctedit/orientationdialog.h + include/sgctedit/projectiondialog.h include/sgctedit/windowcontrol.h ) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index ac8c4e451e..ef1d0303a9 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -27,7 +27,7 @@ class Display : public QWidget Q_OBJECT public: - explicit Display(); + explicit Display(QHBoxLayout* parentLayout, QSize* monitorDims); ~Display(); private slots: @@ -36,7 +36,7 @@ private slots: private: void addWindowControl(); void removeWindowControl(); - void initializeLayout(); + void initializeLayout(QHBoxLayout* parentLayout); void hideSecondWindow(); void showSecondWindow(); unsigned int _monitorResolution[2] = {1920, 1080}; @@ -45,8 +45,8 @@ private: std::vector _windowControl; unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; - QPushButton* _toggleNumMonitorsButton = nullptr; - MonitorBox* _monBox = nullptr; + QPushButton* _toggleNumWindowsButton = nullptr; + MonitorBox* _monBox; QVBoxLayout* _layout = nullptr; QHBoxLayout* _layoutMonBox = nullptr; QHBoxLayout* _layoutMonButton = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 79331895cf..6ec5fc59a0 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -20,12 +20,12 @@ class MonitorBox : public QWidget Q_OBJECT public: - explicit MonitorBox(QRect widgetDims, QRect monitorResolution, + explicit MonitorBox(QRect widgetDims, QSize monitorResolution, QWidget *parent = nullptr); ~MonitorBox(); - void mapMonitorResolutionToWidgetCoordinates(QRect r); + void mapMonitorResolutionToWidgetCoordinates(QSize r); void mapWindowResolutionToWidgetCoordinates(unsigned int index, const QRectF& w); - void setResolution(QRect& res); + void setResolution(QSize& res); void setNumWindowsDisplayed(unsigned int nWindows); int numWindows(); void windowDimensionsChanged(unsigned int index, const QRectF newDimensions); @@ -39,7 +39,7 @@ private: QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; - QRect _monitorResolution; + QSize _monitorResolution; QRectF _monitorDimensionsScaled; std::vector _windowResolutions; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h new file mode 100644 index 0000000000..fee35e9c7f --- /dev/null +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -0,0 +1,37 @@ +#ifndef ORIENTATION_H +#define ORIENTATION_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +class Orientation : public QWidget +{ + Q_OBJECT + +public: + explicit Orientation(QVBoxLayout* parentLayout); + ~Orientation(); + +private slots: + void orientationDialog(); + +private: + QHBoxLayout* _layoutOrientationButton = nullptr; + QPushButton* _orientationButton = nullptr; +}; + +#endif // ORIENTATION_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h new file mode 100644 index 0000000000..cb44aa8743 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h @@ -0,0 +1,54 @@ +#ifndef ORIENTATION_DIALOG_H +#define ORIENTATION_DIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +class OrientationDialog : public QDialog +{ +Q_OBJECT + +public: + explicit OrientationDialog(QWidget* parent); + ~OrientationDialog(); + +private slots: + +private: + QVBoxLayout* _layoutWindow = nullptr; + QHBoxLayout* _layoutPitch = nullptr; + QHBoxLayout* _layoutRoll = nullptr; + QHBoxLayout* _layoutYaw = nullptr; + QHBoxLayout* _layoutButtonBox = nullptr; + + QLabel* _labelPitch = nullptr; + QLabel* _labelRoll = nullptr; + QLabel* _labelYaw = nullptr; + + QLineEdit* _linePitch = nullptr; + QLineEdit* _lineRoll = nullptr; + QLineEdit* _lineYaw = nullptr; + QDoubleValidator* _validatorPitch = nullptr; + QDoubleValidator* _validatorRoll = nullptr; + QDoubleValidator* _validatorYaw = nullptr; + + QPushButton* _buttonSave = nullptr; + QPushButton* _buttonCancel = nullptr; +}; + +#endif // ORIENTATION_DIALOG_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/projectiondialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/projectiondialog.h new file mode 100644 index 0000000000..3fd11ab54e --- /dev/null +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/projectiondialog.h @@ -0,0 +1,54 @@ +#ifndef PROJECTION_DIALOG_H +#define PROJECTION_DIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +class ProjectionDialog : public QDialog +{ +Q_OBJECT + +public: + explicit ProjectionDialog(QWidget* parent); + ~ProjectionDialog(); + +private slots: + +private: + QVBoxLayout* _layoutWindow = nullptr; + QHBoxLayout* _layoutPitch = nullptr; + QHBoxLayout* _layoutRoll = nullptr; + QHBoxLayout* _layoutYaw = nullptr; + QHBoxLayout* _layoutButtonBox = nullptr; + + QLabel* _labelPitch = nullptr; + QLabel* _labelRoll = nullptr; + QLabel* _labelYaw = nullptr; + + QLineEdit* _linePitch = nullptr; + QLineEdit* _lineRoll = nullptr; + QLineEdit* _lineYaw = nullptr; + QDoubleValidator* _validatorPitch = nullptr; + QDoubleValidator* _validatorRoll = nullptr; + QDoubleValidator* _validatorYaw = nullptr; + + QPushButton* _buttonSave = nullptr; + QPushButton* _buttonCancel = nullptr; +}; + +#endif // PROJECTION_DIALOG_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index fa0ef765b8..219e55cd02 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -2,6 +2,7 @@ #define WINDOWCONTROL_H #include +#include #include #include #include @@ -45,6 +46,8 @@ private slots: void onSizeYChanged(const QString& newText); void onOffsetXChanged(const QString& newText); void onOffsetYChanged(const QString& newText); + void onProjectionChanged(int newSelection); + void onQualityChanged(int newSelection); private: void updateScaledWindowDimensions(); @@ -53,18 +56,30 @@ private: {50.0, 50.0, 800.0, 600.0}, {900.0, 400.0, 640.0, 480.0} }; + QList _projectionTypes = { + "Planar", "Fisheye", "Spherical Mirror", "Cylindrical", "Equirectangular" + }; + QList _qualityTypes = { + "Low (256)", "Medium (512)", "High (1K)", "1.5K (1536)", "2K (2048)", + "4K (4096)", "8K (8192)", "16K (16384)", "32K (32768)", "64K (65536)" + }; int _lineEditWidthFixed = 50; float _marginFractionOfWidgetSize = 0.025; int _index = 0; - QVBoxLayout* _layoutWindowCtrl; - QVBoxLayout* _layoutFullWindow; + QVBoxLayout* _layoutWindowCtrl = nullptr; + QVBoxLayout* _layoutFullWindow = nullptr; QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; QLineEdit* _offset_x = nullptr; QLineEdit* _offset_y = nullptr; + QIntValidator* _validatorSize_x = nullptr; + QIntValidator* _validatorSize_y = nullptr; + QIntValidator* _validatorOffset_x = nullptr; + QIntValidator* _validatorOffset_y = nullptr; + QRect _monitorResolution; QRectF _monitorDimsScaled; QRectF _windowDims; @@ -75,6 +90,18 @@ private: QCheckBox* _checkBoxWebGui = nullptr; QCheckBox* _checkBoxSpoutOutput = nullptr; + QComboBox* _comboProjection = nullptr; + QComboBox* _comboQuality = nullptr; + QLabel* _labelFov = nullptr; + QLineEdit* _lineFov = nullptr; + QDoubleValidator* _validatorFov = nullptr; + QLabel* _labelHeightOffset = nullptr; + QLineEdit* _lineHeightOffset = nullptr; + QDoubleValidator* _validatorHeightOffset = nullptr; + + QHBoxLayout* _layoutName = nullptr; + QLabel* _labelName = nullptr; + QLineEdit* _windowName = nullptr; QLabel* _labelSize = nullptr; QLabel* _labelDelim = nullptr; QHBoxLayout* _layoutSize = nullptr; @@ -87,6 +114,12 @@ private: QHBoxLayout* _layoutCBoxVsync = nullptr; QHBoxLayout* _layoutCBoxWebGui = nullptr; QHBoxLayout* _layoutCBoxSpoutOutput = nullptr; + QHBoxLayout* _layoutComboProjection = nullptr; + QHBoxLayout* _layoutComboQuality = nullptr; + QHBoxLayout* _layoutFov = nullptr; + QWidget* _layoutFovWrapper = nullptr; + QHBoxLayout* _layoutHeightOffset = nullptr; + QWidget* _layoutHeightOffsetWrapper = nullptr; }; #endif // WINDOWCONTROL_H diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 76797c81cd..1c8bb8fe3c 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "include/monitorbox.h" @@ -7,23 +8,23 @@ #include "include/display.h" -Display::Display() +Display::Display(QHBoxLayout* parentLayout, QSize* monitorDims) { - _toggleNumMonitorsButton = new QPushButton("Add 2nd Window", this); - _toggleNumMonitorsButton->setObjectName("toggleNumMonitors"); + _toggleNumWindowsButton = new QPushButton("Add 2nd Window", this); + _toggleNumWindowsButton->setObjectName("toggleNumWindows"); - _monBox = new MonitorBox(_widgetDims, _monitorRes, this); + _monBox = new MonitorBox(_widgetDims, *monitorDims, this); //Add 2 window controls addWindowControl(); addWindowControl(); - initializeLayout(); + initializeLayout(parentLayout); - connect(_toggleNumMonitorsButton, SIGNAL(released()), this, + connect(_toggleNumWindowsButton, SIGNAL(released()), this, SLOT(toggleWindows())); } Display::~Display() { - delete _toggleNumMonitorsButton; + delete _toggleNumWindowsButton; delete _monBox; delete _layoutMonBox; delete _layoutMonButton; @@ -31,7 +32,7 @@ Display::~Display() { delete _layout; } -void Display::initializeLayout() { +void Display::initializeLayout(QHBoxLayout* parentLayout) { _layout = new QVBoxLayout(this); _layoutMonBox = new QHBoxLayout(this); _layoutMonBox->addStretch(1); @@ -39,11 +40,12 @@ void Display::initializeLayout() { _layoutMonBox->addWidget(_monBox); _layoutMonBox->addStretch(1); _layout->addLayout(_layoutMonBox); + _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _monBox->setFixedSize(400, 400); _layoutMonButton = new QHBoxLayout(this); _layoutMonButton->addStretch(1); - _layoutMonButton->addWidget(_toggleNumMonitorsButton); + _layoutMonButton->addWidget(_toggleNumWindowsButton); _layoutMonButton->addStretch(1); _layout->addLayout(_layoutMonButton); _layoutWindows = new QHBoxLayout(this); @@ -62,28 +64,30 @@ void Display::initializeLayout() { hideSecondWindow(); _layout->addLayout(_layoutWindows); - this->setLayout(_layout); + parentLayout->addLayout(_layout); +// this->setLayout(parentLayoutWrapper); - QRect defaultMonitorResolution(_monitorResolution[0], _monitorResolution[1], 0, 0); - _monBox->setResolution(defaultMonitorResolution); + //QSize defaultMonitorResolution(_monitorResolution[0], _monitorResolution[1], 0, 0); + //_monBox->setResolution(defaultMonitorResolution); - for (WindowControl* w : _windowControl) { - w->cleanupLayouts(); - } + //for (WindowControl* w : _windowControl) { + // w->cleanupLayouts(); + //} } void Display::toggleWindows() { if (_nWindowsDisplayed == 1) { - _toggleNumMonitorsButton->setText("Remove 2nd window"); + _toggleNumWindowsButton->setText("Remove 2nd window"); showSecondWindow(); } else if (_nWindowsDisplayed == 2) { - _toggleNumMonitorsButton->setText("Add 2nd window"); + _toggleNumWindowsButton->setText("Add 2nd window"); hideSecondWindow(); int minWidth = minimumWidth(); } } + void Display::hideSecondWindow() { _borderFrame->setVisible(false); _layoutWindowWrappers[1]->setVisible(false); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index 80f55d93d3..28fe1e38bf 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -13,29 +13,82 @@ #include "include/display.h" #include "include/monitorbox.h" #include "include/windowcontrol.h" +#include "include/orientation.h" int main(int argc, char *argv[ ]) { QApplication app(argc, argv); + QMainWindow win(nullptr); //Temporary code for monitor detection QList screenList = app.screens(); - for (QScreen* s : screenList) { - std::cout << "Monitor "; - std::cout << s->size().width() << "x" << s->size().height(); - std::cout << std::endl; + std::vector monitorSizeList; + for (size_t s = 0; s < std::min(screenList.length(), 2); ++s) { + monitorSizeList.push_back({//QRect( + screenList[s]->size().width(), + screenList[s]->size().height(), + }); } - QScreen* screen = app.primaryScreen(); - QRect screenGeometry = screen->geometry(); + //for (QScreen* s : screenList) { + // std::cout << "Monitor "; + // std::cout << s->size().width() << "x" << s->size().height() << std::endl; + //} + //std::cout << "Primary"; + //QScreen* screen = app.primaryScreen(); + //std::cout << screen->size().width() << "x" << screen->size().height() << std::endl; + //QRect screenGeometry = screen->geometry(); //End code for monitor detection - QMainWindow win(nullptr); - Display* displayWidget = new Display(); - win.setCentralWidget(displayWidget); - win.setWindowTitle("Test Qt14"); + Display* displayWidget = nullptr; + Display* displayWidget2 = nullptr; + QFrame* monitorBorderFrame = nullptr; + Orientation* orientationWidget = nullptr; + + if (screenList.length() == 0) { + std::cerr << "Error: Qt reports no screens available." << std::endl; + return -1; + } + QVBoxLayout* layoutMainV = new QVBoxLayout(); + QHBoxLayout* layoutMainH = new QHBoxLayout(); +// QWidget* layoutMainHWrapper = new QWidget(); +// layoutMainHWrapper->setLayout(layoutMainH); + displayWidget = new Display(layoutMainH, &monitorSizeList[0]); + layoutMainH->addWidget(displayWidget); + +screenList.push_back(screenList[0]); +QSize* m2 = new QSize(1080, 1920); +monitorSizeList.push_back({m2->width(), m2->height()}); + + if (screenList.size() > 1) { +std::cout << "Add display2." << std::endl; +// displayWidget2 = new Display(layoutMainH, &monitorSizeList[1]); + displayWidget2 = new Display(layoutMainH, &monitorSizeList[1]); + monitorBorderFrame = new QFrame(); + monitorBorderFrame->setFrameShape(QFrame::VLine); + layoutMainH->addWidget(monitorBorderFrame); + layoutMainH->addWidget(displayWidget2); + } + + layoutMainV->addLayout(layoutMainH); + orientationWidget = new Orientation(layoutMainV); + + QWidget* mainWindow = new QWidget(); + mainWindow->setLayout(layoutMainV); + win.setCentralWidget(mainWindow); + + win.setWindowTitle("Window Details"); win.show(); app.exec(); - + delete orientationWidget; delete displayWidget; + if (displayWidget2) { + delete displayWidget2; + } + if (monitorBorderFrame) { + delete monitorBorderFrame; + } + delete layoutMainH; + delete layoutMainV; + delete mainWindow; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 1f21f9470e..ba8a757017 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -2,7 +2,7 @@ -MonitorBox::MonitorBox(QRect widgetDims, QRect monitorResolution, QWidget *parent) +MonitorBox::MonitorBox(QRect widgetDims, QSize monitorResolution, QWidget *parent) : QWidget(parent) , _monitorWidgetSize(widgetDims) { @@ -42,7 +42,7 @@ void MonitorBox::windowDimensionsChanged(unsigned int index, const QRectF newDim mapWindowResolutionToWidgetCoordinates(index, newDimensions); } -void MonitorBox::mapMonitorResolutionToWidgetCoordinates(QRect r) { +void MonitorBox::mapMonitorResolutionToWidgetCoordinates(QSize r) { float aspectRatio = static_cast(r.width()) / static_cast(r.height()); _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; @@ -73,7 +73,7 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates(QRect r) { this->update(); } -void MonitorBox::setResolution(QRect& res) { +void MonitorBox::setResolution(QSize& res) { _monitorResolution = res; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp new file mode 100644 index 0000000000..ddfb441991 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -0,0 +1,26 @@ +#include "display.h" +#include "orientation.h" +#include "orientationdialog.h" + +Orientation::Orientation(QVBoxLayout* parentLayout) +{ + _orientationButton = new QPushButton("Global Orientation"); + _orientationButton->setObjectName("globalOrientation"); + _layoutOrientationButton = new QHBoxLayout(); + _layoutOrientationButton->addStretch(1); + _layoutOrientationButton->addWidget(_orientationButton); + _layoutOrientationButton->addStretch(1); + parentLayout->addLayout(_layoutOrientationButton); + connect(_orientationButton, SIGNAL(released()), this, + SLOT(orientationDialog())); +} + +void Orientation::orientationDialog() { + OrientationDialog(this).exec(); +} + +Orientation::~Orientation() +{ + delete _layoutOrientationButton; +} + diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp new file mode 100644 index 0000000000..0ee2f2d037 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -0,0 +1,90 @@ +#include "display.h" +#include "orientationdialog.h" + +OrientationDialog::OrientationDialog(QWidget* parent) + : QDialog(parent) +{ + setWindowTitle("Global Orientation"); + _layoutWindow = new QVBoxLayout(this); + _layoutPitch = new QHBoxLayout(this); + _layoutRoll = new QHBoxLayout(this); + _layoutYaw = new QHBoxLayout(this); + + _labelPitch = new QLabel(this); + _labelRoll = new QLabel(this); + _labelYaw = new QLabel(this); + _labelPitch->setText("Pitch: "); + _labelRoll ->setText("Roll: "); + _labelYaw ->setText("Yaw: "); + + _linePitch = new QLineEdit(this); + _lineRoll = new QLineEdit(this); + _lineYaw = new QLineEdit(this); + _linePitch->setText("0.0"); + _lineRoll->setText("0.0"); + _lineYaw->setText("0.0"); + _validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); + _validatorPitch->setNotation(QDoubleValidator::StandardNotation); + _validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); + _validatorRoll->setNotation(QDoubleValidator::StandardNotation); + _validatorYaw = new QDoubleValidator(-180.0, 180.0, 15); + _validatorYaw->setNotation(QDoubleValidator::StandardNotation); + _linePitch->setValidator(_validatorPitch); + _lineRoll->setValidator(_validatorRoll); + _lineYaw->setValidator(_validatorYaw); + + _layoutPitch->addStretch(1); + _layoutPitch->addWidget(_labelPitch); + _layoutPitch->addWidget(_linePitch); + //_layoutPitch->addStretch(1); + _layoutWindow->addLayout(_layoutPitch); + + _layoutRoll->addStretch(1); + _layoutRoll->addWidget(_labelRoll); + _layoutRoll->addWidget(_lineRoll); + //_layoutRoll->addStretch(1); + _layoutWindow->addLayout(_layoutRoll); + + _layoutYaw->addStretch(1); + _layoutYaw->addWidget(_labelYaw); + _layoutYaw->addWidget(_lineYaw); + //_layoutYaw->addStretch(1); + _layoutWindow->addLayout(_layoutYaw); + + _layoutButtonBox = new QHBoxLayout; + _buttonSave = new QPushButton("Save"); + _buttonSave->setToolTip("Save global orientation changes"); + //connect(_buttonSave, &QPushButton::clicked, this, &ModulesDialog::listItemSave); + _layoutButtonBox->addStretch(1); + _layoutButtonBox->addWidget(_buttonSave); + + _buttonCancel = new QPushButton("Cancel"); + _buttonCancel->setToolTip("Cancel global orientation changes"); + //connect(_buttonCancel, &QPushButton::clicked, this, &ModulesDialog::listItemCancelSave); + _layoutButtonBox->addWidget(_buttonCancel); + _layoutButtonBox->addStretch(1); + + _layoutWindow->addLayout(_layoutButtonBox); + +} + +OrientationDialog::~OrientationDialog() +{ + delete _labelPitch; + delete _labelRoll; + delete _labelYaw; + delete _validatorPitch; + delete _validatorRoll; + delete _validatorYaw; + delete _linePitch; + delete _lineRoll; + delete _lineYaw; + delete _buttonSave; + delete _buttonCancel; + delete _layoutPitch; + delete _layoutRoll; + delete _layoutYaw; + delete _layoutButtonBox; + delete _layoutWindow; +} + diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/projectiondialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/projectiondialog.cpp new file mode 100644 index 0000000000..99768e2e5c --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/projectiondialog.cpp @@ -0,0 +1,87 @@ +#include "display.h" +#include "projectiondialog.h" + +ProjectionDialog::ProjectionDialog(QWidget* parent) + : QDialog(parent) +{ + setWindowTitle("Global Orientation"); + _layoutWindow = new QVBoxLayout(this); + _layoutPitch = new QHBoxLayout(this); + _layoutRoll = new QHBoxLayout(this); + _layoutYaw = new QHBoxLayout(this); + + _labelPitch = new QLabel(this); + _labelRoll = new QLabel(this); + _labelYaw = new QLabel(this); + _labelPitch->setText("Pitch: "); + _labelRoll ->setText("Roll: "); + _labelYaw ->setText("Yaw: "); + + _linePitch = new QLineEdit(this); + _lineRoll = new QLineEdit(this); + _lineYaw = new QLineEdit(this); + _validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); + _validatorPitch->setNotation(QDoubleValidator::StandardNotation); + _validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); + _validatorRoll->setNotation(QDoubleValidator::StandardNotation); + _validatorYaw = new QDoubleValidator(-180.0, 180.0, 15); + _validatorYaw->setNotation(QDoubleValidator::StandardNotation); + _linePitch->setValidator(_validatorPitch); + _lineRoll->setValidator(_validatorRoll); + _lineYaw->setValidator(_validatorYaw); + + _layoutPitch->addStretch(1); + _layoutPitch->addWidget(_labelPitch); + _layoutPitch->addWidget(_linePitch); + //_layoutPitch->addStretch(1); + _layoutWindow->addLayout(_layoutPitch); + + _layoutRoll->addStretch(1); + _layoutRoll->addWidget(_labelRoll); + _layoutRoll->addWidget(_lineRoll); + //_layoutRoll->addStretch(1); + _layoutWindow->addLayout(_layoutRoll); + + _layoutYaw->addStretch(1); + _layoutYaw->addWidget(_labelYaw); + _layoutYaw->addWidget(_lineYaw); + //_layoutYaw->addStretch(1); + _layoutWindow->addLayout(_layoutYaw); + + _layoutButtonBox = new QHBoxLayout; + _buttonSave = new QPushButton("Save"); + _buttonSave->setToolTip("Save global orientation changes"); + //connect(_buttonSave, &QPushButton::clicked, this, &ModulesDialog::listItemSave); + _layoutButtonBox->addStretch(1); + _layoutButtonBox->addWidget(_buttonSave); + + _buttonCancel = new QPushButton("Cancel"); + _buttonCancel->setToolTip("Cancel global orientation changes"); + //connect(_buttonCancel, &QPushButton::clicked, this, &ModulesDialog::listItemCancelSave); + _layoutButtonBox->addWidget(_buttonCancel); + _layoutButtonBox->addStretch(1); + + _layoutWindow->addLayout(_layoutButtonBox); + +} + +ProjectionDialog::~ProjectionDialog() +{ + delete _labelPitch; + delete _labelRoll; + delete _labelYaw; + delete _validatorPitch; + delete _validatorRoll; + delete _validatorYaw; + delete _linePitch; + delete _lineRoll; + delete _lineYaw; + delete _buttonSave; + delete _buttonCancel; + delete _layoutPitch; + delete _layoutRoll; + delete _layoutYaw; + delete _layoutButtonBox; + delete _layoutWindow; +} + diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 979e990e32..a5b2931dc4 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -34,6 +34,18 @@ WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, _checkBoxVsync = new QCheckBox("VSync", this); _checkBoxWebGui = new QCheckBox("WebGUI here", this); _checkBoxSpoutOutput = new QCheckBox("Spout Output", this); + _comboProjection = new QComboBox(this); + _comboProjection->addItems(_projectionTypes); + + _comboQuality = new QComboBox(this); + _comboQuality->addItems(_qualityTypes); + + _lineFov = new QLineEdit("0.0", parent); + _validatorFov = new QDoubleValidator(-180.0, 180.0, 10); + _lineFov->setValidator(_validatorFov); + _lineHeightOffset = new QLineEdit("0.0", parent); + _validatorHeightOffset = new QDoubleValidator(-1000000.0, 1000000.0, 12); + _lineHeightOffset->setValidator(_validatorHeightOffset); connect(_size_x, SIGNAL(textChanged(const QString&)), this, SLOT(onSizeXChanged(const QString&))); @@ -43,12 +55,27 @@ WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, SLOT(onOffsetXChanged(const QString&))); connect(_offset_y, SIGNAL(textChanged(const QString&)), this, SLOT(onOffsetYChanged(const QString&))); + + connect(_comboProjection, SIGNAL(currentIndexChanged(int)), + this, SLOT(onProjectionChanged(int))); + connect(_comboQuality, SIGNAL(currentIndexChanged(int)), + this, SLOT(onQualityChanged(int))); } QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayout* layout*/) { _layoutFullWindow = new QVBoxLayout(parentWidget); //Window size _layoutWindowCtrl = new QVBoxLayout(parentWidget); + _layoutName = new QHBoxLayout(parentWidget); + _labelName = new QLabel(this); + _labelName->setText("Window Name: "); + _windowName = new QLineEdit(this); + _windowName->setFixedWidth(100); + _layoutName->addStretch(1); + _layoutName->addWidget(_labelName); + _layoutName->addWidget(_windowName); + _layoutName->addStretch(1); + _layoutWindowCtrl->addLayout(_layoutName); _size_x->setFixedWidth(_lineEditWidthFixed); _size_y->setFixedWidth(_lineEditWidthFixed); _labelSize = new QLabel(this); @@ -107,19 +134,51 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _layoutCBoxSpoutOutput->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxSpoutOutput); + _layoutComboProjection = new QHBoxLayout(parentWidget); + _layoutComboProjection->addWidget(_comboProjection); + _layoutComboProjection->addStretch(1); + _layoutCheckboxesFull2->addLayout(_layoutComboProjection); + + _layoutComboQuality = new QHBoxLayout(parentWidget); + _layoutComboQuality->addWidget(_comboQuality); + _layoutComboQuality->addStretch(1); + _layoutCheckboxesFull2->addLayout(_layoutComboQuality); + + _layoutFov = new QHBoxLayout(parentWidget); + _labelFov = new QLabel(); + _labelFov->setText("Horizontal FOV:"); + _layoutFov->addWidget(_labelFov); + _layoutFov->addWidget(_lineFov); + _layoutFov->addStretch(1); + _layoutFovWrapper = new QWidget(); + _layoutFovWrapper->setLayout(_layoutFov); + _layoutCheckboxesFull2->addWidget(_layoutFovWrapper); + _layoutHeightOffset = new QHBoxLayout(parentWidget); + _labelHeightOffset = new QLabel(); + _labelHeightOffset->setText("Height Offset:"); + _layoutHeightOffset->addWidget(_labelHeightOffset); + _layoutHeightOffset->addWidget(_lineHeightOffset); + _layoutHeightOffset->addStretch(1); + _layoutHeightOffsetWrapper = new QWidget(); + _layoutHeightOffsetWrapper->setLayout(_layoutHeightOffset); + _layoutCheckboxesFull2->addWidget(_layoutHeightOffsetWrapper); + _layoutCheckboxesFull1->addLayout(_layoutCheckboxesFull2); _layoutCheckboxesFull1->addStretch(1); _layoutWindowCtrl->addLayout(_layoutCheckboxesFull1); _layoutFullWindow->addLayout(_layoutWindowCtrl); + _comboProjection->setCurrentIndex(0); + onProjectionChanged(0); + _comboQuality->setCurrentIndex(2); + onQualityChanged(2); + return _layoutFullWindow; } void WindowControl::cleanupLayouts() { int labelSize1 = _labelSize->width(); int labelSize2 = _labelOffset->width(); -std::cout << "label1 = " << std::to_string(labelSize1) << std::endl; -std::cout << "label2 = " << std::to_string(labelSize2) << std::endl; int labelWidthStandard = std::max(labelSize1, labelSize2); _labelSize->setFixedWidth(labelWidthStandard); _labelOffset->setFixedWidth(labelWidthStandard); @@ -169,6 +228,38 @@ void WindowControl::onOffsetYChanged(const QString& newText) { } } +void WindowControl::onProjectionChanged(int newSelection) { + switch (newSelection) { + case 0: + _layoutFovWrapper->setVisible(true); + _layoutHeightOffsetWrapper->setVisible(false); + break; + + case 1: + _layoutFovWrapper->setVisible(false); + _layoutHeightOffsetWrapper->setVisible(false); + break; + + case 2: + _layoutFovWrapper->setVisible(false); + _layoutHeightOffsetWrapper->setVisible(false); + break; + + case 3: + _layoutFovWrapper->setVisible(false); + _layoutHeightOffsetWrapper->setVisible(true); + break; + + case 4: + _layoutFovWrapper->setVisible(false); + _layoutHeightOffsetWrapper->setVisible(false); + break; + } +} + +void WindowControl::onQualityChanged(int newSelection) { +} + void WindowControl::setDimensions(const QRectF& dimensions) { _windowDims = dimensions; } @@ -221,8 +312,15 @@ WindowControl::~WindowControl() { delete _size_x; delete _size_y; + delete _validatorSize_x; + delete _validatorSize_y; delete _offset_x; delete _offset_y; + delete _validatorOffset_x; + delete _validatorOffset_y; + delete _layoutName; + delete _labelName; + delete _windowName; delete _labelSize; delete _labelDelim; delete _layoutSize; @@ -233,10 +331,24 @@ WindowControl::~WindowControl() delete _checkBoxVsync; delete _checkBoxWebGui; delete _checkBoxSpoutOutput; + delete _comboProjection; + delete _comboQuality; + delete _labelFov; + delete _lineFov; + delete _validatorFov; + delete _labelHeightOffset; + delete _lineHeightOffset; + delete _validatorHeightOffset; delete _layoutCBoxFullscreen; delete _layoutCBoxVsync; delete _layoutCBoxWebGui; delete _layoutCBoxSpoutOutput; + delete _layoutComboProjection; + delete _layoutComboQuality; + delete _layoutFov; + delete _layoutFovWrapper; + delete _layoutHeightOffset; + delete _layoutHeightOffsetWrapper; delete _layoutCheckboxesFull2; delete _layoutCheckboxesFull1; delete _layoutWindowCtrl; From d21c37bea13d7b66a6c7e4ff074d8dae75aeabc5 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:16:11 -0700 Subject: [PATCH 12/93] Fixed Qt layout warning messages --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 3 - .../ext/launcher/include/sgctedit/display.h | 4 +- .../include/sgctedit/projectiondialog.h | 54 ------------ .../ext/launcher/src/sgctedit/display.cpp | 18 ++-- .../ext/launcher/src/sgctedit/main.cpp | 20 ++--- .../src/sgctedit/orientationdialog.cpp | 6 +- .../src/sgctedit/projectiondialog.cpp | 87 ------------------- .../launcher/src/sgctedit/windowcontrol.cpp | 30 +++---- 8 files changed, 34 insertions(+), 188 deletions(-) delete mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/projectiondialog.h delete mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/projectiondialog.cpp diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index c5d157441e..f9ed342d58 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -46,7 +46,6 @@ set(HEADER_FILES include/sgctedit/monitorbox.h include/sgctedit/orientation.h include/sgctedit/orientationdialog.h - include/sgctedit/projectiondialog.h include/sgctedit/windowcontrol.h ) @@ -73,7 +72,6 @@ set(SOURCE_FILES src/sgctedit/monitorbox.cpp src/sgctedit/orientation.cpp src/sgctedit/orientationdialog.cpp - src/sgctedit/projectiondialog.cpp src/sgctedit/windowcontrol.cpp ) @@ -96,7 +94,6 @@ set(HEADER_SOURCE include/sgctedit/monitorbox.h include/sgctedit/orientation.h include/sgctedit/orientationdialog.h - include/sgctedit/projectiondialog.h include/sgctedit/windowcontrol.h ) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index ef1d0303a9..40a2ebaf6f 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -27,7 +27,7 @@ class Display : public QWidget Q_OBJECT public: - explicit Display(QHBoxLayout* parentLayout, QSize* monitorDims); + explicit Display(QSize* monitorDims); ~Display(); private slots: @@ -36,7 +36,7 @@ private slots: private: void addWindowControl(); void removeWindowControl(); - void initializeLayout(QHBoxLayout* parentLayout); + void initializeLayout(); void hideSecondWindow(); void showSecondWindow(); unsigned int _monitorResolution[2] = {1920, 1080}; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/projectiondialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/projectiondialog.h deleted file mode 100644 index 3fd11ab54e..0000000000 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/projectiondialog.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef PROJECTION_DIALOG_H -#define PROJECTION_DIALOG_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - - -class ProjectionDialog : public QDialog -{ -Q_OBJECT - -public: - explicit ProjectionDialog(QWidget* parent); - ~ProjectionDialog(); - -private slots: - -private: - QVBoxLayout* _layoutWindow = nullptr; - QHBoxLayout* _layoutPitch = nullptr; - QHBoxLayout* _layoutRoll = nullptr; - QHBoxLayout* _layoutYaw = nullptr; - QHBoxLayout* _layoutButtonBox = nullptr; - - QLabel* _labelPitch = nullptr; - QLabel* _labelRoll = nullptr; - QLabel* _labelYaw = nullptr; - - QLineEdit* _linePitch = nullptr; - QLineEdit* _lineRoll = nullptr; - QLineEdit* _lineYaw = nullptr; - QDoubleValidator* _validatorPitch = nullptr; - QDoubleValidator* _validatorRoll = nullptr; - QDoubleValidator* _validatorYaw = nullptr; - - QPushButton* _buttonSave = nullptr; - QPushButton* _buttonCancel = nullptr; -}; - -#endif // PROJECTION_DIALOG_H diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 1c8bb8fe3c..6b17d8e20c 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -8,7 +8,7 @@ #include "include/display.h" -Display::Display(QHBoxLayout* parentLayout, QSize* monitorDims) +Display::Display(QSize* monitorDims) { _toggleNumWindowsButton = new QPushButton("Add 2nd Window", this); _toggleNumWindowsButton->setObjectName("toggleNumWindows"); @@ -17,7 +17,7 @@ Display::Display(QHBoxLayout* parentLayout, QSize* monitorDims) //Add 2 window controls addWindowControl(); addWindowControl(); - initializeLayout(parentLayout); + initializeLayout(); connect(_toggleNumWindowsButton, SIGNAL(released()), this, SLOT(toggleWindows())); @@ -32,9 +32,9 @@ Display::~Display() { delete _layout; } -void Display::initializeLayout(QHBoxLayout* parentLayout) { +void Display::initializeLayout() { _layout = new QVBoxLayout(this); - _layoutMonBox = new QHBoxLayout(this); + _layoutMonBox = new QHBoxLayout(); _layoutMonBox->addStretch(1); //_layout->addWidget(_monBox); _layoutMonBox->addWidget(_monBox); @@ -43,12 +43,12 @@ void Display::initializeLayout(QHBoxLayout* parentLayout) { _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _monBox->setFixedSize(400, 400); - _layoutMonButton = new QHBoxLayout(this); + _layoutMonButton = new QHBoxLayout(); _layoutMonButton->addStretch(1); _layoutMonButton->addWidget(_toggleNumWindowsButton); _layoutMonButton->addStretch(1); _layout->addLayout(_layoutMonButton); - _layoutWindows = new QHBoxLayout(this); + _layoutWindows = new QHBoxLayout(); _winCtrlLayouts.push_back(_windowControl[0]->initializeLayout(this)); _layoutWindowWrappers.push_back(new QWidget()); @@ -64,12 +64,6 @@ void Display::initializeLayout(QHBoxLayout* parentLayout) { hideSecondWindow(); _layout->addLayout(_layoutWindows); - parentLayout->addLayout(_layout); -// this->setLayout(parentLayoutWrapper); - - //QSize defaultMonitorResolution(_monitorResolution[0], _monitorResolution[1], 0, 0); - //_monBox->setResolution(defaultMonitorResolution); - //for (WindowControl* w : _windowControl) { // w->cleanupLayouts(); //} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index 28fe1e38bf..024a095ee2 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -51,9 +51,13 @@ int main(int argc, char *argv[ ]) } QVBoxLayout* layoutMainV = new QVBoxLayout(); QHBoxLayout* layoutMainH = new QHBoxLayout(); -// QWidget* layoutMainHWrapper = new QWidget(); -// layoutMainHWrapper->setLayout(layoutMainH); - displayWidget = new Display(layoutMainH, &monitorSizeList[0]); + + orientationWidget = new Orientation(layoutMainV); + QWidget* mainWindow = new QWidget(); + mainWindow->setLayout(layoutMainV); + win.setCentralWidget(mainWindow); + + displayWidget = new Display(&monitorSizeList[0]); layoutMainH->addWidget(displayWidget); screenList.push_back(screenList[0]); @@ -61,21 +65,13 @@ QSize* m2 = new QSize(1080, 1920); monitorSizeList.push_back({m2->width(), m2->height()}); if (screenList.size() > 1) { -std::cout << "Add display2." << std::endl; -// displayWidget2 = new Display(layoutMainH, &monitorSizeList[1]); - displayWidget2 = new Display(layoutMainH, &monitorSizeList[1]); + displayWidget2 = new Display(&monitorSizeList[1]); monitorBorderFrame = new QFrame(); monitorBorderFrame->setFrameShape(QFrame::VLine); layoutMainH->addWidget(monitorBorderFrame); layoutMainH->addWidget(displayWidget2); } - layoutMainV->addLayout(layoutMainH); - orientationWidget = new Orientation(layoutMainV); - - QWidget* mainWindow = new QWidget(); - mainWindow->setLayout(layoutMainV); - win.setCentralWidget(mainWindow); win.setWindowTitle("Window Details"); win.show(); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 0ee2f2d037..a915807220 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -6,9 +6,9 @@ OrientationDialog::OrientationDialog(QWidget* parent) { setWindowTitle("Global Orientation"); _layoutWindow = new QVBoxLayout(this); - _layoutPitch = new QHBoxLayout(this); - _layoutRoll = new QHBoxLayout(this); - _layoutYaw = new QHBoxLayout(this); + _layoutPitch = new QHBoxLayout(); + _layoutRoll = new QHBoxLayout(); + _layoutYaw = new QHBoxLayout(); _labelPitch = new QLabel(this); _labelRoll = new QLabel(this); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/projectiondialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/projectiondialog.cpp deleted file mode 100644 index 99768e2e5c..0000000000 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/projectiondialog.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "display.h" -#include "projectiondialog.h" - -ProjectionDialog::ProjectionDialog(QWidget* parent) - : QDialog(parent) -{ - setWindowTitle("Global Orientation"); - _layoutWindow = new QVBoxLayout(this); - _layoutPitch = new QHBoxLayout(this); - _layoutRoll = new QHBoxLayout(this); - _layoutYaw = new QHBoxLayout(this); - - _labelPitch = new QLabel(this); - _labelRoll = new QLabel(this); - _labelYaw = new QLabel(this); - _labelPitch->setText("Pitch: "); - _labelRoll ->setText("Roll: "); - _labelYaw ->setText("Yaw: "); - - _linePitch = new QLineEdit(this); - _lineRoll = new QLineEdit(this); - _lineYaw = new QLineEdit(this); - _validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); - _validatorPitch->setNotation(QDoubleValidator::StandardNotation); - _validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); - _validatorRoll->setNotation(QDoubleValidator::StandardNotation); - _validatorYaw = new QDoubleValidator(-180.0, 180.0, 15); - _validatorYaw->setNotation(QDoubleValidator::StandardNotation); - _linePitch->setValidator(_validatorPitch); - _lineRoll->setValidator(_validatorRoll); - _lineYaw->setValidator(_validatorYaw); - - _layoutPitch->addStretch(1); - _layoutPitch->addWidget(_labelPitch); - _layoutPitch->addWidget(_linePitch); - //_layoutPitch->addStretch(1); - _layoutWindow->addLayout(_layoutPitch); - - _layoutRoll->addStretch(1); - _layoutRoll->addWidget(_labelRoll); - _layoutRoll->addWidget(_lineRoll); - //_layoutRoll->addStretch(1); - _layoutWindow->addLayout(_layoutRoll); - - _layoutYaw->addStretch(1); - _layoutYaw->addWidget(_labelYaw); - _layoutYaw->addWidget(_lineYaw); - //_layoutYaw->addStretch(1); - _layoutWindow->addLayout(_layoutYaw); - - _layoutButtonBox = new QHBoxLayout; - _buttonSave = new QPushButton("Save"); - _buttonSave->setToolTip("Save global orientation changes"); - //connect(_buttonSave, &QPushButton::clicked, this, &ModulesDialog::listItemSave); - _layoutButtonBox->addStretch(1); - _layoutButtonBox->addWidget(_buttonSave); - - _buttonCancel = new QPushButton("Cancel"); - _buttonCancel->setToolTip("Cancel global orientation changes"); - //connect(_buttonCancel, &QPushButton::clicked, this, &ModulesDialog::listItemCancelSave); - _layoutButtonBox->addWidget(_buttonCancel); - _layoutButtonBox->addStretch(1); - - _layoutWindow->addLayout(_layoutButtonBox); - -} - -ProjectionDialog::~ProjectionDialog() -{ - delete _labelPitch; - delete _labelRoll; - delete _labelYaw; - delete _validatorPitch; - delete _validatorRoll; - delete _validatorYaw; - delete _linePitch; - delete _lineRoll; - delete _lineYaw; - delete _buttonSave; - delete _buttonCancel; - delete _layoutPitch; - delete _layoutRoll; - delete _layoutYaw; - delete _layoutButtonBox; - delete _layoutWindow; -} - diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index a5b2931dc4..2a9eb00b59 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -63,10 +63,10 @@ WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, } QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayout* layout*/) { - _layoutFullWindow = new QVBoxLayout(parentWidget); + _layoutFullWindow = new QVBoxLayout(); //Window size - _layoutWindowCtrl = new QVBoxLayout(parentWidget); - _layoutName = new QHBoxLayout(parentWidget); + _layoutWindowCtrl = new QVBoxLayout(); + _layoutName = new QHBoxLayout(); _labelName = new QLabel(this); _labelName->setText("Window Name: "); _windowName = new QLineEdit(this); @@ -80,7 +80,7 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _size_y->setFixedWidth(_lineEditWidthFixed); _labelSize = new QLabel(this); _labelDelim = new QLabel(this); - _layoutSize = new QHBoxLayout(parentWidget); + _layoutSize = new QHBoxLayout(); _layoutSize->addStretch(1); _layoutSize->addWidget(_labelSize); //_labelSize->setFixedWidth(50); @@ -97,7 +97,7 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _offset_y->setFixedWidth(_lineEditWidthFixed); _labelOffset = new QLabel(this); _labelComma = new QLabel(this); - _layoutOffset = new QHBoxLayout(parentWidget); + _layoutOffset = new QHBoxLayout(); _layoutOffset->addStretch(1); _layoutOffset->addWidget(_labelOffset); //_labelOffset->setFixedWidth(50); @@ -110,41 +110,41 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _layoutWindowCtrl->addLayout(_layoutOffset); //Window options - _layoutCheckboxesFull1 = new QHBoxLayout(parentWidget); - _layoutCheckboxesFull2 = new QVBoxLayout(parentWidget); + _layoutCheckboxesFull1 = new QHBoxLayout(); + _layoutCheckboxesFull2 = new QVBoxLayout(); _layoutCheckboxesFull1->addStretch(1); - _layoutCBoxFullscreen = new QHBoxLayout(parentWidget); + _layoutCBoxFullscreen = new QHBoxLayout(); //_layoutCBoxFullscreen->addStretch(1); _layoutCBoxFullscreen->addWidget(_checkBoxFullscreen); _layoutCBoxFullscreen->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxFullscreen); - _layoutCBoxVsync= new QHBoxLayout(parentWidget); + _layoutCBoxVsync= new QHBoxLayout(); //_layoutCBoxVsync->addStretch(1); _layoutCBoxVsync->addWidget(_checkBoxVsync); _layoutCBoxVsync->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxVsync); - _layoutCBoxWebGui= new QHBoxLayout(parentWidget); + _layoutCBoxWebGui= new QHBoxLayout(); //_layoutCBoxWebGui->addStretch(1); _layoutCBoxWebGui->addWidget(_checkBoxWebGui); _layoutCBoxWebGui->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); - _layoutCBoxSpoutOutput= new QHBoxLayout(parentWidget); + _layoutCBoxSpoutOutput= new QHBoxLayout(); //_layoutCBoxSpoutOutput->addStretch(1); _layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); _layoutCBoxSpoutOutput->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxSpoutOutput); - _layoutComboProjection = new QHBoxLayout(parentWidget); + _layoutComboProjection = new QHBoxLayout(); _layoutComboProjection->addWidget(_comboProjection); _layoutComboProjection->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutComboProjection); - _layoutComboQuality = new QHBoxLayout(parentWidget); + _layoutComboQuality = new QHBoxLayout(); _layoutComboQuality->addWidget(_comboQuality); _layoutComboQuality->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutComboQuality); - _layoutFov = new QHBoxLayout(parentWidget); + _layoutFov = new QHBoxLayout(); _labelFov = new QLabel(); _labelFov->setText("Horizontal FOV:"); _layoutFov->addWidget(_labelFov); @@ -153,7 +153,7 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _layoutFovWrapper = new QWidget(); _layoutFovWrapper->setLayout(_layoutFov); _layoutCheckboxesFull2->addWidget(_layoutFovWrapper); - _layoutHeightOffset = new QHBoxLayout(parentWidget); + _layoutHeightOffset = new QHBoxLayout(); _labelHeightOffset = new QLabel(); _labelHeightOffset->setText("Height Offset:"); _layoutHeightOffset->addWidget(_labelHeightOffset); From af5d24a2a2d65cd348bfe37304a77b7d2daa67d1 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:19:05 -0700 Subject: [PATCH 13/93] Added main window save and cancel buttons --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 1 + .../ext/launcher/src/sgctedit/filesupport.cpp | 29 +++++++++++++++++++ .../ext/launcher/src/sgctedit/main.cpp | 3 ++ 3 files changed, 33 insertions(+) create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index f9ed342d58..928dcb7b70 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -68,6 +68,7 @@ set(SOURCE_FILES src/profile/profileedit.cpp src/profile/propertiesdialog.cpp src/sgctedit/display.cpp + src/sgctedit/filesupport.cpp src/sgctedit/main.cpp src/sgctedit/monitorbox.cpp src/sgctedit/orientation.cpp diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp new file mode 100644 index 0000000000..b4b5e4f241 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -0,0 +1,29 @@ +#include "filesupport.h" + +FileSupport::FileSupport(QVBoxLayout* parentLayout) +{ + _layoutButtonBox = new QHBoxLayout; + _saveButton = new QPushButton("Save"); + _saveButton->setToolTip("Save global orientation changes"); + _layoutButtonBox->addStretch(1); + _layoutButtonBox->addWidget(_saveButton); + + _cancelButton = new QPushButton("Cancel"); + _cancelButton->setToolTip("Cancel global orientation changes"); + //connect(_buttonCancel, &QPushButton::clicked, this, &ModulesDialog::listItemCancelSave); + _layoutButtonBox->addWidget(_cancelButton); + parentLayout->addLayout(_layoutButtonBox); + connect(_cancelButton, SIGNAL(released()), this, + SLOT(cancel())); +} + +void FileSupport::cancel() { + exit(0); +} + +FileSupport::~FileSupport() +{ + delete _layoutButtonBox; + delete _saveButton; + delete _cancelButton;} + diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index 024a095ee2..90b23dea99 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -11,6 +11,7 @@ #include #include "include/display.h" +#include "include/filesupport.h" #include "include/monitorbox.h" #include "include/windowcontrol.h" #include "include/orientation.h" @@ -71,7 +72,9 @@ monitorSizeList.push_back({m2->width(), m2->height()}); layoutMainH->addWidget(monitorBorderFrame); layoutMainH->addWidget(displayWidget2); } + layoutMainV->addLayout(layoutMainH); + FileSupport* fileSupportWidget = new FileSupport(layoutMainV); win.setWindowTitle("Window Details"); win.show(); From f2e95fb85ca7d2a74bece40c5ca38aa8cef739e2 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:20:24 -0700 Subject: [PATCH 14/93] Forgot to add filesupport.h --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 2 ++ .../launcher/include/sgctedit/filesupport.h | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index 928dcb7b70..59d28f69ad 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -43,6 +43,7 @@ set(HEADER_FILES include/profile/profileedit.h include/profile/propertiesdialog.h include/sgctedit/display.h + include/sgctedit/filesupport.h include/sgctedit/monitorbox.h include/sgctedit/orientation.h include/sgctedit/orientationdialog.h @@ -92,6 +93,7 @@ set(HEADER_SOURCE include/profile/profileedit.h include/profile/propertiesdialog.h include/sgctedit/display.h + include/sgctedit/filesupport.h include/sgctedit/monitorbox.h include/sgctedit/orientation.h include/sgctedit/orientationdialog.h diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h new file mode 100644 index 0000000000..da6969c921 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -0,0 +1,32 @@ +#ifndef FILE_SUPPORT_H +#define FILE_SUPPORT_H + +#include +#include +#include +#include +#include +#include + +#include +#include + + +class FileSupport : public QWidget +{ + Q_OBJECT + +public: + explicit FileSupport(QVBoxLayout* parentLayout); + ~FileSupport(); + +private slots: + void cancel(); + +private: + QHBoxLayout* _layoutButtonBox = nullptr; + QPushButton* _saveButton = nullptr; + QPushButton* _cancelButton = nullptr; +}; + +#endif // FILE_SUPPORT_H From c2a078773dff927249506130e43749d25c91ac07 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:22:23 -0700 Subject: [PATCH 15/93] Working version before switching to combined display window --- .../launcher/include/sgctedit/windowcontrol.h | 7 +- .../ext/launcher/src/sgctedit/main.cpp | 13 ++- .../src/sgctedit/orientationdialog.cpp | 1 - .../launcher/src/sgctedit/windowcontrol.cpp | 93 +++++++++++++------ 4 files changed, 79 insertions(+), 35 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 219e55cd02..fbf604ae1d 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -104,10 +104,13 @@ private: QLineEdit* _windowName = nullptr; QLabel* _labelSize = nullptr; QLabel* _labelDelim = nullptr; - QHBoxLayout* _layoutSize = nullptr; + QGridLayout* _layoutSize = nullptr; + QHBoxLayout* _layoutGridFrame= nullptr; + QHBoxLayout* _layoutGridSizeValues = nullptr; + QHBoxLayout* _layoutGridOffsetValues = nullptr; QLabel* _labelOffset = nullptr; QLabel* _labelComma = nullptr; - QHBoxLayout* _layoutOffset = nullptr; + //QHBoxLayout* _layoutOffset = nullptr; QHBoxLayout* _layoutCheckboxesFull1 = nullptr; QVBoxLayout* _layoutCheckboxesFull2 = nullptr; QHBoxLayout* _layoutCBoxFullscreen = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index 90b23dea99..49467548a0 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -31,10 +31,15 @@ int main(int argc, char *argv[ ]) screenList[s]->size().height(), }); } - //for (QScreen* s : screenList) { - // std::cout << "Monitor "; - // std::cout << s->size().width() << "x" << s->size().height() << std::endl; - //} +for (QScreen* s : screenList) { + std::cout << "Monitor "; + std::cout << s->size().width() << "x" << s->size().height(); + std::cout << ", " << s->availableGeometry().width() << "x"; + std::cout << s->availableGeometry().height() << " offset ["; + std::cout << s->availableGeometry().x() << ","; + std::cout << s->availableGeometry().y() << "]"; + std::cout << std::endl; +} //std::cout << "Primary"; //QScreen* screen = app.primaryScreen(); //std::cout << screen->size().width() << "x" << screen->size().height() << std::endl; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index a915807220..6f2a7a1629 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -65,7 +65,6 @@ OrientationDialog::OrientationDialog(QWidget* parent) _layoutButtonBox->addStretch(1); _layoutWindow->addLayout(_layoutButtonBox); - } OrientationDialog::~OrientationDialog() diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 2a9eb00b59..cebef8f187 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -71,7 +71,7 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _labelName->setText("Window Name: "); _windowName = new QLineEdit(this); _windowName->setFixedWidth(100); - _layoutName->addStretch(1); +// _layoutName->addStretch(1); _layoutName->addWidget(_labelName); _layoutName->addWidget(_windowName); _layoutName->addStretch(1); @@ -80,16 +80,26 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _size_y->setFixedWidth(_lineEditWidthFixed); _labelSize = new QLabel(this); _labelDelim = new QLabel(this); - _layoutSize = new QHBoxLayout(); - _layoutSize->addStretch(1); - _layoutSize->addWidget(_labelSize); + QGridLayout* _layoutSize = new QGridLayout; + //_layoutSize = new QHBoxLayout(); + //_layoutSize->addStretch(1); +// _layoutSize->addRow(_labelSize, _size_x, _labelDelim, _size_y); + _layoutSize->addWidget(_labelSize, 0, 0); + _layoutGridSizeValues = new QHBoxLayout(); + _layoutGridSizeValues->addWidget(_size_x); + _layoutGridSizeValues->addWidget(_labelDelim); + _layoutGridSizeValues->addWidget(_size_y); + _layoutGridSizeValues->addStretch(1); + _layoutSize->addLayout(_layoutGridSizeValues, 0, 1); +// _layoutSize->addWidget(_labelSize); //_labelSize->setFixedWidth(50); _labelSize->setText("Size:"); - _layoutSize->addWidget(_size_x); - _layoutSize->addWidget(_labelDelim); - _layoutSize->addWidget(_size_y); - _layoutSize->addStretch(1); +// _layoutSize->addWidget(_size_x); +// _layoutSize->addWidget(_labelDelim); +// _layoutSize->addWidget(_size_y); +// _layoutSize->addStretch(1); _labelDelim->setText("x"); + _labelDelim->setFixedWidth(10); _layoutWindowCtrl->addLayout(_layoutSize); //Window offset @@ -97,22 +107,36 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _offset_y->setFixedWidth(_lineEditWidthFixed); _labelOffset = new QLabel(this); _labelComma = new QLabel(this); - _layoutOffset = new QHBoxLayout(); - _layoutOffset->addStretch(1); - _layoutOffset->addWidget(_labelOffset); +// _layoutOffset = new QHBoxLayout(); +// _layoutOffset->addStretch(1); +// _layoutOffset->addWidget(_labelOffset); +// _layoutSize->addRow(_labelOffset, _offset_x, _labelComma, _offset_y); + _layoutSize->addWidget(_labelOffset, 1, 0); + _layoutGridOffsetValues = new QHBoxLayout(); + _layoutGridOffsetValues->addWidget(_offset_x); + _layoutGridOffsetValues->addWidget(_labelComma); + _layoutGridOffsetValues->addWidget(_offset_y); + _layoutGridOffsetValues->addStretch(1); + _layoutSize->addLayout(_layoutGridOffsetValues, 1, 1); //_labelOffset->setFixedWidth(50); _labelOffset->setText("Offset:"); - _layoutOffset->addWidget(_offset_x); - _layoutOffset->addWidget(_labelComma); - _layoutOffset->addWidget(_offset_y); - _layoutOffset->addStretch(1); +// _layoutOffset->addWidget(_offset_x); +// _layoutOffset->addWidget(_labelComma); +// _layoutOffset->addWidget(_offset_y); +// _layoutOffset->addStretch(1); _labelComma->setText(","); - _layoutWindowCtrl->addLayout(_layoutOffset); + _labelComma->setFixedWidth(10); + _layoutGridFrame = new QHBoxLayout(); + _layoutGridFrame->addStretch(1); + _layoutGridFrame->addLayout(_layoutSize); + _layoutGridFrame->addStretch(1); + + _layoutWindowCtrl->addLayout(_layoutGridFrame); //Window options _layoutCheckboxesFull1 = new QHBoxLayout(); _layoutCheckboxesFull2 = new QVBoxLayout(); - _layoutCheckboxesFull1->addStretch(1); +// _layoutCheckboxesFull1->addStretch(1); _layoutCBoxFullscreen = new QHBoxLayout(); //_layoutCBoxFullscreen->addStretch(1); _layoutCBoxFullscreen->addWidget(_checkBoxFullscreen); @@ -231,28 +255,38 @@ void WindowControl::onOffsetYChanged(const QString& newText) { void WindowControl::onProjectionChanged(int newSelection) { switch (newSelection) { case 0: - _layoutFovWrapper->setVisible(true); - _layoutHeightOffsetWrapper->setVisible(false); + _labelFov->setEnabled(true); + _lineFov->setEnabled(true); + _labelHeightOffset->setEnabled(false); + _lineHeightOffset->setEnabled(false); break; case 1: - _layoutFovWrapper->setVisible(false); - _layoutHeightOffsetWrapper->setVisible(false); + _labelFov->setEnabled(false); + _lineFov->setEnabled(false); + _labelHeightOffset->setEnabled(false); + _lineHeightOffset->setEnabled(false); break; case 2: - _layoutFovWrapper->setVisible(false); - _layoutHeightOffsetWrapper->setVisible(false); + _labelFov->setEnabled(false); + _lineFov->setEnabled(false); + _labelHeightOffset->setEnabled(false); + _lineHeightOffset->setEnabled(false); break; case 3: - _layoutFovWrapper->setVisible(false); - _layoutHeightOffsetWrapper->setVisible(true); + _labelFov->setEnabled(false); + _lineFov->setEnabled(false); + _labelHeightOffset->setEnabled(true); + _lineHeightOffset->setEnabled(true); break; case 4: - _layoutFovWrapper->setVisible(false); - _layoutHeightOffsetWrapper->setVisible(false); + _labelFov->setEnabled(false); + _lineFov->setEnabled(false); + _labelHeightOffset->setEnabled(false); + _lineHeightOffset->setEnabled(false); break; } } @@ -326,7 +360,10 @@ WindowControl::~WindowControl() delete _layoutSize; delete _labelOffset; delete _labelComma; - delete _layoutOffset; +// delete _layoutOffset; + delete _layoutGridFrame; + delete _layoutGridSizeValues; + delete _layoutGridOffsetValues; delete _checkBoxFullscreen; delete _checkBoxVsync; delete _checkBoxWebGui; From d1f41436ed32ecb1e7c19672c16784dd5dd597d4 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:23:19 -0700 Subject: [PATCH 16/93] Added window ID number to monitorbox rendering --- apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index ba8a757017..e85345d583 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -31,9 +31,13 @@ void MonitorBox::paintEvent(QPaintEvent *event) painter.drawRect(_monitorDimensionsScaled); //Draw window(s) painter.setPen(Qt::blue); + painter.setFont(QFont("Arial", 16)); for (unsigned int i = 0; i < _nWindows; ++i) { if (i <= _windowRendering.size()) { painter.drawRect(*_windowRendering[i]); + QPointF t = QPointF(_windowRendering[i]->left() + 5, + _windowRendering[i]->bottom() - 5); + painter.drawText(t, QString::fromStdString(std::to_string(i + 1))); } } } From 4c4e942ca3861120b5e7edbfe1856451f5f817d0 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:24:13 -0700 Subject: [PATCH 17/93] Monitor number rendering added --- apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index e85345d583..191157bf72 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -29,15 +29,18 @@ void MonitorBox::paintEvent(QPaintEvent *event) //Draw monitor outline painter.setPen(QPen(Qt::black, 2)); painter.drawRect(_monitorDimensionsScaled); + painter.setFont(QFont("Arial", 14)); + QPointF textPos = QPointF(_monitorDimensionsScaled.left() + 5, + _monitorDimensionsScaled.bottom() - 5); + painter.drawText(textPos, QString::fromStdString(std::to_string(0))); //Draw window(s) painter.setPen(Qt::blue); - painter.setFont(QFont("Arial", 16)); for (unsigned int i = 0; i < _nWindows; ++i) { if (i <= _windowRendering.size()) { painter.drawRect(*_windowRendering[i]); - QPointF t = QPointF(_windowRendering[i]->left() + 5, + QPointF textPos = QPointF(_windowRendering[i]->left() + 5, _windowRendering[i]->bottom() - 5); - painter.drawText(t, QString::fromStdString(std::to_string(i + 1))); + painter.drawText(textPos, QString::fromStdString(std::to_string(i + 1))); } } } From fa563f6f83662e0434f5c144ccea1a1fd3639829 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:25:16 -0700 Subject: [PATCH 18/93] Working version with single monitor render box --- .../ext/launcher/include/sgctedit/display.h | 3 +- .../launcher/include/sgctedit/monitorbox.h | 45 +++-- .../launcher/include/sgctedit/windowcontrol.h | 15 +- .../ext/launcher/src/sgctedit/display.cpp | 31 ++-- .../ext/launcher/src/sgctedit/main.cpp | 41 +++-- .../ext/launcher/src/sgctedit/monitorbox.cpp | 162 ++++++++++-------- .../launcher/src/sgctedit/windowcontrol.cpp | 28 +-- 7 files changed, 187 insertions(+), 138 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 40a2ebaf6f..f7839e5c2b 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -27,7 +27,7 @@ class Display : public QWidget Q_OBJECT public: - explicit Display(QSize* monitorDims); + explicit Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox); ~Display(); private slots: @@ -46,6 +46,7 @@ private: unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; QPushButton* _toggleNumWindowsButton = nullptr; + unsigned int _monitorIdx = 0; MonitorBox* _monBox; QVBoxLayout* _layout = nullptr; QHBoxLayout* _layoutMonBox = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 6ec5fc59a0..a29a7d31a2 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -20,39 +20,52 @@ class MonitorBox : public QWidget Q_OBJECT public: - explicit MonitorBox(QRect widgetDims, QSize monitorResolution, - QWidget *parent = nullptr); + explicit MonitorBox(QRect widgetDims, std::vector monitorResolution/*, QWidget *parent = nullptr*/); ~MonitorBox(); - void mapMonitorResolutionToWidgetCoordinates(QSize r); - void mapWindowResolutionToWidgetCoordinates(unsigned int index, const QRectF& w); - void setResolution(QSize& res); - void setNumWindowsDisplayed(unsigned int nWindows); + void mapMonitorResolutionToWidgetCoordinates(); + void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, + const QRectF& w); + void setResolution(unsigned int index, QRect& res); + void setNumWindowsDisplayed(unsigned int mIdx, unsigned int nWindows); int numWindows(); - void windowDimensionsChanged(unsigned int index, const QRectF newDimensions); + void windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, + const QRectF& newDimensions); void addWindowControl(WindowControl* wCtrl); - void removeAdditionalWindowDimensions(); protected: void paintEvent(QPaintEvent *event) override; private: - QLineEdit* _size_x = nullptr; - QLineEdit* _size_y = nullptr; - - QSize _monitorResolution; - QRectF _monitorDimensionsScaled; + unsigned int _maxNumMonitors = 2; + unsigned int _maxNumWindowsPerMonitor = 2; + std::vector _monitorResolution; + //std::vector _monitorRendering; + std::vector _monitorDimensionsScaled; std::vector _windowResolutions; - std::vector _windowRendering; + std::vector> _windowRendering = { + { + {0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0} + }, + { + {0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0} + } + }; float _monitorScaleFactor = 1.0; float _offset[2] = {10.0, 10.0}; float _marginFractionOfWidgetSize = 0.025; + float _marginWidget = 5.0; + std::vector _monitorOffsets; + QRectF _monitorWidgetSize; QRectF _monitorBoundaryRect; - float _marginWidget = 5.0; - unsigned int _nWindows = 0; + + unsigned int _nMonitors = 1; + std::vector _nWindows = {1, 0}; }; #endif // MONITORBOX_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index fbf604ae1d..e326226464 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -23,12 +23,13 @@ class WindowControl : public QWidget Q_OBJECT public: - explicit WindowControl(unsigned int windowIndex, QRect& widgetDims, QRect& monitorDims, - QWidget *parent = nullptr); + explicit WindowControl(unsigned int monitorIndex, unsigned int windowIndex, + QRect& widgetDims, QWidget *parent = nullptr); ~WindowControl(); void setDimensions(const QRectF& dimensions); void setWindowScaleFactor(float scaleFactor); - void setWindowChangeCallback(std::function cb); + void setWindowChangeCallback( + std::function cb); void cleanupLayouts(); QVBoxLayout* initializeLayout(QWidget* parentWidget/*, QHBoxLayout* layout*/); QRectF& dimensions(); @@ -51,10 +52,10 @@ private slots: private: void updateScaledWindowDimensions(); - std::function _windowChangeCallback; + std::function _windowChangeCallback; QRectF defaultWindowSizes[2] = { {50.0, 50.0, 800.0, 600.0}, - {900.0, 400.0, 640.0, 480.0} + {900.0, 400.0, 2540.0, 680.0} }; QList _projectionTypes = { "Planar", "Fisheye", "Spherical Mirror", "Cylindrical", "Equirectangular" @@ -65,7 +66,9 @@ private: }; int _lineEditWidthFixed = 50; float _marginFractionOfWidgetSize = 0.025; - int _index = 0; + unsigned int _monIndex = 0; + unsigned int _index = 0; + unsigned int _maxWindowSizePixels = 10000; QVBoxLayout* _layoutWindowCtrl = nullptr; QVBoxLayout* _layoutFullWindow = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 6b17d8e20c..d4ce02fd17 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -8,12 +8,13 @@ #include "include/display.h" -Display::Display(QSize* monitorDims) +Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox) + : _monitorIdx(monitorIdx) + , _monBox(monitorRenderBox) { _toggleNumWindowsButton = new QPushButton("Add 2nd Window", this); _toggleNumWindowsButton->setObjectName("toggleNumWindows"); - _monBox = new MonitorBox(_widgetDims, *monitorDims, this); //Add 2 window controls addWindowControl(); addWindowControl(); @@ -34,15 +35,7 @@ Display::~Display() { void Display::initializeLayout() { _layout = new QVBoxLayout(this); - _layoutMonBox = new QHBoxLayout(); - _layoutMonBox->addStretch(1); - //_layout->addWidget(_monBox); - _layoutMonBox->addWidget(_monBox); - _layoutMonBox->addStretch(1); - _layout->addLayout(_layoutMonBox); - _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - _monBox->setFixedSize(400, 400); _layoutMonButton = new QHBoxLayout(); _layoutMonButton->addStretch(1); _layoutMonButton->addWidget(_toggleNumWindowsButton); @@ -81,38 +74,40 @@ void Display::toggleWindows() { } } - void Display::hideSecondWindow() { _borderFrame->setVisible(false); _layoutWindowWrappers[1]->setVisible(false); _nWindowsDisplayed = 1; - _monBox->setNumWindowsDisplayed(_nWindowsDisplayed); + _monBox->setNumWindowsDisplayed(_monitorIdx, _nWindowsDisplayed); } void Display::showSecondWindow() { _borderFrame->setVisible(true); _layoutWindowWrappers[1]->setVisible(true); _nWindowsDisplayed = 2; - _monBox->setNumWindowsDisplayed(_nWindowsDisplayed); + _monBox->setNumWindowsDisplayed(_monitorIdx, _nWindowsDisplayed); } void Display::addWindowControl() { if (_nWindowsAllocated < 2) { _windowControl.push_back( new WindowControl( + _monitorIdx, _nWindowsAllocated, _widgetDims, - _monitorRes, this ) ); _windowControl.back()->setWindowChangeCallback( - [this](unsigned int windowIndex, const QRectF& newDims) { - _monBox->windowDimensionsChanged(windowIndex, newDims); + [this](unsigned int monIndex, unsigned int winIndex, const QRectF& newDims) { + _monBox->windowDimensionsChanged(monIndex, winIndex, newDims); } ); - _monBox->mapWindowResolutionToWidgetCoordinates(_nWindowsAllocated, - _windowControl.back()->dimensions()); + _monBox->mapWindowResolutionToWidgetCoordinates( + _monitorIdx, + _nWindowsAllocated, + _windowControl.back()->dimensions() + ); _nWindowsAllocated++; } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index 49467548a0..6406b8748b 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -24,14 +24,16 @@ int main(int argc, char *argv[ ]) //Temporary code for monitor detection QList screenList = app.screens(); - std::vector monitorSizeList; + std::vector monitorSizeList; for (size_t s = 0; s < std::min(screenList.length(), 2); ++s) { - monitorSizeList.push_back({//QRect( - screenList[s]->size().width(), - screenList[s]->size().height(), + monitorSizeList.push_back({ + screenList[s]->availableGeometry().x(), + screenList[s]->availableGeometry().y(), + screenList[s]->availableGeometry().width(), + screenList[s]->availableGeometry().height() }); } -for (QScreen* s : screenList) { +/*for (QScreen* s : screenList) { std::cout << "Monitor "; std::cout << s->size().width() << "x" << s->size().height(); std::cout << ", " << s->availableGeometry().width() << "x"; @@ -45,7 +47,7 @@ for (QScreen* s : screenList) { //std::cout << screen->size().width() << "x" << screen->size().height() << std::endl; //QRect screenGeometry = screen->geometry(); //End code for monitor detection - +*/ Display* displayWidget = nullptr; Display* displayWidget2 = nullptr; QFrame* monitorBorderFrame = nullptr; @@ -63,15 +65,27 @@ for (QScreen* s : screenList) { mainWindow->setLayout(layoutMainV); win.setCentralWidget(mainWindow); - displayWidget = new Display(&monitorSizeList[0]); +monitorSizeList.push_back({3440, 0, 1080, 1920}); + MonitorBox* monBox = new MonitorBox( + {0, 0, 400, 340}, + monitorSizeList/*, + this*/ + ); + QHBoxLayout* layoutMonBox = new QHBoxLayout(); + layoutMonBox->addStretch(1); + //_layout->addWidget(_monBox); + layoutMonBox->addWidget(monBox); + layoutMonBox->addStretch(1); + layoutMainV->addLayout(layoutMonBox); + + monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + monBox->setFixedSize(400, 340); + + displayWidget = new Display(0, monBox); layoutMainH->addWidget(displayWidget); -screenList.push_back(screenList[0]); -QSize* m2 = new QSize(1080, 1920); -monitorSizeList.push_back({m2->width(), m2->height()}); - - if (screenList.size() > 1) { - displayWidget2 = new Display(&monitorSizeList[1]); + if (monitorSizeList.size() > 1) { + displayWidget2 = new Display(1, monBox); monitorBorderFrame = new QFrame(); monitorBorderFrame->setFrameShape(QFrame::VLine); layoutMainH->addWidget(monitorBorderFrame); @@ -92,6 +106,7 @@ monitorSizeList.push_back({m2->width(), m2->height()}); if (monitorBorderFrame) { delete monitorBorderFrame; } + delete monBox; delete layoutMainH; delete layoutMainV; delete mainWindow; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 191157bf72..3856e7a94d 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -1,20 +1,17 @@ #include "monitorbox.h" - -MonitorBox::MonitorBox(QRect widgetDims, QSize monitorResolution, QWidget *parent) - : QWidget(parent) - , _monitorWidgetSize(widgetDims) +MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution/*, QWidget *parent*/) + : /*QWidget(parent) + ,*/ _monitorWidgetSize(widgetDims) + , _monitorResolution(monitorResolution) { - mapMonitorResolutionToWidgetCoordinates(monitorResolution); + _nMonitors = monitorResolution.size(); + mapMonitorResolutionToWidgetCoordinates(); } MonitorBox::~MonitorBox() { - while (_windowRendering.size() > 0) { - delete _windowRendering.back(); - _windowRendering.pop_back(); - } } void MonitorBox::paintEvent(QPaintEvent *event) @@ -26,94 +23,117 @@ void MonitorBox::paintEvent(QPaintEvent *event) //Draw border painter.setPen(QPen(Qt::gray, 4)); painter.drawRoundedRect(0, 0, width() - 1, height() - 1, 10, 10); - //Draw monitor outline + + //Draw monitor outline(s) painter.setPen(QPen(Qt::black, 2)); - painter.drawRect(_monitorDimensionsScaled); painter.setFont(QFont("Arial", 14)); - QPointF textPos = QPointF(_monitorDimensionsScaled.left() + 5, - _monitorDimensionsScaled.bottom() - 5); - painter.drawText(textPos, QString::fromStdString(std::to_string(0))); - //Draw window(s) - painter.setPen(Qt::blue); - for (unsigned int i = 0; i < _nWindows; ++i) { - if (i <= _windowRendering.size()) { - painter.drawRect(*_windowRendering[i]); - QPointF textPos = QPointF(_windowRendering[i]->left() + 5, - _windowRendering[i]->bottom() - 5); + for (unsigned int i = 0; i < _nMonitors; ++i) { + if (i <= _monitorDimensionsScaled.size()) { + painter.drawRect(_monitorDimensionsScaled[i]); + QPointF textPos = QPointF(_monitorDimensionsScaled[i].left() + 5, + _monitorDimensionsScaled[i].bottom() - 5); painter.drawText(textPos, QString::fromStdString(std::to_string(i + 1))); } } + + //Draw window outline(s) + painter.setPen(Qt::blue); + for (unsigned int i = 0; i < _nMonitors ; ++i) { + for (unsigned int j = 0; j < _nWindows[i]; ++j) { + if (j <= _windowRendering[i].size()) { + painter.drawRect(_windowRendering[i][j]); + QPointF textPos = QPointF(_windowRendering[i][j].left() + 5, + _windowRendering[i][j].bottom() - 5); + painter.drawText(textPos, QString::fromStdString(std::to_string(j + 1))); + } + } + } } -void MonitorBox::windowDimensionsChanged(unsigned int index, const QRectF newDimensions) { - mapWindowResolutionToWidgetCoordinates(index, newDimensions); +void MonitorBox::windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, + const QRectF& newDimensions) +{ + mapWindowResolutionToWidgetCoordinates(monitorIdx, windowIdx, newDimensions); } -void MonitorBox::mapMonitorResolutionToWidgetCoordinates(QSize r) { - float aspectRatio = static_cast(r.width()) / - static_cast(r.height()); - _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; +void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { + QSize virtualDesktopResolution; + float maxWidth = 0.0; + float maxHeight = 0.0; + for (auto m : _monitorResolution) { + if ((m.x() + m.width()) > maxWidth) { + maxWidth = m.x() + m.width(); + } + if ((m.y() + m.height()) > maxHeight) { + maxHeight = m.y() + m.height(); + } + } + float aspectRatio = maxWidth / maxHeight; if (aspectRatio >= 1.0) { - float newWidth = _monitorWidgetSize.width() + _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; + float virtualWidth = _monitorWidgetSize.width() * (1.0 - _marginFractionOfWidgetSize * 2.0); - _monitorScaleFactor = newWidth / static_cast(r.width()); - float newHeight = newWidth / aspectRatio; - _monitorDimensionsScaled = { - _marginWidget, - _marginWidget + (_monitorWidgetSize.height() - newHeight) / 2.0, - newWidth, - newHeight - }; + _monitorScaleFactor = virtualWidth / maxWidth; + float newHeight = virtualWidth / aspectRatio; + for (size_t m = 0; m < _monitorResolution.size(); ++m) { + _monitorOffsets.push_back({ + _marginWidget + _monitorResolution[m].x() * _monitorScaleFactor, + _marginWidget + (_monitorWidgetSize.height() - newHeight) / 2.0 + + _monitorResolution[m].y() * _monitorScaleFactor + }); + } } else { - float newHeight = _monitorWidgetSize.height() + _marginWidget = _monitorWidgetSize.height() * _marginFractionOfWidgetSize; + float virtualHeight = _monitorWidgetSize.height() * (1.0 - _marginFractionOfWidgetSize * 2.0); - _monitorScaleFactor = newHeight / static_cast(r.height()); - float newWidth = newHeight * aspectRatio; - _monitorDimensionsScaled = { - _marginWidget + (_monitorWidgetSize.width() - newWidth) / 2.0, - _marginWidget, - newWidth, - newHeight - }; + _monitorScaleFactor = virtualHeight / maxHeight; + float newWidth = virtualHeight * aspectRatio; + for (size_t m = 0; m < _monitorResolution.size(); ++m) { + _monitorOffsets.push_back({ + _marginWidget + (_monitorWidgetSize.width() - newWidth) / 2.0 + + _monitorResolution[m].x() * _monitorScaleFactor, + _marginWidget + _monitorResolution[m].y() * _monitorScaleFactor + }); + } + } + + for (size_t m = 0; m < _monitorResolution.size(); ++m) { + _monitorDimensionsScaled.push_back({ + _monitorOffsets[m].width(), + _monitorOffsets[m].height(), + _monitorResolution[m].width() * _monitorScaleFactor, + _monitorResolution[m].height() * _monitorScaleFactor, + }); } this->update(); } -void MonitorBox::setResolution(QSize& res) { - _monitorResolution = res; +void MonitorBox::setResolution(unsigned int index, QRect& res) { + _monitorResolution[index] = res; } -void MonitorBox::setNumWindowsDisplayed(unsigned int nWindows) { - if (_nWindows != nWindows) { - _nWindows = nWindows; +void MonitorBox::setNumWindowsDisplayed(unsigned int mIdx, unsigned int nWindows) { + if ((mIdx <= (_nMonitors - 1)) && (_nWindows[mIdx] != nWindows)) { + _nWindows[mIdx] = nWindows; this->update(); } } -void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int index, const QRectF& w) { - if (index > 1) { +void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, + unsigned int wIdx, + const QRectF& w) +{ + if (mIdx > (_maxNumMonitors - 1) || wIdx > (_maxNumWindowsPerMonitor - 1)) { return; } - while ((index + 1) > _windowRendering.size()) { - _windowRendering.push_back(new QRectF()); - } - if (_windowRendering[index]) { - QRectF wF = w; - *_windowRendering[index] = { - _monitorDimensionsScaled.x() + wF.left() * _monitorScaleFactor, - _monitorDimensionsScaled.y() + wF.top() * _monitorScaleFactor, - wF.width() * _monitorScaleFactor, - wF.height() * _monitorScaleFactor - }; - } + QRectF wF = w; + _windowRendering[mIdx][wIdx] = { + _monitorDimensionsScaled[mIdx].x() + wF.left() * _monitorScaleFactor, + _monitorDimensionsScaled[mIdx].y() + wF.top() * _monitorScaleFactor, + wF.width() * _monitorScaleFactor, + wF.height() * _monitorScaleFactor + }; this->update(); } -void MonitorBox::removeAdditionalWindowDimensions() { - if (_windowRendering.size() > 1) { - delete _windowRendering.back(); - _windowRendering.pop_back(); - } -} - diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index cebef8f187..7505292804 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -2,10 +2,10 @@ #include "monitorbox.h" #include "windowcontrol.h" -WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, - QRect& monitorResolution, QWidget *parent) - : _index(windowIndex) - , _monitorResolution(monitorResolution) +WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex, + QRect& widgetDims, QWidget *parent) + : _monIndex(monitorIndex) + , _index(windowIndex) , QWidget(parent) { _windowDims = defaultWindowSizes[windowIndex]; @@ -18,13 +18,13 @@ WindowControl::WindowControl(unsigned int windowIndex, QRect& widgetDims, _offset_y = new QLineEdit( QString::fromUtf8(std::to_string(int(_windowDims.y())).c_str()), parent); QIntValidator* _validatorSize_x - = new QIntValidator(10, _monitorResolution.width()); + = new QIntValidator(10, _maxWindowSizePixels); QIntValidator* _validatorSize_y - = new QIntValidator(10, _monitorResolution.height()); + = new QIntValidator(10, _maxWindowSizePixels); QIntValidator* _validatorOffset_x - = new QIntValidator(10, _monitorResolution.width() - 10); + = new QIntValidator(10, _maxWindowSizePixels); QIntValidator* _validatorOffset_y - = new QIntValidator(10, _monitorResolution.height() - 10); + = new QIntValidator(10, _maxWindowSizePixels); _size_x->setValidator(_validatorSize_x); _size_y->setValidator(_validatorSize_y); _offset_x->setValidator(_validatorSize_y); @@ -214,7 +214,7 @@ void WindowControl::onSizeXChanged(const QString& newText) { _windowDims.setWidth(std::stoi(x)); } if (_windowChangeCallback) { - _windowChangeCallback(_index, _windowDims); + _windowChangeCallback(_monIndex, _index, _windowDims); } } @@ -224,7 +224,7 @@ void WindowControl::onSizeYChanged(const QString& newText) { _windowDims.setHeight(std::stoi(y)); } if (_windowChangeCallback) { - _windowChangeCallback(_index, _windowDims); + _windowChangeCallback(_monIndex, _index, _windowDims); } } @@ -236,7 +236,7 @@ void WindowControl::onOffsetXChanged(const QString& newText) { _windowDims.setWidth(prevWidth); } if (_windowChangeCallback) { - _windowChangeCallback(_index, _windowDims); + _windowChangeCallback(_monIndex, _index, _windowDims); } } @@ -248,7 +248,7 @@ void WindowControl::onOffsetYChanged(const QString& newText) { _windowDims.setHeight(prevHeight); } if (_windowChangeCallback) { - _windowChangeCallback(_index, _windowDims); + _windowChangeCallback(_monIndex, _index, _windowDims); } } @@ -298,7 +298,9 @@ void WindowControl::setDimensions(const QRectF& dimensions) { _windowDims = dimensions; } -void WindowControl::setWindowChangeCallback(std::function cb) { +void WindowControl::setWindowChangeCallback( + std::function cb) +{ _windowChangeCallback = cb; } From 334dc2b150040ca39b88d85f237dad101c89f71e Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:26:19 -0700 Subject: [PATCH 19/93] Moved orientation settings button to bottom --- .../OpenSpace/ext/launcher/include/sgctedit/orientation.h | 3 ++- apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp | 3 ++- apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp | 8 +++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index fee35e9c7f..856aa26194 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -23,8 +23,9 @@ class Orientation : public QWidget Q_OBJECT public: - explicit Orientation(QVBoxLayout* parentLayout); + explicit Orientation(); ~Orientation(); + void addButtonToLayout(QVBoxLayout* parentLayout); private slots: void orientationDialog(); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index 6406b8748b..544a20fb74 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -60,7 +60,7 @@ int main(int argc, char *argv[ ]) QVBoxLayout* layoutMainV = new QVBoxLayout(); QHBoxLayout* layoutMainH = new QHBoxLayout(); - orientationWidget = new Orientation(layoutMainV); + orientationWidget = new Orientation(); QWidget* mainWindow = new QWidget(); mainWindow->setLayout(layoutMainV); win.setCentralWidget(mainWindow); @@ -93,6 +93,7 @@ monitorSizeList.push_back({3440, 0, 1080, 1920}); } layoutMainV->addLayout(layoutMainH); + orientationWidget->addButtonToLayout(layoutMainV); FileSupport* fileSupportWidget = new FileSupport(layoutMainV); win.setWindowTitle("Window Details"); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index ddfb441991..52b31e9a08 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -2,19 +2,21 @@ #include "orientation.h" #include "orientationdialog.h" -Orientation::Orientation(QVBoxLayout* parentLayout) -{ +Orientation::Orientation() { _orientationButton = new QPushButton("Global Orientation"); _orientationButton->setObjectName("globalOrientation"); _layoutOrientationButton = new QHBoxLayout(); _layoutOrientationButton->addStretch(1); _layoutOrientationButton->addWidget(_orientationButton); _layoutOrientationButton->addStretch(1); - parentLayout->addLayout(_layoutOrientationButton); connect(_orientationButton, SIGNAL(released()), this, SLOT(orientationDialog())); } +void Orientation::addButtonToLayout(QVBoxLayout* parentLayout) { + parentLayout->addLayout(_layoutOrientationButton); +} + void Orientation::orientationDialog() { OrientationDialog(this).exec(); } From 9b5ca1266183ec8c9d461d8a1e2e2f5ce64ccc30 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:27:11 -0700 Subject: [PATCH 20/93] Limit window label number to extent of display widget --- apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h | 1 + apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index a29a7d31a2..14eb46636e 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -9,6 +9,7 @@ #include #include +#include #include #include diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 3856e7a94d..bc4b23c0c8 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -44,6 +44,8 @@ void MonitorBox::paintEvent(QPaintEvent *event) painter.drawRect(_windowRendering[i][j]); QPointF textPos = QPointF(_windowRendering[i][j].left() + 5, _windowRendering[i][j].bottom() - 5); + textPos.setX(std::clamp(textPos.x(), 0.0, _monitorWidgetSize.width() - 10)); + textPos.setY(std::clamp(textPos.y(), 0.0, _monitorWidgetSize.height() - 10)); painter.drawText(textPos, QString::fromStdString(std::to_string(j + 1))); } } From 5e35ddc1d046a7a993b5780232b580a698498da5 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:28:46 -0700 Subject: [PATCH 21/93] Added optional labels for monitor(s) and window(s) --- .../ext/launcher/include/sgctedit/display.h | 7 ++- .../launcher/include/sgctedit/monitorbox.h | 4 +- .../launcher/include/sgctedit/windowcontrol.h | 13 +++--- .../ext/launcher/src/sgctedit/display.cpp | 22 ++++++++-- .../ext/launcher/src/sgctedit/main.cpp | 44 ++++++++++++------- .../ext/launcher/src/sgctedit/monitorbox.cpp | 15 ++++--- .../launcher/src/sgctedit/windowcontrol.cpp | 35 ++++++++++----- 7 files changed, 97 insertions(+), 43 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index f7839e5c2b..989287ff32 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -27,7 +27,8 @@ class Display : public QWidget Q_OBJECT public: - explicit Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox); + explicit Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, + bool showLabel); ~Display(); private slots: @@ -36,7 +37,7 @@ private slots: private: void addWindowControl(); void removeWindowControl(); - void initializeLayout(); + void initializeLayout(bool showLabel); void hideSecondWindow(); void showSecondWindow(); unsigned int _monitorResolution[2] = {1920, 1080}; @@ -45,11 +46,13 @@ private: std::vector _windowControl; unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; + QLabel* _labelMonNum = nullptr; QPushButton* _toggleNumWindowsButton = nullptr; unsigned int _monitorIdx = 0; MonitorBox* _monBox; QVBoxLayout* _layout = nullptr; QHBoxLayout* _layoutMonBox = nullptr; + QHBoxLayout* _layoutMonNumLabel = nullptr; QHBoxLayout* _layoutMonButton = nullptr; QHBoxLayout* _layoutWindows = nullptr; std::vector _winCtrlLayouts; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 14eb46636e..afeda9b86f 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -21,7 +21,8 @@ class MonitorBox : public QWidget Q_OBJECT public: - explicit MonitorBox(QRect widgetDims, std::vector monitorResolution/*, QWidget *parent = nullptr*/); + explicit MonitorBox(QRect widgetDims, std::vector monitorResolution, + bool showMonitorLabel); ~MonitorBox(); void mapMonitorResolutionToWidgetCoordinates(); void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, @@ -56,6 +57,7 @@ private: }; float _monitorScaleFactor = 1.0; float _offset[2] = {10.0, 10.0}; + bool _showLabel = false; float _marginFractionOfWidgetSize = 0.025; float _marginWidget = 5.0; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index e326226464..5ec1b41823 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -30,14 +30,15 @@ public: void setWindowScaleFactor(float scaleFactor); void setWindowChangeCallback( std::function cb); + void showWindowLabel(bool show); void cleanupLayouts(); - QVBoxLayout* initializeLayout(QWidget* parentWidget/*, QHBoxLayout* layout*/); + QVBoxLayout* initializeLayout(QWidget* parentWidget); QRectF& dimensions(); QLineEdit* lineEditSizeWidth(); QLineEdit* lineEditSizeHeight(); QLineEdit* lineEditSizeOffsetX(); QLineEdit* lineEditSizeOffsetY(); - QCheckBox* checkBoxFullscreen(); + QCheckBox* checkBoxWindowDecor(); QCheckBox* checkBoxVsync(); QCheckBox* checkBoxWebGui(); QCheckBox* checkBoxSpoutOutput(); @@ -73,6 +74,9 @@ private: QVBoxLayout* _layoutWindowCtrl = nullptr; QVBoxLayout* _layoutFullWindow = nullptr; + QHBoxLayout* _layoutWinNum = nullptr; + QLabel* _labelWinNum = nullptr; + QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; QLineEdit* _offset_x = nullptr; @@ -88,7 +92,7 @@ private: QRectF _windowDims; QRectF _windowDimsScaled; float _monitorScaleFactor = 1.0; - QCheckBox* _checkBoxFullscreen = nullptr; + QCheckBox* _checkBoxWindowDecor = nullptr; QCheckBox* _checkBoxVsync = nullptr; QCheckBox* _checkBoxWebGui = nullptr; QCheckBox* _checkBoxSpoutOutput = nullptr; @@ -113,10 +117,9 @@ private: QHBoxLayout* _layoutGridOffsetValues = nullptr; QLabel* _labelOffset = nullptr; QLabel* _labelComma = nullptr; - //QHBoxLayout* _layoutOffset = nullptr; QHBoxLayout* _layoutCheckboxesFull1 = nullptr; QVBoxLayout* _layoutCheckboxesFull2 = nullptr; - QHBoxLayout* _layoutCBoxFullscreen = nullptr; + QHBoxLayout* _layoutCBoxWindowDecor = nullptr; QHBoxLayout* _layoutCBoxVsync = nullptr; QHBoxLayout* _layoutCBoxWebGui = nullptr; QHBoxLayout* _layoutCBoxSpoutOutput = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index d4ce02fd17..855c9b77b9 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -8,7 +8,7 @@ #include "include/display.h" -Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox) +Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, bool showLabel) : _monitorIdx(monitorIdx) , _monBox(monitorRenderBox) { @@ -18,7 +18,7 @@ Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox) //Add 2 window controls addWindowControl(); addWindowControl(); - initializeLayout(); + initializeLayout(showLabel); connect(_toggleNumWindowsButton, SIGNAL(released()), this, SLOT(toggleWindows())); @@ -33,9 +33,19 @@ Display::~Display() { delete _layout; } -void Display::initializeLayout() { +void Display::initializeLayout(bool showLabel) { _layout = new QVBoxLayout(this); + if (showLabel) { + _labelMonNum = new QLabel(); + _labelMonNum->setText("Display " + QString::number(_monitorIdx + 1)); + _layoutMonNumLabel = new QHBoxLayout(); + _layoutMonNumLabel->addStretch(1); + _layoutMonNumLabel->addWidget(_labelMonNum); + _layoutMonNumLabel->addStretch(1); + _layout->addLayout(_layoutMonNumLabel); + } + _layoutMonButton = new QHBoxLayout(); _layoutMonButton->addStretch(1); _layoutMonButton->addWidget(_toggleNumWindowsButton); @@ -79,6 +89,9 @@ void Display::hideSecondWindow() { _layoutWindowWrappers[1]->setVisible(false); _nWindowsDisplayed = 1; _monBox->setNumWindowsDisplayed(_monitorIdx, _nWindowsDisplayed); + for (auto w : _windowControl) { + w->showWindowLabel(false); + } } void Display::showSecondWindow() { @@ -86,6 +99,9 @@ void Display::showSecondWindow() { _layoutWindowWrappers[1]->setVisible(true); _nWindowsDisplayed = 2; _monBox->setNumWindowsDisplayed(_monitorIdx, _nWindowsDisplayed); + for (auto w : _windowControl) { + w->showWindowLabel(true); + } } void Display::addWindowControl() { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index 544a20fb74..ddddb728be 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -17,6 +17,7 @@ #include "include/orientation.h" + int main(int argc, char *argv[ ]) { QApplication app(argc, argv); @@ -48,8 +49,6 @@ int main(int argc, char *argv[ ]) //QRect screenGeometry = screen->geometry(); //End code for monitor detection */ - Display* displayWidget = nullptr; - Display* displayWidget2 = nullptr; QFrame* monitorBorderFrame = nullptr; Orientation* orientationWidget = nullptr; @@ -65,11 +64,13 @@ int main(int argc, char *argv[ ]) mainWindow->setLayout(layoutMainV); win.setCentralWidget(mainWindow); -monitorSizeList.push_back({3440, 0, 1080, 1920}); +//monitorSizeList.push_back({3440, 0, 1920, 1080}); + + bool showMonitorLabel = (monitorSizeList.size() > 1); MonitorBox* monBox = new MonitorBox( {0, 0, 400, 340}, - monitorSizeList/*, - this*/ + monitorSizeList, + showMonitorLabel ); QHBoxLayout* layoutMonBox = new QHBoxLayout(); layoutMonBox->addStretch(1); @@ -81,15 +82,26 @@ monitorSizeList.push_back({3440, 0, 1080, 1920}); monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); monBox->setFixedSize(400, 340); - displayWidget = new Display(0, monBox); - layoutMainH->addWidget(displayWidget); + std::vector displayLayout = {nullptr, nullptr}; + std::vector displayFrame = {nullptr, nullptr}; + std::vector displayWidget = {nullptr, nullptr}; + + displayLayout[0] = new QVBoxLayout(); + displayWidget[0] = new Display(0, monBox, showMonitorLabel); + displayFrame[0] = new QFrame; + displayLayout[0]->addWidget(displayWidget[0]); + displayFrame[0]->setLayout(displayLayout[0]); + displayFrame[0]->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + layoutMainH->addWidget(displayFrame[0]); if (monitorSizeList.size() > 1) { - displayWidget2 = new Display(1, monBox); - monitorBorderFrame = new QFrame(); - monitorBorderFrame->setFrameShape(QFrame::VLine); - layoutMainH->addWidget(monitorBorderFrame); - layoutMainH->addWidget(displayWidget2); + displayLayout[1] = new QVBoxLayout(); + displayWidget[1] = new Display(1, monBox, showMonitorLabel); + displayFrame[1] = new QFrame; + displayLayout[1]->addWidget(displayWidget[1]); + displayFrame[1]->setLayout(displayLayout[1]); + displayFrame[1]->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + layoutMainH->addWidget(displayFrame[1]); } layoutMainV->addLayout(layoutMainH); @@ -99,10 +111,12 @@ monitorSizeList.push_back({3440, 0, 1080, 1920}); win.setWindowTitle("Window Details"); win.show(); app.exec(); + delete orientationWidget; - delete displayWidget; - if (displayWidget2) { - delete displayWidget2; + for (unsigned int i = 0; i <= 1; ++i) { + if (displayWidget[i]) delete displayWidget[i]; + if (displayLayout[i]) delete displayLayout[i]; + if (displayFrame[i]) delete displayFrame[i]; } if (monitorBorderFrame) { delete monitorBorderFrame; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index bc4b23c0c8..bb811fb8ba 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -1,10 +1,11 @@ #include "monitorbox.h" -MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution/*, QWidget *parent*/) - : /*QWidget(parent) - ,*/ _monitorWidgetSize(widgetDims) +MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, + bool showMonitorLabel) + : _monitorWidgetSize(widgetDims) , _monitorResolution(monitorResolution) + , _showLabel(showMonitorLabel) { _nMonitors = monitorResolution.size(); mapMonitorResolutionToWidgetCoordinates(); @@ -30,9 +31,11 @@ void MonitorBox::paintEvent(QPaintEvent *event) for (unsigned int i = 0; i < _nMonitors; ++i) { if (i <= _monitorDimensionsScaled.size()) { painter.drawRect(_monitorDimensionsScaled[i]); - QPointF textPos = QPointF(_monitorDimensionsScaled[i].left() + 5, - _monitorDimensionsScaled[i].bottom() - 5); - painter.drawText(textPos, QString::fromStdString(std::to_string(i + 1))); + if (_showLabel) { + QPointF textPos = QPointF(_monitorDimensionsScaled[i].left() + 5, + _monitorDimensionsScaled[i].bottom() - 5); + painter.drawText(textPos, QString::fromStdString(std::to_string(i + 1))); + } } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 7505292804..03fe352a29 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -30,7 +30,7 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex _offset_x->setValidator(_validatorSize_y); _offset_y->setValidator(_validatorSize_y); - _checkBoxFullscreen = new QCheckBox("Fullscreen", this); + _checkBoxWindowDecor = new QCheckBox("Window Decoration", this); _checkBoxVsync = new QCheckBox("VSync", this); _checkBoxWebGui = new QCheckBox("WebGUI here", this); _checkBoxSpoutOutput = new QCheckBox("Spout Output", this); @@ -62,10 +62,19 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex this, SLOT(onQualityChanged(int))); } -QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayout* layout*/) { +QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutFullWindow = new QVBoxLayout(); //Window size _layoutWindowCtrl = new QVBoxLayout(); + + _labelWinNum = new QLabel(); + _labelWinNum->setText("Window " + QString::number(_index + 1)); + _layoutWinNum = new QHBoxLayout(); + _layoutWinNum->addStretch(1); + _layoutWinNum->addWidget(_labelWinNum); + _layoutWinNum->addStretch(1); + _layoutWindowCtrl->addLayout(_layoutWinNum); + _layoutName = new QHBoxLayout(); _labelName = new QLabel(this); _labelName->setText("Window Name: "); @@ -137,11 +146,11 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou _layoutCheckboxesFull1 = new QHBoxLayout(); _layoutCheckboxesFull2 = new QVBoxLayout(); // _layoutCheckboxesFull1->addStretch(1); - _layoutCBoxFullscreen = new QHBoxLayout(); - //_layoutCBoxFullscreen->addStretch(1); - _layoutCBoxFullscreen->addWidget(_checkBoxFullscreen); - _layoutCBoxFullscreen->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutCBoxFullscreen); + _layoutCBoxWindowDecor = new QHBoxLayout(); + //_layoutCBoxWindowDecor->addStretch(1); + _layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); + _layoutCBoxWindowDecor->addStretch(1); + _layoutCheckboxesFull2->addLayout(_layoutCBoxWindowDecor); _layoutCBoxVsync= new QHBoxLayout(); //_layoutCBoxVsync->addStretch(1); _layoutCBoxVsync->addWidget(_checkBoxVsync); @@ -200,6 +209,10 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget/*, QHBoxLayou return _layoutFullWindow; } +void WindowControl::showWindowLabel(bool show) { + _labelWinNum->setVisible(show); +} + void WindowControl::cleanupLayouts() { int labelSize1 = _labelSize->width(); int labelSize2 = _labelOffset->width(); @@ -328,8 +341,8 @@ QLineEdit* WindowControl::lineEditSizeOffsetY() { return _offset_y; } -QCheckBox* WindowControl::checkBoxFullscreen() { - return _checkBoxFullscreen; +QCheckBox* WindowControl::checkBoxWindowDecor() { + return _checkBoxWindowDecor; } QCheckBox* WindowControl::checkBoxVsync() { @@ -366,7 +379,7 @@ WindowControl::~WindowControl() delete _layoutGridFrame; delete _layoutGridSizeValues; delete _layoutGridOffsetValues; - delete _checkBoxFullscreen; + delete _checkBoxWindowDecor; delete _checkBoxVsync; delete _checkBoxWebGui; delete _checkBoxSpoutOutput; @@ -378,7 +391,7 @@ WindowControl::~WindowControl() delete _labelHeightOffset; delete _lineHeightOffset; delete _validatorHeightOffset; - delete _layoutCBoxFullscreen; + delete _layoutCBoxWindowDecor; delete _layoutCBoxVsync; delete _layoutCBoxWebGui; delete _layoutCBoxSpoutOutput; From b53f16076fe0ba9a24d299f8dce446011a09d390 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:29:40 -0700 Subject: [PATCH 22/93] Added color to individual windows --- apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp | 8 +++++++- .../OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index bb811fb8ba..442c14382d 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -40,9 +40,15 @@ void MonitorBox::paintEvent(QPaintEvent *event) } //Draw window outline(s) - painter.setPen(Qt::blue); +// painter.setPen(Qt::blue); for (unsigned int i = 0; i < _nMonitors ; ++i) { for (unsigned int j = 0; j < _nWindows[i]; ++j) { + if (j == 0) { + painter.setPen(QColor(0x1C, 0x1B, 0x8B)); + } + else if (j == 1) { + painter.setPen(QColor(0xCD, 0x6D, 0x1D)); + } if (j <= _windowRendering[i].size()) { painter.drawRect(_windowRendering[i][j]); QPointF textPos = QPointF(_windowRendering[i][j].left() + 5, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 03fe352a29..c9b189ece6 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -69,6 +69,14 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _labelWinNum = new QLabel(); _labelWinNum->setText("Window " + QString::number(_index + 1)); +// _labelWinNum->setStyleSheet("QLabel { color : blue; }"); + if (_index == 1) { + _labelWinNum->setStyleSheet("QLabel { color : #CD6D1D; }"); + } + else { + _labelWinNum->setStyleSheet("QLabel { color : #1C1B8B; }"); + } + _layoutWinNum = new QHBoxLayout(); _layoutWinNum->addStretch(1); _layoutWinNum->addWidget(_labelWinNum); From 7ce8b5d94733bd37077e61be3f835ce30d42893d Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:30:37 -0700 Subject: [PATCH 23/93] Added support for a display having zero windows --- .../ext/launcher/src/sgctedit/display.cpp | 79 ++++++++++++------- .../ext/launcher/src/sgctedit/main.cpp | 6 +- .../ext/launcher/src/sgctedit/monitorbox.cpp | 1 - 3 files changed, 52 insertions(+), 34 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 855c9b77b9..14d64dbd1c 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -8,24 +8,27 @@ #include "include/display.h" -Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, bool showLabel) +Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, + unsigned int numWindowsInit, bool showLabel) : _monitorIdx(monitorIdx) , _monBox(monitorRenderBox) { - _toggleNumWindowsButton = new QPushButton("Add 2nd Window", this); - _toggleNumWindowsButton->setObjectName("toggleNumWindows"); + _addWindowButton = new QPushButton("Add Window", this); + _removeWindowButton = new QPushButton("Remove Window", this); //Add 2 window controls addWindowControl(); addWindowControl(); - initializeLayout(showLabel); + initializeLayout(showLabel, numWindowsInit); - connect(_toggleNumWindowsButton, SIGNAL(released()), this, - SLOT(toggleWindows())); + connect(_addWindowButton, SIGNAL(released()), this, + SLOT(addWindow())); + connect(_removeWindowButton, SIGNAL(released()), this, + SLOT(removeWindow())); } Display::~Display() { - delete _toggleNumWindowsButton; + delete _addWindowButton; delete _monBox; delete _layoutMonBox; delete _layoutMonButton; @@ -33,7 +36,7 @@ Display::~Display() { delete _layout; } -void Display::initializeLayout(bool showLabel) { +void Display::initializeLayout(bool showLabel, unsigned int numWindowsInit) { _layout = new QVBoxLayout(this); if (showLabel) { @@ -48,7 +51,8 @@ void Display::initializeLayout(bool showLabel) { _layoutMonButton = new QHBoxLayout(); _layoutMonButton->addStretch(1); - _layoutMonButton->addWidget(_toggleNumWindowsButton); + _layoutMonButton->addWidget(_removeWindowButton); + _layoutMonButton->addWidget(_addWindowButton); _layoutMonButton->addStretch(1); _layout->addLayout(_layoutMonButton); _layoutWindows = new QHBoxLayout(); @@ -64,7 +68,7 @@ void Display::initializeLayout(bool showLabel) { _layoutWindowWrappers.push_back(new QWidget()); _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); _layoutWindows->addWidget(_layoutWindowWrappers.back()); - hideSecondWindow(); + showWindows(numWindowsInit); _layout->addLayout(_layoutWindows); //for (WindowControl* w : _windowControl) { @@ -72,35 +76,50 @@ void Display::initializeLayout(bool showLabel) { //} } -void Display::toggleWindows() { +void Display::addWindow() { + if (_nWindowsDisplayed == 0) { + showWindows(1); + _removeWindowButton->setEnabled(true); + } + else if (_nWindowsDisplayed == 1) { + showWindows(2); + _addWindowButton->setEnabled(false); + } +} + +void Display::removeWindow() { if (_nWindowsDisplayed == 1) { - _toggleNumWindowsButton->setText("Remove 2nd window"); - showSecondWindow(); + showWindows(0); + _removeWindowButton->setEnabled(false); } else if (_nWindowsDisplayed == 2) { - _toggleNumWindowsButton->setText("Add 2nd window"); - hideSecondWindow(); - int minWidth = minimumWidth(); + showWindows(1); + _addWindowButton->setEnabled(true); } } -void Display::hideSecondWindow() { - _borderFrame->setVisible(false); - _layoutWindowWrappers[1]->setVisible(false); - _nWindowsDisplayed = 1; +void Display::showWindows(unsigned int nWindowControlsDisplayed) { + _nWindowsDisplayed = nWindowControlsDisplayed; + _borderFrame->setVisible(_nWindowsDisplayed == 2); + _layoutWindowWrappers[0]->setVisible(_nWindowsDisplayed > 0); + _layoutWindowWrappers[1]->setVisible(_nWindowsDisplayed == 2); + _addWindowButton->setEnabled(_nWindowsDisplayed < 2); + _removeWindowButton->setEnabled(_nWindowsDisplayed > 0); _monBox->setNumWindowsDisplayed(_monitorIdx, _nWindowsDisplayed); for (auto w : _windowControl) { - w->showWindowLabel(false); + w->showWindowLabel(_nWindowsDisplayed == 2); } -} - -void Display::showSecondWindow() { - _borderFrame->setVisible(true); - _layoutWindowWrappers[1]->setVisible(true); - _nWindowsDisplayed = 2; - _monBox->setNumWindowsDisplayed(_monitorIdx, _nWindowsDisplayed); - for (auto w : _windowControl) { - w->showWindowLabel(true); + if (_nWindowsDisplayed == 0) { + _addWindowButton->setText("Add Window"); + _removeWindowButton->setText("Remove Window"); + } + else if (_nWindowsDisplayed == 1) { + _addWindowButton->setText("Add 2nd Window"); + _removeWindowButton->setText("Remove Window"); + } + else if (_nWindowsDisplayed == 2) { + _addWindowButton->setText("Add Window"); + _removeWindowButton->setText("Remove Window 2"); } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index ddddb728be..b95afa31fb 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -64,7 +64,7 @@ int main(int argc, char *argv[ ]) mainWindow->setLayout(layoutMainV); win.setCentralWidget(mainWindow); -//monitorSizeList.push_back({3440, 0, 1920, 1080}); +monitorSizeList.push_back({3440, 0, 1920, 1080}); bool showMonitorLabel = (monitorSizeList.size() > 1); MonitorBox* monBox = new MonitorBox( @@ -87,7 +87,7 @@ int main(int argc, char *argv[ ]) std::vector displayWidget = {nullptr, nullptr}; displayLayout[0] = new QVBoxLayout(); - displayWidget[0] = new Display(0, monBox, showMonitorLabel); + displayWidget[0] = new Display(0, monBox, 1, showMonitorLabel); displayFrame[0] = new QFrame; displayLayout[0]->addWidget(displayWidget[0]); displayFrame[0]->setLayout(displayLayout[0]); @@ -96,7 +96,7 @@ int main(int argc, char *argv[ ]) if (monitorSizeList.size() > 1) { displayLayout[1] = new QVBoxLayout(); - displayWidget[1] = new Display(1, monBox, showMonitorLabel); + displayWidget[1] = new Display(1, monBox, 0, showMonitorLabel); displayFrame[1] = new QFrame; displayLayout[1]->addWidget(displayWidget[1]); displayFrame[1]->setLayout(displayLayout[1]); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 442c14382d..b10bd5fa5e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -40,7 +40,6 @@ void MonitorBox::paintEvent(QPaintEvent *event) } //Draw window outline(s) -// painter.setPen(Qt::blue); for (unsigned int i = 0; i < _nMonitors ; ++i) { for (unsigned int j = 0; j < _nWindows[i]; ++j) { if (j == 0) { From 8869fdf1eb4b9e04809d7c26831817909c2ecf11 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:31:48 -0700 Subject: [PATCH 24/93] Improved controls layout for 0 - 2 windows --- .../ext/launcher/include/sgctedit/display.h | 13 +++++++------ .../OpenSpace/ext/launcher/src/sgctedit/display.cpp | 10 ++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 989287ff32..cc813209e4 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -28,18 +28,18 @@ class Display : public QWidget public: explicit Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, - bool showLabel); + unsigned int numWindowsInit, bool showLabel); ~Display(); private slots: - void toggleWindows(); + void addWindow(); + void removeWindow(); private: void addWindowControl(); void removeWindowControl(); - void initializeLayout(bool showLabel); - void hideSecondWindow(); - void showSecondWindow(); + void initializeLayout(bool showLabel, unsigned int numWindowsInit); + void showWindows(unsigned int nWindowControlsDisplayed); unsigned int _monitorResolution[2] = {1920, 1080}; QRect _monitorRes = {0, 0, _monitorResolution[0], _monitorResolution[1]}; QRect _widgetDims = {0, 0, 400, 400}; @@ -47,7 +47,8 @@ private: unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; QLabel* _labelMonNum = nullptr; - QPushButton* _toggleNumWindowsButton = nullptr; + QPushButton* _addWindowButton = nullptr; + QPushButton* _removeWindowButton = nullptr; unsigned int _monitorIdx = 0; MonitorBox* _monBox; QVBoxLayout* _layout = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 14d64dbd1c..c0008f9652 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -57,6 +57,8 @@ void Display::initializeLayout(bool showLabel, unsigned int numWindowsInit) { _layout->addLayout(_layoutMonButton); _layoutWindows = new QHBoxLayout(); + _layout->addStretch(); + _winCtrlLayouts.push_back(_windowControl[0]->initializeLayout(this)); _layoutWindowWrappers.push_back(new QWidget()); _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); @@ -111,15 +113,19 @@ void Display::showWindows(unsigned int nWindowControlsDisplayed) { } if (_nWindowsDisplayed == 0) { _addWindowButton->setText("Add Window"); - _removeWindowButton->setText("Remove Window"); + _addWindowButton->setVisible(true); + _removeWindowButton->setVisible(false); } else if (_nWindowsDisplayed == 1) { _addWindowButton->setText("Add 2nd Window"); _removeWindowButton->setText("Remove Window"); + _addWindowButton->setVisible(true); + _removeWindowButton->setVisible(true); } else if (_nWindowsDisplayed == 2) { - _addWindowButton->setText("Add Window"); _removeWindowButton->setText("Remove Window 2"); + _addWindowButton->setVisible(false); + _removeWindowButton->setVisible(true); } } From 47fa6c60e65ee404fa5bb57c7867f6c649bc9455 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:33:45 -0700 Subject: [PATCH 25/93] Added a button to set a window to fullscreen size --- .../ext/launcher/include/sgctedit/display.h | 5 ++--- .../launcher/include/sgctedit/windowcontrol.h | 8 +++++-- .../ext/launcher/src/sgctedit/display.cpp | 4 +++- .../ext/launcher/src/sgctedit/main.cpp | 21 +++++++++++++------ .../launcher/src/sgctedit/windowcontrol.cpp | 21 ++++++++++++++++++- 5 files changed, 46 insertions(+), 13 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index cc813209e4..9eb0a6c160 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -28,7 +28,7 @@ class Display : public QWidget public: explicit Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, - unsigned int numWindowsInit, bool showLabel); + std::vector& monitorSizeList, unsigned int numWindowsInit, bool showLabel); ~Display(); private slots: @@ -40,8 +40,7 @@ private: void removeWindowControl(); void initializeLayout(bool showLabel, unsigned int numWindowsInit); void showWindows(unsigned int nWindowControlsDisplayed); - unsigned int _monitorResolution[2] = {1920, 1080}; - QRect _monitorRes = {0, 0, _monitorResolution[0], _monitorResolution[1]}; + std::vector& _monitorResolutions; QRect _widgetDims = {0, 0, 400, 400}; std::vector _windowControl; unsigned int _nWindowsAllocated = 0; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 5ec1b41823..48c738d761 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -24,7 +25,7 @@ class WindowControl : public QWidget public: explicit WindowControl(unsigned int monitorIndex, unsigned int windowIndex, - QRect& widgetDims, QWidget *parent = nullptr); + QRect& widgetDims, QRect& monitorDims, QWidget *parent = nullptr); ~WindowControl(); void setDimensions(const QRectF& dimensions); void setWindowScaleFactor(float scaleFactor); @@ -50,6 +51,7 @@ private slots: void onOffsetYChanged(const QString& newText); void onProjectionChanged(int newSelection); void onQualityChanged(int newSelection); + void onFullscreenClicked(); private: void updateScaledWindowDimensions(); @@ -87,11 +89,12 @@ private: QIntValidator* _validatorOffset_x = nullptr; QIntValidator* _validatorOffset_y = nullptr; - QRect _monitorResolution; + QRect& _monitorResolution; QRectF _monitorDimsScaled; QRectF _windowDims; QRectF _windowDimsScaled; float _monitorScaleFactor = 1.0; + QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; QCheckBox* _checkBoxVsync = nullptr; QCheckBox* _checkBoxWebGui = nullptr; @@ -119,6 +122,7 @@ private: QLabel* _labelComma = nullptr; QHBoxLayout* _layoutCheckboxesFull1 = nullptr; QVBoxLayout* _layoutCheckboxesFull2 = nullptr; + QHBoxLayout* _layoutFullscreenButton = nullptr; QHBoxLayout* _layoutCBoxWindowDecor = nullptr; QHBoxLayout* _layoutCBoxVsync = nullptr; QHBoxLayout* _layoutCBoxWebGui = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index c0008f9652..113fc471d8 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -9,9 +9,10 @@ Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, - unsigned int numWindowsInit, bool showLabel) + std::vector& monitorSizeList, unsigned int numWindowsInit, bool showLabel) : _monitorIdx(monitorIdx) , _monBox(monitorRenderBox) + , _monitorResolutions(monitorSizeList) { _addWindowButton = new QPushButton("Add Window", this); _removeWindowButton = new QPushButton("Remove Window", this); @@ -136,6 +137,7 @@ void Display::addWindowControl() { _monitorIdx, _nWindowsAllocated, _widgetDims, + _monitorResolutions[_monitorIdx], this ) ); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index b95afa31fb..a6724d6380 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -27,11 +27,15 @@ int main(int argc, char *argv[ ]) QList screenList = app.screens(); std::vector monitorSizeList; for (size_t s = 0; s < std::min(screenList.length(), 2); ++s) { + int actualWidth = std::max(screenList[s]->size().width(), + screenList[s]->availableGeometry().width()); + int actualHeight = std::max(screenList[s]->size().height(), + screenList[s]->availableGeometry().height()); monitorSizeList.push_back({ screenList[s]->availableGeometry().x(), screenList[s]->availableGeometry().y(), - screenList[s]->availableGeometry().width(), - screenList[s]->availableGeometry().height() + actualWidth, + actualHeight }); } /*for (QScreen* s : screenList) { @@ -64,8 +68,13 @@ int main(int argc, char *argv[ ]) mainWindow->setLayout(layoutMainV); win.setCentralWidget(mainWindow); -monitorSizeList.push_back({3440, 0, 1920, 1080}); - +//monitorSizeList.push_back({3440, 0, 1920, 1080}); +for (QRect m : monitorSizeList) { + std::cout << "Display " << m.x() << "," << m.y() << " and " << m.width() << "x" << m.height() << std::endl; +} +for (QScreen* s : screenList) { + std::cout << "Screen " << s->size().width() << "," << s->size().height() << std::endl; +} bool showMonitorLabel = (monitorSizeList.size() > 1); MonitorBox* monBox = new MonitorBox( {0, 0, 400, 340}, @@ -87,7 +96,7 @@ monitorSizeList.push_back({3440, 0, 1920, 1080}); std::vector displayWidget = {nullptr, nullptr}; displayLayout[0] = new QVBoxLayout(); - displayWidget[0] = new Display(0, monBox, 1, showMonitorLabel); + displayWidget[0] = new Display(0, monBox, monitorSizeList, 1, showMonitorLabel); displayFrame[0] = new QFrame; displayLayout[0]->addWidget(displayWidget[0]); displayFrame[0]->setLayout(displayLayout[0]); @@ -96,7 +105,7 @@ monitorSizeList.push_back({3440, 0, 1920, 1080}); if (monitorSizeList.size() > 1) { displayLayout[1] = new QVBoxLayout(); - displayWidget[1] = new Display(1, monBox, 0, showMonitorLabel); + displayWidget[1] = new Display(1, monBox, monitorSizeList, 0, showMonitorLabel); displayFrame[1] = new QFrame; displayLayout[1]->addWidget(displayWidget[1]); displayFrame[1]->setLayout(displayLayout[1]); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index c9b189ece6..22d779d047 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -3,9 +3,10 @@ #include "windowcontrol.h" WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex, - QRect& widgetDims, QWidget *parent) + QRect& widgetDims, QRect& monitorDims, QWidget *parent) : _monIndex(monitorIndex) , _index(windowIndex) + , _monitorResolution(monitorDims) , QWidget(parent) { _windowDims = defaultWindowSizes[windowIndex]; @@ -30,6 +31,8 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex _offset_x->setValidator(_validatorSize_y); _offset_y->setValidator(_validatorSize_y); + _fullscreenButton = new QPushButton(this); + _fullscreenButton->setText("Set to Fullscreen"); _checkBoxWindowDecor = new QCheckBox("Window Decoration", this); _checkBoxVsync = new QCheckBox("VSync", this); _checkBoxWebGui = new QCheckBox("WebGUI here", this); @@ -60,6 +63,8 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex this, SLOT(onProjectionChanged(int))); connect(_comboQuality, SIGNAL(currentIndexChanged(int)), this, SLOT(onQualityChanged(int))); + + connect(_fullscreenButton, SIGNAL(released()), this, SLOT(onFullscreenClicked())); } QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { @@ -154,6 +159,12 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutCheckboxesFull1 = new QHBoxLayout(); _layoutCheckboxesFull2 = new QVBoxLayout(); // _layoutCheckboxesFull1->addStretch(1); + _layoutFullscreenButton = new QHBoxLayout(); + //_layoutFullscreenButton->addStretch(1); + _layoutFullscreenButton->addWidget(_fullscreenButton); + _layoutFullscreenButton->addStretch(1); + _layoutCheckboxesFull2->addLayout(_layoutFullscreenButton); + _layoutCBoxWindowDecor = new QHBoxLayout(); //_layoutCBoxWindowDecor->addStretch(1); _layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); @@ -273,6 +284,13 @@ void WindowControl::onOffsetYChanged(const QString& newText) { } } +void WindowControl::onFullscreenClicked() { + _offset_x->setText("0"); + _offset_y->setText("0"); + _size_x->setText(QString::number(_monitorResolution.width())); + _size_y->setText(QString::number(_monitorResolution.height())); +} + void WindowControl::onProjectionChanged(int newSelection) { switch (newSelection) { case 0: @@ -399,6 +417,7 @@ WindowControl::~WindowControl() delete _labelHeightOffset; delete _lineHeightOffset; delete _validatorHeightOffset; + delete _layoutFullscreenButton; delete _layoutCBoxWindowDecor; delete _layoutCBoxVsync; delete _layoutCBoxWebGui; From 5295903e8cb97a93d39b2e079173331c692ac948 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 19:35:10 -0700 Subject: [PATCH 26/93] Made Vsync a global option and disable quality for planarprojection --- .../launcher/include/sgctedit/orientation.h | 4 +++- .../launcher/include/sgctedit/windowcontrol.h | 3 --- .../ext/launcher/src/sgctedit/main.cpp | 22 ------------------- .../ext/launcher/src/sgctedit/orientation.cpp | 22 +++++++++++++------ .../launcher/src/sgctedit/windowcontrol.cpp | 17 +++++--------- 5 files changed, 23 insertions(+), 45 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index 856aa26194..8e471528c8 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -31,8 +31,10 @@ private slots: void orientationDialog(); private: - QHBoxLayout* _layoutOrientationButton = nullptr; + QHBoxLayout* _layoutOrientationFull = nullptr; + QVBoxLayout* _layoutOrientationControls = nullptr; QPushButton* _orientationButton = nullptr; + QCheckBox* _checkBoxVsync = nullptr; }; #endif // ORIENTATION_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 48c738d761..712dff3805 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -40,7 +40,6 @@ public: QLineEdit* lineEditSizeOffsetX(); QLineEdit* lineEditSizeOffsetY(); QCheckBox* checkBoxWindowDecor(); - QCheckBox* checkBoxVsync(); QCheckBox* checkBoxWebGui(); QCheckBox* checkBoxSpoutOutput(); @@ -96,7 +95,6 @@ private: float _monitorScaleFactor = 1.0; QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; - QCheckBox* _checkBoxVsync = nullptr; QCheckBox* _checkBoxWebGui = nullptr; QCheckBox* _checkBoxSpoutOutput = nullptr; @@ -124,7 +122,6 @@ private: QVBoxLayout* _layoutCheckboxesFull2 = nullptr; QHBoxLayout* _layoutFullscreenButton = nullptr; QHBoxLayout* _layoutCBoxWindowDecor = nullptr; - QHBoxLayout* _layoutCBoxVsync = nullptr; QHBoxLayout* _layoutCBoxWebGui = nullptr; QHBoxLayout* _layoutCBoxSpoutOutput = nullptr; QHBoxLayout* _layoutComboProjection = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp index a6724d6380..8c27b6f172 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp @@ -38,21 +38,6 @@ int main(int argc, char *argv[ ]) actualHeight }); } -/*for (QScreen* s : screenList) { - std::cout << "Monitor "; - std::cout << s->size().width() << "x" << s->size().height(); - std::cout << ", " << s->availableGeometry().width() << "x"; - std::cout << s->availableGeometry().height() << " offset ["; - std::cout << s->availableGeometry().x() << ","; - std::cout << s->availableGeometry().y() << "]"; - std::cout << std::endl; -} - //std::cout << "Primary"; - //QScreen* screen = app.primaryScreen(); - //std::cout << screen->size().width() << "x" << screen->size().height() << std::endl; - //QRect screenGeometry = screen->geometry(); - //End code for monitor detection -*/ QFrame* monitorBorderFrame = nullptr; Orientation* orientationWidget = nullptr; @@ -68,13 +53,6 @@ int main(int argc, char *argv[ ]) mainWindow->setLayout(layoutMainV); win.setCentralWidget(mainWindow); -//monitorSizeList.push_back({3440, 0, 1920, 1080}); -for (QRect m : monitorSizeList) { - std::cout << "Display " << m.x() << "," << m.y() << " and " << m.width() << "x" << m.height() << std::endl; -} -for (QScreen* s : screenList) { - std::cout << "Screen " << s->size().width() << "," << s->size().height() << std::endl; -} bool showMonitorLabel = (monitorSizeList.size() > 1); MonitorBox* monBox = new MonitorBox( {0, 0, 400, 340}, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index 52b31e9a08..504453bb0f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -3,18 +3,23 @@ #include "orientationdialog.h" Orientation::Orientation() { + _layoutOrientationFull = new QHBoxLayout(); + _layoutOrientationControls = new QVBoxLayout(); _orientationButton = new QPushButton("Global Orientation"); - _orientationButton->setObjectName("globalOrientation"); - _layoutOrientationButton = new QHBoxLayout(); - _layoutOrientationButton->addStretch(1); - _layoutOrientationButton->addWidget(_orientationButton); - _layoutOrientationButton->addStretch(1); + _checkBoxVsync = new QCheckBox("VSync All Windows", this); + _layoutOrientationControls->addWidget(_checkBoxVsync); + _layoutOrientationControls->addWidget(_orientationButton); + + _layoutOrientationFull->addStretch(1); + _layoutOrientationFull->addLayout(_layoutOrientationControls); + _layoutOrientationFull->addStretch(1); + connect(_orientationButton, SIGNAL(released()), this, SLOT(orientationDialog())); } void Orientation::addButtonToLayout(QVBoxLayout* parentLayout) { - parentLayout->addLayout(_layoutOrientationButton); + parentLayout->addLayout(_layoutOrientationFull); } void Orientation::orientationDialog() { @@ -23,6 +28,9 @@ void Orientation::orientationDialog() { Orientation::~Orientation() { - delete _layoutOrientationButton; + delete _orientationButton; + delete _checkBoxVsync; + delete _layoutOrientationFull; + delete _layoutOrientationControls; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 22d779d047..27d1194a52 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -34,7 +34,6 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex _fullscreenButton = new QPushButton(this); _fullscreenButton->setText("Set to Fullscreen"); _checkBoxWindowDecor = new QCheckBox("Window Decoration", this); - _checkBoxVsync = new QCheckBox("VSync", this); _checkBoxWebGui = new QCheckBox("WebGUI here", this); _checkBoxSpoutOutput = new QCheckBox("Spout Output", this); _comboProjection = new QComboBox(this); @@ -170,11 +169,6 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); _layoutCBoxWindowDecor->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxWindowDecor); - _layoutCBoxVsync= new QHBoxLayout(); - //_layoutCBoxVsync->addStretch(1); - _layoutCBoxVsync->addWidget(_checkBoxVsync); - _layoutCBoxVsync->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutCBoxVsync); _layoutCBoxWebGui= new QHBoxLayout(); //_layoutCBoxWebGui->addStretch(1); _layoutCBoxWebGui->addWidget(_checkBoxWebGui); @@ -294,6 +288,7 @@ void WindowControl::onFullscreenClicked() { void WindowControl::onProjectionChanged(int newSelection) { switch (newSelection) { case 0: + _comboQuality->setEnabled(false); _labelFov->setEnabled(true); _lineFov->setEnabled(true); _labelHeightOffset->setEnabled(false); @@ -301,6 +296,7 @@ void WindowControl::onProjectionChanged(int newSelection) { break; case 1: + _comboQuality->setEnabled(true); _labelFov->setEnabled(false); _lineFov->setEnabled(false); _labelHeightOffset->setEnabled(false); @@ -308,6 +304,7 @@ void WindowControl::onProjectionChanged(int newSelection) { break; case 2: + _comboQuality->setEnabled(true); _labelFov->setEnabled(false); _lineFov->setEnabled(false); _labelHeightOffset->setEnabled(false); @@ -315,6 +312,7 @@ void WindowControl::onProjectionChanged(int newSelection) { break; case 3: + _comboQuality->setEnabled(true); _labelFov->setEnabled(false); _lineFov->setEnabled(false); _labelHeightOffset->setEnabled(true); @@ -322,6 +320,7 @@ void WindowControl::onProjectionChanged(int newSelection) { break; case 4: + _comboQuality->setEnabled(true); _labelFov->setEnabled(false); _lineFov->setEnabled(false); _labelHeightOffset->setEnabled(false); @@ -371,10 +370,6 @@ QCheckBox* WindowControl::checkBoxWindowDecor() { return _checkBoxWindowDecor; } -QCheckBox* WindowControl::checkBoxVsync() { - return _checkBoxVsync; -} - QCheckBox* WindowControl::checkBoxWebGui() { return _checkBoxWebGui; } @@ -406,7 +401,6 @@ WindowControl::~WindowControl() delete _layoutGridSizeValues; delete _layoutGridOffsetValues; delete _checkBoxWindowDecor; - delete _checkBoxVsync; delete _checkBoxWebGui; delete _checkBoxSpoutOutput; delete _comboProjection; @@ -419,7 +413,6 @@ WindowControl::~WindowControl() delete _validatorHeightOffset; delete _layoutFullscreenButton; delete _layoutCBoxWindowDecor; - delete _layoutCBoxVsync; delete _layoutCBoxWebGui; delete _layoutCBoxSpoutOutput; delete _layoutComboProjection; From fa628d8d20fb0ba3ff323c9ac0572eeb1d8f4437 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 2 Jan 2022 20:33:28 -0700 Subject: [PATCH 27/93] Code refactoring and getting to work with launcher in OpenSpace app --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 4 +- .../ext/launcher/include/sgctedit/display.h | 3 +- .../launcher/include/sgctedit/monitorbox.h | 35 ++- .../ext/launcher/include/sgctedit/sgctedit.h | 49 ++++ .../launcher/include/sgctedit/windowcontrol.h | 22 +- .../ext/launcher/src/sgctedit/display.cpp | 24 +- .../ext/launcher/src/sgctedit/filesupport.cpp | 3 +- .../ext/launcher/src/sgctedit/main.cpp | 115 --------- .../ext/launcher/src/sgctedit/monitorbox.cpp | 237 ++++++++++++++---- .../ext/launcher/src/sgctedit/orientation.cpp | 7 +- .../src/sgctedit/orientationdialog.cpp | 4 +- .../ext/launcher/src/sgctedit/sgctedit.cpp | 121 +++++++++ .../launcher/src/sgctedit/windowcontrol.cpp | 105 +++----- 13 files changed, 446 insertions(+), 283 deletions(-) create mode 100644 apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h delete mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp create mode 100644 apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index 59d28f69ad..0799196300 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -47,6 +47,7 @@ set(HEADER_FILES include/sgctedit/monitorbox.h include/sgctedit/orientation.h include/sgctedit/orientationdialog.h + include/sgctedit/sgctedit.h include/sgctedit/windowcontrol.h ) @@ -68,9 +69,9 @@ set(SOURCE_FILES src/profile/timedialog.cpp src/profile/profileedit.cpp src/profile/propertiesdialog.cpp + src/sgctedit/sgctedit.cpp src/sgctedit/display.cpp src/sgctedit/filesupport.cpp - src/sgctedit/main.cpp src/sgctedit/monitorbox.cpp src/sgctedit/orientation.cpp src/sgctedit/orientationdialog.cpp @@ -97,6 +98,7 @@ set(HEADER_SOURCE include/sgctedit/monitorbox.h include/sgctedit/orientation.h include/sgctedit/orientationdialog.h + include/sgctedit/sgctedit.h include/sgctedit/windowcontrol.h ) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 9eb0a6c160..cc3ead04c3 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -36,10 +36,11 @@ private slots: void removeWindow(); private: - void addWindowControl(); + void initializeWindowControl(); void removeWindowControl(); void initializeLayout(bool showLabel, unsigned int numWindowsInit); void showWindows(unsigned int nWindowControlsDisplayed); + void addDisplayLayout(unsigned int column, MonitorBox* monBox, QVBoxLayout* layout); std::vector& _monitorResolutions; QRect _widgetDims = {0, 0, 400, 400}; std::vector _windowControl; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index afeda9b86f..21e1456105 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -27,9 +27,7 @@ public: void mapMonitorResolutionToWidgetCoordinates(); void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& w); - void setResolution(unsigned int index, QRect& res); void setNumWindowsDisplayed(unsigned int mIdx, unsigned int nWindows); - int numWindows(); void windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, const QRectF& newDimensions); void addWindowControl(WindowControl* wCtrl); @@ -38,6 +36,21 @@ protected: void paintEvent(QPaintEvent *event) override; private: + void paintWidgetBorder(QPainter& painter, int width, int height); + void paintMonitorOutlines(QPainter& painter); + void paintWindowOutline(QPainter& painter, unsigned int monIdx, unsigned int winIdx); + void paintOutOfBoundsAreas(QPainter& painter, unsigned int monIdx,unsigned int winIdx); + void paintWindowNumber(QPainter& painter, unsigned int monIdx, unsigned int winIdx); + void setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, + bool visibleBorder); + void computeScaledResolution_landscape(float aspectRatio, float maxWidth); + void computeScaledResolution_portrait(float aspectRatio, float maxHeight); + void computeOutOfBounds_horizontal(unsigned int mIdx, unsigned int wIdx); + void computeOutOfBounds_vertical(unsigned int mIdx, unsigned int wIdx); + void addOutOfBoundsArea_horizontal(unsigned int mIdx, unsigned int wIdx, + qreal bounds, qreal extent); + void addOutOfBoundsArea_vertical(unsigned int mIdx, unsigned int wIdx, + qreal bounds, qreal extent); unsigned int _maxNumMonitors = 2; unsigned int _maxNumWindowsPerMonitor = 2; std::vector _monitorResolution; @@ -45,15 +58,17 @@ private: std::vector _monitorDimensionsScaled; std::vector _windowResolutions; + std::vector>> _outOfBoundsRect = { + {{{0.0, 0.0, 0.0, 0.0}}, + {{0.0, 0.0, 0.0, 0.0}}}, + {{{0.0, 0.0, 0.0, 0.0}}, + {{0.0, 0.0, 0.0, 0.0}}} + }; std::vector> _windowRendering = { - { - {0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0} - }, - { - {0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0} - } + {{0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0}}, + {{0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0}} }; float _monitorScaleFactor = 1.0; float _offset[2] = {10.0, 10.0}; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h new file mode 100644 index 0000000000..1eb5d25981 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -0,0 +1,49 @@ +#ifndef __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ +#define __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + + +class SgctEdit final : public QDialog +{ +Q_OBJECT +public: + SgctEdit(QWidget* parent, QApplication& qtApp); + ~SgctEdit(); + void addDisplayLayout(unsigned int column, MonitorBox* monBox, QHBoxLayout* layout); + void createWidgets(); + +private slots: + +private: + void systemMonitorConfiguration(QApplication& qtApp); + std::vector _monitorSizeList; + std::vector _displayLayout = {nullptr, nullptr}; + std::vector _displayFrame = {nullptr, nullptr}; + std::vector _displayWidget = {nullptr, nullptr}; + QRect _monitorWidgetSize = {0, 0, 400, 350}; + FileSupport* _fileSupportWidget = nullptr; + Orientation* _orientationWidget = nullptr; + bool _showMonitorLabel = false; +}; + +#endif // __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 712dff3805..80ab9bab34 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -28,9 +28,8 @@ public: QRect& widgetDims, QRect& monitorDims, QWidget *parent = nullptr); ~WindowControl(); void setDimensions(const QRectF& dimensions); - void setWindowScaleFactor(float scaleFactor); void setWindowChangeCallback( - std::function cb); + std::function cb); void showWindowLabel(bool show); void cleanupLayouts(); QVBoxLayout* initializeLayout(QWidget* parentWidget); @@ -49,15 +48,14 @@ private slots: void onOffsetXChanged(const QString& newText); void onOffsetYChanged(const QString& newText); void onProjectionChanged(int newSelection); - void onQualityChanged(int newSelection); void onFullscreenClicked(); private: void updateScaledWindowDimensions(); - std::function _windowChangeCallback; + std::function _windowChangeCallback; QRectF defaultWindowSizes[2] = { - {50.0, 50.0, 800.0, 600.0}, - {900.0, 400.0, 2540.0, 680.0} + {50.0, 50.0, 1280.0, 720.0}, + {900.0, 400.0, 800.0, 600.0} }; QList _projectionTypes = { "Planar", "Fisheye", "Spherical Mirror", "Cylindrical", "Equirectangular" @@ -70,7 +68,7 @@ private: float _marginFractionOfWidgetSize = 0.025; unsigned int _monIndex = 0; unsigned int _index = 0; - unsigned int _maxWindowSizePixels = 10000; + int _maxWindowSizePixels = 10000; QVBoxLayout* _layoutWindowCtrl = nullptr; QVBoxLayout* _layoutFullWindow = nullptr; @@ -89,10 +87,7 @@ private: QIntValidator* _validatorOffset_y = nullptr; QRect& _monitorResolution; - QRectF _monitorDimsScaled; QRectF _windowDims; - QRectF _windowDimsScaled; - float _monitorScaleFactor = 1.0; QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; QCheckBox* _checkBoxWebGui = nullptr; @@ -112,10 +107,9 @@ private: QLineEdit* _windowName = nullptr; QLabel* _labelSize = nullptr; QLabel* _labelDelim = nullptr; - QGridLayout* _layoutSize = nullptr; - QHBoxLayout* _layoutGridFrame= nullptr; - QHBoxLayout* _layoutGridSizeValues = nullptr; - QHBoxLayout* _layoutGridOffsetValues = nullptr; + QHBoxLayout* _layoutSize = nullptr; + QWidget* _widgetSize = nullptr; + QHBoxLayout* _layoutOffset = nullptr; QLabel* _labelOffset = nullptr; QLabel* _labelComma = nullptr; QHBoxLayout* _layoutCheckboxesFull1 = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 113fc471d8..11064e3488 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -3,9 +3,9 @@ #include #include -#include "include/monitorbox.h" -#include "include/windowcontrol.h" -#include "include/display.h" +#include "sgctedit/monitorbox.h" +#include "sgctedit/windowcontrol.h" +#include "sgctedit/display.h" Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, @@ -18,8 +18,8 @@ Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, _removeWindowButton = new QPushButton("Remove Window", this); //Add 2 window controls - addWindowControl(); - addWindowControl(); + initializeWindowControl(); + initializeWindowControl(); initializeLayout(showLabel, numWindowsInit); connect(_addWindowButton, SIGNAL(released()), this, @@ -30,9 +30,19 @@ Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, Display::~Display() { delete _addWindowButton; + delete _removeWindowButton; delete _monBox; + delete _borderFrame; + delete _labelMonNum; + for (auto w : _windowControl) { + delete w; + } + delete _layoutMonNumLabel; delete _layoutMonBox; delete _layoutMonButton; + for (auto w : _layoutWindowWrappers) { + delete w; + } delete _layoutWindows; delete _layout; } @@ -130,7 +140,7 @@ void Display::showWindows(unsigned int nWindowControlsDisplayed) { } } -void Display::addWindowControl() { +void Display::initializeWindowControl() { if (_nWindowsAllocated < 2) { _windowControl.push_back( new WindowControl( @@ -142,7 +152,7 @@ void Display::addWindowControl() { ) ); _windowControl.back()->setWindowChangeCallback( - [this](unsigned int monIndex, unsigned int winIndex, const QRectF& newDims) { + [this](int monIndex, int winIndex, const QRectF& newDims) { _monBox->windowDimensionsChanged(monIndex, winIndex, newDims); } ); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index b4b5e4f241..6cdefc81fb 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -1,4 +1,4 @@ -#include "filesupport.h" +#include "sgctedit/filesupport.h" FileSupport::FileSupport(QVBoxLayout* parentLayout) { @@ -12,6 +12,7 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout) _cancelButton->setToolTip("Cancel global orientation changes"); //connect(_buttonCancel, &QPushButton::clicked, this, &ModulesDialog::listItemCancelSave); _layoutButtonBox->addWidget(_cancelButton); + //_layoutButtonBox->setSizeConstraint(QLayout::SetFixedSize); parentLayout->addLayout(_layoutButtonBox); connect(_cancelButton, SIGNAL(released()), this, SLOT(cancel())); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp deleted file mode 100644 index 8c27b6f172..0000000000 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/main.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "include/display.h" -#include "include/filesupport.h" -#include "include/monitorbox.h" -#include "include/windowcontrol.h" -#include "include/orientation.h" - - - -int main(int argc, char *argv[ ]) -{ - QApplication app(argc, argv); - QMainWindow win(nullptr); - - //Temporary code for monitor detection - QList screenList = app.screens(); - std::vector monitorSizeList; - for (size_t s = 0; s < std::min(screenList.length(), 2); ++s) { - int actualWidth = std::max(screenList[s]->size().width(), - screenList[s]->availableGeometry().width()); - int actualHeight = std::max(screenList[s]->size().height(), - screenList[s]->availableGeometry().height()); - monitorSizeList.push_back({ - screenList[s]->availableGeometry().x(), - screenList[s]->availableGeometry().y(), - actualWidth, - actualHeight - }); - } - QFrame* monitorBorderFrame = nullptr; - Orientation* orientationWidget = nullptr; - - if (screenList.length() == 0) { - std::cerr << "Error: Qt reports no screens available." << std::endl; - return -1; - } - QVBoxLayout* layoutMainV = new QVBoxLayout(); - QHBoxLayout* layoutMainH = new QHBoxLayout(); - - orientationWidget = new Orientation(); - QWidget* mainWindow = new QWidget(); - mainWindow->setLayout(layoutMainV); - win.setCentralWidget(mainWindow); - - bool showMonitorLabel = (monitorSizeList.size() > 1); - MonitorBox* monBox = new MonitorBox( - {0, 0, 400, 340}, - monitorSizeList, - showMonitorLabel - ); - QHBoxLayout* layoutMonBox = new QHBoxLayout(); - layoutMonBox->addStretch(1); - //_layout->addWidget(_monBox); - layoutMonBox->addWidget(monBox); - layoutMonBox->addStretch(1); - layoutMainV->addLayout(layoutMonBox); - - monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - monBox->setFixedSize(400, 340); - - std::vector displayLayout = {nullptr, nullptr}; - std::vector displayFrame = {nullptr, nullptr}; - std::vector displayWidget = {nullptr, nullptr}; - - displayLayout[0] = new QVBoxLayout(); - displayWidget[0] = new Display(0, monBox, monitorSizeList, 1, showMonitorLabel); - displayFrame[0] = new QFrame; - displayLayout[0]->addWidget(displayWidget[0]); - displayFrame[0]->setLayout(displayLayout[0]); - displayFrame[0]->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - layoutMainH->addWidget(displayFrame[0]); - - if (monitorSizeList.size() > 1) { - displayLayout[1] = new QVBoxLayout(); - displayWidget[1] = new Display(1, monBox, monitorSizeList, 0, showMonitorLabel); - displayFrame[1] = new QFrame; - displayLayout[1]->addWidget(displayWidget[1]); - displayFrame[1]->setLayout(displayLayout[1]); - displayFrame[1]->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - layoutMainH->addWidget(displayFrame[1]); - } - - layoutMainV->addLayout(layoutMainH); - orientationWidget->addButtonToLayout(layoutMainV); - FileSupport* fileSupportWidget = new FileSupport(layoutMainV); - - win.setWindowTitle("Window Details"); - win.show(); - app.exec(); - - delete orientationWidget; - for (unsigned int i = 0; i <= 1; ++i) { - if (displayWidget[i]) delete displayWidget[i]; - if (displayLayout[i]) delete displayLayout[i]; - if (displayFrame[i]) delete displayFrame[i]; - } - if (monitorBorderFrame) { - delete monitorBorderFrame; - } - delete monBox; - delete layoutMainH; - delete layoutMainV; - delete mainWindow; -} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index b10bd5fa5e..b8dd9fdf6c 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -1,4 +1,4 @@ -#include "monitorbox.h" +#include "sgctedit/monitorbox.h" MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, @@ -21,11 +21,24 @@ void MonitorBox::paintEvent(QPaintEvent *event) QPainter painter(this); QPen pen = painter.pen(); painter.setPen(pen); - //Draw border - painter.setPen(QPen(Qt::gray, 4)); - painter.drawRoundedRect(0, 0, width() - 1, height() - 1, 10, 10); - //Draw monitor outline(s) + paintWidgetBorder(painter, width(), height()); + paintMonitorOutlines(painter); + + //Draw window outline(s) + for (unsigned int i = 0; i < _nMonitors ; ++i) { + for (unsigned int j = 0; j < _nWindows[i]; ++j) { + paintWindowOutline(painter, i, j); + } + } +} + +void MonitorBox::paintWidgetBorder(QPainter& painter, int width, int height) { + painter.setPen(QPen(Qt::gray, 4)); + painter.drawRoundedRect(0, 0, width - 1, height - 1, 10, 10); +} + +void MonitorBox::paintMonitorOutlines(QPainter& painter) { painter.setPen(QPen(Qt::black, 2)); painter.setFont(QFont("Arial", 14)); for (unsigned int i = 0; i < _nMonitors; ++i) { @@ -33,35 +46,65 @@ void MonitorBox::paintEvent(QPaintEvent *event) painter.drawRect(_monitorDimensionsScaled[i]); if (_showLabel) { QPointF textPos = QPointF(_monitorDimensionsScaled[i].left() + 5, - _monitorDimensionsScaled[i].bottom() - 5); + _monitorDimensionsScaled[i].top() + 18); painter.drawText(textPos, QString::fromStdString(std::to_string(i + 1))); } } } - - //Draw window outline(s) - for (unsigned int i = 0; i < _nMonitors ; ++i) { - for (unsigned int j = 0; j < _nWindows[i]; ++j) { - if (j == 0) { - painter.setPen(QColor(0x1C, 0x1B, 0x8B)); - } - else if (j == 1) { - painter.setPen(QColor(0xCD, 0x6D, 0x1D)); - } - if (j <= _windowRendering[i].size()) { - painter.drawRect(_windowRendering[i][j]); - QPointF textPos = QPointF(_windowRendering[i][j].left() + 5, - _windowRendering[i][j].bottom() - 5); - textPos.setX(std::clamp(textPos.x(), 0.0, _monitorWidgetSize.width() - 10)); - textPos.setY(std::clamp(textPos.y(), 0.0, _monitorWidgetSize.height() - 10)); - painter.drawText(textPos, QString::fromStdString(std::to_string(j + 1))); - } - } - } +} + +void MonitorBox::paintWindowOutline(QPainter& painter, unsigned int monIdx, + unsigned int winIdx) +{ + setPenSpecificToWindow(painter, winIdx, true); + if (winIdx <= _windowRendering[monIdx].size()) { + painter.drawRect(_windowRendering[monIdx][winIdx]); + //Draw areas of window that are past the monitor boundaries + if (_outOfBoundsRect[monIdx][winIdx].size() > 0) { + paintOutOfBoundsAreas(painter, monIdx, winIdx); + } + paintWindowNumber(painter, monIdx, winIdx); + } +} + +void MonitorBox::paintOutOfBoundsAreas(QPainter& painter, unsigned int monIdx, + unsigned int winIdx) +{ + painter.setBrush(Qt::BDiagPattern); + setPenSpecificToWindow(painter, winIdx, false); + for (QRectF r : _outOfBoundsRect[monIdx][winIdx]) { + painter.drawRect(r); + } + setPenSpecificToWindow(painter, winIdx, true); + painter.setBrush(Qt::NoBrush); +} + +void MonitorBox::paintWindowNumber(QPainter& painter, unsigned int monIdx, + unsigned int winIdx) +{ + QPointF textPos = QPointF(_windowRendering[monIdx][winIdx].left() + 5, + _windowRendering[monIdx][winIdx].bottom() - 5); + textPos.setX(std::clamp(textPos.x(), 0.0, + _monitorWidgetSize.width() - 10)); + textPos.setY(std::clamp(textPos.y(), 0.0, + _monitorWidgetSize.height() - 10)); + painter.drawText(textPos, QString::fromStdString(std::to_string(winIdx + 1))); +} + +void MonitorBox::setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, + bool visibleBorder) +{ + int penWidth = (visibleBorder) ? 1 : -1; + if (windowIdx == 0) { + painter.setPen(QPen(QColor(0x1C, 0x1B, 0x8B), penWidth)); + } + else if (windowIdx == 1) { + painter.setPen(QPen(QColor(0xCD, 0x6D, 0x1D), penWidth)); + } } void MonitorBox::windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, - const QRectF& newDimensions) + const QRectF& newDimensions) { mapWindowResolutionToWidgetCoordinates(monitorIdx, windowIdx, newDimensions); } @@ -80,34 +123,11 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { } float aspectRatio = maxWidth / maxHeight; if (aspectRatio >= 1.0) { - _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; - float virtualWidth = _monitorWidgetSize.width() - * (1.0 - _marginFractionOfWidgetSize * 2.0); - _monitorScaleFactor = virtualWidth / maxWidth; - float newHeight = virtualWidth / aspectRatio; - for (size_t m = 0; m < _monitorResolution.size(); ++m) { - _monitorOffsets.push_back({ - _marginWidget + _monitorResolution[m].x() * _monitorScaleFactor, - _marginWidget + (_monitorWidgetSize.height() - newHeight) / 2.0 + - _monitorResolution[m].y() * _monitorScaleFactor - }); - } + computeScaledResolution_landscape(aspectRatio, maxWidth); } else { - _marginWidget = _monitorWidgetSize.height() * _marginFractionOfWidgetSize; - float virtualHeight = _monitorWidgetSize.height() - * (1.0 - _marginFractionOfWidgetSize * 2.0); - _monitorScaleFactor = virtualHeight / maxHeight; - float newWidth = virtualHeight * aspectRatio; - for (size_t m = 0; m < _monitorResolution.size(); ++m) { - _monitorOffsets.push_back({ - _marginWidget + (_monitorWidgetSize.width() - newWidth) / 2.0 - + _monitorResolution[m].x() * _monitorScaleFactor, - _marginWidget + _monitorResolution[m].y() * _monitorScaleFactor - }); - } + computeScaledResolution_portrait(aspectRatio, maxHeight); } - for (size_t m = 0; m < _monitorResolution.size(); ++m) { _monitorDimensionsScaled.push_back({ _monitorOffsets[m].width(), @@ -119,8 +139,34 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { this->update(); } -void MonitorBox::setResolution(unsigned int index, QRect& res) { - _monitorResolution[index] = res; +void MonitorBox::computeScaledResolution_landscape(float aspectRatio, float maxWidth) { + _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; + float virtualWidth = _monitorWidgetSize.width() + * (1.0 - _marginFractionOfWidgetSize * 2.0); + _monitorScaleFactor = virtualWidth / maxWidth; + float newHeight = virtualWidth / aspectRatio; + for (size_t m = 0; m < _monitorResolution.size(); ++m) { + _monitorOffsets.push_back({ + _marginWidget + _monitorResolution[m].x() * _monitorScaleFactor, + _marginWidget + (_monitorWidgetSize.height() - newHeight) / 2.0 + + _monitorResolution[m].y() * _monitorScaleFactor + }); + } +} + +void MonitorBox::computeScaledResolution_portrait(float aspectRatio, float maxHeight) { + _marginWidget = _monitorWidgetSize.height() * _marginFractionOfWidgetSize; + float virtualHeight = _monitorWidgetSize.height() + * (1.0 - _marginFractionOfWidgetSize * 2.0); + _monitorScaleFactor = virtualHeight / maxHeight; + float newWidth = virtualHeight * aspectRatio; + for (size_t m = 0; m < _monitorResolution.size(); ++m) { + _monitorOffsets.push_back({ + _marginWidget + (_monitorWidgetSize.width() - newWidth) / 2.0 + + _monitorResolution[m].x() * _monitorScaleFactor, + _marginWidget + _monitorResolution[m].y() * _monitorScaleFactor + }); + } } void MonitorBox::setNumWindowsDisplayed(unsigned int mIdx, unsigned int nWindows) { @@ -130,6 +176,11 @@ void MonitorBox::setNumWindowsDisplayed(unsigned int mIdx, unsigned int nWindows } } +void printWindowDims(QRectF& r) { + std::cout << r.width() << "x" << r.height() << " + " << r.x() << "," << r.y(); + std::cout << std::endl; +} + void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& w) @@ -144,6 +195,84 @@ void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, wF.width() * _monitorScaleFactor, wF.height() * _monitorScaleFactor }; + _outOfBoundsRect[mIdx][wIdx].clear(); + computeOutOfBounds_horizontal(mIdx, wIdx); + computeOutOfBounds_vertical(mIdx, wIdx); this->update(); } +void MonitorBox::computeOutOfBounds_horizontal(unsigned int mIdx, unsigned int wIdx) { + qreal windowWidthPlusOffset = _windowRendering[mIdx][wIdx].width() + + _windowRendering[mIdx][wIdx].x() - _monitorDimensionsScaled[mIdx].x(); + if (windowWidthPlusOffset > _monitorDimensionsScaled[mIdx].width()) { + qreal bounds_x = std::max( + _monitorDimensionsScaled[mIdx].width() + _monitorDimensionsScaled[mIdx].x(), + _windowRendering[mIdx][wIdx].x() + ); + qreal extent_x = std::min( + _windowRendering[mIdx][wIdx].width(), + windowWidthPlusOffset - _monitorDimensionsScaled[mIdx].width() + ); + addOutOfBoundsArea_horizontal(mIdx, wIdx, bounds_x, extent_x); + } + if (_windowRendering[mIdx][wIdx].x() < _monitorDimensionsScaled[mIdx].x() ) { + qreal extent_x = std::min( + _windowRendering[mIdx][wIdx].width(), + _monitorDimensionsScaled[mIdx].x() - _windowRendering[mIdx][wIdx].x() + ); + addOutOfBoundsArea_horizontal(mIdx, wIdx, _windowRendering[mIdx][wIdx].x(), + extent_x); + } +} + +void MonitorBox::addOutOfBoundsArea_horizontal(unsigned int mIdx, unsigned int wIdx, + qreal bounds, qreal extent) +{ + _outOfBoundsRect[mIdx][wIdx].push_back({ + bounds, + _windowRendering[mIdx][wIdx].y(), + extent, + _windowRendering[mIdx][wIdx].height() + }); +} + +void MonitorBox::computeOutOfBounds_vertical(unsigned int mIdx, unsigned int wIdx) { + qreal windowHeightPlusOffset = _windowRendering[mIdx][wIdx].height() + + _windowRendering[mIdx][wIdx].y() - _monitorDimensionsScaled[mIdx].y(); + if (windowHeightPlusOffset > _monitorDimensionsScaled[mIdx].height()) { + qreal bounds_y = std::max( + _monitorDimensionsScaled[mIdx].height() + _monitorDimensionsScaled[mIdx].y(), + _windowRendering[mIdx][wIdx].y() + ); + qreal extent_y = std::min( + _windowRendering[mIdx][wIdx].height(), + windowHeightPlusOffset - _monitorDimensionsScaled[mIdx].height() + ); + addOutOfBoundsArea_vertical(mIdx, wIdx, bounds_y, extent_y); + } + if (_windowRendering[mIdx][wIdx].y() < _monitorDimensionsScaled[mIdx].y() ) { + qreal extent_y = std::min( + _windowRendering[mIdx][wIdx].height(), + _monitorDimensionsScaled[mIdx].y() - _windowRendering[mIdx][wIdx].y() + ); + _outOfBoundsRect[mIdx][wIdx].push_back({ + _windowRendering[mIdx][wIdx].x(), + _windowRendering[mIdx][wIdx].y(), + _windowRendering[mIdx][wIdx].width(), + extent_y + }); + addOutOfBoundsArea_vertical(mIdx, wIdx, _windowRendering[mIdx][wIdx].y(), + extent_y); + } +} + +void MonitorBox::addOutOfBoundsArea_vertical(unsigned int mIdx, unsigned int wIdx, + qreal bounds, qreal extent) +{ + _outOfBoundsRect[mIdx][wIdx].push_back({ + _windowRendering[mIdx][wIdx].x(), + bounds, + _windowRendering[mIdx][wIdx].width(), + extent + }); +} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index 504453bb0f..f731640070 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -1,6 +1,6 @@ -#include "display.h" -#include "orientation.h" -#include "orientationdialog.h" +#include "sgctedit/display.h" +#include "sgctedit/orientation.h" +#include "sgctedit/orientationdialog.h" Orientation::Orientation() { _layoutOrientationFull = new QHBoxLayout(); @@ -13,6 +13,7 @@ Orientation::Orientation() { _layoutOrientationFull->addStretch(1); _layoutOrientationFull->addLayout(_layoutOrientationControls); _layoutOrientationFull->addStretch(1); + //_layoutOrientationFull->setSizeConstraint(QLayout::SetFixedSize); connect(_orientationButton, SIGNAL(released()), this, SLOT(orientationDialog())); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 6f2a7a1629..7eafb85316 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -1,5 +1,5 @@ -#include "display.h" -#include "orientationdialog.h" +#include "sgctedit/display.h" +#include "sgctedit/orientationdialog.h" OrientationDialog::OrientationDialog(QWidget* parent) : QDialog(parent) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp new file mode 100644 index 0000000000..df16961f63 --- /dev/null +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -0,0 +1,121 @@ +#include "sgctedit/sgctedit.h" + +/*using namespace openspace; + +namespace { + +}*/ + +SgctEdit::SgctEdit(QWidget* parent, QApplication& qtApp) + : QDialog(parent) +{ + setWindowTitle("Display/Window Editor"); + systemMonitorConfiguration(qtApp); + createWidgets(); +} + +void SgctEdit::systemMonitorConfiguration(QApplication& qtApp) { + QList screenList = qtApp.screens(); + if (screenList.length() == 0) { + std::cerr << "Error: Qt reports no screens available." << std::endl; + return; + } + + for (size_t s = 0; s < std::min(screenList.length(), 2); ++s) { + int actualWidth = std::max(screenList[s]->size().width(), + screenList[s]->availableGeometry().width()); + int actualHeight = std::max(screenList[s]->size().height(), + screenList[s]->availableGeometry().height()); + _monitorSizeList.push_back({ + screenList[s]->availableGeometry().x(), + screenList[s]->availableGeometry().y(), + actualWidth, + actualHeight + }); + } + + //_monitorSizeList.clear(); + //_monitorSizeList.push_back({3440, 0, 1920, 1200}); + //_monitorSizeList.push_back({1080, 0, 1920, 1080}); +} + +void SgctEdit::createWidgets() { +// QApplication app(argc, argv); +// QMainWindow win(nullptr); + +// QFrame* monitorBorderFrame = nullptr; + + QVBoxLayout* layoutMainV = new QVBoxLayout(this); + QHBoxLayout* layoutMainH = new QHBoxLayout; + + _orientationWidget = new Orientation(); +// QWidget* mainWindow = new QWidget(); +// mainWindow->setLayout(layoutMainV); +// win.setCentralWidget(mainWindow); + + if (_monitorSizeList.size() > 1) { + _monitorWidgetSize = QRect(0, 0, 600, 350); + _showMonitorLabel = true; + } + + { + MonitorBox* monBox = new MonitorBox( + _monitorWidgetSize, + _monitorSizeList, + _showMonitorLabel + ); + QHBoxLayout* layoutMonBox = new QHBoxLayout(); + layoutMonBox->addStretch(1); + //_layout->addWidget(_monBox); + layoutMonBox->addWidget(monBox); + layoutMonBox->addStretch(1); + layoutMainV->addLayout(layoutMonBox); + + monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + monBox->setFixedSize(_monitorWidgetSize.width(), _monitorWidgetSize.height()); + + addDisplayLayout(0, monBox, layoutMainH); + if (_monitorSizeList.size() > 1) { + addDisplayLayout(1, monBox, layoutMainH); + } + } + //layoutMainH->setSizeConstraint(QLayout::SetFixedSize); + layoutMainV->addLayout(layoutMainH); + _orientationWidget->addButtonToLayout(layoutMainV); + _fileSupportWidget = new FileSupport(layoutMainV); + +// win.setWindowTitle("Window Details"); +// win.show(); +// app.exec(); +} + +void SgctEdit::addDisplayLayout(unsigned int column, MonitorBox* monBox, + QHBoxLayout* layout) +{ + _displayLayout[column] = new QVBoxLayout(); + _displayWidget[column] = new Display(column, monBox, _monitorSizeList, + (column == 0) ? 1 : 0, _showMonitorLabel); + _displayFrame[column] = new QFrame; + _displayLayout[column]->addWidget(_displayWidget[column]); + _displayFrame[column]->setLayout(_displayLayout[column]); + _displayFrame[column]->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + layout->addWidget(_displayFrame[column]); +} + +SgctEdit::~SgctEdit() { + delete _orientationWidget; + delete _fileSupportWidget; +/* for (unsigned int i = 0; i <= 1; ++i) { + if (displayWidget[i]) delete displayWidget[i]; + if (displayLayout[i]) delete displayLayout[i]; + if (displayFrame[i]) delete displayFrame[i]; + } + if (monitorBorderFrame) { + delete monitorBorderFrame; + } + delete monBox; + delete layoutMonBox; + delete layoutMainH; + delete layoutMainV; + delete mainWindow;*/ +} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 27d1194a52..a96e9e5c0d 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -1,6 +1,6 @@ -#include "display.h" -#include "monitorbox.h" -#include "windowcontrol.h" +#include "sgctedit/display.h" +#include "sgctedit/monitorbox.h" +#include "sgctedit/windowcontrol.h" WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex, QRect& widgetDims, QRect& monitorDims, QWidget *parent) @@ -23,13 +23,13 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex QIntValidator* _validatorSize_y = new QIntValidator(10, _maxWindowSizePixels); QIntValidator* _validatorOffset_x - = new QIntValidator(10, _maxWindowSizePixels); + = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); QIntValidator* _validatorOffset_y - = new QIntValidator(10, _maxWindowSizePixels); + = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); _size_x->setValidator(_validatorSize_x); _size_y->setValidator(_validatorSize_y); - _offset_x->setValidator(_validatorSize_y); - _offset_y->setValidator(_validatorSize_y); + _offset_x->setValidator(_validatorOffset_x); + _offset_y->setValidator(_validatorOffset_y); _fullscreenButton = new QPushButton(this); _fullscreenButton->setText("Set to Fullscreen"); @@ -60,8 +60,6 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex connect(_comboProjection, SIGNAL(currentIndexChanged(int)), this, SLOT(onProjectionChanged(int))); - connect(_comboQuality, SIGNAL(currentIndexChanged(int)), - this, SLOT(onQualityChanged(int))); connect(_fullscreenButton, SIGNAL(released()), this, SLOT(onFullscreenClicked())); } @@ -73,7 +71,6 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _labelWinNum = new QLabel(); _labelWinNum->setText("Window " + QString::number(_index + 1)); -// _labelWinNum->setStyleSheet("QLabel { color : blue; }"); if (_index == 1) { _labelWinNum->setStyleSheet("QLabel { color : #CD6D1D; }"); } @@ -92,7 +89,6 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _labelName->setText("Window Name: "); _windowName = new QLineEdit(this); _windowName->setFixedWidth(100); -// _layoutName->addStretch(1); _layoutName->addWidget(_labelName); _layoutName->addWidget(_windowName); _layoutName->addStretch(1); @@ -101,26 +97,16 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _size_y->setFixedWidth(_lineEditWidthFixed); _labelSize = new QLabel(this); _labelDelim = new QLabel(this); - QGridLayout* _layoutSize = new QGridLayout; - //_layoutSize = new QHBoxLayout(); - //_layoutSize->addStretch(1); -// _layoutSize->addRow(_labelSize, _size_x, _labelDelim, _size_y); - _layoutSize->addWidget(_labelSize, 0, 0); - _layoutGridSizeValues = new QHBoxLayout(); - _layoutGridSizeValues->addWidget(_size_x); - _layoutGridSizeValues->addWidget(_labelDelim); - _layoutGridSizeValues->addWidget(_size_y); - _layoutGridSizeValues->addStretch(1); - _layoutSize->addLayout(_layoutGridSizeValues, 0, 1); -// _layoutSize->addWidget(_labelSize); - //_labelSize->setFixedWidth(50); + _layoutSize = new QHBoxLayout(); + _layoutSize->addWidget(_labelSize); _labelSize->setText("Size:"); -// _layoutSize->addWidget(_size_x); -// _layoutSize->addWidget(_labelDelim); -// _layoutSize->addWidget(_size_y); -// _layoutSize->addStretch(1); + _labelSize->setFixedWidth(55); + _layoutSize->addWidget(_size_x); + _layoutSize->addWidget(_labelDelim); + _layoutSize->addWidget(_size_y); + _layoutSize->addStretch(1); _labelDelim->setText("x"); - _labelDelim->setFixedWidth(10); + _labelDelim->setFixedWidth(7); _layoutWindowCtrl->addLayout(_layoutSize); //Window offset @@ -128,68 +114,45 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _offset_y->setFixedWidth(_lineEditWidthFixed); _labelOffset = new QLabel(this); _labelComma = new QLabel(this); -// _layoutOffset = new QHBoxLayout(); -// _layoutOffset->addStretch(1); -// _layoutOffset->addWidget(_labelOffset); -// _layoutSize->addRow(_labelOffset, _offset_x, _labelComma, _offset_y); - _layoutSize->addWidget(_labelOffset, 1, 0); - _layoutGridOffsetValues = new QHBoxLayout(); - _layoutGridOffsetValues->addWidget(_offset_x); - _layoutGridOffsetValues->addWidget(_labelComma); - _layoutGridOffsetValues->addWidget(_offset_y); - _layoutGridOffsetValues->addStretch(1); - _layoutSize->addLayout(_layoutGridOffsetValues, 1, 1); - //_labelOffset->setFixedWidth(50); + _layoutOffset = new QHBoxLayout(); + _layoutOffset->addWidget(_labelOffset); _labelOffset->setText("Offset:"); -// _layoutOffset->addWidget(_offset_x); -// _layoutOffset->addWidget(_labelComma); -// _layoutOffset->addWidget(_offset_y); -// _layoutOffset->addStretch(1); + _labelOffset->setFixedWidth(55); + _layoutOffset->addWidget(_offset_x); + _layoutOffset->addWidget(_labelComma); + _layoutOffset->addWidget(_offset_y); + _layoutOffset->addStretch(1); _labelComma->setText(","); - _labelComma->setFixedWidth(10); - _layoutGridFrame = new QHBoxLayout(); - _layoutGridFrame->addStretch(1); - _layoutGridFrame->addLayout(_layoutSize); - _layoutGridFrame->addStretch(1); - - _layoutWindowCtrl->addLayout(_layoutGridFrame); + _labelComma->setFixedWidth(7); + _layoutWindowCtrl->addLayout(_layoutOffset); //Window options _layoutCheckboxesFull1 = new QHBoxLayout(); _layoutCheckboxesFull2 = new QVBoxLayout(); -// _layoutCheckboxesFull1->addStretch(1); _layoutFullscreenButton = new QHBoxLayout(); - //_layoutFullscreenButton->addStretch(1); _layoutFullscreenButton->addWidget(_fullscreenButton); _layoutFullscreenButton->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutFullscreenButton); - _layoutCBoxWindowDecor = new QHBoxLayout(); - //_layoutCBoxWindowDecor->addStretch(1); _layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); _layoutCBoxWindowDecor->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxWindowDecor); _layoutCBoxWebGui= new QHBoxLayout(); - //_layoutCBoxWebGui->addStretch(1); _layoutCBoxWebGui->addWidget(_checkBoxWebGui); _layoutCBoxWebGui->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); _layoutCBoxSpoutOutput= new QHBoxLayout(); - //_layoutCBoxSpoutOutput->addStretch(1); _layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); _layoutCBoxSpoutOutput->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxSpoutOutput); - _layoutComboProjection = new QHBoxLayout(); _layoutComboProjection->addWidget(_comboProjection); _layoutComboProjection->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutComboProjection); - _layoutComboQuality = new QHBoxLayout(); _layoutComboQuality->addWidget(_comboQuality); _layoutComboQuality->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutComboQuality); - _layoutFov = new QHBoxLayout(); _labelFov = new QLabel(); _labelFov->setText("Horizontal FOV:"); @@ -208,7 +171,6 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutHeightOffsetWrapper = new QWidget(); _layoutHeightOffsetWrapper->setLayout(_layoutHeightOffset); _layoutCheckboxesFull2->addWidget(_layoutHeightOffsetWrapper); - _layoutCheckboxesFull1->addLayout(_layoutCheckboxesFull2); _layoutCheckboxesFull1->addStretch(1); _layoutWindowCtrl->addLayout(_layoutCheckboxesFull1); @@ -217,7 +179,6 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _comboProjection->setCurrentIndex(0); onProjectionChanged(0); _comboQuality->setCurrentIndex(2); - onQualityChanged(2); return _layoutFullWindow; } @@ -329,23 +290,16 @@ void WindowControl::onProjectionChanged(int newSelection) { } } -void WindowControl::onQualityChanged(int newSelection) { -} - void WindowControl::setDimensions(const QRectF& dimensions) { _windowDims = dimensions; } void WindowControl::setWindowChangeCallback( - std::function cb) + std::function cb) { _windowChangeCallback = cb; } -void WindowControl::setWindowScaleFactor(float scaleFactor) { - _monitorScaleFactor = scaleFactor; -} - QRectF& WindowControl::dimensions() { return _windowDims; } @@ -391,20 +345,19 @@ WindowControl::~WindowControl() delete _layoutName; delete _labelName; delete _windowName; + delete _labelWinNum; delete _labelSize; delete _labelDelim; delete _layoutSize; delete _labelOffset; delete _labelComma; -// delete _layoutOffset; - delete _layoutGridFrame; - delete _layoutGridSizeValues; - delete _layoutGridOffsetValues; + delete _layoutOffset; delete _checkBoxWindowDecor; delete _checkBoxWebGui; delete _checkBoxSpoutOutput; delete _comboProjection; delete _comboQuality; + delete _fullscreenButton; delete _labelFov; delete _lineFov; delete _validatorFov; @@ -423,6 +376,8 @@ WindowControl::~WindowControl() delete _layoutHeightOffsetWrapper; delete _layoutCheckboxesFull2; delete _layoutCheckboxesFull1; + delete _layoutWinNum; delete _layoutWindowCtrl; + delete _layoutFullWindow; } From dd2ff1515fe9796abd50a589935eee13e2a2a7eb Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 7 Jan 2022 21:01:58 -0700 Subject: [PATCH 28/93] Added projection type details and exclusive behavior with some options --- .../ext/launcher/include/sgctedit/display.h | 9 +- .../launcher/include/sgctedit/orientation.h | 7 + .../include/sgctedit/orientationdialog.h | 6 +- .../launcher/include/sgctedit/windowcontrol.h | 54 +++++++- .../ext/launcher/src/sgctedit/display.cpp | 32 ++++- .../ext/launcher/src/sgctedit/orientation.cpp | 12 +- .../src/sgctedit/orientationdialog.cpp | 30 ++++- .../ext/launcher/src/sgctedit/sgctedit.cpp | 16 ++- .../launcher/src/sgctedit/windowcontrol.cpp | 124 ++++++++++++++++-- 9 files changed, 264 insertions(+), 26 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index cc3ead04c3..5ba0a9ac3c 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -28,8 +28,14 @@ class Display : public QWidget public: explicit Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, - std::vector& monitorSizeList, unsigned int numWindowsInit, bool showLabel); + std::vector& monitorSizeList, unsigned int numWindowsInit, bool showLabel, + std::function webGuiCallback); ~Display(); + std::vector windowControls(); + unsigned int nWindows(); + sgct::ivec2 monitorResolution(); + void uncheckWebGuiOptions(); + void setindowChangeCallback(std::function cb); private slots: void addWindow(); @@ -41,6 +47,7 @@ private: void initializeLayout(bool showLabel, unsigned int numWindowsInit); void showWindows(unsigned int nWindowControlsDisplayed); void addDisplayLayout(unsigned int column, MonitorBox* monBox, QVBoxLayout* layout); + std::function _webGuiCheckCallback; std::vector& _monitorResolutions; QRect _widgetDims = {0, 0, 400, 400}; std::vector _windowControl; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index 8e471528c8..107135f02b 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -16,6 +16,9 @@ #include #include +#include +#include +#include class Orientation : public QWidget @@ -26,11 +29,15 @@ public: explicit Orientation(); ~Orientation(); void addButtonToLayout(QVBoxLayout* parentLayout); + sgct::quat orientationValue(); + bool vsyncValue(); private slots: void orientationDialog(); private: + sgct::quat _orientationValue = {0.0, 0.0, 0.0, 0.0}; + OrientationDialog* _orientationDialog = nullptr; QHBoxLayout* _layoutOrientationFull = nullptr; QVBoxLayout* _layoutOrientationControls = nullptr; QPushButton* _orientationButton = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h index cb44aa8743..b7c2bcbb6f 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h @@ -17,6 +17,7 @@ #include #include +#include class OrientationDialog : public QDialog @@ -24,12 +25,15 @@ class OrientationDialog : public QDialog Q_OBJECT public: - explicit OrientationDialog(QWidget* parent); + explicit OrientationDialog(sgct::quat& orientation, QWidget* parent); ~OrientationDialog(); private slots: + void cancel(); + void ok(); private: + sgct::quat& _orientationValue; QVBoxLayout* _layoutWindow = nullptr; QHBoxLayout* _layoutPitch = nullptr; QHBoxLayout* _layoutRoll = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 80ab9bab34..c19f6698d1 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -12,11 +12,13 @@ #include #include #include +#include #include #include #include #include +#include class WindowControl : public QWidget @@ -28,8 +30,8 @@ public: QRect& widgetDims, QRect& monitorDims, QWidget *parent = nullptr); ~WindowControl(); void setDimensions(const QRectF& dimensions); - void setWindowChangeCallback( - std::function cb); + void setWindowChangeCallback(std::function cb); + void setWebGuiChangeCallback(std::function cb); void showWindowLabel(bool show); void cleanupLayouts(); QVBoxLayout* initializeLayout(QWidget* parentWidget); @@ -41,6 +43,30 @@ public: QCheckBox* checkBoxWindowDecor(); QCheckBox* checkBoxWebGui(); QCheckBox* checkBoxSpoutOutput(); + std::string windowName(); + sgct::ivec2 windowSize(); + sgct::ivec2 windowPos(); + bool isDecorated(); + bool isSpoutSelected(); + bool isGuiWindow(); + void enableGuiWindowSelection(bool enabled); + void uncheckWebGuiOption(); + int projectionSelectedIndex(); + int qualitySelectedIndex(); + float fov(); + float heightOffset(); + enum ProjectionIndeces : unsigned int { + Planar = 0, + Fisheye, + Spherical_Mirror, + Cylindrical, + Equirectangular + }; + std::string ProjectionTypeNames[5] = {"Planar", "Fisheye", "Spherical Mirror", + "Cylindrical", "Equirectangular"}; + std::string QualityTypeNames[10] = {"Low (256)", "Medium (512)", "High (1K)", + "1.5K (1536)", "2K (2048)", "4K (4096)", "8K (8192)", "16K (16384)", + "32K (32768)", "64K (65536)"}; private slots: void onSizeXChanged(const QString& newText); @@ -49,20 +75,38 @@ private slots: void onOffsetYChanged(const QString& newText); void onProjectionChanged(int newSelection); void onFullscreenClicked(); + void onSpoutSelection(int selectionState); + void onWebGuiSelection(int selectionState); private: + void enableSpoutProjectionOptions(QComboBox* comboBox, bool enable); + template + void enableProjectionOption(T* comboModel, int selectionIndex, bool enable); void updateScaledWindowDimensions(); std::function _windowChangeCallback; + std::function _windowGuiCheckCallback; QRectF defaultWindowSizes[2] = { {50.0, 50.0, 1280.0, 720.0}, {900.0, 400.0, 800.0, 600.0} }; QList _projectionTypes = { - "Planar", "Fisheye", "Spherical Mirror", "Cylindrical", "Equirectangular" + QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Planar]), + QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Fisheye]), + QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Spherical_Mirror]), + QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Cylindrical]), + QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Equirectangular]), }; QList _qualityTypes = { - "Low (256)", "Medium (512)", "High (1K)", "1.5K (1536)", "2K (2048)", - "4K (4096)", "8K (8192)", "16K (16384)", "32K (32768)", "64K (65536)" + QString::fromStdString(QualityTypeNames[0]), + QString::fromStdString(QualityTypeNames[1]), + QString::fromStdString(QualityTypeNames[2]), + QString::fromStdString(QualityTypeNames[3]), + QString::fromStdString(QualityTypeNames[4]), + QString::fromStdString(QualityTypeNames[5]), + QString::fromStdString(QualityTypeNames[6]), + QString::fromStdString(QualityTypeNames[7]), + QString::fromStdString(QualityTypeNames[8]), + QString::fromStdString(QualityTypeNames[9]), }; int _lineEditWidthFixed = 50; float _marginFractionOfWidgetSize = 0.025; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 11064e3488..6dc36489dc 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -9,10 +9,12 @@ Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, - std::vector& monitorSizeList, unsigned int numWindowsInit, bool showLabel) + std::vector& monitorSizeList, unsigned int numWindowsInit, bool showLabel, + std::function webGuiCallback) : _monitorIdx(monitorIdx) , _monBox(monitorRenderBox) , _monitorResolutions(monitorSizeList) + , _webGuiCheckCallback(webGuiCallback) { _addWindowButton = new QPushButton("Add Window", this); _removeWindowButton = new QPushButton("Remove Window", this); @@ -89,6 +91,21 @@ void Display::initializeLayout(bool showLabel, unsigned int numWindowsInit) { //} } +std::vector Display::windowControls() { + return _windowControl; +} + +unsigned int Display::nWindows() { + return _nWindowsDisplayed; +} + +sgct::ivec2 Display::monitorResolution() { + return { + _monitorResolutions[_monitorIdx].width(), + _monitorResolutions[_monitorIdx].height() + }; +} + void Display::addWindow() { if (_nWindowsDisplayed == 0) { showWindows(1); @@ -156,6 +173,12 @@ void Display::initializeWindowControl() { _monBox->windowDimensionsChanged(monIndex, winIndex, newDims); } ); + _windowControl.back()->setWebGuiChangeCallback( + [this](unsigned int monIndex, unsigned int winIndex) { + _windowControl[(winIndex == 0)? 1 : 0]->uncheckWebGuiOption(); + _webGuiCheckCallback(monIndex); + } + ); _monBox->mapWindowResolutionToWidgetCoordinates( _monitorIdx, _nWindowsAllocated, @@ -164,3 +187,10 @@ void Display::initializeWindowControl() { _nWindowsAllocated++; } } + +void Display::uncheckWebGuiOptions() { + for (auto w : _windowControl) { + w->uncheckWebGuiOption(); + } +} + diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index f731640070..d6b14a62cd 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -3,6 +3,7 @@ #include "sgctedit/orientationdialog.h" Orientation::Orientation() { + _orientationDialog = new OrientationDialog(_orientationValue, this); _layoutOrientationFull = new QHBoxLayout(); _layoutOrientationControls = new QVBoxLayout(); _orientationButton = new QPushButton("Global Orientation"); @@ -24,11 +25,20 @@ void Orientation::addButtonToLayout(QVBoxLayout* parentLayout) { } void Orientation::orientationDialog() { - OrientationDialog(this).exec(); + _orientationDialog->exec(); +} + +sgct::quat Orientation::orientationValue() { + return _orientationValue; +} + +bool Orientation::vsyncValue() { + return (_checkBoxVsync->checkState() == Qt::Checked); } Orientation::~Orientation() { + delete _orientationDialog; delete _orientationButton; delete _checkBoxVsync; delete _layoutOrientationFull; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 7eafb85316..ea2d997b07 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -1,8 +1,10 @@ #include "sgctedit/display.h" #include "sgctedit/orientationdialog.h" -OrientationDialog::OrientationDialog(QWidget* parent) - : QDialog(parent) + +OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) + : _orientationValue(orientation) + , QDialog(parent) { setWindowTitle("Global Orientation"); _layoutWindow = new QVBoxLayout(this); @@ -20,9 +22,9 @@ OrientationDialog::OrientationDialog(QWidget* parent) _linePitch = new QLineEdit(this); _lineRoll = new QLineEdit(this); _lineYaw = new QLineEdit(this); - _linePitch->setText("0.0"); - _lineRoll->setText("0.0"); - _lineYaw->setText("0.0"); + _linePitch->setText(QString::number(_orientationValue.x)); + _lineRoll->setText(QString::number(_orientationValue.z)); + _lineYaw->setText(QString::number(_orientationValue.y)); _validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); _validatorPitch->setNotation(QDoubleValidator::StandardNotation); _validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); @@ -52,7 +54,7 @@ OrientationDialog::OrientationDialog(QWidget* parent) _layoutWindow->addLayout(_layoutYaw); _layoutButtonBox = new QHBoxLayout; - _buttonSave = new QPushButton("Save"); + _buttonSave = new QPushButton("OK"); _buttonSave->setToolTip("Save global orientation changes"); //connect(_buttonSave, &QPushButton::clicked, this, &ModulesDialog::listItemSave); _layoutButtonBox->addStretch(1); @@ -64,9 +66,25 @@ OrientationDialog::OrientationDialog(QWidget* parent) _layoutButtonBox->addWidget(_buttonCancel); _layoutButtonBox->addStretch(1); + connect(_buttonSave, SIGNAL(released()), this, + SLOT(ok())); + connect(_buttonCancel, SIGNAL(released()), this, + SLOT(cancel())); + _layoutWindow->addLayout(_layoutButtonBox); } +void OrientationDialog::ok() { + _orientationValue.x = QString(_linePitch->text()).toFloat(); + _orientationValue.y = QString(_lineYaw->text()).toFloat(); + _orientationValue.z = QString(_lineRoll->text()).toFloat(); + accept(); +} + +void OrientationDialog::cancel() { + reject(); +} + OrientationDialog::~OrientationDialog() { delete _labelPitch; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index df16961f63..cc05ecb83b 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -90,11 +90,21 @@ void SgctEdit::createWidgets() { } void SgctEdit::addDisplayLayout(unsigned int column, MonitorBox* monBox, - QHBoxLayout* layout) + QHBoxLayout* layout) { _displayLayout[column] = new QVBoxLayout(); - _displayWidget[column] = new Display(column, monBox, _monitorSizeList, - (column == 0) ? 1 : 0, _showMonitorLabel); + _displayWidget[column] = new Display( + column, + monBox, + _monitorSizeList, + (column == 0) ? 1 : 0, + _showMonitorLabel, + [this](unsigned int monIndex) { + if (_monitorSizeList.size() > 1) { + _displayWidget[(monIndex == 0) ? 1 : 0]->uncheckWebGuiOptions(); + } + } + ); _displayFrame[column] = new QFrame; _displayLayout[column]->addWidget(_displayWidget[column]); _displayFrame[column]->setLayout(_displayLayout[column]); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index a96e9e5c0d..891ccd8437 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -34,7 +34,7 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex _fullscreenButton = new QPushButton(this); _fullscreenButton->setText("Set to Fullscreen"); _checkBoxWindowDecor = new QCheckBox("Window Decoration", this); - _checkBoxWebGui = new QCheckBox("WebGUI here", this); + _checkBoxWebGui = new QCheckBox("WebGUI only this window", this); _checkBoxSpoutOutput = new QCheckBox("Spout Output", this); _comboProjection = new QComboBox(this); _comboProjection->addItems(_projectionTypes); @@ -60,6 +60,10 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex connect(_comboProjection, SIGNAL(currentIndexChanged(int)), this, SLOT(onProjectionChanged(int))); + connect(_checkBoxSpoutOutput, SIGNAL(stateChanged(int)), + this, SLOT(onSpoutSelection(int))); + connect(_checkBoxWebGui, SIGNAL(stateChanged(int)), + this, SLOT(onWebGuiSelection(int))); connect(_fullscreenButton, SIGNAL(released()), this, SLOT(onFullscreenClicked())); } @@ -106,7 +110,7 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutSize->addWidget(_size_y); _layoutSize->addStretch(1); _labelDelim->setText("x"); - _labelDelim->setFixedWidth(7); + _labelDelim->setFixedWidth(9); _layoutWindowCtrl->addLayout(_layoutSize); //Window offset @@ -123,7 +127,7 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutOffset->addWidget(_offset_y); _layoutOffset->addStretch(1); _labelComma->setText(","); - _labelComma->setFixedWidth(7); + _labelComma->setFixedWidth(9); _layoutWindowCtrl->addLayout(_layoutOffset); //Window options @@ -246,46 +250,94 @@ void WindowControl::onFullscreenClicked() { _size_y->setText(QString::number(_monitorResolution.height())); } +void WindowControl::enableGuiWindowSelection(bool enabled) { + _checkBoxWebGui->setEnabled(enabled); +} + +void WindowControl::onWebGuiSelection(int selectionState) { + if (_windowGuiCheckCallback && (selectionState == Qt::Checked)) { + _windowGuiCheckCallback(_monIndex, _index); + } +} + +void WindowControl::onSpoutSelection(int selectionState) { + if (selectionState == Qt::Checked) { + int currentProjectionSelection = _comboProjection->currentIndex(); + if ((currentProjectionSelection != ProjectionIndeces::Equirectangular) && + (currentProjectionSelection != ProjectionIndeces::Fisheye)) + { + _comboProjection->setCurrentIndex(ProjectionIndeces::Equirectangular); + } + enableSpoutProjectionOptions(_comboProjection, false); + } + else { + enableSpoutProjectionOptions(_comboProjection, true); + } +} + +void WindowControl::enableSpoutProjectionOptions(QComboBox* comboBox, bool enable) { + auto * comboModel = qobject_cast(comboBox->model()); + if (comboModel) { + enableProjectionOption(comboModel, ProjectionIndeces::Planar, enable); + enableProjectionOption(comboModel, ProjectionIndeces::Spherical_Mirror, enable); + enableProjectionOption(comboModel, ProjectionIndeces::Cylindrical, enable); + } +} + +template +void WindowControl::enableProjectionOption(T* comboModel, int selectionIndex, bool enable) +{ + auto* item = comboModel->item(selectionIndex); + if (item) { + item->setEnabled(enable); + } +} + void WindowControl::onProjectionChanged(int newSelection) { switch (newSelection) { - case 0: + case ProjectionIndeces::Planar: _comboQuality->setEnabled(false); _labelFov->setEnabled(true); _lineFov->setEnabled(true); _labelHeightOffset->setEnabled(false); _lineHeightOffset->setEnabled(false); + _checkBoxSpoutOutput->setEnabled(false); break; - case 1: + case ProjectionIndeces::Fisheye: _comboQuality->setEnabled(true); _labelFov->setEnabled(false); _lineFov->setEnabled(false); _labelHeightOffset->setEnabled(false); _lineHeightOffset->setEnabled(false); + _checkBoxSpoutOutput->setEnabled(true); break; - case 2: + case ProjectionIndeces::Spherical_Mirror: _comboQuality->setEnabled(true); _labelFov->setEnabled(false); _lineFov->setEnabled(false); _labelHeightOffset->setEnabled(false); _lineHeightOffset->setEnabled(false); + _checkBoxSpoutOutput->setEnabled(false); break; - case 3: + case ProjectionIndeces::Cylindrical: _comboQuality->setEnabled(true); _labelFov->setEnabled(false); _lineFov->setEnabled(false); _labelHeightOffset->setEnabled(true); _lineHeightOffset->setEnabled(true); + _checkBoxSpoutOutput->setEnabled(false); break; - case 4: + case ProjectionIndeces::Equirectangular: _comboQuality->setEnabled(true); _labelFov->setEnabled(false); _lineFov->setEnabled(false); _labelHeightOffset->setEnabled(false); _lineHeightOffset->setEnabled(false); + _checkBoxSpoutOutput->setEnabled(true); break; } } @@ -300,6 +352,16 @@ void WindowControl::setWindowChangeCallback( _windowChangeCallback = cb; } +void WindowControl::setWebGuiChangeCallback( + std::function cb) +{ + _windowGuiCheckCallback = cb; +} + +void WindowControl::uncheckWebGuiOption() { + _checkBoxWebGui->setCheckState(Qt::Unchecked); +} + QRectF& WindowControl::dimensions() { return _windowDims; } @@ -332,6 +394,52 @@ QCheckBox* WindowControl::checkBoxSpoutOutput() { return _checkBoxSpoutOutput; } +std::string WindowControl::windowName() { + return _windowName->text().toStdString(); +} + +sgct::ivec2 WindowControl::windowSize() { + return { + stoi(_size_x->text().toStdString()), + stoi(_size_y->text().toStdString()) + }; +} + +sgct::ivec2 WindowControl::windowPos() { + return { + stoi(_offset_x->text().toStdString()), + stoi(_offset_y->text().toStdString()) + }; +} + +bool WindowControl::isDecorated() { + return (_checkBoxWindowDecor->checkState() == Qt::Checked); +} + +bool WindowControl::isGuiWindow() { + return (_checkBoxWebGui->checkState() == Qt::Checked); +} + +bool WindowControl::isSpoutSelected() { + return (_checkBoxSpoutOutput->checkState() == Qt::Checked); +} + +int WindowControl::projectionSelectedIndex() { + return _comboProjection->currentIndex(); +} + +int WindowControl::qualitySelectedIndex() { + return _comboQuality->currentIndex(); +} + +float WindowControl::fov() { + return _lineFov->text().toFloat(); +} + +float WindowControl::heightOffset() { + return _lineHeightOffset->text().toFloat(); +} + WindowControl::~WindowControl() { delete _size_x; From ee7ca5b94c49558e797fec6bca2e90396358846b Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 9 Jan 2022 12:16:20 -0700 Subject: [PATCH 29/93] Sgct config changes pre-json output --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 7 +- .../launcher/include/sgctedit/filesupport.h | 24 +- .../ext/launcher/include/sgctedit/sgctedit.h | 11 +- .../ext/launcher/src/launcherwindow.cpp | 53 ++++- .../ext/launcher/src/sgctedit/filesupport.cpp | 207 +++++++++++++++++- .../ext/launcher/src/sgctedit/orientation.cpp | 3 +- .../ext/launcher/src/sgctedit/sgctedit.cpp | 82 +++---- apps/OpenSpace/ext/sgct | 2 +- 8 files changed, 327 insertions(+), 62 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index 0799196300..278f320f0a 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -131,7 +131,12 @@ endif() add_library(openspace-ui-launcher STATIC ${HEADER_FILES} ${SOURCE_FILES} ${MOC_FILES} ${RESOURCE_FILES}) set_openspace_compile_settings(openspace-ui-launcher) -target_include_directories(openspace-ui-launcher PUBLIC include) +target_include_directories( + openspace-ui-launcher + PUBLIC + include + ${OPENSPACE_APPS_DIR}/OpenSpace/ext/sgct/include +) target_link_libraries( openspace-ui-launcher PUBLIC diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index da6969c921..1025c59cd8 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -10,6 +10,9 @@ #include #include +#include +#include +#include class FileSupport : public QWidget @@ -17,16 +20,35 @@ class FileSupport : public QWidget Q_OBJECT public: - explicit FileSupport(QVBoxLayout* parentLayout); + explicit FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, + std::vector& displays, Orientation* orientation, + std::vector& windowList, sgct::config::Cluster& cluster, + std::function cb); ~FileSupport(); + bool isWindowFullscreen(sgct::ivec2 mDims, sgct::ivec2 wDims); + int findGuiWindow(); + void saveCluster(); + void saveWindows(); + void saveProjectionInformation(bool isSpoutSelected, int projectionIndex, + WindowControl* winControl, sgct::config::Viewport& viewport); + std::string saveFilename(); private slots: + void filenameEdited(const QString& newString); void cancel(); + void save(); private: QHBoxLayout* _layoutButtonBox = nullptr; QPushButton* _saveButton = nullptr; QPushButton* _cancelButton = nullptr; + Orientation* _orientationWidget; + std::vector& _displayWidgets; + std::vector& _monitors; + sgct::config::Cluster& _cluster; + std::vector& _windowList; + QLineEdit* _lineFilename = nullptr; + std::function _finishedCallback; }; #endif // FILE_SUPPORT_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index 1eb5d25981..68fe6ff528 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -27,15 +27,17 @@ class SgctEdit final : public QDialog { Q_OBJECT public: - SgctEdit(QWidget* parent, QApplication& qtApp); + SgctEdit(QWidget* parent, std::vector& windowList, + sgct::config::Cluster& cluster, QApplication& qtApp); ~SgctEdit(); void addDisplayLayout(unsigned int column, MonitorBox* monBox, QHBoxLayout* layout); void createWidgets(); - -private slots: + bool wasSaved() const; + std::string saveFilename(); private: void systemMonitorConfiguration(QApplication& qtApp); + MonitorBox* _monBox = nullptr; std::vector _monitorSizeList; std::vector _displayLayout = {nullptr, nullptr}; std::vector _displayFrame = {nullptr, nullptr}; @@ -44,6 +46,9 @@ private: FileSupport* _fileSupportWidget = nullptr; Orientation* _orientationWidget = nullptr; bool _showMonitorLabel = false; + sgct::config::Cluster& _cluster; + std::vector& _windowList; + bool _saveSelected = false; }; #endif // __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 36bafd2c7d..c417461e2b 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -140,6 +140,26 @@ namespace { ); } } + + void saveWindowConfig(QWidget* parent, const std::string& path, + std::vector& windowList, + sgct::config::Cluster& cluster) + { + std::ofstream outFile; + try { + outFile.open(path, std::ofstream::out); + //outFile << p.serialize(); + } + catch (const std::ofstream::failure& e) { + QMessageBox::critical( + parent, + "Exception", + QString::fromStdString(fmt::format( + "Error writing data to file: {} ({})", path, e.what() + )) + ); + } + } } // namespace using namespace openspace; @@ -292,16 +312,16 @@ QWidget* LauncherWindow::createCentralWidget() { newWindowButton->setGeometry(geometry::NewWindowButton); newWindowButton->setCursor(Qt::PointingHandCursor); - QPushButton* editWindowButton = new QPushButton("Edit", centralWidget); - connect( - editWindowButton, &QPushButton::released, - [this]() { - openWindowEditor(); - } - ); - editWindowButton->setObjectName("small"); - editWindowButton->setGeometry(geometry::EditWindowButton); - editWindowButton->setCursor(Qt::PointingHandCursor); + //QPushButton* editWindowButton = new QPushButton("Edit", centralWidget); + //connect( + // editWindowButton, &QPushButton::released, + // [this]() { + // openWindowEditor(); + // } + //); + //editWindowButton->setObjectName("small"); + //editWindowButton->setGeometry(geometry::EditWindowButton); + //editWindowButton->setCursor(Qt::PointingHandCursor); return centralWidget; } @@ -499,8 +519,19 @@ void LauncherWindow::openProfileEditor(const std::string& profile, const bool is } void LauncherWindow::openWindowEditor() { - SgctEdit editor(this, _qApp); + sgct::config::Cluster cluster; + std::vector windowList; + SgctEdit editor(this, windowList, cluster, _qApp); editor.exec(); + if (editor.wasSaved()) { + const std::string path = _userConfigPath + editor.saveFilename() + ".config"; + saveWindowConfig(this, path, windowList, cluster); + populateWindowConfigsList(editor.saveFilename()); + } + else { + const std::string current = _windowConfigBox->currentText().toStdString(); + populateWindowConfigsList(current); + } } bool LauncherWindow::wasLaunchSelected() const { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 6cdefc81fb..316109991b 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -1,7 +1,24 @@ #include "sgctedit/filesupport.h" -FileSupport::FileSupport(QVBoxLayout* parentLayout) +FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, + std::vector& displays, Orientation* orientation, + std::vector& windowList, + sgct::config::Cluster& cluster, std::function cb) + : _monitors(monitorList) + , _displayWidgets(displays) + , _orientationWidget(orientation) + , _cluster(cluster) + , _windowList(windowList) + , _finishedCallback(cb) { + QVBoxLayout* layoutFullVertical = new QVBoxLayout(); + QHBoxLayout* layoutFilename = new QHBoxLayout(); + _lineFilename = new QLineEdit(); + QLabel* labelFilename = new QLabel(); + labelFilename->setText("Filename: "); + layoutFilename->addWidget(labelFilename); + layoutFilename->addWidget(_lineFilename); + _layoutButtonBox = new QHBoxLayout; _saveButton = new QPushButton("Save"); _saveButton->setToolTip("Save global orientation changes"); @@ -13,18 +30,194 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout) //connect(_buttonCancel, &QPushButton::clicked, this, &ModulesDialog::listItemCancelSave); _layoutButtonBox->addWidget(_cancelButton); //_layoutButtonBox->setSizeConstraint(QLayout::SetFixedSize); - parentLayout->addLayout(_layoutButtonBox); - connect(_cancelButton, SIGNAL(released()), this, - SLOT(cancel())); + layoutFullVertical->addLayout(layoutFilename); + layoutFullVertical->addLayout(_layoutButtonBox); + parentLayout->addLayout(layoutFullVertical); + connect(_saveButton, SIGNAL(released()), this, SLOT(save())); + connect(_cancelButton, SIGNAL(released()), this, SLOT(cancel())); + connect(_lineFilename, SIGNAL(textEdited(const QString&)), this, + SLOT(filenameEdited(const QString&))); + _saveButton->setEnabled(false); + _cluster.masterAddress = "127.0.0.1"; +} + +void FileSupport::saveCluster() { + if (_orientationWidget) { + sgct::config::Scene initScene; + initScene.orientation = _orientationWidget->orientationValue(); + _cluster.scene = std::move(initScene); + _cluster.firmSync = _orientationWidget->vsyncValue(); + } +} + +bool FileSupport::isWindowFullscreen(sgct::ivec2 mDims, sgct::ivec2 wDims) { + return ((mDims.x == wDims.x) && (mDims.y == wDims.y)); +} + +int FileSupport::findGuiWindow() { + unsigned int windowIndex = 0; + for (unsigned int m = 0; m < _displayWidgets.size(); ++m) { + if (_displayWidgets[m]) { + for (unsigned int w = 0; w < _displayWidgets[m]->nWindows(); ++w) { + if (_displayWidgets[m]->windowControls()[w]->isGuiWindow()) { + return windowIndex; + } + windowIndex++; + } + } + } + return -1; +} + +void FileSupport::saveWindows() { + int webGuiWindowIndex = findGuiWindow(); + bool isOneOfWindowsSetAsWebGui = (webGuiWindowIndex >= 0); + + unsigned int windowIndex = 0; + for (unsigned int m = 0; m < _displayWidgets.size(); ++m) { + if (_displayWidgets[m]) { + for (unsigned int w = 0; w < _displayWidgets[m]->nWindows(); ++w) { + _windowList.push_back(sgct::config::Window()); + _windowList.back().viewports.push_back(sgct::config::Viewport()); + _windowList.back().viewports.back().isTracked = true; + _windowList.back().viewports.back().position = {0.0, 0.0}; + _windowList.back().viewports.back().size = {1.0, 1.0}; + int projectionIdx + = _displayWidgets[m]->windowControls()[w]->projectionSelectedIndex(); + bool isSpoutSelected + = _displayWidgets[m]->windowControls()[w]->isSpoutSelected(); + + saveProjectionInformation( + isSpoutSelected, + projectionIdx, + _displayWidgets[m]->windowControls()[w], + _windowList.back().viewports.back() + ); + _windowList.back().size + = _displayWidgets[m]->windowControls()[w]->windowSize(); + _windowList.back().pos + = _displayWidgets[m]->windowControls()[w]->windowPos(); + _windowList.back().isDecorated + = _displayWidgets[m]->windowControls()[w]->isDecorated(); + bool isFullScreen = isWindowFullscreen( + _displayWidgets[m]->monitorResolution(), + _displayWidgets[m]->windowControls()[w]->windowSize() + ); + if (isFullScreen) { + _windowList.back().isFullScreen = true; + } + if (isOneOfWindowsSetAsWebGui) { + if (windowIndex == webGuiWindowIndex) { + _windowList.back().draw3D = false; + _windowList.back().viewports.back().isTracked = false; + _windowList.back().tags.push_back("GUI"); + } + else { + _windowList.back().draw2D = false; + } + } + _windowList.back().id = windowIndex++; + } + } + } +} + +void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projectionIndex, + WindowControl* winControl, sgct::config::Viewport& viewport) +{ + if (isSpoutSelected) { + sgct::config::SpoutOutputProjection projection; + switch(projectionIndex) { + case WindowControl::ProjectionIndeces::Fisheye: + projection.mapping + = sgct::config::SpoutOutputProjection::Mapping::Fisheye; + break; + + case WindowControl::ProjectionIndeces::Equirectangular: + default: + projection.mapping + = sgct::config::SpoutOutputProjection::Mapping::Equirectangular; + break; + } + projection.quality = winControl->qualitySelectedIndex(); + projection.mappingSpoutName = "OpenSpace"; + viewport.projection = std::move(projection); + } + else { + switch(projectionIndex) { + case WindowControl::ProjectionIndeces::Fisheye: + { + sgct::config::FisheyeProjection projection; + projection.quality = winControl->qualitySelectedIndex(); + viewport.projection = std::move(projection); + } + break; + + case WindowControl::ProjectionIndeces::Spherical_Mirror: + { + sgct::config::SphericalMirrorProjection projection; + projection.quality = winControl->qualitySelectedIndex(); + viewport.projection = std::move(projection); + } + break; + + case WindowControl::ProjectionIndeces::Cylindrical: + { + sgct::config::CylindricalProjection projection; + projection.quality = winControl->qualitySelectedIndex(); + projection.heightOffset = winControl->heightOffset(); + viewport.projection = std::move(projection); + } + break; + + case WindowControl::ProjectionIndeces::Equirectangular: + { + sgct::config::EquirectangularProjection projection; + projection.quality = winControl->qualitySelectedIndex(); + viewport.projection = std::move(projection); + } + break; + + case WindowControl::ProjectionIndeces::Planar: + default: + { + sgct::config::PlanarProjection projection; + projection.fov.left = winControl->fov() / 2.0; + projection.fov.right = winControl->fov() / 2.0; + viewport.projection = std::move(projection); + } + break; + } + } +} + +void FileSupport::filenameEdited(const QString& newString) { + std::cout << "Edited callback." << std::endl; + if (newString.isEmpty()) { + _saveButton->setEnabled(false); + } + else { + _saveButton->setEnabled(true); + } +} + +std::string FileSupport::saveFilename() { + return _lineFilename->text().toStdString(); +} + +void FileSupport::save() { + _finishedCallback(true); } void FileSupport::cancel() { - exit(0); + _finishedCallback(false); } FileSupport::~FileSupport() { - delete _layoutButtonBox; delete _saveButton; - delete _cancelButton;} + delete _cancelButton; + delete _lineFilename; + delete _layoutButtonBox; +} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index d6b14a62cd..8dba671637 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -2,7 +2,8 @@ #include "sgctedit/orientation.h" #include "sgctedit/orientationdialog.h" -Orientation::Orientation() { +Orientation::Orientation() +{ _orientationDialog = new OrientationDialog(_orientationValue, this); _layoutOrientationFull = new QHBoxLayout(); _layoutOrientationControls = new QVBoxLayout(); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index cc05ecb83b..375b1375ea 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -6,8 +6,11 @@ namespace { }*/ -SgctEdit::SgctEdit(QWidget* parent, QApplication& qtApp) - : QDialog(parent) +SgctEdit::SgctEdit(QWidget* parent, std::vector& windowList, + sgct::config::Cluster& cluster, QApplication& qtApp) + : _cluster(cluster) + , _windowList(windowList) + , QDialog(parent) { setWindowTitle("Display/Window Editor"); systemMonitorConfiguration(qtApp); @@ -40,18 +43,9 @@ void SgctEdit::systemMonitorConfiguration(QApplication& qtApp) { } void SgctEdit::createWidgets() { -// QApplication app(argc, argv); -// QMainWindow win(nullptr); - -// QFrame* monitorBorderFrame = nullptr; - QVBoxLayout* layoutMainV = new QVBoxLayout(this); QHBoxLayout* layoutMainH = new QHBoxLayout; - _orientationWidget = new Orientation(); -// QWidget* mainWindow = new QWidget(); -// mainWindow->setLayout(layoutMainV); -// win.setCentralWidget(mainWindow); if (_monitorSizeList.size() > 1) { _monitorWidgetSize = QRect(0, 0, 600, 350); @@ -59,34 +53,47 @@ void SgctEdit::createWidgets() { } { - MonitorBox* monBox = new MonitorBox( + _monBox = new MonitorBox( _monitorWidgetSize, _monitorSizeList, _showMonitorLabel ); QHBoxLayout* layoutMonBox = new QHBoxLayout(); layoutMonBox->addStretch(1); - //_layout->addWidget(_monBox); - layoutMonBox->addWidget(monBox); + layoutMonBox->addWidget(_monBox); layoutMonBox->addStretch(1); layoutMainV->addLayout(layoutMonBox); - monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - monBox->setFixedSize(_monitorWidgetSize.width(), _monitorWidgetSize.height()); + _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + _monBox->setFixedSize(_monitorWidgetSize.width(), _monitorWidgetSize.height()); - addDisplayLayout(0, monBox, layoutMainH); + addDisplayLayout(0, _monBox, layoutMainH); if (_monitorSizeList.size() > 1) { - addDisplayLayout(1, monBox, layoutMainH); + addDisplayLayout(1, _monBox, layoutMainH); } } - //layoutMainH->setSizeConstraint(QLayout::SetFixedSize); - layoutMainV->addLayout(layoutMainH); - _orientationWidget->addButtonToLayout(layoutMainV); - _fileSupportWidget = new FileSupport(layoutMainV); + { + layoutMainV->addLayout(layoutMainH); + _orientationWidget->addButtonToLayout(layoutMainV); -// win.setWindowTitle("Window Details"); -// win.show(); -// app.exec(); + _fileSupportWidget = new FileSupport( + layoutMainV, + _monitorSizeList, + _displayWidget, + _orientationWidget, + _windowList, + _cluster, + [this](bool accepted) { + if (accepted) { + _saveSelected = true; + accept(); + } + else { + reject(); + } + } + ); + } } void SgctEdit::addDisplayLayout(unsigned int column, MonitorBox* monBox, @@ -112,20 +119,21 @@ void SgctEdit::addDisplayLayout(unsigned int column, MonitorBox* monBox, layout->addWidget(_displayFrame[column]); } +bool SgctEdit::wasSaved() const { + return _saveSelected; +} + +std::string SgctEdit::saveFilename() { + return _fileSupportWidget->saveFilename(); +} + SgctEdit::~SgctEdit() { delete _orientationWidget; delete _fileSupportWidget; -/* for (unsigned int i = 0; i <= 1; ++i) { - if (displayWidget[i]) delete displayWidget[i]; - if (displayLayout[i]) delete displayLayout[i]; - if (displayFrame[i]) delete displayFrame[i]; + for (unsigned int i = 0; i <= _monitorSizeList.size(); ++i) { + if (_displayWidget[i]) delete _displayWidget[i]; + if (_displayLayout[i]) delete _displayLayout[i]; + if (_displayFrame[i]) delete _displayFrame[i]; } - if (monitorBorderFrame) { - delete monitorBorderFrame; - } - delete monBox; - delete layoutMonBox; - delete layoutMainH; - delete layoutMainV; - delete mainWindow;*/ + delete _monBox; } diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index e784220636..b462de9f90 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit e78422063666ff09e68446863694cb6e0ad727b0 +Subproject commit b462de9f90ba537d282a1cbf7a693afed2d5fde4 From 1182c8f74c74823de002dd6a6b8218c356d40154 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 9 Jan 2022 21:07:56 -0700 Subject: [PATCH 30/93] Version working with json output of sgct configuration --- .../ext/launcher/src/launcherwindow.cpp | 5 +++-- .../ext/launcher/src/sgctedit/filesupport.cpp | 20 +++++++++++++++---- .../ext/launcher/src/sgctedit/sgctedit.cpp | 4 ---- apps/OpenSpace/ext/sgct | 2 +- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index c417461e2b..a201b29609 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -40,6 +40,7 @@ #include #include #include +#include using namespace openspace; @@ -148,7 +149,7 @@ namespace { std::ofstream outFile; try { outFile.open(path, std::ofstream::out); - //outFile << p.serialize(); + outFile << sgct::serializeWindowConfig(windowList, cluster); } catch (const std::ofstream::failure& e) { QMessageBox::critical( @@ -524,7 +525,7 @@ void LauncherWindow::openWindowEditor() { SgctEdit editor(this, windowList, cluster, _qApp); editor.exec(); if (editor.wasSaved()) { - const std::string path = _userConfigPath + editor.saveFilename() + ".config"; + const std::string path = _userConfigPath + editor.saveFilename() + ".json"; saveWindowConfig(this, path, windowList, cluster); populateWindowConfigsList(editor.saveFilename()); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 316109991b..8807950973 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -16,8 +16,10 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL _lineFilename = new QLineEdit(); QLabel* labelFilename = new QLabel(); labelFilename->setText("Filename: "); + layoutFilename->addStretch(1); layoutFilename->addWidget(labelFilename); layoutFilename->addWidget(_lineFilename); + layoutFilename->addStretch(1); _layoutButtonBox = new QHBoxLayout; _saveButton = new QPushButton("Save"); @@ -27,9 +29,7 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL _cancelButton = new QPushButton("Cancel"); _cancelButton->setToolTip("Cancel global orientation changes"); - //connect(_buttonCancel, &QPushButton::clicked, this, &ModulesDialog::listItemCancelSave); _layoutButtonBox->addWidget(_cancelButton); - //_layoutButtonBox->setSizeConstraint(QLayout::SetFixedSize); layoutFullVertical->addLayout(layoutFilename); layoutFullVertical->addLayout(_layoutButtonBox); parentLayout->addLayout(layoutFullVertical); @@ -108,14 +108,25 @@ void FileSupport::saveWindows() { } if (isOneOfWindowsSetAsWebGui) { if (windowIndex == webGuiWindowIndex) { + _windowList.back().draw2D = true; _windowList.back().draw3D = false; _windowList.back().viewports.back().isTracked = false; _windowList.back().tags.push_back("GUI"); } else { _windowList.back().draw2D = false; + _windowList.back().draw3D = true; } } + else { + _windowList.back().draw2D = true; + _windowList.back().draw3D = true; + _windowList.back().viewports.back().isTracked = true; + } + if (!_displayWidgets[m]->windowControls()[w]->windowName().empty()) { + _windowList.back().name + = _displayWidgets[m]->windowControls()[w]->windowName(); + } _windowList.back().id = windowIndex++; } } @@ -182,7 +193,7 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection default: { sgct::config::PlanarProjection projection; - projection.fov.left = winControl->fov() / 2.0; + projection.fov.left = -winControl->fov() / 2.0; projection.fov.right = winControl->fov() / 2.0; viewport.projection = std::move(projection); } @@ -192,7 +203,6 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection } void FileSupport::filenameEdited(const QString& newString) { - std::cout << "Edited callback." << std::endl; if (newString.isEmpty()) { _saveButton->setEnabled(false); } @@ -206,6 +216,8 @@ std::string FileSupport::saveFilename() { } void FileSupport::save() { + saveCluster(); + saveWindows(); _finishedCallback(true); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 375b1375ea..a016089b2f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -36,10 +36,6 @@ void SgctEdit::systemMonitorConfiguration(QApplication& qtApp) { actualHeight }); } - - //_monitorSizeList.clear(); - //_monitorSizeList.push_back({3440, 0, 1920, 1200}); - //_monitorSizeList.push_back({1080, 0, 1920, 1080}); } void SgctEdit::createWidgets() { diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index b462de9f90..6c7bf16b6f 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit b462de9f90ba537d282a1cbf7a693afed2d5fde4 +Subproject commit 6c7bf16b6fe0f6459da0e696421c42b7f5e22ea0 From fe6ec3b25efc584d8d00e335327b30cde6e4d27e Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 11 Jan 2022 19:13:12 -0700 Subject: [PATCH 31/93] Fix to prevent crashing when closing editor dialog --- apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp | 2 -- apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp | 1 - 2 files changed, 3 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index 8dba671637..58a5c608f0 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -42,7 +42,5 @@ Orientation::~Orientation() delete _orientationDialog; delete _orientationButton; delete _checkBoxVsync; - delete _layoutOrientationFull; delete _layoutOrientationControls; } - diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index a016089b2f..a9922d183e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -131,5 +131,4 @@ SgctEdit::~SgctEdit() { if (_displayLayout[i]) delete _displayLayout[i]; if (_displayFrame[i]) delete _displayFrame[i]; } - delete _monBox; } From a244379fd7962f144905a3b6eec770fa24495b36 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 11 Jan 2022 19:14:04 -0700 Subject: [PATCH 32/93] Minor formatting for text entry --- apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp | 1 + apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 8807950973..ad9f3bb958 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -14,6 +14,7 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL QVBoxLayout* layoutFullVertical = new QVBoxLayout(); QHBoxLayout* layoutFilename = new QHBoxLayout(); _lineFilename = new QLineEdit(); + _lineFilename->setFixedWidth(190); QLabel* labelFilename = new QLabel(); labelFilename->setText("Filename: "); layoutFilename->addStretch(1); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 891ccd8437..9d620c51f4 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -90,9 +90,9 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutName = new QHBoxLayout(); _labelName = new QLabel(this); - _labelName->setText("Window Name: "); + _labelName->setText("Name: "); _windowName = new QLineEdit(this); - _windowName->setFixedWidth(100); + _windowName->setFixedWidth(160); _layoutName->addWidget(_labelName); _layoutName->addWidget(_windowName); _layoutName->addStretch(1); From faff578b5f3034b57b914ff54cb5d7d5f2babea1 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 11 Jan 2022 19:27:05 -0700 Subject: [PATCH 33/93] Prevent unhandled exception if only a '-' character entered for offset --- .../launcher/src/sgctedit/windowcontrol.cpp | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 9d620c51f4..0f31af0d37 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -222,24 +222,37 @@ void WindowControl::onSizeYChanged(const QString& newText) { void WindowControl::onOffsetXChanged(const QString& newText) { std::string xOffset = newText.toStdString(); float prevWidth = _windowDims.width(); - if (!xOffset.empty()) { - _windowDims.setX(std::stoi(xOffset)); - _windowDims.setWidth(prevWidth); + try { + if (!xOffset.empty()) { + _windowDims.setX(std::stoi(xOffset)); + _windowDims.setWidth(prevWidth); + } + if (_windowChangeCallback) { + _windowChangeCallback(_monIndex, _index, _windowDims); + } } - if (_windowChangeCallback) { - _windowChangeCallback(_monIndex, _index, _windowDims); + catch (...) { + //The QIntValidator ensures that the range is a +/- integer + //However, it's possible to enter only a - character which + //causes an exception throw, which is ignored here (when user + //enters an integer after the - then the value will be updated). } } void WindowControl::onOffsetYChanged(const QString& newText) { std::string yOffset = newText.toStdString(); float prevHeight = _windowDims.height(); - if (!yOffset.empty()) { - _windowDims.setY(std::stoi(yOffset)); - _windowDims.setHeight(prevHeight); + try { + if (!yOffset.empty()) { + _windowDims.setY(std::stoi(yOffset)); + _windowDims.setHeight(prevHeight); + } + if (_windowChangeCallback) { + _windowChangeCallback(_monIndex, _index, _windowDims); + } } - if (_windowChangeCallback) { - _windowChangeCallback(_monIndex, _index, _windowDims); + catch (...) { + //See comment in onOffsetXChanged } } From d8ed9e53dbf5f7c65f95f723892555f64040d408 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 11 Jan 2022 19:53:52 -0700 Subject: [PATCH 34/93] Set window config selection list to accept xml or json files --- apps/OpenSpace/ext/launcher/src/launcherwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index a201b29609..59c9f0e56f 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -443,9 +443,9 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { const QStandardItemModel* model = qobject_cast(_windowConfigBox->model()); model->item(_userConfigCount)->setEnabled(false); ++_userConfigCount; - // Add all the files with the .xml extension to the dropdown + // Add all the files with the .xml or .json extension to the dropdown for (const fs::directory_entry& p : fs::directory_iterator(_userConfigPath)) { - if (p.path().extension() != ".xml") { + if (p.path().extension() != ".xml" && p.path().extension() != ".json") { continue; } _windowConfigBox->addItem(QString::fromStdString(p.path().stem().string())); @@ -456,9 +456,9 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { model->item(_userConfigCount)->setEnabled(false); if (std::filesystem::exists(_configPath)) { - // Add all the files with the .xml extension to the dropdown + // Add all the files with the .xml or .json extension to the dropdown for (const fs::directory_entry& p : fs::directory_iterator(_configPath)) { - if (p.path().extension() != ".xml") { + if (p.path().extension() != ".xml" && p.path().extension() != ".json") { continue; } _windowConfigBox->addItem(QString::fromStdString(p.path().stem().string())); From 8d4e2bc846790e02fad5e370610ceee4e6f288d7 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 11 Jan 2022 20:46:28 -0700 Subject: [PATCH 35/93] Grouped projection-type-specific controls within a border frame --- .../launcher/include/sgctedit/windowcontrol.h | 2 ++ .../launcher/src/sgctedit/windowcontrol.cpp | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index c19f6698d1..ff77e681e4 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -158,6 +158,8 @@ private: QLabel* _labelComma = nullptr; QHBoxLayout* _layoutCheckboxesFull1 = nullptr; QVBoxLayout* _layoutCheckboxesFull2 = nullptr; + QVBoxLayout* _layoutProjectionGroup = nullptr; + QFrame* _borderProjectionGroup = nullptr; QHBoxLayout* _layoutFullscreenButton = nullptr; QHBoxLayout* _layoutCBoxWindowDecor = nullptr; QHBoxLayout* _layoutCBoxWebGui = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 0f31af0d37..67b745db43 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -145,18 +145,23 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutCBoxWebGui->addWidget(_checkBoxWebGui); _layoutCBoxWebGui->addStretch(1); _layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); - _layoutCBoxSpoutOutput= new QHBoxLayout(); - _layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); - _layoutCBoxSpoutOutput->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutCBoxSpoutOutput); + _layoutProjectionGroup = new QVBoxLayout(); _layoutComboProjection = new QHBoxLayout(); _layoutComboProjection->addWidget(_comboProjection); _layoutComboProjection->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutComboProjection); + _layoutProjectionGroup->addLayout(_layoutComboProjection); + _borderProjectionGroup = new QFrame; + _borderProjectionGroup->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + _borderProjectionGroup->setLayout(_layoutProjectionGroup); + _borderProjectionGroup->setVisible(true); + _layoutCBoxSpoutOutput= new QHBoxLayout(); + _layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); + _layoutCBoxSpoutOutput->addStretch(1); + _layoutProjectionGroup->addLayout(_layoutCBoxSpoutOutput); _layoutComboQuality = new QHBoxLayout(); _layoutComboQuality->addWidget(_comboQuality); _layoutComboQuality->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutComboQuality); + _layoutProjectionGroup->addLayout(_layoutComboQuality); _layoutFov = new QHBoxLayout(); _labelFov = new QLabel(); _labelFov->setText("Horizontal FOV:"); @@ -165,7 +170,7 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutFov->addStretch(1); _layoutFovWrapper = new QWidget(); _layoutFovWrapper->setLayout(_layoutFov); - _layoutCheckboxesFull2->addWidget(_layoutFovWrapper); + _layoutProjectionGroup->addWidget(_layoutFovWrapper); _layoutHeightOffset = new QHBoxLayout(); _labelHeightOffset = new QLabel(); _labelHeightOffset->setText("Height Offset:"); @@ -174,7 +179,8 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutHeightOffset->addStretch(1); _layoutHeightOffsetWrapper = new QWidget(); _layoutHeightOffsetWrapper->setLayout(_layoutHeightOffset); - _layoutCheckboxesFull2->addWidget(_layoutHeightOffsetWrapper); + _layoutProjectionGroup->addWidget(_layoutHeightOffsetWrapper); + _layoutCheckboxesFull2->addWidget(_borderProjectionGroup); _layoutCheckboxesFull1->addLayout(_layoutCheckboxesFull2); _layoutCheckboxesFull1->addStretch(1); _layoutWindowCtrl->addLayout(_layoutCheckboxesFull1); @@ -495,6 +501,8 @@ WindowControl::~WindowControl() delete _layoutFovWrapper; delete _layoutHeightOffset; delete _layoutHeightOffsetWrapper; + delete _layoutProjectionGroup; + delete _borderProjectionGroup; delete _layoutCheckboxesFull2; delete _layoutCheckboxesFull1; delete _layoutWinNum; From 68119d64693b27105d404ceb47d85dd30d0724a4 Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 13 Jan 2022 19:30:16 -0700 Subject: [PATCH 36/93] Changes from GUI group feedback, and launcher supporting both xml & json --- apps/OpenSpace/ext/launcher/src/launcherwindow.cpp | 4 ++-- .../ext/launcher/src/sgctedit/filesupport.cpp | 4 ++-- .../ext/launcher/src/sgctedit/windowcontrol.cpp | 1 + apps/OpenSpace/ext/sgct | 2 +- apps/OpenSpace/main.cpp | 12 ++++++------ 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 59c9f0e56f..671c67cb45 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -448,7 +448,7 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { if (p.path().extension() != ".xml" && p.path().extension() != ".json") { continue; } - _windowConfigBox->addItem(QString::fromStdString(p.path().stem().string())); + _windowConfigBox->addItem(QString::fromStdString(p.path().filename().string())); ++_userConfigCount; } _windowConfigBox->addItem(QString::fromStdString("--- OpenSpace Configurations ---")); @@ -461,7 +461,7 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { if (p.path().extension() != ".xml" && p.path().extension() != ".json") { continue; } - _windowConfigBox->addItem(QString::fromStdString(p.path().stem().string())); + _windowConfigBox->addItem(QString::fromStdString(p.path().filename().string())); } } else { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index ad9f3bb958..3174b3235c 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -194,8 +194,8 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection default: { sgct::config::PlanarProjection projection; - projection.fov.left = -winControl->fov() / 2.0; - projection.fov.right = winControl->fov() / 2.0; + projection.fov.left = winControl->fov() / 2.0; + projection.fov.right = projection.fov.left; viewport.projection = std::move(projection); } break; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 67b745db43..7ae5b7635c 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -34,6 +34,7 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex _fullscreenButton = new QPushButton(this); _fullscreenButton->setText("Set to Fullscreen"); _checkBoxWindowDecor = new QCheckBox("Window Decoration", this); + _checkBoxWindowDecor->setChecked(Qt::CheckState::Checked); _checkBoxWebGui = new QCheckBox("WebGUI only this window", this); _checkBoxSpoutOutput = new QCheckBox("Spout Output", this); _comboProjection = new QComboBox(this); diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 6c7bf16b6f..ee93d3e894 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 6c7bf16b6fe0f6459da0e696421c42b7f5e22ea0 +Subproject commit ee93d3e894e515b33f0df1c55efb706f3433c0cf diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index a0bd783d19..234168f2a9 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -990,6 +990,7 @@ std::string setWindowConfigPresetForGui(const std::string labelFromCfgFile, std::string selectedSgctProfileFromLauncher(LauncherWindow& lw, bool hasCliSGCTConfig, std::string windowConfiguration, const std::string& labelFromCfgFile, + const std::string& jsonExt, const std::string& xmlExt) { std::string config = windowConfiguration; @@ -1004,13 +1005,10 @@ std::string selectedSgctProfileFromLauncher(LauncherWindow& lw, bool hasCliSGCTC } } else { - if (std::filesystem::path(config).extension() == ".xml") { - //user customzied sgct config + std::string foundExtension = std::filesystem::path(config).extension().string(); + if (foundExtension != jsonExt && foundExtension != xmlExt) { + config += jsonExt; } - else { - config += xmlExt; - } - } global::configuration->windowConfiguration = config; } @@ -1163,6 +1161,7 @@ int main(int argc, char* argv[]) { // Call profile GUI const std::string labelFromCfgFile = " (from .cfg)"; + const std::string jsonExt = ".json"; const std::string xmlExt = ".xml"; std::string windowCfgPreset = setWindowConfigPresetForGui( labelFromCfgFile, @@ -1213,6 +1212,7 @@ int main(int argc, char* argv[]) { hasSGCTConfig, windowConfiguration, labelFromCfgFile, + jsonExt, xmlExt ); } else { From f6f18857adffb30b3be2fc1878292c0c04e46968 Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 14 Jan 2022 10:20:01 -0700 Subject: [PATCH 37/93] Added vertical FOV for PlanarProjection --- .../launcher/include/sgctedit/windowcontrol.h | 18 ++-- .../ext/launcher/src/sgctedit/filesupport.cpp | 4 +- .../launcher/src/sgctedit/windowcontrol.cpp | 89 +++++++++++++------ 3 files changed, 75 insertions(+), 36 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index ff77e681e4..a89e2e9401 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -53,7 +53,8 @@ public: void uncheckWebGuiOption(); int projectionSelectedIndex(); int qualitySelectedIndex(); - float fov(); + float fovH(); + float fovV(); float heightOffset(); enum ProjectionIndeces : unsigned int { Planar = 0, @@ -139,9 +140,12 @@ private: QComboBox* _comboProjection = nullptr; QComboBox* _comboQuality = nullptr; - QLabel* _labelFov = nullptr; - QLineEdit* _lineFov = nullptr; - QDoubleValidator* _validatorFov = nullptr; + QLabel* _labelFovH = nullptr; + QLineEdit* _lineFovH = nullptr; + QDoubleValidator* _validatorFovH = nullptr; + QLabel* _labelFovV = nullptr; + QLineEdit* _lineFovV = nullptr; + QDoubleValidator* _validatorFovV = nullptr; QLabel* _labelHeightOffset = nullptr; QLineEdit* _lineHeightOffset = nullptr; QDoubleValidator* _validatorHeightOffset = nullptr; @@ -166,8 +170,10 @@ private: QHBoxLayout* _layoutCBoxSpoutOutput = nullptr; QHBoxLayout* _layoutComboProjection = nullptr; QHBoxLayout* _layoutComboQuality = nullptr; - QHBoxLayout* _layoutFov = nullptr; - QWidget* _layoutFovWrapper = nullptr; + QHBoxLayout* _layoutFovH = nullptr; + QHBoxLayout* _layoutFovV = nullptr; + QWidget* _layoutFovWrapperH = nullptr; + QWidget* _layoutFovWrapperV = nullptr; QHBoxLayout* _layoutHeightOffset = nullptr; QWidget* _layoutHeightOffsetWrapper = nullptr; }; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 3174b3235c..32010e82dc 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -194,8 +194,10 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection default: { sgct::config::PlanarProjection projection; - projection.fov.left = winControl->fov() / 2.0; + projection.fov.left = winControl->fovH() / 2.0; projection.fov.right = projection.fov.left; + projection.fov.down = winControl->fovV() / 2.0; + projection.fov.up = projection.fov.down; viewport.projection = std::move(projection); } break; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 7ae5b7635c..912f92b413 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -43,9 +43,12 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex _comboQuality = new QComboBox(this); _comboQuality->addItems(_qualityTypes); - _lineFov = new QLineEdit("0.0", parent); - _validatorFov = new QDoubleValidator(-180.0, 180.0, 10); - _lineFov->setValidator(_validatorFov); + _lineFovH = new QLineEdit("80.0", parent); + _validatorFovH = new QDoubleValidator(-180.0, 180.0, 10); + _lineFovH->setValidator(_validatorFovH); + _lineFovV = new QLineEdit("50.534", parent); + _validatorFovV = new QDoubleValidator(-90.0, 90.0, 10); + _lineFovV->setValidator(_validatorFovV); _lineHeightOffset = new QLineEdit("0.0", parent); _validatorHeightOffset = new QDoubleValidator(-1000000.0, 1000000.0, 12); _lineHeightOffset->setValidator(_validatorHeightOffset); @@ -163,15 +166,24 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutComboQuality->addWidget(_comboQuality); _layoutComboQuality->addStretch(1); _layoutProjectionGroup->addLayout(_layoutComboQuality); - _layoutFov = new QHBoxLayout(); - _labelFov = new QLabel(); - _labelFov->setText("Horizontal FOV:"); - _layoutFov->addWidget(_labelFov); - _layoutFov->addWidget(_lineFov); - _layoutFov->addStretch(1); - _layoutFovWrapper = new QWidget(); - _layoutFovWrapper->setLayout(_layoutFov); - _layoutProjectionGroup->addWidget(_layoutFovWrapper); + _layoutFovH = new QHBoxLayout(); + _labelFovH = new QLabel(); + _labelFovH->setText("Horizontal FOV:"); + _layoutFovH->addWidget(_labelFovH); + _layoutFovH->addWidget(_lineFovH); + _layoutFovH->addStretch(1); + _layoutFovV = new QHBoxLayout(); + _labelFovV = new QLabel(); + _labelFovV->setText("Vertical FOV:"); + _layoutFovV->addWidget(_labelFovV); + _layoutFovV->addWidget(_lineFovV); + _layoutFovV->addStretch(1); + _layoutFovWrapperH = new QWidget(); + _layoutFovWrapperH->setLayout(_layoutFovH); + _layoutFovWrapperV = new QWidget(); + _layoutFovWrapperV->setLayout(_layoutFovV); + _layoutProjectionGroup->addWidget(_layoutFovWrapperH); + _layoutProjectionGroup->addWidget(_layoutFovWrapperV); _layoutHeightOffset = new QHBoxLayout(); _labelHeightOffset = new QLabel(); _labelHeightOffset->setText("Height Offset:"); @@ -317,8 +329,10 @@ void WindowControl::onProjectionChanged(int newSelection) { switch (newSelection) { case ProjectionIndeces::Planar: _comboQuality->setEnabled(false); - _labelFov->setEnabled(true); - _lineFov->setEnabled(true); + _labelFovH->setEnabled(true); + _lineFovH->setEnabled(true); + _labelFovV->setEnabled(true); + _lineFovV->setEnabled(true); _labelHeightOffset->setEnabled(false); _lineHeightOffset->setEnabled(false); _checkBoxSpoutOutput->setEnabled(false); @@ -326,8 +340,10 @@ void WindowControl::onProjectionChanged(int newSelection) { case ProjectionIndeces::Fisheye: _comboQuality->setEnabled(true); - _labelFov->setEnabled(false); - _lineFov->setEnabled(false); + _labelFovH->setEnabled(false); + _lineFovH->setEnabled(false); + _labelFovV->setEnabled(false); + _lineFovV->setEnabled(false); _labelHeightOffset->setEnabled(false); _lineHeightOffset->setEnabled(false); _checkBoxSpoutOutput->setEnabled(true); @@ -335,8 +351,10 @@ void WindowControl::onProjectionChanged(int newSelection) { case ProjectionIndeces::Spherical_Mirror: _comboQuality->setEnabled(true); - _labelFov->setEnabled(false); - _lineFov->setEnabled(false); + _labelFovH->setEnabled(false); + _lineFovH->setEnabled(false); + _labelFovV->setEnabled(false); + _lineFovV->setEnabled(false); _labelHeightOffset->setEnabled(false); _lineHeightOffset->setEnabled(false); _checkBoxSpoutOutput->setEnabled(false); @@ -344,8 +362,10 @@ void WindowControl::onProjectionChanged(int newSelection) { case ProjectionIndeces::Cylindrical: _comboQuality->setEnabled(true); - _labelFov->setEnabled(false); - _lineFov->setEnabled(false); + _labelFovH->setEnabled(false); + _lineFovH->setEnabled(false); + _labelFovV->setEnabled(false); + _lineFovV->setEnabled(false); _labelHeightOffset->setEnabled(true); _lineHeightOffset->setEnabled(true); _checkBoxSpoutOutput->setEnabled(false); @@ -353,8 +373,10 @@ void WindowControl::onProjectionChanged(int newSelection) { case ProjectionIndeces::Equirectangular: _comboQuality->setEnabled(true); - _labelFov->setEnabled(false); - _lineFov->setEnabled(false); + _labelFovH->setEnabled(false); + _lineFovH->setEnabled(false); + _labelFovV->setEnabled(false); + _lineFovV->setEnabled(false); _labelHeightOffset->setEnabled(false); _lineHeightOffset->setEnabled(false); _checkBoxSpoutOutput->setEnabled(true); @@ -452,8 +474,12 @@ int WindowControl::qualitySelectedIndex() { return _comboQuality->currentIndex(); } -float WindowControl::fov() { - return _lineFov->text().toFloat(); +float WindowControl::fovH() { + return _lineFovH->text().toFloat(); +} + +float WindowControl::fovV() { + return _lineFovV->text().toFloat(); } float WindowControl::heightOffset() { @@ -486,9 +512,12 @@ WindowControl::~WindowControl() delete _comboProjection; delete _comboQuality; delete _fullscreenButton; - delete _labelFov; - delete _lineFov; - delete _validatorFov; + delete _labelFovH; + delete _lineFovH; + delete _validatorFovH; + delete _labelFovV; + delete _lineFovV; + delete _validatorFovV; delete _labelHeightOffset; delete _lineHeightOffset; delete _validatorHeightOffset; @@ -498,8 +527,10 @@ WindowControl::~WindowControl() delete _layoutCBoxSpoutOutput; delete _layoutComboProjection; delete _layoutComboQuality; - delete _layoutFov; - delete _layoutFovWrapper; + delete _layoutFovH; + delete _layoutFovV; + delete _layoutFovWrapperH; + delete _layoutFovWrapperV; delete _layoutHeightOffset; delete _layoutHeightOffsetWrapper; delete _layoutProjectionGroup; From e331c3b14102ee1ee7db4c3c5dd43b709054d918 Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 14 Jan 2022 12:12:24 -0700 Subject: [PATCH 38/93] Update window config selection combobox with most recent saved config --- apps/OpenSpace/ext/launcher/src/launcherwindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 671c67cb45..99262b23e7 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -525,9 +525,10 @@ void LauncherWindow::openWindowEditor() { SgctEdit editor(this, windowList, cluster, _qApp); editor.exec(); if (editor.wasSaved()) { - const std::string path = _userConfigPath + editor.saveFilename() + ".json"; + std::string fullFilename = editor.saveFilename() + ".json"; + const std::string path = _userConfigPath + fullFilename; saveWindowConfig(this, path, windowList, cluster); - populateWindowConfigsList(editor.saveFilename()); + populateWindowConfigsList(fullFilename); } else { const std::string current = _windowConfigBox->currentText().toStdString(); From ca7dd2028f8558f9e91b750af08c11ccaef58f7a Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 14 Jan 2022 12:16:41 -0700 Subject: [PATCH 39/93] Improved layout for optional params based on projection type --- .../ext/launcher/include/sgctedit/windowcontrol.h | 3 --- .../ext/launcher/src/sgctedit/windowcontrol.cpp | 15 +++------------ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index a89e2e9401..520f9d79c6 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -172,10 +172,7 @@ private: QHBoxLayout* _layoutComboQuality = nullptr; QHBoxLayout* _layoutFovH = nullptr; QHBoxLayout* _layoutFovV = nullptr; - QWidget* _layoutFovWrapperH = nullptr; - QWidget* _layoutFovWrapperV = nullptr; QHBoxLayout* _layoutHeightOffset = nullptr; - QWidget* _layoutHeightOffsetWrapper = nullptr; }; #endif // WINDOWCONTROL_H diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 912f92b413..d5990092b0 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -178,21 +178,15 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutFovV->addWidget(_labelFovV); _layoutFovV->addWidget(_lineFovV); _layoutFovV->addStretch(1); - _layoutFovWrapperH = new QWidget(); - _layoutFovWrapperH->setLayout(_layoutFovH); - _layoutFovWrapperV = new QWidget(); - _layoutFovWrapperV->setLayout(_layoutFovV); - _layoutProjectionGroup->addWidget(_layoutFovWrapperH); - _layoutProjectionGroup->addWidget(_layoutFovWrapperV); + _layoutProjectionGroup->addLayout(_layoutFovH); + _layoutProjectionGroup->addLayout(_layoutFovV); _layoutHeightOffset = new QHBoxLayout(); _labelHeightOffset = new QLabel(); _labelHeightOffset->setText("Height Offset:"); _layoutHeightOffset->addWidget(_labelHeightOffset); _layoutHeightOffset->addWidget(_lineHeightOffset); _layoutHeightOffset->addStretch(1); - _layoutHeightOffsetWrapper = new QWidget(); - _layoutHeightOffsetWrapper->setLayout(_layoutHeightOffset); - _layoutProjectionGroup->addWidget(_layoutHeightOffsetWrapper); + _layoutProjectionGroup->addLayout(_layoutHeightOffset); _layoutCheckboxesFull2->addWidget(_borderProjectionGroup); _layoutCheckboxesFull1->addLayout(_layoutCheckboxesFull2); _layoutCheckboxesFull1->addStretch(1); @@ -529,10 +523,7 @@ WindowControl::~WindowControl() delete _layoutComboQuality; delete _layoutFovH; delete _layoutFovV; - delete _layoutFovWrapperH; - delete _layoutFovWrapperV; delete _layoutHeightOffset; - delete _layoutHeightOffsetWrapper; delete _layoutProjectionGroup; delete _borderProjectionGroup; delete _layoutCheckboxesFull2; From 07a291a38878ef831c381dda2dbb2c65cb1839a7 Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 14 Jan 2022 12:17:33 -0700 Subject: [PATCH 40/93] Projection quality value saved as pixel count rather than list index --- .../ext/launcher/include/sgctedit/windowcontrol.h | 3 +++ .../ext/launcher/src/sgctedit/filesupport.cpp | 10 +++++----- .../ext/launcher/src/sgctedit/windowcontrol.cpp | 4 ++++ apps/OpenSpace/ext/sgct | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 520f9d79c6..b136807862 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -53,6 +53,7 @@ public: void uncheckWebGuiOption(); int projectionSelectedIndex(); int qualitySelectedIndex(); + int qualitySelectedValue(); float fovH(); float fovV(); float heightOffset(); @@ -68,6 +69,8 @@ public: std::string QualityTypeNames[10] = {"Low (256)", "Medium (512)", "High (1K)", "1.5K (1536)", "2K (2048)", "4K (4096)", "8K (8192)", "16K (16384)", "32K (32768)", "64K (65536)"}; + int QualityValues[10] = {256, 512, 1024, 1536, 2048, 4096, 8192, 16384, + 32768, 65536}; private slots: void onSizeXChanged(const QString& newText); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 32010e82dc..7976490d78 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -151,7 +151,7 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection = sgct::config::SpoutOutputProjection::Mapping::Equirectangular; break; } - projection.quality = winControl->qualitySelectedIndex(); + projection.quality = winControl->qualitySelectedValue(); projection.mappingSpoutName = "OpenSpace"; viewport.projection = std::move(projection); } @@ -160,7 +160,7 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection case WindowControl::ProjectionIndeces::Fisheye: { sgct::config::FisheyeProjection projection; - projection.quality = winControl->qualitySelectedIndex(); + projection.quality = winControl->qualitySelectedValue(); viewport.projection = std::move(projection); } break; @@ -168,7 +168,7 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection case WindowControl::ProjectionIndeces::Spherical_Mirror: { sgct::config::SphericalMirrorProjection projection; - projection.quality = winControl->qualitySelectedIndex(); + projection.quality = winControl->qualitySelectedValue(); viewport.projection = std::move(projection); } break; @@ -176,7 +176,7 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection case WindowControl::ProjectionIndeces::Cylindrical: { sgct::config::CylindricalProjection projection; - projection.quality = winControl->qualitySelectedIndex(); + projection.quality = winControl->qualitySelectedValue(); projection.heightOffset = winControl->heightOffset(); viewport.projection = std::move(projection); } @@ -185,7 +185,7 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection case WindowControl::ProjectionIndeces::Equirectangular: { sgct::config::EquirectangularProjection projection; - projection.quality = winControl->qualitySelectedIndex(); + projection.quality = winControl->qualitySelectedValue(); viewport.projection = std::move(projection); } break; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index d5990092b0..29e044feab 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -468,6 +468,10 @@ int WindowControl::qualitySelectedIndex() { return _comboQuality->currentIndex(); } +int WindowControl::qualitySelectedValue() { + return QualityValues[_comboQuality->currentIndex()]; +} + float WindowControl::fovH() { return _lineFovH->text().toFloat(); } diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index ee93d3e894..bdab900632 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit ee93d3e894e515b33f0df1c55efb706f3433c0cf +Subproject commit bdab9006323747a6af7e0c1f407810c51e72db80 From 5e9a8f737c1594dd628f3a460fe55803ac11be90 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 18 Jan 2022 20:48:03 -0700 Subject: [PATCH 41/93] Added transparent fill to windows --- .../ext/launcher/include/sgctedit/monitorbox.h | 8 +++++++- .../ext/launcher/src/sgctedit/monitorbox.cpp | 16 ++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 21e1456105..3aa305b2af 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -1,6 +1,7 @@ #ifndef MONITORBOX_H #define MONITORBOX_H +#include #include #include #include @@ -38,7 +39,7 @@ protected: private: void paintWidgetBorder(QPainter& painter, int width, int height); void paintMonitorOutlines(QPainter& painter); - void paintWindowOutline(QPainter& painter, unsigned int monIdx, unsigned int winIdx); + void paintWindow(QPainter& painter, unsigned int monIdx, unsigned int winIdx); void paintOutOfBoundsAreas(QPainter& painter, unsigned int monIdx,unsigned int winIdx); void paintWindowNumber(QPainter& painter, unsigned int monIdx, unsigned int winIdx); void setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, @@ -70,6 +71,11 @@ private: {{0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}} }; + QColor _colorWindow[2] = { + {0x1C, 0x1B, 0x8B}, + {0xCD, 0x6D, 0x1D} + }; + int _alphaWindowTransparency = 111; float _monitorScaleFactor = 1.0; float _offset[2] = {10.0, 10.0}; bool _showLabel = false; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index b8dd9fdf6c..1a08ae2f60 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -28,7 +28,7 @@ void MonitorBox::paintEvent(QPaintEvent *event) //Draw window outline(s) for (unsigned int i = 0; i < _nMonitors ; ++i) { for (unsigned int j = 0; j < _nWindows[i]; ++j) { - paintWindowOutline(painter, i, j); + paintWindow(painter, i, j); } } } @@ -53,12 +53,17 @@ void MonitorBox::paintMonitorOutlines(QPainter& painter) { } } -void MonitorBox::paintWindowOutline(QPainter& painter, unsigned int monIdx, +void MonitorBox::paintWindow(QPainter& painter, unsigned int monIdx, unsigned int winIdx) { setPenSpecificToWindow(painter, winIdx, true); if (winIdx <= _windowRendering[monIdx].size()) { painter.drawRect(_windowRendering[monIdx][winIdx]); + QColor fillColor = _colorWindow[winIdx]; + fillColor.setAlpha(_alphaWindowTransparency); + QBrush brush(fillColor); + brush.setStyle(Qt::SolidPattern); + painter.fillRect(_windowRendering[monIdx][winIdx], brush); //Draw areas of window that are past the monitor boundaries if (_outOfBoundsRect[monIdx][winIdx].size() > 0) { paintOutOfBoundsAreas(painter, monIdx, winIdx); @@ -95,12 +100,7 @@ void MonitorBox::setPenSpecificToWindow(QPainter& painter, unsigned int windowId bool visibleBorder) { int penWidth = (visibleBorder) ? 1 : -1; - if (windowIdx == 0) { - painter.setPen(QPen(QColor(0x1C, 0x1B, 0x8B), penWidth)); - } - else if (windowIdx == 1) { - painter.setPen(QPen(QColor(0xCD, 0x6D, 0x1D), penWidth)); - } + painter.setPen(QPen(_colorWindow[windowIdx], penWidth)); } void MonitorBox::windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, From 663347fe8565c06f4f07f57b4d141609f1e386e4 Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 19 Jan 2022 23:39:12 -0700 Subject: [PATCH 42/93] Switched to each window having a monitor selection option --- .../ext/launcher/include/sgctedit/display.h | 20 +-- .../launcher/include/sgctedit/filesupport.h | 6 +- .../launcher/include/sgctedit/monitorbox.h | 49 +++--- .../ext/launcher/include/sgctedit/sgctedit.h | 16 +- .../launcher/include/sgctedit/windowcontrol.h | 24 ++- .../ext/launcher/src/sgctedit/display.cpp | 154 ++++++++---------- .../ext/launcher/src/sgctedit/filesupport.cpp | 121 +++++++------- .../ext/launcher/src/sgctedit/monitorbox.cpp | 123 +++++++------- .../ext/launcher/src/sgctedit/sgctedit.cpp | 44 +++-- .../launcher/src/sgctedit/windowcontrol.cpp | 53 ++++-- 10 files changed, 306 insertions(+), 304 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 5ba0a9ac3c..91ec541803 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -24,16 +24,14 @@ class Display : public QWidget { - Q_OBJECT - +Q_OBJECT public: - explicit Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, - std::vector& monitorSizeList, unsigned int numWindowsInit, bool showLabel, - std::function webGuiCallback); + explicit Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, + std::function webGuiCallback, unsigned int nMaxWindows, + QString* winColors); ~Display(); std::vector windowControls(); unsigned int nWindows(); - sgct::ivec2 monitorResolution(); void uncheckWebGuiOptions(); void setindowChangeCallback(std::function cb); @@ -44,27 +42,29 @@ private slots: private: void initializeWindowControl(); void removeWindowControl(); - void initializeLayout(bool showLabel, unsigned int numWindowsInit); - void showWindows(unsigned int nWindowControlsDisplayed); + void initializeLayout(); + void showWindows(); void addDisplayLayout(unsigned int column, MonitorBox* monBox, QVBoxLayout* layout); std::function _webGuiCheckCallback; std::vector& _monitorResolutions; QRect _widgetDims = {0, 0, 400, 400}; + QString* _winColors; std::vector _windowControl; unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; - QLabel* _labelMonNum = nullptr; + unsigned int _nMaxWindows = 3; + unsigned int _nMonitors = 1; QPushButton* _addWindowButton = nullptr; QPushButton* _removeWindowButton = nullptr; unsigned int _monitorIdx = 0; MonitorBox* _monBox; QVBoxLayout* _layout = nullptr; QHBoxLayout* _layoutMonBox = nullptr; - QHBoxLayout* _layoutMonNumLabel = nullptr; QHBoxLayout* _layoutMonButton = nullptr; QHBoxLayout* _layoutWindows = nullptr; std::vector _winCtrlLayouts; std::vector _layoutWindowWrappers; + std::vector _frameBorderLines; QFrame* _borderFrame = nullptr; }; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index 1025c59cd8..1872c6630d 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -21,11 +21,11 @@ class FileSupport : public QWidget public: explicit FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, - std::vector& displays, Orientation* orientation, + Display* display, Orientation* orientation, std::vector& windowList, sgct::config::Cluster& cluster, std::function cb); ~FileSupport(); - bool isWindowFullscreen(sgct::ivec2 mDims, sgct::ivec2 wDims); + bool isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims); int findGuiWindow(); void saveCluster(); void saveWindows(); @@ -43,7 +43,7 @@ private: QPushButton* _saveButton = nullptr; QPushButton* _cancelButton = nullptr; Orientation* _orientationWidget; - std::vector& _displayWidgets; + Display* _displayWidget; std::vector& _monitors; sgct::config::Cluster& _cluster; std::vector& _windowList; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 3aa305b2af..6840b61337 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -19,16 +19,15 @@ class MonitorBox : public QWidget { - Q_OBJECT - +Q_OBJECT public: explicit MonitorBox(QRect widgetDims, std::vector monitorResolution, - bool showMonitorLabel); + unsigned int nWindows, bool showMonitorLabel, QString* winColors); ~MonitorBox(); void mapMonitorResolutionToWidgetCoordinates(); void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& w); - void setNumWindowsDisplayed(unsigned int mIdx, unsigned int nWindows); + void setNumWindowsDisplayed(unsigned int nWindows); void windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, const QRectF& newDimensions); void addWindowControl(WindowControl* wCtrl); @@ -39,43 +38,37 @@ protected: private: void paintWidgetBorder(QPainter& painter, int width, int height); void paintMonitorOutlines(QPainter& painter); - void paintWindow(QPainter& painter, unsigned int monIdx, unsigned int winIdx); - void paintOutOfBoundsAreas(QPainter& painter, unsigned int monIdx,unsigned int winIdx); - void paintWindowNumber(QPainter& painter, unsigned int monIdx, unsigned int winIdx); + void paintWindow(QPainter& painter, unsigned int winIdx); + void paintOutOfBoundsAreas(QPainter& painter, unsigned int winIdx); + void paintWindowNumber(QPainter& painter, unsigned int winIdx); void setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, bool visibleBorder); void computeScaledResolution_landscape(float aspectRatio, float maxWidth); void computeScaledResolution_portrait(float aspectRatio, float maxHeight); void computeOutOfBounds_horizontal(unsigned int mIdx, unsigned int wIdx); void computeOutOfBounds_vertical(unsigned int mIdx, unsigned int wIdx); - void addOutOfBoundsArea_horizontal(unsigned int mIdx, unsigned int wIdx, - qreal bounds, qreal extent); - void addOutOfBoundsArea_vertical(unsigned int mIdx, unsigned int wIdx, - qreal bounds, qreal extent); + void addOutOfBoundsArea_horizontal(unsigned int wIdx, qreal bounds, qreal extent); + void addOutOfBoundsArea_vertical(unsigned int wIdx, qreal bounds, qreal extent); unsigned int _maxNumMonitors = 2; - unsigned int _maxNumWindowsPerMonitor = 2; std::vector _monitorResolution; //std::vector _monitorRendering; std::vector _monitorDimensionsScaled; std::vector _windowResolutions; - std::vector>> _outOfBoundsRect = { - {{{0.0, 0.0, 0.0, 0.0}}, - {{0.0, 0.0, 0.0, 0.0}}}, - {{{0.0, 0.0, 0.0, 0.0}}, - {{0.0, 0.0, 0.0, 0.0}}} + std::vector> _outOfBoundsRect = { + {{0.0, 0.0, 0.0, 0.0}}, + {{0.0, 0.0, 0.0, 0.0}}, + {{0.0, 0.0, 0.0, 0.0}}, + {{0.0, 0.0, 0.0, 0.0}} }; - std::vector> _windowRendering = { - {{0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0}}, - {{0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0}} + std::vector _windowRendering = { + {0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0} }; - QColor _colorWindow[2] = { - {0x1C, 0x1B, 0x8B}, - {0xCD, 0x6D, 0x1D} - }; - int _alphaWindowTransparency = 111; + QString* _colorsForWindows; + int _alphaWindowOpacity = 170; float _monitorScaleFactor = 1.0; float _offset[2] = {10.0, 10.0}; bool _showLabel = false; @@ -89,7 +82,7 @@ private: unsigned int _nMonitors = 1; - std::vector _nWindows = {1, 0}; + unsigned int _nWindows = 1; }; #endif // MONITORBOX_H diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index 68fe6ff528..8f841c4671 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -2,6 +2,7 @@ #define __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ #include +#include #include #include #include @@ -30,7 +31,7 @@ public: SgctEdit(QWidget* parent, std::vector& windowList, sgct::config::Cluster& cluster, QApplication& qtApp); ~SgctEdit(); - void addDisplayLayout(unsigned int column, MonitorBox* monBox, QHBoxLayout* layout); + void addDisplayLayout(MonitorBox* monBox, QHBoxLayout* layout); void createWidgets(); bool wasSaved() const; std::string saveFilename(); @@ -39,9 +40,9 @@ private: void systemMonitorConfiguration(QApplication& qtApp); MonitorBox* _monBox = nullptr; std::vector _monitorSizeList; - std::vector _displayLayout = {nullptr, nullptr}; - std::vector _displayFrame = {nullptr, nullptr}; - std::vector _displayWidget = {nullptr, nullptr}; + QVBoxLayout* _displayLayout = nullptr; + QFrame* _displayFrame = nullptr; + Display* _displayWidget = nullptr; QRect _monitorWidgetSize = {0, 0, 400, 350}; FileSupport* _fileSupportWidget = nullptr; Orientation* _orientationWidget = nullptr; @@ -49,6 +50,13 @@ private: sgct::config::Cluster& _cluster; std::vector& _windowList; bool _saveSelected = false; + unsigned int _nMaxWindows = 3; + QString _colorsForWindows[4] = { + "#2B9EC3", + "#FCAB10", + "#44AF69", + "#F8333C" + }; }; #endif // __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index b136807862..eb77008194 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -2,6 +2,7 @@ #define WINDOWCONTROL_H #include +#include #include #include #include @@ -23,11 +24,11 @@ class WindowControl : public QWidget { - Q_OBJECT - +Q_OBJECT public: - explicit WindowControl(unsigned int monitorIndex, unsigned int windowIndex, - QRect& widgetDims, QRect& monitorDims, QWidget *parent = nullptr); + explicit WindowControl(unsigned int nMonitors, unsigned int monitorIndex, + unsigned int windowIndex, QRect& widgetDims, std::vector& monitorDims, + QString* winColors, QWidget *parent = nullptr); ~WindowControl(); void setDimensions(const QRectF& dimensions); void setWindowChangeCallback(std::function cb); @@ -54,6 +55,7 @@ public: int projectionSelectedIndex(); int qualitySelectedIndex(); int qualitySelectedValue(); + unsigned int monitorNum(); float fovH(); float fovV(); float heightOffset(); @@ -77,6 +79,7 @@ private slots: void onSizeYChanged(const QString& newText); void onOffsetXChanged(const QString& newText); void onOffsetYChanged(const QString& newText); + void onMonitorChanged(int newSelection); void onProjectionChanged(int newSelection); void onFullscreenClicked(); void onSpoutSelection(int selectionState); @@ -89,9 +92,11 @@ private: void updateScaledWindowDimensions(); std::function _windowChangeCallback; std::function _windowGuiCheckCallback; - QRectF defaultWindowSizes[2] = { + QRectF defaultWindowSizes[4] = { {50.0, 50.0, 1280.0, 720.0}, - {900.0, 400.0, 800.0, 600.0} + {900.0, 250.0, 1280.0, 720.0}, + {1200.0, 340.0, 1280.0, 720.0}, + {50.0, 50.0, 1280.0, 720.0} }; QList _projectionTypes = { QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Planar]), @@ -112,11 +117,14 @@ private: QString::fromStdString(QualityTypeNames[8]), QString::fromStdString(QualityTypeNames[9]), }; + QList _monitorNames = { "Monitor 1", "Monitor 2" }; int _lineEditWidthFixed = 50; float _marginFractionOfWidgetSize = 0.025; + unsigned int _nMonitors = 1; unsigned int _monIndex = 0; unsigned int _index = 0; int _maxWindowSizePixels = 10000; + QString* _colorsForWindows = nullptr; QVBoxLayout* _layoutWindowCtrl = nullptr; QVBoxLayout* _layoutFullWindow = nullptr; @@ -134,13 +142,14 @@ private: QIntValidator* _validatorOffset_x = nullptr; QIntValidator* _validatorOffset_y = nullptr; - QRect& _monitorResolution; + std::vector& _monitorResolutions; QRectF _windowDims; QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; QCheckBox* _checkBoxWebGui = nullptr; QCheckBox* _checkBoxSpoutOutput = nullptr; + QComboBox* _comboMonitorSelect = nullptr; QComboBox* _comboProjection = nullptr; QComboBox* _comboQuality = nullptr; QLabel* _labelFovH = nullptr; @@ -156,6 +165,7 @@ private: QHBoxLayout* _layoutName = nullptr; QLabel* _labelName = nullptr; QLineEdit* _windowName = nullptr; + QHBoxLayout* _layoutMonitorNum = nullptr; QLabel* _labelSize = nullptr; QLabel* _labelDelim = nullptr; QHBoxLayout* _layoutSize = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 6dc36489dc..67b426cae7 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -8,21 +8,25 @@ #include "sgctedit/display.h" -Display::Display(unsigned int monitorIdx, MonitorBox* monitorRenderBox, - std::vector& monitorSizeList, unsigned int numWindowsInit, bool showLabel, - std::function webGuiCallback) - : _monitorIdx(monitorIdx) - , _monBox(monitorRenderBox) +Display::Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, + std::function webGuiCallback, unsigned int nMaxWindows, + QString* winColors) + : _monBox(monitorRenderBox) , _monitorResolutions(monitorSizeList) , _webGuiCheckCallback(webGuiCallback) + , _nMaxWindows(nMaxWindows) + , _winColors(winColors) { - _addWindowButton = new QPushButton("Add Window", this); - _removeWindowButton = new QPushButton("Remove Window", this); + _addWindowButton = new QPushButton("Add Window >", this); + _removeWindowButton = new QPushButton("< Remove Window", this); - //Add 2 window controls - initializeWindowControl(); - initializeWindowControl(); - initializeLayout(showLabel, numWindowsInit); + _nMonitors = _monitorResolutions.size(); + + //Add all window controls (some will be hidden from GUI initially) + for (unsigned int i = 0; i < _nMaxWindows; ++i) { + initializeWindowControl(); + } + initializeLayout(); connect(_addWindowButton, SIGNAL(released()), this, SLOT(addWindow())); @@ -34,12 +38,12 @@ Display::~Display() { delete _addWindowButton; delete _removeWindowButton; delete _monBox; - delete _borderFrame; - delete _labelMonNum; + for (auto f : _frameBorderLines) { + delete f; + } for (auto w : _windowControl) { delete w; } - delete _layoutMonNumLabel; delete _layoutMonBox; delete _layoutMonButton; for (auto w : _layoutWindowWrappers) { @@ -49,19 +53,8 @@ Display::~Display() { delete _layout; } -void Display::initializeLayout(bool showLabel, unsigned int numWindowsInit) { +void Display::initializeLayout() { _layout = new QVBoxLayout(this); - - if (showLabel) { - _labelMonNum = new QLabel(); - _labelMonNum->setText("Display " + QString::number(_monitorIdx + 1)); - _layoutMonNumLabel = new QHBoxLayout(); - _layoutMonNumLabel->addStretch(1); - _layoutMonNumLabel->addWidget(_labelMonNum); - _layoutMonNumLabel->addStretch(1); - _layout->addLayout(_layoutMonNumLabel); - } - _layoutMonButton = new QHBoxLayout(); _layoutMonButton->addStretch(1); _layoutMonButton->addWidget(_removeWindowButton); @@ -69,23 +62,23 @@ void Display::initializeLayout(bool showLabel, unsigned int numWindowsInit) { _layoutMonButton->addStretch(1); _layout->addLayout(_layoutMonButton); _layoutWindows = new QHBoxLayout(); - _layout->addStretch(); - _winCtrlLayouts.push_back(_windowControl[0]->initializeLayout(this)); - _layoutWindowWrappers.push_back(new QWidget()); - _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); - _layoutWindows->addWidget(_layoutWindowWrappers.back()); - _borderFrame = new QFrame; - _borderFrame->setFrameShape(QFrame::VLine); - _layoutWindows->addWidget(_borderFrame); - _winCtrlLayouts.push_back(_windowControl[1]->initializeLayout(this)); - _layoutWindowWrappers.push_back(new QWidget()); - _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); - _layoutWindows->addWidget(_layoutWindowWrappers.back()); - showWindows(numWindowsInit); + //_winCtrlLayouts.push_back(_windowControl[0]->initializeLayout(this)); + for (unsigned int i = 0; i < _nMaxWindows; ++i) { + _winCtrlLayouts.push_back(_windowControl[i]->initializeLayout(this)); + _layoutWindowWrappers.push_back(new QWidget()); + _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); + _layoutWindows->addWidget(_layoutWindowWrappers.back()); + if (i < (_nMaxWindows - 1)) { + _frameBorderLines.push_back(new QFrame()); + _frameBorderLines.back()->setFrameShape(QFrame::VLine); + _layoutWindows->addWidget(_frameBorderLines.back()); + } + } + _nWindowsDisplayed = 1; + showWindows(); _layout->addLayout(_layoutWindows); - //for (WindowControl* w : _windowControl) { // w->cleanupLayouts(); //} @@ -99,72 +92,53 @@ unsigned int Display::nWindows() { return _nWindowsDisplayed; } -sgct::ivec2 Display::monitorResolution() { - return { - _monitorResolutions[_monitorIdx].width(), - _monitorResolutions[_monitorIdx].height() - }; -} - void Display::addWindow() { - if (_nWindowsDisplayed == 0) { - showWindows(1); - _removeWindowButton->setEnabled(true); - } - else if (_nWindowsDisplayed == 1) { - showWindows(2); - _addWindowButton->setEnabled(false); + if (_nWindowsDisplayed < _nMaxWindows) { + _nWindowsDisplayed++; + showWindows(); } } void Display::removeWindow() { - if (_nWindowsDisplayed == 1) { - showWindows(0); - _removeWindowButton->setEnabled(false); - } - else if (_nWindowsDisplayed == 2) { - showWindows(1); - _addWindowButton->setEnabled(true); + if (_nWindowsDisplayed > 1) { + _nWindowsDisplayed--; + showWindows(); } } -void Display::showWindows(unsigned int nWindowControlsDisplayed) { - _nWindowsDisplayed = nWindowControlsDisplayed; - _borderFrame->setVisible(_nWindowsDisplayed == 2); - _layoutWindowWrappers[0]->setVisible(_nWindowsDisplayed > 0); - _layoutWindowWrappers[1]->setVisible(_nWindowsDisplayed == 2); - _addWindowButton->setEnabled(_nWindowsDisplayed < 2); - _removeWindowButton->setEnabled(_nWindowsDisplayed > 0); - _monBox->setNumWindowsDisplayed(_monitorIdx, _nWindowsDisplayed); +void Display::showWindows() { + for (unsigned int i = 0; i < _layoutWindowWrappers.size(); ++i) { + _layoutWindowWrappers[i]->setVisible(i < _nWindowsDisplayed); + } + for (unsigned int i = 0; i < _frameBorderLines.size(); ++i) { + if (i < (_nWindowsDisplayed - 1)) { + _frameBorderLines[i]->setVisible(true); + } + else { + _frameBorderLines[i]->setVisible(false); + } + } + _removeWindowButton->setEnabled(_nWindowsDisplayed > 1); + _removeWindowButton->setVisible(_nWindowsDisplayed > 1); + _addWindowButton->setEnabled(_nWindowsDisplayed != _nMaxWindows); + _addWindowButton->setVisible(_nWindowsDisplayed != _nMaxWindows); for (auto w : _windowControl) { - w->showWindowLabel(_nWindowsDisplayed == 2); - } - if (_nWindowsDisplayed == 0) { - _addWindowButton->setText("Add Window"); - _addWindowButton->setVisible(true); - _removeWindowButton->setVisible(false); - } - else if (_nWindowsDisplayed == 1) { - _addWindowButton->setText("Add 2nd Window"); - _removeWindowButton->setText("Remove Window"); - _addWindowButton->setVisible(true); - _removeWindowButton->setVisible(true); - } - else if (_nWindowsDisplayed == 2) { - _removeWindowButton->setText("Remove Window 2"); - _addWindowButton->setVisible(false); - _removeWindowButton->setVisible(true); + w->showWindowLabel(_nWindowsDisplayed > 1); } + _monBox->setNumWindowsDisplayed(_nWindowsDisplayed); } void Display::initializeWindowControl() { - if (_nWindowsAllocated < 2) { + if (_nWindowsAllocated < _nMaxWindows) { + unsigned int monitorNumForThisWindow = (_nWindowsAllocated >= 3) ? 1 : 0; _windowControl.push_back( new WindowControl( - _monitorIdx, + _nMonitors, + monitorNumForThisWindow, _nWindowsAllocated, _widgetDims, - _monitorResolutions[_monitorIdx], + _monitorResolutions, + _winColors, this ) ); @@ -180,7 +154,7 @@ void Display::initializeWindowControl() { } ); _monBox->mapWindowResolutionToWidgetCoordinates( - _monitorIdx, + monitorNumForThisWindow, _nWindowsAllocated, _windowControl.back()->dimensions() ); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 7976490d78..d4b3ff61fc 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -1,11 +1,11 @@ #include "sgctedit/filesupport.h" FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, - std::vector& displays, Orientation* orientation, + Display* display, Orientation* orientation, std::vector& windowList, sgct::config::Cluster& cluster, std::function cb) : _monitors(monitorList) - , _displayWidgets(displays) + , _displayWidget(display) , _orientationWidget(orientation) , _cluster(cluster) , _windowList(windowList) @@ -51,21 +51,18 @@ void FileSupport::saveCluster() { } } -bool FileSupport::isWindowFullscreen(sgct::ivec2 mDims, sgct::ivec2 wDims) { +bool FileSupport::isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims) { + sgct::ivec2 mDims = {_monitors[monitorIdx].width(), _monitors[monitorIdx].height()}; return ((mDims.x == wDims.x) && (mDims.y == wDims.y)); } int FileSupport::findGuiWindow() { unsigned int windowIndex = 0; - for (unsigned int m = 0; m < _displayWidgets.size(); ++m) { - if (_displayWidgets[m]) { - for (unsigned int w = 0; w < _displayWidgets[m]->nWindows(); ++w) { - if (_displayWidgets[m]->windowControls()[w]->isGuiWindow()) { - return windowIndex; - } - windowIndex++; - } + for (unsigned int w = 0; w < _displayWidget->nWindows(); ++w) { + if (_displayWidget->windowControls()[w]->isGuiWindow()) { + return windowIndex; } + windowIndex++; } return -1; } @@ -75,62 +72,58 @@ void FileSupport::saveWindows() { bool isOneOfWindowsSetAsWebGui = (webGuiWindowIndex >= 0); unsigned int windowIndex = 0; - for (unsigned int m = 0; m < _displayWidgets.size(); ++m) { - if (_displayWidgets[m]) { - for (unsigned int w = 0; w < _displayWidgets[m]->nWindows(); ++w) { - _windowList.push_back(sgct::config::Window()); - _windowList.back().viewports.push_back(sgct::config::Viewport()); - _windowList.back().viewports.back().isTracked = true; - _windowList.back().viewports.back().position = {0.0, 0.0}; - _windowList.back().viewports.back().size = {1.0, 1.0}; - int projectionIdx - = _displayWidgets[m]->windowControls()[w]->projectionSelectedIndex(); - bool isSpoutSelected - = _displayWidgets[m]->windowControls()[w]->isSpoutSelected(); + for (unsigned int w = 0; w < _displayWidget->nWindows(); ++w) { + _windowList.push_back(sgct::config::Window()); + _windowList.back().viewports.push_back(sgct::config::Viewport()); + _windowList.back().viewports.back().isTracked = true; + _windowList.back().viewports.back().position = {0.0, 0.0}; + _windowList.back().viewports.back().size = {1.0, 1.0}; + int projectionIdx + = _displayWidget->windowControls()[w]->projectionSelectedIndex(); + bool isSpoutSelected + = _displayWidget->windowControls()[w]->isSpoutSelected(); - saveProjectionInformation( - isSpoutSelected, - projectionIdx, - _displayWidgets[m]->windowControls()[w], - _windowList.back().viewports.back() - ); - _windowList.back().size - = _displayWidgets[m]->windowControls()[w]->windowSize(); - _windowList.back().pos - = _displayWidgets[m]->windowControls()[w]->windowPos(); - _windowList.back().isDecorated - = _displayWidgets[m]->windowControls()[w]->isDecorated(); - bool isFullScreen = isWindowFullscreen( - _displayWidgets[m]->monitorResolution(), - _displayWidgets[m]->windowControls()[w]->windowSize() - ); - if (isFullScreen) { - _windowList.back().isFullScreen = true; - } - if (isOneOfWindowsSetAsWebGui) { - if (windowIndex == webGuiWindowIndex) { - _windowList.back().draw2D = true; - _windowList.back().draw3D = false; - _windowList.back().viewports.back().isTracked = false; - _windowList.back().tags.push_back("GUI"); - } - else { - _windowList.back().draw2D = false; - _windowList.back().draw3D = true; - } - } - else { - _windowList.back().draw2D = true; - _windowList.back().draw3D = true; - _windowList.back().viewports.back().isTracked = true; - } - if (!_displayWidgets[m]->windowControls()[w]->windowName().empty()) { - _windowList.back().name - = _displayWidgets[m]->windowControls()[w]->windowName(); - } - _windowList.back().id = windowIndex++; + saveProjectionInformation( + isSpoutSelected, + projectionIdx, + _displayWidget->windowControls()[w], + _windowList.back().viewports.back() + ); + _windowList.back().size + = _displayWidget->windowControls()[w]->windowSize(); + _windowList.back().pos + = _displayWidget->windowControls()[w]->windowPos(); + _windowList.back().isDecorated + = _displayWidget->windowControls()[w]->isDecorated(); + bool isFullScreen = isWindowFullscreen( + _displayWidget->windowControls()[w]->monitorNum(), + _displayWidget->windowControls()[w]->windowSize() + ); + if (isFullScreen) { + _windowList.back().isFullScreen = true; + } + if (isOneOfWindowsSetAsWebGui) { + if (windowIndex == webGuiWindowIndex) { + _windowList.back().draw2D = true; + _windowList.back().draw3D = false; + _windowList.back().viewports.back().isTracked = false; + _windowList.back().tags.push_back("GUI"); + } + else { + _windowList.back().draw2D = false; + _windowList.back().draw3D = true; } } + else { + _windowList.back().draw2D = true; + _windowList.back().draw3D = true; + _windowList.back().viewports.back().isTracked = true; + } + if (!_displayWidget->windowControls()[w]->windowName().empty()) { + _windowList.back().name + = _displayWidget->windowControls()[w]->windowName(); + } + _windowList.back().id = windowIndex++; } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 1a08ae2f60..c11e21c3bf 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -2,10 +2,12 @@ MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, - bool showMonitorLabel) + unsigned int nWindows, bool showMonitorLabel, QString* winColors) : _monitorWidgetSize(widgetDims) , _monitorResolution(monitorResolution) + , _nWindows(nWindows) , _showLabel(showMonitorLabel) + , _colorsForWindows(winColors) { _nMonitors = monitorResolution.size(); mapMonitorResolutionToWidgetCoordinates(); @@ -26,10 +28,8 @@ void MonitorBox::paintEvent(QPaintEvent *event) paintMonitorOutlines(painter); //Draw window outline(s) - for (unsigned int i = 0; i < _nMonitors ; ++i) { - for (unsigned int j = 0; j < _nWindows[i]; ++j) { - paintWindow(painter, i, j); - } + for (unsigned int i = 0; i < _nWindows; ++i) { + paintWindow(painter, i); } } @@ -53,42 +53,40 @@ void MonitorBox::paintMonitorOutlines(QPainter& painter) { } } -void MonitorBox::paintWindow(QPainter& painter, unsigned int monIdx, - unsigned int winIdx) +void MonitorBox::paintWindow(QPainter& painter, unsigned int winIdx) { setPenSpecificToWindow(painter, winIdx, true); - if (winIdx <= _windowRendering[monIdx].size()) { - painter.drawRect(_windowRendering[monIdx][winIdx]); - QColor fillColor = _colorWindow[winIdx]; - fillColor.setAlpha(_alphaWindowTransparency); + if (winIdx <= _windowRendering.size()) { + painter.drawRect(_windowRendering[winIdx]); + QColor fillColor = QColor(_colorsForWindows[winIdx]); + fillColor.setAlpha(_alphaWindowOpacity); QBrush brush(fillColor); brush.setStyle(Qt::SolidPattern); - painter.fillRect(_windowRendering[monIdx][winIdx], brush); + painter.fillRect(_windowRendering[winIdx], brush); //Draw areas of window that are past the monitor boundaries - if (_outOfBoundsRect[monIdx][winIdx].size() > 0) { - paintOutOfBoundsAreas(painter, monIdx, winIdx); + if (_outOfBoundsRect.size() >= winIdx && _outOfBoundsRect[winIdx].size() > 0) { + paintOutOfBoundsAreas(painter, winIdx); } - paintWindowNumber(painter, monIdx, winIdx); + paintWindowNumber(painter, winIdx); } } -void MonitorBox::paintOutOfBoundsAreas(QPainter& painter, unsigned int monIdx, - unsigned int winIdx) -{ +void MonitorBox::paintOutOfBoundsAreas(QPainter& painter, unsigned int winIdx) { + if (_outOfBoundsRect.size() <= winIdx) { + return; + } painter.setBrush(Qt::BDiagPattern); setPenSpecificToWindow(painter, winIdx, false); - for (QRectF r : _outOfBoundsRect[monIdx][winIdx]) { + for (QRectF r : _outOfBoundsRect[winIdx]) { painter.drawRect(r); } setPenSpecificToWindow(painter, winIdx, true); painter.setBrush(Qt::NoBrush); } -void MonitorBox::paintWindowNumber(QPainter& painter, unsigned int monIdx, - unsigned int winIdx) -{ - QPointF textPos = QPointF(_windowRendering[monIdx][winIdx].left() + 5, - _windowRendering[monIdx][winIdx].bottom() - 5); +void MonitorBox::paintWindowNumber(QPainter& painter, unsigned int winIdx) { + QPointF textPos = QPointF(_windowRendering[winIdx].left() + 5, + _windowRendering[winIdx].bottom() - 5); textPos.setX(std::clamp(textPos.x(), 0.0, _monitorWidgetSize.width() - 10)); textPos.setY(std::clamp(textPos.y(), 0.0, @@ -100,7 +98,7 @@ void MonitorBox::setPenSpecificToWindow(QPainter& painter, unsigned int windowId bool visibleBorder) { int penWidth = (visibleBorder) ? 1 : -1; - painter.setPen(QPen(_colorWindow[windowIdx], penWidth)); + painter.setPen(QPen(QColor(_colorsForWindows[windowIdx]), penWidth)); } void MonitorBox::windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, @@ -169,9 +167,9 @@ void MonitorBox::computeScaledResolution_portrait(float aspectRatio, float maxHe } } -void MonitorBox::setNumWindowsDisplayed(unsigned int mIdx, unsigned int nWindows) { - if ((mIdx <= (_nMonitors - 1)) && (_nWindows[mIdx] != nWindows)) { - _nWindows[mIdx] = nWindows; +void MonitorBox::setNumWindowsDisplayed(unsigned int nWindows) { + if (_nWindows != nWindows) { + _nWindows = nWindows; this->update(); } } @@ -185,94 +183,95 @@ void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& w) { - if (mIdx > (_maxNumMonitors - 1) || wIdx > (_maxNumWindowsPerMonitor - 1)) { +std::cout << "mapWindowResolutionToWidgetCoordinates mon=" << mIdx << ", win=" << wIdx << std::endl; + if (mIdx > (_maxNumMonitors - 1) || wIdx > (_nWindows - 1)) { return; } QRectF wF = w; - _windowRendering[mIdx][wIdx] = { + _windowRendering[wIdx] = { _monitorDimensionsScaled[mIdx].x() + wF.left() * _monitorScaleFactor, _monitorDimensionsScaled[mIdx].y() + wF.top() * _monitorScaleFactor, wF.width() * _monitorScaleFactor, wF.height() * _monitorScaleFactor }; - _outOfBoundsRect[mIdx][wIdx].clear(); + _outOfBoundsRect[wIdx].clear(); computeOutOfBounds_horizontal(mIdx, wIdx); computeOutOfBounds_vertical(mIdx, wIdx); this->update(); } void MonitorBox::computeOutOfBounds_horizontal(unsigned int mIdx, unsigned int wIdx) { - qreal windowWidthPlusOffset = _windowRendering[mIdx][wIdx].width() - + _windowRendering[mIdx][wIdx].x() - _monitorDimensionsScaled[mIdx].x(); + qreal windowWidthPlusOffset = _windowRendering[wIdx].width() + + _windowRendering[wIdx].x() - _monitorDimensionsScaled[mIdx].x(); if (windowWidthPlusOffset > _monitorDimensionsScaled[mIdx].width()) { qreal bounds_x = std::max( _monitorDimensionsScaled[mIdx].width() + _monitorDimensionsScaled[mIdx].x(), - _windowRendering[mIdx][wIdx].x() + _windowRendering[wIdx].x() ); qreal extent_x = std::min( - _windowRendering[mIdx][wIdx].width(), + _windowRendering[wIdx].width(), windowWidthPlusOffset - _monitorDimensionsScaled[mIdx].width() ); - addOutOfBoundsArea_horizontal(mIdx, wIdx, bounds_x, extent_x); + addOutOfBoundsArea_horizontal(wIdx, bounds_x, extent_x); } - if (_windowRendering[mIdx][wIdx].x() < _monitorDimensionsScaled[mIdx].x() ) { + if (_windowRendering[wIdx].x() < _monitorDimensionsScaled[mIdx].x() ) { qreal extent_x = std::min( - _windowRendering[mIdx][wIdx].width(), - _monitorDimensionsScaled[mIdx].x() - _windowRendering[mIdx][wIdx].x() + _windowRendering[wIdx].width(), + _monitorDimensionsScaled[mIdx].x() - _windowRendering[wIdx].x() ); - addOutOfBoundsArea_horizontal(mIdx, wIdx, _windowRendering[mIdx][wIdx].x(), + addOutOfBoundsArea_horizontal(wIdx, _windowRendering[wIdx].x(), extent_x); } } -void MonitorBox::addOutOfBoundsArea_horizontal(unsigned int mIdx, unsigned int wIdx, - qreal bounds, qreal extent) +void MonitorBox::addOutOfBoundsArea_horizontal(unsigned int wIdx, qreal bounds, + qreal extent) { - _outOfBoundsRect[mIdx][wIdx].push_back({ + _outOfBoundsRect[wIdx].push_back({ bounds, - _windowRendering[mIdx][wIdx].y(), + _windowRendering[wIdx].y(), extent, - _windowRendering[mIdx][wIdx].height() + _windowRendering[wIdx].height() }); } void MonitorBox::computeOutOfBounds_vertical(unsigned int mIdx, unsigned int wIdx) { - qreal windowHeightPlusOffset = _windowRendering[mIdx][wIdx].height() - + _windowRendering[mIdx][wIdx].y() - _monitorDimensionsScaled[mIdx].y(); + qreal windowHeightPlusOffset = _windowRendering[wIdx].height() + + _windowRendering[wIdx].y() - _monitorDimensionsScaled[mIdx].y(); if (windowHeightPlusOffset > _monitorDimensionsScaled[mIdx].height()) { qreal bounds_y = std::max( _monitorDimensionsScaled[mIdx].height() + _monitorDimensionsScaled[mIdx].y(), - _windowRendering[mIdx][wIdx].y() + _windowRendering[wIdx].y() ); qreal extent_y = std::min( - _windowRendering[mIdx][wIdx].height(), + _windowRendering[wIdx].height(), windowHeightPlusOffset - _monitorDimensionsScaled[mIdx].height() ); - addOutOfBoundsArea_vertical(mIdx, wIdx, bounds_y, extent_y); + addOutOfBoundsArea_vertical(wIdx, bounds_y, extent_y); } - if (_windowRendering[mIdx][wIdx].y() < _monitorDimensionsScaled[mIdx].y() ) { + if (_windowRendering[wIdx].y() < _monitorDimensionsScaled[mIdx].y() ) { qreal extent_y = std::min( - _windowRendering[mIdx][wIdx].height(), - _monitorDimensionsScaled[mIdx].y() - _windowRendering[mIdx][wIdx].y() + _windowRendering[wIdx].height(), + _monitorDimensionsScaled[mIdx].y() - _windowRendering[wIdx].y() ); - _outOfBoundsRect[mIdx][wIdx].push_back({ - _windowRendering[mIdx][wIdx].x(), - _windowRendering[mIdx][wIdx].y(), - _windowRendering[mIdx][wIdx].width(), + _outOfBoundsRect[wIdx].push_back({ + _windowRendering[wIdx].x(), + _windowRendering[wIdx].y(), + _windowRendering[wIdx].width(), extent_y }); - addOutOfBoundsArea_vertical(mIdx, wIdx, _windowRendering[mIdx][wIdx].y(), + addOutOfBoundsArea_vertical(wIdx, _windowRendering[wIdx].y(), extent_y); } } -void MonitorBox::addOutOfBoundsArea_vertical(unsigned int mIdx, unsigned int wIdx, +void MonitorBox::addOutOfBoundsArea_vertical(unsigned int wIdx, qreal bounds, qreal extent) { - _outOfBoundsRect[mIdx][wIdx].push_back({ - _windowRendering[mIdx][wIdx].x(), + _outOfBoundsRect[wIdx].push_back({ + _windowRendering[wIdx].x(), bounds, - _windowRendering[mIdx][wIdx].width(), + _windowRendering[wIdx].width(), extent }); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index a9922d183e..36d2d22d78 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -36,6 +36,7 @@ void SgctEdit::systemMonitorConfiguration(QApplication& qtApp) { actualHeight }); } + _nMaxWindows = (_monitorSizeList.size() == 1) ? 3 : 4; } void SgctEdit::createWidgets() { @@ -52,7 +53,9 @@ void SgctEdit::createWidgets() { _monBox = new MonitorBox( _monitorWidgetSize, _monitorSizeList, - _showMonitorLabel + _nMaxWindows, + _showMonitorLabel, + _colorsForWindows ); QHBoxLayout* layoutMonBox = new QHBoxLayout(); layoutMonBox->addStretch(1); @@ -63,10 +66,7 @@ void SgctEdit::createWidgets() { _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _monBox->setFixedSize(_monitorWidgetSize.width(), _monitorWidgetSize.height()); - addDisplayLayout(0, _monBox, layoutMainH); - if (_monitorSizeList.size() > 1) { - addDisplayLayout(1, _monBox, layoutMainH); - } + addDisplayLayout(_monBox, layoutMainH); } { layoutMainV->addLayout(layoutMainH); @@ -92,27 +92,25 @@ void SgctEdit::createWidgets() { } } -void SgctEdit::addDisplayLayout(unsigned int column, MonitorBox* monBox, - QHBoxLayout* layout) +void SgctEdit::addDisplayLayout(MonitorBox* monBox, QHBoxLayout* layout) { - _displayLayout[column] = new QVBoxLayout(); - _displayWidget[column] = new Display( - column, + _displayLayout = new QVBoxLayout(); + _displayWidget = new Display( monBox, _monitorSizeList, - (column == 0) ? 1 : 0, - _showMonitorLabel, [this](unsigned int monIndex) { if (_monitorSizeList.size() > 1) { - _displayWidget[(monIndex == 0) ? 1 : 0]->uncheckWebGuiOptions(); + _displayWidget->uncheckWebGuiOptions(); } - } + }, + _nMaxWindows, + _colorsForWindows ); - _displayFrame[column] = new QFrame; - _displayLayout[column]->addWidget(_displayWidget[column]); - _displayFrame[column]->setLayout(_displayLayout[column]); - _displayFrame[column]->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - layout->addWidget(_displayFrame[column]); + _displayFrame = new QFrame; + _displayLayout->addWidget(_displayWidget); + _displayFrame->setLayout(_displayLayout); + _displayFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + layout->addWidget(_displayFrame); } bool SgctEdit::wasSaved() const { @@ -126,9 +124,7 @@ std::string SgctEdit::saveFilename() { SgctEdit::~SgctEdit() { delete _orientationWidget; delete _fileSupportWidget; - for (unsigned int i = 0; i <= _monitorSizeList.size(); ++i) { - if (_displayWidget[i]) delete _displayWidget[i]; - if (_displayLayout[i]) delete _displayLayout[i]; - if (_displayFrame[i]) delete _displayFrame[i]; - } + delete _displayWidget; + delete _displayLayout; + delete _displayFrame; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 29e044feab..1f2012ef05 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -2,11 +2,14 @@ #include "sgctedit/monitorbox.h" #include "sgctedit/windowcontrol.h" -WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex, - QRect& widgetDims, QRect& monitorDims, QWidget *parent) - : _monIndex(monitorIndex) +WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, + unsigned int windowIndex, QRect& widgetDims, std::vector& monitorDims, + QString* winColors, QWidget *parent) + : _nMonitors(nMonitors) + , _monIndex(monitorIndex) , _index(windowIndex) - , _monitorResolution(monitorDims) + , _monitorResolutions(monitorDims) + , _colorsForWindows(winColors) , QWidget(parent) { _windowDims = defaultWindowSizes[windowIndex]; @@ -31,6 +34,10 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex _offset_x->setValidator(_validatorOffset_x); _offset_y->setValidator(_validatorOffset_y); + _comboMonitorSelect = new QComboBox(this); + _comboMonitorSelect->addItems(_monitorNames); + _comboMonitorSelect->setCurrentIndex(_monIndex); + _fullscreenButton = new QPushButton(this); _fullscreenButton->setText("Set to Fullscreen"); _checkBoxWindowDecor = new QCheckBox("Window Decoration", this); @@ -62,6 +69,8 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex connect(_offset_y, SIGNAL(textChanged(const QString&)), this, SLOT(onOffsetYChanged(const QString&))); + connect(_comboMonitorSelect, SIGNAL(currentIndexChanged(int)), + this, SLOT(onMonitorChanged(int))); connect(_comboProjection, SIGNAL(currentIndexChanged(int)), this, SLOT(onProjectionChanged(int))); connect(_checkBoxSpoutOutput, SIGNAL(stateChanged(int)), @@ -79,12 +88,10 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _labelWinNum = new QLabel(); _labelWinNum->setText("Window " + QString::number(_index + 1)); - if (_index == 1) { - _labelWinNum->setStyleSheet("QLabel { color : #CD6D1D; }"); - } - else { - _labelWinNum->setStyleSheet("QLabel { color : #1C1B8B; }"); - } + QString colorStr = "QLabel { color : "; + colorStr += _colorsForWindows ? _colorsForWindows[_index] : "#FFFFFF"; + colorStr += "; }"; + _labelWinNum->setStyleSheet(colorStr); _layoutWinNum = new QHBoxLayout(); _layoutWinNum->addStretch(1); @@ -101,6 +108,16 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutName->addWidget(_windowName); _layoutName->addStretch(1); _layoutWindowCtrl->addLayout(_layoutName); + + if (_nMonitors > 1) { + _layoutMonitorNum = new QHBoxLayout(); + _layoutMonitorNum->addWidget(_comboMonitorSelect); + _layoutMonitorNum->addStretch(1); + _layoutWindowCtrl->addLayout(_layoutMonitorNum); + } + else { + _comboMonitorSelect->setVisible(false); + } _size_x->setFixedWidth(_lineEditWidthFixed); _size_y->setFixedWidth(_lineEditWidthFixed); _labelSize = new QLabel(this); @@ -272,8 +289,8 @@ void WindowControl::onOffsetYChanged(const QString& newText) { void WindowControl::onFullscreenClicked() { _offset_x->setText("0"); _offset_y->setText("0"); - _size_x->setText(QString::number(_monitorResolution.width())); - _size_y->setText(QString::number(_monitorResolution.height())); + _size_x->setText(QString::number(_monitorResolutions[_monIndex].width())); + _size_y->setText(QString::number(_monitorResolutions[_monIndex].height())); } void WindowControl::enableGuiWindowSelection(bool enabled) { @@ -319,6 +336,13 @@ void WindowControl::enableProjectionOption(T* comboModel, int selectionIndex, bo } } +void WindowControl::onMonitorChanged(int newSelection) { + _monIndex = newSelection; + if (_windowChangeCallback) { + _windowChangeCallback(_monIndex, _index, _windowDims); + } +} + void WindowControl::onProjectionChanged(int newSelection) { switch (newSelection) { case ProjectionIndeces::Planar: @@ -484,6 +508,10 @@ float WindowControl::heightOffset() { return _lineHeightOffset->text().toFloat(); } +unsigned int WindowControl::monitorNum() { + return _monIndex; +} + WindowControl::~WindowControl() { delete _size_x; @@ -532,6 +560,7 @@ WindowControl::~WindowControl() delete _borderProjectionGroup; delete _layoutCheckboxesFull2; delete _layoutCheckboxesFull1; + delete _layoutMonitorNum; delete _layoutWinNum; delete _layoutWindowCtrl; delete _layoutFullWindow; From 14e2f8b8290d6c7a3814f508d806af0cd76b518c Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 20 Jan 2022 21:32:46 -0700 Subject: [PATCH 43/93] Improved rendering of window regions out-of-bounds of monitors --- .../launcher/include/sgctedit/monitorbox.h | 15 +-- .../ext/launcher/src/sgctedit/monitorbox.cpp | 126 ++++-------------- 2 files changed, 25 insertions(+), 116 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 6840b61337..d8b09f433c 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -30,37 +30,26 @@ public: void setNumWindowsDisplayed(unsigned int nWindows); void windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, const QRectF& newDimensions); - void addWindowControl(WindowControl* wCtrl); protected: void paintEvent(QPaintEvent *event) override; private: void paintWidgetBorder(QPainter& painter, int width, int height); - void paintMonitorOutlines(QPainter& painter); + void paintMonitorBackgrounds(QPainter& painter); void paintWindow(QPainter& painter, unsigned int winIdx); - void paintOutOfBoundsAreas(QPainter& painter, unsigned int winIdx); + void paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx); void paintWindowNumber(QPainter& painter, unsigned int winIdx); void setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, bool visibleBorder); void computeScaledResolution_landscape(float aspectRatio, float maxWidth); void computeScaledResolution_portrait(float aspectRatio, float maxHeight); - void computeOutOfBounds_horizontal(unsigned int mIdx, unsigned int wIdx); - void computeOutOfBounds_vertical(unsigned int mIdx, unsigned int wIdx); - void addOutOfBoundsArea_horizontal(unsigned int wIdx, qreal bounds, qreal extent); - void addOutOfBoundsArea_vertical(unsigned int wIdx, qreal bounds, qreal extent); unsigned int _maxNumMonitors = 2; std::vector _monitorResolution; //std::vector _monitorRendering; std::vector _monitorDimensionsScaled; std::vector _windowResolutions; - std::vector> _outOfBoundsRect = { - {{0.0, 0.0, 0.0, 0.0}}, - {{0.0, 0.0, 0.0, 0.0}}, - {{0.0, 0.0, 0.0, 0.0}}, - {{0.0, 0.0, 0.0, 0.0}} - }; std::vector _windowRendering = { {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0}, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index c11e21c3bf..d948e4f279 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -25,9 +25,13 @@ void MonitorBox::paintEvent(QPaintEvent *event) painter.setPen(pen); paintWidgetBorder(painter, width(), height()); - paintMonitorOutlines(painter); - - //Draw window outline(s) + //Draw window out-of-bounds region(s) + for (unsigned int i = 0; i < _nWindows; ++i) { + paintWindowBeyondBounds(painter, i); + } + //Draw & fill monitors over the out-of-bounds regions + paintMonitorBackgrounds(painter); + //Draw window(s) for (unsigned int i = 0; i < _nWindows; ++i) { paintWindow(painter, i); } @@ -38,12 +42,16 @@ void MonitorBox::paintWidgetBorder(QPainter& painter, int width, int height) { painter.drawRoundedRect(0, 0, width - 1, height - 1, 10, 10); } -void MonitorBox::paintMonitorOutlines(QPainter& painter) { +void MonitorBox::paintMonitorBackgrounds(QPainter& painter) { painter.setPen(QPen(Qt::black, 2)); painter.setFont(QFont("Arial", 14)); for (unsigned int i = 0; i < _nMonitors; ++i) { if (i <= _monitorDimensionsScaled.size()) { painter.drawRect(_monitorDimensionsScaled[i]); + QColor fillColor("#DDDDDD"); + QBrush brush(fillColor); + brush.setStyle(Qt::SolidPattern); + painter.fillRect(_monitorDimensionsScaled[i], brush); if (_showLabel) { QPointF textPos = QPointF(_monitorDimensionsScaled[i].left() + 5, _monitorDimensionsScaled[i].top() + 18); @@ -53,8 +61,17 @@ void MonitorBox::paintMonitorOutlines(QPainter& painter) { } } -void MonitorBox::paintWindow(QPainter& painter, unsigned int winIdx) -{ +void MonitorBox::paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx) { + painter.setBrush(Qt::BDiagPattern); + setPenSpecificToWindow(painter, winIdx, false); + if (winIdx <= _windowRendering.size()) { + painter.drawRect(_windowRendering[winIdx]); + } + setPenSpecificToWindow(painter, winIdx, true); + painter.setBrush(Qt::NoBrush); +} + +void MonitorBox::paintWindow(QPainter& painter, unsigned int winIdx) { setPenSpecificToWindow(painter, winIdx, true); if (winIdx <= _windowRendering.size()) { painter.drawRect(_windowRendering[winIdx]); @@ -63,27 +80,10 @@ void MonitorBox::paintWindow(QPainter& painter, unsigned int winIdx) QBrush brush(fillColor); brush.setStyle(Qt::SolidPattern); painter.fillRect(_windowRendering[winIdx], brush); - //Draw areas of window that are past the monitor boundaries - if (_outOfBoundsRect.size() >= winIdx && _outOfBoundsRect[winIdx].size() > 0) { - paintOutOfBoundsAreas(painter, winIdx); - } paintWindowNumber(painter, winIdx); } } -void MonitorBox::paintOutOfBoundsAreas(QPainter& painter, unsigned int winIdx) { - if (_outOfBoundsRect.size() <= winIdx) { - return; - } - painter.setBrush(Qt::BDiagPattern); - setPenSpecificToWindow(painter, winIdx, false); - for (QRectF r : _outOfBoundsRect[winIdx]) { - painter.drawRect(r); - } - setPenSpecificToWindow(painter, winIdx, true); - painter.setBrush(Qt::NoBrush); -} - void MonitorBox::paintWindowNumber(QPainter& painter, unsigned int winIdx) { QPointF textPos = QPointF(_windowRendering[winIdx].left() + 5, _windowRendering[winIdx].bottom() - 5); @@ -183,7 +183,6 @@ void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& w) { -std::cout << "mapWindowResolutionToWidgetCoordinates mon=" << mIdx << ", win=" << wIdx << std::endl; if (mIdx > (_maxNumMonitors - 1) || wIdx > (_nWindows - 1)) { return; } @@ -194,84 +193,5 @@ std::cout << "mapWindowResolutionToWidgetCoordinates mon=" << mIdx << ", win=" < wF.width() * _monitorScaleFactor, wF.height() * _monitorScaleFactor }; - _outOfBoundsRect[wIdx].clear(); - computeOutOfBounds_horizontal(mIdx, wIdx); - computeOutOfBounds_vertical(mIdx, wIdx); this->update(); } - -void MonitorBox::computeOutOfBounds_horizontal(unsigned int mIdx, unsigned int wIdx) { - qreal windowWidthPlusOffset = _windowRendering[wIdx].width() - + _windowRendering[wIdx].x() - _monitorDimensionsScaled[mIdx].x(); - if (windowWidthPlusOffset > _monitorDimensionsScaled[mIdx].width()) { - qreal bounds_x = std::max( - _monitorDimensionsScaled[mIdx].width() + _monitorDimensionsScaled[mIdx].x(), - _windowRendering[wIdx].x() - ); - qreal extent_x = std::min( - _windowRendering[wIdx].width(), - windowWidthPlusOffset - _monitorDimensionsScaled[mIdx].width() - ); - addOutOfBoundsArea_horizontal(wIdx, bounds_x, extent_x); - } - if (_windowRendering[wIdx].x() < _monitorDimensionsScaled[mIdx].x() ) { - qreal extent_x = std::min( - _windowRendering[wIdx].width(), - _monitorDimensionsScaled[mIdx].x() - _windowRendering[wIdx].x() - ); - addOutOfBoundsArea_horizontal(wIdx, _windowRendering[wIdx].x(), - extent_x); - } -} - -void MonitorBox::addOutOfBoundsArea_horizontal(unsigned int wIdx, qreal bounds, - qreal extent) -{ - _outOfBoundsRect[wIdx].push_back({ - bounds, - _windowRendering[wIdx].y(), - extent, - _windowRendering[wIdx].height() - }); -} - -void MonitorBox::computeOutOfBounds_vertical(unsigned int mIdx, unsigned int wIdx) { - qreal windowHeightPlusOffset = _windowRendering[wIdx].height() - + _windowRendering[wIdx].y() - _monitorDimensionsScaled[mIdx].y(); - if (windowHeightPlusOffset > _monitorDimensionsScaled[mIdx].height()) { - qreal bounds_y = std::max( - _monitorDimensionsScaled[mIdx].height() + _monitorDimensionsScaled[mIdx].y(), - _windowRendering[wIdx].y() - ); - qreal extent_y = std::min( - _windowRendering[wIdx].height(), - windowHeightPlusOffset - _monitorDimensionsScaled[mIdx].height() - ); - addOutOfBoundsArea_vertical(wIdx, bounds_y, extent_y); - } - if (_windowRendering[wIdx].y() < _monitorDimensionsScaled[mIdx].y() ) { - qreal extent_y = std::min( - _windowRendering[wIdx].height(), - _monitorDimensionsScaled[mIdx].y() - _windowRendering[wIdx].y() - ); - _outOfBoundsRect[wIdx].push_back({ - _windowRendering[wIdx].x(), - _windowRendering[wIdx].y(), - _windowRendering[wIdx].width(), - extent_y - }); - addOutOfBoundsArea_vertical(wIdx, _windowRendering[wIdx].y(), - extent_y); - } -} - -void MonitorBox::addOutOfBoundsArea_vertical(unsigned int wIdx, - qreal bounds, qreal extent) -{ - _outOfBoundsRect[wIdx].push_back({ - _windowRendering[wIdx].x(), - bounds, - _windowRendering[wIdx].width(), - extent - }); -} From 9f5e8a7de87ec058200486226c3648081449cd9c Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 21 Jan 2022 23:23:09 -0700 Subject: [PATCH 44/93] Hide window options that don't apply to current selected projection type --- .../launcher/include/sgctedit/windowcontrol.h | 8 +- .../ext/launcher/src/sgctedit/display.cpp | 13 +-- .../ext/launcher/src/sgctedit/orientation.cpp | 1 - .../src/sgctedit/orientationdialog.cpp | 5 - .../launcher/src/sgctedit/windowcontrol.cpp | 107 +++++++++--------- 5 files changed, 62 insertions(+), 72 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index eb77008194..f95f18e06b 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -32,7 +32,7 @@ public: ~WindowControl(); void setDimensions(const QRectF& dimensions); void setWindowChangeCallback(std::function cb); - void setWebGuiChangeCallback(std::function cb); + void setWebGuiChangeCallback(std::function cb); void showWindowLabel(bool show); void cleanupLayouts(); QVBoxLayout* initializeLayout(QWidget* parentWidget); @@ -86,12 +86,11 @@ private slots: void onWebGuiSelection(int selectionState); private: - void enableSpoutProjectionOptions(QComboBox* comboBox, bool enable); template void enableProjectionOption(T* comboModel, int selectionIndex, bool enable); void updateScaledWindowDimensions(); std::function _windowChangeCallback; - std::function _windowGuiCheckCallback; + std::function _windowGuiCheckCallback; QRectF defaultWindowSizes[4] = { {50.0, 50.0, 1280.0, 720.0}, {900.0, 250.0, 1280.0, 720.0}, @@ -152,6 +151,7 @@ private: QComboBox* _comboMonitorSelect = nullptr; QComboBox* _comboProjection = nullptr; QComboBox* _comboQuality = nullptr; + QLabel* _labelQuality = nullptr; QLabel* _labelFovH = nullptr; QLineEdit* _lineFovH = nullptr; QDoubleValidator* _validatorFovH = nullptr; @@ -180,8 +180,8 @@ private: QHBoxLayout* _layoutFullscreenButton = nullptr; QHBoxLayout* _layoutCBoxWindowDecor = nullptr; QHBoxLayout* _layoutCBoxWebGui = nullptr; - QHBoxLayout* _layoutCBoxSpoutOutput = nullptr; QHBoxLayout* _layoutComboProjection = nullptr; + QHBoxLayout* _layoutCBoxSpoutOutput = nullptr; QHBoxLayout* _layoutComboQuality = nullptr; QHBoxLayout* _layoutFovH = nullptr; QHBoxLayout* _layoutFovV = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 67b426cae7..ec3954299a 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -64,7 +64,6 @@ void Display::initializeLayout() { _layoutWindows = new QHBoxLayout(); _layout->addStretch(); - //_winCtrlLayouts.push_back(_windowControl[0]->initializeLayout(this)); for (unsigned int i = 0; i < _nMaxWindows; ++i) { _winCtrlLayouts.push_back(_windowControl[i]->initializeLayout(this)); _layoutWindowWrappers.push_back(new QWidget()); @@ -79,9 +78,6 @@ void Display::initializeLayout() { _nWindowsDisplayed = 1; showWindows(); _layout->addLayout(_layoutWindows); - //for (WindowControl* w : _windowControl) { - // w->cleanupLayouts(); - //} } std::vector Display::windowControls() { @@ -148,9 +144,12 @@ void Display::initializeWindowControl() { } ); _windowControl.back()->setWebGuiChangeCallback( - [this](unsigned int monIndex, unsigned int winIndex) { - _windowControl[(winIndex == 0)? 1 : 0]->uncheckWebGuiOption(); - _webGuiCheckCallback(monIndex); + [this](unsigned int winIndex) { + for (unsigned int w = 0; w < _nMaxWindows; ++w) { + if (w != winIndex) { + _windowControl[w]->uncheckWebGuiOption(); + } + } } ); _monBox->mapWindowResolutionToWidgetCoordinates( diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index 58a5c608f0..2477e1d923 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -15,7 +15,6 @@ Orientation::Orientation() _layoutOrientationFull->addStretch(1); _layoutOrientationFull->addLayout(_layoutOrientationControls); _layoutOrientationFull->addStretch(1); - //_layoutOrientationFull->setSizeConstraint(QLayout::SetFixedSize); connect(_orientationButton, SIGNAL(released()), this, SLOT(orientationDialog())); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index ea2d997b07..e0ceb61366 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -38,31 +38,26 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) _layoutPitch->addStretch(1); _layoutPitch->addWidget(_labelPitch); _layoutPitch->addWidget(_linePitch); - //_layoutPitch->addStretch(1); _layoutWindow->addLayout(_layoutPitch); _layoutRoll->addStretch(1); _layoutRoll->addWidget(_labelRoll); _layoutRoll->addWidget(_lineRoll); - //_layoutRoll->addStretch(1); _layoutWindow->addLayout(_layoutRoll); _layoutYaw->addStretch(1); _layoutYaw->addWidget(_labelYaw); _layoutYaw->addWidget(_lineYaw); - //_layoutYaw->addStretch(1); _layoutWindow->addLayout(_layoutYaw); _layoutButtonBox = new QHBoxLayout; _buttonSave = new QPushButton("OK"); _buttonSave->setToolTip("Save global orientation changes"); - //connect(_buttonSave, &QPushButton::clicked, this, &ModulesDialog::listItemSave); _layoutButtonBox->addStretch(1); _layoutButtonBox->addWidget(_buttonSave); _buttonCancel = new QPushButton("Cancel"); _buttonCancel->setToolTip("Cancel global orientation changes"); - //connect(_buttonCancel, &QPushButton::clicked, this, &ModulesDialog::listItemCancelSave); _layoutButtonBox->addWidget(_buttonCancel); _layoutButtonBox->addStretch(1); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 1f2012ef05..a29075bb0c 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -180,6 +180,9 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutCBoxSpoutOutput->addStretch(1); _layoutProjectionGroup->addLayout(_layoutCBoxSpoutOutput); _layoutComboQuality = new QHBoxLayout(); + _labelQuality = new QLabel(); + _labelQuality->setText("Quality:"); + _layoutComboQuality->addWidget(_labelQuality); _layoutComboQuality->addWidget(_comboQuality); _layoutComboQuality->addStretch(1); _layoutProjectionGroup->addLayout(_layoutComboQuality); @@ -208,6 +211,7 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { _layoutCheckboxesFull1->addLayout(_layoutCheckboxesFull2); _layoutCheckboxesFull1->addStretch(1); _layoutWindowCtrl->addLayout(_layoutCheckboxesFull1); + _layoutWindowCtrl->addStretch(1); _layoutFullWindow->addLayout(_layoutWindowCtrl); _comboProjection->setCurrentIndex(0); @@ -299,7 +303,7 @@ void WindowControl::enableGuiWindowSelection(bool enabled) { void WindowControl::onWebGuiSelection(int selectionState) { if (_windowGuiCheckCallback && (selectionState == Qt::Checked)) { - _windowGuiCheckCallback(_monIndex, _index); + _windowGuiCheckCallback(_index); } } @@ -311,19 +315,6 @@ void WindowControl::onSpoutSelection(int selectionState) { { _comboProjection->setCurrentIndex(ProjectionIndeces::Equirectangular); } - enableSpoutProjectionOptions(_comboProjection, false); - } - else { - enableSpoutProjectionOptions(_comboProjection, true); - } -} - -void WindowControl::enableSpoutProjectionOptions(QComboBox* comboBox, bool enable) { - auto * comboModel = qobject_cast(comboBox->model()); - if (comboModel) { - enableProjectionOption(comboModel, ProjectionIndeces::Planar, enable); - enableProjectionOption(comboModel, ProjectionIndeces::Spherical_Mirror, enable); - enableProjectionOption(comboModel, ProjectionIndeces::Cylindrical, enable); } } @@ -346,58 +337,63 @@ void WindowControl::onMonitorChanged(int newSelection) { void WindowControl::onProjectionChanged(int newSelection) { switch (newSelection) { case ProjectionIndeces::Planar: - _comboQuality->setEnabled(false); - _labelFovH->setEnabled(true); - _lineFovH->setEnabled(true); - _labelFovV->setEnabled(true); - _lineFovV->setEnabled(true); - _labelHeightOffset->setEnabled(false); - _lineHeightOffset->setEnabled(false); - _checkBoxSpoutOutput->setEnabled(false); + _comboQuality->setVisible(false); + _labelQuality->setVisible(false); + _labelFovH->setVisible(true); + _lineFovH->setVisible(true); + _labelFovV->setVisible(true); + _lineFovV->setVisible(true); + _labelHeightOffset->setVisible(false); + _lineHeightOffset->setVisible(false); + _checkBoxSpoutOutput->setVisible(false); break; case ProjectionIndeces::Fisheye: - _comboQuality->setEnabled(true); - _labelFovH->setEnabled(false); - _lineFovH->setEnabled(false); - _labelFovV->setEnabled(false); - _lineFovV->setEnabled(false); - _labelHeightOffset->setEnabled(false); - _lineHeightOffset->setEnabled(false); - _checkBoxSpoutOutput->setEnabled(true); + _comboQuality->setVisible(true); + _labelQuality->setVisible(true); + _labelFovH->setVisible(false); + _lineFovH->setVisible(false); + _labelFovV->setVisible(false); + _lineFovV->setVisible(false); + _labelHeightOffset->setVisible(false); + _lineHeightOffset->setVisible(false); + _checkBoxSpoutOutput->setVisible(true); break; case ProjectionIndeces::Spherical_Mirror: - _comboQuality->setEnabled(true); - _labelFovH->setEnabled(false); - _lineFovH->setEnabled(false); - _labelFovV->setEnabled(false); - _lineFovV->setEnabled(false); - _labelHeightOffset->setEnabled(false); - _lineHeightOffset->setEnabled(false); - _checkBoxSpoutOutput->setEnabled(false); + _comboQuality->setVisible(true); + _labelQuality->setVisible(true); + _labelFovH->setVisible(false); + _lineFovH->setVisible(false); + _labelFovV->setVisible(false); + _lineFovV->setVisible(false); + _labelHeightOffset->setVisible(false); + _lineHeightOffset->setVisible(false); + _checkBoxSpoutOutput->setVisible(false); break; case ProjectionIndeces::Cylindrical: - _comboQuality->setEnabled(true); - _labelFovH->setEnabled(false); - _lineFovH->setEnabled(false); - _labelFovV->setEnabled(false); - _lineFovV->setEnabled(false); - _labelHeightOffset->setEnabled(true); - _lineHeightOffset->setEnabled(true); - _checkBoxSpoutOutput->setEnabled(false); + _comboQuality->setVisible(true); + _labelQuality->setVisible(true); + _labelFovH->setVisible(false); + _lineFovH->setVisible(false); + _labelFovV->setVisible(false); + _lineFovV->setVisible(false); + _labelHeightOffset->setVisible(true); + _lineHeightOffset->setVisible(true); + _checkBoxSpoutOutput->setVisible(false); break; case ProjectionIndeces::Equirectangular: - _comboQuality->setEnabled(true); - _labelFovH->setEnabled(false); - _lineFovH->setEnabled(false); - _labelFovV->setEnabled(false); - _lineFovV->setEnabled(false); - _labelHeightOffset->setEnabled(false); - _lineHeightOffset->setEnabled(false); - _checkBoxSpoutOutput->setEnabled(true); + _comboQuality->setVisible(true); + _labelQuality->setVisible(true); + _labelFovH->setVisible(false); + _lineFovH->setVisible(false); + _labelFovV->setVisible(false); + _lineFovV->setVisible(false); + _labelHeightOffset->setVisible(false); + _lineHeightOffset->setVisible(false); + _checkBoxSpoutOutput->setVisible(true); break; } } @@ -413,7 +409,7 @@ void WindowControl::setWindowChangeCallback( } void WindowControl::setWebGuiChangeCallback( - std::function cb) + std::function cb) { _windowGuiCheckCallback = cb; } @@ -547,6 +543,7 @@ WindowControl::~WindowControl() delete _labelHeightOffset; delete _lineHeightOffset; delete _validatorHeightOffset; + delete _labelQuality; delete _layoutFullscreenButton; delete _layoutCBoxWindowDecor; delete _layoutCBoxWebGui; From 4518cfab4901a8be0ed97b53c96f37a8d11d4c36 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 23 Jan 2022 21:16:43 -0700 Subject: [PATCH 45/93] Fixed problem with 2 monitors scaling in portrait configuration --- apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h | 2 +- apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h | 3 +-- apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp | 4 ++-- apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp | 6 ------ 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index d8b09f433c..fa8cfa3191 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -22,7 +22,7 @@ class MonitorBox : public QWidget Q_OBJECT public: explicit MonitorBox(QRect widgetDims, std::vector monitorResolution, - unsigned int nWindows, bool showMonitorLabel, QString* winColors); + unsigned int nWindows, QString* winColors); ~MonitorBox(); void mapMonitorResolutionToWidgetCoordinates(); void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index 8f841c4671..69ff043624 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -43,10 +43,9 @@ private: QVBoxLayout* _displayLayout = nullptr; QFrame* _displayFrame = nullptr; Display* _displayWidget = nullptr; - QRect _monitorWidgetSize = {0, 0, 400, 350}; + QRect _monitorWidgetSize = {0, 0, 500, 500}; FileSupport* _fileSupportWidget = nullptr; Orientation* _orientationWidget = nullptr; - bool _showMonitorLabel = false; sgct::config::Cluster& _cluster; std::vector& _windowList; bool _saveSelected = false; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index d948e4f279..23ab2f2764 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -2,14 +2,14 @@ MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, - unsigned int nWindows, bool showMonitorLabel, QString* winColors) + unsigned int nWindows, QString* winColors) : _monitorWidgetSize(widgetDims) , _monitorResolution(monitorResolution) , _nWindows(nWindows) - , _showLabel(showMonitorLabel) , _colorsForWindows(winColors) { _nMonitors = monitorResolution.size(); + _showLabel = (_nMonitors > 1); mapMonitorResolutionToWidgetCoordinates(); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 36d2d22d78..0e1c418b65 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -44,17 +44,11 @@ void SgctEdit::createWidgets() { QHBoxLayout* layoutMainH = new QHBoxLayout; _orientationWidget = new Orientation(); - if (_monitorSizeList.size() > 1) { - _monitorWidgetSize = QRect(0, 0, 600, 350); - _showMonitorLabel = true; - } - { _monBox = new MonitorBox( _monitorWidgetSize, _monitorSizeList, _nMaxWindows, - _showMonitorLabel, _colorsForWindows ); QHBoxLayout* layoutMonBox = new QHBoxLayout(); From 3cf15920d0f1e00b0ed5f8543426481abca32992 Mon Sep 17 00:00:00 2001 From: GPayne Date: Mon, 24 Jan 2022 23:24:01 -0700 Subject: [PATCH 46/93] json output changes to support updated sgct --- .../ext/launcher/include/sgctedit/filesupport.h | 1 + .../ext/launcher/src/launcherwindow.cpp | 11 ++++++++--- .../ext/launcher/src/sgctedit/filesupport.cpp | 17 ++++++++++++++++- apps/OpenSpace/ext/sgct | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index 1872c6630d..d04ed85e3e 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -29,6 +29,7 @@ public: int findGuiWindow(); void saveCluster(); void saveWindows(); + void saveUser(); void saveProjectionInformation(bool isSpoutSelected, int projectionIndex, WindowControl* winControl, sgct::config::Viewport& viewport); std::string saveFilename(); diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 99262b23e7..2746fa9e4a 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -143,13 +143,12 @@ namespace { } void saveWindowConfig(QWidget* parent, const std::string& path, - std::vector& windowList, sgct::config::Cluster& cluster) { std::ofstream outFile; try { outFile.open(path, std::ofstream::out); - outFile << sgct::serializeWindowConfig(windowList, cluster); + outFile << sgct::serializeConfig(cluster); } catch (const std::ofstream::failure& e) { QMessageBox::critical( @@ -527,7 +526,13 @@ void LauncherWindow::openWindowEditor() { if (editor.wasSaved()) { std::string fullFilename = editor.saveFilename() + ".json"; const std::string path = _userConfigPath + fullFilename; - saveWindowConfig(this, path, windowList, cluster); + if (cluster.nodes.size() == 0) { + cluster.nodes.push_back(sgct::config::Node()); + } + for (auto w : windowList) { + cluster.nodes[0].windows.push_back(w); + } + saveWindowConfig(this, path, cluster); populateWindowConfigsList(fullFilename); } else { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index d4b3ff61fc..ae79490424 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -39,18 +39,32 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL connect(_lineFilename, SIGNAL(textEdited(const QString&)), this, SLOT(filenameEdited(const QString&))); _saveButton->setEnabled(false); - _cluster.masterAddress = "127.0.0.1"; + _cluster.masterAddress = "localhost"; } void FileSupport::saveCluster() { if (_orientationWidget) { sgct::config::Scene initScene; initScene.orientation = _orientationWidget->orientationValue(); + if (_cluster.nodes.size() == 0) { + _cluster.nodes.push_back(sgct::config::Node()); + } + _cluster.nodes.back().address = "localhost"; + _cluster.nodes.back().port = 20401; _cluster.scene = std::move(initScene); _cluster.firmSync = _orientationWidget->vsyncValue(); } } +void FileSupport::saveUser() { + if (_orientationWidget) { + sgct::config::User user; + user.eyeSeparation = 0.065; + user.position = {0.0, 0.0, 4.0}; + _cluster.users.push_back(user); + } +} + bool FileSupport::isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims) { sgct::ivec2 mDims = {_monitors[monitorIdx].width(), _monitors[monitorIdx].height()}; return ((mDims.x == wDims.x) && (mDims.y == wDims.y)); @@ -214,6 +228,7 @@ std::string FileSupport::saveFilename() { void FileSupport::save() { saveCluster(); saveWindows(); + saveUser(); _finishedCallback(true); } diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index bdab900632..f8659e216d 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit bdab9006323747a6af7e0c1f407810c51e72db80 +Subproject commit f8659e216dfdc99b56f345bd9c24876543784acb From d165c8508bee96a47f60fd2e5b3a388591712a70 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Tue, 25 Jan 2022 13:10:58 -0700 Subject: [PATCH 47/93] Merged master in --- apps/OpenSpace/ext/sgct | 2 +- apps/OpenSpace/main.cpp | 4 +- .../examples/temperature_land_highres.asset | 48 +- ...om_w1_sea_ice_concentration_temporal.asset | 22 +- .../colorlayers/aqua_modis_temporal.asset | 22 +- .../layers/colorlayers/esri_viirs_combo.asset | 22 +- ...sst_sea_surface_temperature_temporal.asset | 22 +- ...mur_sea_surface_temperature_temporal.asset | 22 +- .../modis_terra_chlorophyll_a_temporal.asset | 16 +- .../colorlayers/terra_modis_temporal.asset | 22 +- .../colorlayers/viirs_snpp_temporal.asset | 22 +- .../nightlayers/earth_at_night_temporal.asset | 22 +- .../planets/mars/default_layers.asset | 2 +- data/assets/util/webgui.asset | 2 +- ext/ghoul | 2 +- include/openspace/engine/windowdelegate.h | 3 +- .../openspace/navigation/orbitalnavigator.h | 1 + include/openspace/navigation/pathnavigator.h | 3 + include/openspace/rendering/renderengine.h | 2 + .../util/kameleonfieldlinehelper.h | 1 + modules/galaxy/galaxymodule.cpp | 7 + modules/galaxy/galaxymodule.h | 2 + modules/galaxy/rendering/renderablegalaxy.cpp | 9 +- modules/galaxy/rendering/renderablegalaxy.h | 2 + modules/globebrowsing/CMakeLists.txt | 22 +- modules/globebrowsing/globebrowsingmodule.cpp | 44 +- .../globebrowsing/globebrowsingmodule_lua.inl | 2 +- .../globebrowsing/scripts/layer_support.lua | 69 +- .../globebrowsing/shaders/interpolate_fs.glsl | 12 +- .../src/asynctiledataprovider.cpp | 2 - .../globebrowsing/src/asynctiledataprovider.h | 2 - modules/globebrowsing/src/basictypes.h | 6 +- modules/globebrowsing/src/layer.cpp | 20 +- modules/globebrowsing/src/layer.h | 9 +- modules/globebrowsing/src/layeradjustment.cpp | 2 +- modules/globebrowsing/src/layeradjustment.h | 2 - modules/globebrowsing/src/layergroup.cpp | 11 +- modules/globebrowsing/src/layergroup.h | 5 +- modules/globebrowsing/src/layermanager.cpp | 4 +- modules/globebrowsing/src/renderableglobe.cpp | 21 +- modules/globebrowsing/src/tileprovider.cpp | 2009 ----------------- modules/globebrowsing/src/tileprovider.h | 292 --- .../src/tileprovider/defaulttileprovider.cpp | 204 ++ .../src/tileprovider/defaulttileprovider.h | 61 + .../imagesequencetileprovider.cpp | 158 ++ .../tileprovider/imagesequencetileprovider.h | 60 + .../tileprovider/singleimagetileprovider.cpp | 100 + .../tileprovider/singleimagetileprovider.h | 53 + .../sizereferencetileprovider.cpp | 121 + .../tileprovider/sizereferencetileprovider.h | 49 + .../src/tileprovider/temporaltileprovider.cpp | 822 +++++++ .../src/tileprovider/temporaltileprovider.h | 130 ++ .../src/tileprovider/texttileprovider.cpp | 109 + .../src/tileprovider/texttileprovider.h | 60 + .../tileprovider/tileindextileprovider.cpp | 65 + .../src/tileprovider/tileindextileprovider.h | 27 +- .../src/tileprovider/tileprovider.cpp | 238 ++ .../src/tileprovider/tileprovider.h | 145 ++ .../src/tileprovider/tileproviderbyindex.cpp | 140 ++ .../src/tileprovider/tileproviderbyindex.h | 51 + .../src/tileprovider/tileproviderbylevel.cpp | 161 ++ .../src/tileprovider/tileproviderbylevel.h | 55 + .../rendering/renderablecrawlingline.cpp | 2 +- .../rendering/renderablefov.cpp | 2 +- .../rendering/renderablemodelprojection.cpp | 2 +- .../rendering/renderableplaneprojection.cpp | 5 + .../rendering/renderableplaneprojection.h | 2 + .../rendering/renderableplanetprojection.cpp | 2 +- .../rendering/renderableshadowcylinder.cpp | 2 +- .../spacecraftinstrumentsmodule.cpp | 7 +- .../util/projectioncomponent.cpp | 2 +- .../rendering/renderabletoyvolume.cpp | 2 +- src/navigation/orbitalnavigator.cpp | 35 +- src/navigation/path.cpp | 1 - src/navigation/pathnavigator.cpp | 42 +- src/navigation/pathnavigator_lua.inl | 14 +- src/rendering/renderengine.cpp | 15 +- support/coding/codegen | 2 +- tests/CMakeLists.txt | 1 - 79 files changed, 3196 insertions(+), 2567 deletions(-) delete mode 100644 modules/globebrowsing/src/tileprovider.cpp delete mode 100644 modules/globebrowsing/src/tileprovider.h create mode 100644 modules/globebrowsing/src/tileprovider/defaulttileprovider.cpp create mode 100644 modules/globebrowsing/src/tileprovider/defaulttileprovider.h create mode 100644 modules/globebrowsing/src/tileprovider/imagesequencetileprovider.cpp create mode 100644 modules/globebrowsing/src/tileprovider/imagesequencetileprovider.h create mode 100644 modules/globebrowsing/src/tileprovider/singleimagetileprovider.cpp create mode 100644 modules/globebrowsing/src/tileprovider/singleimagetileprovider.h create mode 100644 modules/globebrowsing/src/tileprovider/sizereferencetileprovider.cpp create mode 100644 modules/globebrowsing/src/tileprovider/sizereferencetileprovider.h create mode 100644 modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp create mode 100644 modules/globebrowsing/src/tileprovider/temporaltileprovider.h create mode 100644 modules/globebrowsing/src/tileprovider/texttileprovider.cpp create mode 100644 modules/globebrowsing/src/tileprovider/texttileprovider.h create mode 100644 modules/globebrowsing/src/tileprovider/tileindextileprovider.cpp rename tests/test_temporaltileprovider.cpp => modules/globebrowsing/src/tileprovider/tileindextileprovider.h (71%) create mode 100644 modules/globebrowsing/src/tileprovider/tileprovider.cpp create mode 100644 modules/globebrowsing/src/tileprovider/tileprovider.h create mode 100644 modules/globebrowsing/src/tileprovider/tileproviderbyindex.cpp create mode 100644 modules/globebrowsing/src/tileprovider/tileproviderbyindex.h create mode 100644 modules/globebrowsing/src/tileprovider/tileproviderbylevel.cpp create mode 100644 modules/globebrowsing/src/tileprovider/tileproviderbylevel.h diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index f8659e216d..15c2a977e1 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit f8659e216dfdc99b56f345bd9c24876543784acb +Subproject commit 15c2a977e16350f9c98a4ef74d6b35a43d35b0bb diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 234168f2a9..6d0084bc21 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -865,11 +865,11 @@ void setSgctDelegateFunctions() { currentWindow->viewports().front()->nonLinearProjection() ) != nullptr; }; - sgctDelegate.takeScreenshot = [](bool applyWarping) { + sgctDelegate.takeScreenshot = [](bool applyWarping, std::vector windowIds) { ZoneScoped Settings::instance().setCaptureFromBackBuffer(applyWarping); - Engine::instance().takeScreenshot(); + Engine::instance().takeScreenshot(std::move(windowIds)); return Engine::instance().screenShotNumber(); }; sgctDelegate.swapBuffer = []() { diff --git a/data/assets/examples/temperature_land_highres.asset b/data/assets/examples/temperature_land_highres.asset index 40b562e1f7..b34baebc90 100644 --- a/data/assets/examples/temperature_land_highres.asset +++ b/data/assets/examples/temperature_land_highres.asset @@ -7,28 +7,46 @@ local path = asset.syncedResource({ Version = 1 }) -local layer = { - Identifier = "ERA5_Land_HighRes_Monthly_2M_Temperature_Temporal", - Name = "ERA5 Land HighRes Monthly 2M Temperature (Temporal)", +local layer_prototype = { + Identifier = "ERA5_Land_HighRes_Monthly_2M_Temperature_Temporal_prototype", + Name = "ERA5 Land HighRes Monthly 2M Temperature (Temporal) [Prototype]", Type = "TemporalTileLayer", - FilePath = - "" .. - "1981-01-01" .. - "1990-10-01" .. - "1M" .. - "YYYY-MM-DD" .. - "" .. path .. "rainbow.png" .. - "linear" .. - "" .. path .. "${OpenSpaceTimeId}-land.png" .. - "", + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "1981-01-01", + End = "1990-10-01" + }, + TemporalResolution = "1M", + TimeFormat = "YYYY-MM-DD", + Prototype = path .. "${OpenSpaceTimeId}-land.png" + }, + Interpolation = true, + Colormap = path .. "rainbow.png", + Description = [[ Temporal coverage: 01 Jan 1981 - 31 Dec 2020.]] +} + +local layer_folder = { + Identifier = "ERA5_Land_HighRes_Monthly_2M_Temperature_Temporal_folder", + Name = "ERA5 Land HighRes Monthly 2M Temperature (Temporal) [Folder]", + Type = "TemporalTileLayer", + Mode = "Folder", + Folder = { + Folder = "C:/Development/sync/http/earth_textures_climate/1", + Format = "%Y-%m-%d-land.png" + }, + Interpolation = true, + Colormap = path .. "rainbow.png", Description = [[ Temporal coverage: 01 Jan 1981 - 31 Dec 2020.]] } asset.onInitialize(function () - openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer) + openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer_prototype) + openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer_folder) end) -asset.export("layer", layer) +asset.export("layer", layer_prototype) + asset.meta = { Name = "Climate Earth Layers", Version = "1.0", diff --git a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/amsr2_gcom_w1_sea_ice_concentration_temporal.asset b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/amsr2_gcom_w1_sea_ice_concentration_temporal.asset index 60af47fdec..98388e8e7b 100644 --- a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/amsr2_gcom_w1_sea_ice_concentration_temporal.asset +++ b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/amsr2_gcom_w1_sea_ice_concentration_temporal.asset @@ -4,14 +4,20 @@ local layer = { Identifier = "AMSR2_GCOM_W1_Sea_Ice_Concentration_Temporal", Name = "AMSR2 GCOM W1 Sea Ice Concentration (Temporal)", Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "AMSRU2_Sea_Ice_Concentration_12km", - "2012-05-08", - "Yesterday", - "1d", - "2km", - "png" - ), + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "2012-05-08", + End = "Yesterday" + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml( + "AMSRU2_Sea_Ice_Concentration_12km", + "2km", + "png" + ) + }, Description = [[ Temporal coverage: 02 July 2012 - Present. The Advanced Microwave Scanning Radiometer-E/Advanced Microwave Scanning Radiometer-2 (AMSR-E/AMSR2) unified "Sea Ice Concentration (12 km)" layer displays the percent of sea ice diff --git a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/aqua_modis_temporal.asset b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/aqua_modis_temporal.asset index 61b122ca64..4807d05cd1 100644 --- a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/aqua_modis_temporal.asset +++ b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/aqua_modis_temporal.asset @@ -4,14 +4,20 @@ local layer = { Identifier = "Aqua_Modis_Temporal", Name = "Aqua Modis (Temporal)", Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "MODIS_Aqua_CorrectedReflectance_TrueColor", - "2002-07-04", - "Yesterday", - "1d", - "250m", - "jpg" - ), + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "2002-07-04", + End = "Yesterday" + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml( + "MODIS_Aqua_CorrectedReflectance_TrueColor", + "250m", + "jpg" + ) + }, Description = [[ Temporal coverage: 03 July 2002 - Present. True Color: Red = Band 1, Green = Band 4, Blue = Band 3. These images are called true-color or natural color because this combination of wavelengths is similar to what the human eye would see. diff --git a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/esri_viirs_combo.asset b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/esri_viirs_combo.asset index 35ecc0b6e2..374d067466 100644 --- a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/esri_viirs_combo.asset +++ b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/esri_viirs_combo.asset @@ -13,14 +13,20 @@ local layer = { Identifier = "Temporal_VIIRS_SNPP", Name = "Temporal VIIRS SNPP", Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "VIIRS_SNPP_CorrectedReflectance_TrueColor", - "2015-11-24", - "Today", - "1d", - "250m", - "jpg" - ), + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "2015-11-24", + End = "Today" + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml( + "VIIRS_SNPP_CorrectedReflectance_TrueColor", + "250m", + "jpg" + ) + }, PadTiles = false } }, diff --git a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/ghrsst_l4_g1sst_sea_surface_temperature_temporal.asset b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/ghrsst_l4_g1sst_sea_surface_temperature_temporal.asset index 876fd0199e..9bf43d88d2 100644 --- a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/ghrsst_l4_g1sst_sea_surface_temperature_temporal.asset +++ b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/ghrsst_l4_g1sst_sea_surface_temperature_temporal.asset @@ -4,14 +4,20 @@ local layer = { Identifier = "GHRSST_L4_G1SST_Sea_Surface_Temperature_Temporal", Name = "GHRSST L4 G1SST Sea Surface Temperature (Temporal)", Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "GHRSST_L4_G1SST_Sea_Surface_Temperature", - "2010-06-21", - "2019-12-08", - "1d", - "1km", - "png" - ), + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "2010-06-21", + End = "2019-12-08" + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml( + "GHRSST_L4_G1SST_Sea_Surface_Temperature", + "1km", + "png" + ) + }, Description = [[ Temporal coverage: 21 June 2010 - 08 December 2019. The imagery resolution is 1 km, and the temporal resolution is daily.]], Author = "NASA EOSDIS Global Imagery Browse Services" diff --git a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/ghrsst_l4_mur_sea_surface_temperature_temporal.asset b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/ghrsst_l4_mur_sea_surface_temperature_temporal.asset index 0225ddc0c0..4efb087717 100644 --- a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/ghrsst_l4_mur_sea_surface_temperature_temporal.asset +++ b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/ghrsst_l4_mur_sea_surface_temperature_temporal.asset @@ -4,14 +4,20 @@ local layer = { Identifier = "GHRSST_L4_MUR_Sea_Surface_Temperature_Temporal", Name = "GHRSST L4 MUR Sea Surface Temperature (Temporal)", Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "GHRSST_L4_MUR_Sea_Surface_Temperature", - "2002-06-01", - "Yesterday", - "1d", - "1km", - "png" - ), + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "2002-06-01", + End = "Yesterday" + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml( + "GHRSST_L4_MUR_Sea_Surface_Temperature", + "1km", + "png" + ) + }, Description = [[ Temporal coverage: 01 June 2002 - Present. The imagery resolution is 1 km, and the temporal resolution is daily.]] } diff --git a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/modis_terra_chlorophyll_a_temporal.asset b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/modis_terra_chlorophyll_a_temporal.asset index 186d771ad0..c4377b380e 100644 --- a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/modis_terra_chlorophyll_a_temporal.asset +++ b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/modis_terra_chlorophyll_a_temporal.asset @@ -4,14 +4,20 @@ local layer = { Identifier = "MODIS_Terra_Chlorophyll_A_Temporal", Name = "MODIS Terra Chlorophyll A (Temporal)", Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "2013-07-02", + End = "Yesterday" + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml( "MODIS_Terra_Chlorophyll_A", - "2013-07-02", - "Yesterday", - "1d", "1km", "png" - ), + ) + }, Description = [[ Temporal coverage: 02 July 2013 - Present. The imagery resolution is 1 km, and the temporal resolution is daily.]] } diff --git a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/terra_modis_temporal.asset b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/terra_modis_temporal.asset index 2324d3a9ea..fa39b2eff3 100644 --- a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/terra_modis_temporal.asset +++ b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/terra_modis_temporal.asset @@ -4,14 +4,20 @@ local layer = { Identifier = "Terra_Modis_Temporal", Name = "Terra Modis (Temporal)", Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "MODIS_Terra_CorrectedReflectance_TrueColor", - "2000-02-24", - "Yesterday", - "1d", - "250m", - "jpg" - ), + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "2000-02-24", + End = "Yesterday" + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml( + "MODIS_Terra_CorrectedReflectance_TrueColor", + "250m", + "jpg" + ) + }, Description = [[ Temporal coverage: 02 July 2013 - Present. The imagery resolution is 1 km, and the temporal resolution is daily.]] } diff --git a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/viirs_snpp_temporal.asset b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/viirs_snpp_temporal.asset index b52e86a434..d1bb41c089 100644 --- a/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/viirs_snpp_temporal.asset +++ b/data/assets/scene/solarsystem/planets/earth/layers/colorlayers/viirs_snpp_temporal.asset @@ -4,14 +4,20 @@ local layer = { Identifier = "VIIRS_SNPP_Temporal", Name = "VIIRS SNPP (Temporal)", Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "VIIRS_SNPP_CorrectedReflectance_TrueColor", - "2015-11-24", - "Yesterday", - "1d", - "250m", - "jpg" - ), + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "2015-11-24", + End = "Yesterday" + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml( + "VIIRS_SNPP_CorrectedReflectance_TrueColor", + "250m", + "jpg" + ) + }, Description = [[ Temporal coverage: 11 November 2015 - Present. The imagery resolution is 0.25 km, and the temporal resolution is daily.]] } diff --git a/data/assets/scene/solarsystem/planets/earth/layers/nightlayers/earth_at_night_temporal.asset b/data/assets/scene/solarsystem/planets/earth/layers/nightlayers/earth_at_night_temporal.asset index fa0a192e23..bd3c7f6cfb 100644 --- a/data/assets/scene/solarsystem/planets/earth/layers/nightlayers/earth_at_night_temporal.asset +++ b/data/assets/scene/solarsystem/planets/earth/layers/nightlayers/earth_at_night_temporal.asset @@ -4,14 +4,20 @@ local layer = { Identifier = "Earth_at_Night_Temporal", Name = "Earth at Night (Temporal)", Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "VIIRS_SNPP_DayNightBand_ENCC", - "2012-05-08", - "Yesterday", - "1d", - "500m", - "png" - ), + Mode = "Prototyped", + Prototyped = { + Time = { + Start = "2012-05-08", + End = "Yesterday" + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml( + "VIIRS_SNPP_DayNightBand_ENCC", + "500m", + "png" + ) + }, Description = [[ The VIIRS Nighttime Imagery (Day/Night Band, Enhanced Near Constant Contrast) layer shows the Earth's surface and atmosphere using a sensor designed to capture low-light emission sources, under varying illumination conditions. It diff --git a/data/assets/scene/solarsystem/planets/mars/default_layers.asset b/data/assets/scene/solarsystem/planets/mars/default_layers.asset index f691513188..198fa783b5 100644 --- a/data/assets/scene/solarsystem/planets/mars/default_layers.asset +++ b/data/assets/scene/solarsystem/planets/mars/default_layers.asset @@ -20,7 +20,7 @@ asset.require("./layers/colorlayers/hirisels") -- Height layers asset.require("./layers/heightlayers/mola_sweden") asset.require("./layers/heightlayers/mola_utah") -local heightLayer = asset.require("./layers/heightlayers/mdem200m") +local heightLayer = asset.require("./layers/heightlayers/MDEM200M") asset.require("./layers/heightlayers/hirisels") -- Overlays diff --git a/data/assets/util/webgui.asset b/data/assets/util/webgui.asset index eca2e190a7..203b14ea9d 100644 --- a/data/assets/util/webgui.asset +++ b/data/assets/util/webgui.asset @@ -3,7 +3,7 @@ asset.require("./static_server") local guiCustomization = asset.require("customization/gui") -- Select which commit hashes to use for the frontend and backend -local frontendHash = "4fe18eea379c8493dbcb2cea6798d09a85819912" +local frontendHash = "7e513ba86b0bb989b72f22712ebf0bb5a626ba06" local dataProvider = "data.openspaceproject.com/files/webgui" local frontend = asset.syncedResource({ diff --git a/ext/ghoul b/ext/ghoul index 0edf5e2588..a94d2561aa 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 0edf5e2588e80f402b7449ad7384ceddadd09f03 +Subproject commit a94d2561aadf0b2423185c266b3f77cc8676da04 diff --git a/include/openspace/engine/windowdelegate.h b/include/openspace/engine/windowdelegate.h index 1c2138b2dc..2ebdb6853a 100644 --- a/include/openspace/engine/windowdelegate.h +++ b/include/openspace/engine/windowdelegate.h @@ -76,7 +76,8 @@ struct WindowDelegate { bool (*isFisheyeRendering)() = []() { return false; }; - unsigned int (*takeScreenshot)(bool applyWarping) = [](bool) { return 0u; }; + unsigned int (*takeScreenshot)(bool applyWarping, std::vector windowIds) = + [](bool, std::vector) { return 0u; }; void (*swapBuffer)() = []() {}; diff --git a/include/openspace/navigation/orbitalnavigator.h b/include/openspace/navigation/orbitalnavigator.h index f541e78788..6820a2cfd9 100644 --- a/include/openspace/navigation/orbitalnavigator.h +++ b/include/openspace/navigation/orbitalnavigator.h @@ -148,6 +148,7 @@ private: // Reset camera direction to the aim node. properties::TriggerProperty _retargetAim; + properties::BoolProperty _followAnchorNodeRotation; properties::FloatProperty _followAnchorNodeRotationDistance; properties::FloatProperty _minimumAllowedDistance; diff --git a/include/openspace/navigation/pathnavigator.h b/include/openspace/navigation/pathnavigator.h index dbf8940825..b993d086bc 100644 --- a/include/openspace/navigation/pathnavigator.h +++ b/include/openspace/navigation/pathnavigator.h @@ -81,6 +81,8 @@ public: static scripting::LuaLibrary luaLibrary(); private: + void handlePathEnd(); + /** * Populate list of nodes that are relevant for collision checks, etc */ @@ -90,6 +92,7 @@ private: std::unique_ptr _currentPath = nullptr; bool _isPlaying = false; + bool _startSimulationTimeOnFinish = false; properties::OptionProperty _defaultPathType; properties::BoolProperty _includeRoll; diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index d0f0e419e2..24dde421ca 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -177,6 +178,7 @@ private: properties::BoolProperty _showVersionInfo; properties::BoolProperty _showCameraInfo; + properties::IntListProperty _screenshotWindowIds; properties::BoolProperty _applyWarping; properties::BoolProperty _screenshotUseDate; properties::BoolProperty _showFrameInformation; diff --git a/modules/fieldlinessequence/util/kameleonfieldlinehelper.h b/modules/fieldlinessequence/util/kameleonfieldlinehelper.h index 008137d153..c86c146bb0 100644 --- a/modules/fieldlinessequence/util/kameleonfieldlinehelper.h +++ b/modules/fieldlinessequence/util/kameleonfieldlinehelper.h @@ -27,6 +27,7 @@ #include #include +#include #include namespace openspace { diff --git a/modules/galaxy/galaxymodule.cpp b/modules/galaxy/galaxymodule.cpp index 06670632d4..0000784d55 100644 --- a/modules/galaxy/galaxymodule.cpp +++ b/modules/galaxy/galaxymodule.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -47,4 +48,10 @@ void GalaxyModule::internalInitialize(const ghoul::Dictionary&) { fTask->registerClass("MilkywayPointsConversionTask"); } +std::vector GalaxyModule::documentations() const { + return { + RenderableGalaxy::Documentation() + }; +} + } // namespace openspace diff --git a/modules/galaxy/galaxymodule.h b/modules/galaxy/galaxymodule.h index f34f294da5..8664ed84d7 100644 --- a/modules/galaxy/galaxymodule.h +++ b/modules/galaxy/galaxymodule.h @@ -35,6 +35,8 @@ public: GalaxyModule(); + std::vector documentations() const override; + private: void internalInitialize(const ghoul::Dictionary&) override; }; diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index ce1602f36d..5ce17025ff 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -55,7 +55,7 @@ namespace { constexpr int8_t CurrentCacheVersion = 1; - constexpr const char* _loggerCat = "Renderable Galaxy"; + constexpr const char* _loggerCat = "RenderableGalaxy"; enum StarRenderingMethod { Points, @@ -125,8 +125,7 @@ namespace { { "Downscale", "Downscale Factor Volume Rendering", - "This value set the downscaling factor" - " when rendering the current volume." + "This value sets the downscaling factor when rendering the current volume." }; constexpr openspace::properties::Property::PropertyInfo NumberOfRayCastingStepsInfo = @@ -229,6 +228,10 @@ namespace { namespace openspace { +documentation::Documentation RenderableGalaxy::Documentation() { + return codegen::doc("galaxy_renderablegalaxy"); +} + RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _volumeRenderingEnabled(VolumeRenderingEnabledInfo, true) diff --git a/modules/galaxy/rendering/renderablegalaxy.h b/modules/galaxy/rendering/renderablegalaxy.h index 16841fd097..6d7755d82a 100644 --- a/modules/galaxy/rendering/renderablegalaxy.h +++ b/modules/galaxy/rendering/renderablegalaxy.h @@ -54,6 +54,8 @@ public: void render(const RenderData& data, RendererTasks& tasks) override; void update(const UpdateData& data) override; + static documentation::Documentation Documentation(); + private: void renderPoints(const RenderData& data); void renderBillboards(const RenderData& data); diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index b36fb93297..26d8a1e221 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -57,9 +57,18 @@ set(HEADER_FILES src/skirtedgrid.h src/tileindex.h src/tileloadjob.h - src/tileprovider.h src/tiletextureinitdata.h src/timequantizer.h + src/tileprovider/defaulttileprovider.h + src/tileprovider/imagesequencetileprovider.h + src/tileprovider/singleimagetileprovider.h + src/tileprovider/sizereferencetileprovider.h + src/tileprovider/temporaltileprovider.h + src/tileprovider/texttileprovider.h + src/tileprovider/tileindextileprovider.h + src/tileprovider/tileprovider.h + src/tileprovider/tileproviderbyindex.h + src/tileprovider/tileproviderbylevel.h ) set(SOURCE_FILES @@ -87,9 +96,18 @@ set(SOURCE_FILES src/skirtedgrid.cpp src/tileindex.cpp src/tileloadjob.cpp - src/tileprovider.cpp src/tiletextureinitdata.cpp src/timequantizer.cpp + src/tileprovider/defaulttileprovider.cpp + src/tileprovider/imagesequencetileprovider.cpp + src/tileprovider/singleimagetileprovider.cpp + src/tileprovider/sizereferencetileprovider.cpp + src/tileprovider/temporaltileprovider.cpp + src/tileprovider/texttileprovider.cpp + src/tileprovider/tileindextileprovider.cpp + src/tileprovider/tileprovider.cpp + src/tileprovider/tileproviderbyindex.cpp + src/tileprovider/tileproviderbylevel.cpp ) source_group("Source Files" FILES ${SOURCE_FILES}) diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 56418d997d..baeef89d6d 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -35,7 +35,15 @@ #include #include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -236,7 +244,7 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { _tileCache = std::make_unique(_tileCacheSizeMB); addPropertySubOwner(_tileCache.get()); - tileprovider::initializeDefaultTile(); + TileProvider::initializeDefaultTile(); // Convert from MB to Bytes GdalWrapper::create( @@ -249,10 +257,9 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { global::callback::deinitializeGL->emplace_back([]() { ZoneScopedN("GlobeBrowsingModule") - tileprovider::deinitializeDefaultTile(); + TileProvider::deinitializeDefaultTile(); }); - // Render global::callback::render->emplace_back([&]() { ZoneScopedN("GlobeBrowsingModule") @@ -279,46 +286,45 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { ghoul_assert(fRotation, "Rotation factory was not created"); fRotation->registerClass("GlobeRotation"); - auto fTileProvider = - std::make_unique>(); + auto fTileProvider = std::make_unique>(); ghoul_assert(fTileProvider, "TileProvider factory was not created"); - fTileProvider->registerClass( + fTileProvider->registerClass( layergroupid::LAYER_TYPE_NAMES[static_cast( layergroupid::TypeID::DefaultTileLayer )] ); - fTileProvider->registerClass( + fTileProvider->registerClass( layergroupid::LAYER_TYPE_NAMES[static_cast( layergroupid::TypeID::SingleImageTileLayer )] ); - fTileProvider->registerClass( + fTileProvider->registerClass( layergroupid::LAYER_TYPE_NAMES[static_cast( layergroupid::TypeID::ImageSequenceTileLayer )] ); - fTileProvider->registerClass( + fTileProvider->registerClass( layergroupid::LAYER_TYPE_NAMES[static_cast( layergroupid::TypeID::TemporalTileLayer )] ); - fTileProvider->registerClass( + fTileProvider->registerClass( layergroupid::LAYER_TYPE_NAMES[static_cast( layergroupid::TypeID::TileIndexTileLayer )] ); - fTileProvider->registerClass( + fTileProvider->registerClass( layergroupid::LAYER_TYPE_NAMES[static_cast( layergroupid::TypeID::SizeReferenceTileLayer )] ); - fTileProvider->registerClass( + fTileProvider->registerClass( layergroupid::LAYER_TYPE_NAMES[static_cast( layergroupid::TypeID::ByLevelTileLayer )] ); - fTileProvider->registerClass( + fTileProvider->registerClass( layergroupid::LAYER_TYPE_NAMES[static_cast( layergroupid::TypeID::ByIndexTileLayer )] @@ -376,12 +382,14 @@ scripting::LuaLibrary GlobeBrowsingModule::luaLibrary() const { "moveLayer", &globebrowsing::luascriptfunctions::moveLayer, "string, string, number, number", - "Rearranges the order of a single layer in a scene graph node. The first " - "parameter specifies the scene graph node, the second parameter specifies " + "Rearranges the order of a single layer on a globe. The first parameter" + "is the identifier of the globe, the second parameter specifies " "the name of the layer group, the third parameter is the original position " "of the layer that should be moved and the last parameter is the new " - "position. The new position may be -1 to place the layer at the top or any " - "large number bigger than the number of layers to place it at the bottom." + "position in the list. The first position in the list has index 0, and the " + "last position is given by the number of layers minus one. The new position " + "may be -1 to place the layer at the top or any number bigger than the " + "number of layers to place it at the bottom." }, { "goToChunk", diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index 2cb2d26889..2dd7398a66 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -169,7 +169,7 @@ int moveLayer(lua_State* L) { } globebrowsing::LayerGroup& lg = globe->layerManager().layerGroup(group); - lg.moveLayers(oldPosition, newPosition); + lg.moveLayer(oldPosition, newPosition); return 0; } diff --git a/modules/globebrowsing/scripts/layer_support.lua b/modules/globebrowsing/scripts/layer_support.lua index 0d3b94cc85..8f2d50bc29 100644 --- a/modules/globebrowsing/scripts/layer_support.lua +++ b/modules/globebrowsing/scripts/layer_support.lua @@ -1,30 +1,11 @@ openspace.globebrowsing.documentation = { { Name = "createTemporalGibsGdalXml", - Arguments = "string, string, string, string, string, string, [string]", - Documentation = - "Creates an XML configuration for a temporal GIBS dataset." .. - "Arguments are: Name, Start date, end date, time resolution, time format," .. - "resolution, file format. The last parameter is the temporal format and " .. - "defaults to YYYY-MM-DD. For all specifications, see " .. - "https://wiki.earthdata.nasa.gov/display/GIBS/GIBS+Available+Imagery+Products" .. - "Usage:" .. - "openspace.globebrowsing.addLayer(" .. - "\"Earth\"," .. - "\"ColorLayers\"," .. - "{" .. - "Type = \"TemporalTileLayer\"," .. - "Name = \"MODIS_Terra_Chlorophyll_A\"," .. - "FilePath = openspace.globebrowsing.createTemporalGibsGdalXml(" .. - "\"MODIS_Terra_Chlorophyll_A\"," .. - "\"2013-07-02\"," .. - "\"Yesterday\"," .. - "\"1d\"," .. - "\"1km\"," .. - "\"png\"" .. - ")" .. - "}" .. - ")" + Arguments = "string, string, string", + Documentation = [[ + Creates an XML configuration for a temporal GIBS dataset to be used in + a TemporalTileprovider + ]] }, { Name = "createGibsGdalXml", @@ -40,7 +21,7 @@ openspace.globebrowsing.documentation = { "\"ColorLayers\"," .. "{" .. "Name = \"MODIS_Terra_Chlorophyll_A\"," .. - "FilePath = openspace.globebrowsing.createTemporalGibsGdalXml(" .. + "FilePath = openspace.globebrowsing.createGibsGdalXml(" .. "\"MODIS_Terra_Chlorophyll_A\"," .. "\"2013-07-02\"," .. "\"1km\"," .. @@ -111,21 +92,27 @@ openspace.globebrowsing.addGibsLayer = function(layer, resolution, format, start if endDate == 'Present' then endDate = '' end - local xml = openspace.globebrowsing.createTemporalGibsGdalXml(layer, startDate, endDate, '1d', resolution, format) - openspace.globebrowsing.addLayer('Earth', 'ColorLayers', { Identifier = layer, Type = "TemporalTileLayer", FilePath = xml }) -end -openspace.globebrowsing.createTemporalGibsGdalXml = function (layerName, startDate, endDate, timeResolution, resolution, format, temporalFormat) - temporalFormat = temporalFormat or 'YYYY-MM-DD' - local temporalTemplate = - "" .. - "" .. startDate .. "" .. - "" .. endDate .. "" .. - "" .. timeResolution .. "" .. - "" .. temporalFormat .. "" .. - openspace.globebrowsing.createGibsGdalXml(layerName, "${OpenSpaceTimeId}", resolution, format) .. - "" - return temporalTemplate + local layer = { + Identifier = layerName, + Type = "TemporalTileLayer", + Mode = "Prototyped", + Prototyped = { + Time = { + Start = startDate, + End = endDate + }, + TemporalResolution = "1d", + TimeFormat = "YYYY-MM-DD", + Prototype = openspace.globebrowsing.createTemporalGibsGdalXml(layerName, resolution, format) + } + } + + openspace.globebrowsing.addLayer( + 'Earth', + 'ColorLayers', + layer + ) end openspace.globebrowsing.createGibsGdalXml = function (layerName, date, resolution, format) @@ -196,6 +183,10 @@ openspace.globebrowsing.createGibsGdalXml = function (layerName, date, resolutio return gdalWmsTemplate end +openspace.globebrowsing.createTemporalGibsGdalXml = function (layerName, resolution, format) + return openspace.globebrowsing.createGibsGdalXml(layerName, "${OpenSpaceTimeId}", resolution, format) +end + openspace.globebrowsing.parseInfoFile = function (file) -- We are loading these values from an external info file and since we are switching -- to a strict Lua, we need to predefine these global variables diff --git a/modules/globebrowsing/shaders/interpolate_fs.glsl b/modules/globebrowsing/shaders/interpolate_fs.glsl index a6835c858d..7654a8ac79 100644 --- a/modules/globebrowsing/shaders/interpolate_fs.glsl +++ b/modules/globebrowsing/shaders/interpolate_fs.glsl @@ -26,25 +26,23 @@ uniform sampler2D prevTexture; uniform sampler2D nextTexture; -uniform sampler2D colormapTexture; +uniform sampler1D colormapTexture; uniform float blendFactor; in vec2 texCoord; Fragment getFragment() { - vec4 texel0 = texture2D(prevTexture, texCoord); - vec4 texel1 = texture2D(nextTexture, texCoord); + vec4 texel0 = texture(prevTexture, texCoord); + vec4 texel1 = texture(nextTexture, texCoord); vec4 mixedTexture = mix(texel0, texel1, blendFactor); Fragment frag; if (mixedTexture.r > 0.999) { - vec2 position = vec2(mixedTexture.r - 0.01, 0.5); - frag.color = texture2D(colormapTexture, position); + frag.color = texture(colormapTexture, mixedTexture.r - 0.01); } else { - vec2 position = vec2(mixedTexture.r , 0.5); - frag.color = texture2D(colormapTexture, position); + frag.color = texture(colormapTexture, mixedTexture.r); } frag.color.a = mixedTexture.a; diff --git a/modules/globebrowsing/src/asynctiledataprovider.cpp b/modules/globebrowsing/src/asynctiledataprovider.cpp index e4829851d9..264a3006e0 100644 --- a/modules/globebrowsing/src/asynctiledataprovider.cpp +++ b/modules/globebrowsing/src/asynctiledataprovider.cpp @@ -50,8 +50,6 @@ AsyncTileDataProvider::AsyncTileDataProvider(std::string name, performReset(ResetRawTileDataReader::No); } -AsyncTileDataProvider::~AsyncTileDataProvider() {} // NOLINT - const RawTileDataReader& AsyncTileDataProvider::rawTileDataReader() const { return *_rawTileDataReader; } diff --git a/modules/globebrowsing/src/asynctiledataprovider.h b/modules/globebrowsing/src/asynctiledataprovider.h index fb48af2ffa..34e4325c10 100644 --- a/modules/globebrowsing/src/asynctiledataprovider.h +++ b/modules/globebrowsing/src/asynctiledataprovider.h @@ -50,8 +50,6 @@ public: AsyncTileDataProvider(std::string name, std::unique_ptr rawTileDataReader); - ~AsyncTileDataProvider(); - /** * Creates a job which asynchronously loads a raw tile. This job is enqueued. */ diff --git a/modules/globebrowsing/src/basictypes.h b/modules/globebrowsing/src/basictypes.h index c73c531a0c..0feec1945a 100644 --- a/modules/globebrowsing/src/basictypes.h +++ b/modules/globebrowsing/src/basictypes.h @@ -115,9 +115,8 @@ struct TileMetaData { class Tile { public: /** - * Describe if this Tile is good for usage (OK) or otherwise - * the reason why it is not. - */ + * Describe if this Tile is good for usage (OK) or otherwise the reason why it is not. + */ enum class Status { /** * E.g when texture data is not currently in memory. @@ -168,7 +167,6 @@ struct ChunkTile { -//using ChunkTilePile = std::vector; // The ChunkTilePile either contains 1 or 3 ChunkTile, depending on if layer-blending is // enabled. If it is enabled, we need the two adjacent levels, if it is not enabled, only // the current layer is needed diff --git a/modules/globebrowsing/src/layer.cpp b/modules/globebrowsing/src/layer.cpp index 51a20a5c1e..f5b9070074 100644 --- a/modules/globebrowsing/src/layer.cpp +++ b/modules/globebrowsing/src/layer.cpp @@ -286,13 +286,13 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict, _reset.onChange([&]() { if (_tileProvider) { - tileprovider::reset(*_tileProvider); + _tileProvider->reset(); } }); _remove.onChange([&]() { if (_tileProvider) { - tileprovider::reset(*_tileProvider); + _tileProvider->reset(); _parent.deleteLayer(identifier()); } }); @@ -360,13 +360,13 @@ void Layer::initialize() { ZoneScoped if (_tileProvider) { - tileprovider::initialize(*_tileProvider); + _tileProvider->initialize(); } } void Layer::deinitialize() { if (_tileProvider) { - tileprovider::deinitialize(*_tileProvider); + _tileProvider->deinitialize(); } } @@ -374,7 +374,7 @@ ChunkTilePile Layer::chunkTilePile(const TileIndex& tileIndex, int pileSize) con ZoneScoped if (_tileProvider) { - return tileprovider::chunkTilePile(*_tileProvider, tileIndex, pileSize); + return _tileProvider->chunkTilePile(tileIndex, pileSize); } else { ChunkTilePile chunkTilePile; @@ -390,7 +390,7 @@ ChunkTilePile Layer::chunkTilePile(const TileIndex& tileIndex, int pileSize) con Tile::Status Layer::tileStatus(const TileIndex& index) const { return _tileProvider ? - tileprovider::tileStatus(*_tileProvider, index) : + _tileProvider->tileStatus(index) : Tile::Status::Unavailable; } @@ -404,7 +404,7 @@ layergroupid::BlendModeID Layer::blendMode() const { TileDepthTransform Layer::depthTransform() const { return _tileProvider ? - tileprovider::depthTransform(*_tileProvider) : + _tileProvider->depthTransform() : TileDepthTransform{ 1.f, 0.f }; } @@ -416,7 +416,7 @@ bool Layer::enabled() const { return _enabled; } -tileprovider::TileProvider* Layer::tileProvider() const { +TileProvider* Layer::tileProvider() const { return _tileProvider.get(); } @@ -440,7 +440,7 @@ void Layer::update() { ZoneScoped if (_tileProvider) { - tileprovider::update(*_tileProvider); + _tileProvider->update(); } } @@ -483,7 +483,7 @@ void Layer::initializeBasedOnType(layergroupid::TypeID id, ghoul::Dictionary ini std::string name = initDict.value(KeyName); LDEBUG("Initializing tile provider for layer: '" + name + "'"); } - _tileProvider = tileprovider::createFromDictionary(id, std::move(initDict)); + _tileProvider = TileProvider::createFromDictionary(id, std::move(initDict)); break; } case layergroupid::TypeID::SolidColor: { diff --git a/modules/globebrowsing/src/layer.h b/modules/globebrowsing/src/layer.h index d42ea1fdd9..5b90055c87 100644 --- a/modules/globebrowsing/src/layer.h +++ b/modules/globebrowsing/src/layer.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -40,8 +40,7 @@ namespace openspace::globebrowsing { struct LayerGroup; struct TileIndex; - -namespace tileprovider { struct TileProvider; } +struct TileProvider; class Layer : public properties::PropertyOwner { public: @@ -59,7 +58,7 @@ public: TileDepthTransform depthTransform() const; void setEnabled(bool enabled); bool enabled() const; - tileprovider::TileProvider* tileProvider() const; + TileProvider* tileProvider() const; glm::vec3 solidColor() const; const LayerRenderSettings& renderSettings() const; const LayerAdjustment& layerAdjustment() const; @@ -89,7 +88,7 @@ private: properties::StringProperty _guiDescription; layergroupid::TypeID _type; - std::unique_ptr _tileProvider; + std::unique_ptr _tileProvider; properties::Vec3Property _solidColor; LayerRenderSettings _renderSettings; LayerAdjustment _layerAdjustment; diff --git a/modules/globebrowsing/src/layeradjustment.cpp b/modules/globebrowsing/src/layeradjustment.cpp index 2205bcd9d9..a28cb273f8 100644 --- a/modules/globebrowsing/src/layeradjustment.cpp +++ b/modules/globebrowsing/src/layeradjustment.cpp @@ -74,7 +74,7 @@ documentation::Documentation LayerAdjustment::Documentation() { } LayerAdjustment::LayerAdjustment() - : properties::PropertyOwner({ "adjustment" }) + : properties::PropertyOwner({ "Adjustment" }) , _chromaKeyColor(ChromaKeyColorInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(1.f)) , _chromaKeyTolerance(ChromaKeyToleranceInfo, 0.f, 0.f, 1.f) , _typeOption(TypeInfo, properties::OptionProperty::DisplayType::Dropdown) diff --git a/modules/globebrowsing/src/layeradjustment.h b/modules/globebrowsing/src/layeradjustment.h index c864ab1b93..cbd2616e1d 100644 --- a/modules/globebrowsing/src/layeradjustment.h +++ b/modules/globebrowsing/src/layeradjustment.h @@ -36,8 +36,6 @@ namespace openspace::documentation { struct Documentation; } namespace openspace::globebrowsing { -namespace tileprovider { struct TileProvider; } - class LayerAdjustment : public properties::PropertyOwner { public: LayerAdjustment(); diff --git a/modules/globebrowsing/src/layergroup.cpp b/modules/globebrowsing/src/layergroup.cpp index 65245e6255..3adf42d366 100644 --- a/modules/globebrowsing/src/layergroup.cpp +++ b/modules/globebrowsing/src/layergroup.cpp @@ -212,16 +212,9 @@ void LayerGroup::deleteLayer(const std::string& layerName) { LERROR("Could not find layer " + layerName); } -void LayerGroup::moveLayers(int oldPosition, int newPosition) { +void LayerGroup::moveLayer(int oldPosition, int newPosition) { oldPosition = std::max(0, oldPosition); - newPosition = std::min(newPosition, static_cast(_layers.size())); - - // We need to adjust the new position as we first delete the old position, if this - // position is before the new position we have reduced the size of the vector by 1 and - // need to adapt where we want to put the value in - if (oldPosition < newPosition) { - newPosition -= 1; - } + newPosition = std::min(newPosition, static_cast(_layers.size() - 1)); // There are two synchronous vectors that we have to update here. The _layers vector // is used to determine the order while rendering, the _subowners is the order in diff --git a/modules/globebrowsing/src/layergroup.h b/modules/globebrowsing/src/layergroup.h index 3b2d2b7148..565826c76f 100644 --- a/modules/globebrowsing/src/layergroup.h +++ b/modules/globebrowsing/src/layergroup.h @@ -33,8 +33,7 @@ namespace openspace::globebrowsing { class Layer; - -namespace tileprovider { struct TileProvider; } +struct TileProvider; /** * Convenience class for dealing with multiple Layers. @@ -52,7 +51,7 @@ struct LayerGroup : public properties::PropertyOwner { Layer* addLayer(const ghoul::Dictionary& layerDict); void deleteLayer(const std::string& layerName); - void moveLayers(int oldPosition, int newPosition); + void moveLayer(int oldPosition, int newPosition); /// @returns const vector of all layers std::vector layers() const; diff --git a/modules/globebrowsing/src/layermanager.cpp b/modules/globebrowsing/src/layermanager.cpp index 8674ec1af2..24e0faad86 100644 --- a/modules/globebrowsing/src/layermanager.cpp +++ b/modules/globebrowsing/src/layermanager.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -155,7 +155,7 @@ void LayerManager::reset(bool includeDisabled) { for (std::unique_ptr& layerGroup : _layerGroups) { for (Layer* layer : layerGroup->layers()) { if ((layer->enabled() || includeDisabled) && layer->tileProvider()) { - tileprovider::reset(*layer->tileProvider()); + layer->tileProvider()->reset(); } } } diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 24907b6e96..3458fae95a 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -322,7 +322,7 @@ ChunkTileVector tilesAndSettingsUnsorted(const LayerGroup& layerGroup, for (Layer* layer : layerGroup.activeLayers()) { if (layer->tileProvider()) { tilesAndSettings.emplace_back( - tileprovider::chunkTile(*layer->tileProvider(), tileIndex), + layer->tileProvider()->chunkTile(tileIndex), &layer->renderSettings() ); } @@ -403,7 +403,7 @@ bool colorAvailableForChunk(const Chunk& chunk, const LayerManager& lm) { for (Layer* lyr : colorLayers.activeLayers()) { if (lyr->tileProvider()) { - ChunkTile t = tileprovider::chunkTile(*lyr->tileProvider(), chunk.tileIndex); + ChunkTile t = lyr->tileProvider()->chunkTile(chunk.tileIndex); if (t.tile.status == Tile::Status::Unavailable) { return false; } @@ -1886,16 +1886,15 @@ float RenderableGlobe::getHeight(const glm::dvec3& position) const { _layerManager.layerGroup(layergroupid::GroupID::HeightLayers).activeLayers(); for (Layer* layer : heightMapLayers) { - tileprovider::TileProvider* tileProvider = layer->tileProvider(); + TileProvider* tileProvider = layer->tileProvider(); if (!tileProvider) { continue; } // Transform the uv coordinates to the current tile texture - const ChunkTile chunkTile = tileprovider::chunkTile(*tileProvider, tileIndex); + const ChunkTile chunkTile = tileProvider->chunkTile(tileIndex); const Tile& tile = chunkTile.tile; const TileUvTransform& uvTransform = chunkTile.uvTransform; - const TileDepthTransform& depthTransform = - tileprovider::depthTransform(*tileProvider); + const TileDepthTransform& depthTransform = tileProvider->depthTransform(); if (tile.status != Tile::Status::OK) { return 0; } @@ -1953,10 +1952,10 @@ float RenderableGlobe::getHeight(const glm::dvec3& position) const { std::isnan(sample11); const bool anySampleIsNoData = - sample00 == tileprovider::noDataValueAsFloat(*tileProvider) || - sample01 == tileprovider::noDataValueAsFloat(*tileProvider) || - sample10 == tileprovider::noDataValueAsFloat(*tileProvider) || - sample11 == tileprovider::noDataValueAsFloat(*tileProvider); + sample00 == tileProvider->noDataValueAsFloat() || + sample01 == tileProvider->noDataValueAsFloat() || + sample10 == tileProvider->noDataValueAsFloat() || + sample11 == tileProvider->noDataValueAsFloat(); if (anySampleIsNaN || anySampleIsNoData) { continue; diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp deleted file mode 100644 index 72b0b57b15..0000000000 --- a/modules/globebrowsing/src/tileprovider.cpp +++ /dev/null @@ -1,2009 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2022 * - * * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpl_minixml.h" - -namespace ghoul { - template <> - constexpr openspace::globebrowsing::tileprovider::TemporalTileProvider::TimeFormatType - from_string(std::string_view string) - { - using namespace openspace::globebrowsing::tileprovider; - if (string == "YYYY-MM-DD") { - return TemporalTileProvider::TimeFormatType::YYYY_MM_DD; - } - else if (string == "YYYY-MM-DDThh:mm:ssZ") { - return TemporalTileProvider::TimeFormatType::YYYY_MM_DDThhColonmmColonssZ; - } - else if (string == "YYYY-MM-DDThh_mm_ssZ") { - return TemporalTileProvider::TimeFormatType::YYYY_MM_DDThh_mm_ssZ; - } - else if (string == "YYYYMMDD_hhmmss") { - return TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmmss; - } - else if (string == "YYYYMMDD_hhmm") { - return TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmm; - } - else { - throw ghoul::RuntimeError("Unknown timeformat '" + std::string(string) + "'"); - } - } -} // namespace ghoul - - -namespace openspace::globebrowsing::tileprovider { - -namespace { - -std::unique_ptr DefaultTileTexture; -Tile DefaultTile = Tile { nullptr, std::nullopt, Tile::Status::Unavailable }; - -constexpr const char* KeyFilePath = "FilePath"; - -namespace defaultprovider { - constexpr const char* KeyPerformPreProcessing = "PerformPreProcessing"; - constexpr const char* KeyTilePixelSize = "TilePixelSize"; - constexpr const char* KeyPadTiles = "PadTiles"; - - constexpr openspace::properties::Property::PropertyInfo FilePathInfo = { - "FilePath", - "File Path", - "The path of the GDAL file or the image file that is to be used in this tile " - "provider." - }; - - constexpr openspace::properties::Property::PropertyInfo TilePixelSizeInfo = { - "TilePixelSize", - "Tile Pixel Size", - "This value is the preferred size (in pixels) for each tile. Choosing the right " - "value is a tradeoff between more efficiency (larger images) and better quality " - "(smaller images). The tile pixel size has to be smaller than the size of the " - "complete image if a single image is used." - }; -} // namespace defaultprovider - -namespace singleimageprovider { - constexpr openspace::properties::Property::PropertyInfo FilePathInfo = { - "FilePath", - "File Path", - "The file path that is used for this image provider. The file must point to an " - "image that is then loaded and used for all tiles." - }; -} // namespace singleimageprovider - -namespace imagesequenceprovider { - constexpr openspace::properties::Property::PropertyInfo IndexInfo = { - "Index", - "Index", - "The index into the list of images that is used to pick the currently displayed " - "image" - }; - - constexpr openspace::properties::Property::PropertyInfo CurrentImageInfo = { - "CurrentImage", - "Current Image", - "The read-only value of the currently selected image" - }; - - constexpr openspace::properties::Property::PropertyInfo FolderPathInfo = { - "FolderPath", - "Folder Path", - "The path that is used to look for images for this image provider. The path must " - "point to an existing folder that contains images" - }; -} // namepsace imagesequenceprovider - -namespace sizereferenceprovider { - constexpr const char* KeyRadii = "Radii"; -} // namespace sizereferenceprovider - -namespace byindexprovider { - constexpr const char* KeyDefaultProvider = "DefaultProvider"; - constexpr const char* KeyProviders = "IndexTileProviders"; - constexpr const char* KeyTileIndex = "TileIndex"; - constexpr const char* KeyTileProvider = "TileProvider"; -} // namespace byindexprovider - -namespace bylevelprovider { - constexpr const char* KeyProviders = "LevelTileProviders"; - constexpr const char* KeyMaxLevel = "MaxLevel"; - constexpr const char* KeyTileProvider = "TileProvider"; - constexpr const char* KeyLayerGroupID = "LayerGroupID"; -} // namespace bylevelprovider - -namespace temporal { - constexpr const char* KeyBasePath = "BasePath"; - - constexpr const char* UrlTimePlaceholder = "${OpenSpaceTimeId}"; - constexpr const char* TimeStart = "OpenSpaceTimeStart"; - constexpr const char* TimeEnd = "OpenSpaceTimeEnd"; - constexpr const char* TimeResolution = "OpenSpaceTimeResolution"; - constexpr const char* TimeFormat = "OpenSpaceTimeIdFormat"; - constexpr const char* TimeInterpolation = "OpenSpaceTimeInterpolation"; - constexpr const char* TransferFunction = "OpenSpaceTransferFunction"; - constexpr openspace::properties::Property::PropertyInfo FilePathInfo = { - "FilePath", - "File Path", - "This is the path to the XML configuration file that describes the temporal tile " - "information." - }; - - constexpr openspace::properties::Property::PropertyInfo UseFixedTimeInfo = { - "UseFixedTime", - "Use Fixed Time", - "If this value is enabled, the time-varying timevarying dataset will always use " - "the time that is specified in the 'FixedTime' property, rather than using the " - "actual time from OpenSpace" - }; - - constexpr openspace::properties::Property::PropertyInfo FixedTimeInfo = { - "FixedTime", - "Fixed Time", - "If the 'UseFixedTime' is enabled, this time will be used instead of the actual " - "time taken from OpenSpace for the displayed tiles." - }; -} // namespace temporal - - -// -// DefaultTileProvider -// - -void initAsyncTileDataReader(DefaultTileProvider& t, TileTextureInitData initData) { - ZoneScoped - - t.asyncTextureDataProvider = std::make_unique( - t.name, - std::make_unique( - t.filePath, - initData, - RawTileDataReader::PerformPreprocessing(t.performPreProcessing) - ) - ); -} - -bool initTexturesFromLoadedData(DefaultTileProvider& t) { - ZoneScoped - - if (t.asyncTextureDataProvider) { - std::optional tile = t.asyncTextureDataProvider->popFinishedRawTile(); - if (tile) { - const cache::ProviderTileKey key = { tile->tileIndex, t.uniqueIdentifier }; - ghoul_assert(!t.tileCache->exist(key), "Tile must not be existing in cache"); - t.tileCache->createTileAndPut(key, std::move(*tile)); - return true; - } - } - return false; -} - - -// -// TextTileProvider -// - -void initialize(TextTileProvider& t) { - ZoneScoped - - t.font = global::fontManager->font("Mono", static_cast(t.fontSize)); - t.fontRenderer = ghoul::fontrendering::FontRenderer::createDefault(); - t.fontRenderer->setFramebufferSize(glm::vec2(t.initData.dimensions)); - glGenFramebuffers(1, &t.fbo); -} - -void deinitialize(TextTileProvider& t) { - glDeleteFramebuffers(1, &t.fbo); -} - -Tile tile(TextTileProvider& t, const TileIndex& tileIndex) { - ZoneScoped - TracyGpuZone("tile") - - cache::ProviderTileKey key = { tileIndex, t.uniqueIdentifier }; - Tile tile = t.tileCache->get(key); - if (!tile.texture) { - ghoul::opengl::Texture* texture = t.tileCache->texture(t.initData); - - // Keep track of defaultFBO and viewport to be able to reset state when done - GLint defaultFBO; - defaultFBO = global::renderEngine->openglStateCache().defaultFramebuffer(); - - // Render to texture - glBindFramebuffer(GL_FRAMEBUFFER, t.fbo); - glFramebufferTexture2D( - GL_FRAMEBUFFER, - GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, - *texture, - 0 - ); - - GLsizei w = static_cast(texture->width()); - GLsizei h = static_cast(texture->height()); - glViewport(0, 0, w, h); - glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_COLOR_BUFFER_BIT); - - t.fontRenderer->render(*t.font, t.textPosition, t.text, t.textColor); - - glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - global::renderEngine->openglStateCache().resetViewportState(); - - tile = Tile{ texture, std::nullopt, Tile::Status::OK }; - t.tileCache->put(key, t.initData.hashKey, tile); - } - return tile; -} - -void reset(TextTileProvider& t) { - ZoneScoped - - t.tileCache->clear(); -} - - -// -// TileProviderByLevel -// - -TileProvider* levelProvider(TileProviderByLevel& t, int level) { - ZoneScoped - - if (!t.levelTileProviders.empty()) { - int clampedLevel = glm::clamp( - level, - 0, - static_cast(t.providerIndices.size() - 1) - ); - int idx = t.providerIndices[clampedLevel]; - return t.levelTileProviders[idx].get(); - } - else { - return nullptr; - } -} - - -// -// TemporalTileProvider -// - -// Buffer needs at least 22 characters space -std::string_view timeStringify(TemporalTileProvider::TimeFormatType type, const Time& t) { - ZoneScoped - - char* buffer = reinterpret_cast( - global::memoryManager->TemporaryMemory.allocate(22) - ); - - std::memset(buffer, 0, 22); - const double time = t.j2000Seconds(); - - switch (type) { - case TemporalTileProvider::TimeFormatType::YYYY_MM_DD: - { - constexpr const char Format[] = "YYYY-MM-DD"; - constexpr const int Size = sizeof(Format); - SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); - return std::string_view(buffer, Size - 1); - } - case TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmmss: { - constexpr const char Format[] = "YYYYMMDD_HRMNSC"; - constexpr const int Size = sizeof(Format); - SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); - return std::string_view(buffer, Size - 1); - } - case TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmm: { - constexpr const char Format[] = "YYYYMMDD_HRMN"; - constexpr const int Size = sizeof(Format); - SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); - return std::string_view(buffer, Size - 1); - } - case TemporalTileProvider::TimeFormatType::YYYY_MM_DDThhColonmmColonssZ: - { - constexpr const char Format[] = "YYYY-MM-DDTHR:MN:SCZ"; - constexpr const int Size = sizeof(Format); - SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); - return std::string_view(buffer, Size - 1); - } - case TemporalTileProvider::TimeFormatType::YYYY_MM_DDThh_mm_ssZ: { - constexpr const char Format[] = "YYYY-MM-DDTHR_MN_SCZ"; - constexpr const int Size = sizeof(Format); - SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); - return std::string_view(buffer, Size - 1); - } - default: - throw ghoul::MissingCaseException(); - } -} - -std::unique_ptr initTileProvider(TemporalTileProvider& t, - std::string_view timekey) -{ - ZoneScoped - - static const std::vector IgnoredTokens = { - // From: http://www.gdal.org/frmt_wms.html - "${x}", - "${y}", - "${z}", - "${version}", - "${format}", - "${layer}" - }; - - - std::string xmlTemplate(t.gdalXmlTemplate); - const size_t pos = xmlTemplate.find(temporal::UrlTimePlaceholder); - const size_t numChars = strlen(temporal::UrlTimePlaceholder); - // @FRAGILE: This will only find the first instance. Dangerous if that instance is - // commented out ---abock - std::string xml = xmlTemplate.replace(pos, numChars, timekey); - - xml = FileSys.expandPathTokens(std::move(xml), IgnoredTokens).string(); - - t.initDict.setValue(KeyFilePath, xml); - return std::make_unique(t.initDict); -} - -TileProvider* getTileProvider(TemporalTileProvider& t, std::string_view timekey) { - ZoneScoped - - // @TODO (abock, 2020-08-20) This std::string creation can be removed once we switch - // to C++20 thanks to P0919R2 - const auto it = t.tileProviderMap.find(std::string(timekey)); - if (it != t.tileProviderMap.end()) { - return it->second.get(); - } - else { - std::unique_ptr tileProvider = initTileProvider(t, timekey); - initialize(*tileProvider); - - TileProvider* res = tileProvider.get(); - t.tileProviderMap[std::string(timekey)] = std::move(tileProvider); - return res; - } -} - -TileProvider* getTileProvider(TemporalTileProvider& t, const Time& time) { - ZoneScoped - - if (!t.interpolation) { - if (t.useFixedTime && !t.fixedTime.value().empty()) { - try { - return getTileProvider(t, t.fixedTime.value()); - } - catch (const ghoul::RuntimeError& e) { - LERRORC("TemporalTileProvider", e.message); - return nullptr; - } - } - else { - Time tCopy(time); - if (t.timeQuantizer.quantize(tCopy, true)) { - std::string_view timeStr = timeStringify(t.timeFormat, tCopy); - try { - return getTileProvider(t, timeStr); - } - catch (const ghoul::RuntimeError& e) { - LERRORC("TemporalTileProvider", e.message); - return nullptr; - } - } - } - } - - Time tCopy(time); - if (!t.timeQuantizer.quantize(tCopy, true)) { - return nullptr; - } - - Time simulationTime(time); - Time nextTile; - Time nextNextTile; - Time prevTile; - Time secondToLast; - Time secondToFirst; - - std::string_view tCopyStr = timeStringify(t.timeFormat, tCopy); - try { - t.interpolateTileProvider->t1 = getTileProvider(t, tCopyStr); - } - catch (const ghoul::RuntimeError& e) { - LERRORC("TemporalTileProvider", e.message); - return nullptr; - } - // if the images are for each hour - if (t.myResolution == "1h") { - // the second tile to interpolate between - nextTile.setTime(tCopy.j2000Seconds() + 60 * 60); - // the tile after the second tile - nextNextTile.setTime(tCopy.j2000Seconds() + 120 * 60); - // the tile before the first tile - prevTile.setTime(tCopy.j2000Seconds() - 60 * 60 + 1); - // to make sure that an image outside the dataset is not searched for both ends of - // the dataset are calculated - secondToLast.setTime(t.endTimeJ2000 - 60 * 60); - secondToFirst.setTime(t.startTimeJ2000 + 60 * 60); - } - // if the images are for each month - if (t.myResolution == "1M") { - // the second tile to interpolate between - nextTile.setTime(tCopy.j2000Seconds() + 32 * 60 * 60 * 24); - // the tile after the second tile - nextNextTile.setTime(tCopy.j2000Seconds() + 64 * 60 * 60 * 24); - // the tile before the first tile - prevTile.setTime(tCopy.j2000Seconds() - 2 * 60 * 60 * 24); - // to make sure that an image outside the dataset is not searched for both ends of - // the dataset are calculated - secondToLast.setTime(t.endTimeJ2000 - 2 * 60 * 60 * 24); - secondToFirst.setTime(t.startTimeJ2000 + 32 * 60 * 60 * 24); - - // since months vary in length the time strings are set to the first of each month - auto setToFirstOfMonth = [](Time& time) { - std::string timeString = std::string(time.ISO8601()); - timeString[8] = '0'; - timeString[9] = '1'; - time.setTime(timeString); - }; - - setToFirstOfMonth(nextTile); - setToFirstOfMonth(nextNextTile); - setToFirstOfMonth(prevTile); - setToFirstOfMonth(secondToLast); - setToFirstOfMonth(secondToFirst); - } - - std::string_view nextTileStr = timeStringify(t.timeFormat, nextTile); - std::string_view nextNextTileStr = timeStringify(t.timeFormat, nextNextTile); - std::string_view prevTileStr = timeStringify(t.timeFormat, prevTile); - try { - // the necessary tile providers are loaded if they exist within the - // dataset's timespan - if (secondToLast.j2000Seconds() > simulationTime.j2000Seconds() && - secondToFirst.j2000Seconds() < simulationTime.j2000Seconds()) - { - t.interpolateTileProvider->t2 = getTileProvider(t, nextTileStr); - t.interpolateTileProvider->future = getTileProvider(t, nextNextTileStr); - t.interpolateTileProvider->before = getTileProvider(t, prevTileStr); - } - else if (secondToLast.j2000Seconds() < simulationTime.j2000Seconds() && - t.endTimeJ2000 > simulationTime.j2000Seconds()) - { - t.interpolateTileProvider->t2 = getTileProvider(t, nextTileStr); - t.interpolateTileProvider->future = getTileProvider(t, tCopyStr); - t.interpolateTileProvider->before = getTileProvider(t, prevTileStr); - } - else if (secondToFirst.j2000Seconds() > simulationTime.j2000Seconds() && - t.startTimeJ2000 < simulationTime.j2000Seconds()) - { - t.interpolateTileProvider->t2 = getTileProvider(t, nextTileStr); - t.interpolateTileProvider->future = getTileProvider(t, nextNextTileStr); - t.interpolateTileProvider->before = getTileProvider(t, tCopyStr); - } - else { - t.interpolateTileProvider->t2 = getTileProvider(t, tCopyStr); - t.interpolateTileProvider->future = getTileProvider(t, tCopyStr); - t.interpolateTileProvider->before = getTileProvider(t, tCopyStr); - } - t.interpolateTileProvider->factor = - (simulationTime.j2000Seconds() - tCopy.j2000Seconds()) / - (nextTile.j2000Seconds() - tCopy.j2000Seconds()); - - if (t.interpolateTileProvider->factor > 1) { - t.interpolateTileProvider->factor = 1; - } - return t.interpolateTileProvider.get(); - } - catch (const ghoul::RuntimeError& e) { - LERRORC("TemporalTileProvider", e.message); - return nullptr; - } -} - -void ensureUpdated(TemporalTileProvider& t) { - ZoneScoped - - if (!t.currentTileProvider) { - update(t); - } -} - -std::string xmlValue(TemporalTileProvider& t, CPLXMLNode* node, const std::string& key, - const std::string& defaultVal, bool isOptional = false) -{ - CPLXMLNode* n = CPLSearchXMLNode(node, key.c_str()); - if (!n && !isOptional) { - throw ghoul::RuntimeError( - fmt::format("Unable to parse file {}. {} missing", t.filePath.value(), key) - ); - } - - const bool hasValue = n && n->psChild && n->psChild->pszValue; - return hasValue ? n->psChild->pszValue : defaultVal; -} - -std::string consumeTemporalMetaData(TemporalTileProvider& t, const std::string& xml) { - ZoneScoped - - CPLXMLNode* node = CPLParseXMLString(xml.c_str()); - - std::string timeStart = xmlValue(t, node, temporal::TimeStart, "2000 Jan 1"); - std::string timeResolution = xmlValue(t, node, temporal::TimeResolution, "2d"); - std::string timeEnd = xmlValue(t, node, temporal::TimeEnd, "Today"); - std::string timeIdFormat = xmlValue( - t, - node, - temporal::TimeFormat, - "YYYY-MM-DDThh:mm:ssZ" - ); - std::string timeInterpolation = xmlValue( - t, - node, - temporal::TimeInterpolation, - "none", - true - ); - t.colormap = xmlValue(t, node, temporal::TransferFunction, "none", true); - - Time start = Time(timeStart); - Time end = Time::now(); - Time endOfInterval = Time(timeEnd); - t.startTimeJ2000 = start.j2000Seconds(); - t.endTimeJ2000 = endOfInterval.j2000Seconds(); - if (timeEnd == "Yesterday") { - end.advanceTime(-60.0 * 60.0 * 24.0); // Go back one day - } - else if (timeEnd != "Today") { - end.setTime(std::move(timeEnd)); - } - - try { - t.timeQuantizer.setStartEndRange( - std::string(start.ISO8601()), - std::string(end.ISO8601()) - ); - t.timeQuantizer.setResolution(timeResolution); - t.myResolution = timeResolution; - } - catch (const ghoul::RuntimeError& e) { - throw ghoul::RuntimeError(fmt::format( - "Could not create time quantizer for Temporal GDAL dataset '{}'. {}", - t.filePath.value(), e.message - )); - } - t.timeFormat = ghoul::from_string(timeIdFormat); - t.interpolation = (timeInterpolation == "linear"); - - CPLXMLNode* gdalNode = CPLSearchXMLNode(node, "GDAL_WMS"); - if (gdalNode) { - std::string gdalDescription = CPLSerializeXMLTree(gdalNode); - return gdalDescription; - } - else { - gdalNode = CPLSearchXMLNode(node, "FilePath"); - if (gdalNode) { - std::string gdalDescription = std::string(gdalNode->psChild->pszValue); - return gdalDescription; - } - else { - return ""; - } - } -} - -void readFilePath(TemporalTileProvider& t) { - ZoneScoped - - std::ifstream in(t.filePath.value()); - std::string xml; - if (in.is_open()) { - // read file - xml = std::string( - std::istreambuf_iterator(in), - (std::istreambuf_iterator()) - ); - } - else { - // Assume that it is already an xml - xml = t.filePath; - } - - // File path was not a path to a file but a GDAL config or empty - std::filesystem::path f(t.filePath.value()); - if (std::filesystem::is_regular_file(f)) { - t.initDict.setValue(temporal::KeyBasePath, f.parent_path().string()); - } - - t.gdalXmlTemplate = consumeTemporalMetaData(t, xml); -} - -} // namespace - -unsigned int TileProvider::NumTileProviders = 0; - - -// -// General functions -// -void initializeDefaultTile() { - ZoneScoped - - ghoul_assert(!DefaultTile.texture, "Default tile should not have been created"); - using namespace ghoul::opengl; - - // Create pixel data - TileTextureInitData initData( - 8, - 8, - GL_UNSIGNED_BYTE, - Texture::Format::RGBA, - TileTextureInitData::PadTiles::No, - TileTextureInitData::ShouldAllocateDataOnCPU::Yes - ); - char* pixels = new char[initData.totalNumBytes]; - memset(pixels, 0, initData.totalNumBytes * sizeof(char)); - - // Create ghoul texture - DefaultTileTexture = std::make_unique(initData.dimensions, GL_TEXTURE_2D); - DefaultTileTexture->setDataOwnership(Texture::TakeOwnership::Yes); - DefaultTileTexture->setPixelData(pixels); - DefaultTileTexture->uploadTexture(); - DefaultTileTexture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); - - // Create tile - DefaultTile = Tile{ DefaultTileTexture.get(), std::nullopt, Tile::Status::OK }; -} - -void deinitializeDefaultTile() { - DefaultTileTexture = nullptr; -} - -std::unique_ptr createFromDictionary(layergroupid::TypeID layerTypeID, - const ghoul::Dictionary& dictionary) -{ - ZoneScoped - - const char* type = layergroupid::LAYER_TYPE_NAMES[static_cast(layerTypeID)]; - auto factory = FactoryManager::ref().factory(); - TileProvider* result = factory->create(type, dictionary); - return std::unique_ptr(result); -} - -TileProvider::TileProvider() : properties::PropertyOwner({ "tileProvider" }) {} - -DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary) - : filePath(defaultprovider::FilePathInfo, "") - , tilePixelSize(defaultprovider::TilePixelSizeInfo, 32, 32, 2048) -{ - ZoneScoped - - type = Type::DefaultTileProvider; - - tileCache = global::moduleEngine->module()->tileCache(); - name = "Name unspecified"; - if (dictionary.hasValue("Name")) { - name = dictionary.value("Name"); - } - std::string _loggerCat = "DefaultTileProvider (" + name + ")"; - - // 1. Get required Keys - filePath = dictionary.value(KeyFilePath); - layerGroupID = - static_cast(dictionary.value("LayerGroupID")); - - // 2. Initialize default values for any optional Keys - // getValue does not work for integers - int pixelSize = 0; - if (dictionary.hasValue(defaultprovider::KeyTilePixelSize)) { - pixelSize = static_cast( - dictionary.value(defaultprovider::KeyTilePixelSize) - ); - LDEBUG(fmt::format("Default pixel size overridden: {}", pixelSize)); - } - - if (dictionary.hasValue(defaultprovider::KeyPadTiles)) { - padTiles = dictionary.value(defaultprovider::KeyPadTiles); - } - - TileTextureInitData initData( - tileTextureInitData(layerGroupID, padTiles, pixelSize) - ); - tilePixelSize = initData.dimensions.x; - - - // Only preprocess height layers by default - switch (layerGroupID) { - case layergroupid::GroupID::HeightLayers: performPreProcessing = true; break; - default: performPreProcessing = false; break; - } - - if (dictionary.hasValue(defaultprovider::KeyPerformPreProcessing)) { - performPreProcessing = dictionary.value( - defaultprovider::KeyPerformPreProcessing - ); - LDEBUG(fmt::format( - "Default PerformPreProcessing overridden: {}", performPreProcessing - )); - } - - initAsyncTileDataReader(*this, initData); - - addProperty(filePath); - addProperty(tilePixelSize); -} - - - - - -SingleImageProvider::SingleImageProvider(const ghoul::Dictionary& dictionary) - : filePath(singleimageprovider::FilePathInfo) -{ - ZoneScoped - - type = Type::SingleImageTileProvider; - - filePath = dictionary.value(KeyFilePath); - addProperty(filePath); - - reset(*this); -} - - - - - -ImageSequenceTileProvider::ImageSequenceTileProvider(const ghoul::Dictionary& dictionary) - : index(imagesequenceprovider::IndexInfo, 0) - , currentImage(imagesequenceprovider::CurrentImageInfo) - , folderPath(imagesequenceprovider::FolderPathInfo) - , initDict(dictionary) -{ - ZoneScoped - - type = Type::ImageSequenceTileProvider; - - if (dictionary.hasValue(imagesequenceprovider::IndexInfo.identifier)) { - index = dictionary.value(imagesequenceprovider::IndexInfo.identifier); - } - index.setMinValue(0); - index.onChange([this]() { isImageDirty = true; }); - addProperty(index); - - folderPath.setReadOnly(true); - addProperty(folderPath); - - folderPath = dictionary.value( - imagesequenceprovider::FolderPathInfo.identifier - ); - addProperty(folderPath); - - reset(*this); -} - - - - - -TextTileProvider::TextTileProvider(TileTextureInitData initData_, size_t fontSize_) - : initData(std::move(initData_)) - , fontSize(fontSize_) -{ - ZoneScoped - - tileCache = global::moduleEngine->module()->tileCache(); -} - - - - - -SizeReferenceTileProvider::SizeReferenceTileProvider(const ghoul::Dictionary& dictionary) - : TextTileProvider(tileTextureInitData(layergroupid::GroupID::ColorLayers, false)) -{ - ZoneScoped - - type = Type::SizeReferenceTileProvider; - - font = global::fontManager->font("Mono", static_cast(fontSize)); - - if (dictionary.hasValue(sizereferenceprovider::KeyRadii)) { - ellipsoid = dictionary.value(sizereferenceprovider::KeyRadii); - } - else if (dictionary.hasValue(sizereferenceprovider::KeyRadii)) { - const double r = dictionary.value(sizereferenceprovider::KeyRadii); - ellipsoid = glm::dvec3(r, r, r); - } -} - - - - - -TileIndexTileProvider::TileIndexTileProvider(const ghoul::Dictionary&) - : TextTileProvider(tileTextureInitData(layergroupid::GroupID::ColorLayers, false)) -{ - ZoneScoped - - type = Type::TileIndexTileProvider; -} - - - - - -TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) { - ZoneScoped - - type = Type::ByIndexTileProvider; - - const ghoul::Dictionary& defaultProviderDict = dictionary.value( - byindexprovider::KeyDefaultProvider - ); - - layergroupid::TypeID typeID; - if (defaultProviderDict.hasValue("Type")) { - const std::string& t = defaultProviderDict.value("Type"); - typeID = ghoul::from_string(t); - - if (typeID == layergroupid::TypeID::Unknown) { - throw ghoul::RuntimeError("Unknown layer type: " + t); - } - } - else { - typeID = layergroupid::TypeID::DefaultTileLayer; - } - - defaultTileProvider = createFromDictionary(typeID, defaultProviderDict); - - const ghoul::Dictionary& indexProvidersDict = dictionary.value( - byindexprovider::KeyProviders - ); - for (size_t i = 1; i <= indexProvidersDict.size(); i++) { - ghoul::Dictionary indexProviderDict = indexProvidersDict.value( - std::to_string(i) - ); - ghoul::Dictionary tileIndexDict = indexProviderDict.value( - byindexprovider::KeyTileIndex - ); - ghoul::Dictionary providerDict = indexProviderDict.value( - byindexprovider::KeyTileProvider - ); - - constexpr const char* KeyLevel = "Level"; - constexpr const char* KeyX = "X"; - constexpr const char* KeyY = "Y"; - - int level = static_cast(tileIndexDict.value(KeyLevel)); - ghoul_assert(level < std::numeric_limits::max(), "Level too large"); - int x = static_cast(tileIndexDict.value(KeyX)); - int y = static_cast(tileIndexDict.value(KeyY)); - - const TileIndex tileIndex(x, y, static_cast(level)); - - layergroupid::TypeID providerTypeID = layergroupid::TypeID::DefaultTileLayer; - if (defaultProviderDict.hasValue("Type")) { - const std::string& t = defaultProviderDict.value("Type"); - providerTypeID = ghoul::from_string(t); - - if (providerTypeID == layergroupid::TypeID::Unknown) { - throw ghoul::RuntimeError("Unknown layer type: " + t); - } - } - - std::unique_ptr stp = createFromDictionary( - providerTypeID, - providerDict - ); - TileIndex::TileHashKey key = tileIndex.hashKey(); - tileProviderMap.insert(std::make_pair(key, std::move(stp))); - } -} - - - - - -TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) { - ZoneScoped - - type = Type::ByLevelTileProvider; - - layergroupid::GroupID layerGroupID = static_cast( - dictionary.value(bylevelprovider::KeyLayerGroupID) - ); - - if (dictionary.hasValue(bylevelprovider::KeyProviders)) { - ghoul::Dictionary providers = dictionary.value( - bylevelprovider::KeyProviders - ); - - for (size_t i = 1; i <= providers.size(); i++) { - ghoul::Dictionary levelProviderDict = providers.value( - std::to_string(i) - ); - double floatMaxLevel = levelProviderDict.value( - bylevelprovider::KeyMaxLevel - ); - int maxLevel = static_cast(std::round(floatMaxLevel)); - - ghoul::Dictionary providerDict = levelProviderDict.value( - bylevelprovider::KeyTileProvider - ); - providerDict.setValue( - bylevelprovider::KeyLayerGroupID, - static_cast(layerGroupID) - ); - - layergroupid::TypeID typeID; - if (providerDict.hasValue("Type")) - { - const std::string& typeString = providerDict.value("Type"); - typeID = ghoul::from_string(typeString); - - if (typeID == layergroupid::TypeID::Unknown) { - throw ghoul::RuntimeError("Unknown layer type: " + typeString); - } - } - else { - typeID = layergroupid::TypeID::DefaultTileLayer; - } - - std::unique_ptr tp = createFromDictionary(typeID, providerDict); - - std::string provId = providerDict.value("Identifier"); - tp->setIdentifier(provId); - std::string providerName = providerDict.value("Name"); - tp->setGuiName(providerName); - addPropertySubOwner(tp.get()); - - levelTileProviders.push_back(std::move(tp)); - - // Ensure we can represent the max level - if (static_cast(providerIndices.size()) < maxLevel) { - providerIndices.resize(maxLevel + 1, -1); - } - - // map this level to the tile provider index - providerIndices[maxLevel] = static_cast(levelTileProviders.size()) - 1; - } - } - - // Fill in the gaps (value -1 ) in provider indices, from back to end - for (int i = static_cast(providerIndices.size()) - 2; i >= 0; --i) { - if (providerIndices[i] == -1) { - providerIndices[i] = providerIndices[i + 1]; - } - } -} - - - - - -TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary) - : initDict(dictionary) - , filePath(temporal::FilePathInfo) - , useFixedTime(temporal::UseFixedTimeInfo, false) - , fixedTime(temporal::FixedTimeInfo) -{ - ZoneScoped - - type = Type::TemporalTileProvider; - - filePath = dictionary.value(KeyFilePath); - addProperty(filePath); - - if (dictionary.hasValue(temporal::UseFixedTimeInfo.identifier)) { - useFixedTime = dictionary.value(temporal::UseFixedTimeInfo.identifier); - } - addProperty(useFixedTime); - - if (dictionary.hasValue(temporal::FixedTimeInfo.identifier)) { - fixedTime = dictionary.value(temporal::FixedTimeInfo.identifier); - } - addProperty(fixedTime); - - readFilePath(*this); - - if (interpolation) { - interpolateTileProvider = std::make_unique(dictionary); - interpolateTileProvider->colormap = colormap; - initialize(*interpolateTileProvider); - ghoul::Dictionary dict; - dict.setValue("FilePath", colormap); - interpolateTileProvider->singleImageProvider = - std::make_unique(dict); - } -} - - - - - - -bool initialize(TileProvider& tp) { - ZoneScoped - - ghoul_assert(!tp.isInitialized, "TileProvider can only be initialized once."); - - if (TileProvider::NumTileProviders > - static_cast(std::numeric_limits::max()) - 1) - { - LERRORC( - "TileProvider", - "Number of tile providers exceeds 65535. Something will break soon" - ); - TileProvider::NumTileProviders = 0; - } - tp.uniqueIdentifier = static_cast(TileProvider::NumTileProviders++); - if (TileProvider::NumTileProviders == std::numeric_limits::max()) { - --TileProvider::NumTileProviders; - return false; - } - - tp.isInitialized = true; - - switch (tp.type) { - case Type::DefaultTileProvider: - break; - case Type::SingleImageTileProvider: - break; - case Type::ImageSequenceTileProvider: - break; - case Type::SizeReferenceTileProvider: { - SizeReferenceTileProvider& t = static_cast(tp); - initialize(t); - break; - } - case Type::TileIndexTileProvider: { - TileIndexTileProvider& t = static_cast(tp); - initialize(t); - break; - } - case Type::ByIndexTileProvider: - break; - case Type::ByLevelTileProvider: { - TileProviderByLevel& t = static_cast(tp); - bool success = true; - for (const std::unique_ptr& prov : t.levelTileProviders) { - success &= initialize(*prov); - } - return success; - } - case Type::InterpolateTileProvider: - break; - case Type::TemporalTileProvider: - break; - default: - throw ghoul::MissingCaseException(); - } - - return true; -} - - - - - - -bool deinitialize(TileProvider& tp) { - ZoneScoped - - switch (tp.type) { - case Type::DefaultTileProvider: - break; - case Type::SingleImageTileProvider: - break; - case Type::ImageSequenceTileProvider: - break; - case Type::SizeReferenceTileProvider: { - SizeReferenceTileProvider& t = static_cast(tp); - deinitialize(t); - break; - } - case Type::TileIndexTileProvider: { - TileIndexTileProvider& t = static_cast(tp); - deinitialize(t); - break; - } - case Type::ByIndexTileProvider: - break; - case Type::ByLevelTileProvider: { - TileProviderByLevel& t = static_cast(tp); - bool success = true; - for (const std::unique_ptr& prov : t.levelTileProviders) { - success &= deinitialize(*prov); - } - return success; - } - case Type::InterpolateTileProvider: - break; - case Type::TemporalTileProvider: - break; - default: - throw ghoul::MissingCaseException(); - } - return true; -} - - -// -// InterpolateTileProvider -// -InterpolateTileProvider::InterpolateTileProvider(const ghoul::Dictionary&) { - ZoneScoped - - type = Type::InterpolateTileProvider; - glGenFramebuffers(1, &fbo); - glGenVertexArrays(1, &vaoQuad); - glGenBuffers(1, &vboQuad); - glBindVertexArray(vaoQuad); - glBindBuffer(GL_ARRAY_BUFFER, vboQuad); - tileCache = global::moduleEngine->module()->tileCache(); - // Quad for fullscreen with vertex (xy) and texture coordinates (uv) - const GLfloat vertexData[] = { - // x y u v - -1.f, -1.f, 0.f, 0.f, - 1.f, 1.f, 1.f, 1.f, - -1.f, 1.f, 0.f, 1.f, - -1.f, -1.f, 0.f, 0.f, - 1.f, -1.f, 1.f, 0.f, - 1.f, 1.f, 1.f, 1.f - }; - glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW); - // vertex coordinates at location 0 - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), nullptr); - glEnableVertexAttribArray(0); - // texture coords at location 1 - glVertexAttribPointer( - 1, - 2, - GL_FLOAT, - GL_FALSE, - 4 * sizeof(GLfloat), - reinterpret_cast(sizeof(GLfloat) * 2) - ); - glEnableVertexAttribArray(1); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); - shaderProgram = global::renderEngine->buildRenderProgram( - "InterpolatingProgram", - absPath("${MODULE_GLOBEBROWSING}/shaders/interpolate_vs.glsl"), - absPath("${MODULE_GLOBEBROWSING}/shaders/interpolate_fs.glsl") - ); -} - -InterpolateTileProvider::~InterpolateTileProvider() { - glDeleteFramebuffers(1, &fbo); - glDeleteBuffers(1, &vboQuad); - glDeleteVertexArrays(1, &vaoQuad); -} - -Tile InterpolateTileProvider::calculateTile(const TileIndex& tileIndex) { - ZoneScoped - TracyGpuZone("tile"); - - // prev and next are the two tiles to interpolate between - Tile prev = tile(*t1, tileIndex); - Tile next = tile(*t2, tileIndex); - // the tile before and the tile after the interpolation interval are loaded so the - // interpolation goes smoother - Tile prevprev = tile(*before, tileIndex); - Tile nextnext = tile(*future, tileIndex); - cache::ProviderTileKey key = { tileIndex, uniqueIdentifier }; - - if (!prev.texture || !next.texture) { - return Tile{ nullptr, std::nullopt, Tile::Status::Unavailable }; - } - - // There is a previous and next texture to interpolate between so do the interpolation - - // The texture that will give the color for the interpolated texture - ghoul::opengl::Texture* colormapTexture = singleImageProvider->tile.texture; - long long hkey = cache::ProviderTileHasher()(key); - // The data for initializing the texture - TileTextureInitData initData( - prev.texture->dimensions().x, - prev.texture->dimensions().y, - prev.texture->dataType(), - prev.texture->format(), - TileTextureInitData::PadTiles::No, - TileTextureInitData::ShouldAllocateDataOnCPU::No - ); - - // Check if a tile exists for the given key in the tileCache - // Initializing the tile that will contian the interpolated texture - Tile ourTile; - // The texture that will contain the interpolated image - ghoul::opengl::Texture* writeTexture; - if (tileCache->exist(key)) { - // Get the tile from the tilecache - ourTile = tileCache->get(key); - // Use the texture from the tileCache - writeTexture = ourTile.texture; - } - else { - // Create a texture with the initialization data - writeTexture = tileCache->texture(initData); - // Create a tile with the texture - ourTile = Tile{ writeTexture, std::nullopt, Tile::Status::OK }; - // Add it to the tilecache - tileCache->put(key, initData.hashKey, ourTile); - } - - // Saves current state - GLint currentFBO; - GLint viewport[4]; - glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFBO); - global::renderEngine->openglStateCache().viewport(viewport); - // Bind render texture to FBO - glBindFramebuffer(GL_FRAMEBUFFER, fbo); - glFramebufferTexture( - GL_FRAMEBUFFER, - GL_COLOR_ATTACHMENT0, - *writeTexture, - 0 - ); - glDisable(GL_BLEND); - GLenum textureBuffers[1] = { GL_COLOR_ATTACHMENT0 }; - glDrawBuffers(1, textureBuffers); - // Check that our framebuffer is ok - if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { - LERRORC("TileProvider", "Incomplete framebuffer"); - } - // Setup our own viewport settings - GLsizei w = static_cast(writeTexture->width()); - GLsizei h = static_cast(writeTexture->height()); - glViewport(0, 0, w, h); - glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_COLOR_BUFFER_BIT); - GLint id; - glGetIntegerv(GL_CURRENT_PROGRAM, &id); - // Activate shader and bind uniforms - shaderProgram->activate(); - shaderProgram->setUniform("blendFactor", factor); - - ghoul::opengl::TextureUnit colormapUnit; - colormapUnit.activate(); - colormapTexture->bind(); - shaderProgram->setUniform("colormapTexture", colormapUnit); - - ghoul::opengl::TextureUnit prevUnit; - prevUnit.activate(); - prev.texture->bind(); - shaderProgram->setUniform("prevTexture", prevUnit); - - ghoul::opengl::TextureUnit nextUnit; - nextUnit.activate(); - next.texture->bind(); - shaderProgram->setUniform("nextTexture", nextUnit); - - // Render to the texture - glBindVertexArray(vaoQuad); - glDrawArrays(GL_TRIANGLES, 0, 6); // 2 triangles - // Deactivate shader program (when rendering is completed) - shaderProgram->deactivate(); - glUseProgram(id); - // Restores system state - glBindFramebuffer(GL_FRAMEBUFFER, currentFBO); - glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); - // Restores OpenGL Rendering State - global::renderEngine->openglStateCache().resetColorState(); - global::renderEngine->openglStateCache().resetBlendState(); - global::renderEngine->openglStateCache().resetDepthState(); - global::renderEngine->openglStateCache().resetPolygonAndClippingState(); - global::renderEngine->openglStateCache().resetViewportState(); - - return ourTile; -} - - -Tile tile(TileProvider& tp, const TileIndex& tileIndex) { - ZoneScoped - - switch (tp.type) { - case Type::DefaultTileProvider: { - ZoneScopedN("Type::DefaultTileProvider") - DefaultTileProvider& t = static_cast(tp); - if (t.asyncTextureDataProvider) { - if (tileIndex.level > maxLevel(t)) { - return Tile { nullptr, std::nullopt, Tile::Status::OutOfRange }; - } - const cache::ProviderTileKey key = { tileIndex, t.uniqueIdentifier }; - Tile tile = t.tileCache->get(key); - if (!tile.texture) { - //TracyMessage("Enqueuing tile", 32); - t.asyncTextureDataProvider->enqueueTileIO(tileIndex); - } - - return tile; - } - else { - return Tile { nullptr, std::nullopt, Tile::Status::Unavailable }; - } - } - case Type::SingleImageTileProvider: { - ZoneScopedN("Type::SingleImageTileProvider") - SingleImageProvider& t = static_cast(tp); - return t.tile; - } - case Type::ImageSequenceTileProvider: { - ZoneScopedN("Type::ImageSequenceTileProvider") - ImageSequenceTileProvider& t = static_cast(tp); - if (t.currentTileProvider) { - return tile(*t.currentTileProvider, tileIndex); - } - else { - return Tile(); - } - } - case Type::SizeReferenceTileProvider: { - ZoneScopedN("Type::SizeReferenceTileProvider") - SizeReferenceTileProvider& t = static_cast(tp); - - const GeodeticPatch patch(tileIndex); - const bool aboveEquator = patch.isNorthern(); - const double lat = aboveEquator ? patch.minLat() : patch.maxLat(); - const double lon1 = patch.minLon(); - const double lon2 = patch.maxLon(); - int l = static_cast(t.ellipsoid.longitudalDistance(lat, lon1, lon2)); - - const bool useKm = l > 9999; - if (useKm) { - l /= 1000; - } - l = static_cast(std::round(l)); - if (useKm) { - l *= 1000; - } - double tileLongitudalLength = l; - - const char* unit; - if (tileLongitudalLength > 9999) { - tileLongitudalLength *= 0.001; - unit = "km"; - } - else { - unit = "m"; - } - - t.text = fmt::format(" {:.0f} {:s}", tileLongitudalLength, unit); - t.textPosition = { - 0.f, - aboveEquator ? - t.fontSize / 2.f : - t.initData.dimensions.y - 3.f * t.fontSize / 2.f - }; - t.textColor = glm::vec4(1.f); - - return tile(t, tileIndex); - } - case Type::TileIndexTileProvider: { - ZoneScopedN("Type::TileIndexTileProvider") - TileIndexTileProvider& t = static_cast(tp); - t.text = fmt::format( - "level: {}\nx: {}\ny: {}", tileIndex.level, tileIndex.x, tileIndex.y - ); - t.textPosition = glm::vec2( - t.initData.dimensions.x / 4 - - (t.initData.dimensions.x / 32) * log10(1 << tileIndex.level), - t.initData.dimensions.y / 2 + t.fontSize - ); - t.textColor = glm::vec4(1.f); - - return tile(t, tileIndex); - } - case Type::ByIndexTileProvider: { - ZoneScopedN("Type::ByIndexTileProvider") - TileProviderByIndex& t = static_cast(tp); - const auto it = t.tileProviderMap.find(tileIndex.hashKey()); - const bool hasProvider = it != t.tileProviderMap.end(); - return hasProvider ? tile(*it->second, tileIndex) : Tile(); - } - case Type::ByLevelTileProvider: { - ZoneScopedN("Type::ByLevelTileProvider") - TileProviderByLevel& t = static_cast(tp); - TileProvider* provider = levelProvider(t, tileIndex.level); - if (provider) { - return tile(*provider, tileIndex); - } - else { - return Tile(); - } - } - case Type::InterpolateTileProvider: { - - ZoneScopedN("Type::InterpolateTileProvider") - InterpolateTileProvider& t = static_cast(tp); - return t.calculateTile(tileIndex); - break; - } - case Type::TemporalTileProvider: { - ZoneScopedN("Type::TemporalTileProvider") - TemporalTileProvider& t = static_cast(tp); - ensureUpdated(t); - return tile(*t.currentTileProvider, tileIndex); - } - default: - throw ghoul::MissingCaseException(); - } -} - - - - -Tile::Status tileStatus(TileProvider& tp, const TileIndex& index) { - ZoneScoped - - switch (tp.type) { - case Type::DefaultTileProvider: { - DefaultTileProvider& t = static_cast(tp); - if (t.asyncTextureDataProvider) { - const RawTileDataReader& rawTileDataReader = - t.asyncTextureDataProvider->rawTileDataReader(); - - if (index.level > rawTileDataReader.maxChunkLevel()) { - return Tile::Status::OutOfRange; - } - - const cache::ProviderTileKey key = { index, t.uniqueIdentifier }; - return t.tileCache->get(key).status; - } - else { - return Tile::Status::Unavailable; - } - } - case Type::SingleImageTileProvider: { - SingleImageProvider& t = static_cast(tp); - return t.tile.status; - } - case Type::ImageSequenceTileProvider: { - ImageSequenceTileProvider& t = static_cast(tp); - if (t.currentTileProvider) { - return tileStatus(*t.currentTileProvider, index); - } - else { - return Tile::Status::Unavailable; - } - } - case Type::SizeReferenceTileProvider: - return Tile::Status::OK; - case Type::TileIndexTileProvider: - return Tile::Status::OK; - case Type::ByIndexTileProvider: { - TileProviderByIndex& t = static_cast(tp); - const auto it = t.tileProviderMap.find(index.hashKey()); - const bool hasProvider = it != t.tileProviderMap.end(); - return hasProvider ? - tileStatus(*it->second, index) : - Tile::Status::Unavailable; - } - case Type::ByLevelTileProvider: { - TileProviderByLevel& t = static_cast(tp); - TileProvider* provider = levelProvider(t, index.level); - return provider ? tileStatus(*provider, index) : Tile::Status::Unavailable; - } - case Type::InterpolateTileProvider: { - InterpolateTileProvider& t = static_cast(tp); - Tile::Status t1Stat = tileStatus(*t.t1, index); - Tile::Status t2Stat = tileStatus(*t.t2, index); - if (t1Stat <= t2Stat) { - return t1Stat; - } - else { - return t2Stat; - } - } - case Type::TemporalTileProvider: { - TemporalTileProvider& t = static_cast(tp); - ensureUpdated(t); - return tileStatus(*t.currentTileProvider, index); - } - default: - throw ghoul::MissingCaseException(); - } -} - - - - - - -TileDepthTransform depthTransform(TileProvider& tp) { - ZoneScoped - - switch (tp.type) { - case Type::DefaultTileProvider: { - DefaultTileProvider& t = static_cast(tp); - if (t.asyncTextureDataProvider) { - return t.asyncTextureDataProvider->rawTileDataReader().depthTransform(); - } - else { - return { 1.f, 0.f }; - } - } - case Type::SingleImageTileProvider: - return { 0.f, 1.f }; - case Type::ImageSequenceTileProvider: { - ImageSequenceTileProvider& t = static_cast(tp); - if (t.currentTileProvider) { - return depthTransform(*t.currentTileProvider); - } - else { - return { 1.f, 0.f }; - } - } - case Type::SizeReferenceTileProvider: - return { 0.f, 1.f }; - case Type::TileIndexTileProvider: - return { 0.f, 1.f }; - case Type::ByIndexTileProvider: { - TileProviderByIndex& t = static_cast(tp); - return depthTransform(*t.defaultTileProvider); - } - case Type::ByLevelTileProvider: - return { 0.f, 1.f }; - case Type::InterpolateTileProvider: { - InterpolateTileProvider& t = static_cast(tp); - return depthTransform(*t.t1); - } - case Type::TemporalTileProvider: { - TemporalTileProvider& t = static_cast(tp); - ensureUpdated(t); - return depthTransform(*t.currentTileProvider); - } - default: - throw ghoul::MissingCaseException(); - } -} - - - - - - -void update(TileProvider& tp) { - ZoneScoped - - switch (tp.type) { - case Type::DefaultTileProvider: { - DefaultTileProvider& t = static_cast(tp); - if (!t.asyncTextureDataProvider) { - break; - } - - t.asyncTextureDataProvider->update(); - initTexturesFromLoadedData(t); - - if (t.asyncTextureDataProvider->shouldBeDeleted()) { - t.asyncTextureDataProvider = nullptr; - initAsyncTileDataReader( - t, - tileTextureInitData(t.layerGroupID, t.padTiles, t.tilePixelSize) - ); - } - break; - } - case Type::SingleImageTileProvider: - break; - case Type::ImageSequenceTileProvider: { - ImageSequenceTileProvider& t = static_cast(tp); - - if (t.isImageDirty && !t.imagePaths.empty() && - t.index >= 0 && t.index < t.imagePaths.size()) - { - if (t.currentTileProvider) { - deinitialize(*t.currentTileProvider); - } - - std::string p = t.imagePaths[t.index].string(); - t.currentImage = p; - t.initDict.setValue(KeyFilePath, p); - t.currentTileProvider = std::make_unique(t.initDict); - initialize(*t.currentTileProvider); - t.isImageDirty = false; - } - - if (t.currentTileProvider) { - update(*t.currentTileProvider); - } - break; - } - case Type::SizeReferenceTileProvider: - break; - case Type::TileIndexTileProvider: - break; - case Type::ByIndexTileProvider: { - TileProviderByIndex& t = static_cast(tp); - using K = TileIndex::TileHashKey; - using V = std::unique_ptr; - for (std::pair& it : t.tileProviderMap) { - update(*it.second); - } - update(*t.defaultTileProvider); - break; - } - case Type::ByLevelTileProvider: { - TileProviderByLevel& t = static_cast(tp); - for (const std::unique_ptr& provider : t.levelTileProviders) { - update(*provider); - } - break; - } - case Type::InterpolateTileProvider: { - InterpolateTileProvider& t = static_cast(tp); - update(*t.t1); - update(*t.t2); - update(*t.before); - update(*t.future); - break; - } - case Type::TemporalTileProvider: { - TemporalTileProvider& t = static_cast(tp); - TileProvider* newCurr = getTileProvider(t, global::timeManager->time()); - if (newCurr) { - t.currentTileProvider = newCurr; - } - if (t.currentTileProvider) { - update(*t.currentTileProvider); - } - break; - } - default: - throw ghoul::MissingCaseException(); - } -} - - - - - - -void reset(TileProvider& tp) { - ZoneScoped - - switch (tp.type) { - case Type::DefaultTileProvider: { - DefaultTileProvider& t = static_cast(tp); - t.tileCache->clear(); - if (t.asyncTextureDataProvider) { - t.asyncTextureDataProvider->prepareToBeDeleted(); - } - else { - initAsyncTileDataReader( - t, - tileTextureInitData(t.layerGroupID, t.padTiles, t.tilePixelSize) - ); - } - break; - } - case Type::SingleImageTileProvider: { - SingleImageProvider& t = static_cast(tp); - - if (t.filePath.value().empty()) { - return; - } - t.tileTexture = ghoul::io::TextureReader::ref().loadTexture(t.filePath, 2); - if (!t.tileTexture) { - throw ghoul::RuntimeError( - fmt::format("Unable to load texture '{}'", t.filePath.value()) - ); - } - Tile::Status tileStatus = Tile::Status::OK; - - t.tileTexture->uploadTexture(); - t.tileTexture->setFilter( - ghoul::opengl::Texture::FilterMode::AnisotropicMipMap - ); - - t.tile = Tile{ t.tileTexture.get(), std::nullopt, tileStatus }; - break; - } - case Type::ImageSequenceTileProvider: { - namespace fs = std::filesystem; - ImageSequenceTileProvider& t = static_cast(tp); - std::string path = t.folderPath; - t.imagePaths.clear(); - for (const fs::directory_entry& p : fs::directory_iterator(path)) { - if (p.is_regular_file()) { - t.imagePaths.push_back(p.path()); - } - } - - t.index = 0; - t.index.setMaxValue(static_cast(t.imagePaths.size() - 1)); - - if (t.currentTileProvider) { - reset(*t.currentTileProvider); - } - break; - } - case Type::SizeReferenceTileProvider: { - SizeReferenceTileProvider& t = static_cast(tp); - reset(t); - break; - } - case Type::TileIndexTileProvider: { - TileIndexTileProvider& t = static_cast(tp); - reset(t); - break; - } - case Type::ByIndexTileProvider: { - TileProviderByIndex& t = static_cast(tp); - using K = TileIndex::TileHashKey; - using V = std::unique_ptr; - for (std::pair& it : t.tileProviderMap) { - reset(*it.second); - } - reset(*t.defaultTileProvider); - break; - } - case Type::ByLevelTileProvider: { - TileProviderByLevel& t = static_cast(tp); - for (const std::unique_ptr& provider : t.levelTileProviders) { - reset(*provider); - } - break; - } - case Type::InterpolateTileProvider: { - InterpolateTileProvider& t = static_cast(tp); - reset(*t.t1); - reset(*t.t2); - reset(*t.before); - reset(*t.future); - break; - } - case Type::TemporalTileProvider: { - TemporalTileProvider& t = static_cast(tp); - using K = TemporalTileProvider::TimeKey; - using V = std::unique_ptr; - for (std::pair& it : t.tileProviderMap) { - reset(*it.second); - } - break; - } - default: - throw ghoul::MissingCaseException(); - } -} - - - - - - -int maxLevel(TileProvider& tp) { - switch (tp.type) { - case Type::DefaultTileProvider: { - DefaultTileProvider& t = static_cast(tp); - // 22 is the current theoretical maximum based on the number of hashes that - // are possible to uniquely identify a tile. See ProviderTileHasher in - // memoryawaretilecache.h - return t.asyncTextureDataProvider ? - t.asyncTextureDataProvider->rawTileDataReader().maxChunkLevel() : - 22; - } - case Type::SingleImageTileProvider: - return 1337; // unlimited - case Type::ImageSequenceTileProvider: { - ImageSequenceTileProvider& t = static_cast(tp); - if (t.currentTileProvider) { - return maxLevel(*t.currentTileProvider); - } - else { - return 0; - } - } - case Type::SizeReferenceTileProvider: - return 1337; // unlimited - case Type::TileIndexTileProvider: - return 1337; // unlimited - case Type::ByIndexTileProvider: { - TileProviderByIndex& t = static_cast(tp); - return maxLevel(*t.defaultTileProvider); - } - case Type::ByLevelTileProvider: { - TileProviderByLevel& t = static_cast(tp); - return static_cast(t.providerIndices.size() - 1); - } - case Type::InterpolateTileProvider: { - InterpolateTileProvider& t = static_cast(tp); - return glm::min(maxLevel(*t.t1), maxLevel(*t.t2)); - } - case Type::TemporalTileProvider: { - TemporalTileProvider& t = static_cast(tp); - ensureUpdated(t); - return maxLevel(*t.currentTileProvider); - } - default: - throw ghoul::MissingCaseException(); - } -} - - - - - - -float noDataValueAsFloat(TileProvider& tp) { - ZoneScoped - - ghoul_assert(tp.isInitialized, "TileProvider was not initialized."); - switch (tp.type) { - case Type::DefaultTileProvider: { - DefaultTileProvider& t = static_cast(tp); - return t.asyncTextureDataProvider ? - t.asyncTextureDataProvider->noDataValueAsFloat() : - std::numeric_limits::min(); - } - case Type::SingleImageTileProvider: - return std::numeric_limits::min(); - case Type::ImageSequenceTileProvider: { - ImageSequenceTileProvider& t = static_cast(tp); - if (t.currentTileProvider) { - return noDataValueAsFloat(*t.currentTileProvider); - } - else { - return std::numeric_limits::min(); - } - } - case Type::SizeReferenceTileProvider: - return std::numeric_limits::min(); - case Type::TileIndexTileProvider: - return std::numeric_limits::min(); - case Type::ByIndexTileProvider: - return std::numeric_limits::min(); - case Type::ByLevelTileProvider: - return std::numeric_limits::min(); - case Type::InterpolateTileProvider: - return std::numeric_limits::min(); - case Type::TemporalTileProvider: - return std::numeric_limits::min(); - default: - throw ghoul::MissingCaseException(); - } -} - - - - - -ChunkTile chunkTile(TileProvider& tp, TileIndex tileIndex, int parents, int maxParents) { - ZoneScoped - - ghoul_assert(tp.isInitialized, "TileProvider was not initialized."); - - auto ascendToParent = [](TileIndex& ti, TileUvTransform& uv) { - uv.uvOffset *= 0.5; - uv.uvScale *= 0.5; - - uv.uvOffset += ti.positionRelativeParent(); - - ti.x /= 2; - ti.y /= 2; - ti.level--; - }; - - TileUvTransform uvTransform = { glm::vec2(0.f, 0.f), glm::vec2(1.f, 1.f) }; - - // Step 1. Traverse 0 or more parents up the chunkTree as requested by the caller - for (int i = 0; i < parents && tileIndex.level > 1; i++) { - ascendToParent(tileIndex, uvTransform); - } - maxParents -= parents; - - // Step 2. Traverse 0 or more parents up the chunkTree to make sure we're inside - // the range of defined data. - int maximumLevel = maxLevel(tp); - while (tileIndex.level > maximumLevel) { - ascendToParent(tileIndex, uvTransform); - maxParents--; - } - if (maxParents < 0) { - return ChunkTile { Tile(), uvTransform, TileDepthTransform() }; - } - - // Step 3. Traverse 0 or more parents up the chunkTree until we find a chunk that - // has a loaded tile ready to use. - while (tileIndex.level > 1) { - Tile t = tile(tp, tileIndex); - if (t.status != Tile::Status::OK) { - if (--maxParents < 0) { - return ChunkTile { Tile(), uvTransform, TileDepthTransform() }; - } - ascendToParent(tileIndex, uvTransform); - } - else { - return ChunkTile { std::move(t), uvTransform, TileDepthTransform() }; - } - } - - return ChunkTile { Tile(), uvTransform, TileDepthTransform() }; -} - - - - - - -ChunkTilePile chunkTilePile(TileProvider& tp, TileIndex tileIndex, int pileSize) { - ZoneScoped - - ghoul_assert(tp.isInitialized, "TileProvider was not initialized."); - ghoul_assert(pileSize >= 0, "pileSize must be positive"); - - ChunkTilePile chunkTilePile; - std::fill(chunkTilePile.begin(), chunkTilePile.end(), std::nullopt); - for (int i = 0; i < pileSize; ++i) { - chunkTilePile[i] = chunkTile(tp, tileIndex, i); - if (chunkTilePile[i]->tile.status == Tile::Status::Unavailable) { - if (i == 0) { - // First iteration - chunkTilePile[i]->tile = DefaultTile; - chunkTilePile[i]->uvTransform.uvOffset = { 0.f, 0.f }; - chunkTilePile[i]->uvTransform.uvScale = { 1.f, 1.f }; - } - else { - // We are iterating through the array one-by-one, so we are guaranteed - // that for tile 'i', tile 'i-1' already was initializated - chunkTilePile[i]->tile = chunkTilePile[i - 1]->tile; - chunkTilePile[i]->uvTransform.uvOffset = - chunkTilePile[i - 1]->uvTransform.uvOffset; - chunkTilePile[i]->uvTransform.uvScale = - chunkTilePile[i - 1]->uvTransform.uvScale; - } - } - } - return chunkTilePile; -} - -} // namespace openspace::globebrowsing::tileprovider diff --git a/modules/globebrowsing/src/tileprovider.h b/modules/globebrowsing/src/tileprovider.h deleted file mode 100644 index 9ff944c202..0000000000 --- a/modules/globebrowsing/src/tileprovider.h +++ /dev/null @@ -1,292 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2022 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILE_PROVIDER___H__ -#define __OPENSPACE_MODULE_GLOBEBROWSING___TILE_PROVIDER___H__ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct CPLXMLNode; - -namespace ghoul::fontrendering { - class Font; - class FontRenderer; -} // namespace ghoul::fontrendering - -namespace openspace { class PixelBuffer; } - -namespace openspace::globebrowsing { - class AsyncTileDataProvider; - struct RawTile; - struct TileIndex; - namespace cache { class MemoryAwareTileCache; } -} // namespace openspace::globebrowsing - -namespace openspace::globebrowsing::tileprovider { - -enum class Type { - DefaultTileProvider = 0, - SingleImageTileProvider, - ImageSequenceTileProvider, - SizeReferenceTileProvider, - TemporalTileProvider, - TileIndexTileProvider, - ByIndexTileProvider, - ByLevelTileProvider, - InterpolateTileProvider -}; - - -struct TileProvider : public properties::PropertyOwner { - static unsigned int NumTileProviders; - - Type type; - - TileProvider(); - virtual ~TileProvider() = default; - - std::string name; - - uint16_t uniqueIdentifier = 0; - bool isInitialized = false; -}; - -struct DefaultTileProvider : public TileProvider { - DefaultTileProvider(const ghoul::Dictionary& dictionary); - - std::unique_ptr asyncTextureDataProvider; - - cache::MemoryAwareTileCache* tileCache = nullptr; - - properties::StringProperty filePath; - properties::IntProperty tilePixelSize; - layergroupid::GroupID layerGroupID = layergroupid::GroupID::Unknown; - bool performPreProcessing = false; - bool padTiles = true; -}; - -struct SingleImageProvider : public TileProvider { - SingleImageProvider(const ghoul::Dictionary& dictionary); - - std::unique_ptr tileTexture; - Tile tile; - - properties::StringProperty filePath; -}; - -struct InterpolateTileProvider : public TileProvider { - InterpolateTileProvider(const ghoul::Dictionary&); - virtual ~InterpolateTileProvider(); - - Tile calculateTile(const TileIndex&); - TileProvider* before = nullptr; - TileProvider* t1 = nullptr; - TileProvider* t2 = nullptr; - TileProvider* future = nullptr; - float factor = 1.f; - GLuint vaoQuad = 0; - GLuint vboQuad = 0; - GLuint fbo = 0; - std::string colormap; - std::unique_ptr shaderProgram; - std::unique_ptr singleImageProvider; - cache::MemoryAwareTileCache* tileCache = nullptr; -}; - -struct TextTileProvider : public TileProvider { - TextTileProvider(TileTextureInitData initData, size_t fontSize = 48); - - const TileTextureInitData initData; - - std::unique_ptr fontRenderer; - std::shared_ptr font; - size_t fontSize = 0; - - std::string text; - glm::vec2 textPosition = glm::vec2(0.f); - glm::vec4 textColor = glm::vec4(0.f); - - GLuint fbo = 0; - - cache::MemoryAwareTileCache* tileCache; -}; - -struct SizeReferenceTileProvider : public TextTileProvider { - SizeReferenceTileProvider(const ghoul::Dictionary& dictionary); - - Ellipsoid ellipsoid; -}; - -struct TileIndexTileProvider : public TextTileProvider { - TileIndexTileProvider(const ghoul::Dictionary& dictionary); -}; - -struct TileProviderByIndex : public TileProvider { - TileProviderByIndex(const ghoul::Dictionary& dictionary); - - std::unordered_map< - TileIndex::TileHashKey, std::unique_ptr - > tileProviderMap; - std::unique_ptr defaultTileProvider; -}; - -struct TileProviderByLevel : public TileProvider { - TileProviderByLevel(const ghoul::Dictionary& dictionary); - - std::vector providerIndices; - std::vector> levelTileProviders; -}; - - -struct ImageSequenceTileProvider : public TileProvider { - ImageSequenceTileProvider(const ghoul::Dictionary& dictionary); - - std::unique_ptr currentTileProvider = nullptr; - - properties::IntProperty index; - properties::StringProperty currentImage; - properties::StringProperty folderPath; - - ghoul::Dictionary initDict; - bool isImageDirty = true; - std::vector imagePaths; -}; - -/** - * Provide Tiles from web map services that have temporal resolution. - * - * TemporalTileProviders are instantiated using a ghoul::Dictionary, - * and must define a filepath to a Openspace Temporal dataset description file. - * This is an xml-file that defines the same meta data as the GDAL wms description - * (http://www.gdal.org/frmt_wms.html), but augmented with some - * extra tags describing the temporal properties of the dataset. See - * TemporalTileProvider::TemporalXMLTags - * - */ -struct TemporalTileProvider : public TileProvider { - enum class TimeFormatType { - YYYY_MM_DD = 0, - YYYYMMDD_hhmmss, - YYYYMMDD_hhmm, - YYYY_MM_DDThhColonmmColonssZ, - YYYY_MM_DDThh_mm_ssZ - }; - - using TimeKey = std::string; - - TemporalTileProvider(const ghoul::Dictionary& dictionary); - - ghoul::Dictionary initDict; - properties::StringProperty filePath; - properties::BoolProperty useFixedTime; - properties::StringProperty fixedTime; - std::string gdalXmlTemplate; - - std::unordered_map> tileProviderMap; - - bool interpolation = false; - - TileProvider* currentTileProvider = nullptr; - double startTimeJ2000; - double endTimeJ2000; - TimeFormatType timeFormat; - TimeQuantizer timeQuantizer; - std::string colormap; - - std::string myResolution; - std::unique_ptr interpolateTileProvider; -}; - - - -void initializeDefaultTile(); -void deinitializeDefaultTile(); - -std::unique_ptr createFromDictionary(layergroupid::TypeID layerTypeID, - const ghoul::Dictionary& dictionary); - -bool initialize(TileProvider& tp); -bool deinitialize(TileProvider& tp); - -Tile tile(TileProvider& tp, const TileIndex& tileIndex); - -ChunkTile chunkTile(TileProvider& tp, TileIndex tileIndex, int parents = 0, - int maxParents = 1337); - -ChunkTilePile chunkTilePile(TileProvider& tp, TileIndex tileIndex, int pileSize); - -/** - * Returns the status of a Tile. The Tile::Status - * corresponds the Tile that would be returned - * if the function tile would be invoked with the same - * TileIndex argument at this point in time. - */ -Tile::Status tileStatus(TileProvider& tp, const TileIndex& index); - -/** - * Get the associated depth transform for this TileProvider. - * This is necessary for TileProviders serving height map - * data, in order to correcly map pixel values to meters. - */ -TileDepthTransform depthTransform(TileProvider& tp); - -/** - * This method should be called once per frame. Here, TileProviders - * are given the opportunity to update their internal state. - */ -void update(TileProvider& tp); - -/** - * Provides a uniform way of all TileProviders to reload or - * restore all of its internal state. This is mainly useful - * for debugging purposes. - */ -void reset(TileProvider& tp); - -/** - * \returns The maximum level as defined by TileIndex - * that this TileProvider is able provide. - */ -int maxLevel(TileProvider& tp); - -/** - * \returns the no data value for the dataset. Default is the minimum float avalue. - */ -float noDataValueAsFloat(TileProvider& tp); - -} // namespace openspace::globebrowsing::tileprovider - -#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_PROVIDER___H__ diff --git a/modules/globebrowsing/src/tileprovider/defaulttileprovider.cpp b/modules/globebrowsing/src/tileprovider/defaulttileprovider.cpp new file mode 100644 index 0000000000..7047094a45 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/defaulttileprovider.cpp @@ -0,0 +1,204 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 +#include +#include +#include + +namespace { + constexpr openspace::properties::Property::PropertyInfo FilePathInfo = { + "FilePath", + "File Path", + "The path of the GDAL file or the image file that is to be used in this tile " + "provider." + }; + + constexpr openspace::properties::Property::PropertyInfo TilePixelSizeInfo = { + "TilePixelSize", + "Tile Pixel Size", + "This value is the preferred size (in pixels) for each tile. Choosing the right " + "value is a tradeoff between more efficiency (larger images) and better quality " + "(smaller images). The tile pixel size has to be smaller than the size of the " + "complete image if a single image is used." + }; + + struct [[codegen::Dictionary(DefaultTileProvider)]] Parameters { + // User-facing name of this tile provider + std::optional name; + + // The path to the file that is loaded by GDAL to produce tiles. Since GDAL + // supports it, this can also be the textual representation of the contents of a + // loading file + std::string filePath; + + // The layer into which this tile provider is loaded + int layerGroupID; + + // [[codegen::verbatim(TilePixelSizeInfo.description)]] + std::optional tilePixelSize; + + // Determines whether the tiles should have a padding zone around it, making the + // interpolation between tiles more pleasant + std::optional padTiles; + + // Determines if the tiles should be preprocessed before uploading to the GPU + std::optional performPreProcessing; + + }; +#include "defaulttileprovider_codegen.cpp" +} // namespace + +namespace openspace::globebrowsing { + +DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary) + : _filePath(FilePathInfo, "") + , _tilePixelSize(TilePixelSizeInfo, 32, 32, 2048) +{ + ZoneScoped + + const Parameters p = codegen::bake(dictionary); + + name = p.name.value_or("Name unspecified"); + std::string _loggerCat = "DefaultTileProvider (" + name + ")"; + + // 1. Get required Keys + _filePath = p.filePath; + + _layerGroupID = layergroupid::GroupID(p.layerGroupID); + + // 2. Initialize default values for any optional Keys + // getValue does not work for integers + int pixelSize = p.tilePixelSize.value_or(0); + _padTiles = p.padTiles.value_or(_padTiles); + + // Only preprocess height layers by default + switch (_layerGroupID) { + case layergroupid::GroupID::HeightLayers: _performPreProcessing = true; break; + default: _performPreProcessing = false; break; + } + + _performPreProcessing = p.performPreProcessing.value_or(_performPreProcessing); + + TileTextureInitData initData( + tileTextureInitData(_layerGroupID, _padTiles, pixelSize) + ); + _tilePixelSize = initData.dimensions.x; + initAsyncTileDataReader(initData); + + addProperty(_filePath); + addProperty(_tilePixelSize); +} + +void DefaultTileProvider::initAsyncTileDataReader(TileTextureInitData initData) { + ZoneScoped + + _asyncTextureDataProvider = std::make_unique( + name, + std::make_unique( + _filePath, + initData, + RawTileDataReader::PerformPreprocessing(_performPreProcessing) + ) + ); +} + +Tile DefaultTileProvider::tile(const TileIndex& tileIndex) { + ZoneScoped + + ghoul_assert(_asyncTextureDataProvider, "No data provider"); + if (tileIndex.level > maxLevel()) { + return Tile{ nullptr, std::nullopt, Tile::Status::OutOfRange }; + } + const cache::ProviderTileKey key = { tileIndex, uniqueIdentifier }; + cache::MemoryAwareTileCache* tileCache = + global::moduleEngine->module()->tileCache(); + Tile tile = tileCache->get(key); + if (!tile.texture) { + _asyncTextureDataProvider->enqueueTileIO(tileIndex); + } + + return tile; +} + +Tile::Status DefaultTileProvider::tileStatus(const TileIndex& index) { + ghoul_assert(_asyncTextureDataProvider, "No data provider"); + const RawTileDataReader& reader = _asyncTextureDataProvider->rawTileDataReader(); + + if (index.level > reader.maxChunkLevel()) { + return Tile::Status::OutOfRange; + } + + const cache::ProviderTileKey key = { index, uniqueIdentifier }; + cache::MemoryAwareTileCache* tileCache = + global::moduleEngine->module()->tileCache(); + return tileCache->get(key).status; +} + +TileDepthTransform DefaultTileProvider::depthTransform() { + ghoul_assert(_asyncTextureDataProvider, "No data provider"); + return _asyncTextureDataProvider->rawTileDataReader().depthTransform(); +} + +void DefaultTileProvider::update() { + ghoul_assert(_asyncTextureDataProvider, "No data provider"); + _asyncTextureDataProvider->update(); + + std::optional tile = _asyncTextureDataProvider->popFinishedRawTile(); + if (tile) { + const cache::ProviderTileKey key = { tile->tileIndex, uniqueIdentifier }; + cache::MemoryAwareTileCache* tileCache = + global::moduleEngine->module()->tileCache(); + ghoul_assert(!tileCache->exist(key), "Tile must not be existing in cache"); + tileCache->createTileAndPut(key, std::move(*tile)); + } + + if (_asyncTextureDataProvider->shouldBeDeleted()) { + initAsyncTileDataReader( + tileTextureInitData(_layerGroupID, _padTiles, _tilePixelSize) + ); + } +} + +void DefaultTileProvider::reset() { + global::moduleEngine->module()->tileCache()->clear(); + ghoul_assert(_asyncTextureDataProvider, "No data provider"); + _asyncTextureDataProvider->prepareToBeDeleted(); +} + +int DefaultTileProvider::maxLevel() { + ghoul_assert(_asyncTextureDataProvider, "No data provider"); + return _asyncTextureDataProvider->rawTileDataReader().maxChunkLevel(); +} + +float DefaultTileProvider::noDataValueAsFloat() { + ghoul_assert(_asyncTextureDataProvider, "No data provider"); + return _asyncTextureDataProvider->noDataValueAsFloat(); +} + +} // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/tileprovider/defaulttileprovider.h b/modules/globebrowsing/src/tileprovider/defaulttileprovider.h new file mode 100644 index 0000000000..51250ca02f --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/defaulttileprovider.h @@ -0,0 +1,61 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__DEFAULTTILEPROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__DEFAULTTILEPROVIDER___H__ + +#include + +#include +#include + +namespace openspace::globebrowsing { + +class DefaultTileProvider : public TileProvider { +public: + DefaultTileProvider(const ghoul::Dictionary& dictionary); + + Tile tile(const TileIndex& tileIndex) override final; + Tile::Status tileStatus(const TileIndex& index) override final; + TileDepthTransform depthTransform() override final; + void update() override final; + void reset() override final; + int maxLevel() override final; + float noDataValueAsFloat() override final; + +private: + void initAsyncTileDataReader(TileTextureInitData initData); + + properties::StringProperty _filePath; + properties::IntProperty _tilePixelSize; + + std::unique_ptr _asyncTextureDataProvider; + layergroupid::GroupID _layerGroupID = layergroupid::GroupID::Unknown; + bool _performPreProcessing = false; + bool _padTiles = true; +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__DEFAULTTILEPROVIDER___H__ diff --git a/modules/globebrowsing/src/tileprovider/imagesequencetileprovider.cpp b/modules/globebrowsing/src/tileprovider/imagesequencetileprovider.cpp new file mode 100644 index 0000000000..2bf0485566 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/imagesequencetileprovider.cpp @@ -0,0 +1,158 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 + +namespace { + constexpr openspace::properties::Property::PropertyInfo IndexInfo = { + "Index", + "Index", + "The index into the list of images that is used to pick the currently displayed " + "image" + }; + + constexpr openspace::properties::Property::PropertyInfo CurrentImageInfo = { + "CurrentImage", + "Current Image", + "The read-only value of the currently selected image" + }; + + constexpr openspace::properties::Property::PropertyInfo FolderPathInfo = { + "FolderPath", + "Folder Path", + "The path that is used to look for images for this image provider. The path must " + "point to an existing folder that contains images" + }; + + struct [[codegen::Dictionary(ImageSequenceTileProvider)]] Parameters { + // [[codegen::verbatim(IndexInfo.description)]] + std::optional index; + + // [[codegen::verbatim(FolderPathInfo.description)]] + std::filesystem::path folderPath [[codegen::directory()]]; + }; +#include "imagesequencetileprovider_codegen.cpp" +} // namespace + +namespace openspace::globebrowsing { + +ImageSequenceTileProvider::ImageSequenceTileProvider(const ghoul::Dictionary& dictionary) + : _index(IndexInfo, 0) + , _currentImage(CurrentImageInfo) + , _folderPath(FolderPathInfo) + , _initDict(dictionary) +{ + ZoneScoped + + const Parameters p = codegen::bake(dictionary); + + _index = p.index.value_or(_index); + _index.setMinValue(0); + _index.onChange([this]() { _isImageDirty = true; }); + addProperty(_index); + + _currentImage.setReadOnly(true); + addProperty(_currentImage); + + _folderPath = p.folderPath.string(); + addProperty(_folderPath); + + reset(); +} + +Tile ImageSequenceTileProvider::tile(const TileIndex& tileIndex) { + ZoneScoped + + return _currentTileProvider ? _currentTileProvider->tile(tileIndex) : Tile(); +} + +Tile::Status ImageSequenceTileProvider::tileStatus(const TileIndex& index) { + return _currentTileProvider ? + _currentTileProvider->tileStatus(index) : + Tile::Status::Unavailable; +} + +TileDepthTransform ImageSequenceTileProvider::depthTransform() { + if (_currentTileProvider) { + return _currentTileProvider->depthTransform(); + } + else { + return { 1.f, 0.f }; + } +} + +void ImageSequenceTileProvider::update() { + if (_isImageDirty && !_imagePaths.empty() && + _index >= 0 && _index < _imagePaths.size()) + { + if (_currentTileProvider) { + _currentTileProvider->deinitialize(); + } + + std::string p = _imagePaths[_index].string(); + _currentImage = p; + _initDict.setValue("FilePath", p); + _currentTileProvider = std::make_unique(_initDict); + _currentTileProvider->initialize(); + _isImageDirty = false; + } + + if (_currentTileProvider) { + _currentTileProvider->update(); + } +} + +void ImageSequenceTileProvider::reset() { + namespace fs = std::filesystem; + std::string path = _folderPath; + _imagePaths.clear(); + for (const fs::directory_entry& p : fs::directory_iterator(path)) { + if (p.is_regular_file()) { + _imagePaths.push_back(p.path()); + } + } + + _index = 0; + _index.setMaxValue(static_cast(_imagePaths.size() - 1)); + + if (_currentTileProvider) { + _currentTileProvider->reset(); + } +} + +int ImageSequenceTileProvider::maxLevel() { + return _currentTileProvider ? _currentTileProvider->maxLevel() : 0; +} + +float ImageSequenceTileProvider::noDataValueAsFloat() { + return _currentTileProvider ? + _currentTileProvider->noDataValueAsFloat() : + std::numeric_limits::min(); +} + +} // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/tileprovider/imagesequencetileprovider.h b/modules/globebrowsing/src/tileprovider/imagesequencetileprovider.h new file mode 100644 index 0000000000..0ee4730db9 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/imagesequencetileprovider.h @@ -0,0 +1,60 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__IMAGESEQUENCETILEPROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__IMAGESEQUENCETILEPROVIDER___H__ + +#include + +#include + +namespace openspace::globebrowsing { + +class ImageSequenceTileProvider : public TileProvider { +public: + ImageSequenceTileProvider(const ghoul::Dictionary& dictionary); + + Tile tile(const TileIndex& tileIndex) override final; + Tile::Status tileStatus(const TileIndex& index) override final; + TileDepthTransform depthTransform() override final; + void update() override final; + void reset() override final; + int maxLevel() override final; + float noDataValueAsFloat() override final; + +private: + std::unique_ptr _currentTileProvider = nullptr; + + properties::IntProperty _index; + properties::StringProperty _currentImage; + properties::StringProperty _folderPath; + + ghoul::Dictionary _initDict; + bool _isImageDirty = true; + std::vector _imagePaths; +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__IMAGESEQUENCETILEPROVIDER___H__ diff --git a/modules/globebrowsing/src/tileprovider/singleimagetileprovider.cpp b/modules/globebrowsing/src/tileprovider/singleimagetileprovider.cpp new file mode 100644 index 0000000000..a4a113b2b9 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/singleimagetileprovider.cpp @@ -0,0 +1,100 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 + +namespace { + constexpr openspace::properties::Property::PropertyInfo FilePathInfo = { + "FilePath", + "File Path", + "The file path that is used for this image provider. The file must point to an " + "image that is then loaded and used for all tiles." + }; + + struct [[codegen::Dictionary(SingleImageProvider)]] Parameters { + // [[codegen::verbatim(FilePathInfo.description)]] + std::string filePath; + }; +#include "singleimagetileprovider_codegen.cpp" +} // namespace + +namespace openspace::globebrowsing { + +SingleImageProvider::SingleImageProvider(const ghoul::Dictionary& dictionary) + : _filePath(FilePathInfo) +{ + ZoneScoped + + const Parameters p = codegen::bake(dictionary); + + _filePath = p.filePath; + addProperty(_filePath); + + reset(); +} + +Tile SingleImageProvider::tile(const TileIndex&) { + ZoneScoped + return _tile; +} + +Tile::Status SingleImageProvider::tileStatus(const TileIndex&) { + return _tile.status; +} + +TileDepthTransform SingleImageProvider::depthTransform() { + return { 0.f, 1.f }; +} + +void SingleImageProvider::update() {} + +void SingleImageProvider::reset() { + if (_filePath.value().empty()) { + return; + } + + _tileTexture = ghoul::io::TextureReader::ref().loadTexture(_filePath, 2); + if (!_tileTexture) { + throw ghoul::RuntimeError( + fmt::format("Unable to load texture '{}'", _filePath.value()) + ); + } + + _tileTexture->uploadTexture(); + _tileTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + _tile = Tile{ _tileTexture.get(), std::nullopt, Tile::Status::OK }; +} + +int SingleImageProvider::maxLevel() { + return 1337; // unlimited +} + +float SingleImageProvider::noDataValueAsFloat() { + return std::numeric_limits::min(); +} + +} // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/tileprovider/singleimagetileprovider.h b/modules/globebrowsing/src/tileprovider/singleimagetileprovider.h new file mode 100644 index 0000000000..c3fee2725b --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/singleimagetileprovider.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__SINGLEIMAGETILEPROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__SINGLEIMAGETILEPROVIDER___H__ + +#include + +namespace openspace::globebrowsing { + +class SingleImageProvider : public TileProvider { +public: + SingleImageProvider(const ghoul::Dictionary& dictionary); + + Tile tile(const TileIndex& tileIndex) override final; + Tile::Status tileStatus(const TileIndex& index) override final; + TileDepthTransform depthTransform() override final; + void update() override final; + void reset() override final; + int maxLevel() override final; + float noDataValueAsFloat() override final; + +private: + properties::StringProperty _filePath; + + std::unique_ptr _tileTexture; + Tile _tile; +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__SINGLEIMAGETILEPROVIDER___H__ diff --git a/modules/globebrowsing/src/tileprovider/sizereferencetileprovider.cpp b/modules/globebrowsing/src/tileprovider/sizereferencetileprovider.cpp new file mode 100644 index 0000000000..9343d5a99e --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/sizereferencetileprovider.cpp @@ -0,0 +1,121 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 +#include +#include +#include + +namespace { + struct [[codegen::Dictionary(SizeReferenceTileProvider)]] Parameters { + std::optional> radii; + }; +#include "sizereferencetileprovider_codegen.cpp" +} // namespace + +namespace openspace::globebrowsing { + +SizeReferenceTileProvider::SizeReferenceTileProvider(const ghoul::Dictionary& dictionary) + : TextTileProvider(tileTextureInitData(layergroupid::GroupID::ColorLayers, false)) +{ + ZoneScoped + + const Parameters p = codegen::bake(dictionary); + + font = global::fontManager->font("Mono", static_cast(fontSize)); + + if (p.radii.has_value()) { + if (std::holds_alternative(*p.radii)) { + _ellipsoid = std::get(*p.radii); + } + else { + const double r = std::get(*p.radii); + _ellipsoid = glm::dvec3(r, r, r); + } + } +} + +Tile SizeReferenceTileProvider::tile(const TileIndex& tileIndex) { + ZoneScoped + + const GeodeticPatch patch(tileIndex); + const bool aboveEquator = patch.isNorthern(); + const double lat = aboveEquator ? patch.minLat() : patch.maxLat(); + const double lon1 = patch.minLon(); + const double lon2 = patch.maxLon(); + int l = static_cast(_ellipsoid.longitudalDistance(lat, lon1, lon2)); + + const bool useKm = l > 9999; + if (useKm) { + l /= 1000; + } + l = static_cast(std::round(l)); + if (useKm) { + l *= 1000; + } + double tileLongitudalLength = l; + + const char* unit; + if (tileLongitudalLength > 9999) { + tileLongitudalLength *= 0.001; + unit = "km"; + } + else { + unit = "m"; + } + + std::string text = fmt::format(" {:.0f} {:s}", tileLongitudalLength, unit); + glm::vec2 textPosition = { + 0.f, + aboveEquator ? + fontSize / 2.f : + initData.dimensions.y - 3.f * fontSize / 2.f + }; + + return TextTileProvider::renderTile(tileIndex, text, textPosition, glm::vec4(1.f)); +} + +Tile::Status SizeReferenceTileProvider::tileStatus(const TileIndex& index) { + return Tile::Status::OK; +} + +TileDepthTransform SizeReferenceTileProvider::depthTransform() { + return { 0.f, 1.f }; +} + +void SizeReferenceTileProvider::update() {} + +int SizeReferenceTileProvider::maxLevel() { + return 1337; // unlimited +} + +float SizeReferenceTileProvider::noDataValueAsFloat() { + return std::numeric_limits::min(); +} + +} // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/tileprovider/sizereferencetileprovider.h b/modules/globebrowsing/src/tileprovider/sizereferencetileprovider.h new file mode 100644 index 0000000000..499f8c2a53 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/sizereferencetileprovider.h @@ -0,0 +1,49 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__SIZEREFERENCETILEPROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__SIZEREFERENCETILEPROVIDER___H__ + +#include + +namespace openspace::globebrowsing { + +class SizeReferenceTileProvider : public TextTileProvider { +public: + SizeReferenceTileProvider(const ghoul::Dictionary& dictionary); + + Tile tile(const TileIndex& tileIndex) override final; + Tile::Status tileStatus(const TileIndex& index) override final; + TileDepthTransform depthTransform() override final; + void update() override final; + int maxLevel() override final; + float noDataValueAsFloat() override final; + +private: + Ellipsoid _ellipsoid; +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__SIZEREFERENCETILEPROVIDER___H__ diff --git a/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp b/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp new file mode 100644 index 0000000000..bc71de7b14 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp @@ -0,0 +1,822 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + constexpr const char* KeyBasePath = "BasePath"; + + constexpr const char* TimePlaceholder = "${OpenSpaceTimeId}"; + + constexpr openspace::properties::Property::PropertyInfo FilePathInfo = { + "FilePath", + "File Path", + "This is the path to the XML configuration file that describes the temporal tile " + "information." + }; + + constexpr openspace::properties::Property::PropertyInfo UseFixedTimeInfo = { + "UseFixedTime", + "Use Fixed Time", + "If this value is enabled, the time-varying timevarying dataset will always use " + "the time that is specified in the 'FixedTime' property, rather than using the " + "actual time from OpenSpace" + }; + + constexpr openspace::properties::Property::PropertyInfo FixedTimeInfo = { + "FixedTime", + "Fixed Time", + "If the 'UseFixedTime' is enabled, this time will be used instead of the actual " + "time taken from OpenSpace for the displayed tiles." + }; + + struct [[codegen::Dictionary(TemporalTileProvider)]] Parameters { + // [[codegen::verbatim(UseFixedTimeInfo.description)]] + std::optional useFixedTime; + + // [[codegen::verbatim(FixedTimeInfo.description)]] + std::optional fixedTime; + + enum class Mode { + Prototyped, + Folder + }; + // The mode that his temporal tile provider operates in. In the `Prototyped` mode, + // a given start and end time, temporal resolution, and perscriptive time format + // is used to generate the information used by GDAL to access the data. In the + // `folder` method, a folder and a time format is provided and each file in the + // folder is scanned using the time format instead + Mode mode; + + struct Prototyped { + struct Time { + // The (inclusive) starting time of the temporal image range + std::string start; + // The (inclusive) ending time of the temporal image range + std::string end; + }; + // The starting and ending times for the range of values + Time time; + + // The temporal resolution between each image + std::string temporalResolution; + + // The specification of the date format that is used in the tile provider. The + // time format must be specified in a manner appropriate for the SPICE + // function `timout_c`. + // https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timout_c.html + std::string timeFormat; + + // The text that will be used as the prototype to generate the data to load + // the image layer. Any occurance of `${OpenSpaceTimeId}` in this prototype + // is replaced with the current date according to the remaining information + // such as the resolution and the format and the resulting text is used to + // load the corresponding images + std::string prototype; + + }; + std::optional prototyped; + + struct Folder { + // The folder that is parsed for files. Every file in the provided directory + // is checked against the provided format and added if it adheres to said + // format + std::filesystem::path folder [[codegen::directory()]]; + + // The format of files that is pared in the provided folder. The format string + // has to be compatible to the C++ function get_time. + // https://en.cppreference.com/w/cpp/io/manip/get_time + std::string format; + }; + std::optional folder; + + // Determines whether this tile provider should interpolate between two adjacent + // layers + std::optional interpolation; + + // If provided, the tile provider will use this color map to convert a greyscale + // image to color + std::optional colormap; + }; +#include "temporaltileprovider_codegen.cpp" + + std::string_view timeStringify(const std::string& format, const openspace::Time& t) { + ZoneScoped + + constexpr const int BufferSize = 64; + ghoul_assert(format.size() < BufferSize, "Format string too long"); + + using namespace openspace; + + char FormatBuf[BufferSize]; + std::memset(FormatBuf, '\0', BufferSize); + std::memcpy(FormatBuf, format.c_str(), format.size()); + + char* OutBuf = reinterpret_cast( + global::memoryManager->TemporaryMemory.allocate(BufferSize) + ); + std::memset(OutBuf, '\0', BufferSize); + + const double time = t.j2000Seconds(); + SpiceManager::ref().dateFromEphemerisTime(time, OutBuf, BufferSize, FormatBuf); + return std::string_view(OutBuf, format.size()); + } +} // namespace + +namespace openspace::globebrowsing { + +TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary) + : _initDict(dictionary) + , _useFixedTime(UseFixedTimeInfo, false) + , _fixedTime(FixedTimeInfo) +{ + ZoneScoped + + const Parameters p = codegen::bake(dictionary); + + // Make sure that the user provided the data that they requested. The mode parameter + // is a required one and these two if statements tie the table requirement to the mode + if (p.mode == Parameters::Mode::Folder && !p.folder.has_value()) { + throw ghoul::RuntimeError( + "When selecting the `Folder` mode, a `Folder` table must be specified" + ); + } + if (p.mode == Parameters::Mode::Prototyped && !p.prototyped.has_value()) { + throw ghoul::RuntimeError( + "When selecting the `Prototyped` mode, a `Prototyped` table must be specified" + ); + } + + _useFixedTime = p.useFixedTime.value_or(_useFixedTime); + _useFixedTime.onChange([this]() { _fixedTimeDirty = true; }); + addProperty(_useFixedTime); + + _fixedTime = p.fixedTime.value_or(_fixedTime); + _fixedTime.onChange([this]() { _fixedTimeDirty = true; }); + addProperty(_fixedTime); + + _colormap = p.colormap.value_or(_colormap); + + if (p.prototyped.has_value()) { + _mode = Mode::Prototype; + + Time start = Time(p.prototyped->time.start); + Time end = Time::now(); + _prototyped.startTimeJ2000 = start.j2000Seconds(); + _prototyped.endTimeJ2000 = Time(p.prototyped->time.end).j2000Seconds(); + if (p.prototyped->time.end == "Yesterday") { + end.advanceTime(-60.0 * 60.0 * 24.0); // Go back one day + } + else if (p.prototyped->time.end != "Today") { + end.setTime(p.prototyped->time.end); + } + + try { + _prototyped.timeQuantizer.setStartEndRange( + std::string(start.ISO8601()), + std::string(end.ISO8601()) + ); + _prototyped.timeQuantizer.setResolution(p.prototyped->temporalResolution); + _prototyped.temporalResolution = p.prototyped->temporalResolution; + } + catch (const ghoul::RuntimeError& e) { + throw ghoul::RuntimeError(fmt::format( + "Could not create time quantizer for Temporal GDAL dataset. {}", e.message + )); + } + + if (p.prototyped->timeFormat.size() >= 64) { + throw ghoul::RuntimeError(fmt::format( + "Time format string '{}' too large. Maximum length of 64 is allowed", + p.prototyped->timeFormat + )); + } + _prototyped.timeFormat = p.prototyped->timeFormat; + _prototyped.prototype = p.prototyped->prototype; + } + + if (p.folder.has_value()) { + _mode = Mode::Folder; + + _folder.folder = p.folder->folder; + _folder.format = p.folder->format; + + namespace fs = std::filesystem; + for (const fs::directory_entry& path : fs::directory_iterator(_folder.folder)) { + if (!path.is_regular_file()) { + continue; + } + + std::string file = path.path().filename().string(); + std::istringstream ss(file); + + std::tm tm = {}; + ss >> std::get_time(&tm, p.folder->format.c_str()); + if (!ss.fail()) { + std::string date = fmt::format( + "{}-{}-{} {}:{}:{}", + tm.tm_year + 1900, + tm.tm_mon + 1, + tm.tm_mday, + tm.tm_hour, + tm.tm_min, + tm.tm_sec + ); + + double et = SpiceManager::ref().ephemerisTimeFromDate(date); + _folder.files.push_back({ et, path.path().string() }); + } + } + + using K = double; + using V = std::string; + std::sort( + _folder.files.begin(), + _folder.files.end(), + [](const std::pair& lhs, const std::pair& rhs) { + return lhs.first < rhs.first; + } + ); + } + + _isInterpolating = p.interpolation.value_or(_isInterpolating); + if (_isInterpolating) { + _interpolateTileProvider = std::make_unique(dictionary); + _interpolateTileProvider->initialize(); + _interpolateTileProvider->colormap = + ghoul::io::TextureReader::ref().loadTexture(_colormap, 1); + _interpolateTileProvider->colormap->uploadTexture(); + _interpolateTileProvider->colormap->setFilter( + ghoul::opengl::Texture::FilterMode::AnisotropicMipMap + ); + } +} + +Tile TemporalTileProvider::tile(const TileIndex& tileIndex) { + ZoneScoped + if (!_currentTileProvider) { + update(); + } + + return _currentTileProvider->tile(tileIndex); +} + +Tile::Status TemporalTileProvider::tileStatus(const TileIndex& index) { + if (!_currentTileProvider) { + update(); + } + + return _currentTileProvider->tileStatus(index); +} + +TileDepthTransform TemporalTileProvider::depthTransform() { + if (!_currentTileProvider) { + update(); + } + + return _currentTileProvider->depthTransform(); +} + +void TemporalTileProvider::update() { + TileProvider* newCurr = nullptr; + try { + if (_useFixedTime && !_fixedTime.value().empty()) { + if (_fixedTimeDirty) { + std::string fixedTime = _fixedTime.value(); + double et = SpiceManager::ref().ephemerisTimeFromDate(fixedTime); + newCurr = retrieveTileProvider(Time(et)); + _fixedTimeDirty = false; + } + } + else { + newCurr = tileProvider(global::timeManager->time()); + } + } + catch (const ghoul::RuntimeError& e) { + LERRORC("TemporalTileProvider", e.message); + } + + if (newCurr) { + _currentTileProvider = newCurr; + } + if (_currentTileProvider) { + _currentTileProvider->update(); + } +} + +void TemporalTileProvider::reset() { + for (std::pair& it : _tileProviderMap) { + it.second.reset(); + } +} + +int TemporalTileProvider::maxLevel() { + if (!_currentTileProvider) { + update(); + } + return _currentTileProvider->maxLevel(); +} + +float TemporalTileProvider::noDataValueAsFloat() { + return std::numeric_limits::min(); +} + +DefaultTileProvider TemporalTileProvider::createTileProvider( + std::string_view timekey) const +{ + ZoneScoped + + std::string value; + switch (_mode) { + case Mode::Prototype: { + static const std::vector IgnoredTokens = { + // From: http://www.gdal.org/frmt_wms.html + "${x}", "${y}", "${z}", "${version}" "${format}", "${layer}" + }; + + value = _prototyped.prototype; + while (true) { + const size_t pos = value.find(TimePlaceholder); + + if (pos == std::string::npos) { + break; + } + + const size_t numChars = std::string_view(TimePlaceholder).size(); + value = value.replace(pos, numChars, timekey); + } + + value = FileSys.expandPathTokens(std::move(value), IgnoredTokens).string(); + break; + } + case Mode::Folder: { + value = std::string(timekey); + break; + } + } + + ghoul::Dictionary dict = _initDict; + dict.setValue("FilePath", value); + return DefaultTileProvider(dict); +} + +DefaultTileProvider* TemporalTileProvider::retrieveTileProvider(const Time& t) { + ZoneScoped + + const double time = t.j2000Seconds(); + if (const auto it = _tileProviderMap.find(time); it != _tileProviderMap.end()) { + return &it->second; + } + + std::string_view timeStr = [this, time]() { + switch (_mode) { + case Mode::Prototype: + return timeStringify(_prototyped.timeFormat, Time(time)); + case Mode::Folder: { + // Yes this will have to be done twice since we do the check previously + // but it is only happening when the images change, so I think that should + // be fine + auto it = std::lower_bound( + _folder.files.cbegin(), + _folder.files.cend(), + time, + [](const std::pair& p, double time) { + return p.first < time; + } + ); + return std::string_view(it->second); + } + default: throw ghoul::MissingCaseException(); + }; + }(); + + DefaultTileProvider tileProvider = createTileProvider(timeStr); + tileProvider.initialize(); + + auto it = _tileProviderMap.insert({ time, std::move(tileProvider) }); + return &it.first->second; +} + +template <> +TileProvider* +TemporalTileProvider::tileProvider( + const Time& time) +{ + // Find the most current image that matches the current time. We can't pass the `time` + // variable into the retrieveTileProvider function as it would generate a new + // non-existing TileProvider for every new frame + using It = std::vector>::const_iterator; + It it = std::lower_bound( + _folder.files.begin(), + _folder.files.end(), + time.j2000Seconds(), + [](const std::pair& p, double t) { + return p.first < t; + } + ); + + if (it != _folder.files.begin()) { + it -= 1; + } + + double t = it->first; + return retrieveTileProvider(Time(t)); +} + +template <> +TileProvider* +TemporalTileProvider::tileProvider( + const Time& time) +{ + using It = std::vector>::const_iterator; + It next = std::lower_bound( + _folder.files.begin(), + _folder.files.end(), + time.j2000Seconds(), + [](const std::pair& p, double t) { + return p.first < t; + } + ); + + It curr = next != _folder.files.begin() ? next - 1 : next; + It nextNext = next != _folder.files.end() ? next + 1 : curr; + It prev = curr != _folder.files.begin() ? curr - 1 : curr; + + _interpolateTileProvider->t1 = retrieveTileProvider(Time(curr->first)); + _interpolateTileProvider->t2 = retrieveTileProvider(Time(next->first)); + _interpolateTileProvider->future = retrieveTileProvider(Time(nextNext->first)); + _interpolateTileProvider->before = retrieveTileProvider(Time(prev->first)); + + _interpolateTileProvider->factor = static_cast( + (time.j2000Seconds() - curr->first) / + (next->first - curr->first) + ); + + if (_interpolateTileProvider->factor > 1.f) { + _interpolateTileProvider->factor = 1.f; + } + + return _interpolateTileProvider.get(); +} + +template <> +TileProvider* +TemporalTileProvider::tileProvider( + const Time& time) +{ + Time tCopy(time); + if (_prototyped.timeQuantizer.quantize(tCopy, true)) { + return retrieveTileProvider(tCopy); + } + else { + return nullptr; + } +} + +template <> +TileProvider* +TemporalTileProvider::tileProvider( + const Time& time) +{ + Time tCopy(time); + if (!_prototyped.timeQuantizer.quantize(tCopy, true)) { + return nullptr; + } + + Time nextTile = tCopy; + Time nextNextTile = tCopy; + Time prevTile = tCopy; + Time secondToLast = Time(_prototyped.endTimeJ2000); + Time secondToFirst = Time(_prototyped.startTimeJ2000); + + _interpolateTileProvider->t1 = retrieveTileProvider(tCopy); + + // if the images are for each hour + if (_prototyped.temporalResolution == "1h") { + constexpr const int Hour = 60 * 60; + // the second tile to interpolate between + nextTile.advanceTime(Hour); + // the tile after the second tile + nextNextTile.advanceTime(2 * Hour); + // the tile before the first tile + prevTile.advanceTime(-Hour + 1); + // to make sure that an image outside the dataset is not searched for both + // ends of the dataset are calculated + secondToLast.advanceTime(-Hour); + secondToFirst.advanceTime(Hour); + } + // if the images are for each month + if (_prototyped.temporalResolution == "1M") { + constexpr const int Day = 24 * 60 * 60; + + // the second tile to interpolate between + nextTile.advanceTime(32 * Day); + // the tile after the second tile + nextNextTile.advanceTime(64 * Day); + // the tile before the first tile + prevTile.advanceTime(-2 * Day); + // to make sure that an image outside the dataset is not searched for both + // ends of the dataset are calculated + secondToLast.advanceTime(-2 * Day); + secondToFirst.advanceTime(32 * Day); + + // since months vary in length the time is set to the first of each month + auto setToFirstOfMonth = [](Time& t) { + std::string timeString = std::string(t.ISO8601()); + timeString[8] = '0'; + timeString[9] = '1'; + t.setTime(timeString); + }; + + setToFirstOfMonth(nextTile); + setToFirstOfMonth(nextNextTile); + setToFirstOfMonth(prevTile); + setToFirstOfMonth(secondToLast); + setToFirstOfMonth(secondToFirst); + } + + // the necessary tile providers are loaded if they exist within the timespan + if (secondToLast.j2000Seconds() > time.j2000Seconds() && + secondToFirst.j2000Seconds() < time.j2000Seconds()) + { + _interpolateTileProvider->t2 = retrieveTileProvider(nextTile); + _interpolateTileProvider->future = retrieveTileProvider(nextNextTile); + _interpolateTileProvider->before = retrieveTileProvider(prevTile); + } + else if (secondToLast.j2000Seconds() < time.j2000Seconds() && + _prototyped.endTimeJ2000 > time.j2000Seconds()) + { + _interpolateTileProvider->t2 = retrieveTileProvider(nextTile); + _interpolateTileProvider->future = retrieveTileProvider(tCopy); + _interpolateTileProvider->before = retrieveTileProvider(prevTile); + } + else if (secondToFirst.j2000Seconds() > time.j2000Seconds() && + _prototyped.startTimeJ2000 < time.j2000Seconds()) + { + _interpolateTileProvider->t2 = retrieveTileProvider(nextTile); + _interpolateTileProvider->future = retrieveTileProvider(nextNextTile); + _interpolateTileProvider->before = retrieveTileProvider(tCopy); + } + else { + _interpolateTileProvider->t2 = retrieveTileProvider(tCopy); + _interpolateTileProvider->future = retrieveTileProvider(tCopy); + _interpolateTileProvider->before = retrieveTileProvider(tCopy); + } + _interpolateTileProvider->factor = static_cast( + (time.j2000Seconds() - tCopy.j2000Seconds()) / + (nextTile.j2000Seconds() - tCopy.j2000Seconds()) + ); + + if (_interpolateTileProvider->factor > 1.f) { + _interpolateTileProvider->factor = 1.f; + } + return _interpolateTileProvider.get(); +} + +TileProvider* TemporalTileProvider::tileProvider(const Time& time) { + if (_isInterpolating) { + switch (_mode) { + case Mode::Folder: + return tileProvider(time); + case Mode::Prototype: + return tileProvider(time); + default: throw ghoul::MissingCaseException(); + } + } + else { + switch (_mode) { + case Mode::Folder: + return tileProvider(time); + case Mode::Prototype: + return tileProvider(time); + default: throw ghoul::MissingCaseException(); + } + } +} + +TemporalTileProvider::InterpolateTileProvider::InterpolateTileProvider( + const ghoul::Dictionary&) +{ + ZoneScoped + + glGenFramebuffers(1, &fbo); + glGenVertexArrays(1, &vaoQuad); + glGenBuffers(1, &vboQuad); + glBindVertexArray(vaoQuad); + glBindBuffer(GL_ARRAY_BUFFER, vboQuad); + // Quad for fullscreen with vertex (xy) and texture coordinates (uv) + const GLfloat vertexData[] = { + // x y u v + -1.f, -1.f, 0.f, 0.f, + 1.f, 1.f, 1.f, 1.f, + -1.f, 1.f, 0.f, 1.f, + -1.f, -1.f, 0.f, 0.f, + 1.f, -1.f, 1.f, 0.f, + 1.f, 1.f, 1.f, 1.f + }; + glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW); + // vertex coordinates at location 0 + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), nullptr); + glEnableVertexAttribArray(0); + // texture coords at location 1 + glVertexAttribPointer( + 1, + 2, + GL_FLOAT, + GL_FALSE, + 4 * sizeof(GLfloat), + reinterpret_cast(2 * sizeof(GLfloat)) + ); + glEnableVertexAttribArray(1); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); + shaderProgram = global::renderEngine->buildRenderProgram( + "InterpolatingProgram", + absPath("${MODULE_GLOBEBROWSING}/shaders/interpolate_vs.glsl"), + absPath("${MODULE_GLOBEBROWSING}/shaders/interpolate_fs.glsl") + ); +} + +TemporalTileProvider::InterpolateTileProvider::~InterpolateTileProvider() { + glDeleteFramebuffers(1, &fbo); + glDeleteBuffers(1, &vboQuad); + glDeleteVertexArrays(1, &vaoQuad); +} + +Tile TemporalTileProvider::InterpolateTileProvider::tile(const TileIndex& tileIndex) { + ZoneScoped + TracyGpuZone("tile"); + + // prev and next are the two tiles to interpolate between + Tile prev = t1->tile(tileIndex); + Tile next = t2->tile(tileIndex); + // the tile before and the tile after the interpolation interval are loaded so the + // interpolation goes smoother + Tile prevprev = before->tile(tileIndex); + Tile nextnext = future->tile(tileIndex); + cache::ProviderTileKey key = { tileIndex, uniqueIdentifier }; + + if (!prev.texture || !next.texture) { + return Tile{ nullptr, std::nullopt, Tile::Status::Unavailable }; + } + + // The data for initializing the texture + TileTextureInitData initData( + prev.texture->dimensions().x, + prev.texture->dimensions().y, + prev.texture->dataType(), + prev.texture->format(), + TileTextureInitData::PadTiles::No, + TileTextureInitData::ShouldAllocateDataOnCPU::No + ); + + // Check if a tile exists for the given key in the tileCache + // Initializing the tile that will contian the interpolated texture + Tile ourTile; + // The texture that will contain the interpolated image + ghoul::opengl::Texture* writeTexture; + cache::MemoryAwareTileCache* tileCache = + global::moduleEngine->module()->tileCache(); + if (tileCache->exist(key)) { + ourTile = tileCache->get(key); + writeTexture = ourTile.texture; + } + else { + // Create a texture with the initialization data + writeTexture = tileCache->texture(initData); + ourTile = Tile{ writeTexture, std::nullopt, Tile::Status::OK }; + tileCache->put(key, initData.hashKey, ourTile); + } + + // Saves current state + GLint currentFBO; + GLint viewport[4]; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFBO); + global::renderEngine->openglStateCache().viewport(viewport); + // Bind render texture to FBO + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, *writeTexture, 0); + glDisable(GL_BLEND); + GLenum textureBuffers[1] = { GL_COLOR_ATTACHMENT0 }; + glDrawBuffers(1, textureBuffers); + + // Setup our own viewport settings + GLsizei w = static_cast(writeTexture->width()); + GLsizei h = static_cast(writeTexture->height()); + glViewport(0, 0, w, h); + glClearColor(0.f, 0.f, 0.f, 0.f); + glClear(GL_COLOR_BUFFER_BIT); + GLint id; + glGetIntegerv(GL_CURRENT_PROGRAM, &id); + // Activate shader and bind uniforms + shaderProgram->activate(); + shaderProgram->setUniform("blendFactor", factor); + + // The texture that will give the color for the interpolated texture + ghoul::opengl::TextureUnit colormapUnit; + colormapUnit.activate(); + colormap->bind(); + shaderProgram->setUniform("colormapTexture", colormapUnit); + + ghoul::opengl::TextureUnit prevUnit; + prevUnit.activate(); + prev.texture->bind(); + shaderProgram->setUniform("prevTexture", prevUnit); + + ghoul::opengl::TextureUnit nextUnit; + nextUnit.activate(); + next.texture->bind(); + shaderProgram->setUniform("nextTexture", nextUnit); + + // Render to the texture + glBindVertexArray(vaoQuad); + glDrawArrays(GL_TRIANGLES, 0, 6); // 2 triangles + // Deactivate shader program (when rendering is completed) + shaderProgram->deactivate(); + glUseProgram(id); + // Restores system state + glBindFramebuffer(GL_FRAMEBUFFER, currentFBO); + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + // Restores OpenGL Rendering State + global::renderEngine->openglStateCache().resetColorState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetDepthState(); + global::renderEngine->openglStateCache().resetPolygonAndClippingState(); + global::renderEngine->openglStateCache().resetViewportState(); + + return ourTile; +} + +Tile::Status TemporalTileProvider::InterpolateTileProvider::tileStatus( + const TileIndex& index) +{ + return std::min(t1->tileStatus(index), t2->tileStatus(index)); +} + +TileDepthTransform TemporalTileProvider::InterpolateTileProvider::depthTransform() { + return t1->depthTransform(); +} + +void TemporalTileProvider::InterpolateTileProvider::update() { + t1->update(); + t2->update(); + before->update(); + future->update(); +} + +void TemporalTileProvider::InterpolateTileProvider::reset() { + t1->reset(); + t2->reset(); + before->reset(); + future->reset(); +} + +int TemporalTileProvider::InterpolateTileProvider::maxLevel() { + return glm::min(t1->maxLevel(), t2->maxLevel()); +} + +float TemporalTileProvider::InterpolateTileProvider::noDataValueAsFloat() { + return std::numeric_limits::min(); +} + +} // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/tileprovider/temporaltileprovider.h b/modules/globebrowsing/src/tileprovider/temporaltileprovider.h new file mode 100644 index 0000000000..95dfc1f128 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/temporaltileprovider.h @@ -0,0 +1,130 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TEMPORALTILEPROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TEMPORALTILEPROVIDER___H__ + +#include + +#include +#include + +namespace openspace::globebrowsing { + +/** + * Provide Tiles from web map services that have temporal resolution. + * + * TemporalTileProviders are instantiated using a ghoul::Dictionary, and must define a + * filepath to a Openspace Temporal dataset description file. This is an xml-file that + * defines the same meta data as the GDAL wms description + * (http://www.gdal.org/frmt_wms.html), but augmented with some extra tags describing the + * temporal properties of the dataset. See + * TemporalTileProvider::TemporalXMLTags + */ +class TemporalTileProvider : public TileProvider { +public: + TemporalTileProvider(const ghoul::Dictionary& dictionary); + + Tile tile(const TileIndex& tileIndex) override final; + Tile::Status tileStatus(const TileIndex& index) override final; + TileDepthTransform depthTransform() override final; + void update() override final; + void reset() override final; + int maxLevel() override final; + float noDataValueAsFloat() override final; + +private: + enum class Mode { + Prototype, + Folder + }; + + struct InterpolateTileProvider : public TileProvider { + InterpolateTileProvider(const ghoul::Dictionary&); + virtual ~InterpolateTileProvider(); + + Tile tile(const TileIndex& tileIndex) override final; + Tile::Status tileStatus(const TileIndex& index) override final; + TileDepthTransform depthTransform() override final; + void update() override final; + void reset() override final; + int maxLevel() override final; + float noDataValueAsFloat() override final; + + TileProvider* before = nullptr; + TileProvider* t1 = nullptr; + TileProvider* t2 = nullptr; + TileProvider* future = nullptr; + float factor = 1.f; + GLuint vaoQuad = 0; + GLuint vboQuad = 0; + GLuint fbo = 0; + std::unique_ptr shaderProgram; + std::unique_ptr colormap; + }; + + DefaultTileProvider createTileProvider(std::string_view timekey) const; + DefaultTileProvider* retrieveTileProvider(const Time& t); + + template + TileProvider* tileProvider(const Time& time); + + TileProvider* tileProvider(const Time& time); + + Mode _mode; + + struct { + double startTimeJ2000 = 0.0; + double endTimeJ2000 = 0.0; + + std::string temporalResolution; + std::string timeFormat; + TimeQuantizer timeQuantizer; + std::string prototype; + } _prototyped; + + struct { + std::filesystem::path folder; + std::string format; + + std::vector> files; + } _folder; + + ghoul::Dictionary _initDict; + properties::BoolProperty _useFixedTime; + properties::StringProperty _fixedTime; + bool _fixedTimeDirty = true; + + TileProvider* _currentTileProvider = nullptr; + std::unordered_map _tileProviderMap; + + bool _isInterpolating = false; + + std::string _colormap; + std::unique_ptr _interpolateTileProvider; +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TEMPORALTILEPROVIDER___H__ diff --git a/modules/globebrowsing/src/tileprovider/texttileprovider.cpp b/modules/globebrowsing/src/tileprovider/texttileprovider.cpp new file mode 100644 index 0000000000..aab99b3b8a --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/texttileprovider.cpp @@ -0,0 +1,109 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 +#include +#include +#include +#include +#include + +namespace openspace::globebrowsing { + +TextTileProvider::TextTileProvider(TileTextureInitData initData_, size_t fontSize_) + : initData(std::move(initData_)) + , fontSize(fontSize_) +{ + ZoneScoped + + tileCache = global::moduleEngine->module()->tileCache(); +} + +TextTileProvider::~TextTileProvider() {} + +void TextTileProvider::internalInitialize() { + ZoneScoped + + font = global::fontManager->font("Mono", static_cast(fontSize)); + fontRenderer = ghoul::fontrendering::FontRenderer::createDefault(); + fontRenderer->setFramebufferSize(glm::vec2(initData.dimensions)); + glGenFramebuffers(1, &fbo); +} + +void TextTileProvider::internalDeinitialize() { + glDeleteFramebuffers(1, &fbo); +} + +Tile TextTileProvider::renderTile(const TileIndex& tileIndex, const std::string& text, + const glm::vec2& position, const glm::vec4& color) +{ + ZoneScoped + TracyGpuZone("tile") + + cache::ProviderTileKey key = { tileIndex, uniqueIdentifier }; + Tile tile = tileCache->get(key); + if (!tile.texture) { + ghoul::opengl::Texture* texture = tileCache->texture(initData); + + // Keep track of defaultFBO and viewport to be able to reset state when done + GLint defaultFBO = global::renderEngine->openglStateCache().defaultFramebuffer(); + + // Render to texture + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + glFramebufferTexture2D( + GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, + *texture, + 0 + ); + + GLsizei w = static_cast(texture->width()); + GLsizei h = static_cast(texture->height()); + glViewport(0, 0, w, h); + glClearColor(0.f, 0.f, 0.f, 0.f); + glClear(GL_COLOR_BUFFER_BIT); + + fontRenderer->render(*font, position, text, color); + + glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); + global::renderEngine->openglStateCache().resetViewportState(); + + tile = Tile{ texture, std::nullopt, Tile::Status::OK }; + tileCache->put(key, initData.hashKey, tile); + } + return tile; +} + +void TextTileProvider::reset() { + ZoneScoped + + tileCache->clear(); +} + +} // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/tileprovider/texttileprovider.h b/modules/globebrowsing/src/tileprovider/texttileprovider.h new file mode 100644 index 0000000000..5f3b0816a1 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/texttileprovider.h @@ -0,0 +1,60 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TEXTTILEPROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TEXTTILEPROVIDER___H__ + +#include + +namespace openspace::globebrowsing { + +class TextTileProvider : public TileProvider { +public: + TextTileProvider(TileTextureInitData initData, size_t fontSize = 48); + virtual ~TextTileProvider(); + + void reset() override; + +protected: + Tile renderTile(const TileIndex& tileIndex, const std::string& text, + const glm::vec2& position, const glm::vec4& color); + + const TileTextureInitData initData; + + std::unique_ptr fontRenderer; + std::shared_ptr font; + size_t fontSize = 0; + + GLuint fbo = 0; + + cache::MemoryAwareTileCache* tileCache; + +private: + void internalInitialize() override final; + void internalDeinitialize() override final; +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TEXTTILEPROVIDER___H__ diff --git a/modules/globebrowsing/src/tileprovider/tileindextileprovider.cpp b/modules/globebrowsing/src/tileprovider/tileindextileprovider.cpp new file mode 100644 index 0000000000..30489b9500 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/tileindextileprovider.cpp @@ -0,0 +1,65 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 + +namespace openspace::globebrowsing { + +TileIndexTileProvider::TileIndexTileProvider(const ghoul::Dictionary&) + : TextTileProvider(tileTextureInitData(layergroupid::GroupID::ColorLayers, false)) +{} + +Tile TileIndexTileProvider::tile(const TileIndex& tileIndex) { + ZoneScoped + std::string text = fmt::format( + "level: {}\nx: {}\ny: {}", tileIndex.level, tileIndex.x, tileIndex.y + ); + glm::vec2 textPosition = glm::vec2( + initData.dimensions.x / 4 - + (initData.dimensions.x / 32) * log10(1 << tileIndex.level), + initData.dimensions.y / 2 + fontSize + ); + + return TextTileProvider::renderTile(tileIndex, text, textPosition, glm::vec4(1.f)); +} + +Tile::Status TileIndexTileProvider::tileStatus(const TileIndex&) { + return Tile::Status::OK; +} + +TileDepthTransform TileIndexTileProvider::depthTransform() { + return { 0.f, 1.f }; +} + +void TileIndexTileProvider::update() {} + +int TileIndexTileProvider::maxLevel() { + return 1337; // unlimited +} + +float TileIndexTileProvider::noDataValueAsFloat() { + return std::numeric_limits::min(); +} + +} // namespace openspace::globebrowsing diff --git a/tests/test_temporaltileprovider.cpp b/modules/globebrowsing/src/tileprovider/tileindextileprovider.h similarity index 71% rename from tests/test_temporaltileprovider.cpp rename to modules/globebrowsing/src/tileprovider/tileindextileprovider.h index bbe6ca740b..0913b59fe3 100644 --- a/tests/test_temporaltileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider/tileindextileprovider.h @@ -22,14 +22,25 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include "catch2/catch.hpp" +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEINDEXTILEPROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEINDEXTILEPROVIDER___H__ -#include -#include -#include +#include -namespace { - constexpr const char* fileName = "data/scene/debugglobe/map_service_configs/" - "VIIRS_SNPP_CorrectedReflectance_TrueColor_temporal.xml"; -} // namespace +namespace openspace::globebrowsing { +class TileIndexTileProvider : public TextTileProvider { +public: + TileIndexTileProvider(const ghoul::Dictionary& dictionary); + + Tile tile(const TileIndex& tileIndex) override final; + Tile::Status tileStatus(const TileIndex& index) override final; + TileDepthTransform depthTransform() override final; + void update() override final; + int maxLevel() override final; + float noDataValueAsFloat() override final; +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEINDEXTILEPROVIDER___H__ diff --git a/modules/globebrowsing/src/tileprovider/tileprovider.cpp b/modules/globebrowsing/src/tileprovider/tileprovider.cpp new file mode 100644 index 0000000000..cc7ea99e24 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/tileprovider.cpp @@ -0,0 +1,238 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpl_minixml.h" + +namespace openspace::globebrowsing { + +namespace { + +std::unique_ptr DefaultTileTexture; +Tile DefaultTile = Tile { nullptr, std::nullopt, Tile::Status::Unavailable }; + +constexpr const char* KeyFilePath = "FilePath"; + +} // namespace + +unsigned int TileProvider::NumTileProviders = 0; + +std::unique_ptr TileProvider::createFromDictionary( + layergroupid::TypeID layerTypeID, + const ghoul::Dictionary& dictionary) +{ + ZoneScoped + + const char* type = layergroupid::LAYER_TYPE_NAMES[static_cast(layerTypeID)]; + auto factory = FactoryManager::ref().factory(); + TileProvider* result = factory->create(type, dictionary); + return std::unique_ptr(result); +} + +void TileProvider::initializeDefaultTile() { + ZoneScoped + + ghoul_assert(!DefaultTile.texture, "Default tile should not have been created"); + using namespace ghoul::opengl; + + // Create pixel data + TileTextureInitData initData( + 8, + 8, + GL_UNSIGNED_BYTE, + Texture::Format::RGBA, + TileTextureInitData::PadTiles::No, + TileTextureInitData::ShouldAllocateDataOnCPU::Yes + ); + char* pixels = new char[initData.totalNumBytes]; + memset(pixels, 0, initData.totalNumBytes * sizeof(char)); + + // Create ghoul texture + DefaultTileTexture = std::make_unique(initData.dimensions, GL_TEXTURE_2D); + DefaultTileTexture->setDataOwnership(Texture::TakeOwnership::Yes); + DefaultTileTexture->setPixelData(pixels); + DefaultTileTexture->uploadTexture(); + DefaultTileTexture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); + + // Create tile + DefaultTile = Tile{ DefaultTileTexture.get(), std::nullopt, Tile::Status::OK }; +} + +void TileProvider::deinitializeDefaultTile() { + DefaultTileTexture = nullptr; +} + +TileProvider::TileProvider() : properties::PropertyOwner({ "TileProvider" }) {} + +void TileProvider::initialize() { + ZoneScoped + + ghoul_assert(!isInitialized, "TileProvider can only be initialized once."); + + if (TileProvider::NumTileProviders > + static_cast(std::numeric_limits::max()) - 1) + { + LERRORC( + "TileProvider", + "Number of tile providers exceeds 65535. Something will break soon" + ); + TileProvider::NumTileProviders = 0; + } + uniqueIdentifier = static_cast(TileProvider::NumTileProviders++); + if (TileProvider::NumTileProviders == std::numeric_limits::max()) { + --TileProvider::NumTileProviders; + return; + } + + internalInitialize(); + isInitialized = true; +} + +void TileProvider::deinitialize() { + ZoneScoped + + internalDeinitialize(); +} + +void TileProvider::internalInitialize() {} +void TileProvider::internalDeinitialize() {} + +ChunkTile TileProvider::chunkTile(TileIndex tileIndex, int parents, int maxParents) { + ZoneScoped + + ghoul_assert(isInitialized, "TileProvider was not initialized."); + + auto ascendToParent = [](TileIndex& ti, TileUvTransform& uv) { + uv.uvOffset *= 0.5; + uv.uvScale *= 0.5; + + uv.uvOffset += ti.positionRelativeParent(); + + ti.x /= 2; + ti.y /= 2; + ti.level--; + }; + + TileUvTransform uvTransform = { glm::vec2(0.f, 0.f), glm::vec2(1.f, 1.f) }; + + // Step 1. Traverse 0 or more parents up the chunkTree as requested by the caller + for (int i = 0; i < parents && tileIndex.level > 1; i++) { + ascendToParent(tileIndex, uvTransform); + } + maxParents -= parents; + + // Step 2. Traverse 0 or more parents up the chunkTree to make sure we're inside + // the range of defined data. + int maximumLevel = maxLevel(); + while (tileIndex.level > maximumLevel) { + ascendToParent(tileIndex, uvTransform); + maxParents--; + } + if (maxParents < 0) { + return ChunkTile { Tile(), uvTransform, TileDepthTransform() }; + } + + // Step 3. Traverse 0 or more parents up the chunkTree until we find a chunk that + // has a loaded tile ready to use. + while (tileIndex.level > 1) { + Tile t = tile(tileIndex); + if (t.status != Tile::Status::OK) { + if (--maxParents < 0) { + return ChunkTile { Tile(), uvTransform, TileDepthTransform() }; + } + ascendToParent(tileIndex, uvTransform); + } + else { + return ChunkTile { std::move(t), uvTransform, TileDepthTransform() }; + } + } + + return ChunkTile { Tile(), uvTransform, TileDepthTransform() }; +} + +ChunkTilePile TileProvider::chunkTilePile(TileIndex tileIndex, int pileSize) { + ZoneScoped + + ghoul_assert(isInitialized, "TileProvider was not initialized."); + ghoul_assert(pileSize >= 0, "pileSize must be positive"); + + ChunkTilePile chunkTilePile; + std::fill(chunkTilePile.begin(), chunkTilePile.end(), std::nullopt); + for (int i = 0; i < pileSize; ++i) { + chunkTilePile[i] = chunkTile(tileIndex, i); + if (chunkTilePile[i]->tile.status == Tile::Status::Unavailable) { + if (i == 0) { + // First iteration + chunkTilePile[i]->tile = DefaultTile; + chunkTilePile[i]->uvTransform.uvOffset = { 0.f, 0.f }; + chunkTilePile[i]->uvTransform.uvScale = { 1.f, 1.f }; + } + else { + // We are iterating through the array one-by-one, so we are guaranteed + // that for tile 'i', tile 'i-1' already was initializated + chunkTilePile[i]->tile = chunkTilePile[i - 1]->tile; + chunkTilePile[i]->uvTransform.uvOffset = + chunkTilePile[i - 1]->uvTransform.uvOffset; + chunkTilePile[i]->uvTransform.uvScale = + chunkTilePile[i - 1]->uvTransform.uvScale; + } + } + } + return chunkTilePile; +} + +} // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/tileprovider/tileprovider.h b/modules/globebrowsing/src/tileprovider/tileprovider.h new file mode 100644 index 0000000000..ce9b63aa4e --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/tileprovider.h @@ -0,0 +1,145 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEPROVIDER___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEPROVIDER___H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct CPLXMLNode; + +namespace ghoul::fontrendering { + class Font; + class FontRenderer; +} // namespace ghoul::fontrendering + +namespace openspace { class PixelBuffer; } + +namespace openspace::globebrowsing { + class AsyncTileDataProvider; + struct RawTile; + struct TileIndex; + namespace cache { class MemoryAwareTileCache; } +} // namespace openspace::globebrowsing + +namespace openspace::globebrowsing { + +enum class Type { + DefaultTileProvider = 0, + SingleImageTileProvider, + ImageSequenceTileProvider, + SizeReferenceTileProvider, + TemporalTileProvider, + TileIndexTileProvider, + ByIndexTileProvider, + ByLevelTileProvider, + InterpolateTileProvider +}; + + +struct TileProvider : public properties::PropertyOwner { + static unsigned int NumTileProviders; + + static std::unique_ptr createFromDictionary( + layergroupid::TypeID layerTypeID, const ghoul::Dictionary& dictionary); + + static void initializeDefaultTile(); + static void deinitializeDefaultTile(); + + TileProvider(); + virtual ~TileProvider() = default; + + void initialize(); + void deinitialize(); + + virtual Tile tile(const TileIndex& tileIndex) = 0; + + /** + * Returns the status of a Tile. The Tile::Status + * corresponds the Tile that would be returned if the function + * tile would be invoked with the same TileIndex argument at + * this point in time. + */ + virtual Tile::Status tileStatus(const TileIndex& index) = 0; + + /** + * Get the associated depth transform for this TileProvider. This is necessary for + * TileProviders serving height map data, in order to correcly map pixel values to + * meters. + */ + virtual TileDepthTransform depthTransform() = 0; + + /** + * This method should be called once per frame. Here, TileProviders are given the + * opportunity to update their internal state. + */ + virtual void update() = 0; + + /** + * Provides a uniform way of all TileProviders to reload or restore all of its + * internal state. This is mainly useful for debugging purposes. + */ + virtual void reset() = 0; + + /** + * \return The maximum level as defined by TileIndex that this + * TileProvider is able provide. + */ + virtual int maxLevel() = 0; + + /** + * \return the no data value for the dataset. Default is the minimum float value. + */ + virtual float noDataValueAsFloat() = 0; + + + ChunkTile chunkTile(TileIndex tileIndex, int parents = 0, int maxParents = 1337); + ChunkTilePile chunkTilePile(TileIndex tileIndex, int pileSize); + + + std::string name; + + uint16_t uniqueIdentifier = 0; + bool isInitialized = false; + +private: + virtual void internalInitialize(); + virtual void internalDeinitialize(); +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEPROVIDER___H__ diff --git a/modules/globebrowsing/src/tileprovider/tileproviderbyindex.cpp b/modules/globebrowsing/src/tileprovider/tileproviderbyindex.cpp new file mode 100644 index 0000000000..af85ae70d8 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/tileproviderbyindex.cpp @@ -0,0 +1,140 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 + +namespace { + constexpr const char* KeyDefaultProvider = "DefaultProvider"; + constexpr const char* KeyProviders = "IndexTileProviders"; + constexpr const char* KeyTileIndex = "TileIndex"; + constexpr const char* KeyTileProvider = "TileProvider"; + + struct [[codegen::Dictionary(TileProviderByIndex)]] Parameters { + ghoul::Dictionary defaultProvider; + + struct IndexProvider { + struct Index { + int x [[codegen::greaterequal(0)]]; + int y [[codegen::greaterequal(0)]]; + int level [[codegen::inrange(0, 255)]]; + }; + Index tileIndex; + ghoul::Dictionary tileProvider; + }; + std::vector indexTileProviders; + }; +#include "tileproviderbyindex_codegen.cpp" +} // namespace + +namespace openspace::globebrowsing { + +TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) { + ZoneScoped + + const Parameters p = codegen::bake(dictionary); + + layergroupid::TypeID typeID = layergroupid::TypeID::DefaultTileLayer; + if (p.defaultProvider.hasValue("Type")) { + std::string type = p.defaultProvider.value("Type"); + typeID = ghoul::from_string(type); + + if (typeID == layergroupid::TypeID::Unknown) { + throw ghoul::RuntimeError("Unknown layer type: " + type); + } + } + + _defaultTileProvider = createFromDictionary(typeID, p.defaultProvider); + + for (const Parameters::IndexProvider& ip : p.indexTileProviders) { + const TileIndex tileIndex( + ip.tileIndex.x, + ip.tileIndex.y, + static_cast(ip.tileIndex.level) + ); + + layergroupid::TypeID providerTypeID = layergroupid::TypeID::DefaultTileLayer; + if (ip.tileProvider.hasValue("Type")) { + std::string type = ip.tileProvider.value("Type"); + providerTypeID = ghoul::from_string(type); + + if (providerTypeID == layergroupid::TypeID::Unknown) { + throw ghoul::RuntimeError("Unknown layer type: " + type); + } + } + + std::unique_ptr stp = createFromDictionary( + providerTypeID, + ip.tileProvider + ); + TileIndex::TileHashKey key = tileIndex.hashKey(); + _providers.insert(std::make_pair(key, std::move(stp))); + } +} + +Tile TileProviderByIndex::tile(const TileIndex& tileIndex) { + ZoneScoped + const auto it = _providers.find(tileIndex.hashKey()); + const bool hasProvider = it != _providers.end(); + return hasProvider ? it->second->tile(tileIndex) : Tile(); +} + +Tile::Status TileProviderByIndex::tileStatus(const TileIndex& index) { + const auto it = _providers.find(index.hashKey()); + const bool hasProvider = it != _providers.end(); + return hasProvider ? it->second->tileStatus(index) : Tile::Status::Unavailable; +} + +TileDepthTransform TileProviderByIndex::depthTransform() { + return _defaultTileProvider->depthTransform(); +} + +void TileProviderByIndex::update() { + using K = TileIndex::TileHashKey; + using V = std::unique_ptr; + for (std::pair& it : _providers) { + it.second->update(); + } + _defaultTileProvider->update(); +} + +void TileProviderByIndex::reset() { + using K = TileIndex::TileHashKey; + using V = std::unique_ptr; + for (std::pair& it : _providers) { + it.second->reset(); + } + _defaultTileProvider->reset(); +} + +int TileProviderByIndex::maxLevel() { + return _defaultTileProvider->maxLevel(); +} + +float TileProviderByIndex::noDataValueAsFloat() { + return std::numeric_limits::min(); +} + +} // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/tileprovider/tileproviderbyindex.h b/modules/globebrowsing/src/tileprovider/tileproviderbyindex.h new file mode 100644 index 0000000000..1d523748e2 --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/tileproviderbyindex.h @@ -0,0 +1,51 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEPROVIDERBYINDEX___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEPROVIDERBYINDEX___H__ + +#include + +namespace openspace::globebrowsing { + +class TileProviderByIndex : public TileProvider { +public: + TileProviderByIndex(const ghoul::Dictionary& dictionary); + + Tile tile(const TileIndex& tileIndex) override final; + Tile::Status tileStatus(const TileIndex& index) override final; + TileDepthTransform depthTransform() override final; + void update() override final; + void reset() override final; + int maxLevel() override final; + float noDataValueAsFloat() override final; + +private: + std::unordered_map> _providers; + std::unique_ptr _defaultTileProvider; +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEPROVIDERBYINDEX___H__ diff --git a/modules/globebrowsing/src/tileprovider/tileproviderbylevel.cpp b/modules/globebrowsing/src/tileprovider/tileproviderbylevel.cpp new file mode 100644 index 0000000000..c27576012d --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/tileproviderbylevel.cpp @@ -0,0 +1,161 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 + +namespace { + struct [[codegen::Dictionary(TileProviderByLevel)]] Parameters { + int layerGroupID; + + struct Providers { + int maxLevel [[codegen::greaterequal(0)]]; + ghoul::Dictionary tileProvider; + }; + std::vector levelTileProviders; + }; +#include "tileproviderbylevel_codegen.cpp" +} // namespace + +namespace openspace::globebrowsing { + +TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) { + ZoneScoped + + const Parameters p = codegen::bake(dictionary); + + layergroupid::GroupID layerGroup = static_cast(p.layerGroupID); + + for (Parameters::Providers p : p.levelTileProviders) { + p.tileProvider.setValue("LayerGroupID", static_cast(layerGroup)); + + layergroupid::TypeID typeID = layergroupid::TypeID::DefaultTileLayer; + if (p.tileProvider.hasValue("Type")) { + std::string type = p.tileProvider.value("Type"); + typeID = ghoul::from_string(type); + + if (typeID == layergroupid::TypeID::Unknown) { + throw ghoul::RuntimeError("Unknown layer type: " + type); + } + } + + std::unique_ptr tp = createFromDictionary(typeID, p.tileProvider); + + std::string provId = p.tileProvider.value("Identifier"); + tp->setIdentifier(provId); + std::string providerName = p.tileProvider.value("Name"); + tp->setGuiName(providerName); + addPropertySubOwner(tp.get()); + + _levelTileProviders.push_back(std::move(tp)); + + // Ensure we can represent the max level + if (static_cast(_providerIndices.size()) < p.maxLevel) { + _providerIndices.resize(p.maxLevel + 1, -1); + } + + // map this level to the tile provider index + _providerIndices[p.maxLevel] = static_cast(_levelTileProviders.size()) - 1; + } + + // Fill in the gaps (value -1 ) in provider indices, from back to end + for (int i = static_cast(_providerIndices.size()) - 2; i >= 0; --i) { + if (_providerIndices[i] == -1) { + _providerIndices[i] = _providerIndices[i + 1]; + } + } +} + +void TileProviderByLevel::internalInitialize() { + for (const std::unique_ptr& prov : _levelTileProviders) { + prov->initialize(); + } +} + +void TileProviderByLevel::internalDeinitialize() { + for (const std::unique_ptr& prov : _levelTileProviders) { + prov->deinitialize(); + } +} + +Tile TileProviderByLevel::tile(const TileIndex& tileIndex) { + ZoneScoped + + TileProvider* provider = levelProvider(tileIndex.level); + if (provider) { + return provider->tile(tileIndex); + } + else { + return Tile(); + } +} + +Tile::Status TileProviderByLevel::tileStatus(const TileIndex& index) { + TileProvider* provider = levelProvider(index.level); + return provider ? provider->tileStatus(index) : Tile::Status::Unavailable; +} + +TileProvider* TileProviderByLevel::levelProvider(int level) const { + ZoneScoped + + if (!_levelTileProviders.empty()) { + int clampedLevel = glm::clamp( + level, + 0, + static_cast(_providerIndices.size() - 1) + ); + int idx = _providerIndices[clampedLevel]; + return _levelTileProviders[idx].get(); + } + else { + return nullptr; + } +} + +TileDepthTransform TileProviderByLevel::depthTransform() { + return { 0.f, 1.f }; +} + +void TileProviderByLevel::update() { + for (const std::unique_ptr& provider : _levelTileProviders) { + provider->update(); + } +} + +void TileProviderByLevel::reset() { + for (const std::unique_ptr& provider : _levelTileProviders) { + provider->reset(); + } +} + +int TileProviderByLevel::maxLevel() { + return static_cast(_providerIndices.size() - 1); +} + +float TileProviderByLevel::noDataValueAsFloat() { + return std::numeric_limits::min(); +} + +} // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/tileprovider/tileproviderbylevel.h b/modules/globebrowsing/src/tileprovider/tileproviderbylevel.h new file mode 100644 index 0000000000..1ec3c4995e --- /dev/null +++ b/modules/globebrowsing/src/tileprovider/tileproviderbylevel.h @@ -0,0 +1,55 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEPROVIDERBYLEVEL___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEPROVIDERBYLEVEL___H__ + +#include + +namespace openspace::globebrowsing { + +class TileProviderByLevel : public TileProvider { +public: + TileProviderByLevel(const ghoul::Dictionary& dictionary); + + Tile tile(const TileIndex& tileIndex) override final; + Tile::Status tileStatus(const TileIndex& index) override final; + TileDepthTransform depthTransform() override final; + void update() override final; + void reset() override final; + int maxLevel() override final; + float noDataValueAsFloat() override final; + +private: + std::vector _providerIndices; + std::vector> _levelTileProviders; + + void internalInitialize() override final; + void internalDeinitialize() override final; + TileProvider* levelProvider(int level) const; +}; + +} // namespace openspace::globebrowsing + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILEPROVIDER__TILEPROVIDERBYLEVEL___H__ diff --git a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp index 38862178e5..16a55863b2 100644 --- a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp +++ b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp @@ -73,7 +73,7 @@ namespace { namespace openspace { documentation::Documentation RenderableCrawlingLine::Documentation() { - return codegen::doc("newhorizons_renderable_crawlingline"); + return codegen::doc("spacecraftinstruments_renderablecrawlingline"); } RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictionary) diff --git a/modules/spacecraftinstruments/rendering/renderablefov.cpp b/modules/spacecraftinstruments/rendering/renderablefov.cpp index e7eb9a9134..993cccb0c3 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.cpp +++ b/modules/spacecraftinstruments/rendering/renderablefov.cpp @@ -196,7 +196,7 @@ namespace { namespace openspace { documentation::Documentation RenderableFov::Documentation() { - return codegen::doc("newhorizons_renderable_fieldofview"); + return codegen::doc("spacecraftinstruments_renderablefieldofview"); } RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary) diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 3bd9ea34ba..085aa9b429 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -90,7 +90,7 @@ namespace { namespace openspace { documentation::Documentation RenderableModelProjection::Documentation() { - return codegen::doc("newhorizons_renderable_modelprojection"); + return codegen::doc("spacecraftinstruments_renderablemodelprojection"); } RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& dictionary) diff --git a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp index 9fac9699f6..2a5aab8aeb 100644 --- a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp @@ -45,6 +45,7 @@ namespace { constexpr const char* _loggerCat = "RenderablePlaneProjection"; constexpr const char* GalacticFrame = "GALACTIC"; + // @TODO (emmbr 2022-01-20) Add documentation struct [[codegen::Dictionary(RenderablePlaneProjection)]] Parameters { std::optional spacecraft; std::optional instrument; @@ -58,6 +59,10 @@ namespace { namespace openspace { +documentation::Documentation RenderablePlaneProjection::Documentation() { + return codegen::doc("spacecraftinstruments_renderableorbitdisc"); +} + RenderablePlaneProjection::RenderablePlaneProjection(const ghoul::Dictionary& dict) : Renderable(dict) { diff --git a/modules/spacecraftinstruments/rendering/renderableplaneprojection.h b/modules/spacecraftinstruments/rendering/renderableplaneprojection.h index cf78ef932c..5a225883f7 100644 --- a/modules/spacecraftinstruments/rendering/renderableplaneprojection.h +++ b/modules/spacecraftinstruments/rendering/renderableplaneprojection.h @@ -56,6 +56,8 @@ public: void render(const RenderData& data, RendererTasks& rendererTask) override; void update(const UpdateData& data) override; + static documentation::Documentation Documentation(); + private: void loadTexture(); void updatePlane(const Image& img, double currentTime); diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 05900d0cd0..804c96c71c 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -162,7 +162,7 @@ namespace { namespace openspace { documentation::Documentation RenderablePlanetProjection::Documentation() { - return codegen::doc("newhorizons_renderable_planetprojection"); + return codegen::doc("spacecraftinstruments_renderableplanetprojection"); } RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dict) diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp index 7df88e279f..30f515a775 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp @@ -143,7 +143,7 @@ namespace { namespace openspace { documentation::Documentation RenderableShadowCylinder::Documentation() { - return codegen::doc("newhorizons_renderable_shadowcylinder"); + return codegen::doc("spacecraftinstruments_renderableshadowcylinder"); } RenderableShadowCylinder::RenderableShadowCylinder(const ghoul::Dictionary& dictionary) diff --git a/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp b/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp index b60f0c0181..874b33dfbf 100644 --- a/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp +++ b/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp @@ -61,12 +61,12 @@ void SpacecraftInstrumentsModule::internalInitialize(const ghoul::Dictionary&) { auto fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "No renderable factory existed"); - fRenderable->registerClass("RenderableShadowCylinder"); fRenderable->registerClass("RenderableCrawlingLine"); fRenderable->registerClass("RenderableFov"); + fRenderable->registerClass("RenderableModelProjection"); fRenderable->registerClass("RenderablePlaneProjection"); fRenderable->registerClass("RenderablePlanetProjection"); - fRenderable->registerClass("RenderableModelProjection"); + fRenderable->registerClass("RenderableShadowCylinder"); auto fDecoder = FactoryManager::ref().factory(); fDecoder->registerClass("Instrument"); @@ -85,9 +85,12 @@ std::vector SpacecraftInstrumentsModule::documentations() const { return { + RenderableCrawlingLine::Documentation(), RenderableFov::Documentation(), RenderableModelProjection::Documentation(), + RenderablePlaneProjection::Documentation(), RenderablePlanetProjection::Documentation(), + RenderableShadowCylinder::Documentation(), ProjectionComponent::Documentation() }; } diff --git a/modules/spacecraftinstruments/util/projectioncomponent.cpp b/modules/spacecraftinstruments/util/projectioncomponent.cpp index 3955db5c3c..1298646143 100644 --- a/modules/spacecraftinstruments/util/projectioncomponent.cpp +++ b/modules/spacecraftinstruments/util/projectioncomponent.cpp @@ -162,7 +162,7 @@ namespace { namespace openspace { documentation::Documentation ProjectionComponent::Documentation() { - return codegen::doc("newhorizons_projectioncomponent"); + return codegen::doc("spacecraftinstruments_projectioncomponent"); } ProjectionComponent::ProjectionComponent() diff --git a/modules/toyvolume/rendering/renderabletoyvolume.cpp b/modules/toyvolume/rendering/renderabletoyvolume.cpp index bccf0aee95..c5e5b1934c 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.cpp +++ b/modules/toyvolume/rendering/renderabletoyvolume.cpp @@ -32,7 +32,7 @@ #include namespace { - constexpr const char* _loggerCat = "Renderable ToyVolume"; + constexpr const char* _loggerCat = "RenderableToyVolume"; constexpr openspace::properties::Property::PropertyInfo SizeInfo = { "Size", "Size", diff --git a/src/navigation/orbitalnavigator.cpp b/src/navigation/orbitalnavigator.cpp index 80ab5f441d..d190938d28 100644 --- a/src/navigation/orbitalnavigator.cpp +++ b/src/navigation/orbitalnavigator.cpp @@ -134,24 +134,33 @@ namespace { }; constexpr openspace::properties::Property::PropertyInfo FollowAnchorNodeInfo = { + "FollowAnchorNodeRotation", + "Follow Anchor Node Rotation", + "If true, the camera will rotate with the current achor node if within a " + "certain distance from it. When this happens, the object will appear fixed in " + "relation to the camera. The distance at which the change happens is controlled " + "through another property." + }; + + constexpr openspace::properties::Property::PropertyInfo + FollowAnchorNodeDistanceInfo = { "FollowAnchorNodeRotationDistance", - "Follow anchor node rotation distance", + "Follow Anchor Node Rotation Distance", "A factor used to determine the distance at which the camera starts rotating " - "with the anchor node. When this happends, a the object will appear fixed in " - "relation to the camera. The actual distance will be computed by multiplying " + "with the anchor node. The actual distance will be computed by multiplying " "this factor with the approximate radius of the node." }; constexpr openspace::properties::Property::PropertyInfo MinimumDistanceInfo = { "MinimumAllowedDistance", - "Minimum allowed distance", + "Minimum Allowed Distance", "Limits how close the camera can get to an object. The distance is given in " "meters above the surface." }; constexpr openspace::properties::Property::PropertyInfo VelocityZoomControlInfo = { "VelocityZoomControl", - "Velocity zoom control", + "Velocity Zoom Control", "Controls the velocity of the camera motion when zooming in to the focus node " "on a linear flight. The higher the value the faster the camera will move " "towards the focus." @@ -180,7 +189,7 @@ namespace { constexpr openspace::properties::Property::PropertyInfo StereoInterpolationTimeInfo = { "StereoInterpolationTime", - "Stereo interpolation time", + "Stereo Interpolation Time", "The time to interpolate to a new stereoscopic depth " "when the anchor node is changed, in seconds." }; @@ -188,7 +197,7 @@ namespace { constexpr openspace::properties::Property::PropertyInfo RetargetInterpolationTimeInfo = { "RetargetAnchorInterpolationTime", - "Retarget interpolation time", + "Retarget Interpolation Time", "The time to interpolate the camera rotation " "when the anchor or aim node is changed, in seconds." }; @@ -196,13 +205,13 @@ namespace { constexpr openspace::properties::Property::PropertyInfo FollowRotationInterpTimeInfo = { "FollowRotationInterpolationTime", - "Follow rotation interpolation time", + "Follow Rotation Interpolation Time", "The interpolation time when toggling following focus node rotation." }; constexpr openspace::properties::Property::PropertyInfo InvertMouseButtons = { "InvertMouseButtons", - "Invert left and right mouse buttons", + "Invert Left and Right Mouse Buttons", "If this value is 'false', the left mouse button causes the camera to rotate " "around the object and the right mouse button causes the zooming motion. If this " "value is 'true', these two functionalities are reversed." @@ -229,7 +238,7 @@ namespace { constexpr openspace::properties::Property::PropertyInfo StereoscopicDepthOfFocusSurfaceInfo = { "StereoscopicDepthOfFocusSurface", - "Stereoscopic depth of the surface in focus", + "Stereoscopic Depth of the Surface in Focus", "Set the stereoscopically perceived distance (in meters) to the closest " "point out of the surface of the anchor and the center of the aim node. " "Only used if UseAdaptiveStereoscopicDepthInfo is set to true." @@ -331,7 +340,8 @@ OrbitalNavigator::OrbitalNavigator() , _aim(AimInfo) , _retargetAnchor(RetargetAnchorInfo) , _retargetAim(RetargetAimInfo) - , _followAnchorNodeRotationDistance(FollowAnchorNodeInfo, 5.f, 0.f, 20.f) + , _followAnchorNodeRotation(FollowAnchorNodeInfo, true) + , _followAnchorNodeRotationDistance(FollowAnchorNodeDistanceInfo, 5.f, 0.f, 20.f) , _minimumAllowedDistance(MinimumDistanceInfo, 10.0f, 0.0f, 10000.f) , _mouseSensitivity(MouseSensitivityInfo, 15.f, 1.f, 50.f) , _joystickSensitivity(JoystickSensitivityInfo, 10.f, 1.0f, 50.f) @@ -491,6 +501,7 @@ OrbitalNavigator::OrbitalNavigator() addProperty(_aim); addProperty(_retargetAnchor); addProperty(_retargetAim); + addProperty(_followAnchorNodeRotation); addProperty(_followAnchorNodeRotationDistance); addProperty(_minimumAllowedDistance); @@ -954,7 +965,7 @@ void OrbitalNavigator::setRetargetInterpolationTime(float durationInSeconds) { bool OrbitalNavigator::shouldFollowAnchorRotation(const glm::dvec3& cameraPosition) const { - if (!_anchorNode) { + if (!_anchorNode || !_followAnchorNodeRotation) { return false; } diff --git a/src/navigation/path.cpp b/src/navigation/path.cpp index 6f1da4e7c1..b5fcb02891 100644 --- a/src/navigation/path.cpp +++ b/src/navigation/path.cpp @@ -466,7 +466,6 @@ Path createPathFromDictionary(const ghoul::Dictionary& dictionary, Path::Type ty break; } default: { - LERROR(fmt::format("Uknown camera path target type: {}", p.targetType)); throw ghoul::MissingCaseException(); } } diff --git a/src/navigation/pathnavigator.cpp b/src/navigation/pathnavigator.cpp index 9bd101265d..df29a3e169 100644 --- a/src/navigation/pathnavigator.cpp +++ b/src/navigation/pathnavigator.cpp @@ -200,7 +200,7 @@ void PathNavigator::updateCamera(double deltaTime) { if (_currentPath->hasReachedEnd()) { LINFO("Reached end of path"); - _isPlaying = false; + handlePathEnd(); if (_applyIdleBehaviorOnFinish) { constexpr const char* ApplyIdleBehaviorScript = @@ -263,10 +263,16 @@ void PathNavigator::startPath() { return; } - //OBS! Until we can handle simulation time: early out if not paused + // Always pause the simulation time when flying, to aovid problem with objects + // moving. However, keep track of whether the time was running before the path + // was started, so we can reset it on finish if (!global::timeManager->isPaused()) { - LERROR("Simulation time must be paused to run a camera path"); - return; + global::timeManager->setPause(true); + _startSimulationTimeOnFinish = true; + LINFO( + "Pausing time simulation during path traversal. " + "Will unpause once the camera path is finished" + ); } LINFO("Starting path"); @@ -280,9 +286,7 @@ void PathNavigator::abortPath() { LWARNING("No camera path is playing"); return; } - _isPlaying = false; - clearPath(); // TODO: instead of clearing this could be handled better - + handlePathEnd(); LINFO("Aborted camera path"); } @@ -329,6 +333,16 @@ const std::vector& PathNavigator::relevantNodes() { return _relevantNodes; } +void PathNavigator::handlePathEnd() { + _isPlaying = false; + + if (_startSimulationTimeOnFinish) { + global::timeManager->setPause(false); + } + _startSimulationTimeOnFinish = false; + clearPath(); +} + void PathNavigator::findRelevantNodes() { const std::vector& allNodes = global::renderEngine->scene()->allSceneGraphNodes(); @@ -413,8 +427,8 @@ scripting::LuaLibrary PathNavigator::luaLibrary() { "Stops a path, if one is being played" }, { - "goTo", - &luascriptfunctions::goTo, + "flyTo", + &luascriptfunctions::flyTo, "string [, bool, double]", "Move the camera to the node with the specified identifier. The optional " "double specifies the duration of the motion. If the optional bool is " @@ -422,8 +436,8 @@ scripting::LuaLibrary PathNavigator::luaLibrary() { "node. Either of the optional parameters can be left out." }, { - "goToHeight", - &luascriptfunctions::goToHeight, + "flyToHeight", + &luascriptfunctions::flyToHeight, "string, double [, bool, double]", "Move the camera to the node with the specified identifier. The second " "argument is the desired target height above the target node's bounding " @@ -433,8 +447,8 @@ scripting::LuaLibrary PathNavigator::luaLibrary() { "parameters can be left out." }, { - "goToNavigationState", - &luascriptfunctions::goToNavigationState, + "flyToNavigationState", + &luascriptfunctions::flyToNavigationState, "table, [double]", "Create a path to the navigation state described by the input table. " "The optional double specifies the target duration of the motion. Note " @@ -445,7 +459,7 @@ scripting::LuaLibrary PathNavigator::luaLibrary() { "createPath", &luascriptfunctions::createPath, "table", - "Create the path as described by the lua table input argument" + "Create a camera path as described by the lua table input argument" }, } }; diff --git a/src/navigation/pathnavigator_lua.inl b/src/navigation/pathnavigator_lua.inl index f921fb0182..de306c1d4c 100644 --- a/src/navigation/pathnavigator_lua.inl +++ b/src/navigation/pathnavigator_lua.inl @@ -68,8 +68,8 @@ int stopPath(lua_State* L) { return 0; } -int goTo(lua_State* L) { - ghoul::lua::checkArgumentsAndThrow(L, { 1, 3 }, "lua::goTo"); +int flyTo(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, { 1, 3 }, "lua::flyTo"); auto [nodeIdentifier, useUpFromTargetOrDuration, duration] = ghoul::lua::values< std::string, std::optional>, std::optional >(L); @@ -120,8 +120,8 @@ int goTo(lua_State* L) { return 0; } -int goToHeight(lua_State* L) { - ghoul::lua::checkArgumentsAndThrow(L, { 2, 4 }, "lua::goToHeight"); +int flyToHeight(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, { 2, 4 }, "lua::flyToHeight"); auto [nodeIdentifier, height, useUpFromTargetOrDuration, duration] = ghoul::lua::values< std::string, double, std::optional>, @@ -169,8 +169,8 @@ int goToHeight(lua_State* L) { return 0; } -int goToNavigationState(lua_State* L) { - ghoul::lua::checkArgumentsAndThrow(L, { 1, 2 }, "lua::goToNavigationState"); +int flyToNavigationState(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, { 1, 2 }, "lua::flyToNavigationState"); auto [navigationState, duration] = ghoul::lua::values>(L); @@ -182,7 +182,7 @@ int goToNavigationState(lua_State* L) { ); } catch (documentation::SpecificationError& e) { - LERRORC("goToNavigationState", ghoul::to_string(e.result)); + LERRORC("flyToNavigationState", ghoul::to_string(e.result)); return ghoul::lua::luaError( L, fmt::format("Unable to create a path: {}", e.what()) ); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index b1314aece8..7b7079ee8f 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -130,6 +130,14 @@ namespace { "shown on the screen" }; + constexpr openspace::properties::Property::PropertyInfo ScreenshotWindowIdsInfo = { + "ScreenshotWindowId", + "Screenshow Window Ids", + "The list of window identifiers whose screenshot will be taken the next time " + "anyone triggers a screenshot. If this list is empty (the default), all windows " + "will have their screenshot taken. Id's that do not exist are silently ignored." + }; + constexpr openspace::properties::Property::PropertyInfo ApplyWarpingInfo = { "ApplyWarpingScreenshot", "Apply Warping to Screenshots", @@ -277,6 +285,7 @@ RenderEngine::RenderEngine() , _verticalLogOffset(VerticalLogOffsetInfo, 0.f, 0.f, 1.f) , _showVersionInfo(ShowVersionInfo, true) , _showCameraInfo(ShowCameraInfo, true) + , _screenshotWindowIds(ScreenshotWindowIdsInfo) , _applyWarping(ApplyWarpingInfo, false) , _screenshotUseDate(ScreenshotUseDateInfo, false) , _showFrameInformation(ShowFrameNumberInfo, false) @@ -342,6 +351,7 @@ RenderEngine::RenderEngine() addProperty(_value); addProperty(_globalBlackOutFactor); + addProperty(_screenshotWindowIds); addProperty(_applyWarping); _screenshotUseDate.onChange([this]() { @@ -1046,7 +1056,10 @@ void RenderEngine::takeScreenshot() { std::filesystem::create_directories(absPath("${SCREENSHOTS}")); } - _latestScreenshotNumber = global::windowDelegate->takeScreenshot(_applyWarping); + _latestScreenshotNumber = global::windowDelegate->takeScreenshot( + _applyWarping, + _screenshotWindowIds + ); } unsigned int RenderEngine::latestScreenshotNumber() const { diff --git a/support/coding/codegen b/support/coding/codegen index 4bb5b66dae..425a0a224e 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit 4bb5b66daeb20577e7276aa2465cda4ebf14d8a5 +Subproject commit 425a0a224e28802f0f2d88c0b2034ee5a473cc3b diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 38f2dfb785..076411a2c5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,7 +40,6 @@ add_executable( test_rawvolumeio.cpp test_scriptscheduler.cpp test_spicemanager.cpp - test_temporaltileprovider.cpp test_timequantizer.cpp test_timeline.cpp From 3e2b035893b9368142ede142df297c3d292c72c3 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Tue, 25 Jan 2022 16:06:16 -0700 Subject: [PATCH 48/93] Fixing window offset with multiple monitors --- .../ext/launcher/src/sgctedit/filesupport.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index ae79490424..2672616c68 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -87,31 +87,32 @@ void FileSupport::saveWindows() { unsigned int windowIndex = 0; for (unsigned int w = 0; w < _displayWidget->nWindows(); ++w) { + WindowControl* wCtrl = _displayWidget->windowControls()[w]; _windowList.push_back(sgct::config::Window()); _windowList.back().viewports.push_back(sgct::config::Viewport()); _windowList.back().viewports.back().isTracked = true; _windowList.back().viewports.back().position = {0.0, 0.0}; _windowList.back().viewports.back().size = {1.0, 1.0}; int projectionIdx - = _displayWidget->windowControls()[w]->projectionSelectedIndex(); + = wCtrl->projectionSelectedIndex(); bool isSpoutSelected - = _displayWidget->windowControls()[w]->isSpoutSelected(); + = wCtrl->isSpoutSelected(); saveProjectionInformation( isSpoutSelected, projectionIdx, - _displayWidget->windowControls()[w], + wCtrl, _windowList.back().viewports.back() ); - _windowList.back().size - = _displayWidget->windowControls()[w]->windowSize(); - _windowList.back().pos - = _displayWidget->windowControls()[w]->windowPos(); - _windowList.back().isDecorated - = _displayWidget->windowControls()[w]->isDecorated(); + _windowList.back().size = wCtrl->windowSize(); + _windowList.back().pos = { + _monitors[wCtrl->monitorNum()].x() + wCtrl->windowPos().x, + _monitors[wCtrl->monitorNum()].y() + wCtrl->windowPos().y, + }; + _windowList.back().isDecorated = wCtrl->isDecorated(); bool isFullScreen = isWindowFullscreen( - _displayWidget->windowControls()[w]->monitorNum(), - _displayWidget->windowControls()[w]->windowSize() + wCtrl->monitorNum(), + wCtrl->windowSize() ); if (isFullScreen) { _windowList.back().isFullScreen = true; @@ -133,9 +134,8 @@ void FileSupport::saveWindows() { _windowList.back().draw3D = true; _windowList.back().viewports.back().isTracked = true; } - if (!_displayWidget->windowControls()[w]->windowName().empty()) { - _windowList.back().name - = _displayWidget->windowControls()[w]->windowName(); + if (!wCtrl->windowName().empty()) { + _windowList.back().name = wCtrl->windowName(); } _windowList.back().id = windowIndex++; } From 025b61f7afd8d0571e47ff7dab72e706aac6bc53 Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 26 Jan 2022 19:11:14 -0700 Subject: [PATCH 49/93] More fixes for full json output functionality --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 1 + .../launcher/include/sgctedit/orientationdialog.h | 3 ++- .../ext/launcher/src/sgctedit/filesupport.cpp | 12 ++++++++---- .../ext/launcher/src/sgctedit/orientationdialog.cpp | 10 +++++++--- .../ext/launcher/src/sgctedit/windowcontrol.cpp | 3 +-- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index 278f320f0a..9ecdc9b5e4 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -136,6 +136,7 @@ target_include_directories( PUBLIC include ${OPENSPACE_APPS_DIR}/OpenSpace/ext/sgct/include + ${OPENSPACE_APPS_DIR}/OpenSpace/ext/sgct/sgct/ext/glm ) target_link_libraries( openspace-ui-launcher diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h index b7c2bcbb6f..d7b4e1b1e3 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h @@ -15,8 +15,9 @@ #include #include -#include +#include #include +#include #include diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 2672616c68..aa573308a5 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -168,6 +168,8 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection { sgct::config::FisheyeProjection projection; projection.quality = winControl->qualitySelectedValue(); + projection.fov = 180.0; + projection.tilt = 0.0; viewport.projection = std::move(projection); } break; @@ -200,11 +202,13 @@ void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projection case WindowControl::ProjectionIndeces::Planar: default: { + // The negative values for left & down are according to sgct's + // convection for importing sgct::config::PlanarProjection projection; - projection.fov.left = winControl->fovH() / 2.0; - projection.fov.right = projection.fov.left; - projection.fov.down = winControl->fovV() / 2.0; - projection.fov.up = projection.fov.down; + projection.fov.right = winControl->fovH() / 2.0; + projection.fov.left = -projection.fov.right; + projection.fov.up = winControl->fovV() / 2.0; + projection.fov.down = -projection.fov.up; viewport.projection = std::move(projection); } break; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index e0ceb61366..1c5642d091 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -70,9 +70,13 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) } void OrientationDialog::ok() { - _orientationValue.x = QString(_linePitch->text()).toFloat(); - _orientationValue.y = QString(_lineYaw->text()).toFloat(); - _orientationValue.z = QString(_lineRoll->text()).toFloat(); + _orientationValue.x = QString(_linePitch->text()).toFloat() / 180.0 + * glm::pi(); + _orientationValue.y = QString(_lineYaw->text()).toFloat() / 180.0 + * glm::pi(); + _orientationValue.z = QString(_lineRoll->text()).toFloat() / 180.0 + * glm::pi(); + _orientationValue.w = 1.0; accept(); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index a29075bb0c..cad60cb8cd 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -68,7 +68,6 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, SLOT(onOffsetXChanged(const QString&))); connect(_offset_y, SIGNAL(textChanged(const QString&)), this, SLOT(onOffsetYChanged(const QString&))); - connect(_comboMonitorSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(onMonitorChanged(int))); connect(_comboProjection, SIGNAL(currentIndexChanged(int)), @@ -77,7 +76,6 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, this, SLOT(onSpoutSelection(int))); connect(_checkBoxWebGui, SIGNAL(stateChanged(int)), this, SLOT(onWebGuiSelection(int))); - connect(_fullscreenButton, SIGNAL(released()), this, SLOT(onFullscreenClicked())); } @@ -295,6 +293,7 @@ void WindowControl::onFullscreenClicked() { _offset_y->setText("0"); _size_x->setText(QString::number(_monitorResolutions[_monIndex].width())); _size_y->setText(QString::number(_monitorResolutions[_monIndex].height())); + _checkBoxWindowDecor->setCheckState(Qt::Unchecked); } void WindowControl::enableGuiWindowSelection(bool enabled) { From e19a9c69a31c4999b3244abcbcb696bc8771305e Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Thu, 27 Jan 2022 16:18:35 -0700 Subject: [PATCH 50/93] Removed redundant callback, fixed some warnings --- .../OpenSpace/ext/launcher/include/launcherwindow.h | 2 +- .../ext/launcher/include/sgctedit/display.h | 4 +--- .../ext/launcher/include/sgctedit/windowcontrol.h | 2 +- .../OpenSpace/ext/launcher/src/sgctedit/display.cpp | 4 +--- .../ext/launcher/src/sgctedit/sgctedit.cpp | 13 ++++--------- .../ext/launcher/src/sgctedit/windowcontrol.cpp | 4 ++-- 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/launcherwindow.h b/apps/OpenSpace/ext/launcher/include/launcherwindow.h index 83ac6854f5..caa6d107f0 100644 --- a/apps/OpenSpace/ext/launcher/include/launcherwindow.h +++ b/apps/OpenSpace/ext/launcher/include/launcherwindow.h @@ -89,6 +89,7 @@ private: void populateProfilesList(std::string preset); void populateWindowConfigsList(std::string preset); + QApplication& _qApp; const std::string _assetPath; const std::string _userAssetPath; const std::string _configPath; @@ -101,7 +102,6 @@ private: int _userConfigCount = 0; const std::string _sgctConfigName; - QApplication& _qApp; QComboBox* _profileBox = nullptr; QComboBox* _windowConfigBox = nullptr; QLabel* _backgroundImage = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 91ec541803..40bf35a55c 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -27,8 +27,7 @@ class Display : public QWidget Q_OBJECT public: explicit Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, - std::function webGuiCallback, unsigned int nMaxWindows, - QString* winColors); + unsigned int nMaxWindows, QString* winColors); ~Display(); std::vector windowControls(); unsigned int nWindows(); @@ -45,7 +44,6 @@ private: void initializeLayout(); void showWindows(); void addDisplayLayout(unsigned int column, MonitorBox* monBox, QVBoxLayout* layout); - std::function _webGuiCheckCallback; std::vector& _monitorResolutions; QRect _widgetDims = {0, 0, 400, 400}; QString* _winColors; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index f95f18e06b..d941c637a9 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -122,6 +122,7 @@ private: unsigned int _nMonitors = 1; unsigned int _monIndex = 0; unsigned int _index = 0; + std::vector& _monitorResolutions; int _maxWindowSizePixels = 10000; QString* _colorsForWindows = nullptr; @@ -141,7 +142,6 @@ private: QIntValidator* _validatorOffset_x = nullptr; QIntValidator* _validatorOffset_y = nullptr; - std::vector& _monitorResolutions; QRectF _windowDims; QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index ec3954299a..9665846c23 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -9,11 +9,9 @@ Display::Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, - std::function webGuiCallback, unsigned int nMaxWindows, - QString* winColors) + unsigned int nMaxWindows, QString* winColors) : _monBox(monitorRenderBox) , _monitorResolutions(monitorSizeList) - , _webGuiCheckCallback(webGuiCallback) , _nMaxWindows(nMaxWindows) , _winColors(winColors) { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 0e1c418b65..15b54866fc 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -8,9 +8,9 @@ namespace { SgctEdit::SgctEdit(QWidget* parent, std::vector& windowList, sgct::config::Cluster& cluster, QApplication& qtApp) - : _cluster(cluster) + : QDialog(parent) + , _cluster(cluster) , _windowList(windowList) - , QDialog(parent) { setWindowTitle("Display/Window Editor"); systemMonitorConfiguration(qtApp); @@ -23,8 +23,8 @@ void SgctEdit::systemMonitorConfiguration(QApplication& qtApp) { std::cerr << "Error: Qt reports no screens available." << std::endl; return; } - - for (size_t s = 0; s < std::min(screenList.length(), 2); ++s) { + size_t nScreensManaged = std::min(screenList.length(), 2); + for (size_t s = 0; s < nScreensManaged; ++s) { int actualWidth = std::max(screenList[s]->size().width(), screenList[s]->availableGeometry().width()); int actualHeight = std::max(screenList[s]->size().height(), @@ -92,11 +92,6 @@ void SgctEdit::addDisplayLayout(MonitorBox* monBox, QHBoxLayout* layout) _displayWidget = new Display( monBox, _monitorSizeList, - [this](unsigned int monIndex) { - if (_monitorSizeList.size() > 1) { - _displayWidget->uncheckWebGuiOptions(); - } - }, _nMaxWindows, _colorsForWindows ); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index cad60cb8cd..d227769900 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -5,12 +5,12 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, unsigned int windowIndex, QRect& widgetDims, std::vector& monitorDims, QString* winColors, QWidget *parent) - : _nMonitors(nMonitors) + : QWidget(parent) + , _nMonitors(nMonitors) , _monIndex(monitorIndex) , _index(windowIndex) , _monitorResolutions(monitorDims) , _colorsForWindows(winColors) - , QWidget(parent) { _windowDims = defaultWindowSizes[windowIndex]; _size_x = new QLineEdit( From 051f4388e7aa56a5656823e17fca56e9b69830f7 Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 28 Jan 2022 19:31:40 -0700 Subject: [PATCH 51/93] Code refactoring and cleanup --- .../ext/launcher/include/sgctedit/display.h | 40 ++- .../launcher/include/sgctedit/filesupport.h | 57 +++- .../launcher/include/sgctedit/monitorbox.h | 58 ++-- .../launcher/include/sgctedit/orientation.h | 33 ++- .../include/sgctedit/orientationdialog.h | 31 +- .../ext/launcher/include/sgctedit/sgctedit.h | 35 ++- .../launcher/include/sgctedit/windowcontrol.h | 40 ++- .../ext/launcher/src/launcherwindow.cpp | 10 +- .../ext/launcher/src/sgctedit/display.cpp | 60 ++-- .../ext/launcher/src/sgctedit/filesupport.cpp | 269 ++++++++++-------- .../ext/launcher/src/sgctedit/monitorbox.cpp | 59 ++-- .../ext/launcher/src/sgctedit/orientation.cpp | 24 ++ .../src/sgctedit/orientationdialog.cpp | 62 ++-- .../ext/launcher/src/sgctedit/sgctedit.cpp | 66 +++-- .../launcher/src/sgctedit/windowcontrol.cpp | 117 +++----- 15 files changed, 612 insertions(+), 349 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 40bf35a55c..753acb77df 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -1,5 +1,29 @@ -#ifndef DISPLAY_H -#define DISPLAY_H +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ +#define __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ #include #include @@ -27,10 +51,10 @@ class Display : public QWidget Q_OBJECT public: explicit Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, - unsigned int nMaxWindows, QString* winColors); + const unsigned int nMaxWindows, const QString* winColors); ~Display(); std::vector windowControls(); - unsigned int nWindows(); + unsigned int nWindows() const; void uncheckWebGuiOptions(); void setindowChangeCallback(std::function cb); @@ -44,18 +68,18 @@ private: void initializeLayout(); void showWindows(); void addDisplayLayout(unsigned int column, MonitorBox* monBox, QVBoxLayout* layout); + MonitorBox* _monBox; std::vector& _monitorResolutions; QRect _widgetDims = {0, 0, 400, 400}; - QString* _winColors; - std::vector _windowControl; unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; unsigned int _nMaxWindows = 3; unsigned int _nMonitors = 1; + const QString* _winColors; + std::vector _windowControl; QPushButton* _addWindowButton = nullptr; QPushButton* _removeWindowButton = nullptr; unsigned int _monitorIdx = 0; - MonitorBox* _monBox; QVBoxLayout* _layout = nullptr; QHBoxLayout* _layoutMonBox = nullptr; QHBoxLayout* _layoutMonButton = nullptr; @@ -66,4 +90,4 @@ private: QFrame* _borderFrame = nullptr; }; -#endif // DISPLAY_H +#endif // __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index d04ed85e3e..48e709db49 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -1,5 +1,29 @@ -#ifndef FILE_SUPPORT_H -#define FILE_SUPPORT_H +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_UI_LAUNCHER___FILESUPPORT___H__ +#define __OPENSPACE_UI_LAUNCHER___FILESUPPORT___H__ #include #include @@ -17,21 +41,13 @@ class FileSupport : public QWidget { - Q_OBJECT - +Q_OBJECT public: explicit FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, Display* display, Orientation* orientation, std::vector& windowList, sgct::config::Cluster& cluster, std::function cb); ~FileSupport(); - bool isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims); - int findGuiWindow(); - void saveCluster(); - void saveWindows(); - void saveUser(); - void saveProjectionInformation(bool isSpoutSelected, int projectionIndex, - WindowControl* winControl, sgct::config::Viewport& viewport); std::string saveFilename(); private slots: @@ -40,11 +56,26 @@ private slots: void save(); private: + bool isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims); + bool findGuiWindow(unsigned int& foundWindowIndex); + void saveCluster(); + void saveWindows(); + void saveUser(); + void saveProjectionInformation(bool isSpoutSelected, int projectionIndex, + WindowControl* winControl, sgct::config::Viewport& viewport); + void saveProjection_Spout(int projectionIndex, WindowControl* winControl, + sgct::config::Viewport& viewport); + void saveProjection_NonSpout(int projectionIndex, WindowControl* winControl, + sgct::config::Viewport& viewport); + void saveWindowsViewports(); + void saveWindowsDimensions(WindowControl* wCtrl); + void saveWindowsWebGui(unsigned int wIdx); + void saveWindowsFullScreen(WindowControl* wCtrl); QHBoxLayout* _layoutButtonBox = nullptr; QPushButton* _saveButton = nullptr; QPushButton* _cancelButton = nullptr; - Orientation* _orientationWidget; Display* _displayWidget; + Orientation* _orientationWidget; std::vector& _monitors; sgct::config::Cluster& _cluster; std::vector& _windowList; @@ -52,4 +83,4 @@ private: std::function _finishedCallback; }; -#endif // FILE_SUPPORT_H +#endif // __OPENSPACE_UI_LAUNCHER___FILESUPPORT___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index fa8cfa3191..ebcdddfd3a 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -1,5 +1,29 @@ -#ifndef MONITORBOX_H -#define MONITORBOX_H +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_UI_LAUNCHER___MONITORBOX___H__ +#define __OPENSPACE_UI_LAUNCHER___MONITORBOX___H__ #include #include @@ -35,20 +59,21 @@ protected: void paintEvent(QPaintEvent *event) override; private: - void paintWidgetBorder(QPainter& painter, int width, int height); + void paintWidgetBorder(QPainter& painter, const int width, const int height); void paintMonitorBackgrounds(QPainter& painter); - void paintWindow(QPainter& painter, unsigned int winIdx); - void paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx); - void paintWindowNumber(QPainter& painter, unsigned int winIdx); - void setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, + void paintWindow(QPainter& painter, const unsigned int winIdx); + void paintWindowBeyondBounds(QPainter& painter, const unsigned int winIdx); + void paintWindowNumber(QPainter& painter, const unsigned int winIdx); + void setPenSpecificToWindow(QPainter& painter, const unsigned int windowIdx, bool visibleBorder); - void computeScaledResolution_landscape(float aspectRatio, float maxWidth); - void computeScaledResolution_portrait(float aspectRatio, float maxHeight); + void computeScaledResolution_landscape(const float aspectRatio, const float maxWidth); + void computeScaledResolution_portrait(const float aspectRatio, const float maxHeight); unsigned int _maxNumMonitors = 2; + QRectF _monitorWidgetSize; + QRectF _monitorBoundaryRect; + unsigned int _nMonitors = 1; std::vector _monitorResolution; - //std::vector _monitorRendering; std::vector _monitorDimensionsScaled; - std::vector _windowResolutions; std::vector _windowRendering = { {0.0, 0.0, 0.0, 0.0}, @@ -56,22 +81,15 @@ private: {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0} }; + unsigned int _nWindows = 1; QString* _colorsForWindows; int _alphaWindowOpacity = 170; float _monitorScaleFactor = 1.0; float _offset[2] = {10.0, 10.0}; bool _showLabel = false; - float _marginFractionOfWidgetSize = 0.025; float _marginWidget = 5.0; std::vector _monitorOffsets; - - QRectF _monitorWidgetSize; - QRectF _monitorBoundaryRect; - - - unsigned int _nMonitors = 1; - unsigned int _nWindows = 1; }; -#endif // MONITORBOX_H +#endif // __OPENSPACE_UI_LAUNCHER___MONITORBOX___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index 107135f02b..aaa59c3a08 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -1,5 +1,29 @@ -#ifndef ORIENTATION_H -#define ORIENTATION_H +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_UI_LAUNCHER___ORIENTATION___H__ +#define __OPENSPACE_UI_LAUNCHER___ORIENTATION___H__ #include #include @@ -23,8 +47,7 @@ class Orientation : public QWidget { - Q_OBJECT - +Q_OBJECT public: explicit Orientation(); ~Orientation(); @@ -44,4 +67,4 @@ private: QCheckBox* _checkBoxVsync = nullptr; }; -#endif // ORIENTATION_H +#endif // __OPENSPACE_UI_LAUNCHER___ORIENTATION___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h index d7b4e1b1e3..58a9fe85aa 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h @@ -1,5 +1,29 @@ -#ifndef ORIENTATION_DIALOG_H -#define ORIENTATION_DIALOG_H +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_UI_LAUNCHER___ORIENTATIONDIALOG___H__ +#define __OPENSPACE_UI_LAUNCHER___ORIENTATIONDIALOG___H__ #include #include @@ -24,7 +48,6 @@ class OrientationDialog : public QDialog { Q_OBJECT - public: explicit OrientationDialog(sgct::quat& orientation, QWidget* parent); ~OrientationDialog(); @@ -56,4 +79,4 @@ private: QPushButton* _buttonCancel = nullptr; }; -#endif // ORIENTATION_DIALOG_H +#endif // __OPENSPACE_UI_LAUNCHER___ORIENTATIONDIALOG___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index 69ff043624..5a6f11483c 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -1,3 +1,27 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + #ifndef __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ #define __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ @@ -13,23 +37,20 @@ #include #include #include -#include - -#include #include - +#include +#include #include #include #include #include - class SgctEdit final : public QDialog { Q_OBJECT public: SgctEdit(QWidget* parent, std::vector& windowList, - sgct::config::Cluster& cluster, QApplication& qtApp); + sgct::config::Cluster& cluster, const QList screenList); ~SgctEdit(); void addDisplayLayout(MonitorBox* monBox, QHBoxLayout* layout); void createWidgets(); @@ -37,7 +58,7 @@ public: std::string saveFilename(); private: - void systemMonitorConfiguration(QApplication& qtApp); + void systemMonitorConfiguration(const QList screenList); MonitorBox* _monBox = nullptr; std::vector _monitorSizeList; QVBoxLayout* _displayLayout = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index d941c637a9..258ea4bc4c 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -1,5 +1,29 @@ -#ifndef WINDOWCONTROL_H -#define WINDOWCONTROL_H +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_UI_LAUNCHER___WINDOWCONTROL___H__ +#define __OPENSPACE_UI_LAUNCHER___WINDOWCONTROL___H__ #include #include @@ -27,15 +51,15 @@ class WindowControl : public QWidget Q_OBJECT public: explicit WindowControl(unsigned int nMonitors, unsigned int monitorIndex, - unsigned int windowIndex, QRect& widgetDims, std::vector& monitorDims, - QString* winColors, QWidget *parent = nullptr); + unsigned int windowIndex, std::vector& monitorDims, + const QString* winColors, QWidget *parent = nullptr); ~WindowControl(); void setDimensions(const QRectF& dimensions); void setWindowChangeCallback(std::function cb); void setWebGuiChangeCallback(std::function cb); - void showWindowLabel(bool show); + void showWindowLabel(const bool show); void cleanupLayouts(); - QVBoxLayout* initializeLayout(QWidget* parentWidget); + QVBoxLayout* initializeLayout(); QRectF& dimensions(); QLineEdit* lineEditSizeWidth(); QLineEdit* lineEditSizeHeight(); @@ -124,7 +148,7 @@ private: unsigned int _index = 0; std::vector& _monitorResolutions; int _maxWindowSizePixels = 10000; - QString* _colorsForWindows = nullptr; + const QString* _colorsForWindows = nullptr; QVBoxLayout* _layoutWindowCtrl = nullptr; QVBoxLayout* _layoutFullWindow = nullptr; @@ -188,4 +212,4 @@ private: QHBoxLayout* _layoutHeightOffset = nullptr; }; -#endif // WINDOWCONTROL_H +#endif // __OPENSPACE_UI_LAUNCHER___WINDOWCONTROL___H__ diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 2746fa9e4a..9d85f4d72c 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -519,9 +519,17 @@ void LauncherWindow::openProfileEditor(const std::string& profile, const bool is } void LauncherWindow::openWindowEditor() { + QList screenList = _qApp.screens(); + if (screenList.length() == 0) { + LERRORC( + "LauncherWindow", + "Error: Qt reports no screens/monitors available" + ); + return; + } sgct::config::Cluster cluster; std::vector windowList; - SgctEdit editor(this, windowList, cluster, _qApp); + SgctEdit editor(this, windowList, cluster, screenList); editor.exec(); if (editor.wasSaved()) { std::string fullFilename = editor.saveFilename() + ".json"; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 9665846c23..c6651e8a80 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -1,35 +1,52 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 - #include "sgctedit/monitorbox.h" #include "sgctedit/windowcontrol.h" #include "sgctedit/display.h" - Display::Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, - unsigned int nMaxWindows, QString* winColors) + const unsigned int nMaxWindows, const QString* winColors) : _monBox(monitorRenderBox) , _monitorResolutions(monitorSizeList) , _nMaxWindows(nMaxWindows) , _winColors(winColors) { - _addWindowButton = new QPushButton("Add Window >", this); - _removeWindowButton = new QPushButton("< Remove Window", this); - + _addWindowButton = new QPushButton("Add Window", this); + _removeWindowButton = new QPushButton("Remove Window", this); _nMonitors = _monitorResolutions.size(); - //Add all window controls (some will be hidden from GUI initially) for (unsigned int i = 0; i < _nMaxWindows; ++i) { initializeWindowControl(); } + connect(_addWindowButton, SIGNAL(released()), this, SLOT(addWindow())); + connect(_removeWindowButton, SIGNAL(released()), this, SLOT(removeWindow())); initializeLayout(); - - connect(_addWindowButton, SIGNAL(released()), this, - SLOT(addWindow())); - connect(_removeWindowButton, SIGNAL(released()), this, - SLOT(removeWindow())); } Display::~Display() { @@ -54,16 +71,15 @@ Display::~Display() { void Display::initializeLayout() { _layout = new QVBoxLayout(this); _layoutMonButton = new QHBoxLayout(); - _layoutMonButton->addStretch(1); _layoutMonButton->addWidget(_removeWindowButton); - _layoutMonButton->addWidget(_addWindowButton); _layoutMonButton->addStretch(1); + _layoutMonButton->addWidget(_addWindowButton); _layout->addLayout(_layoutMonButton); _layoutWindows = new QHBoxLayout(); _layout->addStretch(); for (unsigned int i = 0; i < _nMaxWindows; ++i) { - _winCtrlLayouts.push_back(_windowControl[i]->initializeLayout(this)); + _winCtrlLayouts.push_back(_windowControl[i]->initializeLayout()); _layoutWindowWrappers.push_back(new QWidget()); _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); _layoutWindows->addWidget(_layoutWindowWrappers.back()); @@ -82,7 +98,7 @@ std::vector Display::windowControls() { return _windowControl; } -unsigned int Display::nWindows() { +unsigned int Display::nWindows() const { return _nWindowsDisplayed; } @@ -105,17 +121,10 @@ void Display::showWindows() { _layoutWindowWrappers[i]->setVisible(i < _nWindowsDisplayed); } for (unsigned int i = 0; i < _frameBorderLines.size(); ++i) { - if (i < (_nWindowsDisplayed - 1)) { - _frameBorderLines[i]->setVisible(true); - } - else { - _frameBorderLines[i]->setVisible(false); - } + _frameBorderLines[i]->setVisible(i < (_nWindowsDisplayed - 1)); } _removeWindowButton->setEnabled(_nWindowsDisplayed > 1); - _removeWindowButton->setVisible(_nWindowsDisplayed > 1); _addWindowButton->setEnabled(_nWindowsDisplayed != _nMaxWindows); - _addWindowButton->setVisible(_nWindowsDisplayed != _nMaxWindows); for (auto w : _windowControl) { w->showWindowLabel(_nWindowsDisplayed > 1); } @@ -130,7 +139,6 @@ void Display::initializeWindowControl() { _nMonitors, monitorNumForThisWindow, _nWindowsAllocated, - _widgetDims, _monitorResolutions, _winColors, this @@ -160,7 +168,7 @@ void Display::initializeWindowControl() { } void Display::uncheckWebGuiOptions() { - for (auto w : _windowControl) { + for (WindowControl* w : _windowControl) { w->uncheckWebGuiOption(); } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index aa573308a5..52ad58345c 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -1,12 +1,36 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 "sgctedit/filesupport.h" FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, Display* display, Orientation* orientation, std::vector& windowList, sgct::config::Cluster& cluster, std::function cb) - : _monitors(monitorList) - , _displayWidget(display) + : _displayWidget(display) , _orientationWidget(orientation) + , _monitors(monitorList) , _cluster(cluster) , _windowList(windowList) , _finishedCallback(cb) @@ -21,13 +45,11 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL layoutFilename->addWidget(labelFilename); layoutFilename->addWidget(_lineFilename); layoutFilename->addStretch(1); - _layoutButtonBox = new QHBoxLayout; _saveButton = new QPushButton("Save"); _saveButton->setToolTip("Save global orientation changes"); _layoutButtonBox->addStretch(1); _layoutButtonBox->addWidget(_saveButton); - _cancelButton = new QPushButton("Cancel"); _cancelButton->setToolTip("Cancel global orientation changes"); _layoutButtonBox->addWidget(_cancelButton); @@ -70,70 +92,34 @@ bool FileSupport::isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims) return ((mDims.x == wDims.x) && (mDims.y == wDims.y)); } -int FileSupport::findGuiWindow() { +bool FileSupport::findGuiWindow(unsigned int& foundWindowIndex) { unsigned int windowIndex = 0; for (unsigned int w = 0; w < _displayWidget->nWindows(); ++w) { if (_displayWidget->windowControls()[w]->isGuiWindow()) { - return windowIndex; + foundWindowIndex = windowIndex; + return true; } windowIndex++; } - return -1; + return false; } void FileSupport::saveWindows() { - int webGuiWindowIndex = findGuiWindow(); - bool isOneOfWindowsSetAsWebGui = (webGuiWindowIndex >= 0); - unsigned int windowIndex = 0; for (unsigned int w = 0; w < _displayWidget->nWindows(); ++w) { WindowControl* wCtrl = _displayWidget->windowControls()[w]; _windowList.push_back(sgct::config::Window()); - _windowList.back().viewports.push_back(sgct::config::Viewport()); - _windowList.back().viewports.back().isTracked = true; - _windowList.back().viewports.back().position = {0.0, 0.0}; - _windowList.back().viewports.back().size = {1.0, 1.0}; - int projectionIdx - = wCtrl->projectionSelectedIndex(); - bool isSpoutSelected - = wCtrl->isSpoutSelected(); - + saveWindowsViewports(); saveProjectionInformation( - isSpoutSelected, - projectionIdx, + wCtrl->isSpoutSelected(), + wCtrl->projectionSelectedIndex(), wCtrl, _windowList.back().viewports.back() ); - _windowList.back().size = wCtrl->windowSize(); - _windowList.back().pos = { - _monitors[wCtrl->monitorNum()].x() + wCtrl->windowPos().x, - _monitors[wCtrl->monitorNum()].y() + wCtrl->windowPos().y, - }; + saveWindowsDimensions(wCtrl); _windowList.back().isDecorated = wCtrl->isDecorated(); - bool isFullScreen = isWindowFullscreen( - wCtrl->monitorNum(), - wCtrl->windowSize() - ); - if (isFullScreen) { - _windowList.back().isFullScreen = true; - } - if (isOneOfWindowsSetAsWebGui) { - if (windowIndex == webGuiWindowIndex) { - _windowList.back().draw2D = true; - _windowList.back().draw3D = false; - _windowList.back().viewports.back().isTracked = false; - _windowList.back().tags.push_back("GUI"); - } - else { - _windowList.back().draw2D = false; - _windowList.back().draw3D = true; - } - } - else { - _windowList.back().draw2D = true; - _windowList.back().draw3D = true; - _windowList.back().viewports.back().isTracked = true; - } + saveWindowsFullScreen(wCtrl); + saveWindowsWebGui(windowIndex); if (!wCtrl->windowName().empty()) { _windowList.back().name = wCtrl->windowName(); } @@ -141,88 +127,135 @@ void FileSupport::saveWindows() { } } +void FileSupport::saveWindowsViewports() { + _windowList.back().viewports.push_back(sgct::config::Viewport()); + _windowList.back().viewports.back().isTracked = true; + _windowList.back().viewports.back().position = {0.0, 0.0}; + _windowList.back().viewports.back().size = {1.0, 1.0}; +} + +void FileSupport::saveWindowsDimensions(WindowControl* wCtrl) { + _windowList.back().size = wCtrl->windowSize(); + _windowList.back().pos = { + _monitors[wCtrl->monitorNum()].x() + wCtrl->windowPos().x, + _monitors[wCtrl->monitorNum()].y() + wCtrl->windowPos().y, + }; +} + +void FileSupport::saveWindowsWebGui(unsigned int wIdx) { + _windowList.back().draw2D = true; + _windowList.back().draw3D = true; + _windowList.back().viewports.back().isTracked = true; + unsigned int webGuiWindowIndex; + bool isOneOfWindowsSetAsWebGui = findGuiWindow(webGuiWindowIndex); + if (isOneOfWindowsSetAsWebGui) { + if (wIdx == webGuiWindowIndex) { + _windowList.back().viewports.back().isTracked = false; + _windowList.back().tags.push_back("GUI"); + } + _windowList.back().draw2D = (wIdx == webGuiWindowIndex); + _windowList.back().draw3D = !_windowList.back().draw2D; + } +} + +void FileSupport::saveWindowsFullScreen(WindowControl* wCtrl) { + bool isFullScreen = isWindowFullscreen( + wCtrl->monitorNum(), + wCtrl->windowSize() + ); + if (isFullScreen) { + _windowList.back().isFullScreen = true; + } +} + void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projectionIndex, WindowControl* winControl, sgct::config::Viewport& viewport) { if (isSpoutSelected) { - sgct::config::SpoutOutputProjection projection; - switch(projectionIndex) { - case WindowControl::ProjectionIndeces::Fisheye: - projection.mapping - = sgct::config::SpoutOutputProjection::Mapping::Fisheye; - break; - - case WindowControl::ProjectionIndeces::Equirectangular: - default: - projection.mapping - = sgct::config::SpoutOutputProjection::Mapping::Equirectangular; - break; - } - projection.quality = winControl->qualitySelectedValue(); - projection.mappingSpoutName = "OpenSpace"; - viewport.projection = std::move(projection); + saveProjection_Spout(projectionIndex, winControl, viewport); } else { - switch(projectionIndex) { - case WindowControl::ProjectionIndeces::Fisheye: - { - sgct::config::FisheyeProjection projection; - projection.quality = winControl->qualitySelectedValue(); - projection.fov = 180.0; - projection.tilt = 0.0; - viewport.projection = std::move(projection); - } - break; + saveProjection_NonSpout(projectionIndex, winControl, viewport); + } +} - case WindowControl::ProjectionIndeces::Spherical_Mirror: - { - sgct::config::SphericalMirrorProjection projection; - projection.quality = winControl->qualitySelectedValue(); - viewport.projection = std::move(projection); - } - break; +void FileSupport::saveProjection_Spout(int projectionIndex, WindowControl* winControl, + sgct::config::Viewport& viewport) +{ + sgct::config::SpoutOutputProjection projection; + switch(projectionIndex) { + case WindowControl::ProjectionIndeces::Fisheye: + projection.mapping + = sgct::config::SpoutOutputProjection::Mapping::Fisheye; + break; - case WindowControl::ProjectionIndeces::Cylindrical: - { - sgct::config::CylindricalProjection projection; - projection.quality = winControl->qualitySelectedValue(); - projection.heightOffset = winControl->heightOffset(); - viewport.projection = std::move(projection); - } - break; + case WindowControl::ProjectionIndeces::Equirectangular: + default: + projection.mapping + = sgct::config::SpoutOutputProjection::Mapping::Equirectangular; + break; + } + projection.quality = winControl->qualitySelectedValue(); + projection.mappingSpoutName = "OpenSpace"; + viewport.projection = std::move(projection); +} - case WindowControl::ProjectionIndeces::Equirectangular: - { - sgct::config::EquirectangularProjection projection; - projection.quality = winControl->qualitySelectedValue(); - viewport.projection = std::move(projection); - } - break; +void FileSupport::saveProjection_NonSpout(int projectionIndex, WindowControl* winControl, + sgct::config::Viewport& viewport) +{ + switch(projectionIndex) { + case WindowControl::ProjectionIndeces::Fisheye: + { + sgct::config::FisheyeProjection projection; + projection.quality = winControl->qualitySelectedValue(); + projection.fov = 180.0; + projection.tilt = 0.0; + viewport.projection = std::move(projection); + } + break; - case WindowControl::ProjectionIndeces::Planar: - default: - { - // The negative values for left & down are according to sgct's - // convection for importing - sgct::config::PlanarProjection projection; - projection.fov.right = winControl->fovH() / 2.0; - projection.fov.left = -projection.fov.right; - projection.fov.up = winControl->fovV() / 2.0; - projection.fov.down = -projection.fov.up; - viewport.projection = std::move(projection); - } - break; - } + case WindowControl::ProjectionIndeces::Spherical_Mirror: + { + sgct::config::SphericalMirrorProjection projection; + projection.quality = winControl->qualitySelectedValue(); + viewport.projection = std::move(projection); + } + break; + + case WindowControl::ProjectionIndeces::Cylindrical: + { + sgct::config::CylindricalProjection projection; + projection.quality = winControl->qualitySelectedValue(); + projection.heightOffset = winControl->heightOffset(); + viewport.projection = std::move(projection); + } + break; + + case WindowControl::ProjectionIndeces::Equirectangular: + { + sgct::config::EquirectangularProjection projection; + projection.quality = winControl->qualitySelectedValue(); + viewport.projection = std::move(projection); + } + break; + + case WindowControl::ProjectionIndeces::Planar: + default: + { + // The negative values for left & down are according to sgct's convention + sgct::config::PlanarProjection projection; + projection.fov.right = winControl->fovH() / 2.0; + projection.fov.left = -projection.fov.right; + projection.fov.up = winControl->fovV() / 2.0; + projection.fov.down = -projection.fov.up; + viewport.projection = std::move(projection); + } + break; } } void FileSupport::filenameEdited(const QString& newString) { - if (newString.isEmpty()) { - _saveButton->setEnabled(false); - } - else { - _saveButton->setEnabled(true); - } + _saveButton->setEnabled(!newString.isEmpty()); } std::string FileSupport::saveFilename() { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 23ab2f2764..387acf233e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -1,5 +1,28 @@ -#include "sgctedit/monitorbox.h" +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 "sgctedit/monitorbox.h" MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, unsigned int nWindows, QString* winColors) @@ -23,21 +46,20 @@ void MonitorBox::paintEvent(QPaintEvent *event) QPainter painter(this); QPen pen = painter.pen(); painter.setPen(pen); - paintWidgetBorder(painter, width(), height()); - //Draw window out-of-bounds region(s) + //Draw window out-of-bounds region(s) first for (unsigned int i = 0; i < _nWindows; ++i) { paintWindowBeyondBounds(painter, i); } //Draw & fill monitors over the out-of-bounds regions paintMonitorBackgrounds(painter); - //Draw window(s) + //Draw window(s) over both out-of-bounds and monitors for (unsigned int i = 0; i < _nWindows; ++i) { paintWindow(painter, i); } } -void MonitorBox::paintWidgetBorder(QPainter& painter, int width, int height) { +void MonitorBox::paintWidgetBorder(QPainter& painter, const int width, const int height) { painter.setPen(QPen(Qt::gray, 4)); painter.drawRoundedRect(0, 0, width - 1, height - 1, 10, 10); } @@ -61,7 +83,7 @@ void MonitorBox::paintMonitorBackgrounds(QPainter& painter) { } } -void MonitorBox::paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx) { +void MonitorBox::paintWindowBeyondBounds(QPainter& painter, const unsigned int winIdx) { painter.setBrush(Qt::BDiagPattern); setPenSpecificToWindow(painter, winIdx, false); if (winIdx <= _windowRendering.size()) { @@ -71,7 +93,7 @@ void MonitorBox::paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx) painter.setBrush(Qt::NoBrush); } -void MonitorBox::paintWindow(QPainter& painter, unsigned int winIdx) { +void MonitorBox::paintWindow(QPainter& painter, const unsigned int winIdx) { setPenSpecificToWindow(painter, winIdx, true); if (winIdx <= _windowRendering.size()) { painter.drawRect(_windowRendering[winIdx]); @@ -84,17 +106,15 @@ void MonitorBox::paintWindow(QPainter& painter, unsigned int winIdx) { } } -void MonitorBox::paintWindowNumber(QPainter& painter, unsigned int winIdx) { +void MonitorBox::paintWindowNumber(QPainter& painter, const unsigned int winIdx) { QPointF textPos = QPointF(_windowRendering[winIdx].left() + 5, _windowRendering[winIdx].bottom() - 5); - textPos.setX(std::clamp(textPos.x(), 0.0, - _monitorWidgetSize.width() - 10)); - textPos.setY(std::clamp(textPos.y(), 0.0, - _monitorWidgetSize.height() - 10)); + textPos.setX(std::clamp(textPos.x(), 0.0, _monitorWidgetSize.width() - 10)); + textPos.setY(std::clamp(textPos.y(), 0.0, _monitorWidgetSize.height() - 10)); painter.drawText(textPos, QString::fromStdString(std::to_string(winIdx + 1))); } -void MonitorBox::setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, +void MonitorBox::setPenSpecificToWindow(QPainter& painter, const unsigned int windowIdx, bool visibleBorder) { int penWidth = (visibleBorder) ? 1 : -1; @@ -137,7 +157,9 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { this->update(); } -void MonitorBox::computeScaledResolution_landscape(float aspectRatio, float maxWidth) { +void MonitorBox::computeScaledResolution_landscape(const float aspectRatio, + const float maxWidth) +{ _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; float virtualWidth = _monitorWidgetSize.width() * (1.0 - _marginFractionOfWidgetSize * 2.0); @@ -152,7 +174,9 @@ void MonitorBox::computeScaledResolution_landscape(float aspectRatio, float maxW } } -void MonitorBox::computeScaledResolution_portrait(float aspectRatio, float maxHeight) { +void MonitorBox::computeScaledResolution_portrait(const float aspectRatio, + const float maxHeight) +{ _marginWidget = _monitorWidgetSize.height() * _marginFractionOfWidgetSize; float virtualHeight = _monitorWidgetSize.height() * (1.0 - _marginFractionOfWidgetSize * 2.0); @@ -174,11 +198,6 @@ void MonitorBox::setNumWindowsDisplayed(unsigned int nWindows) { } } -void printWindowDims(QRectF& r) { - std::cout << r.width() << "x" << r.height() << " + " << r.x() << "," << r.y(); - std::cout << std::endl; -} - void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& w) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index 2477e1d923..f51beaba0e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -1,3 +1,27 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 "sgctedit/display.h" #include "sgctedit/orientation.h" #include "sgctedit/orientationdialog.h" diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 1c5642d091..846f9763bd 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -1,10 +1,33 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 "sgctedit/display.h" #include "sgctedit/orientationdialog.h" - OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) - : _orientationValue(orientation) - , QDialog(parent) + : QDialog(parent) + , _orientationValue(orientation) { setWindowTitle("Global Orientation"); _layoutWindow = new QVBoxLayout(this); @@ -25,15 +48,15 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) _linePitch->setText(QString::number(_orientationValue.x)); _lineRoll->setText(QString::number(_orientationValue.z)); _lineYaw->setText(QString::number(_orientationValue.y)); - _validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); - _validatorPitch->setNotation(QDoubleValidator::StandardNotation); - _validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); - _validatorRoll->setNotation(QDoubleValidator::StandardNotation); - _validatorYaw = new QDoubleValidator(-180.0, 180.0, 15); - _validatorYaw->setNotation(QDoubleValidator::StandardNotation); - _linePitch->setValidator(_validatorPitch); - _lineRoll->setValidator(_validatorRoll); - _lineYaw->setValidator(_validatorYaw); + _validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); + _validatorPitch->setNotation(QDoubleValidator::StandardNotation); + _validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); + _validatorRoll->setNotation(QDoubleValidator::StandardNotation); + _validatorYaw = new QDoubleValidator(-180.0, 180.0, 15); + _validatorYaw->setNotation(QDoubleValidator::StandardNotation); + _linePitch->setValidator(_validatorPitch); + _lineRoll->setValidator(_validatorRoll); + _lineYaw->setValidator(_validatorYaw); _layoutPitch->addStretch(1); _layoutPitch->addWidget(_labelPitch); @@ -61,21 +84,16 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) _layoutButtonBox->addWidget(_buttonCancel); _layoutButtonBox->addStretch(1); - connect(_buttonSave, SIGNAL(released()), this, - SLOT(ok())); - connect(_buttonCancel, SIGNAL(released()), this, - SLOT(cancel())); + connect(_buttonSave, SIGNAL(released()), this, SLOT(ok())); + connect(_buttonCancel, SIGNAL(released()), this, SLOT(cancel())); _layoutWindow->addLayout(_layoutButtonBox); } void OrientationDialog::ok() { - _orientationValue.x = QString(_linePitch->text()).toFloat() / 180.0 - * glm::pi(); - _orientationValue.y = QString(_lineYaw->text()).toFloat() / 180.0 - * glm::pi(); - _orientationValue.z = QString(_lineRoll->text()).toFloat() / 180.0 - * glm::pi(); + _orientationValue.x = _linePitch->text().toFloat() / 180.0 * glm::pi(); + _orientationValue.y = _lineYaw->text().toFloat() / 180.0 * glm::pi(); + _orientationValue.z = _lineRoll->text().toFloat() / 180.0 * glm::pi(); _orientationValue.w = 1.0; accept(); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 15b54866fc..faad9a4569 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -1,28 +1,41 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 "sgctedit/sgctedit.h" -/*using namespace openspace; - -namespace { - -}*/ - SgctEdit::SgctEdit(QWidget* parent, std::vector& windowList, - sgct::config::Cluster& cluster, QApplication& qtApp) + sgct::config::Cluster& cluster, const QList screenList) : QDialog(parent) , _cluster(cluster) , _windowList(windowList) { - setWindowTitle("Display/Window Editor"); - systemMonitorConfiguration(qtApp); + systemMonitorConfiguration(screenList); + setWindowTitle("Display/Window Configuration Editor"); createWidgets(); } -void SgctEdit::systemMonitorConfiguration(QApplication& qtApp) { - QList screenList = qtApp.screens(); - if (screenList.length() == 0) { - std::cerr << "Error: Qt reports no screens available." << std::endl; - return; - } +void SgctEdit::systemMonitorConfiguration(const QList screenList) { size_t nScreensManaged = std::min(screenList.length(), 2); for (size_t s = 0; s < nScreensManaged; ++s) { int actualWidth = std::max(screenList[s]->size().width(), @@ -56,16 +69,13 @@ void SgctEdit::createWidgets() { layoutMonBox->addWidget(_monBox); layoutMonBox->addStretch(1); layoutMainV->addLayout(layoutMonBox); - _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _monBox->setFixedSize(_monitorWidgetSize.width(), _monitorWidgetSize.height()); - addDisplayLayout(_monBox, layoutMainH); } { layoutMainV->addLayout(layoutMainH); _orientationWidget->addButtonToLayout(layoutMainV); - _fileSupportWidget = new FileSupport( layoutMainV, _monitorSizeList, @@ -111,9 +121,19 @@ std::string SgctEdit::saveFilename() { } SgctEdit::~SgctEdit() { - delete _orientationWidget; - delete _fileSupportWidget; - delete _displayWidget; - delete _displayLayout; - delete _displayFrame; + if (_orientationWidget) { + delete _orientationWidget; + } + if (_fileSupportWidget) { + delete _fileSupportWidget; + } + if (_displayWidget) { + delete _displayWidget; + } + if (_displayLayout) { + delete _displayLayout; + } + if (_displayFrame) { + delete _displayFrame; + } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index d227769900..5c6a8f6f79 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -1,10 +1,34 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * 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 "sgctedit/display.h" #include "sgctedit/monitorbox.h" #include "sgctedit/windowcontrol.h" WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, - unsigned int windowIndex, QRect& widgetDims, std::vector& monitorDims, - QString* winColors, QWidget *parent) + const unsigned int windowIndex, std::vector& monitorDims, + const QString* winColors, QWidget *parent) : QWidget(parent) , _nMonitors(nMonitors) , _monIndex(monitorIndex) @@ -21,14 +45,10 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, QString::fromUtf8(std::to_string(int(_windowDims.x())).c_str()), parent); _offset_y = new QLineEdit( QString::fromUtf8(std::to_string(int(_windowDims.y())).c_str()), parent); - QIntValidator* _validatorSize_x - = new QIntValidator(10, _maxWindowSizePixels); - QIntValidator* _validatorSize_y - = new QIntValidator(10, _maxWindowSizePixels); - QIntValidator* _validatorOffset_x - = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); - QIntValidator* _validatorOffset_y - = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); + _validatorSize_x = new QIntValidator(10, _maxWindowSizePixels); + _validatorSize_y = new QIntValidator(10, _maxWindowSizePixels); + _validatorOffset_x = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); + _validatorOffset_y = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); _size_x->setValidator(_validatorSize_x); _size_y->setValidator(_validatorSize_y); _offset_x->setValidator(_validatorOffset_x); @@ -41,7 +61,7 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, _fullscreenButton = new QPushButton(this); _fullscreenButton->setText("Set to Fullscreen"); _checkBoxWindowDecor = new QCheckBox("Window Decoration", this); - _checkBoxWindowDecor->setChecked(Qt::CheckState::Checked); + _checkBoxWindowDecor->setCheckState(Qt::CheckState::Checked); _checkBoxWebGui = new QCheckBox("WebGUI only this window", this); _checkBoxSpoutOutput = new QCheckBox("Spout Output", this); _comboProjection = new QComboBox(this); @@ -79,7 +99,7 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, connect(_fullscreenButton, SIGNAL(released()), this, SLOT(onFullscreenClicked())); } -QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { +QVBoxLayout* WindowControl::initializeLayout() { _layoutFullWindow = new QVBoxLayout(); //Window size _layoutWindowCtrl = new QVBoxLayout(); @@ -219,7 +239,7 @@ QVBoxLayout* WindowControl::initializeLayout(QWidget* parentWidget) { return _layoutFullWindow; } -void WindowControl::showWindowLabel(bool show) { +void WindowControl::showWindowLabel(const bool show) { _labelWinNum->setVisible(show); } @@ -334,67 +354,16 @@ void WindowControl::onMonitorChanged(int newSelection) { } void WindowControl::onProjectionChanged(int newSelection) { - switch (newSelection) { - case ProjectionIndeces::Planar: - _comboQuality->setVisible(false); - _labelQuality->setVisible(false); - _labelFovH->setVisible(true); - _lineFovH->setVisible(true); - _labelFovV->setVisible(true); - _lineFovV->setVisible(true); - _labelHeightOffset->setVisible(false); - _lineHeightOffset->setVisible(false); - _checkBoxSpoutOutput->setVisible(false); - break; - - case ProjectionIndeces::Fisheye: - _comboQuality->setVisible(true); - _labelQuality->setVisible(true); - _labelFovH->setVisible(false); - _lineFovH->setVisible(false); - _labelFovV->setVisible(false); - _lineFovV->setVisible(false); - _labelHeightOffset->setVisible(false); - _lineHeightOffset->setVisible(false); - _checkBoxSpoutOutput->setVisible(true); - break; - - case ProjectionIndeces::Spherical_Mirror: - _comboQuality->setVisible(true); - _labelQuality->setVisible(true); - _labelFovH->setVisible(false); - _lineFovH->setVisible(false); - _labelFovV->setVisible(false); - _lineFovV->setVisible(false); - _labelHeightOffset->setVisible(false); - _lineHeightOffset->setVisible(false); - _checkBoxSpoutOutput->setVisible(false); - break; - - case ProjectionIndeces::Cylindrical: - _comboQuality->setVisible(true); - _labelQuality->setVisible(true); - _labelFovH->setVisible(false); - _lineFovH->setVisible(false); - _labelFovV->setVisible(false); - _lineFovV->setVisible(false); - _labelHeightOffset->setVisible(true); - _lineHeightOffset->setVisible(true); - _checkBoxSpoutOutput->setVisible(false); - break; - - case ProjectionIndeces::Equirectangular: - _comboQuality->setVisible(true); - _labelQuality->setVisible(true); - _labelFovH->setVisible(false); - _lineFovH->setVisible(false); - _labelFovV->setVisible(false); - _lineFovV->setVisible(false); - _labelHeightOffset->setVisible(false); - _lineHeightOffset->setVisible(false); - _checkBoxSpoutOutput->setVisible(true); - break; - } + _comboQuality->setVisible(newSelection != ProjectionIndeces::Planar); + _labelQuality->setVisible(newSelection != ProjectionIndeces::Planar); + _labelFovH->setVisible(newSelection == ProjectionIndeces::Planar); + _lineFovH->setVisible(newSelection == ProjectionIndeces::Planar); + _labelFovV->setVisible(newSelection == ProjectionIndeces::Planar); + _lineFovV->setVisible(newSelection == ProjectionIndeces::Planar); + _labelHeightOffset->setVisible(newSelection == ProjectionIndeces::Cylindrical); + _lineHeightOffset->setVisible(newSelection == ProjectionIndeces::Cylindrical); + _checkBoxSpoutOutput->setVisible(newSelection == ProjectionIndeces::Fisheye + || newSelection == ProjectionIndeces::Equirectangular); } void WindowControl::setDimensions(const QRectF& dimensions) { From 29975f323dc2f2275ac056544a74201a1928b893 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 30 Jan 2022 20:40:58 -0700 Subject: [PATCH 52/93] More cleanup plus letting Qt clean up more object allocations --- .../ext/launcher/include/sgctedit/display.h | 3 - .../launcher/include/sgctedit/filesupport.h | 1 - .../launcher/include/sgctedit/orientation.h | 2 - .../include/sgctedit/orientationdialog.h | 19 +- .../launcher/include/sgctedit/windowcontrol.h | 41 +- .../ext/launcher/src/sgctedit/display.cpp | 31 +- .../ext/launcher/src/sgctedit/filesupport.cpp | 49 +-- .../ext/launcher/src/sgctedit/orientation.cpp | 28 +- .../src/sgctedit/orientationdialog.cpp | 121 +++--- .../launcher/src/sgctedit/windowcontrol.cpp | 406 +++++++++--------- 10 files changed, 294 insertions(+), 407 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 753acb77df..f90ec83b42 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -81,9 +81,6 @@ private: QPushButton* _removeWindowButton = nullptr; unsigned int _monitorIdx = 0; QVBoxLayout* _layout = nullptr; - QHBoxLayout* _layoutMonBox = nullptr; - QHBoxLayout* _layoutMonButton = nullptr; - QHBoxLayout* _layoutWindows = nullptr; std::vector _winCtrlLayouts; std::vector _layoutWindowWrappers; std::vector _frameBorderLines; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index 48e709db49..817d6800cf 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -47,7 +47,6 @@ public: Display* display, Orientation* orientation, std::vector& windowList, sgct::config::Cluster& cluster, std::function cb); - ~FileSupport(); std::string saveFilename(); private slots: diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index aaa59c3a08..cdb9761d62 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -62,8 +62,6 @@ private: sgct::quat _orientationValue = {0.0, 0.0, 0.0, 0.0}; OrientationDialog* _orientationDialog = nullptr; QHBoxLayout* _layoutOrientationFull = nullptr; - QVBoxLayout* _layoutOrientationControls = nullptr; - QPushButton* _orientationButton = nullptr; QCheckBox* _checkBoxVsync = nullptr; }; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h index 58a9fe85aa..b4b88bd321 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h @@ -50,33 +50,16 @@ class OrientationDialog : public QDialog Q_OBJECT public: explicit OrientationDialog(sgct::quat& orientation, QWidget* parent); - ~OrientationDialog(); private slots: void cancel(); void ok(); private: - sgct::quat& _orientationValue; - QVBoxLayout* _layoutWindow = nullptr; - QHBoxLayout* _layoutPitch = nullptr; - QHBoxLayout* _layoutRoll = nullptr; - QHBoxLayout* _layoutYaw = nullptr; - QHBoxLayout* _layoutButtonBox = nullptr; - - QLabel* _labelPitch = nullptr; - QLabel* _labelRoll = nullptr; - QLabel* _labelYaw = nullptr; - QLineEdit* _linePitch = nullptr; QLineEdit* _lineRoll = nullptr; QLineEdit* _lineYaw = nullptr; - QDoubleValidator* _validatorPitch = nullptr; - QDoubleValidator* _validatorRoll = nullptr; - QDoubleValidator* _validatorYaw = nullptr; - - QPushButton* _buttonSave = nullptr; - QPushButton* _buttonCancel = nullptr; + sgct::quat& _orientationValue; }; #endif // __OPENSPACE_UI_LAUNCHER___ORIENTATIONDIALOG___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 258ea4bc4c..545df93009 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -58,7 +58,6 @@ public: void setWindowChangeCallback(std::function cb); void setWebGuiChangeCallback(std::function cb); void showWindowLabel(const bool show); - void cleanupLayouts(); QVBoxLayout* initializeLayout(); QRectF& dimensions(); QLineEdit* lineEditSizeWidth(); @@ -110,6 +109,7 @@ private slots: void onWebGuiSelection(int selectionState); private: + void createWidgets(QWidget* parent); template void enableProjectionOption(T* comboModel, int selectionIndex, bool enable); void updateScaledWindowDimensions(); @@ -149,67 +149,28 @@ private: std::vector& _monitorResolutions; int _maxWindowSizePixels = 10000; const QString* _colorsForWindows = nullptr; - - QVBoxLayout* _layoutWindowCtrl = nullptr; QVBoxLayout* _layoutFullWindow = nullptr; - - QHBoxLayout* _layoutWinNum = nullptr; QLabel* _labelWinNum = nullptr; - QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; QLineEdit* _offset_x = nullptr; QLineEdit* _offset_y = nullptr; - - QIntValidator* _validatorSize_x = nullptr; - QIntValidator* _validatorSize_y = nullptr; - QIntValidator* _validatorOffset_x = nullptr; - QIntValidator* _validatorOffset_y = nullptr; - QRectF _windowDims; QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; QCheckBox* _checkBoxWebGui = nullptr; QCheckBox* _checkBoxSpoutOutput = nullptr; - QComboBox* _comboMonitorSelect = nullptr; QComboBox* _comboProjection = nullptr; QComboBox* _comboQuality = nullptr; QLabel* _labelQuality = nullptr; QLabel* _labelFovH = nullptr; QLineEdit* _lineFovH = nullptr; - QDoubleValidator* _validatorFovH = nullptr; QLabel* _labelFovV = nullptr; QLineEdit* _lineFovV = nullptr; - QDoubleValidator* _validatorFovV = nullptr; QLabel* _labelHeightOffset = nullptr; QLineEdit* _lineHeightOffset = nullptr; - QDoubleValidator* _validatorHeightOffset = nullptr; - - QHBoxLayout* _layoutName = nullptr; - QLabel* _labelName = nullptr; QLineEdit* _windowName = nullptr; - QHBoxLayout* _layoutMonitorNum = nullptr; - QLabel* _labelSize = nullptr; - QLabel* _labelDelim = nullptr; - QHBoxLayout* _layoutSize = nullptr; - QWidget* _widgetSize = nullptr; - QHBoxLayout* _layoutOffset = nullptr; - QLabel* _labelOffset = nullptr; - QLabel* _labelComma = nullptr; - QHBoxLayout* _layoutCheckboxesFull1 = nullptr; - QVBoxLayout* _layoutCheckboxesFull2 = nullptr; - QVBoxLayout* _layoutProjectionGroup = nullptr; - QFrame* _borderProjectionGroup = nullptr; - QHBoxLayout* _layoutFullscreenButton = nullptr; - QHBoxLayout* _layoutCBoxWindowDecor = nullptr; - QHBoxLayout* _layoutCBoxWebGui = nullptr; - QHBoxLayout* _layoutComboProjection = nullptr; - QHBoxLayout* _layoutCBoxSpoutOutput = nullptr; - QHBoxLayout* _layoutComboQuality = nullptr; - QHBoxLayout* _layoutFovH = nullptr; - QHBoxLayout* _layoutFovV = nullptr; - QHBoxLayout* _layoutHeightOffset = nullptr; }; #endif // __OPENSPACE_UI_LAUNCHER___WINDOWCONTROL___H__ diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index c6651e8a80..ed4394146f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -50,48 +50,39 @@ Display::Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeLi } Display::~Display() { - delete _addWindowButton; - delete _removeWindowButton; delete _monBox; - for (auto f : _frameBorderLines) { - delete f; - } for (auto w : _windowControl) { delete w; } - delete _layoutMonBox; - delete _layoutMonButton; - for (auto w : _layoutWindowWrappers) { - delete w; - } - delete _layoutWindows; delete _layout; } void Display::initializeLayout() { _layout = new QVBoxLayout(this); - _layoutMonButton = new QHBoxLayout(); - _layoutMonButton->addWidget(_removeWindowButton); - _layoutMonButton->addStretch(1); - _layoutMonButton->addWidget(_addWindowButton); - _layout->addLayout(_layoutMonButton); - _layoutWindows = new QHBoxLayout(); + { + QHBoxLayout* layoutMonButton = new QHBoxLayout(); + layoutMonButton->addWidget(_removeWindowButton); + layoutMonButton->addStretch(1); + layoutMonButton->addWidget(_addWindowButton); + _layout->addLayout(layoutMonButton); + } + QHBoxLayout* layoutWindows = new QHBoxLayout(); _layout->addStretch(); for (unsigned int i = 0; i < _nMaxWindows; ++i) { _winCtrlLayouts.push_back(_windowControl[i]->initializeLayout()); _layoutWindowWrappers.push_back(new QWidget()); _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); - _layoutWindows->addWidget(_layoutWindowWrappers.back()); + layoutWindows->addWidget(_layoutWindowWrappers.back()); if (i < (_nMaxWindows - 1)) { _frameBorderLines.push_back(new QFrame()); _frameBorderLines.back()->setFrameShape(QFrame::VLine); - _layoutWindows->addWidget(_frameBorderLines.back()); + layoutWindows->addWidget(_frameBorderLines.back()); } } _nWindowsDisplayed = 1; showWindows(); - _layout->addLayout(_layoutWindows); + _layout->addLayout(layoutWindows); } std::vector Display::windowControls() { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 52ad58345c..441ea8a0c0 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -36,32 +36,35 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL , _finishedCallback(cb) { QVBoxLayout* layoutFullVertical = new QVBoxLayout(); - QHBoxLayout* layoutFilename = new QHBoxLayout(); _lineFilename = new QLineEdit(); _lineFilename->setFixedWidth(190); - QLabel* labelFilename = new QLabel(); - labelFilename->setText("Filename: "); - layoutFilename->addStretch(1); - layoutFilename->addWidget(labelFilename); - layoutFilename->addWidget(_lineFilename); - layoutFilename->addStretch(1); - _layoutButtonBox = new QHBoxLayout; + { + QHBoxLayout* layoutFilename = new QHBoxLayout(); + QLabel* labelFilename = new QLabel(); + labelFilename->setText("Filename: "); + layoutFilename->addStretch(1); + layoutFilename->addWidget(labelFilename); + layoutFilename->addWidget(_lineFilename); + layoutFilename->addStretch(1); + layoutFullVertical->addLayout(layoutFilename); + } _saveButton = new QPushButton("Save"); _saveButton->setToolTip("Save global orientation changes"); - _layoutButtonBox->addStretch(1); - _layoutButtonBox->addWidget(_saveButton); + connect(_saveButton, SIGNAL(released()), this, SLOT(save())); + _saveButton->setEnabled(false); _cancelButton = new QPushButton("Cancel"); _cancelButton->setToolTip("Cancel global orientation changes"); - _layoutButtonBox->addWidget(_cancelButton); - layoutFullVertical->addLayout(layoutFilename); - layoutFullVertical->addLayout(_layoutButtonBox); - parentLayout->addLayout(layoutFullVertical); - connect(_saveButton, SIGNAL(released()), this, SLOT(save())); connect(_cancelButton, SIGNAL(released()), this, SLOT(cancel())); + { + QHBoxLayout* layoutButtonBox = new QHBoxLayout; + layoutButtonBox->addStretch(1); + layoutButtonBox->addWidget(_saveButton); + layoutButtonBox->addWidget(_cancelButton); + layoutFullVertical->addLayout(layoutButtonBox); + } + parentLayout->addLayout(layoutFullVertical); connect(_lineFilename, SIGNAL(textEdited(const QString&)), this, SLOT(filenameEdited(const QString&))); - _saveButton->setEnabled(false); - _cluster.masterAddress = "localhost"; } void FileSupport::saveCluster() { @@ -71,6 +74,7 @@ void FileSupport::saveCluster() { if (_cluster.nodes.size() == 0) { _cluster.nodes.push_back(sgct::config::Node()); } + _cluster.masterAddress = "localhost"; _cluster.nodes.back().address = "localhost"; _cluster.nodes.back().port = 20401; _cluster.scene = std::move(initScene); @@ -154,7 +158,7 @@ void FileSupport::saveWindowsWebGui(unsigned int wIdx) { _windowList.back().tags.push_back("GUI"); } _windowList.back().draw2D = (wIdx == webGuiWindowIndex); - _windowList.back().draw3D = !_windowList.back().draw2D; + _windowList.back().draw3D = !(_windowList.back().draw2D.value()); } } @@ -272,12 +276,3 @@ void FileSupport::save() { void FileSupport::cancel() { _finishedCallback(false); } - -FileSupport::~FileSupport() -{ - delete _saveButton; - delete _cancelButton; - delete _lineFilename; - delete _layoutButtonBox; -} - diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index f51beaba0e..8ec4cbdd60 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -30,18 +30,18 @@ Orientation::Orientation() { _orientationDialog = new OrientationDialog(_orientationValue, this); _layoutOrientationFull = new QHBoxLayout(); - _layoutOrientationControls = new QVBoxLayout(); - _orientationButton = new QPushButton("Global Orientation"); - _checkBoxVsync = new QCheckBox("VSync All Windows", this); - _layoutOrientationControls->addWidget(_checkBoxVsync); - _layoutOrientationControls->addWidget(_orientationButton); - - _layoutOrientationFull->addStretch(1); - _layoutOrientationFull->addLayout(_layoutOrientationControls); - _layoutOrientationFull->addStretch(1); - - connect(_orientationButton, SIGNAL(released()), this, - SLOT(orientationDialog())); + { + QVBoxLayout* layoutOrientationControls = new QVBoxLayout(); + QPushButton* orientationButton = new QPushButton("Global Orientation"); + _checkBoxVsync = new QCheckBox("VSync All Windows", this); + layoutOrientationControls->addWidget(_checkBoxVsync); + layoutOrientationControls->addWidget(orientationButton); + _layoutOrientationFull->addStretch(1); + _layoutOrientationFull->addLayout(layoutOrientationControls); + _layoutOrientationFull->addStretch(1); + connect(orientationButton, SIGNAL(released()), this, + SLOT(orientationDialog())); + } } void Orientation::addButtonToLayout(QVBoxLayout* parentLayout) { @@ -63,7 +63,5 @@ bool Orientation::vsyncValue() { Orientation::~Orientation() { delete _orientationDialog; - delete _orientationButton; - delete _checkBoxVsync; - delete _layoutOrientationControls; + delete _layoutOrientationFull; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 846f9763bd..93334b824f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -30,17 +30,7 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) , _orientationValue(orientation) { setWindowTitle("Global Orientation"); - _layoutWindow = new QVBoxLayout(this); - _layoutPitch = new QHBoxLayout(); - _layoutRoll = new QHBoxLayout(); - _layoutYaw = new QHBoxLayout(); - - _labelPitch = new QLabel(this); - _labelRoll = new QLabel(this); - _labelYaw = new QLabel(this); - _labelPitch->setText("Pitch: "); - _labelRoll ->setText("Roll: "); - _labelYaw ->setText("Yaw: "); + QVBoxLayout* layoutWindow = new QVBoxLayout(this); _linePitch = new QLineEdit(this); _lineRoll = new QLineEdit(this); @@ -48,46 +38,54 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) _linePitch->setText(QString::number(_orientationValue.x)); _lineRoll->setText(QString::number(_orientationValue.z)); _lineYaw->setText(QString::number(_orientationValue.y)); - _validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); - _validatorPitch->setNotation(QDoubleValidator::StandardNotation); - _validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); - _validatorRoll->setNotation(QDoubleValidator::StandardNotation); - _validatorYaw = new QDoubleValidator(-180.0, 180.0, 15); - _validatorYaw->setNotation(QDoubleValidator::StandardNotation); - _linePitch->setValidator(_validatorPitch); - _lineRoll->setValidator(_validatorRoll); - _lineYaw->setValidator(_validatorYaw); - - _layoutPitch->addStretch(1); - _layoutPitch->addWidget(_labelPitch); - _layoutPitch->addWidget(_linePitch); - _layoutWindow->addLayout(_layoutPitch); - - _layoutRoll->addStretch(1); - _layoutRoll->addWidget(_labelRoll); - _layoutRoll->addWidget(_lineRoll); - _layoutWindow->addLayout(_layoutRoll); - - _layoutYaw->addStretch(1); - _layoutYaw->addWidget(_labelYaw); - _layoutYaw->addWidget(_lineYaw); - _layoutWindow->addLayout(_layoutYaw); - - _layoutButtonBox = new QHBoxLayout; - _buttonSave = new QPushButton("OK"); - _buttonSave->setToolTip("Save global orientation changes"); - _layoutButtonBox->addStretch(1); - _layoutButtonBox->addWidget(_buttonSave); - - _buttonCancel = new QPushButton("Cancel"); - _buttonCancel->setToolTip("Cancel global orientation changes"); - _layoutButtonBox->addWidget(_buttonCancel); - _layoutButtonBox->addStretch(1); - - connect(_buttonSave, SIGNAL(released()), this, SLOT(ok())); - connect(_buttonCancel, SIGNAL(released()), this, SLOT(cancel())); - - _layoutWindow->addLayout(_layoutButtonBox); + { + QDoubleValidator* validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); + QDoubleValidator* validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); + QDoubleValidator* validatorYaw = new QDoubleValidator(-180.0, 180.0, 15); + validatorPitch->setNotation(QDoubleValidator::StandardNotation); + validatorRoll->setNotation(QDoubleValidator::StandardNotation); + validatorYaw->setNotation(QDoubleValidator::StandardNotation); + _linePitch->setValidator(validatorPitch); + _lineRoll->setValidator(validatorRoll); + _lineYaw->setValidator(validatorYaw); + } + { + QLabel* labelPitch = new QLabel(this); + labelPitch->setText("Pitch: "); + QHBoxLayout* layoutPitch = new QHBoxLayout(); + layoutPitch->addStretch(1); + layoutPitch->addWidget(labelPitch); + layoutPitch->addWidget(_linePitch); + layoutWindow->addLayout(layoutPitch); + QLabel* labelRoll = new QLabel(this); + labelRoll ->setText("Roll: "); + QHBoxLayout* layoutRoll = new QHBoxLayout(); + layoutRoll->addStretch(1); + layoutRoll->addWidget(labelRoll); + layoutRoll->addWidget(_lineRoll); + layoutWindow->addLayout(layoutRoll); + QLabel* labelYaw = new QLabel(this); + labelYaw ->setText("Yaw: "); + QHBoxLayout* layoutYaw = new QHBoxLayout(); + layoutYaw->addStretch(1); + layoutYaw->addWidget(labelYaw); + layoutYaw->addWidget(_lineYaw); + layoutWindow->addLayout(layoutYaw); + } + { + QHBoxLayout* layoutButtonBox = new QHBoxLayout; + QPushButton* buttonSave = new QPushButton("OK"); + buttonSave->setToolTip("Save global orientation changes"); + layoutButtonBox->addStretch(1); + layoutButtonBox->addWidget(buttonSave); + QPushButton* buttonCancel = new QPushButton("Cancel"); + buttonCancel->setToolTip("Cancel global orientation changes"); + layoutButtonBox->addWidget(buttonCancel); + layoutButtonBox->addStretch(1); + connect(buttonSave, SIGNAL(released()), this, SLOT(ok())); + connect(buttonCancel, SIGNAL(released()), this, SLOT(cancel())); + layoutWindow->addLayout(layoutButtonBox); + } } void OrientationDialog::ok() { @@ -101,24 +99,3 @@ void OrientationDialog::ok() { void OrientationDialog::cancel() { reject(); } - -OrientationDialog::~OrientationDialog() -{ - delete _labelPitch; - delete _labelRoll; - delete _labelYaw; - delete _validatorPitch; - delete _validatorRoll; - delete _validatorYaw; - delete _linePitch; - delete _lineRoll; - delete _lineYaw; - delete _buttonSave; - delete _buttonCancel; - delete _layoutPitch; - delete _layoutRoll; - delete _layoutYaw; - delete _layoutButtonBox; - delete _layoutWindow; -} - diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 5c6a8f6f79..58e2712c4e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -36,7 +36,11 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, , _monitorResolutions(monitorDims) , _colorsForWindows(winColors) { - _windowDims = defaultWindowSizes[windowIndex]; + createWidgets(parent); +} + +void WindowControl::createWidgets(QWidget* parent) { + _windowDims = defaultWindowSizes[_index]; _size_x = new QLineEdit( QString::fromUtf8(std::to_string(int(_windowDims.width())).c_str()), parent); _size_y = new QLineEdit( @@ -45,19 +49,27 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, QString::fromUtf8(std::to_string(int(_windowDims.x())).c_str()), parent); _offset_y = new QLineEdit( QString::fromUtf8(std::to_string(int(_windowDims.y())).c_str()), parent); - _validatorSize_x = new QIntValidator(10, _maxWindowSizePixels); - _validatorSize_y = new QIntValidator(10, _maxWindowSizePixels); - _validatorOffset_x = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); - _validatorOffset_y = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); - _size_x->setValidator(_validatorSize_x); - _size_y->setValidator(_validatorSize_y); - _offset_x->setValidator(_validatorOffset_x); - _offset_y->setValidator(_validatorOffset_y); - - _comboMonitorSelect = new QComboBox(this); - _comboMonitorSelect->addItems(_monitorNames); - _comboMonitorSelect->setCurrentIndex(_monIndex); - + { + QIntValidator* validatorSize_x = new QIntValidator(10, _maxWindowSizePixels); + QIntValidator* validatorSize_y = new QIntValidator(10, _maxWindowSizePixels); + QIntValidator* validatorOffset_x = new QIntValidator( + -_maxWindowSizePixels, + _maxWindowSizePixels + ); + QIntValidator* validatorOffset_y = new QIntValidator( + -_maxWindowSizePixels, + _maxWindowSizePixels + ); + _size_x->setValidator(validatorSize_x); + _size_y->setValidator(validatorSize_y); + _offset_x->setValidator(validatorOffset_x); + _offset_y->setValidator(validatorOffset_y); + } + if (_nMonitors > 1) { + _comboMonitorSelect = new QComboBox(this); + _comboMonitorSelect->addItems(_monitorNames); + _comboMonitorSelect->setCurrentIndex(_monIndex); + } _fullscreenButton = new QPushButton(this); _fullscreenButton->setText("Set to Fullscreen"); _checkBoxWindowDecor = new QCheckBox("Window Decoration", this); @@ -70,39 +82,71 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, _comboQuality = new QComboBox(this); _comboQuality->addItems(_qualityTypes); - _lineFovH = new QLineEdit("80.0", parent); - _validatorFovH = new QDoubleValidator(-180.0, 180.0, 10); - _lineFovH->setValidator(_validatorFovH); - _lineFovV = new QLineEdit("50.534", parent); - _validatorFovV = new QDoubleValidator(-90.0, 90.0, 10); - _lineFovV->setValidator(_validatorFovV); - _lineHeightOffset = new QLineEdit("0.0", parent); - _validatorHeightOffset = new QDoubleValidator(-1000000.0, 1000000.0, 12); - _lineHeightOffset->setValidator(_validatorHeightOffset); + { + _lineFovH = new QLineEdit("80.0", parent); + _lineFovV = new QLineEdit("50.534", parent); + QDoubleValidator* validatorFovH = new QDoubleValidator(-180.0, 180.0, 10); + _lineFovH->setValidator(validatorFovH); + QDoubleValidator* validatorFovV = new QDoubleValidator(-90.0, 90.0, 10); + _lineFovV->setValidator(validatorFovV); + _lineHeightOffset = new QLineEdit("0.0", parent); + QDoubleValidator* validatorHtOff= new QDoubleValidator(-1000000.0, 1000000.0, 12); + _lineHeightOffset->setValidator(validatorHtOff); + } - connect(_size_x, SIGNAL(textChanged(const QString&)), this, - SLOT(onSizeXChanged(const QString&))); - connect(_size_y, SIGNAL(textChanged(const QString&)), this, - SLOT(onSizeYChanged(const QString&))); - connect(_offset_x, SIGNAL(textChanged(const QString&)), this, - SLOT(onOffsetXChanged(const QString&))); - connect(_offset_y, SIGNAL(textChanged(const QString&)), this, - SLOT(onOffsetYChanged(const QString&))); - connect(_comboMonitorSelect, SIGNAL(currentIndexChanged(int)), - this, SLOT(onMonitorChanged(int))); - connect(_comboProjection, SIGNAL(currentIndexChanged(int)), - this, SLOT(onProjectionChanged(int))); - connect(_checkBoxSpoutOutput, SIGNAL(stateChanged(int)), - this, SLOT(onSpoutSelection(int))); - connect(_checkBoxWebGui, SIGNAL(stateChanged(int)), - this, SLOT(onWebGuiSelection(int))); + connect( + _size_x, + SIGNAL(textChanged(const QString&)), + this, + SLOT(onSizeXChanged(const QString&)) + ); + connect( + _size_y, + SIGNAL(textChanged(const QString&)), + this, + SLOT(onSizeYChanged(const QString&)) + ); + connect( + _offset_x, + SIGNAL(textChanged(const QString&)), + this, + SLOT(onOffsetXChanged(const QString&)) + ); + connect( + _offset_y, + SIGNAL(textChanged(const QString&)), + this, + SLOT(onOffsetYChanged(const QString&)) + ); + connect( + _comboMonitorSelect, + SIGNAL(currentIndexChanged(int)), + this, + SLOT(onMonitorChanged(int)) + ); + connect(_comboProjection, + SIGNAL(currentIndexChanged(int)), + this, + SLOT(onProjectionChanged(int)) + ); + connect(_checkBoxSpoutOutput, + SIGNAL(stateChanged(int)), + this, + SLOT(onSpoutSelection(int)) + ); + connect( + _checkBoxWebGui, + SIGNAL(stateChanged(int)), + this, + SLOT(onWebGuiSelection(int)) + ); connect(_fullscreenButton, SIGNAL(released()), this, SLOT(onFullscreenClicked())); } QVBoxLayout* WindowControl::initializeLayout() { _layoutFullWindow = new QVBoxLayout(); //Window size - _layoutWindowCtrl = new QVBoxLayout(); + QVBoxLayout* layoutWindowCtrl = new QVBoxLayout(); _labelWinNum = new QLabel(); _labelWinNum->setText("Window " + QString::number(_index + 1)); @@ -111,126 +155,128 @@ QVBoxLayout* WindowControl::initializeLayout() { colorStr += "; }"; _labelWinNum->setStyleSheet(colorStr); - _layoutWinNum = new QHBoxLayout(); - _layoutWinNum->addStretch(1); - _layoutWinNum->addWidget(_labelWinNum); - _layoutWinNum->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutWinNum); + QHBoxLayout* layoutWinNum = new QHBoxLayout(); + layoutWinNum->addStretch(1); + layoutWinNum->addWidget(_labelWinNum); + layoutWinNum->addStretch(1); + layoutWindowCtrl->addLayout(layoutWinNum); - _layoutName = new QHBoxLayout(); - _labelName = new QLabel(this); - _labelName->setText("Name: "); - _windowName = new QLineEdit(this); - _windowName->setFixedWidth(160); - _layoutName->addWidget(_labelName); - _layoutName->addWidget(_windowName); - _layoutName->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutName); + { + QHBoxLayout* layoutName = new QHBoxLayout(); + QLabel* labelName = new QLabel(this); + labelName->setText("Name: "); + _windowName = new QLineEdit(this); + _windowName->setFixedWidth(160); + layoutName->addWidget(labelName); + layoutName->addWidget(_windowName); + layoutName->addStretch(1); + layoutWindowCtrl->addLayout(layoutName); + } if (_nMonitors > 1) { - _layoutMonitorNum = new QHBoxLayout(); - _layoutMonitorNum->addWidget(_comboMonitorSelect); - _layoutMonitorNum->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutMonitorNum); - } - else { - _comboMonitorSelect->setVisible(false); + QHBoxLayout* layoutMonitorNum = new QHBoxLayout(); + layoutMonitorNum->addWidget(_comboMonitorSelect); + layoutMonitorNum->addStretch(1); + layoutWindowCtrl->addLayout(layoutMonitorNum); } _size_x->setFixedWidth(_lineEditWidthFixed); _size_y->setFixedWidth(_lineEditWidthFixed); - _labelSize = new QLabel(this); - _labelDelim = new QLabel(this); - _layoutSize = new QHBoxLayout(); - _layoutSize->addWidget(_labelSize); - _labelSize->setText("Size:"); - _labelSize->setFixedWidth(55); - _layoutSize->addWidget(_size_x); - _layoutSize->addWidget(_labelDelim); - _layoutSize->addWidget(_size_y); - _layoutSize->addStretch(1); - _labelDelim->setText("x"); - _labelDelim->setFixedWidth(9); - _layoutWindowCtrl->addLayout(_layoutSize); + { + QLabel* labelSize = new QLabel(this); + QLabel* labelDelim = new QLabel(this); + QHBoxLayout* layoutSize = new QHBoxLayout(); + layoutSize->addWidget(labelSize); + labelSize->setText("Size:"); + labelSize->setFixedWidth(55); + layoutSize->addWidget(_size_x); + layoutSize->addWidget(labelDelim); + layoutSize->addWidget(_size_y); + layoutSize->addStretch(1); + labelDelim->setText("x"); + labelDelim->setFixedWidth(9); + layoutWindowCtrl->addLayout(layoutSize); + } - //Window offset _offset_x->setFixedWidth(_lineEditWidthFixed); _offset_y->setFixedWidth(_lineEditWidthFixed); - _labelOffset = new QLabel(this); - _labelComma = new QLabel(this); - _layoutOffset = new QHBoxLayout(); - _layoutOffset->addWidget(_labelOffset); - _labelOffset->setText("Offset:"); - _labelOffset->setFixedWidth(55); - _layoutOffset->addWidget(_offset_x); - _layoutOffset->addWidget(_labelComma); - _layoutOffset->addWidget(_offset_y); - _layoutOffset->addStretch(1); - _labelComma->setText(","); - _labelComma->setFixedWidth(9); - _layoutWindowCtrl->addLayout(_layoutOffset); - - //Window options - _layoutCheckboxesFull1 = new QHBoxLayout(); - _layoutCheckboxesFull2 = new QVBoxLayout(); - _layoutFullscreenButton = new QHBoxLayout(); - _layoutFullscreenButton->addWidget(_fullscreenButton); - _layoutFullscreenButton->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutFullscreenButton); - _layoutCBoxWindowDecor = new QHBoxLayout(); - _layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); - _layoutCBoxWindowDecor->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutCBoxWindowDecor); - _layoutCBoxWebGui= new QHBoxLayout(); - _layoutCBoxWebGui->addWidget(_checkBoxWebGui); - _layoutCBoxWebGui->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); - _layoutProjectionGroup = new QVBoxLayout(); - _layoutComboProjection = new QHBoxLayout(); - _layoutComboProjection->addWidget(_comboProjection); - _layoutComboProjection->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutComboProjection); - _borderProjectionGroup = new QFrame; - _borderProjectionGroup->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - _borderProjectionGroup->setLayout(_layoutProjectionGroup); - _borderProjectionGroup->setVisible(true); - _layoutCBoxSpoutOutput= new QHBoxLayout(); - _layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); - _layoutCBoxSpoutOutput->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutCBoxSpoutOutput); - _layoutComboQuality = new QHBoxLayout(); - _labelQuality = new QLabel(); - _labelQuality->setText("Quality:"); - _layoutComboQuality->addWidget(_labelQuality); - _layoutComboQuality->addWidget(_comboQuality); - _layoutComboQuality->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutComboQuality); - _layoutFovH = new QHBoxLayout(); - _labelFovH = new QLabel(); - _labelFovH->setText("Horizontal FOV:"); - _layoutFovH->addWidget(_labelFovH); - _layoutFovH->addWidget(_lineFovH); - _layoutFovH->addStretch(1); - _layoutFovV = new QHBoxLayout(); - _labelFovV = new QLabel(); - _labelFovV->setText("Vertical FOV:"); - _layoutFovV->addWidget(_labelFovV); - _layoutFovV->addWidget(_lineFovV); - _layoutFovV->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutFovH); - _layoutProjectionGroup->addLayout(_layoutFovV); - _layoutHeightOffset = new QHBoxLayout(); - _labelHeightOffset = new QLabel(); - _labelHeightOffset->setText("Height Offset:"); - _layoutHeightOffset->addWidget(_labelHeightOffset); - _layoutHeightOffset->addWidget(_lineHeightOffset); - _layoutHeightOffset->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutHeightOffset); - _layoutCheckboxesFull2->addWidget(_borderProjectionGroup); - _layoutCheckboxesFull1->addLayout(_layoutCheckboxesFull2); - _layoutCheckboxesFull1->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutCheckboxesFull1); - _layoutWindowCtrl->addStretch(1); - _layoutFullWindow->addLayout(_layoutWindowCtrl); + { + QLabel* labelOffset = new QLabel(this); + QLabel* labelComma = new QLabel(this); + QHBoxLayout* layoutOffset = new QHBoxLayout(); + layoutOffset->addWidget(labelOffset); + labelOffset->setText("Offset:"); + labelOffset->setFixedWidth(55); + layoutOffset->addWidget(_offset_x); + layoutOffset->addWidget(labelComma); + layoutOffset->addWidget(_offset_y); + layoutOffset->addStretch(1); + labelComma->setText(","); + labelComma->setFixedWidth(9); + layoutWindowCtrl->addLayout(layoutOffset); + } + { + QHBoxLayout* layoutCheckboxesFull1 = new QHBoxLayout(); + QVBoxLayout* layoutCheckboxesFull2 = new QVBoxLayout(); + QHBoxLayout* layoutFullscreenButton = new QHBoxLayout(); + layoutFullscreenButton->addWidget(_fullscreenButton); + layoutFullscreenButton->addStretch(1); + layoutCheckboxesFull2->addLayout(layoutFullscreenButton); + QHBoxLayout* layoutCBoxWindowDecor = new QHBoxLayout(); + layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); + layoutCBoxWindowDecor->addStretch(1); + layoutCheckboxesFull2->addLayout(layoutCBoxWindowDecor); + QHBoxLayout* _layoutCBoxWebGui= new QHBoxLayout(); + _layoutCBoxWebGui->addWidget(_checkBoxWebGui); + _layoutCBoxWebGui->addStretch(1); + layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); + QVBoxLayout* layoutProjectionGroup = new QVBoxLayout(); + QHBoxLayout* layoutComboProjection = new QHBoxLayout(); + layoutComboProjection->addWidget(_comboProjection); + layoutComboProjection->addStretch(1); + layoutProjectionGroup->addLayout(layoutComboProjection); + QFrame* borderProjectionGroup = new QFrame; + borderProjectionGroup->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + borderProjectionGroup->setLayout(layoutProjectionGroup); + borderProjectionGroup->setVisible(true); + QHBoxLayout* layoutCBoxSpoutOutput= new QHBoxLayout(); + layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); + layoutCBoxSpoutOutput->addStretch(1); + layoutProjectionGroup->addLayout(layoutCBoxSpoutOutput); + QHBoxLayout* layoutComboQuality = new QHBoxLayout(); + _labelQuality = new QLabel(); + _labelQuality->setText("Quality:"); + layoutComboQuality->addWidget(_labelQuality); + layoutComboQuality->addWidget(_comboQuality); + layoutComboQuality->addStretch(1); + layoutProjectionGroup->addLayout(layoutComboQuality); + QHBoxLayout* layoutFovH = new QHBoxLayout(); + _labelFovH = new QLabel(); + _labelFovH->setText("Horizontal FOV:"); + layoutFovH->addWidget(_labelFovH); + layoutFovH->addWidget(_lineFovH); + layoutFovH->addStretch(1); + QHBoxLayout* layoutFovV = new QHBoxLayout(); + _labelFovV = new QLabel(); + _labelFovV->setText("Vertical FOV:"); + layoutFovV->addWidget(_labelFovV); + layoutFovV->addWidget(_lineFovV); + layoutFovV->addStretch(1); + layoutProjectionGroup->addLayout(layoutFovH); + layoutProjectionGroup->addLayout(layoutFovV); + QHBoxLayout* layoutHeightOffset = new QHBoxLayout(); + _labelHeightOffset = new QLabel(); + _labelHeightOffset->setText("Height Offset:"); + layoutHeightOffset->addWidget(_labelHeightOffset); + layoutHeightOffset->addWidget(_lineHeightOffset); + layoutHeightOffset->addStretch(1); + layoutProjectionGroup->addLayout(layoutHeightOffset); + layoutCheckboxesFull2->addWidget(borderProjectionGroup); + layoutCheckboxesFull1->addLayout(layoutCheckboxesFull2); + layoutCheckboxesFull1->addStretch(1); + layoutWindowCtrl->addLayout(layoutCheckboxesFull1); + } + layoutWindowCtrl->addStretch(1); + _layoutFullWindow->addLayout(layoutWindowCtrl); _comboProjection->setCurrentIndex(0); onProjectionChanged(0); @@ -243,14 +289,6 @@ void WindowControl::showWindowLabel(const bool show) { _labelWinNum->setVisible(show); } -void WindowControl::cleanupLayouts() { - int labelSize1 = _labelSize->width(); - int labelSize2 = _labelOffset->width(); - int labelWidthStandard = std::max(labelSize1, labelSize2); - _labelSize->setFixedWidth(labelWidthStandard); - _labelOffset->setFixedWidth(labelWidthStandard); -} - void WindowControl::onSizeXChanged(const QString& newText) { std::string x = newText.toStdString(); if (!x.empty()) { @@ -478,56 +516,6 @@ unsigned int WindowControl::monitorNum() { WindowControl::~WindowControl() { - delete _size_x; - delete _size_y; - delete _validatorSize_x; - delete _validatorSize_y; - delete _offset_x; - delete _offset_y; - delete _validatorOffset_x; - delete _validatorOffset_y; - delete _layoutName; - delete _labelName; - delete _windowName; - delete _labelWinNum; - delete _labelSize; - delete _labelDelim; - delete _layoutSize; - delete _labelOffset; - delete _labelComma; - delete _layoutOffset; - delete _checkBoxWindowDecor; - delete _checkBoxWebGui; - delete _checkBoxSpoutOutput; - delete _comboProjection; - delete _comboQuality; - delete _fullscreenButton; - delete _labelFovH; - delete _lineFovH; - delete _validatorFovH; - delete _labelFovV; - delete _lineFovV; - delete _validatorFovV; - delete _labelHeightOffset; - delete _lineHeightOffset; - delete _validatorHeightOffset; - delete _labelQuality; - delete _layoutFullscreenButton; - delete _layoutCBoxWindowDecor; - delete _layoutCBoxWebGui; - delete _layoutCBoxSpoutOutput; - delete _layoutComboProjection; - delete _layoutComboQuality; - delete _layoutFovH; - delete _layoutFovV; - delete _layoutHeightOffset; - delete _layoutProjectionGroup; - delete _borderProjectionGroup; - delete _layoutCheckboxesFull2; - delete _layoutCheckboxesFull1; - delete _layoutMonitorNum; - delete _layoutWinNum; - delete _layoutWindowCtrl; delete _layoutFullWindow; } From b62e1eca4522df71c2793145b6db21cd1aad1540 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Fri, 4 Feb 2022 22:05:38 -0700 Subject: [PATCH 53/93] Code review changes in progress --- .../ext/launcher/include/launcherwindow.h | 7 ++-- .../ext/launcher/include/sgctedit/display.h | 22 ++++------ .../launcher/include/sgctedit/filesupport.h | 18 ++++---- .../launcher/include/sgctedit/monitorbox.h | 29 ++++++------- .../launcher/include/sgctedit/orientation.h | 28 ++++--------- .../include/sgctedit/orientationdialog.h | 2 +- .../launcher/include/sgctedit/windowcontrol.h | 2 +- .../ext/launcher/src/launcherwindow.cpp | 6 +-- .../ext/launcher/src/sgctedit/display.cpp | 26 ++++++------ .../ext/launcher/src/sgctedit/filesupport.cpp | 34 +++++++-------- .../ext/launcher/src/sgctedit/monitorbox.cpp | 42 +++++++++---------- .../ext/launcher/src/sgctedit/orientation.cpp | 20 +++++---- .../src/sgctedit/orientationdialog.cpp | 9 ++-- .../ext/launcher/src/sgctedit/sgctedit.cpp | 5 +-- apps/OpenSpace/main.cpp | 1 - 15 files changed, 112 insertions(+), 139 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/launcherwindow.h b/apps/OpenSpace/ext/launcher/include/launcherwindow.h index caa6d107f0..4cc74a6f3e 100644 --- a/apps/OpenSpace/ext/launcher/include/launcherwindow.h +++ b/apps/OpenSpace/ext/launcher/include/launcherwindow.h @@ -25,11 +25,11 @@ #ifndef __OPENSPACE_UI_LAUNCHER___LAUNCHERWINDOW___H__ #define __OPENSPACE_UI_LAUNCHER___LAUNCHERWINDOW___H__ -#include #include -#include #include "sgctedit/sgctedit.h" +#include +#include #include namespace openspace::configuration { struct Configuration; } @@ -51,7 +51,7 @@ public: * \param parentItem The parent that contains this (and possibly other) children * in the tree structure. */ - LauncherWindow(QApplication& qtApp, bool profileEnabled, + LauncherWindow(bool profileEnabled, const openspace::configuration::Configuration& globalConfig, bool sgctConfigEnabled, std::string sgctConfigName, QWidget* parent); @@ -89,7 +89,6 @@ private: void populateProfilesList(std::string preset); void populateWindowConfigsList(std::string preset); - QApplication& _qApp; const std::string _assetPath; const std::string _userAssetPath; const std::string _configPath; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index f90ec83b42..bf0607631a 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -25,6 +25,10 @@ #ifndef __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ #define __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ +#include + +#include "windowcontrol.h" +#include "monitorbox.h" #include #include #include @@ -37,26 +41,17 @@ #include #include #include -#include - #include -#include -#include "windowcontrol.h" -#include "monitorbox.h" - - -class Display : public QWidget -{ +class Display : public QWidget { Q_OBJECT public: - explicit Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, + Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, const unsigned int nMaxWindows, const QString* winColors); ~Display(); - std::vector windowControls(); + std::vector windowControls() const; unsigned int nWindows() const; void uncheckWebGuiOptions(); - void setindowChangeCallback(std::function cb); private slots: void addWindow(); @@ -64,10 +59,8 @@ private slots: private: void initializeWindowControl(); - void removeWindowControl(); void initializeLayout(); void showWindows(); - void addDisplayLayout(unsigned int column, MonitorBox* monBox, QVBoxLayout* layout); MonitorBox* _monBox; std::vector& _monitorResolutions; QRect _widgetDims = {0, 0, 400, 400}; @@ -80,7 +73,6 @@ private: QPushButton* _addWindowButton = nullptr; QPushButton* _removeWindowButton = nullptr; unsigned int _monitorIdx = 0; - QVBoxLayout* _layout = nullptr; std::vector _winCtrlLayouts; std::vector _layoutWindowWrappers; std::vector _frameBorderLines; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index 817d6800cf..1280e7cba2 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -25,25 +25,22 @@ #ifndef __OPENSPACE_UI_LAUNCHER___FILESUPPORT___H__ #define __OPENSPACE_UI_LAUNCHER___FILESUPPORT___H__ +#include + +#include +#include +#include #include #include #include #include #include -#include - #include -#include -#include -#include -#include - -class FileSupport : public QWidget -{ +class FileSupport : public QWidget { Q_OBJECT public: - explicit FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, + FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, Display* display, Orientation* orientation, std::vector& windowList, sgct::config::Cluster& cluster, std::function cb); @@ -70,6 +67,7 @@ private: void saveWindowsDimensions(WindowControl* wCtrl); void saveWindowsWebGui(unsigned int wIdx); void saveWindowsFullScreen(WindowControl* wCtrl); + QHBoxLayout* _layoutButtonBox = nullptr; QPushButton* _saveButton = nullptr; QPushButton* _cancelButton = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index ebcdddfd3a..e3e8a1ddff 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -25,6 +25,9 @@ #ifndef __OPENSPACE_UI_LAUNCHER___MONITORBOX___H__ #define __OPENSPACE_UI_LAUNCHER___MONITORBOX___H__ +#include + +#include "windowcontrol.h" #include #include #include @@ -32,22 +35,15 @@ #include #include #include -#include - #include #include #include -#include "windowcontrol.h" - - -class MonitorBox : public QWidget -{ +class MonitorBox : public QWidget { Q_OBJECT public: - explicit MonitorBox(QRect widgetDims, std::vector monitorResolution, + MonitorBox(QRect widgetDims, std::vector monitorResolution, unsigned int nWindows, QString* winColors); - ~MonitorBox(); void mapMonitorResolutionToWidgetCoordinates(); void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& w); @@ -56,18 +52,19 @@ public: const QRectF& newDimensions); protected: - void paintEvent(QPaintEvent *event) override; + void paintEvent(QPaintEvent* event) override; private: void paintWidgetBorder(QPainter& painter, const int width, const int height); void paintMonitorBackgrounds(QPainter& painter); - void paintWindow(QPainter& painter, const unsigned int winIdx); + void paintWindow(QPainter& painter, const size_t winIdx); void paintWindowBeyondBounds(QPainter& painter, const unsigned int winIdx); void paintWindowNumber(QPainter& painter, const unsigned int winIdx); void setPenSpecificToWindow(QPainter& painter, const unsigned int windowIdx, bool visibleBorder); void computeScaledResolution_landscape(const float aspectRatio, const float maxWidth); void computeScaledResolution_portrait(const float aspectRatio, const float maxHeight); + unsigned int _maxNumMonitors = 2; QRectF _monitorWidgetSize; QRectF _monitorBoundaryRect; @@ -76,18 +73,16 @@ private: std::vector _monitorDimensionsScaled; std::vector _windowResolutions; std::vector _windowRendering = { - {0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0} + {0.f, 0.f, 0.f, 0.f}, + {0.f, 0.f, 0.f, 0.f}, + {0.f, 0.f, 0.f, 0.f}, + {0.f, 0.f, 0.f, 0.f} }; unsigned int _nWindows = 1; QString* _colorsForWindows; int _alphaWindowOpacity = 170; float _monitorScaleFactor = 1.0; - float _offset[2] = {10.0, 10.0}; bool _showLabel = false; - float _marginFractionOfWidgetSize = 0.025; float _marginWidget = 5.0; std::vector _monitorOffsets; }; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index cdb9761d62..cc8c6d111f 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -25,31 +25,21 @@ #ifndef __OPENSPACE_UI_LAUNCHER___ORIENTATION___H__ #define __OPENSPACE_UI_LAUNCHER___ORIENTATION___H__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include #include #include #include +#include +#include +#include +#include +#include - -class Orientation : public QWidget -{ +class Orientation : public QWidget { Q_OBJECT public: - explicit Orientation(); + Orientation(); ~Orientation(); void addButtonToLayout(QVBoxLayout* parentLayout); sgct::quat orientationValue(); @@ -59,8 +49,8 @@ private slots: void orientationDialog(); private: - sgct::quat _orientationValue = {0.0, 0.0, 0.0, 0.0}; - OrientationDialog* _orientationDialog = nullptr; + sgct::quat _orientationValue = {0.f, 0.f, 0.f, 0.f}; + OrientationDialog _orientationDialog; QHBoxLayout* _layoutOrientationFull = nullptr; QCheckBox* _checkBoxVsync = nullptr; }; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h index b4b88bd321..1c8443a75b 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h @@ -49,7 +49,7 @@ class OrientationDialog : public QDialog { Q_OBJECT public: - explicit OrientationDialog(sgct::quat& orientation, QWidget* parent); + OrientationDialog(sgct::quat& orientation, QWidget* parent); private slots: void cancel(); diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 545df93009..f2353e0e8e 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -50,7 +50,7 @@ class WindowControl : public QWidget { Q_OBJECT public: - explicit WindowControl(unsigned int nMonitors, unsigned int monitorIndex, + WindowControl(unsigned int nMonitors, unsigned int monitorIndex, unsigned int windowIndex, std::vector& monitorDims, const QString* winColors, QWidget *parent = nullptr); ~WindowControl(); diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 24cedb499d..e6aba73710 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -164,13 +164,11 @@ namespace { using namespace openspace; -LauncherWindow::LauncherWindow(QApplication& qtApp, - bool profileEnabled, +LauncherWindow::LauncherWindow(bool profileEnabled, const configuration::Configuration& globalConfig, bool sgctConfigEnabled, std::string sgctConfigName, QWidget* parent) : QMainWindow(parent) - , _qApp(qtApp) , _assetPath(absPath(globalConfig.pathTokens.at("ASSETS")).string() + '/') , _userAssetPath(absPath(globalConfig.pathTokens.at("USER_ASSETS")).string() + '/') , _configPath(absPath(globalConfig.pathTokens.at("CONFIG")).string() + '/') @@ -551,7 +549,7 @@ void LauncherWindow::openProfileEditor(const std::string& profile, bool isUserPr } void LauncherWindow::openWindowEditor() { - QList screenList = _qApp.screens(); + QList screenList = qApp->screens(); if (screenList.length() == 0) { LERRORC( "LauncherWindow", diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index ed4394146f..051dececbd 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -22,13 +22,14 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include "sgctedit/display.h" + +#include "sgctedit/monitorbox.h" +#include "sgctedit/windowcontrol.h" #include #include #include #include -#include "sgctedit/monitorbox.h" -#include "sgctedit/windowcontrol.h" -#include "sgctedit/display.h" Display::Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, const unsigned int nMaxWindows, const QString* winColors) @@ -54,20 +55,19 @@ Display::~Display() { for (auto w : _windowControl) { delete w; } - delete _layout; } void Display::initializeLayout() { - _layout = new QVBoxLayout(this); + QVBoxLayout* layout = new QVBoxLayout(this); { - QHBoxLayout* layoutMonButton = new QHBoxLayout(); + QHBoxLayout* layoutMonButton = new QHBoxLayout; layoutMonButton->addWidget(_removeWindowButton); layoutMonButton->addStretch(1); layoutMonButton->addWidget(_addWindowButton); - _layout->addLayout(layoutMonButton); + layout->addLayout(layoutMonButton); } - QHBoxLayout* layoutWindows = new QHBoxLayout(); - _layout->addStretch(); + QHBoxLayout* layoutWindows = new QHBoxLayout; + layout->addStretch(); for (unsigned int i = 0; i < _nMaxWindows; ++i) { _winCtrlLayouts.push_back(_windowControl[i]->initializeLayout()); @@ -82,10 +82,10 @@ void Display::initializeLayout() { } _nWindowsDisplayed = 1; showWindows(); - _layout->addLayout(layoutWindows); + layout->addLayout(layoutWindows); } -std::vector Display::windowControls() { +std::vector Display::windowControls() const { return _windowControl; } @@ -108,10 +108,10 @@ void Display::removeWindow() { } void Display::showWindows() { - for (unsigned int i = 0; i < _layoutWindowWrappers.size(); ++i) { + for (size_t i = 0; i < _layoutWindowWrappers.size(); ++i) { _layoutWindowWrappers[i]->setVisible(i < _nWindowsDisplayed); } - for (unsigned int i = 0; i < _frameBorderLines.size(); ++i) { + for (size_t i = 0; i < _frameBorderLines.size(); ++i) { _frameBorderLines[i]->setVisible(i < (_nWindowsDisplayed - 1)); } _removeWindowButton->setEnabled(_nWindowsDisplayed > 1); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 441ea8a0c0..64bca8beb4 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -35,12 +35,12 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL , _windowList(windowList) , _finishedCallback(cb) { - QVBoxLayout* layoutFullVertical = new QVBoxLayout(); - _lineFilename = new QLineEdit(); + QVBoxLayout* layoutFullVertical = new QVBoxLayout; + _lineFilename = new QLineEdit; _lineFilename->setFixedWidth(190); { - QHBoxLayout* layoutFilename = new QHBoxLayout(); - QLabel* labelFilename = new QLabel(); + QHBoxLayout* layoutFilename = new QHBoxLayout; + QLabel* labelFilename = new QLabel; labelFilename->setText("Filename: "); layoutFilename->addStretch(1); layoutFilename->addWidget(labelFilename); @@ -50,11 +50,11 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL } _saveButton = new QPushButton("Save"); _saveButton->setToolTip("Save global orientation changes"); - connect(_saveButton, SIGNAL(released()), this, SLOT(save())); + connect(_saveButton, &QPushButton::released, this, &FileSupport::save); _saveButton->setEnabled(false); _cancelButton = new QPushButton("Cancel"); _cancelButton->setToolTip("Cancel global orientation changes"); - connect(_cancelButton, SIGNAL(released()), this, SLOT(cancel())); + connect(_cancelButton, &QPushButton::released, this, &FileSupport::cancel); { QHBoxLayout* layoutButtonBox = new QHBoxLayout; layoutButtonBox->addStretch(1); @@ -63,8 +63,7 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL layoutFullVertical->addLayout(layoutButtonBox); } parentLayout->addLayout(layoutFullVertical); - connect(_lineFilename, SIGNAL(textEdited(const QString&)), this, - SLOT(filenameEdited(const QString&))); + connect(_lineFilename, &QLineEdit::textEdited, this, &FileSupport::filenameEdited); } void FileSupport::saveCluster() { @@ -85,15 +84,15 @@ void FileSupport::saveCluster() { void FileSupport::saveUser() { if (_orientationWidget) { sgct::config::User user; - user.eyeSeparation = 0.065; - user.position = {0.0, 0.0, 4.0}; + user.eyeSeparation = 0.065f; + user.position = {0.0f, 0.0f, 4.0f}; _cluster.users.push_back(user); } } bool FileSupport::isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims) { - sgct::ivec2 mDims = {_monitors[monitorIdx].width(), _monitors[monitorIdx].height()}; - return ((mDims.x == wDims.x) && (mDims.y == wDims.y)); + return (_monitors[monitorIdx].width() == wDims.x && + _monitors[monitorIdx].height() == wDims.y); } bool FileSupport::findGuiWindow(unsigned int& foundWindowIndex) { @@ -132,10 +131,11 @@ void FileSupport::saveWindows() { } void FileSupport::saveWindowsViewports() { - _windowList.back().viewports.push_back(sgct::config::Viewport()); - _windowList.back().viewports.back().isTracked = true; - _windowList.back().viewports.back().position = {0.0, 0.0}; - _windowList.back().viewports.back().size = {1.0, 1.0}; + sgct::config::Viewport vp; + vp.isTracked = true; + vp.position = {0.f, 0.f}; + vp.size = {1.f, 1.f}; + _windowList.back().viewports.push_back(std::move(vp)); } void FileSupport::saveWindowsDimensions(WindowControl* wCtrl) { @@ -147,8 +147,6 @@ void FileSupport::saveWindowsDimensions(WindowControl* wCtrl) { } void FileSupport::saveWindowsWebGui(unsigned int wIdx) { - _windowList.back().draw2D = true; - _windowList.back().draw3D = true; _windowList.back().viewports.back().isTracked = true; unsigned int webGuiWindowIndex; bool isOneOfWindowsSetAsWebGui = findGuiWindow(webGuiWindowIndex); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 387acf233e..466596f081 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -24,8 +24,10 @@ #include "sgctedit/monitorbox.h" +constexpr float MarginFractionOfWidgetSize = 0.025; + MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, - unsigned int nWindows, QString* winColors) + unsigned int nWindows, QString* winColors) : _monitorWidgetSize(widgetDims) , _monitorResolution(monitorResolution) , _nWindows(nWindows) @@ -36,12 +38,7 @@ MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, mapMonitorResolutionToWidgetCoordinates(); } -MonitorBox::~MonitorBox() -{ -} - -void MonitorBox::paintEvent(QPaintEvent *event) -{ +void MonitorBox::paintEvent(QPaintEvent* event) { Q_UNUSED(event); QPainter painter(this); QPen pen = painter.pen(); @@ -60,8 +57,9 @@ void MonitorBox::paintEvent(QPaintEvent *event) } void MonitorBox::paintWidgetBorder(QPainter& painter, const int width, const int height) { + constexpr int Radius = 10; painter.setPen(QPen(Qt::gray, 4)); - painter.drawRoundedRect(0, 0, width - 1, height - 1, 10, 10); + painter.drawRoundedRect(0, 0, width - 1, height - 1, Radius, Radius); } void MonitorBox::paintMonitorBackgrounds(QPainter& painter) { @@ -75,8 +73,10 @@ void MonitorBox::paintMonitorBackgrounds(QPainter& painter) { brush.setStyle(Qt::SolidPattern); painter.fillRect(_monitorDimensionsScaled[i], brush); if (_showLabel) { - QPointF textPos = QPointF(_monitorDimensionsScaled[i].left() + 5, - _monitorDimensionsScaled[i].top() + 18); + QPointF textPos = QPointF( + _monitorDimensionsScaled[i].left() + 5, + _monitorDimensionsScaled[i].top() + 18 + ); painter.drawText(textPos, QString::fromStdString(std::to_string(i + 1))); } } @@ -93,7 +93,7 @@ void MonitorBox::paintWindowBeyondBounds(QPainter& painter, const unsigned int w painter.setBrush(Qt::NoBrush); } -void MonitorBox::paintWindow(QPainter& painter, const unsigned int winIdx) { +void MonitorBox::paintWindow(QPainter& painter, const size_t winIdx) { setPenSpecificToWindow(painter, winIdx, true); if (winIdx <= _windowRendering.size()) { painter.drawRect(_windowRendering[winIdx]); @@ -129,9 +129,9 @@ void MonitorBox::windowDimensionsChanged(unsigned int monitorIdx, unsigned int w void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { QSize virtualDesktopResolution; - float maxWidth = 0.0; - float maxHeight = 0.0; - for (auto m : _monitorResolution) { + float maxWidth = 0.f; + float maxHeight = 0.f; + for (const QRect& m : _monitorResolution) { if ((m.x() + m.width()) > maxWidth) { maxWidth = m.x() + m.width(); } @@ -154,15 +154,15 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { _monitorResolution[m].height() * _monitorScaleFactor, }); } - this->update(); + update(); } void MonitorBox::computeScaledResolution_landscape(const float aspectRatio, const float maxWidth) { - _marginWidget = _monitorWidgetSize.width() * _marginFractionOfWidgetSize; + _marginWidget = _monitorWidgetSize.width() * MarginFractionOfWidgetSize; float virtualWidth = _monitorWidgetSize.width() - * (1.0 - _marginFractionOfWidgetSize * 2.0); + * (1.0 - MarginFractionOfWidgetSize * 2.0); _monitorScaleFactor = virtualWidth / maxWidth; float newHeight = virtualWidth / aspectRatio; for (size_t m = 0; m < _monitorResolution.size(); ++m) { @@ -177,9 +177,9 @@ void MonitorBox::computeScaledResolution_landscape(const float aspectRatio, void MonitorBox::computeScaledResolution_portrait(const float aspectRatio, const float maxHeight) { - _marginWidget = _monitorWidgetSize.height() * _marginFractionOfWidgetSize; + _marginWidget = _monitorWidgetSize.height() * MarginFractionOfWidgetSize; float virtualHeight = _monitorWidgetSize.height() - * (1.0 - _marginFractionOfWidgetSize * 2.0); + * (1.0 - MarginFractionOfWidgetSize * 2.0); _monitorScaleFactor = virtualHeight / maxHeight; float newWidth = virtualHeight * aspectRatio; for (size_t m = 0; m < _monitorResolution.size(); ++m) { @@ -194,7 +194,7 @@ void MonitorBox::computeScaledResolution_portrait(const float aspectRatio, void MonitorBox::setNumWindowsDisplayed(unsigned int nWindows) { if (_nWindows != nWindows) { _nWindows = nWindows; - this->update(); + update(); } } @@ -212,5 +212,5 @@ void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, wF.width() * _monitorScaleFactor, wF.height() * _monitorScaleFactor }; - this->update(); + update(); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index 8ec4cbdd60..c8bb0444c5 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -22,16 +22,17 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include "sgctedit/display.h" #include "sgctedit/orientation.h" + +#include "sgctedit/display.h" #include "sgctedit/orientationdialog.h" Orientation::Orientation() + : _orientationDialog(_orientationValue, this) { - _orientationDialog = new OrientationDialog(_orientationValue, this); - _layoutOrientationFull = new QHBoxLayout(); + _layoutOrientationFull = new QHBoxLayout; { - QVBoxLayout* layoutOrientationControls = new QVBoxLayout(); + QVBoxLayout* layoutOrientationControls = new QVBoxLayout; QPushButton* orientationButton = new QPushButton("Global Orientation"); _checkBoxVsync = new QCheckBox("VSync All Windows", this); layoutOrientationControls->addWidget(_checkBoxVsync); @@ -39,8 +40,12 @@ Orientation::Orientation() _layoutOrientationFull->addStretch(1); _layoutOrientationFull->addLayout(layoutOrientationControls); _layoutOrientationFull->addStretch(1); - connect(orientationButton, SIGNAL(released()), this, - SLOT(orientationDialog())); + connect( + orientationButton, + &QPushButton::released, + this, + &Orientation::orientationDialog + ); } } @@ -49,7 +54,7 @@ void Orientation::addButtonToLayout(QVBoxLayout* parentLayout) { } void Orientation::orientationDialog() { - _orientationDialog->exec(); + _orientationDialog.exec(); } sgct::quat Orientation::orientationValue() { @@ -62,6 +67,5 @@ bool Orientation::vsyncValue() { Orientation::~Orientation() { - delete _orientationDialog; delete _layoutOrientationFull; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 93334b824f..683df94b94 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -22,9 +22,10 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include "sgctedit/display.h" #include "sgctedit/orientationdialog.h" +#include "sgctedit/display.h" + OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) : QDialog(parent) , _orientationValue(orientation) @@ -52,21 +53,21 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) { QLabel* labelPitch = new QLabel(this); labelPitch->setText("Pitch: "); - QHBoxLayout* layoutPitch = new QHBoxLayout(); + QHBoxLayout* layoutPitch = new QHBoxLayout; layoutPitch->addStretch(1); layoutPitch->addWidget(labelPitch); layoutPitch->addWidget(_linePitch); layoutWindow->addLayout(layoutPitch); QLabel* labelRoll = new QLabel(this); labelRoll ->setText("Roll: "); - QHBoxLayout* layoutRoll = new QHBoxLayout(); + QHBoxLayout* layoutRoll = new QHBoxLayout; layoutRoll->addStretch(1); layoutRoll->addWidget(labelRoll); layoutRoll->addWidget(_lineRoll); layoutWindow->addLayout(layoutRoll); QLabel* labelYaw = new QLabel(this); labelYaw ->setText("Yaw: "); - QHBoxLayout* layoutYaw = new QHBoxLayout(); + QHBoxLayout* layoutYaw = new QHBoxLayout; layoutYaw->addStretch(1); layoutYaw->addWidget(labelYaw); layoutYaw->addWidget(_lineYaw); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index faad9a4569..2477f637bf 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -56,7 +56,6 @@ void SgctEdit::createWidgets() { QVBoxLayout* layoutMainV = new QVBoxLayout(this); QHBoxLayout* layoutMainH = new QHBoxLayout; _orientationWidget = new Orientation(); - { _monBox = new MonitorBox( _monitorWidgetSize, @@ -64,7 +63,7 @@ void SgctEdit::createWidgets() { _nMaxWindows, _colorsForWindows ); - QHBoxLayout* layoutMonBox = new QHBoxLayout(); + QHBoxLayout* layoutMonBox = new QHBoxLayout; layoutMonBox->addStretch(1); layoutMonBox->addWidget(_monBox); layoutMonBox->addStretch(1); @@ -98,7 +97,7 @@ void SgctEdit::createWidgets() { void SgctEdit::addDisplayLayout(MonitorBox* monBox, QHBoxLayout* layout) { - _displayLayout = new QVBoxLayout(); + _displayLayout = new QVBoxLayout; _displayWidget = new Display( monBox, _monitorSizeList, diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 23df214434..7757d0b47e 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -1208,7 +1208,6 @@ int main(int argc, char* argv[]) { #endif // __APPLE__ LauncherWindow win( - app, !hasProfile, *global::configuration, !hasSGCTConfig, From 4f40bdb8ca9e3b4a703ff9cfd993f8278fe8eafd Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Mon, 7 Feb 2022 15:53:35 -0700 Subject: [PATCH 54/93] More code review changes in progress --- .../ext/launcher/include/sgctedit/display.h | 10 ++++----- .../launcher/include/sgctedit/filesupport.h | 5 +++-- .../launcher/include/sgctedit/monitorbox.h | 4 ++-- .../ext/launcher/include/sgctedit/sgctedit.h | 20 ++++++++++-------- .../launcher/include/sgctedit/windowcontrol.h | 20 +++++------------- .../ext/launcher/src/sgctedit/display.cpp | 14 ++++++------- .../ext/launcher/src/sgctedit/filesupport.cpp | 2 +- .../ext/launcher/src/sgctedit/monitorbox.cpp | 2 +- .../src/sgctedit/orientationdialog.cpp | 4 ++-- .../ext/launcher/src/sgctedit/sgctedit.cpp | 21 +++++++------------ .../launcher/src/sgctedit/windowcontrol.cpp | 9 ++++---- 11 files changed, 48 insertions(+), 63 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index bf0607631a..63880ca020 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -21,7 +21,6 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ - #ifndef __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ #define __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ @@ -46,8 +45,9 @@ class Display : public QWidget { Q_OBJECT public: - Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, - const unsigned int nMaxWindows, const QString* winColors); + Display(std::shared_ptr monitorRenderBox, + std::vector& monitorSizeList, const unsigned int nMaxWindows, + const std::array winColors); ~Display(); std::vector windowControls() const; unsigned int nWindows() const; @@ -61,14 +61,14 @@ private: void initializeWindowControl(); void initializeLayout(); void showWindows(); - MonitorBox* _monBox; + std::shared_ptr _monBox; std::vector& _monitorResolutions; QRect _widgetDims = {0, 0, 400, 400}; unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; unsigned int _nMaxWindows = 3; unsigned int _nMonitors = 1; - const QString* _winColors; + const std::array _winColors; std::vector _windowControl; QPushButton* _addWindowButton = nullptr; QPushButton* _removeWindowButton = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index 1280e7cba2..c3fb68c5cc 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -35,13 +35,14 @@ #include #include #include +#include #include class FileSupport : public QWidget { Q_OBJECT public: FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, - Display* display, Orientation* orientation, + std::shared_ptr display, Orientation* orientation, std::vector& windowList, sgct::config::Cluster& cluster, std::function cb); std::string saveFilename(); @@ -71,7 +72,7 @@ private: QHBoxLayout* _layoutButtonBox = nullptr; QPushButton* _saveButton = nullptr; QPushButton* _cancelButton = nullptr; - Display* _displayWidget; + std::shared_ptr _displayWidget; Orientation* _orientationWidget; std::vector& _monitors; sgct::config::Cluster& _cluster; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index e3e8a1ddff..3aa6597efa 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -43,7 +43,7 @@ class MonitorBox : public QWidget { Q_OBJECT public: MonitorBox(QRect widgetDims, std::vector monitorResolution, - unsigned int nWindows, QString* winColors); + unsigned int nWindows, std::array winColors); void mapMonitorResolutionToWidgetCoordinates(); void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& w); @@ -79,7 +79,7 @@ private: {0.f, 0.f, 0.f, 0.f} }; unsigned int _nWindows = 1; - QString* _colorsForWindows; + const std::array _colorsForWindows; int _alphaWindowOpacity = 170; float _monitorScaleFactor = 1.0; bool _showLabel = false; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index 5a6f11483c..0fe1cbef92 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -25,9 +25,14 @@ #ifndef __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ #define __OPENSPACE_UI_LAUNCHER___SGCTEDIT___H__ +#include + +#include +#include +#include +#include #include #include -#include #include #include #include @@ -38,12 +43,9 @@ #include #include #include +#include #include #include -#include -#include -#include -#include class SgctEdit final : public QDialog { @@ -52,18 +54,18 @@ public: SgctEdit(QWidget* parent, std::vector& windowList, sgct::config::Cluster& cluster, const QList screenList); ~SgctEdit(); - void addDisplayLayout(MonitorBox* monBox, QHBoxLayout* layout); + void addDisplayLayout(QHBoxLayout* layout); void createWidgets(); bool wasSaved() const; std::string saveFilename(); private: void systemMonitorConfiguration(const QList screenList); - MonitorBox* _monBox = nullptr; + std::shared_ptr _monBox = nullptr; std::vector _monitorSizeList; QVBoxLayout* _displayLayout = nullptr; QFrame* _displayFrame = nullptr; - Display* _displayWidget = nullptr; + std::shared_ptr _displayWidget = nullptr; QRect _monitorWidgetSize = {0, 0, 500, 500}; FileSupport* _fileSupportWidget = nullptr; Orientation* _orientationWidget = nullptr; @@ -71,7 +73,7 @@ private: std::vector& _windowList; bool _saveSelected = false; unsigned int _nMaxWindows = 3; - QString _colorsForWindows[4] = { + const std::array _colorsForWindows = { "#2B9EC3", "#FCAB10", "#44AF69", diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index f2353e0e8e..3c0c08289f 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -21,30 +21,20 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ - #ifndef __OPENSPACE_UI_LAUNCHER___WINDOWCONTROL___H__ #define __OPENSPACE_UI_LAUNCHER___WINDOWCONTROL___H__ +#include + +#include #include -#include #include -#include -#include #include #include #include #include -#include -#include #include -#include -#include -#include - #include -#include -#include - class WindowControl : public QWidget { @@ -52,7 +42,7 @@ Q_OBJECT public: WindowControl(unsigned int nMonitors, unsigned int monitorIndex, unsigned int windowIndex, std::vector& monitorDims, - const QString* winColors, QWidget *parent = nullptr); + const std::array winColors, QWidget *parent = nullptr); ~WindowControl(); void setDimensions(const QRectF& dimensions); void setWindowChangeCallback(std::function cb); @@ -148,7 +138,7 @@ private: unsigned int _index = 0; std::vector& _monitorResolutions; int _maxWindowSizePixels = 10000; - const QString* _colorsForWindows = nullptr; + const std::array _colorsForWindows; QVBoxLayout* _layoutFullWindow = nullptr; QLabel* _labelWinNum = nullptr; QLineEdit* _size_x = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 051dececbd..79ab603056 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -31,8 +31,9 @@ #include #include -Display::Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeList, - const unsigned int nMaxWindows, const QString* winColors) +Display::Display(std::shared_ptr monitorRenderBox, + std::vector& monitorSizeList, const unsigned int nMaxWindows, + const std::array winColors) : _monBox(monitorRenderBox) , _monitorResolutions(monitorSizeList) , _nMaxWindows(nMaxWindows) @@ -45,14 +46,13 @@ Display::Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeLi for (unsigned int i = 0; i < _nMaxWindows; ++i) { initializeWindowControl(); } - connect(_addWindowButton, SIGNAL(released()), this, SLOT(addWindow())); - connect(_removeWindowButton, SIGNAL(released()), this, SLOT(removeWindow())); + connect(_addWindowButton, &QPushButton::released, this, &Display::addWindow); + connect(_removeWindowButton, &QPushButton::released, this, &Display::removeWindow); initializeLayout(); } Display::~Display() { - delete _monBox; - for (auto w : _windowControl) { + for (WindowControl* w : _windowControl) { delete w; } } @@ -116,7 +116,7 @@ void Display::showWindows() { } _removeWindowButton->setEnabled(_nWindowsDisplayed > 1); _addWindowButton->setEnabled(_nWindowsDisplayed != _nMaxWindows); - for (auto w : _windowControl) { + for (WindowControl* w : _windowControl) { w->showWindowLabel(_nWindowsDisplayed > 1); } _monBox->setNumWindowsDisplayed(_nWindowsDisplayed); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 64bca8beb4..00f05c603b 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -25,7 +25,7 @@ #include "sgctedit/filesupport.h" FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, - Display* display, Orientation* orientation, + std::shared_ptr display, Orientation* orientation, std::vector& windowList, sgct::config::Cluster& cluster, std::function cb) : _displayWidget(display) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 466596f081..8360953911 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -27,7 +27,7 @@ constexpr float MarginFractionOfWidgetSize = 0.025; MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, - unsigned int nWindows, QString* winColors) + unsigned int nWindows, std::array winColors) : _monitorWidgetSize(widgetDims) , _monitorResolution(monitorResolution) , _nWindows(nWindows) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 683df94b94..0b89be0df5 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -83,8 +83,8 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) buttonCancel->setToolTip("Cancel global orientation changes"); layoutButtonBox->addWidget(buttonCancel); layoutButtonBox->addStretch(1); - connect(buttonSave, SIGNAL(released()), this, SLOT(ok())); - connect(buttonCancel, SIGNAL(released()), this, SLOT(cancel())); + connect(buttonSave, &QPushButton::released, this, &OrientationDialog::ok); + connect(buttonCancel, &QPushButton::released, this, &OrientationDialog::cancel); layoutWindow->addLayout(layoutButtonBox); } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 2477f637bf..abe0a8efc1 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -57,7 +57,7 @@ void SgctEdit::createWidgets() { QHBoxLayout* layoutMainH = new QHBoxLayout; _orientationWidget = new Orientation(); { - _monBox = new MonitorBox( + _monBox = std::make_shared( _monitorWidgetSize, _monitorSizeList, _nMaxWindows, @@ -65,12 +65,12 @@ void SgctEdit::createWidgets() { ); QHBoxLayout* layoutMonBox = new QHBoxLayout; layoutMonBox->addStretch(1); - layoutMonBox->addWidget(_monBox); + layoutMonBox->addWidget(_monBox.get()); layoutMonBox->addStretch(1); layoutMainV->addLayout(layoutMonBox); _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _monBox->setFixedSize(_monitorWidgetSize.width(), _monitorWidgetSize.height()); - addDisplayLayout(_monBox, layoutMainH); + addDisplayLayout(layoutMainH); } { layoutMainV->addLayout(layoutMainH); @@ -95,17 +95,16 @@ void SgctEdit::createWidgets() { } } -void SgctEdit::addDisplayLayout(MonitorBox* monBox, QHBoxLayout* layout) -{ +void SgctEdit::addDisplayLayout(QHBoxLayout* layout) { _displayLayout = new QVBoxLayout; - _displayWidget = new Display( - monBox, + _displayWidget = std::make_shared( + _monBox, _monitorSizeList, _nMaxWindows, _colorsForWindows ); _displayFrame = new QFrame; - _displayLayout->addWidget(_displayWidget); + _displayLayout->addWidget(_displayWidget.get()); _displayFrame->setLayout(_displayLayout); _displayFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); layout->addWidget(_displayFrame); @@ -126,13 +125,7 @@ SgctEdit::~SgctEdit() { if (_fileSupportWidget) { delete _fileSupportWidget; } - if (_displayWidget) { - delete _displayWidget; - } if (_displayLayout) { delete _displayLayout; } - if (_displayFrame) { - delete _displayFrame; - } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 58e2712c4e..c99cdd29ca 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -27,8 +27,9 @@ #include "sgctedit/windowcontrol.h" WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, - const unsigned int windowIndex, std::vector& monitorDims, - const QString* winColors, QWidget *parent) + const unsigned int windowIndex, + std::vector& monitorDims, + const std::array winColors, QWidget *parent) : QWidget(parent) , _nMonitors(nMonitors) , _monIndex(monitorIndex) @@ -150,9 +151,7 @@ QVBoxLayout* WindowControl::initializeLayout() { _labelWinNum = new QLabel(); _labelWinNum->setText("Window " + QString::number(_index + 1)); - QString colorStr = "QLabel { color : "; - colorStr += _colorsForWindows ? _colorsForWindows[_index] : "#FFFFFF"; - colorStr += "; }"; + QString colorStr = "QLabel { color : " + _colorsForWindows[_index] + "; }"; _labelWinNum->setStyleSheet(colorStr); QHBoxLayout* layoutWinNum = new QHBoxLayout(); From 364f80c8310d23fcdb4f76ce07d08bc048442ce1 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Tue, 8 Feb 2022 15:24:23 -0700 Subject: [PATCH 55/93] Additional code review changes --- .../ext/launcher/include/sgctedit/display.h | 1 - .../launcher/include/sgctedit/orientation.h | 7 ++--- .../include/sgctedit/orientationdialog.h | 21 +++----------- .../ext/launcher/include/sgctedit/sgctedit.h | 15 ++++------ .../launcher/include/sgctedit/windowcontrol.h | 12 +++----- .../ext/launcher/src/sgctedit/display.cpp | 19 +++++++------ .../ext/launcher/src/sgctedit/filesupport.cpp | 10 +++---- .../ext/launcher/src/sgctedit/orientation.cpp | 10 ++----- .../src/sgctedit/orientationdialog.cpp | 12 ++++---- .../ext/launcher/src/sgctedit/sgctedit.cpp | 28 +++++++++---------- .../launcher/src/sgctedit/windowcontrol.cpp | 23 ++++----------- 11 files changed, 57 insertions(+), 101 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 63880ca020..3e9a9e2540 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -67,7 +67,6 @@ private: unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; unsigned int _nMaxWindows = 3; - unsigned int _nMonitors = 1; const std::array _winColors; std::vector _windowControl; QPushButton* _addWindowButton = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index cc8c6d111f..ee13404cdf 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -31,19 +31,16 @@ #include #include #include -#include #include -#include #include class Orientation : public QWidget { Q_OBJECT public: Orientation(); - ~Orientation(); void addButtonToLayout(QVBoxLayout* parentLayout); - sgct::quat orientationValue(); - bool vsyncValue(); + sgct::quat orientationValue() const; + bool vsyncValue() const; private slots: void orientationDialog(); diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h index 1c8443a75b..e026c7bbaa 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h @@ -25,28 +25,15 @@ #ifndef __OPENSPACE_UI_LAUNCHER___ORIENTATIONDIALOG___H__ #define __OPENSPACE_UI_LAUNCHER___ORIENTATIONDIALOG___H__ -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +class QWidget; -class OrientationDialog : public QDialog -{ +class OrientationDialog : public QDialog { Q_OBJECT public: OrientationDialog(sgct::quat& orientation, QWidget* parent); diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index 0fe1cbef92..dd77fbb808 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -33,26 +33,20 @@ #include #include #include -#include #include -#include -#include -#include -#include #include -#include -#include -#include #include #include #include +class QWidget; + class SgctEdit final : public QDialog { Q_OBJECT public: SgctEdit(QWidget* parent, std::vector& windowList, - sgct::config::Cluster& cluster, const QList screenList); + sgct::config::Cluster& cluster, const QList& screenList); ~SgctEdit(); void addDisplayLayout(QHBoxLayout* layout); void createWidgets(); @@ -60,7 +54,8 @@ public: std::string saveFilename(); private: - void systemMonitorConfiguration(const QList screenList); + void systemMonitorConfiguration(const QList& screenList); + std::shared_ptr _monBox = nullptr; std::vector _monitorSizeList; QVBoxLayout* _displayLayout = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 3c0c08289f..4fefaff990 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -32,17 +32,15 @@ #include #include #include -#include #include #include -class WindowControl : public QWidget -{ +class WindowControl : public QWidget { Q_OBJECT public: - WindowControl(unsigned int nMonitors, unsigned int monitorIndex, - unsigned int windowIndex, std::vector& monitorDims, - const std::array winColors, QWidget *parent = nullptr); + WindowControl(unsigned int monitorIndex, unsigned int windowIndex, + std::vector& monitorDims, const std::array winColors, + QWidget *parent); ~WindowControl(); void setDimensions(const QRectF& dimensions); void setWindowChangeCallback(std::function cb); @@ -100,8 +98,6 @@ private slots: private: void createWidgets(QWidget* parent); - template - void enableProjectionOption(T* comboModel, int selectionIndex, bool enable); void updateScaledWindowDimensions(); std::function _windowChangeCallback; std::function _windowGuiCheckCallback; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 79ab603056..03494c4ead 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -41,7 +41,6 @@ Display::Display(std::shared_ptr monitorRenderBox, { _addWindowButton = new QPushButton("Add Window", this); _removeWindowButton = new QPushButton("Remove Window", this); - _nMonitors = _monitorResolutions.size(); //Add all window controls (some will be hidden from GUI initially) for (unsigned int i = 0; i < _nMaxWindows; ++i) { initializeWindowControl(); @@ -70,14 +69,17 @@ void Display::initializeLayout() { layout->addStretch(); for (unsigned int i = 0; i < _nMaxWindows; ++i) { - _winCtrlLayouts.push_back(_windowControl[i]->initializeLayout()); - _layoutWindowWrappers.push_back(new QWidget()); - _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); - layoutWindows->addWidget(_layoutWindowWrappers.back()); + QVBoxLayout* layoutForNextWindow = _windowControl[i]->initializeLayout(); + _winCtrlLayouts.push_back(layoutForNextWindow); + QWidget* layoutWrapper = new QWidget(); + layoutWrapper->setLayout(layoutForNextWindow); + _layoutWindowWrappers.push_back(layoutWrapper); + layoutWindows->addWidget(layoutWrapper); if (i < (_nMaxWindows - 1)) { - _frameBorderLines.push_back(new QFrame()); - _frameBorderLines.back()->setFrameShape(QFrame::VLine); - layoutWindows->addWidget(_frameBorderLines.back()); + QFrame* frameForNextWindow = new QFrame(); + frameForNextWindow->setFrameShape(QFrame::VLine); + _frameBorderLines.push_back(frameForNextWindow); + layoutWindows->addWidget(frameForNextWindow); } } _nWindowsDisplayed = 1; @@ -127,7 +129,6 @@ void Display::initializeWindowControl() { unsigned int monitorNumForThisWindow = (_nWindowsAllocated >= 3) ? 1 : 0; _windowControl.push_back( new WindowControl( - _nMonitors, monitorNumForThisWindow, _nWindowsAllocated, _monitorResolutions, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 00f05c603b..7f85de4dc3 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -70,12 +70,12 @@ void FileSupport::saveCluster() { if (_orientationWidget) { sgct::config::Scene initScene; initScene.orientation = _orientationWidget->orientationValue(); - if (_cluster.nodes.size() == 0) { - _cluster.nodes.push_back(sgct::config::Node()); - } + _cluster.nodes.clear(); + sgct::config::Node tmpNode; + tmpNode.address = "localhost"; + tmpNode.port = 20401; + _cluster.nodes.push_back(tmpNode); _cluster.masterAddress = "localhost"; - _cluster.nodes.back().address = "localhost"; - _cluster.nodes.back().port = 20401; _cluster.scene = std::move(initScene); _cluster.firmSync = _orientationWidget->vsyncValue(); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index c8bb0444c5..c5a4be3c5c 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -24,7 +24,6 @@ #include "sgctedit/orientation.h" -#include "sgctedit/display.h" #include "sgctedit/orientationdialog.h" Orientation::Orientation() @@ -57,15 +56,10 @@ void Orientation::orientationDialog() { _orientationDialog.exec(); } -sgct::quat Orientation::orientationValue() { +sgct::quat Orientation::orientationValue() const { return _orientationValue; } -bool Orientation::vsyncValue() { +bool Orientation::vsyncValue() const { return (_checkBoxVsync->checkState() == Qt::Checked); } - -Orientation::~Orientation() -{ - delete _layoutOrientationFull; -} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 0b89be0df5..37218705d8 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -33,9 +33,9 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) setWindowTitle("Global Orientation"); QVBoxLayout* layoutWindow = new QVBoxLayout(this); - _linePitch = new QLineEdit(this); - _lineRoll = new QLineEdit(this); - _lineYaw = new QLineEdit(this); + _linePitch = new QLineEdit; + _lineRoll = new QLineEdit; + _lineYaw = new QLineEdit; _linePitch->setText(QString::number(_orientationValue.x)); _lineRoll->setText(QString::number(_orientationValue.z)); _lineYaw->setText(QString::number(_orientationValue.y)); @@ -51,21 +51,21 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) _lineYaw->setValidator(validatorYaw); } { - QLabel* labelPitch = new QLabel(this); + QLabel* labelPitch = new QLabel; labelPitch->setText("Pitch: "); QHBoxLayout* layoutPitch = new QHBoxLayout; layoutPitch->addStretch(1); layoutPitch->addWidget(labelPitch); layoutPitch->addWidget(_linePitch); layoutWindow->addLayout(layoutPitch); - QLabel* labelRoll = new QLabel(this); + QLabel* labelRoll = new QLabel; labelRoll ->setText("Roll: "); QHBoxLayout* layoutRoll = new QHBoxLayout; layoutRoll->addStretch(1); layoutRoll->addWidget(labelRoll); layoutRoll->addWidget(_lineRoll); layoutWindow->addLayout(layoutRoll); - QLabel* labelYaw = new QLabel(this); + QLabel* labelYaw = new QLabel; labelYaw ->setText("Yaw: "); QHBoxLayout* layoutYaw = new QHBoxLayout; layoutYaw->addStretch(1); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index abe0a8efc1..1e5a271dee 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -25,7 +25,7 @@ #include "sgctedit/sgctedit.h" SgctEdit::SgctEdit(QWidget* parent, std::vector& windowList, - sgct::config::Cluster& cluster, const QList screenList) + sgct::config::Cluster& cluster, const QList& screenList) : QDialog(parent) , _cluster(cluster) , _windowList(windowList) @@ -35,13 +35,17 @@ SgctEdit::SgctEdit(QWidget* parent, std::vector& windowLis createWidgets(); } -void SgctEdit::systemMonitorConfiguration(const QList screenList) { +void SgctEdit::systemMonitorConfiguration(const QList& screenList) { size_t nScreensManaged = std::min(screenList.length(), 2); for (size_t s = 0; s < nScreensManaged; ++s) { - int actualWidth = std::max(screenList[s]->size().width(), - screenList[s]->availableGeometry().width()); - int actualHeight = std::max(screenList[s]->size().height(), - screenList[s]->availableGeometry().height()); + int actualWidth = std::max( + screenList[s]->size().width(), + screenList[s]->availableGeometry().width() + ); + int actualHeight = std::max( + screenList[s]->size().height(), + screenList[s]->availableGeometry().height() + ); _monitorSizeList.push_back({ screenList[s]->availableGeometry().x(), screenList[s]->availableGeometry().y(), @@ -119,13 +123,7 @@ std::string SgctEdit::saveFilename() { } SgctEdit::~SgctEdit() { - if (_orientationWidget) { - delete _orientationWidget; - } - if (_fileSupportWidget) { - delete _fileSupportWidget; - } - if (_displayLayout) { - delete _displayLayout; - } + delete _orientationWidget; + delete _fileSupportWidget; + delete _displayLayout; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index c99cdd29ca..f7e94c9f16 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -26,17 +26,16 @@ #include "sgctedit/monitorbox.h" #include "sgctedit/windowcontrol.h" -WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, - const unsigned int windowIndex, +WindowControl::WindowControl(unsigned int monitorIndex, const unsigned int windowIndex, std::vector& monitorDims, const std::array winColors, QWidget *parent) : QWidget(parent) - , _nMonitors(nMonitors) , _monIndex(monitorIndex) , _index(windowIndex) , _monitorResolutions(monitorDims) , _colorsForWindows(winColors) { + _nMonitors = _monitorResolutions.size(); createWidgets(parent); } @@ -374,15 +373,6 @@ void WindowControl::onSpoutSelection(int selectionState) { } } -template -void WindowControl::enableProjectionOption(T* comboModel, int selectionIndex, bool enable) -{ - auto* item = comboModel->item(selectionIndex); - if (item) { - item->setEnabled(enable); - } -} - void WindowControl::onMonitorChanged(int newSelection) { _monIndex = newSelection; if (_windowChangeCallback) { @@ -408,15 +398,14 @@ void WindowControl::setDimensions(const QRectF& dimensions) { } void WindowControl::setWindowChangeCallback( - std::function cb) + std::function cb) { - _windowChangeCallback = cb; + _windowChangeCallback = std::move(cb); } -void WindowControl::setWebGuiChangeCallback( - std::function cb) +void WindowControl::setWebGuiChangeCallback(std::function cb) { - _windowGuiCheckCallback = cb; + _windowGuiCheckCallback = std::move(cb); } void WindowControl::uncheckWebGuiOption() { From 9f7a5f84abcbc497c642cf8120fa11a1e45b523c Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 11 Feb 2022 20:45:44 -0700 Subject: [PATCH 56/93] Completion of changes from initial code review --- .../ext/launcher/include/sgctedit/display.h | 11 +- .../launcher/include/sgctedit/filesupport.h | 30 +- .../launcher/include/sgctedit/monitorbox.h | 18 +- .../ext/launcher/include/sgctedit/sgctedit.h | 10 +- .../launcher/include/sgctedit/windowcontrol.h | 73 ++-- .../ext/launcher/src/sgctedit/display.cpp | 20 +- .../ext/launcher/src/sgctedit/filesupport.cpp | 115 +++--- .../ext/launcher/src/sgctedit/monitorbox.cpp | 29 +- .../launcher/src/sgctedit/windowcontrol.cpp | 339 +++++++++--------- 9 files changed, 291 insertions(+), 354 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 3e9a9e2540..b6144bfc32 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -46,10 +46,9 @@ class Display : public QWidget { Q_OBJECT public: Display(std::shared_ptr monitorRenderBox, - std::vector& monitorSizeList, const unsigned int nMaxWindows, - const std::array winColors); - ~Display(); - std::vector windowControls() const; + std::vector& monitorSizeList, unsigned int nMaxWindows, + const std::array& winColors); + std::vector> windowControls() const; unsigned int nWindows() const; void uncheckWebGuiOptions(); @@ -67,8 +66,8 @@ private: unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; unsigned int _nMaxWindows = 3; - const std::array _winColors; - std::vector _windowControl; + const std::array& _winColors; + std::vector> _windowControl; QPushButton* _addWindowButton = nullptr; QPushButton* _removeWindowButton = nullptr; unsigned int _monitorIdx = 0; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index c3fb68c5cc..e713596465 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -38,6 +38,17 @@ #include #include +using ProjectionOptions = std::variant< + sgct::config::NoProjection, + sgct::config::CylindricalProjection, + sgct::config::EquirectangularProjection, + sgct::config::FisheyeProjection, + sgct::config::PlanarProjection, + sgct::config::ProjectionPlane, + sgct::config::SphericalMirrorProjection, + sgct::config::SpoutOutputProjection +>; + class FileSupport : public QWidget { Q_OBJECT public: @@ -54,20 +65,17 @@ private slots: private: bool isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims); - bool findGuiWindow(unsigned int& foundWindowIndex); + std::optional findGuiWindow(); void saveCluster(); void saveWindows(); void saveUser(); - void saveProjectionInformation(bool isSpoutSelected, int projectionIndex, - WindowControl* winControl, sgct::config::Viewport& viewport); - void saveProjection_Spout(int projectionIndex, WindowControl* winControl, - sgct::config::Viewport& viewport); - void saveProjection_NonSpout(int projectionIndex, WindowControl* winControl, - sgct::config::Viewport& viewport); - void saveWindowsViewports(); - void saveWindowsDimensions(WindowControl* wCtrl); - void saveWindowsWebGui(unsigned int wIdx); - void saveWindowsFullScreen(WindowControl* wCtrl); + ProjectionOptions saveProjectionInformation( + std::shared_ptr winControl); + ProjectionOptions saveProjectionSpout(std::shared_ptr winControl); + ProjectionOptions saveProjectionNoSpout(std::shared_ptr winControl); + sgct::config::Viewport generateViewport(); + sgct::config::Window saveWindowsDimensions(std::shared_ptr wCtrl); + void saveWindowsWebGui(unsigned int wIdx, sgct::config::Window& win); QHBoxLayout* _layoutButtonBox = nullptr; QPushButton* _saveButton = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 3aa6597efa..2f331b373e 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -43,7 +43,7 @@ class MonitorBox : public QWidget { Q_OBJECT public: MonitorBox(QRect widgetDims, std::vector monitorResolution, - unsigned int nWindows, std::array winColors); + unsigned int nWindows, const std::array& winColors); void mapMonitorResolutionToWidgetCoordinates(); void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& w); @@ -55,15 +55,15 @@ protected: void paintEvent(QPaintEvent* event) override; private: - void paintWidgetBorder(QPainter& painter, const int width, const int height); + void paintWidgetBorder(QPainter& painter, int width, int height); void paintMonitorBackgrounds(QPainter& painter); - void paintWindow(QPainter& painter, const size_t winIdx); - void paintWindowBeyondBounds(QPainter& painter, const unsigned int winIdx); - void paintWindowNumber(QPainter& painter, const unsigned int winIdx); - void setPenSpecificToWindow(QPainter& painter, const unsigned int windowIdx, + void paintWindow(QPainter& painter, size_t winIdx); + void paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx); + void paintWindowNumber(QPainter& painter, unsigned int winIdx); + void setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, bool visibleBorder); - void computeScaledResolution_landscape(const float aspectRatio, const float maxWidth); - void computeScaledResolution_portrait(const float aspectRatio, const float maxHeight); + void computeScaledResolutionLandscape(float aspectRatio, float maxWidth); + void computeScaledResolutionPortrait(float aspectRatio, float maxHeight); unsigned int _maxNumMonitors = 2; QRectF _monitorWidgetSize; @@ -79,7 +79,7 @@ private: {0.f, 0.f, 0.f, 0.f} }; unsigned int _nWindows = 1; - const std::array _colorsForWindows; + const std::array _colorsForWindows; int _alphaWindowOpacity = 170; float _monitorScaleFactor = 1.0; bool _showLabel = false; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index dd77fbb808..dbab4e2d58 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -68,11 +68,11 @@ private: std::vector& _windowList; bool _saveSelected = false; unsigned int _nMaxWindows = 3; - const std::array _colorsForWindows = { - "#2B9EC3", - "#FCAB10", - "#44AF69", - "#F8333C" + const std::array _colorsForWindows = { + QColor(0x2B, 0x9E, 0xC3), + QColor(0xFC, 0xAB, 0x10), + QColor(0x44, 0xAF, 0x69), + QColor(0xF8, 0x33, 0x3C) }; }; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 4fefaff990..dc912ba06a 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -39,49 +39,37 @@ class WindowControl : public QWidget { Q_OBJECT public: WindowControl(unsigned int monitorIndex, unsigned int windowIndex, - std::vector& monitorDims, const std::array winColors, + std::vector& monitorDims, const QColor& winColor, QWidget *parent); ~WindowControl(); - void setDimensions(const QRectF& dimensions); void setWindowChangeCallback(std::function cb); void setWebGuiChangeCallback(std::function cb); - void showWindowLabel(const bool show); + void showWindowLabel(bool show); QVBoxLayout* initializeLayout(); QRectF& dimensions(); - QLineEdit* lineEditSizeWidth(); - QLineEdit* lineEditSizeHeight(); - QLineEdit* lineEditSizeOffsetX(); - QLineEdit* lineEditSizeOffsetY(); QCheckBox* checkBoxWindowDecor(); QCheckBox* checkBoxWebGui(); QCheckBox* checkBoxSpoutOutput(); - std::string windowName(); - sgct::ivec2 windowSize(); - sgct::ivec2 windowPos(); - bool isDecorated(); - bool isSpoutSelected(); - bool isGuiWindow(); - void enableGuiWindowSelection(bool enabled); + std::string windowName() const; + sgct::ivec2 windowSize() const; + sgct::ivec2 windowPos() const; + bool isDecorated() const; + bool isSpoutSelected() const; + bool isGuiWindow() const; void uncheckWebGuiOption(); - int projectionSelectedIndex(); - int qualitySelectedIndex(); - int qualitySelectedValue(); - unsigned int monitorNum(); - float fovH(); - float fovV(); - float heightOffset(); - enum ProjectionIndeces : unsigned int { + int qualitySelectedValue() const; + unsigned int monitorNum() const; + float fovH() const; + float fovV() const; + float heightOffset() const; + enum class ProjectionIndeces { Planar = 0, Fisheye, - Spherical_Mirror, + SphericalMirror, Cylindrical, Equirectangular }; - std::string ProjectionTypeNames[5] = {"Planar", "Fisheye", "Spherical Mirror", - "Cylindrical", "Equirectangular"}; - std::string QualityTypeNames[10] = {"Low (256)", "Medium (512)", "High (1K)", - "1.5K (1536)", "2K (2048)", "4K (4096)", "8K (8192)", "16K (16384)", - "32K (32768)", "64K (65536)"}; + ProjectionIndeces projectionSelectedIndex() const; int QualityValues[10] = {256, 512, 1024, 1536, 2048, 4096, 8192, 16384, 32768, 65536}; @@ -107,25 +95,6 @@ private: {1200.0, 340.0, 1280.0, 720.0}, {50.0, 50.0, 1280.0, 720.0} }; - QList _projectionTypes = { - QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Planar]), - QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Fisheye]), - QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Spherical_Mirror]), - QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Cylindrical]), - QString::fromStdString(ProjectionTypeNames[ProjectionIndeces::Equirectangular]), - }; - QList _qualityTypes = { - QString::fromStdString(QualityTypeNames[0]), - QString::fromStdString(QualityTypeNames[1]), - QString::fromStdString(QualityTypeNames[2]), - QString::fromStdString(QualityTypeNames[3]), - QString::fromStdString(QualityTypeNames[4]), - QString::fromStdString(QualityTypeNames[5]), - QString::fromStdString(QualityTypeNames[6]), - QString::fromStdString(QualityTypeNames[7]), - QString::fromStdString(QualityTypeNames[8]), - QString::fromStdString(QualityTypeNames[9]), - }; QList _monitorNames = { "Monitor 1", "Monitor 2" }; int _lineEditWidthFixed = 50; float _marginFractionOfWidgetSize = 0.025; @@ -134,13 +103,13 @@ private: unsigned int _index = 0; std::vector& _monitorResolutions; int _maxWindowSizePixels = 10000; - const std::array _colorsForWindows; + const QColor& _colorForWindow; QVBoxLayout* _layoutFullWindow = nullptr; QLabel* _labelWinNum = nullptr; - QLineEdit* _size_x = nullptr; - QLineEdit* _size_y = nullptr; - QLineEdit* _offset_x = nullptr; - QLineEdit* _offset_y = nullptr; + QLineEdit* _sizeX = nullptr; + QLineEdit* _sizeY = nullptr; + QLineEdit* _offsetX = nullptr; + QLineEdit* _offsetY = nullptr; QRectF _windowDims; QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 03494c4ead..5832c87e98 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -32,8 +32,8 @@ #include Display::Display(std::shared_ptr monitorRenderBox, - std::vector& monitorSizeList, const unsigned int nMaxWindows, - const std::array winColors) + std::vector& monitorSizeList, unsigned int nMaxWindows, + const std::array& winColors) : _monBox(monitorRenderBox) , _monitorResolutions(monitorSizeList) , _nMaxWindows(nMaxWindows) @@ -50,12 +50,6 @@ Display::Display(std::shared_ptr monitorRenderBox, initializeLayout(); } -Display::~Display() { - for (WindowControl* w : _windowControl) { - delete w; - } -} - void Display::initializeLayout() { QVBoxLayout* layout = new QVBoxLayout(this); { @@ -87,7 +81,7 @@ void Display::initializeLayout() { layout->addLayout(layoutWindows); } -std::vector Display::windowControls() const { +std::vector> Display::windowControls() const { return _windowControl; } @@ -118,7 +112,7 @@ void Display::showWindows() { } _removeWindowButton->setEnabled(_nWindowsDisplayed > 1); _addWindowButton->setEnabled(_nWindowsDisplayed != _nMaxWindows); - for (WindowControl* w : _windowControl) { + for (std::shared_ptr w : _windowControl) { w->showWindowLabel(_nWindowsDisplayed > 1); } _monBox->setNumWindowsDisplayed(_nWindowsDisplayed); @@ -128,11 +122,11 @@ void Display::initializeWindowControl() { if (_nWindowsAllocated < _nMaxWindows) { unsigned int monitorNumForThisWindow = (_nWindowsAllocated >= 3) ? 1 : 0; _windowControl.push_back( - new WindowControl( + std::make_shared( monitorNumForThisWindow, _nWindowsAllocated, _monitorResolutions, - _winColors, + _winColors[_nWindowsAllocated], this ) ); @@ -160,7 +154,7 @@ void Display::initializeWindowControl() { } void Display::uncheckWebGuiOptions() { - for (WindowControl* w : _windowControl) { + for (std::shared_ptr w : _windowControl) { w->uncheckWebGuiOption(); } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 7f85de4dc3..37d146ac7f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -95,97 +95,88 @@ bool FileSupport::isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims) _monitors[monitorIdx].height() == wDims.y); } -bool FileSupport::findGuiWindow(unsigned int& foundWindowIndex) { +std::optional FileSupport::findGuiWindow() { unsigned int windowIndex = 0; for (unsigned int w = 0; w < _displayWidget->nWindows(); ++w) { if (_displayWidget->windowControls()[w]->isGuiWindow()) { - foundWindowIndex = windowIndex; - return true; + return std::optional(windowIndex); } windowIndex++; } - return false; + return std::nullopt; } void FileSupport::saveWindows() { unsigned int windowIndex = 0; for (unsigned int w = 0; w < _displayWidget->nWindows(); ++w) { - WindowControl* wCtrl = _displayWidget->windowControls()[w]; - _windowList.push_back(sgct::config::Window()); - saveWindowsViewports(); - saveProjectionInformation( - wCtrl->isSpoutSelected(), - wCtrl->projectionSelectedIndex(), - wCtrl, - _windowList.back().viewports.back() + std::shared_ptr wCtrl = _displayWidget->windowControls()[w]; + sgct::config::Window tmpWindow = saveWindowsDimensions(wCtrl); + tmpWindow.viewports.push_back(generateViewport()); + tmpWindow.viewports.back().projection = saveProjectionInformation(wCtrl); + tmpWindow.isDecorated = wCtrl->isDecorated(); + tmpWindow.isFullScreen = isWindowFullscreen( + wCtrl->monitorNum(), + wCtrl->windowSize() ); - saveWindowsDimensions(wCtrl); - _windowList.back().isDecorated = wCtrl->isDecorated(); - saveWindowsFullScreen(wCtrl); - saveWindowsWebGui(windowIndex); + saveWindowsWebGui(windowIndex, tmpWindow); if (!wCtrl->windowName().empty()) { - _windowList.back().name = wCtrl->windowName(); + tmpWindow.name = wCtrl->windowName(); } - _windowList.back().id = windowIndex++; + tmpWindow.id = windowIndex++; + _windowList.push_back(tmpWindow); } } -void FileSupport::saveWindowsViewports() { +sgct::config::Viewport FileSupport::generateViewport() { sgct::config::Viewport vp; vp.isTracked = true; vp.position = {0.f, 0.f}; vp.size = {1.f, 1.f}; - _windowList.back().viewports.push_back(std::move(vp)); + return vp; } -void FileSupport::saveWindowsDimensions(WindowControl* wCtrl) { - _windowList.back().size = wCtrl->windowSize(); - _windowList.back().pos = { +sgct::config::Window FileSupport::saveWindowsDimensions( + std::shared_ptr wCtrl) +{ + sgct::config::Window tmpWindow; + tmpWindow.size = wCtrl->windowSize(); + tmpWindow.pos = { _monitors[wCtrl->monitorNum()].x() + wCtrl->windowPos().x, _monitors[wCtrl->monitorNum()].y() + wCtrl->windowPos().y, }; + return tmpWindow; } -void FileSupport::saveWindowsWebGui(unsigned int wIdx) { - _windowList.back().viewports.back().isTracked = true; - unsigned int webGuiWindowIndex; - bool isOneOfWindowsSetAsWebGui = findGuiWindow(webGuiWindowIndex); +void FileSupport::saveWindowsWebGui(unsigned int wIdx, sgct::config::Window& win) { + win.viewports.back().isTracked = true; + std::optional webGuiWindowIndex = findGuiWindow(); + bool isOneOfWindowsSetAsWebGui = webGuiWindowIndex.has_value(); if (isOneOfWindowsSetAsWebGui) { - if (wIdx == webGuiWindowIndex) { - _windowList.back().viewports.back().isTracked = false; - _windowList.back().tags.push_back("GUI"); + if (wIdx == webGuiWindowIndex.value()) { + win.viewports.back().isTracked = false; + win.tags.push_back("GUI"); } - _windowList.back().draw2D = (wIdx == webGuiWindowIndex); - _windowList.back().draw3D = !(_windowList.back().draw2D.value()); + win.draw2D = (wIdx == webGuiWindowIndex.value()); + win.draw3D = !(win.draw2D.value()); } } -void FileSupport::saveWindowsFullScreen(WindowControl* wCtrl) { - bool isFullScreen = isWindowFullscreen( - wCtrl->monitorNum(), - wCtrl->windowSize() - ); - if (isFullScreen) { - _windowList.back().isFullScreen = true; - } -} - -void FileSupport::saveProjectionInformation(bool isSpoutSelected, int projectionIndex, - WindowControl* winControl, sgct::config::Viewport& viewport) +ProjectionOptions FileSupport::saveProjectionInformation( + std::shared_ptr winControl) { - if (isSpoutSelected) { - saveProjection_Spout(projectionIndex, winControl, viewport); + if (winControl->isSpoutSelected()) { + return saveProjectionSpout(winControl); } else { - saveProjection_NonSpout(projectionIndex, winControl, viewport); + return saveProjectionNoSpout(winControl); } } -void FileSupport::saveProjection_Spout(int projectionIndex, WindowControl* winControl, - sgct::config::Viewport& viewport) +ProjectionOptions FileSupport::saveProjectionSpout( + std::shared_ptr winControl) { sgct::config::SpoutOutputProjection projection; - switch(projectionIndex) { + switch(winControl->projectionSelectedIndex()) { case WindowControl::ProjectionIndeces::Fisheye: projection.mapping = sgct::config::SpoutOutputProjection::Mapping::Fisheye; @@ -199,28 +190,28 @@ void FileSupport::saveProjection_Spout(int projectionIndex, WindowControl* winCo } projection.quality = winControl->qualitySelectedValue(); projection.mappingSpoutName = "OpenSpace"; - viewport.projection = std::move(projection); + return projection; } -void FileSupport::saveProjection_NonSpout(int projectionIndex, WindowControl* winControl, - sgct::config::Viewport& viewport) +ProjectionOptions FileSupport::saveProjectionNoSpout( + std::shared_ptr winControl) { - switch(projectionIndex) { + switch(winControl->projectionSelectedIndex()) { case WindowControl::ProjectionIndeces::Fisheye: { sgct::config::FisheyeProjection projection; projection.quality = winControl->qualitySelectedValue(); - projection.fov = 180.0; - projection.tilt = 0.0; - viewport.projection = std::move(projection); + projection.fov = 180.f; + projection.tilt = 0.f; + return projection; } break; - case WindowControl::ProjectionIndeces::Spherical_Mirror: + case WindowControl::ProjectionIndeces::SphericalMirror: { sgct::config::SphericalMirrorProjection projection; projection.quality = winControl->qualitySelectedValue(); - viewport.projection = std::move(projection); + return projection; } break; @@ -229,7 +220,7 @@ void FileSupport::saveProjection_NonSpout(int projectionIndex, WindowControl* wi sgct::config::CylindricalProjection projection; projection.quality = winControl->qualitySelectedValue(); projection.heightOffset = winControl->heightOffset(); - viewport.projection = std::move(projection); + return projection; } break; @@ -237,7 +228,7 @@ void FileSupport::saveProjection_NonSpout(int projectionIndex, WindowControl* wi { sgct::config::EquirectangularProjection projection; projection.quality = winControl->qualitySelectedValue(); - viewport.projection = std::move(projection); + return projection; } break; @@ -250,7 +241,7 @@ void FileSupport::saveProjection_NonSpout(int projectionIndex, WindowControl* wi projection.fov.left = -projection.fov.right; projection.fov.up = winControl->fovV() / 2.0; projection.fov.down = -projection.fov.up; - viewport.projection = std::move(projection); + return projection; } break; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 8360953911..c184101ace 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -27,7 +27,7 @@ constexpr float MarginFractionOfWidgetSize = 0.025; MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, - unsigned int nWindows, std::array winColors) + unsigned int nWindows, const std::array& winColors) : _monitorWidgetSize(widgetDims) , _monitorResolution(monitorResolution) , _nWindows(nWindows) @@ -39,7 +39,6 @@ MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, } void MonitorBox::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); QPainter painter(this); QPen pen = painter.pen(); painter.setPen(pen); @@ -56,7 +55,7 @@ void MonitorBox::paintEvent(QPaintEvent* event) { } } -void MonitorBox::paintWidgetBorder(QPainter& painter, const int width, const int height) { +void MonitorBox::paintWidgetBorder(QPainter& painter, int width, int height) { constexpr int Radius = 10; painter.setPen(QPen(Qt::gray, 4)); painter.drawRoundedRect(0, 0, width - 1, height - 1, Radius, Radius); @@ -83,7 +82,7 @@ void MonitorBox::paintMonitorBackgrounds(QPainter& painter) { } } -void MonitorBox::paintWindowBeyondBounds(QPainter& painter, const unsigned int winIdx) { +void MonitorBox::paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx) { painter.setBrush(Qt::BDiagPattern); setPenSpecificToWindow(painter, winIdx, false); if (winIdx <= _windowRendering.size()) { @@ -93,11 +92,11 @@ void MonitorBox::paintWindowBeyondBounds(QPainter& painter, const unsigned int w painter.setBrush(Qt::NoBrush); } -void MonitorBox::paintWindow(QPainter& painter, const size_t winIdx) { +void MonitorBox::paintWindow(QPainter& painter, size_t winIdx) { setPenSpecificToWindow(painter, winIdx, true); if (winIdx <= _windowRendering.size()) { painter.drawRect(_windowRendering[winIdx]); - QColor fillColor = QColor(_colorsForWindows[winIdx]); + QColor fillColor = _colorsForWindows[winIdx]; fillColor.setAlpha(_alphaWindowOpacity); QBrush brush(fillColor); brush.setStyle(Qt::SolidPattern); @@ -106,7 +105,7 @@ void MonitorBox::paintWindow(QPainter& painter, const size_t winIdx) { } } -void MonitorBox::paintWindowNumber(QPainter& painter, const unsigned int winIdx) { +void MonitorBox::paintWindowNumber(QPainter& painter, unsigned int winIdx) { QPointF textPos = QPointF(_windowRendering[winIdx].left() + 5, _windowRendering[winIdx].bottom() - 5); textPos.setX(std::clamp(textPos.x(), 0.0, _monitorWidgetSize.width() - 10)); @@ -114,11 +113,11 @@ void MonitorBox::paintWindowNumber(QPainter& painter, const unsigned int winIdx) painter.drawText(textPos, QString::fromStdString(std::to_string(winIdx + 1))); } -void MonitorBox::setPenSpecificToWindow(QPainter& painter, const unsigned int windowIdx, +void MonitorBox::setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, bool visibleBorder) { int penWidth = (visibleBorder) ? 1 : -1; - painter.setPen(QPen(QColor(_colorsForWindows[windowIdx]), penWidth)); + painter.setPen(QPen(_colorsForWindows[windowIdx], penWidth)); } void MonitorBox::windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, @@ -141,10 +140,10 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { } float aspectRatio = maxWidth / maxHeight; if (aspectRatio >= 1.0) { - computeScaledResolution_landscape(aspectRatio, maxWidth); + computeScaledResolutionLandscape(aspectRatio, maxWidth); } else { - computeScaledResolution_portrait(aspectRatio, maxHeight); + computeScaledResolutionPortrait(aspectRatio, maxHeight); } for (size_t m = 0; m < _monitorResolution.size(); ++m) { _monitorDimensionsScaled.push_back({ @@ -157,9 +156,7 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { update(); } -void MonitorBox::computeScaledResolution_landscape(const float aspectRatio, - const float maxWidth) -{ +void MonitorBox::computeScaledResolutionLandscape(float aspectRatio, float maxWidth) { _marginWidget = _monitorWidgetSize.width() * MarginFractionOfWidgetSize; float virtualWidth = _monitorWidgetSize.width() * (1.0 - MarginFractionOfWidgetSize * 2.0); @@ -174,9 +171,7 @@ void MonitorBox::computeScaledResolution_landscape(const float aspectRatio, } } -void MonitorBox::computeScaledResolution_portrait(const float aspectRatio, - const float maxHeight) -{ +void MonitorBox::computeScaledResolutionPortrait(float aspectRatio, float maxHeight) { _marginWidget = _monitorWidgetSize.height() * MarginFractionOfWidgetSize; float virtualHeight = _monitorWidgetSize.height() * (1.0 - MarginFractionOfWidgetSize * 2.0); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index f7e94c9f16..ce141d8155 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -22,48 +22,77 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include "sgctedit/display.h" -#include "sgctedit/monitorbox.h" #include "sgctedit/windowcontrol.h" -WindowControl::WindowControl(unsigned int monitorIndex, const unsigned int windowIndex, +#include +#include "sgctedit/display.h" +#include "sgctedit/monitorbox.h" + +const std::string ProjectionTypeNames[5] = {"Planar", "Fisheye", "Spherical Mirror", + "Cylindrical", "Equirectangular"}; +QList ProjectionTypes = { + QString::fromStdString(ProjectionTypeNames[static_cast( + WindowControl::ProjectionIndeces::Planar)]), + QString::fromStdString(ProjectionTypeNames[static_cast( + WindowControl::ProjectionIndeces::Fisheye)]), + QString::fromStdString(ProjectionTypeNames[static_cast( + WindowControl::ProjectionIndeces::SphericalMirror)]), + QString::fromStdString(ProjectionTypeNames[static_cast( + WindowControl::ProjectionIndeces::Cylindrical)]), + QString::fromStdString(ProjectionTypeNames[static_cast( + WindowControl::ProjectionIndeces::Equirectangular)]) +}; +const QList QualityTypes = { + "Low (256)", + "Medium (512)", + "High (1K)", + "1.5K (1536)", + "2K (2048)", + "4K (4096)", + "8K (8192)", + "16K (16384)", + "32K (32768)", + "64K (65536)" +}; + +WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex, std::vector& monitorDims, - const std::array winColors, QWidget *parent) + const QColor& winColor, QWidget *parent) : QWidget(parent) , _monIndex(monitorIndex) , _index(windowIndex) , _monitorResolutions(monitorDims) - , _colorsForWindows(winColors) + , _colorForWindow(winColor) { _nMonitors = _monitorResolutions.size(); createWidgets(parent); } +WindowControl::~WindowControl() { + delete _layoutFullWindow; +} + void WindowControl::createWidgets(QWidget* parent) { _windowDims = defaultWindowSizes[_index]; - _size_x = new QLineEdit( - QString::fromUtf8(std::to_string(int(_windowDims.width())).c_str()), parent); - _size_y = new QLineEdit( - QString::fromUtf8(std::to_string(int(_windowDims.height())).c_str()), parent); - _offset_x = new QLineEdit( - QString::fromUtf8(std::to_string(int(_windowDims.x())).c_str()), parent); - _offset_y = new QLineEdit( - QString::fromUtf8(std::to_string(int(_windowDims.y())).c_str()), parent); + _sizeX = new QLineEdit(QString::number(_windowDims.width()), parent); + _sizeY = new QLineEdit(QString::number(_windowDims.height()), parent); + _offsetX = new QLineEdit(QString::number(_windowDims.x()), parent); + _offsetY = new QLineEdit(QString::number(_windowDims.y()), parent); { - QIntValidator* validatorSize_x = new QIntValidator(10, _maxWindowSizePixels); - QIntValidator* validatorSize_y = new QIntValidator(10, _maxWindowSizePixels); - QIntValidator* validatorOffset_x = new QIntValidator( + QIntValidator* validatorSizeX = new QIntValidator(10, _maxWindowSizePixels); + QIntValidator* validatorSizeY = new QIntValidator(10, _maxWindowSizePixels); + QIntValidator* validatorOffsetX = new QIntValidator( -_maxWindowSizePixels, _maxWindowSizePixels ); - QIntValidator* validatorOffset_y = new QIntValidator( + QIntValidator* validatorOffsetY = new QIntValidator( -_maxWindowSizePixels, _maxWindowSizePixels ); - _size_x->setValidator(validatorSize_x); - _size_y->setValidator(validatorSize_y); - _offset_x->setValidator(validatorOffset_x); - _offset_y->setValidator(validatorOffset_y); + _sizeX->setValidator(validatorSizeX); + _sizeY->setValidator(validatorSizeY); + _offsetX->setValidator(validatorOffsetX); + _offsetY->setValidator(validatorOffsetY); } if (_nMonitors > 1) { _comboMonitorSelect = new QComboBox(this); @@ -77,10 +106,10 @@ void WindowControl::createWidgets(QWidget* parent) { _checkBoxWebGui = new QCheckBox("WebGUI only this window", this); _checkBoxSpoutOutput = new QCheckBox("Spout Output", this); _comboProjection = new QComboBox(this); - _comboProjection->addItems(_projectionTypes); + _comboProjection->addItems(ProjectionTypes); _comboQuality = new QComboBox(this); - _comboQuality->addItems(_qualityTypes); + _comboQuality->addItems(QualityTypes); { _lineFovH = new QLineEdit("80.0", parent); @@ -94,73 +123,62 @@ void WindowControl::createWidgets(QWidget* parent) { _lineHeightOffset->setValidator(validatorHtOff); } - connect( - _size_x, - SIGNAL(textChanged(const QString&)), - this, - SLOT(onSizeXChanged(const QString&)) - ); - connect( - _size_y, - SIGNAL(textChanged(const QString&)), - this, - SLOT(onSizeYChanged(const QString&)) - ); - connect( - _offset_x, - SIGNAL(textChanged(const QString&)), - this, - SLOT(onOffsetXChanged(const QString&)) - ); - connect( - _offset_y, - SIGNAL(textChanged(const QString&)), - this, - SLOT(onOffsetYChanged(const QString&)) - ); + connect(_sizeX, &QLineEdit::textChanged, this, &WindowControl::onSizeXChanged); + connect(_sizeY, &QLineEdit::textChanged, this, &WindowControl::onSizeYChanged); + connect(_offsetX, &QLineEdit::textChanged, this, &WindowControl::onOffsetXChanged); + connect(_offsetY, &QLineEdit::textChanged, this, &WindowControl::onOffsetYChanged); connect( _comboMonitorSelect, - SIGNAL(currentIndexChanged(int)), + qOverload(&QComboBox::currentIndexChanged), this, - SLOT(onMonitorChanged(int)) + &WindowControl::onMonitorChanged ); - connect(_comboProjection, - SIGNAL(currentIndexChanged(int)), + connect( + _comboProjection, + qOverload(&QComboBox::currentIndexChanged), this, - SLOT(onProjectionChanged(int)) + &WindowControl::onProjectionChanged ); - connect(_checkBoxSpoutOutput, - SIGNAL(stateChanged(int)), + connect( + _checkBoxSpoutOutput, + &QCheckBox::stateChanged, this, - SLOT(onSpoutSelection(int)) + &WindowControl::onSpoutSelection ); connect( _checkBoxWebGui, - SIGNAL(stateChanged(int)), + &QCheckBox::stateChanged, this, - SLOT(onWebGuiSelection(int)) + &WindowControl::onWebGuiSelection + ); + connect( + _fullscreenButton, + &QPushButton::released, + this, + &WindowControl::onFullscreenClicked ); - connect(_fullscreenButton, SIGNAL(released()), this, SLOT(onFullscreenClicked())); } QVBoxLayout* WindowControl::initializeLayout() { - _layoutFullWindow = new QVBoxLayout(); + _layoutFullWindow = new QVBoxLayout; //Window size - QVBoxLayout* layoutWindowCtrl = new QVBoxLayout(); + QVBoxLayout* layoutWindowCtrl = new QVBoxLayout; - _labelWinNum = new QLabel(); + _labelWinNum = new QLabel; _labelWinNum->setText("Window " + QString::number(_index + 1)); - QString colorStr = "QLabel { color : " + _colorsForWindows[_index] + "; }"; + QString colorStr = QString::fromStdString( + fmt::format("QLabel {{ color : #{:02x}{:02x}{:02x}; }}", + _colorForWindow.red(), _colorForWindow.green(), _colorForWindow.blue())); _labelWinNum->setStyleSheet(colorStr); - QHBoxLayout* layoutWinNum = new QHBoxLayout(); + QHBoxLayout* layoutWinNum = new QHBoxLayout; layoutWinNum->addStretch(1); layoutWinNum->addWidget(_labelWinNum); layoutWinNum->addStretch(1); layoutWindowCtrl->addLayout(layoutWinNum); { - QHBoxLayout* layoutName = new QHBoxLayout(); + QHBoxLayout* layoutName = new QHBoxLayout; QLabel* labelName = new QLabel(this); labelName->setText("Name: "); _windowName = new QLineEdit(this); @@ -172,63 +190,63 @@ QVBoxLayout* WindowControl::initializeLayout() { } if (_nMonitors > 1) { - QHBoxLayout* layoutMonitorNum = new QHBoxLayout(); + QHBoxLayout* layoutMonitorNum = new QHBoxLayout; layoutMonitorNum->addWidget(_comboMonitorSelect); layoutMonitorNum->addStretch(1); layoutWindowCtrl->addLayout(layoutMonitorNum); } - _size_x->setFixedWidth(_lineEditWidthFixed); - _size_y->setFixedWidth(_lineEditWidthFixed); + _sizeX->setFixedWidth(_lineEditWidthFixed); + _sizeY->setFixedWidth(_lineEditWidthFixed); { QLabel* labelSize = new QLabel(this); QLabel* labelDelim = new QLabel(this); - QHBoxLayout* layoutSize = new QHBoxLayout(); + QHBoxLayout* layoutSize = new QHBoxLayout; layoutSize->addWidget(labelSize); labelSize->setText("Size:"); labelSize->setFixedWidth(55); - layoutSize->addWidget(_size_x); + layoutSize->addWidget(_sizeX); layoutSize->addWidget(labelDelim); - layoutSize->addWidget(_size_y); + layoutSize->addWidget(_sizeY); layoutSize->addStretch(1); labelDelim->setText("x"); labelDelim->setFixedWidth(9); layoutWindowCtrl->addLayout(layoutSize); } - _offset_x->setFixedWidth(_lineEditWidthFixed); - _offset_y->setFixedWidth(_lineEditWidthFixed); + _offsetX->setFixedWidth(_lineEditWidthFixed); + _offsetY->setFixedWidth(_lineEditWidthFixed); { QLabel* labelOffset = new QLabel(this); QLabel* labelComma = new QLabel(this); - QHBoxLayout* layoutOffset = new QHBoxLayout(); + QHBoxLayout* layoutOffset = new QHBoxLayout; layoutOffset->addWidget(labelOffset); labelOffset->setText("Offset:"); labelOffset->setFixedWidth(55); - layoutOffset->addWidget(_offset_x); + layoutOffset->addWidget(_offsetX); layoutOffset->addWidget(labelComma); - layoutOffset->addWidget(_offset_y); + layoutOffset->addWidget(_offsetY); layoutOffset->addStretch(1); labelComma->setText(","); labelComma->setFixedWidth(9); layoutWindowCtrl->addLayout(layoutOffset); } { - QHBoxLayout* layoutCheckboxesFull1 = new QHBoxLayout(); - QVBoxLayout* layoutCheckboxesFull2 = new QVBoxLayout(); - QHBoxLayout* layoutFullscreenButton = new QHBoxLayout(); + QHBoxLayout* layoutCheckboxesFull1 = new QHBoxLayout; + QVBoxLayout* layoutCheckboxesFull2 = new QVBoxLayout; + QHBoxLayout* layoutFullscreenButton = new QHBoxLayout; layoutFullscreenButton->addWidget(_fullscreenButton); layoutFullscreenButton->addStretch(1); layoutCheckboxesFull2->addLayout(layoutFullscreenButton); - QHBoxLayout* layoutCBoxWindowDecor = new QHBoxLayout(); + QHBoxLayout* layoutCBoxWindowDecor = new QHBoxLayout; layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); layoutCBoxWindowDecor->addStretch(1); layoutCheckboxesFull2->addLayout(layoutCBoxWindowDecor); - QHBoxLayout* _layoutCBoxWebGui= new QHBoxLayout(); + QHBoxLayout* _layoutCBoxWebGui= new QHBoxLayout; _layoutCBoxWebGui->addWidget(_checkBoxWebGui); _layoutCBoxWebGui->addStretch(1); layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); - QVBoxLayout* layoutProjectionGroup = new QVBoxLayout(); - QHBoxLayout* layoutComboProjection = new QHBoxLayout(); + QVBoxLayout* layoutProjectionGroup = new QVBoxLayout; + QHBoxLayout* layoutComboProjection = new QHBoxLayout; layoutComboProjection->addWidget(_comboProjection); layoutComboProjection->addStretch(1); layoutProjectionGroup->addLayout(layoutComboProjection); @@ -236,33 +254,33 @@ QVBoxLayout* WindowControl::initializeLayout() { borderProjectionGroup->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); borderProjectionGroup->setLayout(layoutProjectionGroup); borderProjectionGroup->setVisible(true); - QHBoxLayout* layoutCBoxSpoutOutput= new QHBoxLayout(); + QHBoxLayout* layoutCBoxSpoutOutput= new QHBoxLayout; layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); layoutCBoxSpoutOutput->addStretch(1); layoutProjectionGroup->addLayout(layoutCBoxSpoutOutput); - QHBoxLayout* layoutComboQuality = new QHBoxLayout(); - _labelQuality = new QLabel(); + QHBoxLayout* layoutComboQuality = new QHBoxLayout; + _labelQuality = new QLabel; _labelQuality->setText("Quality:"); layoutComboQuality->addWidget(_labelQuality); layoutComboQuality->addWidget(_comboQuality); layoutComboQuality->addStretch(1); layoutProjectionGroup->addLayout(layoutComboQuality); - QHBoxLayout* layoutFovH = new QHBoxLayout(); - _labelFovH = new QLabel(); + QHBoxLayout* layoutFovH = new QHBoxLayout; + _labelFovH = new QLabel; _labelFovH->setText("Horizontal FOV:"); layoutFovH->addWidget(_labelFovH); layoutFovH->addWidget(_lineFovH); layoutFovH->addStretch(1); - QHBoxLayout* layoutFovV = new QHBoxLayout(); - _labelFovV = new QLabel(); + QHBoxLayout* layoutFovV = new QHBoxLayout; + _labelFovV = new QLabel; _labelFovV->setText("Vertical FOV:"); layoutFovV->addWidget(_labelFovV); layoutFovV->addWidget(_lineFovV); layoutFovV->addStretch(1); layoutProjectionGroup->addLayout(layoutFovH); layoutProjectionGroup->addLayout(layoutFovV); - QHBoxLayout* layoutHeightOffset = new QHBoxLayout(); - _labelHeightOffset = new QLabel(); + QHBoxLayout* layoutHeightOffset = new QHBoxLayout; + _labelHeightOffset = new QLabel; _labelHeightOffset->setText("Height Offset:"); layoutHeightOffset->addWidget(_labelHeightOffset); layoutHeightOffset->addWidget(_lineHeightOffset); @@ -277,49 +295,40 @@ QVBoxLayout* WindowControl::initializeLayout() { _layoutFullWindow->addLayout(layoutWindowCtrl); _comboProjection->setCurrentIndex(0); - onProjectionChanged(0); + onProjectionChanged(static_cast(ProjectionIndeces::Planar)); _comboQuality->setCurrentIndex(2); return _layoutFullWindow; } -void WindowControl::showWindowLabel(const bool show) { +void WindowControl::showWindowLabel(bool show) { _labelWinNum->setVisible(show); } void WindowControl::onSizeXChanged(const QString& newText) { - std::string x = newText.toStdString(); - if (!x.empty()) { - _windowDims.setWidth(std::stoi(x)); - } + _windowDims.setWidth(newText.toInt()); if (_windowChangeCallback) { _windowChangeCallback(_monIndex, _index, _windowDims); } } void WindowControl::onSizeYChanged(const QString& newText) { - std::string y = newText.toStdString(); - if (!y.empty()) { - _windowDims.setHeight(std::stoi(y)); - } + _windowDims.setHeight(newText.toInt()); if (_windowChangeCallback) { _windowChangeCallback(_monIndex, _index, _windowDims); } } void WindowControl::onOffsetXChanged(const QString& newText) { - std::string xOffset = newText.toStdString(); float prevWidth = _windowDims.width(); try { - if (!xOffset.empty()) { - _windowDims.setX(std::stoi(xOffset)); - _windowDims.setWidth(prevWidth); - } + _windowDims.setX(newText.toInt()); + _windowDims.setWidth(prevWidth); if (_windowChangeCallback) { _windowChangeCallback(_monIndex, _index, _windowDims); } } - catch (...) { + catch (std::exception &e) { //The QIntValidator ensures that the range is a +/- integer //However, it's possible to enter only a - character which //causes an exception throw, which is ignored here (when user @@ -328,34 +337,27 @@ void WindowControl::onOffsetXChanged(const QString& newText) { } void WindowControl::onOffsetYChanged(const QString& newText) { - std::string yOffset = newText.toStdString(); float prevHeight = _windowDims.height(); try { - if (!yOffset.empty()) { - _windowDims.setY(std::stoi(yOffset)); - _windowDims.setHeight(prevHeight); - } + _windowDims.setY(newText.toInt()); + _windowDims.setHeight(prevHeight); if (_windowChangeCallback) { _windowChangeCallback(_monIndex, _index, _windowDims); } } - catch (...) { + catch (std::exception &e) { //See comment in onOffsetXChanged } } void WindowControl::onFullscreenClicked() { - _offset_x->setText("0"); - _offset_y->setText("0"); - _size_x->setText(QString::number(_monitorResolutions[_monIndex].width())); - _size_y->setText(QString::number(_monitorResolutions[_monIndex].height())); + _offsetX->setText("0"); + _offsetY->setText("0"); + _sizeX->setText(QString::number(_monitorResolutions[_monIndex].width())); + _sizeY->setText(QString::number(_monitorResolutions[_monIndex].height())); _checkBoxWindowDecor->setCheckState(Qt::Unchecked); } -void WindowControl::enableGuiWindowSelection(bool enabled) { - _checkBoxWebGui->setEnabled(enabled); -} - void WindowControl::onWebGuiSelection(int selectionState) { if (_windowGuiCheckCallback && (selectionState == Qt::Checked)) { _windowGuiCheckCallback(_index); @@ -364,11 +366,16 @@ void WindowControl::onWebGuiSelection(int selectionState) { void WindowControl::onSpoutSelection(int selectionState) { if (selectionState == Qt::Checked) { - int currentProjectionSelection = _comboProjection->currentIndex(); + WindowControl::ProjectionIndeces currentProjectionSelection; + currentProjectionSelection = static_cast( + _comboProjection->currentIndex() + ); if ((currentProjectionSelection != ProjectionIndeces::Equirectangular) && (currentProjectionSelection != ProjectionIndeces::Fisheye)) { - _comboProjection->setCurrentIndex(ProjectionIndeces::Equirectangular); + _comboProjection->setCurrentIndex( + static_cast(ProjectionIndeces::Equirectangular) + ); } } } @@ -381,20 +388,18 @@ void WindowControl::onMonitorChanged(int newSelection) { } void WindowControl::onProjectionChanged(int newSelection) { - _comboQuality->setVisible(newSelection != ProjectionIndeces::Planar); - _labelQuality->setVisible(newSelection != ProjectionIndeces::Planar); - _labelFovH->setVisible(newSelection == ProjectionIndeces::Planar); - _lineFovH->setVisible(newSelection == ProjectionIndeces::Planar); - _labelFovV->setVisible(newSelection == ProjectionIndeces::Planar); - _lineFovV->setVisible(newSelection == ProjectionIndeces::Planar); - _labelHeightOffset->setVisible(newSelection == ProjectionIndeces::Cylindrical); - _lineHeightOffset->setVisible(newSelection == ProjectionIndeces::Cylindrical); - _checkBoxSpoutOutput->setVisible(newSelection == ProjectionIndeces::Fisheye - || newSelection == ProjectionIndeces::Equirectangular); -} - -void WindowControl::setDimensions(const QRectF& dimensions) { - _windowDims = dimensions; + WindowControl::ProjectionIndeces selected + = static_cast(newSelection); + _comboQuality->setVisible(selected != ProjectionIndeces::Planar); + _labelQuality->setVisible(selected != ProjectionIndeces::Planar); + _labelFovH->setVisible(selected == ProjectionIndeces::Planar); + _lineFovH->setVisible(selected == ProjectionIndeces::Planar); + _labelFovV->setVisible(selected == ProjectionIndeces::Planar); + _lineFovV->setVisible(selected == ProjectionIndeces::Planar); + _labelHeightOffset->setVisible(selected == ProjectionIndeces::Cylindrical); + _lineHeightOffset->setVisible(selected == ProjectionIndeces::Cylindrical); + _checkBoxSpoutOutput->setVisible(selected == ProjectionIndeces::Fisheye + || selected == ProjectionIndeces::Equirectangular); } void WindowControl::setWindowChangeCallback( @@ -416,22 +421,6 @@ QRectF& WindowControl::dimensions() { return _windowDims; } -QLineEdit* WindowControl::lineEditSizeWidth() { - return _size_x; -} - -QLineEdit* WindowControl::lineEditSizeHeight() { - return _size_y; -} - -QLineEdit* WindowControl::lineEditSizeOffsetX() { - return _offset_x; -} - -QLineEdit* WindowControl::lineEditSizeOffsetY() { - return _offset_y; -} - QCheckBox* WindowControl::checkBoxWindowDecor() { return _checkBoxWindowDecor; } @@ -444,66 +433,58 @@ QCheckBox* WindowControl::checkBoxSpoutOutput() { return _checkBoxSpoutOutput; } -std::string WindowControl::windowName() { +std::string WindowControl::windowName() const { return _windowName->text().toStdString(); } -sgct::ivec2 WindowControl::windowSize() { +sgct::ivec2 WindowControl::windowSize() const { return { - stoi(_size_x->text().toStdString()), - stoi(_size_y->text().toStdString()) + _sizeX->text().toInt(), + _sizeY->text().toInt() }; } -sgct::ivec2 WindowControl::windowPos() { +sgct::ivec2 WindowControl::windowPos() const { return { - stoi(_offset_x->text().toStdString()), - stoi(_offset_y->text().toStdString()) + _offsetX->text().toInt(), + _offsetY->text().toInt() }; } -bool WindowControl::isDecorated() { +bool WindowControl::isDecorated() const { return (_checkBoxWindowDecor->checkState() == Qt::Checked); } -bool WindowControl::isGuiWindow() { +bool WindowControl::isGuiWindow() const { return (_checkBoxWebGui->checkState() == Qt::Checked); } -bool WindowControl::isSpoutSelected() { +bool WindowControl::isSpoutSelected() const { return (_checkBoxSpoutOutput->checkState() == Qt::Checked); } -int WindowControl::projectionSelectedIndex() { - return _comboProjection->currentIndex(); +WindowControl::ProjectionIndeces WindowControl::projectionSelectedIndex() const { + return + static_cast(_comboProjection->currentIndex()); } -int WindowControl::qualitySelectedIndex() { - return _comboQuality->currentIndex(); -} - -int WindowControl::qualitySelectedValue() { +int WindowControl::qualitySelectedValue() const { return QualityValues[_comboQuality->currentIndex()]; } -float WindowControl::fovH() { +float WindowControl::fovH() const { return _lineFovH->text().toFloat(); } -float WindowControl::fovV() { +float WindowControl::fovV() const { return _lineFovV->text().toFloat(); } -float WindowControl::heightOffset() { +float WindowControl::heightOffset() const { return _lineHeightOffset->text().toFloat(); } -unsigned int WindowControl::monitorNum() { +unsigned int WindowControl::monitorNum() const { return _monIndex; } -WindowControl::~WindowControl() -{ - delete _layoutFullWindow; -} - From 92470f81297746e8a8156f7b08b73aaf04b8da71 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 15 Feb 2022 19:38:22 -0700 Subject: [PATCH 57/93] Improve contrast of window numbers --- apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index c184101ace..90ca571d84 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -39,6 +39,7 @@ MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, } void MonitorBox::paintEvent(QPaintEvent* event) { + Q_UNUSED(event) QPainter painter(this); QPen pen = painter.pen(); painter.setPen(pen); @@ -49,7 +50,11 @@ void MonitorBox::paintEvent(QPaintEvent* event) { } //Draw & fill monitors over the out-of-bounds regions paintMonitorBackgrounds(painter); - //Draw window(s) over both out-of-bounds and monitors + //Draw window number(s) first for darker contrast, then window(s) over both + //out-of-bounds and monitors + for (unsigned int i = 0; i < _nWindows; ++i) { + paintWindowNumber(painter, i); + } for (unsigned int i = 0; i < _nWindows; ++i) { paintWindow(painter, i); } @@ -101,7 +106,6 @@ void MonitorBox::paintWindow(QPainter& painter, size_t winIdx) { QBrush brush(fillColor); brush.setStyle(Qt::SolidPattern); painter.fillRect(_windowRendering[winIdx], brush); - paintWindowNumber(painter, winIdx); } } From 15d92719d39d2e32b2ebf2010edf9f70a4ead0d5 Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 17 Feb 2022 16:55:13 -0700 Subject: [PATCH 58/93] Added GUI tooltips, window label size correction, fixed button click bug --- .../launcher/include/sgctedit/windowcontrol.h | 2 +- .../ext/launcher/src/sgctedit/display.cpp | 16 +++-- .../ext/launcher/src/sgctedit/filesupport.cpp | 4 ++ .../ext/launcher/src/sgctedit/monitorbox.cpp | 12 ++-- .../ext/launcher/src/sgctedit/orientation.cpp | 7 ++ .../src/sgctedit/orientationdialog.cpp | 15 +++++ .../ext/launcher/src/sgctedit/sgctedit.cpp | 4 +- .../launcher/src/sgctedit/windowcontrol.cpp | 66 ++++++++++++++++++- 8 files changed, 114 insertions(+), 12 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index dc912ba06a..a413ecd979 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -95,7 +95,7 @@ private: {1200.0, 340.0, 1280.0, 720.0}, {50.0, 50.0, 1280.0, 720.0} }; - QList _monitorNames = { "Monitor 1", "Monitor 2" }; + QList _monitorNames = { "Primary", "Secondary" }; int _lineEditWidthFixed = 50; float _marginFractionOfWidgetSize = 0.025; unsigned int _nMonitors = 1; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 5832c87e98..7d3fa066ed 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -24,6 +24,7 @@ #include "sgctedit/display.h" +#include #include "sgctedit/monitorbox.h" #include "sgctedit/windowcontrol.h" #include @@ -39,14 +40,14 @@ Display::Display(std::shared_ptr monitorRenderBox, , _nMaxWindows(nMaxWindows) , _winColors(winColors) { - _addWindowButton = new QPushButton("Add Window", this); - _removeWindowButton = new QPushButton("Remove Window", this); + _addWindowButton = new QPushButton("Add Window"); + _removeWindowButton = new QPushButton("Remove Window"); //Add all window controls (some will be hidden from GUI initially) for (unsigned int i = 0; i < _nMaxWindows; ++i) { initializeWindowControl(); } - connect(_addWindowButton, &QPushButton::released, this, &Display::addWindow); - connect(_removeWindowButton, &QPushButton::released, this, &Display::removeWindow); + connect(_addWindowButton, &QPushButton::clicked, this, &Display::addWindow); + connect(_removeWindowButton, &QPushButton::clicked, this, &Display::removeWindow); initializeLayout(); } @@ -54,6 +55,13 @@ void Display::initializeLayout() { QVBoxLayout* layout = new QVBoxLayout(this); { QHBoxLayout* layoutMonButton = new QHBoxLayout; + _removeWindowButton->setToolTip( + "Remove window from the configuration (at least one window is required)" + ); + std::string addTip = fmt::format( + "Add a window to the configuration (up to {} windows allowed)", _nMaxWindows + ); + _addWindowButton->setToolTip(QString::fromStdString(addTip)); layoutMonButton->addWidget(_removeWindowButton); layoutMonButton->addStretch(1); layoutMonButton->addWidget(_addWindowButton); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 37d146ac7f..58033bd02b 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -41,6 +41,10 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL { QHBoxLayout* layoutFilename = new QHBoxLayout; QLabel* labelFilename = new QLabel; + QString fileTip = "Enter a filename for this custom configuration to be saved " + "as a .json file in the user/config/ directory"; + labelFilename->setToolTip(fileTip); + _lineFilename->setToolTip(fileTip); labelFilename->setText("Filename: "); layoutFilename->addStretch(1); layoutFilename->addWidget(labelFilename); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 90ca571d84..d956c0485f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -68,7 +68,9 @@ void MonitorBox::paintWidgetBorder(QPainter& painter, int width, int height) { void MonitorBox::paintMonitorBackgrounds(QPainter& painter) { painter.setPen(QPen(Qt::black, 2)); - painter.setFont(QFont("Arial", 14)); + QFont f("Arial"); + f.setPixelSize(24); + painter.setFont(f); for (unsigned int i = 0; i < _nMonitors; ++i) { if (i <= _monitorDimensionsScaled.size()) { painter.drawRect(_monitorDimensionsScaled[i]); @@ -78,10 +80,12 @@ void MonitorBox::paintMonitorBackgrounds(QPainter& painter) { painter.fillRect(_monitorDimensionsScaled[i], brush); if (_showLabel) { QPointF textPos = QPointF( - _monitorDimensionsScaled[i].left() + 5, - _monitorDimensionsScaled[i].top() + 18 + _monitorDimensionsScaled[i].left() + 4, + _monitorDimensionsScaled[i].top() + 24 ); - painter.drawText(textPos, QString::fromStdString(std::to_string(i + 1))); + if (i == 0) { + painter.drawText(textPos, "Primary"); + } } } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index c5a4be3c5c..e00bb75d08 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -34,7 +34,14 @@ Orientation::Orientation() QVBoxLayout* layoutOrientationControls = new QVBoxLayout; QPushButton* orientationButton = new QPushButton("Global Orientation"); _checkBoxVsync = new QCheckBox("VSync All Windows", this); + _checkBoxVsync->setToolTip( + "If enabled, the server will frame lock and wait for all client nodes" + ); layoutOrientationControls->addWidget(_checkBoxVsync); + orientationButton->setToolTip( + "Opens a separate dialog for setting the pitch, " + "yaw, and roll of the camera\n(the orientation applies to all viewports)" + ); layoutOrientationControls->addWidget(orientationButton); _layoutOrientationFull->addStretch(1); _layoutOrientationFull->addLayout(layoutOrientationControls); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 37218705d8..b60f56b9a1 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -55,6 +55,11 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) labelPitch->setText("Pitch: "); QHBoxLayout* layoutPitch = new QHBoxLayout; layoutPitch->addStretch(1); + QString pitchTip = "Pitch or elevation: negative numbers tilt the camera " + "downwards; positive numbers tilt upwards.\nThe allowed range is [-90, 90]. " + "Internally, this corresponds to the x value in the quaternion."; + labelPitch->setToolTip(pitchTip); + _linePitch->setToolTip(pitchTip); layoutPitch->addWidget(labelPitch); layoutPitch->addWidget(_linePitch); layoutWindow->addLayout(layoutPitch); @@ -62,6 +67,11 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) labelRoll ->setText("Roll: "); QHBoxLayout* layoutRoll = new QHBoxLayout; layoutRoll->addStretch(1); + QString rollTip = "Roll or bank: negative numbers rotate the camera counter-" + "clockwise; positive numbers clockwise.\nThe allowed range is [-180, 180]. " + "Internally, this corresponds to the z value in the quaternion."; + labelRoll->setToolTip(rollTip); + _lineRoll->setToolTip(rollTip); layoutRoll->addWidget(labelRoll); layoutRoll->addWidget(_lineRoll); layoutWindow->addLayout(layoutRoll); @@ -69,6 +79,11 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) labelYaw ->setText("Yaw: "); QHBoxLayout* layoutYaw = new QHBoxLayout; layoutYaw->addStretch(1); + QString yawTip = "Yaw, heading, or azimuth: negative numbers pan the camera " + "to the left; positive numbers pan to the\nright. The allowed range is " + "[-360, 360]. Internally, this corresponds to the y value in the quaternion."; + labelYaw->setToolTip(yawTip); + _lineYaw->setToolTip(yawTip); layoutYaw->addWidget(labelYaw); layoutYaw->addWidget(_lineYaw); layoutWindow->addLayout(layoutYaw); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 1e5a271dee..97cf4c996a 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -31,7 +31,7 @@ SgctEdit::SgctEdit(QWidget* parent, std::vector& windowLis , _windowList(windowList) { systemMonitorConfiguration(screenList); - setWindowTitle("Display/Window Configuration Editor"); + setWindowTitle("Window Configuration Editor"); createWidgets(); } @@ -52,6 +52,8 @@ void SgctEdit::systemMonitorConfiguration(const QList& screenList) { actualWidth, actualHeight }); +std::cout << _monitorSizeList.back().width() << "x" << _monitorSizeList.back().height() << " @ " +<< _monitorSizeList.back().x() << "," << _monitorSizeList.back().y() << std::endl; } _nMaxWindows = (_monitorSizeList.size() == 1) ? 3 : 4; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index ce141d8155..744c9b09e1 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -179,10 +179,13 @@ QVBoxLayout* WindowControl::initializeLayout() { { QHBoxLayout* layoutName = new QHBoxLayout; + QString tip("Enter a name for the window (displayed in title bar)"); QLabel* labelName = new QLabel(this); labelName->setText("Name: "); + labelName->setToolTip(tip); _windowName = new QLineEdit(this); _windowName->setFixedWidth(160); + _windowName->setToolTip(tip); layoutName->addWidget(labelName); layoutName->addWidget(_windowName); layoutName->addStretch(1); @@ -191,6 +194,12 @@ QVBoxLayout* WindowControl::initializeLayout() { if (_nMonitors > 1) { QHBoxLayout* layoutMonitorNum = new QHBoxLayout; + QLabel* labelLocation = new QLabel(this); + labelLocation->setText("Monitor: "); + QString tip("Select monitor where this window is located"); + labelLocation->setToolTip(tip); + _comboMonitorSelect->setToolTip(tip); + layoutMonitorNum->addWidget(labelLocation); layoutMonitorNum->addWidget(_comboMonitorSelect); layoutMonitorNum->addStretch(1); layoutWindowCtrl->addLayout(layoutMonitorNum); @@ -200,16 +209,22 @@ QVBoxLayout* WindowControl::initializeLayout() { { QLabel* labelSize = new QLabel(this); QLabel* labelDelim = new QLabel(this); + QLabel* labelUnit = new QLabel(this); QHBoxLayout* layoutSize = new QHBoxLayout; + labelSize->setToolTip("Enter window width & height in pixels"); + _sizeX->setToolTip("Enter window width (pixels)"); + _sizeY->setToolTip("Enter window height (pixels)"); layoutSize->addWidget(labelSize); labelSize->setText("Size:"); labelSize->setFixedWidth(55); layoutSize->addWidget(_sizeX); layoutSize->addWidget(labelDelim); layoutSize->addWidget(_sizeY); + layoutSize->addWidget(labelUnit); layoutSize->addStretch(1); labelDelim->setText("x"); labelDelim->setFixedWidth(9); + labelUnit->setText(" px"); layoutWindowCtrl->addLayout(layoutSize); } @@ -218,35 +233,56 @@ QVBoxLayout* WindowControl::initializeLayout() { { QLabel* labelOffset = new QLabel(this); QLabel* labelComma = new QLabel(this); + QLabel* labelUnit = new QLabel(this); QHBoxLayout* layoutOffset = new QHBoxLayout; + std::string baseTip = "Enter {} location of window's upper left " + "corner from monitor's {} (pixels)"; + labelOffset->setToolTip(QString::fromStdString(fmt::format( + baseTip, "x,y", "upper-left corner origin"))); + _offsetX->setToolTip(QString::fromStdString(fmt::format( + baseTip, "x", "left side"))); + _offsetY->setToolTip(QString::fromStdString(fmt::format( + baseTip, "y", "top edge"))); layoutOffset->addWidget(labelOffset); labelOffset->setText("Offset:"); labelOffset->setFixedWidth(55); layoutOffset->addWidget(_offsetX); layoutOffset->addWidget(labelComma); layoutOffset->addWidget(_offsetY); + layoutOffset->addWidget(labelUnit); layoutOffset->addStretch(1); labelComma->setText(","); labelComma->setFixedWidth(9); + labelUnit->setText(" px"); layoutWindowCtrl->addLayout(layoutOffset); } { QHBoxLayout* layoutCheckboxesFull1 = new QHBoxLayout; QVBoxLayout* layoutCheckboxesFull2 = new QVBoxLayout; QHBoxLayout* layoutFullscreenButton = new QHBoxLayout; + _fullscreenButton->setToolTip("If enabled, the window will be created in an " + "exclusive fullscreen mode. The size of this\nwindow will be set to the " + "screen resolution, and the window decoration automatically disabled."); layoutFullscreenButton->addWidget(_fullscreenButton); layoutFullscreenButton->addStretch(1); layoutCheckboxesFull2->addLayout(layoutFullscreenButton); QHBoxLayout* layoutCBoxWindowDecor = new QHBoxLayout; + _checkBoxWindowDecor->setToolTip("If enabled, the window will not have a border " + "frame or title bar, and no\n controls for minimizing/maximizing, " + "resizing, or closing the window."); layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); layoutCBoxWindowDecor->addStretch(1); layoutCheckboxesFull2->addLayout(layoutCBoxWindowDecor); QHBoxLayout* _layoutCBoxWebGui= new QHBoxLayout; + _checkBoxWebGui->setToolTip("If enabled, the window will be dedicated solely to " + "displaying the GUI controls, and will not\nrender any 3D content. All other " + "window(s) will render in 3D but will not have GUI controls."); _layoutCBoxWebGui->addWidget(_checkBoxWebGui); _layoutCBoxWebGui->addStretch(1); layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); QVBoxLayout* layoutProjectionGroup = new QVBoxLayout; QHBoxLayout* layoutComboProjection = new QHBoxLayout; + _comboProjection->setToolTip("Select from the supported window projection types"); layoutComboProjection->addWidget(_comboProjection); layoutComboProjection->addStretch(1); layoutProjectionGroup->addLayout(layoutComboProjection); @@ -255,12 +291,24 @@ QVBoxLayout* WindowControl::initializeLayout() { borderProjectionGroup->setLayout(layoutProjectionGroup); borderProjectionGroup->setVisible(true); QHBoxLayout* layoutCBoxSpoutOutput= new QHBoxLayout; + QString spoutTip = "This projection method provides the ability to share the " + "reprojected image using the Spout library.\nThis library only supports the " + "Windows operating system. Spout makes it possible to make the rendered\n" + "images available to other real-time applications on the same machine for " + "further processing.\nThe SpoutOutputProjection option can work with either " + "Fisheye or Equirectangular projection."; + _checkBoxSpoutOutput->setToolTip(spoutTip); layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); layoutCBoxSpoutOutput->addStretch(1); layoutProjectionGroup->addLayout(layoutCBoxSpoutOutput); QHBoxLayout* layoutComboQuality = new QHBoxLayout; _labelQuality = new QLabel; _labelQuality->setText("Quality:"); + QString qualityTip = "Determines the pixel resolution of the projection " + "rendering. The higher resolution,\nthe better the rendering quality, but at " + "the expense of increased rendering times."; + _labelQuality->setToolTip(qualityTip); + _comboQuality->setToolTip(qualityTip); layoutComboQuality->addWidget(_labelQuality); layoutComboQuality->addWidget(_comboQuality); layoutComboQuality->addStretch(1); @@ -268,20 +316,34 @@ QVBoxLayout* WindowControl::initializeLayout() { QHBoxLayout* layoutFovH = new QHBoxLayout; _labelFovH = new QLabel; _labelFovH->setText("Horizontal FOV:"); + QString hfovTip = "The total horizontal field of view of the viewport (degrees). " + "Internally,\nthe values for 'left' & 'right' will each be half this value."; + _labelFovH->setToolTip(hfovTip); + _lineFovH->setToolTip(hfovTip); layoutFovH->addWidget(_labelFovH); - layoutFovH->addWidget(_lineFovH); layoutFovH->addStretch(1); + layoutFovH->addWidget(_lineFovH); QHBoxLayout* layoutFovV = new QHBoxLayout; _labelFovV = new QLabel; _labelFovV->setText("Vertical FOV:"); + QString vfovTip = "The total vertical field of view of the viewport (degrees). " + "Internally,\nthe values for 'up' & 'down' will each be half this value."; + _labelFovV->setToolTip(vfovTip); + _lineFovV->setToolTip(vfovTip); layoutFovV->addWidget(_labelFovV); - layoutFovV->addWidget(_lineFovV); layoutFovV->addStretch(1); + layoutFovV->addWidget(_lineFovV); layoutProjectionGroup->addLayout(layoutFovH); layoutProjectionGroup->addLayout(layoutFovV); QHBoxLayout* layoutHeightOffset = new QHBoxLayout; _labelHeightOffset = new QLabel; _labelHeightOffset->setText("Height Offset:"); + QString heightTip = "Offsets the height from which the cylindrical projection " + "is generated.\nThis is, in general, only necessary if the user position is " + "offset and\ncountering that offset is desired in order to continue producing" + "\na 'standard' cylindrical projection."; + _labelHeightOffset->setToolTip(heightTip); + _lineHeightOffset->setToolTip(heightTip); layoutHeightOffset->addWidget(_labelHeightOffset); layoutHeightOffset->addWidget(_lineHeightOffset); layoutHeightOffset->addStretch(1); From 976dd8912840817d65e115300a650ca1d4d370ad Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 20 Feb 2022 21:57:14 -0700 Subject: [PATCH 59/93] Fix for monitor preview to handle windows os negative coordinates --- .../launcher/include/sgctedit/monitorbox.h | 2 ++ .../ext/launcher/src/sgctedit/monitorbox.cpp | 35 ++++++++++++------- .../ext/launcher/src/sgctedit/sgctedit.cpp | 2 -- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 2f331b373e..8e19d860ad 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -71,6 +72,7 @@ private: unsigned int _nMonitors = 1; std::vector _monitorResolution; std::vector _monitorDimensionsScaled; + QRectF _negativeCorrectionOffsets = {0.f, 0.f, 0.f, 0.f}; std::vector _windowResolutions; std::vector _windowRendering = { {0.f, 0.f, 0.f, 0.f}, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index d956c0485f..06df2c6a21 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -24,7 +24,7 @@ #include "sgctedit/monitorbox.h" -constexpr float MarginFractionOfWidgetSize = 0.025; +constexpr float MarginFractionOfWidgetSize = 0.025f; MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, unsigned int nWindows, const std::array& winColors) @@ -33,7 +33,7 @@ MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, , _nWindows(nWindows) , _colorsForWindows(winColors) { - _nMonitors = monitorResolution.size(); + _nMonitors = static_cast(monitorResolution.size()); _showLabel = (_nMonitors > 1); mapMonitorResolutionToWidgetCoordinates(); } @@ -102,7 +102,7 @@ void MonitorBox::paintWindowBeyondBounds(QPainter& painter, unsigned int winIdx) } void MonitorBox::paintWindow(QPainter& painter, size_t winIdx) { - setPenSpecificToWindow(painter, winIdx, true); + setPenSpecificToWindow(painter, static_cast(winIdx), true); if (winIdx <= _windowRendering.size()) { painter.drawRect(_windowRendering[winIdx]); QColor fillColor = _colorsForWindows[winIdx]; @@ -135,15 +135,22 @@ void MonitorBox::windowDimensionsChanged(unsigned int monitorIdx, unsigned int w } void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { - QSize virtualDesktopResolution; + for (const QRect& m : _monitorResolution) { + if (m.x() < _negativeCorrectionOffsets.x()) { + _negativeCorrectionOffsets.setX(m.x()); + } + if (m.y() < _negativeCorrectionOffsets.y()) { + _negativeCorrectionOffsets.setY(m.y()); + } + } float maxWidth = 0.f; float maxHeight = 0.f; for (const QRect& m : _monitorResolution) { - if ((m.x() + m.width()) > maxWidth) { - maxWidth = m.x() + m.width(); + if ((m.x() + m.width() - _negativeCorrectionOffsets.x()) > maxWidth) { + maxWidth = m.x() + m.width() - _negativeCorrectionOffsets.x(); } - if ((m.y() + m.height()) > maxHeight) { - maxHeight = m.y() + m.height(); + if ((m.y() + m.height() - _negativeCorrectionOffsets.y()) > maxHeight) { + maxHeight = m.y() + m.height() - _negativeCorrectionOffsets.y(); } } float aspectRatio = maxWidth / maxHeight; @@ -172,9 +179,11 @@ void MonitorBox::computeScaledResolutionLandscape(float aspectRatio, float maxWi float newHeight = virtualWidth / aspectRatio; for (size_t m = 0; m < _monitorResolution.size(); ++m) { _monitorOffsets.push_back({ - _marginWidget + _monitorResolution[m].x() * _monitorScaleFactor, + _marginWidget + (_monitorResolution[m].x() - _negativeCorrectionOffsets.x()) + * _monitorScaleFactor, _marginWidget + (_monitorWidgetSize.height() - newHeight) / 2.0 + - _monitorResolution[m].y() * _monitorScaleFactor + (_monitorResolution[m].y() - _negativeCorrectionOffsets.y()) + * _monitorScaleFactor }); } } @@ -188,8 +197,10 @@ void MonitorBox::computeScaledResolutionPortrait(float aspectRatio, float maxHei for (size_t m = 0; m < _monitorResolution.size(); ++m) { _monitorOffsets.push_back({ _marginWidget + (_monitorWidgetSize.width() - newWidth) / 2.0 - + _monitorResolution[m].x() * _monitorScaleFactor, - _marginWidget + _monitorResolution[m].y() * _monitorScaleFactor + + (_monitorResolution[m].x() - _negativeCorrectionOffsets.x()) + * _monitorScaleFactor, + _marginWidget + (_monitorResolution[m].y() - _negativeCorrectionOffsets.y()) + * _monitorScaleFactor }); } } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 97cf4c996a..38ac9516b6 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -52,8 +52,6 @@ void SgctEdit::systemMonitorConfiguration(const QList& screenList) { actualWidth, actualHeight }); -std::cout << _monitorSizeList.back().width() << "x" << _monitorSizeList.back().height() << " @ " -<< _monitorSizeList.back().x() << "," << _monitorSizeList.back().y() << std::endl; } _nMaxWindows = (_monitorSizeList.size() == 1) ? 3 : 4; } From 49aa1d524f712b76973545639afb3b2be370e781 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 22 Feb 2022 13:50:16 -0700 Subject: [PATCH 60/93] Some warnings fixes --- .../ext/launcher/include/sgctedit/windowcontrol.h | 10 +++++----- apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp | 2 +- .../ext/launcher/src/sgctedit/windowcontrol.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index a413ecd979..9938583988 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -90,14 +90,14 @@ private: std::function _windowChangeCallback; std::function _windowGuiCheckCallback; QRectF defaultWindowSizes[4] = { - {50.0, 50.0, 1280.0, 720.0}, - {900.0, 250.0, 1280.0, 720.0}, - {1200.0, 340.0, 1280.0, 720.0}, - {50.0, 50.0, 1280.0, 720.0} + {50.f, 50.f, 1280.f, 720.f}, + {900.f, 250.f, 1280.f, 720.f}, + {1200.f, 340.f, 1280.f, 720.f}, + {50.f, 50.f, 1280.f, 720.f} }; QList _monitorNames = { "Primary", "Secondary" }; int _lineEditWidthFixed = 50; - float _marginFractionOfWidgetSize = 0.025; + float _marginFractionOfWidgetSize = 0.025f; unsigned int _nMonitors = 1; unsigned int _monIndex = 0; unsigned int _index = 0; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 38ac9516b6..0e2603354f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -37,7 +37,7 @@ SgctEdit::SgctEdit(QWidget* parent, std::vector& windowLis void SgctEdit::systemMonitorConfiguration(const QList& screenList) { size_t nScreensManaged = std::min(screenList.length(), 2); - for (size_t s = 0; s < nScreensManaged; ++s) { + for (unsigned int s = 0; s < static_cast(nScreensManaged); ++s) { int actualWidth = std::max( screenList[s]->size().width(), screenList[s]->availableGeometry().width() diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 744c9b09e1..a327fff657 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -64,7 +64,7 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex , _monitorResolutions(monitorDims) , _colorForWindow(winColor) { - _nMonitors = _monitorResolutions.size(); + _nMonitors = static_cast(_monitorResolutions.size()); createWidgets(parent); } @@ -390,7 +390,7 @@ void WindowControl::onOffsetXChanged(const QString& newText) { _windowChangeCallback(_monIndex, _index, _windowDims); } } - catch (std::exception &e) { + catch (std::exception) { //The QIntValidator ensures that the range is a +/- integer //However, it's possible to enter only a - character which //causes an exception throw, which is ignored here (when user @@ -407,7 +407,7 @@ void WindowControl::onOffsetYChanged(const QString& newText) { _windowChangeCallback(_monIndex, _index, _windowDims); } } - catch (std::exception &e) { + catch (std::exception) { //See comment in onOffsetXChanged } } From 133645d6467d3a410d2a0961284b04136a5c5383 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 22 Feb 2022 14:40:14 -0700 Subject: [PATCH 61/93] Header file public methods comment blocks --- .../launcher/include/sgctedit/monitorbox.h | 37 +++++++++++++++++-- .../launcher/include/sgctedit/windowcontrol.h | 29 ++++++++++++--- .../ext/launcher/src/sgctedit/monitorbox.cpp | 12 +++--- .../launcher/src/sgctedit/windowcontrol.cpp | 12 ------ 4 files changed, 64 insertions(+), 26 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index 8e19d860ad..a516c9be4c 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -43,19 +43,50 @@ class MonitorBox : public QWidget { Q_OBJECT public: + /** + * Constructor for MonitorBox class, which displays the system's monitor(s), + * their relative position and size, and window(s) that they contain + * + * \param widgetDims The size of the display widget in pixels, stored in QRect + * \param monitorResolution A vector containing the monitor's maximum display + * size in pixels in a QRect object + * \param nWindows The current number of windows that has been selected by the user + * \param winColors An array of QColor objects for window colors. The indexing of + * this array matches the window indexing used elsewhere in the + * class. This allows for a unique color for each window. + */ MonitorBox(QRect widgetDims, std::vector monitorResolution, unsigned int nWindows, const std::array& winColors); - void mapMonitorResolutionToWidgetCoordinates(); + /** + * Maps window resolution into the scaled resolution of the display widget + * + * \param mIdx The zero-based monitor index (primary monitor is 0) + * \param wIdx The zero-based window index + * \param winDimensions Dimensions (pixels) of window to be mapped in QRect + */ void mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, - const QRectF& w); + const QRectF& winDimensions); + /** + * Sets the number of windows to be displayed + * + * \param nWindows Number of windows to be displayed + */ void setNumWindowsDisplayed(unsigned int nWindows); - void windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, + /** + * Called when window dimensions or monitor location have changed, requiring redraw + * + * \param mIdx The zero-based monitor index (primary monitor is 0) + * \param wIdx The zero-based window index + * \param newDimensions Dimensions (pixels) of window to be mapped in QRect + */ + void windowDimensionsChanged(unsigned int mIdx, unsigned int wIdx, const QRectF& newDimensions); protected: void paintEvent(QPaintEvent* event) override; private: + void mapMonitorResolutionToWidgetCoordinates(); void paintWidgetBorder(QPainter& painter, int width, int height); void paintMonitorBackgrounds(QPainter& painter); void paintWindow(QPainter& painter, size_t winIdx); diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 9938583988..665d00e1d7 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -38,18 +38,37 @@ class WindowControl : public QWidget { Q_OBJECT public: + /** + * Constructor for WindowControl class, which contains settings and configuration + * for individual windows + * + * \param monitorIndex The zero-based index for monitor number that this window + * resides in + * \param windowIndex The zero-based window index + * \param monitorDims Vector of monitor dimensions in QRect form + * \param winColor A QColor object for this window's unique color + */ WindowControl(unsigned int monitorIndex, unsigned int windowIndex, std::vector& monitorDims, const QColor& winColor, QWidget *parent); ~WindowControl(); + /** + * Sets callback function to be invoked when a window's setting changes + * + * \param cb Callback function that accepts the listed arg types, in order of + * monitorIndex, windowIndex, and windowDims (that were just changed) + */ void setWindowChangeCallback(std::function cb); + /** + * Sets callback function to be invoked when a window gets its GUI checkbox selected + * + * \param cb Callback function that accepts the index of the window that has its + * WebGUI option selected + */ void setWebGuiChangeCallback(std::function cb); void showWindowLabel(bool show); QVBoxLayout* initializeLayout(); QRectF& dimensions(); - QCheckBox* checkBoxWindowDecor(); - QCheckBox* checkBoxWebGui(); - QCheckBox* checkBoxSpoutOutput(); std::string windowName() const; sgct::ivec2 windowSize() const; sgct::ivec2 windowPos() const; @@ -70,8 +89,6 @@ public: Equirectangular }; ProjectionIndeces projectionSelectedIndex() const; - int QualityValues[10] = {256, 512, 1024, 1536, 2048, 4096, 8192, 16384, - 32768, 65536}; private slots: void onSizeXChanged(const QString& newText); @@ -96,6 +113,8 @@ private: {50.f, 50.f, 1280.f, 720.f} }; QList _monitorNames = { "Primary", "Secondary" }; + int QualityValues[10] = { 256, 512, 1024, 1536, 2048, 4096, 8192, 16384, + 32768, 65536 }; int _lineEditWidthFixed = 50; float _marginFractionOfWidgetSize = 0.025f; unsigned int _nMonitors = 1; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 06df2c6a21..8d9df62cc8 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -122,16 +122,16 @@ void MonitorBox::paintWindowNumber(QPainter& painter, unsigned int winIdx) { } void MonitorBox::setPenSpecificToWindow(QPainter& painter, unsigned int windowIdx, - bool visibleBorder) + bool visibleBorder) { int penWidth = (visibleBorder) ? 1 : -1; painter.setPen(QPen(_colorsForWindows[windowIdx], penWidth)); } -void MonitorBox::windowDimensionsChanged(unsigned int monitorIdx, unsigned int windowIdx, - const QRectF& newDimensions) +void MonitorBox::windowDimensionsChanged(unsigned int mIdx, unsigned int wIdx, + const QRectF& newDimensions) { - mapWindowResolutionToWidgetCoordinates(monitorIdx, windowIdx, newDimensions); + mapWindowResolutionToWidgetCoordinates(mIdx, wIdx, newDimensions); } void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { @@ -214,12 +214,12 @@ void MonitorBox::setNumWindowsDisplayed(unsigned int nWindows) { void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, - const QRectF& w) + const QRectF& winDimensions) { if (mIdx > (_maxNumMonitors - 1) || wIdx > (_nWindows - 1)) { return; } - QRectF wF = w; + QRectF wF = winDimensions; _windowRendering[wIdx] = { _monitorDimensionsScaled[mIdx].x() + wF.left() * _monitorScaleFactor, _monitorDimensionsScaled[mIdx].y() + wF.top() * _monitorScaleFactor, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index a327fff657..ac2469c07a 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -483,18 +483,6 @@ QRectF& WindowControl::dimensions() { return _windowDims; } -QCheckBox* WindowControl::checkBoxWindowDecor() { - return _checkBoxWindowDecor; -} - -QCheckBox* WindowControl::checkBoxWebGui() { - return _checkBoxWebGui; -} - -QCheckBox* WindowControl::checkBoxSpoutOutput() { - return _checkBoxSpoutOutput; -} - std::string WindowControl::windowName() const { return _windowName->text().toStdString(); } From 0632fe0c6c12760f0493c8dc646351e5552deb19 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 22 Feb 2022 22:26:09 -0700 Subject: [PATCH 62/93] More header file public methods comments --- .../ext/launcher/include/sgctedit/display.h | 24 +++++- .../launcher/include/sgctedit/orientation.h | 30 ++++++- .../include/sgctedit/orientationdialog.h | 7 ++ .../ext/launcher/include/sgctedit/sgctedit.h | 27 ++++++- .../launcher/include/sgctedit/windowcontrol.h | 79 +++++++++++++++++++ .../ext/launcher/src/sgctedit/display.cpp | 6 -- .../ext/launcher/src/sgctedit/orientation.cpp | 2 +- .../ext/launcher/src/sgctedit/sgctedit.cpp | 2 +- 8 files changed, 165 insertions(+), 12 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index b6144bfc32..b874f913a4 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -45,12 +45,34 @@ class Display : public QWidget { Q_OBJECT public: + /** + * Constructor for Display class, which manages the overall control layout including + * monitorBox, multiple WindowControl columns, and additional controls + * + * \param monitorRenderBox pointer to the MonitorBox object + * \param monitorSizeList A vector containing QRect objects containing pixel dims + * of each monitor + * \param nMaxWindows The maximum number of windows allowed (depends on the number + * of monitors in the system) + * \param winColors An array of QColor objects for window colors. The indexing of + * this array matches the window indexing used elsewhere in the + * class. This allows for a unique color for each window. + */ Display(std::shared_ptr monitorRenderBox, std::vector& monitorSizeList, unsigned int nMaxWindows, const std::array& winColors); + /** + * Returns a vector of pointers to all WindowControl objects for all windows + * + * \return vector of pointers of WindowControl objects + */ std::vector> windowControls() const; + /** + * Returns the current number of windows + * + * \return the currently-selected number of windows in unsigned int + */ unsigned int nWindows() const; - void uncheckWebGuiOptions(); private slots: void addWindow(); diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index ee13404cdf..d2266f48b1 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -37,9 +37,37 @@ class Orientation : public QWidget { Q_OBJECT public: + /** + * Constructor for Orientation class, which manages the overall control layout including + * monitorBox, multiple WindowControl columns, and additional controls + * + * \param monitorRenderBox pointer to the MonitorBox object + * \param monitorSizeList A vector containing QRect objects containing pixel dims + * of each monitor + * \param nMaxWindows The maximum number of windows allowed (depends on the number + * of monitors in the system) + * \param winColors An array of QColor objects for window colors. The indexing of + * this array matches the window indexing used elsewhere in the + * class. This allows for a unique color for each window. + */ Orientation(); - void addButtonToLayout(QVBoxLayout* parentLayout); + /** + * Add Orientation controls to the parent layout + * + * \param parentLayout the layout to which the Orientation's controls will be added + */ + void addControlsToParentLayout(QVBoxLayout* parentLayout); + /** + * Gets the user-provided x,y,z orientation values (degrees) + * + * \return the orientation angles provided in sgct::quat object + */ sgct::quat orientationValue() const; + /** + * Gets the value for if VSync is enabled + * + * \return true if the VSync option is checked/enabled + */ bool vsyncValue() const; private slots: diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h index e026c7bbaa..9d9615dcbf 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h @@ -36,6 +36,13 @@ class QWidget; class OrientationDialog : public QDialog { Q_OBJECT public: + /** + * Constructor for OrientationDialog object which contains the input text boxes for + * orientation x,y,z values + * + * \param orientation x,y,z angles in degrees contained in sgct::quat object + * \param parent pointer to Qt QWidget parent object + */ OrientationDialog(sgct::quat& orientation, QWidget* parent); private slots: diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index dbab4e2d58..a664a60706 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -45,15 +45,38 @@ class SgctEdit final : public QDialog { Q_OBJECT public: + /** + * Constructor for SgctEdit class, the underlying class for the full window + * configuration editor + * + * \param parent The Qt QWidget parent object + * \param windowList vector of sgct::config::Window objects which will be modified + * by the user settings, and then used for writing to file in + * the launcher code + * \param cluster reference to sgct::config::Cluster object that contains sgct + * objects that will be modified by the window configuration settings + * \param screenList A QList containing a QScreen object for each monitor in the + * system + */ SgctEdit(QWidget* parent, std::vector& windowList, sgct::config::Cluster& cluster, const QList& screenList); ~SgctEdit(); - void addDisplayLayout(QHBoxLayout* layout); - void createWidgets(); + /** + * Used to determine if the window configuration was saved to file, or canceled + * + * \return true if configuration was saved to file + */ bool wasSaved() const; + /** + * Returns the saved filename + * + * \return saved filename in std::string + */ std::string saveFilename(); private: + void addDisplayLayout(QHBoxLayout* layout); + void createWidgets(); void systemMonitorConfiguration(const QList& screenList); std::shared_ptr _monBox = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 665d00e1d7..d99d9630e5 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -66,20 +66,94 @@ public: * WebGUI option selected */ void setWebGuiChangeCallback(std::function cb); + /** + * Makes the window label at top of a window control column visible + * + * \param bool Shows the window label if true + */ void showWindowLabel(bool show); + /** + * Initializes the layout of a window controls column, returning the Qt layout object + * + * \return the QVBoxLayout object that contains the entire windows control column + */ QVBoxLayout* initializeLayout(); + /** + * Returns the dimensions of the window + * + * \return the QRectF object that contains the windows dimensions + */ QRectF& dimensions(); + /** + * Returns the title name of the window + * + * \return the std::string of the window name + */ std::string windowName() const; + /** + * Returns the user-entered window size width, height from the text line objects + * + * \return the user-entered window size in sgct::ivec2 object + */ sgct::ivec2 windowSize() const; + /** + * Returns the user-entered window position in x,y pixles from the text line objects + * + * \return the user-entered window position in sgct::ivec2 object + */ sgct::ivec2 windowPos() const; + /** + * Returns bool for if the window control checkbox is set to be decorated + * + * \return bool for if window decoration is enabled + */ bool isDecorated() const; + /** + * Returns bool for if the window control checkbox spout selection is enabled + * + * \return bool for if window has spout enabled + */ bool isSpoutSelected() const; + /** + * Returns bool for if the window control checkbox for WebGUI is enabled + * + * \return bool for if window has WebGUI enabled + */ bool isGuiWindow() const; + /** + * Function called in order to disable/uncheck the WebGUI checkbox option + */ void uncheckWebGuiOption(); + /** + * Returns index number of the selected window quality value. This is an index into + * the QualityValues array + * + * \return index int into the QualityValues array + */ int qualitySelectedValue() const; + /** + * Returns index number of the monitor that this window is assigned to + * + * \return int index of monitor + */ unsigned int monitorNum() const; + /** + * Returns the user-entered horizontal field-of-view (planar projection only) + * + * \return float value of horizontal FOV + */ float fovH() const; + /** + * Returns the user-entered vertical field-of-view (planar projection only) + * + * \return float value of vertical FOV + */ float fovV() const; + /** + * Returns the user-entered height offset (cylindrical projection only) + * + * \return float value of height offset + */ float heightOffset() const; enum class ProjectionIndeces { Planar = 0, @@ -88,6 +162,11 @@ public: Cylindrical, Equirectangular }; + /** + * Returns the user-selected window projection type + * + * \return ProjectionIndeces enum of the projection type + */ ProjectionIndeces projectionSelectedIndex() const; private slots: diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 7d3fa066ed..93ab23ceb0 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -161,9 +161,3 @@ void Display::initializeWindowControl() { } } -void Display::uncheckWebGuiOptions() { - for (std::shared_ptr w : _windowControl) { - w->uncheckWebGuiOption(); - } -} - diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index e00bb75d08..4f939bdaa4 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -55,7 +55,7 @@ Orientation::Orientation() } } -void Orientation::addButtonToLayout(QVBoxLayout* parentLayout) { +void Orientation::addControlsToParentLayout(QVBoxLayout* parentLayout) { parentLayout->addLayout(_layoutOrientationFull); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 0e2603354f..aa94140a98 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -78,7 +78,7 @@ void SgctEdit::createWidgets() { } { layoutMainV->addLayout(layoutMainH); - _orientationWidget->addButtonToLayout(layoutMainV); + _orientationWidget->addControlsToParentLayout(layoutMainV); _fileSupportWidget = new FileSupport( layoutMainV, _monitorSizeList, From 3a529c30e79fdd5be130ff71c7e2ffeabdf06924 Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 24 Feb 2022 23:16:17 -0700 Subject: [PATCH 63/93] Added save file dialog and option to run with temp config file --- .../launcher/include/sgctedit/filesupport.h | 38 ++++++-- .../ext/launcher/include/sgctedit/sgctedit.h | 6 +- .../ext/launcher/src/launcherwindow.cpp | 26 ++++-- .../ext/launcher/src/sgctedit/filesupport.cpp | 90 ++++++++++--------- .../ext/launcher/src/sgctedit/sgctedit.cpp | 17 ++-- 5 files changed, 117 insertions(+), 60 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index e713596465..669995675f 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -27,14 +27,17 @@ #include +#include #include #include #include +#include #include #include #include #include #include +#include #include #include @@ -49,23 +52,44 @@ using ProjectionOptions = std::variant< sgct::config::SpoutOutputProjection >; +struct SgctConfigElements { + std::vector& windowList; + sgct::config::Cluster& cluster; +}; + +struct UserConfigurationElements { + std::vector& monitorList; + std::shared_ptr display; + Orientation* orientation; + const std::string configSavePath; +}; + class FileSupport : public QWidget { Q_OBJECT public: - FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, - std::shared_ptr display, Orientation* orientation, - std::vector& windowList, sgct::config::Cluster& cluster, - std::function cb); + /** + * Constructor for FileSupport class, which saves the window configuration settings + * into the SGCT json structure according to the sgct code + * + * \param parentLayout Qt vertical (QVBoxLayout) layout where controls are added + * \param cfgElements struct of elements needed to read user settings from GUI + * \param sgctElements struct of the window and cluster objects needed for saving + * \param finishedCallback function to be called when user has selected to either + * save changes to file, apply and run without saving, or cancel + */ + FileSupport(QVBoxLayout* parentLayout, UserConfigurationElements& cfgElements, + SgctConfigElements& sgctElements, std::function finishedCallback); std::string saveFilename(); private slots: - void filenameEdited(const QString& newString); void cancel(); void save(); + void apply(); private: bool isWindowFullscreen(unsigned int monitorIdx, sgct::ivec2 wDims); std::optional findGuiWindow(); + void saveConfigToSgctFormat(); void saveCluster(); void saveWindows(); void saveUser(); @@ -80,13 +104,15 @@ private: QHBoxLayout* _layoutButtonBox = nullptr; QPushButton* _saveButton = nullptr; QPushButton* _cancelButton = nullptr; + QPushButton* _applyButton = nullptr; std::shared_ptr _displayWidget; Orientation* _orientationWidget; std::vector& _monitors; sgct::config::Cluster& _cluster; std::vector& _windowList; - QLineEdit* _lineFilename = nullptr; std::function _finishedCallback; + const std::string _userConfigPath; + std::string _saveTarget; }; #endif // __OPENSPACE_UI_LAUNCHER___FILESUPPORT___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index a664a60706..8891341f8d 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -57,9 +57,12 @@ public: * objects that will be modified by the window configuration settings * \param screenList A QList containing a QScreen object for each monitor in the * system + * \param userConfigPath A string containing the file path of the user config + * directory where all window configs are stored */ SgctEdit(QWidget* parent, std::vector& windowList, - sgct::config::Cluster& cluster, const QList& screenList); + sgct::config::Cluster& cluster, const QList& screenList, + const std::string userConfigPath); ~SgctEdit(); /** * Used to determine if the window configuration was saved to file, or canceled @@ -89,6 +92,7 @@ private: Orientation* _orientationWidget = nullptr; sgct::config::Cluster& _cluster; std::vector& _windowList; + const std::string _userConfigPath; bool _saveSelected = false; unsigned int _nMaxWindows = 3; const std::array _colorsForWindows = { diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index e6aba73710..36a1841b74 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -500,6 +500,8 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { ); } + //Always add the .cfg sgct default as first item + _windowConfigBox->insertItem(0, QString::fromStdString(_sgctConfigName)); // Try to find the requested configuration file and set it as the current one. As we // have support for function-generated configuration files that will not be in the // list we need to add a preset that doesn't exist a file for @@ -509,8 +511,11 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { } else { // Add the requested preset at the top - _windowConfigBox->insertItem(0, QString::fromStdString(preset)); - _windowConfigBox->setCurrentIndex(0); + _windowConfigBox->insertItem(1, QString::fromStdString(preset)); + //Increment the user config count because there is an additional option added + //before the user config options + _userConfigCount++; + _windowConfigBox->setCurrentIndex(1); } } @@ -559,19 +564,26 @@ void LauncherWindow::openWindowEditor() { } sgct::config::Cluster cluster; std::vector windowList; - SgctEdit editor(this, windowList, cluster, screenList); + SgctEdit editor(this, windowList, cluster, screenList, _userConfigPath); editor.exec(); if (editor.wasSaved()) { - std::string fullFilename = editor.saveFilename() + ".json"; - const std::string path = _userConfigPath + fullFilename; + std::string ext = ".json"; + std::string savePath = editor.saveFilename(); + if (savePath.size() >= ext.size() + && !(savePath.substr(savePath.size() - ext.size()).compare(ext) == 0)) + { + savePath += ext; + } if (cluster.nodes.size() == 0) { cluster.nodes.push_back(sgct::config::Node()); } for (auto w : windowList) { cluster.nodes[0].windows.push_back(w); } - saveWindowConfig(this, path, cluster); - populateWindowConfigsList(fullFilename); + saveWindowConfig(this, savePath, cluster); + //Truncate path to convert this back to path relative to _userConfigPath + savePath = savePath.substr(_userConfigPath.size()); + populateWindowConfigsList(savePath); } else { const std::string current = _windowConfigBox->currentText().toStdString(); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 58033bd02b..f76f64ea0e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -24,50 +24,37 @@ #include "sgctedit/filesupport.h" -FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorList, - std::shared_ptr display, Orientation* orientation, - std::vector& windowList, - sgct::config::Cluster& cluster, std::function cb) - : _displayWidget(display) - , _orientationWidget(orientation) - , _monitors(monitorList) - , _cluster(cluster) - , _windowList(windowList) - , _finishedCallback(cb) +FileSupport::FileSupport(QVBoxLayout* parentLayout, + UserConfigurationElements& cfgElements, + SgctConfigElements& sgctElements, + std::function finishedCallback) + : _displayWidget(cfgElements.display) + , _orientationWidget(cfgElements.orientation) + , _monitors(cfgElements.monitorList) + , _cluster(sgctElements.cluster) + , _windowList(sgctElements.windowList) + , _finishedCallback(finishedCallback) + , _userConfigPath(cfgElements.configSavePath) { QVBoxLayout* layoutFullVertical = new QVBoxLayout; - _lineFilename = new QLineEdit; - _lineFilename->setFixedWidth(190); - { - QHBoxLayout* layoutFilename = new QHBoxLayout; - QLabel* labelFilename = new QLabel; - QString fileTip = "Enter a filename for this custom configuration to be saved " - "as a .json file in the user/config/ directory"; - labelFilename->setToolTip(fileTip); - _lineFilename->setToolTip(fileTip); - labelFilename->setText("Filename: "); - layoutFilename->addStretch(1); - layoutFilename->addWidget(labelFilename); - layoutFilename->addWidget(_lineFilename); - layoutFilename->addStretch(1); - layoutFullVertical->addLayout(layoutFilename); - } - _saveButton = new QPushButton("Save"); - _saveButton->setToolTip("Save global orientation changes"); + _saveButton = new QPushButton("Save As"); + _saveButton->setToolTip("Save configuration changes (opens file chooser dialog)"); connect(_saveButton, &QPushButton::released, this, &FileSupport::save); - _saveButton->setEnabled(false); _cancelButton = new QPushButton("Cancel"); - _cancelButton->setToolTip("Cancel global orientation changes"); + _cancelButton->setToolTip("Cancel changes"); connect(_cancelButton, &QPushButton::released, this, &FileSupport::cancel); + _applyButton = new QPushButton("Apply Without Saving"); + _applyButton->setToolTip("Apply configuration changes without saving to file"); + connect(_applyButton, &QPushButton::released, this, &FileSupport::apply); { QHBoxLayout* layoutButtonBox = new QHBoxLayout; layoutButtonBox->addStretch(1); - layoutButtonBox->addWidget(_saveButton); layoutButtonBox->addWidget(_cancelButton); + layoutButtonBox->addWidget(_saveButton); + layoutButtonBox->addWidget(_applyButton); layoutFullVertical->addLayout(layoutButtonBox); } parentLayout->addLayout(layoutFullVertical); - connect(_lineFilename, &QLineEdit::textEdited, this, &FileSupport::filenameEdited); } void FileSupport::saveCluster() { @@ -251,21 +238,42 @@ ProjectionOptions FileSupport::saveProjectionNoSpout( } } -void FileSupport::filenameEdited(const QString& newString) { - _saveButton->setEnabled(!newString.isEmpty()); -} - std::string FileSupport::saveFilename() { - return _lineFilename->text().toStdString(); + return _saveTarget; } void FileSupport::save() { - saveCluster(); - saveWindows(); - saveUser(); - _finishedCallback(true); + QString fileName = QFileDialog::getSaveFileName(this, + "Save Window Configuration File", QString::fromStdString(_userConfigPath), + "Window Configuration (*.json);;(*.json)", nullptr, + QFileDialog::DontUseNativeDialog); + if (fileName.length() != 0) { + _saveTarget = fileName.toStdString(); + saveConfigToSgctFormat(); + _finishedCallback(true); + } } void FileSupport::cancel() { _finishedCallback(false); } + +void FileSupport::apply() { + std::string userCfgTempDir = _userConfigPath; + if (userCfgTempDir.back() != '/') { + userCfgTempDir += "/"; + } + userCfgTempDir += "temp"; + if (!std::filesystem::is_directory(userCfgTempDir)) { + std::filesystem::create_directories(absPath(userCfgTempDir)); + } + _saveTarget = userCfgTempDir + "/" + "apply-without-saving.json"; + saveConfigToSgctFormat(); + _finishedCallback(true); +} + +void FileSupport::saveConfigToSgctFormat() { + saveCluster(); + saveWindows(); + saveUser(); +} diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index aa94140a98..c12fa05097 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -23,12 +23,15 @@ ****************************************************************************************/ #include "sgctedit/sgctedit.h" +#include SgctEdit::SgctEdit(QWidget* parent, std::vector& windowList, - sgct::config::Cluster& cluster, const QList& screenList) + sgct::config::Cluster& cluster, const QList& screenList, + const std::string userConfigPath) : QDialog(parent) , _cluster(cluster) , _windowList(windowList) + , _userConfigPath(userConfigPath) { systemMonitorConfiguration(screenList); setWindowTitle("Window Configuration Editor"); @@ -79,13 +82,17 @@ void SgctEdit::createWidgets() { { layoutMainV->addLayout(layoutMainH); _orientationWidget->addControlsToParentLayout(layoutMainV); - _fileSupportWidget = new FileSupport( - layoutMainV, + SgctConfigElements sgctCfg = {_windowList, _cluster}; + UserConfigurationElements userCfg = { _monitorSizeList, _displayWidget, _orientationWidget, - _windowList, - _cluster, + _userConfigPath + }; + _fileSupportWidget = new FileSupport( + layoutMainV, + userCfg, + sgctCfg, [this](bool accepted) { if (accepted) { _saveSelected = true; From d73fd4e242122f3dc7f8ffb988d334db05ec656b Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 25 Feb 2022 23:01:00 -0700 Subject: [PATCH 64/93] Added auto-window size based on monitor resolution --- .../ext/launcher/include/sgctedit/display.h | 1 - .../launcher/include/sgctedit/windowcontrol.h | 12 ++- .../ext/launcher/src/sgctedit/display.cpp | 6 +- .../ext/launcher/src/sgctedit/monitorbox.cpp | 3 - .../ext/launcher/src/sgctedit/sgctedit.cpp | 5 ++ .../launcher/src/sgctedit/windowcontrol.cpp | 80 ++++++++++++++----- 6 files changed, 81 insertions(+), 26 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index b874f913a4..64a1bca94d 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -84,7 +84,6 @@ private: void showWindows(); std::shared_ptr _monBox; std::vector& _monitorResolutions; - QRect _widgetDims = {0, 0, 400, 400}; unsigned int _nWindowsAllocated = 0; unsigned int _nWindowsDisplayed = 0; unsigned int _nMaxWindows = 3; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index d99d9630e5..cf87164096 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -168,6 +168,10 @@ public: * \return ProjectionIndeces enum of the projection type */ ProjectionIndeces projectionSelectedIndex() const; + /** + * Resets all controls for this window to default settings + */ + void resetToDefaults(); private slots: void onSizeXChanged(const QString& newText); @@ -182,6 +186,7 @@ private slots: private: void createWidgets(QWidget* parent); + void determineIdealWindowSize(); void updateScaledWindowDimensions(); std::function _windowChangeCallback; std::function _windowGuiCheckCallback; @@ -194,10 +199,15 @@ private: QList _monitorNames = { "Primary", "Secondary" }; int QualityValues[10] = { 256, 512, 1024, 1536, 2048, 4096, 8192, 16384, 32768, 65536 }; - int _lineEditWidthFixed = 50; + int _lineEditWidthFixedWinSize = 50; + int _lineEditWidthFixedFov = 80; float _marginFractionOfWidgetSize = 0.025f; + float _defaultFovH = 80.f; + float _defaultFovV = 50.534f; + float _defaultHeightOffset = 0.f; unsigned int _nMonitors = 1; unsigned int _monIndex = 0; + unsigned int _monIndexDefault = 0; unsigned int _index = 0; std::vector& _monitorResolutions; int _maxWindowSizePixels = 10000; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index 93ab23ceb0..37f3753b02 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -99,6 +99,7 @@ unsigned int Display::nWindows() const { void Display::addWindow() { if (_nWindowsDisplayed < _nMaxWindows) { + _windowControl[_nWindowsDisplayed]->resetToDefaults(); _nWindowsDisplayed++; showWindows(); } @@ -128,7 +129,10 @@ void Display::showWindows() { void Display::initializeWindowControl() { if (_nWindowsAllocated < _nMaxWindows) { - unsigned int monitorNumForThisWindow = (_nWindowsAllocated >= 3) ? 1 : 0; + unsigned int monitorNumForThisWindow = 0; + if (_nMaxWindows > 3 && _nWindowsAllocated >= 2) { + monitorNumForThisWindow = 1; + } _windowControl.push_back( std::make_shared( monitorNumForThisWindow, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 8d9df62cc8..3dd155555e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -216,9 +216,6 @@ void MonitorBox::mapWindowResolutionToWidgetCoordinates(unsigned int mIdx, unsigned int wIdx, const QRectF& winDimensions) { - if (mIdx > (_maxNumMonitors - 1) || wIdx > (_nWindows - 1)) { - return; - } QRectF wF = winDimensions; _windowRendering[wIdx] = { _monitorDimensionsScaled[mIdx].x() + wF.left() * _monitorScaleFactor, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index c12fa05097..853680d32b 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -82,6 +82,11 @@ void SgctEdit::createWidgets() { { layoutMainV->addLayout(layoutMainH); _orientationWidget->addControlsToParentLayout(layoutMainV); + + QFrame* bottomBorder = new QFrame(); + bottomBorder->setFrameShape(QFrame::HLine); + layoutMainV->addWidget(bottomBorder); + SgctConfigElements sgctCfg = {_windowList, _cluster}; UserConfigurationElements userCfg = { _monitorSizeList, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index ac2469c07a..23bc71a72e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -60,24 +60,67 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex const QColor& winColor, QWidget *parent) : QWidget(parent) , _monIndex(monitorIndex) + , _monIndexDefault(monitorIndex) , _index(windowIndex) , _monitorResolutions(monitorDims) , _colorForWindow(winColor) { _nMonitors = static_cast(_monitorResolutions.size()); createWidgets(parent); + resetToDefaults(); } WindowControl::~WindowControl() { delete _layoutFullWindow; } -void WindowControl::createWidgets(QWidget* parent) { +void WindowControl::resetToDefaults() { + determineIdealWindowSize(); + _windowName->setText(""); + _monIndex = _monIndexDefault; + _comboMonitorSelect->setCurrentIndex(_monIndexDefault); + _checkBoxWindowDecor->setCheckState(Qt::CheckState::Checked); + _checkBoxWebGui->setCheckState(Qt::CheckState::Unchecked); + onWebGuiSelection(_checkBoxWebGui->checkState()); + _checkBoxSpoutOutput->setCheckState(Qt::CheckState::Unchecked); + onSpoutSelection(_checkBoxSpoutOutput->checkState()); + _comboProjection->setCurrentIndex(static_cast(ProjectionIndeces::Planar)); + onProjectionChanged(_comboProjection->currentIndex()); + _lineFovH->setText(QString::number(_defaultFovH)); + _lineFovV->setText(QString::number(_defaultFovV)); + _lineHeightOffset->setText(QString::number(_defaultHeightOffset)); + _comboQuality->setCurrentIndex(2); + if (_windowChangeCallback) { + _windowChangeCallback(_monIndex, _index, _windowDims); + } +} + +void WindowControl::determineIdealWindowSize() { + constexpr float idealAspectRatio = 16.f / 9.f; + constexpr float idealScaleVerticalLines = 2.f / 3.f; + const unsigned int primaryMonitorIdx = 0; _windowDims = defaultWindowSizes[_index]; - _sizeX = new QLineEdit(QString::number(_windowDims.width()), parent); - _sizeY = new QLineEdit(QString::number(_windowDims.height()), parent); - _offsetX = new QLineEdit(QString::number(_windowDims.x()), parent); - _offsetY = new QLineEdit(QString::number(_windowDims.y()), parent); + _offsetX->setText(QString::number(_windowDims.x())); + _offsetY->setText(QString::number(_windowDims.y())); + float newHeight = static_cast(_monitorResolutions[primaryMonitorIdx].height()) + * idealScaleVerticalLines; + float newWidth = newHeight * idealAspectRatio; + _windowDims.setHeight(newHeight); + _windowDims.setWidth(newWidth); + _sizeX->setText(QString::number(static_cast(newWidth))); + _sizeY->setText(QString::number(static_cast(newHeight))); +} + +void WindowControl::createWidgets(QWidget* parent) { + _windowName = new QLineEdit(parent); + _sizeX = new QLineEdit(parent); + _sizeY = new QLineEdit(parent); + _offsetX = new QLineEdit(parent); + _offsetY = new QLineEdit(parent); + _labelQuality = new QLabel; + _labelFovH = new QLabel; + _labelFovV = new QLabel; + _labelHeightOffset = new QLabel; { QIntValidator* validatorSizeX = new QIntValidator(10, _maxWindowSizePixels); QIntValidator* validatorSizeY = new QIntValidator(10, _maxWindowSizePixels); @@ -97,7 +140,7 @@ void WindowControl::createWidgets(QWidget* parent) { if (_nMonitors > 1) { _comboMonitorSelect = new QComboBox(this); _comboMonitorSelect->addItems(_monitorNames); - _comboMonitorSelect->setCurrentIndex(_monIndex); + _comboMonitorSelect->setCurrentIndex(_monIndexDefault); } _fullscreenButton = new QPushButton(this); _fullscreenButton->setText("Set to Fullscreen"); @@ -112,13 +155,13 @@ void WindowControl::createWidgets(QWidget* parent) { _comboQuality->addItems(QualityTypes); { - _lineFovH = new QLineEdit("80.0", parent); - _lineFovV = new QLineEdit("50.534", parent); + _lineFovH = new QLineEdit(QString::number(_defaultFovH), parent); + _lineFovV = new QLineEdit(QString::number(_defaultFovV), parent); QDoubleValidator* validatorFovH = new QDoubleValidator(-180.0, 180.0, 10); _lineFovH->setValidator(validatorFovH); QDoubleValidator* validatorFovV = new QDoubleValidator(-90.0, 90.0, 10); _lineFovV->setValidator(validatorFovV); - _lineHeightOffset = new QLineEdit("0.0", parent); + _lineHeightOffset = new QLineEdit(QString::number(_defaultHeightOffset), parent); QDoubleValidator* validatorHtOff= new QDoubleValidator(-1000000.0, 1000000.0, 12); _lineHeightOffset->setValidator(validatorHtOff); } @@ -183,7 +226,6 @@ QVBoxLayout* WindowControl::initializeLayout() { QLabel* labelName = new QLabel(this); labelName->setText("Name: "); labelName->setToolTip(tip); - _windowName = new QLineEdit(this); _windowName->setFixedWidth(160); _windowName->setToolTip(tip); layoutName->addWidget(labelName); @@ -204,8 +246,8 @@ QVBoxLayout* WindowControl::initializeLayout() { layoutMonitorNum->addStretch(1); layoutWindowCtrl->addLayout(layoutMonitorNum); } - _sizeX->setFixedWidth(_lineEditWidthFixed); - _sizeY->setFixedWidth(_lineEditWidthFixed); + _sizeX->setFixedWidth(_lineEditWidthFixedWinSize); + _sizeY->setFixedWidth(_lineEditWidthFixedWinSize); { QLabel* labelSize = new QLabel(this); QLabel* labelDelim = new QLabel(this); @@ -228,8 +270,8 @@ QVBoxLayout* WindowControl::initializeLayout() { layoutWindowCtrl->addLayout(layoutSize); } - _offsetX->setFixedWidth(_lineEditWidthFixed); - _offsetY->setFixedWidth(_lineEditWidthFixed); + _offsetX->setFixedWidth(_lineEditWidthFixedWinSize); + _offsetY->setFixedWidth(_lineEditWidthFixedWinSize); { QLabel* labelOffset = new QLabel(this); QLabel* labelComma = new QLabel(this); @@ -302,7 +344,6 @@ QVBoxLayout* WindowControl::initializeLayout() { layoutCBoxSpoutOutput->addStretch(1); layoutProjectionGroup->addLayout(layoutCBoxSpoutOutput); QHBoxLayout* layoutComboQuality = new QHBoxLayout; - _labelQuality = new QLabel; _labelQuality->setText("Quality:"); QString qualityTip = "Determines the pixel resolution of the projection " "rendering. The higher resolution,\nthe better the rendering quality, but at " @@ -314,7 +355,6 @@ QVBoxLayout* WindowControl::initializeLayout() { layoutComboQuality->addStretch(1); layoutProjectionGroup->addLayout(layoutComboQuality); QHBoxLayout* layoutFovH = new QHBoxLayout; - _labelFovH = new QLabel; _labelFovH->setText("Horizontal FOV:"); QString hfovTip = "The total horizontal field of view of the viewport (degrees). " "Internally,\nthe values for 'left' & 'right' will each be half this value."; @@ -324,7 +364,6 @@ QVBoxLayout* WindowControl::initializeLayout() { layoutFovH->addStretch(1); layoutFovH->addWidget(_lineFovH); QHBoxLayout* layoutFovV = new QHBoxLayout; - _labelFovV = new QLabel; _labelFovV->setText("Vertical FOV:"); QString vfovTip = "The total vertical field of view of the viewport (degrees). " "Internally,\nthe values for 'up' & 'down' will each be half this value."; @@ -333,10 +372,11 @@ QVBoxLayout* WindowControl::initializeLayout() { layoutFovV->addWidget(_labelFovV); layoutFovV->addStretch(1); layoutFovV->addWidget(_lineFovV); + _lineFovH->setFixedWidth(_lineEditWidthFixedFov); + _lineFovV->setFixedWidth(_lineEditWidthFixedFov); layoutProjectionGroup->addLayout(layoutFovH); layoutProjectionGroup->addLayout(layoutFovV); QHBoxLayout* layoutHeightOffset = new QHBoxLayout; - _labelHeightOffset = new QLabel; _labelHeightOffset->setText("Height Offset:"); QString heightTip = "Offsets the height from which the cylindrical projection " "is generated.\nThis is, in general, only necessary if the user position is " @@ -390,7 +430,7 @@ void WindowControl::onOffsetXChanged(const QString& newText) { _windowChangeCallback(_monIndex, _index, _windowDims); } } - catch (std::exception) { + catch (std::exception const&) { //The QIntValidator ensures that the range is a +/- integer //However, it's possible to enter only a - character which //causes an exception throw, which is ignored here (when user @@ -407,7 +447,7 @@ void WindowControl::onOffsetYChanged(const QString& newText) { _windowChangeCallback(_monIndex, _index, _windowDims); } } - catch (std::exception) { + catch (std::exception const&) { //See comment in onOffsetXChanged } } From 3d24835c77d329c30a52892f54d58bfb157259e0 Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 25 Feb 2022 23:56:20 -0700 Subject: [PATCH 65/93] Renamed Display class to DisplayWindowUnion --- apps/OpenSpace/ext/launcher/CMakeLists.txt | 6 ++--- .../{display.h => displaywindowunion.h} | 14 ++++++------ .../launcher/include/sgctedit/filesupport.h | 6 ++--- .../ext/launcher/include/sgctedit/sgctedit.h | 7 +++--- .../ext/launcher/src/launcherwindow.cpp | 11 ---------- .../{display.cpp => displaywindowunion.cpp} | 22 +++++++++---------- .../src/sgctedit/orientationdialog.cpp | 2 +- .../ext/launcher/src/sgctedit/sgctedit.cpp | 2 +- .../launcher/src/sgctedit/windowcontrol.cpp | 2 +- 9 files changed, 30 insertions(+), 42 deletions(-) rename apps/OpenSpace/ext/launcher/include/sgctedit/{display.h => displaywindowunion.h} (90%) rename apps/OpenSpace/ext/launcher/src/sgctedit/{display.cpp => displaywindowunion.cpp} (92%) diff --git a/apps/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index 9ecdc9b5e4..305cdffd05 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -42,7 +42,7 @@ set(HEADER_FILES include/profile/timedialog.h include/profile/profileedit.h include/profile/propertiesdialog.h - include/sgctedit/display.h + include/sgctedit/displaywindowunion.h include/sgctedit/filesupport.h include/sgctedit/monitorbox.h include/sgctedit/orientation.h @@ -70,7 +70,7 @@ set(SOURCE_FILES src/profile/profileedit.cpp src/profile/propertiesdialog.cpp src/sgctedit/sgctedit.cpp - src/sgctedit/display.cpp + src/sgctedit/displaywindowunion.cpp src/sgctedit/filesupport.cpp src/sgctedit/monitorbox.cpp src/sgctedit/orientation.cpp @@ -93,7 +93,7 @@ set(HEADER_SOURCE include/profile/timedialog.h include/profile/profileedit.h include/profile/propertiesdialog.h - include/sgctedit/display.h + include/sgctedit/displaywindowunion.h include/sgctedit/filesupport.h include/sgctedit/monitorbox.h include/sgctedit/orientation.h diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/displaywindowunion.h similarity index 90% rename from apps/OpenSpace/ext/launcher/include/sgctedit/display.h rename to apps/OpenSpace/ext/launcher/include/sgctedit/displaywindowunion.h index 64a1bca94d..c2aff2c374 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/displaywindowunion.h @@ -21,8 +21,8 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ -#define __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ +#ifndef __OPENSPACE_UI_LAUNCHER___DISPLAYWINDOWUNION___H__ +#define __OPENSPACE_UI_LAUNCHER___DISPLAYWINDOWUNION___H__ #include @@ -42,12 +42,12 @@ #include #include -class Display : public QWidget { +class DisplayWindowUnion : public QWidget { Q_OBJECT public: /** - * Constructor for Display class, which manages the overall control layout including - * monitorBox, multiple WindowControl columns, and additional controls + * Constructor for DisplayWindowUnion class, which manages the overall control layout + * including monitorBox, multiple WindowControl columns, and additional controls * * \param monitorRenderBox pointer to the MonitorBox object * \param monitorSizeList A vector containing QRect objects containing pixel dims @@ -58,7 +58,7 @@ public: * this array matches the window indexing used elsewhere in the * class. This allows for a unique color for each window. */ - Display(std::shared_ptr monitorRenderBox, + DisplayWindowUnion(std::shared_ptr monitorRenderBox, std::vector& monitorSizeList, unsigned int nMaxWindows, const std::array& winColors); /** @@ -98,4 +98,4 @@ private: QFrame* _borderFrame = nullptr; }; -#endif // __OPENSPACE_UI_LAUNCHER___DISPLAY___H__ +#endif // __OPENSPACE_UI_LAUNCHER___DISPLAYWINDOWUNION___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index 669995675f..e8a66cf6f0 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -59,7 +59,7 @@ struct SgctConfigElements { struct UserConfigurationElements { std::vector& monitorList; - std::shared_ptr display; + std::shared_ptr display; Orientation* orientation; const std::string configSavePath; }; @@ -105,7 +105,7 @@ private: QPushButton* _saveButton = nullptr; QPushButton* _cancelButton = nullptr; QPushButton* _applyButton = nullptr; - std::shared_ptr _displayWidget; + std::shared_ptr _displayWidget; Orientation* _orientationWidget; std::vector& _monitors; sgct::config::Cluster& _cluster; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index 8891341f8d..5ce30f6024 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -27,7 +27,7 @@ #include -#include +#include #include #include #include @@ -41,8 +41,7 @@ class QWidget; -class SgctEdit final : public QDialog -{ +class SgctEdit final : public QDialog { Q_OBJECT public: /** @@ -86,7 +85,7 @@ private: std::vector _monitorSizeList; QVBoxLayout* _displayLayout = nullptr; QFrame* _displayFrame = nullptr; - std::shared_ptr _displayWidget = nullptr; + std::shared_ptr _displayWidget = nullptr; QRect _monitorWidgetSize = {0, 0, 500, 500}; FileSupport* _fileSupportWidget = nullptr; Orientation* _orientationWidget = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 36a1841b74..775ee7fb98 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -310,17 +310,6 @@ QWidget* LauncherWindow::createCentralWidget() { newWindowButton->setGeometry(geometry::NewWindowButton); newWindowButton->setCursor(Qt::PointingHandCursor); - //QPushButton* editWindowButton = new QPushButton("Edit", centralWidget); - //connect( - // editWindowButton, &QPushButton::released, - // [this]() { - // openWindowEditor(); - // } - //); - //editWindowButton->setObjectName("small"); - //editWindowButton->setGeometry(geometry::EditWindowButton); - //editWindowButton->setCursor(Qt::PointingHandCursor); - return centralWidget; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp similarity index 92% rename from apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp rename to apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp index 37f3753b02..7a9901a859 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include "sgctedit/display.h" +#include "sgctedit/displaywindowunion.h" #include #include "sgctedit/monitorbox.h" @@ -32,7 +32,7 @@ #include #include -Display::Display(std::shared_ptr monitorRenderBox, +DisplayWindowUnion::DisplayWindowUnion(std::shared_ptr monitorRenderBox, std::vector& monitorSizeList, unsigned int nMaxWindows, const std::array& winColors) : _monBox(monitorRenderBox) @@ -46,12 +46,12 @@ Display::Display(std::shared_ptr monitorRenderBox, for (unsigned int i = 0; i < _nMaxWindows; ++i) { initializeWindowControl(); } - connect(_addWindowButton, &QPushButton::clicked, this, &Display::addWindow); - connect(_removeWindowButton, &QPushButton::clicked, this, &Display::removeWindow); + connect(_addWindowButton, &QPushButton::clicked, this, &DisplayWindowUnion::addWindow); + connect(_removeWindowButton, &QPushButton::clicked, this, &DisplayWindowUnion::removeWindow); initializeLayout(); } -void Display::initializeLayout() { +void DisplayWindowUnion::initializeLayout() { QVBoxLayout* layout = new QVBoxLayout(this); { QHBoxLayout* layoutMonButton = new QHBoxLayout; @@ -89,15 +89,15 @@ void Display::initializeLayout() { layout->addLayout(layoutWindows); } -std::vector> Display::windowControls() const { +std::vector> DisplayWindowUnion::windowControls() const { return _windowControl; } -unsigned int Display::nWindows() const { +unsigned int DisplayWindowUnion::nWindows() const { return _nWindowsDisplayed; } -void Display::addWindow() { +void DisplayWindowUnion::addWindow() { if (_nWindowsDisplayed < _nMaxWindows) { _windowControl[_nWindowsDisplayed]->resetToDefaults(); _nWindowsDisplayed++; @@ -105,14 +105,14 @@ void Display::addWindow() { } } -void Display::removeWindow() { +void DisplayWindowUnion::removeWindow() { if (_nWindowsDisplayed > 1) { _nWindowsDisplayed--; showWindows(); } } -void Display::showWindows() { +void DisplayWindowUnion::showWindows() { for (size_t i = 0; i < _layoutWindowWrappers.size(); ++i) { _layoutWindowWrappers[i]->setVisible(i < _nWindowsDisplayed); } @@ -127,7 +127,7 @@ void Display::showWindows() { _monBox->setNumWindowsDisplayed(_nWindowsDisplayed); } -void Display::initializeWindowControl() { +void DisplayWindowUnion::initializeWindowControl() { if (_nWindowsAllocated < _nMaxWindows) { unsigned int monitorNumForThisWindow = 0; if (_nMaxWindows > 3 && _nWindowsAllocated >= 2) { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index b60f56b9a1..9cfb85a23d 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -24,7 +24,7 @@ #include "sgctedit/orientationdialog.h" -#include "sgctedit/display.h" +#include "sgctedit/displaywindowunion.h" OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) : QDialog(parent) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 853680d32b..320f7cf69e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -113,7 +113,7 @@ void SgctEdit::createWidgets() { void SgctEdit::addDisplayLayout(QHBoxLayout* layout) { _displayLayout = new QVBoxLayout; - _displayWidget = std::make_shared( + _displayWidget = std::make_shared( _monBox, _monitorSizeList, _nMaxWindows, diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 23bc71a72e..dc8949cf12 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -25,7 +25,7 @@ #include "sgctedit/windowcontrol.h" #include -#include "sgctedit/display.h" +#include "sgctedit/displaywindowunion.h" #include "sgctedit/monitorbox.h" const std::string ProjectionTypeNames[5] = {"Planar", "Fisheye", "Spherical Mirror", From dcca589695b014e6b5c9eb25a512e1679e7f7cbb Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 27 Feb 2022 12:53:57 -0700 Subject: [PATCH 66/93] Added lock for window aspect ratio --- .../launcher/include/sgctedit/orientation.h | 4 +- .../launcher/include/sgctedit/windowcontrol.h | 6 +++ .../resources/images/outline_locked.png | Bin 0 -> 278 bytes .../resources/images/outline_unlocked.png | Bin 0 -> 1470 bytes .../ext/launcher/resources/resources.qrc | 2 + .../src/sgctedit/displaywindowunion.cpp | 14 ++++++- .../launcher/src/sgctedit/windowcontrol.cpp | 35 ++++++++++++++++++ 7 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 apps/OpenSpace/ext/launcher/resources/images/outline_locked.png create mode 100644 apps/OpenSpace/ext/launcher/resources/images/outline_unlocked.png diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index d2266f48b1..79f9806cb4 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -38,8 +38,8 @@ class Orientation : public QWidget { Q_OBJECT public: /** - * Constructor for Orientation class, which manages the overall control layout including - * monitorBox, multiple WindowControl columns, and additional controls + * Constructor for Orientation class, which manages the overall control layout + * including monitorBox, multiple WindowControl columns, and additional controls * * \param monitorRenderBox pointer to the MonitorBox object * \param monitorSizeList A vector containing QRect objects containing pixel dims diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index cf87164096..dc1be2dc54 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -183,6 +183,7 @@ private slots: void onFullscreenClicked(); void onSpoutSelection(int selectionState); void onWebGuiSelection(int selectionState); + void onAspectRatioLockClicked(); private: void createWidgets(QWidget* parent); @@ -201,6 +202,7 @@ private: 32768, 65536 }; int _lineEditWidthFixedWinSize = 50; int _lineEditWidthFixedFov = 80; + float _aspectRatioSize = 16.f / 9.f; float _marginFractionOfWidgetSize = 0.025f; float _defaultFovH = 80.f; float _defaultFovV = 50.534f; @@ -209,6 +211,7 @@ private: unsigned int _monIndex = 0; unsigned int _monIndexDefault = 0; unsigned int _index = 0; + bool _aspectRatioLocked = false; std::vector& _monitorResolutions; int _maxWindowSizePixels = 10000; const QColor& _colorForWindow; @@ -218,6 +221,7 @@ private: QLineEdit* _sizeY = nullptr; QLineEdit* _offsetX = nullptr; QLineEdit* _offsetY = nullptr; + QPushButton* _buttonLockAspectRatio = nullptr; QRectF _windowDims; QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; @@ -234,6 +238,8 @@ private: QLabel* _labelHeightOffset = nullptr; QLineEdit* _lineHeightOffset = nullptr; QLineEdit* _windowName = nullptr; + QIcon _lockIcon; + QIcon _unlockIcon; }; #endif // __OPENSPACE_UI_LAUNCHER___WINDOWCONTROL___H__ diff --git a/apps/OpenSpace/ext/launcher/resources/images/outline_locked.png b/apps/OpenSpace/ext/launcher/resources/images/outline_locked.png new file mode 100644 index 0000000000000000000000000000000000000000..a920237d1a6376221606affa56d3a763c6078506 GIT binary patch literal 278 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8LpT~8Os5Rc=@2@8ZDBy*%`upLTJ z=+03%WYGLj{cyd;AI>M86Owzx4m0miH2A@w;k79{;aCjIt`xQjEt0N_RxfMbTAR|* z)a}Apsj%_o5{bk7yt6e#E^1^%d=$R&urz*c a28L~tZdLgWtLlIrW$<+Mb6Mw<&;$UlePaUv literal 0 HcmV?d00001 diff --git a/apps/OpenSpace/ext/launcher/resources/images/outline_unlocked.png b/apps/OpenSpace/ext/launcher/resources/images/outline_unlocked.png new file mode 100644 index 0000000000000000000000000000000000000000..9cda380c49ac1e5900576034a4229590917fe786 GIT binary patch literal 1470 zcmV;v1ws0WP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+U=KHvg0TWhTmC5F9AsiiREA}RlS2*e*a*{Cpo8Q zy1QncrUGR{ge=MW1WCg9>-!Af(5Pe%NzHS~IijVK3Rg@#o~`UV#kB9cak|#%RUYmI zhDb2V`O)g7Um@3z2Od7?c$EjgR@g5?bQ|7HmghC^&p|@Yr<|@pLK){I7q{n7kIPVd zMC>0|y2Cn$^*Ou<3|Z<5N5VXWB<{PP5y-k&>K-eu3_V1QIY|x}RQNK6guJ}oV~p`R zK`%*u%);mF-?LB2=X%NIQ!ewBBTRm}K>A58w;O(TEO$iwx?u7!^)<lP z6#dQ>;^I|V2xF03cW40!&5N7v1V8$PKR(sZD%AwFm1f5a)_9yI4yBLUlFeD5rx?#I zM8W!H04aiRMKB~F5HpEVrfAGYggiO`RYcB`_y7S?<&GdZ33f{`c3!^mjM3I*<;+Wr zvk4$nvKZJDseqM|qJAtnYN)DcQq`=c9<*r9l2g{4v*mTjRTE35md(tqSatE_>ess(H#JCu*~0{_ z<3txT5aUE3Zi@g4nisR^loBs;i&-p;O`(h+b+HMZ7BL`9gIFis>^{i-7Pp}OTip0p z0VHWdLr_UWLm+T+Z)Rz1WdHzpoSl%dO2beThQCzN zBI=?z6o(A11sCJuQWb(wA=V03r}U=9ViH4=QhWp7L?5PuAovJAfP%CCjSdcG@xtN% zIGpqU_g-kYu}O->T}aY0_j{ee<>1O)expH)ChP2nrpP)$(53c#zT#MYXWg%nn!Hw(7bs;Y zkBPi&!X1e`Z65Z2zt=v_s!eBWo`rc>wH8#3@fhA8VQl~#&#-b`lhyqFwwf8Qn)&A& zzX1GzP;W*r`-=bo00Lr5M??TRY=QcK00009a7bBm000XU000XU0RWnu7ytkO2XskI zMF-{r8VC?HEXV=)0003gNklMH~xt)y&(S9kWUZxv$x|dpXR!H@hC`x}ZS~81hQQ zk*d;Vf!@@DF4bc&bv|Rrwuam!#S00(qDcjS0dK%Px4<Xzw`3N$`6a9ApYS}@GC9pL75P))a(3g8d6*(z4(4mU7 z361+KRY;p+GN_XYvaL=sXygPMeZP1+X~C0aB!A!3asw5ti7Q&bGh-L*dK&xknW53l z@GVKp>wY}!{?9;B42sf|wq_56r_=VxezWDN8Oi@o#1$0oO(eZ`X%Wqss/launcher.qss images/openspace-horiz-logo-small.png images/launcher-background.png + images/outline_locked.png + images/outline_unlocked.png diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp index 7a9901a859..8e31fa0e2d 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp @@ -46,8 +46,18 @@ DisplayWindowUnion::DisplayWindowUnion(std::shared_ptr monitorRender for (unsigned int i = 0; i < _nMaxWindows; ++i) { initializeWindowControl(); } - connect(_addWindowButton, &QPushButton::clicked, this, &DisplayWindowUnion::addWindow); - connect(_removeWindowButton, &QPushButton::clicked, this, &DisplayWindowUnion::removeWindow); + connect( + _addWindowButton, + &QPushButton::clicked, + this, + &DisplayWindowUnion::addWindow + ); + connect( + _removeWindowButton, + &QPushButton::clicked, + this, + &DisplayWindowUnion::removeWindow + ); initializeLayout(); } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index dc8949cf12..bf4ffb5df1 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -65,6 +65,7 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex , _monitorResolutions(monitorDims) , _colorForWindow(winColor) { + Q_INIT_RESOURCE(resources); _nMonitors = static_cast(_monitorResolutions.size()); createWidgets(parent); resetToDefaults(); @@ -121,6 +122,10 @@ void WindowControl::createWidgets(QWidget* parent) { _labelFovH = new QLabel; _labelFovV = new QLabel; _labelHeightOffset = new QLabel; + _buttonLockAspectRatio = new QPushButton(parent); + _lockIcon.addPixmap(QPixmap(":/images/outline_locked.png")); + _unlockIcon.addPixmap(QPixmap(":/images/outline_unlocked.png")); + _buttonLockAspectRatio->setIcon(_unlockIcon); { QIntValidator* validatorSizeX = new QIntValidator(10, _maxWindowSizePixels); QIntValidator* validatorSizeY = new QIntValidator(10, _maxWindowSizePixels); @@ -200,6 +205,12 @@ void WindowControl::createWidgets(QWidget* parent) { this, &WindowControl::onFullscreenClicked ); + connect( + _buttonLockAspectRatio, + &QPushButton::released, + this, + &WindowControl::onAspectRatioLockClicked + ); } QVBoxLayout* WindowControl::initializeLayout() { @@ -256,6 +267,7 @@ QVBoxLayout* WindowControl::initializeLayout() { labelSize->setToolTip("Enter window width & height in pixels"); _sizeX->setToolTip("Enter window width (pixels)"); _sizeY->setToolTip("Enter window height (pixels)"); + _buttonLockAspectRatio->setToolTip("Locks/Unlocks size aspect ratio"); layoutSize->addWidget(labelSize); labelSize->setText("Size:"); labelSize->setFixedWidth(55); @@ -263,6 +275,7 @@ QVBoxLayout* WindowControl::initializeLayout() { layoutSize->addWidget(labelDelim); layoutSize->addWidget(_sizeY); layoutSize->addWidget(labelUnit); + layoutSize->addWidget(_buttonLockAspectRatio); layoutSize->addStretch(1); labelDelim->setText("x"); labelDelim->setFixedWidth(9); @@ -409,6 +422,13 @@ void WindowControl::showWindowLabel(bool show) { void WindowControl::onSizeXChanged(const QString& newText) { _windowDims.setWidth(newText.toInt()); + if (_aspectRatioLocked) { + int updatedHeight = _windowDims.width() / _aspectRatioSize; + _sizeY->blockSignals(true); + _sizeY->setText(QString::number(updatedHeight)); + _sizeY->blockSignals(false); + _windowDims.setHeight(updatedHeight); + } if (_windowChangeCallback) { _windowChangeCallback(_monIndex, _index, _windowDims); } @@ -416,6 +436,13 @@ void WindowControl::onSizeXChanged(const QString& newText) { void WindowControl::onSizeYChanged(const QString& newText) { _windowDims.setHeight(newText.toInt()); + if (_aspectRatioLocked) { + int updatedWidth = _windowDims.height() * _aspectRatioSize; + _sizeX->blockSignals(true); + _sizeX->setText(QString::number(updatedWidth)); + _sizeX->blockSignals(false); + _windowDims.setWidth(updatedWidth); + } if (_windowChangeCallback) { _windowChangeCallback(_monIndex, _index, _windowDims); } @@ -504,6 +531,14 @@ void WindowControl::onProjectionChanged(int newSelection) { || selected == ProjectionIndeces::Equirectangular); } +void WindowControl::onAspectRatioLockClicked() { + _aspectRatioLocked = !_aspectRatioLocked; + _buttonLockAspectRatio->setIcon(_aspectRatioLocked ? _lockIcon : _unlockIcon); + if (_aspectRatioLocked) { + _aspectRatioSize = _windowDims.width() / _windowDims.height(); + } +} + void WindowControl::setWindowChangeCallback( std::function cb) { From 1e01166c4a8226dc84ef9cef0cab0aca15fa1493 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 27 Feb 2022 20:42:45 -0700 Subject: [PATCH 67/93] Implemented lock for Planar field of view --- .../launcher/include/sgctedit/windowcontrol.h | 13 +++-- .../launcher/src/sgctedit/windowcontrol.cpp | 47 +++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index dc1be2dc54..3149c9ee3e 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -184,25 +184,28 @@ private slots: void onSpoutSelection(int selectionState); void onWebGuiSelection(int selectionState); void onAspectRatioLockClicked(); + void onFovLockClicked(); private: void createWidgets(QWidget* parent); void determineIdealWindowSize(); + void updatePlanarLockedFov(); void updateScaledWindowDimensions(); std::function _windowChangeCallback; std::function _windowGuiCheckCallback; QRectF defaultWindowSizes[4] = { {50.f, 50.f, 1280.f, 720.f}, - {900.f, 250.f, 1280.f, 720.f}, - {1200.f, 340.f, 1280.f, 720.f}, - {50.f, 50.f, 1280.f, 720.f} + {150.f, 150.f, 1280.f, 720.f}, + {50.f, 50.f, 1280.f, 720.f}, + {150.f, 150.f, 1280.f, 720.f} }; QList _monitorNames = { "Primary", "Secondary" }; int QualityValues[10] = { 256, 512, 1024, 1536, 2048, 4096, 8192, 16384, 32768, 65536 }; int _lineEditWidthFixedWinSize = 50; int _lineEditWidthFixedFov = 80; - float _aspectRatioSize = 16.f / 9.f; + const float _idealAspectRatio = 16.f / 9.f; + float _aspectRatioSize = _idealAspectRatio; float _marginFractionOfWidgetSize = 0.025f; float _defaultFovH = 80.f; float _defaultFovV = 50.534f; @@ -212,6 +215,7 @@ private: unsigned int _monIndexDefault = 0; unsigned int _index = 0; bool _aspectRatioLocked = false; + bool _FovLocked = true; std::vector& _monitorResolutions; int _maxWindowSizePixels = 10000; const QColor& _colorForWindow; @@ -222,6 +226,7 @@ private: QLineEdit* _offsetX = nullptr; QLineEdit* _offsetY = nullptr; QPushButton* _buttonLockAspectRatio = nullptr; + QPushButton* _buttonLockFov = nullptr; QRectF _windowDims; QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index bf4ffb5df1..d90ec57b9f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -123,9 +123,11 @@ void WindowControl::createWidgets(QWidget* parent) { _labelFovV = new QLabel; _labelHeightOffset = new QLabel; _buttonLockAspectRatio = new QPushButton(parent); + _buttonLockFov = new QPushButton(parent); _lockIcon.addPixmap(QPixmap(":/images/outline_locked.png")); _unlockIcon.addPixmap(QPixmap(":/images/outline_unlocked.png")); _buttonLockAspectRatio->setIcon(_unlockIcon); + _buttonLockFov->setIcon(_lockIcon); { QIntValidator* validatorSizeX = new QIntValidator(10, _maxWindowSizePixels); QIntValidator* validatorSizeY = new QIntValidator(10, _maxWindowSizePixels); @@ -211,6 +213,12 @@ void WindowControl::createWidgets(QWidget* parent) { this, &WindowControl::onAspectRatioLockClicked ); + connect( + _buttonLockFov, + &QPushButton::released, + this, + &WindowControl::onFovLockClicked + ); } QVBoxLayout* WindowControl::initializeLayout() { @@ -339,6 +347,9 @@ QVBoxLayout* WindowControl::initializeLayout() { QHBoxLayout* layoutComboProjection = new QHBoxLayout; _comboProjection->setToolTip("Select from the supported window projection types"); layoutComboProjection->addWidget(_comboProjection); + layoutComboProjection->addWidget(_buttonLockFov); + _buttonLockFov->setToolTip("Locks and scales the Horizontal & Vertical F.O.V. " + "to the ideal settings based on aspect ratio."); layoutComboProjection->addStretch(1); layoutProjectionGroup->addLayout(layoutComboProjection); QFrame* borderProjectionGroup = new QFrame; @@ -387,6 +398,8 @@ QVBoxLayout* WindowControl::initializeLayout() { layoutFovV->addWidget(_lineFovV); _lineFovH->setFixedWidth(_lineEditWidthFixedFov); _lineFovV->setFixedWidth(_lineEditWidthFixedFov); + _lineFovH->setEnabled(false); + _lineFovV->setEnabled(false); layoutProjectionGroup->addLayout(layoutFovH); layoutProjectionGroup->addLayout(layoutFovV); QHBoxLayout* layoutHeightOffset = new QHBoxLayout; @@ -432,6 +445,9 @@ void WindowControl::onSizeXChanged(const QString& newText) { if (_windowChangeCallback) { _windowChangeCallback(_monIndex, _index, _windowDims); } + if (_FovLocked) { + updatePlanarLockedFov(); + } } void WindowControl::onSizeYChanged(const QString& newText) { @@ -446,6 +462,9 @@ void WindowControl::onSizeYChanged(const QString& newText) { if (_windowChangeCallback) { _windowChangeCallback(_monIndex, _index, _windowDims); } + if (_FovLocked) { + updatePlanarLockedFov(); + } } void WindowControl::onOffsetXChanged(const QString& newText) { @@ -525,6 +544,7 @@ void WindowControl::onProjectionChanged(int newSelection) { _lineFovH->setVisible(selected == ProjectionIndeces::Planar); _labelFovV->setVisible(selected == ProjectionIndeces::Planar); _lineFovV->setVisible(selected == ProjectionIndeces::Planar); + _buttonLockFov->setVisible(selected == ProjectionIndeces::Planar); _labelHeightOffset->setVisible(selected == ProjectionIndeces::Cylindrical); _lineHeightOffset->setVisible(selected == ProjectionIndeces::Cylindrical); _checkBoxSpoutOutput->setVisible(selected == ProjectionIndeces::Fisheye @@ -539,6 +559,33 @@ void WindowControl::onAspectRatioLockClicked() { } } +void WindowControl::onFovLockClicked() { + _FovLocked = !_FovLocked; + _buttonLockFov->setIcon(_FovLocked ? _lockIcon : _unlockIcon); + if (_FovLocked) { + _lineFovH->setEnabled(false); + _lineFovV->setEnabled(false); + updatePlanarLockedFov(); + } + else { + _lineFovH->setEnabled(true); + _lineFovV->setEnabled(true); + } +} + +void WindowControl::updatePlanarLockedFov() { + float currentAspectRatio = _windowDims.width() / _windowDims.height(); + float relativeRatio = currentAspectRatio / _idealAspectRatio; + if (relativeRatio >= 1.0) { + _lineFovH->setText(QString::number(std::min(_defaultFovH *relativeRatio, 180.f))); + _lineFovV->setText(QString::number(_defaultFovV)); + } + else { + _lineFovH->setText(QString::number(_defaultFovH)); + _lineFovV->setText(QString::number(std::min(_defaultFovV /relativeRatio, 180.f))); + } +} + void WindowControl::setWindowChangeCallback( std::function cb) { From 02ebc0b402af6c2d92b2784c472bcc7ea70072fb Mon Sep 17 00:00:00 2001 From: GPayne Date: Mon, 28 Feb 2022 15:30:35 -0700 Subject: [PATCH 68/93] Change option for native OS file chooser dialog to linux only --- .../ext/launcher/src/sgctedit/filesupport.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index f76f64ea0e..e1c4d24df4 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -243,10 +243,16 @@ std::string FileSupport::saveFilename() { } void FileSupport::save() { - QString fileName = QFileDialog::getSaveFileName(this, - "Save Window Configuration File", QString::fromStdString(_userConfigPath), - "Window Configuration (*.json);;(*.json)", nullptr, - QFileDialog::DontUseNativeDialog); + QString fileName = QFileDialog::getSaveFileName( + this, + "Save Window Configuration File", + QString::fromStdString(_userConfigPath), + "Window Configuration (*.json);;(*.json)", + nullptr +#ifdef __linux__ + , QFileDialog::DontUseNativeDialog +#endif + ); if (fileName.length() != 0) { _saveTarget = fileName.toStdString(); saveConfigToSgctFormat(); From 9bd2c77f69d8ef5ca19c350b72f78ea5111d353a Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 3 Mar 2022 16:01:35 -0700 Subject: [PATCH 69/93] Added resolution info to monitor selection combo box --- .../launcher/include/sgctedit/windowcontrol.h | 1 + .../launcher/src/sgctedit/windowcontrol.cpp | 26 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 3149c9ee3e..efd0a13a8c 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -189,6 +189,7 @@ private slots: private: void createWidgets(QWidget* parent); void determineIdealWindowSize(); + QString resolutionLabelText(QRect resolution); void updatePlanarLockedFov(); void updateScaledWindowDimensions(); std::function _windowChangeCallback; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index d90ec57b9f..94673bf32f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -79,7 +79,9 @@ void WindowControl::resetToDefaults() { determineIdealWindowSize(); _windowName->setText(""); _monIndex = _monIndexDefault; - _comboMonitorSelect->setCurrentIndex(_monIndexDefault); + if (_nMonitors > 1) { + _comboMonitorSelect->setCurrentIndex(_monIndexDefault); + } _checkBoxWindowDecor->setCheckState(Qt::CheckState::Checked); _checkBoxWebGui->setCheckState(Qt::CheckState::Unchecked); onWebGuiSelection(_checkBoxWebGui->checkState()); @@ -112,6 +114,11 @@ void WindowControl::determineIdealWindowSize() { _sizeY->setText(QString::number(static_cast(newHeight))); } +QString WindowControl::resolutionLabelText(QRect resolution) { + return QString::number(resolution.width()) + "x" + + QString::number(resolution.height()); +} + void WindowControl::createWidgets(QWidget* parent) { _windowName = new QLineEdit(parent); _sizeX = new QLineEdit(parent); @@ -146,6 +153,9 @@ void WindowControl::createWidgets(QWidget* parent) { } if (_nMonitors > 1) { _comboMonitorSelect = new QComboBox(this); + for (unsigned int i = 0; i < _nMonitors; ++i) { + _monitorNames[i] += " (" + resolutionLabelText(_monitorResolutions[i]) + ")"; + } _comboMonitorSelect->addItems(_monitorNames); _comboMonitorSelect->setCurrentIndex(_monIndexDefault); } @@ -177,12 +187,14 @@ void WindowControl::createWidgets(QWidget* parent) { connect(_sizeY, &QLineEdit::textChanged, this, &WindowControl::onSizeYChanged); connect(_offsetX, &QLineEdit::textChanged, this, &WindowControl::onOffsetXChanged); connect(_offsetY, &QLineEdit::textChanged, this, &WindowControl::onOffsetYChanged); - connect( - _comboMonitorSelect, - qOverload(&QComboBox::currentIndexChanged), - this, - &WindowControl::onMonitorChanged - ); + if (_nMonitors > 1) { + connect( + _comboMonitorSelect, + qOverload(&QComboBox::currentIndexChanged), + this, + &WindowControl::onMonitorChanged + ); + } connect( _comboProjection, qOverload(&QComboBox::currentIndexChanged), From 69fb34908f023863d43d695fbc4e94e403672f05 Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 3 Mar 2022 16:03:42 -0700 Subject: [PATCH 70/93] Prevent buttons from getting focus and activating from Enter key press --- .../OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp | 2 ++ apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp | 3 +++ apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp | 1 + apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp | 2 ++ apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp | 3 +++ 5 files changed, 11 insertions(+) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp index 8e31fa0e2d..5fba039b22 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/displaywindowunion.cpp @@ -72,6 +72,8 @@ void DisplayWindowUnion::initializeLayout() { "Add a window to the configuration (up to {} windows allowed)", _nMaxWindows ); _addWindowButton->setToolTip(QString::fromStdString(addTip)); + _addWindowButton->setFocusPolicy(Qt::NoFocus); + _removeWindowButton->setFocusPolicy(Qt::NoFocus); layoutMonButton->addWidget(_removeWindowButton); layoutMonButton->addStretch(1); layoutMonButton->addWidget(_addWindowButton); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index e1c4d24df4..6fbe37c11e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -39,12 +39,15 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, QVBoxLayout* layoutFullVertical = new QVBoxLayout; _saveButton = new QPushButton("Save As"); _saveButton->setToolTip("Save configuration changes (opens file chooser dialog)"); + _saveButton->setFocusPolicy(Qt::NoFocus); connect(_saveButton, &QPushButton::released, this, &FileSupport::save); _cancelButton = new QPushButton("Cancel"); _cancelButton->setToolTip("Cancel changes"); + _cancelButton->setFocusPolicy(Qt::NoFocus); connect(_cancelButton, &QPushButton::released, this, &FileSupport::cancel); _applyButton = new QPushButton("Apply Without Saving"); _applyButton->setToolTip("Apply configuration changes without saving to file"); + _applyButton->setFocusPolicy(Qt::NoFocus); connect(_applyButton, &QPushButton::released, this, &FileSupport::apply); { QHBoxLayout* layoutButtonBox = new QHBoxLayout; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index 4f939bdaa4..4f47b82ec8 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -42,6 +42,7 @@ Orientation::Orientation() "Opens a separate dialog for setting the pitch, " "yaw, and roll of the camera\n(the orientation applies to all viewports)" ); + orientationButton->setFocusPolicy(Qt::NoFocus); layoutOrientationControls->addWidget(orientationButton); _layoutOrientationFull->addStretch(1); _layoutOrientationFull->addLayout(layoutOrientationControls); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 9cfb85a23d..91ef797269 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -92,10 +92,12 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) QHBoxLayout* layoutButtonBox = new QHBoxLayout; QPushButton* buttonSave = new QPushButton("OK"); buttonSave->setToolTip("Save global orientation changes"); + buttonSave->setFocusPolicy(Qt::NoFocus); layoutButtonBox->addStretch(1); layoutButtonBox->addWidget(buttonSave); QPushButton* buttonCancel = new QPushButton("Cancel"); buttonCancel->setToolTip("Cancel global orientation changes"); + buttonCancel->setFocusPolicy(Qt::NoFocus); layoutButtonBox->addWidget(buttonCancel); layoutButtonBox->addStretch(1); connect(buttonSave, &QPushButton::released, this, &OrientationDialog::ok); diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 94673bf32f..ee4b28c114 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -287,6 +287,7 @@ QVBoxLayout* WindowControl::initializeLayout() { labelSize->setToolTip("Enter window width & height in pixels"); _sizeX->setToolTip("Enter window width (pixels)"); _sizeY->setToolTip("Enter window height (pixels)"); + _buttonLockAspectRatio->setFocusPolicy(Qt::NoFocus); _buttonLockAspectRatio->setToolTip("Locks/Unlocks size aspect ratio"); layoutSize->addWidget(labelSize); labelSize->setText("Size:"); @@ -338,6 +339,7 @@ QVBoxLayout* WindowControl::initializeLayout() { _fullscreenButton->setToolTip("If enabled, the window will be created in an " "exclusive fullscreen mode. The size of this\nwindow will be set to the " "screen resolution, and the window decoration automatically disabled."); + _fullscreenButton->setFocusPolicy(Qt::NoFocus); layoutFullscreenButton->addWidget(_fullscreenButton); layoutFullscreenButton->addStretch(1); layoutCheckboxesFull2->addLayout(layoutFullscreenButton); @@ -362,6 +364,7 @@ QVBoxLayout* WindowControl::initializeLayout() { layoutComboProjection->addWidget(_buttonLockFov); _buttonLockFov->setToolTip("Locks and scales the Horizontal & Vertical F.O.V. " "to the ideal settings based on aspect ratio."); + _buttonLockFov->setFocusPolicy(Qt::NoFocus); layoutComboProjection->addStretch(1); layoutProjectionGroup->addLayout(layoutComboProjection); QFrame* borderProjectionGroup = new QFrame; From fb5d06d75697312b5d1f11bf8858a1e0fc61dde1 Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 3 Mar 2022 16:05:20 -0700 Subject: [PATCH 71/93] Fix to prevent fullscreen windows from only appearing in primary monitor --- apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 6fbe37c11e..9746e16745 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -112,6 +112,9 @@ void FileSupport::saveWindows() { wCtrl->monitorNum(), wCtrl->windowSize() ); + if (tmpWindow.isFullScreen) { + tmpWindow.monitor = wCtrl->monitorNum(); + } saveWindowsWebGui(windowIndex, tmpWindow); if (!wCtrl->windowName().empty()) { tmpWindow.name = wCtrl->windowName(); From 1454e099b161c9a260d8e07ad8ae6baa710436df Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 3 Mar 2022 16:08:25 -0700 Subject: [PATCH 72/93] Preview pane now adjusts to display arrangement to avoid excessive space --- .../launcher/include/sgctedit/monitorbox.h | 3 + .../ext/launcher/src/sgctedit/monitorbox.cpp | 61 ++++++++++++++----- .../ext/launcher/src/sgctedit/sgctedit.cpp | 2 - 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h index a516c9be4c..9d5eebf8e0 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/monitorbox.h @@ -86,6 +86,7 @@ protected: void paintEvent(QPaintEvent* event) override; private: + void determineMonitorArrangement(); void mapMonitorResolutionToWidgetCoordinates(); void paintWidgetBorder(QPainter& painter, int width, int height); void paintMonitorBackgrounds(QPainter& painter); @@ -101,6 +102,8 @@ private: QRectF _monitorWidgetSize; QRectF _monitorBoundaryRect; unsigned int _nMonitors = 1; + float _monitorArrangementAspectRatio = 1.f; + QSizeF _monitorArrangementDimensions = { 0.0, 0.0 }; std::vector _monitorResolution; std::vector _monitorDimensionsScaled; QRectF _negativeCorrectionOffsets = {0.f, 0.f, 0.f, 0.f}; diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 3dd155555e..22b1af4abd 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -24,7 +24,7 @@ #include "sgctedit/monitorbox.h" -constexpr float MarginFractionOfWidgetSize = 0.025f; +constexpr float MarginFractionOfWidgetSize = 0.05f; MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, unsigned int nWindows, const std::array& winColors) @@ -35,6 +35,20 @@ MonitorBox::MonitorBox(QRect widgetDims, std::vector monitorResolution, { _nMonitors = static_cast(monitorResolution.size()); _showLabel = (_nMonitors > 1); + determineMonitorArrangement(); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + float borderMargin = MarginFractionOfWidgetSize * 2.f; + if (_monitorArrangementAspectRatio > 1.0) { + borderMargin *= _monitorWidgetSize.width(); + _monitorWidgetSize.setHeight(_monitorWidgetSize.width() + / _monitorArrangementAspectRatio + borderMargin); + } + else { + borderMargin *= _monitorWidgetSize.height(); + _monitorWidgetSize.setWidth(_monitorWidgetSize.height() + * _monitorArrangementAspectRatio + borderMargin); + } + this->setFixedSize(_monitorWidgetSize.width(), _monitorWidgetSize.height()); mapMonitorResolutionToWidgetCoordinates(); } @@ -117,7 +131,7 @@ void MonitorBox::paintWindowNumber(QPainter& painter, unsigned int winIdx) { QPointF textPos = QPointF(_windowRendering[winIdx].left() + 5, _windowRendering[winIdx].bottom() - 5); textPos.setX(std::clamp(textPos.x(), 0.0, _monitorWidgetSize.width() - 10)); - textPos.setY(std::clamp(textPos.y(), 0.0, _monitorWidgetSize.height() - 10)); + textPos.setY(std::clamp(textPos.y(), 20.0, _monitorWidgetSize.height())); painter.drawText(textPos, QString::fromStdString(std::to_string(winIdx + 1))); } @@ -134,7 +148,7 @@ void MonitorBox::windowDimensionsChanged(unsigned int mIdx, unsigned int wIdx, mapWindowResolutionToWidgetCoordinates(mIdx, wIdx, newDimensions); } -void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { +void MonitorBox::determineMonitorArrangement() { for (const QRect& m : _monitorResolution) { if (m.x() < _negativeCorrectionOffsets.x()) { _negativeCorrectionOffsets.setX(m.x()); @@ -143,22 +157,37 @@ void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { _negativeCorrectionOffsets.setY(m.y()); } } - float maxWidth = 0.f; - float maxHeight = 0.f; for (const QRect& m : _monitorResolution) { - if ((m.x() + m.width() - _negativeCorrectionOffsets.x()) > maxWidth) { - maxWidth = m.x() + m.width() - _negativeCorrectionOffsets.x(); + if ((m.x() + m.width() - _negativeCorrectionOffsets.x()) + > _monitorArrangementDimensions.width()) + { + _monitorArrangementDimensions.setWidth( + m.x() + m.width() - _negativeCorrectionOffsets.x()); } - if ((m.y() + m.height() - _negativeCorrectionOffsets.y()) > maxHeight) { - maxHeight = m.y() + m.height() - _negativeCorrectionOffsets.y(); + if ((m.y() + m.height() - _negativeCorrectionOffsets.y()) + > _monitorArrangementDimensions.height()) + { + _monitorArrangementDimensions.setHeight( + m.y() + m.height() - _negativeCorrectionOffsets.y()); } } - float aspectRatio = maxWidth / maxHeight; - if (aspectRatio >= 1.0) { - computeScaledResolutionLandscape(aspectRatio, maxWidth); + _monitorArrangementAspectRatio = _monitorArrangementDimensions.width() + / _monitorArrangementDimensions.height(); +} + +void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { + + if (_monitorArrangementAspectRatio >= 1.0) { + computeScaledResolutionLandscape( + _monitorArrangementAspectRatio, + _monitorArrangementDimensions.width() + ); } else { - computeScaledResolutionPortrait(aspectRatio, maxHeight); + computeScaledResolutionPortrait( + _monitorArrangementAspectRatio, + _monitorArrangementDimensions.height() + ); } for (size_t m = 0; m < _monitorResolution.size(); ++m) { _monitorDimensionsScaled.push_back({ @@ -181,8 +210,8 @@ void MonitorBox::computeScaledResolutionLandscape(float aspectRatio, float maxWi _monitorOffsets.push_back({ _marginWidget + (_monitorResolution[m].x() - _negativeCorrectionOffsets.x()) * _monitorScaleFactor, - _marginWidget + (_monitorWidgetSize.height() - newHeight) / 2.0 + - (_monitorResolution[m].y() - _negativeCorrectionOffsets.y()) + _marginWidget + (_monitorWidgetSize.height() - newHeight - _marginWidget) / 4.0 + + (_monitorResolution[m].y() - _negativeCorrectionOffsets.y()) * _monitorScaleFactor }); } @@ -196,7 +225,7 @@ void MonitorBox::computeScaledResolutionPortrait(float aspectRatio, float maxHei float newWidth = virtualHeight * aspectRatio; for (size_t m = 0; m < _monitorResolution.size(); ++m) { _monitorOffsets.push_back({ - _marginWidget + (_monitorWidgetSize.width() - newWidth) / 2.0 + _marginWidget + (_monitorWidgetSize.width() - newWidth - _marginWidget) / 4.0 + (_monitorResolution[m].x() - _negativeCorrectionOffsets.x()) * _monitorScaleFactor, _marginWidget + (_monitorResolution[m].y() - _negativeCorrectionOffsets.y()) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 320f7cf69e..1dfffc4291 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -75,8 +75,6 @@ void SgctEdit::createWidgets() { layoutMonBox->addWidget(_monBox.get()); layoutMonBox->addStretch(1); layoutMainV->addLayout(layoutMonBox); - _monBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - _monBox->setFixedSize(_monitorWidgetSize.width(), _monitorWidgetSize.height()); addDisplayLayout(layoutMainH); } { From 234b5ce200b05ba00dac02a25ac707688ab8027e Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 3 Mar 2022 16:15:21 -0700 Subject: [PATCH 73/93] Accidental blank line --- apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp index 22b1af4abd..23214a79be 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/monitorbox.cpp @@ -176,7 +176,6 @@ void MonitorBox::determineMonitorArrangement() { } void MonitorBox::mapMonitorResolutionToWidgetCoordinates() { - if (_monitorArrangementAspectRatio >= 1.0) { computeScaledResolutionLandscape( _monitorArrangementAspectRatio, From 2f29fcd9e232473af59ec056480e25620c781f3a Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Tue, 22 Mar 2022 11:15:20 +0100 Subject: [PATCH 74/93] Fix wrong order of path type enum, and make it enum class --- include/openspace/navigation/path.h | 6 +++--- src/navigation/pathnavigator.cpp | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/openspace/navigation/path.h b/include/openspace/navigation/path.h index 17aa20c690..e3de95defd 100644 --- a/include/openspace/navigation/path.h +++ b/include/openspace/navigation/path.h @@ -39,10 +39,10 @@ namespace openspace::interaction { class Path { public: - enum Type { - AvoidCollision, - Linear, + enum class Type { + AvoidCollision = 0, ZoomOutOverview, + Linear, AvoidCollisionWithLookAt // @TODO (2021-08-13, emmbr) This type right now leads // to rapid rotations, but is useful in specific // scenarios, e.g. close to surfaces. Later we want to diff --git a/src/navigation/pathnavigator.cpp b/src/navigation/pathnavigator.cpp index 98e74dca57..81148164b1 100644 --- a/src/navigation/pathnavigator.cpp +++ b/src/navigation/pathnavigator.cpp @@ -123,10 +123,10 @@ PathNavigator::PathNavigator() , _relevantNodeTags(RelevantNodeTagsInfo) { _defaultPathType.addOptions({ - { Path::Type::AvoidCollision, "AvoidCollision" }, - { Path::Type::ZoomOutOverview, "ZoomOutOverview"}, - { Path::Type::Linear, "Linear" }, - { Path::Type::AvoidCollisionWithLookAt, "AvoidCollisionWithLookAt"} + { static_cast(Path::Type::AvoidCollision), "AvoidCollision" }, + { static_cast(Path::Type::ZoomOutOverview), "ZoomOutOverview" }, + { static_cast(Path::Type::Linear), "Linear" }, + { static_cast(Path::Type::AvoidCollisionWithLookAt), "AvoidCollisionWithLookAt"} }); addProperty(_defaultPathType); @@ -343,8 +343,7 @@ void PathNavigator::continuePath() { } Path::Type PathNavigator::defaultPathType() const { - const int pathType = _defaultPathType; - return Path::Type(pathType); + return static_cast(_defaultPathType.value()); } double PathNavigator::minValidBoundingSphere() const { From a81960e511a136f260c99d90a04826f784bbc2e9 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Tue, 22 Mar 2022 11:17:44 +0100 Subject: [PATCH 75/93] Add info messages when creating paths to different "invisble" nodes --- src/navigation/path.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/navigation/path.cpp b/src/navigation/path.cpp index 1bd4eb3b30..1c991fb2c8 100644 --- a/src/navigation/path.cpp +++ b/src/navigation/path.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -533,6 +534,34 @@ Waypoint computeWaypointFromNodeInfo(const NodeInfo& info, const Waypoint& start return Waypoint(targetPos, targetRot, info.identifier); } +void checkVisibilityAndShowMessage(const SceneGraphNode* node) { + auto isEnabled = [](const Renderable* r) { + std::any propertyValueAny = r->property("Enabled")->get(); + return std::any_cast(propertyValueAny); + }; + + // Show some info related to the visiblity of the object + const Renderable* renderable = node->renderable(); + if (!renderable) { + // Check if any of the children are visible, if it has children + bool foundVisible = false; + for (const SceneGraphNode* child : node->children()) { + const Renderable* cr = child->renderable(); + if (cr && isEnabled(cr)) { + foundVisible = true; + break; + } + } + + if (!foundVisible) { + LINFO("Creating path to a node without a renderable or visible child nodes"); + } + } + else if (!isEnabled(renderable)) { + LINFO("Creating path to disabled object"); + } +} + Path createPathFromDictionary(const ghoul::Dictionary& dictionary, std::optional forceType) { @@ -606,6 +635,8 @@ Path createPathFromDictionary(const ghoul::Dictionary& dictionary, throw PathCurve::TooShortPathError("Path too short!"); } + checkVisibilityAndShowMessage(waypointToAdd.node()); + try { return Path(startPoint, waypointToAdd, type, duration); } From 594d5128455d09ad7687bfa75163e2f2300034fd Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 24 Mar 2022 13:06:37 +0100 Subject: [PATCH 76/93] Update Mimas radii to the correct values --- data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset b/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset index 1a950717a6..1309dc9832 100644 --- a/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset +++ b/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset @@ -27,7 +27,7 @@ local Mimas = { }, Renderable = { Type = "RenderableGlobe", - Radii = 198000, + Radii = { 207000, 197000, 191000 }, SegmentsPerPatch = 64, Layers = { }, Labels = { From 7c7a6e5cff4105d0a54ccb9fe1eb272002c89ee3 Mon Sep 17 00:00:00 2001 From: Micah Acinapura Date: Thu, 24 Mar 2022 10:24:12 -0400 Subject: [PATCH 77/93] sort file lists before showing user. closes #1559 (#1943) --- .../ext/launcher/src/launcherwindow.cpp | 36 +++++++++++++++---- src/interaction/sessionrecording.cpp | 1 + 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 8702e0e8da..c330a9c619 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -354,13 +354,18 @@ void LauncherWindow::populateProfilesList(std::string preset) { ++_userAssetCount; // Add all the files with the .profile extension to the dropdown + std::vector profiles; for (const fs::directory_entry& p : fs::directory_iterator(_userProfilePath)) { if (p.path().extension() != ".profile") { continue; } - _profileBox->addItem(QString::fromStdString(p.path().stem().string())); + profiles.push_back(p); ++_userAssetCount; } + std::sort(profiles.begin(), profiles.end()); + for (const fs::directory_entry& p : profiles) { + _profileBox->addItem(QString::fromStdString(p.path().stem().string())); + } _profileBox->addItem(QString::fromStdString("--- OpenSpace Profiles ---")); model = qobject_cast(_profileBox->model()); @@ -368,11 +373,17 @@ void LauncherWindow::populateProfilesList(std::string preset) { ++_userAssetCount; // Add all the files with the .profile extension to the dropdown - for (const fs::directory_entry& p : fs::directory_iterator(_profilePath)) { - if (p.path().extension() != ".profile") { + profiles.clear(); + for (const fs::directory_entry& path : fs::directory_iterator(_profilePath)) { + if (path.path().extension() != ".profile") { continue; } - _profileBox->addItem(QString::fromStdString(p.path().stem().string())); + profiles.push_back(path); + } + std::sort(profiles.begin(), profiles.end()); + //add sorted items to list + for (const fs::directory_entry& profile : profiles) { + _profileBox->addItem(QString::fromStdString(profile.path().stem().string())); } // Try to find the requested profile and set it as the current one @@ -414,8 +425,15 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { bool hasXmlConfig = false; - // Add all the files with the .xml or .json extension to the dropdown + //sort files + std::vector files; for (const fs::directory_entry& p : fs::directory_iterator(_userConfigPath)) { + files.push_back(p); + } + std::sort(files.begin(), files.end()); + + // Add all the files with the .xml or .json extension to the dropdown + for (const fs::directory_entry& p : files) { bool isConfigFile = handleConfigurationFile(*_windowConfigBox, p); if (isConfigFile) { ++_userConfigCount; @@ -428,8 +446,14 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { model->item(_userConfigCount)->setEnabled(false); if (std::filesystem::exists(_configPath)) { - // Add all the files with the .xml or .json extension to the dropdown + //sort files + files.clear(); for (const fs::directory_entry& p : fs::directory_iterator(_configPath)) { + files.push_back(p); + } + std::sort(files.begin(), files.end()); + // Add all the files with the .xml or .json extension to the dropdown + for (const fs::directory_entry& p : files) { handleConfigurationFile(*_windowConfigBox, p); hasXmlConfig |= p.path().extension() == ".xml"; } diff --git a/src/interaction/sessionrecording.cpp b/src/interaction/sessionrecording.cpp index 8ccd49385c..3d6ce56dc8 100644 --- a/src/interaction/sessionrecording.cpp +++ b/src/interaction/sessionrecording.cpp @@ -2155,6 +2155,7 @@ std::vector SessionRecording::playbackList() const { } } } + std::sort(fileList.begin(), fileList.end()); return fileList; } From 5c5d70a2c30c950fa6164f74b385b572e1d08ba7 Mon Sep 17 00:00:00 2001 From: Micah Acinapura Date: Sat, 26 Mar 2022 11:39:07 -0400 Subject: [PATCH 78/93] update to themis ir night; closes #1707 (#1959) --- .../colorlayers/themis_ir_night_sweden.asset | 2 +- .../colorlayers/themis_ir_night_sweden.vrt | 26 +++++++++++++++++++ .../colorlayers/themis_ir_night_sweden.wms | 4 +-- .../colorlayers/themis_ir_night_utah.asset | 2 +- .../colorlayers/themis_ir_night_utah.vrt | 26 +++++++++++++++++++ .../colorlayers/themis_ir_night_utah.wms | 4 +-- 6 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.vrt create mode 100644 data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.vrt diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.asset b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.asset index 4baf2cec7f..76781643a2 100644 --- a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.asset +++ b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.asset @@ -3,7 +3,7 @@ local globeIdentifier = asset.require("../../mars").Mars.Identifier local layer = { Identifier = "Themis_IR_Night_Sweden", Name = "Themis IR Night [Sweden]", - FilePath = asset.localResource("themis_ir_night_sweden.wms"), + FilePath = asset.localResource("themis_ir_night_sweden.vrt"), BlendMode = "Color", Description = [[This mosaic represents the Thermal Emission Imaging System (THEMIS) -nighttime infrared (IR) 100 meter/pixel mosaic (version 12) released in the diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.vrt b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.vrt new file mode 100644 index 0000000000..9e774461f2 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.vrt @@ -0,0 +1,26 @@ + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + -1.8000000000000000e+02, 1.6870676889047182e-03, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -1.6870518768452129e-03 + + Gray + + themis_ir_night_sweden.wms + 1 + + + + + + + Alpha + + themis_ir_night_sweden.wms + 1 + + + + 255 + 0 + + + diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.wms b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.wms index 849d34bc5b..4ec51d1669 100644 --- a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.wms +++ b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_sweden.wms @@ -4,9 +4,9 @@ -180.0 - 90.0 + 60.0 180.0 - -90.0 + -60.0 213388 71130 9 diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.asset b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.asset index 3ec6fd56b7..696049397f 100644 --- a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.asset +++ b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.asset @@ -3,7 +3,7 @@ local globeIdentifier = asset.require("../../mars").Mars.Identifier local layer = { Identifier = "Themis_IR_Night_Utah", Name = "Themis IR Night [Utah]", - FilePath = asset.localResource("themis_ir_night_utah.wms"), + FilePath = asset.localResource("themis_ir_night_utah.vrt"), BlendMode = "Color", Description = [[This mosaic represents the Thermal Emission Imaging System (THEMIS) -nighttime infrared (IR) 100 meter/pixel mosaic (version 12) released in the diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.vrt b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.vrt new file mode 100644 index 0000000000..3521c013b7 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.vrt @@ -0,0 +1,26 @@ + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + -1.8000000000000000e+02, 1.6870676889047182e-03, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -1.6870518768452129e-03 + + Gray + + themis_ir_night_utah.wms + 1 + + + + + + + Alpha + + themis_ir_night_utah.wms + 1 + + + + 255 + 0 + + + diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.wms b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.wms index 6ae6c9848d..9ad8055b56 100644 --- a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.wms +++ b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/themis_ir_night_utah.wms @@ -4,9 +4,9 @@ -180.0 - 90.0 + 60.0 180.0 - -90.0 + -60.0 213388 71130 9 From 804f8f7c79dca2d508b0bfd5f0247cdaede983e1 Mon Sep 17 00:00:00 2001 From: Micah Acinapura Date: Sat, 26 Mar 2022 11:40:05 -0400 Subject: [PATCH 79/93] added warning for gaia module on mac; not adding renderable to scene. fixes #843 (#1961) --- data/assets/scene/milkyway/gaia/gaiastars.asset | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/data/assets/scene/milkyway/gaia/gaiastars.asset b/data/assets/scene/milkyway/gaia/gaiastars.asset index a3f761a349..39032409e8 100644 --- a/data/assets/scene/milkyway/gaia/gaiastars.asset +++ b/data/assets/scene/milkyway/gaia/gaiastars.asset @@ -1,3 +1,9 @@ +local fullOS = openspace.systemCapabilities.fullOperatingSystem() +if string.find(fullOS, "Darwin") then + openspace.printWarning("Gaia module (RenderableGaiaStars) not supported on mac") + return +end + -- Download a preprocessed binary octree of Radial Velocity subset values per star (preprocessed into 8 binary files). local starsFolder = asset.syncedResource({ Name = "Gaia Stars RV", From 3e679ecea3d179eab57d8e48f5a70b73acb3c3cb Mon Sep 17 00:00:00 2001 From: Micah Date: Sat, 26 Mar 2022 12:03:14 -0400 Subject: [PATCH 80/93] update messenger dem values for mercury; closes #1799 --- .../scene/solarsystem/planets/mercury/default_layers.asset | 4 +++- .../mercury/layers/heightlayers/messenger_dem_utah.asset | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/data/assets/scene/solarsystem/planets/mercury/default_layers.asset b/data/assets/scene/solarsystem/planets/mercury/default_layers.asset index b5b9eba9b5..3379168eec 100644 --- a/data/assets/scene/solarsystem/planets/mercury/default_layers.asset +++ b/data/assets/scene/solarsystem/planets/mercury/default_layers.asset @@ -33,13 +33,15 @@ asset.require("./layers/colorlayers/fesimap_02122015") asset.require("./layers/colorlayers/mgsimap_02122015") asset.require("./layers/colorlayers/ssimap_02122015") -asset.require("./layers/heightlayers/messenger_dem_utah") +local heightLayer = asset.require("./layers/heightlayers/messenger_dem_utah") -- Set enabled layers (temporary solution) -- @TODO: do this using a boolean that's passed to the 'asset.require' instead asset.onInitialize(function () openspace.setPropertyValueSingle("Scene.Mercury.Renderable.Layers.ColorLayers." .. colorLayer.layer.Identifier .. ".Enabled", true) + openspace.setPropertyValueSingle("Scene.Mercury.Renderable.Layers.HeightLayers." .. + heightLayer.layer.Identifier .. ".Enabled", true) end) diff --git a/data/assets/scene/solarsystem/planets/mercury/layers/heightlayers/messenger_dem_utah.asset b/data/assets/scene/solarsystem/planets/mercury/layers/heightlayers/messenger_dem_utah.asset index b2bc20cf7e..a2d24d2ee9 100644 --- a/data/assets/scene/solarsystem/planets/mercury/layers/heightlayers/messenger_dem_utah.asset +++ b/data/assets/scene/solarsystem/planets/mercury/layers/heightlayers/messenger_dem_utah.asset @@ -4,6 +4,10 @@ local layer = { Identifier = "Messenger_DEM_Utah", Name = "Messenger DEM [Utah]", FilePath = asset.localResource("messenger_dem_utah.wms"), + Settings = { + Gamma = 1.59, + Multiplier = 1.38 + }, TilePixelSize = 64 } From 8673b0fa46c58e64fd48692843b80ce9dfa7e945 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 27 Mar 2022 14:04:54 -0600 Subject: [PATCH 81/93] Added SpoutFlatProjection type to support latest sgct config --- apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index e8a66cf6f0..1913ff1846 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -49,7 +49,8 @@ using ProjectionOptions = std::variant< sgct::config::PlanarProjection, sgct::config::ProjectionPlane, sgct::config::SphericalMirrorProjection, - sgct::config::SpoutOutputProjection + sgct::config::SpoutOutputProjection, + sgct::config::SpoutFlatProjection >; struct SgctConfigElements { From 3c4f13c650dd17d84ce7515be9c95612ee11fe30 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Mon, 28 Mar 2022 16:10:56 +0200 Subject: [PATCH 82/93] Add bounding spheres to a bunch of renderable types (#1957) * RenderabeDUMeshes (And reimplement reading of vertex info from speck, to make it easier to compute sphere. The plan is to phase out this renderable anyways) * RenderablePoints * Grids: RenderableGrid, RenderableBoxGrid, RenderableRadialGrid & RenderableSphericalGrid * RenderableGalaxy --- .../rendering/grids/renderableboxgrid.cpp | 2 + .../base/rendering/grids/renderablegrid.cpp | 2 + .../rendering/grids/renderableradialgrid.cpp | 2 + .../grids/renderablesphericalgrid.cpp | 3 + .../rendering/renderabledumeshes.cpp | 122 +++++++++++------- .../rendering/renderablepoints.cpp | 6 + modules/galaxy/rendering/renderablegalaxy.cpp | 5 + 7 files changed, 98 insertions(+), 44 deletions(-) diff --git a/modules/base/rendering/grids/renderableboxgrid.cpp b/modules/base/rendering/grids/renderableboxgrid.cpp index 22ee194217..f79ea17fc9 100644 --- a/modules/base/rendering/grids/renderableboxgrid.cpp +++ b/modules/base/rendering/grids/renderableboxgrid.cpp @@ -235,6 +235,8 @@ void RenderableBoxGrid::update(const UpdateData&) { _varray.push_back({ v7.x, v7.y, v7.z }); _varray.push_back({ v3.x, v3.y, v3.z }); + setBoundingSphere(static_cast(glm::length(urb))); + glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); glBufferData( diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index 7af979a23e..3afdd6209d 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -243,6 +243,8 @@ void RenderableGrid::update(const UpdateData&) { _varray[nr++] = { halfSize.x, y1, 0.f }; } + setBoundingSphere(static_cast(glm::length(halfSize))); + glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); glBufferData( diff --git a/modules/base/rendering/grids/renderableradialgrid.cpp b/modules/base/rendering/grids/renderableradialgrid.cpp index 67454d91b7..e260af9626 100644 --- a/modules/base/rendering/grids/renderableradialgrid.cpp +++ b/modules/base/rendering/grids/renderableradialgrid.cpp @@ -274,6 +274,8 @@ void RenderableRadialGrid::update(const UpdateData&) { } _lines.update(); + setBoundingSphere(static_cast(outerRadius)); + _gridIsDirty = false; } diff --git a/modules/base/rendering/grids/renderablesphericalgrid.cpp b/modules/base/rendering/grids/renderablesphericalgrid.cpp index 8be264d66f..059cb6dac7 100644 --- a/modules/base/rendering/grids/renderablesphericalgrid.cpp +++ b/modules/base/rendering/grids/renderablesphericalgrid.cpp @@ -103,6 +103,9 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio _lineWidth = p.lineWidth.value_or(_lineWidth); addProperty(_lineWidth); + + // Radius is always 1 + setBoundingSphere(1.0); } bool RenderableSphericalGrid::isReady() const { diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index bbd77b824e..d39535e4f7 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -460,6 +460,9 @@ bool RenderableDUMeshes::readSpeckFile() { return false; } + const float scale = static_cast(toMeter(_unit)); + double maxRadius = 0.0; + int meshIndex = 0; // The beginning of the speck file has a header that either contains comments @@ -540,23 +543,55 @@ bool RenderableDUMeshes::readSpeckFile() { // We can now read the vertices data: for (int l = 0; l < mesh.numU * mesh.numV; ++l) { std::getline(file, line); - if (line.substr(0, 1) != "}") { - std::stringstream lineData(line); - for (int i = 0; i < 7; ++i) { - GLfloat value; - lineData >> value; - bool errorReading = lineData.rdstate() & std::ifstream::failbit; - if (!errorReading) { - mesh.vertices.push_back(value); - } - else { - break; - } - } - } - else { + if (line.substr(0, 1) == "}") { break; } + + std::stringstream lineData(line); + + // Try to read three values for the position + glm::vec3 pos; + bool success = true; + for (int i = 0; i < 3; ++i) { + GLfloat value; + lineData >> value; + bool errorReading = lineData.rdstate() & std::ifstream::failbit; + if (errorReading) { + success = false; + break; + } + + GLfloat scaledValue = value * scale; + pos[i] = scaledValue; + mesh.vertices.push_back(scaledValue); + } + + if (!success) { + LERROR(fmt::format( + "Failed reading position on line {} of mesh {} in file: '{}'. " + "Stopped reading mesh data", l, meshIndex, _speckFile + )); + break; + } + + // Check if new max radius + const double r = static_cast(glm::length(pos)); + maxRadius = std::max(maxRadius, r); + + // OLD CODE: + // (2022-03-23, emmbr) None of our files included texture coordinates, + // and if they would they would still not be used by the shader + //for (int i = 0; i < 7; ++i) { + // GLfloat value; + // lineData >> value; + // bool errorReading = lineData.rdstate() & std::ifstream::failbit; + // if (!errorReading) { + // mesh.vertices.push_back(value); + // } + // else { + // break; + // } + //} } std::getline(file, line); @@ -569,6 +604,8 @@ bool RenderableDUMeshes::readSpeckFile() { } } + setBoundingSphere(maxRadius); + return true; } @@ -579,12 +616,6 @@ void RenderableDUMeshes::createMeshes() { LDEBUG("Creating planes"); for (std::pair& p : _renderingMeshesMap) { - float scale = static_cast(toMeter(_unit)); - - for (GLfloat& v : p.second.vertices) { - v *= scale; - } - for (int i = 0; i < p.second.numU; ++i) { GLuint vao; glGenVertexArrays(1, &vao); @@ -605,29 +636,32 @@ void RenderableDUMeshes::createMeshes() { ); // in_position glEnableVertexAttribArray(0); - // U and V may not be given by the user - if (p.second.vertices.size() / (p.second.numU * p.second.numV) > 3) { - glVertexAttribPointer( - 0, - 3, - GL_FLOAT, - GL_FALSE, - sizeof(GLfloat) * 5, - reinterpret_cast(sizeof(GLfloat) * i * p.second.numV) - ); + // (2022-03-23, emmbr) This code was actually never used. We only read three + // values per line and di not handle any texture cooridnates, even if there + // would have been some in the file + //// U and V may not be given by the user + //if (p.second.vertices.size() / (p.second.numU * p.second.numV) > 3) { + // glVertexAttribPointer( + // 0, + // 3, + // GL_FLOAT, + // GL_FALSE, + // sizeof(GLfloat) * 5, + // reinterpret_cast(sizeof(GLfloat) * i * p.second.numV) + // ); - // texture coords - glEnableVertexAttribArray(1); - glVertexAttribPointer( - 1, - 2, - GL_FLOAT, - GL_FALSE, - sizeof(GLfloat) * 7, - reinterpret_cast(sizeof(GLfloat) * 3 * i * p.second.numV) - ); - } - else { // no U and V: + // // texture coords + // glEnableVertexAttribArray(1); + // glVertexAttribPointer( + // 1, + // 2, + // GL_FLOAT, + // GL_FALSE, + // sizeof(GLfloat) * 7, + // reinterpret_cast(sizeof(GLfloat) * 3 * i * p.second.numV) + // ); + //} + //else { // no U and V: glVertexAttribPointer( 0, 3, @@ -636,7 +670,7 @@ void RenderableDUMeshes::createMeshes() { 0, reinterpret_cast(sizeof(GLfloat) * 3 * i * p.second.numV) ); - } + //} } // Grid: we need columns diff --git a/modules/digitaluniverse/rendering/renderablepoints.cpp b/modules/digitaluniverse/rendering/renderablepoints.cpp index d94ad66e88..b1f36dd249 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.cpp +++ b/modules/digitaluniverse/rendering/renderablepoints.cpp @@ -397,12 +397,17 @@ std::vector RenderablePoints::createDataSlice() { slice.reserve(4 * _dataset.entries.size()); } + double maxRadius = 0.0; + int colorIndex = 0; for (const speck::Dataset::Entry& e : _dataset.entries) { glm::dvec3 p = e.position; double scale = toMeter(_unit); p *= scale; + const double r = glm::length(p); + maxRadius = std::max(maxRadius, r); + glm::dvec4 position(p, 1.0); if (_hasColorMapFile) { @@ -423,6 +428,7 @@ std::vector RenderablePoints::createDataSlice() { 0 : colorIndex + 1; } + setBoundingSphere(maxRadius); return slice; } diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 891270155b..bfe86b1871 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -318,6 +319,10 @@ RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) _downScaleVolumeRendering.setVisibility(properties::Property::Visibility::Developer); addProperty(_downScaleVolumeRendering); addProperty(_numberOfRayCastingSteps); + + // Use max component instead of length, to avoid problems with taking square + // of huge value + setBoundingSphere(glm::compMax(0.5f * _volumeSize)); } void RenderableGalaxy::initialize() { From f7d3d3bad1f2a714874a100d56322fd53b9d99a4 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Mon, 28 Mar 2022 19:53:14 +0200 Subject: [PATCH 83/93] Fix problems with precision of new bounding spheres glm::length => squared computation => we need the double precision in the computation. Got bounding sphere values of "inf" for a few large renderables (the DU grids)... --- modules/base/rendering/grids/renderableboxgrid.cpp | 2 +- modules/base/rendering/grids/renderablegrid.cpp | 2 +- modules/digitaluniverse/rendering/renderabledumeshes.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/base/rendering/grids/renderableboxgrid.cpp b/modules/base/rendering/grids/renderableboxgrid.cpp index f79ea17fc9..4cf68b3b9d 100644 --- a/modules/base/rendering/grids/renderableboxgrid.cpp +++ b/modules/base/rendering/grids/renderableboxgrid.cpp @@ -235,7 +235,7 @@ void RenderableBoxGrid::update(const UpdateData&) { _varray.push_back({ v7.x, v7.y, v7.z }); _varray.push_back({ v3.x, v3.y, v3.z }); - setBoundingSphere(static_cast(glm::length(urb))); + setBoundingSphere(glm::length(glm::dvec3(urb))); glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index 3afdd6209d..0140717e70 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -243,7 +243,7 @@ void RenderableGrid::update(const UpdateData&) { _varray[nr++] = { halfSize.x, y1, 0.f }; } - setBoundingSphere(static_cast(glm::length(halfSize))); + setBoundingSphere(glm::length(glm::dvec2(halfSize))); glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index d39535e4f7..56f1c1d350 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -575,7 +575,7 @@ bool RenderableDUMeshes::readSpeckFile() { } // Check if new max radius - const double r = static_cast(glm::length(pos)); + const double r = glm::length(glm::dvec3(pos)); maxRadius = std::max(maxRadius, r); // OLD CODE: From 49e15f55a0d9ecb11237e8cd47cde0b41190b9b0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 29 Mar 2022 17:27:49 +0200 Subject: [PATCH 84/93] Add the current working directory correctly when registering the binary path --- apps/OpenSpace/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 5857440162..9addd0c833 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -1044,9 +1044,10 @@ int main(int argc, char* argv[]) { // to make it possible to find other files in the same directory. FileSys.registerPathToken( "${BIN}", - std::filesystem::path(argv[0]).parent_path(), + std::filesystem::current_path() / std::filesystem::path(argv[0]).parent_path(), ghoul::filesystem::FileSystem::Override::Yes ); + LDEBUG(fmt::format("Registering ${{BIN}} to {}", absPath("${BIN}"))); // // Parse commandline arguments From acfb5d76ef6d81497872d208fc22e32153a17ed5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 29 Mar 2022 17:31:48 +0200 Subject: [PATCH 85/93] Fix error introduced in the Lua function codegen update that accidentally changed some function names --- modules/globebrowsing/globebrowsingmodule.cpp | 2 +- modules/globebrowsing/globebrowsingmodule_lua.inl | 2 +- src/interaction/sessionrecording_lua.inl | 4 +++- src/navigation/navigationhandler_lua.inl | 10 +++++++--- src/scripting/systemcapabilitiesbinding_lua.inl | 2 +- src/util/time_lua.inl | 2 +- support/coding/codegen | 2 +- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 774bb2fb10..b9074cda6b 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -716,7 +716,7 @@ scripting::LuaLibrary GlobeBrowsingModule::luaLibrary() const { codegen::lua::GetGeoPositionForCamera, codegen::lua::LoadWMSCapabilities, codegen::lua::RemoveWMSServer, - codegen::lua::Capabilities + codegen::lua::CapabilitiesWMS }; res.scripts = { absPath("${MODULE_GLOBEBROWSING}/scripts/layer_support.lua") diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index 045e3b8ec9..8c6a6cee94 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -437,7 +437,7 @@ getLocalPositionFromGeo(std::string globeIdentifier, double latitude, double lon * can be used in the 'FilePath' argument for a call to the 'addLayer' function to add the * value to a globe. */ -[[codegen::luawrap]] std::vector capabilities(std::string name) { +[[codegen::luawrap]] std::vector capabilitiesWMS(std::string name) { using namespace openspace; using namespace globebrowsing; diff --git a/src/interaction/sessionrecording_lua.inl b/src/interaction/sessionrecording_lua.inl index 7b8cfbf626..66766e7e22 100644 --- a/src/interaction/sessionrecording_lua.inl +++ b/src/interaction/sessionrecording_lua.inl @@ -70,7 +70,9 @@ namespace { * value of true is given, then playback will continually loop until it is manually * stopped. */ -[[codegen::luawrap]] void startPlaybackDefault(std::string file, bool loop = false) { +[[codegen::luawrap("startPlayback")]] void startPlaybackDefault(std::string file, + bool loop = false) +{ using namespace openspace; if (file.empty()) { diff --git a/src/navigation/navigationhandler_lua.inl b/src/navigation/navigationhandler_lua.inl index 2a6107a966..05b8dfcd6d 100644 --- a/src/navigation/navigationhandler_lua.inl +++ b/src/navigation/navigationhandler_lua.inl @@ -218,8 +218,10 @@ joystickAxis(std::string joystickName, int axis) * Finds the input joystick with the given 'name' and sets the deadzone for a particular * joystick axis, which means that any input less than this value is completely ignored. */ -[[codegen::luawrap]] void setJoystickAxisDeadZone(std::string joystickName, int axis, - float deadzone) +[[codegen::luawrap("setAxisDeadZone")]] void setJoystickAxisDeadZone( + std::string joystickName, + int axis, + float deadzone) { using namespace openspace; global::navigationHandler->setJoystickAxisDeadzone(joystickName, axis, deadzone); @@ -228,7 +230,9 @@ joystickAxis(std::string joystickName, int axis) /** * Returns the deadzone for the desired axis of the provided joystick. */ -[[codegen::luawrap]] float joystickAxisDeadzone(std::string joystickName, int axis) { +[[codegen::luawrap("axisDeadzone")]] float joystickAxisDeadzone(std::string joystickName, + int axis) +{ float deadzone = openspace::global::navigationHandler->joystickAxisDeadzone( joystickName, axis diff --git a/src/scripting/systemcapabilitiesbinding_lua.inl b/src/scripting/systemcapabilitiesbinding_lua.inl index 44d676cfa5..aa34390ceb 100644 --- a/src/scripting/systemcapabilitiesbinding_lua.inl +++ b/src/scripting/systemcapabilitiesbinding_lua.inl @@ -95,7 +95,7 @@ namespace { } // Returns the L2 associativity. -[[codegen::luawrap]] int l2Associativity() { +[[codegen::luawrap("L2Associativity")]] int l2Associativity() { int assoc = static_cast(CpuCap.L2Associativity()); return assoc; } diff --git a/src/util/time_lua.inl b/src/util/time_lua.inl index b19dc1b7f2..99c9a84f03 100644 --- a/src/util/time_lua.inl +++ b/src/util/time_lua.inl @@ -273,7 +273,7 @@ namespace { /** * Returns the current time as an ISO 8601 date string (YYYY-MM-DDTHH:MN:SS). */ -[[codegen::luawrap]] std::string currentTimeUTC() { +[[codegen::luawrap("UTC")]] std::string currentTimeUTC() { return std::string(openspace::global::timeManager->time().UTC()); } diff --git a/support/coding/codegen b/support/coding/codegen index c6178634f7..b2c8623b81 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit c6178634f7e6bcdc62a67af08f315ee384d0227d +Subproject commit b2c8623b81005283666ee319b3a972dd2b03c7a0 From 8dd7bd93147ca4bfd95ed76e029bfb7b90d981c0 Mon Sep 17 00:00:00 2001 From: Micah Acinapura Date: Tue, 29 Mar 2022 13:09:13 -0400 Subject: [PATCH 86/93] update cef and a few calls for it (#1916) * update cef and a few calls for it * fixing ref ptf for cef * fixes for macos cef update; fixes #1114 * roll back cef version to 91 * remove print from cmake --- modules/webbrowser/CMakeLists.txt | 58 ++++++++++++------- .../cmake/patch/cmake/cef_variables.cmake | 14 ++--- .../webbrowser/cmake/webbrowser_helpers.cmake | 8 ++- .../include/defaultbrowserlauncher.h | 16 +++-- modules/webbrowser/src/browserinstance.cpp | 3 +- .../webbrowser/src/defaultbrowserlauncher.cpp | 1 + modules/webbrowser/src/screenspacebrowser.cpp | 4 +- modules/webbrowser/src/webbrowserapp.cpp | 6 +- 8 files changed, 68 insertions(+), 42 deletions(-) diff --git a/modules/webbrowser/CMakeLists.txt b/modules/webbrowser/CMakeLists.txt index 79592629a2..ac92c74dc0 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -55,14 +55,15 @@ cmake_policy(SET CMP0074 NEW) # Specify the CEF distribution version. -# Release from 04/24/2019 verified to work on Windows. -set(CEF_VERSION "73.1.13+g6e3c989+chromium-73.0.3683.75") +# Release from 03/21/2022 verified to work on Windows. +set(CEF_VERSION "91.1.23+g04c8d56+chromium-91.0.4472.164") +# Removing - micahnyc 03/21/2022 # 73.1.13 has an issue on MacOS: The GUI freezing upon interaction. # Therefore, we fall back to 3.3578.1867 from 01/29/2019 -if (APPLE) - set(CEF_VERSION "3.3578.1867.g0f6d65a") -endif () +#if (APPLE) +# set(CEF_VERSION "3.3578.1867.g0f6d65a") +#endif () # CEF Sandbox is not working with the latest Visual Studio, so we disable it for now. if (WIN32) @@ -128,7 +129,9 @@ set(WEBBROWSER_SOURCES ${WEBBROWSER_SOURCES} ${WEBBROWSER_RESOURCES_SOURCES}) # CEF helper sources set(WEBBROWSER_HELPER_SOURCES src/webbrowserapp.cpp) -set(WEBBROWSER_HELPER_SOURCES_MACOSX src/processhelpermac.cpp) +if (OS_MACOSX) + list(APPEND WEBBROWSER_HELPER_SOURCES src/processhelpermac.cpp) +endif() set(WEBBROWSER_HELPER_SOURCES_WINDOWS src/processhelperwindows.cpp) APPEND_PLATFORM_SOURCES(WEBBROWSER_HELPER_SOURCES) @@ -151,30 +154,41 @@ set(WEBBROWSER_RESOURCES_SRCS # Place Helper in separate executable # The naming style " Helper" is required by Chromium. set(CEF_HELPER_TARGET "OpenSpace Helper" CACHE INTERNAL "CEF_HELPER_TARGET") +set(CEF_HELPER_TARGET_GPU "OpenSpace Helper (GPU)" CACHE INTERNAL "CEF_HELPER_TARGET_GPU") +set(CEF_HELPER_TARGET_RENDERER "OpenSpace Helper (Renderer)" CACHE INTERNAL "CEF_HELPER_TARGET_RENDERER") # # CEF platform-specific config # +list(APPEND Targets ${CEF_HELPER_TARGET} ${CEF_HELPER_TARGET_GPU} ${CEF_HELPER_TARGET_RENDERER}) + + if (OS_MACOSX) - # Helper executable target. - add_executable(${CEF_HELPER_TARGET} MACOSX_BUNDLE ${WEBBROWSER_HELPER_SOURCES}) - SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_HELPER_TARGET}) - # add_cef_logical_target("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}") - add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper) - target_link_libraries(${CEF_HELPER_TARGET} libcef_dll_wrapper ${CEF_STANDARD_LIBS}) - set_target_properties(${CEF_HELPER_TARGET} PROPERTIES - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/helper-Info.plist - ) + ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") + foreach(target IN LISTS Targets) + # Helper executable target. + add_executable(${target} MACOSX_BUNDLE ${WEBBROWSER_HELPER_SOURCES}) + SET_EXECUTABLE_TARGET_PROPERTIES(${target}) + # add_cef_logical_target("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}") + add_dependencies(${target} libcef_dll_wrapper) + target_link_libraries(${target} libcef_dll_wrapper ${CEF_STANDARD_LIBS}) + set_target_properties(${target} PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/helper-Info.plist + ) - target_compile_options(${CEF_HELPER_TARGET} PRIVATE -Wno-deprecated-declarations) - target_compile_options(libcef_dll_wrapper PRIVATE -Wno-deprecated-declarations) + target_compile_options(${target} PRIVATE -Wno-deprecated-declarations) + target_compile_options(libcef_dll_wrapper PRIVATE -Wno-deprecated-declarations) + + if (USE_SANDBOX) + # Logical target used to link the cef_sandbox library. + target_link_libraries(${target} cef_sandbox_lib) + endif () + endforeach() + +set_property(TARGET ${CEF_HELPER_TARGET_GPU} PROPERTY FOLDER "Helper") +set_property(TARGET ${CEF_HELPER_TARGET_RENDERER} PROPERTY FOLDER "Helper") - if (USE_SANDBOX) - # Logical target used to link the cef_sandbox library. - ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") - target_link_libraries(${CEF_HELPER_TARGET} cef_sandbox_lib) - endif () endif () if (OS_WINDOWS) diff --git a/modules/webbrowser/cmake/patch/cmake/cef_variables.cmake b/modules/webbrowser/cmake/patch/cmake/cef_variables.cmake index a1089c036e..449b226b5c 100644 --- a/modules/webbrowser/cmake/patch/cmake/cef_variables.cmake +++ b/modules/webbrowser/cmake/patch/cmake/cef_variables.cmake @@ -100,7 +100,7 @@ if(OS_LINUX) -fno-rtti # Disable real-time type information -fno-threadsafe-statics # Don't generate thread-safe statics -fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions - -std=gnu++11 # Use the C++11 language standard including GNU extensions + -std=gnu++14 # Use the C++14 language standard including GNU extensions -Wsign-compare # Warn about mixed signed/unsigned type comparisons ) list(APPEND CEF_COMPILER_FLAGS_DEBUG @@ -259,7 +259,7 @@ if(OS_MACOSX) -fno-threadsafe-statics # Don't generate thread-safe statics -fobjc-call-cxx-cdtors # Call the constructor/destructor of C++ instance variables in ObjC objects -fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions - -std=gnu++11 # Use the C++11 language standard including GNU extensions + -std=gnu++14 # Use the C++14 language standard including GNU extensions -Wno-narrowing # Don't warn about type narrowing -Wsign-compare # Warn about mixed signed/unsigned type comparisons ) @@ -456,12 +456,10 @@ if(OS_WINDOWS) # List of CEF binary files. set(CEF_BINARY_FILES chrome_elf.dll - d3dcompiler_43.dll d3dcompiler_47.dll libcef.dll libEGL.dll libGLESv2.dll - natives_blob.bin snapshot_blob.bin v8_context_snapshot.bin #swiftshader @@ -469,11 +467,9 @@ if(OS_WINDOWS) # List of CEF resource files. set(CEF_RESOURCE_FILES - cef.pak - cef_100_percent.pak - cef_200_percent.pak - cef_extensions.pak - devtools_resources.pak + chrome_100_percent.pak + chrome_200_percent.pak + resources.pak icudtl.dat locales ) diff --git a/modules/webbrowser/cmake/webbrowser_helpers.cmake b/modules/webbrowser/cmake/webbrowser_helpers.cmake index 8ae283eca1..e7bdf407ca 100644 --- a/modules/webbrowser/cmake/webbrowser_helpers.cmake +++ b/modules/webbrowser/cmake/webbrowser_helpers.cmake @@ -69,12 +69,16 @@ function(run_cef_macosx_config CEF_ROOT module_path) set(CEF_FINAL_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CEF_OUTPUT_PREFIX}${CEF_TARGET}.app") set(CEF_INTERMEDIATE_HELPER_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CEF_OUTPUT_PREFIX}${CEF_HELPER_TARGET}.app") + set(CEF_INTERMEDIATE_HELPER_APP_GPU "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CEF_OUTPUT_PREFIX}${CEF_HELPER_TARGET_GPU}.app") + set(CEF_INTERMEDIATE_HELPER_APP_RENDERER "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CEF_OUTPUT_PREFIX}${CEF_HELPER_TARGET_RENDERER}.app") set(CEF_FINAL_HELPER_APP "${CEF_FINAL_APP}/Contents/Frameworks/${CEF_HELPER_TARGET}.app") + set(CEF_FINAL_HELPER_APP_GPU "${CEF_FINAL_APP}/Contents/Frameworks/${CEF_HELPER_TARGET_GPU}.app") + set(CEF_FINAL_HELPER_APP_RENDERER "${CEF_FINAL_APP}/Contents/Frameworks/${CEF_HELPER_TARGET_RENDERER}.app") set(CEF_FRAMEWORK_LOCATION "${CEF_BINARY_DIR}/Chromium Embedded Framework.framework") set(CEF_FRAMEWORK_FINAL_LOCATION "${CEF_FINAL_APP}/Contents/Frameworks/Chromium Embedded Framework.framework") - add_dependencies(${CEF_TARGET} libcef_dll_wrapper "${CEF_HELPER_TARGET}") + add_dependencies(${CEF_TARGET} libcef_dll_wrapper "${CEF_HELPER_TARGET}" "${CEF_HELPER_TARGET_GPU}" "${CEF_HELPER_TARGET_RENDERER}") # target_link_libraries(${CEF_TARGET} PUBLIC libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}) target_link_libraries(${CEF_TARGET} PUBLIC libcef_dll_wrapper ${CEF_STANDARD_LIBS}) @@ -89,6 +93,8 @@ function(run_cef_macosx_config CEF_ROOT module_path) POST_BUILD # Copy the helper app bundle into the Frameworks directory. COMMAND ${CMAKE_COMMAND} -E copy_directory "${CEF_INTERMEDIATE_HELPER_APP}" "${CEF_FINAL_HELPER_APP}" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${CEF_INTERMEDIATE_HELPER_APP_GPU}" "${CEF_FINAL_HELPER_APP_GPU}" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${CEF_INTERMEDIATE_HELPER_APP_RENDERER}" "${CEF_FINAL_HELPER_APP_RENDERER}" # Copy the CEF framework into the Frameworks directory. COMMAND ${CMAKE_COMMAND} -E copy_directory "${CEF_FRAMEWORK_LOCATION}" "${CEF_FRAMEWORK_FINAL_LOCATION}" VERBATIM diff --git a/modules/webbrowser/include/defaultbrowserlauncher.h b/modules/webbrowser/include/defaultbrowserlauncher.h index 1d5abc176d..86704ab033 100644 --- a/modules/webbrowser/include/defaultbrowserlauncher.h +++ b/modules/webbrowser/include/defaultbrowserlauncher.h @@ -41,11 +41,17 @@ namespace openspace { class DefaultBrowserLauncher : public CefLifeSpanHandler, public CefRequestHandler { public: - bool OnBeforePopup(CefRefPtr browser, CefRefPtr frame, - const CefString& targetUrl, const CefString& targetFrameName, - CefLifeSpanHandler::WindowOpenDisposition targetDisposition, bool userGesture, - const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, - CefRefPtr& client, CefBrowserSettings& settings, + bool OnBeforePopup(CefRefPtr browser, + CefRefPtr frame, + const CefString& targetUrl, + const CefString& targetFrameName, + CefLifeSpanHandler::WindowOpenDisposition targetDisposition, + bool userGesture, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + CefRefPtr& client, + CefBrowserSettings& settings, + CefRefPtr& extra_info, bool* noJavascriptAccess) override; //bool OnOpenURLFromTab(CefRefPtr browser, CefRefPtr frame, diff --git a/modules/webbrowser/src/browserinstance.cpp b/modules/webbrowser/src/browserinstance.cpp index f56997d391..40299d98c4 100644 --- a/modules/webbrowser/src/browserinstance.cpp +++ b/modules/webbrowser/src/browserinstance.cpp @@ -48,7 +48,7 @@ BrowserInstance::BrowserInstance(WebRenderHandler* renderer, : _renderHandler(renderer) , _keyboardHandler(keyboardHandler) { - _client = new BrowserClient(_renderHandler, _keyboardHandler); + _client = new BrowserClient(_renderHandler.get(), _keyboardHandler.get()); CefWindowInfo windowInfo; windowInfo.SetAsWindowless(nullptr); @@ -62,6 +62,7 @@ BrowserInstance::BrowserInstance(WebRenderHandler* renderer, _client.get(), url, browserSettings, + nullptr, nullptr ); diff --git a/modules/webbrowser/src/defaultbrowserlauncher.cpp b/modules/webbrowser/src/defaultbrowserlauncher.cpp index 6b3558d687..30c290f818 100644 --- a/modules/webbrowser/src/defaultbrowserlauncher.cpp +++ b/modules/webbrowser/src/defaultbrowserlauncher.cpp @@ -38,6 +38,7 @@ bool DefaultBrowserLauncher::OnBeforePopup(CefRefPtr, CefRefPtr&, CefBrowserSettings&, + CefRefPtr&, bool*) { // never permit CEF popups, always launch in default browser diff --git a/modules/webbrowser/src/screenspacebrowser.cpp b/modules/webbrowser/src/screenspacebrowser.cpp index d03292ed5f..d166b5e139 100644 --- a/modules/webbrowser/src/screenspacebrowser.cpp +++ b/modules/webbrowser/src/screenspacebrowser.cpp @@ -94,8 +94,8 @@ ScreenSpaceBrowser::ScreenSpaceBrowser(const ghoul::Dictionary& dictionary) _renderHandler = new ScreenSpaceRenderHandler; _keyboardHandler = new WebKeyboardHandler(); _browserInstance = std::make_unique( - _renderHandler, - _keyboardHandler + _renderHandler.get(), + _keyboardHandler.get() ); _url.onChange([this]() { _isUrlDirty = true; }); diff --git a/modules/webbrowser/src/webbrowserapp.cpp b/modules/webbrowser/src/webbrowserapp.cpp index 05b2f93ccd..af5dec9666 100644 --- a/modules/webbrowser/src/webbrowserapp.cpp +++ b/modules/webbrowser/src/webbrowserapp.cpp @@ -42,8 +42,10 @@ void WebBrowserApp::OnContextCreated(CefRefPtr, CefRefPtr, void WebBrowserApp::OnBeforeCommandLineProcessing(const CefString&, CefRefPtr commandLine) { - commandLine->AppendSwitch("disable-gpu"); - commandLine->AppendSwitch("disable-gpu-compositing"); + commandLine->AppendSwitch("use-gl=desktop"); + commandLine->AppendSwitch("ignore-gpu-blacklist"); + commandLine->AppendSwitch("log-gpu-control-list-decisions"); + commandLine->AppendSwitch("use-mock-keychain"); commandLine->AppendSwitch("enable-begin-frame-scheduling"); commandLine->AppendSwitchWithValue("autoplay-policy", "no-user-gesture-required"); } From b840ff8ea1421c37d3f628c72d9000fc12c3264f Mon Sep 17 00:00:00 2001 From: Micah Acinapura Date: Tue, 29 Mar 2022 13:47:12 -0400 Subject: [PATCH 87/93] Feature/mars moons (#1963) * Add Mars moon models * wip commit * update size and roations for deimos and phobos * update asset for pr comments Co-authored-by: Malin E --- .../solarsystem/planets/default_layers.asset | 4 +- .../planets/mars/moons/deimos.asset | 31 ++++++--- .../planets/mars/moons/deimos_globe.asset | 63 +++++++++++++++++++ .../layers/colorlayers/deimos_viking.asset | 2 +- .../layers/colorlayers/phobos_viking.asset | 2 +- .../planets/mars/moons/phobos.asset | 34 +++++++--- .../planets/mars/moons/phobos_globe.asset | 63 +++++++++++++++++++ 7 files changed, 178 insertions(+), 21 deletions(-) create mode 100644 data/assets/scene/solarsystem/planets/mars/moons/deimos_globe.asset create mode 100644 data/assets/scene/solarsystem/planets/mars/moons/phobos_globe.asset diff --git a/data/assets/scene/solarsystem/planets/default_layers.asset b/data/assets/scene/solarsystem/planets/default_layers.asset index 2aae0ad044..1e4565ec20 100644 --- a/data/assets/scene/solarsystem/planets/default_layers.asset +++ b/data/assets/scene/solarsystem/planets/default_layers.asset @@ -7,9 +7,7 @@ asset.require("./jupiter/europa/default_layers") asset.require("./jupiter/ganymede/default_layers") asset.require("./jupiter/io/default_layers") -asset.require("./mars/default_layers") -asset.require("./mars/moons/layers/colorlayers/deimos_viking") -asset.require("./mars/moons/layers/colorlayers/phobos_viking") +asset.require('./mars/default_layers') asset.require("./mercury/default_layers") diff --git a/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset b/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset index bb9f981936..db687edcbf 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset @@ -1,4 +1,13 @@ -local transforms = asset.require("../transforms") +local transforms = asset.require('scene/solarsystem/planets/mars/transforms') +local sunTransforms = asset.require('scene/solarsystem/sun/transforms') +local sun = asset.require("scene/solarsystem/sun/sun") + +local model = asset.syncedResource({ + Name = "Deimos Model", + Type = "HttpSynchronization", + Identifier = "deimos_model", + Version = 1 +}) local kernels = asset.syncedResource({ Name = "Mars Spice Kernels", @@ -25,10 +34,17 @@ local Deimos = { } }, Renderable = { - Type = "RenderableGlobe", - Radii = { 15000, 12200, 11000 }, - SegmentsPerPatch = 90, - Layers = {} + Type = "RenderableModel", + GeometryFile = model .. "/Deimos_1_1000.glb", + ModelScale = 'Kilometer', + RotationVector = { 180, 0, 180 }, + AmbientIntensity = 0.02, + SpecularIntensity = 0.0, + LightSources = { + sun.LightSource + }, + PerformShading = true, + DisableFaceCulling = true }, Tag = { "moon_solarSystem", "moon_terrestrial", "moon_mars" }, GUI = { @@ -74,11 +90,10 @@ asset.export(Deimos) asset.export(DeimosTrail) - asset.meta = { Name = "Deimos", - Version = "1.1", - Description = [[ RenderableGlobe and Trail for Deimos.]], + Version = "1.0", + Description = [[ RenderableModel and Trail for Deimos.]], Author = "OpenSpace Team", URL = "http://openspaceproject.com", License = "MIT license" diff --git a/data/assets/scene/solarsystem/planets/mars/moons/deimos_globe.asset b/data/assets/scene/solarsystem/planets/mars/moons/deimos_globe.asset new file mode 100644 index 0000000000..4fb9ad6aa0 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/mars/moons/deimos_globe.asset @@ -0,0 +1,63 @@ +local transforms = asset.require('../transforms') + +local kernels = asset.syncedResource({ + Name = "Mars Spice Kernels", + Type = "HttpSynchronization", + Identifier = "mars_kernels", + Version = 1 +}) + + +local DeimosGlobe = { + Identifier = "Deimos_Globe", + Parent = transforms.MarsBarycenter.Identifier, + Transform = { + Rotation = { + Type = "SpiceRotation", + SourceFrame = "IAU_DEIMOS", + DestinationFrame = "GALACTIC", + Kernels = kernels .. "mar097.bsp" + }, + Translation = { + Type = "SpiceTranslation", + Target = "DEIMOS", + Observer = "MARS BARYCENTER", + Kernels = kernels .. "mar097.bsp" + } + }, + Renderable = { + Type = "RenderableGlobe", + Radii = { 7500, 6100, 5200 }, +--Radius source +--https://sci.esa.int/documents/35171/36506/1567259108230-5-ESLAB46-Day2-Rosenblatt.pdf + SegmentsPerPatch = 90, + Layers = {} + }, + Tag = { "moon_solarSystem", "moon_terrestrial", "moon_mars" }, + GUI = { + Name = "Deimos_Globe", + Path = "/Solar System/Planets/Mars", + Description = [[One of two moons of Mars.]] + } +} + +asset.onInitialize(function() + openspace.addSceneGraphNode(DeimosGlobe) +end) + +asset.onDeinitialize(function() + openspace.removeSceneGraphNode(DeimosGlobe) +end) + +asset.export(DeimosGlobe) + + +asset.meta = { + Name = "Deimos Globe", + Version = "1.0", + Description = [[ RenderableGlobe for Deimos.]], + Author = "OpenSpace Team", + URL = "http://openspaceproject.com", + License = "MIT license", + Identifiers = {"Deimos"} +} diff --git a/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/deimos_viking.asset b/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/deimos_viking.asset index a07f1b275f..bb4eac747d 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/deimos_viking.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/deimos_viking.asset @@ -1,4 +1,4 @@ -local globeIdentifier = asset.require("../../deimos").Deimos.Identifier +local globeIdentifier = asset.require("./../../deimos_globe").Deimos_Globe.Identifier local layer = { Identifier = "Deimos_Global_Mosaic_USGS", diff --git a/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/phobos_viking.asset b/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/phobos_viking.asset index d4f2b61ef5..6b259f3ab0 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/phobos_viking.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/phobos_viking.asset @@ -1,4 +1,4 @@ -local globeIdentifier = asset.require("../../phobos").Phobos.Identifier +local globeIdentifier = asset.require("./../../phobos_globe").Phobos_Globe.Identifier local layer = { Identifier = "Phobos_Global_Shaded_Relief_USGS", diff --git a/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset b/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset index 81223634ca..ad27d32b46 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset @@ -1,4 +1,13 @@ -local transforms = asset.require("../transforms") +local transforms = asset.require('scene/solarsystem/planets/mars/transforms') +local sunTransforms = asset.require('scene/solarsystem/sun/transforms') +local sun = asset.require("scene/solarsystem/sun/sun") + +local model = asset.syncedResource({ + Name = "Phobos Model", + Type = "HttpSynchronization", + Identifier = "phobos_model", + Version = 1 +}) local kernels = asset.syncedResource({ Name = "Mars Spice Kernels", @@ -7,6 +16,7 @@ local kernels = asset.syncedResource({ Version = 1 }) + local Phobos = { Identifier = "Phobos", Parent = transforms.MarsBarycenter.Identifier, @@ -25,10 +35,17 @@ local Phobos = { } }, Renderable = { - Type = "RenderableGlobe", - Radii = { 27000, 22000, 18000 }, - SegmentsPerPatch = 90, - Layers = {} + Type = "RenderableModel", + GeometryFile = model .. "/Phobos_1_1000.glb", + ModelScale = 'Kilometer', + RotationVector = { 90, 0, 90 }, + AmbientIntensity = 0.02, + SpecularIntensity = 0.0, + LightSources = { + sun.LightSource + }, + PerformShading = true, + DisableFaceCulling = true }, Tag = { "moon_solarSystem", "moon_terrestrial", "moon_mars" }, GUI = { @@ -46,7 +63,8 @@ local PhobosTrail = { Translation = { Type = "SpiceTranslation", Target = "PHOBOS", - Observer = "MARS BARYCENTER" + Observer = "MARS BARYCENTER", + Kernels = kernels .. "mar097.bsp" }, Color = { 1.0, 0.605, 0.420 }, Period = 0.31891023, @@ -77,8 +95,8 @@ asset.export(PhobosTrail) asset.meta = { Name = "Phobos", - Version = "1.1", - Description = [[ RenderableGlobe and Trail for Phobos.]], + Version = "1.0", + Description = [[ RenderableModel and Trail for Phobos.]], Author = "OpenSpace Team", URL = "http://openspaceproject.com", License = "MIT license" diff --git a/data/assets/scene/solarsystem/planets/mars/moons/phobos_globe.asset b/data/assets/scene/solarsystem/planets/mars/moons/phobos_globe.asset new file mode 100644 index 0000000000..efdba64a7a --- /dev/null +++ b/data/assets/scene/solarsystem/planets/mars/moons/phobos_globe.asset @@ -0,0 +1,63 @@ +local transforms = asset.require('../transforms') + +local kernels = asset.syncedResource({ + Name = "Mars Spice Kernels", + Type = "HttpSynchronization", + Identifier = "mars_kernels", + Version = 1 +}) + + +local PhobosGlobe = { + Identifier = "Phobos_Globe", + Parent = transforms.MarsBarycenter.Identifier, + Transform = { + Rotation = { + Type = "SpiceRotation", + SourceFrame = "IAU_PHOBOS", + DestinationFrame = "GALACTIC", + Kernels = kernels .. "mar097.bsp" + }, + Translation = { + Type = "SpiceTranslation", + Target = "PHOBOS", + Observer = "MARS BARYCENTER", + Kernels = kernels .. "mar097.bsp" + } + }, + Renderable = { + Type = "RenderableGlobe", + Radii = { 13030, 11400, 9140 }, +--Radius source +--https://naif.jpl.nasa.gov/pub/naif/generic_kernels/dsk/satellites/willner_etal_phobos.pdf + SegmentsPerPatch = 90, + Layers = {} + }, + Tag = { "moon_solarSystem", "moon_terrestrial", "moon_mars" }, + GUI = { + Name = "Phobos_Globe", + Path = "/Solar System/Planets/Mars", + Description = [[One of two moons of Mars.]] + } +} + +asset.onInitialize(function() + openspace.addSceneGraphNode(PhobosGlobe) +end) + +asset.onDeinitialize(function() + openspace.removeSceneGraphNode(PhobosGlobe) +end) + +asset.export(PhobosGlobe) + + +asset.meta = { + Name = "Phobos Globe", + Version = "1.0", + Description = [[ RenderableGlobe for Phobos.]], + Author = "OpenSpace Team", + URL = "http://openspaceproject.com", + License = "MIT license", + Identifiers = {"Phobos"} +} From 31586bc462f5dbc5f1f72d80065234ef54223c79 Mon Sep 17 00:00:00 2001 From: Micah Acinapura Date: Tue, 29 Mar 2022 14:25:44 -0400 Subject: [PATCH 88/93] fix build error for qt6 return type change --- apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 1dfffc4291..ae2fd75917 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -39,7 +39,7 @@ SgctEdit::SgctEdit(QWidget* parent, std::vector& windowLis } void SgctEdit::systemMonitorConfiguration(const QList& screenList) { - size_t nScreensManaged = std::min(screenList.length(), 2); + size_t nScreensManaged = std::min(static_cast(screenList.length()), 2); for (unsigned int s = 0; s < static_cast(nScreensManaged); ++s) { int actualWidth = std::max( screenList[s]->size().width(), From 5ea93cdd7bac2426477b007645cb44103ac20940 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 30 Mar 2022 10:45:01 +0200 Subject: [PATCH 89/93] Prevent crash in DashboardItemInstruments when using dates before 2000 (closes #1878). Remove the padding images from New Horizons that screw up the instruments timing --- .../scene/solarsystem/missions/newhorizons/pluto.asset | 2 +- .../dashboard/dashboarditeminstruments.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset index 234234b79c..b6456a2a5a 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset @@ -27,7 +27,7 @@ local images = asset.syncedResource({ Name = "Pluto Images", Type = "HttpSynchronization", Identifier = "newhorizons_plutoencounter_pluto_images", - Version = 1 + Version = 2 }) local plutoRadius = 1.173E6 diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp index 87f549dd7b..f9f27d4931 100644 --- a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp @@ -131,8 +131,9 @@ void DashboardItemInstruments::render(glm::vec2& penPosition) { double previous = sequencer.prevCaptureTime(currentTime); double next = sequencer.nextCaptureTime(currentTime); - double remaining = sequencer.nextCaptureTime(currentTime) - currentTime; - const float t = static_cast(1.0 - remaining / (next - previous)); + double remaining = next - currentTime; + float t = static_cast(1.0 - remaining / (next - previous)); + t = std::clamp(t, 0.f, 1.f); if (remaining > 0.0) { RenderFont( From 7b462422fe37f13e1cf2577ce48c78870d81c32b Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 30 Mar 2022 10:58:53 +0200 Subject: [PATCH 90/93] Make the UTC function return the date in actual UTC format and add SPICE as a way to get the old format (closes #1776) --- src/util/time.cpp | 1 + src/util/time_lua.inl | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/util/time.cpp b/src/util/time.cpp index 8bb5d1ed3e..a0a7fe8d2e 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -164,6 +164,7 @@ scripting::LuaLibrary Time::luaLibrary() { codegen::lua::InterpolateTimeRelative, codegen::lua::CurrentTime, codegen::lua::CurrentTimeUTC, + codegen::lua::CurrentTimeSpice, codegen::lua::CurrentWallTime, codegen::lua::CurrentApplicationTime, codegen::lua::AdvancedTime diff --git a/src/util/time_lua.inl b/src/util/time_lua.inl index 99c9a84f03..ae68fc9c6f 100644 --- a/src/util/time_lua.inl +++ b/src/util/time_lua.inl @@ -274,6 +274,15 @@ namespace { * Returns the current time as an ISO 8601 date string (YYYY-MM-DDTHH:MN:SS). */ [[codegen::luawrap("UTC")]] std::string currentTimeUTC() { + return std::string(openspace::global::timeManager->time().ISO8601()); +} + + +/** + * Returns the current time as an date string of the form + * (YYYY MON DDTHR:MN:SC.### ::RND) as returned by SPICE. + */ +[[codegen::luawrap("SPICE")]] std::string currentTimeSpice() { return std::string(openspace::global::timeManager->time().UTC()); } From 3ba3e977eb1c1d5efef3ff29dec7a20aa32bbaf5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 30 Mar 2022 15:14:18 +0200 Subject: [PATCH 91/93] Add an action to automatically switch the Sun and SunGlare when approaching the Sun (closes #1914) --- data/assets/events/toggle_sun.asset | 61 +++++++++++++++++++++ data/assets/events/toggle_trail.asset | 8 +-- data/assets/scene/solarsystem/sun/sun.asset | 1 + data/profiles/default.profile | 3 +- data/profiles/default_full.profile | 3 +- 5 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 data/assets/events/toggle_sun.asset diff --git a/data/assets/events/toggle_sun.asset b/data/assets/events/toggle_sun.asset new file mode 100644 index 0000000000..29d1a48d34 --- /dev/null +++ b/data/assets/events/toggle_sun.asset @@ -0,0 +1,61 @@ +local toggle_sun = { + Identifier = "os.toggle_sun", + Name = "Toggle Sun", + Command = [[ + if not is_declared("args") then + openspace.printError("Cannot execute 'os.toggle_sun' manually") + return + end + + if args.Transition == "Approaching" then + openspace.setPropertyValueSingle("Scene.SunGlare.Renderable.Enabled", false) + openspace.setPropertyValueSingle("Scene.Sun.Renderable.Enabled", true) + else -- "Exiting" + openspace.setPropertyValueSingle("Scene.SunGlare.Renderable.Enabled", true) + openspace.setPropertyValueSingle("Scene.Sun.Renderable.Enabled", false) + end + ]], + Documentation = [[Toggles the visibility of the Sun glare and the Sun globe when the + camera is approaching either so that from far away the Sun Glare is rendered and when + close up, the globe is rendered instead.]], + GuiPath = "/Sun", + IsLocal = false +} + +asset.onInitialize(function() + openspace.action.registerAction(toggle_sun) + openspace.event.registerEventAction( + "CameraFocusTransition", + toggle_sun.Identifier, + { Node = "Sun", Transition = "Approaching" } + ) + openspace.event.registerEventAction( + "CameraFocusTransition", + toggle_sun.Identifier, + { Node = "Sun", Transition = "Exiting" } + ) +end) + +asset.onDeinitialize(function() + openspace.event.unregisterEventAction( + "CameraFocusTransition", + toggle_sun.Identifier, + { Node = "Sun", Transition = "Exiting" } + ) + openspace.event.unregisterEventAction( + "CameraFocusTransition", + toggle_sun.Identifier, + { Node = "Sun", Transition = "Approaching" } + ) + openspace.action.removeAction(toggle_sun) +end) + + +asset.meta = { + Name = "Actions - Toggle current Trails", + Version = "1.0", + Description = [[ Asset providing actions to toggle trails]], + Author = "OpenSpace Team", + URL = "http://openspaceproject.com", + License = "MIT license" +} diff --git a/data/assets/events/toggle_trail.asset b/data/assets/events/toggle_trail.asset index 803885cf73..27b054134a 100644 --- a/data/assets/events/toggle_trail.asset +++ b/data/assets/events/toggle_trail.asset @@ -5,12 +5,12 @@ asset.onInitialize(function() "CameraFocusTransition", action.show_trail, { Transition = "Exiting" } - ); + ) openspace.event.registerEventAction( "CameraFocusTransition", action.hide_trail, { Transition = "Approaching" } - ); + ) end) asset.onDeinitialize(function() @@ -18,10 +18,10 @@ asset.onDeinitialize(function() "CameraFocusTransition", action.show_trail, { Transition = "Exiting" } - ); + ) openspace.event.unregisterEventAction( "CameraFocusTransition", action.hide_trail, { Transition = "Approaching" } - ); + ) end) diff --git a/data/assets/scene/solarsystem/sun/sun.asset b/data/assets/scene/solarsystem/sun/sun.asset index 0c6964a694..23c35428e4 100644 --- a/data/assets/scene/solarsystem/sun/sun.asset +++ b/data/assets/scene/solarsystem/sun/sun.asset @@ -12,6 +12,7 @@ local Sun = { Layers = {}, PerformShading = false }, + ApproachFactor = 15.0, GUI = { Name = "Sun", Path = "/Solar System/Sun", diff --git a/data/profiles/default.profile b/data/profiles/default.profile index 6d3077cc1b..1eabb6ca02 100644 --- a/data/profiles/default.profile +++ b/data/profiles/default.profile @@ -27,6 +27,7 @@ ], "assets": [ "base", + "events/toggle_sun", "scene/solarsystem/planets/earth/earth", "scene/solarsystem/planets/earth/satellites/satellites" ], @@ -104,4 +105,4 @@ "major": 1, "minor": 1 } -} \ No newline at end of file +} diff --git a/data/profiles/default_full.profile b/data/profiles/default_full.profile index d2bbfc3a8c..e693cd6e9b 100644 --- a/data/profiles/default_full.profile +++ b/data/profiles/default_full.profile @@ -35,6 +35,7 @@ ], "assets": [ "base", + "events/toggle_sun", "scene/solarsystem/planets/earth/earth", "scene/solarsystem/planets/earth/satellites/satellites", "scene/solarsystem/planets/jupiter/major_moons", @@ -130,4 +131,4 @@ "major": 1, "minor": 1 } -} \ No newline at end of file +} From 92b250d86054f8bf97e05776530fb455318cb15e Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 30 Mar 2022 14:35:34 -0600 Subject: [PATCH 92/93] Added active satellites asset file; closes #1805 --- .../earth/satellites/misc/active.asset | 21 +++++++++++++++++++ .../earth/satellites/satellites_misc.asset | 1 + 2 files changed, 22 insertions(+) create mode 100644 data/assets/scene/solarsystem/planets/earth/satellites/misc/active.asset diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/active.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/active.asset new file mode 100644 index 0000000000..0144732ffc --- /dev/null +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/active.asset @@ -0,0 +1,21 @@ +local shared = asset.require("util/tle_helper") + +local group = { + Title = "Active", + Url = "http://www.celestrak.com/NORAD/elements/active.txt", + TrailColor = { 0.45, 0.25, 0.45 }, + Description = [[Satellites that employ active communication.]] +} + +local tle = shared.downloadTLEFile(asset, group.Url, group.Title) +shared.registerSatelliteGroupObjects(asset, group, tle, true) + + +asset.meta = { + Name = "Satellites Active", + Version = "1.0", + Description = [[ Satellites that employ active communication. Data from Celestrak]], + Author = "OpenSpace Team", + URL = "https://celestrak.com/NORAD/elements/", + License = "Celestrak" +} diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_misc.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_misc.asset index 76fb2afaed..b05af852dc 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_misc.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_misc.asset @@ -2,6 +2,7 @@ asset.require("./misc/military") asset.require("./misc/radar") asset.require("./misc/cubesats") asset.require("./misc/other") +asset.require("./misc/active") asset.meta = { From 83561ca09d67a532652533c6e1219092fa6a2f5d Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 30 Mar 2022 14:36:52 -0600 Subject: [PATCH 93/93] Added Starlink satellites asset file; closes #1818 --- .../satellites/communications/starlink.asset | 23 +++++++++++++++++++ .../satellites_communications.asset | 1 + 2 files changed, 24 insertions(+) create mode 100644 data/assets/scene/solarsystem/planets/earth/satellites/communications/starlink.asset diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/starlink.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/starlink.asset new file mode 100644 index 0000000000..2a9d8500c5 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/starlink.asset @@ -0,0 +1,23 @@ +local shared = asset.require("util/tle_helper") + +local group = { + Title = "Starlink", + Url = "http://www.celestrak.com/NORAD/elements/starlink.txt", + TrailColor = { 0.65, 0.55, 0.55 }, + Description = [[LEO satellite constellation launched by SpaceX to provide + broadband internet access.]] +} + +local tle = shared.downloadTLEFile(asset, group.Url, group.Title) +shared.registerSatelliteGroupObjects(asset, group, tle, true) + + +asset.meta = { + Name = "Satellites Communications - Starlink", + Version = "1.0", + Description = [[ Satellites asset for Communications - Starlink. Data from + Celestrak]], + Author = "OpenSpace Team", + URL = "https://celestrak.com/NORAD/elements/", + License = "Celestrak" +} diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_communications.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_communications.asset index b5c6871dc8..b5caa1c6f5 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_communications.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_communications.asset @@ -11,6 +11,7 @@ asset.require("./communications/other_comm") asset.require("./communications/gorizont") asset.require("./communications/raduga") asset.require("./communications/molniya") +asset.require("./communications/starlink") asset.meta = {