Invert th meaning of min scale and max scale to be coherent with other qgis feature. Minimum scale is the most zoomed out scale, maximum scale the most zoomed in. Enrich the tooltip to be more explicit. Should fix issue #35786.

This commit is contained in:
obrix 2020-04-15 15:45:00 +02:00 committed by Hugo Mercier
parent 64caa4c03d
commit 44fec550d5
5 changed files with 15 additions and 12 deletions

View File

@ -285,7 +285,7 @@ Sets the tolerance
double minimumScale() const;
%Docstring
Returns the min scale
Returns the min scale (i.e. most \"zoomed out\" scale)
.. versionadded:: 3.14
%End
@ -299,7 +299,7 @@ Sets the min scale on which snapping is enabled, 0.0 disable scale limit
double maximumScale() const;
%Docstring
Returns the max scale
Returns the max scale (i.e. most \"zoomed in\" scale)
.. versionadded:: 3.14
%End

View File

@ -104,14 +104,14 @@ QWidget *QgsSnappingLayerDelegate::createEditor( QWidget *parent, const QStyleOp
if ( index.column() == QgsSnappingLayerTreeModel::MinScaleColumn )
{
QgsScaleWidget *minLimitSp = new QgsScaleWidget( parent );
minLimitSp->setToolTip( tr( "Min Scale" ) );
minLimitSp->setToolTip( tr( "Minimum scale from which snapping is enabled (i.e. most \"zoomed out\" scale)" ) );
return minLimitSp;
}
if ( index.column() == QgsSnappingLayerTreeModel::MaxScaleColumn )
{
QgsScaleWidget *maxLimitSp = new QgsScaleWidget( parent );
maxLimitSp->setToolTip( tr( "Max Scale" ) );
maxLimitSp->setToolTip( tr( "Maximum scale up to which snapping is enabled (i.e. most \"zoomed in\" scale)" ) );
return maxLimitSp;
}

View File

@ -195,12 +195,12 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
connect( mToleranceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSnappingWidget::changeTolerance );
mMinScaleWidget = new QgsScaleWidget();
mMinScaleWidget->setToolTip( tr( "Minimum scale from which snapping is enabled" ) );
mMinScaleWidget->setToolTip( tr( "Minimum scale from which snapping is enabled (i.e. most \"zoomed out\" scale)" ) );
mMinScaleWidget->setObjectName( QStringLiteral( "SnappingMinScaleSpinBox" ) );
connect( mMinScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsSnappingWidget::changeMinScale );
mMaxScaleWidget = new QgsScaleWidget();
mMaxScaleWidget->setToolTip( tr( "Maximum scale up to which snapping is enabled" ) );
mMaxScaleWidget->setToolTip( tr( "Maximum scale up to which snapping is enabled (i.e. most \"zoomed in\" scale)" ) );
mMaxScaleWidget->setObjectName( QStringLiteral( "SnappingMaxScaleSpinBox" ) );
connect( mMaxScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsSnappingWidget::changeMaxScale );

View File

@ -288,7 +288,7 @@ class CORE_EXPORT QgsSnappingConfig
void setTolerance( double tolerance );
/**
* Returns the min scale
* Returns the min scale (i.e. most \"zoomed out\" scale)
* \since QGIS 3.14
*/
double minimumScale() const;
@ -300,7 +300,7 @@ class CORE_EXPORT QgsSnappingConfig
void setMinimumScale( double minScale );
/**
* Returns the max scale
* Returns the max scale (i.e. most \"zoomed in\" scale)
* \since QGIS 3.14
*/
double maximumScale() const;

View File

@ -294,15 +294,18 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPointXY &pointMap,
QList<LayerAndAreaOfInterest> layers;
QList<LayerConfig> filteredConfigs;
bool inRangeGlobal = ( mSnappingConfig.minimumScale() <= 0.0 || mMapSettings.scale() >= mSnappingConfig.minimumScale() )
&& ( mSnappingConfig.maximumScale() <= 0.0 || mMapSettings.scale() <= mSnappingConfig.maximumScale() );
//maximum scale is the one with smallest denominator
//minimum scale is the one with highest denominator
//So : maxscale < range on which snapping is enabled < minscale
bool inRangeGlobal = ( mSnappingConfig.minimumScale() <= 0.0 || mMapSettings.scale() <= mSnappingConfig.minimumScale() )
&& ( mSnappingConfig.maximumScale() <= 0.0 || mMapSettings.scale() >= mSnappingConfig.maximumScale() );
for ( const LayerConfig &layerConfig : qgis::as_const( mLayers ) )
{
QgsSnappingConfig::IndividualLayerSettings layerSettings = mSnappingConfig.individualLayerSettings( layerConfig.layer );
bool inRangeLayer = ( layerSettings.minimumScale() <= 0.0 || mMapSettings.scale() >= layerSettings.minimumScale() )
&& ( layerSettings.maximumScale() <= 0.0 || mMapSettings.scale() <= layerSettings.maximumScale() );
bool inRangeLayer = ( layerSettings.minimumScale() <= 0.0 || mMapSettings.scale() <= layerSettings.minimumScale() )
&& ( layerSettings.maximumScale() <= 0.0 || mMapSettings.scale() >= layerSettings.maximumScale() );
//If limit to scale is disabled, snapping activated on all layer
//If no per layer config is set use the global one, otherwise use the layer config