Skip to content

Commit ad2bd1e

Browse files
committed
#8725: use default drawing config
1 parent f48238f commit ad2bd1e

File tree

4 files changed

+198
-0
lines changed

4 files changed

+198
-0
lines changed

src/app/qgsoptions.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
560560
chkAntiAliasing->setChecked( settings.value( "/qgis/enable_anti_aliasing", true ).toBool() );
561561
chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
562562

563+
// Default simplify drawing configuration
564+
mSimplifyDrawingGroupBox->setChecked( settings.value( "/qgis/simplifyDrawingHints", (int)QgsVectorLayer::FullSimplification ).toInt() != QgsVectorLayer::NoSimplification );
565+
mSimplifyDrawingSlider->setValue( (int)(5.0f * (settings.value( "/qgis/simplifyDrawingTol", 1.0F ).toFloat()-1)) );
566+
mSimplifyDrawingPanel->setVisible( mSimplifyDrawingSlider->value()>0 );
567+
563568
// Slightly awkard here at the settings value is true to use QImage,
564569
// but the checkbox is true to use QPixmap
565570
chkUseQPixmap->setChecked( !( settings.value( "/qgis/use_qimage_to_render", true ).toBool() ) );
@@ -1091,6 +1096,10 @@ void QgsOptions::saveOptions()
10911096
bool legendLayersCapitalise = settings.value( "/qgis/capitaliseLayerName", false ).toBool();
10921097
settings.setValue( "/qgis/capitaliseLayerName", capitaliseCheckBox->isChecked() );
10931098

1099+
// Default simplify drawing configuration
1100+
settings.setValue( "/qgis/simplifyDrawingHints", (int)(mSimplifyDrawingGroupBox->isChecked() ? QgsVectorLayer::FullSimplification : QgsVectorLayer::NoSimplification) );
1101+
settings.setValue( "/qgis/simplifyDrawingTol", (float)(1.0f + 0.2f*mSimplifyDrawingSlider->value()) );
1102+
10941103
// project
10951104
settings.setValue( "/qgis/projOpenAtLaunch", mProjectOnLaunchCmbBx->currentIndex() );
10961105
settings.setValue( "/qgis/projOpenAtLaunchPath", mProjectOnLaunchLineEdit->text() );
@@ -2063,3 +2072,8 @@ void QgsOptions::saveDefaultDatumTransformations()
20632072
s.endGroup();
20642073
}
20652074

2075+
void QgsOptions::on_mSimplifyDrawingSlider_valueChanged( int value )
2076+
{
2077+
mSimplifyDrawingPanel->setVisible( value>0 );
2078+
}
2079+

src/app/qgsoptions.h

+2
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
235235
void on_mRemoveDefaultTransformButton_clicked();
236236
void on_mAddDefaultTransformButton_clicked();
237237

238+
void on_mSimplifyDrawingSlider_valueChanged( int value );
239+
238240
private:
239241
QStringList i18nList();
240242
void initContrastEnhancement( QComboBox *cbox, QString name, QString defaultVal );

src/core/qgsvectorlayer.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
181181
connect( this, SIGNAL( selectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ), this, SIGNAL( selectionChanged() ) );
182182

183183
connect( QgsProject::instance()->relationManager(), SIGNAL( relationsLoaded() ), this, SLOT( onRelationsLoaded() ) );
184+
185+
// Default simplify drawing configuration
186+
QSettings settings;
187+
setSimplifyDrawingHints( settings.value( "/qgis/simplifyDrawingHints", (int)mSimplifyDrawingHints ).toInt() );
188+
setSimplifyDrawingTol( settings.value( "/qgis/simplifyDrawingTol", mSimplifyDrawingTol ).toFloat() );
189+
184190
} // QgsVectorLayer ctor
185191

186192

src/ui/qgsoptionsbase.ui

