mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
Various small reworks :
* better documentation * translation on non translated string * Grey out column min and max of individual layer snapping settings when snapping limit on scale is disabled. Force the refresh when rowChanged is called even if the individual settings are the same to enable/disable immediately the columns when the snapping limit on scale button is pushed.
This commit is contained in:
parent
30a52ac55e
commit
f56e0f51c1
@ -73,7 +73,7 @@ This is a container of advanced configuration (per layer) of the snapping of the
|
||||
%End
|
||||
public:
|
||||
|
||||
IndividualLayerSettings( bool enabled, SnappingType type, double tolerance, QgsTolerance::UnitType units, double minScale, double maxScale ) /Deprecated/;
|
||||
IndividualLayerSettings( bool enabled, SnappingType type, double tolerance, QgsTolerance::UnitType units ) /Deprecated/;
|
||||
%Docstring
|
||||
IndividualLayerSettings
|
||||
|
||||
|
@ -278,6 +278,13 @@ Qt::ItemFlags QgsSnappingLayerTreeModel::flags( const QModelIndex &idx ) const
|
||||
return Qt::NoItemFlags;
|
||||
}
|
||||
}
|
||||
else if( idx.column() == MaxScaleColumn || idx.column() == MinScaleColumn )
|
||||
{
|
||||
if( mProject->snappingConfig().limitToScale() )
|
||||
{
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsEditable;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsEditable;
|
||||
@ -381,7 +388,7 @@ void QgsSnappingLayerTreeModel::hasRowchanged( QgsLayerTreeNode *node, const QHa
|
||||
{
|
||||
emit dataChanged( QModelIndex(), idx );
|
||||
}
|
||||
if ( oldSettings.value( vl ) != mProject->snappingConfig().individualLayerSettings().value( vl ) )
|
||||
else
|
||||
{
|
||||
mIndividualLayerSettings.insert( vl, mProject->snappingConfig().individualLayerSettings().value( vl ) );
|
||||
emit dataChanged( idx, index( idx.row(), columnCount( idx ) - 1 ) );
|
||||
@ -637,7 +644,7 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con
|
||||
{
|
||||
if ( ls.minScale() <= 0.0 )
|
||||
{
|
||||
return QString( "not set" );
|
||||
return QString( tr( "not set" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -657,7 +664,7 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con
|
||||
{
|
||||
if ( ls.maxScale() <= 0.0 )
|
||||
{
|
||||
return QString( "not set" );
|
||||
return QString( tr( "not set" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -186,10 +186,10 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
|
||||
connect( mMaxScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsSnappingWidget::changeMaxScale );
|
||||
|
||||
|
||||
mLimitToScale = new QAction( tr( "Toggle Snapping limit on scale" ), this );
|
||||
mLimitToScale = new QAction( tr( "Toggle scale dependent snapping" ), this );
|
||||
mLimitToScale->setCheckable( true );
|
||||
mLimitToScale->setIcon( QIcon( QgsApplication::getThemeIcon( "/mIconSnappingOnScale.svg" ) ) );
|
||||
mLimitToScale->setObjectName( QStringLiteral( "EnableSnappinLimitOnScaleAction" ) );
|
||||
mLimitToScale->setObjectName( QStringLiteral( "EnableSnappingLimitOnScaleAction" ) );
|
||||
connect( mLimitToScale, &QAction::toggled, this, &QgsSnappingWidget::changeLimitToScale );
|
||||
|
||||
// units
|
||||
@ -472,10 +472,12 @@ void QgsSnappingWidget::toggleSnappingWidgets( bool enabled )
|
||||
mMinScaleWidget->setEnabled( enabled && mConfig.limitToScale() );
|
||||
mMaxScaleWidget->setEnabled( enabled && mConfig.limitToScale() );
|
||||
mUnitsComboBox->setEnabled( enabled );
|
||||
|
||||
if ( mEditAdvancedConfigAction )
|
||||
{
|
||||
mEditAdvancedConfigAction->setEnabled( enabled );
|
||||
}
|
||||
|
||||
if ( mAdvancedConfigWidget )
|
||||
{
|
||||
mAdvancedConfigWidget->setEnabled( enabled );
|
||||
|
@ -35,13 +35,11 @@ QgsSnappingConfig::IndividualLayerSettings::IndividualLayerSettings( bool enable
|
||||
, mMaxScale( maxScale )
|
||||
{}
|
||||
|
||||
QgsSnappingConfig::IndividualLayerSettings::IndividualLayerSettings( bool enabled, SnappingType type, double tolerance, QgsTolerance::UnitType units, double minScale, double maxScale )
|
||||
QgsSnappingConfig::IndividualLayerSettings::IndividualLayerSettings( bool enabled, SnappingType type, double tolerance, QgsTolerance::UnitType units )
|
||||
: mValid( true )
|
||||
, mEnabled( enabled )
|
||||
, mTolerance( tolerance )
|
||||
, mUnits( units )
|
||||
, mMinScale( minScale )
|
||||
, mMaxScale( maxScale )
|
||||
{
|
||||
Q_NOWARN_DEPRECATED_PUSH
|
||||
setType( type );
|
||||
|
@ -120,7 +120,7 @@ class CORE_EXPORT QgsSnappingConfig
|
||||
* \param maxScale 0.0 disable scale limit
|
||||
* \deprecated since QGIS 3.12 use the method with SnappingTypeFlag instead.
|
||||
*/
|
||||
Q_DECL_DEPRECATED IndividualLayerSettings( bool enabled, SnappingType type, double tolerance, QgsTolerance::UnitType units, double minScale, double maxScale ) SIP_DEPRECATED;
|
||||
Q_DECL_DEPRECATED IndividualLayerSettings( bool enabled, SnappingType type, double tolerance, QgsTolerance::UnitType units ) SIP_DEPRECATED;
|
||||
|
||||
/**
|
||||
* \brief IndividualLayerSettings
|
||||
@ -172,28 +172,52 @@ class CORE_EXPORT QgsSnappingConfig
|
||||
*/
|
||||
void setTypeFlag( QgsSnappingConfig::SnappingTypeFlag type );
|
||||
|
||||
//! Returns the tolerance
|
||||
/**!
|
||||
* Returns the tolerance
|
||||
* \since QGIS 3.12
|
||||
*/
|
||||
double tolerance() const;
|
||||
|
||||
//! Sets the tolerance
|
||||
/**
|
||||
* Sets the tolerance
|
||||
* \since QGIS 3.12
|
||||
*/
|
||||
void setTolerance( double tolerance );
|
||||
|
||||
//! Returns the type of units
|
||||
/**
|
||||
* Returns the type of units
|
||||
* \since QGIS 3.12
|
||||
*/
|
||||
QgsTolerance::UnitType units() const;
|
||||
|
||||
//! Sets the type of units
|
||||
/**
|
||||
* Sets the type of units
|
||||
* \since QGIS 3.12
|
||||
*/
|
||||
void setUnits( QgsTolerance::UnitType units );
|
||||
|
||||
//! Returns min scale on which snapping is limited
|
||||
/**
|
||||
* Returns min scale on which snapping is limited
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
double minScale() const;
|
||||
|
||||
//! Sets the min scale value on which snapping is used, 0.0 disable scale limit
|
||||
/**
|
||||
* Sets the min scale value on which snapping is used, 0.0 disable scale limit
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setMinScale( double p_minScale );
|
||||
|
||||
//! Returns max scale on which snapping is limite
|
||||
/**
|
||||
* Returns max scale on which snapping is limited
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
double maxScale() const;
|
||||
|
||||
//! Sets the max scale value on which snapping is used, 0.0 disable scale limit
|
||||
/**
|
||||
* Sets the max scale value on which snapping is used, 0.0 disable scale limit
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setMaxScale( double p_maxScale );
|
||||
|
||||
/**
|
||||
@ -265,22 +289,40 @@ class CORE_EXPORT QgsSnappingConfig
|
||||
//! Sets the tolerance
|
||||
void setTolerance( double tolerance );
|
||||
|
||||
//! Returns the min scale
|
||||
/**
|
||||
* Returns the min scale
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
double minScale() const;
|
||||
|
||||
//! Sets the min scale on which snapping is enabled, 0.0 disable scale limit
|
||||
/**
|
||||
* Sets the min scale on which snapping is enabled, 0.0 disable scale limit
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setMinScale( double pMinScale );
|
||||
|
||||
//! Returns the max scale
|
||||
/**
|
||||
* Returns the max scale
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
double maxScale() const;
|
||||
|
||||
//! Set the max scale on which snapping is enabled, 0.0 disable scale limit
|
||||
/**
|
||||
* Set the max scale on which snapping is enabled, 0.0 disable scale limit
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setMaxScale( double pMaxScale );
|
||||
|
||||
//! Returns limit to scale
|
||||
/**
|
||||
* Returns limit to scale
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
bool limitToScale() const;
|
||||
|
||||
//! Set limit to scale, true means snapping will be limited to the [minScale, maxScale] range
|
||||
/**
|
||||
* Set limit to scale, true means snapping will be limited to the [minScale, maxScale] range
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setLimitToScale( bool pLimitSnapping );
|
||||
|
||||
//! Returns the type of units
|
||||
|
@ -291,16 +291,14 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPointXY &pointMap,
|
||||
}
|
||||
else if ( mSnappingConfig.mode() == QgsSnappingConfig::AdvancedConfiguration )
|
||||
{
|
||||
typedef QList<LayerConfig>::const_iterator LayerConfigIterator;
|
||||
QList<LayerAndAreaOfInterest> layers;
|
||||
QList<LayerConfigIterator> filteredConfigs;
|
||||
QList<LayerConfig> 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 ( const LayerConfig &layerConfig : qgis::as_const( mLayers ))
|
||||
{
|
||||
const LayerConfig &layerConfig = *it;
|
||||
QgsSnappingConfig::IndividualLayerSettings layerSettings = mSnappingConfig.individualLayerSettings( layerConfig.layer );
|
||||
|
||||
//Default value for layer config means it is not set ( appears NULL ) layerSpecificRange <- false
|
||||
@ -313,7 +311,7 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPointXY &pointMap,
|
||||
{
|
||||
double tolerance = QgsTolerance::toleranceInProjectUnits( layerConfig.tolerance, layerConfig.layer, mMapSettings, layerConfig.unit );
|
||||
layers << qMakePair( layerConfig.layer, _areaOfInterest( pointMap, tolerance ) );
|
||||
filteredConfigs << it;
|
||||
filteredConfigs << layerConfig;
|
||||
}
|
||||
}
|
||||
prepareIndex( layers, relaxed );
|
||||
@ -322,9 +320,8 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPointXY &pointMap,
|
||||
QgsPointLocator::MatchList edges; // for snap on intersection
|
||||
double maxSnapIntTolerance = 0;
|
||||
|
||||
for ( LayerConfigIterator &it : filteredConfigs )
|
||||
for ( const LayerConfig &layerConfig : qgis::as_const( filteredConfigs ) )
|
||||
{
|
||||
const LayerConfig &layerConfig = *it;
|
||||
double tolerance = QgsTolerance::toleranceInProjectUnits( layerConfig.tolerance, layerConfig.layer, mMapSettings, layerConfig.unit );
|
||||
if ( QgsPointLocator *loc = locatorForLayerUsingStrategy( layerConfig.layer, pointMap, tolerance ) )
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ struct FilterExcludePoint : public QgsPointLocator::MatchFilter
|
||||
{
|
||||
explicit FilterExcludePoint( const QgsPointXY &p ) : mPoint( p ) {}
|
||||
|
||||
bool acceptMatch( const QgsPointLocator::Match &match ) override { return match.point() != mPoint; }
|
||||
bool acceptMatch( const QgsPointLocator::Match &match ) override { return match.point() != mPoint; }
|
||||
|
||||
QgsPointXY mPoint;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user