44  qDeleteAll( mLabels );
 
 
   61    QTransform t = QTransform::fromTranslate( center.
x(), center.
y() );
 
   63    t.translate( -center.
x(), -center.
y() );
 
   68  auto feature = std::make_unique< QgsTextLabelFeature >( mLabels.size(),
 
   70                 QSizeF( size.width() * uPP,
 
   71                         size.height() * uPP ) );
 
   73  feature->setDocument( doc, documentMetrics );
 
   74  feature->setFixedAngle( 0 );
 
   75  feature->setHasFixedAngle( 
true );
 
   76  feature->setQuadOffset( QPointF( 0, 0 ) );
 
   77  feature->setZIndex( mZIndex );
 
   81  mLabels.append( feature.release() );
 
 
   91  mNumericFormat = std::move( format );
 
 
   96  return mNumericFormat.get();
 
 
  101  mResampleMethod = method;
 
 
  106  mResampleOver = pixels;
 
 
  136struct RasterProviderSettingsRestorer
 
  139  const bool mProviderResampling;
 
  141  const double mMaxOversampling;
 
  144    : mProvider( provider )
 
  145    , mProviderResampling( provider->isProviderResamplingEnabled() )
 
  146    , mZoomedOutMethod( provider->zoomedOutResamplingMethod() )
 
  147    , mMaxOversampling( provider->maxOversampling() ) {}
 
  149  ~RasterProviderSettingsRestorer()
 
  167  if ( provider->
xSize() == 0 || provider->
ySize() == 0 )
 
  170  if ( !rasterViewPort )
 
  198  int subRegionWidth = 0;
 
  199  int subRegionHeight = 0;
 
  200  int subRegionLeft = 0;
 
  201  int subRegionTop = 0;
 
  212  const double rasterUnitsPerPixelX = provider->
extent().
width() / provider->
xSize() * mResampleOver;
 
  213  const double rasterUnitsPerPixelY = provider->
extent().
height() / provider->
ySize() * mResampleOver;
 
  216  if ( minPixelSizePainterUnits > 0 )
 
  221                   rasterSubRegion.
yMinimum() + rasterSubRegion.
height() / subRegionHeight );
 
  229      QgsDebugError( QStringLiteral( 
"Could not transform raster pixel to map crs" ) );
 
  234    const double painterUnitsPerRasterPixel = std::max( std::fabs( p1PainterUnits.
x() - p2PainterUnits.
x() ),
 
  235        std::fabs( p1PainterUnits.
y() - p2PainterUnits.
y() ) ) * mResampleOver;
 
  236    if ( painterUnitsPerRasterPixel < minPixelSizePainterUnits )
 
  240  iterator.
startRasterRead( mBandNumber, subRegionWidth, subRegionHeight, rasterSubRegion, feedback );
 
  250  std::unique_ptr< QgsRasterBlock > block;
 
  251  bool isNoData = 
false;
 
  252  int numberLabels = 0;
 
  254  RasterProviderSettingsRestorer restorer( provider );
 
  255  if ( mResampleOver > 1 )
 
  262  while ( iterator.
next( mBandNumber, iterCols, iterRows, iterLeft, iterTop, blockExtent ) )
 
  264    if ( feedback && feedback->isCanceled() )
 
  267    const int resampledColumns = iterCols / mResampleOver;
 
  268    const int resampledRows = iterRows / mResampleOver;
 
  269    block.reset( provider->
block( mBandNumber, blockExtent, resampledColumns, resampledRows, feedback ) );
 
  271    double currentY = blockExtent.
yMaximum() - 0.5 * rasterUnitsPerPixelY;
 
  273    for ( 
int row = 0; row < resampledRows; row++ )
 
  275      if ( feedback && feedback->isCanceled() )
 
  278      double currentX = blockExtent.
xMinimum() + 0.5 * rasterUnitsPerPixelX;
 
  280      for ( 
int column = 0; column < resampledColumns; column++ )
 
  282        const double value = block->valueAndNoData( row, column, isNoData );
 
  287            QgsPoint pixelCenter( currentX, currentY );
 
  294            if ( maxNumLabels > 0 && numberLabels >= maxNumLabels )
 
  299            QgsDebugError( QStringLiteral( 
"Could not transform raster pixel center to map crs" ) );
 
  302        currentX += rasterUnitsPerPixelX;
 
  304      currentY -= rasterUnitsPerPixelY;
 
 
  325  const QString 
