mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 12:29:04 -06:00
Merge branch 'develop' into feature/remote_redesign
* develop: Renamed getLua, setLua, getString, and setString methods to add "Value" to the end of the method name Added documentation for getString/setString methods Enable Properties to be set by strings Add a button to the SyncWidget to allow it to be closed Updated to new Ghoul version Make multithreaded download a toggle Correctly Set the CMAKE_PREFIX_PATH for Qt on Mac Add commandline argument to OpenSpaceEngine to override scene file Make scene file selectable in Launcher, using the configurationfile value as default Non-Windows compile fix Include stylesheet in main file Add stylesheets and general improvements
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(libtorrent)
|
||||
set (SOVERSION "8")
|
||||
set (VERSION "1.0.5")
|
||||
set(SOVERSION "8")
|
||||
set(VERSION "1.0.5")
|
||||
|
||||
set(sources
|
||||
web_connection_base
|
||||
|
||||
@@ -43,26 +43,34 @@ InfoWidget::InfoWidget(QString name, int totalBytes)
|
||||
setFixedHeight(100);
|
||||
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
layout->setVerticalSpacing(0);
|
||||
layout->setHorizontalSpacing(10);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
_name = new QLabel(name);
|
||||
layout->addWidget(_name, 0, 0);
|
||||
_name->setObjectName("Name");
|
||||
//_name->setMaximumWidth(300);
|
||||
_name->setFixedWidth(450);
|
||||
layout->addWidget(_name, 0, 0, 1, 2);
|
||||
layout->setRowStretch(1, 10);
|
||||
|
||||
_bytes = new QLabel("");
|
||||
layout->addWidget(_bytes, 1, 0);
|
||||
_bytes->setObjectName("Bytes");
|
||||
layout->addWidget(_bytes, 2, 0);
|
||||
|
||||
_progress = new QProgressBar;
|
||||
layout->addWidget(_progress, 1, 1);
|
||||
_progress->setTextVisible(false);
|
||||
_progress->setFixedWidth(285);
|
||||
layout->addWidget(_progress, 2, 1);
|
||||
|
||||
_messagesLeft = new QLabel("");
|
||||
_messagesLeft->setObjectName("MessageLeft");
|
||||
_messagesCenter = new QLabel("");
|
||||
_messagesCenter->setObjectName("MessageCenter");
|
||||
_messagesRight = new QLabel("");
|
||||
|
||||
layout->addWidget(_messagesLeft, 2, 0, 1, 2);
|
||||
layout->addWidget(_messagesCenter, 2, 0, 1, 2, Qt::AlignCenter);
|
||||
layout->addWidget(_messagesRight, 2, 0, 1, 2, Qt::AlignRight);
|
||||
_messagesRight->setObjectName("MessageRight");
|
||||
|
||||
layout->addWidget(_messagesLeft, 3, 0, 1, 2);
|
||||
layout->addWidget(_messagesCenter, 3, 0, 1, 2, Qt::AlignCenter);
|
||||
layout->addWidget(_messagesRight, 3, 0, 1, 2, Qt::AlignRight);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
@@ -99,13 +107,13 @@ void InfoWidget::update(libtorrent::torrent_status s) {
|
||||
if (bytesPerSecond > 0 && remainingBytes > 0) {
|
||||
float seconds = static_cast<float>(remainingBytes) / bytesPerSecond;
|
||||
|
||||
QString left = "Time remaining %1 s";
|
||||
QString left = "Remaining: %1 s";
|
||||
_messagesLeft->setText(left.arg(static_cast<int>(seconds)));
|
||||
|
||||
QString center = "Peers: %1 (%2) | Seeds: %3 (%4)";
|
||||
_messagesCenter->setText(center.arg(s.num_peers).arg(s.list_peers).arg(s.num_seeds).arg(s.list_seeds));
|
||||
|
||||
QString right = "Download Rate: %1 KiB/s";
|
||||
QString right = "%1 KiB/s";
|
||||
_messagesRight->setText(right.arg(bytesPerSecond / 1024));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -24,130 +24,151 @@
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
//static const QString style = R"style(
|
||||
//QWidget {
|
||||
// background-color: rgb(80, 80, 80);
|
||||
// font-family: Helvetica;
|
||||
//}
|
||||
//
|
||||
//QGroupBox {
|
||||
// background-color: qlineargradient(
|
||||
// x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
// stop: 0 #858585,
|
||||
// stop: 1 #959595);
|
||||
// border: 2px solid gray;
|
||||
// border-radius: 5px;
|
||||
// margin-top: 4ex;
|
||||
// font-size: bold 12px;
|
||||
//}
|
||||
//
|
||||
//QGroupBox::title {
|
||||
// background-color: #E0E0E0;
|
||||
// border: 2px solid gray;
|
||||
// border-radius: 5px;
|
||||
// subcontrol-origin: margin;
|
||||
// subcontrol-position: top center;
|
||||
// padding: 0 10px;
|
||||
//}
|
||||
//
|
||||
//QLineEdit {
|
||||
// color: lightgray;
|
||||
//}
|
||||
//
|
||||
//QSlider::groove:horizontal {
|
||||
// border: 1px solid #999999;
|
||||
// height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
|
||||
// background: qlineargradient(
|
||||
// x1:0, y1:0, x2:1, y2:0,
|
||||
// stop:0 #c4c4c4,
|
||||
// stop:0.5 #555555,
|
||||
// stop:1 #c4c4c4
|
||||
// );
|
||||
// margin: 2px 0;
|
||||
//}
|
||||
//
|
||||
//QSlider::handle:horizontal {
|
||||
// background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
|
||||
// border: 1px solid #5c5c5c;
|
||||
// width: 18px;
|
||||
// margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
|
||||
// border-radius: 3px;
|
||||
//}
|
||||
//
|
||||
//QPushButton {
|
||||
// background-color: lightgray;
|
||||
// border-style: outset;
|
||||
// border-width: 0.5px;
|
||||
// border-radius: 5px;
|
||||
// border-color: black;
|
||||
// font: bold 12px;
|
||||
// min-width: 10em;
|
||||
//}
|
||||
//
|
||||
//QPushButton#connection {
|
||||
// background-color: lightgreen;
|
||||
//}
|
||||
//
|
||||
//QPushButton#connection:pressed {
|
||||
// background-color: green;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//QPushButton#pause, QPushButton#play {
|
||||
// padding: 5px;
|
||||
//}
|
||||
//
|
||||
//QPushButton#pause:pressed, QPushButton#play:pressed, QPushButton:pressed {
|
||||
// background-color: darkgray;
|
||||
// border-style: inset;
|
||||
//}
|
||||
//
|
||||
//QCombobox {
|
||||
// border: 1px solid gray;
|
||||
// border-radius: 3px;
|
||||
// padding: 1px 18px 1px 3px;
|
||||
// min-width: 6em;
|
||||
//}
|
||||
//
|
||||
//QComboBox:editable {
|
||||
// background: lightgrey;
|
||||
//}
|
||||
//
|
||||
//QComboBox QAbstractItemView {
|
||||
// border: 2px solid darkgray;
|
||||
// border-radius: 5px;
|
||||
// background-color: #a8a8a8;
|
||||
// selection-background-color: #a8a8a8;
|
||||
//}
|
||||
//
|
||||
//QLabel#label {
|
||||
// font-size: 13px;
|
||||
// background-color: transparent;
|
||||
// font-variant: small-caps;
|
||||
//}
|
||||
//
|
||||
//QLabel#value {
|
||||
// font-family: monospace;
|
||||
// font-weight: bold;
|
||||
// font-size: 14px;
|
||||
// background-color: transparent;
|
||||
//}
|
||||
//
|
||||
//QWidget#background {
|
||||
// background-color: transparent;
|
||||
//}
|
||||
//
|
||||
//QTextEdit {
|
||||
// font-family: monospace;
|
||||
//}
|
||||
//)style";
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
|
||||
static const QString style = R"style(
|
||||
QWidget {
|
||||
/*font-family: "Helvetica";*/
|
||||
}
|
||||
QWidget#MainWindow, QTextEdit, QWidget#SyncWidget, QWidget#DownloadArea {
|
||||
background-color: rgb(40, 40, 40);
|
||||
}
|
||||
QTextEdit, QLabel, QComboBox, QCheckBox {
|
||||
color: #EDEDED;
|
||||
font-size: 12px;
|
||||
}
|
||||
QLabel {
|
||||
font-size: 13px;
|
||||
}
|
||||
QLabel#Image {
|
||||
margin: -10px 0px -5px 0px;
|
||||
}
|
||||
QTextEdit {
|
||||
border-width: 2px 2px 0px 0px;
|
||||
border-style: solid;
|
||||
background-color: rgb(60, 60, 60);
|
||||
}
|
||||
QPushButton {
|
||||
color:#202020;
|
||||
background-color:
|
||||
qlineargradient(
|
||||
x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 white,
|
||||
stop: 1 #555555
|
||||
);
|
||||
border: 1px solid black;
|
||||
font-size: 11px;
|
||||
min-height: 20px;
|
||||
}
|
||||
QComboBox {
|
||||
background-color: rgb(60, 60, 60);
|
||||
min-height: 20px;
|
||||
}
|
||||
QComboBox:focus, QComboBox:focus QAbstractItemView {
|
||||
color: white;
|
||||
background-color: rgb(60, 60, 60);
|
||||
selection-background-color: rgb(75, 75, 75);
|
||||
}
|
||||
QCheckBox {
|
||||
border: none;
|
||||
}
|
||||
QCheckBox::indicator {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
QCheckBox::indicator::unchecked {
|
||||
border: 1px solid #5A5A5A;
|
||||
background: transparent;
|
||||
}
|
||||
QCheckBox::indicator:unchecked:hover {
|
||||
border: 1px solid #DDDDDD;
|
||||
}
|
||||
QCheckBox::indicator::checked {
|
||||
border: 1px solid #AAAAAA;
|
||||
background: #666666;
|
||||
}
|
||||
QCheckBox::indicator:checked:hover {
|
||||
border: 1px solid #DDDDDD;
|
||||
background: #555555;
|
||||
}
|
||||
QGroupBox, QScrollArea {
|
||||
border: 0px;
|
||||
}
|
||||
InfoWidget {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #BBBBBB;
|
||||
margin: 2px 1px 2px 1px;
|
||||
padding: 7.5px;
|
||||
}
|
||||
InfoWidget QLabel#Name {
|
||||
font-size: 17px;
|
||||
}
|
||||
InfoWidget QLabel#Bytes {
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Console";
|
||||
}
|
||||
InfoWidget QLabel#MessageLeft, QLabel#MessageCenter, QLabel#MessageRight {
|
||||
font-size: 11.5px;
|
||||
margin-top: -2px;
|
||||
}
|
||||
InfoWidget QProgressBar {
|
||||
border: 2px solid #BBBBBB;
|
||||
border-radius: 5px;
|
||||
background: white;
|
||||
height: 15px;
|
||||
}
|
||||
InfoWidget QProgressBar::chunk {
|
||||
background: qlineargradient(
|
||||
x1: 0, y1: 0.5, x2: 1, y2: 0.5,
|
||||
stop: 0 #444444,
|
||||
stop: 1 #600000
|
||||
);
|
||||
}
|
||||
QScrollBar {
|
||||
border: 1px solid #000000;
|
||||
background: #282828;
|
||||
width: 15px;
|
||||
margin: 16px 0px 16px 0px;
|
||||
}
|
||||
QScrollBar::handle {
|
||||
background: #B0B0B0;
|
||||
border: 1px solid #000000;
|
||||
border-width: 1px 0px 1px 0px;
|
||||
min-height: 20px;
|
||||
}
|
||||
QScrollBar::add-line, QScrollBar::sub-line {
|
||||
background:#B0B0B0;
|
||||
border: 1px solid #5A5A5A;
|
||||
subcontrol-origin: margin;
|
||||
}
|
||||
QScrollBar::add-line {
|
||||
top: 15px;
|
||||
height: 15px;
|
||||
}
|
||||
QScrollBar::sub-line {
|
||||
height: 15px;
|
||||
subcontrol-position: top;
|
||||
}
|
||||
QScrollBar::up-arrow, QScrollBar::down-arrow {
|
||||
border: 1px solid #5A5A5A;
|
||||
width: 3px;
|
||||
height: 3px;
|
||||
background-color: #353535;
|
||||
}
|
||||
QScrollBar::add-page, QScrollBar::sub-page {
|
||||
background: none;
|
||||
}
|
||||
)style";
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
QApplication app(argc, argv);
|
||||
app.setStyleSheet(style);
|
||||
|
||||
// app.setStyleSheet(style);
|
||||
MainWindow window;
|
||||
window.show();
|
||||
|
||||
|
||||
@@ -79,19 +79,28 @@ MainWindow::MainWindow()
|
||||
, _shortcutWidget(nullptr)
|
||||
, _syncWidget(nullptr)
|
||||
{
|
||||
setObjectName("MainWindow");
|
||||
setFixedSize(WindowSize);
|
||||
//setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QLabel* image = new QLabel;
|
||||
//image->setContentsMargins(0, 0, 0, 0);
|
||||
image->setObjectName("Image");
|
||||
QPixmap p = QPixmap(":/images/header.png");
|
||||
image->setPixmap(p.scaledToWidth(WindowSize.width()));
|
||||
layout->addWidget(image, 0, 0, 1, 2);
|
||||
|
||||
|
||||
_informationWidget = new QTextEdit(this);
|
||||
_informationWidget->setReadOnly(true);
|
||||
_informationWidget->setEnabled(false);
|
||||
layout->addWidget(_informationWidget, 1, 0, 2, 1);
|
||||
layout->setRowStretch(1, 10);
|
||||
layout->setColumnStretch(0, 4);
|
||||
layout->setColumnStretch(1, 5);
|
||||
|
||||
QWidget* container = new QWidget;
|
||||
{
|
||||
@@ -104,11 +113,18 @@ MainWindow::MainWindow()
|
||||
this, SLOT(shortcutButtonPressed())
|
||||
);
|
||||
layout->addWidget(shortcutButton, 0, 1);
|
||||
|
||||
layout->setRowStretch(1, 10);
|
||||
|
||||
QLabel* configurationSelectionLabel = new QLabel("Configuration:");
|
||||
layout->addWidget(configurationSelectionLabel, 2, 0);
|
||||
_configurations = new QComboBox;
|
||||
layout->addWidget(_configurations, 2, 1);
|
||||
|
||||
QLabel* sceneSelectionLabel = new QLabel("Scenes:");
|
||||
layout->addWidget(sceneSelectionLabel, 1, 0);
|
||||
layout->addWidget(sceneSelectionLabel, 3, 0);
|
||||
_scenes = new QComboBox;
|
||||
layout->addWidget(_scenes);
|
||||
layout->addWidget(_scenes, 3, 1);
|
||||
|
||||
container->setLayout(layout);
|
||||
}
|
||||
@@ -181,27 +197,40 @@ void MainWindow::initialize() {
|
||||
std::string configurationFile = _configurationFile;
|
||||
bool found = openspace::OpenSpaceEngine::findConfiguration(configurationFile);
|
||||
if (!found) {
|
||||
LERRORC("MainWindow", "Could not find configuration file");
|
||||
}
|
||||
|
||||
_configuration = new openspace::ConfigurationManager;
|
||||
_configuration->loadFromFile(configurationFile);
|
||||
|
||||
|
||||
QString modulesDirectory = QString::fromStdString(
|
||||
absPath("${SCENE}")
|
||||
);
|
||||
// Load all available scenes
|
||||
QString modulesDirectory = QString::fromStdString(absPath("${SCENE}"));
|
||||
QDir d(modulesDirectory);
|
||||
d.setFilter(QDir::Files);
|
||||
|
||||
QFileInfoList list = d.entryInfoList();
|
||||
_scenes->addItem("Use Default");
|
||||
for (const QFileInfo& i : list) {
|
||||
_sceneFiles.insert(i.fileName(), i.absoluteFilePath());
|
||||
_scenes->addItem(i.fileName());
|
||||
QString file = i.fileName();
|
||||
file = file.replace(".scene", "");
|
||||
_sceneFiles.insert(file, i.absoluteFilePath());
|
||||
_scenes->addItem(file);
|
||||
}
|
||||
|
||||
_scenes->setCurrentText("default.scene");
|
||||
|
||||
_scenes->setCurrentText("Use Default");
|
||||
_syncWidget->setSceneFiles(_sceneFiles);
|
||||
|
||||
// Load all available configuration files
|
||||
QString configurationDirectory = QString::fromStdString(absPath("${SGCT}"));
|
||||
d = QDir(configurationDirectory);
|
||||
d.setFilter(QDir::Files);
|
||||
list = d.entryInfoList();
|
||||
_configurations->addItem("Use Default");
|
||||
for (const QFileInfo& i : list) {
|
||||
QString file = i.fileName();
|
||||
file = file.replace(".xml", "");
|
||||
_configurationFiles.insert(file, i.absoluteFilePath());
|
||||
_configurations->addItem(file);
|
||||
}
|
||||
_configurations->setCurrentText("Use Default");
|
||||
}
|
||||
|
||||
void MainWindow::shortcutButtonPressed() {
|
||||
@@ -213,7 +242,15 @@ void MainWindow::syncButtonPressed() {
|
||||
}
|
||||
|
||||
void MainWindow::startButtonPressed() {
|
||||
QProcess::startDetached(OpenSpaceExecutable);
|
||||
QString exec = OpenSpaceExecutable;
|
||||
if (_sceneFiles.contains(_scenes->currentText()))
|
||||
exec += " -scene \"" + _sceneFiles[_scenes->currentText()] + "\"";
|
||||
|
||||
if (_configurationFiles.contains(_configurations->currentText()))
|
||||
exec += " -sgct \"" + _configurationFiles[_configurations->currentText()] + "\"";
|
||||
|
||||
LINFOC("MainWindow", "Executing: " << exec.toStdString());
|
||||
QProcess::startDetached(exec);
|
||||
}
|
||||
|
||||
void MainWindow::newsNetworkError() {
|
||||
|
||||
@@ -63,9 +63,12 @@ private:
|
||||
|
||||
QTextEdit* _informationWidget;
|
||||
|
||||
QComboBox* _configurations;
|
||||
QMap<QString, QString> _configurationFiles;
|
||||
|
||||
QComboBox* _scenes;
|
||||
QMap<QString, QString> _sceneFiles;
|
||||
|
||||
|
||||
ShortcutWidget* _shortcutWidget;
|
||||
SyncWidget* _syncWidget;
|
||||
|
||||
|
||||
@@ -82,9 +82,11 @@ SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
|
||||
, _sceneLayout(nullptr)
|
||||
, _session(new libtorrent::session)
|
||||
{
|
||||
setObjectName("SyncWidget");
|
||||
setFixedSize(500, 500);
|
||||
|
||||
QBoxLayout* layout = new QVBoxLayout;
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
{
|
||||
QGroupBox* sceneBox = new QGroupBox;
|
||||
_sceneLayout = new QGridLayout;
|
||||
@@ -92,7 +94,8 @@ SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
|
||||
layout->addWidget(sceneBox);
|
||||
}
|
||||
{
|
||||
QPushButton* syncButton = new QPushButton("Synchronize Scenes");
|
||||
QPushButton* syncButton = new QPushButton("Synchronize Data");
|
||||
syncButton->setObjectName("SyncButton");
|
||||
QObject::connect(
|
||||
syncButton, SIGNAL(clicked(bool)),
|
||||
this, SLOT(syncButtonPressed())
|
||||
@@ -106,6 +109,7 @@ SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
|
||||
area->setWidgetResizable(true);
|
||||
|
||||
QWidget* w = new QWidget;
|
||||
w->setObjectName("DownloadArea");
|
||||
area->setWidget(w);
|
||||
|
||||
_downloadLayout = new QVBoxLayout(w);
|
||||
@@ -115,6 +119,12 @@ SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
|
||||
|
||||
layout->addWidget(area);
|
||||
}
|
||||
QPushButton* close = new QPushButton("Close");
|
||||
layout->addWidget(close, Qt::AlignRight);
|
||||
QObject::connect(
|
||||
close, SIGNAL(clicked(bool)),
|
||||
this, SLOT(close())
|
||||
);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
@@ -213,7 +223,6 @@ void SyncWidget::setSceneFiles(QMap<QString, QString> sceneFiles) {
|
||||
const QString& sceneName = keys[i];
|
||||
|
||||
QCheckBox* checkbox = new QCheckBox(sceneName);
|
||||
|
||||
checkbox->setChecked(true);
|
||||
|
||||
_sceneLayout->addWidget(checkbox, i / nColumns, i % nColumns);
|
||||
@@ -326,7 +335,13 @@ void SyncWidget::handleTorrentFiles() {
|
||||
}
|
||||
|
||||
if (_torrentInfoWidgetMap.find(h) == _torrentInfoWidgetMap.end()) {
|
||||
InfoWidget* w = new InfoWidget(f.file, h.status().total_wanted);
|
||||
QString fileString = f.file;
|
||||
QString t = QString(".torrent");
|
||||
fileString.replace(fileString.indexOf(t), t.size(), "");
|
||||
|
||||
fileString = f.module + "/" + fileString;
|
||||
|
||||
InfoWidget* w = new InfoWidget(fileString, h.status().total_wanted);
|
||||
_downloadLayout->insertWidget(_downloadLayout->count() - 1, w);
|
||||
_torrentInfoWidgetMap[h] = w;
|
||||
}
|
||||
|
||||
Submodule ext/ghoul updated: 5a6d99432b...f87ad95260
@@ -40,10 +40,13 @@ public:
|
||||
NumericalProperty(std::string identifier, std::string guiName, T value,
|
||||
T minimumValue, T maximumValue, T steppingValue);
|
||||
|
||||
bool getLua(lua_State* state) const override;
|
||||
bool setLua(lua_State* state) override;
|
||||
bool getLuaValue(lua_State* state) const override;
|
||||
bool setLuaValue(lua_State* state) override;
|
||||
int typeLua() const override;
|
||||
|
||||
bool getStringValue(std::string& value) const override;
|
||||
bool setStringValue(std::string value) override;
|
||||
|
||||
T minValue() const;
|
||||
T maxValue() const;
|
||||
|
||||
|
||||
@@ -29,22 +29,29 @@ namespace properties {
|
||||
|
||||
#define REGISTER_NUMERICALPROPERTY_HEADER(CLASS_NAME, TYPE) \
|
||||
typedef NumericalProperty<TYPE> CLASS_NAME; \
|
||||
\
|
||||
template <> \
|
||||
std::string PropertyDelegate<NumericalProperty<TYPE>>::className(); \
|
||||
\
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>(); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>(); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>(); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>(); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue(lua_State* state, \
|
||||
@@ -64,61 +71,92 @@ namespace properties {
|
||||
template <> \
|
||||
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua(); \
|
||||
template <> \
|
||||
int PropertyDelegate<NumericalProperty<TYPE>>::typeLua();
|
||||
int PropertyDelegate<NumericalProperty<TYPE>>::typeLua(); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromString(std::string value, \
|
||||
bool& success); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromString(std::string value, \
|
||||
bool& success); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
|
||||
TYPE inValue); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<NumericalProperty<TYPE>>::toString(std::string& outValue, \
|
||||
TYPE inValue);
|
||||
|
||||
|
||||
#define REGISTER_NUMERICALPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE, \
|
||||
DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, \
|
||||
DEFAULT_STEPPING, FROM_LUA_LAMBDA_EXPRESSION, \
|
||||
TO_LUA_LAMBDA_EXPRESSION, LUA_TYPE) \
|
||||
TO_LUA_LAMBDA_EXPRESSION, \
|
||||
FROM_STRING_LAMBDA_EXPRESSION, \
|
||||
TO_STRING_LAMBDA_EXPRESSION, LUA_TYPE) \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
|
||||
{ \
|
||||
return #CLASS_NAME; \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
std::string PropertyDelegate<NumericalProperty<TYPE>>::className() \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_VALUE; \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_MIN_VALUE; \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_MAX_VALUE; \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_STEPPING; \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(lua_State * state, \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(lua_State* state, \
|
||||
bool& success) \
|
||||
{ \
|
||||
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromLuaValue<TYPE>( \
|
||||
lua_State * state, bool& success) \
|
||||
lua_State* state, bool& success) \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(state, \
|
||||
success); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(lua_State * state, \
|
||||
@@ -126,6 +164,7 @@ namespace properties {
|
||||
{ \
|
||||
return TO_LUA_LAMBDA_EXPRESSION(state, value); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<NumericalProperty<TYPE>>::toLuaValue<TYPE>(lua_State * state, \
|
||||
@@ -133,15 +172,50 @@ namespace properties {
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(state, value); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua() \
|
||||
{ \
|
||||
return LUA_TYPE; \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
int PropertyDelegate<NumericalProperty<TYPE>>::typeLua() \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::typeLua(); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromString(std::string value, \
|
||||
bool& success) \
|
||||
{ \
|
||||
return FROM_STRING_LAMBDA_EXPRESSION(value, success); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromString(std::string value, \
|
||||
bool& success) \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::fromString<TYPE>(value, \
|
||||
success); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
|
||||
TYPE inValue) \
|
||||
{ \
|
||||
return TO_STRING_LAMBDA_EXPRESSION(outValue, inValue); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<NumericalProperty<TYPE>>::toString(std::string& outValue, \
|
||||
TYPE inValue) \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::toString(outValue, inValue); \
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +280,7 @@ std::string NumericalProperty<T>::className() const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::setLua(lua_State* state)
|
||||
bool NumericalProperty<T>::setLuaValue(lua_State* state)
|
||||
{
|
||||
bool success = false;
|
||||
T value = PropertyDelegate<NumericalProperty<T>>::template fromLuaValue<T>(state, success);
|
||||
@@ -216,7 +290,7 @@ bool NumericalProperty<T>::setLua(lua_State* state)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::getLua(lua_State* state) const
|
||||
bool NumericalProperty<T>::getLuaValue(lua_State* state) const
|
||||
{
|
||||
bool success = PropertyDelegate<NumericalProperty<T>>::template toLuaValue<T>(state, TemplateProperty<T>::_value);
|
||||
return success;
|
||||
@@ -227,6 +301,21 @@ int NumericalProperty<T>::typeLua() const {
|
||||
return PropertyDelegate<NumericalProperty<T>>::typeLua();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::getStringValue(std::string& value) const {
|
||||
bool success = PropertyDelegate<NumericalProperty<T>>::template toString<T>(value, _value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::setStringValue(std::string value) {
|
||||
bool success = false;
|
||||
T thisValue = PropertyDelegate<NumericalProperty<T>>::template fromString<T>(value, success);
|
||||
if (success)
|
||||
set(boost::any(thisValue));
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T NumericalProperty<T>::minValue() const {
|
||||
return _minimumValue;
|
||||
|
||||
@@ -45,8 +45,9 @@ class PropertyOwner;
|
||||
* Property. Per PropertyOwner, the <code>identifier</code> needs to be unique and can be
|
||||
* used as a URI. This class is an abstract base class and each subclass (most notable
|
||||
* TemplateProperty) needs to implement the methods Property::className, Property::get,
|
||||
* Property::set, Property::type(), Property::getLua, Property::setLua, and
|
||||
* Property::typeLua to make full use of the infrastructure.
|
||||
* Property::set, Property::type(), Property::getLuaValue, Property::setLuaValue,
|
||||
* Property::getStringValue, Property::setStringValue and Property::typeLua to make full
|
||||
* use of the infrastructure.
|
||||
* The most common types can be implemented by creating a specialized instantiation of
|
||||
* TemplateProperty, which provides default implementations for these methods.
|
||||
*
|
||||
@@ -118,47 +119,69 @@ public:
|
||||
* This method encodes the encapsulated value of this Property at the top of the Lua
|
||||
* stack. The specific details of this serialization is up to the property developer
|
||||
* as long as the rest of the stack is unchanged. The implementation has to be
|
||||
* synchronized with the Property::setLua method. The default implementation is a
|
||||
* synchronized with the Property::setLuaValue method. The default implementation is a
|
||||
* no-op.
|
||||
* \param state The Lua state to which the value will be encoded
|
||||
* \return <code>true</code> if the encoding succeeded, <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool getLua(lua_State* state) const;
|
||||
virtual bool getLuaValue(lua_State* state) const;
|
||||
|
||||
/**
|
||||
* This method sets the value encapsulated by this Property by deserializing the value
|
||||
* on top of the passed Lua stack. The specific details of the deserialization are up
|
||||
* to the Property developer, but they must only depend on the top element of the
|
||||
* stack and must leave all other elements unchanged. The implementation has to be
|
||||
* synchronized with the Property::getLua method. The default implementation is a
|
||||
* synchronized with the Property::getLuaValue method. The default implementation is a
|
||||
* no-op.
|
||||
* \param state The Lua state from which the value will be decoded
|
||||
* \return <code>true</code> if the decoding and setting of the value succeeded,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool setLua(lua_State* state);
|
||||
virtual bool setLuaValue(lua_State* state);
|
||||
|
||||
/**
|
||||
* Returns the Lua type that will be put onto the stack in the Property::getLua method
|
||||
* and which will be consumed by the Property::setLua method. The returned value
|
||||
* and which will be consumed by the Property::setLuaValue method. The returned value
|
||||
* can belong to the set of Lua types: <code>LUA_TNONE</code>, <code>LUA_TNIL</code>,
|
||||
* <code>LUA_TBOOLEAN</code>, <code>LUA_TLIGHTUSERDATA</code>,
|
||||
* <code>LUA_TNUMBER</code>, <code>LUA_TSTRING</code>, <code>LUA_TTABLE</code>,
|
||||
* <code>LUA_TFUNCTION</code>, <code>LUA_TUSERDATA</code>, or
|
||||
* <code>LUA_TTHREAD</code>. The default implementation will return
|
||||
* <code>LUA_TNONE</code>.
|
||||
* \return The Lua type that will be consumed or produced by the Property::getLua and
|
||||
* Property::setLua methods.
|
||||
* \return The Lua type that will be consumed or produced by the Property::getLuaValue
|
||||
* and Property::setLuaValue methods.
|
||||
*/
|
||||
virtual int typeLua() const;
|
||||
|
||||
/**
|
||||
* This method encodes the encapsulated value of this Property as a
|
||||
* <code>std::string</code>. The specific details of this serialization is up to the
|
||||
* property developer. The implementation has to be synchronized with the
|
||||
Property::setStringValue method. The default implementation is a no-op.
|
||||
* \param value The value to which the Property will be encoded
|
||||
* \return <code>true</code> if the encoding succeeded, <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool getStringValue(std::string& value) const;
|
||||
|
||||
/**
|
||||
* This method sets the value encapsulated by this Property by deserializing the
|
||||
* passed <code>std::string</code>. The specific details of the deserialization are up
|
||||
* to the Property developer. The implementation has to be synchronized with the
|
||||
* Property::getLuaValue method. The default implementation is a no-op.
|
||||
* \param value The value from which the Property will be decoded
|
||||
* \return <code>true</code> if the decoding and setting of the value succeeded,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool setStringValue(std::string value);
|
||||
|
||||
/**
|
||||
* This method registers a <code>callback</code> function that will be called every
|
||||
* time if either Property:set or Property::setLua was called with a value that is
|
||||
* different from the previously stored value. The callback can be removed my passing
|
||||
* an empty <code>std::function<void()></code> object.
|
||||
* time if either Property:set or Property::setLuaValue was called with a value that
|
||||
* is different from the previously stored value. The callback can be removed by
|
||||
* passing an empty <code>std::function<void()></code> object.
|
||||
* \param callback The callback function that is called when the encapsulated type has
|
||||
* been successfully changed by either the Property::set or Property::setLua methods.
|
||||
* been successfully changed by either the Property::set or Property::setLuaValue
|
||||
* methods.
|
||||
*/
|
||||
virtual void onChange(std::function<void()> callback);
|
||||
|
||||
@@ -243,9 +266,10 @@ public:
|
||||
/**
|
||||
* This method determines if this Property should be read-only in external
|
||||
* applications. This setting is only a hint and does not need to be followed by GUI
|
||||
* applications and does not have any effect on the Property::set or Property::setLua
|
||||
* methods. The value is stored in the metaData Dictionary with the key:
|
||||
* <code>isReadOnly</code>. The default value is <code>false</code>.
|
||||
* applications and does not have any effect on the Property::set,
|
||||
* Property::setLuaValue, or Property::setStringValue methods. The value is stored in
|
||||
* the metaData Dictionary with the key: <code>isReadOnly</code>. The default value is
|
||||
* <code>false</code>.
|
||||
* \param state <code>true</code> if the Property should be read only,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
|
||||
@@ -149,6 +149,12 @@ public:
|
||||
* PropertyDelegate::toLuaValue and PropertyDelegate::fromLuaValue methods.
|
||||
*/
|
||||
static int typeLua();
|
||||
|
||||
template <typename U>
|
||||
static U fromString(std::string value, bool& success);
|
||||
|
||||
template <typename U>
|
||||
static bool toString(std::string& outValue, U inValue);
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
|
||||
@@ -81,5 +81,19 @@ int PropertyDelegate<T>::typeLua() {
|
||||
"Unimplemented PropertyDelegate::luaType specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
bool PropertyDelegate<T>::toString(std::string& outValue, U inValue) {
|
||||
static_assert(sizeof(T) == 0,
|
||||
"Unimplemented PropertyDelegate::toString specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::fromString(std::string value, bool& success) {
|
||||
static_assert(sizeof(T) == 0,
|
||||
"Unimplemented PropertyDelegate::fromString specialization");
|
||||
}
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
@@ -67,6 +67,14 @@ bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toLuaValue(lua_State*
|
||||
template <>
|
||||
int PropertyDelegate<TemplateProperty<std::vector<int>>>::typeLua();
|
||||
|
||||
template <>
|
||||
template <>
|
||||
std::vector<int> PropertyDelegate<TemplateProperty<std::vector<int>>>::fromString(std::string value, bool& success);
|
||||
|
||||
template <>
|
||||
template <>
|
||||
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toString(std::string& outValue, std::vector<int> inValue);
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
* \param state The Lua state onto which the encoded object will be pushed
|
||||
* \return <code>true</code> if the encoding succeeded; <code>false</code> otherwise
|
||||
*/
|
||||
bool getLua(lua_State* state) const override;
|
||||
bool getLuaValue(lua_State* state) const override;
|
||||
|
||||
/**
|
||||
* Sets the value of this TemplateProprty by decoding the object at the top of the Lua
|
||||
@@ -122,11 +122,15 @@ public:
|
||||
* \param state The Lua state from which the value will be decoded
|
||||
* \return <code>true</code> if the decoding succeeded; <code>false</code> otherwise
|
||||
*/
|
||||
bool setLua(lua_State* state) override;
|
||||
bool setLuaValue(lua_State* state) override;
|
||||
|
||||
/// \see Property::typeLua
|
||||
int typeLua() const override;
|
||||
|
||||
bool getStringValue(std::string& value) const override;
|
||||
|
||||
bool setStringValue(std::string value) override;
|
||||
|
||||
/**
|
||||
* Returns the description for this TemplateProperty as a Lua script that returns a
|
||||
* table on execution
|
||||
|
||||
@@ -37,21 +37,37 @@ namespace properties {
|
||||
// TYPE = The template parameter T for which the TemplateProperty is specialized
|
||||
#define REGISTER_TEMPLATEPROPERTY_HEADER(CLASS_NAME, TYPE) \
|
||||
typedef TemplateProperty<TYPE> CLASS_NAME; \
|
||||
\
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>(); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue(lua_State* state, \
|
||||
bool& success); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue(lua_State* state, \
|
||||
TYPE value); \
|
||||
\
|
||||
template <> \
|
||||
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua();
|
||||
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua(); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromString(std::string value, \
|
||||
bool& success); \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
|
||||
TYPE inValue);
|
||||
|
||||
|
||||
// CLASS_NAME = The string that the Property::className() should return as well as the
|
||||
// C++ class name for which a typedef will be created
|
||||
@@ -70,18 +86,22 @@ namespace properties {
|
||||
// Lambda expressions
|
||||
#define REGISTER_TEMPLATEPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE, \
|
||||
FROM_LUA_LAMBDA_EXPRESSION, \
|
||||
TO_LUA_LAMBDA_EXPRESSION, LUA_TYPE) \
|
||||
TO_LUA_LAMBDA_EXPRESSION, \
|
||||
FROM_STRING_LAMBDA_EXPRESSION, \
|
||||
TO_STRING_LAMBDA_EXPRESSION, LUA_TYPE) \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
|
||||
{ \
|
||||
return #CLASS_NAME; \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_VALUE; \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(lua_State * state, \
|
||||
@@ -89,6 +109,7 @@ namespace properties {
|
||||
{ \
|
||||
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(lua_State * state, \
|
||||
@@ -96,11 +117,30 @@ namespace properties {
|
||||
{ \
|
||||
return TO_LUA_LAMBDA_EXPRESSION(state, value); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua() \
|
||||
{ \
|
||||
return LUA_TYPE; \
|
||||
}
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromString(std::string value, \
|
||||
bool& success) \
|
||||
{ \
|
||||
return FROM_STRING_LAMBDA_EXPRESSION(value, success); \
|
||||
} \
|
||||
\
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
|
||||
TYPE inValue) \
|
||||
{ \
|
||||
return TO_STRING_LAMBDA_EXPRESSION(outValue, inValue); \
|
||||
} \
|
||||
|
||||
|
||||
|
||||
// Delegating constructors are necessary; automatic template deduction cannot
|
||||
// deduce template argument for 'U' if 'default' methods are used as default values in
|
||||
@@ -195,8 +235,13 @@ const std::type_info& TemplateProperty<T>::type() const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::setLua(lua_State* state)
|
||||
{
|
||||
bool TemplateProperty<T>::getLuaValue(lua_State* state) const {
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toLuaValue<T>(state, _value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::setLuaValue(lua_State* state) {
|
||||
bool success = false;
|
||||
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromLuaValue<T>(state, success);
|
||||
if (success)
|
||||
@@ -204,17 +249,25 @@ bool TemplateProperty<T>::setLua(lua_State* state)
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::getLua(lua_State* state) const
|
||||
{
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toLuaValue<T>(state, _value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int TemplateProperty<T>::typeLua() const {
|
||||
return PropertyDelegate<TemplateProperty<T>>::typeLua();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::getStringValue(std::string& value) const {
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toString<T>(value, _value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::setStringValue(std::string value) {
|
||||
bool success = false;
|
||||
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromString<T>(value, success);
|
||||
if (success)
|
||||
set(boost::any(thisValue));
|
||||
return success;
|
||||
}
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
* \param state The unused Lua state
|
||||
* \return Returns always <code>true</code>
|
||||
*/
|
||||
bool setLua(lua_State* state);
|
||||
bool setLuaValue(lua_State* state);
|
||||
|
||||
/**
|
||||
* Silently ignores any value that is passed into this function and will trigger the
|
||||
|
||||
@@ -40,13 +40,15 @@
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#define USE_MULTITHREADED_DOWNLOAD
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "DownloadManager";
|
||||
|
||||
const std::string RequestIdentifier = "identifier";
|
||||
const std::string RequestFileVersion = "file_version";
|
||||
const std::string RequestApplicationVersion = "application_version";
|
||||
|
||||
|
||||
struct ProgressInformation {
|
||||
openspace::DownloadManager::FileFuture* future;
|
||||
std::chrono::system_clock::time_point startTime;
|
||||
@@ -145,7 +147,10 @@ DownloadManager::FileFuture* DownloadManager::downloadFile(
|
||||
|
||||
LDEBUG("Starting download for file: '" << url <<
|
||||
"' into file '" << file.path() << "'");
|
||||
|
||||
#ifdef USE_MULTITHREADED_DOWNLOAD
|
||||
std::thread t = std::thread([url, finishedCallback, progressCallback, future, fp]() {
|
||||
#endif
|
||||
CURL* curl = curl_easy_init();
|
||||
if (curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
@@ -174,6 +179,7 @@ DownloadManager::FileFuture* DownloadManager::downloadFile(
|
||||
if (finishedCallback)
|
||||
finishedCallback(*future);
|
||||
}
|
||||
#ifdef USE_MULTITHREADED_DOWNLOAD
|
||||
});
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -185,6 +191,7 @@ DownloadManager::FileFuture* DownloadManager::downloadFile(
|
||||
#endif
|
||||
|
||||
t.detach();
|
||||
#endif // USE_MULTITHREADED_DOWNLOAD
|
||||
|
||||
return future;
|
||||
}
|
||||
@@ -253,7 +260,9 @@ void DownloadManager::downloadRequestFilesAsync(
|
||||
bool overrideFiles,
|
||||
AsyncDownloadFinishedCallback callback)
|
||||
{
|
||||
#ifdef USE_MULTITHREADED_DOWNLOAD
|
||||
std::thread t = std::thread([this, identifier, destination, version, overrideFiles, callback](){
|
||||
#endif
|
||||
std::vector<FileFuture*> f = downloadRequestFiles(
|
||||
identifier,
|
||||
destination,
|
||||
@@ -262,6 +271,7 @@ void DownloadManager::downloadRequestFilesAsync(
|
||||
);
|
||||
|
||||
callback(f);
|
||||
#ifdef USE_MULTITHREADED_DOWNLOAD
|
||||
});
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -273,6 +283,7 @@ void DownloadManager::downloadRequestFilesAsync(
|
||||
#endif
|
||||
|
||||
t.detach();
|
||||
#endif // USE_MULTITHREADED_DOWNLOAD
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace {
|
||||
struct {
|
||||
std::string configurationName;
|
||||
std::string sgctConfigurationName;
|
||||
std::string sceneName;
|
||||
} commandlineArgumentPlaceholders;
|
||||
}
|
||||
|
||||
@@ -358,11 +359,14 @@ bool OpenSpaceEngine::initialize() {
|
||||
_renderEngine->initialize();
|
||||
sceneGraph->initialize();
|
||||
|
||||
std::string sceneDescriptionPath;
|
||||
success = configurationManager()->getValue(
|
||||
ConfigurationManager::KeyConfigScene, sceneDescriptionPath);
|
||||
if (success)
|
||||
sceneGraph->scheduleLoadSceneFile(sceneDescriptionPath);
|
||||
std::string sceneDescriptionPath = "";
|
||||
if (commandlineArgumentPlaceholders.sceneName.empty()) {
|
||||
success = configurationManager()->getValue(
|
||||
ConfigurationManager::KeyConfigScene, sceneDescriptionPath);
|
||||
}
|
||||
else
|
||||
sceneDescriptionPath = commandlineArgumentPlaceholders.sceneName;
|
||||
sceneGraph->scheduleLoadSceneFile(sceneDescriptionPath);
|
||||
|
||||
_interactionHandler->setKeyboardController(new interaction::KeyboardControllerFixed);
|
||||
_interactionHandler->setMouseController(new interaction::OrbitalMouseController);
|
||||
@@ -413,6 +417,13 @@ bool OpenSpaceEngine::gatherCommandlineArguments() {
|
||||
"the OpenSpace configuration file");
|
||||
_commandlineParser->addCommand(sgctConfigFileCommand);
|
||||
|
||||
commandlineArgumentPlaceholders.sceneName = "";
|
||||
CommandlineCommand* sceneFileCommand = new SingleCommand<std::string>(
|
||||
&commandlineArgumentPlaceholders.sceneName, "-scene", "",
|
||||
"Provides the path to the scene file, overriding the value set in the OpenSpace"
|
||||
" configuration file");
|
||||
_commandlineParser->addCommand(sceneFileCommand);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,11 @@
|
||||
|
||||
#include <openspace/properties/matrixproperty.h>
|
||||
|
||||
#include <ghoul/misc/misc.h>
|
||||
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
using std::numeric_limits;
|
||||
|
||||
@@ -32,7 +36,7 @@ namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \
|
||||
[](lua_State * state, bool& success) -> __TYPE__ { \
|
||||
[](lua_State* state, bool& success) -> __TYPE__ { \
|
||||
__TYPE__ result; \
|
||||
int number = 1; \
|
||||
for (__TYPE__::size_type i = 0; i < __TYPE__::row_size(); ++i) { \
|
||||
@@ -54,7 +58,7 @@ namespace properties {
|
||||
}
|
||||
|
||||
#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \
|
||||
[](lua_State * state, __TYPE__ value) -> bool { \
|
||||
[](lua_State* state, __TYPE__ value) -> bool { \
|
||||
lua_newtable(state); \
|
||||
int number = 1; \
|
||||
for (__TYPE__::size_type i = 0; i < __TYPE__::row_size(); ++i) { \
|
||||
@@ -67,6 +71,45 @@ namespace properties {
|
||||
return true; \
|
||||
}
|
||||
|
||||
#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \
|
||||
[](std::string value, bool& success) -> __TYPE__ { \
|
||||
__TYPE__ result; \
|
||||
std::vector<std::string> tokens = ghoul::tokenizeString(value, ','); \
|
||||
if (tokens.size() != (__TYPE__::row_size() * __TYPE__::col_size())) { \
|
||||
success = false; \
|
||||
return result; \
|
||||
} \
|
||||
int number = 0; \
|
||||
for (__TYPE__::size_type i = 0; i < __TYPE__::row_size(); ++i) { \
|
||||
for (__TYPE__::size_type j = 0; j < __TYPE__::col_size(); ++j) { \
|
||||
std::stringstream s(tokens[number]); \
|
||||
__TYPE__::value_type v; \
|
||||
s >> v; \
|
||||
if (s.fail()) { \
|
||||
success = false; \
|
||||
return result; \
|
||||
} \
|
||||
else { \
|
||||
result[i][j] = v; \
|
||||
++number; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
success = true; \
|
||||
return result; \
|
||||
}
|
||||
|
||||
#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \
|
||||
[](std::string& outValue, __TYPE__ inValue) -> bool { \
|
||||
outValue = ""; \
|
||||
for (__TYPE__::size_type i = 0; i < __TYPE__::row_size(); ++i) { \
|
||||
for (__TYPE__::size_type j = 0; j < __TYPE__::col_size(); ++j) { \
|
||||
outValue += std::to_string(inValue[i][j]) + ","; \
|
||||
} \
|
||||
} \
|
||||
return true; \
|
||||
}
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Mat2Property, glm::mat2x2, glm::mat2x2(0),
|
||||
glm::mat2x2(
|
||||
numeric_limits<float>::lowest(),
|
||||
@@ -85,7 +128,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat2Property, glm::mat2x2, glm::mat2x2(0),
|
||||
0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat2x2),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat2x2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat2x2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::mat2x2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::mat2x2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x3Property, glm::mat2x3, glm::mat2x3(0),
|
||||
glm::mat2x3(
|
||||
@@ -109,7 +155,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x3Property, glm::mat2x3, glm::mat2x3(0),
|
||||
0.01f, 0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat2x3),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat2x3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat2x3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::mat2x3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::mat2x3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x4Property, glm::mat2x4, glm::mat2x4(0),
|
||||
glm::mat2x4(
|
||||
@@ -137,7 +186,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x4Property, glm::mat2x4, glm::mat2x4(0),
|
||||
0.01f, 0.01f, 0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat2x4),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat2x4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat2x4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::mat2x4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::mat2x4),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x2Property, glm::mat3x2, glm::mat3x2(0),
|
||||
glm::mat3x2(
|
||||
@@ -161,7 +213,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x2Property, glm::mat3x2, glm::mat3x2(0),
|
||||
0.01f, 0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat3x2),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat3x2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat3x2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::mat3x2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::mat3x2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Mat3Property, glm::mat3x3, glm::mat3x3(0),
|
||||
glm::mat3x3(
|
||||
@@ -192,7 +247,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat3Property, glm::mat3x3, glm::mat3x3(0),
|
||||
0.01f, 0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat3x3),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat3x3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat3x3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::mat3x3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::mat3x3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x4Property, glm::mat3x4, glm::mat3x4(0),
|
||||
glm::mat3x4(
|
||||
@@ -229,7 +287,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x4Property, glm::mat3x4, glm::mat3x4(0),
|
||||
0.01f, 0.01f, 0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat3x4),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat3x4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat3x4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::mat3x4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::mat3x4),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x2Property, glm::mat4x2, glm::mat4x2(0),
|
||||
glm::mat4x2(
|
||||
@@ -257,7 +318,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x2Property, glm::mat4x2, glm::mat4x2(0),
|
||||
0.01f, 0.01f, 0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat4x2),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat4x2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat4x2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::mat4x2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::mat4x2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x3Property, glm::mat4x3, glm::mat4x3(0),
|
||||
glm::mat4x3(
|
||||
@@ -294,7 +358,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x3Property, glm::mat4x3, glm::mat4x3(0),
|
||||
0.01f, 0.01f, 0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat4x3),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat4x3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat4x3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::mat4x3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::mat4x3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Mat4Property, glm::mat4x4, glm::mat4x4(0),
|
||||
glm::mat4x4(
|
||||
@@ -340,7 +407,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(Mat4Property, glm::mat4x4, glm::mat4x4(0),
|
||||
0.01f, 0.01f, 0.01f, 0.01f
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::mat4x4),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat4x4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::mat4x4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::mat4x4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::mat4x4),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DMat2Property, glm::dmat2x2, glm::dmat2x2(0),
|
||||
glm::dmat2x2(
|
||||
@@ -360,7 +430,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DMat2Property, glm::dmat2x2, glm::dmat2x2(0),
|
||||
0.01, 0.01
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x2),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat2x2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat2x2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dmat2x2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dmat2x2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x3Property, glm::dmat2x3, glm::dmat2x3(0),
|
||||
glm::dmat2x3(
|
||||
@@ -384,7 +457,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x3Property, glm::dmat2x3, glm::dmat2x3(0)
|
||||
0.01, 0.01, 0.01
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x3),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat2x3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat2x3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dmat2x3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dmat2x3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x4Property, glm::dmat2x4, glm::dmat2x4(0),
|
||||
glm::dmat2x4(
|
||||
@@ -412,7 +488,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x4Property, glm::dmat2x4, glm::dmat2x4(0)
|
||||
0.01, 0.01, 0.01, 0.01
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x4),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat2x4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat2x4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dmat2x4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dmat2x4),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x2Property, glm::dmat3x2, glm::dmat3x2(0),
|
||||
glm::dmat3x2(
|
||||
@@ -436,7 +515,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x2Property, glm::dmat3x2, glm::dmat3x2(0)
|
||||
0.01, 0.01, 0.01
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x2),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat3x2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat3x2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dmat3x2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dmat3x2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DMat3Property, glm::dmat3x3, glm::dmat3x3(0),
|
||||
glm::dmat3x3(
|
||||
@@ -467,7 +549,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DMat3Property, glm::dmat3x3, glm::dmat3x3(0),
|
||||
0.01, 0.01, 0.01
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x3),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat3x3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat3x3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dmat3x3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dmat3x3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x4Property, glm::dmat3x4, glm::dmat3x4(0),
|
||||
glm::dmat3x4(
|
||||
@@ -504,7 +589,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x4Property, glm::dmat3x4, glm::dmat3x4(0)
|
||||
0.01, 0.01, 0.01, 0.01
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x4),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat3x4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat3x4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dmat3x4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dmat3x4),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x2Property, glm::dmat4x2, glm::dmat4x2(0),
|
||||
glm::dmat4x2(
|
||||
@@ -532,7 +620,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x2Property, glm::dmat4x2, glm::dmat4x2(0)
|
||||
0.01, 0.01, 0.01, 0.01
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x2),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat4x2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat4x2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dmat4x2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dmat4x2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x3Property, glm::dmat4x3, glm::dmat4x3(0),
|
||||
glm::dmat4x3(
|
||||
@@ -569,7 +660,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x3Property, glm::dmat4x3, glm::dmat4x3(0)
|
||||
0.01, 0.01, 0.01, 0.01
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x3),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat4x3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat4x3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dmat4x3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dmat4x3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DMat4Property, glm::dmat4x4, glm::dmat4x4(0),
|
||||
glm::dmat4x4(
|
||||
@@ -615,7 +709,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DMat4Property, glm::dmat4x4, glm::dmat4x4(0),
|
||||
0.01, 0.01, 0.01, 0.01
|
||||
),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x4),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat4x4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dmat4x4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dmat4x4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dmat4x4),
|
||||
LUA_TTABLE);
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
@@ -85,14 +85,13 @@ boost::any Property::get() const {
|
||||
return boost::any();
|
||||
}
|
||||
|
||||
bool Property::getLua(lua_State* state) const {
|
||||
return true;
|
||||
bool Property::getLuaValue(lua_State* state) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Property::set(boost::any value) {
|
||||
}
|
||||
void Property::set(boost::any value) {}
|
||||
|
||||
bool Property::setLua(lua_State* state) {
|
||||
bool Property::setLuaValue(lua_State* state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,6 +103,14 @@ int Property::typeLua() const {
|
||||
return LUA_TNIL;
|
||||
}
|
||||
|
||||
bool Property::getStringValue(std::string& value) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Property::setStringValue(std::string value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Property::guiName() const {
|
||||
std::string result;
|
||||
_metaData.getValue(_metaDataKeyGuiName, result);
|
||||
|
||||
@@ -27,27 +27,44 @@
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
|
||||
using std::numeric_limits;
|
||||
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \
|
||||
[](lua_State* state, bool& success) -> TYPE { \
|
||||
success = (lua_isnumber(state, -1) == 1); \
|
||||
if (success) \
|
||||
return static_cast<TYPE>(lua_tonumber(state, -1)); \
|
||||
else \
|
||||
return DEFAULT_VALUE; \
|
||||
#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \
|
||||
[](lua_State* state, bool& success) -> TYPE { \
|
||||
success = (lua_isnumber(state, -1) == 1); \
|
||||
if (success) \
|
||||
return static_cast<TYPE>(lua_tonumber(state, -1)); \
|
||||
else \
|
||||
return DEFAULT_VALUE; \
|
||||
}
|
||||
|
||||
#define DEFAULT_TO_LUA_LAMBDA(TYPE) \
|
||||
[](lua_State* state, TYPE value) -> bool { \
|
||||
lua_pushnumber(state, static_cast<lua_Number>(value)); \
|
||||
return true; \
|
||||
#define DEFAULT_TO_LUA_LAMBDA(TYPE) \
|
||||
[](lua_State* state, TYPE value) -> bool { \
|
||||
lua_pushnumber(state, static_cast<lua_Number>(value)); \
|
||||
return true; \
|
||||
}
|
||||
|
||||
#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \
|
||||
[](std::string value, bool& success) -> TYPE { \
|
||||
std::stringstream s(value); \
|
||||
TYPE v; \
|
||||
s >> v; \
|
||||
success = !s.fail(); \
|
||||
if (success) \
|
||||
return v; \
|
||||
}
|
||||
|
||||
#define DEFAULT_TO_STRING_LAMBDA(TYPE) \
|
||||
[](std::string& outValue, TYPE inValue) -> bool { \
|
||||
outValue = std::to_string(inValue); \
|
||||
return true; \
|
||||
}
|
||||
|
||||
// char16_t and char32_t are not supported on Visual Studio 2013 and are defined to
|
||||
// be equal to unsigned short and unsigned int which causes a compile error
|
||||
|
||||
@@ -63,6 +80,8 @@ REGISTER_TEMPLATEPROPERTY_SOURCE(BoolProperty, bool, false,
|
||||
lua_pushboolean(state, value);
|
||||
return true;
|
||||
},
|
||||
DEFAULT_FROM_STRING_LAMBDA(bool, false),
|
||||
DEFAULT_TO_STRING_LAMBDA(bool),
|
||||
LUA_TBOOLEAN
|
||||
);
|
||||
|
||||
@@ -70,7 +89,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(CharProperty, char, char(0),
|
||||
numeric_limits<char>::lowest(),
|
||||
numeric_limits<char>::max(), char(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(char, char(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(char), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(char),
|
||||
DEFAULT_FROM_STRING_LAMBDA(char, char(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(char),
|
||||
LUA_TNUMBER);
|
||||
|
||||
// REGISTER_NUMERICALPROPERTY_SOURCE(Char16Property, char16_t, char16_t(0),
|
||||
// numeric_limits<char16_t>::lowest(), numeric_limits<char16_t>::max(), char16_t(1));
|
||||
@@ -78,92 +100,145 @@ REGISTER_NUMERICALPROPERTY_SOURCE(CharProperty, char, char(0),
|
||||
// REGISTER_NUMERICALPROPERTY_SOURCE(Char32Property, char32_t, char32_t(0),
|
||||
// numeric_limits<char32_t>::lowest(), numeric_limits<char32_t>::max(), char32_t(1));
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(WCharProperty, wchar_t, wchar_t(0),
|
||||
numeric_limits<wchar_t>::lowest(),
|
||||
numeric_limits<wchar_t>::max(), wchar_t(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(wchar_t, wchar_t(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(wchar_t), LUA_TNUMBER);
|
||||
//REGISTER_NUMERICALPROPERTY_SOURCE(WCharProperty, wchar_t, wchar_t(0),
|
||||
// numeric_limits<wchar_t>::lowest(),
|
||||
// numeric_limits<wchar_t>::max(), wchar_t(1),
|
||||
// DEFAULT_FROM_LUA_LAMBDA(wchar_t, wchar_t(0)),
|
||||
// DEFAULT_TO_LUA_LAMBDA(wchar_t),
|
||||
// DEFAULT_FROM_STRING_LAMBDA(wchar_t, wchar_t(0)),
|
||||
// DEFAULT_TO_STRING_LAMBDA(wchar_t),
|
||||
// LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(SignedCharProperty, signed char, (signed char)(0),
|
||||
numeric_limits<signed char>::lowest(),
|
||||
numeric_limits<signed char>::max(), (signed char)0,
|
||||
DEFAULT_FROM_LUA_LAMBDA(signed char, (signed char)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(signed char), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(signed char),
|
||||
DEFAULT_FROM_STRING_LAMBDA(signed char, (signed char)(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(signed char),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(UCharProperty, unsigned char, (unsigned char)0,
|
||||
numeric_limits<unsigned char>::lowest(),
|
||||
numeric_limits<unsigned char>::max(), (unsigned char)1,
|
||||
DEFAULT_FROM_LUA_LAMBDA(unsigned char,
|
||||
(unsigned char)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned char), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned char),
|
||||
DEFAULT_FROM_STRING_LAMBDA(unsigned char,
|
||||
(unsigned char)(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(unsigned char),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(ShortProperty, short, short(0),
|
||||
numeric_limits<short>::lowest(),
|
||||
numeric_limits<short>::max(), short(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(short, short(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(short), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(short),
|
||||
DEFAULT_FROM_STRING_LAMBDA(short, short(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(short),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(
|
||||
UShortProperty, unsigned short, (unsigned short)(0),
|
||||
numeric_limits<unsigned short>::lowest(), numeric_limits<unsigned short>::max(),
|
||||
(unsigned short)1, DEFAULT_FROM_LUA_LAMBDA(unsigned short, (unsigned short)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned short), LUA_TNUMBER);
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(UShortProperty, unsigned short, (unsigned short)(0),
|
||||
numeric_limits<unsigned short>::lowest(),
|
||||
numeric_limits<unsigned short>::max(),
|
||||
(unsigned short)1,
|
||||
DEFAULT_FROM_LUA_LAMBDA(unsigned short,
|
||||
(unsigned short)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned short),
|
||||
DEFAULT_FROM_STRING_LAMBDA(unsigned short,
|
||||
(unsigned short)(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(unsigned short),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(IntProperty, int, int(0), numeric_limits<int>::lowest(),
|
||||
numeric_limits<int>::max(), int(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(int, int(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(int), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(int),
|
||||
DEFAULT_FROM_STRING_LAMBDA(int, int(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(int),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(UIntProperty, unsigned int, (unsigned int)0,
|
||||
numeric_limits<unsigned int>::lowest(),
|
||||
numeric_limits<unsigned int>::max(), (unsigned int)1,
|
||||
DEFAULT_FROM_LUA_LAMBDA(unsigned int,
|
||||
(unsigned int)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned int), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned int),
|
||||
DEFAULT_FROM_STRING_LAMBDA(unsigned int,
|
||||
(unsigned int)(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(unsigned int),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(LongProperty, long, long(0),
|
||||
numeric_limits<long>::lowest(),
|
||||
numeric_limits<long>::max(), long(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(long, long(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(long), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(long),
|
||||
DEFAULT_FROM_STRING_LAMBDA(long, long(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(long),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(ULongProperty, unsigned long, (unsigned long)0,
|
||||
numeric_limits<unsigned long>::lowest(),
|
||||
numeric_limits<unsigned long>::max(), (unsigned long)1,
|
||||
DEFAULT_FROM_LUA_LAMBDA(unsigned long,
|
||||
(unsigned long)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned long), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned long),
|
||||
DEFAULT_FROM_STRING_LAMBDA(unsigned long,
|
||||
(unsigned long)(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(unsigned long),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(LongLongProperty, long long, (long long)0,
|
||||
numeric_limits<long long>::lowest(),
|
||||
numeric_limits<long long>::max(), (long long)1,
|
||||
DEFAULT_FROM_LUA_LAMBDA(long long, (long long)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(long long), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(long long),
|
||||
DEFAULT_FROM_STRING_LAMBDA(long long,
|
||||
(long long)(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(long long),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(
|
||||
ULongLongProperty, unsigned long long, (unsigned long long)1,
|
||||
numeric_limits<unsigned long long>::lowest(),
|
||||
numeric_limits<unsigned long long>::max(), (unsigned long long)1,
|
||||
DEFAULT_FROM_LUA_LAMBDA(unsigned long long, (unsigned long long)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned long long), LUA_TNUMBER);
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(ULongLongProperty, unsigned long long,
|
||||
(unsigned long long)1,
|
||||
numeric_limits<unsigned long long>::lowest(),
|
||||
numeric_limits<unsigned long long>::max(),
|
||||
(unsigned long long)1,
|
||||
DEFAULT_FROM_LUA_LAMBDA(unsigned long long,
|
||||
(unsigned long long)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(unsigned long long),
|
||||
DEFAULT_FROM_STRING_LAMBDA(unsigned long long,
|
||||
(unsigned long long)(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(unsigned long long),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(FloatProperty, float, 0.f,
|
||||
numeric_limits<float>::lowest(),
|
||||
numeric_limits<float>::max(), 0.01f,
|
||||
DEFAULT_FROM_LUA_LAMBDA(float, float(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(float), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(float),
|
||||
DEFAULT_FROM_STRING_LAMBDA(float, float(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(float),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DoubleProperty, double, 0.0,
|
||||
numeric_limits<double>::lowest(),
|
||||
numeric_limits<double>::max(), 0.01,
|
||||
DEFAULT_FROM_LUA_LAMBDA(double, double(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(double), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(double),
|
||||
DEFAULT_FROM_STRING_LAMBDA(double, double(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(double),
|
||||
LUA_TNUMBER);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(LongDoubleProperty, long double, (long double)0,
|
||||
numeric_limits<long double>::lowest(),
|
||||
numeric_limits<long double>::max(), (long double)0.01f,
|
||||
DEFAULT_FROM_LUA_LAMBDA(long double, (long double)(0)),
|
||||
DEFAULT_TO_LUA_LAMBDA(long double), LUA_TNUMBER);
|
||||
DEFAULT_TO_LUA_LAMBDA(long double),
|
||||
DEFAULT_FROM_STRING_LAMBDA(long double,
|
||||
(long double)(0)),
|
||||
DEFAULT_TO_STRING_LAMBDA(long double),
|
||||
LUA_TNUMBER);
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SelectionProperty";
|
||||
|
||||
const std::string Delimiter = ",";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -109,6 +111,29 @@ int PropertyDelegate<TemplateProperty<std::vector<int>>>::typeLua() {
|
||||
return LUA_TTABLE;
|
||||
}
|
||||
|
||||
template <>
|
||||
template <>
|
||||
std::vector<int> PropertyDelegate<TemplateProperty<std::vector<int>>>::fromString(std::string value, bool& success) {
|
||||
std::vector<int> result;
|
||||
size_t pos = 0;
|
||||
while ((pos = value.find(Delimiter)) != std::string::npos) {
|
||||
std::string token = value.substr(0, pos);
|
||||
result.push_back(std::stoi(token));
|
||||
value.erase(0, pos + Delimiter.length());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <>
|
||||
template <>
|
||||
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toString(std::string& outValue, std::vector<int> inValue) {
|
||||
outValue = "[";
|
||||
for (int i : inValue)
|
||||
outValue += std::to_string(i) + Delimiter;
|
||||
outValue += "]";
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string SelectionProperty::generateAdditionalDescription() const {
|
||||
std::string result;
|
||||
result += OptionsKey + " = {";
|
||||
|
||||
@@ -41,6 +41,14 @@ REGISTER_TEMPLATEPROPERTY_SOURCE(StringProperty, std::string, "",
|
||||
lua_pushstring(state, value.c_str());
|
||||
return true;
|
||||
},
|
||||
[](std::string value, bool& success) -> std::string {
|
||||
success = true;
|
||||
return value;
|
||||
},
|
||||
[](std::string& outValue, std::string inValue) -> bool {
|
||||
outValue = inValue;
|
||||
return true;
|
||||
},
|
||||
LUA_TSTRING
|
||||
);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ std::string TriggerProperty::className() const {
|
||||
return "TriggerProperty";
|
||||
}
|
||||
|
||||
bool TriggerProperty::setLua(lua_State* state) {
|
||||
bool TriggerProperty::setLuaValue(lua_State* state) {
|
||||
notifyListener();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/misc/misc.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
@@ -68,6 +69,37 @@ namespace properties {
|
||||
return true; \
|
||||
}
|
||||
|
||||
#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \
|
||||
[](std::string value, bool& success) -> __TYPE__ { \
|
||||
__TYPE__ result; \
|
||||
std::vector<std::string> tokens = ghoul::tokenizeString(value, ','); \
|
||||
if (tokens.size() != result.length()) { \
|
||||
success = false; \
|
||||
return result; \
|
||||
} \
|
||||
for (__TYPE__::size_type i = 0; i < result.length(); ++i) { \
|
||||
std::stringstream s(tokens[i]); \
|
||||
__TYPE__::value_type v; \
|
||||
s >> v; \
|
||||
if (s.fail()) { \
|
||||
success = false; \
|
||||
return result; \
|
||||
} \
|
||||
else \
|
||||
result[i] = v; \
|
||||
} \
|
||||
success = true; \
|
||||
return result; \
|
||||
}
|
||||
|
||||
#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \
|
||||
[](std::string& outValue, __TYPE__ inValue) -> bool { \
|
||||
outValue = ""; \
|
||||
for (__TYPE__::size_type i = 0; i < inValue.length(); ++i) \
|
||||
outValue += std::to_string(inValue[i]) + ","; \
|
||||
return true; \
|
||||
}
|
||||
|
||||
|
||||
// Forcing value from int to bool is acceptable here (line 48)
|
||||
#ifdef WIN32
|
||||
@@ -78,40 +110,64 @@ namespace properties {
|
||||
REGISTER_TEMPLATEPROPERTY_SOURCE(BVec2Property, glm::bvec2, glm::bvec2(false),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::bvec2, lua_toboolean,
|
||||
lua_isboolean),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::bvec2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::bvec2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::bvec2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::bvec2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_TEMPLATEPROPERTY_SOURCE(BVec3Property, glm::bvec3, glm::bvec3(false),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::bvec3, lua_toboolean,
|
||||
lua_isboolean),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::bvec3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::bvec3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::bvec3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::bvec3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_TEMPLATEPROPERTY_SOURCE(BVec4Property, glm::bvec4, glm::bvec4(false),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::bvec4, lua_toboolean,
|
||||
lua_isboolean),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::bvec4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::bvec4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::bvec4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::bvec4),
|
||||
LUA_TTABLE);
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(default : 4800)
|
||||
#endif
|
||||
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(
|
||||
Vec2Property, glm::vec2, glm::vec2(0), glm::vec2(numeric_limits<float>::lowest()),
|
||||
glm::vec2(numeric_limits<float>::max()), glm::vec2(0.01f),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::vec2, lua_tonumber, lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::vec2), LUA_TTABLE);
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Vec2Property, glm::vec2, glm::vec2(0),
|
||||
glm::vec2(numeric_limits<float>::lowest()),
|
||||
glm::vec2(numeric_limits<float>::max()),
|
||||
glm::vec2(0.01f),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::vec2, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::vec2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::vec2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::vec2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(
|
||||
Vec3Property, glm::vec3, glm::vec3(0), glm::vec3(numeric_limits<float>::lowest()),
|
||||
glm::vec3(numeric_limits<float>::max()), glm::vec3(0.01f),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::vec3, lua_tonumber, lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::vec3), LUA_TTABLE);
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Vec3Property, glm::vec3, glm::vec3(0),
|
||||
glm::vec3(numeric_limits<float>::lowest()),
|
||||
glm::vec3(numeric_limits<float>::max()),
|
||||
glm::vec3(0.01f),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::vec3, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::vec3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::vec3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::vec3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(
|
||||
Vec4Property, glm::vec4, glm::vec4(0), glm::vec4(numeric_limits<float>::lowest()),
|
||||
glm::vec4(numeric_limits<float>::max()), glm::vec4(0.01f),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::vec4, lua_tonumber, lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::vec4), LUA_TTABLE);
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(Vec4Property, glm::vec4, glm::vec4(0),
|
||||
glm::vec4(numeric_limits<float>::lowest()),
|
||||
glm::vec4(numeric_limits<float>::max()),
|
||||
glm::vec4(0.01f),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::vec4, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::vec4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::vec4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::vec4),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DVec2Property, glm::dvec2, glm::dvec2(0),
|
||||
glm::dvec2(numeric_limits<double>::lowest()),
|
||||
@@ -119,7 +175,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DVec2Property, glm::dvec2, glm::dvec2(0),
|
||||
glm::dvec2(0.01),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dvec2, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dvec2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dvec2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dvec2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dvec2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DVec3Property, glm::dvec3, glm::dvec3(0),
|
||||
glm::dvec3(numeric_limits<double>::lowest()),
|
||||
@@ -127,7 +186,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DVec3Property, glm::dvec3, glm::dvec3(0),
|
||||
glm::dvec3(0.01),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dvec3, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dvec3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dvec3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dvec3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dvec3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(DVec4Property, glm::dvec4, glm::dvec4(0),
|
||||
glm::dvec4(numeric_limits<double>::lowest()),
|
||||
@@ -135,28 +197,40 @@ REGISTER_NUMERICALPROPERTY_SOURCE(DVec4Property, glm::dvec4, glm::dvec4(0),
|
||||
glm::dvec4(0.01),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::dvec4, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dvec4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::dvec4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::dvec4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::dvec4),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(IVec2Property, glm::ivec2, glm::ivec2(0),
|
||||
glm::ivec2(numeric_limits<int>::lowest()),
|
||||
glm::ivec2(numeric_limits<int>::max()), glm::ivec2(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::ivec2, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::ivec2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::ivec2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::ivec2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::ivec2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(IVec3Property, glm::ivec3, glm::ivec3(0),
|
||||
glm::ivec3(numeric_limits<int>::lowest()),
|
||||
glm::ivec3(numeric_limits<int>::max()), glm::ivec3(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::ivec3, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::ivec3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::ivec3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::ivec3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::ivec3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(IVec4Property, glm::ivec4, glm::ivec4(0),
|
||||
glm::ivec4(numeric_limits<int>::lowest()),
|
||||
glm::ivec4(numeric_limits<int>::max()), glm::ivec4(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::ivec4, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::ivec4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::ivec4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::ivec4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::ivec4),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(UVec2Property, glm::uvec2, glm::uvec2(0),
|
||||
glm::uvec2(numeric_limits<unsigned int>::lowest()),
|
||||
@@ -164,7 +238,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(UVec2Property, glm::uvec2, glm::uvec2(0),
|
||||
glm::uvec2(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::uvec2, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::uvec2), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::uvec2),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::uvec2),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::uvec2),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(UVec3Property, glm::uvec3, glm::uvec3(0),
|
||||
glm::uvec3(numeric_limits<unsigned int>::lowest()),
|
||||
@@ -172,7 +249,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(UVec3Property, glm::uvec3, glm::uvec3(0),
|
||||
glm::uvec3(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::uvec3, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::uvec3), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::uvec3),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::uvec3),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::uvec3),
|
||||
LUA_TTABLE);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_SOURCE(UVec4Property, glm::uvec4, glm::uvec4(0),
|
||||
glm::uvec4(numeric_limits<unsigned int>::lowest()),
|
||||
@@ -180,7 +260,10 @@ REGISTER_NUMERICALPROPERTY_SOURCE(UVec4Property, glm::uvec4, glm::uvec4(0),
|
||||
glm::uvec4(1),
|
||||
DEFAULT_FROM_LUA_LAMBDA(glm::uvec4, lua_tonumber,
|
||||
lua_isnumber),
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::uvec4), LUA_TTABLE);
|
||||
DEFAULT_TO_LUA_LAMBDA(glm::uvec4),
|
||||
DEFAULT_FROM_STRING_LAMBDA(glm::uvec4),
|
||||
DEFAULT_TO_STRING_LAMBDA(glm::uvec4),
|
||||
LUA_TTABLE);
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
@@ -58,7 +58,7 @@ int property_setValue(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
prop->setLua(L);
|
||||
prop->setLuaValue(L);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ int property_getValue(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
prop->getLua(L);
|
||||
prop->getLuaValue(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,15 @@ function (include_external_library target_name library_name path)
|
||||
target_link_libraries(${target_name} ${library_name})
|
||||
target_include_directories(${target_name} PUBLIC SYSTEM ${INCLUDE_DIR})
|
||||
set_property(TARGET ${library_name} PROPERTY FOLDER "External")
|
||||
if (MSVC)
|
||||
target_compile_options(${library_name} PUBLIC "/MP")
|
||||
endif ()
|
||||
if (OPENSPACE_DISABLE_EXTERNAL_WARNINGS)
|
||||
if (MSVC)
|
||||
target_compile_options(${library_name} PUBLIC "/W0" "/MP")
|
||||
target_compile_options(${library_name} PUBLIC "/W0")
|
||||
else ()
|
||||
target_compile_options(${library_name} PUBLIC "-w")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endfunction ()
|
||||
endfunction ()
|
||||
|
||||
@@ -178,6 +178,13 @@ function (add_external_dependencies)
|
||||
target_compile_definitions(libOpenSpace PUBLIC "OPENSPACE_CURL_ENABLED")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# Qt
|
||||
# Unfortunately, we have to set this value manually; sigh
|
||||
# In the future, if the Qt version is updated, just add to this variable ---abock
|
||||
if (APPLE)
|
||||
set(CMAKE_PREFIX_PATH "~/Qt/5.5/clang_64/lib/cmake" PARENT_SCOPE)
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user