QGIS API Documentation 3.43.0-Master (b60ef06885e)
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 "moc_qgslayoutscalebarwidget.cpp"
19#include "qgslayoutitemmap.h"
22#include "qgslayout.h"
24#include "qgslayoutundostack.h"
25#include "qgsfillsymbol.h"
26#include "qgslinesymbol.h"
28#include "qgsvectorlayer.h"
29
30#include <QColorDialog>
31#include <QFontDialog>
32#include <QWidget>
33
35 : QgsLayoutItemBaseWidget( nullptr, scaleBar )
36 , mScalebar( scaleBar )
37{
38 setupUi( this );
39
40 mNumberOfSubdivisionsSpinBox->setClearValue( 1 );
41
42 connect( mHeightSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mHeightSpinBox_valueChanged );
43 connect( mSegmentSizeSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mSegmentSizeSpinBox_valueChanged );
44 connect( mSegmentsLeftSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mSegmentsLeftSpinBox_valueChanged );
45 connect( mNumberOfSegmentsSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mNumberOfSegmentsSpinBox_valueChanged );
46 connect( mNumberOfSubdivisionsSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mNumberOfSubdivisionsSpinBox_valueChanged );
47 connect( mSubdivisionsHeightSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mSubdivisionsHeightSpinBox_valueChanged );
48 connect( mUnitLabelLineEdit, &QLineEdit::textChanged, this, &QgsLayoutScaleBarWidget::mUnitLabelLineEdit_textChanged );
49 connect( mMapUnitsPerBarUnitSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mMapUnitsPerBarUnitSpinBox_valueChanged );
50 connect( mStyleComboBox, &QComboBox::currentTextChanged, this, &QgsLayoutScaleBarWidget::mStyleComboBox_currentIndexChanged );
51 connect( mLabelBarSpaceSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged );
52 connect( mBoxSizeSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mBoxSizeSpinBox_valueChanged );
53 connect( mAlignmentComboBox, &QgsAlignmentComboBox::changed, this, &QgsLayoutScaleBarWidget::alignmentChanged );
54 connect( mDistanceLabelPlacementComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsLayoutScaleBarWidget::mDistanceLabelPlacementComboBox_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 connect( mScaleMethodWidget, &QgsScaleMethodWidget::methodChanged, this, [=] {
60 if ( !mScalebar )
61 {
62 return;
63 }
64
65 disconnectUpdateSignal();
66 mScalebar->beginCommand( tr( "Set Scalebar Method" ) );
67 mScalebar->setMethod( mScaleMethodWidget->scaleMethod() );
68 mScalebar->update();
69 connectUpdateSignal();
70 mScalebar->endCommand();
71 } );
72
81
82 mSegmentsLeftDDBtn->registerEnabledWidget( mSegmentsLeftSpinBox, false );
83 mSegmentsRightDDBtn->registerEnabledWidget( mNumberOfSegmentsSpinBox, false );
84 mSegmentSizeDDBtn->registerEnabledWidget( mSegmentSizeSpinBox, false );
85 mMinWidthDDBtn->registerEnabledWidget( mMinWidthSpinBox, false );
86 mMaxWidthDDBtn->registerEnabledWidget( mMaxWidthSpinBox, false );
87
88 setPanelTitle( tr( "Scalebar Properties" ) );
89
90 mFontButton->registerExpressionContextGenerator( this );
91
92 connectUpdateSignal();
93
94 //add widget for general composer item properties
95 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, scaleBar );
96 mainLayout->addWidget( mItemPropertiesWidget );
97
98 mSegmentSizeRadioGroup.addButton( mFixedSizeRadio );
99 mSegmentSizeRadioGroup.addButton( mFitWidthRadio );
100 connect( &mSegmentSizeRadioGroup, static_cast<void ( QButtonGroup::* )( QAbstractButton * )>( &QButtonGroup::buttonClicked ), this, &QgsLayoutScaleBarWidget::segmentSizeRadioChanged );
101
102 blockMemberSignals( true );
103
104 //style combo box
105 const QStringList renderers = QgsApplication::scaleBarRendererRegistry()->sortedRendererList();
106 for ( const QString &renderer : renderers )
107 {
108 mStyleComboBox->addItem( QgsApplication::scaleBarRendererRegistry()->visibleName( renderer ), renderer );
109 }
110
111 //label vertical/horizontal placement combo box
112 mDistanceLabelPlacementComboBox->addItem( tr( "Above Segment Edges" ), static_cast<int>( DistanceLabelPlacement::CenteredAboveSegmentEdges ) );
113 mDistanceLabelPlacementComboBox->addItem( tr( "Above Segment Centers" ), static_cast<int>( DistanceLabelPlacement::CenteredAboveSegmentCenters ) );
114 mDistanceLabelPlacementComboBox->addItem( tr( "Below Segment Edges" ), static_cast<int>( DistanceLabelPlacement::CenteredBelowSegmentEdges ) );
115 mDistanceLabelPlacementComboBox->addItem( tr( "Below Segment Centers" ), static_cast<int>( DistanceLabelPlacement::CenteredBelowSegmentCenters ) );
116
117 //alignment combo box
118 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
119
120 //units combo box
121 mUnitsComboBox->addItem( tr( "Map units" ), static_cast<int>( Qgis::DistanceUnit::Unknown ) );
122 mUnitsComboBox->addItem( tr( "Meters" ), static_cast<int>( Qgis::DistanceUnit::Meters ) );
123 mUnitsComboBox->addItem( tr( "Kilometers" ), static_cast<int>( Qgis::DistanceUnit::Kilometers ) );
124 mUnitsComboBox->addItem( tr( "Feet" ), static_cast<int>( Qgis::DistanceUnit::Feet ) );
125 mUnitsComboBox->addItem( tr( "Yards" ), static_cast<int>( Qgis::DistanceUnit::Yards ) );
126 mUnitsComboBox->addItem( tr( "Miles" ), static_cast<int>( Qgis::DistanceUnit::Miles ) );
127 mUnitsComboBox->addItem( tr( "Nautical Miles" ), static_cast<int>( Qgis::DistanceUnit::NauticalMiles ) );
128 mUnitsComboBox->addItem( tr( "Centimeters" ), static_cast<int>( Qgis::DistanceUnit::Centimeters ) );
129 mUnitsComboBox->addItem( tr( "Millimeters" ), static_cast<int>( Qgis::DistanceUnit::Millimeters ) );
130 mUnitsComboBox->addItem( tr( "Inches" ), static_cast<int>( Qgis::DistanceUnit::Inches ) );
131
132 mLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
133 connect( mLineStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::lineSymbolChanged );
134
135 mDivisionStyleButton->setSymbolType( Qgis::SymbolType::Line );
136 connect( mDivisionStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::divisionSymbolChanged );
137
138 mSubdivisionStyleButton->setSymbolType( Qgis::SymbolType::Line );
139 connect( mSubdivisionStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::subdivisionSymbolChanged );
140
141 mFillSymbol1Button->setSymbolType( Qgis::SymbolType::Fill );
142 connect( mFillSymbol1Button, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::fillSymbol1Changed );
143
144 mFillSymbol2Button->setSymbolType( Qgis::SymbolType::Fill );
145 connect( mFillSymbol2Button, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::fillSymbol2Changed );
146
147 mFontButton->setDialogTitle( tr( "Scalebar Font" ) );
148 mFontButton->setMode( QgsFontButton::ModeTextRenderer );
149
150 if ( mScalebar )
151 {
152 QgsLayout *scaleBarLayout = mScalebar->layout();
153 if ( scaleBarLayout )
154 {
155 mMapItemComboBox->setCurrentLayout( scaleBarLayout );
156 mMapItemComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
157 }
158 }
159
160 connect( mMapItemComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutScaleBarWidget::mapChanged );
161
162 blockMemberSignals( false );
163 setGuiElements(); //set the GUI elements to the state of scaleBar
164
165 mLineStyleButton->registerExpressionContextGenerator( mScalebar );
166 mLineStyleButton->setLayer( coverageLayer() );
167 mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
168 mDivisionStyleButton->setLayer( coverageLayer() );
169 mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
170 mSubdivisionStyleButton->setLayer( coverageLayer() );
171 mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
172 mFillSymbol1Button->setLayer( coverageLayer() );
173 mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
174 mFillSymbol2Button->setLayer( coverageLayer() );
175
176 connect( mFontButton, &QgsFontButton::changed, this, &QgsLayoutScaleBarWidget::textFormatChanged );
177 mFontButton->setLayer( coverageLayer() );
178 if ( mScalebar->layout() )
179 {
180 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFontButton, &QgsFontButton::setLayer );
181 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mLineStyleButton, &QgsSymbolButton::setLayer );
182 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mDivisionStyleButton, &QgsSymbolButton::setLayer );
183 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mSubdivisionStyleButton, &QgsSymbolButton::setLayer );
184 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFillSymbol1Button, &QgsSymbolButton::setLayer );
185 connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFillSymbol2Button, &QgsSymbolButton::setLayer );
186 }
187}
188
190{
191 if ( mItemPropertiesWidget )
192 mItemPropertiesWidget->setMasterLayout( masterLayout );
193}
194
196{
197 QgsExpressionContext context = mScalebar->createExpressionContext();
198 QgsExpressionContextScope *scaleScope = new QgsExpressionContextScope( QStringLiteral( "scalebar_text" ) );
199 scaleScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "scale_value" ), 0, true, false ) );
200 context.appendScope( scaleScope );
201 context.setHighlightedVariables( QStringList() << QStringLiteral( "scale_value" ) );
202 return context;
203}
204
206{
208 return false;
209
210 disconnectUpdateSignal();
211
212 mScalebar = qobject_cast<QgsLayoutItemScaleBar *>( item );
213 mItemPropertiesWidget->setItem( mScalebar );
214
215 if ( mScalebar )
216 {
217 connectUpdateSignal();
218 mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
219 mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
220 mLineStyleButton->registerExpressionContextGenerator( mScalebar );
221 mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
222 mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
223 }
224
225 setGuiElements();
226
227 return true;
228}
229
230void QgsLayoutScaleBarWidget::lineSymbolChanged()
231{
232 if ( !mScalebar )
233 return;
234
235 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Line Style" ), QgsLayoutItem::UndoShapeStyle );
236 mScalebar->setLineSymbol( mLineStyleButton->clonedSymbol<QgsLineSymbol>() );
237 mScalebar->update();
238 mScalebar->layout()->undoStack()->endCommand();
239}
240
241void QgsLayoutScaleBarWidget::divisionSymbolChanged()
242{
243 if ( !mScalebar )
244 return;
245
246 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Division Style" ), QgsLayoutItem::UndoShapeStyle );
247 mScalebar->setDivisionLineSymbol( mDivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
248 mScalebar->update();
249 mScalebar->layout()->undoStack()->endCommand();
250}
251
252void QgsLayoutScaleBarWidget::subdivisionSymbolChanged()
253{
254 if ( !mScalebar )
255 return;
256
257 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Subdivision Style" ), QgsLayoutItem::UndoShapeStyle );
258 mScalebar->setSubdivisionLineSymbol( mSubdivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
259 mScalebar->update();
260 mScalebar->layout()->undoStack()->endCommand();
261}
262
263void QgsLayoutScaleBarWidget::fillSymbol1Changed()
264{
265 if ( !mScalebar )
266 return;
267
268 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Fill Style" ), QgsLayoutItem::UndoShapeStyle );
269 mScalebar->setFillSymbol( mFillSymbol1Button->clonedSymbol<QgsFillSymbol>() );
270 mScalebar->update();
271 mScalebar->layout()->undoStack()->endCommand();
272}
273
274void QgsLayoutScaleBarWidget::fillSymbol2Changed()
275{
276 if ( !mScalebar )
277 return;
278
279 mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Fill Style" ), QgsLayoutItem::UndoShapeStyle );
280 mScalebar->setAlternateFillSymbol( mFillSymbol2Button->clonedSymbol<QgsFillSymbol>() );
281 mScalebar->update();
282 mScalebar->layout()->undoStack()->endCommand();
283}
284
285void QgsLayoutScaleBarWidget::setGuiElements()
286{
287 if ( !mScalebar )
288 {
289 return;
290 }
291
292 blockMemberSignals( true );
293 mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
294 mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
295 mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
296 mHeightSpinBox->setValue( mScalebar->height() );
297 mNumberOfSubdivisionsSpinBox->setValue( mScalebar->numberOfSubdivisions() );
298 mSubdivisionsHeightSpinBox->setValue( mScalebar->subdivisionsHeight() );
299 mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
300 mLabelBarSpaceSpinBox->setValue( mScalebar->labelBarSpace() );
301 mBoxSizeSpinBox->setValue( mScalebar->boxContentSpace() );
302 mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
303 mFontButton->setTextFormat( mScalebar->textFormat() );
304
305 whileBlocking( mLineStyleButton )->setSymbol( mScalebar->lineSymbol()->clone() );
306 whileBlocking( mDivisionStyleButton )->setSymbol( mScalebar->divisionLineSymbol()->clone() );
307 whileBlocking( mSubdivisionStyleButton )->setSymbol( mScalebar->subdivisionLineSymbol()->clone() );
308 whileBlocking( mFillSymbol1Button )->setSymbol( mScalebar->fillSymbol()->clone() );
309 whileBlocking( mFillSymbol2Button )->setSymbol( mScalebar->alternateFillSymbol()->clone() );
310
311 //map combo box
312 mMapItemComboBox->setItem( mScalebar->linkedMap() );
313
314 //style...
315 const QString style = mScalebar->style();
316 mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( style ) );
317 toggleStyleSpecificControls( style );
318
319 //label vertical/horizontal placement
320 mDistanceLabelPlacementComboBox->setCurrentIndex( mDistanceLabelPlacementComboBox->findData( static_cast<int>(
321 distanceLabelPlacement( mScalebar->labelHorizontalPlacement(), mScalebar->labelVerticalPlacement() )
322 ) ) );
323
324 //alignment
325
326 Qt::Alignment a = Qt::AlignLeft;
327 switch ( mScalebar->alignment() )
328 {
330 a = Qt::AlignLeft;
331 break;
333 a = Qt::AlignRight;
334 break;
336 a = Qt::AlignHCenter;
337 break;
338 }
339 mAlignmentComboBox->setCurrentAlignment( a );
340
341 //units
342 mUnitsComboBox->setCurrentIndex( mUnitsComboBox->findData( static_cast<int>( mScalebar->units() ) ) );
343
344 switch ( mScalebar->segmentSizeMode() )
345 {
347 {
348 mFixedSizeRadio->setChecked( true );
349 mSegmentSizeWidget->setEnabled( true );
350 mMinWidthWidget->setEnabled( false );
351 mMaxWidthWidget->setEnabled( false );
352 break;
353 }
354
356 {
357 mFitWidthRadio->setChecked( true );
358 mSegmentSizeWidget->setEnabled( false );
359 mMinWidthWidget->setEnabled( true );
360 mMaxWidthWidget->setEnabled( true );
361 break;
362 }
363 }
364 mMinWidthSpinBox->setValue( mScalebar->minimumBarWidth() );
365 mMaxWidthSpinBox->setValue( mScalebar->maximumBarWidth() );
366
367 mScaleMethodWidget->setScaleMethod( mScalebar->method() );
368
369 populateDataDefinedButtons();
370
371 blockMemberSignals( false );
372}
373
374//slots
375
376void QgsLayoutScaleBarWidget::mSegmentSizeSpinBox_valueChanged( double d )
377{
378 if ( !mScalebar )
379 {
380 return;
381 }
382
383 mScalebar->beginCommand( tr( "Set Scalebar Segment Size" ), QgsLayoutItem::UndoScaleBarSegmentSize );
384 disconnectUpdateSignal();
385 mScalebar->setUnitsPerSegment( d );
386 mScalebar->update();
387 connectUpdateSignal();
388 mScalebar->endCommand();
389}
390
391void QgsLayoutScaleBarWidget::mSegmentsLeftSpinBox_valueChanged( int i )
392{
393 if ( !mScalebar )
394 {
395 return;
396 }
397
398 mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegmentsLeft );
399 disconnectUpdateSignal();
400 mScalebar->setNumberOfSegmentsLeft( i );
401 mScalebar->update();
402 connectUpdateSignal();
403 mScalebar->endCommand();
404}
405
406void QgsLayoutScaleBarWidget::mNumberOfSegmentsSpinBox_valueChanged( int i )
407{
408 if ( !mScalebar )
409 {
410 return;
411 }
412
413 mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegments );
414 disconnectUpdateSignal();
415 mScalebar->setNumberOfSegments( i );
416 mScalebar->update();
417 connectUpdateSignal();
418 mScalebar->endCommand();
419}
420
421void QgsLayoutScaleBarWidget::mHeightSpinBox_valueChanged( double d )
422{
423 if ( !mScalebar )
424 {
425 return;
426 }
427 mScalebar->beginCommand( tr( "Set Scalebar Height" ), QgsLayoutItem::UndoScaleBarHeight );
428 disconnectUpdateSignal();
429 mScalebar->setHeight( d );
430 mScalebar->update();
431 connectUpdateSignal();
432 mScalebar->endCommand();
433}
434
435void QgsLayoutScaleBarWidget::mNumberOfSubdivisionsSpinBox_valueChanged( int i )
436{
437 if ( !mScalebar )
438 {
439 return;
440 }
441
442 mScalebar->beginCommand( tr( "Set Scalebar Subdivisions" ), QgsLayoutItem::UndoScaleBarSubdivisions );
443 disconnectUpdateSignal();
444 mScalebar->setNumberOfSubdivisions( i );
445 mScalebar->update();
446 connectUpdateSignal();
447 mScalebar->endCommand();
448}
449
450void QgsLayoutScaleBarWidget::mSubdivisionsHeightSpinBox_valueChanged( double d )
451{
452 if ( !mScalebar )
453 {
454 return;
455 }
456 mScalebar->beginCommand( tr( "Set Subdivisions Height" ), QgsLayoutItem::UndoScaleBarSubdivisionsHeight );
457 disconnectUpdateSignal();
458 mScalebar->setSubdivisionsHeight( d );
459 mScalebar->update();
460 connectUpdateSignal();
461 mScalebar->endCommand();
462}
463
464void QgsLayoutScaleBarWidget::textFormatChanged()
465{
466 if ( !mScalebar )
467 {
468 return;
469 }
470
471 mScalebar->beginCommand( tr( "Set Scalebar Font" ) );
472 disconnectUpdateSignal();
473 mScalebar->setTextFormat( mFontButton->textFormat() );
474 connectUpdateSignal();
475 mScalebar->endCommand();
476 mScalebar->update();
477}
478
479void QgsLayoutScaleBarWidget::changeNumberFormat()
480{
481 if ( !mScalebar )
482 {
483 return;
484 }
485
487 widget->setPanelTitle( tr( "Number Format" ) );
488 widget->setFormat( mScalebar->numericFormat() );
489 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [=] {
490 mScalebar->beginCommand( tr( "Set Scalebar Number Format" ) );
491 disconnectUpdateSignal();
492 mScalebar->setNumericFormat( widget->format() );
493 connectUpdateSignal();
494 mScalebar->endCommand();
495 mScalebar->update();
496 } );
497 openPanel( widget );
498 return;
499}
500
501QgsLayoutScaleBarWidget::DistanceLabelPlacement QgsLayoutScaleBarWidget::distanceLabelPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement horizontalPlacement, Qgis::ScaleBarDistanceLabelVerticalPlacement verticalPlacement )
502{
503 switch ( horizontalPlacement )
504 {
506 switch ( verticalPlacement )
507 {
509 return DistanceLabelPlacement::CenteredAboveSegmentEdges;
511 return DistanceLabelPlacement::CenteredBelowSegmentEdges;
512 }
514
516 switch ( verticalPlacement )
517 {
519 return DistanceLabelPlacement::CenteredAboveSegmentCenters;
521 return DistanceLabelPlacement::CenteredBelowSegmentCenters;
522 }
524 }
526}
527
528void QgsLayoutScaleBarWidget::mUnitLabelLineEdit_textChanged( const QString &text )
529{
530 if ( !mScalebar )
531 {
532 return;
533 }
534
535 mScalebar->beginCommand( tr( "Set Scalebar Unit Text" ), QgsLayoutItem::UndoScaleBarUnitText );
536 disconnectUpdateSignal();
537 mScalebar->setUnitLabel( text );
538 mScalebar->update();
539 connectUpdateSignal();
540 mScalebar->endCommand();
541}
542
543void QgsLayoutScaleBarWidget::mMapUnitsPerBarUnitSpinBox_valueChanged( double d )
544{
545 if ( !mScalebar )
546 {
547 return;
548 }
549
550 mScalebar->beginCommand( tr( "Set Scalebar Map Units per Segment" ), QgsLayoutItem::UndoScaleBarMapUnitsSegment );
551 disconnectUpdateSignal();
552 mScalebar->setMapUnitsPerScaleBarUnit( d );
553 mScalebar->update();
554 connectUpdateSignal();
555 mScalebar->endCommand();
556}
557
558void QgsLayoutScaleBarWidget::mStyleComboBox_currentIndexChanged( const QString & )
559{
560 if ( !mScalebar )
561 {
562 return;
563 }
564
565 const QString rendererId = mStyleComboBox->currentData().toString();
566 if ( rendererId == mScalebar->style() )
567 return;
568
569 mScalebar->beginCommand( tr( "Set Scalebar Style" ) );
570 disconnectUpdateSignal();
571
572 bool defaultsApplied = false;
573 const std::unique_ptr<QgsScaleBarRenderer> renderer( QgsApplication::scaleBarRendererRegistry()->renderer( rendererId ) );
574 if ( renderer )
575 defaultsApplied = mScalebar->applyDefaultRendererSettings( renderer.get() );
576
577 //disable or enable controls which apply to specific scale bar styles
578 toggleStyleSpecificControls( rendererId );
579
580 mScalebar->setStyle( rendererId );
581 mScalebar->update();
582 connectUpdateSignal();
583 mScalebar->endCommand();
584
585 if ( defaultsApplied )
586 setGuiElements();
587}
588
589void QgsLayoutScaleBarWidget::toggleStyleSpecificControls( const QString &style )
590{
591 std::unique_ptr<QgsScaleBarRenderer> renderer( QgsApplication::scaleBarRendererRegistry()->renderer( style ) );
592
593 //Selectively enable controls which apply to the scale bar style
594 mUnitsComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
595 mUnitsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
596 mMapUnitsPerBarUnitSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
597 mMapUnitsPerBarUnitLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
598 mUnitLabelLineEdit->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
599 mUnitLabelLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
600 mSubdivisionsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
601 mNumberOfSubdivisionsSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
602 mSubdivisionsHeightLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
603 mSubdivisionsHeightSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
604 mGroupBoxSegments->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSegments : true );
605 if ( !mGroupBoxUnits->isEnabled() )
606 mGroupBoxSegments->setCollapsed( true );
607 mLabelBarSpaceSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
608 mLabelBarSpaceLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
609 mDistanceLabelPlacementComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement : true );
610 mLabelVerticalPlacementLabel->setEnabled( renderer ? ( renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelHorizontalPlacement || renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement ) : true );
611 mAlignmentComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
612 mAlignmentLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
613 mFillSymbol1Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
614 mFillSymbol1Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
615 mFillSymbol2Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
616 mFillSymbol2Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
617 mLineStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
618 mLineStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
619 mDivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
620 mDivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
621 mSubdivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
622 mSubdivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
623}
624
625void QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged( double d )
626{
627 if ( !mScalebar )
628 {
629 return;
630 }
631
632 mScalebar->beginCommand( tr( "Set Scalebar Label Space" ), QgsLayoutItem::UndoScaleBarLabelBarSize );
633 disconnectUpdateSignal();
634 mScalebar->setLabelBarSpace( d );
635 mScalebar->update();
636 connectUpdateSignal();
637 mScalebar->endCommand();
638}
639
640void QgsLayoutScaleBarWidget::mBoxSizeSpinBox_valueChanged( double d )
641{
642 if ( !mScalebar )
643 {
644 return;
645 }
646
647 mScalebar->beginCommand( tr( "Set Scalebar Box Space" ), QgsLayoutItem::UndoScaleBarBoxContentSpace );
648 disconnectUpdateSignal();
649 mScalebar->setBoxContentSpace( d );
650 mScalebar->update();
651 connectUpdateSignal();
652 mScalebar->endCommand();
653}
654
655void QgsLayoutScaleBarWidget::mDistanceLabelPlacementComboBox_currentIndexChanged( int index )
656{
657 if ( !mScalebar )
658 {
659 return;
660 }
661
662 mScalebar->beginCommand( tr( "Set Scalebar Label Placement" ) );
663 disconnectUpdateSignal();
664
665 const DistanceLabelPlacement placement = static_cast<DistanceLabelPlacement>( mDistanceLabelPlacementComboBox->itemData( index ).toInt() );
666 switch ( placement )
667 {
668 case DistanceLabelPlacement::CenteredAboveSegmentEdges:
669 mScalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::AboveSegment );
670 mScalebar->setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredEdge );
671 break;
672 case DistanceLabelPlacement::CenteredAboveSegmentCenters:
673 mScalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::AboveSegment );
674 mScalebar->setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredSegment );
675 break;
676 case DistanceLabelPlacement::CenteredBelowSegmentEdges:
677 mScalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::BelowSegment );
678 mScalebar->setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredEdge );
679 break;
680 case DistanceLabelPlacement::CenteredBelowSegmentCenters:
681 mScalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::BelowSegment );
682 mScalebar->setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredSegment );
683 break;
684 }
685
686 mScalebar->update();
687 connectUpdateSignal();
688 mScalebar->endCommand();
689}
690
691void QgsLayoutScaleBarWidget::alignmentChanged()
692{
693 if ( !mScalebar )
694 {
695 return;
696 }
697
698 mScalebar->beginCommand( tr( "Set Scalebar Alignment" ) );
699 disconnectUpdateSignal();
700
701 const Qgis::ScaleBarAlignment a = mAlignmentComboBox->currentAlignment() & Qt::AlignLeft ? Qgis::ScaleBarAlignment::Left
702 : mAlignmentComboBox->currentAlignment() & Qt::AlignRight ? Qgis::ScaleBarAlignment::Right
704 mScalebar->setAlignment( a );
705 mScalebar->update();
706 connectUpdateSignal();
707 mScalebar->endCommand();
708}
709
710void QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged( int index )
711{
712 if ( !mScalebar )
713 {
714 return;
715 }
716
717 const QVariant unitData = mUnitsComboBox->itemData( index );
718 if ( unitData.userType() == QMetaType::Type::UnknownType )
719 {
720 return;
721 }
722
723 disconnectUpdateSignal();
724 mScalebar->beginCommand( tr( "Set Scalebar Units" ) );
725 mScalebar->applyDefaultSize( static_cast<Qgis::DistanceUnit>( unitData.toInt() ) );
726 mScalebar->update();
727
728 mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
729 mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
730 mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
731 mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
732 mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
733
734 connectUpdateSignal();
735 mScalebar->endCommand();
736}
737
738void QgsLayoutScaleBarWidget::blockMemberSignals( bool block )
739{
740 mSegmentSizeSpinBox->blockSignals( block );
741 mNumberOfSegmentsSpinBox->blockSignals( block );
742 mSegmentsLeftSpinBox->blockSignals( block );
743 mNumberOfSubdivisionsSpinBox->blockSignals( block );
744 mSubdivisionsHeightSpinBox->blockSignals( block );
745 mStyleComboBox->blockSignals( block );
746 mUnitLabelLineEdit->blockSignals( block );
747 mMapUnitsPerBarUnitSpinBox->blockSignals( block );
748 mHeightSpinBox->blockSignals( block );
749 mLineStyleButton->blockSignals( block );
750 mDivisionStyleButton->blockSignals( block );
751 mSubdivisionStyleButton->blockSignals( block );
752 mLabelBarSpaceSpinBox->blockSignals( block );
753 mBoxSizeSpinBox->blockSignals( block );
754 mDistanceLabelPlacementComboBox->blockSignals( block );
755 mAlignmentComboBox->blockSignals( block );
756 mUnitsComboBox->blockSignals( block );
757 mFillSymbol1Button->blockSignals( block );
758 mFillSymbol2Button->blockSignals( block );
759 mSegmentSizeRadioGroup.blockSignals( block );
760 mMapItemComboBox->blockSignals( block );
761 mFontButton->blockSignals( block );
762 mMinWidthSpinBox->blockSignals( block );
763 mMaxWidthSpinBox->blockSignals( block );
764 mScaleMethodWidget->blockSignals( block );
765}
766
767void QgsLayoutScaleBarWidget::connectUpdateSignal()
768{
769 if ( mScalebar )
770 {
771 connect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
772 }
773}
774
775void QgsLayoutScaleBarWidget::disconnectUpdateSignal()
776{
777 if ( mScalebar )
778 {
779 disconnect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
780 }
781}
782
783void QgsLayoutScaleBarWidget::segmentSizeRadioChanged( QAbstractButton *radio )
784{
785 const bool fixedSizeMode = radio == mFixedSizeRadio;
786 mMinWidthWidget->setEnabled( !fixedSizeMode );
787 mMaxWidthWidget->setEnabled( !fixedSizeMode );
788 mSegmentSizeWidget->setEnabled( fixedSizeMode );
789
790 if ( !mScalebar )
791 {
792 return;
793 }
794
795 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
796 disconnectUpdateSignal();
797 if ( mFixedSizeRadio->isChecked() )
798 {
799 mScalebar->setSegmentSizeMode( Qgis::ScaleBarSegmentSizeMode::Fixed );
800 mScalebar->setUnitsPerSegment( mSegmentSizeSpinBox->value() );
801 }
802 else /*if(mFitWidthRadio->isChecked())*/
803 {
804 mScalebar->setSegmentSizeMode( Qgis::ScaleBarSegmentSizeMode::FitWidth );
805 }
806 mScalebar->update();
807 connectUpdateSignal();
808 mScalebar->endCommand();
809}
810
811void QgsLayoutScaleBarWidget::mapChanged( QgsLayoutItem *item )
812{
813 QgsLayoutItemMap *map = qobject_cast<QgsLayoutItemMap *>( item );
814 if ( !map )
815 {
816 return;
817 }
818
819 //set it to scale bar
820 mScalebar->beginCommand( tr( "Set Scalebar Map" ) );
821 disconnectUpdateSignal();
822 mScalebar->setLinkedMap( map );
823 mScalebar->update();
824 connectUpdateSignal();
825 mScalebar->endCommand();
826}
827
828void QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged( double )
829{
830 if ( !mScalebar )
831 {
832 return;
833 }
834
835 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
836 disconnectUpdateSignal();
837 mScalebar->setMinimumBarWidth( mMinWidthSpinBox->value() );
838 mScalebar->update();
839 connectUpdateSignal();
840 mScalebar->endCommand();
841}
842
843void QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged( double )
844{
845 if ( !mScalebar )
846 {
847 return;
848 }
849
850 mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
851 disconnectUpdateSignal();
852 mScalebar->setMaximumBarWidth( mMaxWidthSpinBox->value() );
853 mScalebar->update();
854 connectUpdateSignal();
855 mScalebar->endCommand();
856}
857
858void QgsLayoutScaleBarWidget::populateDataDefinedButtons()
859{
860 updateDataDefinedButton( mSegmentsLeftDDBtn );
861 updateDataDefinedButton( mSegmentsRightDDBtn );
862 updateDataDefinedButton( mSegmentSizeDDBtn );
863 updateDataDefinedButton( mMinWidthDDBtn );
864 updateDataDefinedButton( mMaxWidthDDBtn );
865 updateDataDefinedButton( mHeightDDBtn );
866 updateDataDefinedButton( mSubdivisionHeightDDBtn );
867 updateDataDefinedButton( mRightSegmentSubdivisionsDDBtn );
868}
ScaleBarDistanceLabelHorizontalPlacement
Scale bar distance label horizontal placement.
Definition qgis.h:5140
@ 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:5126
@ AboveSegment
Labels are drawn above the scalebar.
@ BelowSegment
Labels are drawn below the scalebar.
ScaleBarAlignment
Scalebar alignment.
Definition qgis.h:5097
@ Right
Right aligned.
@ Middle
Center aligned.
DistanceUnit
Units of distance.
Definition qgis.h:4843
@ Feet
Imperial feet.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Unknown
Unknown distance unit.
@ Yards
Imperial yards.
@ 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.
@ ScalebarRightSegments
Number of segments on the right of 0.
@ ScalebarRightSegmentSubdivisions
Number of subdivisions per segment on right of 0.
@ ScalebarMaximumWidth
Scalebar segment maximum width.
@ ScalebarSubdivisionHeight
Scalebar subdivision height.
@ ScalebarLeftSegments
Number of segments on the left of 0.
@ ScalebarSegmentWidth
Scalebar width in map units of a single segment.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
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 methodChanged()
Emitted when the selected method is changed.
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:6896
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:6190
Single variable definition for use within a QgsExpressionContextScope.