type = element.attribute( QStringLiteral( 
"type" ) );
 
  326  if ( 
type == QLatin1String( 
"simple" ) )
 
 
  340  QDomDocument doc = parent.ownerDocument();
 
  341  parent.appendChild( doc.createComment( QStringLiteral( 
"SE Export for %1 not implemented yet" ).arg( 
type() ) ) );
 
 
  366  return QStringLiteral( 
"simple" );
 
 
  371  auto res = std::make_unique< QgsRasterLayerSimpleLabeling >();
 
  372  res->setTextFormat( mTextFormat );
 
  374  if ( mNumericFormat )
 
  375    res->mNumericFormat.reset( mNumericFormat->clone() );
 
  377  res->setBand( mBandNumber );
 
  378  res->setPriority( mPriority );
 
  379  res->setPlacementSettings( mPlacementSettings );
 
  380  res->setThinningSettings( mThinningSettings );
 
  381  res->setZIndex( mZIndex );
 
  382  res->setScaleBasedVisibility( mScaleVisibility );
 
  383  res->setMaximumScale( mMaximumScale );
 
  384  res->setMinimumScale( mMinimumScale );
 
  385  res->setResampleMethod( mResampleMethod );
 
  386  res->setResampleOver( mResampleOver );
 
  388  return res.release();
 
 
  393  auto res = std::make_unique< QgsRasterLayerLabelProvider >( layer );
 
  394  res->setTextFormat( mTextFormat );
 
  395  res->setBand( mBandNumber );
 
  396  res->setPriority( mPriority );
 
  397  res->setPlacementSettings( mPlacementSettings );
 
  398  res->setZIndex( mZIndex );
 
  399  res->setThinningSettings( mThinningSettings );
 
  400  res->setResampleMethod( mResampleMethod );
 
  401  res->setResampleOver( mResampleOver );
 
  402  if ( mNumericFormat )
 
  404    res->setNumericFormat( std::unique_ptr< QgsNumericFormat >( mNumericFormat->clone() ) );
 
 
  411  QDomElement elem = doc.createElement( QStringLiteral( 
"labeling" ) );
 
  412  elem.setAttribute( QStringLiteral( 
"type" ), QStringLiteral( 
"simple" ) );
 
  413  elem.setAttribute( QStringLiteral( 
"band" ), mBandNumber );
 
  414  elem.setAttribute( QStringLiteral( 
"priority" ), mPriority );
 
  415  elem.setAttribute( QStringLiteral( 
"zIndex" ), mZIndex );
 
  417  if ( mResampleOver > 1 )
 
  419    elem.setAttribute( QStringLiteral( 
"resampleOver" ), mResampleOver );
 
  421  elem.setAttribute( QStringLiteral( 
"resampleMethod" ), 
qgsEnumValueToKey( mResampleMethod ) );
 
  424    QDomElement textFormatElem = doc.createElement( QStringLiteral( 
"textFormat" ) );
 
  425    textFormatElem.appendChild( mTextFormat.
writeXml( doc, context ) );
 
  426    elem.appendChild( textFormatElem );
 
  430    QDomElement numericFormatElem = doc.createElement( QStringLiteral( 
"numericFormat" ) );
 
  431    mNumericFormat->writeXml( numericFormatElem, doc, context );
 
  432    elem.appendChild( numericFormatElem );
 
  436    QDomElement placementElem = doc.createElement( QStringLiteral( 
"placement" ) );
 
  438    elem.appendChild( placementElem );
 
  442    QDomElement thinningElem = doc.createElement( QStringLiteral( 
"thinning" ) );
 
  443    thinningElem.setAttribute( QStringLiteral( 
"maxNumLabels" ), mThinningSettings.
maximumNumberLabels() );
 
  445    thinningElem.setAttribute( QStringLiteral( 
"minFeatureSize" ), mThinningSettings.
minimumFeatureSize() );
 
  446    elem.appendChild( thinningElem );
 
  450    QDomElement renderingElem = doc.createElement( QStringLiteral( 
"rendering" ) );
 
  451    renderingElem.setAttribute( QStringLiteral( 
"scaleVisibility" ), mScaleVisibility );
 
  453    renderingElem.setAttribute( QStringLiteral( 
"scaleMin" ), mMaximumScale );
 
  454    renderingElem.setAttribute( QStringLiteral( 
"scaleMax" ), mMinimumScale );
 
  455    elem.appendChild( renderingElem );
 
 
  464  if ( !visitor->
visit( &entity ) )
 
 
  482  auto res = std::make_unique< QgsRasterLayerSimpleLabeling >();
 
  483  res->setBand( element.attribute( QStringLiteral( 
"band" ), QStringLiteral( 
"1" ) ).toInt() );
 
  484  res->setPriority( element.attribute( QStringLiteral( 
"priority" ), QStringLiteral( 
"0.5" ) ).toDouble() );
 
  485  res->setZIndex( element.attribute( QStringLiteral( 
"zIndex" ), QStringLiteral( 
"0" ) ).toDouble() );
 
  486  res->setResampleOver( element.attribute( QStringLiteral( 
"resampleOver" ), QStringLiteral( 
"1" ) ).toInt() );
 
  489  const QDomElement textFormatElem = element.firstChildElement( QStringLiteral( 
"textFormat" ) );
 
  490  if ( !textFormatElem.isNull() )
 
  492    const QDomNodeList textFormatNodeList = textFormatElem.elementsByTagName( QStringLiteral( 
"text-style" ) );
 
  493    const QDomElement textFormatElem = textFormatNodeList.at( 0 ).toElement();
 
  495    format.
