Skip to content
Permalink
Browse files

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

Also unify API with other scale API.

Fix #16349
  • Loading branch information
nyalldawson committed Jun 9, 2017
1 parent b2e102d commit e41346375582b6c01f2c88a801ed94b243da98ca
@@ -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}
@@ -376,15 +376,15 @@ 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
%End

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
@@ -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)
@@ -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 );
@@ -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 )
@@ -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 );
@@ -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 )
@@ -426,15 +426,15 @@ 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
*/
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

0 comments on commit e413463

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