QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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"
19 #include "qgslayoutitemscalebar.h"
21 #include "qgslayout.h"
22 #include "qgsguiutils.h"
23 #include "qgsvectorlayer.h"
25 #include "qgslayoutundostack.h"
26 #include "qgsfillsymbol.h"
27 #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" ), QgsUnitTypes::DistanceUnknownUnit );
109  mUnitsComboBox->addItem( tr( "Meters" ), QgsUnitTypes::DistanceMeters );
110  mUnitsComboBox->addItem( tr( "Kilometers" ), QgsUnitTypes::DistanceKilometers );
111  mUnitsComboBox->addItem( tr( "Feet" ), QgsUnitTypes::DistanceFeet );
112  mUnitsComboBox->addItem( tr( "Yards" ), QgsUnitTypes::DistanceYards );
113  mUnitsComboBox->addItem( tr( "Miles" ), QgsUnitTypes::DistanceMiles );
114  mUnitsComboBox->addItem( tr( "Nautical Miles" ), QgsUnitTypes::DistanceNauticalMiles );
115  mUnitsComboBox->addItem( tr( "Centimeters" ), QgsUnitTypes::DistanceCentimeters );
116  mUnitsComboBox->addItem( tr( "Millimeters" ), QgsUnitTypes::DistanceMillimeters );
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 
216 void 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 
227 void 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 
238 void 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 
249 void 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 
260 void 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 
271 void QgsLayoutScaleBarWidget::setGuiElements()
272 {
273  if ( !mScalebar )
274  {
275  return;
276  }
277 
278  blockMemberSignals( true );
279  mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
280  mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
281  mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
282  mHeightSpinBox->setValue( mScalebar->height() );
283  mNumberOfSubdivisionsSpinBox->setValue( mScalebar->numberOfSubdivisions() );
284  mSubdivisionsHeightSpinBox->setValue( mScalebar->subdivisionsHeight() );
285  mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
286  mLabelBarSpaceSpinBox->setValue( mScalebar->labelBarSpace() );
287  mBoxSizeSpinBox->setValue( mScalebar->boxContentSpace() );
288  mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
289  mFontButton->setTextFormat( mScalebar->textFormat() );
290 
291  whileBlocking( mLineStyleButton )->setSymbol( mScalebar->lineSymbol()->clone() );
292  whileBlocking( mDivisionStyleButton )->setSymbol( mScalebar->divisionLineSymbol()->clone() );
293  whileBlocking( mSubdivisionStyleButton )->setSymbol( mScalebar->subdivisionLineSymbol()->clone() );
294  whileBlocking( mFillSymbol1Button )->setSymbol( mScalebar->fillSymbol()->clone() );
295  whileBlocking( mFillSymbol2Button )->setSymbol( mScalebar->alternateFillSymbol()->clone() );
296 
297  //map combo box
298  mMapItemComboBox->setItem( mScalebar->linkedMap() );
299 
300  //style...
301  const QString style = mScalebar->style();
302  mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( style ) );
303  toggleStyleSpecificControls( style );
304 
305  //label vertical/horizontal placement
306  mLabelVerticalPlacementComboBox->setCurrentIndex( mLabelVerticalPlacementComboBox->findData( static_cast< int >( mScalebar->labelVerticalPlacement() ) ) );
307  mLabelHorizontalPlacementComboBox->setCurrentIndex( mLabelHorizontalPlacementComboBox->findData( static_cast< int >( mScalebar->labelHorizontalPlacement() ) ) );
308 
309  //alignment
310 
311  Qt::Alignment a = Qt::AlignLeft;
312  switch ( mScalebar->alignment() )
313  {
315  a = Qt::AlignLeft;
316  break;
318  a = Qt::AlignRight;
319  break;
321  a = Qt::AlignHCenter;
322  break;
323  }
324  mAlignmentComboBox->setCurrentAlignment( a );
325 
326  //units
327  mUnitsComboBox->setCurrentIndex( mUnitsComboBox->findData( static_cast< int >( mScalebar->units() ) ) );
328 
329  if ( mScalebar->segmentSizeMode() == QgsScaleBarSettings::SegmentSizeFixed )
330  {
331  mFixedSizeRadio->setChecked( true );
332  mSegmentSizeSpinBox->setEnabled( true );
333  mMinWidthSpinBox->setEnabled( false );
334  mMaxWidthSpinBox->setEnabled( false );
335  }
336  else /*if(mComposerScaleBar->segmentSizeMode() == QgsComposerScaleBar::SegmentSizeFitWidth)*/
337  {
338  mFitWidthRadio->setChecked( true );
339  mSegmentSizeSpinBox->setEnabled( false );
340  mMinWidthSpinBox->setEnabled( true );
341  mMaxWidthSpinBox->setEnabled( true );
342  }
343  mMinWidthSpinBox->setValue( mScalebar->minimumBarWidth() );
344  mMaxWidthSpinBox->setValue( mScalebar->maximumBarWidth() );
345 
346  populateDataDefinedButtons();
347 
348  blockMemberSignals( false );
349 }
350 
351 //slots
352 
353 void QgsLayoutScaleBarWidget::mSegmentSizeSpinBox_valueChanged( double d )
354 {
355  if ( !mScalebar )
356  {
357  return;
358  }
359 
360  mScalebar->beginCommand( tr( "Set Scalebar Segment Size" ), QgsLayoutItem::UndoScaleBarSegmentSize );
361  disconnectUpdateSignal();
362  mScalebar->setUnitsPerSegment( d );
363  mScalebar->update();
364  connectUpdateSignal();
365  mScalebar->endCommand();
366 }
367 
368 void QgsLayoutScaleBarWidget::mSegmentsLeftSpinBox_valueChanged( int i )
369 {
370  if ( !mScalebar )
371  {
372  return;
373  }
374 
375  mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegmentsLeft );
376  disconnectUpdateSignal();
377  mScalebar->setNumberOfSegmentsLeft( i );
378  mScalebar->update();
379  connectUpdateSignal();
380  mScalebar->endCommand();
381 }
382 
383 void QgsLayoutScaleBarWidget::mNumberOfSegmentsSpinBox_valueChanged( int i )
384 {
385  if ( !mScalebar )
386  {
387  return;
388  }
389 
390  mScalebar->beginCommand( tr( "Set Scalebar Segments" ), QgsLayoutItem::UndoScaleBarSegments );
391  disconnectUpdateSignal();
392  mScalebar->setNumberOfSegments( i );
393  mScalebar->update();
394  connectUpdateSignal();
395  mScalebar->endCommand();
396 }
397 
398 void QgsLayoutScaleBarWidget::mHeightSpinBox_valueChanged( double d )
399 {
400  if ( !mScalebar )
401  {
402  return;
403  }
404  mScalebar->beginCommand( tr( "Set Scalebar Height" ), QgsLayoutItem::UndoScaleBarHeight );
405  disconnectUpdateSignal();
406  mScalebar->setHeight( d );
407  mScalebar->update();
408  connectUpdateSignal();
409  mScalebar->endCommand();
410 }
411 
412 void QgsLayoutScaleBarWidget::mNumberOfSubdivisionsSpinBox_valueChanged( int i )
413 {
414  if ( !mScalebar )
415  {
416  return;
417  }
418 
419  mScalebar->beginCommand( tr( "Set Scalebar Subdivisions" ), QgsLayoutItem::UndoScaleBarSubdivisions );
420  disconnectUpdateSignal();
421  mScalebar->setNumberOfSubdivisions( i );
422  mScalebar->update();
423  connectUpdateSignal();
424  mScalebar->endCommand();
425 }
426 
427 void QgsLayoutScaleBarWidget::mSubdivisionsHeightSpinBox_valueChanged( double d )
428 {
429  if ( !mScalebar )
430  {
431  return;
432  }
433  mScalebar->beginCommand( tr( "Set Subdivisions Height" ), QgsLayoutItem::UndoScaleBarSubdivisionsHeight );
434  disconnectUpdateSignal();
435  mScalebar->setSubdivisionsHeight( d );
436  mScalebar->update();
437  connectUpdateSignal();
438  mScalebar->endCommand();
439 }
440 
441 void QgsLayoutScaleBarWidget::textFormatChanged()
442 {
443  if ( !mScalebar )
444  {
445  return;
446  }
447 
448  mScalebar->beginCommand( tr( "Set Scalebar Font" ) );
449  disconnectUpdateSignal();
450  mScalebar->setTextFormat( mFontButton->textFormat() );
451  connectUpdateSignal();
452  mScalebar->endCommand();
453  mScalebar->update();
454 }
455 
456 void QgsLayoutScaleBarWidget::changeNumberFormat()
457 {
458  if ( !mScalebar )
459  {
460  return;
461  }
462 
464  widget->setPanelTitle( tr( "Number Format" ) );
465  widget->setFormat( mScalebar->numericFormat() );
466  connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [ = ]
467  {
468  mScalebar->beginCommand( tr( "Set Scalebar Number Format" ) );
469  disconnectUpdateSignal();
470  mScalebar->setNumericFormat( widget->format() );
471  connectUpdateSignal();
472  mScalebar->endCommand();
473  mScalebar->update();
474  } );
475  openPanel( widget );
476  return;
477 }
478 
479 void QgsLayoutScaleBarWidget::mUnitLabelLineEdit_textChanged( const QString &text )
480 {
481  if ( !mScalebar )
482  {
483  return;
484  }
485 
486  mScalebar->beginCommand( tr( "Set Scalebar Unit Text" ), QgsLayoutItem::UndoScaleBarUnitText );
487  disconnectUpdateSignal();
488  mScalebar->setUnitLabel( text );
489  mScalebar->update();
490  connectUpdateSignal();
491  mScalebar->endCommand();
492 }
493 
494 void QgsLayoutScaleBarWidget::mMapUnitsPerBarUnitSpinBox_valueChanged( double d )
495 {
496  if ( !mScalebar )
497  {
498  return;
499  }
500 
501  mScalebar->beginCommand( tr( "Set Scalebar Map Units per Segment" ), QgsLayoutItem::UndoScaleBarMapUnitsSegment );
502  disconnectUpdateSignal();
503  mScalebar->setMapUnitsPerScaleBarUnit( d );
504  mScalebar->update();
505  connectUpdateSignal();
506  mScalebar->endCommand();
507 }
508 
509 void QgsLayoutScaleBarWidget::mStyleComboBox_currentIndexChanged( const QString & )
510 {
511  if ( !mScalebar )
512  {
513  return;
514  }
515 
516  const QString rendererId = mStyleComboBox->currentData().toString();
517  if ( rendererId == mScalebar->style() )
518  return;
519 
520  mScalebar->beginCommand( tr( "Set Scalebar Style" ) );
521  disconnectUpdateSignal();
522 
523  bool defaultsApplied = false;
524  const std::unique_ptr< QgsScaleBarRenderer > renderer( QgsApplication::scaleBarRendererRegistry()->renderer( rendererId ) );
525  if ( renderer )
526  defaultsApplied = mScalebar->applyDefaultRendererSettings( renderer.get() );
527 
528  //disable or enable controls which apply to specific scale bar styles
529  toggleStyleSpecificControls( rendererId );
530 
531  mScalebar->setStyle( rendererId );
532  mScalebar->update();
533  connectUpdateSignal();
534  mScalebar->endCommand();
535 
536  if ( defaultsApplied )
537  setGuiElements();
538 }
539 
540 void QgsLayoutScaleBarWidget::toggleStyleSpecificControls( const QString &style )
541 {
542  std::unique_ptr< QgsScaleBarRenderer > renderer( QgsApplication::scaleBarRendererRegistry()->renderer( style ) );
543 
544  //Selectively enable controls which apply to the scale bar style
545  mUnitsComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
546  mUnitsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsUnits : true );
547  mMapUnitsPerBarUnitSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
548  mMapUnitsPerBarUnitLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit : true );
549  mUnitLabelLineEdit->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
550  mUnitLabelLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesUnitLabel : true );
551  mSubdivisionsLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
552  mNumberOfSubdivisionsSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisions : true );
553  mSubdivisionsHeightLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
554  mSubdivisionsHeightSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight : true );
555  mGroupBoxSegments->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSegments : true );
556  if ( !mGroupBoxUnits->isEnabled() )
557  mGroupBoxSegments->setCollapsed( true );
558  mLabelBarSpaceSpinBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
559  mLabelBarSpaceLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace : true );
560  mLabelVerticalPlacementComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement : true );
561  mLabelVerticalPlacementLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement : true );
562  mLabelHorizontalPlacementComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelHorizontalPlacement : true );
563  mLabelHorizontalPlacementLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLabelHorizontalPlacement : true );
564  mAlignmentComboBox->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
565  mAlignmentLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlignment : true );
566  mFillSymbol1Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
567  mFillSymbol1Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
568  mFillSymbol2Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
569  mFillSymbol2Label->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
570  mLineStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
571  mLineStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
572  mDivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
573  mDivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
574  mSubdivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
575  mSubdivisionStyleLabel->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
576 }
577 
578 void QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged( double d )
579 {
580  if ( !mScalebar )
581  {
582  return;
583  }
584 
585  mScalebar->beginCommand( tr( "Set Scalebar Label Space" ), QgsLayoutItem::UndoScaleBarLabelBarSize );
586  disconnectUpdateSignal();
587  mScalebar->setLabelBarSpace( d );
588  mScalebar->update();
589  connectUpdateSignal();
590  mScalebar->endCommand();
591 }
592 
593 void QgsLayoutScaleBarWidget::mBoxSizeSpinBox_valueChanged( double d )
594 {
595  if ( !mScalebar )
596  {
597  return;
598  }
599 
600  mScalebar->beginCommand( tr( "Set Scalebar Box Space" ), QgsLayoutItem::UndoScaleBarBoxContentSpace );
601  disconnectUpdateSignal();
602  mScalebar->setBoxContentSpace( d );
603  mScalebar->update();
604  connectUpdateSignal();
605  mScalebar->endCommand();
606 }
607 
608 void QgsLayoutScaleBarWidget::mLabelVerticalPlacementComboBox_currentIndexChanged( int index )
609 {
610  if ( !mScalebar )
611  {
612  return;
613  }
614 
615  mScalebar->beginCommand( tr( "Set Scalebar Label Vertical Placement" ) );
616  disconnectUpdateSignal();
617  mScalebar->setLabelVerticalPlacement( static_cast<QgsScaleBarSettings::LabelVerticalPlacement>( mLabelVerticalPlacementComboBox->itemData( index ).toInt() ) );
618  mScalebar->update();
619  connectUpdateSignal();
620  mScalebar->endCommand();
621 }
622 
623 void QgsLayoutScaleBarWidget::mLabelHorizontalPlacementComboBox_currentIndexChanged( int index )
624 {
625  if ( !mScalebar )
626  {
627  return;
628  }
629 
630  mScalebar->beginCommand( tr( "Set Scalebar Label Horizontal Placement" ) );
631  disconnectUpdateSignal();
632  mScalebar->setLabelHorizontalPlacement( static_cast<QgsScaleBarSettings::LabelHorizontalPlacement>( mLabelHorizontalPlacementComboBox->itemData( index ).toInt() ) );
633  mScalebar->update();
634  connectUpdateSignal();
635  mScalebar->endCommand();
636 }
637 
638 void QgsLayoutScaleBarWidget::alignmentChanged()
639 {
640  if ( !mScalebar )
641  {
642  return;
643  }
644 
645  mScalebar->beginCommand( tr( "Set Scalebar Alignment" ) );
646  disconnectUpdateSignal();
647 
648  const QgsScaleBarSettings::Alignment a = mAlignmentComboBox->currentAlignment() & Qt::AlignLeft ? QgsScaleBarSettings::AlignLeft
649  : mAlignmentComboBox->currentAlignment() & Qt::AlignRight ? QgsScaleBarSettings::AlignRight : QgsScaleBarSettings::AlignMiddle;
650  mScalebar->setAlignment( a );
651  mScalebar->update();
652  connectUpdateSignal();
653  mScalebar->endCommand();
654 }
655 
656 void QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged( int index )
657 {
658  if ( !mScalebar )
659  {
660  return;
661  }
662 
663  const QVariant unitData = mUnitsComboBox->itemData( index );
664  if ( unitData.type() == QVariant::Invalid )
665  {
666  return;
667  }
668 
669  disconnectUpdateSignal();
670  mScalebar->beginCommand( tr( "Set Scalebar Units" ) );
671  mScalebar->applyDefaultSize( static_cast< QgsUnitTypes::DistanceUnit >( unitData.toInt() ) );
672  mScalebar->update();
673 
674  mNumberOfSegmentsSpinBox->setValue( mScalebar->numberOfSegments() );
675  mSegmentsLeftSpinBox->setValue( mScalebar->numberOfSegmentsLeft() );
676  mUnitLabelLineEdit->setText( mScalebar->unitLabel() );
677  mSegmentSizeSpinBox->setValue( mScalebar->unitsPerSegment() );
678  mMapUnitsPerBarUnitSpinBox->setValue( mScalebar->mapUnitsPerScaleBarUnit() );
679 
680  connectUpdateSignal();
681  mScalebar->endCommand();
682 }
683 
684 void QgsLayoutScaleBarWidget::blockMemberSignals( bool block )
685 {
686  mSegmentSizeSpinBox->blockSignals( block );
687  mNumberOfSegmentsSpinBox->blockSignals( block );
688  mSegmentsLeftSpinBox->blockSignals( block );
689  mNumberOfSubdivisionsSpinBox->blockSignals( block );
690  mSubdivisionsHeightSpinBox->blockSignals( block );
691  mStyleComboBox->blockSignals( block );
692  mUnitLabelLineEdit->blockSignals( block );
693  mMapUnitsPerBarUnitSpinBox->blockSignals( block );
694  mHeightSpinBox->blockSignals( block );
695  mLineStyleButton->blockSignals( block );
696  mDivisionStyleButton->blockSignals( block );
697  mSubdivisionStyleButton->blockSignals( block );
698  mLabelBarSpaceSpinBox->blockSignals( block );
699  mBoxSizeSpinBox->blockSignals( block );
700  mLabelVerticalPlacementComboBox->blockSignals( block );
701  mLabelHorizontalPlacementComboBox->blockSignals( block );
702  mAlignmentComboBox->blockSignals( block );
703  mUnitsComboBox->blockSignals( block );
704  mFillSymbol1Button->blockSignals( block );
705  mFillSymbol2Button->blockSignals( block );
706  mSegmentSizeRadioGroup.blockSignals( block );
707  mMapItemComboBox->blockSignals( block );
708  mFontButton->blockSignals( block );
709  mMinWidthSpinBox->blockSignals( block );
710  mMaxWidthSpinBox->blockSignals( block );
711 }
712 
713 void QgsLayoutScaleBarWidget::connectUpdateSignal()
714 {
715  if ( mScalebar )
716  {
717  connect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
718  }
719 }
720 
721 void QgsLayoutScaleBarWidget::disconnectUpdateSignal()
722 {
723  if ( mScalebar )
724  {
725  disconnect( mScalebar, &QgsLayoutObject::changed, this, &QgsLayoutScaleBarWidget::setGuiElements );
726  }
727 }
728 
729 void QgsLayoutScaleBarWidget::segmentSizeRadioChanged( QAbstractButton *radio )
730 {
731  const bool fixedSizeMode = radio == mFixedSizeRadio;
732  mMinWidthSpinBox->setEnabled( !fixedSizeMode );
733  mMaxWidthSpinBox->setEnabled( !fixedSizeMode );
734  mSegmentSizeSpinBox->setEnabled( fixedSizeMode );
735 
736  if ( !mScalebar )
737  {
738  return;
739  }
740 
741  mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
742  disconnectUpdateSignal();
743  if ( mFixedSizeRadio->isChecked() )
744  {
745  mScalebar->setSegmentSizeMode( QgsScaleBarSettings::SegmentSizeFixed );
746  mScalebar->setUnitsPerSegment( mSegmentSizeSpinBox->value() );
747  }
748  else /*if(mFitWidthRadio->isChecked())*/
749  {
750  mScalebar->setSegmentSizeMode( QgsScaleBarSettings::SegmentSizeFitWidth );
751  }
752  mScalebar->update();
753  connectUpdateSignal();
754  mScalebar->endCommand();
755 }
756 
757 void QgsLayoutScaleBarWidget::mapChanged( QgsLayoutItem *item )
758 {
759  QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( item );
760  if ( !map )
761  {
762  return;
763  }
764 
765  //set it to scale bar
766  mScalebar->beginCommand( tr( "Set Scalebar Map" ) );
767  disconnectUpdateSignal();
768  mScalebar->setLinkedMap( map );
769  mScalebar->update();
770  connectUpdateSignal();
771  mScalebar->endCommand();
772 }
773 
774 void QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged( double )
775 {
776  if ( !mScalebar )
777  {
778  return;
779  }
780 
781  mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
782  disconnectUpdateSignal();
783  mScalebar->setMinimumBarWidth( mMinWidthSpinBox->value() );
784  mScalebar->update();
785  connectUpdateSignal();
786  mScalebar->endCommand();
787 }
788 
789 void QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged( double )
790 {
791  if ( !mScalebar )
792  {
793  return;
794  }
795 
796  mScalebar->beginCommand( tr( "Set Scalebar Size Mode" ), QgsLayoutItem::UndoScaleBarSegmentSize );
797  disconnectUpdateSignal();
798  mScalebar->setMaximumBarWidth( mMaxWidthSpinBox->value() );
799  mScalebar->update();
800  connectUpdateSignal();
801  mScalebar->endCommand();
802 }
803 
804 void QgsLayoutScaleBarWidget::populateDataDefinedButtons()
805 {
806  updateDataDefinedButton( mSegmentsLeftDDBtn );
807  updateDataDefinedButton( mSegmentsRightDDBtn );
808  updateDataDefinedButton( mSegmentSizeDDBtn );
809  updateDataDefinedButton( mMinWidthDDBtn );
810  updateDataDefinedButton( mMaxWidthDDBtn );
811  updateDataDefinedButton( mHeightDDBtn );
812  updateDataDefinedButton( mSubdivisionHeightDDBtn );
813  updateDataDefinedButton( mRightSegmentSubdivisionsDDBtn );
814 }
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsLayoutItemBaseWidget::updateDataDefinedButton
void updateDataDefinedButton(QgsPropertyOverrideButton *button)
Updates a previously registered data defined button to reflect the item's current properties.
Definition: qgslayoutitemwidget.cpp:251
qgsscalebarrendererregistry.h
QgsLayoutScaleBarWidget::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgslayoutscalebarwidget.cpp:181
QgsSymbolButton::changed
void changed()
Emitted when the symbol's settings are changed.
qgslayoutundostack.h
Qgis::SymbolType::Fill
@ Fill
Fill symbol.
Qgis::SymbolType::Line
@ Line
Line symbol.
QgsScaleBarRenderer::Flag::FlagUsesUnitLabel
@ FlagUsesUnitLabel
Renderer uses the QgsScaleBarSettings::unitLabel() setting.
QgsExpressionContextScope::addVariable
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
Definition: qgsexpressioncontext.cpp:97
QgsUnitTypes::DistanceUnknownUnit
@ DistanceUnknownUnit
Unknown distance unit.
Definition: qgsunittypes.h:78
QgsLayoutObject::ScalebarRightSegments
@ ScalebarRightSegments
Number of segments on the right of 0 (since QGIS 3.26)
Definition: qgslayoutobject.h:197
QgsLayoutItem::UndoShapeStyle
@ UndoShapeStyle
Shape symbol style.
Definition: qgslayoutitem.h:226
QgsNumericFormatSelectorWidget::format
QgsNumericFormat * format() const
Returns a new format object representing the settings currently configured in the widget.
Definition: qgsnumericformatselectorwidget.cpp:73
QgsScaleBarSettings::AlignLeft
@ AlignLeft
Left aligned.
Definition: qgsscalebarsettings.h:49
QgsScaleBarRenderer::Flag::FlagUsesFillSymbol
@ FlagUsesFillSymbol
Renderer utilizes the scalebar fill symbol (see QgsScaleBarSettings::fillSymbol() )
QgsLayoutItem::UndoScaleBarUnitText
@ UndoScaleBarUnitText
Scalebar unit text.
Definition: qgslayoutitem.h:287
QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol
@ FlagUsesAlternateFillSymbol
Renderer utilizes the alternate scalebar fill symbol (see QgsScaleBarSettings::alternateFillSymbol() ...
QgsLayoutItem::UndoScaleBarMapUnitsSegment
@ UndoScaleBarMapUnitsSegment
Scalebar map units per segment.
Definition: qgslayoutitem.h:288
QgsPanelWidget::openPanel
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
Definition: qgspanelwidget.cpp:84
QgsLayoutItemBaseWidget::registerDataDefinedButton
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property)
Registers a data defined button, setting up its initial value, connections and description.
Definition: qgslayoutitemwidget.cpp:246
QgsScaleBarSettings::LabelHorizontalPlacement
LabelHorizontalPlacement
Label horizontal placement.
Definition: qgsscalebarsettings.h:75
QgsScaleBarRenderer::Flag::FlagUsesLabelHorizontalPlacement
@ FlagUsesLabelHorizontalPlacement
Renderer uses the QgsScaleBarSettings::labelHorizontalPlacement() setting.
QgsScaleBarSettings::AlignMiddle
@ AlignMiddle
Center aligned.
Definition: qgsscalebarsettings.h:50
QgsScaleBarSettings::LabelBelowSegment
@ LabelBelowSegment
Labels are drawn below the scalebar.
Definition: qgsscalebarsettings.h:69
QgsUnitTypes::DistanceUnit
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:67
QgsLayoutItem::UndoScaleBarBoxContentSpace
@ UndoScaleBarBoxContentSpace
Scalebar box context space.
Definition: qgslayoutitem.h:290
QgsScaleBarSettings::SegmentSizeFitWidth
@ SegmentSizeFitWidth
Scale bar segment size is calculated to fit a size range.
Definition: qgsscalebarsettings.h:60
QgsLayoutObject::changed
void changed()
Emitted when the object's properties change.
QgsUnitTypes::DistanceKilometers
@ DistanceKilometers
Kilometers.
Definition: qgsunittypes.h:70
QgsLayoutItemPropertiesWidget
A widget for controlling the common properties of layout items (e.g. position and size,...
Definition: qgslayoutitemwidget.h:217
QgsNumericFormatSelectorWidget
A widget which allows choice of numeric formats and the properties of them.
Definition: qgsnumericformatselectorwidget.h:34
QgsLayoutItemBaseWidget::coverageLayer
QgsVectorLayer * coverageLayer() const
Returns the current layout context coverage layer (if set).
Definition: qgslayoutitemwidget.cpp:256
QgsNumericFormatSelectorWidget::setFormat
void setFormat(const QgsNumericFormat *format)
Sets the format to show in the widget.
Definition: qgsnumericformatselectorwidget.cpp:51
QgsLayoutItemPropertiesWidget::setMasterLayout
void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
Definition: qgslayoutitemwidget.cpp:420
QgsScaleBarSettings::LabelCenteredEdge
@ LabelCenteredEdge
Labels are drawn centered relative to segment's edge.
Definition: qgsscalebarsettings.h:77
QgsLayoutItem::type
int type() const override
Returns a unique graphics item type identifier.
Definition: qgslayoutitem.cpp:124
QgsLayoutItem::UndoScaleBarSegmentSize
@ UndoScaleBarSegmentSize
Scalebar segment size.
Definition: qgslayoutitem.h:277
QgsScaleBarRenderer::Flag::FlagUsesLabelVerticalPlacement
@ FlagUsesLabelVerticalPlacement
Renderer uses the QgsScaleBarSettings::labelVerticalPlacement() setting.
QgsScaleBarSettings::SegmentSizeFixed
@ SegmentSizeFixed
Scale bar segment size is fixed to a map unit.
Definition: qgsscalebarsettings.h:59
QgsScaleBarSettings::Alignment
Alignment
Scalebar alignment.
Definition: qgsscalebarsettings.h:47
whileBlocking
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:2191
QgsLayoutItem::UndoScaleBarSegmentsLeft
@ UndoScaleBarSegmentsLeft
Scalebar segments left.
Definition: qgslayoutitem.h:278
QgsScaleBarRenderer::Flag::FlagUsesLineSymbol
@ FlagUsesLineSymbol
Renderer utilizes the scalebar line symbol (see QgsScaleBarSettings::lineSymbol() )
QgsLayoutObject::ScalebarRightSegmentSubdivisions
@ ScalebarRightSegmentSubdivisions
Number of subdivisions per segment on right of 0 (since QGIS 3.26)
Definition: qgslayoutobject.h:202
QgsLayoutObject::ScalebarMinimumWidth
@ ScalebarMinimumWidth
Scalebar segment minimum width (since QGIS 3.26)
Definition: qgslayoutobject.h:199
QgsLayoutObject::ScalebarSegmentWidth
@ ScalebarSegmentWidth
Scalebar width in map units of a single segment (since QGIS 3.26)
Definition: qgslayoutobject.h:198
QgsLayoutObject::ScalebarLeftSegments
@ ScalebarLeftSegments
Number of segments on the left of 0 (since QGIS 3.26)
Definition: qgslayoutobject.h:196
QgsScaleBarRenderer::Flag::FlagUsesAlignment
@ FlagUsesAlignment
Renderer uses the QgsScaleBarSettings::alignment() setting.
QgsScaleBarRenderer::Flag::FlagRespectsMapUnitsPerScaleBarUnit
@ FlagRespectsMapUnitsPerScaleBarUnit
Renderer respects the QgsScaleBarSettings::mapUnitsPerScaleBarUnit() setting.
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:29
qgslayoutscalebarwidget.h
qgsnumericformatselectorwidget.h
QgsUnitTypes::DistanceFeet
@ DistanceFeet
Imperial feet.
Definition: qgsunittypes.h:71
QgsUnitTypes::DistanceMeters
@ DistanceMeters
Meters.
Definition: qgsunittypes.h:69
QgsScaleBarRendererRegistry::sortedRendererList
QStringList sortedRendererList() const
Returns a list of the renderer ids currently contained in the registry, sorted in an order respecting...
Definition: qgsscalebarrendererregistry.cpp:48
QgsLayoutItem::UndoScaleBarSubdivisions
@ UndoScaleBarSubdivisions
Scalebar number of subdivisions.
Definition: qgslayoutitem.h:281
QgsLayoutItem::UndoScaleBarSegments
@ UndoScaleBarSegments
Scalebar number of segments.
Definition: qgslayoutitem.h:279
QgsScaleBarSettings::AlignRight
@ AlignRight
Right aligned.
Definition: qgsscalebarsettings.h:51
QgsLayoutItem::UndoScaleBarLabelBarSize
@ UndoScaleBarLabelBarSize
Scalebar label bar size.
Definition: qgslayoutitem.h:289
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:112
QgsPanelWidget::setPanelTitle
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
Definition: qgspanelwidget.h:44
QgsLayoutObject::ScalebarHeight
@ ScalebarHeight
Scalebar height (since QGIS 3.26)
Definition: qgslayoutobject.h:201
qgslayout.h
QgsLayoutItemRegistry::LayoutScaleBar
@ LayoutScaleBar
Scale bar item.
Definition: qgslayoutitemregistry.h:354
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext....
Definition: qgsexpressioncontext.h:113
QgsLayoutItemBaseWidget
A base class for property widgets for layout items. All layout item widgets should inherit from this ...
Definition: qgslayoutitemwidget.h:122
QgsExpressionContext::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Definition: qgsexpressioncontext.cpp:494
qgsvectorlayer.h
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:317
QgsScaleBarSettings::LabelAboveSegment
@ LabelAboveSegment
Labels are drawn above the scalebar.
Definition: qgsscalebarsettings.h:68
QgsScaleBarRenderer::Flag::FlagUsesSubdivisions
@ FlagUsesSubdivisions
Renderer uses the scalebar subdivisions (see QgsScaleBarSettings::numberOfSubdivisions() )
QgsFontButton::ModeTextRenderer
@ ModeTextRenderer
Configure font settings for use with QgsTextRenderer.
Definition: qgsfontbutton.h:61
QgsScaleBarRenderer::Flag::FlagRespectsUnits
@ FlagRespectsUnits
Renderer respects the QgsScaleBarSettings::units() setting.
QgsLayoutScaleBarWidget::setNewItem
bool setNewItem(QgsLayoutItem *item) override
Attempts to update the widget to show the properties for the specified item.
Definition: qgslayoutscalebarwidget.cpp:191
QgsSymbolButton::setLayer
void setLayer(QgsVectorLayer *layer)
Sets a layer to associate with the widget.
Definition: qgssymbolbutton.cpp:208
QgsUnitTypes::DistanceMillimeters
@ DistanceMillimeters
Millimeters.
Definition: qgsunittypes.h:77
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
QgsUnitTypes::DistanceCentimeters
@ DistanceCentimeters
Centimeters.
Definition: qgsunittypes.h:76
QgsScaleBarRenderer::Flag::FlagUsesSubdivisionsHeight
@ FlagUsesSubdivisionsHeight
Renderer uses the scalebar subdivisions height (see QgsScaleBarSettings::subdivisionsHeight() )
QgsFillSymbol
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:29
QgsScaleBarSettings::LabelCenteredSegment
@ LabelCenteredSegment
Labels are drawn centered relative to segment.
Definition: qgsscalebarsettings.h:78
QgsLayoutItemRegistry::LayoutMap
@ LayoutMap
Map item.
Definition: qgslayoutitemregistry.h:347
QgsLayoutItem::UndoScaleBarSubdivisionsHeight
@ UndoScaleBarSubdivisionsHeight
Scalebar subdivisions height.
Definition: qgslayoutitem.h:282
QgsUnitTypes::DistanceYards
@ DistanceYards
Imperial yards.
Definition: qgsunittypes.h:73
QgsLayoutScaleBarWidget::QgsLayoutScaleBarWidget
QgsLayoutScaleBarWidget(QgsLayoutItemScaleBar *scaleBar)
constructor
Definition: qgslayoutscalebarwidget.cpp:33
QgsExpressionContext::setHighlightedVariables
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
Definition: qgsexpressioncontext.cpp:328
QgsUnitTypes::DistanceMiles
@ DistanceMiles
Terrestrial miles.
Definition: qgsunittypes.h:74
QgsLayoutItemComboBox::itemChanged
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
QgsFontButton::setLayer
void setLayer(QgsVectorLayer *layer)
Sets a layer to associate with the widget.
Definition: qgsfontbutton.cpp:762
QgsScaleBarRenderer::Flag::FlagUsesLabelBarSpace
@ FlagUsesLabelBarSpace
Renderer uses the QgsScaleBarSettings::labelBarSpace() setting.
QgsUnitTypes::DistanceNauticalMiles
@ DistanceNauticalMiles
Nautical miles.
Definition: qgsunittypes.h:72
QgsScaleBarRenderer::Flag::FlagUsesSegments
@ FlagUsesSegments
Renderer uses the scalebar segments.
QgsLayoutItemScaleBar
A layout item subclass for scale bars.
Definition: qgslayoutitemscalebar.h:35
QgsMasterLayoutInterface
Interface for master layout type objects, such as print layouts and reports.
Definition: qgsmasterlayoutinterface.h:42
qgsguiutils.h
QgsLayoutItemPropertiesWidget::setItem
void setItem(QgsLayoutItem *item)
Sets the layout item.
Definition: qgslayoutitemwidget.cpp:401
QgsLayoutReportContext::layerChanged
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
QgsLayoutItem::UndoScaleBarHeight
@ UndoScaleBarHeight
Scalebar height.
Definition: qgslayoutitem.h:280
QgsExpressionContextScope::StaticVariable
Single variable definition for use within a QgsExpressionContextScope.
Definition: qgsexpressioncontext.h:120
qgsfillsymbol.h
QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol
@ FlagUsesDivisionSymbol
Renderer utilizes the scalebar division symbol (see QgsScaleBarSettings::divisionLineSymbol() )
qgslayoutitemscalebar.h
QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol
@ FlagUsesSubdivisionSymbol
Renderer utilizes the scalebar subdivision symbol (see QgsScaleBarSettings::subdivisionLineSymbol() )
QgsLayoutObject::ScalebarSubdivisionHeight
@ ScalebarSubdivisionHeight
Scalebar subdivision height (since QGIS 3.26)
Definition: qgslayoutobject.h:203
QgsNumericFormatSelectorWidget::changed
void changed()
Emitted whenever the format configured55 in the widget is changed.
QgsLayoutScaleBarWidget::setMasterLayout
void setMasterLayout(QgsMasterLayoutInterface *masterLayout) override
Sets the master layout associated with the item.
Definition: qgslayoutscalebarwidget.cpp:175
QgsLayoutObject::ScalebarMaximumWidth
@ ScalebarMaximumWidth
Scalebar segment maximum width (since QGIS 3.26)
Definition: qgslayoutobject.h:200
QgsAlignmentComboBox::changed
void changed()
Emitted when the alignment is changed.
qgslinesymbol.h
qgslayoutitemmap.h
QgsApplication::scaleBarRendererRegistry
static QgsScaleBarRendererRegistry * scaleBarRendererRegistry()
Gets the registry of available scalebar renderers.
Definition: qgsapplication.cpp:2495
QgsFontButton::changed
void changed()
Emitted when the widget's text format settings are changed.
QgsScaleBarSettings::LabelVerticalPlacement
LabelVerticalPlacement
Label vertical placement.
Definition: qgsscalebarsettings.h:66