60 mCopyFromDockMenu =
new QMenu(
this );
61 connect( mCopyFromDockMenu, &QMenu::aboutToShow,
this, [
this] {
sBuildCopyMenuFunction(
this, mCopyFromDockMenu ); } );
63 connect( mActionRefresh, &QAction::triggered,
this, [
this] {
68 mProfile->invalidateCache();
72 QToolButton *copyFromDockButton =
new QToolButton();
73 copyFromDockButton->setAutoRaise(
true );
74 copyFromDockButton->setToolTip( tr(
"Copy From Profile" ) );
75 copyFromDockButton->setMenu( mCopyFromDockMenu );
76 copyFromDockButton->setPopupMode( QToolButton::InstantPopup );
79 mDockToolbar->addWidget( copyFromDockButton );
83 mainLayout->addWidget( mItemPropertiesWidget );
91 connect( mRangeMethodCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
92 if ( !mProfile || mBlockChanges )
99 mRangesStackedWidget->setCurrentWidget( mPageManualRanges );
103 mRangesStackedWidget->setCurrentWidget( mPageFixedScales );
107 mProfile->beginCommand( tr(
"Change Profile Range Method" ) );
108 mProfile->setRangeMethod( method );
109 mProfile->invalidateCache();
111 mProfile->endCommand();
115 if ( !mProfile || mBlockChanges )
118 mProfile->beginCommand( tr(
"Change Distance Scale" ) );
119 mProfile->setDistanceScale( mDistanceScaleWidget->scale() );
120 mProfile->invalidateCache();
122 mProfile->endCommand();
126 mElevationScaleWidget->setPredefinedScales( { 5000, 2500, 1000, 500, 250, 100, 50, 10 } );
128 if ( !mProfile || mBlockChanges )
131 mProfile->beginCommand( tr(
"Change Elevation Scale" ) );
132 mProfile->setElevationScale( mElevationScaleWidget->scale() );
133 mProfile->invalidateCache();
135 mProfile->endCommand();
138 mSpinTolerance->setClearValue( 0 );
139 connect( mSpinTolerance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
140 if ( !mProfile || mBlockChanges )
144 mProfile->setTolerance( value );
145 mProfile->invalidateCache();
147 mProfile->endCommand();
150 connect( mCheckControlledByAtlas, &QCheckBox::toggled,
this, [
this] {
151 if ( !mProfile || mBlockChanges )
154 mProfile->beginCommand( tr(
"Change Profile Atlas Control" ) );
155 mProfile->setAtlasDriven( mCheckControlledByAtlas->isChecked() );
156 mProfile->invalidateCache();
158 mProfile->endCommand();
164 if ( !mProfile || mBlockChanges )
168 mProfile->setSubsectionsSymbol( mSubsectionsSymbolButton->clonedSymbol<
QgsLineSymbol>() );
169 mProfile->invalidateCache();
171 mProfile->endCommand();
175 connect( mSubsectionsActivateCheck, &QGroupBox::toggled,
this, [
this] {
176 if ( !mProfile || mBlockChanges )
179 const bool subsectionsActivated = mSubsectionsActivateCheck->isChecked();
181 std::unique_ptr<QgsLineSymbol> subSectionsSymbol( subsectionsActivated ? mSubsectionsSymbolButton->clonedSymbol<
QgsLineSymbol>() :
nullptr );
182 mProfile->setSubsectionsSymbol( subSectionsSymbol.release() );
184 mProfile->invalidateCache();
186 mProfile->endCommand();
189 mSpinMinDistance->setClearValue( 0 );
190 connect( mSpinMinDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
191 if ( !mProfile || mBlockChanges )
195 mProfile->plot()->setXMinimum( value );
196 mProfile->invalidateCache();
198 mProfile->endCommand();
201 connect( mSpinMaxDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
202 if ( !mProfile || mBlockChanges )
206 mProfile->plot()->setXMaximum( value );
207 mProfile->invalidateCache();
209 mProfile->endCommand();
212 mSpinMinElevation->setClearValue( 0 );
213 mSpinMinElevation2->setClearValue( 0 );
215 connect( mSpinMinElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ), mSpinMinElevation2, &QDoubleSpinBox::setValue );
216 connect( mSpinMinElevation2, qOverload<double>( &QDoubleSpinBox::valueChanged ), mSpinMinElevation, &QDoubleSpinBox::setValue );
218 connect( mSpinMinElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
219 if ( !mProfile || mBlockChanges )
223 mProfile->plot()->setYMinimum( value );
224 mProfile->invalidateCache();
226 mProfile->endCommand();
229 connect( mSpinMaxElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
230 if ( !mProfile || mBlockChanges )
234 mProfile->plot()->setYMaximum( value );
235 mProfile->invalidateCache();
237 mProfile->endCommand();
242 if ( !mProfile || mBlockChanges )
246 mProfile->plot()->xAxis().setGridMajorSymbol( mDistanceAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
247 mProfile->invalidateCache();
249 mProfile->endCommand();
255 if ( !mProfile || mBlockChanges )
259 mProfile->plot()->xAxis().setGridMinorSymbol( mDistanceAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
260 mProfile->invalidateCache();
262 mProfile->endCommand();
266 connect( mDistanceAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
267 if ( !mProfile || mBlockChanges )
271 mProfile->plot()->xAxis().setGridIntervalMajor( value );
272 mProfile->invalidateCache();
274 mProfile->endCommand();
277 connect( mDistanceAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
278 if ( !mProfile || mBlockChanges )
282 mProfile->plot()->xAxis().setGridIntervalMinor( value );
283 mProfile->invalidateCache();
285 mProfile->endCommand();
288 connect( mDistanceAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
289 if ( !mProfile || mBlockChanges )
293 mProfile->plot()->xAxis().setLabelInterval( value );
294 mProfile->invalidateCache();
296 mProfile->endCommand();
301 if ( !mProfile || mBlockChanges )
305 mProfile->plot()->yAxis().setGridMajorSymbol( mElevationAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
306 mProfile->invalidateCache();
308 mProfile->endCommand();
314 if ( !mProfile || mBlockChanges )
318 mProfile->plot()->yAxis().setGridMinorSymbol( mElevationAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
319 mProfile->invalidateCache();
321 mProfile->endCommand();
325 connect( mElevationAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
326 if ( !mProfile || mBlockChanges )
330 mProfile->plot()->yAxis().setLabelInterval( value );
331 mProfile->invalidateCache();
333 mProfile->endCommand();
336 connect( mElevationAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
337 if ( !mProfile || mBlockChanges )
341 mProfile->plot()->yAxis().setGridIntervalMajor( value );
342 mProfile->invalidateCache();
344 mProfile->endCommand();
347 connect( mElevationAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
348 if ( !mProfile || mBlockChanges )
352 mProfile->plot()->yAxis().setGridIntervalMinor( value );
353 mProfile->invalidateCache();
355 mProfile->endCommand();
360 if ( !mProfile || mBlockChanges )
364 mProfile->plot()->setChartBackgroundSymbol( mChartBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
365 mProfile->invalidateCache();
367 mProfile->endCommand();
373 if ( !mProfile || mBlockChanges )
377 mProfile->plot()->setChartBorderSymbol( mChartBorderSymbolButton->clonedSymbol<
QgsFillSymbol>() );
378 mProfile->invalidateCache();
380 mProfile->endCommand();
384 connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked,
this, [
this] {
385 if ( !mProfile || mBlockChanges )
390 widget->
setFormat( mProfile->plot()->xAxis().numericFormat() );
393 mProfile->plot()->xAxis().setNumericFormat( widget->
format() );
394 mProfile->invalidateCache();
395 mProfile->endCommand();
401 connect( mElevationAxisLabelFormatButton, &QPushButton::clicked,
this, [
this] {
402 if ( !mProfile || mBlockChanges )
407 widget->
setFormat( mProfile->plot()->yAxis().numericFormat() );
410 mProfile->plot()->yAxis().setNumericFormat( widget->
format() );
411 mProfile->invalidateCache();
412 mProfile->endCommand();
418 mDistanceAxisLabelFontButton->setDialogTitle( tr(
"Distance Label Font" ) );
419 mElevationAxisLabelFontButton->setDialogTitle( tr(
"Elevation Label Font" ) );
424 if ( !mProfile || mBlockChanges )
428 mProfile->plot()->xAxis().setTextFormat( mDistanceAxisLabelFontButton->textFormat() );
429 mProfile->invalidateCache();
430 mProfile->endCommand();
435 if ( !mProfile || mBlockChanges )
439 mProfile->plot()->yAxis().setTextFormat( mElevationAxisLabelFontButton->textFormat() );
440 mProfile->invalidateCache();
441 mProfile->endCommand();
445 mSpinLeftMargin->setClearValue( 0 );
446 connect( mSpinLeftMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
447 if ( !mProfile || mBlockChanges )
451 QgsMargins margins = mProfile->plot()->margins();
453 mProfile->plot()->setMargins( margins );
454 mProfile->invalidateCache();
456 mProfile->endCommand();
459 mSpinRightMargin->setClearValue( 0 );
460 connect( mSpinRightMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
461 if ( !mProfile || mBlockChanges )
465 QgsMargins margins = mProfile->plot()->margins();
467 mProfile->plot()->setMargins( margins );
468 mProfile->invalidateCache();
470 mProfile->endCommand();
473 mSpinTopMargin->setClearValue( 0 );
474 connect( mSpinTopMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
475 if ( !mProfile || mBlockChanges )
479 QgsMargins margins = mProfile->plot()->margins();
481 mProfile->plot()->setMargins( margins );
482 mProfile->invalidateCache();
484 mProfile->endCommand();
487 mSpinBottomMargin->setClearValue( 0 );
488 connect( mSpinBottomMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
489 if ( !mProfile || mBlockChanges )
493 QgsMargins margins = mProfile->plot()->margins();
495 mProfile->plot()->setMargins( margins );
496 mProfile->invalidateCache();
498 mProfile->endCommand();
523 mDistanceUnitCombo->addItem( title, QVariant::fromValue( unit ) );
526 connect( mDistanceUnitCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
527 if ( !mProfile || mBlockChanges )
530 mProfile->beginCommand( tr(
"Change Profile Chart Units" ) );
531 mProfile->setDistanceUnit( mDistanceUnitCombo->currentData().value<
Qgis::DistanceUnit>() );
532 mProfile->invalidateCache();
534 mProfile->endCommand();
542 connect( mDistanceLabelsCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
543 if ( !mProfile || mBlockChanges )
546 mProfile->beginCommand( tr(
"Change Profile Chart Label Placement" ) );
548 mProfile->invalidateCache();
550 mProfile->endCommand();
572 QVBoxLayout *vl =
new QVBoxLayout();
573 vl->setContentsMargins( 0, 0, 0, 0 );
574 vl->addWidget( mLayerTreeView );
575 mTreeViewContainer->setLayout( vl );
578 mLayerTreeView->populateInitialSources( mProfile->layout() && mProfile->layout()->project() ? mProfile->layout()->project() :
QgsProject::instance() );
581 setGuiElementValues();
584 mSubsectionsSymbolButton->registerExpressionContextGenerator( mProfile );
585 mDistanceAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
586 mDistanceAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
587 mElevationAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
588 mElevationAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
589 mChartBackgroundSymbolButton->registerExpressionContextGenerator( mProfile );
590 mChartBorderSymbolButton->registerExpressionContextGenerator( mProfile );
591 mDistanceAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
592 mElevationAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
595 mDistanceAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
596 mDistanceAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
597 mElevationAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
598 mElevationAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
604 if ( mProfile->layout() )
607 mSubsectionsSymbolButton->setLayer( layer );
608 mDistanceAxisMajorLinesSymbolButton->setLayer( layer );
609 mDistanceAxisMinorLinesSymbolButton->setLayer( layer );
610 mElevationAxisMajorLinesSymbolButton->setLayer( layer );
611 mElevationAxisMinorLinesSymbolButton->setLayer( layer );
612 mDistanceAxisLabelFontButton->setLayer( layer );
613 mElevationAxisLabelFontButton->setLayer( layer );
614 mChartBackgroundSymbolButton->setLayer( layer );
615 mChartBorderSymbolButton->setLayer( layer );
624 layoutAtlasToggled( atlas->enabled() );