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