QGIS API Documentation 3.39.0-Master (3aed037ce22)
Loading...
Searching...
No Matches
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"
23#include "qgslayoutundostack.h"
24#include "qgsfillsymbol.h"
25#include "qgslinesymbol.h"
27#include "qgsvectorlayer.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( mDistanceLabelPlacementComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsLayoutScaleBarWidget::mDistanceLabelPlacementComboBox_currentIndexChanged );
54 connect( mUnitsComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged );
55 connect( mMinWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged );
56 connect( mMaxWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged );
57 connect( mNumberFormatPushButton, &QPushButton::clicked, this, &QgsLayoutScaleBarWidget::changeNumberFormat );
58
67
68 mSegmentsLeftDDBtn->registerEnabledWidget( mSegmentsLeftSpinBox, false );
69 mSegmentsRightDDBtn->registerEnabledWidget( mNumberOfSegmentsSpinBox, false );
70 mSegmentSizeDDBtn->registerEnabledWidget( mSegmentSizeSpinBox, false );
71 mMinWidthDDBtn->registerEnabledWidget( mMinWidthSpinBox, false );
72 mMaxWidthDDBtn->registerEnabledWidget( mMaxWidthSpinBox, false );
73
74 setPanelTitle( tr( "Scalebar Properties" ) );
75
76 mFontButton->registerExpressionContextGenerator( this );
77
78 connectUpdateSignal();
79
80 //add widget for general composer item properties
81 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, scaleBar );
82 mainLayout->addWidget( mItemPropertiesWidget );
83
84 mSegmentSizeRadioGroup.addButton( mFixedSizeRadio );
85 mSegmentSizeRadioGroup.addButton( mFitWidthRadio );
86 connect( &mSegmentSizeRadioGroup, static_cast < void ( QButtonGroup::* )( QAbstractButton * ) > ( &QButtonGroup::buttonClicked ), this, &QgsLayoutScaleBarWidget::segmentSizeRadioChanged );
87
88 blockMemberSignals( true );
89
90 //style combo box
91 const QStringList renderers = QgsApplication::scaleBarRendererRegistry()->sortedRendererList();
92 for ( const QString &renderer : renderers )
93 {
94 mStyleComboBox->addItem( QgsApplication::scaleBarRendererRegistry()->visibleName( renderer ), renderer );
95 }
96
97 //label vertical/horizontal placement combo box
98 mDistanceLabelPlacementComboBox->addItem( tr( "Above Segment Edges" ), static_cast< int >( DistanceLabelPlacement::CenteredAboveSegmentEdges ) );
99 mDistanceLabelPlacementComboBox->addItem( tr( "Above Segment Centers" ), static_cast< int >( DistanceLabelPlacement::CenteredAboveSegmentCenters ) );
100 mDistanceLabelPlacementComboBox->addItem( tr( "Below Segment Edges" ), static_cast< int >( DistanceLabelPlacement::CenteredBelowSegmentEdges ) );
101 mDistanceLabelPlacementComboBox->addItem( tr( "Below Segment Centers" ), static_cast< int >( DistanceLabelPlacement::CenteredBelowSegmentCenters ) );
102
103 //alignment combo box
104 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
105
106 //units combo box
107 mUnitsComboBox->addItem( tr( "Map units" ), static_cast< int >( Qgis::DistanceUnit::Unknown ) );
108 mUnitsComboBox->addItem( tr( "Meters" ), static_cast< int >( Qgis::DistanceUnit::Meters ) );
109 mUnitsComboBox->addItem( tr( "Kilometers" ), static_cast< int >( Qgis::DistanceUnit::Kilometers ) );
110 mUnitsComboBox->addItem( tr( "Feet" ), static_cast< int >( Qgis::DistanceUnit::Feet ) );
111 mUnitsComboBox->addItem( tr( "Yards" ), static_cast< int >( Qgis::DistanceUnit::Yards ) );
112 mUnitsComboBox->addItem( tr( "Miles" ), static_cast< int >( Qgis::DistanceUnit::Miles ) );
113 mUnitsComboBox->addItem( tr( "Nautical Miles" ), static_cast< int >( Qgis::DistanceUnit::NauticalMiles ) );
114 mUnitsComboBox->addItem( tr( "Centimeters" ), static_cast< int >( Qgis::DistanceUnit::Centimeters ) );
115 mUnitsComboBox->addItem( tr( "Millimeters" ), static_cast< int >( Qgis::DistanceUnit::Millimeters ) );
116 mUnitsComboBox->addItem( tr( "Inches" ), static_cast< int >( Qgis::DistanceUnit::Inches ) );
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 mDistanceLabelPlacementComboBox->setCurrentIndex( mDistanceLabelPlacementComboBox->findData( static_cast< int >(
307 distanceLabelPlacement( mScalebar->labelHorizontalPlacement(), mScalebar->labelVerticalPlacement() ) ) ) );
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 switch ( mScalebar->segmentSizeMode() )
330 {
332 {
333 mFixedSizeRadio->setChecked( true );
334 mSegmentSizeWidget->setEnabled( true );
335 mMinWidthWidget->setEnabled( false );
336 mMaxWidthWidget->setEnabled( false );
337 break;
338 }
339
341 {
342 mFitWidthRadio->setChecked( true );
343 mSegmentSizeWidget->setEnabled( false );
344 mMinWidthWidget->setEnabled( true );
345 mMaxWidthWidget->setEnabled( true );
346 break;
347 }
348 }
349 mMinWidthSpinBox->setValue( mScalebar->minimumBarWidth() );
350 mMaxWidthSpinBox->setValue( mScalebar->maximumBarWidth() );
351
352 populateDataDefinedButtons();
353
354 blockMemberSignals( false );
355}
356
357//slots
358
359void QgsLayoutScaleBarWidget::mSegmentSizeSpinBox_valueChanged( double d )
360{
361 if ( !mScalebar )
362 {
363 return;
364 }
365
366 mScalebar->beginCommand( tr( "Set Scalebar Segment Size" ), QgsLayoutItem::UndoScaleBarSegmentSize );
367 disconnectUpdateSignal();
368 mScalebar->setUnitsPerSegment( d );
369 mScalebar->update();
370 connectUpdateSignal();
371 mScalebar->endCommand();
372}
373
374void QgsLayoutScaleBarWidget::mSegmentsLeftSpinBox_valueChanged( int i )
375{
376 if ( !mScalebar )
377 {
378 return;
379 }
380
381 mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegmentsLeft );
382 disconnectUpdateSignal();
383 mScalebar->setNumberOfSegmentsLeft( i );
384 mScalebar->update();
385 connectUpdateSignal();
386 mScalebar->endCommand();
387}
388
389void QgsLayoutScaleBarWidget::mNumberOfSegmentsSpinBox_valueChanged( int i )
390{
391 if ( !mScalebar )
392 {
393 return;
394 }
395
396 mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegments );
397 disconnectUpdateSignal();
398 mScalebar->setNumberOfSegments( i );
399 mScalebar->update();
400 connectUpdateSignal();
401 mScalebar->endCommand();
402}
403
404void QgsLayoutScaleBarWidget::mHeightSpinBox_valueChanged( double d )
405{
406 if ( !mScalebar )
407 {
408 return;
409 }
410 mScalebar->beginCommand( tr( "Set Scalebar Height" ), QgsLayoutItem::UndoScaleBarHeight );
411 disconnectUpdateSignal();
412 mScalebar->setHeight( d );
413 mScalebar->update();
414 connectUpdateSignal();
415 mScalebar->endCommand();
416}
417
418void QgsLayoutScaleBarWidget::mNumberOfSubdivisionsSpinBox_valueChanged( int i )
419{
420 if ( !mScalebar )
421 {
422 return;
423 }
424
425 mScalebar->beginCommand( tr( "Set Scalebar Subdivisions" ), QgsLayoutItem::UndoScaleBarSubdivisions );
426 disconnectUpdateSignal();
427 mScalebar->setNumberOfSubdivisions( i );
428 mScalebar->update();
429 connectUpdateSignal();
430 mScalebar->endCommand();
431}
432
433void QgsLayoutScaleBarWidget::mSubdivisionsHeightSpinBox_valueChanged( double d )
434{
435 if ( !mScalebar )
436 {
437 return;
438 }
439 mScalebar->beginCommand( tr( "Set Subdivisions Height" ), QgsLayoutItem::UndoScaleBarSubdivisionsHeight );
440 disconnectUpdateSignal();
441 mScalebar->setSubdivisionsHeight( d );
442 mScalebar->update();
443 connectUpdateSignal();
444 mScalebar->endCommand();
445}
446
447void QgsLayoutScaleBarWidget::textFormatChanged()
448{
449 if ( !mScalebar )
450 {
451 return;
452 }
453
454 mScalebar->beginCommand( tr( "Set Scalebar Font" ) );
455 disconnectUpdateSignal();
456 mScalebar->setTextFormat( mFontButton->textFormat() );
457 connectUpdateSignal();
458 mScalebar->endCommand();
459 mScalebar->update();
460}
461
462void QgsLayoutScaleBarWidget::changeNumberFormat()
463{
464 if ( !mScalebar )
465 {
466 return;
467 }
468
470 widget->setPanelTitle( tr( "Number Format" ) );
471 widget->setFormat( mScalebar->numericFormat() );
472 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [ = ]
473 {
474 mScalebar->beginCommand( tr( "Set Scalebar Number Format" ) );
475 disconnectUpdateSignal();
476 mScalebar->setNumericFormat( widget->format() );
477 connectUpdateSignal();
478 mScalebar->endCommand();
479 mScalebar->update();
480 } );
481 openPanel( widget );
482 return;
483}
484
485QgsLayoutScaleBarWidget::DistanceLabelPlacement QgsLayoutScaleBarWidget::distanceLabelPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement horizontalPlacement, Qgis::ScaleBarDistanceLabelVerticalPlacement verticalPlacement )
486{
487 switch ( horizontalPlacement )
488 {
490 switch ( verticalPlacement )
491 {
493 return DistanceLabelPlacement::CenteredAboveSegmentEdges;
495 return DistanceLabelPlacement::CenteredBelowSegmentEdges;
496 }
498
500 switch ( verticalPlacement )
501 {
503 return DistanceLabelPlacement::CenteredAboveSegmentCenters;
505 return DistanceLabelPlacement::CenteredBelowSegmentCenters;
506 }
508 }
510}
511
512void QgsLayoutScaleBarWidget::mUnitLabelLineEdit_textChanged( const QString &text )
513{
514 if ( !mScalebar )
515 {
516 return;
517 }
518
519 mScalebar->beginCommand( tr( "Set Scalebar Unit Text" ), QgsLayoutItem::UndoScaleBarUnitText );
520 disconnectUpdateSignal();
521 mScalebar->setUnitLabel( text );
522 mScalebar->update();
523 connectUpdateSignal();
524 mScalebar->endCommand();
525}
526
527void QgsLayoutScaleBarWidget::mMapUnitsPerBarUnitSpinBox_valueChanged( double d )
528{
529 if ( !mScalebar )
530 {
531 return;
532 }
533
534 mScalebar->beginCommand( tr( "Set Scalebar Map Units per Segment" ), QgsLayoutItem::UndoScaleBarMapUnitsSegment );
535 disconnectUpdateSignal();
536 mScalebar->setMapUnitsPerScaleBarUnit( d );
537 mScalebar->update();
538 connectUpdateSignal();
539 mScalebar->endCommand();
540}
541
542void QgsLayoutScaleBarWidget::mStyleComboBox_currentIndexChanged( const QString & )
543{
544 if ( !mScalebar )
545 {
546 return;
547 }
548
549 const QString rendererId = mStyleComboBox->currentData().toString();
550 if ( rendererId == mScalebar->style() )
551 return;
552
553 mScalebar->beginCommand( tr( "Set Scalebar Style" ) );
554 disconnectUpdateSignal();
555
556 bool defaultsApplied = false;
557 const std::unique_ptr< QgsScaleBarRenderer > renderer( QgsApplication::scaleBarRendererRegistry()->renderer( rendererId ) );
558 if ( renderer )
559 defaultsApplied = mScalebar->applyDefaultRendererSettings( renderer.get() );
560
561 //disable or enable controls which apply to specific scale bar styles
562 toggleStyleSpecificControls( rendererId );
563
564 mScalebar->setStyle( rendererId );
565 mScalebar->update();
566 connectUpdateSignal();
567 mScalebar->endCommand();
568
569 if ( defaultsApplied )
570 setGuiElements();
571}
572
573void QgsLayoutScaleBarWidget::toggleStyleSpecificControls( const QString &style )
574{
575 std::unique_ptr< QgsScaleBarRenderer > renderer( QgsApplication::scaleBarRendererRegistry()->renderer( style ) );
576
577 //Selectively enable controls which apply to the scale bar style
578 mUnitsComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
579 mUnitsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
580 mMapUnitsPerBarUnitSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
581 mMapUnitsPerBarUnitLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
582 mUnitLabelLineEdit->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
583 mUnitLabelLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
584 mSubdivisionsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
585 mNumberOfSubdivisionsSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
586 mSubdivisionsHeightLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
587 mSubdivisionsHeightSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
588 mGroupBoxSegments->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSegments : true );
589 if ( !mGroupBoxUnits->isEnabled() )
590 mGroupBoxSegments->setCollapsed( true );
591 mLabelBarSpaceSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
592 mLabelBarSpaceLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
593 mDistanceLabelPlacementComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement : true );
594 mLabelVerticalPlacementLabel->setEnabled( renderer ? ( renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelHorizontalPlacement
595 || renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement ) : true );
596 mAlignmentComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
597 mAlignmentLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
598 mFillSymbol1Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
599 mFillSymbol1Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
600 mFillSymbol2Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
601 mFillSymbol2Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
602 mLineStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
603 mLineStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
604 mDivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
605 mDivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
606 mSubdivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
607 mSubdivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
608}
609
610void QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged( double d )
611{
612 if ( !mScalebar )
613 {
614 return;
615 }
616
617 mScalebar->beginCommand( tr( "Set Scalebar Label Space" ), QgsLayoutItem::UndoScaleBarLabelBarSize );
618 disconnectUpdateSignal();
619 mScalebar->setLabelBarSpace( d );
620 mScalebar->update();
621 connectUpdateSignal();
622 mScalebar->endCommand();
623}
624
625void QgsLayoutScaleBarWidget::mBoxSizeSpinBox_valueChanged( double d )
626{
627 if ( !mScalebar )
628 {
629 return;
630 }
631
632 mScalebar->beginCommand( tr( "Set Scalebar Box Space" ), QgsLayoutItem::UndoScaleBarBoxContentSpace );
633 disconnectUpdateSignal();
634 mScalebar->setBoxContentSpace( d );
635 mScalebar->update();
636 connectUpdateSignal();
637 mScalebar->endCommand();
638}
639
640void QgsLayoutScaleBarWidget::mDistanceLabelPlacementComboBox_currentIndexChanged( int index )
641{
642 if ( !mScalebar )
643 {
644 return;
645 }
646
647 mScalebar->beginCommand( tr( "Set Scalebar Label Placement" ) );
648 disconnectUpdateSignal();
649
650 const DistanceLabelPlacement placement = static_cast<DistanceLabelPlacement>( mDistanceLabelPlacementComboBox->itemData( index ).toInt() );
651 switch ( placement )
652 {
653 case DistanceLabelPlacement::CenteredAboveSegmentEdges:
654 mScalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::AboveSegment );
655 mScalebar->setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredEdge );
656 break;
657 case DistanceLabelPlacement::CenteredAboveSegmentCenters:
658 mScalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::AboveSegment );
659 mScalebar->setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredSegment );
660 break;
661 case DistanceLabelPlacement::CenteredBelowSegmentEdges:
662 mScalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::BelowSegment );
663 mScalebar->setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredEdge );
664 break;
665 case DistanceLabelPlacement::CenteredBelowSegmentCenters:
666 mScalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::BelowSegment );
667 mScalebar->setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredSegment );
668 break;
669 }
670
671 mScalebar->update();
672 connectUpdateSignal();
673 mScalebar->endCommand();
674}
675
676void QgsLayoutScaleBarWidget::alignmentChanged()
677{
678 if ( !mScalebar )
679 {
680 return;
681 }
682
683 mScalebar->beginCommand( tr( "Set Scalebar Alignment" ) );
684 disconnectUpdateSignal();
685
686 const Qgis::ScaleBarAlignment a = mAlignmentComboBox->currentAlignment() & Qt::AlignLeft ? Qgis::ScaleBarAlignment::Left
687 : mAlignmentComboBox->currentAlignment() & Qt::AlignRight ? Qgis::ScaleBarAlignment::Right : Qgis::ScaleBarAlignment::Middle;
688 mScalebar->setAlignment( a );
689 mScalebar->update();
690 connectUpdateSignal();
691 mScalebar->endCommand();
692}
693
694void QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged( int index )
695{
696 if ( !mScalebar )
697 {
698 return;
699 }
700
701 const QVariant unitData = mUnitsComboBox->itemData( index );
702 if ( unitData.userType() == QMetaType::Type::UnknownType )
703 {
704 return;
705 }
706
707 disconnectUpdateSignal();
708 mScalebar->beginCommand( tr( "Set Scalebar Units" ) );
709 mScalebar->applyDefaultSize( static_cast< Qgis::DistanceUnit >( unitData.toInt() ) );
710 mScalebar->update();
711
712 mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
713 mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
714 mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
715 mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
716 mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
717
718 connectUpdateSignal();
719 mScalebar->endCommand();
720}
721
722void QgsLayoutScaleBarWidget::blockMemberSignals( bool block )
723{
724 mSegmentSizeSpinBox->blockSignals( block );
725 mNumberOfSegmentsSpinBox->blockSignals( block );
726 mSegmentsLeftSpinBox->blockSignals( block );
727 mNumberOfSubdivisionsSpinBox->blockSignals( block );
728 mSubdivisionsHeightSpinBox->blockSignals( block );
729 mStyleComboBox->blockSignals( block );
730 mUnitLabelLineEdit->blockSignals( block );
731 mMapUnitsPerBarUnitSpinBox->blockSignals( block );
732 mHeightSpinBox->blockSignals( block );
733 mLineStyleButton->blockSignals( block );
734 mDivisionStyleButton->blockSignals( block );
735 mSubdivisionStyleButton->blockSignals( block );
736 mLabelBarSpaceSpinBox->blockSignals( block );
737 mBoxSizeSpinBox->blockSignals( block );
738 mDistanceLabelPlacementComboBox->blockSignals( block );
739 mAlignmentComboBox->blockSignals( block );
740 mUnitsComboBox->blockSignals( block );
741 mFillSymbol1Button->blockSignals( block );
742 mFillSymbol2Button->blockSignals( block );
743 mSegmentSizeRadioGroup.blockSignals( block );
744 mMapItemComboBox->blockSignals( block );
745 mFontButton->blockSignals( block );
746 mMinWidthSpinBox->blockSignals( block );
747 mMaxWidthSpinBox->blockSignals( block );
748}
749
750void QgsLayoutScaleBarWidget::connectUpdateSignal()
751{
752 if ( mScalebar )
753 {
754 connect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
755 }
756}
757
758void QgsLayoutScaleBarWidget::disconnectUpdateSignal()
759{
760 if ( mScalebar )
761 {
762 disconnect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
763 }
764}
765
766void QgsLayoutScaleBarWidget::segmentSizeRadioChanged( QAbstractButton *radio )
767{
768 const bool fixedSizeMode = radio == mFixedSizeRadio;
769 mMinWidthWidget->setEnabled( !fixedSizeMode );
770 mMaxWidthWidget->setEnabled( !fixedSizeMode );
771 mSegmentSizeWidget->setEnabled( fixedSizeMode );
772
773 if ( !mScalebar )
774 {
775 return;
776 }
777
778 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
779 disconnectUpdateSignal();
780 if ( mFixedSizeRadio->isChecked() )
781 {
782 mScalebar->setSegmentSizeMode( Qgis::ScaleBarSegmentSizeMode::Fixed );
783 mScalebar->setUnitsPerSegment( mSegmentSizeSpinBox->value() );
784 }
785 else /*if(mFitWidthRadio->isChecked())*/
786 {
787 mScalebar->setSegmentSizeMode( Qgis::ScaleBarSegmentSizeMode::FitWidth );
788 }
789 mScalebar->update();
790 connectUpdateSignal();
791 mScalebar->endCommand();
792}
793
794void QgsLayoutScaleBarWidget::mapChanged( QgsLayoutItem *item )
795{
796 QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( item );
797 if ( !map )
798 {
799 return;
800 }
801
802 //set it to scale bar
803 mScalebar->beginCommand( tr( "Set Scalebar Map" ) );
804 disconnectUpdateSignal();
805 mScalebar->setLinkedMap( map );
806 mScalebar->update();
807 connectUpdateSignal();
808 mScalebar->endCommand();
809}
810
811void QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged( double )
812{
813 if ( !mScalebar )
814 {
815 return;
816 }
817
818 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
819 disconnectUpdateSignal();
820 mScalebar->setMinimumBarWidth( mMinWidthSpinBox->value() );
821 mScalebar->update();
822 connectUpdateSignal();
823 mScalebar->endCommand();
824}
825
826void QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged( double )
827{
828 if ( !mScalebar )
829 {
830 return;
831 }
832
833 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
834 disconnectUpdateSignal();
835 mScalebar->setMaximumBarWidth( mMaxWidthSpinBox->value() );
836 mScalebar->update();
837 connectUpdateSignal();
838 mScalebar->endCommand();
839}
840
841void QgsLayoutScaleBarWidget::populateDataDefinedButtons()
842{
843 updateDataDefinedButton( mSegmentsLeftDDBtn );
844 updateDataDefinedButton( mSegmentsRightDDBtn );
845 updateDataDefinedButton( mSegmentSizeDDBtn );
846 updateDataDefinedButton( mMinWidthDDBtn );
847 updateDataDefinedButton( mMaxWidthDDBtn );
848 updateDataDefinedButton( mHeightDDBtn );
849 updateDataDefinedButton( mSubdivisionHeightDDBtn );
850 updateDataDefinedButton( mRightSegmentSubdivisionsDDBtn );
851}
ScaleBarDistanceLabelHorizontalPlacement
Scale bar distance label horizontal placement.
Definition qgis.h:4706
@ 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.
Definition qgis.h:4692
@ AboveSegment
Labels are drawn above the scalebar.
@ BelowSegment
Labels are drawn below the scalebar.
ScaleBarAlignment
Scalebar alignment.
Definition qgis.h:4663
@ Right
Right aligned.
@ Middle
Center aligned.
DistanceUnit
Units of distance.
Definition qgis.h:4463
@ Feet
Imperial feet.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Unknown
Unknown distance unit.
@ Yards
Imperial yards.
@ Inches
Inches (since QGIS 3.32)
@ NauticalMiles
Nautical miles.
@ Kilometers
Kilometers.
@ FitWidth
Scale bar segment size is calculated to fit a size range.
@ Fixed
Scale bar segment size is fixed to a map unit.
@ 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.
@ ModeTextRenderer
Configure font settings for use with QgsTextRenderer.
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.
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)
@ ScalebarRightSegments
Number of segments on the right of 0 (since QGIS 3.26)
@ ScalebarRightSegmentSubdivisions
Number of subdivisions per segment on right of 0 (since QGIS 3.26)
@ ScalebarMaximumWidth
Scalebar segment maximum width (since QGIS 3.26)
@ ScalebarHeight
Scalebar height (since QGIS 3.26)
@ ScalebarSubdivisionHeight
Scalebar subdivision height (since QGIS 3.26)
@ ScalebarLeftSegments
Number of segments on the left of 0 (since QGIS 3.26)
@ ScalebarSegmentWidth
Scalebar width in map units of a single segment (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:49
A line symbol type, for rendering LineString and MultiLineString geometries.
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...
QString visibleName(const QString &id) const
Returns the translated, user-visible name for the renderer with matching id.
@ 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() )
void setLayer(QgsVectorLayer *layer)
Sets a layer to associate with the widget.
void changed()
Emitted when the symbol's settings are changed.
#define BUILTIN_UNREACHABLE
Definition qgis.h:6306
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:5556
Single variable definition for use within a QgsExpressionContextScope.