52 mCopyFromDockMenu =
new QMenu(
this );
53 connect( mCopyFromDockMenu, &QMenu::aboutToShow,
this, [=] {
57 connect( mActionRefresh, &QAction::triggered,
this, [=] {
62 mProfile->invalidateCache();
66 QToolButton *copyFromDockButton =
new QToolButton();
67 copyFromDockButton->setAutoRaise(
true );
68 copyFromDockButton->setToolTip( tr(
"Copy From Profile" ) );
69 copyFromDockButton->setMenu( mCopyFromDockMenu );
70 copyFromDockButton->setPopupMode( QToolButton::InstantPopup );
73 mDockToolbar->addWidget( copyFromDockButton );
77 mainLayout->addWidget( mItemPropertiesWidget );
82 mSpinTolerance->setClearValue( 0 );
83 connect( mSpinTolerance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
84 if ( !mProfile || mBlockChanges )
88 mProfile->setTolerance( value );
89 mProfile->invalidateCache();
91 mProfile->endCommand();
94 connect( mCheckControlledByAtlas, &QCheckBox::toggled,
this, [=] {
95 if ( !mProfile || mBlockChanges )
98 mProfile->beginCommand( tr(
"Change Profile Atlas Control" ) );
99 mProfile->setAtlasDriven( mCheckControlledByAtlas->isChecked() );
100 mProfile->invalidateCache();
102 mProfile->endCommand();
105 mSpinMinDistance->setClearValue( 0 );
106 connect( mSpinMinDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
107 if ( !mProfile || mBlockChanges )
111 mProfile->plot()->setXMinimum( value );
112 mProfile->invalidateCache();
114 mProfile->endCommand();
117 connect( mSpinMaxDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
118 if ( !mProfile || mBlockChanges )
122 mProfile->plot()->setXMaximum( value );
123 mProfile->invalidateCache();
125 mProfile->endCommand();
128 mSpinMinElevation->setClearValue( 0 );
129 connect( mSpinMinElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
130 if ( !mProfile || mBlockChanges )
134 mProfile->plot()->setYMinimum( value );
135 mProfile->invalidateCache();
137 mProfile->endCommand();
140 connect( mSpinMaxElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
141 if ( !mProfile || mBlockChanges )
145 mProfile->plot()->setYMaximum( value );
146 mProfile->invalidateCache();
148 mProfile->endCommand();
153 if ( !mProfile || mBlockChanges )
157 mProfile->plot()->xAxis().setGridMajorSymbol( mDistanceAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
158 mProfile->invalidateCache();
160 mProfile->endCommand();
166 if ( !mProfile || mBlockChanges )
170 mProfile->plot()->xAxis().setGridMinorSymbol( mDistanceAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
171 mProfile->invalidateCache();
173 mProfile->endCommand();
177 connect( mDistanceAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
178 if ( !mProfile || mBlockChanges )
182 mProfile->plot()->xAxis().setGridIntervalMajor( value );
183 mProfile->invalidateCache();
185 mProfile->endCommand();
188 connect( mDistanceAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
189 if ( !mProfile || mBlockChanges )
193 mProfile->plot()->xAxis().setGridIntervalMinor( value );
194 mProfile->invalidateCache();
196 mProfile->endCommand();
199 connect( mDistanceAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
200 if ( !mProfile || mBlockChanges )
204 mProfile->plot()->xAxis().setLabelInterval( value );
205 mProfile->invalidateCache();
207 mProfile->endCommand();
212 if ( !mProfile || mBlockChanges )
216 mProfile->plot()->yAxis().setGridMajorSymbol( mElevationAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
217 mProfile->invalidateCache();
219 mProfile->endCommand();
225 if ( !mProfile || mBlockChanges )
229 mProfile->plot()->yAxis().setGridMinorSymbol( mElevationAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
230 mProfile->invalidateCache();
232 mProfile->endCommand();
236 connect( mElevationAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
237 if ( !mProfile || mBlockChanges )
241 mProfile->plot()->yAxis().setLabelInterval( value );
242 mProfile->invalidateCache();
244 mProfile->endCommand();
247 connect( mElevationAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
248 if ( !mProfile || mBlockChanges )
252 mProfile->plot()->yAxis().setGridIntervalMajor( value );
253 mProfile->invalidateCache();
255 mProfile->endCommand();
258 connect( mElevationAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
259 if ( !mProfile || mBlockChanges )
263 mProfile->plot()->yAxis().setGridIntervalMinor( value );
264 mProfile->invalidateCache();
266 mProfile->endCommand();
271 if ( !mProfile || mBlockChanges )
275 mProfile->plot()->setChartBackgroundSymbol( mChartBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
276 mProfile->invalidateCache();
278 mProfile->endCommand();
284 if ( !mProfile || mBlockChanges )
288 mProfile->plot()->setChartBorderSymbol( mChartBorderSymbolButton->clonedSymbol<
QgsFillSymbol>() );
289 mProfile->invalidateCache();
291 mProfile->endCommand();
295 connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked,
this, [=] {
296 if ( !mProfile || mBlockChanges )
301 widget->
setFormat( mProfile->plot()->xAxis().numericFormat() );
304 mProfile->plot()->xAxis().setNumericFormat( widget->
format() );
305 mProfile->invalidateCache();
306 mProfile->endCommand();
312 connect( mElevationAxisLabelFormatButton, &QPushButton::clicked,
this, [=] {
313 if ( !mProfile || mBlockChanges )
318 widget->
setFormat( mProfile->plot()->yAxis().numericFormat() );
321 mProfile->plot()->yAxis().setNumericFormat( widget->
format() );
322 mProfile->invalidateCache();
323 mProfile->endCommand();
329 mDistanceAxisLabelFontButton->setDialogTitle( tr(
"Distance Label Font" ) );
330 mElevationAxisLabelFontButton->setDialogTitle( tr(
"Elevation Label Font" ) );
335 if ( !mProfile || mBlockChanges )
339 mProfile->plot()->xAxis().setTextFormat( mDistanceAxisLabelFontButton->textFormat() );
340 mProfile->invalidateCache();
341 mProfile->endCommand();
346 if ( !mProfile || mBlockChanges )
350 mProfile->plot()->yAxis().setTextFormat( mElevationAxisLabelFontButton->textFormat() );
351 mProfile->invalidateCache();
352 mProfile->endCommand();
356 mSpinLeftMargin->setClearValue( 0 );
357 connect( mSpinLeftMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
358 if ( !mProfile || mBlockChanges )
362 QgsMargins margins = mProfile->plot()->margins();
364 mProfile->plot()->setMargins( margins );
365 mProfile->invalidateCache();
367 mProfile->endCommand();
370 mSpinRightMargin->setClearValue( 0 );
371 connect( mSpinRightMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
372 if ( !mProfile || mBlockChanges )
376 QgsMargins margins = mProfile->plot()->margins();
378 mProfile->plot()->setMargins( margins );
379 mProfile->invalidateCache();
381 mProfile->endCommand();
384 mSpinTopMargin->setClearValue( 0 );
385 connect( mSpinTopMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double value ) {
386 if ( !mProfile || mBlockChanges )
390 QgsMargins margins = mProfile->plot()->margins();
392 mProfile->plot()->setMargins( margins );
393 mProfile->invalidateCache();
395 mProfile->endCommand();
398 mSpinBottomMargin->setClearValue( 0 );
399 connect( mSpinBottomMargin, 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();
435 mDistanceUnitCombo->addItem( title, QVariant::fromValue( unit ) );
438 connect( mDistanceUnitCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
439 if ( !mProfile || mBlockChanges )
442 mProfile->beginCommand( tr(
"Change Profile Chart Units" ) );
443 mProfile->setDistanceUnit( mDistanceUnitCombo->currentData().value<
Qgis::DistanceUnit>() );
444 mProfile->invalidateCache();
446 mProfile->endCommand();
454 connect( mDistanceLabelsCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
455 if ( !mProfile || mBlockChanges )
458 mProfile->beginCommand( tr(
"Change Profile Chart Label Placement" ) );
460 mProfile->invalidateCache();
462 mProfile->endCommand();
484 QVBoxLayout *vl =
new QVBoxLayout();
485 vl->setContentsMargins( 0, 0, 0, 0 );
486 vl->addWidget( mLayerTreeView );
487 mTreeViewContainer->setLayout( vl );
493 setGuiElementValues();
495 mDistanceAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
496 mDistanceAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
497 mElevationAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
498 mElevationAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
499 mChartBackgroundSymbolButton->registerExpressionContextGenerator( mProfile );
500 mChartBorderSymbolButton->registerExpressionContextGenerator( mProfile );
501 mDistanceAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
502 mElevationAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
504 mDistanceAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
505 mDistanceAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
506 mElevationAxisMajorLinesSymbolButton->setLayer(
coverageLayer() );
507 mElevationAxisMinorLinesSymbolButton->setLayer(
coverageLayer() );
513 if ( mProfile->layout() )
516 mDistanceAxisMajorLinesSymbolButton->setLayer( layer );
517 mDistanceAxisMinorLinesSymbolButton->setLayer( layer );
518 mElevationAxisMajorLinesSymbolButton->setLayer( layer );
519 mElevationAxisMinorLinesSymbolButton->setLayer( layer );
520 mDistanceAxisLabelFontButton->setLayer( layer );
521 mElevationAxisLabelFontButton->setLayer( layer );
522 mChartBackgroundSymbolButton->setLayer( layer );
523 mChartBorderSymbolButton->setLayer( layer );
532 layoutAtlasToggled( atlas->enabled() );