30#include <QColorDialog>
35#include "moc_qgslayoutscalebarwidget.cpp"
37using namespace Qt::StringLiterals;
41 , mScalebar( scaleBar )
45 mNumberOfSubdivisionsSpinBox->setClearValue( 1 );
47 connect( mHeightSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mHeightSpinBox_valueChanged );
48 connect( mSegmentSizeSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mSegmentSizeSpinBox_valueChanged );
49 connect( mSegmentsLeftSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mSegmentsLeftSpinBox_valueChanged );
50 connect( mNumberOfSegmentsSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mNumberOfSegmentsSpinBox_valueChanged );
51 connect( mNumberOfSubdivisionsSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mNumberOfSubdivisionsSpinBox_valueChanged );
52 connect( mSubdivisionsHeightSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mSubdivisionsHeightSpinBox_valueChanged );
53 connect( mUnitLabelLineEdit, &QLineEdit::textChanged,
this, &QgsLayoutScaleBarWidget::mUnitLabelLineEdit_textChanged );
54 connect( mMapUnitsPerBarUnitSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mMapUnitsPerBarUnitSpinBox_valueChanged );
55 connect( mStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsLayoutScaleBarWidget::mStyleComboBox_currentIndexChanged );
56 connect( mLabelBarSpaceSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged );
57 connect( mBoxSizeSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mBoxSizeSpinBox_valueChanged );
59 connect( mDistanceLabelPlacementComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutScaleBarWidget::mDistanceLabelPlacementComboBox_currentIndexChanged );
60 connect( mUnitsComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged );
61 connect( mMinWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged );
62 connect( mMaxWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged );
63 connect( mNumberFormatPushButton, &QPushButton::clicked,
this, &QgsLayoutScaleBarWidget::changeNumberFormat );
70 disconnectUpdateSignal();
71 mScalebar->beginCommand( tr(
"Set Scalebar Method" ) );
72 mScalebar->setMethod( mScaleMethodWidget->scaleMethod() );
74 connectUpdateSignal();
75 mScalebar->endCommand();
87 mSegmentsLeftDDBtn->registerEnabledWidget( mSegmentsLeftSpinBox,
false );
88 mSegmentsRightDDBtn->registerEnabledWidget( mNumberOfSegmentsSpinBox,
false );
89 mSegmentSizeDDBtn->registerEnabledWidget( mSegmentSizeSpinBox,
false );
90 mMinWidthDDBtn->registerEnabledWidget( mMinWidthSpinBox,
false );
91 mMaxWidthDDBtn->registerEnabledWidget( mMaxWidthSpinBox,
false );
95 mFontButton->registerExpressionContextGenerator(
this );
97 connectUpdateSignal();
101 mainLayout->addWidget( mItemPropertiesWidget );
103 mSegmentSizeRadioGroup.addButton( mFixedSizeRadio );
104 mSegmentSizeRadioGroup.addButton( mFitWidthRadio );
105 connect( &mSegmentSizeRadioGroup,
static_cast<void ( QButtonGroup::* )( QAbstractButton * )
>( &QButtonGroup::buttonClicked ),
this, &QgsLayoutScaleBarWidget::segmentSizeRadioChanged );
107 blockMemberSignals(
true );
111 for (
const QString &renderer : renderers )
117 mDistanceLabelPlacementComboBox->addItem( tr(
"Above Segment Edges" ),
static_cast<int>( DistanceLabelPlacement::CenteredAboveSegmentEdges ) );
118 mDistanceLabelPlacementComboBox->addItem( tr(
"Above Segment Centers" ),
static_cast<int>( DistanceLabelPlacement::CenteredAboveSegmentCenters ) );
119 mDistanceLabelPlacementComboBox->addItem( tr(
"Below Segment Edges" ),
static_cast<int>( DistanceLabelPlacement::CenteredBelowSegmentEdges ) );
120 mDistanceLabelPlacementComboBox->addItem( tr(
"Below Segment Centers" ),
static_cast<int>( DistanceLabelPlacement::CenteredBelowSegmentCenters ) );
123 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
160 connect( mSubdivisionStyleButton, &
QgsSymbolButton::changed,
this, &QgsLayoutScaleBarWidget::subdivisionSymbolChanged );
168 mFontButton->setDialogTitle( tr(
"Scalebar Font" ) );
173 QgsLayout *scaleBarLayout = mScalebar->layout();
174 if ( scaleBarLayout )
176 mMapItemComboBox->setCurrentLayout( scaleBarLayout );
183 blockMemberSignals(
false );
186 mLineStyleButton->registerExpressionContextGenerator( mScalebar );
188 mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
190 mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
192 mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
194 mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
199 if ( mScalebar->layout() )
212 if ( mItemPropertiesWidget )
213 mItemPropertiesWidget->setMasterLayout( masterLayout );
231 disconnectUpdateSignal();
233 mScalebar = qobject_cast<QgsLayoutItemScaleBar *>( item );
234 mItemPropertiesWidget->setItem( mScalebar );
238 connectUpdateSignal();
239 mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
240 mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
241 mLineStyleButton->registerExpressionContextGenerator( mScalebar );
242 mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
243 mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
251void QgsLayoutScaleBarWidget::lineSymbolChanged()
257 mScalebar->setLineSymbol( mLineStyleButton->clonedSymbol<
QgsLineSymbol>() );
259 mScalebar->layout()->undoStack()->endCommand();
262void QgsLayoutScaleBarWidget::divisionSymbolChanged()
268 mScalebar->setDivisionLineSymbol( mDivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
270 mScalebar->layout()->undoStack()->endCommand();
273void QgsLayoutScaleBarWidget::subdivisionSymbolChanged()
279 mScalebar->setSubdivisionLineSymbol( mSubdivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
281 mScalebar->layout()->undoStack()->endCommand();
284void QgsLayoutScaleBarWidget::fillSymbol1Changed()
290 mScalebar->setFillSymbol( mFillSymbol1Button->clonedSymbol<QgsFillSymbol>() );
292 mScalebar->layout()->undoStack()->endCommand();
295void QgsLayoutScaleBarWidget::fillSymbol2Changed()
301 mScalebar->setAlternateFillSymbol( mFillSymbol2Button->clonedSymbol<QgsFillSymbol>() );
303 mScalebar->layout()->undoStack()->endCommand();
306void QgsLayoutScaleBarWidget::setGuiElements()
313 blockMemberSignals(
true );
314 mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
315 mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
316 mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
317 mHeightSpinBox->setValue( mScalebar->height() );
318 mNumberOfSubdivisionsSpinBox->setValue( mScalebar->numberOfSubdivisions() );
319 mSubdivisionsHeightSpinBox->setValue( mScalebar->subdivisionsHeight() );
320 mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
321 mLabelBarSpaceSpinBox->setValue( mScalebar->labelBarSpace() );
322 mBoxSizeSpinBox->setValue( mScalebar->boxContentSpace() );
323 mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
324 mFontButton->setTextFormat( mScalebar->textFormat() );
326 whileBlocking( mLineStyleButton )->setSymbol( mScalebar->lineSymbol()->clone() );
327 whileBlocking( mDivisionStyleButton )->setSymbol( mScalebar->divisionLineSymbol()->clone() );
328 whileBlocking( mSubdivisionStyleButton )->setSymbol( mScalebar->subdivisionLineSymbol()->clone() );
329 whileBlocking( mFillSymbol1Button )->setSymbol( mScalebar->fillSymbol()->clone() );
330 whileBlocking( mFillSymbol2Button )->setSymbol( mScalebar->alternateFillSymbol()->clone() );
333 mMapItemComboBox->setItem( mScalebar->linkedMap() );
336 const QString style = mScalebar->style();
337 mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( style ) );
338 toggleStyleSpecificControls( style );
341 mDistanceLabelPlacementComboBox->setCurrentIndex(
342 mDistanceLabelPlacementComboBox->findData(
static_cast<int>( distanceLabelPlacement( mScalebar->labelHorizontalPlacement(), mScalebar->labelVerticalPlacement() ) ) )
349 Qt::Alignment a = Qt::AlignLeft;
350 switch ( mScalebar->alignment() )
359 a = Qt::AlignHCenter;
362 mAlignmentComboBox->setCurrentAlignment( a );
365 mUnitsComboBox->setCurrentIndex( mUnitsComboBox->findData(
static_cast<int>( mScalebar->units() ) ) );
367 switch ( mScalebar->segmentSizeMode() )
371 mFixedSizeRadio->setChecked(
true );
372 mSegmentSizeWidget->setEnabled(
true );
373 mMinWidthWidget->setEnabled(
false );
374 mMaxWidthWidget->setEnabled(
false );
380 mFitWidthRadio->setChecked(
true );
381 mSegmentSizeWidget->setEnabled(
false );
382 mMinWidthWidget->setEnabled(
true );
383 mMaxWidthWidget->setEnabled(
true );
387 mMinWidthSpinBox->setValue( mScalebar->minimumBarWidth() );
388 mMaxWidthSpinBox->setValue( mScalebar->maximumBarWidth() );
390 mScaleMethodWidget->setScaleMethod( mScalebar->method() );
392 populateDataDefinedButtons();
394 blockMemberSignals(
false );
399void QgsLayoutScaleBarWidget::mSegmentSizeSpinBox_valueChanged(
double d )
407 disconnectUpdateSignal();
408 mScalebar->setUnitsPerSegment( d );
410 connectUpdateSignal();
411 mScalebar->endCommand();
414void QgsLayoutScaleBarWidget::mSegmentsLeftSpinBox_valueChanged(
int i )
422 disconnectUpdateSignal();
423 mScalebar->setNumberOfSegmentsLeft( i );
425 connectUpdateSignal();
426 mScalebar->endCommand();
429void QgsLayoutScaleBarWidget::mNumberOfSegmentsSpinBox_valueChanged(
int i )
437 disconnectUpdateSignal();
438 mScalebar->setNumberOfSegments( i );
440 connectUpdateSignal();
441 mScalebar->endCommand();
444void QgsLayoutScaleBarWidget::mHeightSpinBox_valueChanged(
double d )
451 disconnectUpdateSignal();
452 mScalebar->setHeight( d );
454 connectUpdateSignal();
455 mScalebar->endCommand();
458void QgsLayoutScaleBarWidget::mNumberOfSubdivisionsSpinBox_valueChanged(
int i )
466 disconnectUpdateSignal();
467 mScalebar->setNumberOfSubdivisions( i );
469 connectUpdateSignal();
470 mScalebar->endCommand();
473void QgsLayoutScaleBarWidget::mSubdivisionsHeightSpinBox_valueChanged(
double d )
480 disconnectUpdateSignal();
481 mScalebar->setSubdivisionsHeight( d );
483 connectUpdateSignal();
484 mScalebar->endCommand();
487void QgsLayoutScaleBarWidget::textFormatChanged()
494 mScalebar->beginCommand( tr(
"Set Scalebar Font" ) );
495 disconnectUpdateSignal();
496 mScalebar->setTextFormat( mFontButton->textFormat() );
497 connectUpdateSignal();
498 mScalebar->endCommand();
502void QgsLayoutScaleBarWidget::changeNumberFormat()
509 QgsNumericFormatSelectorWidget *widget =
new QgsNumericFormatSelectorWidget(
this );
511 widget->
setFormat( mScalebar->numericFormat() );
513 mScalebar->beginCommand( tr(
"Set Scalebar Number Format" ) );
514 disconnectUpdateSignal();
515 mScalebar->setNumericFormat( widget->
format() );
516 connectUpdateSignal();
517 mScalebar->endCommand();
524QgsLayoutScaleBarWidget::DistanceLabelPlacement QgsLayoutScaleBarWidget::distanceLabelPlacement(
528 switch ( horizontalPlacement )
531 switch ( verticalPlacement )
534 return DistanceLabelPlacement::CenteredAboveSegmentEdges;
536 return DistanceLabelPlacement::CenteredBelowSegmentEdges;
541 switch ( verticalPlacement )
544 return DistanceLabelPlacement::CenteredAboveSegmentCenters;
546 return DistanceLabelPlacement::CenteredBelowSegmentCenters;
553void QgsLayoutScaleBarWidget::mUnitLabelLineEdit_textChanged(
const QString &text )
561 disconnectUpdateSignal();
562 mScalebar->setUnitLabel( text );
564 connectUpdateSignal();
565 mScalebar->endCommand();
568void QgsLayoutScaleBarWidget::mMapUnitsPerBarUnitSpinBox_valueChanged(
double d )
576 disconnectUpdateSignal();
577 mScalebar->setMapUnitsPerScaleBarUnit( d );
579 connectUpdateSignal();
580 mScalebar->endCommand();
583void QgsLayoutScaleBarWidget::mStyleComboBox_currentIndexChanged(
const QString & )
590 const QString rendererId = mStyleComboBox->currentData().toString();
591 if ( rendererId == mScalebar->style() )
594 mScalebar->beginCommand( tr(
"Set Scalebar Style" ) );
595 disconnectUpdateSignal();
597 bool defaultsApplied =
false;
600 defaultsApplied = mScalebar->applyDefaultRendererSettings( renderer.get() );
603 toggleStyleSpecificControls( rendererId );
605 mScalebar->setStyle( rendererId );
607 connectUpdateSignal();
608 mScalebar->endCommand();
610 if ( defaultsApplied )
614void QgsLayoutScaleBarWidget::toggleStyleSpecificControls(
const QString &style )
630 if ( !mGroupBoxUnits->isEnabled() )
631 mGroupBoxSegments->setCollapsed(
true );
635 mLabelVerticalPlacementLabel->setEnabled(
652void QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged(
double d )
660 disconnectUpdateSignal();
661 mScalebar->setLabelBarSpace( d );
663 connectUpdateSignal();
664 mScalebar->endCommand();
667void QgsLayoutScaleBarWidget::mBoxSizeSpinBox_valueChanged(
double d )
675 disconnectUpdateSignal();
676 mScalebar->setBoxContentSpace( d );
678 connectUpdateSignal();
679 mScalebar->endCommand();
682void QgsLayoutScaleBarWidget::mDistanceLabelPlacementComboBox_currentIndexChanged(
int index )
689 mScalebar->beginCommand( tr(
"Set Scalebar Label Placement" ) );
690 disconnectUpdateSignal();
692 const DistanceLabelPlacement placement =
static_cast<DistanceLabelPlacement
>( mDistanceLabelPlacementComboBox->itemData( index ).toInt() );
695 case DistanceLabelPlacement::CenteredAboveSegmentEdges:
699 case DistanceLabelPlacement::CenteredAboveSegmentCenters:
703 case DistanceLabelPlacement::CenteredBelowSegmentEdges:
707 case DistanceLabelPlacement::CenteredBelowSegmentCenters:
714 connectUpdateSignal();
715 mScalebar->endCommand();
718void QgsLayoutScaleBarWidget::alignmentChanged()
725 mScalebar->beginCommand( tr(
"Set Scalebar Alignment" ) );
726 disconnectUpdateSignal();
731 mScalebar->setAlignment( a );
733 connectUpdateSignal();
734 mScalebar->endCommand();
737void QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged(
int index )
744 const QVariant unitData = mUnitsComboBox->itemData( index );
745 if ( unitData.userType() == QMetaType::Type::UnknownType )
750 disconnectUpdateSignal();
751 mScalebar->beginCommand( tr(
"Set Scalebar Units" ) );
755 mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
756 mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
757 mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
758 mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
759 mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
761 connectUpdateSignal();
762 mScalebar->endCommand();
765void QgsLayoutScaleBarWidget::blockMemberSignals(
bool block )
767 mSegmentSizeSpinBox->blockSignals( block );
768 mNumberOfSegmentsSpinBox->blockSignals( block );
769 mSegmentsLeftSpinBox->blockSignals( block );
770 mNumberOfSubdivisionsSpinBox->blockSignals( block );
771 mSubdivisionsHeightSpinBox->blockSignals( block );
772 mStyleComboBox->blockSignals( block );
773 mUnitLabelLineEdit->blockSignals( block );
774 mMapUnitsPerBarUnitSpinBox->blockSignals( block );
775 mHeightSpinBox->blockSignals( block );
776 mLineStyleButton->blockSignals( block );
777 mDivisionStyleButton->blockSignals( block );
778 mSubdivisionStyleButton->blockSignals( block );
779 mLabelBarSpaceSpinBox->blockSignals( block );
780 mBoxSizeSpinBox->blockSignals( block );
781 mDistanceLabelPlacementComboBox->blockSignals( block );
782 mAlignmentComboBox->blockSignals( block );
783 mUnitsComboBox->blockSignals( block );
784 mFillSymbol1Button->blockSignals( block );
785 mFillSymbol2Button->blockSignals( block );
786 mSegmentSizeRadioGroup.blockSignals( block );
787 mMapItemComboBox->blockSignals( block );
788 mFontButton->blockSignals( block );
789 mMinWidthSpinBox->blockSignals( block );
790 mMaxWidthSpinBox->blockSignals( block );
791 mScaleMethodWidget->blockSignals( block );
792 mUnitLabelPlacementComboBox->blockSignals( block );
795void QgsLayoutScaleBarWidget::connectUpdateSignal()
803void QgsLayoutScaleBarWidget::disconnectUpdateSignal()
811void QgsLayoutScaleBarWidget::segmentSizeRadioChanged( QAbstractButton *radio )
813 const bool fixedSizeMode = radio == mFixedSizeRadio;
814 mMinWidthWidget->setEnabled( !fixedSizeMode );
815 mMaxWidthWidget->setEnabled( !fixedSizeMode );
816 mSegmentSizeWidget->setEnabled( fixedSizeMode );
824 disconnectUpdateSignal();
825 if ( mFixedSizeRadio->isChecked() )
828 mScalebar->setUnitsPerSegment( mSegmentSizeSpinBox->value() );
835 connectUpdateSignal();
836 mScalebar->endCommand();
839void QgsLayoutScaleBarWidget::mapChanged(
QgsLayoutItem *item )
841 QgsLayoutItemMap *map = qobject_cast<QgsLayoutItemMap *>( item );
848 mScalebar->beginCommand( tr(
"Set Scalebar Map" ) );
849 disconnectUpdateSignal();
850 mScalebar->setLinkedMap( map );
852 connectUpdateSignal();
853 mScalebar->endCommand();
855 mUnitsComboBox->setItemText( mUnitsComboBox->findData(
static_cast<int>(
Qgis::DistanceUnit::Unknown ) ), linkedMapUnitsString( mScalebar ) );
858void QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged(
double )
866 disconnectUpdateSignal();
867 mScalebar->setMinimumBarWidth( mMinWidthSpinBox->value() );
869 connectUpdateSignal();
870 mScalebar->endCommand();
873void QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged(
double )
881 disconnectUpdateSignal();
882 mScalebar->setMaximumBarWidth( mMaxWidthSpinBox->value() );
884 connectUpdateSignal();
885 mScalebar->endCommand();
888void QgsLayoutScaleBarWidget::labelUnitPlacementChanged()
895 mScalebar->beginCommand( tr(
"Set Scalebar Label Unit Placement" ) );
896 disconnectUpdateSignal();
899 connectUpdateSignal();
900 mScalebar->endCommand();
903void QgsLayoutScaleBarWidget::populateDataDefinedButtons()
920 if ( QgsLayoutItemMap *map = scalebar->
linkedMap() )
929 return mapUnit.isEmpty() ? tr(
"Map Units" ) : tr(
"Map Units (%1)" ).arg( mapUnit );
ScaleBarDistanceLabelHorizontalPlacement
Scale bar distance label horizontal placement.
@ CenteredSegment
Labels are drawn centered relative to segment.
@ CenteredEdge
Labels are drawn centered relative to segment's edge.
ScaleBarDistanceLabelVerticalPlacement
Scale bar distance label vertical placement.
@ AboveSegment
Labels are drawn above the scalebar.
@ BelowSegment
Labels are drawn below the scalebar.
ScaleBarAlignment
Scalebar alignment.
DistanceUnit
Units of distance.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Unknown
Unknown distance unit.
@ NauticalMiles
Nautical miles.
ScaleBarUnitLabelPlacement
Available placement options for a scale bar's unit label.
@ AfterLastDistanceLabel
Placed after the last distance label.
@ CenteredBelow
Horizontally centered on the bar, below the bar.
@ LeftAbove
Text centered over the left edge of the bar, above the bar.
@ AfterBar
Vertically centered on the bar, after the bar ends.
@ BeforeBar
Vertically centered on the bar, before the bar begins.
@ BeforeEveryDistanceLabel
Placed before every distance label (as part of the distance label text).
@ CenteredAbove
Horizontally centered on the bar, above the bar.
@ RightBelow
Text centered over the right edge of the bar, below the bar.
@ OnBarAfterFirstDivision
Placed on top of the bar, after the first bar division.
@ BeforeFirstDistanceLabel
Placed before the first distance label.
@ RightAbove
Text centered over the right edge of the bar, above the bar.
@ AfterEveryDistanceLabel
Placed after every distance label (as part of the distance label text).
@ LeftBelow
Text centered over the left edge of the bar, below the bar.
@ FitWidth
Scale bar segment size is calculated to fit a size range.
@ Fixed
Scale bar segment size is fixed to a map unit.
void changed()
Emitted when the alignment is changed.
static QgsScaleBarRendererRegistry * scaleBarRendererRegistry()
Gets the registry of available scalebar renderers.
void checkedItemsChanged(const QStringList &items)
Emitted whenever the checked items list changed.
Qgis::DistanceUnit mapUnits
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used for rendering the map.
@ LayoutScaleBar
Scale bar item.
A layout item subclass for scale bars.
QgsLayoutItemMap * linkedMap() const
Returns the map item linked to the scalebar.
Base class for graphical items within a QgsLayout.
@ UndoScaleBarSubdivisionsHeight
Scalebar subdivisions height.
@ UndoScaleBarLabelBarSize
Scalebar label bar size.
@ UndoScaleBarMapUnitsSegment
Scalebar map units per segment.
@ UndoScaleBarBoxContentSpace
Scalebar box context space.
@ UndoScaleBarSegmentSize
Scalebar segment size.
@ UndoScaleBarHeight
Scalebar height.
@ UndoScaleBarSegments
Scalebar number of segments.
@ UndoScaleBarSubdivisions
Scalebar number of subdivisions.
@ UndoShapeStyle
Shape symbol style.
@ UndoScaleBarSegmentsLeft
Scalebar segments left.
@ UndoScaleBarUnitText
Scalebar unit text.
int type() const override
Returns a unique graphics item type identifier.
void changed()
Emitted when the object's properties change.
@ ScalebarMinimumWidth
Scalebar segment minimum width.
@ ScalebarRightSegments
Number of segments on the right of 0.
@ ScalebarRightSegmentSubdivisions
Number of subdivisions per segment on right of 0.
@ ScalebarMaximumWidth
Scalebar segment maximum width.
@ ScalebarHeight
Scalebar height.
@ ScalebarSubdivisionHeight
Scalebar subdivision height.
@ ScalebarLeftSegments
Number of segments on the left of 0.
@ ScalebarSegmentWidth
Scalebar width in map units of a single segment.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
A line symbol type, for rendering LineString and MultiLineString geometries.
Interface for master layout type objects, such as print layouts and reports.
QStringList sortedRendererList() const
Returns a list of the renderer ids currently contained in the registry, sorted in an order respecting...
@ FlagUsesLabelVerticalPlacement
Renderer uses the QgsScaleBarSettings::labelVerticalPlacement() setting.
@ FlagUsesLabelHorizontalPlacement
Renderer uses the QgsScaleBarSettings::labelHorizontalPlacement() setting.
@ FlagUsesLineSymbol
Renderer utilizes the scalebar line symbol (see QgsScaleBarSettings::lineSymbol() ).
@ FlagUsesUnitLabel
Renderer uses the QgsScaleBarSettings::unitLabel() setting.
@ FlagUsesSubdivisionsHeight
Renderer uses the scalebar subdivisions height (see QgsScaleBarSettings::subdivisionsHeight() ).
@ FlagUsesSubdivisionSymbol
Renderer utilizes the scalebar subdivision symbol (see QgsScaleBarSettings::subdivisionLineSymbol() )...
@ FlagUsesSegments
Renderer uses the scalebar segments.
@ FlagUsesLabelBarSpace
Renderer uses the QgsScaleBarSettings::labelBarSpace() setting.
@ FlagUsesAlignment
Renderer uses the QgsScaleBarSettings::alignment() setting.
@ FlagUsesFillSymbol
Renderer utilizes the scalebar fill symbol (see QgsScaleBarSettings::fillSymbol() ).
@ FlagRespectsMapUnitsPerScaleBarUnit
Renderer respects the QgsScaleBarSettings::mapUnitsPerScaleBarUnit() setting.
@ FlagRespectsUnits
Renderer respects the QgsScaleBarSettings::units() setting.
@ FlagUsesAlternateFillSymbol
Renderer utilizes the alternate scalebar fill symbol (see QgsScaleBarSettings::alternateFillSymbol() ...
@ FlagUsesSubdivisions
Renderer uses the scalebar subdivisions (see QgsScaleBarSettings::numberOfSubdivisions() ).
@ FlagUsesDivisionSymbol
Renderer utilizes the scalebar division symbol (see QgsScaleBarSettings::divisionLineSymbol() ).
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
#define BUILTIN_UNREACHABLE
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Single variable definition for use within a QgsExpressionContextScope.