36 #include <QButtonGroup>    37 #include <QMessageBox>    67   if ( !abstractMetadata )
    69     QgsDebugMsg( QStringLiteral( 
"Failed to find callout entry in registry: %1" ).arg( name ) );
    75     QgsDebugMsg( QStringLiteral( 
"Failed to cast callout's metadata: " ) .arg( name ) );
    82 void QgsLabelingGui::initCalloutWidgets()
    84   _initCalloutWidgetFunction( QStringLiteral( 
"simple" ), QgsSimpleLineCalloutWidget::create );
    85   _initCalloutWidgetFunction( QStringLiteral( 
"manhattan" ), QgsManhattanLineCalloutWidget::create );
    88 void QgsLabelingGui::updateCalloutWidget( 
QgsCallout *callout )
    92     mCalloutStackedWidget->setCurrentWidget( pageDummy );
    96   if ( mCalloutStackedWidget->currentWidget() != pageDummy )
    99     if ( 
QgsCalloutWidget *pew = qobject_cast< QgsCalloutWidget * >( mCalloutStackedWidget->currentWidget() ) )
   110       if ( mGeometryGeneratorGroupBox->isChecked() )
   113         geometryType = mLayer->geometryType();
   114       w->setGeometryType( geometryType );
   115       w->setCallout( callout );
   117       w->setContext( context() );
   118       mCalloutStackedWidget->addWidget( w );
   119       mCalloutStackedWidget->setCurrentWidget( w );
   126   mCalloutStackedWidget->setCurrentWidget( pageDummy );
   129 void QgsLabelingGui::showObstacleSettings()
   143   auto applySettings = [ = ]
   145     mObstacleSettings = widget->
settings();
   148     emit widgetChanged();
   174   , mGeomType( geomType )
   175   , mSettings( layerSettings )
   177   , mCanvas( mapCanvas )
   179   static std::once_flag initialized;
   180   std::call_once( initialized, [ = ]( )
   182     initCalloutWidgets();
   186   connect( mBufferDrawChkBx, &QAbstractButton::toggled, 
this, &QgsLabelingGui::updateUi );
   187   connect( mEnableMaskChkBx, &QAbstractButton::toggled, 
this, &QgsLabelingGui::updateUi );
   188   connect( mShapeDrawChkBx, &QAbstractButton::toggled, 
this, &QgsLabelingGui::updateUi );
   189   connect( mShadowDrawChkBx, &QAbstractButton::toggled, 
this, &QgsLabelingGui::updateUi );
   190   connect( mDirectSymbChkBx, &QAbstractButton::toggled, 
this, &QgsLabelingGui::updateUi );
   191   connect( mFormatNumChkBx, &QAbstractButton::toggled, 
this, &QgsLabelingGui::updateUi );
   192   connect( mScaleBasedVisibilityChkBx, &QAbstractButton::toggled, 
this, &QgsLabelingGui::updateUi );
   193   connect( mFontLimitPixelChkBox, &QAbstractButton::toggled, 
this, &QgsLabelingGui::updateUi );
   194   connect( mGeometryGeneratorGroupBox, &QGroupBox::toggled, 
this, &QgsLabelingGui::updateGeometryTypeBasedWidgets );
   195   connect( mGeometryGeneratorType, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), 
this, &QgsLabelingGui::updateGeometryTypeBasedWidgets );
   196   connect( mGeometryGeneratorExpressionButton, &QToolButton::clicked, 
this, &QgsLabelingGui::showGeometryGeneratorExpressionBuilder );
   197   connect( mGeometryGeneratorGroupBox, &QGroupBox::toggled, 
this, &QgsLabelingGui::validateGeometryGeneratorExpression );
   198   connect( mGeometryGenerator, &QgsCodeEditorExpression::textChanged, 
this, &QgsLabelingGui::validateGeometryGeneratorExpression );
   199   connect( mGeometryGeneratorType, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), 