readXml( textFormatElem, context );
 
  496    res->setTextFormat( format );
 
  499  const QDomNodeList numericFormatNodeList = element.elementsByTagName( QStringLiteral( 
"numericFormat" ) );
 
  500  if ( !numericFormatNodeList.isEmpty() )
 
  502    const QDomElement numericFormatElem = numericFormatNodeList.at( 0 ).toElement();
 
  506  QDomElement placementElem = element.firstChildElement( QStringLiteral( 
"placement" ) );
 
  509  QDomElement thinningElem = element.firstChildElement( QStringLiteral( 
"thinning" ) );
 
  510  res->mThinningSettings.setMaximumNumberLabels( thinningElem.attribute( QStringLiteral( 
"maxNumLabels" ), QStringLiteral( 
"4000" ) ).toInt() );
 
  511  res->mThinningSettings.setLimitNumberLabelsEnabled( thinningElem.attribute( QStringLiteral( 
"limitNumLabels" ), QStringLiteral( 
"1" ) ).toInt() );
 
  512  res->mThinningSettings.setMinimumFeatureSize( thinningElem.attribute( QStringLiteral( 
"minFeatureSize" ), QStringLiteral( 
"8" ) ).toDouble() );
 
  514  QDomElement renderingElem = element.firstChildElement( QStringLiteral( 
"rendering" ) );
 
  516  res->mMaximumScale = renderingElem.attribute( QStringLiteral( 
"scaleMin" ), QStringLiteral( 
"0" ) ).toDouble();
 
  517  res->mMinimumScale = renderingElem.attribute( QStringLiteral( 
"scaleMax" ), QStringLiteral( 
"0" ) ).toDouble();
 
  518  res->mScaleVisibility = renderingElem.attribute( QStringLiteral( 
"scaleVisibility" ) ).toInt();
 
  520  return res.release();
 
 
  530  mTextFormat = format;
 
 
  535  return mNumericFormat.get();
 
 
  540  if ( format != mNumericFormat.get() )
 
  541    mNumericFormat.reset( format );
 
 
  556  return mMaximumScale;
 
 
  561  mMaximumScale = scale;
 
 
  566  return mMinimumScale;
 
 
  571  mMinimumScale = scale;
 
 
  576  return mScaleVisibility;
 
 
  583  return !mScaleVisibility
 
 
  590  return mResampleMethod;
 
 
  595  mResampleMethod = method;
 
 
  600  return mResampleOver;
 
 
  605  mResampleOver = pixels;
 
 
  610  mScaleVisibility = enabled;
 
 
  620  auto res = std::make_unique< QgsRasterLayerSimpleLabeling >();
 
  623  return res.release();
 
 
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
 
