@@ -637,34 +637,47 @@ class CORE_EXPORT QgsImageFillSymbolLayer: public QgsFillSymbolLayer
637
637
bool setSubSymbol ( QgsSymbol *symbol SIP_TRANSFER ) override ;
638
638
639
639
/* *
640
- * Sets the units for the symbol's stroke width.
641
- * \param unit symbol units
640
+ * Sets the \a units fo the symbol's stroke width.
642
641
* \see strokeWidthUnit()
642
+ * \see setStrokeWidthMapUnitScale()
643
643
*/
644
644
void setStrokeWidthUnit ( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
645
645
646
646
/* *
647
647
* Returns the units for the symbol's stroke width.
648
648
* \see setStrokeWidthUnit()
649
+ * \see strokeWidthMapUnitScale()
649
650
*/
650
651
QgsUnitTypes::RenderUnit strokeWidthUnit () const { return mStrokeWidthUnit ; }
651
652
653
+ /* *
654
+ * Sets the stroke width map unit \a scale.
655
+ *
656
+ * \see strokeWidthMapUnitScale()
657
+ * \see setStrokeWidth()
658
+ * \see setStrokeWidthUnit()
659
+ */
652
660
void setStrokeWidthMapUnitScale ( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
661
+
662
+ /* *
663
+ * Returns the stroke width map unit scale.
664
+ *
665
+ * \see setStrokeWidthMapUnitScale()
666
+ * \see strokeWidth()
667
+ * \see strokeWidthUnit()
668
+ *
669
+ * \since QGIS 2.16
670
+ */
653
671
const QgsMapUnitScale &strokeWidthMapUnitScale () const { return mStrokeWidthMapUnitScale ; }
654
672
655
673
void setOutputUnit ( QgsUnitTypes::RenderUnit unit ) override ;
656
674
QgsUnitTypes::RenderUnit outputUnit () const override ;
657
-
658
675
void setMapUnitScale ( const QgsMapUnitScale &scale ) override ;
659
676
QgsMapUnitScale mapUnitScale () const override ;
660
-
661
677
double estimateMaxBleed ( const QgsRenderContext &context ) const override ;
662
-
663
678
double dxfWidth ( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override ;
664
679
QColor dxfColor ( QgsSymbolRenderContext &context ) const override ;
665
-
666
680
Qt::PenStyle dxfPenStyle () const override ;
667
-
668
681
QSet<QString> usedAttributes ( const QgsRenderContext &context ) const override ;
669
682
670
683
protected:
@@ -697,14 +710,23 @@ class CORE_EXPORT QgsRasterFillSymbolLayer: public QgsImageFillSymbolLayer
697
710
{
698
711
public:
699
712
713
+ // ! Fill coordinate modes, dictates fill tiling behavior
700
714
enum FillCoordinateMode
701
715
{
702
- Feature,
703
- Viewport
716
+ Feature, // !< Tiling is based on feature bounding box
717
+ Viewport, // !< Tiling is based on complete map viewport
704
718
};
705
719
720
+ /* *
721
+ * Constructor for QgsRasterFillSymbolLayer, using a raster fill from the
722
+ * specified \a imageFilePath.
723
+ */
706
724
QgsRasterFillSymbolLayer ( const QString &imageFilePath = QString() );
707
725
726
+ /* *
727
+ * Creates a new QgsRasterFillSymbolLayer from a \a properties map. The caller takes
728
+ * ownership of the returned object.
729
+ */
708
730
static QgsSymbolLayer *create ( const QgsStringMap &properties = QgsStringMap() ) SIP_FACTORY;
709
731
710
732
/* *
@@ -883,6 +905,10 @@ class CORE_EXPORT QgsRasterFillSymbolLayer: public QgsImageFillSymbolLayer
883
905
884
906
protected:
885
907
908
+ void applyDataDefinedSettings ( QgsSymbolRenderContext &context ) override ;
909
+
910
+ private:
911
+
886
912
// ! Path to the image file
887
913
QString mImageFilePath ;
888
914
FillCoordinateMode mCoordinateMode = QgsRasterFillSymbolLayer::Feature;
@@ -896,27 +922,39 @@ class CORE_EXPORT QgsRasterFillSymbolLayer: public QgsImageFillSymbolLayer
896
922
QgsUnitTypes::RenderUnit mWidthUnit = QgsUnitTypes::RenderPixels;
897
923
QgsMapUnitScale mWidthMapUnitScale ;
898
924
899
- void applyDataDefinedSettings ( QgsSymbolRenderContext &context ) override ;
900
-
901
- private:
902
-
903
925
// ! Applies the image pattern to the brush
904
926
void applyPattern ( QBrush &brush, const QString &imageFilePath, double width, double opacity,
905
927
const QgsSymbolRenderContext &context );
906
928
};
907
929
908
930
/* *
909
931
* \ingroup core
910
- * A class for svg fill patterns. The class automatically scales the pattern to
911
- the appropriate pixel dimensions of the output device */
932
+ * A class for filling symbols with a repeated SVG file.
933
+ */
912
934
class CORE_EXPORT QgsSVGFillSymbolLayer: public QgsImageFillSymbolLayer
913
935
{
914
936
public:
915
- // ! Constructs SVG fill symbol layer with picture from given absolute path to a SVG file
937
+
938
+ /* *
939
+ * Constructor for QgsSVGFillSymbolLayer, using the SVG picture at the specified absolute file path.
940
+ */
916
941
QgsSVGFillSymbolLayer ( const QString &svgFilePath, double width = 20 , double rotation = 0.0 );
942
+
943
+ /* *
944
+ * Constructor for QgsSVGFillSymbolLayer, using the specified SVG picture data.
945
+ */
917
946
QgsSVGFillSymbolLayer ( const QByteArray &svgData, double width = 20 , double rotation = 0.0 );
918
947
948
+ /* *
949
+ * Creates a new QgsSVGFillSymbolLayer from a \a properties map. The caller takes
950
+ * ownership of the returned object.
951
+ */
919
952
static QgsSymbolLayer *create ( const QgsStringMap &properties = QgsStringMap() ) SIP_FACTORY;
953
+
954
+ /* *
955
+ * Creates a new QgsSVGFillSymbolLayer from a SLD \a element. The caller takes
956
+ * ownership of the returned object.
957
+ */
920
958
static QgsSymbolLayer *createFromSld ( QDomElement &element ) SIP_FACTORY;
921
959
922
960
/* *
@@ -929,60 +967,189 @@ class CORE_EXPORT QgsSVGFillSymbolLayer: public QgsImageFillSymbolLayer
929
967
// implemented from base classes
930
968
931
969
QString layerType () const override ;
932
-
933
970
void startRender ( QgsSymbolRenderContext &context ) override ;
934
971
void stopRender ( QgsSymbolRenderContext &context ) override ;
935
-
936
972
QgsStringMap properties () const override ;
937
-
938
973
QgsSVGFillSymbolLayer *clone () const override SIP_FACTORY;
939
-
940
974
void toSld ( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const override ;
941
975
942
- // getters and setters
976
+ /* *
977
+ * Sets the path to the SVG file to render in the fill.
978
+ *
979
+ * This is usually an absolute file path. Other supported options include
980
+ * - relative paths to folders from the user's SVG search paths
981
+ * - base64 encoded content, prefixed with a 'base64:' string
982
+ * - http(s) paths
983
+ *
984
+ * \see svgFilePath()
985
+ */
943
986
void setSvgFilePath ( const QString &svgPath );
987
+
988
+ /* *
989
+ * Returns the path to the SVG file used to render the fill.
990
+ *
991
+ * \see setSvgFilePath()
992
+ */
944
993
QString svgFilePath () const { return mSvgFilePath ; }
994
+
995
+ /* *
996
+ * Sets the \a width to render the SVG content as within the fill (i.e. the pattern repeat/tile size).
997
+ *
998
+ * Units are specified by setPatternWidthUnit()
999
+ *
1000
+ * \see patternWidth()
1001
+ * \see setPatternWidthUnit()
1002
+ * \see setPatternWidthMapUnitScale(*)
1003
+ */
945
1004
void setPatternWidth ( double width ) { mPatternWidth = width;}
1005
+
1006
+ /* *
1007
+ * Returns the width of the rendered SVG content within the fill (i.e. the pattern repeat/tile size).
1008
+ *
1009
+ * Units are retrieved by patternWidthUnit()
1010
+ *
1011
+ * \see setPatternWidth()
1012
+ * \see patternWidthUnit()
1013
+ * \see patternWidthMapUnitScale(*)
1014
+ */
946
1015
double patternWidth () const { return mPatternWidth ; }
947
1016
1017
+ /* *
1018
+ * Sets the fill color used for rendering the SVG content.
1019
+ *
1020
+ * Fill color is only supported for parameterized SVG files. Color opacity is
1021
+ * ignored if the SVG file does not support parameterized fill opacity.
1022
+ *
1023
+ * \see svgFillColor()
1024
+ * \see setSvgStrokeColor()
1025
+ */
948
1026
void setSvgFillColor ( const QColor &c ) { setColor ( c ); }
1027
+
1028
+ /* *
1029
+ * Returns the fill color used for rendering the SVG content.
1030
+ *
1031
+ * Fill color is only supported for parameterized SVG files.
1032
+ *
1033
+ * \see setSvgFillColor()
1034
+ * \see svgStrokeColor()
1035
+ */
949
1036
QColor svgFillColor () const { return color (); }
950
1037
1038
+ /* *
1039
+ * Sets the stroke color used for rendering the SVG content.
1040
+ *
1041
+ * Stroke color is only supported for parameterized SVG files. Color opacity is
1042
+ * ignored if the SVG file does not support parameterized outline opacity.
1043
+ *
1044
+ * \see svgStrokeColor()
1045
+ * \see setSvgFillColor()
1046
+ */
951
1047
void setSvgStrokeColor ( const QColor &c ) { mSvgStrokeColor = c; }
1048
+
1049
+ /* *
1050
+ * Returns the stroke color used for rendering the SVG content.
1051
+ *
1052
+ * Stroke color is only supported for parameterized SVG files.
1053
+ *
1054
+ * \see setSvgStrokeColor()
1055
+ * \see svgFillColor()
1056
+ */
952
1057
QColor svgStrokeColor () const { return mSvgStrokeColor ; }
1058
+
1059
+ /* *
1060
+ * Sets the stroke width used for rendering the SVG content.
1061
+ *
1062
+ * Stroke width is only supported for parameterized SVG files. Units are
1063
+ * specified via setSvgStrokeWidthUnit()
1064
+ *
1065
+ * \see svgStrokeWidth()
1066
+ * \see setSvgStrokeWidthUnit()
1067
+ * \see setSvgStrokeWidthMapUnitScale()
1068
+ */
953
1069
void setSvgStrokeWidth ( double w ) { mSvgStrokeWidth = w; }
1070
+
1071
+ /* *
1072
+ * Returns the stroke width used for rendering the SVG content.
1073
+ *
1074
+ * Stroke width is only supported for parameterized SVG files. Units are
1075
+ * retrieved via setSvgStrokeWidthUnit()
1076
+ *
1077
+ * \see setSvgStrokeWidth()
1078
+ * \see svgStrokeWidthUnit()
1079
+ * \see svgStrokeWidthMapUnitScale()
1080
+ */
954
1081
double svgStrokeWidth () const { return mSvgStrokeWidth ; }
955
1082
956
1083
/* *
957
- * Sets the units for the width of the SVG images in the pattern.
958
- * \param unit width units
1084
+ * Sets the \a unit for the width of the SVG images in the pattern.
1085
+ *
959
1086
* \see patternWidthUnit()
1087
+ * \see setPatternWidth()
1088
+ * \see setPatternWidthMapUnitScale()
960
1089
*/
961
1090
void setPatternWidthUnit ( QgsUnitTypes::RenderUnit unit ) { mPatternWidthUnit = unit; }
962
1091
963
1092
/* *
964
1093
* Returns the units for the width of the SVG images in the pattern.
1094
+ *
965
1095
* \see setPatternWidthUnit()
1096
+ * \see patternWidth()
1097
+ * \see patternWidthMapUnitScale()
966
1098
*/
967
1099
QgsUnitTypes::RenderUnit patternWidthUnit () const { return mPatternWidthUnit ; }
968
1100
1101
+ /* *
1102
+ * Sets the map unit \a scale for the pattern's width.
1103
+ *
1104
+ * \see patternWidthMapUnitScale()
1105
+ * \see setPatternWidth()
1106
+ * \see setPatternWidthUnit()
1107
+ */
969
1108
void setPatternWidthMapUnitScale ( const QgsMapUnitScale &scale ) { mPatternWidthMapUnitScale = scale; }
1109
+
1110
+ /* *
1111
+ * Returns the map unit scale for the pattern's width.
1112
+ *
1113
+ * \see setPatternWidthMapUnitScale()
1114
+ * \see patternWidth()
1115
+ * \see patternWidthUnit()
1116
+ */
970
1117
const QgsMapUnitScale &patternWidthMapUnitScale () const { return mPatternWidthMapUnitScale ; }
971
1118
972
1119
/* *
973
- * Sets the units for the stroke width.
974
- * \param unit width units
1120
+ * Sets the \a unit for the stroke width.
1121
+ *
975
1122
* \see svgStrokeWidthUnit()
1123
+ * \see setSvgStrokeWidth()
1124
+ * \see setSvgStrokeWidthMapUnitScale()
976
1125
*/
977
1126
void setSvgStrokeWidthUnit ( QgsUnitTypes::RenderUnit unit ) { mSvgStrokeWidthUnit = unit; }
978
1127
979
1128
/* *
980
1129
* Returns the units for the stroke width.
1130
+ *
981
1131
* \see setSvgStrokeWidthUnit()
1132
+ * \see svgStrokeWidth()
1133
+ * \see svgStrokeWidthMapUnitScale()
982
1134
*/
983
1135
QgsUnitTypes::RenderUnit svgStrokeWidthUnit () const { return mSvgStrokeWidthUnit ; }
984
1136
1137
+ /* *
1138
+ * Sets the map unit \a scale for the pattern's stroke.
1139
+ *
1140
+ * \see svgStrokeWidthMapUnitScale()
1141
+ * \see setSvgStrokeWidth()
1142
+ * \see setSvgStrokeWidthUnit()
1143
+ */
985
1144
void setSvgStrokeWidthMapUnitScale ( const QgsMapUnitScale &scale ) { mSvgStrokeWidthMapUnitScale = scale; }
1145
+
1146
+ /* *
1147
+ * Returns the map unit scale for the pattern's stroke.
1148
+ *
1149
+ * \see setSvgStrokeWidthMapUnitScale()
1150
+ * \see svgStrokeWidth()
1151
+ * \see svgStrokeWidthUnit()
1152
+ */
986
1153
const QgsMapUnitScale &svgStrokeWidthMapUnitScale () const { return mSvgStrokeWidthMapUnitScale ; }
987
1154
988
1155
void setOutputUnit ( QgsUnitTypes::RenderUnit unit ) override ;
@@ -992,9 +1159,14 @@ class CORE_EXPORT QgsSVGFillSymbolLayer: public QgsImageFillSymbolLayer
992
1159
QgsMapUnitScale mapUnitScale () const override ;
993
1160
994
1161
protected:
1162
+
1163
+ void applyDataDefinedSettings ( QgsSymbolRenderContext &context ) override ;
1164
+
1165
+ private:
1166
+
995
1167
// ! Width of the pattern (in output units)
996
- double mPatternWidth ;
997
- QgsUnitTypes::RenderUnit mPatternWidthUnit ;
1168
+ double mPatternWidth = 20 ;
1169
+ QgsUnitTypes::RenderUnit mPatternWidthUnit = QgsUnitTypes::RenderMillimeters ;
998
1170
QgsMapUnitScale mPatternWidthMapUnitScale ;
999
1171
1000
1172
// ! SVG data
@@ -1006,14 +1178,11 @@ class CORE_EXPORT QgsSVGFillSymbolLayer: public QgsImageFillSymbolLayer
1006
1178
1007
1179
// param(fill), param(stroke), param(stroke-width) are going
1008
1180
// to be replaced in memory
1009
- QColor mSvgStrokeColor ;
1010
- double mSvgStrokeWidth ;
1011
- QgsUnitTypes::RenderUnit mSvgStrokeWidthUnit ;
1181
+ QColor mSvgStrokeColor = QColor( 35 , 35 , 35 ) ;
1182
+ double mSvgStrokeWidth = 0.2 ;
1183
+ QgsUnitTypes::RenderUnit mSvgStrokeWidthUnit = QgsUnitTypes::RenderMillimeters ;
1012
1184
QgsMapUnitScale mSvgStrokeWidthMapUnitScale ;
1013
1185
1014
- void applyDataDefinedSettings ( QgsSymbolRenderContext &context ) override ;
1015
-
1016
- private:
1017
1186
// ! Helper function that gets the view box from the byte array
1018
1187
void storeViewBox ();
1019
1188
void setDefaultSvgParams (); // fills mSvgFillColor, mSvgStrokeColor, mSvgStrokeWidth with default values for mSvgFilePath
0 commit comments