mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
Enable snapping whatever the scale when limit to scale is off. Also fix style.
This commit is contained in:
parent
b484caee81
commit
2346718ac7
@ -265,6 +265,36 @@ Returns the tolerance
|
||||
void setTolerance( double tolerance );
|
||||
%Docstring
|
||||
Sets the tolerance
|
||||
%End
|
||||
|
||||
double minScale() const;
|
||||
%Docstring
|
||||
Returns the min scale
|
||||
%End
|
||||
|
||||
void setMinScale( double pMinScale );
|
||||
%Docstring
|
||||
Sets the min scale
|
||||
%End
|
||||
|
||||
double maxScale() const;
|
||||
%Docstring
|
||||
Returns the max scale
|
||||
%End
|
||||
|
||||
void setMaxScale( double pMaxScale );
|
||||
%Docstring
|
||||
Set the max scale
|
||||
%End
|
||||
|
||||
bool limitToScale() const;
|
||||
%Docstring
|
||||
Returns limit to scale
|
||||
%End
|
||||
|
||||
void setLimitToScale( bool pLimitSnapping );
|
||||
%Docstring
|
||||
Set limit to scale
|
||||
%End
|
||||
|
||||
QgsTolerance::UnitType units() const;
|
||||
|
@ -107,7 +107,7 @@ QWidget *QgsSnappingLayerDelegate::createEditor( QWidget *parent, const QStyleOp
|
||||
minLimitSp->setMinimum( 0.0 );
|
||||
minLimitSp->setMaximum( 99999999.990000 );
|
||||
minLimitSp->setToolTip( tr( "Min Scale" ) );
|
||||
minLimitSp->setSpecialValueText("NULL");
|
||||
minLimitSp->setSpecialValueText( "NULL" );
|
||||
return minLimitSp;
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ QWidget *QgsSnappingLayerDelegate::createEditor( QWidget *parent, const QStyleOp
|
||||
maxLimitSp->setMinimum( 0.0 );
|
||||
maxLimitSp->setMaximum( 99999999.990000 );
|
||||
maxLimitSp->setToolTip( tr( "Max Scale" ) );
|
||||
maxLimitSp->setSpecialValueText("NULL");
|
||||
maxLimitSp->setSpecialValueText( "NULL" );
|
||||
return maxLimitSp;
|
||||
}
|
||||
|
||||
@ -628,7 +628,7 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con
|
||||
{
|
||||
if ( role == Qt::DisplayRole )
|
||||
{
|
||||
if( ls.minScale() <= 0.0)
|
||||
if ( ls.minScale() <= 0.0 )
|
||||
{
|
||||
return QString( "NULL" );
|
||||
}
|
||||
@ -648,7 +648,7 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con
|
||||
{
|
||||
if ( role == Qt::DisplayRole )
|
||||
{
|
||||
if( ls.maxScale() <= 0.0 )
|
||||
if ( ls.maxScale() <= 0.0 )
|
||||
{
|
||||
return QString( "NULL" );
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
|
||||
mMinScaleSpinBox->setMinimum( 0.0 );
|
||||
mMinScaleSpinBox->setToolTip( tr( "Min scale on which snapping is enabled" ) );
|
||||
mMinScaleSpinBox->setObjectName( QStringLiteral( "SnappingMinScaleSpinBox" ) );
|
||||
mMinScaleSpinBox->setSpecialValueText("NULL");
|
||||
mMinScaleSpinBox->setSpecialValueText( "NULL" );
|
||||
connect( mMinScaleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSnappingWidget::changeMinScale );
|
||||
|
||||
mMaxScaleSpinBox = new QDoubleSpinBox();
|
||||
@ -189,7 +189,7 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
|
||||
mMaxScaleSpinBox->setMinimum( 0.0 );
|
||||
mMaxScaleSpinBox->setToolTip( tr( "Max scale on which snapping is enabled" ) );
|
||||
mMaxScaleSpinBox->setObjectName( QStringLiteral( "SnappingMaxScaleSpinBox" ) );
|
||||
mMaxScaleSpinBox->setSpecialValueText("NULL");
|
||||
mMaxScaleSpinBox->setSpecialValueText( "NULL" );
|
||||
connect( mMaxScaleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSnappingWidget::changeMaxScale );
|
||||
|
||||
|
||||
@ -447,11 +447,7 @@ void QgsSnappingWidget::projectSnapSettingsChanged()
|
||||
mMaxScaleSpinBox->setValue( config.maxScale() );
|
||||
}
|
||||
|
||||
mLimitToScale->setChecked(config.limitToScale());
|
||||
/*if( mLimitToScale->isChecked() != config.limitToScale() )
|
||||
{
|
||||
mLimitToScale->setCheckState( config.limitToScale() ? Qt::Checked : Qt::Unchecked );
|
||||
}*/
|
||||
mLimitToScale->setChecked( config.limitToScale() );
|
||||
|
||||
if ( config.intersectionSnapping() != mIntersectionSnappingAction->isChecked() )
|
||||
{
|
||||
@ -519,8 +515,8 @@ void QgsSnappingWidget::changeMaxScale( double pMaxScale )
|
||||
void QgsSnappingWidget::changeLimitToScale( bool enabled )
|
||||
{
|
||||
mConfig.setLimitToScale( enabled );
|
||||
mMinScaleSpinBox->setEnabled(mConfig.limitToScale());
|
||||
mMaxScaleSpinBox->setEnabled(mConfig.limitToScale());
|
||||
mMinScaleSpinBox->setEnabled( mConfig.limitToScale() );
|
||||
mMaxScaleSpinBox->setEnabled( mConfig.limitToScale() );
|
||||
mProject->setSnappingConfig( mConfig );
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
|
||||
|
||||
void changeMaxScale( double pMaxScale );
|
||||
|
||||
void changeLimitToScale(bool enabled);
|
||||
void changeLimitToScale( bool enabled );
|
||||
|
||||
void changeUnit( int idx );
|
||||
|
||||
@ -151,7 +151,7 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
|
||||
QAction *mCentroidAction = nullptr;
|
||||
QAction *mMiddleAction = nullptr;
|
||||
QDoubleSpinBox *mToleranceSpinBox = nullptr;
|
||||
QAction* mLimitToScale = nullptr;
|
||||
QAction *mLimitToScale = nullptr;
|
||||
QDoubleSpinBox *mMinScaleSpinBox = nullptr;
|
||||
QDoubleSpinBox *mMaxScaleSpinBox = nullptr;
|
||||
QAction *mToleranceAction = nullptr; // hide widget does not work on toolbar, action needed
|
||||
|
@ -655,7 +655,7 @@ double QgsSnappingConfig::minScale() const
|
||||
return mMinScale;
|
||||
}
|
||||
|
||||
void QgsSnappingConfig::setMinScale(double pMinScale)
|
||||
void QgsSnappingConfig::setMinScale( double pMinScale )
|
||||
{
|
||||
mMinScale = pMinScale;
|
||||
}
|
||||
@ -665,7 +665,7 @@ double QgsSnappingConfig::maxScale() const
|
||||
return mMaxScale;
|
||||
}
|
||||
|
||||
void QgsSnappingConfig::setMaxScale(double pMaxScale)
|
||||
void QgsSnappingConfig::setMaxScale( double pMaxScale )
|
||||
{
|
||||
mMaxScale = pMaxScale;
|
||||
}
|
||||
|
@ -296,19 +296,20 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPointXY &pointMap,
|
||||
QList<LayerConfigIterator> filteredConfigs;
|
||||
|
||||
bool inRangeGlobal = ( mSnappingConfig.minScale() <= 0.0 || mMapSettings.scale() >= mSnappingConfig.minScale() )
|
||||
&& ( mSnappingConfig.maxScale() <= 0.0 || mMapSettings.scale() <= mSnappingConfig.maxScale() );
|
||||
&& ( mSnappingConfig.maxScale() <= 0.0 || mMapSettings.scale() <= mSnappingConfig.maxScale() );
|
||||
|
||||
for ( LayerConfigIterator it = mLayers.begin(); it != mLayers.end(); ++it )
|
||||
{
|
||||
const LayerConfig &layerConfig = *it;
|
||||
QgsSnappingConfig::IndividualLayerSettings layerSettings = mSnappingConfig.individualLayerSettings( layerConfig.layer );
|
||||
|
||||
//Default value for layer config means it is not set (appears NULL)
|
||||
//Default value for layer config means it is not set ( appears NULL ) layerSpecificRange <- false
|
||||
bool layerSpecificRange = layerSettings.minScale() > 0.0 || layerSettings.maxScale() > 0.0;
|
||||
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) )
|
||||
//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
|
||||
if ( !mSnappingConfig.limitToScale() || ( ( !layerSpecificRange && inRangeGlobal ) || ( layerSpecificRange && inRangeLayer ) ) )
|
||||
{
|
||||
double tolerance = QgsTolerance::toleranceInProjectUnits( layerConfig.tolerance, layerConfig.layer, mMapSettings, layerConfig.unit );
|
||||
layers << qMakePair( layerConfig.layer, _areaOfInterest( pointMap, tolerance ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user