diff --git a/src/MainWindow.h b/src/MainWindow.h index 577209f7..55462907 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -69,6 +69,7 @@ private slots: void setFileName(const QString &filename); void setFont(const QString &family, uint size); void showProgress(); + void openCSGSettingsChanged(); private: void openFile(const QString &filename); diff --git a/src/Preferences.cc b/src/Preferences.cc index 33d71bd5..9e1e1f1a 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -70,6 +70,7 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) this->defaultmap["advanced/polysetCacheSize"] = uint(PolySetCache::instance()->maxSize()); this->defaultmap["advanced/cgalCacheSize"] = uint(CGALCache::instance()->maxSize()); this->defaultmap["advanced/openCSGLimit"] = 2000; + this->defaultmap["advanced/forceGoldfeather"] = false; // Toolbar @@ -207,6 +208,13 @@ void Preferences::on_opencsgLimitEdit_textChanged(const QString &text) // FIXME: Set this globally? } +void Preferences::on_forceGoldfeatherBox_toggled(bool state) +{ + QSettings settings; + settings.setValue("advanced/forceGoldfeather", state); + emit openCSGSettingsChanged(); +} + void Preferences::keyPressEvent(QKeyEvent *e) { #ifdef Q_WS_MAC @@ -271,10 +279,12 @@ void Preferences::updateGUI() this->cgalCacheSizeEdit->setText(getValue("advanced/cgalCacheSize").toString()); this->polysetCacheSizeEdit->setText(getValue("advanced/polysetCacheSize").toString()); this->opencsgLimitEdit->setText(getValue("advanced/openCSGLimit").toString()); + this->forceGoldfeatherBox->setChecked(getValue("advanced/forceGoldfeather").toBool()); } void Preferences::apply() const { emit fontChanged(getValue("editor/fontfamily").toString(), getValue("editor/fontsize").toUInt()); emit requestRedraw(); + emit openCSGSettingsChanged(); } diff --git a/src/Preferences.h b/src/Preferences.h index 492a2614..5ebce430 100644 --- a/src/Preferences.h +++ b/src/Preferences.h @@ -27,10 +27,12 @@ public slots: void on_cgalCacheSizeEdit_textChanged(const QString &); void on_polysetCacheSizeEdit_textChanged(const QString &); void on_opencsgLimitEdit_textChanged(const QString &); + void on_forceGoldfeatherBox_toggled(bool); signals: void requestRedraw() const; void fontChanged(const QString &family, uint size) const; + void openCSGSettingsChanged() const; private: Preferences(QWidget *parent = NULL); diff --git a/src/Preferences.ui b/src/Preferences.ui index 8ff2828a..9ca8179e 100644 --- a/src/Preferences.ui +++ b/src/Preferences.ui @@ -6,8 +6,8 @@ 0 0 - 418 - 269 + 531 + 418 @@ -176,20 +176,64 @@ - - - Show OpenCSG capability warning - - - true - - - - - - - Enable OpenCSG for OpenGL 1.x + + + OpenCSG + + + + + Show capability warning + + + true + + + + + + + Enable for OpenGL 1.x + + + + + + + + + Turn off rendering at + + + + + + + + + + elements + + + + + + + + + Force Goldfeather + + + + + openCSGWarningBox + + enableOpenCSGBox + enableOpenCSGBox + + openCSGWarningBox + forceGoldfeatherBox @@ -234,27 +278,6 @@ - - - - - - Turn off OpenCSG rendering at - - - - - - - - - - elements - - - - - diff --git a/src/mainwin.cc b/src/mainwin.cc index f8a6f433..a8507c0c 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -41,6 +41,7 @@ #ifdef ENABLE_OPENCSG #include "CSGTermEvaluator.h" #include "OpenCSGRenderer.h" +#include #endif #include "ProgressWidget.h" #include "ThrownTogetherRenderer.h" @@ -347,6 +348,8 @@ MainWindow::MainWindow(const QString &filename) connect(Preferences::inst(), SIGNAL(requestRedraw()), this->glview, SLOT(updateGL())); connect(Preferences::inst(), SIGNAL(fontChanged(const QString&,uint)), this, SLOT(setFont(const QString&,uint))); + connect(Preferences::inst(), SIGNAL(openCSGSettingsChanged()), + this, SLOT(openCSGSettingsChanged())); Preferences::inst()->apply(); // make sure it looks nice.. @@ -1786,3 +1789,10 @@ void MainWindow::clearCurrentOutput() { set_output_handler(NULL, NULL); } + +void MainWindow::openCSGSettingsChanged() +{ +#ifdef ENABLE_OPENCSG + OpenCSG::setOption(OpenCSG::AlgorithmSetting, Preferences::inst()->getValue("advanced/forceGoldfeather").toBool() ? OpenCSG::Goldfeather : OpenCSG::Automatic); +#endif +}