Added experimental support for forcing OpenCSG to use the Goldfeather algorithm

felipesanches-svg
Marius Kintel 2012-01-14 01:22:46 +01:00
parent 81f2d0a610
commit 9267b15bd7
5 changed files with 82 additions and 36 deletions

View File

@ -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);

View File

@ -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();
}

View File

@ -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);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>269</height>
<width>531</width>
<height>418</height>
</rect>
</property>
<property name="windowTitle">
@ -176,20 +176,64 @@
<widget class="QWidget" name="pageAdvanced">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="openCSGWarningBox">
<property name="text">
<string>Show OpenCSG capability warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableOpenCSGBox">
<property name="text">
<string>Enable OpenCSG for OpenGL 1.x</string>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>OpenCSG</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="openCSGWarningBox">
<property name="text">
<string>Show capability warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableOpenCSGBox">
<property name="text">
<string>Enable for OpenGL 1.x</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Turn off rendering at </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="opencsgLimitEdit"/>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>elements</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="forceGoldfeatherBox">
<property name="text">
<string>Force Goldfeather</string>
</property>
</widget>
</item>
</layout>
<zorder>openCSGWarningBox</zorder>
<zorder></zorder>
<zorder>enableOpenCSGBox</zorder>
<zorder>enableOpenCSGBox</zorder>
<zorder></zorder>
<zorder>openCSGWarningBox</zorder>
<zorder>forceGoldfeatherBox</zorder>
</widget>
</item>
<item>
@ -234,27 +278,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Turn off OpenCSG rendering at </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="opencsgLimitEdit"/>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>elements</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">

View File

@ -41,6 +41,7 @@
#ifdef ENABLE_OPENCSG
#include "CSGTermEvaluator.h"
#include "OpenCSGRenderer.h"
#include <opencsg.h>
#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
}