35 #include <QButtonGroup> 36 #include <QMessageBox> 66 if ( !abstractMetadata )
68 QgsDebugMsg( QStringLiteral(
"Failed to find callout entry in registry: %1" ).arg( name ) );
74 QgsDebugMsg( QStringLiteral(
"Failed to cast callout's metadata: " ) .arg( name ) );
81 void QgsLabelingGui::initCalloutWidgets()
83 _initCalloutWidgetFunction( QStringLiteral(
"simple" ), QgsSimpleLineCalloutWidget::create );
84 _initCalloutWidgetFunction( QStringLiteral(
"manhattan" ), QgsManhattanLineCalloutWidget::create );
87 void QgsLabelingGui::updateCalloutWidget(
QgsCallout *callout )
91 mCalloutStackedWidget->setCurrentWidget( pageDummy );
95 if ( mCalloutStackedWidget->currentWidget() != pageDummy )
98 if (
QgsCalloutWidget *pew = qobject_cast< QgsCalloutWidget * >( mCalloutStackedWidget->currentWidget() ) )
109 if ( mGeometryGeneratorGroupBox->isChecked() )
112 geometryType = mLayer->geometryType();
113 w->setGeometryType( geometryType );
114 w->setCallout( callout );
116 w->setContext( context() );
117 mCalloutStackedWidget->addWidget( w );
118 mCalloutStackedWidget->setCurrentWidget( w );
125 mCalloutStackedWidget->setCurrentWidget( pageDummy );
130 , mGeomType( geomType )
131 , mSettings( layerSettings )
133 , mCanvas( mapCanvas )
135 static std::once_flag initialized;
136 std::call_once( initialized, [ = ]( )
138 initCalloutWidgets();
142 connect( mBufferDrawChkBx, &QAbstractButton::toggled,
this, &QgsLabelingGui::updateUi );
143 connect( mShapeDrawChkBx, &QAbstractButton::toggled,
this, &QgsLabelingGui::updateUi );
144 connect( mShadowDrawChkBx, &QAbstractButton::toggled,
this, &QgsLabelingGui::updateUi );
145 connect( mDirectSymbChkBx, &QAbstractButton::toggled,
this, &QgsLabelingGui::updateUi );
146 connect( mFormatNumChkBx, &QAbstractButton::toggled,
this, &QgsLabelingGui::updateUi );
147 connect( mScaleBasedVisibilityChkBx, &QAbstractButton::toggled,
this, &QgsLabelingGui::updateUi );
148 connect( mFontLimitPixelChkBox, &QAbstractButton::toggled,
this, &QgsLabelingGui::updateUi );
149 connect( mGeometryGeneratorGroupBox, &QGroupBox::toggled,
this, &QgsLabelingGui::updateGeometryTypeBasedWidgets );
150 connect( mGeometryGeneratorType, qgis::overload<int>::of( &QComboBox::currentIndexChanged ),
this, &QgsLabelingGui::updateGeometryTypeBasedWidgets );
151 connect( mGeometryGeneratorExpressionButton, &QToolButton::clicked,
this, &QgsLabelingGui::showGeometryGeneratorExpressionBuilder );
152 connect( mGeometryGeneratorGroupBox, &QGroupBox::toggled,
this, &QgsLabelingGui::validateGeometryGeneratorExpression );
153 connect( mGeometryGenerator, &QgsCodeEditorExpression::textChanged,
this, &QgsLabelingGui::validateGeometryGeneratorExpression );
154 connect( mGeometryGeneratorType, qgis::overload<int>::of( &QComboBox::currentIndexChanged ),
this, &QgsLabelingGui::validateGeometryGeneratorExpression );
156 mFieldExpressionWidget->registerExpressionContextGenerator(
this );
158 mMinScaleWidget->setMapCanvas( mCanvas );
159 mMinScaleWidget->setShowCurrentScaleButton(
true );
160 mMaxScaleWidget->setMapCanvas( mCanvas );
161 mMaxScaleWidget->setShowCurrentScaleButton(
true );
164 for (
const QString &type : calloutTypes )
170 mGeometryGeneratorWarningLabel->setStyleSheet( QStringLiteral(
"color: #FFC107;" ) );
171 mGeometryGeneratorWarningLabel->setTextInteractionFlags( Qt::TextBrowserInteraction );
172 connect( mGeometryGeneratorWarningLabel, &QLabel::linkActivated,
this, [
this](
const QString & link )
174 if ( link == QLatin1String(
"#determineGeometryGeneratorType" ) )
175 determineGeometryGeneratorType();
178 connect( mCalloutStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLabelingGui::calloutTypeChanged );
183 void QgsLabelingGui::setLayer(
QgsMapLayer *mapLayer )
198 mTextFormatsListWidget->setLayerType( mLayer ? mLayer->geometryType() : mGeomType );
199 mBackgroundSymbolButton->setLayer( mLayer );
202 updateGeometryTypeBasedWidgets();
204 mFieldExpressionWidget->setLayer( mLayer );
209 mFieldExpressionWidget->setGeomCalculator( da );
211 mFieldExpressionWidget->setEnabled( mMode == Labels || !mLayer );
212 mLabelingFrame->setEnabled( mMode == Labels || !mLayer );
214 blockInitSignals(
true );
216 mGeometryGenerator->setText( mSettings.geometryGenerator );
217 mGeometryGeneratorGroupBox->setChecked( mSettings.geometryGeneratorEnabled );
218 mGeometryGeneratorType->setCurrentIndex( mGeometryGeneratorType->findData( mSettings.geometryGeneratorType ) );
220 updateWidgetForFormat( mSettings.format() );
222 mFieldExpressionWidget->setRow( -1 );
223 mFieldExpressionWidget->setField( mSettings.fieldName );
224 mCheckBoxSubstituteText->setChecked( mSettings.useSubstitutions );
225 mSubstitutions = mSettings.substitutions;
228 mCentroidRadioWhole->setChecked( mSettings.centroidWhole );
229 mCentroidInsideCheckBox->setChecked( mSettings.centroidInside );
230 mFitInsidePolygonCheckBox->setChecked( mSettings.fitInPolygonOnly );
231 mLineDistanceSpnBx->setValue( mSettings.dist );
232 mLineDistanceUnitWidget->setUnit( mSettings.distUnits );
233 mLineDistanceUnitWidget->setMapUnitScale( mSettings.distMapUnitScale );
234 mOffsetTypeComboBox->setCurrentIndex( mOffsetTypeComboBox->findData( mSettings.offsetType ) );
235 mQuadrantBtnGrp->button( static_cast<int>( mSettings.quadOffset ) )->setChecked(
true );
236 mPointOffsetXSpinBox->setValue( mSettings.xOffset );
237 mPointOffsetYSpinBox->setValue( mSettings.yOffset );
238 mPointOffsetUnitWidget->setUnit( mSettings.offsetUnits );
239 mPointOffsetUnitWidget->setMapUnitScale( mSettings.labelOffsetMapUnitScale );
240 mPointAngleSpinBox->setValue( mSettings.angleOffset );
246 switch ( mSettings.placement )
249 radAroundPoint->setChecked(
true );
250 radAroundCentroid->setChecked(
true );
254 radOverPoint->setChecked(
true );
255 radOverCentroid->setChecked(
true );
258 radPredefinedOrder->setChecked(
true );
261 radLineParallel->setChecked(
true );
262 radPolygonPerimeter->setChecked(
true );
265 radLineCurved->setChecked(
true );
268 radPolygonHorizontal->setChecked(
true );
269 radLineHorizontal->setChecked(
true );
272 radPolygonFree->setChecked(
true );
275 radPolygonPerimeterCurved->setChecked(
true );
280 mRepeatDistanceSpinBox->setValue( mSettings.repeatDistance );
281 mRepeatDistanceUnitWidget->setUnit( mSettings.repeatDistanceUnit );
282 mRepeatDistanceUnitWidget->setMapUnitScale( mSettings.repeatDistanceMapUnitScale );
284 mOverrunDistanceSpinBox->setValue( mSettings.overrunDistance );
285 mOverrunDistanceUnitWidget->setUnit( mSettings.overrunDistanceUnit );
286 mOverrunDistanceUnitWidget->setMapUnitScale( mSettings.overrunDistanceMapUnitScale );
288 mPrioritySlider->setValue( mSettings.priority );
289 mChkNoObstacle->setChecked( mSettings.obstacle );
290 mObstacleFactorSlider->setValue( mSettings.obstacleFactor * 50 );
291 mObstacleTypeComboBox->setCurrentIndex( mObstacleTypeComboBox->findData( mSettings.obstacleType ) );
292 mPolygonObstacleTypeFrame->setEnabled( mSettings.obstacle );
293 mObstaclePriorityFrame->setEnabled( mSettings.obstacle );
294 chkLabelPerFeaturePart->setChecked( mSettings.labelPerPart );
295 mPalShowAllLabelsForLayerChkBx->setChecked( mSettings.displayAll );
296 chkMergeLines->setChecked( mSettings.mergeLines );
297 mMinSizeSpinBox->setValue( mSettings.minFeatureSize );
298 mLimitLabelChkBox->setChecked( mSettings.limitNumLabels );
299 mLimitLabelSpinBox->setValue( mSettings.maxNumLabels );
302 mDirectSymbChkBx->setChecked( mSettings.addDirectionSymbol );
303 mDirectSymbLeftLineEdit->setText( mSettings.leftDirectionSymbol );
304 mDirectSymbRightLineEdit->setText( mSettings.rightDirectionSymbol );
305 mDirectSymbRevChkBx->setChecked( mSettings.reverseDirectionSymbol );
307 mDirectSymbBtnGrp->button( static_cast<int>( mSettings.placeDirectionSymbol ) )->setChecked(
true );
308 mUpsidedownBtnGrp->button( static_cast<int>( mSettings.upsidedownLabels ) )->setChecked(
true );
311 mMaxCharAngleInDSpinBox->setValue( mSettings.maxCurvedCharAngleIn );
313 mMaxCharAngleOutDSpinBox->setValue( std::fabs( mSettings.maxCurvedCharAngleOut ) );
315 wrapCharacterEdit->setText( mSettings.wrapChar );
316 mAutoWrapLengthSpinBox->setValue( mSettings.autoWrapLength );
317 mAutoWrapTypeComboBox->setCurrentIndex( mSettings.useMaxLineLengthForAutoWrap ? 0 : 1 );
319 if ( (
int ) mSettings.multilineAlign < mFontMultiLineAlignComboBox->count() )
321 mFontMultiLineAlignComboBox->setCurrentIndex( mSettings.multilineAlign );
327 mFontMultiLineAlignComboBox->setCurrentIndex( 0 );
330 chkPreserveRotation->setChecked( mSettings.preserveRotation );
332 mScaleBasedVisibilityChkBx->setChecked( mSettings.scaleVisibility );
333 mMinScaleWidget->setScale( mSettings.minimumScale );
334 mMaxScaleWidget->setScale( mSettings.maximumScale );
336 mFormatNumChkBx->setChecked( mSettings.formatNumbers );
337 mFormatNumDecimalsSpnBx->setValue( mSettings.decimals );
338 mFormatNumPlusSignChkBx->setChecked( mSettings.plusSign );
342 mFontLimitPixelChkBox->setChecked( mSettings.fontLimitPixelSize );
343 mMinPixelLimit = mSettings.fontMinPixelSize;
344 mFontMinPixelSpinBox->setValue( mSettings.fontMinPixelSize == 0 ? 3 : mSettings.fontMinPixelSize );
345 mFontMaxPixelSpinBox->setValue( mSettings.fontMaxPixelSize );
347 mZIndexSpinBox->setValue( mSettings.zIndex );
349 mDataDefinedProperties = mSettings.dataDefinedProperties();
352 if ( mSettings.callout() )
354 whileBlocking( mCalloutsDrawCheckBox )->setChecked( mSettings.callout()->enabled() );
355 whileBlocking( mCalloutStyleComboBox )->setCurrentIndex( mCalloutStyleComboBox->findData( mSettings.callout()->type() ) );
356 updateCalloutWidget( mSettings.callout() );
361 whileBlocking( mCalloutStyleComboBox )->setCurrentIndex( mCalloutStyleComboBox->findData( defaultCallout->type() ) );
363 updateCalloutWidget( defaultCallout.get() );
366 updatePlacementWidgets();
367 updateLinePlacementOptions();
370 blockInitSignals(
false );
374 populateDataDefinedButtons();
376 enableDataDefinedAlignment( mCoordXDDBtn->isActive() && mCoordYDDBtn->isActive() );
382 mSettings = settings;
386 void QgsLabelingGui::blockInitSignals(
bool block )
388 chkLineAbove->blockSignals( block );
389 chkLineBelow->blockSignals( block );
390 mPlacePointBtnGrp->blockSignals( block );
391 mPlaceLineBtnGrp->blockSignals( block );
392 mPlacePolygonBtnGrp->blockSignals( block );
395 void QgsLabelingGui::setLabelMode( LabelMode mode )
398 mFieldExpressionWidget->setEnabled( mMode == Labels );
399 mLabelingFrame->setEnabled( mMode == Labels );
406 lyr.
drawLabels = ( mMode == Labels ) || !mLayer;
409 lyr.
fieldName = mFieldExpressionWidget->currentField( &isExpression );
415 QWidget *curPlacementWdgt = stackedPlacement->currentWidget();
419 lyr.
dist = mLineDistanceSpnBx->value();
420 lyr.
distUnits = mLineDistanceUnitWidget->unit();
423 if ( mQuadrantBtnGrp )
427 lyr.
xOffset = mPointOffsetXSpinBox->value();
428 lyr.
yOffset = mPointOffsetYSpinBox->value();
432 if ( chkLineAbove->isChecked() )
434 if ( chkLineBelow->isChecked() )
436 if ( chkLineOn->isChecked() )
438 if ( ! chkLineOrientationDependent->isChecked() )
440 if ( ( curPlacementWdgt == pagePoint && radAroundPoint->isChecked() )
441 || ( curPlacementWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
445 else if ( ( curPlacementWdgt == pagePoint && radOverPoint->isChecked() )
446 || ( curPlacementWdgt == pagePolygon && radOverCentroid->isChecked() ) )
450 else if ( curPlacementWdgt == pagePoint && radPredefinedOrder->isChecked() )
454 else if ( ( curPlacementWdgt == pageLine && radLineParallel->isChecked() )
455 || ( curPlacementWdgt == pagePolygon && radPolygonPerimeter->isChecked() ) )
459 else if ( curPlacementWdgt == pageLine && radLineCurved->isChecked() )
463 else if ( curPlacementWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() )
467 else if ( ( curPlacementWdgt == pageLine && radLineHorizontal->isChecked() )
468 || ( curPlacementWdgt == pagePolygon && radPolygonHorizontal->isChecked() ) )
472 else if ( radPolygonFree->isChecked() )
478 qFatal(
"Invalid settings" );
489 lyr.
priority = mPrioritySlider->value();
490 lyr.
obstacle = mChkNoObstacle->isChecked() || mMode == ObstaclesOnly;
494 lyr.
displayAll = mPalShowAllLabelsForLayerChkBx->isChecked();
507 lyr.
decimals = mFormatNumDecimalsSpnBx->value();
508 lyr.
plusSign = mFormatNumPlusSignChkBx->isChecked();
515 if ( mDirectSymbBtnGrp )
519 if ( mUpsidedownBtnGrp )
535 lyr.
wrapChar = wrapCharacterEdit->text();
544 lyr.
layerType = mLayer ? mLayer->geometryType() : mGeomType;
546 lyr.
zIndex = mZIndexSpinBox->value();
551 const QString calloutType = mCalloutStyleComboBox->currentData().toString();
552 std::unique_ptr< QgsCallout > callout;
553 if (
QgsCalloutWidget *pew = qobject_cast< QgsCalloutWidget * >( mCalloutStackedWidget->currentWidget() ) )
555 callout.reset( pew->callout()->clone() );
560 callout->
setEnabled( mCalloutsDrawCheckBox->isChecked() );
569 if ( ddBtn->
isActive() && !chkBx->isChecked() )
571 chkBx->setChecked(
true );
573 f->setEnabled( chkBx->isChecked() );
576 void QgsLabelingGui::updateUi()
580 syncDefinedCheckboxFrame( mBufferDrawDDBtn, mBufferDrawChkBx, mBufferFrame );
581 syncDefinedCheckboxFrame( mShapeDrawDDBtn, mShapeDrawChkBx, mShapeFrame );
582 syncDefinedCheckboxFrame( mShadowDrawDDBtn, mShadowDrawChkBx, mShadowFrame );
584 syncDefinedCheckboxFrame( mDirectSymbDDBtn, mDirectSymbChkBx, mDirectSymbFrame );
585 syncDefinedCheckboxFrame( mFormatNumDDBtn, mFormatNumChkBx, mFormatNumFrame );
586 syncDefinedCheckboxFrame( mScaleBasedVisibilityDDBtn, mScaleBasedVisibilityChkBx, mScaleBasedVisibilityFrame );
587 syncDefinedCheckboxFrame( mFontLimitPixelDDBtn, mFontLimitPixelChkBox, mFontLimitPixelFrame );
589 chkMergeLines->setEnabled( !mDirectSymbChkBx->isChecked() );
590 if ( mDirectSymbChkBx->isChecked() )
592 chkMergeLines->setToolTip( tr(
"This option is not compatible with line direction symbols." ) );
596 chkMergeLines->setToolTip( QString() );
624 settings.
fieldName = mFieldExpressionWidget->currentField( &isExpression );
627 setSettings( settings );
635 if (
QgsCalloutWidget *cw = qobject_cast< QgsCalloutWidget * >( mCalloutStackedWidget->currentWidget() ) )
637 cw->setContext( context );
642 void QgsLabelingGui::saveFormat()
649 saveDlg.setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
650 if ( !saveDlg.exec() )
653 if ( saveDlg.name().isEmpty() )
656 switch ( saveDlg.selectedType() )
663 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
664 tr(
"Format with name '%1' already exists. Overwrite?" )
665 .arg( saveDlg.name() ),
666 QMessageBox::Yes | QMessageBox::No );
667 if ( res != QMessageBox::Yes )
673 QStringList symbolTags = saveDlg.tags().split(
',' );
677 style->
saveTextFormat( saveDlg.name(), newFormat, saveDlg.isFavorite(), symbolTags );
686 int res = QMessageBox::warning(
this, tr(
"Save Label Settings" ),
687 tr(
"Label settings with the name '%1' already exist. Overwrite?" )
688 .arg( saveDlg.name() ),
689 QMessageBox::Yes | QMessageBox::No );
690 if ( res != QMessageBox::Yes )
696 QStringList symbolTags = saveDlg.tags().split(
',' );
700 style->
saveLabelSettings( saveDlg.name(), newSettings, saveDlg.isFavorite(), symbolTags );
712 void QgsLabelingGui::updateGeometryTypeBasedWidgets()
716 if ( mGeometryGeneratorGroupBox->isChecked() )
719 geometryType = mLayer->geometryType();
730 switch ( geometryType )
733 stackedPlacement->setCurrentWidget( pagePoint );
736 stackedPlacement->setCurrentWidget( pageLine );
739 stackedPlacement->setCurrentWidget( pagePolygon );
744 qFatal(
"unknown geometry type unexpected" );
750 if ( mFontMultiLineAlignComboBox->findText( tr(
"Follow label placement" ) ) == -1 )
751 mFontMultiLineAlignComboBox->addItem( tr(
"Follow label placement" ) );
755 int idx = mFontMultiLineAlignComboBox->findText( tr(
"Follow label placement" ) );
757 mFontMultiLineAlignComboBox->removeItem( idx );
760 updatePlacementWidgets();
761 updateLinePlacementOptions();
764 void QgsLabelingGui::showGeometryGeneratorExpressionBuilder()
768 expressionBuilder.setExpressionText( mGeometryGenerator->text() );
769 expressionBuilder.setExpressionContext( createExpressionContext() );
771 if ( expressionBuilder.exec() )
773 mGeometryGenerator->setText( expressionBuilder.expressionText() );
777 void QgsLabelingGui::validateGeometryGeneratorExpression()
781 if ( mGeometryGeneratorGroupBox->isChecked() )
783 if ( !mPreviewFeature.isValid() && mLayer )
784 mLayer->getFeatures(
QgsFeatureRequest().setLimit( 1 ) ).nextFeature( mPreviewFeature );
788 context.setFeature( mPreviewFeature );
790 expression.prepare( &context );
792 if ( expression.hasParserError() )
794 mGeometryGeneratorWarningLabel->setText( expression.parserErrorString() );
799 const QVariant result = expression.evaluate( &context );
804 mGeometryGeneratorWarningLabel->setText( tr(
"Result of the expression is not a geometry" ) );
807 else if ( geometry.
type() != configuredGeometryType )
809 mGeometryGeneratorWarningLabel->setText( QStringLiteral(
"<p>%1</p><p><a href=\"#determineGeometryGeneratorType\">%2</a></p>" ).arg(
810 tr(
"Result of the expression does not match configured geometry type." ),
819 QTimer *timer =
new QTimer();
820 connect( timer, &QTimer::timeout,
this, [
this, valid]()
822 mGeometryGeneratorWarningLabel->setVisible( !valid );
824 connect( timer, &QTimer::timeout, timer, &QTimer::deleteLater );
828 void QgsLabelingGui::determineGeometryGeneratorType()
830 if ( !mPreviewFeature.isValid() && mLayer )
831 mLayer->getFeatures(
QgsFeatureRequest().setLimit( 1 ) ).nextFeature( mPreviewFeature );
835 context.setFeature( mPreviewFeature );
837 expression.prepare( &context );
840 mGeometryGeneratorType->setCurrentIndex( mGeometryGeneratorType->findData( geometry.
type() ) );
843 void QgsLabelingGui::calloutTypeChanged()
845 QString newCalloutType = mCalloutStyleComboBox->currentData().toString();
865 updateCalloutWidget( newCallout.get() );
878 QVBoxLayout *vLayout =
new QVBoxLayout();
879 mWidget =
new QgsLabelingGui( layer, mapCanvas, settings,
nullptr, geomType );
880 vLayout->addWidget( mWidget );
881 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
882 connect( mButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
883 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
884 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsLabelSettingsDialog::showHelp );
885 vLayout->addWidget( mButtonBox );
886 setLayout( vLayout );
887 setWindowTitle( tr(
"Label Settings" ) );
890 QDialogButtonBox *QgsLabelSettingsDialog::buttonBox()
const 895 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.
double obstacleFactor
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, 1.0 less likely to be covered
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.
bool obstacle
true if features for layer are obstacles to labels of other layers.
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.
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.
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.
ObstacleType obstacleType
Controls how features act as obstacles for labels.
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.
int maxNumLabels
The maximum number of labels which should be drawn for this layer.
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.
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.
bool limitNumLabels
true if the number of labels drawn should be limited.
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.
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.
double minFeatureSize
Minimum feature size (in millimeters) for a feature to be labelled.
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.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
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.