Skip to content
Permalink
Browse files

Invert th meaning of min scale and max scale to be coherent with othe…

…r 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.
  • Loading branch information
obrix authored and mhugo committed Apr 15, 2020
1 parent 64caa4c commit 44fec550d5e9e95c1ce6f5d1f28febebadeda7de
@@ -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
@@ -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;
}

@@ -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 );

@@ -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;
@@ -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

0 comments on commit 44fec55

Please sign in to comment.
You can’t perform that action at this time.