[needs-docs] Use standard scale widgets and terminology for labeling

Also unify API with other scale API.

Fix #16349
This commit is contained in:
Nyall Dawson 2017-06-09 12:46:41 +10:00
parent b2e102d2f5
commit e413463755
14 changed files with 356 additions and 278 deletions

View File

@ -1751,6 +1751,8 @@ and setDataDefinedProperties() instead.
- readXml() and writeXml() now expect a reference to QgsReadWriteContext.
- fromLayer() has been reoved. Labeling is read/written in QgsAbstractVectorLayerLabeling and its subclasses.
- angleOffset is now in degrees clockwise. QGIS 2.x used degrees counterclockwise.
- scaleMin and scaleMax were removed. Use minimumScale and maximumScale instead (note that the definition
of these are the opposite of scaleMin/scaleMax).
QgsPanelWidgetStack {#qgis_api_break_3_0_QgsPanelWidgetStack}

View File

@ -376,7 +376,7 @@ Opacity, from 0 (transparent) to 1.0 (opaque)
double maximumScale;
%Docstring
The maximum map scale (i.e. most "zoomed in" scale) at which the layer will be visible.
The maximum map scale (i.e. most "zoomed in" scale) at which the diagrams will be visible.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
A scale of 0 indicates no maximum scale visibility.
.. seealso:: minimumScale
@ -384,7 +384,7 @@ Opacity, from 0 (transparent) to 1.0 (opaque)
double minimumScale;
%Docstring
The minimum map scale (i.e. most "zoomed out" scale) at which the layer will be visible.
The minimum map scale (i.e. most "zoomed out" scale) at which the diagrams will be visible.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
A scale of 0 indicates no minimum scale visibility.
.. seealso:: maximumScale

View File

@ -248,7 +248,9 @@ class QgsPalLayerSettings
// rendering
ScaleVisibility,
MinScale,
MinimumScale,
MaxScale,
MaximumScale,
FontLimitPixel,
FontMinPixel,
FontMaxPixel,
@ -362,8 +364,22 @@ Label rotation, in degrees clockwise
bool scaleVisibility;
int scaleMin;
int scaleMax;
double maximumScale;
%Docstring
The maximum map scale (i.e. most "zoomed in" scale) at which the labels will be visible.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
A scale of 0 indicates no maximum scale visibility.
.. seealso:: minimumScale
%End
double minimumScale;
%Docstring
The minimum map scale (i.e. most "zoomed out" scale) at which the labels will be visible.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
A scale of 0 indicates no minimum scale visibility.
.. seealso:: maximumScale
%End
bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)

View File

@ -73,6 +73,11 @@ QgsLabelingGui::QgsLabelingGui( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas,
mFieldExpressionWidget->registerExpressionContextGenerator( this );
mMinScaleWidget->setMapCanvas( mapCanvas );
mMinScaleWidget->setShowCurrentScaleButton( true );
mMaxScaleWidget->setMapCanvas( mapCanvas );
mMaxScaleWidget->setShowCurrentScaleButton( true );
setLayer( layer );
}
@ -243,8 +248,8 @@ void QgsLabelingGui::setLayer( QgsMapLayer *mapLayer )
setPreviewBackground( lyr.previewBkgrdColor );
mScaleBasedVisibilityChkBx->setChecked( lyr.scaleVisibility );
mScaleBasedVisibilityMinSpnBx->setValue( lyr.scaleMin );
mScaleBasedVisibilityMaxSpnBx->setValue( lyr.scaleMax );
mMinScaleWidget->setScale( lyr.minimumScale );
mMaxScaleWidget->setScale( lyr.maximumScale );
mFormatNumChkBx->setChecked( lyr.formatNumbers );
mFormatNumDecimalsSpnBx->setValue( lyr.decimals );
@ -385,8 +390,8 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
lyr.mergeLines = chkMergeLines->isChecked();
lyr.scaleVisibility = mScaleBasedVisibilityChkBx->isChecked();
lyr.scaleMin = mScaleBasedVisibilityMinSpnBx->value();
lyr.scaleMax = mScaleBasedVisibilityMaxSpnBx->value();
lyr.minimumScale = mMinScaleWidget->scale();
lyr.maximumScale = mMaxScaleWidget->scale();
lyr.useSubstitutions = mCheckBoxSubstituteText->isChecked();
lyr.substitutions = mSubstitutions;
@ -553,9 +558,9 @@ void QgsLabelingGui::populateDataDefinedButtons()
"Value of 0 disables the specific limit." );
registerDataDefinedButton( mScaleBasedVisibilityDDBtn, QgsPalLayerSettings::ScaleVisibility );
mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
registerDataDefinedButton( mScaleBasedVisibilityMinDDBtn, QgsPalLayerSettings::MinScale );
registerDataDefinedButton( mScaleBasedVisibilityMinDDBtn, QgsPalLayerSettings::MinimumScale );
mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
registerDataDefinedButton( mScaleBasedVisibilityMaxDDBtn, QgsPalLayerSettings::MaxScale );
registerDataDefinedButton( mScaleBasedVisibilityMaxDDBtn, QgsPalLayerSettings::MaximumScale );
mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
registerDataDefinedButton( mFontLimitPixelDDBtn, QgsPalLayerSettings::FontLimitPixel );

