52 mCopyFromDockMenu =
new QMenu(
this );
53 connect( mCopyFromDockMenu, &QMenu::aboutToShow,
this, [ = ]
58 connect( mActionRefresh, &QAction::triggered,
this, [ = ]
64 mProfile->invalidateCache();
68 QToolButton *copyFromDockButton =
new QToolButton();
69 copyFromDockButton->setAutoRaise(
true );
70 copyFromDockButton->setToolTip( tr(
"Copy From Profile" ) );
71 copyFromDockButton->setMenu( mCopyFromDockMenu );
72 copyFromDockButton->setPopupMode( QToolButton::InstantPopup );
75 mDockToolbar->addWidget( copyFromDockButton );
79 mainLayout->addWidget( mItemPropertiesWidget );
84 mSpinTolerance->setClearValue( 0 );
85 connect( mSpinTolerance, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
87 if ( !mProfile || mBlockChanges )
91 mProfile->setTolerance( value );
92 mProfile->invalidateCache();
94 mProfile->endCommand();
97 connect( mCheckControlledByAtlas, &QCheckBox::toggled,
this, [ = ]
99 if ( !mProfile || mBlockChanges )
102 mProfile->beginCommand( tr(
"Change Profile Atlas Control" ) );
103 mProfile->setAtlasDriven( mCheckControlledByAtlas->isChecked() );
104 mProfile->invalidateCache();
106 mProfile->endCommand();
109 mSpinMinDistance->setClearValue( 0 );
110 connect( mSpinMinDistance, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
112 if ( !mProfile || mBlockChanges )
116 mProfile->plot()->setXMinimum( value );
117 mProfile->invalidateCache();
119 mProfile->endCommand();
122 connect( mSpinMaxDistance, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
124 if ( !mProfile || mBlockChanges )
128 mProfile->plot()->setXMaximum( value );
129 mProfile->invalidateCache();
131 mProfile->endCommand();
134 mSpinMinElevation->setClearValue( 0 );
135 connect( mSpinMinElevation, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
137 if ( !mProfile || mBlockChanges )
141 mProfile->plot()->setYMinimum( value );
142 mProfile->invalidateCache();
144 mProfile->endCommand();
147 connect( mSpinMaxElevation, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
149 if ( !mProfile || mBlockChanges )
153 mProfile->plot()->setYMaximum( value );
154 mProfile->invalidateCache();
156 mProfile->endCommand();
162 if ( !mProfile || mBlockChanges )
166 mProfile->plot()->xAxis().setGridMajorSymbol( mDistanceAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
167 mProfile->invalidateCache();
169 mProfile->endCommand();
176 if ( !mProfile || mBlockChanges )
180 mProfile->plot()->xAxis().setGridMinorSymbol( mDistanceAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
181 mProfile->invalidateCache();
183 mProfile->endCommand();
187 connect( mDistanceAxisMajorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
189 if ( !mProfile || mBlockChanges )
193 mProfile->plot()->xAxis().setGridIntervalMajor( value );
194 mProfile->invalidateCache();
196 mProfile->endCommand();
199 connect( mDistanceAxisMinorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
201 if ( !mProfile || mBlockChanges )
205 mProfile->plot()->xAxis().setGridIntervalMinor( value );
206 mProfile->invalidateCache();
208 mProfile->endCommand();
211 connect( mDistanceAxisLabelIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
213 if ( !mProfile || mBlockChanges )
217 mProfile->plot()->xAxis().setLabelInterval( value );
218 mProfile->invalidateCache();
220 mProfile->endCommand();
226 if ( !mProfile || mBlockChanges )
230 mProfile->plot()->yAxis().setGridMajorSymbol( mElevationAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
231 mProfile->invalidateCache();
233 mProfile->endCommand();
240 if ( !mProfile || mBlockChanges )
244 mProfile->plot()->yAxis().setGridMinorSymbol( mElevationAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
245 mProfile->invalidateCache();
247 mProfile->endCommand();
251 connect( mElevationAxisLabelIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
253 if ( !mProfile || mBlockChanges )
257 mProfile->plot()->yAxis().setLabelInterval( value );
258 mProfile->invalidateCache();
260 mProfile->endCommand();
263 connect( mElevationAxisMajorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
265 if ( !mProfile || mBlockChanges )
269 mProfile->plot()->yAxis().setGridIntervalMajor( value );
270 mProfile->invalidateCache();
272 mProfile->endCommand();
275 connect( mElevationAxisMinorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
277 if ( !mProfile || mBlockChanges )
281 mProfile->plot()->yAxis().setGridIntervalMinor( value );
282 mProfile->invalidateCache();
284 mProfile->endCommand();
290 if ( !mProfile || mBlockChanges )
294 mProfile->plot()->setChartBackgroundSymbol( mChartBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
295 mProfile->invalidateCache();
297 mProfile->endCommand();
304 if ( !mProfile || mBlockChanges )
308 mProfile->plot()->setChartBorderSymbol( mChartBorderSymbolButton->clonedSymbol<
QgsFillSymbol>() );
309 mProfile->invalidateCache();
311 mProfile->endCommand();
315 connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked,
this, [ = ]
317 if ( !mProfile || mBlockChanges )
322 widget->
setFormat( mProfile->plot()->xAxis().numericFormat() );
326 mProfile->plot()->xAxis().setNumericFormat( widget->
format() );
327 mProfile->invalidateCache();
328 mProfile->endCommand();
334 connect( mElevationAxisLabelFormatButton, &QPushButton::clicked,
this, [ = ]
336 if ( !mProfile || mBlockChanges )
341 widget->
setFormat( mProfile->plot()->yAxis().numericFormat() );
345 mProfile->plot()->yAxis().setNumericFormat( widget->
format() );
346 mProfile->invalidateCache();
347 mProfile->endCommand();
353 mDistanceAxisLabelFontButton->setDialogTitle( tr(
"Distance Label Font" ) );
354 mElevationAxisLabelFontButton->setDialogTitle( tr(
"Elevation Label Font" ) );
360 if ( !mProfile || mBlockChanges )
364 mProfile->plot()->xAxis().setTextFormat( mDistanceAxisLabelFontButton->textFormat() );
365 mProfile->invalidateCache();
366 mProfile->endCommand();
372 if ( !mProfile || mBlockChanges )
376 mProfile->plot()->yAxis().setTextFormat( mElevationAxisLabelFontButton->textFormat() );
377 mProfile->invalidateCache();
378 mProfile->endCommand();
382 mSpinLeftMargin->setClearValue( 0 );
383 connect( mSpinLeftMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
385 if ( !mProfile || mBlockChanges )
389 QgsMargins margins = mProfile->plot()->margins();
391 mProfile->plot()->setMargins( margins );
392 mProfile->invalidateCache();
394 mProfile->endCommand();
397 mSpinRightMargin->setClearValue( 0 );
398 connect( mSpinRightMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
400 if ( !mProfile || mBlockChanges )
404 QgsMargins margins = mProfile->plot()->margins();
406 mProfile->plot()->setMargins( margins );
407 mProfile->invalidateCache();
409 mProfile->endCommand();
412 mSpinTopMargin->setClearValue( 0 );
413 connect( mSpinTopMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
415 if ( !mProfile || mBlockChanges )
419 QgsMargins margins = mProfile->plot()->margins();
421 mProfile->plot()->setMargins( margins );
422 mProfile->invalidateCache();
424 mProfile->endCommand();
427 mSpinBottomMargin->setClearValue( 0 );
428 connect( mSpinBottomMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
430 if ( !mProfile || mBlockChanges )
434 QgsMargins margins = mProfile->plot()->margins();
436 mProfile->plot()->setMargins( margins );
437 mProfile->invalidateCache();
439 mProfile->endCommand();
465 mDistanceUnitCombo->addItem( title, QVariant::fromValue( unit ) );
468 connect( mDistanceUnitCombo, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
470 if ( !mProfile || mBlockChanges )
473 mProfile->beginCommand( tr(
"Change Profile Chart Units" ) );
474 mProfile->setDistanceUnit( mDistanceUnitCombo->currentData().value<
Qgis::DistanceUnit >() );
475 mProfile->invalidateCache();
477 mProfile->endCommand();
485 connect( mDistanceLabelsCombo, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
487 if ( !mProfile || mBlockChanges )
490 mProfile->beginCommand( tr(
"Change Profile Chart Label Placement" ) );
492 mProfile->invalidateCache();
494 mProfile->endCommand();
516 QVBoxLayout *vl =
new QVBoxLayout();
517 vl->setContentsMargins( 0, 0, 0, 0 );
518 vl->addWidget( mLayerTreeView );
519 mTreeViewContainer->setLayout( vl );
525 setGuiElementValues();
527 mDistanceAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
528 mDistanceAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
529 mElevationAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
530 mElevationAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
531 mChartBackgroundSymbolButton->registerExpressionContextGenerator( mProfile );
532 mChartBorderSymbolButton->registerExpressionContextGenerator( mProfile );
533 mDistanceAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
534 mElevationAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
536 mDistanceAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
537 mDistanceAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
538 mElevationAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
539 mElevationAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
545 if ( mProfile->layout() )
549 mDistanceAxisMajorLinesSymbolButton->setLayer( layer );
550 mDistanceAxisMinorLinesSymbolButton->setLayer( layer );
551 mElevationAxisMajorLinesSymbolButton->setLayer( layer );
552 mElevationAxisMinorLinesSymbolButton->setLayer( layer );
553 mDistanceAxisLabelFontButton->setLayer( layer );
554 mElevationAxisLabelFontButton->setLayer( layer );
555 mChartBackgroundSymbolButton->setLayer( layer );
556 mChartBorderSymbolButton->setLayer( layer );
560 this, &QgsLayoutElevationProfileWidget::atlasLayerChanged );
566 layoutAtlasToggled( atlas->enabled() );