Skip to content
Permalink
Browse files
[feature] Expose choice of symbology reference scale for vector
layers, in the vector layer properties -> Rendering tab

If set, the reference scale indicates the map scale at which
symbology and labeling sizes which uses paper-based units
(such as millimeters or points) relate to. The sizes will
be scaled accordingly whenever the map is viewed at a different
scale.

For instance, a line layer using a 2mm wide line with a 1:2000
reference scale set will be rendered using 4mm wide lines when
the map is viewed at 1:1000.

Sponsored by North Road, thanks to SLYR
  • Loading branch information
nyalldawson committed Jun 28, 2021
1 parent d9b7c67 commit ed75524b071f93c4430a1354b4c77a20f0df4c04
@@ -2567,10 +2567,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
{
setMinimumScale( minScale );
}
}

if ( categories.testFlag( Rendering ) )
{
QDomElement e = node.toElement();

// get the simplification drawing settings
@@ -2579,6 +2576,9 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage,
mSimplifyMethod.setThreshold( e.attribute( QStringLiteral( "simplifyDrawingTol" ), QStringLiteral( "1" ) ).toFloat() );
mSimplifyMethod.setForceLocalOptimization( e.attribute( QStringLiteral( "simplifyLocal" ), QStringLiteral( "1" ) ).toInt() );
mSimplifyMethod.setMaximumScale( e.attribute( QStringLiteral( "simplifyMaxScale" ), QStringLiteral( "1" ) ).toFloat() );

if ( mRenderer )
mRenderer->setReferenceScale( e.attribute( QStringLiteral( "symbologyReferenceScale" ), QStringLiteral( "-1" ) ).toDouble() );
}

//diagram renderer and diagram layer settings
@@ -2926,6 +2926,8 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err
mapLayerNode.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
mapLayerNode.setAttribute( QStringLiteral( "maxScale" ), maximumScale() );
mapLayerNode.setAttribute( QStringLiteral( "minScale" ), minimumScale() );

mapLayerNode.setAttribute( QStringLiteral( "symbologyReferenceScale" ), mRenderer ? mRenderer->referenceScale() : -1 );
}

if ( categories.testFlag( Diagrams ) && mDiagramRenderer )
@@ -540,6 +540,14 @@ void QgsVectorLayerProperties::syncToLayer()
mScaleVisibilityGroupBox->setChecked( mLayer->hasScaleBasedVisibility() );
mScaleRangeWidget->setMapCanvas( mCanvas );

mUseReferenceScaleGroupBox->setChecked( mLayer->renderer() && mLayer->renderer()->referenceScale() > 0 );
mReferenceScaleWidget->setShowCurrentScaleButton( true );
mReferenceScaleWidget->setMapCanvas( mCanvas );
if ( mUseReferenceScaleGroupBox->isChecked() )
mReferenceScaleWidget->setScale( mLayer->renderer()->referenceScale() );
else if ( mCanvas )
mReferenceScaleWidget->setScale( mCanvas->scale() );

// get simplify drawing configuration
const QgsVectorSimplifyMethod &simplifyMethod = mLayer->simplifyMethod();
mSimplifyDrawingGroupBox->setChecked( simplifyMethod.simplifyHints() != QgsVectorSimplifyMethod::NoSimplification );
@@ -805,7 +813,10 @@ void QgsVectorLayerProperties::apply()
mLayer->setSimplifyMethod( simplifyMethod );

if ( mLayer->renderer() )
{
mLayer->renderer()->setForceRasterRender( mForceRasterCheckBox->isChecked() );
mLayer->renderer()->setReferenceScale( mUseReferenceScaleGroupBox->isChecked() ? mReferenceScaleWidget->scale() : -1 );
}

mLayer->setAutoRefreshInterval( mRefreshLayerIntervalSpinBox->value() * 1000.0 );
mLayer->setAutoRefreshEnabled( mRefreshLayerCheckBox->isChecked() );
@@ -363,7 +363,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
<number>12</number>
</property>
<widget class="QWidget" name="mOptsPage_Information">
<layout class="QVBoxLayout" name="verticalLayout_5">
@@ -440,7 +440,7 @@
<x>0</x>
<y>0</y>
<width>653</width>
<height>681</height>
<height>679</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
@@ -757,7 +757,7 @@ border-radius: 2px;</string>
<x>0</x>
<y>0</y>
<width>653</width>
<height>681</height>
<height>679</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
@@ -974,7 +974,7 @@ border-radius: 2px;</string>
<x>0</x>
<y>0</y>
<width>653</width>
<height>681</height>
<height>679</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
@@ -1369,7 +1369,7 @@ border-radius: 2px;</string>
<x>0</x>
<y>0</y>
<width>653</width>
<height>681</height>
<height>679</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@@ -1570,8 +1570,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>695</width>
<height>667</height>
<width>689</width>
<height>665</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
@@ -1723,6 +1723,58 @@ border-radius: 2px;</string>
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mUseReferenceScaleGroupBox">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="title">
<string>Fixed Reference Scale</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="syncGroup" stdset="0">
<string notr="true">vectorgeneral</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Reference scale</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsScaleWidget" name="mReferenceScaleWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If set, the reference scale indicates the map scale at which symbology and labeling sizes which uses paper-based units (such as millimeters or points) relate to. The sizes will be scaled accordingly whenever the map is viewed at a different scale.&lt;/p&gt;&lt;p&gt;For instance, a line layer using a 2mm wide line with a 1:2000 reference scale set will be rendered using 4mm wide lines when the map is viewed at 1:1000.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mForceRasterCheckBox">
<property name="text">
@@ -2062,8 +2114,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>639</width>
<height>769</height>
<width>343</width>
<height>800</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@@ -2639,6 +2691,12 @@ border-radius: 2px;</string>
<header>qgsvectorlayerlegendwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScaleWidget</class>
<extends>QWidget</extends>
<header>qgsscalewidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mSearchLineEdit</tabstop>
@@ -2679,6 +2737,8 @@ border-radius: 2px;</string>
<tabstop>mSimplifyAlgorithmComboBox</tabstop>
<tabstop>mSimplifyDrawingAtProvider</tabstop>
<tabstop>mSimplifyMaximumScaleComboBox</tabstop>
<tabstop>mUseReferenceScaleGroupBox</tabstop>
<tabstop>mReferenceScaleWidget</tabstop>
<tabstop>mForceRasterCheckBox</tabstop>
<tabstop>mRefreshLayerCheckBox</tabstop>
<tabstop>mRefreshLayerIntervalSpinBox</tabstop>
@@ -2707,6 +2767,7 @@ border-radius: 2px;</string>
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>

0 comments on commit ed75524

Please sign in to comment.