67 mRect = mCanvas->rect();
70 prepareGeometryChange();
71 setPos( mRect.topLeft() );
74 mCachedImages.clear();
82 mCachedImages.clear();
87 bool redrawResults(
const QString &sourceId )
89 auto it = mCachedImages.find( sourceId );
90 if ( it == mCachedImages.end() )
93 mCachedImages.erase( it );
98 QRectF boundingRect()
const override
103 QString distanceSuffix()
const
105 switch ( mDistanceUnit )
158 return QObject::tr(
"°" );
167 mDistanceUnit = unit;
174 if ( !mPlotArea.isNull() )
179 if ( !scene()->views().isEmpty() )
180 context.
setScaleFactor( scene()->views().at( 0 )->logicalDpiX() / 25.4 );
189 const QRectF area = plotArea();
190 if ( !area.contains( point.x(), point.y() ) )
193 const double distance = ( point.x() - area.left() ) / area.width() * (
xMaximum() -
xMinimum() ) * mXScaleFactor +
xMinimum() * mXScaleFactor;
200 if ( point.
distance() < xMinimum() * mXScaleFactor || point.
distance() > xMaximum()* mXScaleFactor || point.
elevation() < yMinimum() || point.
elevation() > yMaximum() )
203 const QRectF area = plotArea();
212 mPlotArea = plotArea;
217 const double pixelRatio = !scene()->views().empty() ? scene()->views().at( 0 )->devicePixelRatioF() : 1;
219 const QStringList sourceIds = mRenderer->sourceIds();
220 for (
const QString &source : sourceIds )
223 auto it = mCachedImages.constFind( source );
224 if ( it != mCachedImages.constEnd() )
230 plot = mRenderer->renderToImage( plotArea.width() * pixelRatio,
231 plotArea.height() * pixelRatio, xMinimum() * mXScaleFactor,
xMaximum() * mXScaleFactor,
yMinimum(),
yMaximum(), source, pixelRatio );
232 plot.setDevicePixelRatio( pixelRatio );
233 mCachedImages.insert( source, plot );
235 rc.
painter()->drawImage( QPointF( plotArea.left(),
236 plotArea.top() ), plot );
240 void paint( QPainter *painter )
override
243 if ( !mImage.isNull() )
245 painter->drawImage( QPointF( 0, 0 ), mImage );
249 const double pixelRatio = !scene()->views().empty() ? scene()->views().at( 0 )->devicePixelRatioF() : 1;
250 mImage = QImage( mRect.width() * pixelRatio, mRect.height() * pixelRatio, QImage::Format_ARGB32_Premultiplied );
251 mImage.setDevicePixelRatio( pixelRatio );
252 mImage.fill( Qt::transparent );
254 QPainter imagePainter( &mImage );
255 imagePainter.setRenderHint( QPainter::Antialiasing,
true );
259 const double mapUnitsPerPixel = (
xMaximum() -
xMinimum() ) * mXScaleFactor / plotArea().width();
269 painter->drawImage( QPointF( 0, 0 ), mImage );
274 double mXScaleFactor = 1.0;
282 QMap< QString, QImage > mCachedImages;
295 , mPlotItem( plotItem )
301 mRect = mCanvas->rect();
303 prepareGeometryChange();
304 setPos( mRect.topLeft() );
314 QRectF boundingRect()
const override
319 void paint( QPainter *painter )
override
321 const QgsPointXY crossHairPlotPoint = mPlotItem->plotPointToCanvasPoint( mPoint );
322 if ( crossHairPlotPoint.
isEmpty() )
326 painter->setBrush( Qt::NoBrush );
328 crossHairPen.setCosmetic(
true );
329 crossHairPen.setWidthF( 1 );
330 crossHairPen.setStyle( Qt::DashLine );
331 crossHairPen.setCapStyle( Qt::FlatCap );
332 const QPalette scenePalette = mPlotItem->scene()->palette();
333 QColor penColor = scenePalette.color( QPalette::ColorGroup::Active, QPalette::Text );
334 penColor.setAlpha( 150 );
335 crossHairPen.setColor( penColor );
336 painter->setPen( crossHairPen );
337 painter->drawLine( QPointF( mPlotItem->plotArea().left(), crossHairPlotPoint.
y() ), QPointF( mPlotItem->plotArea().right(), crossHairPlotPoint.
y() ) );
338 painter->drawLine( QPointF( crossHairPlotPoint.
x(), mPlotItem->plotArea().top() ), QPointF( crossHairPlotPoint.
x(), mPlotItem->plotArea().bottom() ) );
343 const QString xCoordinateText = mPlotItem->xAxis().numericFormat()->formatDouble( mPoint.distance() / mPlotItem->mXScaleFactor, numericContext )
344 + mPlotItem->distanceSuffix();
346 const QString yCoordinateText = mPlotItem->yAxis().numericFormat()->formatDouble( mPoint.elevation(), numericContext );
349 const QFontMetrics fm( font );
350 const double height = fm.capHeight();
351 const double xWidth = fm.horizontalAdvance( xCoordinateText );
352 const double yWidth = fm.horizontalAdvance( yCoordinateText );
353 const double textAxisMargin = fm.horizontalAdvance(
' ' );
355 QPointF xCoordOrigin;
356 QPointF yCoordOrigin;
358 if ( mPoint.distance() < ( mPlotItem->xMaximum() + mPlotItem->xMinimum() ) * 0.5 * mPlotItem->mXScaleFactor )
360 if ( mPoint.elevation() < ( mPlotItem->yMaximum() + mPlotItem->yMinimum() ) * 0.5 )
363 xCoordOrigin = QPointF( crossHairPlotPoint.
x() + textAxisMargin, mPlotItem->plotArea().top() + height + textAxisMargin );
365 yCoordOrigin = QPointF( mPlotItem->plotArea().right() - yWidth - textAxisMargin, crossHairPlotPoint.
y() - textAxisMargin );
370 xCoordOrigin = QPointF( crossHairPlotPoint.
x() + textAxisMargin, mPlotItem->plotArea().bottom() - textAxisMargin );
372 yCoordOrigin = QPointF( mPlotItem->plotArea().right() - yWidth - textAxisMargin, crossHairPlotPoint.
y() + height + textAxisMargin );
377 if ( mPoint.elevation() < ( mPlotItem->yMaximum() + mPlotItem->yMinimum() ) * 0.5 )
380 xCoordOrigin = QPointF( crossHairPlotPoint.
x() - xWidth - textAxisMargin, mPlotItem->plotArea().top() + height + textAxisMargin );
382 yCoordOrigin = QPointF( mPlotItem->plotArea().left() + textAxisMargin, crossHairPlotPoint.
y() - textAxisMargin );
387 xCoordOrigin = QPointF( crossHairPlotPoint.
x() - xWidth - textAxisMargin, mPlotItem->plotArea().bottom() - textAxisMargin );
389 yCoordOrigin = QPointF( mPlotItem->plotArea().left() + textAxisMargin, crossHairPlotPoint.
y() + height + textAxisMargin );
394 QColor backgroundColor = mPlotItem->chartBackgroundSymbol()->color();
395 backgroundColor.setAlpha( 220 );
396 painter->setBrush( QBrush( backgroundColor ) );
397 painter->setPen( Qt::NoPen );
398 painter->drawRect( QRectF( xCoordOrigin.x() - textAxisMargin + 1, xCoordOrigin.y() - textAxisMargin - height + 1, xWidth + 2 * textAxisMargin - 2, height + 2 * textAxisMargin - 2 ) );
399 painter->drawRect( QRectF( yCoordOrigin.x() - textAxisMargin + 1, yCoordOrigin.y() - textAxisMargin - height + 1, yWidth + 2 * textAxisMargin - 2, height + 2 * textAxisMargin - 2 ) );
401 painter->setBrush( Qt::NoBrush );
402 painter->setPen( scenePalette.color( QPalette::ColorGroup::Active, QPalette::Text ) );
404 painter->drawText( xCoordOrigin, xCoordinateText );
405 painter->drawText( yCoordOrigin, yCoordinateText );
413 QgsElevationProfilePlotItem *mPlotItem =
nullptr;
423 mPlotItem =
new QgsElevationProfilePlotItem(
this );
428 mCrossHairsItem =
new QgsElevationProfileCrossHairsItem(
this, mPlotItem );
429 mCrossHairsItem->setZValue( 100 );
430 mCrossHairsItem->hide();
433 mDeferredRegenerationTimer =
new QTimer(
this );
434 mDeferredRegenerationTimer->setSingleShot(
true );
435 mDeferredRegenerationTimer->stop();
436 connect( mDeferredRegenerationTimer, &QTimer::timeout,
this, &QgsElevationProfileCanvas::startDeferredRegeneration );
438 mDeferredRedrawTimer =
new QTimer(
this );
439 mDeferredRedrawTimer->setSingleShot(
true );
440 mDeferredRedrawTimer->stop();
441 connect( mDeferredRedrawTimer, &QTimer::timeout,
this, &QgsElevationProfileCanvas::startDeferredRedraw );
449 mPlotItem->setRenderer(
nullptr );
450 mCurrentJob->deleteLater();
451 mCurrentJob =
nullptr;
459 mPlotItem->setRenderer(
nullptr );
462 mCurrentJob->deleteLater();
463 mCurrentJob =
nullptr;
469 const double dxPercent = dx / mPlotItem->plotArea().width();
470 const double dyPercent = dy / mPlotItem->plotArea().height();
473 const double dxPlot = - dxPercent * ( mPlotItem->xMaximum() - mPlotItem->xMinimum() );
474 const double dyPlot = dyPercent * ( mPlotItem->yMaximum() - mPlotItem->yMinimum() );
477 mPlotItem->setXMinimum( mPlotItem->xMinimum() + dxPlot );
478 mPlotItem->setXMaximum( mPlotItem->xMaximum() + dxPlot );
479 mPlotItem->setYMinimum( mPlotItem->yMinimum() + dyPlot );
480 mPlotItem->setYMaximum( mPlotItem->yMaximum() + dyPlot );
484 mPlotItem->updatePlot();
490 if ( !mPlotItem->plotArea().contains( x, y ) )
493 const double newCenterX = mPlotItem->xMinimum() + ( x - mPlotItem->plotArea().left() ) / mPlotItem->plotArea().width() * ( mPlotItem->xMaximum() - mPlotItem->xMinimum() );
494 const double newCenterY = mPlotItem->yMinimum() + ( mPlotItem->plotArea().bottom() - y ) / mPlotItem->plotArea().height() * ( mPlotItem->yMaximum() - mPlotItem->yMinimum() );
496 const double dxPlot = newCenterX - ( mPlotItem->xMaximum() + mPlotItem->xMinimum() ) * 0.5;
497 const double dyPlot = newCenterY - ( mPlotItem->yMaximum() + mPlotItem->yMinimum() ) * 0.5;
500 mPlotItem->setXMinimum( mPlotItem->xMinimum() + dxPlot );
501 mPlotItem->setXMaximum( mPlotItem->xMaximum() + dxPlot );
502 mPlotItem->setYMinimum( mPlotItem->yMinimum() + dyPlot );
503 mPlotItem->setYMaximum( mPlotItem->yMaximum() + dyPlot );
507 mPlotItem->updatePlot();
519 const double toleranceInPixels = QFontMetrics( font() ).horizontalAdvance(
' ' );
520 const double xToleranceInPlotUnits = ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor / ( mPlotItem->plotArea().width() ) * toleranceInPixels;
521 const double yToleranceInPlotUnits = ( mPlotItem->yMaximum() - mPlotItem->yMinimum() ) / ( mPlotItem->plotArea().height() ) * toleranceInPixels;
529 / ( ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor / ( mPlotItem->plotArea().width() ) );
536 const double toleranceInPixels = QFontMetrics( font() ).horizontalAdvance(
' ' );
537 const double xToleranceInPlotUnits = ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor / ( mPlotItem->plotArea().width() ) * toleranceInPixels;
538 const double yToleranceInPlotUnits = ( mPlotItem->yMaximum() - mPlotItem->yMinimum() ) / ( mPlotItem->plotArea().height() ) * toleranceInPixels;
546 / ( ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor / ( mPlotItem->plotArea().width() ) );
553void QgsElevationProfileCanvas::setupLayerConnections(
QgsMapLayer *layer,
bool isDisconnect )
568 switch ( layer->
type() )
601void QgsElevationProfileCanvas::adjustRangeForAxisScaleLock(
double &xMinimum,
double &xMaximum,
double &yMinimum,
double &yMaximum )
const
604 const double horizontalScale = ( xMaximum - xMinimum ) / mPlotItem->plotArea().width();
605 const double verticalScale = ( yMaximum - yMinimum ) / mPlotItem->plotArea().height();
606 if ( horizontalScale > verticalScale )
608 const double height = horizontalScale * mPlotItem->plotArea().height();
609 const double deltaHeight = ( yMaximum - yMinimum ) - height;
610 yMinimum += deltaHeight / 2;
611 yMaximum -= deltaHeight / 2;
615 const double width = verticalScale * mPlotItem->plotArea().width();
616 const double deltaWidth = ( ( xMaximum - xMinimum ) - width );
617 xMinimum += deltaWidth / 2;
618 xMaximum -= deltaWidth / 2;
624 return mDistanceUnit;
629 mDistanceUnit = unit;
630 const double oldMin = mPlotItem->xMinimum() * mPlotItem->mXScaleFactor;
631 const double oldMax = mPlotItem->xMaximum() * mPlotItem->mXScaleFactor;
633 mPlotItem->setXAxisUnits( mDistanceUnit );
634 mPlotItem->setXMinimum( oldMin / mPlotItem->mXScaleFactor );
635 mPlotItem->setXMaximum( oldMax / mPlotItem->mXScaleFactor );
636 mPlotItem->updatePlot();
641 if ( !color.isValid() )
643 QPalette customPalette = qApp->palette();
644 const QColor baseColor = qApp->palette().color( QPalette::ColorRole::Base );
645 const QColor windowColor = qApp->palette().color( QPalette::ColorRole::Window );
646 customPalette.setColor( QPalette::ColorRole::Base, windowColor );
647 customPalette.setColor( QPalette::ColorRole::Window, baseColor );
648 setPalette( customPalette );
649 scene()->setPalette( customPalette );
654 const bool isDarkTheme = color.lightnessF() < 0.5;
655 QPalette customPalette = qApp->palette();
656 customPalette.setColor( QPalette::ColorRole::Window, color );
659 customPalette.setColor( QPalette::ColorRole::Text, QColor( 255, 255, 255 ) );
660 customPalette.setColor( QPalette::ColorRole::Base, color.lighter( 120 ) );
664 customPalette.setColor( QPalette::ColorRole::Text, QColor( 0, 0, 0 ) );
665 customPalette.setColor( QPalette::ColorRole::Base, color.darker( 120 ) );
668 setPalette( customPalette );
669 scene()->setPalette( customPalette );
672 updateChartFromPalette();
677 return mLockAxisScales;
682 mLockAxisScales = lock;
683 if ( mLockAxisScales )
685 double xMinimum = mPlotItem->xMinimum() * mPlotItem->mXScaleFactor;
686 double xMaximum = mPlotItem->xMaximum() * mPlotItem->mXScaleFactor;
687 double yMinimum = mPlotItem->yMinimum();
688 double yMaximum = mPlotItem->yMaximum();
689 adjustRangeForAxisScaleLock( xMinimum, xMaximum, yMinimum, yMaximum );
690 mPlotItem->setXMinimum( xMinimum / mPlotItem->mXScaleFactor );
691 mPlotItem->setXMaximum( xMaximum / mPlotItem->mXScaleFactor );
692 mPlotItem->setYMinimum( yMinimum );
693 mPlotItem->setYMaximum( yMaximum );
696 mPlotItem->updatePlot();
703 if ( !mCurrentJob || !mSnappingEnabled )
717 if ( mLockAxisScales )
720 const double currentWidth = ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor;
721 const double currentHeight = mPlotItem->yMaximum() - mPlotItem->yMinimum();
723 const double newWidth = currentWidth / xFactor;
724 const double newHeight = currentHeight / yFactor;
726 const double currentCenterX = ( mPlotItem->xMinimum() + mPlotItem->xMaximum() ) * 0.5 * mPlotItem->mXScaleFactor;
727 const double currentCenterY = ( mPlotItem->yMinimum() + mPlotItem->yMaximum() ) * 0.5;
729 double xMinimum = currentCenterX - newWidth * 0.5;
730 double xMaximum = currentCenterX + newWidth * 0.5;
731 double yMinimum = currentCenterY - newHeight * 0.5;
732 double yMaximum = currentCenterY + newHeight * 0.5;
733 if ( mLockAxisScales )
735 adjustRangeForAxisScaleLock( xMinimum, xMaximum, yMinimum, yMaximum );
738 mPlotItem->setXMinimum( xMinimum / mPlotItem->mXScaleFactor );
739 mPlotItem->setXMaximum( xMaximum / mPlotItem->mXScaleFactor );
740 mPlotItem->setYMinimum( yMinimum );
741 mPlotItem->setYMaximum( yMaximum );
744 mPlotItem->updatePlot();
750 const QRectF intersected = rect.intersected( mPlotItem->plotArea() );
752 double minX = ( intersected.left() - mPlotItem->plotArea().left() ) / mPlotItem->plotArea().width() * ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor + mPlotItem->xMinimum() * mPlotItem->mXScaleFactor;
753 double maxX = ( intersected.right() - mPlotItem->plotArea().left() ) / mPlotItem->plotArea().width() * ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor + mPlotItem->xMinimum() * mPlotItem->mXScaleFactor;
754 double minY = ( mPlotItem->plotArea().bottom() - intersected.bottom() ) / mPlotItem->plotArea().height() * ( mPlotItem->yMaximum() - mPlotItem->yMinimum() ) + mPlotItem->yMinimum();
755 double maxY = ( mPlotItem->plotArea().bottom() - intersected.top() ) / mPlotItem->plotArea().height() * ( mPlotItem->yMaximum() - mPlotItem->yMinimum() ) + mPlotItem->yMinimum();
757 if ( mLockAxisScales )
759 adjustRangeForAxisScaleLock( minX, maxX, minY, maxY );
762 mPlotItem->setXMinimum( minX / mPlotItem->mXScaleFactor );
763 mPlotItem->setXMaximum( maxX / mPlotItem->mXScaleFactor );
764 mPlotItem->setYMinimum( minY );
765 mPlotItem->setYMaximum( maxY );
768 mPlotItem->updatePlot();
776 double zoomFactor = settings.
value( QStringLiteral(
"qgis/zoom_factor" ), 2 ).toDouble();
777 bool reverseZoom = settings.
value( QStringLiteral(
"qgis/reverse_wheel_zoom" ),
false ).toBool();
778 bool zoomIn = reverseZoom ?
event->angleDelta().y() < 0 :
event->angleDelta().y() > 0;
781 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs(
event->angleDelta().y() );
783 if (
event->modifiers() & Qt::ControlModifier )
786 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
790 double scaleFactor = ( zoomIn ? 1 / zoomFactor : zoomFactor );
792 QRectF viewportRect = mPlotItem->plotArea();
794 if ( viewportRect.contains(
event->position() ) )
797 const double oldCenterX = 0.5 * ( mPlotItem->xMaximum() + mPlotItem->xMinimum() );
798 const double oldCenterY = 0.5 * ( mPlotItem->yMaximum() + mPlotItem->yMinimum() );
800 const double eventPosX = (
event->position().x() - viewportRect.left() ) / viewportRect.width() * ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) + mPlotItem->xMinimum();
801 const double eventPosY = ( viewportRect.bottom() -
event->position().y() ) / viewportRect.height() * ( mPlotItem->yMaximum() - mPlotItem->yMinimum() ) + mPlotItem->yMinimum();
803 const double newCenterX = eventPosX + ( ( oldCenterX - eventPosX ) * scaleFactor );
804 const double newCenterY = eventPosY + ( ( oldCenterY - eventPosY ) * scaleFactor );
806 const double dxPlot = newCenterX - ( mPlotItem->xMaximum() + mPlotItem->xMinimum() ) * 0.5;
807 const double dyPlot = newCenterY - ( mPlotItem->yMaximum() + mPlotItem->yMinimum() ) * 0.5;
810 mPlotItem->setXMinimum( mPlotItem->xMinimum() + dxPlot );
811 mPlotItem->setXMaximum( mPlotItem->xMaximum() + dxPlot );
812 mPlotItem->setYMinimum( mPlotItem->yMinimum() + dyPlot );
813 mPlotItem->setYMaximum( mPlotItem->yMaximum() + dyPlot );
831 if ( e->isAccepted() )
833 mCrossHairsItem->hide();
838 if ( mCurrentJob && mSnappingEnabled && !plotPoint.
isEmpty() )
847 mCrossHairsItem->hide();
851 mCrossHairsItem->setPoint( plotPoint );
852 mCrossHairsItem->show();
859 return mPlotItem->plotArea();
869 mPlotItem->setRenderer(
nullptr );
871 mCurrentJob->deleteLater();
872 mCurrentJob =
nullptr;
885 const QList< QgsMapLayer * > layersToGenerate =
layers();
886 QList< QgsAbstractProfileSource * > sources;
888 sources.reserve( layersToGenerate.size() + registrySources.size() );
890 sources << registrySources;
894 sources.append( source );
902 generationContext.
setMaximumErrorMapUnits( MAX_ERROR_PIXELS * ( mProfileCurve->length() ) / mPlotItem->plotArea().width() );
907 mPlotItem->setRenderer( mCurrentJob );
914 mZoomFullWhenJobFinished =
true;
917void QgsElevationProfileCanvas::generationFinished()
924 if ( mZoomFullWhenJobFinished )
927 mZoomFullWhenJobFinished =
false;
936 mPlotItem->updatePlot();
939 if ( mForceRegenerationAfterCurrentJobCompletes )
941 mForceRegenerationAfterCurrentJobCompletes =
false;
943 scheduleDeferredRegeneration();
947void QgsElevationProfileCanvas::onLayerProfileGenerationPropertyChanged()
950 if ( !mCurrentJob || mCurrentJob->
isActive() )
957 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( properties->parent() ) )
962 scheduleDeferredRegeneration();
967void QgsElevationProfileCanvas::onLayerProfileRendererPropertyChanged()
970 if ( !mCurrentJob || mCurrentJob->
isActive() )
977 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( properties->parent() ) )
983 if ( mPlotItem->redrawResults( layer->
id() ) )
984 scheduleDeferredRedraw();
988void QgsElevationProfileCanvas::regenerateResultsForLayer()
990 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( sender() ) )
995 scheduleDeferredRegeneration();
1000void QgsElevationProfileCanvas::scheduleDeferredRegeneration()
1002 if ( !mDeferredRegenerationScheduled )
1004 mDeferredRegenerationTimer->start( 1 );
1005 mDeferredRegenerationScheduled =
true;
1009void QgsElevationProfileCanvas::scheduleDeferredRedraw()
1011 if ( !mDeferredRedrawScheduled )
1013 mDeferredRedrawTimer->start( 1 );
1014 mDeferredRedrawScheduled =
true;
1018void QgsElevationProfileCanvas::startDeferredRegeneration()
1020 if ( mCurrentJob && !mCurrentJob->
isActive() )
1025 else if ( mCurrentJob )
1027 mForceRegenerationAfterCurrentJobCompletes =
true;
1030 mDeferredRegenerationScheduled =
false;
1033void QgsElevationProfileCanvas::startDeferredRedraw()
1035 mPlotItem->update();
1036 mDeferredRedrawScheduled =
false;
1039void QgsElevationProfileCanvas::refineResults()
1045 const double plotDistanceRange = ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor;
1046 const double plotElevationRange = mPlotItem->yMaximum() - mPlotItem->yMinimum();
1047 const double plotDistanceUnitsPerPixel = plotDistanceRange / mPlotItem->plotArea().width();
1051 const double targetMaxErrorInMapUnits = MAX_ERROR_PIXELS * plotDistanceUnitsPerPixel;
1052 const double factor = std::pow( 10.0, 1 - std::ceil( std::log10( std::fabs( targetMaxErrorInMapUnits ) ) ) );
1053 const double roundedErrorInMapUnits = std::floor( targetMaxErrorInMapUnits * factor ) / factor;
1061 mPlotItem->xMaximum() * mPlotItem->mXScaleFactor + plotDistanceRange * 0.05 ) );
1064 mPlotItem->yMaximum() + plotElevationRange * 0.05 ) );
1067 scheduleDeferredRegeneration();
1070void QgsElevationProfileCanvas::updateChartFromPalette()
1072 const QPalette chartPalette = palette();
1073 setBackgroundBrush( QBrush( chartPalette.color( QPalette::ColorRole::Base ) ) );
1076 textFormat.
setColor( chartPalette.color( QPalette::ColorGroup::Active, QPalette::Text ) );
1077 mPlotItem->xAxis().setTextFormat( textFormat );
1078 mPlotItem->yAxis().setTextFormat( textFormat );
1081 std::unique_ptr< QgsFillSymbol > chartFill( mPlotItem->chartBackgroundSymbol()->clone() );
1082 chartFill->setColor( chartPalette.color( QPalette::ColorGroup::Active, QPalette::ColorRole::Window ) );
1083 mPlotItem->setChartBackgroundSymbol( chartFill.release() );
1086 std::unique_ptr< QgsFillSymbol > chartBorder( mPlotItem->chartBorderSymbol()->clone() );
1087 chartBorder->setColor( chartPalette.color( QPalette::ColorGroup::Active, QPalette::ColorRole::Text ) );
1088 mPlotItem->setChartBorderSymbol( chartBorder.release() );
1091 std::unique_ptr< QgsLineSymbol > chartMajorSymbol( mPlotItem->xAxis().gridMajorSymbol()->clone() );
1092 QColor
c = chartPalette.color( QPalette::ColorGroup::Active, QPalette::ColorRole::Text );
1094 chartMajorSymbol->setColor(
c );
1095 mPlotItem->xAxis().setGridMajorSymbol( chartMajorSymbol->clone() );
1096 mPlotItem->yAxis().setGridMajorSymbol( chartMajorSymbol.release() );
1099 std::unique_ptr< QgsLineSymbol > chartMinorSymbol( mPlotItem->xAxis().gridMinorSymbol()->clone() );
1100 QColor
c = chartPalette.color( QPalette::ColorGroup::Active, QPalette::ColorRole::Text );
1102 chartMinorSymbol->setColor(
c );
1103 mPlotItem->xAxis().setGridMinorSymbol( chartMinorSymbol->clone() );
1104 mPlotItem->yAxis().setGridMinorSymbol( chartMinorSymbol.release() );
1106 mPlotItem->updatePlot();
1111 if ( !mPlotItem->plotArea().contains( point.x(), point.y() ) )
1114 return mPlotItem->canvasPointToPlotPoint( point );
1119 return mPlotItem->plotPointToCanvasPoint( point );
1125 mPlotItem->mProject = project;
1135 mProfileCurve.reset( curve );
1140 return mProfileCurve.get();
1155 for (
QgsMapLayer *layer : std::as_const( mLayers ) )
1157 setupLayerConnections( layer,
true );
1161 auto filteredList =
layers;
1162 filteredList.erase( std::remove_if( filteredList.begin(), filteredList.end(),
1165 return !layer || !layer->isValid();
1166 } ), filteredList.end() );
1168 mLayers = _qgis_listRawToQPointer( filteredList );
1169 for (
QgsMapLayer *layer : std::as_const( mLayers ) )
1171 setupLayerConnections( layer,
false );
1177 return _qgis_listQPointerToRaw( mLayers );
1184 if ( mLockAxisScales )
1186 double xMinimum = mPlotItem->xMinimum();
1187 double xMaximum = mPlotItem->xMaximum();
1188 double yMinimum = mPlotItem->yMinimum();
1189 double yMaximum = mPlotItem->yMaximum();
1190 adjustRangeForAxisScaleLock( xMinimum, xMaximum, yMinimum, yMaximum );
1191 mPlotItem->setXMinimum( xMinimum );
1192 mPlotItem->setXMaximum( xMaximum );
1193 mPlotItem->setYMinimum( yMinimum );
1194 mPlotItem->setYMaximum( yMaximum );
1197 mPlotItem->updateRect();
1198 mCrossHairsItem->updateRect();
1203 QgsPlotCanvas::paintEvent(
event );
1205 if ( !mFirstDrawOccurred )
1208 mFirstDrawOccurred =
true;
1209 mPlotItem->updateRect();
1210 mCrossHairsItem->updateRect();
1216 if ( !mPlotItem->plotArea().contains( point.
x(), point.
y() ) )
1219 if ( !mProfileCurve )
1222 const double dx = point.
x() - mPlotItem->plotArea().left();
1224 const double distanceAlongPlotPercent = dx / mPlotItem->plotArea().width();
1225 double distanceAlongCurveLength = distanceAlongPlotPercent * ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor + mPlotItem->xMinimum() * mPlotItem->mXScaleFactor;
1227 std::unique_ptr< QgsPoint > mapXyPoint( mProfileCurve->interpolatePoint( distanceAlongCurveLength ) );
1231 const double mapZ = ( mPlotItem->yMaximum() - mPlotItem->yMinimum() ) / ( mPlotItem->plotArea().height() ) * ( mPlotItem->plotArea().bottom() - point.
y() ) + mPlotItem->yMinimum();
1233 return QgsPoint( mapXyPoint->x(), mapXyPoint->y(), mapZ );
1238 if ( !mProfileCurve )
1243 const double distanceAlongCurve =
geos.lineLocatePoint( point, &error );
1245 const double distanceAlongCurveOnPlot = distanceAlongCurve - mPlotItem->xMinimum() * mPlotItem->mXScaleFactor;
1246 const double distanceAlongCurvePercent = distanceAlongCurveOnPlot / ( ( mPlotItem->xMaximum() - mPlotItem->xMinimum() ) * mPlotItem->mXScaleFactor );
1247 const double distanceAlongPlotRect = distanceAlongCurvePercent * mPlotItem->plotArea().width();
1249 const double canvasX = mPlotItem->plotArea().left() + distanceAlongPlotRect;
1252 if ( std::isnan( point.
z() ) || point.
z() < mPlotItem->yMinimum() )
1254 canvasY = mPlotItem->plotArea().top();
1256 else if ( point.
z() > mPlotItem->yMaximum() )
1258 canvasY = mPlotItem->plotArea().bottom();
1262 const double yPercent = ( point.
z() - mPlotItem->yMinimum() ) / ( mPlotItem->yMaximum() - mPlotItem->yMinimum() );
1263 canvasY = mPlotItem->plotArea().bottom() - mPlotItem->plotArea().height() * yPercent;
1276 double yMinimum = 0;
1277 double yMaximum = 0;
1288 yMinimum = zRange.
lower() - 5;
1289 yMaximum = zRange.
lower() + 5;
1294 const double margin = ( zRange.
upper() - zRange.
lower() ) * 0.05;
1295 yMinimum = zRange.
lower() - margin;
1296 yMaximum = zRange.
upper() + margin;
1300 double xMinimum = 0;
1302 double xMaximum = profileLength * 1.02;
1304 if ( mLockAxisScales )
1306 adjustRangeForAxisScaleLock( xMinimum, xMaximum, yMinimum, yMaximum );
1309 mPlotItem->setXMinimum( xMinimum / mPlotItem->mXScaleFactor );
1310 mPlotItem->setXMaximum( xMaximum / mPlotItem->mXScaleFactor );
1311 mPlotItem->setYMinimum( yMinimum );
1312 mPlotItem->setYMaximum( yMaximum );
1315 mPlotItem->updatePlot();
1321 if ( mLockAxisScales )
1323 adjustRangeForAxisScaleLock( minimumDistance, maximumDistance, minimumElevation, maximumElevation );
1326 mPlotItem->setYMinimum( minimumElevation );
1327 mPlotItem->setYMaximum( maximumElevation );
1328 mPlotItem->setXMinimum( minimumDistance / mPlotItem->mXScaleFactor );
1329 mPlotItem->setXMaximum( maximumDistance / mPlotItem->mXScaleFactor );
1331 mPlotItem->updatePlot();
1337 return QgsDoubleRange( mPlotItem->xMinimum() * mPlotItem->mXScaleFactor, mPlotItem->xMaximum() * mPlotItem->mXScaleFactor );
1342 return QgsDoubleRange( mPlotItem->yMinimum(), mPlotItem->yMaximum() );
1351class QgsElevationProfilePlot :
public Qgs2DPlot
1356 : mRenderer( renderer )
1365 rc.
painter()->translate( plotArea.left(), plotArea.top() );
1366 mRenderer->render( rc, plotArea.width(), plotArea.height(), xMinimum() * mXScale,
xMaximum() * mXScale,
yMinimum(),
yMaximum() );
1367 rc.
painter()->translate( -plotArea.left(), -plotArea.top() );
1386 QgsElevationProfilePlot profilePlot( mCurrentJob );
1390 QDomElement elem = doc.createElement( QStringLiteral(
"plot" ) );
1392 plotSettings.
writeXml( elem, doc, rwContext );
1393 profilePlot.readXml( elem, rwContext );
1395 profilePlot.mXScale = mPlotItem->mXScaleFactor;
1396 profilePlot.xAxis().setLabelSuffix( mPlotItem->xAxis().labelSuffix() );
1397 profilePlot.xAxis().setLabelSuffixPlacement( mPlotItem->xAxis().labelSuffixPlacement() );
1399 profilePlot.setSize( QSizeF( width, height ) );
1400 profilePlot.render( context );
1410 return mCurrentJob->
identify( plotPoint, identifyContext() );
1421 double distance1 = topLeftPlotPoint.
distance();
1422 double distance2 = bottomRightPlotPoint.
distance();
1423 if ( distance2 < distance1 )
1424 std::swap( distance1, distance2 );
1426 double elevation1 = topLeftPlotPoint.
elevation();
1427 double elevation2 = bottomRightPlotPoint.
elevation();
1428 if ( elevation2 < elevation1 )
1429 std::swap( elevation1, elevation2 );
1437 mPlotItem->setRenderer(
nullptr );
1438 mPlotItem->updatePlot();
1443 mSnappingEnabled = enabled;
@ FirstAndLastLabels
Place suffix after the first and last label values only.
DistanceUnit
Units of distance.
@ YardsBritishSears1922Truncated
British yards (Sears 1922 truncated)
@ MilesUSSurvey
US Survery miles.
@ LinksBritishSears1922
British links (Sears 1922)
@ YardsBritishBenoit1895A
British yards (Benoit 1895 A)
@ LinksBritishBenoit1895A
British links (Benoit 1895 A)
@ Centimeters
Centimeters.
@ YardsIndian1975
Indian yards (1975)
@ FeetUSSurvey
US Survery feet.
@ Millimeters
Millimeters.
@ FeetBritishSears1922
British feet (Sears 1922)
@ YardsClarkes
Clarke's yards.
@ YardsIndian
Indian yards.
@ FeetBritishBenoit1895B
British feet (Benoit 1895 B)
@ Miles
Terrestrial miles.
@ LinksUSSurvey
US Survery links.
@ ChainsUSSurvey
US Survery chains.
@ FeetClarkes
Clarke's feet.
@ Unknown
Unknown distance unit.
@ FeetBritish1936
British feet (1936)
@ FeetIndian1962
Indian feet (1962)
@ YardsBritishSears1922
British yards (Sears 1922)
@ FeetIndian1937
Indian feet (1937)
@ YardsIndian1937
Indian yards (1937)
@ Degrees
Degrees, for planar geographic CRS distance measurements.
@ ChainsBritishBenoit1895B
British chains (Benoit 1895 B)
@ LinksBritishSears1922Truncated
British links (Sears 1922 truncated)
@ ChainsBritishBenoit1895A
British chains (Benoit 1895 A)
@ YardsBritishBenoit1895B
British yards (Benoit 1895 B)
@ FeetBritish1865
British feet (1865)
@ YardsIndian1962
Indian yards (1962)
@ FeetBritishSears1922Truncated
British feet (Sears 1922 truncated)
@ MetersGermanLegal
German legal meter.
@ LinksBritishBenoit1895B
British links (Benoit 1895 B)
@ ChainsInternational
International chains.
@ LinksInternational
International links.
@ ChainsBritishSears1922Truncated
British chains (Sears 1922 truncated)
@ FeetIndian
Indian (geodetic) feet.
@ NauticalMiles
Nautical miles.
@ ChainsClarkes
Clarke's chains.
@ LinksClarkes
Clarke's links.
@ ChainsBritishSears1922
British chains (Sears 1922)
@ FeetIndian1975
Indian feet (1975)
@ FeetGoldCoast
Gold Coast feet.
@ FeetBritishBenoit1895A
British feet (Benoit 1895 A)
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
Base class for 2-dimensional plot/chart/graphs.
void calculateOptimisedIntervals(QgsRenderContext &context)
Automatically sets the grid and label intervals to optimal values for display in the given render con...
double yMaximum() const
Returns the maximum value of the y axis.
bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const override
Writes the plot's properties into an XML element.
QgsPlotAxis & xAxis()
Returns a reference to the plot's x axis.
void setSize(QSizeF size)
Sets the overall size of the plot (including titles and over components which sit outside the plot ar...
double xMaximum() const
Returns the maximum value of the x axis.
void render(QgsRenderContext &context)
Renders the plot.
void setYMaximum(double maximum)
Sets the maximum value of the y axis.
double xMinimum() const
Returns the minimum value of the x axis.
double yMinimum() const
Returns the minimum value of the y axis.
QRectF interiorPlotArea(QgsRenderContext &context) const
Returns the area of the plot which corresponds to the actual plot content (excluding all titles and o...
void setYMinimum(double minimum)
Sets the minimum value of the y axis.
virtual void renderContent(QgsRenderContext &context, const QRectF &plotArea)
Renders the plot content.
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
Interface for classes which can generate elevation profiles.
virtual QgsAbstractTerrainProvider * clone() const =0
Creates a clone of the provider and returns the new object.
static QgsProfileSourceRegistry * profileSourceRegistry()
Returns registry of available profile source implementations.
This class represents a coordinate reference system (CRS).
Qgis::DistanceUnit mapUnits
Abstract base class for curved geometry type.
QgsRange which stores a range of double values.
A canvas for elevation profiles.
QgsDoubleRange visibleElevationRange() const
Returns the elevation range currently visible in the plot.
QgsCurve * profileCurve() const
Returns the profile curve.
void setTolerance(double tolerance)
Sets the profile tolerance (in crs() units).
void setLockAxisScales(bool lock)
Sets whether the distance and elevation scales are locked to each other.
void setProfileCurve(QgsCurve *curve)
Sets the profile curve.
void zoomToRect(const QRectF &rect) override
Zooms the plot to the specified rect in canvas units.
void activeJobCountChanged(int count)
Emitted when the number of active background jobs changes.
QgsElevationProfileCanvas(QWidget *parent=nullptr)
Constructor for QgsElevationProfileCanvas, with the specified parent widget.
void scalePlot(double factor) override
Scales the plot by a specified scale factor.
void paintEvent(QPaintEvent *event) override
QgsDoubleRange visibleDistanceRange() const
Returns the distance range currently visible in the plot.
void cancelJobs() override
Cancel any rendering job, in a blocking way.
QgsCoordinateReferenceSystem crs() const override
Returns the coordinate reference system (CRS) for map coordinates used by the canvas.
void clear()
Clears the current profile.
void setDistanceUnit(Qgis::DistanceUnit unit)
Sets the distance unit used by the canvas.
QgsProfilePoint canvasPointToPlotPoint(QPointF point) const
Converts a canvas point to the equivalent plot point.
void setBackgroundColor(const QColor &color)
Sets the background color to use for the profile canvas.
QgsPointXY plotPointToCanvasPoint(const QgsProfilePoint &point) const
Converts a plot point to the equivalent canvas point.
QgsPoint toMapCoordinates(const QgsPointXY &point) const override
Converts a point on the canvas to the associated map coordinate.
bool lockAxisScales() const
Returns true if the distance and elevation scales are locked to each other.
void setVisiblePlotRange(double minimumDistance, double maximumDistance, double minimumElevation, double maximumElevation)
Sets the visible area of the plot.
void canvasPointHovered(const QgsPointXY &point, const QgsProfilePoint &profilePoint)
Emitted when the mouse hovers over the specified point (in canvas coordinates).
void render(QgsRenderContext &context, double width, double height, const Qgs2DPlot &plotSettings)
Renders a portion of the profile using the specified render context.
QgsPointXY snapToPlot(QPoint point) override
Snap a canvas point to the plot.
void setProject(QgsProject *project)
Sets the project associated with the profile.
QList< QgsMapLayer * > layers() const
Returns the list of layers included in the profile.
void resizeEvent(QResizeEvent *event) override
void centerPlotOn(double x, double y) override
Centers the plot on the plot point corresponding to x, y in canvas units.
const Qgs2DPlot & plot() const
Returns a reference to the 2D plot used by the widget.
void wheelZoom(QWheelEvent *event) override
Zoom plot from a mouse wheel event.
void refresh() override
Triggers a complete regeneration of the profile, causing the profile extraction to perform in the bac...
Qgis::DistanceUnit distanceUnit() const
Returns the distance unit used by the canvas.
double tolerance() const
Returns the tolerance of the profile (in crs() units).
void mouseMoveEvent(QMouseEvent *e) override
void panContentsBy(double dx, double dy) override
Pans the plot contents by dx, dy in canvas units.
void invalidateCurrentPlotExtent()
Invalidates the current plot extent, which means that the visible plot area will be recalculated and ...
QgsPointXY toCanvasCoordinates(const QgsPoint &point) const override
Converts a point in map coordinates to the associated canvas point.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the crs associated with the canvas' map coordinates.
~QgsElevationProfileCanvas() override
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of layers to include in the profile.
void zoomFull()
Zooms to the full extent of the profile.
void setSnappingEnabled(bool enabled)
Sets whether snapping of cursor points is enabled.
QVector< QgsProfileIdentifyResults > identify(QPointF point)
Identify results visible at the specified plot point.
QRectF plotArea() const
Returns the interior rectangle representing the surface of the plot, in canvas coordinates.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Does vector analysis using the geos library and handles import, export, exception handling*.
Base class for storage of map layer elevation properties.
void profileGenerationPropertyChanged()
Emitted when any of the elevation properties which relate solely to generation of elevation profiles ...
void profileRenderingPropertyChanged()
Emitted when any of the elevation properties which relate solely to presentation of elevation results...
Base class for all map layer types.
void dataChanged()
Data of layer changed.
virtual QgsMapLayerElevationProperties * elevationProperties()
Returns the layer's elevation properties.
Perform transforms between map coordinates and device coordinates.
A context for numeric formats.
void setLabelSuffixPlacement(Qgis::PlotAxisSuffixPlacement placement)
Sets the placement for the axis label suffixes.
void setLabelSuffix(const QString &suffix)
Sets the axis label suffix.
An abstract class for items that can be placed on a QgsPlotCanvas.
virtual void paint(QPainter *painter)=0
Paints the item.
Plot canvas is a class for displaying interactive 2d charts and plots.
bool event(QEvent *e) override
void plotAreaChanged()
Emitted whenever the visible area of the plot is changed.
void mouseMoveEvent(QMouseEvent *e) override
void resizeEvent(QResizeEvent *e) override
A class to represent a 2D point.
bool isEmpty() const
Returns true if the geometry is empty.
Point geometry type, with support for z-dimension and m-values.
Encapsulates the context in which an elevation profile is to be generated.
double maximumErrorMapUnits() const
Returns the maximum allowed error in the generated result, in profile curve map units.
void setDpi(double dpi)
Sets the dpi (dots per inch) for the profie, to be used in size conversions.
void setMaximumErrorMapUnits(double error)
Sets the maximum allowed error in the generated result, in profile curve map units.
void setDistanceRange(const QgsDoubleRange &range)
Sets the range of distances to include in the generation.
void setElevationRange(const QgsDoubleRange &range)
Sets the range of elevations to include in the generation.
void setMapUnitsPerDistancePixel(double units)
Sets the number of map units per pixel in the distance dimension.
Encapsulates the context of identifying profile results.
double maximumPointElevationDelta
Maximum allowed snapping delta for the elevation values when identifying a point.
double maximumPointDistanceDelta
Maximum allowed snapping delta for the distance values when identifying a point.
QgsProject * project
Associated project.
double displayRatioElevationVsDistance
Display ratio of elevation vs distance units.
double maximumSurfaceDistanceDelta
Maximum allowed snapping delta for the distance values when identifying a continuous elevation surfac...
double maximumSurfaceElevationDelta
Maximum allowed snapping delta for the elevation values when identifying a continuous elevation surfa...
Generates and renders elevation profile plots.
QgsProfileSnapResult snapPoint(const QgsProfilePoint &point, const QgsProfileSnapContext &context)
Snap a point to the results.
void regenerateInvalidatedResults()
Starts a background regeneration of any invalidated results and immediately returns.
void invalidateAllRefinableSources()
Invalidates previous results from all refinable sources.
void cancelGeneration()
Stop the generation job - does not return until the job has terminated.
void startGeneration()
Start the generation job and immediately return.
QgsDoubleRange zRange() const
Returns the limits of the retrieved elevation values.
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context)
Identify results visible at the specified profile point.
bool isActive() const
Returns true if the generation job is currently running in background.
bool invalidateResults(QgsAbstractProfileSource *source)
Invalidates the profile results from the source with matching ID.
void replaceSource(QgsAbstractProfileSource *source)
Replaces the existing source with matching ID.
void setContext(const QgsProfileGenerationContext &context)
Sets the context in which the profile generation will occur.
void generationFinished()
Emitted when the profile generation is finished (or canceled).
Encapsulates a point on a distance-elevation profile.
double elevation() const
Returns the elevation of the point.
double distance() const
Returns the distance of the point.
bool isEmpty() const
Returns true if the point is empty.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
QgsProfileRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate expressions.
QgsProfileRequest & setTransformContext(const QgsCoordinateTransformContext &context)
Sets the transform context, for use when transforming coordinates from a source to the request's crs(...
QgsProfileRequest & setTerrainProvider(QgsAbstractTerrainProvider *provider)
Sets the terrain provider.
QgsProfileRequest & setTolerance(double tolerance)
Sets the tolerance of the request (in crs() units).
QgsProfileRequest & setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the desired Coordinate Reference System (crs) for the profile.
Encapsulates the context of snapping a profile point.
double maximumPointDistanceDelta
Maximum allowed snapping delta for the distance values when snapping to a point.
double maximumSurfaceElevationDelta
Maximum allowed snapping delta for the elevation values when snapping to a continuous elevation surfa...
double maximumPointElevationDelta
Maximum allowed snapping delta for the elevation values when snapping to a point.
double maximumSurfaceDistanceDelta
Maximum allowed snapping delta for the distance values when snapping to a continuous elevation surfac...
double displayRatioElevationVsDistance
Display ratio of elevation vs distance units.
Encapsulates results of snapping a profile point.
bool isValid() const
Returns true if the result is a valid point.
QgsProfilePoint snappedPoint
Snapped point.
QList< QgsAbstractProfileSource * > profileSources() const
Returns a list of registered profile sources.
QgsAbstractTerrainProvider * terrainProvider()
Returns the project's terrain provider.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
const QgsProjectElevationProperties * elevationProperties() const
Returns the project's elevation properties, which contains the project's elevation related settings.
QgsCoordinateTransformContext transformContext
T lower() const
Returns the lower bound of the range.
T upper() const
Returns the upper bound of the range.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
void setDevicePixelRatio(float ratio)
Sets the device pixel ratio.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
A utility class for dynamic handling of changes to screen properties.
double screenDpi() const
Returns the current screen DPI for the screen that the parent widget appears on.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Container for all settings relating to text rendering.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE QString toAbbreviatedString(Qgis::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
Represents a vector layer which manages a vector based data sets.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &value)
Emitted whenever an attribute value change is done in the edit buffer.
void featureAdded(QgsFeatureId fid)
Emitted when a new feature has been added to the layer.
void featureDeleted(QgsFeatureId fid)
Emitted when a feature has been deleted.
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geometry)
Emitted whenever a geometry change is done in the edit buffer.
Contains geos related utilities and functions.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define BUILTIN_UNREACHABLE
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
const QgsCoordinateReferenceSystem & crs