RasterResamplingMethod
Resampling method for raster provider-level resampling.
 
@ Average
Average resampling.
 
@ Labeling
Labeling-specific layout mode.
 
@ Point
Text at point of origin layout mode.
 
@ Horizontal
Horizontally oriented text.
 
@ Millimeters
Millimeters.
 
@ PreventOverlap
Do not allow labels to overlap other labels.
 
@ Reverse
Reverse/inverse transform (from destination to source)
 
An abstract interface class for label providers.
 
Flags mFlags
Flags altering drawing and registration of features.
 
virtual void startRender(QgsRenderContext &context)
To be called before rendering of labels begins.
 
Qgis::LabelPlacement mPlacement
Placement strategy.
 
@ DrawLabels
Whether the labels should be rendered.
 
Abstract base class for labeling settings for raster layers.
 
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
 
virtual bool isInScaleRange(double scale) const
Tests whether the labels should be visible at the specified scale.
 
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
 
virtual void toSld(QDomNode &parent, const QVariantMap &props) const
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
 
static QgsAbstractRasterLayerLabeling * createFromElement(const QDomElement &element, const QgsReadWriteContext &context)
Tries to create an instance of an implementation based on the XML data.
 
virtual void multiplyOpacity(double opacityFactor)
Multiply opacity by opacityFactor.
 
static QgsAbstractRasterLayerLabeling * defaultLabelingForLayer(QgsRasterLayer *layer)
Creates default labeling for a raster layer.
 
static QgsNumericFormatRegistry * numericFormatRegistry()
Gets the registry of available numeric formats.
 
Custom exception class for Coordinate Reference System related exceptions.
 
static geos::unique_ptr asGeos(const QgsGeometry &geometry, double precision=0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlags())
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destr...
 
Qgis::LabelOverlapHandling overlapHandling() const
Returns the technique used to handle overlapping labels.
 
void setMaximumNumberLabels(int number)
Sets the maximum number of labels which should be drawn for this layer.
 
double minimumFeatureSize() const
Returns the minimum feature size (in millimeters) for a feature to be labelled.
 
int maximumNumberLabels() const
Returns the maximum number of labels which should be drawn for this layer.
 
void setLimitNumberLabelsEnabled(bool enabled)
Sets whether the the number of labels drawn for the layer should be limited.
 
bool limitNumberOfLabelsEnabled() const
Returns true if the number of labels drawn for the layer should be limited.
 
void setMinimumFeatureSize(double size)
Sets the minimum feature size (in millimeters) for a feature to be labelled.
 
QgsProject * project() const
Returns the parent project if this map layer is added to a project.
 
Perform transforms between map coordinates and device coordinates.
 
void setMapRotation(double degrees, double cx, double cy)
Sets map rotation in degrees (clockwise).
 
double mapUnitsPerPixel() const
Returns the current map units per pixel.
 
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
 
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
 
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
 
A context for numeric formats.
 
QPointF toQPointF() const
Converts a point to a QPointF.
 
Point geometry type, with support for z-dimension and m-values.
 
void transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection d=Qgis::TransformDirection::Forward, bool transformZ=false) override
Transforms the geometry using a coordinate transform.
 
bool hasActiveProperties() const final
Returns true if the collection has any active properties, or false if all properties within the colle...
 
Base class for raster data providers.
 
virtual QSize maximumTileSize() const
Returns the maximum tile size in pixels for the data provider.
 
virtual bool setZoomedOutResamplingMethod(Qgis::RasterResamplingMethod method)
Set resampling method to apply for zoomed-out operations.
 
virtual bool enableProviderResampling(bool enable)
Enable or disable provider-level resampling.
 
QgsRectangle extent() const override=0
Returns the extent of the layer.
 
virtual bool setMaxOversampling(double factor)
Sets maximum oversampling factor for zoomed-out operations.
 
