QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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 mUnitsComboBox->addItem( tr( "Inches" ), static_cast< int >( Qgis::DistanceUnit::Inches ) );
118
119 mLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
120 connect( mLineStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::lineSymbolChanged );
121
122 mDivisionStyleButton->setSymbolType( Qgis::SymbolType::Line );
123 connect( mDivisionStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::divisionSymbolChanged );
124
125 mSubdivisionStyleButton->setSymbolType( Qgis::SymbolType::Line );
126 connect( mSubdivisionStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::subdivisionSymbolChanged );
127
128 mFillSymbol1Button->setSymbolType( Qgis::SymbolType::Fill );
129 connect( mFillSymbol1Button, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::fillSymbol1Changed );
130
131 mFillSymbol2Button->setSymbolType( Qgis::SymbolType::Fill );
132 connect( mFillSymbol2Button, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::fillSymbol2Changed );
133
134 mFontButton->setDialogTitle( tr( "Scalebar Font" ) );
135 mFontButton->setMode( QgsFontButton::ModeTextRenderer );
136
137 if ( mScalebar )
138 {
139 QgsLayout *scaleBarLayout = mScalebar->layout();
140 if ( scaleBarLayout )
141 {
142 mMapItemComboBox->setCurrentLayout( scaleBarLayout );
143 mMapItemComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
144 }
145 }
146
147 connect( mMapItemComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutScaleBarWidget::mapChanged );
148
149 blockMemberSignals( false );
150 setGuiElements(); //set the GUI elements to the state of scaleBar
151
152 mLineStyleButton->registerExpressionContextGenerator( mScalebar );
153 mLineStyleButton->setLayer( coverageLayer() );
154 mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
155 mDivisionStyleButton->setLayer( coverageLayer() );
156 mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
157 mSubdivisionStyleButton->setLayer( coverageLayer() );
158 mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
159 mFillSymbol1Button->setLayer( coverageLayer() );
160 mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
161 mFillSymbol2Button->setLayer( coverageLayer() );
162
163 connect( mFontButton, &QgsFontButton::changed, this, &QgsLayoutScaleBarWidget::textFormatChanged );
164 mFontButton->setLayer( coverageLayer() );
165 if ( mScalebar->layout() )
166 {
167 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFontButton, &QgsFontButton::setLayer );
168 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mLineStyleButton, &QgsSymbolButton::setLayer );
169 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mDivisionStyleButton, &QgsSymbolButton::setLayer );
170 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mSubdivisionStyleButton, &QgsSymbolButton::setLayer );
171 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFillSymbol1Button, &QgsSymbolButton::setLayer );
172 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFillSymbol2Button, &QgsSymbolButton::setLayer );
173 }
174}
175
177{
178 if ( mItemPropertiesWidget )
179 mItemPropertiesWidget->setMasterLayout( masterLayout );
180}
181
183{
184 QgsExpressionContext context = mScalebar->createExpressionContext();
185 QgsExpressionContextScope *scaleScope = new QgsExpressionContextScope( QStringLiteral( "scalebar_text" ) );
186 scaleScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "scale_value" ), 0, true, false ) );
187 context.appendScope( scaleScope );
188 context.setHighlightedVariables( QStringList() << QStringLiteral( "scale_value" ) );
189 return context;
190}
191
193{
195 return false;
196
197 disconnectUpdateSignal();
198
199 mScalebar = qobject_cast< QgsLayoutItemScaleBar * >( item );
200 mItemPropertiesWidget->setItem( mScalebar );
201
202 if ( mScalebar )
203 {
204 connectUpdateSignal();
205 mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
206 mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
207 mLineStyleButton->registerExpressionContextGenerator( mScalebar );
208 mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
209 mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
210 }
211
212 setGuiElements();
213
214 return true;
215}
216
217void QgsLayoutScaleBarWidget::lineSymbolChanged()
218{
219 if ( !mScalebar )
220 return;
221
222 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Line Style" ), QgsLayoutItem::UndoShapeStyle );
223 mScalebar->setLineSymbol( mLineStyleButton->clonedSymbol<QgsLineSymbol>() );
224 mScalebar->update();
225 mScalebar->layout()->undoStack()->endCommand();
226}
227
228void QgsLayoutScaleBarWidget::divisionSymbolChanged()
229{
230 if ( !mScalebar )
231 return;
232
233 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Division Style" ), QgsLayoutItem::UndoShapeStyle );
234 mScalebar->setDivisionLineSymbol( mDivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
235 mScalebar->update();
236 mScalebar->layout()->undoStack()->endCommand();
237}
238
239void QgsLayoutScaleBarWidget::subdivisionSymbolChanged()
240{
241 if ( !mScalebar )
242 return;
243
244 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Subdivision Style" ), QgsLayoutItem::UndoShapeStyle );
245 mScalebar->setSubdivisionLineSymbol( mSubdivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
246 mScalebar->update();
247 mScalebar->layout()->undoStack()->endCommand();
248}
249
250void QgsLayoutScaleBarWidget::fillSymbol1Changed()
251{
252 if ( !mScalebar )
253 return;
254
255 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Fill Style" ), QgsLayoutItem::UndoShapeStyle );
256 mScalebar->setFillSymbol( mFillSymbol1Button->clonedSymbol<QgsFillSymbol>() );
257 mScalebar->update();
258 mScalebar->layout()->undoStack()->endCommand();
259}
260
261void QgsLayoutScaleBarWidget::fillSymbol2Changed()
262{
263 if ( !mScalebar )
264 return;
265
266 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Fill Style" ), QgsLayoutItem::UndoShapeStyle );
267 mScalebar->setAlternateFillSymbol( mFillSymbol2Button->clonedSymbol<QgsFillSymbol>() );
268 mScalebar->update();
269 mScalebar->layout()->undoStack()->endCommand();
270}
271
272void QgsLayoutScaleBarWidget::setGuiElements()
273{
274 if ( !mScalebar )
275 {
276 return;
277 }
278
279 blockMemberSignals( true );
280 mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
281 mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
282 mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
283 mHeightSpinBox->setValue( mScalebar->height() );
284 mNumberOfSubdivisionsSpinBox->setValue( mScalebar->numberOfSubdivisions() );
285 mSubdivisionsHeightSpinBox->setValue( mScalebar->subdivisionsHeight() );
286 mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
287 mLabelBarSpaceSpinBox->setValue( mScalebar->labelBarSpace() );
288 mBoxSizeSpinBox->setValue( mScalebar->boxContentSpace() );
289 mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
290 mFontButton->setTextFormat( mScalebar->textFormat() );
291
292 whileBlocking( mLineStyleButton )->setSymbol( mScalebar->lineSymbol()->clone() );
293 whileBlocking( mDivisionStyleButton )->setSymbol( mScalebar->divisionLineSymbol()->clone() );
294 whileBlocking( mSubdivisionStyleButton )->setSymbol( mScalebar->subdivisionLineSymbol()->clone() );
295 whileBlocking( mFillSymbol1Button )->setSymbol( mScalebar->fillSymbol()->clone() );
296 whileBlocking( mFillSymbol2Button )->setSymbol( mScalebar->alternateFillSymbol()->clone() );
297
298 //map combo box
299 mMapItemComboBox->setItem( mScalebar->linkedMap() );
300
301 //style...
302 const QString style = mScalebar->style();
303 mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( style ) );
304 toggleStyleSpecificControls( style );
305
306 //label vertical/horizontal placement
307 mLabelVerticalPlacementComboBox->setCurrentIndex( mLabelVerticalPlacementComboBox->findData( static_cast< int >( mScalebar->labelVerticalPlacement() ) ) );
308 mLabelHorizontalPlacementComboBox->setCurrentIndex( mLabelHorizontalPlacementComboBox->findData( static_cast< int >( mScalebar->labelHorizontalPlacement() ) ) );
309
310 //alignment
311
312 Qt::Alignment a = Qt::AlignLeft;
313 switch ( mScalebar->alignment() )
314 {
316 a = Qt::AlignLeft;
317 break;
319 a = Qt::AlignRight;
320 break;
322 a = Qt::AlignHCenter;
323 break;
324 }
325 mAlignmentComboBox->setCurrentAlignment( a );
326
327 //units
328 mUnitsComboBox->setCurrentIndex( mUnitsComboBox->findData( static_cast< int >( mScalebar->units() ) ) );
329
330 if ( mScalebar->segmentSizeMode() == QgsScaleBarSettings::SegmentSizeFixed )
331 {
332 mFixedSizeRadio->setChecked( true );
333 mSegmentSizeSpinBox->setEnabled( true );
334 mMinWidthSpinBox->setEnabled( false );
335 mMaxWidthSpinBox->setEnabled( false );
336 }
337 else /*if(mComposerScaleBar->segmentSizeMode() == QgsComposerScaleBar::SegmentSizeFitWidth)*/
338 {
339 mFitWidthRadio->setChecked( true );
340 mSegmentSizeSpinBox->setEnabled( false );
341 mMinWidthSpinBox->setEnabled( true );
342 mMaxWidthSpinBox->setEnabled( true );
343 }
344 mMinWidthSpinBox->setValue( mScalebar->minimumBarWidth() );
345 mMaxWidthSpinBox->setValue( mScalebar->maximumBarWidth() );
346
347 populateDataDefinedButtons();
348
349 blockMemberSignals( false );
350}
351
352//slots
353
354void QgsLayoutScaleBarWidget::mSegmentSizeSpinBox_valueChanged( double d )
355{
356 if ( !mScalebar )
357 {
358 return;
359 }
360
361 mScalebar->beginCommand( tr( "Set Scalebar Segment Size" ), QgsLayoutItem::UndoScaleBarSegmentSize );
362 disconnectUpdateSignal();
363 mScalebar->setUnitsPerSegment( d );
364 mScalebar->update();
365 connectUpdateSignal();
366 mScalebar->endCommand();
367}
368
369void QgsLayoutScaleBarWidget::mSegmentsLeftSpinBox_valueChanged( int i )
370{
371 if ( !mScalebar )
372 {
373 return;
374 }
375
376 mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegmentsLeft );
377 disconnectUpdateSignal();
378 mScalebar->setNumberOfSegmentsLeft( i );
379 mScalebar->update();
380 connectUpdateSignal();
381 mScalebar->endCommand();
382}
383
384void QgsLayoutScaleBarWidget::mNumberOfSegmentsSpinBox_valueChanged( int i )
385{
386 if ( !mScalebar )
387 {
388 return;
389 }
390
391 mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegments );
392 disconnectUpdateSignal();
393 mScalebar->setNumberOfSegments( i );
394 mScalebar->update();
395 connectUpdateSignal();
396 mScalebar->endCommand();
397}
398
399void QgsLayoutScaleBarWidget::mHeightSpinBox_valueChanged( double d )
400{
401 if ( !mScalebar )
402 {
403 return;
404 }
405 mScalebar->beginCommand( tr( "Set Scalebar Height" ), QgsLayoutItem::UndoScaleBarHeight );
406 disconnectUpdateSignal();
407 mScalebar->setHeight( d );
408 mScalebar->update();
409 connectUpdateSignal();
410 mScalebar->endCommand();
411}
412
413void QgsLayoutScaleBarWidget::mNumberOfSubdivisionsSpinBox_valueChanged( int i )
414{
415 if ( !mScalebar )
416 {
417 return;
418 }
419
420 mScalebar->beginCommand( tr( "Set Scalebar Subdivisions" ), QgsLayoutItem::UndoScaleBarSubdivisions );
421 disconnectUpdateSignal();
422 mScalebar->setNumberOfSubdivisions( i );
423 mScalebar->update();
424 connectUpdateSignal();
425 mScalebar->endCommand();
426}
427
428void QgsLayoutScaleBarWidget::mSubdivisionsHeightSpinBox_valueChanged( double d )
429{
430 if ( !mScalebar )
431 {
432 return;
433 }
434 mScalebar->beginCommand( tr( "Set Subdivisions Height" ), QgsLayoutItem::UndoScaleBarSubdivisionsHeight );
435 disconnectUpdateSignal();
436 mScalebar->setSubdivisionsHeight( d );
437 mScalebar->update();
438 connectUpdateSignal();
439 mScalebar->endCommand();
440}
441
442void QgsLayoutScaleBarWidget::textFormatChanged()
443{
444 if ( !mScalebar )
445 {
446 return;
447 }
448
449 mScalebar->beginCommand( tr( "Set Scalebar Font" ) );
450 disconnectUpdateSignal();
451 mScalebar->setTextFormat( mFontButton->textFormat() );
452 connectUpdateSignal();
453 mScalebar->endCommand();
454 mScalebar->update();
455}
456
457void QgsLayoutScaleBarWidget::changeNumberFormat()
458{
459 if ( !mScalebar )
460 {
461 return;
462 }
463
465 widget->setPanelTitle( tr( "Number Format" ) );
466 widget->setFormat( mScalebar->numericFormat() );
467 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [ = ]
468 {
469 mScalebar->beginCommand( tr( "Set Scalebar Number Format" ) );
470 disconnectUpdateSignal();
471 mScalebar->setNumericFormat( widget->format() );
472 connectUpdateSignal();
473 mScalebar->endCommand();
474 mScalebar->update();
475 } );
476 openPanel( widget );
477 return;
478}
479
480void QgsLayoutScaleBarWidget::mUnitLabelLineEdit_textChanged( const QString &text )
481{
482 if ( !mScalebar )
483 {
484 return;
485 }
486
487 mScalebar->beginCommand( tr( "Set Scalebar Unit Text" ), QgsLayoutItem::UndoScaleBarUnitText );
488 disconnectUpdateSignal();
489 mScalebar->setUnitLabel( text );
490 mScalebar->update();
491 connectUpdateSignal();
492 mScalebar->endCommand();
493}
494
495void QgsLayoutScaleBarWidget::mMapUnitsPerBarUnitSpinBox_valueChanged( double d )
496{
497 if ( !mScalebar )
498 {
499 return;
500 }
501
502 mScalebar->beginCommand( tr( "Set Scalebar Map Units per Segment" ), QgsLayoutItem::UndoScaleBarMapUnitsSegment );
503 disconnectUpdateSignal();
504 mScalebar->setMapUnitsPerScaleBarUnit( d );
505 mScalebar->update();
506 connectUpdateSignal();
507 mScalebar->endCommand();
508}
509
510void QgsLayoutScaleBarWidget::mStyleComboBox_currentIndexChanged( const QString & )
511{
512 if ( !mScalebar )
513 {
514 return;
515 }
516
517 const QString rendererId = mStyleComboBox->currentData().toString();
518 if ( rendererId == mScalebar->style() )
519 return;
520
521 mScalebar->beginCommand( tr( "Set Scalebar Style" ) );
522 disconnectUpdateSignal();
523
524 bool defaultsApplied = false;
525 const std::unique_ptr< QgsScaleBarRenderer > renderer( QgsApplication::scaleBarRendererRegistry()->renderer( rendererId ) );
526 if ( renderer )
527 defaultsApplied = mScalebar->applyDefaultRendererSettings( renderer.get() );
528
529 //disable or enable controls which apply to specific scale bar styles
530 toggleStyleSpecificControls( rendererId );
531
532 mScalebar->setStyle( rendererId );
533 mScalebar->update();
534 connectUpdateSignal();
535 mScalebar->endCommand();
536
537 if ( defaultsApplied )
538 setGuiElements();
539}
540
541void QgsLayoutScaleBarWidget::toggleStyleSpecificControls( const QString &style )
542{
543 std::unique_ptr< QgsScaleBarRenderer > renderer( QgsApplication::scaleBarRendererRegistry()->renderer( style ) );
544
545 //Selectively enable controls which apply to the scale bar style
546 mUnitsComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
547 mUnitsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
548 mMapUnitsPerBarUnitSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
549 mMapUnitsPerBarUnitLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
550 mUnitLabelLineEdit->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
551 mUnitLabelLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
552 mSubdivisionsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
553 mNumberOfSubdivisionsSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
554 mSubdivisionsHeightLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
555 mSubdivisionsHeightSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
556 mGroupBoxSegments->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSegments : true );
557 if ( !mGroupBoxUnits->isEnabled() )
558 mGroupBoxSegments->setCollapsed( true );
559 mLabelBarSpaceSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
560 mLabelBarSpaceLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
561 mLabelVerticalPlacementComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement : true );
562 mLabelVerticalPlacementLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement : true );
563 mLabelHorizontalPlacementComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelHorizontalPlacement : true );
564 mLabelHorizontalPlacementLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelHorizontalPlacement : true );
565 mAlignmentComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
566 mAlignmentLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
567 mFillSymbol1Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
568 mFillSymbol1Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
569 mFillSymbol2Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
570 mFillSymbol2Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
571 mLineStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
572 mLineStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
573 mDivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
574 mDivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
575 mSubdivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
576 mSubdivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
577}
578
579void QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged( double d )
580{
581 if ( !mScalebar )
582 {
583 return;
584 }
585
586 mScalebar->beginCommand( tr( "Set Scalebar Label Space" ), QgsLayoutItem::UndoScaleBarLabelBarSize );
587 disconnectUpdateSignal();
588 mScalebar->setLabelBarSpace( d );
589 mScalebar->update();
590 connectUpdateSignal();
591 mScalebar->endCommand();
592}
593
594void QgsLayoutScaleBarWidget::mBoxSizeSpinBox_valueChanged( double d )
595{
596 if ( !mScalebar )
597 {
598 return;
599 }
600
601 mScalebar->beginCommand( tr( "Set Scalebar Box Space" ), QgsLayoutItem::UndoScaleBarBoxContentSpace );
602 disconnectUpdateSignal();
603 mScalebar->setBoxContentSpace( d );
604 mScalebar->update();
605 connectUpdateSignal();
606 mScalebar->endCommand();
607}
608
609void QgsLayoutScaleBarWidget::mLabelVerticalPlacementComboBox_currentIndexChanged( int index )
610{
611 if ( !mScalebar )
612 {
613 return;
614 }
615
616 mScalebar->beginCommand( tr( "Set Scalebar Label Vertical Placement" ) );
617 disconnectUpdateSignal();
618 mScalebar->setLabelVerticalPlacement( static_cast<QgsScaleBarSettings::LabelVerticalPlacement>( mLabelVerticalPlacementComboBox->itemData( index ).toInt() ) );
619 mScalebar->update();
620 connectUpdateSignal();
621 mScalebar->endCommand();
622}
623
624void QgsLayoutScaleBarWidget::mLabelHorizontalPlacementComboBox_currentIndexChanged( int index )
625{
626 if ( !mScalebar )
627 {
628 return;
629 }
630
631 mScalebar->beginCommand( tr( "Set Scalebar Label Horizontal Placement" ) );
632 disconnectUpdateSignal();
633 mScalebar->setLabelHorizontalPlacement( static_cast<QgsScaleBarSettings::LabelHorizontalPlacement>( mLabelHorizontalPlacementComboBox->itemData( index ).toInt() ) );
634 mScalebar->update();
635 connectUpdateSignal();
636 mScalebar->endCommand();
637}
638
639void QgsLayoutScaleBarWidget::alignmentChanged()
640{
641 if ( !mScalebar )
642 {
643 return;
644 }
645
646 mScalebar->beginCommand( tr( "Set Scalebar Alignment" ) );
647 disconnectUpdateSignal();
648
649 const QgsScaleBarSettings::Alignment a = mAlignmentComboBox->currentAlignment() & Qt::AlignLeft ? QgsScaleBarSettings::AlignLeft
650 : mAlignmentComboBox->currentAlignment() & Qt::AlignRight ? QgsScaleBarSettings::AlignRight : QgsScaleBarSettings::AlignMiddle;
651 mScalebar->setAlignment( a );
652 mScalebar->update();
653 connectUpdateSignal();
654 mScalebar->endCommand();
655}
656
657void QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged( int index )
658{
659 if ( !mScalebar )
660 {
661 return;
662 }
663
664 const QVariant unitData = mUnitsComboBox->itemData( index );
665 if ( unitData.type() == QVariant::Invalid )
666 {
667 return;
668 }
669
670 disconnectUpdateSignal();
671 mScalebar->beginCommand( tr( "Set Scalebar Units" ) );
672 mScalebar->applyDefaultSize( static_cast< Qgis::DistanceUnit >( unitData.toInt() ) );
673 mScalebar->update();
674
675 mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
676 mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
677 mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
678 mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
679 mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
680
681 connectUpdateSignal();
682 mScalebar->endCommand();
683}
684
685void QgsLayoutScaleBarWidget::blockMemberSignals( bool block )
686{
687 mSegmentSizeSpinBox->blockSignals( block );
688 mNumberOfSegmentsSpinBox->blockSignals( block );
689 mSegmentsLeftSpinBox->blockSignals( block );
690 mNumberOfSubdivisionsSpinBox->blockSignals( block );
691 mSubdivisionsHeightSpinBox->blockSignals( block );
692 mStyleComboBox->blockSignals( block );
693 mUnitLabelLineEdit->blockSignals( block );
694 mMapUnitsPerBarUnitSpinBox->blockSignals( block );
695 mHeightSpinBox->blockSignals( block );
696 mLineStyleButton->blockSignals( block );
697 mDivisionStyleButton->blockSignals( block );
698 mSubdivisionStyleButton->blockSignals( block );
699 mLabelBarSpaceSpinBox->blockSignals( block );
700 mBoxSizeSpinBox->blockSignals( block );
701 mLabelVerticalPlacementComboBox->blockSignals( block );
702 mLabelHorizontalPlacementComboBox->blockSignals( block );
703 mAlignmentComboBox->blockSignals( block );
704 mUnitsComboBox->blockSignals( block );
705 mFillSymbol1Button->blockSignals( block );
706 mFillSymbol2Button->blockSignals( block );
707 mSegmentSizeRadioGroup.blockSignals( block );
708 mMapItemComboBox->blockSignals( block );
709 mFontButton->blockSignals( block );
710 mMinWidthSpinBox->blockSignals( block );
711 mMaxWidthSpinBox->blockSignals( block );
712}
713
714void QgsLayoutScaleBarWidget::connectUpdateSignal()
715{
716 if ( mScalebar )
717 {
718 connect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
719 }
720}
721
722void QgsLayoutScaleBarWidget::disconnectUpdateSignal()
723{
724 if ( mScalebar )
725 {
726 disconnect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
727 }
728}
729
730void QgsLayoutScaleBarWidget::segmentSizeRadioChanged( QAbstractButton *radio )
731{
732 const bool fixedSizeMode = radio == mFixedSizeRadio;
733 mMinWidthSpinBox->setEnabled( !fixedSizeMode );
734 mMaxWidthSpinBox->setEnabled( !fixedSizeMode );
735 mSegmentSizeSpinBox->setEnabled( fixedSizeMode );
736
737 if ( !mScalebar )
738 {
739 return;
740 }
741
742 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
743 disconnectUpdateSignal();
744 if ( mFixedSizeRadio->isChecked() )
745 {
746 mScalebar->setSegmentSizeMode( QgsScaleBarSettings::SegmentSizeFixed );
747 mScalebar->setUnitsPerSegment( mSegmentSizeSpinBox->value() );
748 }
749 else /*if(mFitWidthRadio->isChecked())*/
750 {
751 mScalebar->setSegmentSizeMode( QgsScaleBarSettings::SegmentSizeFitWidth );
752 }
753 mScalebar->update();
754 connectUpdateSignal();
755 mScalebar->endCommand();
756}
757
758void QgsLayoutScaleBarWidget::mapChanged( QgsLayoutItem *item )
759{
760 QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( item );
761 if ( !map )
762 {
763 return;
764 }
765
766 //set it to scale bar
767 mScalebar->beginCommand( tr( "Set Scalebar Map" ) );
768 disconnectUpdateSignal();
769 mScalebar->setLinkedMap( map );
770 mScalebar->update();
771 connectUpdateSignal();
772 mScalebar->endCommand();
773}
774
775void QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged( double )
776{
777 if ( !mScalebar )
778 {
779 return;
780 }
781
782 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
783 disconnectUpdateSignal();
784 mScalebar->setMinimumBarWidth( mMinWidthSpinBox->value() );
785 mScalebar->update();
786 connectUpdateSignal();
787 mScalebar->endCommand();
788}
789
790void QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged( double )
791{
792 if ( !mScalebar )
793 {
794 return;
795 }
796
797 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
798 disconnectUpdateSignal();
799 mScalebar->setMaximumBarWidth( mMaxWidthSpinBox->value() );
800 mScalebar->update();
801 connectUpdateSignal();
802 mScalebar->endCommand();
803}
804
805void QgsLayoutScaleBarWidget::populateDataDefinedButtons()
806{
807 updateDataDefinedButton( mSegmentsLeftDDBtn );
808 updateDataDefinedButton( mSegmentsRightDDBtn );
809 updateDataDefinedButton( mSegmentSizeDDBtn );
810 updateDataDefinedButton( mMinWidthDDBtn );
811 updateDataDefinedButton( mMaxWidthDDBtn );
812 updateDataDefinedButton( mHeightDDBtn );
813 updateDataDefinedButton( mSubdivisionHeightDDBtn );
814 updateDataDefinedButton( mRightSegmentSubdivisionsDDBtn );
815}
DistanceUnit
Units of distance.
Definition: qgis.h:3310
@ Inches
Inches (since QGIS 3.32)
@ 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:3914
Single variable definition for use within a QgsExpressionContextScope.