this, &QgsLabelingGui::validateGeometryGeneratorExpression );
   200   connect( mObstacleSettingsButton, &QAbstractButton::clicked, 
this, &QgsLabelingGui::showObstacleSettings );
   202   mFieldExpressionWidget->registerExpressionContextGenerator( 
this );
   204   mMinScaleWidget->setMapCanvas( mCanvas );
   205   mMinScaleWidget->setShowCurrentScaleButton( 
true );
   206   mMaxScaleWidget->setMapCanvas( mCanvas );
   207   mMaxScaleWidget->setShowCurrentScaleButton( 
true );
   210   for ( 
const QString &type : calloutTypes )
   216   mGeometryGeneratorWarningLabel->setStyleSheet( QStringLiteral( 
"color: #FFC107;" ) );
   217   mGeometryGeneratorWarningLabel->setTextInteractionFlags( Qt::TextBrowserInteraction );
   218   connect( mGeometryGeneratorWarningLabel, &QLabel::linkActivated, 
this, [
this]( 
const QString & link )
   220     if ( link == QLatin1String( 
"#determineGeometryGeneratorType" ) )
   221       determineGeometryGeneratorType();
   224   connect( mCalloutStyleComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLabelingGui::calloutTypeChanged );
   229 void QgsLabelingGui::setLayer( 
QgsMapLayer *mapLayer )
   244   mTextFormatsListWidget->setLayerType( mLayer ? mLayer->geometryType() : mGeomType );
   245   mBackgroundSymbolButton->setLayer( mLayer );
   248   updateGeometryTypeBasedWidgets();
   250   mFieldExpressionWidget->setLayer( mLayer );
   255   mFieldExpressionWidget->setGeomCalculator( da );
   257   mFieldExpressionWidget->setEnabled( mMode == Labels || !mLayer );
   258   mLabelingFrame->setEnabled( mMode == Labels || !mLayer );
   260   blockInitSignals( 
true );
   262   mGeometryGenerator->setText( mSettings.geometryGenerator );
   263   mGeometryGeneratorGroupBox->setChecked( mSettings.geometryGeneratorEnabled );
   264   mGeometryGeneratorType->setCurrentIndex( mGeometryGeneratorType->findData( mSettings.geometryGeneratorType ) );
   266   updateWidgetForFormat( mSettings.format() );
   268   mFieldExpressionWidget->setRow( -1 );
   269   mFieldExpressionWidget->setField( mSettings.fieldName );
   270   mCheckBoxSubstituteText->setChecked( mSettings.useSubstitutions );
   271   mSubstitutions = mSettings.substitutions;
   274   mCentroidRadioWhole->setChecked( mSettings.centroidWhole );
   275   mCentroidInsideCheckBox->setChecked( mSettings.centroidInside );
   276   mFitInsidePolygonCheckBox->setChecked( mSettings.fitInPolygonOnly );
   277   mLineDistanceSpnBx->setValue( mSettings.dist );
   278   mLineDistanceUnitWidget->setUnit( mSettings.distUnits );
   279   mLineDistanceUnitWidget->setMapUnitScale( mSettings.distMapUnitScale );
   280   mOffsetTypeComboBox->setCurrentIndex( mOffsetTypeComboBox->findData( mSettings.offsetType ) );
   281   mQuadrantBtnGrp->button( static_cast<int>( mSettings.quadOffset ) )->setChecked( 
true );
   282   mPointOffsetXSpinBox->setValue( mSettings.xOffset );
   283   mPointOffsetYSpinBox->setValue( mSettings.yOffset );
   284   mPointOffsetUnitWidget->setUnit( mSettings.offsetUnits );
   285   mPointOffsetUnitWidget->setMapUnitScale( mSettings.labelOffsetMapUnitScale );
   286   mPointAngleSpinBox->setValue( mSettings.angleOffset );
   292   switch ( mSettings.placement )
   295       radAroundPoint->setChecked( 
true );
   296       radAroundCentroid->setChecked( 
true );
   300       radOverPoint->setChecked( 
true );
   301       radOverCentroid->setChecked( 
true );
   304       radPredefinedOrder->setChecked( 
true );
   307       radLineParallel->setChecked( 
true );
   308       radPolygonPerimeter->setChecked( 
true );
   311       radLineCurved->setChecked( 
true );
   314       radPolygonHorizontal->setChecked( 
true );
   315       radLineHorizontal->setChecked( 
true );
   318       radPolygonFree->setChecked( 
true );
   321       radPolygonPerimeterCurved->setChecked( 
true );
   326   mRepeatDistanceSpinBox->setValue( mSettings.repeatDistance );
   327   mRepeatDistanceUnitWidget->setUnit( mSettings.repeatDistanceUnit );
   328   mRepeatDistanceUnitWidget->setMapUnitScale( mSettings.repeatDistanceMapUnitScale );
   330   mOverrunDistanceSpinBox->setValue( mSettings.overrunDistance );
   331   mOverrunDistanceUnitWidget->setUnit( mSettings.overrunDistanceUnit );
   332   mOverrunDistanceUnitWidget->setMapUnitScale( mSettings.overrunDistanceMapUnitScale );
   334   mPrioritySlider->setValue( mSettings.priority );
   335   mChkNoObstacle->setChecked( mSettings.obstacleSettings().isObstacle() );
   337   mObstacleSettings = mSettings.obstacleSettings();
   339   chkLabelPerFeaturePart->setChecked( mSettings.labelPerPart );
   340   mPalShowAllLabelsForLayerChkBx->setChecked( mSettings.displayAll );
   341   chkMergeLines->setChecked( mSettings.mergeLines );
   342   mMinSizeSpinBox->setValue( mSettings.thinningSettings().minimumFeatureSize() );
   343   mLimitLabelChkBox->setChecked( mSettings.thinningSettings().limitNumberOfLabelsEnabled() );
   344   mLimitLabelSpinBox->setValue( mSettings.thinningSettings().maximumNumberLabels() );
   347   mDirectSymbChkBx->setChecked( mSettings.addDirectionSymbol );
   348   mDirectSymbLeftLineEdit->setText( mSettings.leftDirectionSymbol );
   349   mDirectSymbRightLineEdit->setText( mSettings.rightDirectionSymbol );
   350   mDirectSymbRevChkBx->setChecked( mSettings.reverseDirectionSymbol );
   352   mDirectSymbBtnGrp->button( static_cast<int>( mSettings.placeDirectionSymbol ) )->setChecked( 
true );
   353   mUpsidedownBtnGrp->button( static_cast<int>( mSettings.upsidedownLabels ) )->setChecked( 
true );
   356   mMaxCharAngleInDSpinBox->setValue( mSettings.maxCurvedCharAngleIn );
   358   mMaxCharAngleOutDSpinBox->setValue( std::fabs( mSettings.maxCurvedCharAngleOut ) );
   360   wrapCharacterEdit->setText( mSettings.wrapChar );
   361   mAutoWrapLengthSpinBox->setValue( mSettings.autoWrapLength );
   362   mAutoWrapTypeComboBox->setCurrentIndex( mSettings.useMaxLineLengthForAutoWrap ? 0 : 1 );
   364   if ( ( 
int ) mSettings.multilineAlign < mFontMultiLineAlignComboBox->count() )
   366     mFontMultiLineAlignComboBox->setCurrentIndex( mSettings.multilineAlign );
   372     mFontMultiLineAlignComboBox->setCurrentIndex( 0 );
   375   chkPreserveRotation->setChecked( mSettings.preserveRotation );
   377   mScaleBasedVisibilityChkBx->setChecked( mSettings.scaleVisibility );
   378   mMinScaleWidget->setScale( mSettings.minimumScale );
   379   mMaxScaleWidget->setScale( mSettings.maximumScale );
   381   mFormatNumChkBx->setChecked( mSettings.formatNumbers );
   382   mFormatNumDecimalsSpnBx->setValue( mSettings.decimals );
   383   mFormatNumPlusSignChkBx->setChecked( mSettings.plusSign );
   387   mFontLimitPixelChkBox->setChecked( mSettings.fontLimitPixelSize );
   388   mMinPixelLimit = mSettings.fontMinPixelSize; 
   389   mFontMinPixelSpinBox->setValue( mSettings.fontMinPixelSize == 0 ? 3 : mSettings.fontMinPixelSize );
   390   mFontMaxPixelSpinBox->setValue( mSettings.fontMaxPixelSize );
   392   mZIndexSpinBox->setValue( mSettings.zIndex );
   394   mDataDefinedProperties = mSettings.dataDefinedProperties();
   397   if ( mSettings.callout() )
   399     whileBlocking( mCalloutsDrawCheckBox )->setChecked( mSettings.callout()->enabled() );
   400     whileBlocking( mCalloutStyleComboBox )->setCurrentIndex( mCalloutStyleComboBox->findData( mSettings.callout()->type() ) );
   401     updateCalloutWidget( mSettings.callout() );
   406     whileBlocking( mCalloutStyleComboBox )->setCurrentIndex( mCalloutStyleComboBox->findData( defaultCallout->type() ) );
   408     updateCalloutWidget( defaultCallout.get() );
   411   updatePlacementWidgets();
   412   updateLinePlacementOptions();
   415   blockInitSignals( 
false );
   419   populateDataDefinedButtons();
   421   enableDataDefinedAlignment( mCoordXDDBtn->isActive() && mCoordYDDBtn->isActive() );
   427   mSettings = settings;
   431 void QgsLabelingGui::blockInitSignals( 
bool block )
   433   chkLineAbove->blockSignals( block );
   434   chkLineBelow->blockSignals( block );
   435   mPlacePointBtnGrp->blockSignals( block );
   436   mPlaceLineBtnGrp->blockSignals( block );
   437   mPlacePolygonBtnGrp->blockSignals( block );
   440 void QgsLabelingGui::setLabelMode( LabelMode mode )
   443   mFieldExpressionWidget->setEnabled( mMode == Labels );
   444   mLabelingFrame->setEnabled( mMode == Labels );
   451   lyr.
drawLabels = ( mMode == Labels ) || !mLayer;
   454   lyr.
fieldName = mFieldExpressionWidget->currentField( &isExpression );
   460   QWidget *curPlacementWdgt = stackedPlacement->currentWidget();
   464   lyr.
dist = mLineDistanceSpnBx->value();
   465   lyr.
distUnits = mLineDistanceUnitWidget->unit();
   468   if ( mQuadrantBtnGrp )
   472   lyr.
xOffset = mPointOffsetXSpinBox->value();
   473   lyr.
yOffset = mPointOffsetYSpinBox->value();
   477   if ( chkLineAbove->isChecked() )
   479   if ( chkLineBelow->isChecked() )
   481   if ( chkLineOn->isChecked() )
   483   if ( ! chkLineOrientationDependent->isChecked() )
   485   if ( ( curPlacementWdgt == pagePoint && radAroundPoint->isChecked() )
   486        || ( curPlacementWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
   490   else if ( ( curPlacementWdgt == pagePoint && radOverPoint->isChecked() )
   491             || ( curPlacementWdgt == pagePolygon && radOverCentroid->isChecked() ) )
   495   else if ( curPlacementWdgt == pagePoint && radPredefinedOrder->isChecked() )
   499   else if ( ( curPlacementWdgt == pageLine && radLineParallel->isChecked() )
   500             || ( curPlacementWdgt == pagePolygon && radPolygonPerimeter->isChecked() ) )
   504   else if ( curPlacementWdgt == pageLine && radLineCurved->isChecked() )
   508   else if ( curPlacementWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() )
   512   else if ( ( curPlacementWdgt == pageLine && radLineHorizontal->isChecked() )
   513             || ( curPlacementWdgt == pagePolygon && radPolygonHorizontal->isChecked() ) )
   517   else if ( radPolygonFree->isChecked() )
   523     qFatal( 
"Invalid settings" );
   534   lyr.
priority = mPrioritySlider->value();
   536   mObstacleSettings.setIsObstacle( mChkNoObstacle->isChecked() || mMode == ObstaclesOnly );
   540   lyr.
displayAll = mPalShowAllLabelsForLayerChkBx->isChecked();
   553   lyr.
decimals = mFormatNumDecimalsSpnBx->value();
   554   lyr.
plusSign = mFormatNumPlusSignChkBx->isChecked();
   561   if ( mDirectSymbBtnGrp )
   565   if ( mUpsidedownBtnGrp )
   581   lyr.
wrapChar = wrapCharacterEdit->text();
   590   lyr.
layerType = mLayer ? mLayer->geometryType() : mGeomType;
   592   lyr.
zIndex = mZIndexSpinBox->value();
   597   const QString calloutType = mCalloutStyleComboBox->currentData().toString();
   598   std::unique_ptr< QgsCallout > callout;
   599   if ( 
QgsCalloutWidget *pew = qobject_cast< QgsCalloutWidget * >( mCalloutStackedWidget->currentWidget() ) )
   601     callout.reset( pew->callout()->clone() );
   606   callout->
setEnabled( mCalloutsDrawCheckBox->isChecked() );
   614   if ( ddBtn->
isActive() && !chkBx->isChecked() )
   616     chkBx->setChecked( 
true );
   618   f->setEnabled( chkBx->isChecked() );
   621 void QgsLabelingGui::updateUi()
   625   syncDefinedCheckboxFrame( mBufferDrawDDBtn, mBufferDrawChkBx, mBufferFrame );
   626   syncDefinedCheckboxFrame( mEnableMaskDDBtn, mEnableMaskChkBx, mMaskFrame );
   627   syncDefinedCheckboxFrame( mShapeDrawDDBtn, mShapeDrawChkBx, mShapeFrame );
   628   syncDefinedCheckboxFrame( mShadowDrawDDBtn, mShadowDrawChkBx, mShadowFrame );
   630   syncDefinedCheckboxFrame( mDirectSymbDDBtn, mDirectSymbChkBx, mDirectSymbFrame );
   631   syncDefinedCheckboxFrame( mFormatNumDDBtn, mFormatNumChkBx, mFormatNumFrame );
   632   syncDefinedCheckboxFrame( mScaleBasedVisibilityDDBtn, mScaleBasedVisibilityChkBx, mScaleBasedVisibilityFrame );
   633   syncDefinedCheckboxFrame( mFontLimitPixelDDBtn, mFontLimitPixelChkBox, mFontLimitPixelFrame );
   635   chkMergeLines->setEnabled( !mDirectSymbChkBx->isChecked() );
   636   if ( mDirectSymbChkBx->isChecked() )
   638     chkMergeLines->setToolTip( tr( 
"This option is not compatible with line direction symbols." ) );
   642     chkMergeLines->setToolTip( QString() );
   670         settings.
fieldName = mFieldExpressionWidget->currentField( &isExpression );
   673       setSettings( settings );
   681   if ( 
QgsCalloutWidget *cw = qobject_cast< QgsCalloutWidget * >( mCalloutStackedWidget->currentWidget() ) )
   683     cw->setContext( context );
   688 void QgsLabelingGui::saveFormat()
   695   saveDlg.setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
   696   if ( !saveDlg.exec() )
   699   if ( saveDlg.name().isEmpty() )
   702   switch ( saveDlg.selectedType() )
   709         int res = QMessageBox::warning( 
this, tr( 
"Save Text Format" ),
   710                                         tr( 
"Format with name '%1' already exists. Overwrite?" )
   711                                         .arg( saveDlg.name() ),
   712                                         QMessageBox::Yes | QMessageBox::No );
   713         if ( res != QMessageBox::Yes )
   719       QStringList symbolTags = saveDlg.tags().split( 
',' );
   723       style->
saveTextFormat( saveDlg.name(), newFormat, saveDlg.isFavorite(), symbolTags );
   732         int res = QMessageBox::warning( 
this, tr( 
"Save Label Settings" ),
   733                                         tr( 
"Label settings with the name '%1' already exist. Overwrite?" )
   734                                         .arg( saveDlg.name() ),
   735                                         QMessageBox::Yes | QMessageBox::No );
   736         if ( res != QMessageBox::Yes )
   742       QStringList symbolTags = saveDlg.tags().split( 
',' );
   746       style->
saveLabelSettings( saveDlg.name(), newSettings, saveDlg.isFavorite(), symbolTags );
   758 void QgsLabelingGui::updateGeometryTypeBasedWidgets()
   762   if ( mGeometryGeneratorGroupBox->isChecked() )
   765     geometryType = mLayer->geometryType();
   775   switch ( geometryType )
   778       stackedPlacement->setCurrentWidget( pagePoint );
   781       stackedPlacement->setCurrentWidget( pageLine );
   784       stackedPlacement->setCurrentWidget( pagePolygon );
   789       qFatal( 
"unknown geometry type unexpected" );
   795     if ( mFontMultiLineAlignComboBox->findText( tr( 
"Follow label placement" ) ) == -1 )
   796       mFontMultiLineAlignComboBox->addItem( tr( 
"Follow label placement" ) );
   800     int idx = mFontMultiLineAlignComboBox->findText( tr( 
"Follow label placement" ) );
   802       mFontMultiLineAlignComboBox->removeItem( idx );
   805   updatePlacementWidgets();
   806   updateLinePlacementOptions();
   809 void QgsLabelingGui::showGeometryGeneratorExpressionBuilder()
   813   expressionBuilder.setExpressionText( mGeometryGenerator->text() );
   814   expressionBuilder.setExpressionContext( createExpressionContext() );
   816   if ( expressionBuilder.exec() )
   818     mGeometryGenerator->setText( expressionBuilder.expressionText() );
   822 void QgsLabelingGui::validateGeometryGeneratorExpression()
   826   if ( mGeometryGeneratorGroupBox->isChecked() )
   828     if ( !mPreviewFeature.isValid() && mLayer )
   829       mLayer->getFeatures( 
QgsFeatureRequest().setLimit( 1 ) ).nextFeature( mPreviewFeature );
   833     context.setFeature( mPreviewFeature );
   835     expression.prepare( &context );
   837     if ( expression.hasParserError() )
   839       mGeometryGeneratorWarningLabel->setText( expression.parserErrorString() );
   844       const QVariant result = expression.evaluate( &context );
   849         mGeometryGeneratorWarningLabel->setText( tr( 
"Result of the expression is not a geometry" ) );
   852       else if ( geometry.
type() != configuredGeometryType )
   854         mGeometryGeneratorWarningLabel->setText( QStringLiteral( 
"<p>%1</p><p><a href=\"#determineGeometryGeneratorType\">%2</a></p>" ).arg(
   855               tr( 
"Result of the expression does not match configured geometry type." ),
   864   QTimer *timer = 
new QTimer();
   865   connect( timer, &QTimer::timeout, 
this, [
this, valid]()
   867     mGeometryGeneratorWarningLabel->setVisible( !valid );
   869   connect( timer, &QTimer::timeout, timer, &QTimer::deleteLater );
   873 void QgsLabelingGui::determineGeometryGeneratorType()
   875   if ( !mPreviewFeature.isValid() && mLayer )
   876     mLayer->getFeatures( 
QgsFeatureRequest().setLimit( 1 ) ).nextFeature( mPreviewFeature );
   880   context.setFeature( mPreviewFeature );
   882   expression.prepare( &context );
   885   mGeometryGeneratorType->setCurrentIndex( mGeometryGeneratorType->findData( geometry.
type() ) );
   888 void QgsLabelingGui::calloutTypeChanged()
   890   QString newCalloutType = mCalloutStyleComboBox->currentData().toString();
   910   updateCalloutWidget( newCallout.get() );
   923   QVBoxLayout *vLayout = 
new QVBoxLayout();
   924   mWidget = 
new QgsLabelingGui( layer, mapCanvas, settings, 
nullptr, geomType );
   925   vLayout->addWidget( mWidget );
   926   mButtonBox = 
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
   927   connect( mButtonBox, &QDialogButtonBox::accepted, 
this, &QDialog::accept );
   928   connect( mButtonBox, &QDialogButtonBox::rejected, 
this, &QDialog::reject );
   929   connect( mButtonBox, &QDialogButtonBox::helpRequested, 
this, &QgsLabelSettingsDialog::showHelp );
   930   vLayout->addWidget( mButtonBox );
   931   setLayout( vLayout );
   932   setWindowTitle( tr( 
"Label Settings" ) );
   935 QDialogButtonBox *QgsLabelSettingsDialog::buttonBox()
 const   940 void QgsLabelSettingsDialog::showHelp()
 static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable. 
 
Class for parsing and evaluation of expressions (formerly called "search strings"). 
 
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context. 
 
double xOffset
Horizontal offset of label. 
 
The class is used as a container of context for various read/write operations on other objects...
 
QString geometryGenerator
The geometry generator expression. Null if disabled. 
 
Base class for all map layer types. 
 
double maxCurvedCharAngleOut
Maximum angle between outside curved label characters (valid range -20.0 to -95.0) ...
 
double maximumScale
The maximum map scale (i.e. 
 
Abstract base class for callout renderers. 
 
QString leftDirectionSymbol
String to use for left direction arrows. 
 
static QgsCalloutRegistry * calloutRegistry()
Returns the application's callout registry, used for managing callout types. 
 
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style. 
 
QgsUnitTypes::RenderUnit repeatDistanceUnit
Units for repeating labels for a single feature. 
 
QStringList calloutTypes() const
Returns a list of all available callout types. 
 
QgsMapUnitScale overrunDistanceMapUnitScale
Map unit scale for label overrun distance. 
 
QgsMapLayerType type() const
Returns the type of the layer. 
 
double angleOffset
Label rotation, in degrees clockwise. 
 
bool formatNumbers
Set to true to format numeric label text as numbers (e.g. 
 
UpsideDownLabels upsidedownLabels
Controls whether upside down labels are displayed and how they are handled. 
 
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
 
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
 
Arranges candidates following the curvature of a line feature. Applies to line layers only...
 
bool addLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool update=false)
Adds label settings with the specified name to the style. 
 
int decimals
Number of decimal places to show for numeric labels. 
 
double repeatDistance
Distance for repeating labels for a single feature. 
 
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
 
QuadrantPosition quadOffset
Sets the quadrant in which to offset labels from feature. 
 
QgsUnitTypes::RenderUnit offsetUnits
Units for offsets of label. 
 
double yOffset
Vertical offset of label. 
 
bool addDirectionSymbol
If true, '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be ...
 
bool geometryGeneratorEnabled
Defines if the geometry generator is enabled or not. If disabled, the standard geometry will be taken...
 
A geometry is the spatial representation of a feature. 
 
bool drawLabels
Whether to draw labels for this layer. 
 
bool mergeLines
true if connected line features with identical label text should be merged prior to generating label ...
 
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature. 
 
MultiLineAlign multilineAlign
Horizontal alignment of multi-line labels. 
 
void setMaximumNumberLabels(int number)
Sets the maximum number of labels which should be drawn for this layer. 
 
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym. 
 
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project. 
 
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
 
A widget for customizing text formatting settings. 
 
QgsCalloutAbstractMetadata * calloutMetadata(const QString &type) const
Returns the metadata for specified the specified callout type. 
 
int autoWrapLength
If non-zero, indicates that label text should be automatically wrapped to (ideally) the specified num...
 
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas. 
 
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget. 
 
double maxCurvedCharAngleIn
Maximum angle between inside curved label characters (valid range 20.0 to 60.0). 
 
Map canvas is a class for displaying all GIS data types on a canvas. 
 
bool reverseDirectionSymbol
True if direction symbols should be reversed. 
 
static QgsStyle * defaultStyle()
Returns default application-wide style. 
 
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc. 
 
double zIndex
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-ind...
 
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels. 
 
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
 
StyleEntity
Enum for Entities involved in a style. 
 
QStringList textFormatNames() const
Returns a list of names of text formats in the style. 
 
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name. 
 
Labels can be placed directly over a line feature. 
 
bool displayAll
If true, all features will be labelled even when overlaps occur. 
 
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
 
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label's property collection, used for data defined overrides. 
 
int fontMaxPixelSize
Maximum pixel size for showing rendered map unit labels (1 - 10000). 
 
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
 
QStringList labelSettingsNames() const
Returns a list of names of label settings in the style. 
 
Labels can be placed above a line feature. 
 
static QString geometryDisplayString(GeometryType type)
Returns a display string for a geometry type. 
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
 
This class wraps a request for features to a vector layer (or directly its vector data provider)...
 
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable. 
 
OffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes...
 
Single scope for storing variables and functions for use within a QgsExpressionContext. 
 
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label obstacle settings. 
 
void setLimitNumberLabelsEnabled(bool enabled)
Sets whether the the number of labels drawn for the layer should be limited. 
 
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget. 
 
virtual void setFormatFromStyle(const QString &name, QgsStyle::StyleEntity type)
Sets the current text settings from a style entry. 
 
virtual QString type() const =0
Returns a unique string representing the callout type. 
 
bool plusSign
Whether '+' signs should be prepended to positive numeric labels. 
 
QgsCoordinateTransformContext transformContext
 
unsigned int placementFlags
 
QgsWkbTypes::GeometryType geometryGeneratorType
The type of the result geometry of the geometry generator. 
 
QString wrapChar
Wrapping character string. 
 
QgsCalloutWidget *(* QgsCalloutWidgetFunc)(QgsVectorLayer *)
 
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way. 
 
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database. 
 
A general purpose distance and area calculator, capable of performing ellipsoid based calculations...
 
QString rightDirectionSymbol
String to use for right direction arrows. 
 
bool preserveRotation
True if label rotation should be preserved during label pin/unpin operations. 
 
bool removeTextFormat(const QString &name)
Removes a text format from the style. 
 
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
 
bool centroidWhole
true if feature centroid should be calculated from the whole feature, or false if only the visible pa...
 
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object. 
 
bool scaleVisibility
Set to true to limit label visibility to a range of scales. 
 
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
 
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance. 
 
bool fitInPolygonOnly
true if only labels which completely fit within a polygon are allowed. 
 
OffsetType offsetType
Offset type for layer (only applies in certain placement modes) 
 
static QgsProject * instance()
Returns the QgsProject singleton instance. 
 
double dist
Distance from feature to the label. 
 
const QgsLabelThinningSettings & thinningSettings() const
Returns the label thinning settings. 
 
bool useSubstitutions
True if substitutions should be applied. 
 
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser. 
 
Registry of available callout classes. 
 
Labels can be placed below a line feature. 
 
A grouped map of multiple QgsProperty objects, each referenced by a integer key value. 
 
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user...
 
Signifies that the AboveLine and BelowLine flags should respect the map's orientation rather than the...
 
bool isExpression
true if this label is made from a expression string, e.g., FieldName || 'mm' 
 
double overrunDistance
Distance which labels are allowed to overrun past the start or end of line features. 
 
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs. 
 
QgsWkbTypes::GeometryType type
 
QgsUnitTypes::RenderUnit overrunDistanceUnit
Units for label overrun distance. 
 
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer. 
 
void setCallout(QgsCallout *callout)
Sets the label callout renderer, responsible for drawing label callouts. 
 
void setMinimumFeatureSize(double size)
Sets the minimum feature size (in millimeters) for a feature to be labelled. 
 
Container for all settings relating to text rendering. 
 
bool saveLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool favorite, const QStringList &tags)
Adds label settings to the database. 
 
bool centroidInside
true if centroid positioned labels must be placed inside their corresponding feature polygon...
 
virtual QVariantMap properties(const QgsReadWriteContext &context) const
Returns the properties describing the callout encoded in a string format. 
 
Represents a vector layer which manages a vector based data sets. 
 
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only...
 
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context. 
 
bool removeLabelSettings(const QString &name)
Removes label settings from the style. 
 
int fontMinPixelSize
Minimum pixel size for showing rendered map unit labels (1 - 1000). 
 
int priority
Label priority. 
 
A generic dialog for building expression strings. 
 
bool labelPerPart
true if every part of a multi-part feature should be labeled. 
 
QgsUnitTypes::RenderUnit distUnits
Units the distance from feature to the label. 
 
bool useMaxLineLengthForAutoWrap
If true, indicates that when auto wrapping label text the autoWrapLength length indicates the maximum...
 
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset. 
 
void setEnabled(bool enabled)
Sets whether the callout is enabled. 
 
double minimumScale
The minimum map scale (i.e. 
 
QString fieldName
Name of field (or an expression) to use for label text. 
 
bool fontLimitPixelSize
true if label sizes should be limited by pixel size. 
 
DirectionSymbols placeDirectionSymbol
Placement option for direction symbols. 
 
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
 
QgsWkbTypes::GeometryType layerType
Geometry type of layers associated with these settings.