[QGIS-Developer] set data defined override expression with python?

Raymond Nijssen r.nijssen at terglobo.nl
Thu Oct 18 03:56:11 PDT 2018


On 16-10-18 04:19, Nyall Dawson wrote:
> The API uses ints instead of the direct DataDefinedProperty enums, as
> the enums vary by part of code (there's separate enums for symbology,
> labelling, layouts, etc)
> 
> For symbology:
> 
> layer = QgsSvgMarkerSymbolLayer(...)
> ...
> layer.setDataDefinedProperty( QgsSymbolLayer.PropertyName,
> QgsProperty.fromExpression( " some expression ") )
> 
> Nyall
> 


Thanks Nyall, that works!

And now I know the property name, I could also find the other 
properties. And then I started searching the code for more and found the 
ones listed below. Possibly there are more.

It was apparently too hard for me finding these property names and I 
wonder if others are struggling as well. Where could we put this in a 
way where people can find it and where it will be easily to maintain? 
The cookbook?

Regards,
Raymond



QgsAbstract3DSymbol
       PropertyHeight = 0,       //!< Height (altitude)
       PropertyExtrusionHeight,  //!< Extrusion height (zero means no 
extrusion)

QgsLayoutObject
       NoProperty = 0, //!< No property
       AllProperties, //!< All properties for item
       TestProperty, //!< Dummy property with no effect on item
       //composer page properties
       PresetPaperSize, //!< Preset paper size for composition
       PaperWidth, //!< Paper width (deprecated)
       PaperHeight, //!< Paper height (deprecated)
       NumPages, //!< Number of pages in composition (deprecated)
       PaperOrientation, //!< Paper orientation
       //general composer item properties
       PageNumber, //!< Page number for item placement
       PositionX, //!< X position on page
       PositionY, //!< Y position on page
       ItemWidth, //!< Width of item
       ItemHeight, //!< Height of item
       ItemRotation, //!< Rotation of item
       Transparency, //!< Item transparency (deprecated)
       Opacity, //!< Item opacity
       BlendMode, //!< Item blend mode
       ExcludeFromExports, //!< Exclude item from exports
       FrameColor, //!< Item frame color
       BackgroundColor, //!< Item background color
       //composer map
       MapRotation, //!< Map rotation
       MapScale, //!< Map scale
       MapXMin, //!< Map extent x minimum
       MapYMin, //!< Map extent y minimum
       MapXMax, //!< Map extent x maximum
       MapYMax, //!< Map extent y maximum
       MapAtlasMargin, //!< Map atlas margin
       MapLayers, //!< Map layer set
       MapStylePreset, //!< Layer and style map theme
       //composer picture
       PictureSource, //!< Picture source url
       PictureSvgBackgroundColor, //!< SVG background color
       PictureSvgStrokeColor, //!< SVG stroke color
       PictureSvgStrokeWidth, //!< SVG stroke width
       //html item
       SourceUrl, //!< Html source url
       //legend item
       LegendTitle, //!< Legend title
       LegendColumnCount, //!< Legend column count
       //scalebar item
       ScalebarFillColor, //!< Scalebar fill color
       ScalebarFillColor2, //!< Scalebar secondary fill color
       ScalebarLineColor, //!< Scalebar line color
       ScalebarLineWidth, //!< Scalebar line width,
       //table item
       AttributeTableSourceLayer, //!< Attribute table source layer

QgsDiagramLayerSettings
       BackgroundColor, //!< Diagram background color
       StrokeColor, //!< Stroke color
       StrokeWidth, //!< Stroke width
       PositionX, //! x-coordinate data defined diagram position
       PositionY, //! y-coordinate data defined diagram position
       Distance, //! Distance to diagram from feature
       Priority, //! Diagram priority (between 0 and 10)
       ZIndex, //! Z-index for diagram ordering
       IsObstacle, //! Whether diagram features act as obstacles for 
other diagrams/labels
       Show, //! Whether to show the diagram
       AlwaysShow, //! Whether the diagram should always be shown, even 
