mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-09 00:08:52 -04:00
Add global config for snapping limit on scale (with action and icon to enable). Also use 0.0 for disabling value and display NULL to be more explicit.
This commit is contained in:
parent
7b4be2b7fa
commit
b484caee81
@ -684,6 +684,7 @@
|
|||||||
<file>themes/default/mIconSnappingArea.svg</file>
|
<file>themes/default/mIconSnappingArea.svg</file>
|
||||||
<file>themes/default/mIconSnappingCentroid.svg</file>
|
<file>themes/default/mIconSnappingCentroid.svg</file>
|
||||||
<file>themes/default/mIconSnappingMiddle.svg</file>
|
<file>themes/default/mIconSnappingMiddle.svg</file>
|
||||||
|
<file>themes/default/mIconSnappingOnScale.svg</file>
|
||||||
<file>themes/default/mIconSnappingVertex.svg</file>
|
<file>themes/default/mIconSnappingVertex.svg</file>
|
||||||
<file>themes/default/mIconSnappingSegment.svg</file>
|
<file>themes/default/mIconSnappingSegment.svg</file>
|
||||||
<file>themes/default/mIconTopologicalEditing.svg</file>
|
<file>themes/default/mIconTopologicalEditing.svg</file>
|
||||||
|
158
images/themes/default/mIconSnappingOnScale.svg
Normal file
158
images/themes/default/mIconSnappingOnScale.svg
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
width="24"
|
||||||
|
version="1.1"
|
||||||
|
id="svg7302"
|
||||||
|
sodipodi:docname="mIconSnapping.svg"
|
||||||
|
inkscape:version="0.92.3 (2405546, 2018-03-11)">
|
||||||
|
<metadata
|
||||||
|
id="metadata7308">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs7306" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1171"
|
||||||
|
id="namedview7304"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:showpageshadow="false"
|
||||||
|
inkscape:zoom="23.393298"
|
||||||
|
inkscape:cx="14.684039"
|
||||||
|
inkscape:cy="11.598263"
|
||||||
|
inkscape:window-x="1920"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg7302"
|
||||||
|
inkscape:snap-global="true" />
|
||||||
|
<path
|
||||||
|
d="m 13.178333,7.3757775 3.707633,3.8795835 c 2.42837,2.42837 -0.69923,5.643032 -3.334371,3.197319 l -3.900157,-3.550008 -2.116137,2.116137 4.10594,4.062746 0.304487,0.295282 c 2.01388,1.895018 5.296031,1.700951 7.371786,-0.435881 2.091969,-2.140268 2.281205,-5.47878 0.315809,-7.4422485 L 19.431056,9.2956512 15.29447,5.2596406 Z"
|
||||||
|
id="path7296"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#d00000;stroke:#860000;stroke-width:0.67199868;stroke-linecap:square;stroke-linejoin:round" />
|
||||||
|
<path
|
||||||
|
d="M 11.740021,13.228218 9.7592562,11.255364 8.0046724,13.006085 10.004126,15.00434 Z"
|
||||||
|
id="path7298"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#eeeeec;stroke-width:1.06720102" />
|
||||||
|
<path
|
||||||
|
d="M 17.324822,7.7284671 15.297296,5.7283353 13.628048,7.4016289 15.64716,9.4687692 Z"
|
||||||
|
id="path7300"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#eeeeec;stroke-width:1.06720102" />
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#860000;fill-opacity:1;stroke:none;stroke-width:3.14419723;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||||
|
id="rect7853"
|
||||||
|
width="18.76606"
|
||||||
|
height="0.67092407"
|
||||||
|
x="4.4457178"
|
||||||
|
y="3.381155" />
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#860000;fill-opacity:1;stroke:none;stroke-width:3.14419723;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||||
|
id="rect7853-0"
|
||||||
|
width="18.76606"
|
||||||
|
height="0.67092407"
|
||||||
|
x="4.4457178"
|
||||||
|
y="19.853975" />
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#860000;fill-opacity:1;stroke:none;stroke-width:7.77270412;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||||
|
id="rect7853-7"
|
||||||
|
width="3.3770342"
|
||||||
|
height="22.784304"
|
||||||
|
x="-3.8480341"
|
||||||
|
y="0.57448733"
|
||||||
|
transform="scale(-1,1)" />
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2.48809075;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||||
|
id="rect7853-6"
|
||||||
|
width="6.0701156"
|
||||||
|
height="1.2988601"
|
||||||
|
x="0.57448733"
|
||||||
|
y="-2.1595175"
|
||||||
|
transform="rotate(90)" />
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2.48809075;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||||
|
id="rect7853-6-0"
|
||||||
|
width="6.0701156"
|
||||||
|
height="1.2988601"
|
||||||
|
x="6.6446028"
|
||||||
|
y="-3.4583771"
|
||||||
|
transform="rotate(90)"
|
||||||
|
inkscape:transform-center-x="1.558632"
|
||||||
|
inkscape:transform-center-y="-2.6503317" />
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2.48809075;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||||
|
id="rect7853-6-0-1"
|
||||||
|
width="6.0701156"
|
||||||
|
height="1.2988601"
|
||||||
|
x="12.714718"
|
||||||
|
y="-2.1595175"
|
||||||
|
transform="rotate(90)"
|
||||||
|
inkscape:transform-center-x="1.5586321"
|
||||||
|
inkscape:transform-center-y="-2.6503317" />
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2.19980192;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||||
|
id="rect7853-6-0-1-0"
|
||||||
|
width="4.7449498"
|
||||||
|
height="1.2988601"
|
||||||
|
x="18.784834"
|
||||||
|
y="-3.4583778"
|
||||||
|
transform="rotate(90)"
|
||||||
|
inkscape:transform-center-x="1.558632"
|
||||||
|
inkscape:transform-center-y="-2.0717382" />
|
||||||
|
<g
|
||||||
|
id="g7964"
|
||||||
|
transform="translate(-18.851552,-7.2242912)"
|
||||||
|
style="stroke:#860000;stroke-opacity:1">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path7945"
|
||||||
|
d="M 31.120024,8.4827354 32.6803,10.043011"
|
||||||
|
style="fill:none;stroke:#860000;stroke-width:0.69999999;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path7945-2"
|
||||||
|
d="M 34.240576,8.4827354 32.6803,10.043011"
|
||||||
|
style="fill:none;stroke:#860000;stroke-width:0.69999999;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g7964-5"
|
||||||
|
transform="rotate(-180,23.254524,15.5916)"
|
||||||
|
style="stroke:#860000;stroke-opacity:1">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path7945-1"
|
||||||
|
d="M 31.120024,8.4827354 32.6803,10.043011"
|
||||||
|
style="fill:none;stroke:#860000;stroke-width:0.69999999;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path7945-2-9"
|
||||||
|
d="M 34.240576,8.4827354 32.6803,10.043011"
|
||||||
|
style="fill:none;stroke:#860000;stroke-width:0.69999999;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 6.7 KiB |
@ -104,9 +104,10 @@ QWidget *QgsSnappingLayerDelegate::createEditor( QWidget *parent, const QStyleOp
|
|||||||
{
|
{
|
||||||
QDoubleSpinBox *minLimitSp = new QDoubleSpinBox( parent );
|
QDoubleSpinBox *minLimitSp = new QDoubleSpinBox( parent );
|
||||||
minLimitSp->setDecimals( 5 );
|
minLimitSp->setDecimals( 5 );
|
||||||
minLimitSp->setMinimum( -1.0 );
|
minLimitSp->setMinimum( 0.0 );
|
||||||
minLimitSp->setMaximum( 99999999.990000 );
|
minLimitSp->setMaximum( 99999999.990000 );
|
||||||
minLimitSp->setToolTip( tr( "Min Scale" ) );
|
minLimitSp->setToolTip( tr( "Min Scale" ) );
|
||||||
|
minLimitSp->setSpecialValueText("NULL");
|
||||||
return minLimitSp;
|
return minLimitSp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,9 +115,10 @@ QWidget *QgsSnappingLayerDelegate::createEditor( QWidget *parent, const QStyleOp
|
|||||||
{
|
{
|
||||||
QDoubleSpinBox *maxLimitSp = new QDoubleSpinBox( parent );
|
QDoubleSpinBox *maxLimitSp = new QDoubleSpinBox( parent );
|
||||||
maxLimitSp->setDecimals( 5 );
|
maxLimitSp->setDecimals( 5 );
|
||||||
maxLimitSp->setMinimum( -1.0 );
|
maxLimitSp->setMinimum( 0.0 );
|
||||||
maxLimitSp->setMaximum( 99999999.990000 );
|
maxLimitSp->setMaximum( 99999999.990000 );
|
||||||
maxLimitSp->setToolTip( tr( "Max Scale" ) );
|
maxLimitSp->setToolTip( tr( "Max Scale" ) );
|
||||||
|
maxLimitSp->setSpecialValueText("NULL");
|
||||||
return maxLimitSp;
|
return maxLimitSp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,9 +627,16 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con
|
|||||||
if ( idx.column() == MinScaleColumn )
|
if ( idx.column() == MinScaleColumn )
|
||||||
{
|
{
|
||||||
if ( role == Qt::DisplayRole )
|
if ( role == Qt::DisplayRole )
|
||||||
|
{
|
||||||
|
if( ls.minScale() <= 0.0)
|
||||||
|
{
|
||||||
|
return QString( "NULL" );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return QString::number( ls.minScale() );
|
return QString::number( ls.minScale() );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( role == Qt::UserRole )
|
if ( role == Qt::UserRole )
|
||||||
{
|
{
|
||||||
@ -638,9 +647,16 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con
|
|||||||
if ( idx.column() == MaxScaleColumn )
|
if ( idx.column() == MaxScaleColumn )
|
||||||
{
|
{
|
||||||
if ( role == Qt::DisplayRole )
|
if ( role == Qt::DisplayRole )
|
||||||
|
{
|
||||||
|
if( ls.maxScale() <= 0.0 )
|
||||||
|
{
|
||||||
|
return QString( "NULL" );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return QString::number( ls.maxScale() );
|
return QString::number( ls.maxScale() );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( role == Qt::UserRole )
|
if ( role == Qt::UserRole )
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
#include "qgisapp.h"
|
#include "qgisapp.h"
|
||||||
#include "qgsapplication.h"
|
#include "qgsapplication.h"
|
||||||
@ -173,6 +174,31 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
|
|||||||
mToleranceSpinBox->setObjectName( QStringLiteral( "SnappingToleranceSpinBox" ) );
|
mToleranceSpinBox->setObjectName( QStringLiteral( "SnappingToleranceSpinBox" ) );
|
||||||
connect( mToleranceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSnappingWidget::changeTolerance );
|
connect( mToleranceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSnappingWidget::changeTolerance );
|
||||||
|
|
||||||
|
mMinScaleSpinBox = new QDoubleSpinBox();
|
||||||
|
mMinScaleSpinBox->setDecimals( 2 );
|
||||||
|
mMinScaleSpinBox->setMaximum( 99999999.990000 );
|
||||||
|
mMinScaleSpinBox->setMinimum( 0.0 );
|
||||||
|
mMinScaleSpinBox->setToolTip( tr( "Min scale on which snapping is enabled" ) );
|
||||||
|
mMinScaleSpinBox->setObjectName( QStringLiteral( "SnappingMinScaleSpinBox" ) );
|
||||||
|
mMinScaleSpinBox->setSpecialValueText("NULL");
|
||||||
|
connect( mMinScaleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSnappingWidget::changeMinScale );
|
||||||
|
|
||||||
|
mMaxScaleSpinBox = new QDoubleSpinBox();
|
||||||
|
mMaxScaleSpinBox->setDecimals( 2 );
|
||||||
|
mMaxScaleSpinBox->setMaximum( 99999999.990000 );
|
||||||
|
mMaxScaleSpinBox->setMinimum( 0.0 );
|
||||||
|
mMaxScaleSpinBox->setToolTip( tr( "Max scale on which snapping is enabled" ) );
|
||||||
|
mMaxScaleSpinBox->setObjectName( QStringLiteral( "SnappingMaxScaleSpinBox" ) );
|
||||||
|
mMaxScaleSpinBox->setSpecialValueText("NULL");
|
||||||
|
connect( mMaxScaleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSnappingWidget::changeMaxScale );
|
||||||
|
|
||||||
|
|
||||||
|
mLimitToScale = new QAction( tr( "Toggle Snapping limit on scale" ), this );
|
||||||
|
mLimitToScale->setCheckable( true );
|
||||||
|
mLimitToScale->setIcon( QIcon( QgsApplication::getThemeIcon( "/mIconSnappingOnScale.svg" ) ) );
|
||||||
|
mLimitToScale->setObjectName( QStringLiteral( "EnableSnappinLimitOnScaleAction" ) );
|
||||||
|
connect( mLimitToScale, &QAction::toggled, this, &QgsSnappingWidget::changeLimitToScale );
|
||||||
|
|
||||||
// units
|
// units
|
||||||
mUnitsComboBox = new QComboBox();
|
mUnitsComboBox = new QComboBox();
|
||||||
mUnitsComboBox->addItem( tr( "px" ), QgsTolerance::Pixels );
|
mUnitsComboBox->addItem( tr( "px" ), QgsTolerance::Pixels );
|
||||||
@ -261,6 +287,10 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
|
|||||||
mTypeAction = tb->addWidget( mTypeButton );
|
mTypeAction = tb->addWidget( mTypeButton );
|
||||||
mToleranceAction = tb->addWidget( mToleranceSpinBox );
|
mToleranceAction = tb->addWidget( mToleranceSpinBox );
|
||||||
mUnitAction = tb->addWidget( mUnitsComboBox );
|
mUnitAction = tb->addWidget( mUnitsComboBox );
|
||||||
|
tb->addAction( mLimitToScale );
|
||||||
|
mMinScaleAction = tb->addWidget( mMinScaleSpinBox );
|
||||||
|
mMaxScaleAction = tb->addWidget( mMaxScaleSpinBox );
|
||||||
|
|
||||||
tb->addAction( mTopologicalEditingAction );
|
tb->addAction( mTopologicalEditingAction );
|
||||||
tb->addAction( mIntersectionSnappingAction );
|
tb->addAction( mIntersectionSnappingAction );
|
||||||
tb->addAction( mEnableTracingAction );
|
tb->addAction( mEnableTracingAction );
|
||||||
@ -279,6 +309,12 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
|
|||||||
layout->addWidget( mTypeButton );
|
layout->addWidget( mTypeButton );
|
||||||
layout->addWidget( mToleranceSpinBox );
|
layout->addWidget( mToleranceSpinBox );
|
||||||
layout->addWidget( mUnitsComboBox );
|
layout->addWidget( mUnitsComboBox );
|
||||||
|
QToolButton *limitToScaleButton = new QToolButton();
|
||||||
|
limitToScaleButton->addAction( mLimitToScale );
|
||||||
|
limitToScaleButton->setDefaultAction( mLimitToScale );
|
||||||
|
layout->addWidget( limitToScaleButton );
|
||||||
|
layout->addWidget( mMinScaleSpinBox );
|
||||||
|
layout->addWidget( mMaxScaleSpinBox );
|
||||||
|
|
||||||
QToolButton *topoButton = new QToolButton();
|
QToolButton *topoButton = new QToolButton();
|
||||||
topoButton->addAction( mTopologicalEditingAction );
|
topoButton->addAction( mTopologicalEditingAction );
|
||||||
@ -401,12 +437,29 @@ void QgsSnappingWidget::projectSnapSettingsChanged()
|
|||||||
mToleranceSpinBox->setValue( config.tolerance() );
|
mToleranceSpinBox->setValue( config.tolerance() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( mMinScaleSpinBox->value() != config.minScale() )
|
||||||
|
{
|
||||||
|
mMinScaleSpinBox->setValue( config.minScale() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mMaxScaleSpinBox->value() != config.maxScale() )
|
||||||
|
{
|
||||||
|
mMaxScaleSpinBox->setValue( config.maxScale() );
|
||||||
|
}
|
||||||
|
|
||||||
|
mLimitToScale->setChecked(config.limitToScale());
|
||||||
|
/*if( mLimitToScale->isChecked() != config.limitToScale() )
|
||||||
|
{
|
||||||
|
mLimitToScale->setCheckState( config.limitToScale() ? Qt::Checked : Qt::Unchecked );
|
||||||
|
}*/
|
||||||
|
|
||||||
if ( config.intersectionSnapping() != mIntersectionSnappingAction->isChecked() )
|
if ( config.intersectionSnapping() != mIntersectionSnappingAction->isChecked() )
|
||||||
{
|
{
|
||||||
mIntersectionSnappingAction->setChecked( config.intersectionSnapping() );
|
mIntersectionSnappingAction->setChecked( config.intersectionSnapping() );
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSnappingWidgets( config.enabled() );
|
toggleSnappingWidgets( config.enabled() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsSnappingWidget::projectTopologicalEditingChanged()
|
void QgsSnappingWidget::projectTopologicalEditingChanged()
|
||||||
@ -429,6 +482,9 @@ void QgsSnappingWidget::toggleSnappingWidgets( bool enabled )
|
|||||||
mModeButton->setEnabled( enabled );
|
mModeButton->setEnabled( enabled );
|
||||||
mTypeButton->setEnabled( enabled );
|
mTypeButton->setEnabled( enabled );
|
||||||
mToleranceSpinBox->setEnabled( enabled );
|
mToleranceSpinBox->setEnabled( enabled );
|
||||||
|
mLimitToScale->setEnabled( enabled );
|
||||||
|
mMinScaleSpinBox->setEnabled( enabled && mConfig.limitToScale() );
|
||||||
|
mMaxScaleSpinBox->setEnabled( enabled && mConfig.limitToScale() );
|
||||||
mUnitsComboBox->setEnabled( enabled );
|
mUnitsComboBox->setEnabled( enabled );
|
||||||
if ( mEditAdvancedConfigAction )
|
if ( mEditAdvancedConfigAction )
|
||||||
{
|
{
|
||||||
@ -448,6 +504,26 @@ void QgsSnappingWidget::changeTolerance( double tolerance )
|
|||||||
mProject->setSnappingConfig( mConfig );
|
mProject->setSnappingConfig( mConfig );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsSnappingWidget::changeMinScale( double pMinScale )
|
||||||
|
{
|
||||||
|
mConfig.setMinScale( pMinScale );
|
||||||
|
mProject->setSnappingConfig( mConfig );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsSnappingWidget::changeMaxScale( double pMaxScale )
|
||||||
|
{
|
||||||
|
mConfig.setMaxScale( pMaxScale );
|
||||||
|
mProject->setSnappingConfig( mConfig );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsSnappingWidget::changeLimitToScale( bool enabled )
|
||||||
|
{
|
||||||
|
mConfig.setLimitToScale( enabled );
|
||||||
|
mMinScaleSpinBox->setEnabled(mConfig.limitToScale());
|
||||||
|
mMaxScaleSpinBox->setEnabled(mConfig.limitToScale());
|
||||||
|
mProject->setSnappingConfig( mConfig );
|
||||||
|
}
|
||||||
|
|
||||||
void QgsSnappingWidget::changeUnit( int idx )
|
void QgsSnappingWidget::changeUnit( int idx )
|
||||||
{
|
{
|
||||||
QgsTolerance::UnitType unit = static_cast<QgsTolerance::UnitType>( mUnitsComboBox->itemData( idx ).toInt() );
|
QgsTolerance::UnitType unit = static_cast<QgsTolerance::UnitType>( mUnitsComboBox->itemData( idx ).toInt() );
|
||||||
@ -564,6 +640,9 @@ void QgsSnappingWidget::modeChanged()
|
|||||||
mToleranceAction->setVisible( !advanced );
|
mToleranceAction->setVisible( !advanced );
|
||||||
mUnitAction->setVisible( !advanced );
|
mUnitAction->setVisible( !advanced );
|
||||||
mEditAdvancedConfigAction->setVisible( advanced );
|
mEditAdvancedConfigAction->setVisible( advanced );
|
||||||
|
mMaxScaleAction->setVisible( advanced );
|
||||||
|
mMinScaleAction->setVisible( advanced );
|
||||||
|
mLimitToScale->setVisible( advanced );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -574,6 +653,9 @@ void QgsSnappingWidget::modeChanged()
|
|||||||
{
|
{
|
||||||
mAdvancedConfigWidget->setVisible( advanced );
|
mAdvancedConfigWidget->setVisible( advanced );
|
||||||
}
|
}
|
||||||
|
mMinScaleSpinBox->setVisible( advanced );
|
||||||
|
mMaxScaleSpinBox->setVisible( advanced );
|
||||||
|
mLimitToScale->setVisible( advanced );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ class QDoubleSpinBox;
|
|||||||
class QFont;
|
class QFont;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
|
class QCheckBox;
|
||||||
|
|
||||||
class QgsDoubleSpinBox;
|
class QgsDoubleSpinBox;
|
||||||
class QgsFloatingWidget;
|
class QgsFloatingWidget;
|
||||||
@ -100,6 +101,12 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
|
|||||||
|
|
||||||
void changeTolerance( double tolerance );
|
void changeTolerance( double tolerance );
|
||||||
|
|
||||||
|
void changeMinScale( double pMinScale );
|
||||||
|
|
||||||
|
void changeMaxScale( double pMaxScale );
|
||||||
|
|
||||||
|
void changeLimitToScale(bool enabled);
|
||||||
|
|
||||||
void changeUnit( int idx );
|
void changeUnit( int idx );
|
||||||
|
|
||||||
void enableTopologicalEditing( bool enabled );
|
void enableTopologicalEditing( bool enabled );
|
||||||
@ -144,7 +151,13 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
|
|||||||
QAction *mCentroidAction = nullptr;
|
QAction *mCentroidAction = nullptr;
|
||||||
QAction *mMiddleAction = nullptr;
|
QAction *mMiddleAction = nullptr;
|
||||||
QDoubleSpinBox *mToleranceSpinBox = nullptr;
|
QDoubleSpinBox *mToleranceSpinBox = nullptr;
|
||||||
|
QAction* mLimitToScale = nullptr;
|
||||||
|
QDoubleSpinBox *mMinScaleSpinBox = nullptr;
|
||||||
|
QDoubleSpinBox *mMaxScaleSpinBox = nullptr;
|
||||||
QAction *mToleranceAction = nullptr; // hide widget does not work on toolbar, action needed
|
QAction *mToleranceAction = nullptr; // hide widget does not work on toolbar, action needed
|
||||||
|
QAction *mLimitToScaleAction = nullptr;
|
||||||
|
QAction *mMinScaleAction = nullptr;
|
||||||
|
QAction *mMaxScaleAction = nullptr;
|
||||||
QComboBox *mUnitsComboBox = nullptr;
|
QComboBox *mUnitsComboBox = nullptr;
|
||||||
QAction *mUnitAction = nullptr; // hide widget does not work on toolbar, action needed
|
QAction *mUnitAction = nullptr; // hide widget does not work on toolbar, action needed
|
||||||
QAction *mTopologicalEditingAction = nullptr;
|
QAction *mTopologicalEditingAction = nullptr;
|
||||||
|
@ -181,7 +181,10 @@ bool QgsSnappingConfig::operator==( const QgsSnappingConfig &other ) const
|
|||||||
&& mTolerance == other.mTolerance
|
&& mTolerance == other.mTolerance
|
||||||
&& mUnits == other.mUnits
|
&& mUnits == other.mUnits
|
||||||
&& mIntersectionSnapping == other.mIntersectionSnapping
|
&& mIntersectionSnapping == other.mIntersectionSnapping
|
||||||
&& mIndividualLayerSettings == other.mIndividualLayerSettings;
|
&& mIndividualLayerSettings == other.mIndividualLayerSettings
|
||||||
|
&& mLimitToScale == other.mLimitToScale
|
||||||
|
&& mMinScale == other.mMinScale
|
||||||
|
&& mMaxScale == other.mMaxScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsSnappingConfig::reset()
|
void QgsSnappingConfig::reset()
|
||||||
@ -204,6 +207,9 @@ void QgsSnappingConfig::reset()
|
|||||||
mMode = mode;
|
mMode = mode;
|
||||||
mType = type;
|
mType = type;
|
||||||
mTolerance = tolerance;
|
mTolerance = tolerance;
|
||||||
|
mLimitToScale = false;
|
||||||
|
mMinScale = 0.0;
|
||||||
|
mMaxScale = 0.0;
|
||||||
// do not allow unit to be "layer" if not in advanced configuration
|
// do not allow unit to be "layer" if not in advanced configuration
|
||||||
if ( mUnits == QgsTolerance::LayerUnits && mMode != AdvancedConfiguration )
|
if ( mUnits == QgsTolerance::LayerUnits && mMode != AdvancedConfiguration )
|
||||||
{
|
{
|
||||||
@ -225,7 +231,7 @@ void QgsSnappingConfig::reset()
|
|||||||
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
|
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
|
||||||
if ( vl )
|
if ( vl )
|
||||||
{
|
{
|
||||||
mIndividualLayerSettings.insert( vl, IndividualLayerSettings( enabled, type, tolerance, units, -1.0, -1.0 ) );
|
mIndividualLayerSettings.insert( vl, IndividualLayerSettings( enabled, type, tolerance, units, 0.0, 0.0 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -373,7 +379,10 @@ bool QgsSnappingConfig::operator!=( const QgsSnappingConfig &other ) const
|
|||||||
|| mType != other.mType
|
|| mType != other.mType
|
||||||
|| mTolerance != other.mTolerance
|
|| mTolerance != other.mTolerance
|
||||||
|| mUnits != other.mUnits
|
|| mUnits != other.mUnits
|
||||||
|| mIndividualLayerSettings != other.mIndividualLayerSettings;
|
|| mIndividualLayerSettings != other.mIndividualLayerSettings
|
||||||
|
|| mLimitToScale != other.mLimitToScale
|
||||||
|
|| mMinScale != other.mMinScale
|
||||||
|
|| mMaxScale != other.mMaxScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsSnappingConfig::readProject( const QDomDocument &doc )
|
void QgsSnappingConfig::readProject( const QDomDocument &doc )
|
||||||
@ -437,6 +446,15 @@ void QgsSnappingConfig::readProject( const QDomDocument &doc )
|
|||||||
if ( snapSettingsElem.hasAttribute( QStringLiteral( "tolerance" ) ) )
|
if ( snapSettingsElem.hasAttribute( QStringLiteral( "tolerance" ) ) )
|
||||||
mTolerance = snapSettingsElem.attribute( QStringLiteral( "tolerance" ) ).toDouble();
|
mTolerance = snapSettingsElem.attribute( QStringLiteral( "tolerance" ) ).toDouble();
|
||||||
|
|
||||||
|
if ( snapSettingsElem.hasAttribute( QStringLiteral( "limitToScale" ) ) )
|
||||||
|
mLimitToScale = snapSettingsElem.attribute( QStringLiteral( "limitToScale" ) ) == QLatin1String( "1" );
|
||||||
|
|
||||||
|
if ( snapSettingsElem.hasAttribute( QStringLiteral( "minScale" ) ) )
|
||||||
|
mMinScale = snapSettingsElem.attribute( QStringLiteral( "minScale" ) ).toDouble();
|
||||||
|
|
||||||
|
if ( snapSettingsElem.hasAttribute( QStringLiteral( "maxScale" ) ) )
|
||||||
|
mMaxScale = snapSettingsElem.attribute( QStringLiteral( "maxScale" ) ).toDouble();
|
||||||
|
|
||||||
if ( snapSettingsElem.hasAttribute( QStringLiteral( "unit" ) ) )
|
if ( snapSettingsElem.hasAttribute( QStringLiteral( "unit" ) ) )
|
||||||
mUnits = ( QgsTolerance::UnitType )snapSettingsElem.attribute( QStringLiteral( "unit" ) ).toInt();
|
mUnits = ( QgsTolerance::UnitType )snapSettingsElem.attribute( QStringLiteral( "unit" ) ).toInt();
|
||||||
|
|
||||||
@ -488,6 +506,9 @@ void QgsSnappingConfig::writeProject( QDomDocument &doc )
|
|||||||
snapSettingsElem.setAttribute( QStringLiteral( "tolerance" ), mTolerance );
|
snapSettingsElem.setAttribute( QStringLiteral( "tolerance" ), mTolerance );
|
||||||
snapSettingsElem.setAttribute( QStringLiteral( "unit" ), static_cast<int>( mUnits ) );
|
snapSettingsElem.setAttribute( QStringLiteral( "unit" ), static_cast<int>( mUnits ) );
|
||||||
snapSettingsElem.setAttribute( QStringLiteral( "intersection-snapping" ), QString::number( mIntersectionSnapping ) );
|
snapSettingsElem.setAttribute( QStringLiteral( "intersection-snapping" ), QString::number( mIntersectionSnapping ) );
|
||||||
|
snapSettingsElem.setAttribute( QStringLiteral( "limitToScale" ), QString::number( mLimitToScale ) );
|
||||||
|
snapSettingsElem.setAttribute( QStringLiteral( "minScale" ), mMinScale );
|
||||||
|
snapSettingsElem.setAttribute( QStringLiteral( "maxScale" ), mMaxScale );
|
||||||
|
|
||||||
QDomElement ilsElement = doc.createElement( QStringLiteral( "individual-layer-settings" ) );
|
QDomElement ilsElement = doc.createElement( QStringLiteral( "individual-layer-settings" ) );
|
||||||
QHash<QgsVectorLayer *, IndividualLayerSettings>::const_iterator layerIt = mIndividualLayerSettings.constBegin();
|
QHash<QgsVectorLayer *, IndividualLayerSettings>::const_iterator layerIt = mIndividualLayerSettings.constBegin();
|
||||||
@ -524,7 +545,7 @@ bool QgsSnappingConfig::addLayers( const QList<QgsMapLayer *> &layers )
|
|||||||
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
|
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
|
||||||
if ( vl && vl->isSpatial() )
|
if ( vl && vl->isSpatial() )
|
||||||
{
|
{
|
||||||
mIndividualLayerSettings.insert( vl, IndividualLayerSettings( enabled, type, tolerance, units, -1.0, -1.0 ) );
|
mIndividualLayerSettings.insert( vl, IndividualLayerSettings( enabled, type, tolerance, units, 0.0, 0.0 ) );
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -599,7 +620,7 @@ void QgsSnappingConfig::readLegacySettings()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
mIndividualLayerSettings.insert( vlayer, IndividualLayerSettings( *enabledIt == QLatin1String( "enabled" ), t, tolIt->toDouble(), static_cast<QgsTolerance::UnitType>( tolUnitIt->toInt() ), -1.0, -1.0 ) );
|
mIndividualLayerSettings.insert( vlayer, IndividualLayerSettings( *enabledIt == QLatin1String( "enabled" ), t, tolIt->toDouble(), static_cast<QgsTolerance::UnitType>( tolUnitIt->toInt() ), 0.0, 0.0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString snapType = mProject->readEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/DefaultSnapType" ), QStringLiteral( "off" ) );
|
QString snapType = mProject->readEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/DefaultSnapType" ), QStringLiteral( "off" ) );
|
||||||
@ -628,3 +649,37 @@ void QgsSnappingConfig::setProject( QgsProject *project )
|
|||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double QgsSnappingConfig::minScale() const
|
||||||
|
{
|
||||||
|
return mMinScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsSnappingConfig::setMinScale(double pMinScale)
|
||||||
|
{
|
||||||
|
mMinScale = pMinScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
double QgsSnappingConfig::maxScale() const
|
||||||
|
{
|
||||||
|
return mMaxScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsSnappingConfig::setMaxScale(double pMaxScale)
|
||||||
|
{
|
||||||
|
mMaxScale = pMaxScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QgsSnappingConfig::limitToScale() const
|
||||||
|
{
|
||||||
|
return mLimitToScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsSnappingConfig::setLimitToScale( bool pLimitSnapping )
|
||||||
|
{
|
||||||
|
mLimitToScale = pLimitSnapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,6 +265,24 @@ class CORE_EXPORT QgsSnappingConfig
|
|||||||
//! Sets the tolerance
|
//! Sets the tolerance
|
||||||
void setTolerance( double tolerance );
|
void setTolerance( double tolerance );
|
||||||
|
|
||||||
|
//! Returns the min scale
|
||||||
|
double minScale() const;
|
||||||
|
|
||||||
|
//! Sets the min scale
|
||||||
|
void setMinScale( double pMinScale );
|
||||||
|
|
||||||
|
//! Returns the max scale
|
||||||
|
double maxScale() const;
|
||||||
|
|
||||||
|
//! Set the max scale
|
||||||
|
void setMaxScale( double pMaxScale );
|
||||||
|
|
||||||
|
//! Returns limit to scale
|
||||||
|
bool limitToScale() const;
|
||||||
|
|
||||||
|
//! Set limit to scale
|
||||||
|
void setLimitToScale( bool pLimitSnapping );
|
||||||
|
|
||||||
//! Returns the type of units
|
//! Returns the type of units
|
||||||
QgsTolerance::UnitType units() const;
|
QgsTolerance::UnitType units() const;
|
||||||
|
|
||||||
@ -395,6 +413,9 @@ class CORE_EXPORT QgsSnappingConfig
|
|||||||
SnappingMode mMode = ActiveLayer;
|
SnappingMode mMode = ActiveLayer;
|
||||||
SnappingTypeFlag mType = VertexFlag;
|
SnappingTypeFlag mType = VertexFlag;
|
||||||
double mTolerance = 0.0;
|
double mTolerance = 0.0;
|
||||||
|
bool mLimitToScale = false;
|
||||||
|
double mMinScale = 0.0;
|
||||||
|
double mMaxScale = 0.0;
|
||||||
QgsTolerance::UnitType mUnits = QgsTolerance::ProjectUnits;
|
QgsTolerance::UnitType mUnits = QgsTolerance::ProjectUnits;
|
||||||
bool mIntersectionSnapping = false;
|
bool mIntersectionSnapping = false;
|
||||||
|
|
||||||
|
@ -295,14 +295,20 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPointXY &pointMap,
|
|||||||
QList<LayerAndAreaOfInterest> layers;
|
QList<LayerAndAreaOfInterest> layers;
|
||||||
QList<LayerConfigIterator> filteredConfigs;
|
QList<LayerConfigIterator> filteredConfigs;
|
||||||
|
|
||||||
|
bool inRangeGlobal = ( mSnappingConfig.minScale() <= 0.0 || mMapSettings.scale() >= mSnappingConfig.minScale() )
|
||||||
|
&& ( mSnappingConfig.maxScale() <= 0.0 || mMapSettings.scale() <= mSnappingConfig.maxScale() );
|
||||||
|
|
||||||
for ( LayerConfigIterator it = mLayers.begin(); it != mLayers.end(); ++it )
|
for ( LayerConfigIterator it = mLayers.begin(); it != mLayers.end(); ++it )
|
||||||
{
|
{
|
||||||
const LayerConfig &layerConfig = *it;
|
const LayerConfig &layerConfig = *it;
|
||||||
QgsSnappingConfig::IndividualLayerSettings layerSettings = mSnappingConfig.individualLayerSettings( layerConfig.layer );
|
QgsSnappingConfig::IndividualLayerSettings layerSettings = mSnappingConfig.individualLayerSettings( layerConfig.layer );
|
||||||
|
|
||||||
//Add the layers only if scale is in specified range. Value < 0.0 disable the limit.
|
//Default value for layer config means it is not set (appears NULL)
|
||||||
bool inRange = ( layerSettings.minScale() < 0.0 || mMapSettings.scale() >= layerSettings.minScale() ) && ( layerSettings.maxScale() < 0.0 || mMapSettings.scale() <= layerSettings.maxScale() );
|
bool layerSpecificRange = layerSettings.minScale() > 0.0 || layerSettings.maxScale() > 0.0;
|
||||||
if ( inRange )
|
bool inRangeLayer = ( layerSettings.minScale() < 0.0 || mMapSettings.scale() >= layerSettings.minScale() ) && ( layerSettings.maxScale() < 0.0 || mMapSettings.scale() <= layerSettings.maxScale() );
|
||||||
|
|
||||||
|
//If no per layer config is set use the global one otherwise use the layer config if it is set
|
||||||
|
if ( ( !layerSpecificRange && inRangeGlobal ) || ( layerSpecificRange && inRangeLayer) )
|
||||||
{
|
{
|
||||||
double tolerance = QgsTolerance::toleranceInProjectUnits( layerConfig.tolerance, layerConfig.layer, mMapSettings, layerConfig.unit );
|
double tolerance = QgsTolerance::toleranceInProjectUnits( layerConfig.tolerance, layerConfig.layer, mMapSettings, layerConfig.unit );
|
||||||
layers << qMakePair( layerConfig.layer, _areaOfInterest( pointMap, tolerance ) );
|
layers << qMakePair( layerConfig.layer, _areaOfInterest( pointMap, tolerance ) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user