1 /*************************************************************************** 2 qgstextrenderer.h 3 ----------------- 4 begin : September 2015 5 copyright : (C) Nyall Dawson 6 email : nyall dot dawson at gmail dot com 7 8 *************************************************************************** 9 * * 10 * This program is free software; you can redistribute it and/or modify * 11 * it under the terms of the GNU General Public License as published by * 12 * the Free Software Foundation; either version 2 of the License, or * 13 * (at your option) any later version. * 14 * * 15 ***************************************************************************/ 16 17 #ifndef QGSTEXTRENDERER_PRIVATE_H 18 #define QGSTEXTRENDERER_PRIVATE_H 19 20 #define SIP_NO_FILE 21 22 #include "qgis_core.h" 23 #include "qgstextshadowsettings.h" 24 #include "qgstextbackgroundsettings.h" 25 #include "qgstextformat.h" 26 #include "qgsmapunitscale.h" 27 #include "qgsunittypes.h" 28 #include "qgsapplication.h" 29 #include "qgspainteffect.h" 30 #include "qgssymbollayerreference.h" 31 #include "qgsstringutils.h" 32 33 #include <QSharedData> 34 #include <QPainter> 35 36 /// @cond 37 38 // 39 // W A R N I N G 40 // ------------- 41 // 42 // This file is not part of the QGIS API. It exists purely as an 43 // implementation detail. This header file may change from version to 44 // version without notice, or even be removed. 45 // 46 47 48 class QgsTextBufferSettingsPrivate : public QSharedData 49 { 50 public: 51 QgsTextBufferSettingsPrivate()52 QgsTextBufferSettingsPrivate() 53 : color( Qt::white ) 54 { 55 } 56 QgsTextBufferSettingsPrivate(const QgsTextBufferSettingsPrivate & other)57 QgsTextBufferSettingsPrivate( const QgsTextBufferSettingsPrivate &other ) 58 : QSharedData( other ) 59 , enabled( other.enabled ) 60 , size( other.size ) 61 , sizeUnit( other.sizeUnit ) 62 , sizeMapUnitScale( other.sizeMapUnitScale ) 63 , color( other.color ) 64 , opacity( other.opacity ) 65 , fillBufferInterior( other.fillBufferInterior ) 66 , joinStyle( other.joinStyle ) 67 , blendMode( other.blendMode ) 68 , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr ) 69 { 70 } 71 72 bool enabled = false; 73 double size = 1; 74 QgsUnitTypes::RenderUnit sizeUnit = QgsUnitTypes::RenderMillimeters; 75 QgsMapUnitScale sizeMapUnitScale; 76 QColor color; 77 double opacity = 1.0; 78 bool fillBufferInterior = false; 79 Qt::PenJoinStyle joinStyle = Qt::RoundJoin; 80 QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver; 81 std::unique_ptr< QgsPaintEffect > paintEffect; 82 83 private: 84 QgsTextBufferSettingsPrivate &operator=( const QgsTextBufferSettingsPrivate & ) = delete; 85 }; 86 87 88 class QgsTextBackgroundSettingsPrivate : public QSharedData 89 { 90 public: 91 QgsTextBackgroundSettingsPrivate()92 QgsTextBackgroundSettingsPrivate() 93 : size( QSizeF( 0.0, 0.0 ) ) 94 , offset( QPointF( 0.0, 0.0 ) ) 95 , radii( QSizeF( 0.0, 0.0 ) ) 96 , fillColor( Qt::white ) 97 , strokeColor( Qt::darkGray ) 98 { 99 } 100 QgsTextBackgroundSettingsPrivate(const QgsTextBackgroundSettingsPrivate & other)101 QgsTextBackgroundSettingsPrivate( const QgsTextBackgroundSettingsPrivate &other ) 102 : QSharedData( other ) 103 , enabled( other.enabled ) 104 , type( other.type ) 105 , svgFile( other.svgFile ) 106 , sizeType( other.sizeType ) 107 , size( other.size ) 108 , sizeUnits( other.sizeUnits ) 109 , sizeMapUnitScale( other.sizeMapUnitScale ) 110 , rotationType( other.rotationType ) 111 , rotation( other.rotation ) 112 , offset( other.offset ) 113 , offsetUnits( other.offsetUnits ) 114 , offsetMapUnitScale( other.offsetMapUnitScale ) 115 , radii( other.radii ) 116 , radiiUnits( other.radiiUnits ) 117 , radiiMapUnitScale( other.radiiMapUnitScale ) 118 , blendMode( other.blendMode ) 119 , fillColor( other.fillColor ) 120 , strokeColor( other.strokeColor ) 121 , opacity( other.opacity ) 122 , strokeWidth( other.strokeWidth ) 123 , strokeWidthUnits( other.strokeWidthUnits ) 124 , strokeWidthMapUnitScale( other.strokeWidthMapUnitScale ) 125 , joinStyle( other.joinStyle ) 126 , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr ) 127 , markerSymbol( other.markerSymbol ? other.markerSymbol->clone() : nullptr ) 128 { 129 } 130 131 bool enabled = false; 132 QgsTextBackgroundSettings::ShapeType type = QgsTextBackgroundSettings::ShapeRectangle; 133 QString svgFile; //!< Absolute path to SVG file 134 QgsTextBackgroundSettings::SizeType sizeType = QgsTextBackgroundSettings::SizeBuffer; 135 QSizeF size; 136 QgsUnitTypes::RenderUnit sizeUnits = QgsUnitTypes::RenderMillimeters; 137 QgsMapUnitScale sizeMapUnitScale; 138 QgsTextBackgroundSettings::RotationType rotationType = QgsTextBackgroundSettings::RotationSync; 139 double rotation = 0.0; 140 QPointF offset; 141 QgsUnitTypes::RenderUnit offsetUnits = QgsUnitTypes::RenderMillimeters; 142 QgsMapUnitScale offsetMapUnitScale; 143 QSizeF radii; 144 QgsUnitTypes::RenderUnit radiiUnits = QgsUnitTypes::RenderMillimeters; 145 QgsMapUnitScale radiiMapUnitScale; 146 QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver; 147 QColor fillColor; 148 QColor strokeColor; 149 double opacity = 1.0; 150 double strokeWidth = 0.0; 151 QgsUnitTypes::RenderUnit strokeWidthUnits = QgsUnitTypes::RenderMillimeters; 152 QgsMapUnitScale strokeWidthMapUnitScale; 153 Qt::PenJoinStyle joinStyle = Qt::BevelJoin; 154 std::unique_ptr< QgsPaintEffect > paintEffect; 155 std::unique_ptr< QgsMarkerSymbol > markerSymbol; 156 157 private: 158 QgsTextBackgroundSettingsPrivate &operator=( const QgsTextBackgroundSettingsPrivate & ) = delete; 159 }; 160 161 162 163 class QgsTextShadowSettingsPrivate : public QSharedData 164 { 165 public: 166 QgsTextShadowSettingsPrivate()167 QgsTextShadowSettingsPrivate() 168 : color( QColor( 0, 0, 0 ) ) 169 { 170 171 } 172 QgsTextShadowSettingsPrivate(const QgsTextShadowSettingsPrivate & other)173 QgsTextShadowSettingsPrivate( const QgsTextShadowSettingsPrivate &other ) 174 : QSharedData( other ) 175 , enabled( other.enabled ) 176 , shadowUnder( other.shadowUnder ) 177 , offsetAngle( other.offsetAngle ) 178 , offsetDist( other.offsetDist ) 179 , offsetUnits( other.offsetUnits ) 180 , offsetMapUnitScale( other.offsetMapUnitScale ) 181 , offsetGlobal( other.offsetGlobal ) 182 , radius( other.radius ) 183 , radiusUnits( other.radiusUnits ) 184 , radiusMapUnitScale( other.radiusMapUnitScale ) 185 , radiusAlphaOnly( other.radiusAlphaOnly ) 186 , scale( other.scale ) 187 , color( other.color ) 188 , opacity( other.opacity ) 189 , blendMode( other.blendMode ) 190 { 191 } 192 193 bool enabled = false; 194 QgsTextShadowSettings::ShadowPlacement shadowUnder = QgsTextShadowSettings::ShadowLowest; 195 int offsetAngle = 135; 196 double offsetDist = 1.0; 197 QgsUnitTypes::RenderUnit offsetUnits = QgsUnitTypes::RenderMillimeters; 198 QgsMapUnitScale offsetMapUnitScale; 199 bool offsetGlobal = true; 200 double radius = 1.5; 201 QgsUnitTypes::RenderUnit radiusUnits = QgsUnitTypes::RenderMillimeters; 202 QgsMapUnitScale radiusMapUnitScale; 203 bool radiusAlphaOnly = false; 204 int scale = 100; 205 QColor color; 206 double opacity = 0.7; 207 QPainter::CompositionMode blendMode = QPainter::CompositionMode_Multiply; 208 209 private: 210 QgsTextShadowSettingsPrivate &operator=( const QgsTextShadowSettingsPrivate & ) = delete; 211 }; 212 213 214 class QgsTextMaskSettingsPrivate : public QSharedData 215 { 216 public: 217 QgsTextMaskSettingsPrivate()218 QgsTextMaskSettingsPrivate() 219 { 220 221 } 222 QgsTextMaskSettingsPrivate(const QgsTextMaskSettingsPrivate & other)223 QgsTextMaskSettingsPrivate( const QgsTextMaskSettingsPrivate &other ) 224 : QSharedData( other ) 225 , enabled( other.enabled ) 226 , type( other.type ) 227 , size( other.size ) 228 , sizeUnit( other.sizeUnit ) 229 , sizeMapUnitScale( other.sizeMapUnitScale ) 230 , joinStyle( other.joinStyle ) 231 , opacity( other.opacity ) 232 , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr ) 233 , maskedSymbolLayers( other.maskedSymbolLayers ) 234 { 235 } 236 237 bool enabled = false; 238 QgsTextMaskSettings::MaskType type = QgsTextMaskSettings::MaskBuffer; 239 double size = 1.5; 240 QgsUnitTypes::RenderUnit sizeUnit = QgsUnitTypes::RenderMillimeters; 241 QgsMapUnitScale sizeMapUnitScale; 242 Qt::PenJoinStyle joinStyle = Qt::RoundJoin; 243 double opacity = 1.0; 244 std::unique_ptr< QgsPaintEffect > paintEffect; 245 QgsSymbolLayerReferenceList maskedSymbolLayers; 246 247 private: 248 QgsTextMaskSettingsPrivate &operator=( const QgsTextMaskSettingsPrivate & ) = delete; 249 }; 250 251 252 class QgsTextSettingsPrivate : public QSharedData 253 { 254 public: 255 QgsTextSettingsPrivate()256 QgsTextSettingsPrivate() 257 : textColor( Qt::black ) 258 { 259 } 260 QgsTextSettingsPrivate(const QgsTextSettingsPrivate & other)261 QgsTextSettingsPrivate( const QgsTextSettingsPrivate &other ) 262 : QSharedData( other ) 263 , isValid( other.isValid ) 264 , textFont( other.textFont ) 265 , textNamedStyle( other.textNamedStyle ) 266 , fontSizeUnits( other.fontSizeUnits ) 267 , fontSizeMapUnitScale( other.fontSizeMapUnitScale ) 268 , fontSize( other.fontSize ) 269 , textColor( other.textColor ) 270 , opacity( other.opacity ) 271 , blendMode( other.blendMode ) 272 , multilineHeight( other.multilineHeight ) 273 , orientation( other.orientation ) 274 , previewBackgroundColor( other.previewBackgroundColor ) 275 , allowHtmlFormatting( other.allowHtmlFormatting ) 276 , capitalization( other.capitalization ) 277 , mDataDefinedProperties( other.mDataDefinedProperties ) 278 { 279 } 280 281 bool isValid = false; 282 QFont textFont; 283 QString textNamedStyle; 284 QgsUnitTypes::RenderUnit fontSizeUnits = QgsUnitTypes::RenderPoints; 285 QgsMapUnitScale fontSizeMapUnitScale; 286 double fontSize = 10 ; //may differ from size in textFont due to units (e.g., size in map units) 287 QColor textColor; 288 double opacity = 1.0; 289 QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver; 290 double multilineHeight = 1.0 ; //0.0 to 10.0, leading between lines as multiplyer of line height 291 QgsTextFormat::TextOrientation orientation = QgsTextFormat::HorizontalOrientation; 292 QColor previewBackgroundColor = Qt::white; 293 bool allowHtmlFormatting = false; 294 QgsStringUtils::Capitalization capitalization = QgsStringUtils::MixedCase; 295 296 //! Property collection for data defined settings 297 QgsPropertyCollection mDataDefinedProperties; 298 299 private: 300 QgsTextSettingsPrivate &operator=( const QgsTextSettingsPrivate & ) = delete; 301 }; 302 303 304 305 306 307 /// @endcond 308 309 #endif // QGSTEXTRENDERER_PRIVATE_H 310