if it overlaps other diagrams/labels
       StartAngle, //! Angle offset for pie diagram

QgsPalLayerSettings
       Size = 0, //!< Label size
       Bold = 1, //!< Use bold style
       Italic = 2, //!< Use italic style
       Underline = 3, //!< Use underline
       Color = 4, //!< Text color
       Strikeout = 5, //!< Use strikeout
       Family = 6, //!< Font family
       FontStyle = 21, //!< Font style name
       FontSizeUnit = 22, //!< Font size units
       FontTransp = 18, //!< Text transparency (deprecated)
       FontOpacity = 92, //!< Text opacity
       FontCase = 27, //!< Label text case
       FontLetterSpacing = 28, //!< Letter spacing
       FontWordSpacing = 29, //!< Word spacing
       FontBlendMode = 30, //! Text blend mode

       // text formatting
       MultiLineWrapChar = 31,
       AutoWrapLength = 101,
       MultiLineHeight = 32,
       MultiLineAlignment = 33,
       DirSymbDraw = 34,
       DirSymbLeft = 35,
       DirSymbRight = 36,
       DirSymbPlacement = 37,
       DirSymbReverse = 38,
       NumFormat = 39,
       NumDecimals = 40,
       NumPlusSign = 41,

       // text buffer
       BufferDraw = 42,
       BufferSize = 7,
       BufferUnit = 43,
       BufferColor = 8,
       BufferTransp = 19, //!< Buffer transparency (deprecated)
       BufferOpacity = 94, //!< Buffer opacity
       BufferJoinStyle = 44,
       BufferBlendMode = 45,

       // background
       ShapeDraw = 46,
       ShapeKind = 47,
       ShapeSVGFile = 48,
       ShapeSizeType = 49,
       ShapeSizeX = 50,
       ShapeSizeY = 85,
       ShapeSizeUnits = 51,
       ShapeRotationType = 52,
       ShapeRotation = 53,
       ShapeOffset = 54,
       ShapeOffsetUnits = 55,
       ShapeRadii = 56,
       ShapeRadiiUnits = 57,
       ShapeTransparency = 63, //!< Shape transparency (deprecated)
       ShapeOpacity = 93, //!< Shape opacity
       ShapeBlendMode = 64,
       ShapeFillColor = 58,
       ShapeStrokeColor = 59,
       ShapeStrokeWidth = 60,
       ShapeStrokeWidthUnits = 61,
       ShapeJoinStyle = 62,

       // drop shadow
       ShadowDraw = 65,
       ShadowUnder = 66,
       ShadowOffsetAngle = 67,
       ShadowOffsetDist = 68,
       ShadowOffsetUnits = 69,
       ShadowRadius = 70,
       ShadowRadiusUnits = 71,
       ShadowTransparency = 72, //!< Shadow transparency (deprecated)
       ShadowOpacity = 95, //!< Shadow opacity
       ShadowScale = 73,
       ShadowColor = 74,
       ShadowBlendMode = 75,

       // placement
       CentroidWhole = 76,
       OffsetQuad = 77,
       OffsetXY = 78,
       OffsetUnits = 80,
       LabelDistance = 13,
       DistanceUnits = 81,
       OffsetRotation = 82,
       CurvedCharAngleInOut = 83,
       // (data defined only)
       PositionX = 9, //!< X-coordinate data defined label position
       PositionY = 10, //!< Y-coordinate data defined label position
       Hali = 11, //!< Horizontal alignment for data defined label 
position (Left, Center, Right)
       Vali = 12, //!< Vertical alignment for data defined label 
position (Bottom, Base, Half, Cap, Top)
       Rotation = 14, //!< Label rotation (deprecated, for old project 
compatibility only)
       LabelRotation = 96, //!< Label rotation
       RepeatDistance = 84,
       RepeatDistanceUnit = 86,
       Priority = 87,
       PredefinedPositionOrder = 91,

       // rendering
       ScaleVisibility = 23,
       MinScale = 16, //!< Min scale (deprecated, for old project 
