QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgslayoutelevationprofilewidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutelevationprofilewidget.cpp
3 ----------------------
4 begin : January 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19#include "moc_qgslayoutelevationprofilewidget.cpp"
21#include "qgslayoutitemwidget.h"
23#include "qgsplot.h"
24#include "qgsfillsymbol.h"
25#include "qgslinesymbol.h"
26#include "qgsvectorlayer.h"
28#include "qgslayout.h"
29#include "qgslayertree.h"
33#include "qgscurve.h"
34#include "qgslayoutatlas.h"
36#include "qgsgui.h"
37#include <QMenu>
38
40
42 : QgsLayoutItemBaseWidget( nullptr, profile )
43 , mProfile( profile )
44 , mLayerTree( new QgsLayerTree() )
45 , mLayerTreeBridge( new QgsLayerTreeRegistryBridge( mLayerTree.get(), mProfile->layout() ? mProfile->layout()->project() : QgsProject::instance(), this ) )
46{
47 Q_ASSERT( mProfile );
48
49 setupUi( this );
50 setPanelTitle( tr( "Elevation Profile Properties" ) );
51
52 mCopyFromDockMenu = new QMenu( this );
53 connect( mCopyFromDockMenu, &QMenu::aboutToShow, this, [ = ]
54 {
55 sBuildCopyMenuFunction( this, mCopyFromDockMenu );
56 } );
57
58 connect( mActionRefresh, &QAction::triggered, this, [ = ]
59 {
60 if ( !mProfile )
61 {
62 return;
63 }
64 mProfile->invalidateCache();
65 mProfile->refresh();
66 } );
67
68 QToolButton *copyFromDockButton = new QToolButton();
69 copyFromDockButton->setAutoRaise( true );
70 copyFromDockButton->setToolTip( tr( "Copy From Profile" ) );
71 copyFromDockButton->setMenu( mCopyFromDockMenu );
72 copyFromDockButton->setPopupMode( QToolButton::InstantPopup );
73 copyFromDockButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionCopyProfileSettings.svg" ) ) );
74
75 mDockToolbar->addWidget( copyFromDockButton );
76
77 //add widget for general composer item properties
78 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, profile );
79 mainLayout->addWidget( mItemPropertiesWidget );
80
81 connect( mLayerTree.get(), &QgsLayerTree::layerOrderChanged, this, &QgsLayoutElevationProfileWidget::updateItemLayers );
82 connect( mLayerTree.get(), &QgsLayerTreeGroup::visibilityChanged, this, &QgsLayoutElevationProfileWidget::updateItemLayers );
83
84 mSpinTolerance->setClearValue( 0 );
85 connect( mSpinTolerance, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
86 {
87 if ( !mProfile || mBlockChanges )
88 return;
89
90 mProfile->beginCommand( tr( "Change Profile Tolerance Distance" ), QgsLayoutItem::UndoElevationProfileTolerance );
91 mProfile->setTolerance( value );
92 mProfile->invalidateCache();
93 mProfile->update();
94 mProfile->endCommand();
95 } );
96
97 connect( mCheckControlledByAtlas, &QCheckBox::toggled, this, [ = ]
98 {
99 if ( !mProfile || mBlockChanges )
100 return;
101
102 mProfile->beginCommand( tr( "Change Profile Atlas Control" ) );
103 mProfile->setAtlasDriven( mCheckControlledByAtlas->isChecked() );
104 mProfile->invalidateCache();
105 mProfile->update();
106 mProfile->endCommand();
107 } );
108
109 mSpinMinDistance->setClearValue( 0 );
110 connect( mSpinMinDistance, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
111 {
112 if ( !mProfile || mBlockChanges )
113 return;
114
115 mProfile->beginCommand( tr( "Change Profile Chart Minimum Distance" ), QgsLayoutItem::UndoElevationProfileMinimumDistance );
116 mProfile->plot()->setXMinimum( value );
117 mProfile->invalidateCache();
118 mProfile->update();
119 mProfile->endCommand();
120 } );
121
122 connect( mSpinMaxDistance, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
123 {
124 if ( !mProfile || mBlockChanges )
125 return;
126
127 mProfile->beginCommand( tr( "Change Profile Chart Maximum Distance" ), QgsLayoutItem::UndoElevationProfileMaximumDistance );
128 mProfile->plot()->setXMaximum( value );
129 mProfile->invalidateCache();
130 mProfile->update();
131 mProfile->endCommand();
132 } );
133
134 mSpinMinElevation->setClearValue( 0 );
135 connect( mSpinMinElevation, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
136 {
137 if ( !mProfile || mBlockChanges )
138 return;
139
140 mProfile->beginCommand( tr( "Change Profile Chart Minimum Elevation" ), QgsLayoutItem::UndoElevationProfileMinimumElevation );
141 mProfile->plot()->setYMinimum( value );
142 mProfile->invalidateCache();
143 mProfile->update();
144 mProfile->endCommand();
145 } );
146
147 connect( mSpinMaxElevation, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
148 {
149 if ( !mProfile || mBlockChanges )
150 return;
151
152 mProfile->beginCommand( tr( "Change Profile Chart Maximum Elevation" ), QgsLayoutItem::UndoElevationProfileMaximumElevation );
153 mProfile->plot()->setYMaximum( value );
154 mProfile->invalidateCache();
155 mProfile->update();
156 mProfile->endCommand();
157 } );
158
159 mDistanceAxisMajorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
160 connect( mDistanceAxisMajorLinesSymbolButton, &QgsSymbolButton::changed, this, [ = ]
161 {
162 if ( !mProfile || mBlockChanges )
163 return;
164
165 mProfile->beginCommand( tr( "Change Profile Chart Distance Major Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMajorGridlines );
166 mProfile->plot()->xAxis().setGridMajorSymbol( mDistanceAxisMajorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
167 mProfile->invalidateCache();
168 mProfile->update();
169 mProfile->endCommand();
170 } );
171 mDistanceAxisMajorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMajorSymbol() );
172
173 mDistanceAxisMinorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
174 connect( mDistanceAxisMinorLinesSymbolButton, &QgsSymbolButton::changed, this, [ = ]
175 {
176 if ( !mProfile || mBlockChanges )
177 return;
178
179 mProfile->beginCommand( tr( "Change Profile Chart Distance Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMinorGridlines );
180 mProfile->plot()->xAxis().setGridMinorSymbol( mDistanceAxisMinorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
181 mProfile->invalidateCache();
182 mProfile->update();
183 mProfile->endCommand();
184 } );
185 mDistanceAxisMinorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMinorSymbol() );
186
187 connect( mDistanceAxisMajorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
188 {
189 if ( !mProfile || mBlockChanges )
190 return;
191
192 mProfile->beginCommand( tr( "Change Profile Chart Distance Major Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMajorGridlines );
193 mProfile->plot()->xAxis().setGridIntervalMajor( value );
194 mProfile->invalidateCache();
195 mProfile->update();
196 mProfile->endCommand();
197 } );
198
199 connect( mDistanceAxisMinorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
200 {
201 if ( !mProfile || mBlockChanges )
202 return;
203
204 mProfile->beginCommand( tr( "Change Profile Chart Distance Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMinorGridlines );
205 mProfile->plot()->xAxis().setGridIntervalMinor( value );
206 mProfile->invalidateCache();
207 mProfile->update();
208 mProfile->endCommand();
209 } );
210
211 connect( mDistanceAxisLabelIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
212 {
213 if ( !mProfile || mBlockChanges )
214 return;
215
216 mProfile->beginCommand( tr( "Change Profile Chart Distance Label" ), QgsLayoutItem::UndoElevationProfileDistanceLabels );
217 mProfile->plot()->xAxis().setLabelInterval( value );
218 mProfile->invalidateCache();
219 mProfile->update();
220 mProfile->endCommand();
221 } );
222
223 mElevationAxisMajorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
224 connect( mElevationAxisMajorLinesSymbolButton, &QgsSymbolButton::changed, this, [ = ]
225 {
226 if ( !mProfile || mBlockChanges )
227 return;
228
229 mProfile->beginCommand( tr( "Change Profile Chart Elevation Major Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMajorGridlines );
230 mProfile->plot()->yAxis().setGridMajorSymbol( mElevationAxisMajorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
231 mProfile->invalidateCache();
232 mProfile->update();
233 mProfile->endCommand();
234 } );
235 mElevationAxisMajorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMajorSymbol() );
236
237 mElevationAxisMinorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
238 connect( mElevationAxisMinorLinesSymbolButton, &QgsSymbolButton::changed, this, [ = ]
239 {
240 if ( !mProfile || mBlockChanges )
241 return;
242
243 mProfile->beginCommand( tr( "Change Profile Chart Elevation Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMinorGridlines );
244 mProfile->plot()->yAxis().setGridMinorSymbol( mElevationAxisMinorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
245 mProfile->invalidateCache();
246 mProfile->update();
247 mProfile->endCommand();
248 } );
249 mElevationAxisMinorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMinorSymbol() );
250
251 connect( mElevationAxisLabelIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
252 {
253 if ( !mProfile || mBlockChanges )
254 return;
255
256 mProfile->beginCommand( tr( "Change Profile Chart Elevation Label" ), QgsLayoutItem::UndoElevationProfileElevationLabels );
257 mProfile->plot()->yAxis().setLabelInterval( value );
258 mProfile->invalidateCache();
259 mProfile->update();
260 mProfile->endCommand();
261 } );
262
263 connect( mElevationAxisMajorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
264 {
265 if ( !mProfile || mBlockChanges )
266 return;
267
268 mProfile->beginCommand( tr( "Change Profile Chart Elevation Major Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMajorGridlines );
269 mProfile->plot()->yAxis().setGridIntervalMajor( value );
270 mProfile->invalidateCache();
271 mProfile->update();
272 mProfile->endCommand();
273 } );
274
275 connect( mElevationAxisMinorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
276 {
277 if ( !mProfile || mBlockChanges )
278 return;
279
280 mProfile->beginCommand( tr( "Change Profile Chart Distance Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMinorGridlines );
281 mProfile->plot()->yAxis().setGridIntervalMinor( value );
282 mProfile->invalidateCache();
283 mProfile->update();
284 mProfile->endCommand();
285 } );
286
287 mChartBackgroundSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
288 connect( mChartBackgroundSymbolButton, &QgsSymbolButton::changed, this, [ = ]
289 {
290 if ( !mProfile || mBlockChanges )
291 return;
292
293 mProfile->beginCommand( tr( "Change Profile Chart Background" ), QgsLayoutItem::UndoElevationProfileChartBackground );
294 mProfile->plot()->setChartBackgroundSymbol( mChartBackgroundSymbolButton->clonedSymbol<QgsFillSymbol>() );
295 mProfile->invalidateCache();
296 mProfile->update();
297 mProfile->endCommand();
298 } );
299 mChartBackgroundSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::chartBackgroundSymbol() );
300
301 mChartBorderSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
302 connect( mChartBorderSymbolButton, &QgsSymbolButton::changed, this, [ = ]
303 {
304 if ( !mProfile || mBlockChanges )
305 return;
306
307 mProfile->beginCommand( tr( "Change Profile Chart Border" ), QgsLayoutItem::UndoElevationProfileChartBorder );
308 mProfile->plot()->setChartBorderSymbol( mChartBorderSymbolButton->clonedSymbol<QgsFillSymbol>() );
309 mProfile->invalidateCache();
310 mProfile->update();
311 mProfile->endCommand();
312 } );
313 mChartBorderSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::chartBorderSymbol() );
314
315 connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked, this, [ = ]
316 {
317 if ( !mProfile || mBlockChanges )
318 return;
319
321 widget->setPanelTitle( tr( "Distance Number Format" ) );
322 widget->setFormat( mProfile->plot()->xAxis().numericFormat() );
323 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [ = ]
324 {
325 mProfile->beginCommand( tr( "Change Profile Chart Distance Format" ), QgsLayoutItem::UndoElevationProfileDistanceFormat );
326 mProfile->plot()->xAxis().setNumericFormat( widget->format() );
327 mProfile->invalidateCache();
328 mProfile->endCommand();
329 mProfile->update();
330 } );
331 openPanel( widget );
332 } );
333
334 connect( mElevationAxisLabelFormatButton, &QPushButton::clicked, this, [ = ]
335 {
336 if ( !mProfile || mBlockChanges )
337 return;
338
340 widget->setPanelTitle( tr( "Elevation Number Format" ) );
341 widget->setFormat( mProfile->plot()->yAxis().numericFormat() );
342 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [ = ]
343 {
344 mProfile->beginCommand( tr( "Change Profile Chart Elevation Format" ), QgsLayoutItem::UndoElevationProfileElevationFormat );
345 mProfile->plot()->yAxis().setNumericFormat( widget->format() );
346 mProfile->invalidateCache();
347 mProfile->endCommand();
348 mProfile->update();
349 } );
350 openPanel( widget );
351 } );
352
353 mDistanceAxisLabelFontButton->setDialogTitle( tr( "Distance Label Font" ) );
354 mElevationAxisLabelFontButton->setDialogTitle( tr( "Elevation Label Font" ) );
355 mDistanceAxisLabelFontButton->setMode( QgsFontButton::ModeTextRenderer );
356 mElevationAxisLabelFontButton->setMode( QgsFontButton::ModeTextRenderer );
357
358 connect( mDistanceAxisLabelFontButton, &QgsFontButton::changed, this, [ = ]
359 {
360 if ( !mProfile || mBlockChanges )
361 return;
362
363 mProfile->beginCommand( tr( "Change Profile Chart Distance Font" ), QgsLayoutItem::UndoElevationProfileDistanceFont );
364 mProfile->plot()->xAxis().setTextFormat( mDistanceAxisLabelFontButton->textFormat() );
365 mProfile->invalidateCache();
366 mProfile->endCommand();
367 mProfile->update();
368 } );
369
370 connect( mElevationAxisLabelFontButton, &QgsFontButton::changed, this, [ = ]
371 {
372 if ( !mProfile || mBlockChanges )
373 return;
374
375 mProfile->beginCommand( tr( "Change Profile Chart Elevation Font" ), QgsLayoutItem::UndoElevationProfileElevationFont );
376 mProfile->plot()->yAxis().setTextFormat( mElevationAxisLabelFontButton->textFormat() );
377 mProfile->invalidateCache();
378 mProfile->endCommand();
379 mProfile->update();
380 } );
381
382 mSpinLeftMargin->setClearValue( 0 );
383 connect( mSpinLeftMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
384 {
385 if ( !mProfile || mBlockChanges )
386 return;
387
388 mProfile->beginCommand( tr( "Change Profile Chart Left Margin" ), QgsLayoutItem::UndoMarginLeft );
389 QgsMargins margins = mProfile->plot()->margins();
390 margins.setLeft( value );
391 mProfile->plot()->setMargins( margins );
392 mProfile->invalidateCache();
393 mProfile->update();
394 mProfile->endCommand();
395 } );
396
397 mSpinRightMargin->setClearValue( 0 );
398 connect( mSpinRightMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
399 {
400 if ( !mProfile || mBlockChanges )
401 return;
402
403 mProfile->beginCommand( tr( "Change Profile Chart Right Margin" ), QgsLayoutItem::UndoMarginRight );
404 QgsMargins margins = mProfile->plot()->margins();
405 margins.setRight( value );
406 mProfile->plot()->setMargins( margins );
407 mProfile->invalidateCache();
408 mProfile->update();
409 mProfile->endCommand();
410 } );
411
412 mSpinTopMargin->setClearValue( 0 );
413 connect( mSpinTopMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
414 {
415 if ( !mProfile || mBlockChanges )
416 return;
417
418 mProfile->beginCommand( tr( "Change Profile Chart Top Margin" ), QgsLayoutItem::UndoMarginTop );
419 QgsMargins margins = mProfile->plot()->margins();
420 margins.setTop( value );
421 mProfile->plot()->setMargins( margins );
422 mProfile->invalidateCache();
423 mProfile->update();
424 mProfile->endCommand();
425 } );
426
427 mSpinBottomMargin->setClearValue( 0 );
428 connect( mSpinBottomMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
429 {
430 if ( !mProfile || mBlockChanges )
431 return;
432
433 mProfile->beginCommand( tr( "Change Profile Chart Bottom Margin" ), QgsLayoutItem::UndoMarginBottom );
434 QgsMargins margins = mProfile->plot()->margins();
435 margins.setBottom( value );
436 mProfile->plot()->setMargins( margins );
437 mProfile->invalidateCache();
438 mProfile->update();
439 mProfile->endCommand();
440 } );
441
442 for ( Qgis::DistanceUnit unit :
443 {
454 } )
455 {
456 QString title;
458 {
460 }
461 else
462 {
463 title = QgsUnitTypes::toString( unit );
464 }
465 mDistanceUnitCombo->addItem( title, QVariant::fromValue( unit ) );
466 }
467
468 connect( mDistanceUnitCombo, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
469 {
470 if ( !mProfile || mBlockChanges )
471 return;
472
473 mProfile->beginCommand( tr( "Change Profile Chart Units" ) );
474 mProfile->setDistanceUnit( mDistanceUnitCombo->currentData().value< Qgis::DistanceUnit >() );
475 mProfile->invalidateCache();
476 mProfile->update();
477 mProfile->endCommand();
478 } );
479
480 mDistanceLabelsCombo->addItem( tr( "None" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::NoLabels ) );
481 mDistanceLabelsCombo->addItem( tr( "Every Value" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::EveryLabel ) );
482 mDistanceLabelsCombo->addItem( tr( "First Value" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::FirstLabel ) );
483 mDistanceLabelsCombo->addItem( tr( "Last Value" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::LastLabel ) );
484 mDistanceLabelsCombo->addItem( tr( "First and Last Values" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::FirstAndLastLabels ) );
485 connect( mDistanceLabelsCombo, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
486 {
487 if ( !mProfile || mBlockChanges )
488 return;
489
490 mProfile->beginCommand( tr( "Change Profile Chart Label Placement" ) );
491 mProfile->plot()->xAxis().setLabelSuffixPlacement( mDistanceLabelsCombo->currentData().value< Qgis::PlotAxisSuffixPlacement >() );
492 mProfile->invalidateCache();
493 mProfile->update();
494 mProfile->endCommand();
495 } );
496
497
513
514 mLayerTreeView = new QgsElevationProfileLayerTreeView( mLayerTree.get() );
515
516 QVBoxLayout *vl = new QVBoxLayout();
517 vl->setContentsMargins( 0, 0, 0, 0 );
518 vl->addWidget( mLayerTreeView );
519 mTreeViewContainer->setLayout( vl );
520
521 mBlockChanges++;
522 mLayerTreeView->populateInitialLayers( mProfile->layout() && mProfile->layout()->project() ? mProfile->layout()->project() : QgsProject::instance() );
523 mBlockChanges--;
524
525 setGuiElementValues();
526
527 mDistanceAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
528 mDistanceAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
529 mElevationAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
530 mElevationAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
531 mChartBackgroundSymbolButton->registerExpressionContextGenerator( mProfile );
532 mChartBorderSymbolButton->registerExpressionContextGenerator( mProfile );
533 mDistanceAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
534 mElevationAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
535
536 mDistanceAxisMajorLinesSymbolButton->setLayer( coverageLayer() );
537 mDistanceAxisMinorLinesSymbolButton->setLayer( coverageLayer() );
538 mElevationAxisMajorLinesSymbolButton->setLayer( coverageLayer() );
539 mElevationAxisMinorLinesSymbolButton->setLayer( coverageLayer() );
540 mDistanceAxisLabelFontButton->setLayer( coverageLayer() );
541 mElevationAxisLabelFontButton->setLayer( coverageLayer() );
542 mChartBackgroundSymbolButton->setLayer( coverageLayer() );
543 mChartBorderSymbolButton->setLayer( coverageLayer() );
544
545 if ( mProfile->layout() )
546 {
547 connect( &mProfile->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, this, [ = ]( QgsVectorLayer * layer )
548 {
549 mDistanceAxisMajorLinesSymbolButton->setLayer( layer );
550 mDistanceAxisMinorLinesSymbolButton->setLayer( layer );
551 mElevationAxisMajorLinesSymbolButton->setLayer( layer );
552 mElevationAxisMinorLinesSymbolButton->setLayer( layer );
553 mDistanceAxisLabelFontButton->setLayer( layer );
554 mElevationAxisLabelFontButton->setLayer( layer );
555 mChartBackgroundSymbolButton->setLayer( layer );
556 mChartBorderSymbolButton->setLayer( layer );
557 } );
558
559 connect( &mProfile->layout()->reportContext(), &QgsLayoutReportContext::layerChanged,
560 this, &QgsLayoutElevationProfileWidget::atlasLayerChanged );
561 }
562
563 if ( QgsLayoutAtlas *atlas = layoutAtlas() )
564 {
565 connect( atlas, &QgsLayoutAtlas::toggled, this, &QgsLayoutElevationProfileWidget::layoutAtlasToggled );
566 layoutAtlasToggled( atlas->enabled() );
567 }
568}
569
571
573{
574 if ( mItemPropertiesWidget )
575 mItemPropertiesWidget->setMasterLayout( masterLayout );
576}
577
579{
580 return mProfile->createExpressionContext();
581}
582
588
590{
591 mCheckControlledByAtlas->setText( tr( "Controlled by %1" ).arg( string == tr( "atlas" ) ? tr( "Atlas" ) : tr( "Report" ) ) );
592}
593
595{
596 mBlockChanges++;
597
598 mProfile->setCrs( canvas->crs() );
599
600 mSpinTolerance->setValue( canvas->tolerance() );
601 mProfile->setTolerance( canvas->tolerance() );
602
603 mProfile->setDistanceUnit( canvas->distanceUnit() );
604 mDistanceUnitCombo->setCurrentIndex( mDistanceUnitCombo->findData( QVariant::fromValue( canvas->distanceUnit() ) ) );
605
606 mProfile->plot()->xAxis().setLabelSuffixPlacement( canvas->plot().xAxis().labelSuffixPlacement() );
607 mDistanceLabelsCombo->setCurrentIndex( mDistanceLabelsCombo->findData( QVariant::fromValue( canvas->plot().xAxis().labelSuffixPlacement() ) ) );
608
609 if ( const QgsCurve *curve = canvas->profileCurve() )
610 mProfile->setProfileCurve( curve->clone() );
611
612 mSpinMinDistance->setValue( canvas->plot().xMinimum() );
613 mSpinMinDistance->setClearValue( canvas->plot().xMinimum() );
614 mProfile->plot()->setXMinimum( canvas->plot().xMinimum() );
615
616 mSpinMaxDistance->setValue( canvas->plot().xMaximum() );
617 mSpinMaxDistance->setClearValue( canvas->plot().xMaximum() );
618 mProfile->plot()->setXMaximum( canvas->plot().xMaximum() );
619
620 mDistanceAxisMajorIntervalSpin->setValue( canvas->plot().xAxis().gridIntervalMajor() );
621 mDistanceAxisMajorIntervalSpin->setClearValue( canvas->plot().xAxis().gridIntervalMajor() );
622 mProfile->plot()->xAxis().setGridIntervalMajor( canvas->plot().xAxis().gridIntervalMajor() );
623
624 mDistanceAxisMinorIntervalSpin->setValue( canvas->plot().xAxis().gridIntervalMinor() );
625 mDistanceAxisMinorIntervalSpin->setClearValue( canvas->plot().xAxis().gridIntervalMinor() );
626 mProfile->plot()->xAxis().setGridIntervalMinor( canvas->plot().xAxis().gridIntervalMinor() );
627
628 mDistanceAxisLabelIntervalSpin->setValue( canvas->plot().xAxis().labelInterval() );
629 mDistanceAxisLabelIntervalSpin->setClearValue( canvas->plot().xAxis().labelInterval() );
630 mProfile->plot()->xAxis().setLabelInterval( canvas->plot().xAxis().labelInterval() );
631
632 mSpinMinElevation->setValue( canvas->plot().xMinimum() );
633 mSpinMinElevation->setClearValue( canvas->plot().yMinimum() );
634 mProfile->plot()->setYMinimum( canvas->plot().yMinimum() );
635
636 mSpinMaxElevation->setValue( canvas->plot().yMaximum() );
637 mSpinMaxElevation->setClearValue( canvas->plot().yMaximum() );
638 mProfile->plot()->setYMaximum( canvas->plot().yMaximum() );
639
640 mElevationAxisMajorIntervalSpin->setValue( canvas->plot().yAxis().gridIntervalMajor() );
641 mElevationAxisMajorIntervalSpin->setClearValue( canvas->plot().yAxis().gridIntervalMajor() );
642 mProfile->plot()->yAxis().setGridIntervalMajor( canvas->plot().yAxis().gridIntervalMajor() );
643
644 mElevationAxisMinorIntervalSpin->setValue( canvas->plot().yAxis().gridIntervalMinor() );
645 mElevationAxisMinorIntervalSpin->setClearValue( canvas->plot().yAxis().gridIntervalMinor() );
646 mProfile->plot()->yAxis().setGridIntervalMinor( canvas->plot().yAxis().gridIntervalMinor() );
647
648 mElevationAxisLabelIntervalSpin->setValue( canvas->plot().yAxis().labelInterval() );
649 mElevationAxisLabelIntervalSpin->setClearValue( canvas->plot().yAxis().labelInterval() );
650 mProfile->plot()->yAxis().setLabelInterval( canvas->plot().yAxis().labelInterval() );
651
652 QList<QgsMapLayer *> canvasLayers = canvas->layers();
653 // canvas layers are in opposite direction to what the layout item requires
654 std::reverse( canvasLayers.begin(), canvasLayers.end() );
655 mProfile->setLayers( canvasLayers );
656 const QList<QgsLayerTreeLayer *> layers = mLayerTree->findLayers();
657 for ( QgsLayerTreeLayer *layer : layers )
658 {
659 layer->setItemVisibilityChecked( mProfile->layers().contains( layer->layer() ) );
660 }
661 mLayerTree->reorderGroupLayers( mProfile->layers() );
662
663 mProfile->invalidateCache();
664 mProfile->update();
665 mBlockChanges--;
666}
667
669{
671 return false;
672
673 if ( mProfile )
674 {
675 disconnect( mProfile, &QgsLayoutObject::changed, this, &QgsLayoutElevationProfileWidget::setGuiElementValues );
676 }
677
678 mProfile = qobject_cast< QgsLayoutItemElevationProfile * >( item );
679 mItemPropertiesWidget->setItem( mProfile );
680
681 if ( mProfile )
682 {
683 connect( mProfile, &QgsLayoutObject::changed, this, &QgsLayoutElevationProfileWidget::setGuiElementValues );
684 mDistanceAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
685 mDistanceAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
686 mElevationAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
687 mElevationAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
688 mDistanceAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
689 mElevationAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
690 mChartBackgroundSymbolButton->registerExpressionContextGenerator( mProfile );
691 mChartBorderSymbolButton->registerExpressionContextGenerator( mProfile );
692 }
693
694 setGuiElementValues();
695
696 return true;
697}
698
699void QgsLayoutElevationProfileWidget::setGuiElementValues()
700{
701 mBlockChanges++;
702
703 mSpinTolerance->setValue( mProfile->tolerance() );
704 mCheckControlledByAtlas->setChecked( mProfile->atlasDriven() );
705
706 mSpinMinDistance->setValue( mProfile->plot()->xMinimum() );
707 mSpinMaxDistance->setValue( mProfile->plot()->xMaximum() );
708 mSpinMinElevation->setValue( mProfile->plot()->yMinimum() );
709 mSpinMaxElevation->setValue( mProfile->plot()->yMaximum() );
710
711 if ( mProfile->plot()->xAxis().gridMajorSymbol() )
712 mDistanceAxisMajorLinesSymbolButton->setSymbol( mProfile->plot()->xAxis().gridMajorSymbol()->clone() );
713 if ( mProfile->plot()->xAxis().gridMinorSymbol() )
714 mDistanceAxisMinorLinesSymbolButton->setSymbol( mProfile->plot()->xAxis().gridMinorSymbol()->clone() );
715 if ( mProfile->plot()->yAxis().gridMajorSymbol() )
716 mElevationAxisMajorLinesSymbolButton->setSymbol( mProfile->plot()->yAxis().gridMajorSymbol()->clone() );
717 if ( mProfile->plot()->yAxis().gridMajorSymbol() )
718 mElevationAxisMinorLinesSymbolButton->setSymbol( mProfile->plot()->yAxis().gridMinorSymbol()->clone() );
719
720 mDistanceAxisLabelFontButton->setTextFormat( mProfile->plot()->xAxis().textFormat() );
721 mElevationAxisLabelFontButton->setTextFormat( mProfile->plot()->yAxis().textFormat() );
722
723 mDistanceUnitCombo->setCurrentIndex( mDistanceUnitCombo->findData( QVariant::fromValue( mProfile->distanceUnit() ) ) );
724 mDistanceLabelsCombo->setCurrentIndex( mDistanceLabelsCombo->findData( QVariant::fromValue( mProfile->plot()->xAxis().labelSuffixPlacement() ) ) );
725
726 mDistanceAxisMajorIntervalSpin->setValue( mProfile->plot()->xAxis().gridIntervalMajor() );
727 mDistanceAxisMinorIntervalSpin->setValue( mProfile->plot()->xAxis().gridIntervalMinor() );
728 mDistanceAxisLabelIntervalSpin->setValue( mProfile->plot()->xAxis().labelInterval() );
729
730 mElevationAxisMajorIntervalSpin->setValue( mProfile->plot()->yAxis().gridIntervalMajor() );
731 mElevationAxisMinorIntervalSpin->setValue( mProfile->plot()->yAxis().gridIntervalMinor() );
732 mElevationAxisLabelIntervalSpin->setValue( mProfile->plot()->yAxis().labelInterval() );
733
734 if ( mProfile->plot()->chartBackgroundSymbol() )
735 mChartBackgroundSymbolButton->setSymbol( mProfile->plot()->chartBackgroundSymbol()->clone() );
736 if ( mProfile->plot()->chartBorderSymbol() )
737 mChartBorderSymbolButton->setSymbol( mProfile->plot()->chartBorderSymbol()->clone() );
738
739 mSpinLeftMargin->setValue( mProfile->plot()->margins().left() );
740 mSpinRightMargin->setValue( mProfile->plot()->margins().right() );
741 mSpinTopMargin->setValue( mProfile->plot()->margins().top() );
742 mSpinBottomMargin->setValue( mProfile->plot()->margins().bottom() );
743
744 const QList<QgsLayerTreeLayer *> layers = mLayerTree->findLayers();
745 for ( QgsLayerTreeLayer *layer : layers )
746 {
747 layer->setItemVisibilityChecked( mProfile->layers().contains( layer->layer() ) );
748 }
749 mLayerTree->reorderGroupLayers( mProfile->layers() );
750
751 updateDataDefinedButton( mDDBtnTolerance );
752 updateDataDefinedButton( mDDBtnMinDistance );
753 updateDataDefinedButton( mDDBtnMaxDistance );
754 updateDataDefinedButton( mDDBtnMinElevation );
755 updateDataDefinedButton( mDDBtnMaxElevation );
756 updateDataDefinedButton( mDDBtnDistanceMajorInterval );
757 updateDataDefinedButton( mDDBtnDistanceMinorInterval );
758 updateDataDefinedButton( mDDBtnDistanceLabelInterval );
759 updateDataDefinedButton( mDDBtnElevationMajorInterval );
760 updateDataDefinedButton( mDDBtnElevationMinorInterval );
761 updateDataDefinedButton( mDDBtnElevationLabelInterval );
762 updateDataDefinedButton( mDDBtnLeftMargin );
763 updateDataDefinedButton( mDDBtnRightMargin );
764 updateDataDefinedButton( mDDBtnTopMargin );
765 updateDataDefinedButton( mDDBtnBottomMargin );
766
767 mBlockChanges--;
768}
769
770void QgsLayoutElevationProfileWidget::updateItemLayers()
771{
772 if ( mBlockChanges )
773 return;
774
775 QList<QgsMapLayer *> layers;
776 const QList< QgsMapLayer * > layerOrder = mLayerTree->layerOrder();
777 layers.reserve( layerOrder.size() );
778 for ( QgsMapLayer *layer : layerOrder )
779 {
780 if ( mLayerTree->findLayer( layer )->isVisible() )
781 layers << layer;
782 }
783
784 mProfile->setLayers( layers );
785 mProfile->update();
786}
787
788void QgsLayoutElevationProfileWidget::layoutAtlasToggled( bool atlasEnabled )
789{
790 if ( atlasEnabled &&
791 mProfile && mProfile->layout() && mProfile->layout()->reportContext().layer()
792 && mProfile->layout()->reportContext().layer()->geometryType() == Qgis::GeometryType::Line )
793 {
794 mCheckControlledByAtlas->setEnabled( true );
795 }
796 else
797 {
798 mCheckControlledByAtlas->setEnabled( false );
799 mCheckControlledByAtlas->setChecked( false );
800 }
801}
802
803void QgsLayoutElevationProfileWidget::atlasLayerChanged( QgsVectorLayer *layer )
804{
805 if ( !layer || layer->geometryType() != Qgis::GeometryType::Line )
806 {
807 //non-line layer, disable atlas control
808 mCheckControlledByAtlas->setChecked( false );
809 mCheckControlledByAtlas->setEnabled( false );
810 return;
811 }
812 else
813 {
814 mCheckControlledByAtlas->setEnabled( true );
815 }
816}
PlotAxisSuffixPlacement
Placement options for suffixes in the labels for axis of plots.
Definition qgis.h:3095
@ FirstAndLastLabels
Place suffix after the first and last label values only.
@ EveryLabel
Place suffix after every value label.
@ FirstLabel
Place suffix after the first label value only.
@ LastLabel
Place suffix after the last label value only.
@ NoLabels
Do not place suffixes.
DistanceUnit
Units of distance.
Definition qgis.h:4677
@ Feet
Imperial feet.
@ Centimeters
Centimeters.
@ Millimeters
Millimeters.
@ Miles
Terrestrial miles.
@ Yards
Imperial yards.
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ NauticalMiles
Nautical miles.
@ Kilometers
Kilometers.
@ TitleCase
Simple title case conversion - does not fully grammatically parse the text and uses simple rules only...
@ Line
Line symbol.
@ Fill
Fill symbol.
double yMaximum() const
Returns the maximum value of the y axis.
Definition qgsplot.h:383
QgsPlotAxis & xAxis()
Returns a reference to the plot's x axis.
Definition qgsplot.h:397
double xMaximum() const
Returns the maximum value of the x axis.
Definition qgsplot.h:369
double xMinimum() const
Returns the minimum value of the x axis.
Definition qgsplot.h:341
QgsPlotAxis & yAxis()
Returns a reference to the plot's y axis.
Definition qgsplot.h:411
double yMinimum() const
Returns the minimum value of the y axis.
Definition qgsplot.h:355
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Abstract base class for curved geometry type.
Definition qgscurve.h:35
A canvas for elevation profiles.
QgsCurve * profileCurve() const
Returns the profile curve.
QgsCoordinateReferenceSystem crs() const override
Returns the coordinate reference system (CRS) for map coordinates used by the canvas.
QList< QgsMapLayer * > layers() const
Returns the list of layers included in the profile.
const Qgs2DPlot & plot() const
Returns a reference to the 2D plot used by the widget.
Qgis::DistanceUnit distanceUnit() const
Returns the distance unit used by the canvas.
double tolerance() const
Returns the tolerance of the profile (in crs() units).
A layer tree view for elevation profiles.
void populateInitialLayers(QgsProject *project)
Initially populates the tree view using layers from a project.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
@ ModeTextRenderer
Configure font settings for use with QgsTextRenderer.
void changed()
Emitted when the widget's text format settings are changed.
@ HigDialogTitleIsTitleCase
Dialog titles should be title case.
Definition qgsgui.h:271
static QgsGui::HigFlags higFlags()
Returns the platform's HIG flags.
Definition qgsgui.cpp:233
Layer tree node points to a map layer.
void visibilityChanged(QgsLayerTreeNode *node)
Emitted when check state of a node within the tree has been changed.
Listens to the updates in map layer registry and does changes in layer tree.
Namespace with helper functions for layer tree operations.
void layerOrderChanged()
Emitted when the layer order has changed.
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
void toggled(bool enabled)
Emitted when atlas is enabled or disabled.
A common interface for layout designer dialogs and widgets.
A widget for layout elevation profile item settings.
void setReportTypeString(const QString &string) override
Sets the string to use to describe the current report type (e.g.
static std::function< void(QgsLayoutElevationProfileWidget *, QMenu *) > sBuildCopyMenuFunction
void copySettingsFromProfileCanvas(QgsElevationProfileCanvas *canvas)
Copies selected settings from a elevation profile canvas.
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.
bool setNewItem(QgsLayoutItem *item) override
Attempts to update the widget to show the properties for the specified item.
QgsLayoutElevationProfileWidget(QgsLayoutItemElevationProfile *profile)
constructor
void setDesignerInterface(QgsLayoutDesignerInterface *iface) override
Sets the the layout designer interface in which the widget is being shown.
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.
virtual void setDesignerInterface(QgsLayoutDesignerInterface *iface)
Sets the the layout designer interface in which the widget is being shown.
QgsLayoutAtlas * layoutAtlas() const
Returns the atlas for the layout (if available)
A layout item subclass for elevation profile plots.
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.
@ LayoutElevationProfile
Elevation profile item.
Base class for graphical items within a QgsLayout.
@ UndoElevationProfileElevationMajorGridlines
Change elevation profile elevation axis major gridlines.
@ UndoElevationProfileMaximumDistance
Change elevation profile maximum distance.
@ UndoElevationProfileChartBackground
Change elevation profile chart background.
@ UndoElevationProfileDistanceMinorGridlines
Change elevation profile distance axis minor gridlines.
@ UndoMarginTop
Top margin.
@ UndoElevationProfileChartBorder
Change elevation profile chart border.
@ UndoElevationProfileMaximumElevation
Change elevation profile maximum elevation.
@ UndoMarginLeft
Left margin.
@ UndoMarginRight
Right margin.
@ UndoElevationProfileTolerance
Change elevation profile distance tolerance.
@ UndoElevationProfileElevationFormat
Change elevation profile elevation axis number format.
@ UndoElevationProfileMinimumElevation
Change elevation profile minimum elevation.
@ UndoElevationProfileDistanceLabels
Change elevation profile distance axis label interval.
@ UndoMarginBottom
Bottom margin.
@ UndoElevationProfileElevationFont
Change elevation profile elevation axis number font.
@ UndoElevationProfileDistanceFormat
Change elevation profile distance axis number format.
@ UndoElevationProfileElevationMinorGridlines
Change elevation profile elevation axis minor gridlines.
@ UndoElevationProfileDistanceFont
Change elevation profile distance axis number font.
@ UndoElevationProfileElevationLabels
Change elevation profile elevation axis label interval.
@ UndoElevationProfileDistanceMajorGridlines
Change elevation profile distance axis major gridlines.
@ UndoElevationProfileMinimumDistance
Change elevation profile minimum distance.
int type() const override
Returns a unique graphics item type identifier.
void changed()
Emitted when the object's properties change.
@ ElevationProfileMaximumDistance
Maximum distance value for elevation profile.
@ ElevationProfileElevationMinorInterval
Minor grid line interval for elevation profile elevation axis.
@ ElevationProfileDistanceMinorInterval
Minor grid line interval for elevation profile distance axis.
@ ElevationProfileMinimumDistance
Minimum distance value for elevation profile.
@ ElevationProfileMaximumElevation
Maximum elevation value for elevation profile.
@ ElevationProfileDistanceLabelInterval
Label interval for elevation profile distance axis.
@ ElevationProfileTolerance
Tolerance distance for elevation profiles.
@ ElevationProfileMinimumElevation
Minimum elevation value for elevation profile.
@ ElevationProfileElevationLabelInterval
Label interval for elevation profile elevation axis.
@ ElevationProfileDistanceMajorInterval
Major grid line interval for elevation profile distance axis.
@ ElevationProfileElevationMajorInterval
Major grid line interval for elevation profile elevation axis.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
A line symbol type, for rendering LineString and MultiLineString geometries.
Base class for all map layer types.
Definition qgsmaplayer.h:76
The QgsMargins class defines the four margins of a rectangle.
Definition qgsmargins.h:37
void setBottom(double bottom)
Sets the bottom margin to bottom.
Definition qgsmargins.h:113
void setLeft(double left)
Sets the left margin to left.
Definition qgsmargins.h:95
void setRight(double right)
Sets the right margin to right.
Definition qgsmargins.h:107
void setTop(double top)
Sets the top margin to top.
Definition qgsmargins.h:101
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.
double gridIntervalMinor() const
Returns the interval of minor grid lines for the axis.
Definition qgsplot.h:99
double gridIntervalMajor() const
Returns the interval of major grid lines for the axis.
Definition qgsplot.h:113
double labelInterval() const
Returns the interval of labels for the axis.
Definition qgsplot.h:127
Qgis::PlotAxisSuffixPlacement labelSuffixPlacement() const
Returns the placement for the axis label suffixes.
Definition qgsplot.cpp:124
static QgsFillSymbol * chartBorderSymbol()
Returns the default fill symbol to use for the chart area border.
Definition qgsplot.cpp:805
static QgsLineSymbol * axisGridMinorSymbol()
Returns the default line symbol to use for axis minor grid lines.
Definition qgsplot.cpp:792
static QgsFillSymbol * chartBackgroundSymbol()
Returns the default fill symbol to use for the chart area background fill.
Definition qgsplot.cpp:799
static QgsLineSymbol * axisGridMajorSymbol()
Returns the default line symbol to use for axis major grid lines.
Definition qgsplot.cpp:785
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
static QgsProject * instance()
Returns the QgsProject singleton instance.
static QString capitalize(const QString &string, Qgis::Capitalization capitalization)
Converts a string by applying capitalization rules to the string.
void changed()
Emitted when the symbol's settings are changed.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.