53 mCopyFromDockMenu =
new QMenu(
this );
54 connect( mCopyFromDockMenu, &QMenu::aboutToShow,
this, [=] {
58 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 ) {
85 if ( !mProfile || mBlockChanges )
89 mProfile->setTolerance( value );
90 mProfile->invalidateCache();
92 mProfile->endCommand();
95 connect( mCheckControlledByAtlas, &QCheckBox::toggled,
this, [=] {
96 if ( !mProfile || mBlockChanges )
99 mProfile->beginCommand( tr(
"Change Profile Atlas Control" ) );
100 mProfile->setAtlasDriven( mCheckControlledByAtlas->isChecked() );
101 mProfile->invalidateCache();
103 mProfile->endCommand();
109 if ( !mProfile || mBlockChanges )
113 mProfile->setSubsectionsSymbol( mSubsectionsSymbolButton->clonedSymbol<
QgsLineSymbol>() );
114 mProfile->invalidateCache();
116 mProfile->endCommand();
120 connect( mSubsectionsActivateCheck, &QCheckBox::toggled,
this, [=] {
121 if ( !mProfile || mBlockChanges )
124 const bool subsectionsActivated = mSubsectionsActivateCheck->isChecked();
126 mSubsectionsSymbolButton->setEnabled( subsectionsActivated );
127 mSubsectionsSymbolLabel->setEnabled( subsectionsActivated );
128 std::unique_ptr<QgsLineSymbol> subSectionsSymbol( subsectionsActivated ? mSubsectionsSymbolButton->clonedSymbol<
QgsLineSymbol>() : nullptr );
129 mProfile->setSubsectionsSymbol( subSectionsSymbol.release() );
131 mProfile->invalidateCache();
133 mProfile->endCommand();
136 mSpinMinDistance->setClearValue( 0 );
137 connect( mSpinMinDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
138 if ( !mProfile || mBlockChanges )
142 mProfile->plot()->setXMinimum( value );
143 mProfile->invalidateCache();
145 mProfile->endCommand();
148 connect( mSpinMaxDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
149 if ( !mProfile || mBlockChanges )
153 mProfile->plot()->setXMaximum( value );
154 mProfile->invalidateCache();
156 mProfile->endCommand();
159 mSpinMinElevation->setClearValue( 0 );
160 connect( mSpinMinElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
161 if ( !mProfile || mBlockChanges )
165 mProfile->plot()->setYMinimum( value );
166 mProfile->invalidateCache();
168 mProfile->endCommand();
171 connect( mSpinMaxElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
172 if ( !mProfile || mBlockChanges )
176 mProfile->plot()->setYMaximum( value );
177 mProfile->invalidateCache();
179 mProfile->endCommand();
184 if ( !mProfile || mBlockChanges )
188 mProfile->plot()->xAxis().setGridMajorSymbol( mDistanceAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
189 mProfile->invalidateCache();
191 mProfile->endCommand();
197 if ( !mProfile || mBlockChanges )
201 mProfile->plot()->xAxis().setGridMinorSymbol( mDistanceAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
202 mProfile->invalidateCache();
204 mProfile->endCommand();
208 connect( mDistanceAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
209 if ( !mProfile || mBlockChanges )
213 mProfile->plot()->xAxis().setGridIntervalMajor( value );
214 mProfile->invalidateCache();
216 mProfile->endCommand();
219 connect( mDistanceAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
220 if ( !mProfile || mBlockChanges )
224 mProfile->plot()->xAxis().setGridIntervalMinor( value );
225 mProfile->invalidateCache();
227 mProfile->endCommand();
230 connect( mDistanceAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
231 if ( !mProfile || mBlockChanges )
235 mProfile->plot()->xAxis().setLabelInterval( value );
236 mProfile->invalidateCache();
238 mProfile->endCommand();
243 if ( !mProfile || mBlockChanges )
247 mProfile->plot()->yAxis().setGridMajorSymbol( mElevationAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
248 mProfile->invalidateCache();
250 mProfile->endCommand();
256 if ( !mProfile || mBlockChanges )
260 mProfile->plot()->yAxis().setGridMinorSymbol( mElevationAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
261 mProfile->invalidateCache();
263 mProfile->endCommand();
267 connect( mElevationAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
268 if ( !mProfile || mBlockChanges )
272 mProfile->plot()->yAxis().setLabelInterval( value );
273 mProfile->invalidateCache();
275 mProfile->endCommand();
278 connect( mElevationAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
279 if ( !mProfile || mBlockChanges )
283 mProfile->plot()->yAxis().setGridIntervalMajor( value );
284 mProfile->invalidateCache();
286 mProfile->endCommand();
289 connect( mElevationAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
290 if ( !mProfile || mBlockChanges )
294 mProfile->plot()->yAxis().setGridIntervalMinor( value );
295 mProfile->invalidateCache();
297 mProfile->endCommand();
302 if ( !mProfile || mBlockChanges )
306 mProfile->plot()->setChartBackgroundSymbol( mChartBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
307 mProfile->invalidateCache();
309 mProfile->endCommand();
315 if ( !mProfile || mBlockChanges )
319 mProfile->plot()->setChartBorderSymbol( mChartBorderSymbolButton->clonedSymbol<
QgsFillSymbol>() );
320 mProfile->invalidateCache();
322 mProfile->endCommand();
326 connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked,
this, [=] {
327 if ( !mProfile || mBlockChanges )
332 widget->
setFormat( mProfile->plot()->xAxis().numericFormat() );
335 mProfile->plot()->xAxis().setNumericFormat( widget->
format() );
336 mProfile->invalidateCache();
337 mProfile->endCommand();
343 connect( mElevationAxisLabelFormatButton, &QPushButton::clicked,
this, [=] {
344 if ( !mProfile || mBlockChanges )
349 widget->
setFormat( mProfile->plot()->yAxis().numericFormat() );
352 mProfile->plot()->yAxis().setNumericFormat( widget->
format() );
353 mProfile->invalidateCache();
354 mProfile->endCommand();
360 mDistanceAxisLabelFontButton->setDialogTitle( tr(
"Distance Label Font" ) );
361 mElevationAxisLabelFontButton->setDialogTitle( tr(
"Elevation Label Font" ) );
366 if ( !mProfile || mBlockChanges )
370 mProfile->plot()->xAxis().setTextFormat( mDistanceAxisLabelFontButton->textFormat() );
371 mProfile->invalidateCache();
372 mProfile->endCommand();
377 if ( !mProfile || mBlockChanges )
381 mProfile->plot()->yAxis().setTextFormat( mElevationAxisLabelFontButton->textFormat() );
382 mProfile->invalidateCache();
383 mProfile->endCommand();
387 mSpinLeftMargin->setClearValue( 0 );
388 connect( mSpinLeftMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
389 if ( !mProfile || mBlockChanges )
393 QgsMargins margins = mProfile->plot()->margins();
395 mProfile->plot()->setMargins( margins );
396 mProfile->invalidateCache();
398 mProfile->endCommand();
401 mSpinRightMargin->setClearValue( 0 );
402 connect( mSpinRightMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
403 if ( !mProfile || mBlockChanges )
407 QgsMargins margins = mProfile->plot()->margins();
409 mProfile->plot()->setMargins( margins );
410 mProfile->invalidateCache();
412 mProfile->endCommand();
415 mSpinTopMargin->setClearValue( 0 );
416 connect( mSpinTopMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
417 if ( !mProfile || mBlockChanges )
421 QgsMargins margins = mProfile->plot()->margins();
423 mProfile->plot()->setMargins( margins );
424 mProfile->invalidateCache();
426 mProfile->endCommand();
429 mSpinBottomMargin->setClearValue( 0 );
430 connect( mSpinBottomMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
431 if ( !mProfile || mBlockChanges )
435 QgsMargins margins = mProfile->plot()->margins();
437 mProfile->plot()->setMargins( margins );
438 mProfile->invalidateCache();
440 mProfile->endCommand();
466 mDistanceUnitCombo->addItem( title, QVariant::fromValue( unit ) );
469 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 ) {
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 mSubsectionsSymbolButton->registerExpressionContextGenerator( mProfile );
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 );
537 mDistanceAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
538 mDistanceAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
539 mElevationAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
540 mElevationAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
546 if ( mProfile->layout() )
549 mSubsectionsSymbolButton->setLayer( layer );
550 mDistanceAxisMajorLinesSymbolButton->setLayer( layer );
551 mDistanceAxisMinorLinesSymbolButton->setLayer( layer );
552 mElevationAxisMajorLinesSymbolButton->setLayer( layer );
553 mElevationAxisMinorLinesSymbolButton->setLayer( layer );
554 mDistanceAxisLabelFontButton->setLayer( layer );
555 mElevationAxisLabelFontButton->setLayer( layer );
556 mChartBackgroundSymbolButton->setLayer( layer );
557 mChartBorderSymbolButton->setLayer( layer );
566 layoutAtlasToggled( atlas->enabled() );
598 mProfile->setCrs( canvas->
crs() );
600 mSpinTolerance->setValue( canvas->
tolerance() );
601 mProfile->setTolerance( canvas->
tolerance() );
604 mDistanceUnitCombo->setCurrentIndex( mDistanceUnitCombo->findData( QVariant::fromValue( canvas->
distanceUnit() ) ) );
607 mDistanceLabelsCombo->setCurrentIndex( mDistanceLabelsCombo->findData( QVariant::fromValue( canvas->
plot().
xAxis().
labelSuffixPlacement() ) ) );
610 mProfile->setProfileCurve( curve->clone() );
612 mSpinMinDistance->setValue( canvas->
plot().
xMinimum() );
613 mSpinMinDistance->setClearValue( canvas->
plot().
xMinimum() );
614 mProfile->plot()->setXMinimum( canvas->
plot().
xMinimum() );
616 mSpinMaxDistance->setValue( canvas->
plot().
xMaximum() );
617 mSpinMaxDistance->setClearValue( canvas->
plot().
xMaximum() );
618 mProfile->plot()->setXMaximum( canvas->
plot().
xMaximum() );
632 mSpinMinElevation->setValue( canvas->
plot().
xMinimum() );
633 mSpinMinElevation->setClearValue( canvas->
plot().
yMinimum() );
634 mProfile->plot()->setYMinimum( canvas->
plot().
yMinimum() );
636 mSpinMaxElevation->setValue( canvas->
plot().
yMaximum() );
637 mSpinMaxElevation->setClearValue( canvas->
plot().
yMaximum() );
638 mProfile->plot()->setYMaximum( canvas->
plot().
yMaximum() );
653 const bool subSectionsEnabled =
static_cast< bool >( subSectionsSymbol );
654 mSubsectionsSymbolLabel->setEnabled( subSectionsEnabled );
655 mSubsectionsSymbolButton->setEnabled( subSectionsEnabled );
656 mSubsectionsActivateCheck->setChecked( subSectionsEnabled );
657 if ( subSectionsSymbol )
659 mSubsectionsSymbolButton->setSymbol( subSectionsSymbol->
clone() );
660 mProfile->setSubsectionsSymbol( subSectionsSymbol->
clone() );
663 QList<QgsMapLayer *> canvasLayers = canvas->
layers();
665 std::reverse( canvasLayers.begin(), canvasLayers.end() );
666 mProfile->setLayers( canvasLayers );
667 const QList<QgsLayerTreeLayer *> layers = mLayerTree->findLayers();
670 layer->setItemVisibilityChecked( mProfile->layers().contains( layer->layer() ) );
672 mLayerTree->reorderGroupLayers( mProfile->layers() );
674 mProfile->invalidateCache();