mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 14:29:42 -05:00
Passing around Profile as a reference instead of a pointer
This commit is contained in:
@@ -98,7 +98,7 @@ private:
|
||||
void populateProfilesList(QString preset);
|
||||
void populateWindowConfigsList(QString preset);
|
||||
bool loadProfileFromFile(openspace::Profile*& p, std::string filename);
|
||||
void saveProfileToFile(const std::string& path, openspace::Profile* p);
|
||||
void saveProfileToFile(const std::string& path, const openspace::Profile& p);
|
||||
|
||||
ProfileEdit* myEditorWindow;
|
||||
FileSystemAccess _fileAccessProfiles;
|
||||
|
||||
@@ -41,13 +41,13 @@ public:
|
||||
* new or imported profile.
|
||||
* \param parent Pointer to parent Qt widget
|
||||
*/
|
||||
AdditionalScriptsDialog(openspace::Profile* profile, QWidget* parent);
|
||||
AdditionalScriptsDialog(openspace::Profile& profile, QWidget* parent);
|
||||
|
||||
private slots:
|
||||
void parseScript();
|
||||
|
||||
private:
|
||||
openspace::Profile* _profile = nullptr;
|
||||
openspace::Profile& _profile;
|
||||
QTextEdit* _textScripts = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
* in class #assetTreeModel)
|
||||
* \param parent Pointer to parent Qt widget
|
||||
*/
|
||||
AssetsDialog(openspace::Profile* profile, const std::string reportAssets,
|
||||
AssetsDialog(openspace::Profile& profile, const std::string reportAssets,
|
||||
QWidget* parent);
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ private slots:
|
||||
void selected(const QModelIndex&);
|
||||
|
||||
private:
|
||||
openspace::Profile* _profile = nullptr;
|
||||
openspace::Profile& _profile;
|
||||
AssetTreeModel _assetTreeModel;
|
||||
QTreeView* _assetTree = nullptr;
|
||||
QTextEdit* _summary = nullptr;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
* new or imported profile.
|
||||
* \param parent Pointer to parent Qt widget (optional)
|
||||
*/
|
||||
CameraDialog(openspace::Profile* profile, QWidget* parent);
|
||||
CameraDialog(openspace::Profile& profile, QWidget* parent);
|
||||
|
||||
private slots:
|
||||
void approved();
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
void addErrorMsg(QString errorDescription);
|
||||
bool areRequiredFormsFilledAndValid();
|
||||
|
||||
openspace::Profile* _profile = nullptr;
|
||||
openspace::Profile& _profile;
|
||||
QTabWidget* _tabWidget = nullptr;
|
||||
struct {
|
||||
QLineEdit* anchor = nullptr;
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
* new or imported profile.
|
||||
* \param parent Pointer to parent Qt widget (optional)
|
||||
*/
|
||||
DeltaTimesDialog(openspace::Profile* profile, QWidget* parent);
|
||||
DeltaTimesDialog(openspace::Profile& profile, QWidget* parent);
|
||||
|
||||
/**
|
||||
* Returns a text summary of the delta time list for display purposes
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
QString checkForTimeDescription(int intervalIndex, int value);
|
||||
bool isLineEmpty(int index);
|
||||
|
||||
openspace::Profile* _profile;
|
||||
openspace::Profile& _profile;
|
||||
std::vector<double> _data;
|
||||
bool _editModeNewItem = false;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
* new or imported profile.
|
||||
* \param parent Pointer to parent Qt widget (optional)
|
||||
*/
|
||||
KeybindingsDialog(openspace::Profile* profile, QWidget* parent);
|
||||
KeybindingsDialog(openspace::Profile& profile, QWidget* parent);
|
||||
|
||||
/**
|
||||
* Handles keypress while the Qt dialog window is open
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
const std::string& to);
|
||||
bool isLineEmpty(int index);
|
||||
|
||||
openspace::Profile* _profile;
|
||||
openspace::Profile& _profile;
|
||||
std::vector<openspace::Profile::Keybinding> _data;
|
||||
std::vector<int> _mapModKeyComboBoxIndexToKeyValue;
|
||||
std::vector<int> _mapKeyComboBoxIndexToKeyValue;
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
* new or imported profile.
|
||||
* \param parent Pointer to parent Qt widget
|
||||
*/
|
||||
MarkNodesDialog(openspace::Profile* profile, QWidget* parent);
|
||||
MarkNodesDialog(openspace::Profile& profile, QWidget* parent);
|
||||
|
||||
/**
|
||||
* Handles keypress while the Qt dialog window is open
|
||||
@@ -61,7 +61,7 @@ public slots:
|
||||
|
||||
private:
|
||||
std::vector<QListWidgetItem*> _markedNodesListItems;
|
||||
openspace::Profile* _profile;
|
||||
openspace::Profile& _profile;
|
||||
std::vector<std::string> _data;
|
||||
|
||||
QListWidget* _list = nullptr;
|
||||
|
||||
@@ -43,13 +43,13 @@ public:
|
||||
* new or imported profile.
|
||||
* \param parent Pointer to parent Qt widget
|
||||
*/
|
||||
MetaDialog(openspace::Profile* profile, QWidget* parent);
|
||||
MetaDialog(openspace::Profile& profile, QWidget* parent);
|
||||
|
||||
public slots:
|
||||
void save();
|
||||
|
||||
private:
|
||||
openspace::Profile* _profile;
|
||||
openspace::Profile& _profile;
|
||||
|
||||
QLineEdit* _nameEdit = nullptr;
|
||||
QLineEdit* _versionEdit = nullptr;
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
* new or imported profile.
|
||||
* \param parent Pointer to parent Qt widget
|
||||
*/
|
||||
ModulesDialog(openspace::Profile* profiles, QWidget* parent);
|
||||
ModulesDialog(openspace::Profile& profiles, QWidget* parent);
|
||||
|
||||
/**
|
||||
* Handles keypress while the Qt dialog window is open
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
void editBoxDisabled(bool disabled);
|
||||
bool isLineEmpty(int index);
|
||||
|
||||
openspace::Profile* _profile;
|
||||
openspace::Profile& _profile;
|
||||
std::vector<openspace::Profile::Module> _data;
|
||||
bool _editModeNewItem = false;
|
||||
const openspace::Profile::Module kBlank = {"", "", ""};
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
* not be overwritten
|
||||
* \param parent Pointer to parent Qt widget (optional)
|
||||
*/
|
||||
ProfileEdit(openspace::Profile* profile, const std::string reportedAssets,
|
||||
ProfileEdit(openspace::Profile& profile, const std::string reportedAssets,
|
||||
std::vector<std::string>& profilesReadOnly, QWidget* parent);
|
||||
|
||||
/**
|
||||
@@ -106,21 +106,11 @@ private:
|
||||
std::string summarizeAssets();
|
||||
std::string summarizeProperties();
|
||||
std::string summarizeKeybindings();
|
||||
void labelText(openspace::Profile* pData, int size, QString title, QLabel* pLabel);
|
||||
void labelText(const openspace::Profile& pData, int size, QString title,
|
||||
QLabel* pLabel);
|
||||
bool isReadOnly(std::string profileToSave);
|
||||
|
||||
QWidget* _parent;
|
||||
MetaDialog* _meta;
|
||||
PropertiesDialog* _properties;
|
||||
ModulesDialog* _modules;
|
||||
KeybindingsDialog* _keybindings;
|
||||
AssetsDialog* _assets;
|
||||
TimeDialog* _time;
|
||||
AdditionalScriptsDialog* _addedScripts;
|
||||
DeltaTimesDialog* _deltaTimes;
|
||||
CameraDialog* _camera;
|
||||
MarkNodesDialog* _markNodes;
|
||||
openspace::Profile* _pData;
|
||||
openspace::Profile& _profile;
|
||||
const std::string _reportedAssets;
|
||||
bool _saveSelected = false;
|
||||
std::vector<std::string> _profilesReadOnly;
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
* new or imported profile.
|
||||
* \param parent Pointer to parent Qt widget (optional)
|
||||
*/
|
||||
PropertiesDialog(openspace::Profile* profile, QWidget* parent);
|
||||
PropertiesDialog(openspace::Profile& profile, QWidget* parent);
|
||||
|
||||
/**
|
||||
* Handles keypress while the Qt dialog window is open
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
bool areRequiredFormsFilled();
|
||||
bool isLineEmpty(int index);
|
||||
|
||||
openspace::Profile* _profile;
|
||||
openspace::Profile& _profile;
|
||||
std::vector<openspace::Profile::Property> _data;
|
||||
bool _editModeNewItem = false;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
* new or imported profile.
|
||||
* \param parent Pointer to parent Qt widget (optional)
|
||||
*/
|
||||
TimeDialog(openspace::Profile* profile, QWidget* parent);
|
||||
TimeDialog(openspace::Profile& profile, QWidget* parent);
|
||||
|
||||
public slots:
|
||||
void enableAccordingToType(int);
|
||||
@@ -52,7 +52,7 @@ public slots:
|
||||
|
||||
private:
|
||||
void enableFormatForAbsolute(bool enableAbs);
|
||||
openspace::Profile* _profile;
|
||||
openspace::Profile& _profile;
|
||||
openspace::Profile::Time _data;
|
||||
bool _initializedAsAbsolute = true;
|
||||
|
||||
|
||||
@@ -46,8 +46,10 @@ namespace {
|
||||
constexpr const int SmallItemWidth = 100;
|
||||
} // namespace
|
||||
|
||||
using namespace openspace;
|
||||
|
||||
LauncherWindow::LauncherWindow(std::string basePath, bool profileEnabled,
|
||||
openspace::configuration::Configuration& globalConfig,
|
||||
configuration::Configuration& globalConfig,
|
||||
bool sgctConfigEnabled, std::string sgctConfigName,
|
||||
QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
@@ -56,7 +58,7 @@ LauncherWindow::LauncherWindow(std::string basePath, bool profileEnabled,
|
||||
, _filesystemAccess(".asset",
|
||||
{"scene", "global", "customization", "examples", "util"},
|
||||
true, true)
|
||||
, _basePath(QString::fromUtf8(basePath.c_str()))
|
||||
, _basePath(QString::fromStdString(basePath))
|
||||
, _profileChangeAllowed(profileEnabled)
|
||||
, _sgctConfigChangeAllowed(sgctConfigEnabled)
|
||||
, _globalConfig(globalConfig)
|
||||
@@ -124,8 +126,8 @@ LauncherWindow::LauncherWindow(std::string basePath, bool profileEnabled,
|
||||
|
||||
|
||||
_reportAssetsInFilesystem = _filesystemAccess.useQtFileSystemModelToTraverseDir(
|
||||
QString(basePath.c_str()) + "/data/assets");
|
||||
populateProfilesList(QString(globalConfig.profile.c_str()));
|
||||
QString::fromStdString(basePath) + "/data/assets");
|
||||
populateProfilesList(QString::fromStdString(globalConfig.profile));
|
||||
|
||||
_profileBox->setDisabled(!_profileChangeAllowed);
|
||||
|
||||
@@ -141,7 +143,6 @@ LauncherWindow::LauncherWindow(std::string basePath, bool profileEnabled,
|
||||
hasSyncFiles = true;
|
||||
}
|
||||
|
||||
|
||||
QString filename;
|
||||
QString bgpath;
|
||||
if (hasSyncFiles) {
|
||||
@@ -150,7 +151,7 @@ LauncherWindow::LauncherWindow(std::string basePath, bool profileEnabled,
|
||||
std::uniform_int_distribution<int> uni(0, 4);
|
||||
auto random_integer = uni(rng);
|
||||
filename = QString::fromStdString("/http/launcher_images/1/profile" + std::to_string(random_integer) + ".png");
|
||||
bgpath = QString(globalConfig.pathTokens["SYNC"].c_str()) + filename;
|
||||
bgpath = QString::fromStdString(globalConfig.pathTokens["SYNC"]) + filename;
|
||||
}
|
||||
else {
|
||||
bgpath = QString::fromStdString(":/images/launcher-background.png");
|
||||
@@ -164,7 +165,8 @@ void LauncherWindow::populateProfilesList(QString preset) {
|
||||
_profileBox->removeItem(i);
|
||||
}
|
||||
std::string reportProfiles = _fileAccessProfiles.useQtFileSystemModelToTraverseDir(
|
||||
_basePath + "/data/profiles");
|
||||
_basePath + "/data/profiles"
|
||||
);
|
||||
std::stringstream instream(reportProfiles);
|
||||
std::string iline;
|
||||
QStringList profilesListLine;
|
||||
@@ -183,12 +185,13 @@ void LauncherWindow::populateProfilesList(QString preset) {
|
||||
|
||||
void LauncherWindow::populateWindowConfigsList(QString preset) {
|
||||
std::string reportConfigs = _fileAccessWinConfigs.useQtFileSystemModelToTraverseDir(
|
||||
_basePath + "/config");
|
||||
_basePath + "/config"
|
||||
);
|
||||
std::stringstream instream(reportConfigs);
|
||||
std::string iline;
|
||||
QStringList windowConfigsListLine;
|
||||
while (std::getline(instream, iline)) {
|
||||
windowConfigsListLine << iline.c_str();
|
||||
windowConfigsListLine << QString::fromStdString(iline);
|
||||
}
|
||||
_windowConfigBox->addItems(windowConfigsListLine);
|
||||
if (preset.length() > 0) {
|
||||
@@ -205,55 +208,52 @@ void LauncherWindow::populateWindowConfigsList(QString preset) {
|
||||
|
||||
void LauncherWindow::openWindow_new() {
|
||||
QString initialProfileSelection = _profileBox->currentText();
|
||||
openspace::Profile* pData = new openspace::Profile();
|
||||
if (pData != nullptr) {
|
||||
myEditorWindow = new ProfileEdit(pData, _reportAssetsInFilesystem,
|
||||
_globalConfig.profilesReadOnly, this);
|
||||
myEditorWindow->exec();
|
||||
if (myEditorWindow->wasSaved()) {
|
||||
std::string saveProfilePath = _basePath.toUtf8().constData();
|
||||
saveProfilePath += "/data/profiles/";
|
||||
saveProfilePath += myEditorWindow->specifiedFilename() + ".profile";
|
||||
saveProfileToFile(saveProfilePath, pData);
|
||||
populateProfilesList(QString(myEditorWindow->specifiedFilename().c_str()));
|
||||
}
|
||||
else {
|
||||
populateProfilesList(initialProfileSelection);
|
||||
}
|
||||
delete myEditorWindow;
|
||||
delete pData;
|
||||
Profile profile;
|
||||
myEditorWindow = new ProfileEdit(profile, _reportAssetsInFilesystem,
|
||||
_globalConfig.profilesReadOnly, this);
|
||||
myEditorWindow->exec();
|
||||
if (myEditorWindow->wasSaved()) {
|
||||
std::string saveProfilePath = _basePath.toUtf8().constData();
|
||||
saveProfilePath += "/data/profiles/";
|
||||
saveProfilePath += myEditorWindow->specifiedFilename() + ".profile";
|
||||
saveProfileToFile(saveProfilePath, profile);
|
||||
populateProfilesList(QString(myEditorWindow->specifiedFilename().c_str()));
|
||||
}
|
||||
else {
|
||||
populateProfilesList(initialProfileSelection);
|
||||
}
|
||||
delete myEditorWindow;
|
||||
}
|
||||
|
||||
void LauncherWindow::openWindow_edit() {
|
||||
QString initialProfileSelection = _profileBox->currentText();
|
||||
std::string profilePath = _basePath.toUtf8().constData();
|
||||
std::string profilePath = _basePath.toStdString();
|
||||
profilePath += "/data/profiles/";
|
||||
int selectedProfileIdx = _profileBox->currentIndex();
|
||||
QString profileToSet = _profileBox->itemText(selectedProfileIdx);
|
||||
std::string editProfilePath = profilePath + profileToSet.toUtf8().constData();
|
||||
std::string editProfilePath = profilePath + profileToSet.toStdString();
|
||||
editProfilePath += ".profile";
|
||||
openspace::Profile* pData;
|
||||
bool validFile = loadProfileFromFile(pData, editProfilePath);
|
||||
if (pData != nullptr && validFile) {
|
||||
myEditorWindow = new ProfileEdit(pData, _reportAssetsInFilesystem,
|
||||
Profile* profile;
|
||||
bool validFile = loadProfileFromFile(profile, editProfilePath);
|
||||
if (profile != nullptr && validFile) {
|
||||
myEditorWindow = new ProfileEdit(*profile, _reportAssetsInFilesystem,
|
||||
_globalConfig.profilesReadOnly, this);
|
||||
myEditorWindow->setProfileName(profileToSet);
|
||||
myEditorWindow->exec();
|
||||
if (myEditorWindow->wasSaved()) {
|
||||
profilePath += myEditorWindow->specifiedFilename() + ".profile";
|
||||
saveProfileToFile(profilePath, pData);
|
||||
saveProfileToFile(profilePath, *profile);
|
||||
populateProfilesList(QString(myEditorWindow->specifiedFilename().c_str()));
|
||||
}
|
||||
else {
|
||||
populateProfilesList(initialProfileSelection);
|
||||
}
|
||||
delete myEditorWindow;
|
||||
delete pData;
|
||||
delete profile;
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherWindow::saveProfileToFile(const std::string& path, openspace::Profile* p) {
|
||||
void LauncherWindow::saveProfileToFile(const std::string& path, const Profile& p) {
|
||||
std::ofstream outFile;
|
||||
try {
|
||||
outFile.open(path, std::ofstream::out);
|
||||
@@ -269,7 +269,7 @@ void LauncherWindow::saveProfileToFile(const std::string& path, openspace::Profi
|
||||
}
|
||||
|
||||
try {
|
||||
outFile << p->serialize();
|
||||
outFile << p.serialize();
|
||||
}
|
||||
catch (const std::ofstream::failure& e) {
|
||||
QMessageBox::critical(
|
||||
@@ -284,7 +284,7 @@ void LauncherWindow::saveProfileToFile(const std::string& path, openspace::Profi
|
||||
outFile.close();
|
||||
}
|
||||
|
||||
bool LauncherWindow::loadProfileFromFile(openspace::Profile*& p, std::string filename) {
|
||||
bool LauncherWindow::loadProfileFromFile(Profile*& p, std::string filename) {
|
||||
bool successfulLoad = true;
|
||||
std::string content;
|
||||
if (filename.length() > 0) {
|
||||
@@ -305,9 +305,9 @@ bool LauncherWindow::loadProfileFromFile(openspace::Profile*& p, std::string fil
|
||||
}
|
||||
}
|
||||
try {
|
||||
p = new openspace::Profile(content);
|
||||
p = new Profile(content);
|
||||
}
|
||||
catch (const openspace::Profile::ParsingError& e) {
|
||||
catch (const Profile::ParsingError& e) {
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
"Exception",
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
AdditionalScriptsDialog::AdditionalScriptsDialog(openspace::Profile* profile,
|
||||
AdditionalScriptsDialog::AdditionalScriptsDialog(openspace::Profile& profile,
|
||||
QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
@@ -69,7 +69,7 @@ AdditionalScriptsDialog::AdditionalScriptsDialog(openspace::Profile* profile,
|
||||
layout->addWidget(buttons);
|
||||
}
|
||||
|
||||
std::vector<std::string> scripts = _profile->additionalScripts();
|
||||
std::vector<std::string> scripts = _profile.additionalScripts();
|
||||
std::string scpts = std::accumulate(
|
||||
scripts.begin(), scripts.end(),
|
||||
std::string(), [](std::string lhs, std::string rhs) { return lhs + rhs + '\n'; }
|
||||
@@ -86,6 +86,6 @@ void AdditionalScriptsDialog::parseScript() {
|
||||
getline(iss, s);
|
||||
tmpMultilineStringToVector.push_back(s);
|
||||
}
|
||||
_profile->setAdditionalScripts(tmpMultilineStringToVector);
|
||||
_profile.setAdditionalScripts(tmpMultilineStringToVector);
|
||||
accept();
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
AssetsDialog::AssetsDialog(openspace::Profile* profile, const std::string reportAssets,
|
||||
AssetsDialog::AssetsDialog(openspace::Profile& profile, const std::string reportAssets,
|
||||
QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
@@ -151,7 +151,7 @@ AssetsDialog::AssetsDialog(openspace::Profile* profile, const std::string report
|
||||
connect(_assetTree, &QTreeView::clicked, this, &AssetsDialog::selected);
|
||||
|
||||
|
||||
for (const std::string& a : _profile->assets()) {
|
||||
for (const std::string& a : _profile.assets()) {
|
||||
QModelIndex parent = _assetTreeModel.index(-1, 0);
|
||||
int nRows = _assetTreeModel.rowCount(parent);
|
||||
traverseToFindFilesystemMatch(_assetTreeModel, parent, nRows, a);
|
||||
@@ -220,13 +220,13 @@ QString AssetsDialog::createTextSummary() {
|
||||
}
|
||||
|
||||
void AssetsDialog::parseSelections() {
|
||||
_profile->clearAssets();
|
||||
_profile.clearAssets();
|
||||
std::vector<std::string> summaryPaths;
|
||||
std::vector<AssetTreeItem*> summaryItems;
|
||||
_assetTreeModel.getSelectedAssets(summaryPaths, summaryItems);
|
||||
|
||||
for (const std::string& sel : summaryPaths) {
|
||||
_profile->addAsset(sel);
|
||||
_profile.addAsset(sel);
|
||||
}
|
||||
accept();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
CameraDialog::CameraDialog(openspace::Profile* profile, QWidget *parent)
|
||||
CameraDialog::CameraDialog(openspace::Profile& profile, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
{
|
||||
@@ -92,8 +92,8 @@ CameraDialog::CameraDialog(openspace::Profile* profile, QWidget *parent)
|
||||
layout->addLayout(footerLayout);
|
||||
}
|
||||
|
||||
if (_profile->camera().has_value()) {
|
||||
openspace::Profile::CameraType type = _profile->camera().value();
|
||||
if (_profile.camera().has_value()) {
|
||||
openspace::Profile::CameraType type = *_profile.camera();
|
||||
std::visit(overloaded {
|
||||
[this](const openspace::Profile::CameraNavState& nav) {
|
||||
_tabWidget->setCurrentIndex(CameraTypeNav);
|
||||
@@ -400,7 +400,7 @@ void CameraDialog::approved() {
|
||||
else {
|
||||
nav.pitch = std::nullopt;
|
||||
}
|
||||
_profile->setCamera(nav);
|
||||
_profile.setCamera(nav);
|
||||
}
|
||||
else if (_tabWidget->currentIndex() == CameraTypeGeo) {
|
||||
openspace::Profile::CameraGoToGeo geo;
|
||||
@@ -410,7 +410,7 @@ void CameraDialog::approved() {
|
||||
if (!_geoState.altitude->text().isEmpty()) {
|
||||
geo.altitude = _geoState.altitude->text().toDouble();
|
||||
}
|
||||
_profile->setCamera(geo);
|
||||
_profile.setCamera(geo);
|
||||
}
|
||||
|
||||
accept();
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace {
|
||||
|
||||
} // namespace
|
||||
|
||||
DeltaTimesDialog::DeltaTimesDialog(openspace::Profile* profile, QWidget *parent)
|
||||
DeltaTimesDialog::DeltaTimesDialog(openspace::Profile& profile, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
{
|
||||
@@ -155,7 +155,7 @@ DeltaTimesDialog::DeltaTimesDialog(openspace::Profile* profile, QWidget *parent)
|
||||
}
|
||||
|
||||
|
||||
_data = _profile->deltaTimes();
|
||||
_data = _profile.deltaTimes();
|
||||
|
||||
for (size_t d = 0; d < _data.size(); ++d) {
|
||||
std::string summary = createSummaryForDeltaTime(d, true);
|
||||
@@ -375,7 +375,7 @@ void DeltaTimesDialog::parseSelections() {
|
||||
for (size_t i = 0; i < (finalNonzeroIndex + 1); ++i) {
|
||||
tempDt.push_back(_data[i]);
|
||||
}
|
||||
_profile->setDeltaTimes(tempDt);
|
||||
_profile.setDeltaTimes(tempDt);
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
@@ -93,10 +93,10 @@ namespace {
|
||||
|
||||
} // namespace
|
||||
|
||||
KeybindingsDialog::KeybindingsDialog(openspace::Profile* profile, QWidget *parent)
|
||||
KeybindingsDialog::KeybindingsDialog(openspace::Profile& profile, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
, _data(_profile->keybindings())
|
||||
, _data(_profile.keybindings())
|
||||
{
|
||||
setWindowTitle("Assign Keybindings");
|
||||
|
||||
@@ -484,7 +484,7 @@ void KeybindingsDialog::parseSelections() {
|
||||
if ((_data.size() == 1) && (_data.at(0).name.empty())) {
|
||||
_data.clear();
|
||||
}
|
||||
_profile->setKeybindings(_data);
|
||||
_profile.setKeybindings(_data);
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
MarkNodesDialog::MarkNodesDialog(openspace::Profile* profile, QWidget* parent)
|
||||
MarkNodesDialog::MarkNodesDialog(openspace::Profile& profile, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
, _data(_profile->markNodes())
|
||||
, _data(_profile.markNodes())
|
||||
{
|
||||
setWindowTitle("Mark Interesting Nodes");
|
||||
|
||||
@@ -136,7 +136,7 @@ void MarkNodesDialog::listItemRemove() {
|
||||
}
|
||||
|
||||
void MarkNodesDialog::parseSelections() {
|
||||
_profile->setMarkNodes(_data);
|
||||
_profile.setMarkNodes(_data);
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <algorithm>
|
||||
|
||||
MetaDialog::MetaDialog(openspace::Profile* profile, QWidget *parent)
|
||||
MetaDialog::MetaDialog(openspace::Profile& profile, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
{
|
||||
@@ -72,8 +72,8 @@ MetaDialog::MetaDialog(openspace::Profile* profile, QWidget *parent)
|
||||
layout->addWidget(buttons);
|
||||
|
||||
|
||||
if (_profile->meta().has_value()) {
|
||||
openspace::Profile::Meta meta = *_profile->meta();
|
||||
if (_profile.meta().has_value()) {
|
||||
openspace::Profile::Meta meta = *_profile.meta();
|
||||
if (meta.name.has_value()) {
|
||||
_nameEdit->setText(QString::fromStdString(*meta.name));
|
||||
}
|
||||
@@ -121,10 +121,10 @@ void MetaDialog::save() {
|
||||
if (!_licenseEdit->text().isEmpty()) {
|
||||
m.license = _licenseEdit->text().toStdString();
|
||||
}
|
||||
_profile->setMeta(m);
|
||||
_profile.setMeta(m);
|
||||
}
|
||||
else {
|
||||
_profile->clearMeta();
|
||||
_profile.clearMeta();
|
||||
}
|
||||
accept();
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
ModulesDialog::ModulesDialog(openspace::Profile* profile, QWidget *parent)
|
||||
ModulesDialog::ModulesDialog(openspace::Profile& profile, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
, _data(_profile->modules())
|
||||
, _data(_profile.modules())
|
||||
{
|
||||
setWindowTitle("Modules");
|
||||
|
||||
@@ -343,7 +343,7 @@ void ModulesDialog::parseSelections() {
|
||||
if ((_data.size() == 1) && (_data.at(0).name.empty())) {
|
||||
_data.clear();
|
||||
}
|
||||
_profile->setModules(_data);
|
||||
_profile.setModules(_data);
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,14 +34,16 @@
|
||||
#include <QTextEdit>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
using namespace openspace;
|
||||
|
||||
template <class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
|
||||
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
ProfileEdit::ProfileEdit(openspace::Profile* profile, const std::string reportedAssets,
|
||||
ProfileEdit::ProfileEdit(Profile& profile, const std::string reportedAssets,
|
||||
std::vector<std::string>& profilesReadOnly, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, _reportedAssets(reportedAssets)
|
||||
, _pData(profile)
|
||||
, _profile(profile)
|
||||
, _profilesReadOnly(profilesReadOnly)
|
||||
{
|
||||
setWindowTitle("Profile Editor");
|
||||
@@ -319,25 +321,25 @@ ProfileEdit::ProfileEdit(openspace::Profile* profile, const std::string reported
|
||||
}
|
||||
|
||||
void ProfileEdit::initSummaryTextForEachCategory() {
|
||||
labelText(_pData, _pData->modules().size(), "Modules", _modulesLabel);
|
||||
labelText(_profile, _profile.modules().size(), "Modules", _modulesLabel);
|
||||
|
||||
labelText(_pData, _pData->assets().size(), "Assets", _assetsLabel);
|
||||
labelText(_profile, _profile.assets().size(), "Assets", _assetsLabel);
|
||||
_assetsEdit->setText(QString::fromStdString(summarizeAssets()));
|
||||
|
||||
labelText(_pData, _pData->properties().size(), "Properties", _propertiesLabel);
|
||||
labelText(_profile, _profile.properties().size(), "Properties", _propertiesLabel);
|
||||
_propertiesEdit->setText(QString::fromStdString(summarizeProperties()));
|
||||
|
||||
labelText(_pData, _pData->keybindings().size(), "Keybindings", _keybindingsLabel);
|
||||
labelText(_profile, _profile.keybindings().size(), "Keybindings", _keybindingsLabel);
|
||||
_keybindingsEdit->setText(QString::fromStdString(summarizeKeybindings()));
|
||||
|
||||
labelText(_pData, _pData->deltaTimes().size(), "Simulation Time Increments",
|
||||
labelText(_profile, _profile.deltaTimes().size(), "Simulation Time Increments",
|
||||
_deltaTimesLabel);
|
||||
labelText(_pData, _pData->markNodes().size(), "Mark Interesting Nodes",
|
||||
labelText(_profile, _profile.markNodes().size(), "Mark Interesting Nodes",
|
||||
_interestingNodesLabel);
|
||||
labelText(_pData, 0, "Camera", _cameraLabel);
|
||||
labelText(_pData, 0, "Time", _timeLabel);
|
||||
labelText(_pData, 0, "Meta", _metaLabel);
|
||||
labelText(_pData, 0, "Additional Scripts", _additionalScriptsLabel);
|
||||
labelText(_profile, 0, "Camera", _cameraLabel);
|
||||
labelText(_profile, 0, "Time", _timeLabel);
|
||||
labelText(_profile, 0, "Meta", _metaLabel);
|
||||
labelText(_profile, 0, "Additional Scripts", _additionalScriptsLabel);
|
||||
}
|
||||
|
||||
void ProfileEdit::setProfileName(QString profileToSet) {
|
||||
@@ -366,96 +368,77 @@ void ProfileEdit::duplicateProfile() {
|
||||
|
||||
void ProfileEdit::openMeta() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
MetaDialog(_pData, this).exec();
|
||||
}
|
||||
MetaDialog(_profile, this).exec();
|
||||
}
|
||||
|
||||
void ProfileEdit::openModules() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
ModulesDialog(_pData, this).exec();
|
||||
labelText(_pData, _pData->modules().size(), "Modules", _modulesLabel);
|
||||
}
|
||||
ModulesDialog(_profile, this).exec();
|
||||
labelText(_profile, _profile.modules().size(), "Modules", _modulesLabel);
|
||||
}
|
||||
|
||||
void ProfileEdit::openProperties() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
PropertiesDialog(_pData, this).exec();
|
||||
labelText(_pData, _pData->properties().size(), "Properties", _propertiesLabel);
|
||||
_propertiesEdit->setText(QString::fromStdString(summarizeProperties()));
|
||||
}
|
||||
PropertiesDialog(_profile, this).exec();
|
||||
labelText(_profile, _profile.properties().size(), "Properties", _propertiesLabel);
|
||||
_propertiesEdit->setText(QString::fromStdString(summarizeProperties()));
|
||||
}
|
||||
|
||||
void ProfileEdit::openKeybindings() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
KeybindingsDialog(_pData, this).exec();
|
||||
labelText(_pData, _pData->keybindings().size(), "Keybindings",
|
||||
_keybindingsLabel
|
||||
);
|
||||
_keybindingsEdit->setText(QString::fromStdString(summarizeKeybindings()));
|
||||
}
|
||||
KeybindingsDialog(_profile, this).exec();
|
||||
labelText(_profile, _profile.keybindings().size(), "Keybindings",
|
||||
_keybindingsLabel
|
||||
);
|
||||
_keybindingsEdit->setText(QString::fromStdString(summarizeKeybindings()));
|
||||
}
|
||||
|
||||
void ProfileEdit::openAssets() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
AssetsDialog(_pData, _reportedAssets, this).exec();
|
||||
labelText(_pData, _pData->assets().size(), "Assets", _assetsLabel);
|
||||
_assetsEdit->setText(_assets->createTextSummary());
|
||||
_assetsEdit->setText(QString::fromStdString(summarizeAssets()));
|
||||
}
|
||||
AssetsDialog assets(_profile, _reportedAssets, this);
|
||||
assets.exec();
|
||||
labelText(_profile, _profile.assets().size(), "Assets", _assetsLabel);
|
||||
_assetsEdit->setText(assets.createTextSummary());
|
||||
_assetsEdit->setText(QString::fromStdString(summarizeAssets()));
|
||||
}
|
||||
|
||||
void ProfileEdit::openTime() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
TimeDialog(_pData, this).exec();
|
||||
}
|
||||
TimeDialog(_profile, this).exec();
|
||||
}
|
||||
|
||||
void ProfileEdit::openDeltaTimes() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
DeltaTimesDialog(_pData, this).exec();
|
||||
labelText(_pData, _pData->deltaTimes().size(), "Simulation Time Increments",
|
||||
_deltaTimesLabel
|
||||
);
|
||||
}
|
||||
DeltaTimesDialog(_profile, this).exec();
|
||||
labelText(
|
||||
_profile,
|
||||
_profile.deltaTimes().size(),
|
||||
"Simulation Time Increments",
|
||||
_deltaTimesLabel
|
||||
);
|
||||
}
|
||||
|
||||
void ProfileEdit::openAddedScripts() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
AdditionalScriptsDialog(_pData, this).exec();
|
||||
}
|
||||
AdditionalScriptsDialog(_profile, this).exec();
|
||||
}
|
||||
|
||||
void ProfileEdit::openCamera() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
CameraDialog(_pData, this).exec();
|
||||
}
|
||||
CameraDialog(_profile, this).exec();
|
||||
}
|
||||
|
||||
void ProfileEdit::openMarkNodes() {
|
||||
_errorMsg->clear();
|
||||
if (_pData) {
|
||||
MarkNodesDialog(_pData, this).exec();
|
||||
labelText(_pData, _pData->markNodes().size(), "Mark Interesting Nodes",
|
||||
_interestingNodesLabel
|
||||
);
|
||||
}
|
||||
MarkNodesDialog(_profile, this).exec();
|
||||
labelText(_profile, _profile.markNodes().size(), "Mark Interesting Nodes",
|
||||
_interestingNodesLabel
|
||||
);
|
||||
}
|
||||
|
||||
void ProfileEdit::labelText(openspace::Profile* pData, int size, QString title,
|
||||
void ProfileEdit::labelText(const Profile& pData, int size, QString title,
|
||||
QLabel* pLabel)
|
||||
{
|
||||
if (pData == nullptr) {
|
||||
return;
|
||||
}
|
||||
QString label;
|
||||
if (size > 0) {
|
||||
label = title + " (" + QString::number(size) + ")";
|
||||
@@ -468,22 +451,16 @@ void ProfileEdit::labelText(openspace::Profile* pData, int size, QString title,
|
||||
}
|
||||
|
||||
std::string ProfileEdit::summarizeProperties() {
|
||||
if (_pData == nullptr) {
|
||||
return "";
|
||||
}
|
||||
std::string results;
|
||||
for (openspace::Profile::Property p : _pData->properties()) {
|
||||
for (openspace::Profile::Property p : _profile.properties()) {
|
||||
results += p.name + " = " + p.value + '\n';
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
std::string ProfileEdit::summarizeKeybindings() {
|
||||
if (_pData == nullptr) {
|
||||
return "";
|
||||
}
|
||||
std::string results;
|
||||
for (openspace::Profile::Keybinding k : _pData->keybindings()) {
|
||||
for (openspace::Profile::Keybinding k : _profile.keybindings()) {
|
||||
results += k.name + " (";
|
||||
int keymod = static_cast<int>(k.key.modifier);
|
||||
if (keymod != static_cast<int>(openspace::KeyModifier::NoModifier)) {
|
||||
@@ -497,7 +474,7 @@ std::string ProfileEdit::summarizeKeybindings() {
|
||||
|
||||
std::string ProfileEdit::summarizeAssets() {
|
||||
std::string results;
|
||||
for (const std::string& a : _pData->assets()) {
|
||||
for (const std::string& a : _profile.assets()) {
|
||||
results += a + "\n";
|
||||
}
|
||||
return results;
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
PropertiesDialog::PropertiesDialog(openspace::Profile* profile, QWidget *parent)
|
||||
PropertiesDialog::PropertiesDialog(openspace::Profile& profile, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
, _data(_profile->properties())
|
||||
, _data(_profile.properties())
|
||||
{
|
||||
setWindowTitle("Set Property Values");
|
||||
|
||||
@@ -347,7 +347,7 @@ void PropertiesDialog::parseSelections() {
|
||||
if ((_data.size() == 1) && (_data.at(0).name.compare("") == 0)) {
|
||||
_data.clear();
|
||||
}
|
||||
_profile->setProperties(_data);
|
||||
_profile.setProperties(_data);
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
using namespace openspace;
|
||||
|
||||
TimeDialog::TimeDialog(openspace::Profile* profile, QWidget* parent)
|
||||
TimeDialog::TimeDialog(openspace::Profile& profile, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, _profile(profile)
|
||||
{
|
||||
@@ -90,8 +90,8 @@ TimeDialog::TimeDialog(openspace::Profile* profile, QWidget* parent)
|
||||
|
||||
QStringList types { "Absolute", "Relative" };
|
||||
_typeCombo->addItems(types);
|
||||
if (_profile->time().has_value()) {
|
||||
_data = _profile->time().value();
|
||||
if (_profile.time().has_value()) {
|
||||
_data = *_profile.time();
|
||||
if (_data.type == Profile::Time::Type::Relative) {
|
||||
if (_data.value == "") {
|
||||
_data.value = "now";
|
||||
@@ -148,13 +148,13 @@ void TimeDialog::approved() {
|
||||
constexpr const int Relative = static_cast<int>(Profile::Time::Type::Relative);
|
||||
if (_typeCombo->currentIndex() == Relative) {
|
||||
if (_relativeEdit->text().isEmpty()) {
|
||||
_profile->clearTime();
|
||||
_profile.clearTime();
|
||||
}
|
||||
else {
|
||||
Profile::Time t;
|
||||
t.type = Profile::Time::Type::Relative;
|
||||
t.value = _relativeEdit->text().toUtf8().constData();
|
||||
_profile->setTime(t);
|
||||
_profile.setTime(t);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -165,7 +165,7 @@ void TimeDialog::approved() {
|
||||
_absoluteEdit->date().toString("yyyy-MM-dd").toStdString(),
|
||||
_absoluteEdit->time().toString().toStdString()
|
||||
);
|
||||
_profile->setTime(t);
|
||||
_profile.setTime(t);
|
||||
}
|
||||
accept();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user