[Qgis-developer] Data-defined buttons for "en masse" size and rotation

Vincent Mora vincent.mora at oslandia.com
Fri Jan 16 09:29:53 PST 2015


Hi all,

As an attempt  to "Improve GUI consistency & UX for data-defined style" 
(#9881) I'm planing to add a data-defined button[1] to the "en masse" 
size and rotation changing fields [2].

This could *replace* the scaling factor, scaling method and rotation 
available in the 'Advanced' menu.

After that a graphical assistant (accessible from the data-defined 
button) will be developed to help the user define the scale-function 
(preview the various symbol sizes).

I'd like to have your impression on that change, especially on the 
*replace*, and comment on the plan below.

Thanks,

V.

[1] QgsDataDefinedButton: the button already in the Label properties for 
data-defined properties.

[2] What I call the "en masse" size and rotation fields are the fields 
Size and Rotation displayed at the Marker level for simple symbol and 
the popup for size in the graduated, categorized and rule-based 
symbologies (I plan to add rotation there too).








Data defined property buttons will be added to the "en masse" change 
fields for single symbol, graduated, categorized and rule-based 
symbologies.

This is especially useful to be able to use scaling functions to define 
the size of the scaled symbols:
- Flannery (recommanded): scale_exp( variable, minValue, maxValue, 
minSize, maxSize, 0.57 )
- Area : scale_exp( variable, minValue, maxValue, minSize, maxSize, 0.5 )
- Linear : scale_linear( variable, minValue, maxValue, minSize, maxSize )

Using an expression at the "en masse" level will set expressions for all 
symbols composing the marker. The behavior will be the same as with size 
and rotation changing: the expression will be the one of the last symbol 
in the marker, others markers will be scaled/rotated relative to the 
last marker. For the size, if the scalling method is area, the scale 
factor will be put inside the sqrt(). If size/rotation are defined by 
expressions/fields, those definitions will be lost.

Definition: "en masse" expression pattern:
- Size with scale method Area
     - `sqrt( expression )` for the last symbol of the marker
     - `sqrt( symbolSize/lastSymbolOfTheMarkerSize * expression )` for 
other symbols
- Size with scale method Linear
     - `expression` for the last symbol of the marker
     - `(symbolSize/lastSymbolOfTheMarkerSize) * expression` for other 
symbols
- Rotation
     - `expression` for the last symbol of the marker,
     - `expression + (symbolRotation - lastSymbolOfTheMarkerRotation)` 
for other symbols

Disabling "en masse" will disable all size/rotation expressions for 
markers composing the symbol if they match the "en masse" expressions 
pattern.

Note that the data-defined expression at this "en masse" level will only 
be set (yellow highlight) if the size/scale expression of all the 
symbols composing the marker match the "en masse" expression pattern.

To avoid functionality duplication the scale and rotation could be 
removed from the 'Advanced menu'. This  will simplify the symbology 
classes. To ensure backward compatibilities of old project files, the 
following scaling/rotation expression can be defined using old 
scale/rotation parameters to ensure the same rendered map:
- For size
    - newSymbolSizeExpression = sqrt( oldScaleExpression * 
oldSymbolSizeOrSizeExpression )
    or
    - newSymbolSizeExpression = oldScaleExpression * 
oldSymbolSizeOrSizeExpression
- For rotation:
    - newSymbolRotationExpression = oldRotationExpression + 
oldSymbolRotationOrRotationExpression

As a result, if expressions are used for the symbol size/rotation in 
addition to scalling/rotation of the marker, the replaced expressions 
(with scale/rotation included) may not match the "en masse" expression 
pattern and the data defined button will not be highlighted. This seems 
to be a minor and rare inconvenience since it will happen for project 
with scaled/rotated markers composed of multiple symbols with different 
data-defined size/rotation.




More information about the Qgis-developer mailing list