QgsRasterBlock * block(int bandNo, const QgsRectangle &boundingBox, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
 
virtual int xSize() const
Gets raster size.
 
virtual int ySize() const
 
Iterator for sequentially processing raster cells.
 
void setSnapToPixelFactor(int factor)
Sets the "snap to pixel" factor in pixels.
 
static QgsRectangle subRegion(const QgsRectangle &rasterExtent, int rasterWidth, int rasterHeight, const QgsRectangle &subRegion, int &subRegionWidth, int &subRegionHeight, int &subRegionLeft, int &subRegionTop, int resamplingFactor=1)
Given an overall raster extent and width and height in pixels, calculates the sub region of the raste...
 
bool next(int bandNumber, int &columns, int &rows, int &topLeftColumn, int &topLeftRow, QgsRectangle &blockExtent)
Fetches details of the next part of the raster data.
 
void setMaximumTileWidth(int w)
Sets the maximum tile width returned during iteration.
 
void startRasterRead(int bandNumber, qgssize nCols, qgssize nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback=nullptr)
Start reading of raster band.
 
void setMaximumTileHeight(int h)
Sets the minimum tile height returned during iteration.
 
void setTextFormat(const QgsTextFormat &format)
Sets the text format used for rendering the labels.
 
QgsRasterLayerLabelProvider(QgsRasterLayer *layer)
Constructor for QgsRasterLayerLabelProvider.
 
~QgsRasterLayerLabelProvider() final
 
void setResampleMethod(Qgis::RasterResamplingMethod method)
Sets the resampling method to use when the raster labels are being resampled over neighboring pixels.
 
void addLabel(const QgsPoint &mapPoint, const QString &text, QgsRenderContext &context)
Adds a label at the specified point in map coordinates.
 
QgsNumericFormat * numericFormat()
Returns the numeric format to be used for the labels.
 
void generateLabels(QgsRenderContext &context, QgsRasterPipe *pipe, QgsRasterViewPort *rasterViewPort, QgsRasterLayerRendererFeedback *feedback)
Generates the labels, given a render context and input pipe.
 
void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const final
Draw this label at the position determined by the labeling engine.
 
QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &) final
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
 
void setNumericFormat(std::unique_ptr< QgsNumericFormat > format)
Sets the numeric format used for the labels.
 
void startRender(QgsRenderContext &context) final
To be called before rendering of labels begins.
 
void setResampleOver(int pixels)
Sets the number of neighboring pixels to resample over, when labels are showing values resampled over...
 
Basic implementation of the labeling interface for raster layers.
 