+176
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,182 @@
16611661
</property>
16621662
</widget>
16631663
</item>
1664+
<item row="5" column="0">
1665+
<widget class="QGroupBox" name="mSimplifyDrawingGroupBox">
1666+
<property name="title">
1667+
<string>By default simplify geometries</string>
1668+
</property>
1669+
<property name="checkable">
1670+
<bool>true</bool>
1671+
</property>
1672+
<layout class="QGridLayout" name="_14">
1673+
<item row="0" column="2" colspan="3">
1674+
<widget class="QLabel" name="label_59">
1675+
<property name="sizePolicy">
1676+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
1677+
<horstretch>0</horstretch>
1678+
<verstretch>0</verstretch>
1679+
</sizepolicy>
1680+
</property>
1681+
<property name="text">
1682+
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
1683+
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
1684+
p, li { white-space: pre-wrap; }
1685+
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
1686+
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;By default new vector layers added to the map should simplify geometries to improve rendering speed. The simplification applies only during rendering of the layer and does not modify the layer geometry.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1687+
</property>
1688+
<property name="wordWrap">
1689+
<bool>true</bool>
1690+
</property>
1691+
<property name="margin">
1692+
<number>2</number>
1693+
</property>
1694+
</widget>
1695+
</item>
1696+
<item row="5" column="2">
1697+
<widget class="QLabel" name="label_56">
1698+
<property name="text">
1699+
<string>Simplification factor (higher values result in more simplification): </string>
1700+
</property>
1701+
<property name="margin">
1702+
<number>2</number>
1703+
</property>
1704+
</widget>
1705+
</item>
1706+
<item row="5" column="3">
1707+
<widget class="QSlider" name="mSimplifyDrawingSlider">
1708+
<property name="maximumSize">
1709+
<size>
1710+
<width>130</width>
1711+
<height>16777215</height>
1712+
</size>
1713+
</property>
1714+
<property name="toolTip">
1715+
<string>Higher values result in more simplification</string>
1716+
</property>
1717+
<property name="minimum">
1718+
<number>0</number>
1719+
</property>
1720+
<property name="maximum">
1721+
<number>20</number>
1722+
</property>
1723+
<property name="value">
1724+
<number>0</number>
1725+
</property>
1726+
<property name="tracking">
1727+
<bool>true</bool>
1728+
</property>
1729+
<property name="orientation">
1730+
<enum>Qt::Horizontal</enum>
1731+
</property>
1732+
<property name="invertedAppearance">
1733+
<bool>false</bool>
1734+
</property>
1735+
<property name="invertedControls">
1736+
<bool>false</bool>
1737+
</property>
1738+
</widget>
1739+
</item>
1740+
<item row="8" column="2" colspan="2">
1741+
<widget class="QFrame" name="mSimplifyDrawingPanel">
1742+
<property name="minimumSize">
1743+
<size>
1744+
<width>0</width>
1745+
<height>70</height>
1746+
</size>
1747+
</property>
1748+
<property name="maximumSize">
1749+
<size>
1750+
<width>16777215</width>
1751+
<height>16777215</height>
1752+
</size>
1753+
</property>
1754+
<property name="frameShape">
1755+
<enum>QFrame::Box</enum>
1756+
</property>
1757+
<property name="frameShadow">
1758+
<enum>QFrame::Raised</enum>
1759+
</property>
1760+
<widget class="QLabel" name="mSimplifyDrawingIcon">
1761+
<property name="geometry">
1762+
<rect>
1763+
<x>10</x>
1764+
<y>0</y>
1765+
<width>60</width>
1766+
<height>67</height>
1767+
</rect>
1768+
</property>
1769+
<property name="sizePolicy">
1770+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
1771+
<horstretch>0</horstretch>
1772+
<verstretch>0</verstretch>
1773+
</sizepolicy>
1774+
</property>
1775+
<property name="minimumSize">
1776+
<size>
1777+
<width>60</width>
1778+
<height>67</height>
1779+
</size>
1780+
</property>
1781+
<property name="maximumSize">
1782+
<size>
1783+
<width>40</width>
1784+
<height>40</height>
1785+
</size>
1786+
</property>
1787+
<property name="layoutDirection">
1788+
<enum>Qt::LeftToRight</enum>
1789+
</property>
1790+
<property name="autoFillBackground">
1791+
<bool>false</bool>
1792+
</property>
1793+
<property name="text">
1794+
<string/>
1795+
</property>
1796+
<property name="pixmap">
1797+
<pixmap resource="../../images/images.qrc">:/images/themes/default/mIconWarn.png</pixmap>
1798+
</property>
1799+
<property name="scaledContents">
1800+
<bool>false</bool>
1801+
</property>
1802+
</widget>
1803+
<widget class="QLabel" name="mSimplifyDrawingLabel">
1804+
<property name="geometry">
1805+
<rect>
1806+
<x>45</x>
1807+
<y>8</y>
1808+
<width>411</width>
1809+
<height>51</height>
1810+
</rect>
1811+
</property>
1812+
<property name="text">
1813+
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
1814+
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
1815+
p, li { white-space: pre-wrap; }
1816+
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
1817+
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;Warning:&lt;/span&gt;&lt;/p&gt;
1818+
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; Increasing this factor will further speed up rendering, but may result in gaps &lt;/span&gt;&lt;/p&gt;
1819+
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; or topological errors in the layer display.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1820+
</property>
1821+
</widget>
1822+
</widget>
1823+
</item>
1824+
<item row="5" column="4">
1825+
<spacer name="horizontalSpacer_40">
1826+
<property name="orientation">
1827+
<enum>Qt::Horizontal</enum>
1828+
</property>
1829+
<property name="sizeHint" stdset="0">
1830+
<size>
1831+
<width>20</width>
1832+
<height>20</height>
1833+
</size>
1834+
</property>
1835+
</spacer>
1836+
</item>
1837+
</layout>
1838+
</widget>
1839+
</item>
16641840
</layout>
16651841
</widget>
16661842
</item>

0 commit comments

Comments
 (0)