QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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
20#include "qgscurve.h"
23#include "qgsfillsymbol.h"
24#include "qgsgui.h"
25#include "qgslayertree.h"
27#include "qgslayout.h"
28#include "qgslayoutatlas.h"
31#include "qgslayoutitemwidget.h"
33#include "qgslinesymbol.h"
35#include "qgsplot.h"
36#include "qgsprofilerenderer.h"
38#include "qgsvectorlayer.h"
39
40#include <QMenu>
41#include <QString>
42
43#include "moc_qgslayoutelevationprofilewidget.cpp"
44
45using namespace Qt::StringLiterals;
46
48
50 : QgsLayoutItemBaseWidget( nullptr, profile )
51 , mProfile( profile )
52 , mLayerTree( new QgsLayerTree() )
53 , mLayerTreeBridge( new QgsLayerTreeRegistryBridge( mLayerTree.get(), mProfile->layout() ? mProfile->layout()->project() : QgsProject::instance(), this ) )
54{
55 Q_ASSERT( mProfile );
56
57 setupUi( this );
58 setPanelTitle( tr( "Elevation Profile Properties" ) );
59
60 mCopyFromDockMenu = new QMenu( this );
61 connect( mCopyFromDockMenu, &QMenu::aboutToShow, this, [this] { sBuildCopyMenuFunction( this, mCopyFromDockMenu ); } );
62
63 connect( mActionRefresh, &QAction::triggered, this, [this] {
64 if ( !mProfile )
65 {
66 return;
67 }
68 mProfile->invalidateCache();
69 mProfile->refresh();
70 } );
71
72 QToolButton *copyFromDockButton = new QToolButton();
73 copyFromDockButton->setAutoRaise( true );
74 copyFromDockButton->setToolTip( tr( "Copy From Profile" ) );
75 copyFromDockButton->setMenu( mCopyFromDockMenu );
76 copyFromDockButton->setPopupMode( QToolButton::InstantPopup );
77 copyFromDockButton->setIcon( QgsApplication::getThemeIcon( u"/mActionCopyProfileSettings.svg"_s ) );
78
79 mDockToolbar->addWidget( copyFromDockButton );
80
81 //add widget for general composer item properties
82 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, profile );
83 mainLayout->addWidget( mItemPropertiesWidget );
84
85 connect( mLayerTree.get(), &QgsLayerTree::layerOrderChanged, this, &QgsLayoutElevationProfileWidget::updateItemSources );
86 connect( mLayerTree.get(), &QgsLayerTreeGroup::visibilityChanged, this, &QgsLayoutElevationProfileWidget::updateItemSources );
87
88 mSpinTolerance->setClearValue( 0 );
89 connect( mSpinTolerance, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
90 if ( !mProfile || mBlockChanges )
91 return;
92
93 mProfile->beginCommand( tr( "Change Profile Tolerance Distance" ), QgsLayoutItem::UndoElevationProfileTolerance );
94 mProfile->setTolerance( value );
95 mProfile->invalidateCache();
96 mProfile->update();
97 mProfile->endCommand();
98 } );
99
100 connect( mCheckControlledByAtlas, &QCheckBox::toggled, this, [this] {
101 if ( !mProfile || mBlockChanges )
102 return;
103
104 mProfile->beginCommand( tr( "Change Profile Atlas Control" ) );
105 mProfile->setAtlasDriven( mCheckControlledByAtlas->isChecked() );
106 mProfile->invalidateCache();
107 mProfile->update();
108 mProfile->endCommand();
109 } );
110
111 // subsections indicator
112 mSubsectionsSymbolButton->setSymbolType( Qgis::SymbolType::Line );
113 connect( mSubsectionsSymbolButton, &QgsSymbolButton::changed, this, [this] {
114 if ( !mProfile || mBlockChanges )
115 return;
116
117 mProfile->beginCommand( tr( "Change Profile Subsection Indicator" ), QgsLayoutItem::UndoElevationProfileSubsectionLines );
118 mProfile->setSubsectionsSymbol( mSubsectionsSymbolButton->clonedSymbol<QgsLineSymbol>() );
119 mProfile->invalidateCache();
120 mProfile->update();
121 mProfile->endCommand();
122 } );
123 mSubsectionsSymbolButton->setDefaultSymbol( QgsProfilePlotRenderer::defaultSubSectionsSymbol().release() );
124
125 connect( mSubsectionsActivateCheck, &QGroupBox::toggled, this, [this] {
126 if ( !mProfile || mBlockChanges )
127 return;
128
129 const bool subsectionsActivated = mSubsectionsActivateCheck->isChecked();
130 mProfile->beginCommand( tr( "Change Profile Subsection Indicator" ), QgsLayoutItem::UndoElevationProfileSubsectionLines );
131 std::unique_ptr<QgsLineSymbol> subSectionsSymbol( subsectionsActivated ? mSubsectionsSymbolButton->clonedSymbol<QgsLineSymbol>() : nullptr );
132 mProfile->setSubsectionsSymbol( subSectionsSymbol.release() );
133
134 mProfile->invalidateCache();
135 mProfile->update();
136 mProfile->endCommand();
137 } );
138
139 mSpinMinDistance->setClearValue( 0 );
140 connect( mSpinMinDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
141 if ( !mProfile || mBlockChanges )
142 return;
143
144 mProfile->beginCommand( tr( "Change Profile Chart Minimum Distance" ), QgsLayoutItem::UndoElevationProfileMinimumDistance );
145 mProfile->plot()->setXMinimum( value );
146 mProfile->invalidateCache();
147 mProfile->update();
148 mProfile->endCommand();
149 } );
150
151 connect( mSpinMaxDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
152 if ( !mProfile || mBlockChanges )
153 return;
154
155 mProfile->beginCommand( tr( "Change Profile Chart Maximum Distance" ), QgsLayoutItem::UndoElevationProfileMaximumDistance );
156 mProfile->plot()->setXMaximum( value );
157 mProfile->invalidateCache();
158 mProfile->update();
159 mProfile->endCommand();
160 } );
161
162 mSpinMinElevation->setClearValue( 0 );
163 connect( mSpinMinElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
164 if ( !mProfile || mBlockChanges )
165 return;
166
167 mProfile->beginCommand( tr( "Change Profile Chart Minimum Elevation" ), QgsLayoutItem::UndoElevationProfileMinimumElevation );
168 mProfile->plot()->setYMinimum( value );
169 mProfile->invalidateCache();
170 mProfile->update();
171 mProfile->endCommand();
172 } );
173
174 connect( mSpinMaxElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
175 if ( !mProfile || mBlockChanges )
176 return;
177
178 mProfile->beginCommand( tr( "Change Profile Chart Maximum Elevation" ), QgsLayoutItem::UndoElevationProfileMaximumElevation );
179 mProfile->plot()->setYMaximum( value );
180 mProfile->invalidateCache();
181 mProfile->update();
182 mProfile->endCommand();
183 } );
184
185 mDistanceAxisMajorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
186 connect( mDistanceAxisMajorLinesSymbolButton, &QgsSymbolButton::changed, this, [this] {
187 if ( !mProfile || mBlockChanges )
188 return;
189
190 mProfile->beginCommand( tr( "Change Profile Chart Distance Major Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMajorGridlines );
191 mProfile->plot()->xAxis().setGridMajorSymbol( mDistanceAxisMajorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
192 mProfile->invalidateCache();
193 mProfile->update();
194 mProfile->endCommand();
195 } );
196 mDistanceAxisMajorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMajorSymbol() );
197
198 mDistanceAxisMinorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
199 connect( mDistanceAxisMinorLinesSymbolButton, &QgsSymbolButton::changed, this, [this] {
200 if ( !mProfile || mBlockChanges )
201 return;
202
203 mProfile->beginCommand( tr( "Change Profile Chart Distance Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMinorGridlines );
204 mProfile->plot()->xAxis().setGridMinorSymbol( mDistanceAxisMinorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
205 mProfile->invalidateCache();
206 mProfile->update();
207 mProfile->endCommand();
208 } );
209 mDistanceAxisMinorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMinorSymbol() );
210
211 connect( mDistanceAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
212 if ( !mProfile || mBlockChanges )
213 return;
214
215 mProfile->beginCommand( tr( "Change Profile Chart Distance Major Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMajorGridlines );
216 mProfile->plot()->xAxis().setGridIntervalMajor( value );
217 mProfile->invalidateCache();
218 mProfile->update();
219 mProfile->endCommand();
220 } );
221
222 connect( mDistanceAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
223 if ( !mProfile || mBlockChanges )
224 return;
225
226 mProfile->beginCommand( tr( "Change Profile Chart Distance Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMinorGridlines );
227 mProfile->plot()->xAxis().setGridIntervalMinor( value );
228 mProfile->invalidateCache();
229 mProfile->update();
230 mProfile->endCommand();
231 } );
232
233 connect( mDistanceAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
234 if ( !mProfile || mBlockChanges )
235 return;
236
237 mProfile->beginCommand( tr( "Change Profile Chart Distance Label" ), QgsLayoutItem::UndoElevationProfileDistanceLabels );
238 mProfile->plot()->xAxis().setLabelInterval( value );
239 mProfile->invalidateCache();
240 mProfile->update();
241 mProfile->endCommand();
242 } );
243
244 mElevationAxisMajorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
245 connect( mElevationAxisMajorLinesSymbolButton, &QgsSymbolButton::changed, this, [this] {
246 if ( !mProfile || mBlockChanges )
247 return;
248
249 mProfile->beginCommand( tr( "Change Profile Chart Elevation Major Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMajorGridlines );
250 mProfile->plot()->yAxis().setGridMajorSymbol( mElevationAxisMajorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
251 mProfile->invalidateCache();
252 mProfile->update();
253 mProfile->endCommand();
254 } );
255 mElevationAxisMajorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMajorSymbol() );
256
257 mElevationAxisMinorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
258 connect( mElevationAxisMinorLinesSymbolButton, &QgsSymbolButton::changed, this, [this] {
259 if ( !mProfile || mBlockChanges )
260 return;
261
262 mProfile->beginCommand( tr( "Change Profile Chart Elevation Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMinorGridlines );
263 mProfile->plot()->yAxis().setGridMinorSymbol( mElevationAxisMinorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
264 mProfile->invalidateCache();
265 mProfile->update();
266 mProfile->endCommand();
267 } );
268 mElevationAxisMinorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMinorSymbol() );
269
270 connect( mElevationAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
271 if ( !mProfile || mBlockChanges )
272 return;
273
274 mProfile->beginCommand( tr( "Change Profile Chart Elevation Label" ), QgsLayoutItem::UndoElevationProfileElevationLabels );
275 mProfile->plot()->yAxis().setLabelInterval( value );
276 mProfile->invalidateCache();
277 mProfile->update();
278 mProfile->endCommand();
279 } );
280
281 connect( mElevationAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
282 if ( !mProfile || mBlockChanges )
283 return;
284
285 mProfile->beginCommand( tr( "Change Profile Chart Elevation Major Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMajorGridlines );
286 mProfile->plot()->yAxis().setGridIntervalMajor( value );
287 mProfile->invalidateCache();
288 mProfile->update();
289 mProfile->endCommand();
290 } );
291
292 connect( mElevationAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
293 if ( !mProfile || mBlockChanges )
294 return;
295
296 mProfile->beginCommand( tr( "Change Profile Chart Distance Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMinorGridlines );
297 mProfile->plot()->yAxis().setGridIntervalMinor( value );
298 mProfile->invalidateCache();
299 mProfile->update();
300 mProfile->endCommand();
301 } );
302
303 mChartBackgroundSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
304 connect( mChartBackgroundSymbolButton, &QgsSymbolButton::changed, this, [this] {
305 if ( !mProfile || mBlockChanges )
306 return;
307
308 mProfile->beginCommand( tr( "Change Profile Chart Background" ), QgsLayoutItem::UndoElevationProfileChartBackground );
309 mProfile->plot()->setChartBackgroundSymbol( mChartBackgroundSymbolButton->clonedSymbol<QgsFillSymbol>() );
310 mProfile->invalidateCache();
311 mProfile->update();
312 mProfile->endCommand();
313 } );
314 mChartBackgroundSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::chartBackgroundSymbol() );
315
316 mChartBorderSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
317 connect( mChartBorderSymbolButton, &QgsSymbolButton::changed, this, [this] {
318 if ( !mProfile || mBlockChanges )
319 return;
320
321 mProfile->beginCommand( tr( "Change Profile Chart Border" ), QgsLayoutItem::UndoElevationProfileChartBorder );
322 mProfile->plot()->setChartBorderSymbol( mChartBorderSymbolButton->clonedSymbol<QgsFillSymbol>() );
323 mProfile->invalidateCache();
324 mProfile->update();
325 mProfile->endCommand();
326 } );
327 mChartBorderSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::chartBorderSymbol() );
328
329 connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked, this, [this] {
330 if ( !mProfile || mBlockChanges )
331 return;
332
334 widget->setPanelTitle( tr( "Distance Number Format" ) );
335 widget->setFormat( mProfile->plot()->xAxis().numericFormat() );
336 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [this, widget] {
337 mProfile->beginCommand( tr( "Change Profile Chart Distance Format" ), QgsLayoutItem::UndoElevationProfileDistanceFormat );
338 mProfile->plot()->xAxis().setNumericFormat( widget->format() );
339 mProfile->invalidateCache();
340 mProfile->endCommand();
341 mProfile->update();
342 } );
343 openPanel( widget );
344 } );
345
346 connect( mElevationAxisLabelFormatButton, &QPushButton::clicked, this, [this] {
347 if ( !mProfile || mBlockChanges )
348 return;
349
351 widget->setPanelTitle( tr( "Elevation Number Format" ) );
352 widget->setFormat( mProfile->plot()->yAxis().numericFormat() );
353 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [this, widget] {
354 mProfile->beginCommand( tr( "Change Profile Chart Elevation Format" ), QgsLayoutItem::UndoElevationProfileElevationFormat );
355 mProfile->plot()->yAxis().setNumericFormat( widget->format() );
356 mProfile->invalidateCache();
357 mProfile->endCommand();
358 mProfile->update();
359 } );
360 openPanel( widget );
361 } );
362
363 mDistanceAxisLabelFontButton->setDialogTitle( tr( "Distance Label Font" ) );
364 mElevationAxisLabelFontButton->setDialogTitle( tr( "Elevation Label Font" ) );
365 mDistanceAxisLabelFontButton->setMode( QgsFontButton::ModeTextRenderer );
366 mElevationAxisLabelFontButton->setMode( QgsFontButton::ModeTextRenderer );
367
368 connect( mDistanceAxisLabelFontButton, &QgsFontButton::changed, this, [this] {
369 if ( !mProfile || mBlockChanges )
370 return;
371
372 mProfile->beginCommand( tr( "Change Profile Chart Distance Font" ), QgsLayoutItem::UndoElevationProfileDistanceFont );
373 mProfile->plot()->xAxis().setTextFormat( mDistanceAxisLabelFontButton->textFormat() );
374 mProfile->invalidateCache();
375 mProfile->endCommand();
376 mProfile->update();
377 } );
378
379 connect( mElevationAxisLabelFontButton, &QgsFontButton::changed, this, [this] {
380 if ( !mProfile || mBlockChanges )
381 return;
382
383 mProfile->beginCommand( tr( "Change Profile Chart Elevation Font" ), QgsLayoutItem::UndoElevationProfileElevationFont );
384 mProfile->plot()->yAxis().setTextFormat( mElevationAxisLabelFontButton->textFormat() );
385 mProfile->invalidateCache();
386 mProfile->endCommand();
387 mProfile->update();
388 } );
389
390 mSpinLeftMargin->setClearValue( 0 );
391 connect( mSpinLeftMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
392 if ( !mProfile || mBlockChanges )
393 return;
394
395 mProfile->beginCommand( tr( "Change Profile Chart Left Margin" ), QgsLayoutItem::UndoMarginLeft );
396 QgsMargins margins = mProfile->plot()->margins();
397 margins.setLeft( value );
398 mProfile->plot()->setMargins( margins );
399 mProfile->invalidateCache();
400 mProfile->update();
401 mProfile->endCommand();
402 } );
403
404 mSpinRightMargin->setClearValue( 0 );
405 connect( mSpinRightMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
406 if ( !mProfile || mBlockChanges )
407 return;
408
409 mProfile->beginCommand( tr( "Change Profile Chart Right Margin" ), QgsLayoutItem::UndoMarginRight );
410 QgsMargins margins = mProfile->plot()->margins();
411 margins.setRight( value );
412 mProfile->plot()->setMargins( margins );
413 mProfile->invalidateCache();
414 mProfile->update();
415 mProfile->endCommand();
416 } );
417
418 mSpinTopMargin->setClearValue( 0 );
419 connect( mSpinTopMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
420 if ( !mProfile || mBlockChanges )
421 return;
422
423 mProfile->beginCommand( tr( "Change Profile Chart Top Margin" ), QgsLayoutItem::UndoMarginTop );
424 QgsMargins margins = mProfile->plot()->margins();
425 margins.setTop( value );
426 mProfile->plot()->setMargins( margins );
427 mProfile->invalidateCache();
428 mProfile->update();
429 mProfile->endCommand();
430 } );
431
432 mSpinBottomMargin->setClearValue( 0 );
433 connect( mSpinBottomMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
434 if ( !mProfile || mBlockChanges )
435 return;
436
437 mProfile->beginCommand( tr( "Change Profile Chart Bottom Margin" ), QgsLayoutItem::UndoMarginBottom );
438 QgsMargins margins = mProfile->plot()->margins();
439 margins.setBottom( value );
440 mProfile->plot()->setMargins( margins );
441 mProfile->invalidateCache();
442 mProfile->update();
443 mProfile->endCommand();
444 } );
445
446 for ( Qgis::DistanceUnit unit : {
457 } )
458 {
459 QString title;
461 {
463 }
464 else
465 {
466 title = QgsUnitTypes::toString( unit );
467 }
468 mDistanceUnitCombo->addItem( title, QVariant::fromValue( unit ) );
469 }
470
471 connect( mDistanceUnitCombo, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
472 if ( !mProfile || mBlockChanges )
473 return;
474
475 mProfile->beginCommand( tr( "Change Profile Chart Units" ) );
476 mProfile->setDistanceUnit( mDistanceUnitCombo->currentData().value<Qgis::DistanceUnit>() );
477 mProfile->invalidateCache();
478 mProfile->update();
479 mProfile->endCommand();
480 } );
481
482 mDistanceLabelsCombo->addItem( tr( "None" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::NoLabels ) );
483 mDistanceLabelsCombo->addItem( tr( "Every Value" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::EveryLabel ) );
484 mDistanceLabelsCombo->addItem( tr( "First Value" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::FirstLabel ) );
485 mDistanceLabelsCombo->addItem( tr( "Last Value" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::LastLabel ) );
486 mDistanceLabelsCombo->addItem( tr( "First and Last Values" ), QVariant::fromValue( Qgis::PlotAxisSuffixPlacement::FirstAndLastLabels ) );
487 connect( mDistanceLabelsCombo, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
488 if ( !mProfile || mBlockChanges )
489 return;
490
491 mProfile->beginCommand( tr( "Change Profile Chart Label Placement" ) );
492 mProfile->plot()->xAxis().setLabelSuffixPlacement( mDistanceLabelsCombo->currentData().value<Qgis::PlotAxisSuffixPlacement>() );
493 mProfile->invalidateCache();
494 mProfile->update();
495 mProfile->endCommand();
496 } );
497
498
514
515 mLayerTreeView = new QgsElevationProfileLayerTreeView( mLayerTree.get() );
516
517 QVBoxLayout *vl = new QVBoxLayout();
518 vl->setContentsMargins( 0, 0, 0, 0 );
519 vl->addWidget( mLayerTreeView );
520 mTreeViewContainer->setLayout( vl );
521
522 mBlockChanges++;
523 mLayerTreeView->populateInitialSources( mProfile->layout() && mProfile->layout()->project() ? mProfile->layout()->project() : QgsProject::instance() );
524 mBlockChanges--;
525
526 setGuiElementValues();
527
528 mSubsectionsSymbolButton->registerExpressionContextGenerator( mProfile );
529 mDistanceAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
530 mDistanceAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
531 mElevationAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
532 mElevationAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
533 mChartBackgroundSymbolButton->registerExpressionContextGenerator( mProfile );
534 mChartBorderSymbolButton->registerExpressionContextGenerator( mProfile );
535 mDistanceAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
536 mElevationAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
537
538 mSubsectionsSymbolButton->setLayer( coverageLayer() );
539 mDistanceAxisMajorLinesSymbolButton->setLayer( coverageLayer() );
540 mDistanceAxisMinorLinesSymbolButton->setLayer( coverageLayer() );
541 mElevationAxisMajorLinesSymbolButton->setLayer( coverageLayer() );
542 mElevationAxisMinorLinesSymbolButton->setLayer( coverageLayer() );
543 mDistanceAxisLabelFontButton->setLayer( coverageLayer() );
544 mElevationAxisLabelFontButton->setLayer( coverageLayer() );
545 mChartBackgroundSymbolButton->setLayer( coverageLayer() );
546 mChartBorderSymbolButton->setLayer( coverageLayer() );
547
548 if ( mProfile->layout() )
549 {
550 connect( &mProfile->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, this, [this]( QgsVectorLayer *layer ) {
551 mSubsectionsSymbolButton->setLayer( layer );
552 mDistanceAxisMajorLinesSymbolButton->setLayer( layer );
553 mDistanceAxisMinorLinesSymbolButton->setLayer( layer );
554 mElevationAxisMajorLinesSymbolButton->setLayer( layer );
555 mElevationAxisMinorLinesSymbolButton->setLayer( layer );
556 mDistanceAxisLabelFontButton->setLayer( layer );
557 mElevationAxisLabelFontButton->setLayer( layer );
558 mChartBackgroundSymbolButton->setLayer( layer );
559 mChartBorderSymbolButton->setLayer( layer );
560 } );
561
562 connect( &mProfile->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, this, &QgsLayoutElevationProfileWidget::atlasLayerChanged );
563 }
564
565 if ( QgsLayoutAtlas *atlas = layoutAtlas() )
566 {
567 connect( atlas, &QgsLayoutAtlas::toggled, this, &QgsLayoutElevationProfileWidget::layoutAtlasToggled );
568 layoutAtlasToggled( atlas->enabled() );
569 }
570}
571
573
575{
576 if ( mItemPropertiesWidget )
577 mItemPropertiesWidget->setMasterLayout( masterLayout );
578}
579
581{
582 QgsExpressionContext context = mProfile->createExpressionContext();
583
584 auto plotScope = std::make_unique<QgsExpressionContextScope>( u"plot"_s );
585 plotScope->addVariable( QgsExpressionContextScope::StaticVariable( u"plot_axis"_s, QString(), true ) );
586 plotScope->addVariable( QgsExpressionContextScope::StaticVariable( u"plot_axis_value"_s, 0.0, true ) );
587 context.appendScope( plotScope.release() );
588
589 return context;
590}
591
597
599{
600 mCheckControlledByAtlas->setText( tr( "Controlled by %1" ).arg( string == tr( "atlas" ) ? tr( "Atlas" ) : tr( "Report" ) ) );
601}
602
604{
605 mBlockChanges++;
606
607 mProfile->setCrs( canvas->crs() );
608
609 mSpinTolerance->setValue( canvas->tolerance() );
610 mProfile->setTolerance( canvas->tolerance() );
611
612 mProfile->setDistanceUnit( canvas->distanceUnit() );
613 mDistanceUnitCombo->setCurrentIndex( mDistanceUnitCombo->findData( QVariant::fromValue( canvas->distanceUnit() ) ) );
614
615 mProfile->plot()->xAxis().setLabelSuffixPlacement( canvas->plot().xAxis().labelSuffixPlacement() );
616 mDistanceLabelsCombo->setCurrentIndex( mDistanceLabelsCombo->findData( QVariant::fromValue( canvas->plot().xAxis().labelSuffixPlacement() ) ) );
617
618 if ( const QgsCurve *curve = canvas->profileCurve() )
619 mProfile->setProfileCurve( curve->clone() );
620
621 mSpinMinDistance->setValue( canvas->plot().xMinimum() );
622 mSpinMinDistance->setClearValue( canvas->plot().xMinimum() );
623 mProfile->plot()->setXMinimum( canvas->plot().xMinimum() );
624
625 mSpinMaxDistance->setValue( canvas->plot().xMaximum() );
626 mSpinMaxDistance->setClearValue( canvas->plot().xMaximum() );
627 mProfile->plot()->setXMaximum( canvas->plot().xMaximum() );
628
629 mDistanceAxisMajorIntervalSpin->setValue( canvas->plot().xAxis().gridIntervalMajor() );
630 mDistanceAxisMajorIntervalSpin->setClearValue( canvas->plot().xAxis().gridIntervalMajor() );
631 mProfile->plot()->xAxis().setGridIntervalMajor( canvas->plot().xAxis().gridIntervalMajor() );
632
633 mDistanceAxisMinorIntervalSpin->setValue( canvas->plot().xAxis().gridIntervalMinor() );
634 mDistanceAxisMinorIntervalSpin->setClearValue( canvas->plot().xAxis().gridIntervalMinor() );
635 mProfile->plot()->xAxis().setGridIntervalMinor( canvas->plot().xAxis().gridIntervalMinor() );
636
637 mDistanceAxisLabelIntervalSpin->setValue( canvas->plot().xAxis().labelInterval() );
638 mDistanceAxisLabelIntervalSpin->setClearValue( canvas->plot().xAxis().labelInterval() );
639 mProfile->plot()->xAxis().setLabelInterval( canvas->plot().xAxis().labelInterval() );
640
641 mSpinMinElevation->setValue( canvas->plot().yMinimum() );
642 mSpinMinElevation->setClearValue( canvas->plot().yMinimum() );
643 mProfile->plot()->setYMinimum( canvas->plot().yMinimum() );
644
645 mSpinMaxElevation->setValue( canvas->plot().yMaximum() );
646 mSpinMaxElevation->setClearValue( canvas->plot().yMaximum() );
647 mProfile->plot()->setYMaximum( canvas->plot().yMaximum() );
648
649 mElevationAxisMajorIntervalSpin->setValue( canvas->plot().yAxis().gridIntervalMajor() );
650 mElevationAxisMajorIntervalSpin->setClearValue( canvas->plot().yAxis().gridIntervalMajor() );
651 mProfile->plot()->yAxis().setGridIntervalMajor( canvas->plot().yAxis().gridIntervalMajor() );
652
653 mElevationAxisMinorIntervalSpin->setValue( canvas->plot().yAxis().gridIntervalMinor() );
654 mElevationAxisMinorIntervalSpin->setClearValue( canvas->plot().yAxis().gridIntervalMinor() );
655 mProfile->plot()->yAxis().setGridIntervalMinor( canvas->plot().yAxis().gridIntervalMinor() );
656
657 mElevationAxisLabelIntervalSpin->setValue( canvas->plot().yAxis().labelInterval() );
658 mElevationAxisLabelIntervalSpin->setClearValue( canvas->plot().yAxis().labelInterval() );
659 mProfile->plot()->yAxis().setLabelInterval( canvas->plot().yAxis().labelInterval() );
660
661 const QgsLineSymbol *subSectionsSymbol = canvas->subsectionsSymbol() ? canvas->subsectionsSymbol() : nullptr;
662 const bool subSectionsEnabled = static_cast< bool >( subSectionsSymbol );
663 mSubsectionsActivateCheck->setChecked( subSectionsEnabled );
664 if ( subSectionsSymbol )
665 {
666 mSubsectionsSymbolButton->setSymbol( subSectionsSymbol->clone() );
667 mProfile->setSubsectionsSymbol( subSectionsSymbol->clone() );
668 }
669
670 QList<QgsMapLayer *> canvasLayers = canvas->layers();
671 mProfile->setLayers( canvasLayers );
672
673 QList<QgsAbstractProfileSource *> canvasSources = canvas->sources();
674 mProfile->setSources( canvasSources );
675
676 syncLayerTreeAndProfileItemSources();
677
678 mProfile->invalidateCache();
679 mProfile->update();
680 mBlockChanges--;
681}
682
683void QgsLayoutElevationProfileWidget::syncLayerTreeAndProfileItemSources()
684{
685 // Update layer tree node visibility, based on layout item profile
686 const QList<QgsLayerTreeNode *> nodes = mLayerTree->findLayersAndCustomNodes();
687 for ( QgsLayerTreeNode *node : nodes )
688 {
689 QgsAbstractProfileSource *source = nullptr;
690 if ( QgsLayerTree::isLayer( node ) )
691 {
692 QgsLayerTreeLayer *layerNode = QgsLayerTree::toLayer( node );
693 QgsMapLayer *layer = layerNode->layer();
694 if ( !layer )
695 continue;
696
697 source = layer->profileSource();
698 }
699 else if ( QgsLayerTree::isCustomNode( node ) && node->customProperty( u"source"_s ) == QgsElevationProfileLayerTreeView::CUSTOM_NODE_ELEVATION_PROFILE_SOURCE )
700 {
701 QgsLayerTreeCustomNode *customNode = QgsLayerTree::toCustomNode( node );
703 }
704
705 if ( !source )
706 {
707 node->setItemVisibilityChecked( false );
708 }
709 else
710 {
711 node->setItemVisibilityChecked( mProfile->sources().contains( source ) );
712 }
713 }
714
715 // Update layer tree node ordering, based on layout item profile
716 QList< QgsLayerTreeNode * > orderedNodes;
717 const QList<QgsAbstractProfileSource *> profileSources = mProfile->sources();
718 for ( const QgsAbstractProfileSource *source : profileSources )
719 {
720 if ( QgsLayerTreeLayer *layerNode = mLayerTree->findLayer( source->profileSourceId() ) )
721 {
722 orderedNodes << layerNode;
723 }
724 else if ( QgsLayerTreeCustomNode *customNode = mLayerTree->findCustomNode( source->profileSourceId() ) )
725 {
726 orderedNodes << customNode;
727 }
728 }
729 mLayerTree->reorderGroupLayersAndCustomNodes( orderedNodes );
730}
731
733{
735 return false;
736
737 if ( mProfile )
738 {
739 disconnect( mProfile, &QgsLayoutObject::changed, this, &QgsLayoutElevationProfileWidget::setGuiElementValues );
740 }
741
742 mProfile = qobject_cast<QgsLayoutItemElevationProfile *>( item );
743 mItemPropertiesWidget->setItem( mProfile );
744
745 if ( mProfile )
746 {
747 connect( mProfile, &QgsLayoutObject::changed, this, &QgsLayoutElevationProfileWidget::setGuiElementValues );
748 mSubsectionsSymbolButton->registerExpressionContextGenerator( mProfile );
749 mDistanceAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
750 mDistanceAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
751 mElevationAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
752 mElevationAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
753 mDistanceAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
754 mElevationAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
755 mChartBackgroundSymbolButton->registerExpressionContextGenerator( mProfile );
756 mChartBorderSymbolButton->registerExpressionContextGenerator( mProfile );
757 }
758
759 setGuiElementValues();
760
761 return true;
762}
763
764void QgsLayoutElevationProfileWidget::setGuiElementValues()
765{
766 mBlockChanges++;
767
768 mSpinTolerance->setValue( mProfile->tolerance() );
769 mCheckControlledByAtlas->setChecked( mProfile->atlasDriven() );
770
771 mSpinMinDistance->setValue( mProfile->plot()->xMinimum() );
772 mSpinMaxDistance->setValue( mProfile->plot()->xMaximum() );
773 mSpinMinElevation->setValue( mProfile->plot()->yMinimum() );
774 mSpinMaxElevation->setValue( mProfile->plot()->yMaximum() );
775
776 mSubsectionsActivateCheck->setChecked( mProfile->subsectionsSymbol() );
777 if ( mProfile->subsectionsSymbol() )
778 {
779 mSubsectionsSymbolButton->setSymbol( mProfile->subsectionsSymbol()->clone() );
780 }
781
782 if ( mProfile->plot()->xAxis().gridMajorSymbol() )
783 mDistanceAxisMajorLinesSymbolButton->setSymbol( mProfile->plot()->xAxis().gridMajorSymbol()->clone() );
784 if ( mProfile->plot()->xAxis().gridMinorSymbol() )
785 mDistanceAxisMinorLinesSymbolButton->setSymbol( mProfile->plot()->xAxis().gridMinorSymbol()->clone() );
786 if ( mProfile->plot()->yAxis().gridMajorSymbol() )
787 mElevationAxisMajorLinesSymbolButton->setSymbol( mProfile->plot()->yAxis().gridMajorSymbol()->clone() );
788 if ( mProfile->plot()->yAxis().gridMinorSymbol() )
789 mElevationAxisMinorLinesSymbolButton->setSymbol( mProfile->plot()->yAxis().gridMinorSymbol()->clone() );
790
791 mDistanceAxisLabelFontButton->setTextFormat( mProfile->plot()->xAxis().textFormat() );
792 mElevationAxisLabelFontButton->setTextFormat( mProfile->plot()->yAxis().textFormat() );
793
794 mDistanceUnitCombo->setCurrentIndex( mDistanceUnitCombo->findData( QVariant::fromValue( mProfile->distanceUnit() ) ) );
795 mDistanceLabelsCombo->setCurrentIndex( mDistanceLabelsCombo->findData( QVariant::fromValue( mProfile->plot()->xAxis().labelSuffixPlacement() ) ) );
796
797 mDistanceAxisMajorIntervalSpin->setValue( mProfile->plot()->xAxis().gridIntervalMajor() );
798 mDistanceAxisMinorIntervalSpin->setValue( mProfile->plot()->xAxis().gridIntervalMinor() );
799 mDistanceAxisLabelIntervalSpin->setValue( mProfile->plot()->xAxis().labelInterval() );
800
801 mElevationAxisMajorIntervalSpin->setValue( mProfile->plot()->yAxis().gridIntervalMajor() );
802 mElevationAxisMinorIntervalSpin->setValue( mProfile->plot()->yAxis().gridIntervalMinor() );
803 mElevationAxisLabelIntervalSpin->setValue( mProfile->plot()->yAxis().labelInterval() );
804
805 if ( mProfile->plot()->chartBackgroundSymbol() )
806 mChartBackgroundSymbolButton->setSymbol( mProfile->plot()->chartBackgroundSymbol()->clone() );
807 if ( mProfile->plot()->chartBorderSymbol() )
808 mChartBorderSymbolButton->setSymbol( mProfile->plot()->chartBorderSymbol()->clone() );
809
810 mSpinLeftMargin->setValue( mProfile->plot()->margins().left() );
811 mSpinRightMargin->setValue( mProfile->plot()->margins().right() );
812 mSpinTopMargin->setValue( mProfile->plot()->margins().top() );
813 mSpinBottomMargin->setValue( mProfile->plot()->margins().bottom() );
814
815 syncLayerTreeAndProfileItemSources();
816
817 updateDataDefinedButton( mDDBtnTolerance );
818 updateDataDefinedButton( mDDBtnMinDistance );
819 updateDataDefinedButton( mDDBtnMaxDistance );
820 updateDataDefinedButton( mDDBtnMinElevation );
821 updateDataDefinedButton( mDDBtnMaxElevation );
822 updateDataDefinedButton( mDDBtnDistanceMajorInterval );
823 updateDataDefinedButton( mDDBtnDistanceMinorInterval );
824 updateDataDefinedButton( mDDBtnDistanceLabelInterval );
825 updateDataDefinedButton( mDDBtnElevationMajorInterval );
826 updateDataDefinedButton( mDDBtnElevationMinorInterval );
827 updateDataDefinedButton( mDDBtnElevationLabelInterval );
828 updateDataDefinedButton( mDDBtnLeftMargin );
829 updateDataDefinedButton( mDDBtnRightMargin );
830 updateDataDefinedButton( mDDBtnTopMargin );
831 updateDataDefinedButton( mDDBtnBottomMargin );
832
833 mBlockChanges--;
834}
835
836void QgsLayoutElevationProfileWidget::updateItemSources()
837{
838 if ( mBlockChanges )
839 return;
840
841 QList<QgsMapLayer *> layers;
842 QList<QgsAbstractProfileSource *> sources;
843 const QList<QgsLayerTreeNode *> layerAndCustomNodeOrder = mLayerTree->layerAndCustomNodeOrder();
844 for ( QgsLayerTreeNode *node : layerAndCustomNodeOrder )
845 {
846 if ( QgsLayerTree::isLayer( node ) )
847 {
848 QgsMapLayer *layer = QgsLayerTree::toLayer( node )->layer();
849 if ( mLayerTree->findLayer( layer )->isVisible() )
850 {
851 layers << layer;
852 sources << layer->profileSource();
853 }
854 }
855 else if ( QgsLayerTree::isCustomNode( node ) && node->customProperty( u"source"_s ) == QgsElevationProfileLayerTreeView::CUSTOM_NODE_ELEVATION_PROFILE_SOURCE )
856 {
857 QgsLayerTreeCustomNode *customNode = QgsLayerTree::toCustomNode( node );
858 if ( mLayerTree->findCustomNode( customNode->nodeId() )->isVisible() )
859 {
860 if ( QgsAbstractProfileSource *customSource = QgsApplication::profileSourceRegistry()->findSourceById( customNode->nodeId() ) )
861 {
862 sources << customSource;
863 }
864 }
865 }
866 }
867
868 // Legacy: layer tree layers are in opposite direction to what the elevation profile requires
869 std::reverse( layers.begin(), layers.end() );
870 mProfile->setLayers( layers );
871
872 mProfile->setSources( sources );
873 mProfile->update();
874}
875
876void QgsLayoutElevationProfileWidget::layoutAtlasToggled( bool atlasEnabled )
877{
878 if ( atlasEnabled && mProfile && mProfile->layout() && mProfile->layout()->reportContext().layer() && mProfile->layout()->reportContext().layer()->geometryType() == Qgis::GeometryType::Line )
879 {
880 mCheckControlledByAtlas->setEnabled( true );
881 }
882 else
883 {
884 mCheckControlledByAtlas->setEnabled( false );
885 mCheckControlledByAtlas->setChecked( false );
886 }
887}
888
889void QgsLayoutElevationProfileWidget::atlasLayerChanged( QgsVectorLayer *layer )
890{
891 if ( !layer || layer->geometryType() != Qgis::GeometryType::Line )
892 {
893 //non-line layer, disable atlas control
894 mCheckControlledByAtlas->setChecked( false );
895 mCheckControlledByAtlas->setEnabled( false );
896 return;
897 }
898 else
899 {
900 mCheckControlledByAtlas->setEnabled( true );
901 }
902}
PlotAxisSuffixPlacement
Placement options for suffixes in the labels for axis of plots.
Definition qgis.h:3432
@ FirstAndLastLabels
Place suffix after the first and last label values only.
Definition qgis.h:3437
@ EveryLabel
Place suffix after every value label.
Definition qgis.h:3434
@ FirstLabel
Place suffix after the first label value only.
Definition qgis.h:3435
@ LastLabel
Place suffix after the last label value only.
Definition qgis.h:3436
@ NoLabels
Do not place suffixes.
Definition qgis.h:3433
DistanceUnit
Units of distance.
Definition qgis.h:5170
@ Feet
Imperial feet.
Definition qgis.h:5173
@ Centimeters
Centimeters.
Definition qgis.h:5178
@ Millimeters
Millimeters.
Definition qgis.h:5179
@ Miles
Terrestrial miles.
Definition qgis.h:5176
@ Meters
Meters.
Definition qgis.h:5171
@ Yards
Imperial yards.
Definition qgis.h:5175
@ Degrees
Degrees, for planar geographic CRS distance measurements.
Definition qgis.h:5177
@ Inches
Inches.
Definition qgis.h:5180
@ NauticalMiles
Nautical miles.
Definition qgis.h:5174
@ Kilometers
Kilometers.
Definition qgis.h:5172
@ TitleCase
Simple title case conversion - does not fully grammatically parse the text and uses simple rules only...
Definition qgis.h:3509
@ Line
Lines.
Definition qgis.h:381
@ Line
Line symbol.
Definition qgis.h:638
@ Fill
Fill symbol.
Definition qgis.h:639
double yMaximum() const
Returns the maximum value of the y axis.
Definition qgsplot.h:769
double xMinimum() const
Returns the minimum value of the x axis.
Definition qgsplot.h:727
QgsPlotAxis & yAxis()
Returns a reference to the plot's y axis.
Definition qgsplot.h:797
QgsPlotAxis & xAxis()
Returns a reference to the plot's x axis.
Definition qgsplot.h:783
double yMinimum() const
Returns the minimum value of the y axis.
Definition qgsplot.h:741
double xMaximum() const
Returns the maximum value of the x axis.
Definition qgsplot.h:755
Interface for classes which can generate elevation profiles.
virtual QString profileSourceId() const
Returns a unique identifier for this profile source.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsProfileSourceRegistry * profileSourceRegistry()
Returns registry of available profile source implementations.
Abstract base class for curved geometry type.
Definition qgscurve.h:36
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.
const Qgs2DXyPlot & plot() const
Returns a reference to the 2D plot used by the widget.
QList< QgsMapLayer * > layers() const
Returns the list of layers included in the profile.
Qgis::DistanceUnit distanceUnit() const
Returns the distance unit used by the canvas.
double tolerance() const
Returns the tolerance of the profile (in crs() units).
QList< QgsAbstractProfileSource * > sources() const
Returns the list of sources included in the profile.
QgsLineSymbol * subsectionsSymbol()
Returns the symbol used to draw the subsections.
A layer tree view for elevation profiles.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
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:284
static QgsGui::HigFlags higFlags()
Returns the platform's HIG flags.
Definition qgsgui.cpp:253
QString nodeId() const
Returns the node's unique identifier.
Layer tree node points to a map layer.
QgsMapLayer * layer() const
Returns the map layer associated with this node.
Base class for nodes in a layer tree.
void visibilityChanged(QgsLayerTreeNode *node)
Emitted when check state of a node within the tree has been changed.
Listens to layer changes from a QgsProject and applies changes to a QgsLayerTree.
Namespace with helper functions for layer tree operations.
static QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer.
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
void layerOrderChanged()
Emitted when the layer order has changed.
static bool isCustomNode(const QgsLayerTreeNode *node)
Check whether the node is a valid custom node.
static QgsLayerTreeCustomNode * toCustomNode(QgsLayerTreeNode *node)
Cast node to a custom node.
Used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.
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.
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.
static std::function< void(QgsLayoutElevationProfileWidget *, QMenu *)> sBuildCopyMenuFunction
QgsLayoutElevationProfileWidget(QgsLayoutItemElevationProfile *profile)
constructor
void setDesignerInterface(QgsLayoutDesignerInterface *iface) override
Sets the the layout designer interface in which the widget is being shown.
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).
QgsLayoutItemBaseWidget(QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject)
Constructor for QgsLayoutItemBaseWidget, linked with the specified layoutObject.
A layout item subclass for elevation profile plots.
A widget for controlling the common properties of layout items (e.g.
@ 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.
@ UndoElevationProfileSubsectionLines
Change elevation profile subsection indicator symbol.
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.
QgsLineSymbol * clone() const override
Returns a deep copy of this symbol.
Base class for all map layer types.
Definition qgsmaplayer.h:83
virtual QgsAbstractProfileSource * profileSource()
Returns the layer's profile source if it has profile capabilities.
Defines the four margins of a rectangle.
Definition qgsmargins.h:40
void setBottom(double bottom)
Sets the bottom margin to bottom.
Definition qgsmargins.h:112
void setLeft(double left)
Sets the left margin to left.
Definition qgsmargins.h:94
void setRight(double right)
Sets the right margin to right.
Definition qgsmargins.h:106
void setTop(double top)
Sets the top margin to top.
Definition qgsmargins.h:100
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:389
double gridIntervalMajor() const
Returns the interval of major grid lines for the axis.
Definition qgsplot.h:403
double labelInterval() const
Returns the interval of labels for the axis.
Definition qgsplot.h:417
Qgis::PlotAxisSuffixPlacement labelSuffixPlacement() const
Returns the placement for the axis label suffixes.
Definition qgsplot.cpp:205
static QgsFillSymbol * chartBorderSymbol()
Returns the default fill symbol to use for the chart area border.
Definition qgsplot.cpp:1407
static QgsLineSymbol * axisGridMinorSymbol()
Returns the default line symbol to use for axis minor grid lines.
Definition qgsplot.cpp:1394
static QgsFillSymbol * chartBackgroundSymbol()
Returns the default fill symbol to use for the chart area background fill.
Definition qgsplot.cpp:1401
static QgsLineSymbol * axisGridMajorSymbol()
Returns the default line symbol to use for axis major grid lines.
Definition qgsplot.cpp:1387
static std::unique_ptr< QgsLineSymbol > defaultSubSectionsSymbol()
Returns the default line symbol to use for subsections lines.
QgsAbstractProfileSource * findSourceById(const QString &sourceId) const
Finds a registered profile source by id.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:113
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 dataset.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
Single variable definition for use within a QgsExpressionContextScope.