18 #ifndef QGSPALLABELING_H
19 #define QGSPALLABELING_H
21 #include "qgis_core.h"
25 #include <QFontDatabase>
159 FontLetterSpacing = 28,
160 FontWordSpacing = 29,
162 FontStretchFactor = 113,
165 MultiLineWrapChar = 31,
166 AutoWrapLength = 101,
167 MultiLineHeight = 32,
168 MultiLineAlignment = 33,
169 TextOrientation = 110,
173 DirSymbPlacement = 37,
186 BufferJoinStyle = 44,
187 BufferBlendMode = 45,
191 MaskBufferSize = 105,
192 MaskBufferUnit = 106,
204 ShapeRotationType = 52,
207 ShapeOffsetUnits = 55,
209 ShapeRadiiUnits = 57,
210 ShapeTransparency = 63,
214 ShapeStrokeColor = 59,
215 ShapeStrokeWidth = 60,
216 ShapeStrokeWidthUnits = 61,
222 ShadowOffsetAngle = 67,
223 ShadowOffsetDist = 68,
224 ShadowOffsetUnits = 69,
226 ShadowRadiusUnits = 71,
227 ShadowTransparency = 72,
231 ShadowBlendMode = 75,
241 CurvedCharAngleInOut = 83,
251 RepeatDistanceUnit = 86,
253 PredefinedPositionOrder = 91,
254 LinePlacementOptions = 99,
255 OverrunDistance = 102,
257 PolygonLabelOutside = 109,
258 LineAnchorPercent = 111,
259 LineAnchorClipping = 112,
260 LineAnchorType = 115,
261 LineAnchorTextPoint = 116,
264 ScaleVisibility = 23,
277 AllowDegradedPlacement = 117,
278 OverlapHandling = 118,
329 bool containsAdvancedEffects()
const;
345 bool drawLabels =
true;
360 bool isExpression =
false;
370 Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
375 bool useSubstitutions =
false;
392 int autoWrapLength = 0;
404 bool useMaxLineLengthForAutoWrap =
true;
415 bool formatNumbers =
false;
429 bool plusSign =
false;
456 bool centroidWhole =
false;
463 bool centroidInside =
false;
471 QVector< Qgis::LabelPredefinedPointPosition > predefinedPositionOrder
SIP_SKIP;
476 bool fitInPolygonOnly =
false;
507 double repeatDistance = 0;
561 double angleOffset = 0;
564 bool preserveRotation =
true;
584 double maxCurvedCharAngleIn = 25.0;
590 double maxCurvedCharAngleOut = -25.0;
605 bool scaleVisibility =
false;
617 double maximumScale = 0;
629 double minimumScale = 0;
636 bool fontLimitPixelSize =
false;
643 int fontMinPixelSize = 0;
650 int fontMaxPixelSize = 10000;
659 bool labelPerPart =
false;
664 SIP_PROPERTY( name = limitNumLabels, get = _limitNumLabels, set = _setLimitNumLabels )
665 SIP_PROPERTY( name = maxNumLabels, get = _maxNumLabels, set = _setMaxNumLabels )
666 SIP_PROPERTY( name = minFeatureSize, get = _minFeatureSize, set = _setMinFeatureSize )
667 SIP_PROPERTY( name = obstacle, get = _getIsObstacle, set = _setIsObstacle )
668 SIP_PROPERTY( name = obstacleFactor, get = _getObstacleFactor, set = _setObstacleFactor )
669 SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
670 SIP_PROPERTY( name = placementFlags, get = _getLinePlacementFlags, set = _setLinePlacementFlags )
671 SIP_PROPERTY( name = mergeLines, get = _getMergeLines, set = _setMergeLines )
672 SIP_PROPERTY( name = addDirectionSymbol, get = _getAddDirectionSymbol, set = _setAddDirectionSymbol )
673 SIP_PROPERTY( name = leftDirectionSymbol, get = _getLeftDirectionSymbol, set = _setLeftDirectionSymbol )
674 SIP_PROPERTY( name = rightDirectionSymbol, get = _getRightDirectionSymbol, set = _setRightDirectionSymbol )
675 SIP_PROPERTY( name = reverseDirectionSymbol, get = _getReverseDirectionSymbol, set = _setReverseDirectionSymbol )
676 SIP_PROPERTY( name = placeDirectionSymbol, get = _getPlaceDirectionSymbol, set = _setPlaceDirectionSymbol )
678 SIP_PROPERTY( name = overrunDistance, get = _getOverrunDistance, set = _setOverrunDistance )
679 SIP_PROPERTY( name = overrunDistanceUnit, get = _getOverrunDistanceUnit, set = _setOverrunDistanceUnit )
680 SIP_PROPERTY( name = overrunDistanceMapUnitScale, get = _getOverrunDistanceMapUnitScale, set = _setOverrunDistanceMapUnitScale )
681 SIP_PROPERTY( name = displayAll, get = _getDisplayAll, set = _setDisplayAll )
685 bool _limitNumLabels()
const {
return mThinningSettings.limitNumberOfLabelsEnabled(); }
686 void _setLimitNumLabels(
bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
687 int _maxNumLabels()
const {
return mThinningSettings.maximumNumberLabels(); }
688 void _setMaxNumLabels(
int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
689 double _minFeatureSize()
const {
return mThinningSettings.minimumFeatureSize(); }
690 void _setMinFeatureSize(
double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
691 bool _getIsObstacle()
const {
return mObstacleSettings.isObstacle(); }
692 void _setIsObstacle(
bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
693 double _getObstacleFactor()
const {
return mObstacleSettings.factor(); }
694 void _setObstacleFactor(
double factor ) { mObstacleSettings.setFactor( factor ); }
695 ObstacleType _getObstacleType()
const {
return static_cast< ObstacleType
>( mObstacleSettings.type() ); }
697 unsigned int _getLinePlacementFlags()
const {
return static_cast< unsigned int >( mLineSettings.placementFlags() ); }
698 void _setLinePlacementFlags(
unsigned int flags ) { mLineSettings.setPlacementFlags(
static_cast< QgsLabeling::LinePlacementFlags
>( flags ) ); }
699 bool _getMergeLines()
const {
return mLineSettings.mergeLines(); }
700 void _setMergeLines(
bool merge ) { mLineSettings.setMergeLines( merge ); }
701 bool _getAddDirectionSymbol()
const {
return mLineSettings.addDirectionSymbol(); }
702 void _setAddDirectionSymbol(
bool add ) { mLineSettings.setAddDirectionSymbol( add ); }
703 QString _getLeftDirectionSymbol()
const {
return mLineSettings.leftDirectionSymbol(); }
704 void _setLeftDirectionSymbol(
const QString &symbol ) { mLineSettings.setLeftDirectionSymbol( symbol ); }
705 QString _getRightDirectionSymbol()
const {
return mLineSettings.rightDirectionSymbol(); }
706 void _setRightDirectionSymbol(
const QString &symbol ) { mLineSettings.setRightDirectionSymbol( symbol ); }
707 bool _getReverseDirectionSymbol()
const {
return mLineSettings.reverseDirectionSymbol(); }
708 void _setReverseDirectionSymbol(
bool reverse ) { mLineSettings.setReverseDirectionSymbol( reverse ); }
710 DirectionSymbols _getPlaceDirectionSymbol()
const {
return static_cast< DirectionSymbols
>( mLineSettings.directionSymbolPlacement() ); }
713 double _getOverrunDistance()
const {
return mLineSettings.overrunDistance(); }
714 void _setOverrunDistance(
double distance ) { mLineSettings.setOverrunDistance( distance ); }
717 QgsMapUnitScale _getOverrunDistanceMapUnitScale()
const {
return mLineSettings.overrunDistanceMapUnitScale(); }
718 void _setOverrunDistanceMapUnitScale(
const QgsMapUnitScale &scale ) { mLineSettings.setOverrunDistanceMapUnitScale( scale ); }
733 bool geometryGeneratorEnabled =
false;
760 void calculateLabelSize(
const QFontMetricsF *fm,
const QString &text,
double &labelX,
double &labelY,
const QgsFeature *f =
nullptr,
QgsRenderContext *context =
nullptr,
double *rotatedLabelX
SIP_OUT =
nullptr,
double *rotatedLabelY
SIP_OUT =
nullptr,
763 void calculateLabelSize(
const QFontMetricsF *fm,
const QString &text,
double &labelX,
double &labelY,
const QgsFeature *f =
nullptr,
QgsRenderContext *context =
nullptr,
double *rotatedLabelX
SIP_OUT =
nullptr,
double *rotatedLabelY
SIP_OUT =
nullptr );
973 static QPixmap labelSettingsPreviewPixmap(
const QgsPalLayerSettings &settings, QSize size,
const QString &previewText = QString(),
int padding = 0 );
1001 int mFeaturesToLabel = 0;
1002 int mFeatsSendingToPal = 0;
1003 int mFeatsRegPal = 0;
1018 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
1025 enum DataDefinedValueType
1044 bool dataDefinedValEval( DataDefinedValueType valType,
1046 QVariant &exprVal,
QgsExpressionContext &context,
const QVariant &originalValue = QVariant() );
1048 void parseTextStyle( QFont &labelFont,
1073 QMap<Property, QVariant> dataDefinedValues;
1080 std::unique_ptr< QFontDatabase > mFontDB;
1084 std::unique_ptr< QgsCallout > mCallout;
1091 QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon;
1095 bool mRenderStarted =
false;
1097 QString mLegendString = QObject::tr(
"Aa" );
1104 static void initPropertyDefinitions();
1133 static bool staticWillUseLayer(
const QgsMapLayer *layer );
1174 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1184 static QStringList splitToGraphemes(
const QString &text );
1189 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1193 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1197 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1201 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1205 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1209 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1228 #endif // QGSPALLABELING_H