View File

@ -44,6 +44,8 @@ QgsLabelPropertyDialog::QgsLabelPropertyDialog( const QString &layerId, const QS
QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/ChangeLabelProps/geometry" ) ).toByteArray() );
connect( mMinScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsLabelPropertyDialog::minScaleChanged );
connect( mMaxScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsLabelPropertyDialog::maxScaleChanged );
}
QgsLabelPropertyDialog::~QgsLabelPropertyDialog()
@ -52,6 +54,14 @@ QgsLabelPropertyDialog::~QgsLabelPropertyDialog()
settings.setValue( QStringLiteral( "Windows/ChangeLabelProps/geometry" ), saveGeometry() );
}
void QgsLabelPropertyDialog::setMapCanvas( QgsMapCanvas *canvas )
{
mMinScaleWidget->setMapCanvas( canvas );
mMinScaleWidget->setShowCurrentScaleButton( true );
mMaxScaleWidget->setMapCanvas( canvas );
mMaxScaleWidget->setShowCurrentScaleButton( true );
}
void QgsLabelPropertyDialog::on_buttonBox_clicked( QAbstractButton *button )
{
if ( buttonBox->buttonRole( button ) == QDialogButtonBox::ApplyRole )
@ -143,8 +153,8 @@ void QgsLabelPropertyDialog::init( const QString &layerId, const QString &provid
mShowLabelChkbx->setChecked( true );
mFontColorButton->setColor( format.color() );
mBufferColorButton->setColor( buffer.color() );
mMinScaleSpinBox->setValue( layerSettings.scaleMin );
mMaxScaleSpinBox->setValue( layerSettings.scaleMax );
mMinScaleWidget->setScale( layerSettings.minimumScale );
mMaxScaleWidget->setScale( layerSettings.maximumScale );
mHaliComboBox->setCurrentIndex( mHaliComboBox->findData( "Left" ) );
mValiComboBox->setCurrentIndex( mValiComboBox->findData( "Bottom" ) );
mFontColorButton->setColorDialogTitle( tr( "Font color" ) );
@ -166,8 +176,8 @@ void QgsLabelPropertyDialog::disableGuiElements()
{
mShowLabelChkbx->setEnabled( false );
mAlwaysShowChkbx->setEnabled( false );
mMinScaleSpinBox->setEnabled( false );
mMaxScaleSpinBox->setEnabled( false );
mMinScaleWidget->setEnabled( false );
mMaxScaleWidget->setEnabled( false );
mFontFamilyCmbBx->setEnabled( false );
mFontStyleCmbBx->setEnabled( false );
mFontUnderlineBtn->setEnabled( false );
@ -190,8 +200,8 @@ void QgsLabelPropertyDialog::blockElementSignals( bool block )
{
mShowLabelChkbx->blockSignals( block );
mAlwaysShowChkbx->blockSignals( block );
mMinScaleSpinBox->blockSignals( block );
mMaxScaleSpinBox->blockSignals( block );
mMinScaleWidget->blockSignals( block );
mMaxScaleWidget->blockSignals( block );
mFontFamilyCmbBx->blockSignals( block );
mFontStyleCmbBx->blockSignals( block );
mFontUnderlineBtn->blockSignals( block );
@ -249,21 +259,21 @@ void QgsLabelPropertyDialog::setDataDefinedValues( QgsVectorLayer *vlayer )
case QgsPalLayerSettings::AlwaysShow:
mAlwaysShowChkbx->setChecked( result.toBool() );
break;
case QgsPalLayerSettings::MinScale:
case QgsPalLayerSettings::MinimumScale:
{
int minScale = result.toInt( &ok );
double minScale = result.toDouble( &ok );
if ( ok )
{
mMinScaleSpinBox->setValue( minScale );
mMinScaleWidget->setScale( minScale );
}
break;
}
case QgsPalLayerSettings::MaxScale:
case QgsPalLayerSettings::MaximumScale:
{
int maxScale = result.toInt( &ok );
double maxScale = result.toDouble( &ok );
if ( ok )
{
mMaxScaleSpinBox->setValue( maxScale );
mMaxScaleWidget->setScale( maxScale );
}
break;
}
@ -378,11 +388,11 @@ void QgsLabelPropertyDialog::enableDataDefinedWidgets( QgsVectorLayer *vlayer )
case QgsPalLayerSettings::AlwaysShow:
mAlwaysShowChkbx->setEnabled( true );
break;
case QgsPalLayerSettings::MinScale:
mMinScaleSpinBox->setEnabled( true );
case QgsPalLayerSettings::MinimumScale:
mMinScaleWidget->setEnabled( true );
break;
case QgsPalLayerSettings::MaxScale:
mMaxScaleSpinBox->setEnabled( true );
case QgsPalLayerSettings::MaximumScale:
mMaxScaleWidget->setEnabled( true );
break;
case QgsPalLayerSettings::BufferSize:
mBufferSizeSpinBox->setEnabled( true );
@ -504,14 +514,14 @@ void QgsLabelPropertyDialog::on_mAlwaysShowChkbx_toggled( bool chkd )
insertChangedValue( QgsPalLayerSettings::AlwaysShow, ( chkd ? 1 : 0 ) );
}
void QgsLabelPropertyDialog::on_mMinScaleSpinBox_valueChanged( int i )
void QgsLabelPropertyDialog::minScaleChanged( double scale )
{
insertChangedValue( QgsPalLayerSettings::MinScale, i );
insertChangedValue( QgsPalLayerSettings::MinimumScale, scale );
}
void QgsLabelPropertyDialog::on_mMaxScaleSpinBox_valueChanged( int i )
void QgsLabelPropertyDialog::maxScaleChanged( double scale )
{
insertChangedValue( QgsPalLayerSettings::MaxScale, i );
insertChangedValue( QgsPalLayerSettings::MaximumScale, scale );
}
void QgsLabelPropertyDialog::on_mLabelDistanceSpinBox_valueChanged( double d )

View File

@ -36,6 +36,8 @@ class APP_EXPORT QgsLabelPropertyDialog: public QDialog, private Ui::QgsLabelPro
//! Returns properties changed by the user
const QgsAttributeMap &changedProperties() const { return mChangedProperties; }
void setMapCanvas( QgsMapCanvas *canvas );
signals:
/** Emitted when dialog settings are applied
@ -47,8 +49,8 @@ class APP_EXPORT QgsLabelPropertyDialog: public QDialog, private Ui::QgsLabelPro
void on_buttonBox_clicked( QAbstractButton *button );
void on_mShowLabelChkbx_toggled( bool chkd );
void on_mAlwaysShowChkbx_toggled( bool chkd );
void on_mMinScaleSpinBox_valueChanged( int i );
void on_mMaxScaleSpinBox_valueChanged( int i );
void minScaleChanged( double scale );
void maxScaleChanged( double scale );
void on_mLabelDistanceSpinBox_valueChanged( double d );
void on_mXCoordSpinBox_valueChanged( double d );
void on_mYCoordSpinBox_valueChanged( double d );

View File

@ -65,6 +65,7 @@ void QgsMapToolChangeLabelProperties::canvasReleaseEvent( QgsMapMouseEvent *e )
mCurrentLabel.pos.featureId,
mCurrentLabel.pos.labelFont,
labeltext, nullptr );
d.setMapCanvas( canvas() );
connect( &d, &QgsLabelPropertyDialog::applied, this, &QgsMapToolChangeLabelProperties::dialogPropertiesApplied );
if ( d.exec() == QDialog::Accepted )

View File

@ -426,7 +426,7 @@ class CORE_EXPORT QgsDiagramSettings
bool scaleBasedVisibility;
/**
* The maximum map scale (i.e. most "zoomed in" scale) at which the layer will be visible.
* The maximum map scale (i.e. most "zoomed in" scale) at which the diagrams will be visible.
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
* A scale of 0 indicates no maximum scale visibility.
* \see minimumScale
@ -434,7 +434,7 @@ class CORE_EXPORT QgsDiagramSettings
double maximumScale = 0;
/**
* The minimum map scale (i.e. most "zoomed out" scale) at which the layer will be visible.
* The minimum map scale (i.e. most "zoomed out" scale) at which the diagrams will be visible.
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
* A scale of 0 indicates no minimum scale visibility.
* \see maximumScale

View File

@ -216,6 +216,8 @@ void QgsPalLayerSettings::initPropertyDefinitions()
{ QgsPalLayerSettings::ScaleVisibility, QgsPropertyDefinition( "ScaleVisibility", QObject::tr( "Scale based visibility" ), QgsPropertyDefinition::Boolean ) },
{ QgsPalLayerSettings::MinScale, QgsPropertyDefinition( "MinScale", QObject::tr( "Minimum scale (denominator)" ), QgsPropertyDefinition::Double ) },
{ QgsPalLayerSettings::MaxScale, QgsPropertyDefinition( "MaxScale", QObject::tr( "Maximum scale (denominator)" ), QgsPropertyDefinition::Double ) },
{ QgsPalLayerSettings::MinimumScale, QgsPropertyDefinition( "MinimumScale", QObject::tr( "Minimum scale (denominator)" ), QgsPropertyDefinition::Double ) },
{ QgsPalLayerSettings::MaximumScale, QgsPropertyDefinition( "MaximumScale", QObject::tr( "Maximum scale (denominator)" ), QgsPropertyDefinition::Double ) },
{ QgsPalLayerSettings::FontLimitPixel, QgsPropertyDefinition( "FontLimitPixel", QObject::tr( "Limit font pixel size" ), QgsPropertyDefinition::Boolean ) },
{ QgsPalLayerSettings::FontMinPixel, QgsPropertyDefinition( "FontMinPixel", QObject::tr( "Minimum pixel size" ), QgsPropertyDefinition::IntegerPositive ) },
@ -281,8 +283,8 @@ QgsPalLayerSettings::QgsPalLayerSettings()
// rendering
scaleVisibility = false;
scaleMin = 1;
scaleMax = 10000000;
maximumScale = 0.0;
minimumScale = 0.0;
fontLimitPixelSize = false;
fontMinPixelSize = 0; //trigger to turn it on by default for map unit labels
fontMaxPixelSize = 10000;
@ -369,8 +371,8 @@ QgsPalLayerSettings &QgsPalLayerSettings::operator=( const QgsPalLayerSettings &
// rendering
scaleVisibility = s.scaleVisibility;
scaleMin = s.scaleMin;
scaleMax = s.scaleMax;
maximumScale = s.maximumScale;
minimumScale = s.minimumScale;
fontLimitPixelSize = s.fontLimitPixelSize;
fontMinPixelSize = s.fontMinPixelSize;
fontMaxPixelSize = s.fontMaxPixelSize;
@ -635,22 +637,22 @@ void QgsPalLayerSettings::readFromLayerCustomProperties( QgsVectorLayer *layer )
}
// rendering
int scalemn = layer->customProperty( QStringLiteral( "labeling/scaleMin" ), QVariant( 0 ) ).toInt();
int scalemx = layer->customProperty( QStringLiteral( "labeling/scaleMax" ), QVariant( 0 ) ).toInt();
double scalemn = layer->customProperty( QStringLiteral( "labeling/scaleMin" ), QVariant( 0 ) ).toDouble();
double scalemx = layer->customProperty( QStringLiteral( "labeling/scaleMax" ), QVariant( 0 ) ).toDouble();
// fix for scale visibility limits being keyed off of just its values in the past (<2.0)
QVariant scalevis = layer->customProperty( QStringLiteral( "labeling/scaleVisibility" ), QVariant() );
if ( scalevis.isValid() )
{
scaleVisibility = scalevis.toBool();
scaleMin = scalemn;
scaleMax = scalemx;
maximumScale = scalemn;
minimumScale = scalemx;
}
else if ( scalemn > 0 || scalemx > 0 )
{
scaleVisibility = true;
scaleMin = scalemn;
scaleMax = scalemx;
maximumScale = scalemn;
minimumScale = scalemx;
}
else
{
@ -714,6 +716,17 @@ void QgsPalLayerSettings::readFromLayerCustomProperties( QgsVectorLayer *layer )
mDataDefinedProperties.setProperty( LabelRotation, QgsProperty::fromExpression( QStringLiteral( "360 - (%1)" ).arg( mDataDefinedProperties.property( Rotation ).asExpression() ) ) );
mDataDefinedProperties.setProperty( Rotation, QgsProperty() );
}
// older 2.x projects had min/max scale flipped - so change them here.
if ( mDataDefinedProperties.isActive( MinScale ) )
{
mDataDefinedProperties.setProperty( MaximumScale, mDataDefinedProperties.property( MinScale ) );
mDataDefinedProperties.setProperty( MinScale, QgsProperty() );
}
if ( mDataDefinedProperties.isActive( MaxScale ) )
{
mDataDefinedProperties.setProperty( MinimumScale, mDataDefinedProperties.property( MaxScale ) );
mDataDefinedProperties.setProperty( MaxScale, QgsProperty() );
}
}
void QgsPalLayerSettings::readXml( QDomElement &elem, const QgsReadWriteContext &context )
@ -817,8 +830,8 @@ void QgsPalLayerSettings::readXml( QDomElement &elem, const QgsReadWriteContext
drawLabels = renderingElem.attribute( QStringLiteral( "drawLabels" ), QStringLiteral( "1" ) ).toInt();
scaleMin = renderingElem.attribute( QStringLiteral( "scaleMin" ), QStringLiteral( "0" ) ).toInt();
scaleMax = renderingElem.attribute( QStringLiteral( "scaleMax" ), QStringLiteral( "0" ) ).toInt();
maximumScale = renderingElem.attribute( QStringLiteral( "scaleMin" ), QStringLiteral( "0" ) ).toDouble();
minimumScale = renderingElem.attribute( QStringLiteral( "scaleMax" ), QStringLiteral( "0" ) ).toDouble();
scaleVisibility = renderingElem.attribute( QStringLiteral( "scaleVisibility" ) ).toInt();
fontLimitPixelSize = renderingElem.attribute( QStringLiteral( "fontLimitPixelSize" ), QStringLiteral( "0" ) ).toInt();
@ -875,6 +888,17 @@ void QgsPalLayerSettings::readXml( QDomElement &elem, const QgsReadWriteContext
mDataDefinedProperties.setProperty( LabelRotation, QgsProperty::fromExpression( QStringLiteral( "360 - (%1)" ).arg( mDataDefinedProperties.property( Rotation ).asExpression() ) ) );
mDataDefinedProperties.setProperty( Rotation, QgsProperty() );
}
// older 2.x projects had min/max scale flipped - so change them here.
if ( mDataDefinedProperties.isActive( MinScale ) )
{
mDataDefinedProperties.setProperty( MaximumScale, mDataDefinedProperties.property( MinScale ) );
mDataDefinedProperties.setProperty( MinScale, QgsProperty() );
}
if ( mDataDefinedProperties.isActive( MaxScale ) )
{
mDataDefinedProperties.setProperty( MinimumScale, mDataDefinedProperties.property( MaxScale ) );
mDataDefinedProperties.setProperty( MaxScale, QgsProperty() );
}
}
@ -935,8 +959,8 @@ QDomElement QgsPalLayerSettings::writeXml( QDomDocument &doc, const QgsReadWrite
QDomElement renderingElem = doc.createElement( QStringLiteral( "rendering" ) );
renderingElem.setAttribute( QStringLiteral( "drawLabels" ), drawLabels );
renderingElem.setAttribute( QStringLiteral( "scaleVisibility" ), scaleVisibility );
renderingElem.setAttribute( QStringLiteral( "scaleMin" ), scaleMin );
renderingElem.setAttribute( QStringLiteral( "scaleMax" ), scaleMax );
renderingElem.setAttribute( QStringLiteral( "scaleMin" ), maximumScale );
renderingElem.setAttribute( QStringLiteral( "scaleMax" ), minimumScale );
renderingElem.setAttribute( QStringLiteral( "fontLimitPixelSize" ), fontLimitPixelSize );
renderingElem.setAttribute( QStringLiteral( "fontMinPixelSize" ), fontMinPixelSize );
renderingElem.setAttribute( QStringLiteral( "fontMaxPixelSize" ), fontMaxPixelSize );
@ -1147,23 +1171,8 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
if ( useScaleVisibility )
{
// data defined min scale?
context.expressionContext().setOriginalValueVariable( scaleMin );
double minScale = mDataDefinedProperties.valueAsDouble( QgsPalLayerSettings::MinScale, context.expressionContext(), scaleMin );
// scales closer than 1:1
if ( minScale < 0 )
{
minScale = 1 / qAbs( minScale );
}
if ( !qgsDoubleNear( minScale, 0.0 ) && context.rendererScale() < minScale )
{
return;
}
// data defined max scale?
context.expressionContext().setOriginalValueVariable( scaleMax );
double maxScale = mDataDefinedProperties.valueAsDouble( QgsPalLayerSettings::MaxScale, context.expressionContext(), scaleMax );
context.expressionContext().setOriginalValueVariable( maximumScale );
double maxScale = mDataDefinedProperties.valueAsDouble( QgsPalLayerSettings::MaximumScale, context.expressionContext(), maximumScale );
// scales closer than 1:1
if ( maxScale < 0 )
@ -1171,7 +1180,22 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
maxScale = 1 / qAbs( maxScale );
}
if ( !qgsDoubleNear( maxScale, 0.0 ) && context.rendererScale() > maxScale )
if ( !qgsDoubleNear( maxScale, 0.0 ) && context.rendererScale() < maxScale )
{
return;
}
// data defined max scale?
context.expressionContext().setOriginalValueVariable( minimumScale );
double minScale = mDataDefinedProperties.valueAsDouble( QgsPalLayerSettings::MinimumScale, context.expressionContext(), minimumScale );
// scales closer than 1:1
if ( minScale < 0 )
{
minScale = 1 / qAbs( minScale );
}
if ( !qgsDoubleNear( minScale, 0.0 ) && context.rendererScale() > minScale )
{
return;
}

View File

@ -334,7 +334,7 @@ class CORE_EXPORT QgsPalLayerSettings
ShadowRadius = 70,
ShadowRadiusUnits = 71,
ShadowTransparency = 72, //!< Shadow transparency (deprecated)
ShadowOpacity = 94, //!< Shadow opacity
ShadowOpacity = 95, //!< Shadow opacity
ShadowScale = 73,
ShadowColor = 74,
ShadowBlendMode = 75,
@ -354,7 +354,7 @@ class CORE_EXPORT QgsPalLayerSettings
Hali = 11, //!< Horizontal alignment for data defined label position (Left, Center, Right)
Vali = 12, //!< Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
Rotation = 14, //!< Label rotation (deprecated, for old project compatibility only)
LabelRotation = 96, //!< Label rotation (deprecated, for old project compatibility only)
LabelRotation = 96, //!< Label rotation
RepeatDistance = 84,
RepeatDistanceUnit = 86,
Priority = 87,
@ -362,8 +362,10 @@ class CORE_EXPORT QgsPalLayerSettings
// rendering
ScaleVisibility = 23,
MinScale = 16,
MaxScale = 17,
MinScale = 16, //!< Min scale (deprecated, for old project compatibility only)
MinimumScale = 97, //!< Minimum map scale (ie most "zoomed out")
MaxScale = 17, //!< Max scale (deprecated, for old project compatibility only)
MaximumScale = 98, //!< Maximum map scale (ie most "zoomed in")
FontLimitPixel = 24,
FontMinPixel = 25,
FontMaxPixel = 26,
@ -478,8 +480,22 @@ class CORE_EXPORT QgsPalLayerSettings
//-- rendering
bool scaleVisibility;
int scaleMin;
int scaleMax;
/**
* The maximum map scale (i.e. most "zoomed in" scale) at which the labels will be visible.
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
* A scale of 0 indicates no maximum scale visibility.
* \see minimumScale
*/
double maximumScale;
/**
* The minimum map scale (i.e. most "zoomed out" scale) at which the labels will be visible.
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
* A scale of 0 indicates no minimum scale visibility.
* \see maximumScale
*/
double minimumScale;
bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)

View File

@ -28,12 +28,12 @@ QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent )
QLabel *minLbl = new QLabel( tr( "Minimum (exclusive)" ), this );
minLbl->setWordWrap( true );
minLbl->setAlignment( Qt::AlignTop );
minLbl->setToolTip( tr( "Minimum scale, i.e. maximum scale denominator. "
minLbl->setToolTip( tr( "Minimum scale, i.e. most \"zoomed out\". "
"This limit is exclusive, that means the layer will not be displayed on this scale." ) );
QLabel *maxLbl = new QLabel( tr( "Maximum (inclusive)" ), this );
maxLbl->setWordWrap( true );
maxLbl->setAlignment( Qt::AlignTop );
maxLbl->setToolTip( tr( "Maximum scale, i.e. minimum scale denominator. "
maxLbl->setToolTip( tr( "Maximum scale, i.e. most \"zoomed in\". "
"This limit is inclusive, that means the layer will be displayed on this scale." ) );
mMinimumScaleIconLabel = new QLabel( this );

View File

@ -375,9 +375,9 @@ void QgsTextFormatWidget::initWidget()
<< mScaleBasedVisibilityChkBx
<< mScaleBasedVisibilityDDBtn
<< mScaleBasedVisibilityMaxDDBtn
<< mScaleBasedVisibilityMaxSpnBx
<< mMaxScaleWidget
<< mScaleBasedVisibilityMinDDBtn
<< mScaleBasedVisibilityMinSpnBx
<< mMinScaleWidget
<< mShadowBlendCmbBx
<< mShadowBlendDDBtn
<< mShadowColorBtn
@ -555,6 +555,10 @@ void QgsTextFormatWidget::connectValueChanged( const QList<QWidget *> &widgets,
{
connect( w, SIGNAL( opacityChanged( double ) ), this, slot );
}
else if ( QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
{
connect( w, SIGNAL( scaleChanged( double ) ), this, slot );
}
else if ( QgsUnitSelectionWidget *w = qobject_cast<QgsUnitSelectionWidget *>( widget ) )
{
connect( w, SIGNAL( changed() ), this, slot );

View File

@ -37,9 +37,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-391</y>
<y>0</y>
<width>417</width>
<height>689</height>
<height>680</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mLabelPropertiesLayout">
@ -65,37 +65,22 @@
</widget>
</item>
<item>
<widget class="QgsSpinBox" name="mMinScaleSpinBox">
<property name="prefix">
<string>Min </string>
<widget class="QgsScaleWidget" name="mMinScaleWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="showClearButton" stdset="0">
<bool>false</bool>
<property name="toolTip">
<string>Minimum scale, i.e. most &quot;zoomed out&quot;.</string>
</property>
</widget>
</item>
<item>
<widget class="QgsSpinBox" name="mMaxScaleSpinBox">
<property name="prefix">
<string>Max </string>
<widget class="QgsScaleWidget" name="mMaxScaleWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="value">
<number>10000000</number>
</property>
<property name="showClearButton" stdset="0">
<bool>false</bool>
<property name="toolTip">
<string>Minimum scale, i.e. most &quot;zoomed out&quot;.</string>
</property>
</widget>
</item>
@ -630,21 +615,11 @@
</widget>
<customwidgets>
<customwidget>
<class>QgsColorButton</class>
<extends>QToolButton</extends>
<header>qgscolorbutton.h</header>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsSpinBox</class>
<extends>QSpinBox</extends>
<header>qgsspinbox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
@ -652,21 +627,29 @@
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<class>QgsScaleWidget</class>
<extends>QWidget</extends>
<header>qgsscalewidget.h</header>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsColorButton</class>
<extends>QToolButton</extends>
<header>qgscolorbutton.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mLabelTextLineEdit</tabstop>
<tabstop>scrollArea</tabstop>
<tabstop>mDisplayGroupBox</tabstop>
<tabstop>mShowLabelChkbx</tabstop>
<tabstop>mMinScaleSpinBox</tabstop>
<tabstop>mMaxScaleSpinBox</tabstop>
<tabstop>mMinScaleWidget</tabstop>
<tabstop>mMaxScaleWidget</tabstop>
<tabstop>mAlwaysShowChkbx</tabstop>
<tabstop>mFontGroupBox</tabstop>
<tabstop>mFontFamilyCmbBx</tabstop>
<tabstop>mFontStyleCmbBx</tabstop>
<tabstop>mFontUnderlineBtn</tabstop>
@ -675,10 +658,8 @@
<tabstop>mFontItalicBtn</tabstop>
<tabstop>mFontSizeSpinBox</tabstop>
<tabstop>mFontColorButton</tabstop>
<tabstop>mBufferGroupBox</tabstop>
<tabstop>mBufferSizeSpinBox</tabstop>
<tabstop>mBufferColorButton</tabstop>
<tabstop>mPositionGroupBlox</tabstop>
<tabstop>mLabelDistanceSpinBox</tabstop>
<tabstop>mXCoordSpinBox</tabstop>
<tabstop>mYCoordSpinBox</tabstop>

View File

@ -29,7 +29,67 @@
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="5" column="0">
<item row="0" column="0">
<widget class="QFrame" name="frameLabelWith">
<layout class="QHBoxLayout" name="horizontalLayout_19">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Label with</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFieldExpressionWidget" name="mFieldExpressionWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QFrame" name="mLabelingFrame">
<property name="minimumSize">
<size>
@ -1406,7 +1466,7 @@ font-style: italic;</string>
<rect>
<x>0</x>
<y>0</y>
<width>452</width>
<width>359</width>
<height>410</height>
</rect>
</property>
@ -2041,8 +2101,8 @@ font-style: italic;</string>
<rect>
<x>0</x>
<y>0</y>
<width>466</width>
<height>322</height>
<width>302</width>
<height>317</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
@ -2392,8 +2452,8 @@ font-style: italic;</string>
<property name="geometry">
<rect>
<x>0</x>
<y>-308</y>
<width>459</width>
<y>0</y>
<width>458</width>
<height>778</height>
</rect>
</property>
@ -3206,8 +3266,8 @@ font-style: italic;</string>
<property name="geometry">
<rect>
<x>0</x>
<y>-105</y>
<width>452</width>
<y>0</y>
<width>311</width>
<height>470</height>
</rect>
</property>
@ -5315,7 +5375,7 @@ font-style: italic;</string>
<x>0</x>
<y>0</y>
<width>452</width>
<height>881</height>
<height>877</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
@ -5357,7 +5417,7 @@ font-style: italic;</string>
</sizepolicy>
</property>
<property name="text">
<string>Scale-based visibility</string>
<string>Scale dependent visibility</string>
</property>
</widget>
</item>
@ -5386,7 +5446,7 @@ font-style: italic;</string>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1,0">
<property name="leftMargin">
<number>20</number>
</property>
@ -5402,70 +5462,63 @@ font-style: italic;</string>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QgsSpinBox" name="mScaleBasedVisibilityMinSpnBx">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="1" column="1">
<widget class="QgsScaleWidget" name="mMaxScaleWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Value &amp;lt; 0 represents a scale closer than 1:1, e.g. -10 = 10:1.&lt;br&gt;Value of 0 disables the specific limit.</string>
<string>Maximum scale, i.e. most &quot;zoomed in&quot;.</string>
</property>
<property name="prefix">
<string>Minimum </string>
</property>
<property name="minimum">
<number>-999999999</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="showClearButton" stdset="0">
<bool>false</bool>
</widget>
</item>
<item row="1" column="2">
<widget class="QgsPropertyOverrideButton" name="mScaleBasedVisibilityMaxDDBtn">
<property name="text">
<string>…</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsScaleWidget" name="mMinScaleWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Minimum scale, i.e. most &quot;zoomed out&quot;.</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QgsPropertyOverrideButton" name="mScaleBasedVisibilityMinDDBtn">
<property name="text">
<string>…</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QgsSpinBox" name="mScaleBasedVisibilityMaxSpnBx">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>Value &amp;lt; 0 represents a scale closer than 1:1, e.g. -10 = 10:1.&lt;br&gt;Value of 0 disables the specific limit.</string>
<string>Minimum scale, i.e. most &quot;zoomed out&quot;.</string>
</property>
<property name="prefix">
<string>Maximum </string>
<property name="text">
<string/>
</property>
<property name="minimum">
<number>-999999999</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="value">
<number>10000000</number>
</property>
<property name="showClearButton" stdset="0">
<bool>false</bool>
<property name="pixmap">
<pixmap resource="../../images/images.qrc">:/images/themes/default/mActionZoomOut.svg</pixmap>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsPropertyOverrideButton" name="mScaleBasedVisibilityMaxDDBtn">
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="toolTip">
<string>Maximum scale, i.e. most &quot;zoomed in&quot;.</string>
</property>
<property name="text">
<string>…</string>
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../images/images.qrc">:/images/themes/default/mActionZoomIn.svg</pixmap>
</property>
</widget>
</item>
@ -6234,70 +6287,43 @@ font-style: italic;</string>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QFrame" name="frameLabelWith">
<layout class="QHBoxLayout" name="horizontalLayout_19">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Label with</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFieldExpressionWidget" name="mFieldExpressionWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsSpinBox</class>
<extends>QSpinBox</extends>
<header>qgsspinbox.h</header>
</customwidget>
<customwidget>
<class>QgsScaleWidget</class>
<extends>QWidget</extends>
<header>qgsscalewidget.h</header>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsUnitSelectionWidget</class>
<extends>QWidget</extends>
<header>qgsunitselectionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsColorButton</class>
<extends>QToolButton</extends>
@ -6310,54 +6336,21 @@ font-style: italic;</string>
<header>qgspropertyoverridebutton.h</header>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsSpinBox</class>
<extends>QSpinBox</extends>
<header>qgsspinbox.h</header>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsPenJoinStyleComboBox</class>
<extends>QComboBox</extends>
<header>qgspenstylecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsUnitSelectionWidget</class>
<extends>QWidget</extends>
<header>qgsunitselectionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsFieldExpressionWidget</class>
<extends>QWidget</extends>
<header>qgsfieldexpressionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScaleWidget</class>
<extends>QWidget</extends>
<header>qgsscalewidget.h</header>
</customwidget>
<customwidget>
<class>QgsTextPreview</class>
<extends>QLabel</extends>
@ -6590,9 +6583,9 @@ font-style: italic;</string>
<tabstop>scrollArea_4</tabstop>
<tabstop>mScaleBasedVisibilityChkBx</tabstop>
<tabstop>mScaleBasedVisibilityDDBtn</tabstop>
<tabstop>mScaleBasedVisibilityMinSpnBx</tabstop>
<tabstop>mMinScaleWidget</tabstop>
<tabstop>mScaleBasedVisibilityMinDDBtn</tabstop>
<tabstop>mScaleBasedVisibilityMaxSpnBx</tabstop>
<tabstop>mMaxScaleWidget</tabstop>
<tabstop>mScaleBasedVisibilityMaxDDBtn</tabstop>
<tabstop>mFontLimitPixelChkBox</tabstop>
<tabstop>mFontLimitPixelDDBtn</tabstop>
@ -6623,6 +6616,30 @@ font-style: italic;</string>
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>