53  mCopyFromDockMenu = 
new QMenu( 
this );
 
   54  connect( mCopyFromDockMenu, &QMenu::aboutToShow, 
this, [
this] {
 
   58  connect( mActionRefresh, &QAction::triggered, 
this, [
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, [
this]( 
double value ) {
 
   85    if ( !mProfile || mBlockChanges )
 
   89    mProfile->setTolerance( value );
 
   90    mProfile->invalidateCache();
 
   92    mProfile->endCommand();
 
   95  connect( mCheckControlledByAtlas, &QCheckBox::toggled, 
this, [
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, &QGroupBox::toggled, 
this, [
this] {
 
  121    if ( !mProfile || mBlockChanges )
 
  124    const bool subsectionsActivated = mSubsectionsActivateCheck->isChecked();
 
  126    std::unique_ptr<QgsLineSymbol> subSectionsSymbol( subsectionsActivated ? mSubsectionsSymbolButton->clonedSymbol<
QgsLineSymbol>() : nullptr );
 
  127    mProfile->setSubsectionsSymbol( subSectionsSymbol.release() );
 
  129    mProfile->invalidateCache();
 
  131    mProfile->endCommand();
 
  134  mSpinMinDistance->setClearValue( 0 );
 
  135  connect( mSpinMinDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  136    if ( !mProfile || mBlockChanges )
 
  140    mProfile->plot()->setXMinimum( value );
 
  141    mProfile->invalidateCache();
 
  143    mProfile->endCommand();
 
  146  connect( mSpinMaxDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  147    if ( !mProfile || mBlockChanges )
 
  151    mProfile->plot()->setXMaximum( value );
 
  152    mProfile->invalidateCache();
 
  154    mProfile->endCommand();
 
  157  mSpinMinElevation->setClearValue( 0 );
 
  158  connect( mSpinMinElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  159    if ( !mProfile || mBlockChanges )
 
  163    mProfile->plot()->setYMinimum( value );
 
  164    mProfile->invalidateCache();
 
  166    mProfile->endCommand();
 
  169  connect( mSpinMaxElevation, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  170    if ( !mProfile || mBlockChanges )
 
  174    mProfile->plot()->setYMaximum( value );
 
  175    mProfile->invalidateCache();
 
  177    mProfile->endCommand();
 
  182    if ( !mProfile || mBlockChanges )
 
  186    mProfile->plot()->xAxis().setGridMajorSymbol( mDistanceAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
 
  187    mProfile->invalidateCache();
 
  189    mProfile->endCommand();
 
  195    if ( !mProfile || mBlockChanges )
 
  199    mProfile->plot()->xAxis().setGridMinorSymbol( mDistanceAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
 
  200    mProfile->invalidateCache();
 
  202    mProfile->endCommand();
 
  206  connect( mDistanceAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  207    if ( !mProfile || mBlockChanges )
 
  211    mProfile->plot()->xAxis().setGridIntervalMajor( value );
 
  212    mProfile->invalidateCache();
 
  214    mProfile->endCommand();
 
  217  connect( mDistanceAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  218    if ( !mProfile || mBlockChanges )
 
  222    mProfile->plot()->xAxis().setGridIntervalMinor( value );
 
  223    mProfile->invalidateCache();
 
  225    mProfile->endCommand();
 
  228  connect( mDistanceAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  229    if ( !mProfile || mBlockChanges )
 
  233    mProfile->plot()->xAxis().setLabelInterval( value );
 
  234    mProfile->invalidateCache();
 
  236    mProfile->endCommand();
 
  241    if ( !mProfile || mBlockChanges )
 
  245    mProfile->plot()->yAxis().setGridMajorSymbol( mElevationAxisMajorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
 
  246    mProfile->invalidateCache();
 
  248    mProfile->endCommand();
 
  254    if ( !mProfile || mBlockChanges )
 
  258    mProfile->plot()->yAxis().setGridMinorSymbol( mElevationAxisMinorLinesSymbolButton->clonedSymbol<
QgsLineSymbol>() );
 
  259    mProfile->invalidateCache();
 
  261    mProfile->endCommand();
 
  265  connect( mElevationAxisLabelIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  266    if ( !mProfile || mBlockChanges )
 
  270    mProfile->plot()->yAxis().setLabelInterval( value );
 
  271    mProfile->invalidateCache();
 
  273    mProfile->endCommand();
 
  276  connect( mElevationAxisMajorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  277    if ( !mProfile || mBlockChanges )
 
  281    mProfile->plot()->yAxis().setGridIntervalMajor( value );
 
  282    mProfile->invalidateCache();
 
  284    mProfile->endCommand();
 
  287  connect( mElevationAxisMinorIntervalSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  288    if ( !mProfile || mBlockChanges )
 
  292    mProfile->plot()->yAxis().setGridIntervalMinor( value );
 
  293    mProfile->invalidateCache();
 
  295    mProfile->endCommand();
 
  300    if ( !mProfile || mBlockChanges )
 
  304    mProfile->plot()->setChartBackgroundSymbol( mChartBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
 
  305    mProfile->invalidateCache();
 
  307    mProfile->endCommand();
 
  313    if ( !mProfile || mBlockChanges )
 
  317    mProfile->plot()->setChartBorderSymbol( mChartBorderSymbolButton->clonedSymbol<
QgsFillSymbol>() );
 
  318    mProfile->invalidateCache();
 
  320    mProfile->endCommand();
 
  324  connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked, 
this, [
this] {
 
  325    if ( !mProfile || mBlockChanges )
 
  330    widget->
setFormat( mProfile->plot()->xAxis().numericFormat() );
 
  333      mProfile->plot()->xAxis().setNumericFormat( widget->
format() );
 
  334      mProfile->invalidateCache();
 
  335      mProfile->endCommand();
 
  341  connect( mElevationAxisLabelFormatButton, &QPushButton::clicked, 
this, [
this] {
 
  342    if ( !mProfile || mBlockChanges )
 
  347    widget->
setFormat( mProfile->plot()->yAxis().numericFormat() );
 
  350      mProfile->plot()->yAxis().setNumericFormat( widget->
format() );
 
  351      mProfile->invalidateCache();
 
  352      mProfile->endCommand();
 
  358  mDistanceAxisLabelFontButton->setDialogTitle( tr( 
"Distance Label Font" ) );
 
  359  mElevationAxisLabelFontButton->setDialogTitle( tr( 
"Elevation Label Font" ) );
 
  364    if ( !mProfile || mBlockChanges )
 
  368    mProfile->plot()->xAxis().setTextFormat( mDistanceAxisLabelFontButton->textFormat() );
 
  369    mProfile->invalidateCache();
 
  370    mProfile->endCommand();
 
  375    if ( !mProfile || mBlockChanges )
 
  379    mProfile->plot()->yAxis().setTextFormat( mElevationAxisLabelFontButton->textFormat() );
 
  380    mProfile->invalidateCache();
 
  381    mProfile->endCommand();
 
  385  mSpinLeftMargin->setClearValue( 0 );
 
  386  connect( mSpinLeftMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  387    if ( !mProfile || mBlockChanges )
 
  391    QgsMargins margins = mProfile->plot()->margins();
 
  393    mProfile->plot()->setMargins( margins );
 
  394    mProfile->invalidateCache();
 
  396    mProfile->endCommand();
 
  399  mSpinRightMargin->setClearValue( 0 );
 
  400  connect( mSpinRightMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
this]( 
double value ) {
 
  401    if ( !mProfile || mBlockChanges )
 
  405    QgsMargins margins = mProfile->plot()->margins();
 
  407    mProfile->plot()->setMargins( margins );
 
  408    mProfile->invalidateCache();
 
  410    mProfile->endCommand();
 
  413  mSpinTopMargin->setClearValue( 0 );
 
  414  connect( mSpinTopMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, [
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, [
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, [
this]( 
int ) {
 
  468    if ( !mProfile || mBlockChanges )
 
  471    mProfile->beginCommand( tr( 
"Change Profile Chart Units" ) );
 
  472    mProfile->setDistanceUnit( mDistanceUnitCombo->currentData().value<
Qgis::DistanceUnit>() );
 
  473    mProfile->invalidateCache();
 
  475    mProfile->endCommand();
 
  483  connect( mDistanceLabelsCombo, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [
this]( 
int ) {
 
  484    if ( !mProfile || mBlockChanges )
 
  487    mProfile->beginCommand( tr( 
"Change Profile Chart Label Placement" ) );
 
  489    mProfile->invalidateCache();
 
  491    mProfile->endCommand();
 
  513  QVBoxLayout *vl = 
new QVBoxLayout();
 
  514  vl->setContentsMargins( 0, 0, 0, 0 );
 
  515  vl->addWidget( mLayerTreeView );
 
  516  mTreeViewContainer->setLayout( vl );
 
  522  setGuiElementValues();
 
  524  mSubsectionsSymbolButton->registerExpressionContextGenerator( mProfile );
 
  525  mDistanceAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
 
  526  mDistanceAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
 
  527  mElevationAxisMajorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
 
  528  mElevationAxisMinorLinesSymbolButton->registerExpressionContextGenerator( mProfile );
 
  529  mChartBackgroundSymbolButton->registerExpressionContextGenerator( mProfile );
 
  530  mChartBorderSymbolButton->registerExpressionContextGenerator( mProfile );
 
  531  mDistanceAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
 
  532  mElevationAxisLabelFontButton->registerExpressionContextGenerator( mProfile );
 
  535  mDistanceAxisMajorLinesSymbolButton->setLayer( 
coverageLayer() );
 
  536  mDistanceAxisMinorLinesSymbolButton->setLayer( 
coverageLayer() );
 
  537  mElevationAxisMajorLinesSymbolButton->setLayer( 
coverageLayer() );
 
  538  mElevationAxisMinorLinesSymbolButton->setLayer( 
coverageLayer() );
 
  544  if ( mProfile->layout() )
 
  547      mSubsectionsSymbolButton->setLayer( layer );
 
  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 );
 
  564    layoutAtlasToggled( atlas->enabled() );