double maximumScale() const
Returns the maximum map scale (i.e.
 
int resampleOver() const
Returns the number of neighboring pixels to resample over, when labels are showing values resampled o...
 
void setTextFormat(const QgsTextFormat &format)
Sets the text format used for rendering the labels.
 
double zIndex() const
Returns the Z-Index of the labels.
 
double minimumScale() const
Returns the minimum map scale (i.e.
 
QgsRasterLayerSimpleLabeling()
 
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the labels.
 
static QgsRasterLayerSimpleLabeling * create(const QDomElement &element, const QgsReadWriteContext &context)
Creates a QgsRasterLayerSimpleLabeling from a DOM element with saved configuration.
 
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the labels.
 
void setResampleMethod(Qgis::RasterResamplingMethod method)
Sets the resampling method to use when the raster labels are being resampled over neighboring pixels.
 
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
 
void setNumericFormat(QgsNumericFormat *format)
Sets the numeric format used for the labels.
 
~QgsRasterLayerSimpleLabeling() override
 
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
 
std::unique_ptr< QgsRasterLayerLabelProvider > provider(QgsRasterLayer *layer) const override
Creates a raster label provider corresponding to this object's configuration.
 
QgsTextFormat textFormat() const
Returns the text format used for rendering the labels.
 
bool isInScaleRange(double scale) const override
Tests whether the labels should be visible at the specified scale.
 
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
 
Qgis::RasterResamplingMethod resampleMethod() const
Returns the resampling method used when the raster labels are being resampled over neighboring pixels...
 
void setResampleOver(int pixels)
Sets the number of neighboring pixels to resample over, when labels are showing values resampled over...
 
void multiplyOpacity(double opacityFactor) override
Multiply opacity by opacityFactor.
 
QString type() const override
Unique type string of the labeling configuration implementation.
 
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Saves the labeling configuration to an XML element.
 
QgsRasterLayerSimpleLabeling * clone() const override
Returns a new copy of the object.
 
bool hasNonDefaultCompositionMode() const override
Returns true the labeling requires a non-default composition mode.
 
const QgsNumericFormat * numericFormat() const
Returns the numeric format used for the labels.
 
bool requiresAdvancedEffects() const override
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
 
void setZIndex(double index)
Sets the Z-Index of the labels.
 
Represents a raster layer.
 
Contains a pipeline of raster interfaces for sequential raster processing.
 
QgsRasterDataProvider * provider() const
Returns the data provider interface, or nullptr if no data provider is present in the pipe.
 
A container for the context for various read/write operations on objects.
 
A rectangle specified with double values.
 
Contains information about the context of a rendering operation.
 
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
 
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
 
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
 
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
 
static bool equalToOrGreaterThanMinimumScale(const double scale, const double minScale)
Returns whether the scale is equal to or greater than the minScale, taking non-round numbers into acc...
 
static bool lessThanMaximumScale(const double scale, const double maxScale)
Returns whether the scale is less than the maxScale, taking non-round numbers into account.
 
An interface for classes which can visit style entity (e.g.
 
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
 
A text format entity for QgsStyle databases.
 
static QgsTextFormat defaultTextFormatForProject(QgsProject *project, QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling)
Returns the default text format to use for new text based objects for the specified project,...
 
Contains pre-calculated metrics of a QgsTextDocument.
 
static QgsTextDocumentMetrics calculateMetrics(const QgsTextDocument &document, const QgsTextFormat &format, const QgsRenderContext &context, double scaleFactor=1.0, const QgsTextDocumentRenderContext &documentContext=QgsTextDocumentRenderContext())
Returns precalculated text metrics for a text document, when rendered using the given base format and...
 
Represents a document consisting of one or more QgsTextBlock objects.
 
static QgsTextDocument fromTextAndFormat(const QStringList &lines, const QgsTextFormat &format)
Constructor for QgsTextDocument consisting of a set of lines, respecting settings from a text format.
 
Container for all settings relating to text rendering.
 
void updateDataDefinedProperties(QgsRenderContext &context)
Updates the format by evaluating current values of data defined properties.
 
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the format's property collection, used for data defined overrides.
 
void multiplyOpacity(double opacityFactor)
Multiply opacity by opacityFactor.
 
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Read settings from a DOM element.
 
bool hasNonDefaultCompositionMode() const
Returns true if any component of the font format requires a non-default composition mode.
 
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Write settings into a DOM element.
 
bool containsAdvancedEffects() const
Returns true if any component of the font format requires advanced effects such as blend modes,...
 
Adds extra information to QgsLabelFeature for text labels.
 
const QgsTextDocumentMetrics & documentMetrics() const
Returns the document metrics for the label.
 
const QgsTextDocument & document() const
Returns the document for the label.
 
static void drawDocument(const QRectF &rect, const QgsTextFormat &format, const QgsTextDocument &document, const QgsTextDocumentMetrics &metrics, QgsRenderContext &context, Qgis::TextHorizontalAlignment horizontalAlignment=Qgis::TextHorizontalAlignment::Left, Qgis::TextVerticalAlignment verticalAlignment=Qgis::TextVerticalAlignment::Top, double rotation=0, Qgis::TextLayoutMode mode=Qgis::TextLayoutMode::Rectangle, Qgis::TextRendererFlags flags=Qgis::TextRendererFlags())
Draws a text document within a rectangle using the specified settings.
 
QgsLabelFeature * feature()
Returns the parent feature.
 
LabelPosition is a candidate feature label position.
 
double getAlpha() const
Returns the angle to rotate text (in radians).
 
FeaturePart * getFeaturePart() const
Returns the feature corresponding to this labelposition.
 
double getX(int i=0) const
Returns the down-left x coordinate.
 
double getY(int i=0) const
Returns the down-left y coordinate.
 
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
 
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
 
#define QgsDebugError(str)
 
This class provides details of the viewable area that a raster will be rendered into.
 
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent, in map (destination) CRS.