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 "SettingsWindow.h"
|
|
|
|
|
#include "AppSettings.h"
|
|
|
|
|
|
2026-04-11 20:05:50 +10:00
|
|
|
#include <QCheckBox>
|
2026-04-11 16:30:10 +10:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QShowEvent>
|
2026-04-29 08:54:35 +10:00
|
|
|
#include <QSpinBox>
|
2026-04-11 16:30:10 +10:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
SettingsWindow::SettingsWindow(QWidget *parent)
|
|
|
|
|
: QDialog(parent)
|
|
|
|
|
{
|
|
|
|
|
setWindowTitle("Settings");
|
|
|
|
|
setupUi();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SettingsWindow::setupUi() {
|
|
|
|
|
auto* form = new QFormLayout();
|
|
|
|
|
|
|
|
|
|
geometry_library_edit_ = new QLineEdit(this);
|
|
|
|
|
geometry_library_edit_->setMinimumWidth(280);
|
|
|
|
|
form->addRow("Geometry Library", geometry_library_edit_);
|
|
|
|
|
|
2026-04-11 20:05:50 +10:00
|
|
|
show_stats_check_ = new QCheckBox(this);
|
|
|
|
|
form->addRow("Show Performance Stats", show_stats_check_);
|
|
|
|
|
|
2026-04-12 22:07:19 +10:00
|
|
|
backface_culling_check_ = new QCheckBox(this);
|
|
|
|
|
backface_culling_check_->setToolTip(
|
|
|
|
|
"Skip triangles facing away from the camera. Big FPS win on "
|
|
|
|
|
"closed solids; disable if you see holes in open geometry.");
|
|
|
|
|
form->addRow("Backface Culling", backface_culling_check_);
|
|
|
|
|
|
2026-04-24 13:45:04 +10:00
|
|
|
load_data_source_check_ = new QCheckBox(this);
|
|
|
|
|
load_data_source_check_->setToolTip(
|
|
|
|
|
"Keep the .ifc/.rdb open after loading so element properties can "
|
|
|
|
|
"be queried. Disable for geometry-only viewing — saves memory "
|
|
|
|
|
"and, on sidecar hits, avoids a second file read.");
|
|
|
|
|
form->addRow("Load Property Data Source", load_data_source_check_);
|
|
|
|
|
|
2026-04-29 08:54:35 +10:00
|
|
|
void_limit_spin_ = new QSpinBox(this);
|
|
|
|
|
void_limit_spin_->setRange(0, 100000);
|
|
|
|
|
void_limit_spin_->setToolTip(
|
|
|
|
|
"Skip elements with more openings (HasOpenings) than this. "
|
|
|
|
|
"A handful of pathological elements can dominate boolean-subtraction "
|
|
|
|
|
"time; dropping them keeps load times sane.");
|
|
|
|
|
form->addRow("Void Limit", void_limit_spin_);
|
|
|
|
|
|
2026-04-11 16:30:10 +10:00
|
|
|
auto* button_box = new QDialogButtonBox(
|
|
|
|
|
QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
|
|
|
|
|
|
|
|
|
auto* root = new QVBoxLayout(this);
|
|
|
|
|
root->addLayout(form);
|
|
|
|
|
root->addWidget(button_box);
|
|
|
|
|
|
|
|
|
|
connect(button_box, &QDialogButtonBox::accepted, this, &SettingsWindow::onAccepted);
|
|
|
|
|
connect(button_box, &QDialogButtonBox::rejected, this, &SettingsWindow::reject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SettingsWindow::showEvent(QShowEvent* event) {
|
|
|
|
|
// Re-sync widgets from the persisted settings every time the dialog is
|
|
|
|
|
// shown, so a previous Cancel doesn't leave stale text in the field.
|
|
|
|
|
syncFromSettings();
|
|
|
|
|
QDialog::showEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SettingsWindow::syncFromSettings() {
|
|
|
|
|
geometry_library_edit_->setText(AppSettings::instance().geometryLibrary());
|
2026-04-11 20:05:50 +10:00
|
|
|
show_stats_check_->setChecked(AppSettings::instance().showStats());
|
2026-04-12 22:07:19 +10:00
|
|
|
backface_culling_check_->setChecked(AppSettings::instance().backfaceCulling());
|
2026-04-24 13:45:04 +10:00
|
|
|
load_data_source_check_->setChecked(AppSettings::instance().loadDataSource());
|
2026-04-29 08:54:35 +10:00
|
|
|
void_limit_spin_->setValue(AppSettings::instance().voidLimit());
|
2026-04-11 16:30:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SettingsWindow::onAccepted() {
|
|
|
|
|
AppSettings::instance().setGeometryLibrary(geometry_library_edit_->text());
|
2026-04-11 20:05:50 +10:00
|
|
|
AppSettings::instance().setShowStats(show_stats_check_->isChecked());
|
2026-04-12 22:07:19 +10:00
|
|
|
AppSettings::instance().setBackfaceCulling(backface_culling_check_->isChecked());
|
2026-04-24 13:45:04 +10:00
|
|
|
AppSettings::instance().setLoadDataSource(load_data_source_check_->isChecked());
|
2026-04-29 08:54:35 +10:00
|
|
|
AppSettings::instance().setVoidLimit(void_limit_spin_->value());
|
2026-04-11 16:30:10 +10:00
|
|
|
accept();
|
|
|
|
|
}
|