LCOV - code coverage report
Current view: top level - core/labeling - qgslabelfeature.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 0 54 0.0 %
Date: 2021-03-26 12:19:53 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :     qgslabelfeature.h
       3                 :            :     ---------------------
       4                 :            :     begin                : December 2015
       5                 :            :     copyright            : (C) 2015 by Martin Dobias
       6                 :            :     email                : wonder dot sk at gmail dot com
       7                 :            :  ***************************************************************************
       8                 :            :  *                                                                         *
       9                 :            :  *   This program is free software; you can redistribute it and/or modify  *
      10                 :            :  *   it under the terms of the GNU General Public License as published by  *
      11                 :            :  *   the Free Software Foundation; either version 2 of the License, or     *
      12                 :            :  *   (at your option) any later version.                                   *
      13                 :            :  *                                                                         *
      14                 :            :  ***************************************************************************/
      15                 :            : #ifndef QGSLABELFEATURE_H
      16                 :            : #define QGSLABELFEATURE_H
      17                 :            : 
      18                 :            : #define SIP_NO_FILE
      19                 :            : 
      20                 :            : #include "qgis_core.h"
      21                 :            : #include "qgspallabeling.h"
      22                 :            : #include "geos_c.h"
      23                 :            : #include "qgsgeos.h"
      24                 :            : #include "qgsmargins.h"
      25                 :            : #include "qgslabelobstaclesettings.h"
      26                 :            : #include "qgslabeling.h"
      27                 :            : 
      28                 :            : namespace pal
      29                 :            : {
      30                 :            :   class LabelInfo;
      31                 :            :   class Layer;
      32                 :            : }
      33                 :            : 
      34                 :            : class QgsAbstractLabelProvider;
      35                 :            : class QgsRenderContext;
      36                 :            : class QgsGeometry;
      37                 :            : 
      38                 :            : 
      39                 :            : /**
      40                 :            :  * \ingroup core
      41                 :            :  * \brief The QgsLabelFeature class describes a feature that
      42                 :            :  * should be used within the labeling engine. Those may be the usual textual labels,
      43                 :            :  * diagrams, or any other custom type of map annotations (generated by custom
      44                 :            :  * label providers).
      45                 :            :  *
      46                 :            :  * Instances only contain data relevant to the labeling engine (geometry, label size etc.)
      47                 :            :  * necessary for the layout. Rendering of labels is done by label providers.
      48                 :            :  *
      49                 :            :  * Individual label providers may create subclasses of QgsLabelFeature in order to add
      50                 :            :  * more data to the instances that will be later used for drawing of labels.
      51                 :            :  *
      52                 :            :  * \note this class is not a part of public API yet. See notes in QgsLabelingEngine
      53                 :            :  * \note not available in Python bindings
      54                 :            :  * \since QGIS 2.12
      55                 :            :  */
      56                 :            : class CORE_EXPORT QgsLabelFeature
      57                 :            : {
      58                 :            :   public:
      59                 :            : 
      60                 :            :     //! Create label feature, takes ownership of the geometry instance
      61                 :            :     QgsLabelFeature( QgsFeatureId id, geos::unique_ptr geometry, QSizeF size );
      62                 :            :     //! Clean up geometry and curved label info (if present)
      63                 :            :     virtual ~QgsLabelFeature();
      64                 :            : 
      65                 :            :     //! Identifier of the label (unique within the parent label provider)
      66                 :          0 :     QgsFeatureId id() const { return mId; }
      67                 :            : 
      68                 :            :     //! Gets access to the associated geometry
      69                 :          0 :     GEOSGeometry *geometry() const { return mGeometry.get(); }
      70                 :            : 
      71                 :            :     /**
      72                 :            :      * Sets the label's permissible zone geometry. If set, the feature's label MUST be fully contained
      73                 :            :      * within this zone, and the feature will not be labeled if no candidates can be generated which
      74                 :            :      * are not contained within the zone.
      75                 :            :      * \param geometry permissible zone geometry. If an invalid QgsGeometry is passed then no zone limit
      76                 :            :      * will be applied to the label candidates (this is the default behavior).
      77                 :            :      * \see permissibleZone()
      78                 :            :      * \since QGIS 3.0
      79                 :            :      */
      80                 :            :     void setPermissibleZone( const QgsGeometry &geometry );
      81                 :            : 
      82                 :            :     /**
      83                 :            :      * Returns the label's permissible zone geometry. If a valid geometry is returned, the feature's label
      84                 :            :      * MUST be fully contained within this zone, and the feature will not be labeled if no candidates can be
      85                 :            :      * generated which are not contained within the zone.
      86                 :            :      * \see setPermissibleZone()
      87                 :            :      * \see permissibleZonePrepared()
      88                 :            :      * \since QGIS 3.0
      89                 :            :      */
      90                 :          0 :     QgsGeometry permissibleZone() const { return mPermissibleZone; }
      91                 :            : 
      92                 :            :     /**
      93                 :            :      * Returns a GEOS prepared geometry representing the label's permissibleZone().
      94                 :            :      * \see permissibleZone()
      95                 :            :      * \since QGIS 3.0
      96                 :            :      */
      97                 :            :     //TODO - remove when QgsGeometry caches GEOS preparedness
      98                 :          0 :     const GEOSPreparedGeometry *permissibleZonePrepared() const { return mPermissibleZoneGeosPrepared.get(); }
      99                 :            : 
     100                 :            :     //! Size of the label (in map units)
     101                 :            :     QSizeF size( double angle = 0.0 ) const;
     102                 :            : 
     103                 :            :     /**
     104                 :            :      * Sets the visual margin for the label feature. The visual margin represents a margin
     105                 :            :      * within the label which should not be considered when calculating the positions of candidates
     106                 :            :      * for the label feature. It is used in certain label placement modes to adjust the position
     107                 :            :      * of candidates so that they all appear to be at visually equal distances from a point feature.
     108                 :            :      * For instance, this can be used to place labels which sit above a point so that their baseline
     109                 :            :      * rather then the descender of the label is at a preset distance from the point.
     110                 :            :      * \param margin visual margins for label
     111                 :            :      * \see visualMargin()
     112                 :            :      */
     113                 :          0 :     void setVisualMargin( const QgsMargins &margin ) { mVisualMargin = margin; }
     114                 :            : 
     115                 :            :     /**
     116                 :            :      * Returns the visual margin for the label feature.
     117                 :            :      * \see setVisualMargin() for details
     118                 :            :      */
     119                 :          0 :     const QgsMargins &visualMargin() const { return mVisualMargin; }
     120                 :            : 
     121                 :            :     /**
     122                 :            :      * Sets the size of the rendered symbol associated with this feature. This size is taken into
     123                 :            :      * account in certain label placement modes to avoid placing labels over the rendered
     124                 :            :      * symbol for this feature.
     125                 :            :      * \see symbolSize()
     126                 :            :      */
     127                 :          0 :     void setSymbolSize( QSizeF size ) { mSymbolSize = size; }
     128                 :            : 
     129                 :            :     /**
     130                 :            :      * Returns the size of the rendered symbol associated with this feature, if applicable.
     131                 :            :      * This size is taken into account in certain label placement modes to avoid placing labels over
     132                 :            :      * the rendered symbol for this feature. The size will only be set for labels associated
     133                 :            :      * with a point feature.
     134                 :            :      * \see symbolSize()
     135                 :            :      */
     136                 :          0 :     const QSizeF &symbolSize() const { return mSymbolSize; }
     137                 :            : 
     138                 :            :     /**
     139                 :            :      * Returns the feature's labeling priority.
     140                 :            :      * \returns feature's priority, as a value between 0 (highest priority)
     141                 :            :      * and 1 (lowest priority). Returns -1.0 if feature will use the layer's default priority.
     142                 :            :      * \see setPriority
     143                 :            :      */
     144                 :          0 :     double priority() const { return mPriority; }
     145                 :            : 
     146                 :            :     /**
     147                 :            :      * Sets the priority for labeling the feature.
     148                 :            :      * \param priority feature's priority, as a value between 0 (highest priority)
     149                 :            :      * and 1 (lowest priority). Set to -1.0 to use the layer's default priority
     150                 :            :      * for this feature.
     151                 :            :      * \see priority
     152                 :            :      */
     153                 :          0 :     void setPriority( double priority ) { mPriority = priority; }
     154                 :            : 
     155                 :            :     /**
     156                 :            :      * Returns the label's z-index. Higher z-index labels are rendered on top of lower
     157                 :            :      * z-index labels.
     158                 :            :      * \see setZIndex()
     159                 :            :      * \since QGIS 2.14
     160                 :            :      */
     161                 :          0 :     double zIndex() const { return mZIndex; }
     162                 :            : 
     163                 :            :     /**
     164                 :            :      * Sets the label's z-index. Higher z-index labels are rendered on top of lower
     165                 :            :      * z-index labels.
     166                 :            :      * \param zIndex z-index for label
     167                 :            :      * \see zIndex()
     168                 :            :      * \since QGIS 2.14
     169                 :            :      */
     170                 :          0 :     void setZIndex( double zIndex ) { mZIndex = zIndex; }
     171                 :            : 
     172                 :            :     //! Whether the label should use a fixed position instead of being automatically placed
     173                 :          0 :     bool hasFixedPosition() const { return mHasFixedPosition; }
     174                 :            :     //! Sets whether the label should use a fixed position instead of being automatically placed
     175                 :          0 :     void setHasFixedPosition( bool enabled ) { mHasFixedPosition = enabled; }
     176                 :            :     //! Coordinates of the fixed position (relevant only if hasFixedPosition() returns TRUE)
     177                 :          0 :     QgsPointXY fixedPosition() const { return mFixedPosition; }
     178                 :            : 
     179                 :            :     //! Sets coordinates of the fixed position (relevant only if hasFixedPosition() returns TRUE)
     180                 :          0 :     void setFixedPosition( const QgsPointXY &point ) { mFixedPosition = point; }
     181                 :            : 
     182                 :            :     /**
     183                 :            :      * In case of quadrand or aligned positioning, this is set to the anchor point.
     184                 :            :      * This can be used for proper vector based output like DXF.
     185                 :            :      *
     186                 :            :      * \since QGIS 3.12
     187                 :            :      */
     188                 :            :     QgsPointXY anchorPosition() const;
     189                 :            : 
     190                 :            :     /**
     191                 :            :      * In case of quadrand or aligned positioning, this is set to the anchor point.
     192                 :            :      * This can be used for proper vector based output like DXF.
     193                 :            :      *
     194                 :            :      * \since QGIS 3.12
     195                 :            :      */
     196                 :            :     void setAnchorPosition( const QgsPointXY &anchorPosition );
     197                 :            : 
     198                 :            :     //! Whether the label should use a fixed angle instead of using angle from automatic placement
     199                 :          0 :     bool hasFixedAngle() const { return mHasFixedAngle; }
     200                 :            :     //! Sets whether the label should use a fixed angle instead of using angle from automatic placement
     201                 :          0 :     void setHasFixedAngle( bool enabled ) { mHasFixedAngle = enabled; }
     202                 :            :     //! Angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns TRUE)
     203                 :          0 :     double fixedAngle() const { return mFixedAngle; }
     204                 :            :     //! Sets angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns TRUE)
     205                 :          0 :     void setFixedAngle( double angle ) { mFixedAngle = angle; }
     206                 :            : 
     207                 :            :     /**
     208                 :            :      * Returns whether the quadrant for the label is fixed.
     209                 :            :      * Applies to "around point" placement strategy.
     210                 :            :      * \see setHasFixedQuadrant
     211                 :            :      * \see quadOffset
     212                 :            :      */
     213                 :          0 :     bool hasFixedQuadrant() const { return mHasFixedQuadrant; }
     214                 :            : 
     215                 :            :     /**
     216                 :            :      * Sets whether the quadrant for the label must be respected. This can be used
     217                 :            :      * to fix the quadrant for specific features when using an "around point" placement.
     218                 :            :      * \see hasFixedQuadrant
     219                 :            :      * \see quadOffset
     220                 :            :      */
     221                 :          0 :     void setHasFixedQuadrant( bool enabled ) { mHasFixedQuadrant = enabled; }
     222                 :            : 
     223                 :            :     /**
     224                 :            :      * Applies to "offset from point" placement strategy and "around point" (in case hasFixedQuadrant() returns TRUE).
     225                 :            :      * Determines which side of the point to use.
     226                 :            :      * For X coordinate, values -1, 0, 1 mean left, center, right.
     227                 :            :      * For Y coordinate, values -1, 0, 1 mean above, center, below.
     228                 :            :      */
     229                 :          0 :     QPointF quadOffset() const { return mQuadOffset; }
     230                 :            : 
     231                 :            :     /**
     232                 :            :      * Set which side of the point to use
     233                 :            :      * \see quadOffset
     234                 :            :      */
     235                 :          0 :     void setQuadOffset( QPointF quadOffset ) { mQuadOffset = quadOffset; }
     236                 :            : 
     237                 :            :     /**
     238                 :            :      * Applies only to "offset from point" placement strategy.
     239                 :            :      * What offset (in map units) to use from the point
     240                 :            :      */
     241                 :          0 :     QgsPointXY positionOffset() const { return mPositionOffset; }
     242                 :            : 
     243                 :            :     /**
     244                 :            :      * Applies only to "offset from point" placement strategy.
     245                 :            :      * Set what offset (in map units) to use from the point
     246                 :            :      */
     247                 :          0 :     void setPositionOffset( const QgsPointXY &offset ) { mPositionOffset = offset; }
     248                 :            : 
     249                 :            :     /**
     250                 :            :      * Returns the offset type, which determines how offsets and distance to label
     251                 :            :      * behaves. Support depends on which placement mode is used for generating
     252                 :            :      * label candidates.
     253                 :            :      * \see setOffsetType()
     254                 :            :      */
     255                 :          0 :     QgsPalLayerSettings::OffsetType offsetType() const { return mOffsetType; }
     256                 :            : 
     257                 :            :     /**
     258                 :            :      * Sets the offset type, which determines how offsets and distance to label
     259                 :            :      * behaves. Support depends on which placement mode is used for generating
     260                 :            :      * label candidates.
     261                 :            :      * \see offsetType()
     262                 :            :      */
     263                 :          0 :     void setOffsetType( QgsPalLayerSettings::OffsetType type ) { mOffsetType = type; }
     264                 :            : 
     265                 :            :     /**
     266                 :            :      * Applies to "around point" placement strategy or linestring features.
     267                 :            :      * Distance of the label from the feature (in map units)
     268                 :            :      */
     269                 :          0 :     double distLabel() const { return mDistLabel; }
     270                 :            : 
     271                 :            :     /**
     272                 :            :      * Applies to "around point" placement strategy or linestring features.
     273                 :            :      * Set distance of the label from the feature (in map units)
     274                 :            :      */
     275                 :          0 :     void setDistLabel( double dist ) { mDistLabel = dist; }
     276                 :            : 
     277                 :            :     /**
     278                 :            :      * Returns the priority ordered list of predefined positions for label candidates. This property
     279                 :            :      * is only used for OrderedPositionsAroundPoint placements.
     280                 :            :      * \see setPredefinedPositionOrder()
     281                 :            :      */
     282                 :          0 :     QVector< QgsPalLayerSettings::PredefinedPointPosition > predefinedPositionOrder() const { return mPredefinedPositionOrder; }
     283                 :            : 
     284                 :            :     /**
     285                 :            :      * Sets the priority ordered list of predefined positions for label candidates. This property
     286                 :            :      * is only used for OrderedPositionsAroundPoint placements.
     287                 :            :      * \see predefinedPositionOrder()
     288                 :            :      */
     289                 :          0 :     void setPredefinedPositionOrder( const QVector< QgsPalLayerSettings::PredefinedPointPosition > &order ) { mPredefinedPositionOrder = order; }
     290                 :            : 
     291                 :            :     /**
     292                 :            :      * Applies only to linestring features - after what distance (in map units)
     293                 :            :      * the labels should be repeated (0 = no repetitions)
     294                 :            :      */
     295                 :          0 :     double repeatDistance() const { return mRepeatDistance; }
     296                 :            : 
     297                 :            :     /**
     298                 :            :      * Applies only to linestring features - set after what distance (in map units)
     299                 :            :      * the labels should be repeated (0 = no repetitions)
     300                 :            :      */
     301                 :          0 :     void setRepeatDistance( double dist ) { mRepeatDistance = dist; }
     302                 :            : 
     303                 :            :     //! Whether label should be always shown (sets very high label priority)
     304                 :          0 :     bool alwaysShow() const { return mAlwaysShow; }
     305                 :            :     //! Sets whether label should be always shown (sets very high label priority)
     306                 :          0 :     void setAlwaysShow( bool enabled ) { mAlwaysShow = enabled; }
     307                 :            : 
     308                 :            :     /**
     309                 :            :      * Returns the feature's arrangement flags.
     310                 :            :      * \see setArrangementFlags
     311                 :            :      */
     312                 :          0 :     QgsLabeling::LinePlacementFlags arrangementFlags() const { return mArrangementFlags; }
     313                 :            : 
     314                 :            :     /**
     315                 :            :      * Sets the feature's arrangement flags.
     316                 :            :      * \param flags arrangement flags
     317                 :            :      * \see arrangementFlags
     318                 :            :      */
     319                 :          0 :     void setArrangementFlags( QgsLabeling::LinePlacementFlags flags ) { mArrangementFlags = flags; }
     320                 :            : 
     321                 :            :     /**
     322                 :            :      * Returns the polygon placement flags, which dictate how polygon labels can be placed.
     323                 :            :      *
     324                 :            :      * \see setPolygonPlacementFlags()
     325                 :            :      * \since QGIS 3.14
     326                 :            :      */
     327                 :          0 :     QgsLabeling::PolygonPlacementFlags polygonPlacementFlags() const { return mPolygonPlacementFlags; }
     328                 :            : 
     329                 :            :     /**
     330                 :            :      * Sets the polygon placement \a flags, which dictate how polygon labels can be placed.
     331                 :            :      *
     332                 :            :      * \see polygonPlacementFlags()
     333                 :            :      * \since QGIS 3.14
     334                 :            :      */
     335                 :          0 :     void setPolygonPlacementFlags( QgsLabeling::PolygonPlacementFlags flags ) { mPolygonPlacementFlags = flags; }
     336                 :            : 
     337                 :            :     /**
     338                 :            :      * Text of the label
     339                 :            :      *
     340                 :            :      * Used also if "merge connected lines to avoid duplicate labels" is enabled
     341                 :            :      * to identify which features may be merged.
     342                 :            :      */
     343                 :          0 :     QString labelText() const { return mLabelText; }
     344                 :            :     //! Sets text of the label
     345                 :          0 :     void setLabelText( const QString &text ) { mLabelText = text; }
     346                 :            : 
     347                 :            :     //! Gets additional info required for curved label placement. Returns NULLPTR if not set
     348                 :          0 :     pal::LabelInfo *curvedLabelInfo() const { return mInfo; }
     349                 :            :     //! takes ownership of the instance
     350                 :            :     void setCurvedLabelInfo( pal::LabelInfo *info ) { mInfo = info; }
     351                 :            : 
     352                 :            :     //! Gets PAL layer of the label feature. Should be only used internally in PAL
     353                 :          0 :     pal::Layer *layer() const { return mLayer; }
     354                 :            :     //! Assign PAL layer to the label feature. Should be only used internally in PAL
     355                 :          0 :     void setLayer( pal::Layer *layer ) { mLayer = layer; }
     356                 :            : 
     357                 :            :     //! Returns provider of this instance
     358                 :            :     QgsAbstractLabelProvider *provider() const;
     359                 :            : 
     360                 :            :     /**
     361                 :            :      * Returns the original feature associated with this label.
     362                 :            :      * \see setFeature()
     363                 :            :      *
     364                 :            :      * \since QGIS 3.10
     365                 :            :      */
     366                 :            :     QgsFeature feature() const;
     367                 :            : 
     368                 :            :     /**
     369                 :            :      * Sets the original \a feature associated with this label.
     370                 :            :      * \see feature()
     371                 :            :      *
     372                 :            :      * \since QGIS 3.10
     373                 :            :      */
     374                 :            :     void setFeature( const QgsFeature &feature );
     375                 :            : 
     376                 :            :     /**
     377                 :            :      * Returns the feature symbol associated with this label.
     378                 :            :      * \see setSymbol()
     379                 :            :      *
     380                 :            :      * \since QGIS 3.10
     381                 :            :      */
     382                 :          0 :     const QgsSymbol *symbol() { return mSymbol; }
     383                 :            : 
     384                 :            :     /**
     385                 :            :      * Sets the feature \a symbol associated with this label.
     386                 :            :      * Ownership of \a symbol is not transferred to the label feature, .
     387                 :            :      * \see symbol()
     388                 :            :      *
     389                 :            :      * \since QGIS 3.10
     390                 :            :      */
     391                 :          0 :     void setSymbol( const QgsSymbol *symbol ) { mSymbol = symbol; }
     392                 :            : 
     393                 :            :     /**
     394                 :            :      * Returns the permissible distance (in map units) which labels are allowed to overrun the start
     395                 :            :      * or end of linear features.
     396                 :            :      *
     397                 :            :      * \see setOverrunDistance()
     398                 :            :      * \see overrunSmoothDistance()
     399                 :            :      * \since QGIS 3.10
     400                 :            :      */
     401                 :            :     double overrunDistance() const;
     402                 :            : 
     403                 :            :     /**
     404                 :            :      * Sets the permissible \a distance (in map units) which labels are allowed to overrun the start
     405                 :            :      * or end of linear features.
     406                 :            :      *
     407                 :            :      * \see overrunDistance()
     408                 :            :      * \see setOverrunSmoothDistance()
     409                 :            :      * \since QGIS 3.10
     410                 :            :      */
     411                 :            :     void setOverrunDistance( double distance );
     412                 :            : 
     413                 :            :     /**
     414                 :            :      * Returns the distance (in map units) with which the ends of linear features are averaged over when
     415                 :            :      * calculating the direction at which to overrun labels.
     416                 :            :      *
     417                 :            :      * \see setOverrunSmoothDistance()
     418                 :            :      * \see overrunDistance()
     419                 :            :      * \since QGIS 3.10
     420                 :            :      */
     421                 :            :     double overrunSmoothDistance() const;
     422                 :            : 
     423                 :            :     /**
     424                 :            :      * Sets the \a distance (in map units) with which the ends of linear features are averaged over when
     425                 :            :      * calculating the direction at which to overrun labels.
     426                 :            :      *
     427                 :            :      * \see overrunSmoothDistance()
     428                 :            :      * \see setOverrunDistance()
     429                 :            :      * \since QGIS 3.10
     430                 :            :      */
     431                 :            :     void setOverrunSmoothDistance( double distance );
     432                 :            : 
     433                 :            :     /**
     434                 :            :      * Returns the percent along the line at which labels should be placed, for line labels only.
     435                 :            :      *
     436                 :            :      * By default, this is 0.5 which indicates that labels should be placed as close to the
     437                 :            :      * center of the line as possible. A value of 0.0 indicates that the labels should be placed
     438                 :            :      * as close to the start of the line as possible, while a value of 1.0 pushes labels towards
     439                 :            :      * the end of the line.
     440                 :            :      *
     441                 :            :      * \see setLineAnchorPercent()
     442                 :            :      * \see lineAnchorType()
     443                 :            :      * \since QGIS 3.16
     444                 :            :      */
     445                 :          0 :     double lineAnchorPercent() const { return mLineAnchorPercent; }
     446                 :            : 
     447                 :            :     /**
     448                 :            :      * Sets the \a percent along the line at which labels should be placed, for line labels only.
     449                 :            :      *
     450                 :            :      * By default, this is 0.5 which indicates that labels should be placed as close to the
     451                 :            :      * center of the line as possible. A value of 0.0 indicates that the labels should be placed
     452                 :            :      * as close to the start of the line as possible, while a value of 1.0 pushes labels towards
     453                 :            :      * the end of the line.
     454                 :            :      *
     455                 :            :      * \see lineAnchorPercent()
     456                 :            :      * \see setLineAnchorType()
     457                 :            :      * \since QGIS 3.16
     458                 :            :      */
     459                 :          0 :     void setLineAnchorPercent( double percent ) { mLineAnchorPercent = percent; }
     460                 :            : 
     461                 :            : 
     462                 :            :     /**
     463                 :            :      * Returns the line anchor type, which dictates how the lineAnchorPercent() setting is
     464                 :            :      * handled.
     465                 :            :      *
     466                 :            :      * \see setLineAnchorType()
     467                 :            :      * \see lineAnchorPercent()
     468                 :            :      */
     469                 :          0 :     QgsLabelLineSettings::AnchorType lineAnchorType() const { return mLineAnchorType; }
     470                 :            : 
     471                 :            :     /**
     472                 :            :      * Sets the line anchor \a type, which dictates how the lineAnchorPercent() setting is
     473                 :            :      * handled.
     474                 :            :      *
     475                 :            :      * \see lineAnchorType()
     476                 :            :      * \see setLineAnchorPercent()
     477                 :            :      */
     478                 :          0 :     void setLineAnchorType( QgsLabelLineSettings::AnchorType type ) { mLineAnchorType = type; }
     479                 :            : 
     480                 :            :     /**
     481                 :            :      * Returns TRUE if all parts of the feature should be labeled.
     482                 :            :      * \see setLabelAllParts()
     483                 :            :      * \since QGIS 3.10
     484                 :            :      */
     485                 :          0 :     bool labelAllParts() const { return mLabelAllParts; }
     486                 :            : 
     487                 :            :     /**
     488                 :            :      * Sets whether all parts of the feature should be labeled.
     489                 :            :      * \see labelAllParts()
     490                 :            :      * \since QGIS 3.10
     491                 :            :      */
     492                 :          0 :     void setLabelAllParts( bool labelAllParts ) { mLabelAllParts = labelAllParts; }
     493                 :            : 
     494                 :            :     /**
     495                 :            :      * Sets an alternate label \a size to be used when a label rotation angle is between 45 to 135
     496                 :            :      * and 235 to 313 degrees and the text rotation mode is set to rotation-based.
     497                 :            :      * \since QGIS 3.10
     498                 :            :      */
     499                 :          0 :     void setRotatedSize( QSizeF size ) { mRotatedSize = size; }
     500                 :            : 
     501                 :            :     /**
     502                 :            :      * Returns the label's obstacle settings.
     503                 :            :      *
     504                 :            :      * \see setObstacleSettings()
     505                 :            :      * \since QGIS 3.12
     506                 :            :      */
     507                 :            :     const QgsLabelObstacleSettings &obstacleSettings() const;
     508                 :            : 
     509                 :            :     /**
     510                 :            :      * Sets the label's obstacle \a settings.
     511                 :            :      *
     512                 :            :      * \see obstacleSettings()
     513                 :            :      * \since QGIS 3.12
     514                 :            :      */
     515                 :            :     void setObstacleSettings( const QgsLabelObstacleSettings &settings );
     516                 :            : 
     517                 :            :     /**
     518                 :            :      * Returns the original layer CRS of the feature associated with the label.
     519                 :            :      *
     520                 :            :      * \see setOriginalFeatureCrs()
     521                 :            :      * \since QGIS 3.20
     522                 :            :      */
     523                 :            :     QgsCoordinateReferenceSystem originalFeatureCrs() const;
     524                 :            : 
     525                 :            :     /**
     526                 :            :      * Sets the original layer \a crs of the feature associated with the label.
     527                 :            :      *
     528                 :            :      * \see originalFeatureCrs()
     529                 :            :      * \since QGIS 3.20
     530                 :            :      */
     531                 :            :     void setOriginalFeatureCrs( const QgsCoordinateReferenceSystem &crs );
     532                 :            : 
     533                 :            :   protected:
     534                 :            :     //! Pointer to PAL layer (assigned when registered to PAL)
     535                 :            :     pal::Layer *mLayer = nullptr;
     536                 :            : 
     537                 :            :     //! Associated ID unique within the parent label provider
     538                 :            :     QgsFeatureId mId;
     539                 :            :     //! Geometry of the feature to be labelled
     540                 :            :     geos::unique_ptr mGeometry;
     541                 :            :     //! Optional geometry to use for label's permissible zone
     542                 :            :     QgsGeometry mPermissibleZone;
     543                 :            :     //! Width and height of the label
     544                 :            :     QSizeF mSize;
     545                 :            :     //! Width and height of the label when rotated between 45 to 135 and 235 to 315 degrees;
     546                 :            :     QSizeF mRotatedSize;
     547                 :            :     //! Visual margin of label contents
     548                 :            :     QgsMargins mVisualMargin;
     549                 :            :     //! Size of associated rendered symbol, if applicable
     550                 :            :     QSizeF mSymbolSize;
     551                 :            :     //! Priority of the label
     552                 :            :     double mPriority = -1;
     553                 :            :     //! Z-index of label (higher z-index labels are rendered on top of lower z-index labels)
     554                 :            :     double mZIndex = 0;
     555                 :            :     //! whether mFixedPosition should be respected
     556                 :            :     bool mHasFixedPosition = false;
     557                 :            :     //! fixed position for the label (instead of automatic placement)
     558                 :            :     QgsPointXY mFixedPosition;
     559                 :            :     //! whether mFixedAngle should be respected
     560                 :            :     bool mHasFixedAngle = false;
     561                 :            :     //! fixed rotation for the label (instead of automatic choice)
     562                 :            :     double mFixedAngle = 0;
     563                 :            :     //! whether mQuadOffset should be respected (only for "around point" placement)
     564                 :            :     bool mHasFixedQuadrant = false;
     565                 :            :     //! whether the side of the label is fixed (only for "around point" placement)
     566                 :            :     QPointF mQuadOffset;
     567                 :            :     //! offset of label from the feature (only for "offset from point" placement)
     568                 :            :     QgsPointXY mPositionOffset;
     569                 :            :     //! distance of label from the feature (only for "around point" placement or linestrings)
     570                 :            :     double mDistLabel = 0;
     571                 :            :     //! Offset type for certain placement modes
     572                 :            :     QgsPalLayerSettings::OffsetType mOffsetType = QgsPalLayerSettings::FromPoint;
     573                 :            :     //! Ordered list of predefined positions for label (only for OrderedPositionsAroundPoint placement)
     574                 :            :     QVector< QgsPalLayerSettings::PredefinedPointPosition > mPredefinedPositionOrder;
     575                 :            :     //! distance after which label should be repeated (only for linestrings)
     576                 :            :     double mRepeatDistance = 0;
     577                 :            :     //! whether to always show label - even in case of collisions
     578                 :            :     bool mAlwaysShow = false;
     579                 :            :     //! text of the label
     580                 :            :     QString mLabelText;
     581                 :            :     //! extra information for curved labels (may be NULLPTR)
     582                 :            :     pal::LabelInfo *mInfo = nullptr;
     583                 :            : 
     584                 :            :     //! Distance to allow label to overrun linear features
     585                 :            :     double mOverrunDistance = 0;
     586                 :            :     //! Distance to smooth angle of line start and end when calculating overruns
     587                 :            :     double mOverrunSmoothDistance = 0;
     588                 :            : 
     589                 :            :     QgsLabeling::LinePlacementFlags mArrangementFlags = QgsLabeling::LinePlacementFlags();
     590                 :            :     QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon;
     591                 :            : 
     592                 :            :   private:
     593                 :            : 
     594                 :            :     //! GEOS geometry on which mPermissibleZoneGeosPrepared is based on
     595                 :            :     geos::unique_ptr mPermissibleZoneGeos;
     596                 :            : 
     597                 :            :     // TODO - not required when QgsGeometry caches geos preparedness
     598                 :            :     geos::prepared_unique_ptr mPermissibleZoneGeosPrepared;
     599                 :            : 
     600                 :            :     QgsFeature mFeature;
     601                 :            : 
     602                 :            :     const QgsSymbol *mSymbol = nullptr;
     603                 :            : 
     604                 :            :     bool mLabelAllParts = false;
     605                 :            : 
     606                 :            :     QgsLabelObstacleSettings mObstacleSettings{};
     607                 :            : 
     608                 :            :     QgsPointXY mAnchorPosition;
     609                 :            : 
     610                 :            :     double mLineAnchorPercent = 0.5;
     611                 :            :     QgsLabelLineSettings::AnchorType mLineAnchorType = QgsLabelLineSettings::AnchorType::HintOnly;
     612                 :            : 
     613                 :            :     QgsCoordinateReferenceSystem mOriginalFeatureCrs;
     614                 :            : };
     615                 :            : 
     616                 :            : #endif // QGSLABELFEATURE_H

Generated by: LCOV version 1.14