compatibility only)
       MinimumScale = 97, //!< Minimum map scale (ie most "zoomed out")
       MaxScale = 17, //!< Max scale (deprecated, for old project 
compatibility only)
       MaximumScale = 98, //!< Maximum map scale (ie most "zoomed in")
       FontLimitPixel = 24,
       FontMinPixel = 25,
       FontMaxPixel = 26,
       IsObstacle = 88,
       ObstacleFactor = 89,
       ZIndex = 90,

       // (data defined only)
       Show = 15,
       AlwaysShow = 20

QgsSymbolLayer
       PropertySize = 0, //!< Symbol size
       PropertyAngle, //!< Symbol angle
       PropertyName, //!< Name, eg shape name for simple markers
       PropertyFillColor, //!< Fill color
       PropertyStrokeColor, //!< Stroke color
       PropertyStrokeWidth, //!< Stroke width
       PropertyStrokeStyle, //!< Stroke style (eg solid, dashed)
       PropertyOffset, //!< Symbol offset
       PropertyCharacter, //!< Character, eg for font marker symbol layers
       PropertyWidth, //!< Symbol width
       PropertyHeight, //!< Symbol height
       PropertyPreserveAspectRatio, //!< Preserve aspect ratio between 
width and height
       PropertyFillStyle, //!< Fill style (eg solid, dots)
       PropertyJoinStyle, //!< Line join style
       PropertySecondaryColor, //!< Secondary color (eg for gradient fills)
       PropertyLineAngle, //!< Line angle
       PropertyLineDistance, //!< Distance between lines
       PropertyGradientType, //!< Gradient fill type
       PropertyCoordinateMode, //!< Gradient coordinate mode
       PropertyGradientSpread, //!< Gradient spread mode
       PropertyGradientReference1X, //!< Gradient reference point 1 x
       PropertyGradientReference1Y, //!< Gradient reference point 1 y
       PropertyGradientReference2X, //!< Gradient reference point 2 x
       PropertyGradientReference2Y, //!< Gradient reference point 2 y
       PropertyGradientReference1IsCentroid, //!< Gradient reference 
point 1 is centroid
       PropertyGradientReference2IsCentroid, //!< Gradient reference 
point 2 is centroid
       PropertyBlurRadius, //!< Shapeburst blur radius
       PropertyShapeburstUseWholeShape, //!< Shapeburst use whole shape
       PropertyShapeburstMaxDistance, //!< Shapeburst fill from edge 
distance
       PropertyShapeburstIgnoreRings, //!< Shapeburst ignore rings
       PropertyFile, //!< Filename, eg for svg files
       PropertyDistanceX, //!< Horizontal distance between points
       PropertyDistanceY, //!< Vertical distance between points
       PropertyDisplacementX, //!< Horizontal displacement
       PropertyDisplacementY, //!< Vertical displacement
       PropertyOpacity, //!< Opacity
       PropertyCustomDash, //!< Custom dash pattern
       PropertyCapStyle, //!< Line cap style
       PropertyPlacement, //!< Line marker placement
       PropertyInterval, //!< Line marker interval
       PropertyOffsetAlongLine, //!< Offset along line
       PropertyHorizontalAnchor, //!< Horizontal anchor point
       PropertyVerticalAnchor, //!< Vertical anchor point
       PropertyLayerEnabled, //!< Whether symbol layer is enabled
       PropertyArrowWidth, //!< Arrow tail width
       PropertyArrowStartWidth, //!< Arrow tail start width
       PropertyArrowHeadLength, //!< Arrow head length
       PropertyArrowHeadThickness, //!< Arrow head thickness
       PropertyArrowHeadType, //!< Arrow head type
       PropertyArrowType, //!< Arrow type

QgsWidgetWrapper
       RootPath = 0, //!< Root path for external resource
       DocumentViewerContent //!< Document type for external resource


More information about the QGIS-Developer mailing list