51 mCopyFromDockMenu =
new QMenu(
this );
52 connect( mCopyFromDockMenu, &QMenu::aboutToShow,
this, [ = ]
57 connect( mActionRefresh, &QAction::triggered,
this, [ = ]
63 mProfile->invalidateCache();
67 QToolButton *copyFromDockButton =
new QToolButton();
68 copyFromDockButton->setAutoRaise(
true );
69 copyFromDockButton->setToolTip( tr(
"Copy From Profile" ) );
70 copyFromDockButton->setMenu( mCopyFromDockMenu );
71 copyFromDockButton->setPopupMode( QToolButton::InstantPopup );
74 mDockToolbar->addWidget( copyFromDockButton );
78 mainLayout->addWidget( mItemPropertiesWidget );
83 mSpinTolerance->setClearValue( 0 );
84 connect( mSpinTolerance, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
86 if ( !mProfile || mBlockChanges )
90 mProfile->setTolerance( value );
91 mProfile->invalidateCache();
93 mProfile->endCommand();
96 connect( mCheckControlledByAtlas, &QCheckBox::toggled,
this, [ = ]
98 if ( !mProfile || mBlockChanges )
101 mProfile->beginCommand( tr(
"Change Profile Atlas Control" ) );
102 mProfile->setAtlasDriven( mCheckControlledByAtlas->isChecked() );
103 mProfile->invalidateCache();
105 mProfile->endCommand();
108 mSpinMinDistance->setClearValue( 0 );
109 connect( mSpinMinDistance, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
111 if ( !mProfile || mBlockChanges )
115 mProfile->plot()->setXMinimum( value );
116 mProfile->invalidateCache();
118 mProfile->endCommand();
121 connect( mSpinMaxDistance, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
123 if ( !mProfile || mBlockChanges )
127 mProfile->plot()->setXMaximum( value );
128 mProfile->invalidateCache();
130 mProfile->endCommand();
133 mSpinMinElevation->setClearValue( 0 );
134 connect( mSpinMinElevation, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
136 if ( !mProfile || mBlockChanges )
140 mProfile->plot()->setYMinimum( value );
141 mProfile->invalidateCache();
143 mProfile->endCommand();
146 connect( mSpinMaxElevation, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
148 if ( !mProfile || mBlockChanges )
152 mProfile->plot()->setYMaximum( value );
153 mProfile->invalidateCache();
155 mProfile->endCommand();
161 if ( !mProfile || mBlockChanges )
165 mProfile->plot()->xAxis().setGridMajorSymbol( mDistanceAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
166 mProfile->invalidateCache();
168 mProfile->endCommand();
175 if ( !mProfile || mBlockChanges )
179 mProfile->plot()->xAxis().setGridMinorSymbol( mDistanceAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
180 mProfile->invalidateCache();
182 mProfile->endCommand();
186 connect( mDistanceAxisMajorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
188 if ( !mProfile || mBlockChanges )
192 mProfile->plot()->xAxis().setGridIntervalMajor( value );
193 mProfile->invalidateCache();
195 mProfile->endCommand();
198 connect( mDistanceAxisMinorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
200 if ( !mProfile || mBlockChanges )
204 mProfile->plot()->xAxis().setGridIntervalMinor( value );
205 mProfile->invalidateCache();
207 mProfile->endCommand();
210 connect( mDistanceAxisLabelIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
212 if ( !mProfile || mBlockChanges )
216 mProfile->plot()->xAxis().setLabelInterval( value );
217 mProfile->invalidateCache();
219 mProfile->endCommand();
225 if ( !mProfile || mBlockChanges )
229 mProfile->plot()->yAxis().setGridMajorSymbol( mElevationAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
230 mProfile->invalidateCache();
232 mProfile->endCommand();
239 if ( !mProfile || mBlockChanges )
243 mProfile->plot()->yAxis().setGridMinorSymbol( mElevationAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
244 mProfile->invalidateCache();
246 mProfile->endCommand();
250 connect( mElevationAxisLabelIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
252 if ( !mProfile || mBlockChanges )
256 mProfile->plot()->yAxis().setLabelInterval( value );
257 mProfile->invalidateCache();
259 mProfile->endCommand();
262 connect( mElevationAxisMajorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
264 if ( !mProfile || mBlockChanges )
268 mProfile->plot()->yAxis().setGridIntervalMajor( value );
269 mProfile->invalidateCache();
271 mProfile->endCommand();
274 connect( mElevationAxisMinorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
276 if ( !mProfile || mBlockChanges )
280 mProfile->plot()->yAxis().setGridIntervalMinor( value );
281 mProfile->invalidateCache();
283 mProfile->endCommand();
289 if ( !mProfile || mBlockChanges )
293 mProfile->plot()->setChartBackgroundSymbol( mChartBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
294 mProfile->invalidateCache();
296 mProfile->endCommand();
303 if ( !mProfile || mBlockChanges )
307 mProfile->plot()->setChartBorderSymbol( mChartBorderSymbolButton->clonedSymbol<
QgsFillSymbol>() );
308 mProfile->invalidateCache();
310 mProfile->endCommand();
314 connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked,
this, [ = ]
316 if ( !mProfile || mBlockChanges )
321 widget->
setFormat( mProfile->plot()->xAxis().numericFormat() );
325 mProfile->plot()->xAxis().setNumericFormat( widget->
format() );
326 mProfile->invalidateCache();
327 mProfile->endCommand();
333 connect( mElevationAxisLabelFormatButton, &QPushButton::clicked,
this, [ = ]
335 if ( !mProfile || mBlockChanges )
340 widget->
setFormat( mProfile->plot()->yAxis().numericFormat() );
344 mProfile->plot()->yAxis().setNumericFormat( widget->
format() );
345 mProfile->invalidateCache();
346 mProfile->endCommand();
352 mDistanceAxisLabelFontButton->setDialogTitle( tr(
"Distance Label Font" ) );
353 mElevationAxisLabelFontButton->setDialogTitle( tr(
"Elevation Label Font" ) );
359 if ( !mProfile || mBlockChanges )
363 mProfile->plot()->xAxis().setTextFormat( mDistanceAxisLabelFontButton->textFormat() );
364 mProfile->invalidateCache();
365 mProfile->endCommand();
371 if ( !mProfile || mBlockChanges )
375 mProfile->plot()->yAxis().setTextFormat( mElevationAxisLabelFontButton->textFormat() );
376 mProfile->invalidateCache();
377 mProfile->endCommand();
381 mSpinLeftMargin->setClearValue( 0 );
382 connect( mSpinLeftMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
384 if ( !mProfile || mBlockChanges )
388 QgsMargins margins = mProfile->plot()->margins();
390 mProfile->plot()->setMargins( margins );
391 mProfile->invalidateCache();
393 mProfile->endCommand();
396 mSpinRightMargin->setClearValue( 0 );
397 connect( mSpinRightMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
399 if ( !mProfile || mBlockChanges )
403 QgsMargins margins = mProfile->plot()->margins();
405 mProfile->plot()->setMargins( margins );
406 mProfile->invalidateCache();
408 mProfile->endCommand();
411 mSpinTopMargin->setClearValue( 0 );
412 connect( mSpinTopMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
414 if ( !mProfile || mBlockChanges )
418 QgsMargins margins = mProfile->plot()->margins();
420 mProfile->plot()->setMargins( margins );
421 mProfile->invalidateCache();
423 mProfile->endCommand();
426 mSpinBottomMargin->setClearValue( 0 );
427 connect( mSpinBottomMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
429 if ( !mProfile || mBlockChanges )
433 QgsMargins margins = mProfile->plot()->margins();
435 mProfile->plot()->setMargins( margins );
436 mProfile->invalidateCache();
438 mProfile->endCommand();
464 mDistanceUnitCombo->addItem( title, QVariant::fromValue( unit ) );
467 connect( mDistanceUnitCombo, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
469 if ( !mProfile || mBlockChanges )
472 mProfile->beginCommand( tr(
"Change Profile Chart Units" ) );
473 mProfile->setDistanceUnit( mDistanceUnitCombo->currentData().value<
Qgis::DistanceUnit >() );
474 mProfile->invalidateCache();
476 mProfile->endCommand();
484 connect( mDistanceLabelsCombo, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
486 if ( !mProfile || mBlockChanges )
489 mProfile->beginCommand( tr(
"Change Profile Chart Label Placement" ) );
491 mProfile->invalidateCache();
493 mProfile->endCommand();
515 QVBoxLayout *vl =
new QVBoxLayout();
516 vl->setContentsMargins( 0, 0, 0, 0 );
517 vl->addWidget( mLayerTreeView );
518 mTreeViewContainer->setLayout( vl );
524 setGuiElementValues();
526 mDistanceAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
527 mDistanceAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
528 mElevationAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
529 mElevationAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
530 mChartBackgroundSymbolButton->registerExpressionContextGenerator( mProfile );
531 mChartBorderSymbolButton->registerExpressionContextGenerator( mProfile );
532 mDistanceAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
533 mElevationAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
535 mDistanceAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
536 mDistanceAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
537 mElevationAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
538 mElevationAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
544 if ( mProfile->layout() )
548 mDistanceAxisMajorLinesSymbolButton->setLayer( layer );
549 mDistanceAxisMinorLinesSymbolButton->setLayer( layer );
550 mElevationAxisMajorLinesSymbolButton->setLayer( layer );
551 mElevationAxisMinorLinesSymbolButton->setLayer( layer );
552 mDistanceAxisLabelFontButton->setLayer( layer );
553 mElevationAxisLabelFontButton->setLayer( layer );
554 mChartBackgroundSymbolButton->setLayer( layer );
555 mChartBorderSymbolButton->setLayer( layer );
559 this, &QgsLayoutElevationProfileWidget::atlasLayerChanged );
565 layoutAtlasToggled( atlas->enabled() );