QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgslayoutscalebarwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutscalebarwidget.cpp
3 -----------------------------
4 begin : 11 June 2008
5 copyright : (C) 2008 by Marco Hugentobler
6 email : marco dot hugentobler at karto dot baug dot ethz dot ch
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
18#include "qgslayoutitemmap.h"
21#include "qgslayout.h"
22#include "qgsvectorlayer.h"
24#include "qgslayoutundostack.h"
25#include "qgsfillsymbol.h"
26#include "qgslinesymbol.h"
28
29#include <QColorDialog>
30#include <QFontDialog>
31#include <QWidget>
32
34 : QgsLayoutItemBaseWidget( nullptr, scaleBar )
35 , mScalebar( scaleBar )
36{
37 setupUi( this );
38
39 mNumberOfSubdivisionsSpinBox->setClearValue( 1 );
40
41 connect( mHeightSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mHeightSpinBox_valueChanged );
42 connect( mSegmentSizeSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mSegmentSizeSpinBox_valueChanged );
43 connect( mSegmentsLeftSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mSegmentsLeftSpinBox_valueChanged );
44 connect( mNumberOfSegmentsSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mNumberOfSegmentsSpinBox_valueChanged );
45 connect( mNumberOfSubdivisionsSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mNumberOfSubdivisionsSpinBox_valueChanged );
46 connect( mSubdivisionsHeightSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mSubdivisionsHeightSpinBox_valueChanged );
47 connect( mUnitLabelLineEdit, &QLineEdit::textChanged, this, &QgsLayoutScaleBarWidget::mUnitLabelLineEdit_textChanged );
48 connect( mMapUnitsPerBarUnitSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mMapUnitsPerBarUnitSpinBox_valueChanged );
49 connect( mStyleComboBox, &QComboBox::currentTextChanged, this, &QgsLayoutScaleBarWidget::mStyleComboBox_currentIndexChanged );
50 connect( mLabelBarSpaceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged );
51 connect( mBoxSizeSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mBoxSizeSpinBox_valueChanged );
52 connect( mAlignmentComboBox, &QgsAlignmentComboBox::changed, this, &QgsLayoutScaleBarWidget::alignmentChanged );
53 connect( mLabelVerticalPlacementComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutScaleBarWidget::mLabelVerticalPlacementComboBox_currentIndexChanged );
54 connect( mLabelHorizontalPlacementComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutScaleBarWidget::mLabelHorizontalPlacementComboBox_currentIndexChanged );
55 connect( mUnitsComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged );
56 connect( mMinWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged );
57 connect( mMaxWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged );
58 connect( mNumberFormatPushButton, &QPushButton::clicked, this, &QgsLayoutScaleBarWidget::changeNumberFormat );
59
68
69 mSegmentsLeftDDBtn->registerEnabledWidget( mSegmentsLeftSpinBox, false );
70 mSegmentsRightDDBtn->registerEnabledWidget( mNumberOfSegmentsSpinBox, false );
71 mSegmentSizeDDBtn->registerEnabledWidget( mSegmentSizeSpinBox, false );
72 mMinWidthDDBtn->registerEnabledWidget( mMinWidthSpinBox, false );
73 mMaxWidthDDBtn->registerEnabledWidget( mMaxWidthSpinBox, false );
74
75 setPanelTitle( tr( "Scalebar Properties" ) );
76
77 mFontButton->registerExpressionContextGenerator( this );
78
79 connectUpdateSignal();
80
81 //add widget for general composer item properties
82 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, scaleBar );
83 mainLayout->addWidget( mItemPropertiesWidget );
84
85 mSegmentSizeRadioGroup.addButton( mFixedSizeRadio );
86 mSegmentSizeRadioGroup.addButton( mFitWidthRadio );
87 connect( &mSegmentSizeRadioGroup, static_cast < void ( QButtonGroup::* )( QAbstractButton * ) > ( &QButtonGroup::buttonClicked ), this, &QgsLayoutScaleBarWidget::segmentSizeRadioChanged );
88
89 blockMemberSignals( true );
90
91 //style combo box
92 const QStringList renderers = QgsApplication::scaleBarRendererRegistry()->sortedRendererList();
93 for ( const QString &renderer : renderers )
94 {
95 mStyleComboBox->addItem( QgsApplication::scaleBarRendererRegistry()->visibleName( renderer ), renderer );
96 }
97
98 //label vertical/horizontal placement combo box
99 mLabelVerticalPlacementComboBox->addItem( tr( "Above Segments" ), static_cast< int >( QgsScaleBarSettings::LabelAboveSegment ) );
100 mLabelVerticalPlacementComboBox->addItem( tr( "Below Segments" ), static_cast< int >( QgsScaleBarSettings::LabelBelowSegment ) );
101 mLabelHorizontalPlacementComboBox->addItem( tr( "Centered at Segment Edge" ), static_cast< int >( QgsScaleBarSettings::LabelCenteredEdge ) );
102 mLabelHorizontalPlacementComboBox->addItem( tr( "Centered at Center of Segment" ), static_cast< int >( QgsScaleBarSettings::LabelCenteredSegment ) );
103
104 //alignment combo box
105 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
106
107 //units combo box
108 mUnitsComboBox->addItem( tr( "Map units" ), static_cast< int >( Qgis::DistanceUnit::Unknown ) );
109 mUnitsComboBox->addItem( tr( "Meters" ), static_cast< int >( Qgis::DistanceUnit::Meters ) );
110 mUnitsComboBox->addItem( tr( "Kilometers" ), static_cast< int >( Qgis::DistanceUnit::Kilometers ) );
111 mUnitsComboBox->addItem( tr( "Feet" ), static_cast< int >( Qgis::DistanceUnit::Feet ) );
112 mUnitsComboBox->addItem( tr( "Yards" ), static_cast< int >( Qgis::DistanceUnit::Yards ) );
113 mUnitsComboBox->addItem( tr( "Miles" ), static_cast< int >( Qgis::DistanceUnit::Miles ) );
114 mUnitsComboBox->addItem( tr( "Nautical Miles" ), static_cast< int >( Qgis::DistanceUnit::NauticalMiles ) );
115 mUnitsComboBox->addItem( tr( "Centimeters" ), static_cast< int >( Qgis::DistanceUnit::Centimeters ) );
116 mUnitsComboBox->addItem( tr( "Millimeters" ), static_cast< int >( Qgis::DistanceUnit::Millimeters ) );
117
118 mLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
119 connect( mLineStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::lineSymbolChanged );
120
121 mDivisionStyleButton->setSymbolType( Qgis::SymbolType::Line );
122 connect( mDivisionStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::divisionSymbolChanged );
123
124 mSubdivisionStyleButton->setSymbolType( Qgis::SymbolType::Line );
125 connect( mSubdivisionStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::subdivisionSymbolChanged );
126
127 mFillSymbol1Button->setSymbolType( Qgis::SymbolType::Fill );
128 connect( mFillSymbol1Button, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::fillSymbol1Changed );
129
130 mFillSymbol2Button->setSymbolType( Qgis::SymbolType::Fill );
131 connect( mFillSymbol2Button, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::fillSymbol2Changed );
132
133 mFontButton->setDialogTitle( tr( "Scalebar Font" ) );
134 mFontButton->setMode( QgsFontButton::ModeTextRenderer );
135
136 if ( mScalebar )
137 {
138 QgsLayout *scaleBarLayout = mScalebar->layout();
139 if ( scaleBarLayout )
140 {
141 mMapItemComboBox->setCurrentLayout( scaleBarLayout );
142 mMapItemComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
143 }
144 }
145
146 connect( mMapItemComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutScaleBarWidget::mapChanged );
147
148 blockMemberSignals( false );
149 setGuiElements(); //set the GUI elements to the state of scaleBar
150
151 mLineStyleButton->registerExpressionContextGenerator( mScalebar );
152 mLineStyleButton->setLayer( coverageLayer() );
153 mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
154 mDivisionStyleButton->setLayer( coverageLayer() );
155 mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
156 mSubdivisionStyleButton->setLayer( coverageLayer() );
157 mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
158 mFillSymbol1Button->setLayer( coverageLayer() );
159 mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
160 mFillSymbol2Button->setLayer( coverageLayer() );
161
162 connect( mFontButton, &QgsFontButton::changed, this, &QgsLayoutScaleBarWidget::textFormatChanged );
163 mFontButton->setLayer( coverageLayer() );
164 if ( mScalebar->layout() )
165 {
166 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFontButton, &QgsFontButton::setLayer );
167 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mLineStyleButton, &QgsSymbolButton::setLayer );
168 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mDivisionStyleButton, &QgsSymbolButton::setLayer );
169 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mSubdivisionStyleButton, &QgsSymbolButton::setLayer );
170 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFillSymbol1Button, &QgsSymbolButton::setLayer );
171 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFillSymbol2Button, &QgsSymbolButton::setLayer );
172 }
173}
174
176{
177 if ( mItemPropertiesWidget )
178 mItemPropertiesWidget->setMasterLayout( masterLayout );
179}
180
182{
183 QgsExpressionContext context = mScalebar->createExpressionContext();
184 QgsExpressionContextScope *scaleScope = new QgsExpressionContextScope( QStringLiteral( "scalebar_text" ) );
185 scaleScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "scale_value" ), 0, true, false ) );
186 context.appendScope( scaleScope );
187 context.setHighlightedVariables( QStringList() << QStringLiteral( "scale_value" ) );
188 return context;
189}
190
192{
194 return false;
195
196 disconnectUpdateSignal();
197
198 mScalebar = qobject_cast< QgsLayoutItemScaleBar * >( item );
199 mItemPropertiesWidget->setItem( mScalebar );
200
201 if ( mScalebar )
202 {
203 connectUpdateSignal();
204 mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
205 mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
206 mLineStyleButton->registerExpressionContextGenerator( mScalebar );
207 mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
208 mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
209 }
210
211 setGuiElements();
212
213 return true;
214}
215
216void QgsLayoutScaleBarWidget::lineSymbolChanged()
217{
218 if ( !mScalebar )
219 return;
220
221 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Line Style" ), QgsLayoutItem::UndoShapeStyle );
222 mScalebar->setLineSymbol( mLineStyleButton->clonedSymbol<QgsLineSymbol>() );
223 mScalebar->update();
224 mScalebar->layout()->undoStack()->endCommand();
225}
226
227void QgsLayoutScaleBarWidget::divisionSymbolChanged()
228{
229 if ( !mScalebar )
230 return;
231
232 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Division Style" ), QgsLayoutItem::UndoShapeStyle );
233 mScalebar->setDivisionLineSymbol( mDivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
234 mScalebar->update();
235 mScalebar->layout()->undoStack()->endCommand();
236}
237
238void QgsLayoutScaleBarWidget::subdivisionSymbolChanged()
239{
240 if ( !mScalebar )
241 return;
242
243 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Subdivision Style" ), QgsLayoutItem::UndoShapeStyle );
244 mScalebar->setSubdivisionLineSymbol( mSubdivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
245 mScalebar->update();
246 mScalebar->layout()->undoStack()->endCommand();
247}
248
249void QgsLayoutScaleBarWidget::fillSymbol1Changed()
250{
251 if ( !mScalebar )
252 return;
253
254 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Fill Style" ), QgsLayoutItem::UndoShapeStyle );
255 mScalebar->setFillSymbol( mFillSymbol1Button->clonedSymbol<QgsFillSymbol>() );
256 mScalebar->update();
257 mScalebar->layout()->undoStack()->endCommand();
258}
259
260void QgsLayoutScaleBarWidget::fillSymbol2Changed()
261{
262 if ( !mScalebar )
263 return;
264
265 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Fill Style" ), QgsLayoutItem::UndoShapeStyle );
266 mScalebar->setAlternateFillSymbol( mFillSymbol2Button->clonedSymbol<QgsFillSymbol>() );
267 mScalebar->update();
268 mScalebar->layout()->undoStack()->endCommand();
269}
270
271void QgsLayoutScaleBarWidget::setGuiElements()
272{
273 if ( !mScalebar )
274 {
275 return;
276 }
277
278 blockMemberSignals( true );
279 mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
280 mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
281 mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
282 mHeightSpinBox->setValue( mScalebar->height() );
283 mNumberOfSubdivisionsSpinBox->setValue( mScalebar->numberOfSubdivisions() );
284 mSubdivisionsHeightSpinBox->setValue( mScalebar->subdivisionsHeight() );
285 mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
286 mLabelBarSpaceSpinBox->setValue( mScalebar->labelBarSpace() );
287 mBoxSizeSpinBox->setValue( mScalebar->boxContentSpace() );
288 mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
289 mFontButton->setTextFormat( mScalebar->textFormat() );
290
291 whileBlocking( mLineStyleButton )->setSymbol( mScalebar->lineSymbol()->clone() );
292 whileBlocking( mDivisionStyleButton )->setSymbol( mScalebar->divisionLineSymbol()->clone() );
293 whileBlocking( mSubdivisionStyleButton )->setSymbol( mScalebar->subdivisionLineSymbol()->clone() );
294 whileBlocking( mFillSymbol1Button )->setSymbol( mScalebar->fillSymbol()->clone() );
295 whileBlocking( mFillSymbol2Button )->setSymbol( mScalebar->alternateFillSymbol()->clone() );
296
297 //map combo box
298 mMapItemComboBox->setItem( mScalebar->linkedMap() );
299
300 //style...
301 const QString style = mScalebar->style();
302 mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( style ) );
303 toggleStyleSpecificControls( style );
304
305 //label vertical/horizontal placement
306 mLabelVerticalPlacementComboBox->setCurrentIndex( mLabelVerticalPlacementComboBox->findData( static_cast< int >( mScalebar->labelVerticalPlacement() ) ) );
307 mLabelHorizontalPlacementComboBox->setCurrentIndex( mLabelHorizontalPlacementComboBox->findData( static_cast< int >( mScalebar->labelHorizontalPlacement() ) ) );
308
309 //alignment
310
311 Qt::Alignment a = Qt::AlignLeft;
312 switch ( mScalebar->alignment() )
313 {
315 a = Qt::AlignLeft;
316 break;
318 a = Qt::AlignRight;
319 break;
321 a = Qt::AlignHCenter;
322 break;
323 }
324 mAlignmentComboBox->setCurrentAlignment( a );
325
326 //units
327 mUnitsComboBox->setCurrentIndex( mUnitsComboBox->findData( static_cast< int >( mScalebar->units() ) ) );
328
329 if ( mScalebar->segmentSizeMode() == QgsScaleBarSettings::SegmentSizeFixed )
330 {
331 mFixedSizeRadio->setChecked( true );
332 mSegmentSizeSpinBox->setEnabled( true );
333 mMinWidthSpinBox->setEnabled( false );
334 mMaxWidthSpinBox->setEnabled( false );
335 }
336 else /*if(mComposerScaleBar->segmentSizeMode() == QgsComposerScaleBar::SegmentSizeFitWidth)*/
337 {
338 mFitWidthRadio->setChecked( true );
339 mSegmentSizeSpinBox->setEnabled( false );
340 mMinWidthSpinBox->setEnabled( true );
341 mMaxWidthSpinBox->setEnabled( true );
342 }
343 mMinWidthSpinBox->setValue( mScalebar->minimumBarWidth() );
344 mMaxWidthSpinBox->setValue( mScalebar->maximumBarWidth() );
345
346 populateDataDefinedButtons();
347
348 blockMemberSignals( false );
349}
350
351//slots
352
353void QgsLayoutScaleBarWidget::mSegmentSizeSpinBox_valueChanged( double d )
354{
355 if ( !mScalebar )
356 {
357 return;
358 }
359
360 mScalebar->beginCommand( tr( "Set Scalebar Segment Size" ), QgsLayoutItem::UndoScaleBarSegmentSize );
361 disconnectUpdateSignal();
362 mScalebar->setUnitsPerSegment( d );
363 mScalebar->update();
364 connectUpdateSignal();
365 mScalebar->endCommand();
366}
367
368void QgsLayoutScaleBarWidget::mSegmentsLeftSpinBox_valueChanged( int i )
369{
370 if ( !mScalebar )
371 {
372 return;
373 }
374
375 mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegmentsLeft );
376 disconnectUpdateSignal();
377 mScalebar->setNumberOfSegmentsLeft( i );
378 mScalebar->update();
379 connectUpdateSignal();
380 mScalebar->endCommand();
381}
382
383void QgsLayoutScaleBarWidget::mNumberOfSegmentsSpinBox_valueChanged( int i )
384{
385 if ( !mScalebar )
386 {
387 return;
388 }
389
390 mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegments );
391 disconnectUpdateSignal();
392 mScalebar->setNumberOfSegments( i );
393 mScalebar->update();
394 connectUpdateSignal();
395 mScalebar->endCommand();
396}
397
398void QgsLayoutScaleBarWidget::mHeightSpinBox_valueChanged( double d )
399{
400 if ( !mScalebar )
401 {
402 return;
403 }
404 mScalebar->beginCommand( tr( "Set Scalebar Height" ), QgsLayoutItem::UndoScaleBarHeight );
405 disconnectUpdateSignal();
406 mScalebar->setHeight( d );
407 mScalebar->update();
408 connectUpdateSignal();
409 mScalebar->endCommand();
410}
411
412void QgsLayoutScaleBarWidget::mNumberOfSubdivisionsSpinBox_valueChanged( int i )
413{
414 if ( !mScalebar )
415 {
416 return;
417 }
418
419 mScalebar->beginCommand( tr( "Set Scalebar Subdivisions" ), QgsLayoutItem::UndoScaleBarSubdivisions );
420 disconnectUpdateSignal();
421 mScalebar->setNumberOfSubdivisions( i );
422 mScalebar->update();
423 connectUpdateSignal();
424 mScalebar->endCommand();
425}
426
427void QgsLayoutScaleBarWidget::mSubdivisionsHeightSpinBox_valueChanged( double d )
428{
429 if ( !mScalebar )
430 {
431 return;
432 }
433 mScalebar->beginCommand( tr( "Set Subdivisions Height" ), QgsLayoutItem::UndoScaleBarSubdivisionsHeight );
434 disconnectUpdateSignal();
435 mScalebar->setSubdivisionsHeight( d );
436 mScalebar->update();
437 connectUpdateSignal();
438 mScalebar->endCommand();
439}
440
441void QgsLayoutScaleBarWidget::textFormatChanged()
442{
443 if ( !mScalebar )
444 {
445 return;
446 }
447
448 mScalebar->beginCommand( tr( "Set Scalebar Font" ) );
449 disconnectUpdateSignal();
450 mScalebar->setTextFormat( mFontButton->textFormat() );
451 connectUpdateSignal();
452 mScalebar->endCommand();
453 mScalebar->update();
454}
455
456void QgsLayoutScaleBarWidget::changeNumberFormat()
457{
458 if ( !mScalebar )
459 {
460 return;
461 }
462
464 widget->setPanelTitle( tr( "Number Format" ) );
465 widget->setFormat( mScalebar->numericFormat() );
466 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [ = ]
467 {
468 mScalebar->beginCommand( tr( "Set Scalebar Number Format" ) );
469 disconnectUpdateSignal();
470 mScalebar->setNumericFormat( widget->format() );
471 connectUpdateSignal();
472 mScalebar->endCommand();
473 mScalebar->update();
474 } );
475 openPanel( widget );
476 return;
477}
478
479void QgsLayoutScaleBarWidget::mUnitLabelLineEdit_textChanged( const QString &text )
480{
481 if ( !mScalebar )
482 {
483 return;
484 }
485
486 mScalebar->beginCommand( tr( "Set Scalebar Unit Text" ), QgsLayoutItem::UndoScaleBarUnitText );
487 disconnectUpdateSignal();
488 mScalebar->setUnitLabel( text );
489 mScalebar->update();
490 connectUpdateSignal();
491 mScalebar->endCommand();
492}
493
494void QgsLayoutScaleBarWidget::mMapUnitsPerBarUnitSpinBox_valueChanged( double d )
495{
496 if ( !mScalebar )
497 {
498 return;
499 }
500
501 mScalebar->beginCommand( tr( "Set Scalebar Map Units per Segment" ), QgsLayoutItem::UndoScaleBarMapUnitsSegment );
502 disconnectUpdateSignal();
503 mScalebar->setMapUnitsPerScaleBarUnit( d );
504 mScalebar->update();
505 connectUpdateSignal();
506 mScalebar->endCommand();
507}
508
509void QgsLayoutScaleBarWidget::mStyleComboBox_currentIndexChanged( const QString & )
510{
511 if ( !mScalebar )
512 {
513 return;
514 }
515
516 const QString rendererId = mStyleComboBox->currentData().toString();
517 if ( rendererId == mScalebar->style() )
518 return;
519
520 mScalebar->beginCommand( tr( "Set Scalebar Style" ) );
521 disconnectUpdateSignal();
522
523 bool defaultsApplied = false;
524 const std::unique_ptr< QgsScaleBarRenderer > renderer( QgsApplication::scaleBarRendererRegistry()->renderer( rendererId ) );
525 if ( renderer )
526 defaultsApplied = mScalebar->applyDefaultRendererSettings( renderer.get() );
527
528 //disable or enable controls which apply to specific scale bar styles
529 toggleStyleSpecificControls( rendererId );
530
531 mScalebar->setStyle( rendererId );
532 mScalebar->update();
533 connectUpdateSignal();
534 mScalebar->endCommand();
535
536 if ( defaultsApplied )
537 setGuiElements();
538}
539
540void QgsLayoutScaleBarWidget::toggleStyleSpecificControls( const QString &style )
541{
542 std::unique_ptr< QgsScaleBarRenderer > renderer( QgsApplication::scaleBarRendererRegistry()->renderer( style ) );
543
544 //Selectively enable controls which apply to the scale bar style
545 mUnitsComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
546 mUnitsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
547 mMapUnitsPerBarUnitSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
548 mMapUnitsPerBarUnitLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
549 mUnitLabelLineEdit->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
550 mUnitLabelLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
551 mSubdivisionsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
552 mNumberOfSubdivisionsSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
553 mSubdivisionsHeightLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
554 mSubdivisionsHeightSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
555 mGroupBoxSegments->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSegments : true );
556 if ( !mGroupBoxUnits->isEnabled() )
557 mGroupBoxSegments->setCollapsed( true );
558 mLabelBarSpaceSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
559 mLabelBarSpaceLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
560 mLabelVerticalPlacementComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement : true );
561 mLabelVerticalPlacementLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement : true );
562 mLabelHorizontalPlacementComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelHorizontalPlacement : true );
563 mLabelHorizontalPlacementLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelHorizontalPlacement : true );
564 mAlignmentComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
565 mAlignmentLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
566 mFillSymbol1Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
567 mFillSymbol1Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
568 mFillSymbol2Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
569 mFillSymbol2Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
570 mLineStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
571 mLineStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
572 mDivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
573 mDivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
574 mSubdivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
575 mSubdivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
576}
577
578void QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged( double d )
579{
580 if ( !mScalebar )
581 {
582 return;
583 }
584
585 mScalebar->beginCommand( tr( "Set Scalebar Label Space" ), QgsLayoutItem::UndoScaleBarLabelBarSize );
586 disconnectUpdateSignal();
587 mScalebar->setLabelBarSpace( d );
588 mScalebar->update();
589 connectUpdateSignal();
590 mScalebar->endCommand();
591}
592
593void QgsLayoutScaleBarWidget::mBoxSizeSpinBox_valueChanged( double d )
594{
595 if ( !mScalebar )
596 {
597 return;
598 }
599
600 mScalebar->beginCommand( tr( "Set Scalebar Box Space" ), QgsLayoutItem::UndoScaleBarBoxContentSpace );
601 disconnectUpdateSignal();
602 mScalebar->setBoxContentSpace( d );
603 mScalebar->update();
604 connectUpdateSignal();
605 mScalebar->endCommand();
606}
607
608void QgsLayoutScaleBarWidget::mLabelVerticalPlacementComboBox_currentIndexChanged( int index )
609{
610 if ( !mScalebar )
611 {
612 return;
613 }
614
615 mScalebar->beginCommand( tr( "Set Scalebar Label Vertical Placement" ) );
616 disconnectUpdateSignal();
617 mScalebar->setLabelVerticalPlacement( static_cast<QgsScaleBarSettings::LabelVerticalPlacement>( mLabelVerticalPlacementComboBox->itemData( index ).toInt() ) );
618 mScalebar->update();
619 connectUpdateSignal();
620 mScalebar->endCommand();
621}
622
623void QgsLayoutScaleBarWidget::mLabelHorizontalPlacementComboBox_currentIndexChanged( int index )
624{
625 if ( !mScalebar )
626 {
627 return;
628 }
629
630 mScalebar->beginCommand( tr( "Set Scalebar Label Horizontal Placement" ) );
631 disconnectUpdateSignal();
632 mScalebar->setLabelHorizontalPlacement( static_cast<QgsScaleBarSettings::LabelHorizontalPlacement>( mLabelHorizontalPlacementComboBox->itemData( index ).toInt() ) );
633 mScalebar->update();
634 connectUpdateSignal();
635 mScalebar->endCommand();
636}
637
638void QgsLayoutScaleBarWidget::alignmentChanged()
639{
640 if ( !mScalebar )
641 {
642 return;
643 }
644
645 mScalebar->beginCommand( tr( "Set Scalebar Alignment" ) );
646 disconnectUpdateSignal();
647
648 const QgsScaleBarSettings::Alignment a = mAlignmentComboBox->currentAlignment() & Qt::AlignLeft ? QgsScaleBarSettings::AlignLeft
649 : mAlignmentComboBox->currentAlignment() & Qt::AlignRight ? QgsScaleBarSettings::AlignRight : QgsScaleBarSettings::AlignMiddle;
650 mScalebar->setAlignment( a );
651 mScalebar->update();
652 connectUpdateSignal();
653 mScalebar->endCommand();
654}
655
656void QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged( int index )
657{
658 if ( !mScalebar )
659 {
660 return;
661 }
662
663 const QVariant unitData = mUnitsComboBox->itemData( index );
664 if ( unitData.type() == QVariant::Invalid )
665 {
666 return;
667 }
668
669 disconnectUpdateSignal();
670 mScalebar->beginCommand( tr( "Set Scalebar Units" ) );
671 mScalebar->applyDefaultSize( static_cast< Qgis::DistanceUnit >( unitData.toInt() ) );
672 mScalebar->update();
673
674 mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
675 mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
676 mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
677 mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
678 mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
679
680 connectUpdateSignal();
681 mScalebar->endCommand();
682}
683
684void QgsLayoutScaleBarWidget::blockMemberSignals( bool block )
685{
686 mSegmentSizeSpinBox->blockSignals( block );
687 mNumberOfSegmentsSpinBox->blockSignals( block );
688 mSegmentsLeftSpinBox->blockSignals( block );
689 mNumberOfSubdivisionsSpinBox->blockSignals( block );
690 mSubdivisionsHeightSpinBox->blockSignals( block );
691 mStyleComboBox->blockSignals( block );
692 mUnitLabelLineEdit->blockSignals( block );
693 mMapUnitsPerBarUnitSpinBox->blockSignals( block );
694 mHeightSpinBox->blockSignals( block );
695 mLineStyleButton->blockSignals( block );
696 mDivisionStyleButton->blockSignals( block );
697 mSubdivisionStyleButton->blockSignals( block );
698 mLabelBarSpaceSpinBox->blockSignals( block );
699 mBoxSizeSpinBox->blockSignals( block );
700 mLabelVerticalPlacementComboBox->blockSignals( block );
701 mLabelHorizontalPlacementComboBox->blockSignals( block );
702 mAlignmentComboBox->blockSignals( block );
703 mUnitsComboBox->blockSignals( block );
704 mFillSymbol1Button->blockSignals( block );
705 mFillSymbol2Button->blockSignals( block );
706 mSegmentSizeRadioGroup.blockSignals( block );
707 mMapItemComboBox->blockSignals( block );
708 mFontButton->blockSignals( block );
709 mMinWidthSpinBox->blockSignals( block );
710 mMaxWidthSpinBox->blockSignals( block );
711}
712
713void QgsLayoutScaleBarWidget::connectUpdateSignal()
714{
715 if ( mScalebar )
716 {
717 connect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
718 }
719}
720
721void QgsLayoutScaleBarWidget::disconnectUpdateSignal()
722{
723 if ( mScalebar )
724 {
725 disconnect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
726 }
727}
728
729void QgsLayoutScaleBarWidget::segmentSizeRadioChanged( QAbstractButton *radio )
730{
731 const bool fixedSizeMode = radio == mFixedSizeRadio;
732 mMinWidthSpinBox->setEnabled( !fixedSizeMode );
733 mMaxWidthSpinBox->setEnabled( !fixedSizeMode );
734 mSegmentSizeSpinBox->setEnabled( fixedSizeMode );
735
736 if ( !mScalebar )
737 {
738 return;
739 }
740
741 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
742 disconnectUpdateSignal();
743 if ( mFixedSizeRadio->isChecked() )
744 {
745 mScalebar->setSegmentSizeMode( QgsScaleBarSettings::SegmentSizeFixed );
746 mScalebar->setUnitsPerSegment( mSegmentSizeSpinBox->value() );
747 }
748 else /*if(mFitWidthRadio->isChecked())*/
749 {
750 mScalebar->setSegmentSizeMode( QgsScaleBarSettings::SegmentSizeFitWidth );
751 }
752 mScalebar->update();
753 connectUpdateSignal();
754 mScalebar->endCommand();
755}
756
757void QgsLayoutScaleBarWidget::mapChanged( QgsLayoutItem *item )
758{
759 QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( item );
760 if ( !map )
761 {
762 return;
763 }
764
765 //set it to scale bar
766 mScalebar->beginCommand( tr( "Set Scalebar Map" ) );
767 disconnectUpdateSignal();
768 mScalebar->setLinkedMap( map );
769 mScalebar->update();
770 connectUpdateSignal();
771 mScalebar->endCommand();
772}
773
774void QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged( double )
775{
776 if ( !mScalebar )
777 {
778 return;
779 }
780
781 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
782 disconnectUpdateSignal();
783 mScalebar->setMinimumBarWidth( mMinWidthSpinBox->value() );
784 mScalebar->update();
785 connectUpdateSignal();
786 mScalebar->endCommand();
787}
788
789void QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged( double )
790{
791 if ( !mScalebar )
792 {
793 return;
794 }
795
796 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
797 disconnectUpdateSignal();
798 mScalebar->setMaximumBarWidth( mMaxWidthSpinBox->value() );
799 mScalebar->update();
800 connectUpdateSignal();
801 mScalebar->endCommand();
802}
803
804void QgsLayoutScaleBarWidget::populateDataDefinedButtons()
805{
806 updateDataDefinedButton( mSegmentsLeftDDBtn );
807 updateDataDefinedButton( mSegmentsRightDDBtn );
808 updateDataDefinedButton( mSegmentSizeDDBtn );
809 updateDataDefinedButton( mMinWidthDDBtn );
810 updateDataDefinedButton( mMaxWidthDDBtn );
811 updateDataDefinedButton( mHeightDDBtn );
812 updateDataDefinedButton( mSubdivisionHeightDDBtn );
813 updateDataDefinedButton( mRightSegmentSubdivisionsDDBtn );
814}
DistanceUnit
Units of distance.
Definition: qgis.h:3047
@ Line
Line symbol.
@ Fill
Fill symbol.
void changed()
Emitted when the alignment is changed.
static QgsScaleBarRendererRegistry * scaleBarRendererRegistry()
Gets the registry of available scalebar renderers.
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.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
@ ModeTextRenderer
Configure font settings for use with QgsTextRenderer.
Definition: qgsfontbutton.h:62
void setLayer(QgsVectorLayer *layer)
Sets a layer to associate with the widget.
void changed()
Emitted when the widget's text format settings are changed.
A base class for property widgets for layout items.
void updateDataDefinedButton(QgsPropertyOverrideButton *button)
Updates a previously registered data defined button to reflect the item's current properties.
QgsVectorLayer * coverageLayer() const
Returns the current layout context coverage layer (if set).
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property)
Registers a data defined button, setting up its initial value, connections and description.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
Layout graphical items for displaying a map.
A widget for controlling the common properties of layout items (e.g.
void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
void setItem(QgsLayoutItem *item)
Sets the layout item.
@ LayoutScaleBar
Scale bar item.
A layout item subclass for scale bars.
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 (since QGIS 3.26)
@ ScalebarSegmentWidth
Scalebar width in map units of a single segment (since QGIS 3.26)
@ ScalebarMaximumWidth
Scalebar segment maximum width (since QGIS 3.26)
@ ScalebarHeight
Scalebar height (since QGIS 3.26)
@ ScalebarRightSegments
Number of segments on the right of 0 (since QGIS 3.26)
@ ScalebarSubdivisionHeight
Scalebar subdivision height (since QGIS 3.26)
@ ScalebarRightSegmentSubdivisions
Number of subdivisions per segment on right of 0 (since QGIS 3.26)
@ ScalebarLeftSegments
Number of segments on the left of 0 (since QGIS 3.26)
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
bool setNewItem(QgsLayoutItem *item) override
Attempts to update the widget to show the properties for the specified item.
QgsLayoutScaleBarWidget(QgsLayoutItemScaleBar *scaleBar)
constructor
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void setMasterLayout(QgsMasterLayoutInterface *masterLayout) override
Sets the master layout associated with the item.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
Interface for master layout type objects, such as print layouts and reports.
A widget which allows choice of numeric formats and the properties of them.
QgsNumericFormat * format() const
Returns a new format object representing the settings currently configured in the widget.
void changed()
Emitted whenever the format configured55 in the widget is changed.
void setFormat(const QgsNumericFormat *format)
Sets the format to show in the widget.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
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() )
Alignment
Scalebar alignment.
@ AlignLeft
Left aligned.
@ AlignMiddle
Center aligned.
@ AlignRight
Right aligned.
LabelHorizontalPlacement
Label horizontal placement.
@ LabelCenteredSegment
Labels are drawn centered relative to segment.
@ LabelCenteredEdge
Labels are drawn centered relative to segment's edge.
LabelVerticalPlacement
Label vertical placement.
@ LabelAboveSegment
Labels are drawn above the scalebar.
@ LabelBelowSegment
Labels are drawn below the scalebar.
@ SegmentSizeFitWidth
Scale bar segment size is calculated to fit a size range.
@ SegmentSizeFixed
Scale bar segment size is fixed to a map unit.
void setLayer(QgsVectorLayer *layer)
Sets a layer to associate with the widget.
void changed()
Emitted when the symbol's settings are changed.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:3435
Single variable definition for use within a QgsExpressionContextScope.