2026-04-11 16:30:10 +10:00
|
|
|
/********************************************************************************
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of IfcOpenShell. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the Lesser GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation, either version 3.0 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* Lesser GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the Lesser GNU General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
* *
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "AppSettings.h"
|
|
|
|
|
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
constexpr const char* kGeometryLibraryKey = "geometry/library";
|
|
|
|
|
constexpr const char* kGeometryLibraryDefault = "hybrid-cgal-simple-opencascade";
|
2026-04-11 20:05:50 +10:00
|
|
|
constexpr const char* kShowStatsKey = "viewport/show_stats";
|
2026-04-12 22:07:19 +10:00
|
|
|
constexpr const char* kBackfaceCullingKey = "viewport/backface_culling";
|
2026-04-24 13:45:04 +10:00
|
|
|
constexpr const char* kLoadDataSourceKey = "loading/load_data_source";
|
2026-04-29 08:54:35 +10:00
|
|
|
constexpr const char* kVoidLimitKey = "loading/void_limit";
|
|
|
|
|
constexpr int kVoidLimitDefault = 30;
|
2026-04-11 16:30:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppSettings& AppSettings::instance() {
|
|
|
|
|
static AppSettings inst;
|
|
|
|
|
return inst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppSettings::AppSettings() {
|
|
|
|
|
load();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AppSettings::geometryLibrary() const {
|
|
|
|
|
return geometry_library_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppSettings::setGeometryLibrary(const QString& value) {
|
|
|
|
|
if (geometry_library_ == value) return;
|
|
|
|
|
geometry_library_ = value;
|
|
|
|
|
persist();
|
|
|
|
|
emit geometryLibraryChanged(value);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 20:05:50 +10:00
|
|
|
bool AppSettings::showStats() const {
|
|
|
|
|
return show_stats_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppSettings::setShowStats(bool value) {
|
|
|
|
|
if (show_stats_ == value) return;
|
|
|
|
|
show_stats_ = value;
|
|
|
|
|
persist();
|
|
|
|
|
emit showStatsChanged(value);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-12 22:07:19 +10:00
|
|
|
bool AppSettings::backfaceCulling() const {
|
|
|
|
|
return backface_culling_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppSettings::setBackfaceCulling(bool value) {
|
|
|
|
|
if (backface_culling_ == value) return;
|
|
|
|
|
backface_culling_ = value;
|
|
|
|
|
persist();
|
|
|
|
|
emit backfaceCullingChanged(value);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-24 13:45:04 +10:00
|
|
|
bool AppSettings::loadDataSource() const {
|
|
|
|
|
return load_data_source_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppSettings::setLoadDataSource(bool value) {
|
|
|
|
|
if (load_data_source_ == value) return;
|
|
|
|
|
load_data_source_ = value;
|
|
|
|
|
persist();
|
|
|
|
|
emit loadDataSourceChanged(value);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-29 08:54:35 +10:00
|
|
|
int AppSettings::voidLimit() const {
|
|
|
|
|
return void_limit_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppSettings::setVoidLimit(int value) {
|
|
|
|
|
if (value < 0) value = 0;
|
|
|
|
|
if (void_limit_ == value) return;
|
|
|
|
|
void_limit_ = value;
|
|
|
|
|
persist();
|
|
|
|
|
emit voidLimitChanged(value);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 16:30:10 +10:00
|
|
|
void AppSettings::load() {
|
|
|
|
|
QSettings settings;
|
|
|
|
|
geometry_library_ = settings.value(kGeometryLibraryKey, kGeometryLibraryDefault).toString();
|
2026-04-11 20:05:50 +10:00
|
|
|
show_stats_ = settings.value(kShowStatsKey, false).toBool();
|
2026-04-12 22:07:19 +10:00
|
|
|
backface_culling_ = settings.value(kBackfaceCullingKey, true).toBool();
|
2026-04-24 13:45:04 +10:00
|
|
|
load_data_source_ = settings.value(kLoadDataSourceKey, true).toBool();
|
2026-04-29 08:54:35 +10:00
|
|
|
void_limit_ = settings.value(kVoidLimitKey, kVoidLimitDefault).toInt();
|
|
|
|
|
if (void_limit_ < 0) void_limit_ = 0;
|
2026-04-11 16:30:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppSettings::persist() {
|
|
|
|
|
QSettings settings;
|
|
|
|
|
settings.setValue(kGeometryLibraryKey, geometry_library_);
|
2026-04-11 20:05:50 +10:00
|
|
|
settings.setValue(kShowStatsKey, show_stats_);
|
2026-04-12 22:07:19 +10:00
|
|
|
settings.setValue(kBackfaceCullingKey, backface_culling_);
|
2026-04-24 13:45:04 +10:00
|
|
|
settings.setValue(kLoadDataSourceKey, load_data_source_);
|
2026-04-29 08:54:35 +10:00
|
|
|
settings.setValue(kVoidLimitKey, void_limit_);
|
2026-04-11 16:30:10 +10:00
|
|
|
}
|