mirror of https://github.com/vitalif/openscad
Added GUI for cache size adjustment
parent
a4810e0019
commit
5c999479a3
|
@ -39,21 +39,6 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
// Editor pane
|
// Editor pane
|
||||||
QFontDatabase db;
|
|
||||||
foreach(int size, db.standardSizes()) {
|
|
||||||
this->fontSize->addItem(QString::number(size));
|
|
||||||
if (size == 12) {
|
|
||||||
this->fontSize->setCurrentIndex(this->fontSize->count()-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup default settings
|
|
||||||
this->defaultmap["3dview/colorscheme"] = this->colorSchemeChooser->currentItem()->text();
|
|
||||||
this->defaultmap["advanced/opencsg_show_warning"] = true;
|
|
||||||
this->defaultmap["advanced/enable_opencsg_opengl1x"] = true;
|
|
||||||
this->defaultmap["caches/polysetCacheSize"] = uint(PolySetCache::instance()->maxSize());
|
|
||||||
this->defaultmap["caches/cgalCacheSize"] = uint(CGALCache::instance()->maxSize());
|
|
||||||
|
|
||||||
// Setup default font (Try to use a nice monospace font)
|
// Setup default font (Try to use a nice monospace font)
|
||||||
QString fontfamily;
|
QString fontfamily;
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
|
@ -70,6 +55,23 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)
|
||||||
this->defaultmap["editor/fontfamily"] = found_family;
|
this->defaultmap["editor/fontfamily"] = found_family;
|
||||||
this->defaultmap["editor/fontsize"] = 12;
|
this->defaultmap["editor/fontsize"] = 12;
|
||||||
|
|
||||||
|
QFontDatabase db;
|
||||||
|
foreach(int size, db.standardSizes()) {
|
||||||
|
this->fontSize->addItem(QString::number(size));
|
||||||
|
if (size == 12) {
|
||||||
|
this->fontSize->setCurrentIndex(this->fontSize->count()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup default settings
|
||||||
|
this->defaultmap["3dview/colorscheme"] = this->colorSchemeChooser->currentItem()->text();
|
||||||
|
this->defaultmap["advanced/opencsg_show_warning"] = true;
|
||||||
|
this->defaultmap["advanced/enable_opencsg_opengl1x"] = true;
|
||||||
|
this->defaultmap["advanced/polysetCacheSize"] = uint(PolySetCache::instance()->maxSize());
|
||||||
|
this->defaultmap["advanced/cgalCacheSize"] = uint(CGALCache::instance()->maxSize());
|
||||||
|
this->defaultmap["advanced/openCSGLimit"] = 2000;
|
||||||
|
|
||||||
|
|
||||||
// Toolbar
|
// Toolbar
|
||||||
QActionGroup *group = new QActionGroup(this);
|
QActionGroup *group = new QActionGroup(this);
|
||||||
group->addAction(prefsAction3DView);
|
group->addAction(prefsAction3DView);
|
||||||
|
@ -114,14 +116,12 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)
|
||||||
this->colorschemes["Sunset"][RenderSettings::CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00);
|
this->colorschemes["Sunset"][RenderSettings::CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00);
|
||||||
this->colorschemes["Sunset"][RenderSettings::CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00);
|
this->colorschemes["Sunset"][RenderSettings::CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00);
|
||||||
|
|
||||||
connect(this->colorSchemeChooser, SIGNAL(itemSelectionChanged()),
|
// Advanced pane
|
||||||
this, SLOT(colorSchemeChanged()));
|
QValidator *validator = new QIntValidator(this);
|
||||||
connect(this->fontChooser, SIGNAL(activated(const QString &)),
|
this->cgalCacheSizeEdit->setValidator(validator);
|
||||||
this, SLOT(fontFamilyChanged(const QString &)));
|
this->polysetCacheSizeEdit->setValidator(validator);
|
||||||
connect(this->fontSize, SIGNAL(editTextChanged(const QString &)),
|
this->opencsgLimitEdit->setValidator(validator);
|
||||||
this, SLOT(fontSizeChanged(const QString &)));
|
|
||||||
connect(this->openCSGWarningBox, SIGNAL(toggled(bool)),
|
|
||||||
this, SLOT(openCSGWarningChanged(bool)));
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
|
||||||
RenderSettings::inst()->setColors(this->colorschemes[getValue("3dview/colorscheme").toString()]);
|
RenderSettings::inst()->setColors(this->colorschemes[getValue("3dview/colorscheme").toString()]);
|
||||||
|
@ -146,7 +146,7 @@ Preferences::actionTriggered(QAction *action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::colorSchemeChanged()
|
void Preferences::on_colorSchemeChooser_itemSelectionChanged()
|
||||||
{
|
{
|
||||||
QString scheme = this->colorSchemeChooser->currentItem()->text();
|
QString scheme = this->colorSchemeChooser->currentItem()->text();
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
@ -157,14 +157,14 @@ void Preferences::colorSchemeChanged()
|
||||||
emit requestRedraw();
|
emit requestRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::fontFamilyChanged(const QString &family)
|
void Preferences::on_fontChooser_activated(const QString &family)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue("editor/fontfamily", family);
|
settings.setValue("editor/fontfamily", family);
|
||||||
emit fontChanged(family, getValue("editor/fontsize").toUInt());
|
emit fontChanged(family, getValue("editor/fontsize").toUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::fontSizeChanged(const QString &size)
|
void Preferences::on_fontSize_editTextChanged(const QString &size)
|
||||||
{
|
{
|
||||||
uint intsize = size.toUInt();
|
uint intsize = size.toUInt();
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
@ -173,19 +173,40 @@ void Preferences::fontSizeChanged(const QString &size)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Preferences::openCSGWarningChanged(bool state)
|
Preferences::on_openCSGWarningBox_toggled(bool state)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue("advanced/opencsg_show_warning",state);
|
settings.setValue("advanced/opencsg_show_warning",state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Preferences::enableOpenCSGChanged(bool state)
|
Preferences::on_enableOpenCSGBox_toggled(bool state)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue("advanced/enable_opencsg_opengl1x", state);
|
settings.setValue("advanced/enable_opencsg_opengl1x", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Preferences::on_cgalCacheSizeEdit_textChanged(const QString &text)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue("advanced/cgalCacheSize", text);
|
||||||
|
CGALCache::instance()->setMaxSize(text.toULong());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Preferences::on_polysetCacheSizeEdit_textChanged(const QString &text)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue("advanced/polysetCacheSize", text);
|
||||||
|
PolySetCache::instance()->setMaxSize(text.toULong());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Preferences::on_opencsgLimitEdit_textChanged(const QString &text)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue("advanced/openCSGLimit", text);
|
||||||
|
// FIXME: Set this globally?
|
||||||
|
}
|
||||||
|
|
||||||
void Preferences::keyPressEvent(QKeyEvent *e)
|
void Preferences::keyPressEvent(QKeyEvent *e)
|
||||||
{
|
{
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
|
@ -218,6 +239,7 @@ void Preferences::removeDefaultSettings()
|
||||||
QVariant Preferences::getValue(const QString &key) const
|
QVariant Preferences::getValue(const QString &key) const
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
assert(settings.contains(key) || this->defaultmap.contains(key));
|
||||||
return settings.value(key, this->defaultmap[key]);
|
return settings.value(key, this->defaultmap[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +268,9 @@ void Preferences::updateGUI()
|
||||||
|
|
||||||
this->openCSGWarningBox->setChecked(getValue("advanced/opencsg_show_warning").toBool());
|
this->openCSGWarningBox->setChecked(getValue("advanced/opencsg_show_warning").toBool());
|
||||||
this->enableOpenCSGBox->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool());
|
this->enableOpenCSGBox->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool());
|
||||||
|
this->cgalCacheSizeEdit->setText(getValue("advanced/cgalCacheSize").toString());
|
||||||
|
this->polysetCacheSizeEdit->setText(getValue("advanced/polysetCacheSize").toString());
|
||||||
|
this->opencsgLimitEdit->setText(getValue("advanced/openCSGLimit").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::apply() const
|
void Preferences::apply() const
|
||||||
|
|
|
@ -19,11 +19,14 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void actionTriggered(class QAction *);
|
void actionTriggered(class QAction *);
|
||||||
void colorSchemeChanged();
|
void on_colorSchemeChooser_itemSelectionChanged();
|
||||||
void fontFamilyChanged(const QString &);
|
void on_fontChooser_activated(const QString &);
|
||||||
void fontSizeChanged(const QString &);
|
void on_fontSize_editTextChanged(const QString &);
|
||||||
void openCSGWarningChanged(bool);
|
void on_openCSGWarningBox_toggled(bool);
|
||||||
void enableOpenCSGChanged(bool);
|
void on_enableOpenCSGBox_toggled(bool);
|
||||||
|
void on_cgalCacheSizeEdit_textChanged(const QString &);
|
||||||
|
void on_polysetCacheSizeEdit_textChanged(const QString &);
|
||||||
|
void on_opencsgLimitEdit_textChanged(const QString &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestRedraw() const;
|
void requestRedraw() const;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>418</width>
|
<width>418</width>
|
||||||
<height>243</height>
|
<height>269</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -175,43 +175,99 @@
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="pageAdvanced">
|
<widget class="QWidget" name="pageAdvanced">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<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>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="openCSGWarningBox">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show OpenCSG capability warning</string>
|
<string>CGAL Cache size</string>
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="enableOpenCSGBox">
|
<widget class="QLineEdit" name="cgalCacheSizeEdit"/>
|
||||||
<property name="text">
|
|
||||||
<string>Enable OpenCSG for OpenGL 1.x</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Vertical</enum>
|
<string>bytes</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
</widget>
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>PolySet Cache size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="polysetCacheSizeEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>bytes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</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">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>11</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -411,9 +411,9 @@ MainWindow::loadDesignSettings()
|
||||||
if (settings.value("design/autoReload").toBool()) {
|
if (settings.value("design/autoReload").toBool()) {
|
||||||
designActionAutoReload->setChecked(true);
|
designActionAutoReload->setChecked(true);
|
||||||
}
|
}
|
||||||
uint polySetCacheSize = Preferences::inst()->getValue("caches/polysetCacheSize").toUInt();
|
uint polySetCacheSize = Preferences::inst()->getValue("advanced/polysetCacheSize").toUInt();
|
||||||
PolySetCache::instance()->setMaxSize(polySetCacheSize);
|
PolySetCache::instance()->setMaxSize(polySetCacheSize);
|
||||||
uint cgalCacheSize = Preferences::inst()->getValue("caches/cgalCacheSize").toUInt();
|
uint cgalCacheSize = Preferences::inst()->getValue("advanced/cgalCacheSize").toUInt();
|
||||||
CGALCache::instance()->setMaxSize(cgalCacheSize);
|
CGALCache::instance()->setMaxSize(cgalCacheSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,7 +804,7 @@ void MainWindow::compileCSG(bool procevents)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root_chain->polysets.size() > 1000) {
|
if (root_chain->polysets.size() > Preferences::inst()->getValue("advanced/openCSGLimit").toUInt()) {
|
||||||
PRINTF("WARNING: Normalized tree has %d elements!", int(root_chain->polysets.size()));
|
PRINTF("WARNING: Normalized tree has %d elements!", int(root_chain->polysets.size()));
|
||||||
PRINTF("WARNING: OpenCSG rendering has been disabled.");
|
PRINTF("WARNING: OpenCSG rendering has been disabled.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue