QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
42#include "moc_qgslayoutelevationprofilewidget.cpp"
43
45
47 : QgsLayoutItemBaseWidget( nullptr, profile )
48 , mProfile( profile )
49 , mLayerTree( new QgsLayerTree() )
50 , mLayerTreeBridge( new QgsLayerTreeRegistryBridge( mLayerTree.get(), mProfile->layout() ? mProfile->layout()->project() : QgsProject::instance(), this ) )
51{
52 Q_ASSERT( mProfile );
53
54 setupUi( this );
55 setPanelTitle( tr( "Elevation Profile Properties" ) );
56
57 mCopyFromDockMenu = new QMenu( this );
58 connect( mCopyFromDockMenu, &QMenu::aboutToShow, this, [this] {
59 sBuildCopyMenuFunction( this, mCopyFromDockMenu );
60 } );
61
62 connect( mActionRefresh, &QAction::triggered, this, [this] {
63 if ( !mProfile )
64 {
65 return;
66 }
67 mProfile->invalidateCache();
68 mProfile->refresh();
69 } );
70
71 QToolButton *copyFromDockButton = new QToolButton();
72 copyFromDockButton->setAutoRaise( true );
73 copyFromDockButton->setToolTip( tr( "Copy From Profile" ) );
74 copyFromDockButton->setMenu( mCopyFromDockMenu );
75 copyFromDockButton->setPopupMode( QToolButton::InstantPopup );
76 copyFromDockButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionCopyProfileSettings.svg" ) ) );
77
78 mDockToolbar->addWidget( copyFromDockButton );
79
80 //add widget for general composer item properties
81 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, profile );
82 mainLayout->addWidget( mItemPropertiesWidget );
83
84 connect( mLayerTree.get(), &QgsLayerTree::layerOrderChanged, this, &QgsLayoutElevationProfileWidget::updateItemSources );
85 connect( mLayerTree.get(), &QgsLayerTreeGroup::visibilityChanged, this, &QgsLayoutElevationProfileWidget::updateItemSources );
86
87 mSpinTolerance->setClearValue( 0 );
88 connect( mSpinTolerance, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
89 if ( !mProfile || mBlockChanges )
90 return;
91
92 mProfile->beginCommand( tr( "Change Profile Tolerance Distance" ), QgsLayoutItem::UndoElevationProfileTolerance );
93 mProfile->setTolerance( value );
94 mProfile->invalidateCache();
95 mProfile->update();
96 mProfile->endCommand();
97 } );
98
99 connect( mCheckControlledByAtlas, &QCheckBox::toggled, this, [this] {
100 if ( !mProfile || mBlockChanges )
101 return;
102
103 mProfile->beginCommand( tr( "Change Profile Atlas Control" ) );
104 mProfile->setAtlasDriven( mCheckControlledByAtlas->isChecked() );
105 mProfile->invalidateCache();
106 mProfile->update();
107 mProfile->endCommand();
108 } );
109
110 // subsections indicator
111 mSubsectionsSymbolButton->setSymbolType( Qgis::SymbolType::Line );
112 connect( mSubsectionsSymbolButton, &QgsSymbolButton::changed, this, [this] {
113 if ( !mProfile || mBlockChanges )
114 return;
115
116 mProfile->beginCommand( tr( "Change Profile Subsection Indicator" ), QgsLayoutItem::UndoElevationProfileSubsectionLines );
117 mProfile->setSubsectionsSymbol( mSubsectionsSymbolButton->clonedSymbol<QgsLineSymbol>() );
118 mProfile->invalidateCache();
119 mProfile->update();
120 mProfile->endCommand();
121 } );
122 mSubsectionsSymbolButton->setDefaultSymbol( QgsProfilePlotRenderer::defaultSubSectionsSymbol().release() );
123
124 connect( mSubsectionsActivateCheck, &QGroupBox::toggled, this, [this] {
125 if ( !mProfile || mBlockChanges )
126 return;
127
128 const bool subsectionsActivated = mSubsectionsActivateCheck->isChecked();
129 mProfile->beginCommand( tr( "Change Profile Subsection Indicator" ), QgsLayoutItem::UndoElevationProfileSubsectionLines );
130 std::unique_ptr<QgsLineSymbol> subSectionsSymbol( subsectionsActivated ? mSubsectionsSymbolButton->clonedSymbol<QgsLineSymbol>() : nullptr );
131 mProfile->setSubsectionsSymbol( subSectionsSymbol.release() );
132
133 mProfile->invalidateCache();
134 mProfile->update();
135 mProfile->endCommand();
136 } );
137
138 mSpinMinDistance->setClearValue( 0 );
139 connect( mSpinMinDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
140 if ( !mProfile || mBlockChanges )
141 return;
142
143 mProfile->beginCommand( tr( "Change Profile Chart Minimum Distance" ), QgsLayoutItem::UndoElevationProfileMinimumDistance );
144 mProfile->plot()->setXMinimum( value );
145 mProfile->invalidateCache();
146 mProfile->update();
147 mProfile->endCommand();
148 } );
149
150 connect( mSpinMaxDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
151 if ( !mProfile || mBlockChanges )
152 return;
153
154 mProfile->beginCommand( tr( "Change Profile Chart Maximum Distance" ), QgsLayoutItem::UndoElevationProfileMaximumDistance );
155 mProfile->plot()->setXMaximum( value );
156 mProfile->invalidateCache();
157 mProfile->update();
158 mProfile->endCommand();
159 } );
160
161 mSpinMinElevation->setClearValue( 0 );
162 connect( mSpinMinElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
163 if ( !mProfile || mBlockChanges )
164 return;
165
166 mProfile->beginCommand( tr( "Change Profile Chart Minimum Elevation" ), QgsLayoutItem::UndoElevationProfileMinimumElevation );
167 mProfile->plot()->setYMinimum( value );
168 mProfile->invalidateCache();
169 mProfile->update();
170 mProfile->endCommand();
171 } );
172
173 connect( mSpinMaxElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
174 if ( !mProfile || mBlockChanges )
175 return;
176
177 mProfile->beginCommand( tr( "Change Profile Chart Maximum Elevation" ), QgsLayoutItem::UndoElevationProfileMaximumElevation );
178 mProfile->plot()->setYMaximum( value );
179 mProfile->invalidateCache();
180 mProfile->update();
181 mProfile->endCommand();
182 } );
183
184 mDistanceAxisMajorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
185 connect( mDistanceAxisMajorLinesSymbolButton, &QgsSymbolButton::changed, this, [this] {
186 if ( !mProfile || mBlockChanges )
187 return;
188
189 mProfile->beginCommand( tr( "Change Profile Chart Distance Major Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMajorGridlines );
190 mProfile->plot()->xAxis().setGridMajorSymbol( mDistanceAxisMajorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
191 mProfile->invalidateCache();
192 mProfile->update();
193 mProfile->endCommand();
194 } );
195 mDistanceAxisMajorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMajorSymbol() );
196
197 mDistanceAxisMinorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
198 connect( mDistanceAxisMinorLinesSymbolButton, &QgsSymbolButton::changed, this, [this] {
199 if ( !mProfile || mBlockChanges )
200 return;
201
202 mProfile->beginCommand( tr( "Change Profile Chart Distance Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMinorGridlines );
203 mProfile->plot()->xAxis().setGridMinorSymbol( mDistanceAxisMinorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
204 mProfile->invalidateCache();
205 mProfile->update();
206 mProfile->endCommand();
207 } );
208 mDistanceAxisMinorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMinorSymbol() );
209
210 connect( mDistanceAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
211 if ( !mProfile || mBlockChanges )
212 return;
213
214 mProfile->beginCommand( tr( "Change Profile Chart Distance Major Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMajorGridlines );
215 mProfile->plot()->xAxis().setGridIntervalMajor( value );
216 mProfile->invalidateCache();
217 mProfile->update();
218 mProfile->endCommand();
219 } );
220
221 connect( mDistanceAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
222 if ( !mProfile || mBlockChanges )
223 return;
224
225 mProfile->beginCommand( tr( "Change Profile Chart Distance Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileDistanceMinorGridlines );
226 mProfile->plot()->xAxis().setGridIntervalMinor( value );
227 mProfile->invalidateCache();
228 mProfile->update();
229 mProfile->endCommand();
230 } );
231
232 connect( mDistanceAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
233 if ( !mProfile || mBlockChanges )
234 return;
235
236 mProfile->beginCommand( tr( "Change Profile Chart Distance Label" ), QgsLayoutItem::UndoElevationProfileDistanceLabels );
237 mProfile->plot()->xAxis().setLabelInterval( value );
238 mProfile->invalidateCache();
239 mProfile->update();
240 mProfile->endCommand();
241 } );
242
243 mElevationAxisMajorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
244 connect( mElevationAxisMajorLinesSymbolButton, &QgsSymbolButton::changed, this, [this] {
245 if ( !mProfile || mBlockChanges )
246 return;
247
248 mProfile->beginCommand( tr( "Change Profile Chart Elevation Major Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMajorGridlines );
249 mProfile->plot()->yAxis().setGridMajorSymbol( mElevationAxisMajorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
250 mProfile->invalidateCache();
251 mProfile->update();
252 mProfile->endCommand();
253 } );
254 mElevationAxisMajorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMajorSymbol() );
255
256 mElevationAxisMinorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
257 connect( mElevationAxisMinorLinesSymbolButton, &QgsSymbolButton::changed, this, [this] {
258 if ( !mProfile || mBlockChanges )
259 return;
260
261 mProfile->beginCommand( tr( "Change Profile Chart Elevation Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMinorGridlines );
262 mProfile->plot()->yAxis().setGridMinorSymbol( mElevationAxisMinorLinesSymbolButton->clonedSymbol<QgsLineSymbol>() );
263 mProfile->invalidateCache();
264 mProfile->update();
265 mProfile->endCommand();
266 } );
267 mElevationAxisMinorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMinorSymbol() );
268
269 connect( mElevationAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
270 if ( !mProfile || mBlockChanges )
271 return;
272
273 mProfile->beginCommand( tr( "Change Profile Chart Elevation Label" ), QgsLayoutItem::UndoElevationProfileElevationLabels );
274 mProfile->plot()->yAxis().setLabelInterval( value );
275 mProfile->invalidateCache();
276 mProfile->update();
277 mProfile->endCommand();
278 } );
279
280 connect( mElevationAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
281 if ( !mProfile || mBlockChanges )
282 return;
283
284 mProfile->beginCommand( tr( "Change Profile Chart Elevation Major Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMajorGridlines );
285 mProfile->plot()->yAxis().setGridIntervalMajor( value );
286 mProfile->invalidateCache();
287 mProfile->update();
288 mProfile->endCommand();
289 } );
290
291 connect( mElevationAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
292 if ( !mProfile || mBlockChanges )
293 return;
294
295 mProfile->beginCommand( tr( "Change Profile Chart Distance Minor Gridlines" ), QgsLayoutItem::UndoElevationProfileElevationMinorGridlines );
296 mProfile->plot()->yAxis().setGridIntervalMinor( value );
297 mProfile->invalidateCache();
298 mProfile->update();
299 mProfile->endCommand();
300 } );
301
302 mChartBackgroundSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
303 connect( mChartBackgroundSymbolButton, &QgsSymbolButton::changed, this, [this] {
304 if ( !mProfile || mBlockChanges )
305 return;
306
307 mProfile->beginCommand( tr( "Change Profile Chart Background" ), QgsLayoutItem::UndoElevationProfileChartBackground );
308 mProfile->plot()->setChartBackgroundSymbol( mChartBackgroundSymbolButton->clonedSymbol<QgsFillSymbol>() );
309 mProfile->invalidateCache();
310 mProfile->update();
311 mProfile->endCommand();
312 } );
313 mChartBackgroundSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::chartBackgroundSymbol() );
314
315 mChartBorderSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
316 connect( mChartBorderSymbolButton, &QgsSymbolButton::changed, this, [this] {
317 if ( !mProfile || mBlockChanges )
318 return;
319
320 mProfile->beginCommand( tr( "Change Profile Chart Border" ), QgsLayoutItem::UndoElevationProfileChartBorder );
321 mProfile->plot()->setChartBorderSymbol( mChartBorderSymbolButton->clonedSymbol<QgsFillSymbol>() );
322 mProfile->invalidateCache();
323 mProfile->update();
324 mProfile->endCommand();
325 } );
326 mChartBorderSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::chartBorderSymbol() );
327
328 connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked, this, [this] {
329 if ( !mProfile || mBlockChanges )
330 return;
331
333 widget->setPanelTitle( tr( "Distance Number Format" ) );
334 widget->setFormat( mProfile->plot()->xAxis().numericFormat() );
335 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [this, widget] {
336 mProfile->beginCommand( tr( "Change Profile Chart Distance Format" ), QgsLayoutItem::UndoElevationProfileDistanceFormat );
337 mProfile->plot()->xAxis().setNumericFormat( widget->format() );
338 mProfile->invalidateCache();
339 mProfile->endCommand();
340 mProfile->update();
341 } );
342 openPanel( widget );
343 } );
344
345 connect( mElevationAxisLabelFormatButton, &QPushButton::clicked, this, [this] {
346 if ( !mProfile || mBlockChanges )
347 return;
348
350 widget->setPanelTitle( tr( "Elevation Number Format" ) );
351 widget->setFormat( mProfile->plot()->yAxis().numericFormat() );
352 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [this, widget] {
353 mProfile->beginCommand( tr( "Change Profile Chart Elevation Format" ), QgsLayoutItem::UndoElevationProfileElevationFormat );
354 mProfile->plot()->yAxis().setNumericFormat( widget->format() );
355 mProfile->invalidateCache();
356 mProfile->endCommand();
357 mProfile->update();
358 } );
359 openPanel( widget );
360 } );
361
362 mDistanceAxisLabelFontButton->setDialogTitle( tr( "Distance Label Font" ) );
363 mElevationAxisLabelFontButton->setDialogTitle( tr( "Elevation Label Font" ) );
364 mDistanceAxisLabelFontButton->setMode( QgsFontButton::ModeTextRenderer );
365 mElevationAxisLabelFontButton->setMode( QgsFontButton::ModeTextRenderer );
366
367 connect( mDistanceAxisLabelFontButton, &QgsFontButton::changed, this, [this] {
368 if ( !mProfile || mBlockChanges )
369 return;
370
371 mProfile->beginCommand( tr( "Change Profile Chart Distance Font" ), QgsLayoutItem::UndoElevationProfileDistanceFont );
372 mProfile->plot()->xAxis().setTextFormat( mDistanceAxisLabelFontButton->textFormat() );
373 mProfile->invalidateCache();
374 mProfile->endCommand();
375 mProfile->update();
376 } );
377
378 connect( mElevationAxisLabelFontButton, &QgsFontButton::changed, this, [this] {
379 if ( !mProfile || mBlockChanges )
380 return;
381
382 mProfile->beginCommand( tr( "Change Profile Chart Elevation Font" ), QgsLayoutItem::UndoElevationProfileElevationFont );
383 mProfile->plot()->yAxis().setTextFormat( mElevationAxisLabelFontButton->textFormat() );
384 mProfile->invalidateCache();
385 mProfile->endCommand();
386 mProfile->update();
387 } );
388
389 mSpinLeftMargin->setClearValue( 0 );
390 connect( mSpinLeftMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
391 if ( !mProfile || mBlockChanges )
392 return;
393
394 mProfile->beginCommand( tr( "Change Profile Chart Left Margin" ), QgsLayoutItem::UndoMarginLeft );
395 QgsMargins margins = mProfile->plot()->margins();
396 margins.setLeft( value );
397 mProfile->plot()->setMargins( margins );
398 mProfile->invalidateCache();
399 mProfile->update();
400 mProfile->endCommand();
401 } );
402
403 mSpinRightMargin->setClearValue( 0 );
404 connect( mSpinRightMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
405 if ( !mProfile || mBlockChanges )
406 return;
407
408 mProfile->beginCommand( tr( "Change Profile Chart Right Margin" ), QgsLayoutItem::UndoMarginRight );
409 QgsMargins margins = mProfile->plot()->margins();
410 margins.setRight( value );
411 mProfile->plot()->setMargins( margins );
412 mProfile->invalidateCache();
413 mProfile->update();
414 mProfile->endCommand();
415 } );
416
417 mSpinTopMargin->setClearValue( 0 );
418 connect( mSpinTopMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
419 if ( !mProfile || mBlockChanges )
420 return;
421
422 mProfile->beginCommand( tr( "Change Profile Chart Top Margin" ), QgsLayoutItem::UndoMarginTop );
423 QgsMargins margins = mProfile->plot()->margins();
424 margins.setTop( value );
425 mProfile->plot()->setMargins( margins );
426 mProfile->invalidateCache();
427 mProfile->update();
428 mProfile->endCommand();
429 } );
430
431 mSpinBottomMargin->setClearValue( 0 );
432 connect( mSpinBottomMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
433 if ( !mProfile || mBlockChanges )
434 return;
435
436 mProfile->beginCommand( tr( "Change Profile Chart Bottom Margin" ), QgsLayoutItem::UndoMarginBottom );
437 QgsMargins margins = mProfile->plot()->margins();
438 margins.setBottom( value );
439 mProfile->plot()->setMargins( margins );
440 mProfile->invalidateCache();
441 mProfile->update();
442 mProfile->endCommand();
443 } );
444
445 for ( Qgis::DistanceUnit unit :
446 {
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>( QStringLiteral( "plot" ) );
585 plotScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "plot_axis" ), QString(), true ) );
586 plotScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "plot_axis_value" ), 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( QStringLiteral( "source" ) ) == 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( QStringLiteral( "source" ) ) == 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()
879 && mProfile->layout()->reportContext().layer()->geometryType() == Qgis::GeometryType::Line )
880 {
881 mCheckControlledByAtlas->setEnabled( true );
882 }
883 else
884 {
885 mCheckControlledByAtlas->setEnabled( false );
886 mCheckControlledByAtlas->setChecked( false );
887 }
888}
889
890void QgsLayoutElevationProfileWidget::atlasLayerChanged( QgsVectorLayer *layer )
891{
892 if ( !layer || layer->geometryType() != Qgis::GeometryType::Line )
893 {
894 //non-line layer, disable atlas control
895 mCheckControlledByAtlas->setChecked( false );
896 mCheckControlledByAtlas->setEnabled( false );
897 return;
898 }
899 else
900 {
901 mCheckControlledByAtlas->setEnabled( true );
902 }
903}
PlotAxisSuffixPlacement
Placement options for suffixes in the labels for axis of plots.
Definition qgis.h:3318
@ FirstAndLastLabels
Place suffix after the first and last label values only.
Definition qgis.h:3323
@ EveryLabel
Place suffix after every value label.
Definition qgis.h:3320
@ FirstLabel
Place suffix after the first label value only.
Definition qgis.h:3321
@ LastLabel
Place suffix after the last label value only.
Definition qgis.h:3322
@ NoLabels
Do not place suffixes.
Definition qgis.h:3319
DistanceUnit
Units of distance.
Definition qgis.h:5013
@ Feet
Imperial feet.
Definition qgis.h:5016
@ Centimeters
Centimeters.
Definition qgis.h:5021
@ Millimeters
Millimeters.
Definition qgis.h:5022
@ Miles
Terrestrial miles.
Definition qgis.h:5019
@ Meters
Meters.
Definition qgis.h:5014
@ Yards
Imperial yards.
Definition qgis.h:5018
@ Degrees
Degrees, for planar geographic CRS distance measurements.
Definition qgis.h:5020
@ Inches
Inches.
Definition qgis.h:5023
@ NauticalMiles
Nautical miles.
Definition qgis.h:5017
@ Kilometers
Kilometers.
Definition qgis.h:5015
@ TitleCase
Simple title case conversion - does not fully grammatically parse the text and uses simple rules only...
Definition qgis.h:3395
@ Line
Lines.
Definition qgis.h:360
@ Line
Line symbol.
Definition qgis.h:612
@ Fill
Fill symbol.
Definition qgis.h:613
double yMaximum() const
Returns the maximum value of the y axis.
Definition qgsplot.h:742
double xMinimum() const
Returns the minimum value of the x axis.
Definition qgsplot.h:700
QgsPlotAxis & yAxis()
Returns a reference to the plot's y axis.
Definition qgsplot.h:770
QgsPlotAxis & xAxis()
Returns a reference to the plot's x axis.
Definition qgsplot.h:756
double yMinimum() const
Returns the minimum value of the y axis.
Definition qgsplot.h:714
double xMaximum() const
Returns the maximum value of the x axis.
Definition qgsplot.h:728
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:281
static QgsGui::HigFlags higFlags()
Returns the platform's HIG flags.
Definition qgsgui.cpp:250
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:80
virtual QgsAbstractProfileSource * profileSource()
Returns the layer's profile source if it has profile capabilities.
Defines the four margins of a rectangle.
Definition qgsmargins.h:38
void setBottom(double bottom)
Sets the bottom margin to bottom.
Definition qgsmargins.h:114
void setLeft(double left)
Sets the left margin to left.
Definition qgsmargins.h:96
void setRight(double right)
Sets the right margin to right.
Definition qgsmargins.h:108
void setTop(double top)
Sets the top margin to top.
Definition qgsmargins.h:102
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:184
static QgsFillSymbol * chartBorderSymbol()
Returns the default fill symbol to use for the chart area border.
Definition qgsplot.cpp:1190
static QgsLineSymbol * axisGridMinorSymbol()
Returns the default line symbol to use for axis minor grid lines.
Definition qgsplot.cpp:1177
static QgsFillSymbol * chartBackgroundSymbol()
Returns the default fill symbol to use for the chart area background fill.
Definition qgsplot.cpp:1184
static QgsLineSymbol * axisGridMajorSymbol()
Returns the default line symbol to use for axis major grid lines.
Definition qgsplot.cpp:1170
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:109
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.