Skip to content

Commit c4ec256

Browse files
committed
Tweaked numeric assistant for rotation properties
1 parent a30fe35 commit c4ec256

9 files changed

+51
-15
lines changed

python/core/qgsproperty.sip

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class QgsPropertyDefinition
1414
Double,
1515
DoublePositive,
1616
Double0To1,
17+
Rotation,
1718
String,
1819
Transparency,
1920
RenderUnits,

src/core/composer/qgscomposerobject.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ void QgsComposerObject::initPropertyDefinitions()
4747
{ QgsComposerObject::PositionY, QgsPropertyDefinition( "dataDefinedPositionY" , QObject::tr( "Position (Y)" ), QgsPropertyDefinition::Double ) },
4848
{ QgsComposerObject::ItemWidth, QgsPropertyDefinition( "dataDefinedWidth" , QObject::tr( "Width" ), QgsPropertyDefinition::DoublePositive ) },
4949
{ QgsComposerObject::ItemHeight, QgsPropertyDefinition( "dataDefinedHeight" , QObject::tr( "Height" ), QgsPropertyDefinition::DoublePositive ) },
50-
{ QgsComposerObject::ItemRotation, QgsPropertyDefinition( "dataDefinedRotation" , QObject::tr( "Rotation angle" ), QgsPropertyDefinition::Double ) },
50+
{ QgsComposerObject::ItemRotation, QgsPropertyDefinition( "dataDefinedRotation" , QObject::tr( "Rotation angle" ), QgsPropertyDefinition::Rotation ) },
5151
{ QgsComposerObject::Transparency, QgsPropertyDefinition( "dataDefinedTransparency" , QObject::tr( "Transparency" ), QgsPropertyDefinition::Transparency ) },
5252
{ QgsComposerObject::BlendMode, QgsPropertyDefinition( "dataDefinedBlendMode" , QObject::tr( "Blend mode" ), QgsPropertyDefinition::BlendMode ) },
5353
{ QgsComposerObject::ExcludeFromExports, QgsPropertyDefinition( "dataDefinedExcludeExports", QObject::tr( "Exclude item from exports" ), QgsPropertyDefinition::Boolean ) },
5454
{ QgsComposerObject::FrameColor, QgsPropertyDefinition( "dataDefinedFrameColor", QObject::tr( "Frame color" ), QgsPropertyDefinition::ColorWithAlpha ) },
5555
{ QgsComposerObject::BackgroundColor, QgsPropertyDefinition( "dataDefinedBackgroundColor", QObject::tr( "Background color" ), QgsPropertyDefinition::ColorWithAlpha ) },
56-
{ QgsComposerObject::MapRotation, QgsPropertyDefinition( "dataDefinedMapRotation" , QObject::tr( "Map rotation" ), QgsPropertyDefinition::Double ) },
56+
{ QgsComposerObject::MapRotation, QgsPropertyDefinition( "dataDefinedMapRotation" , QObject::tr( "Map rotation" ), QgsPropertyDefinition::Rotation ) },
5757
{ QgsComposerObject::MapScale, QgsPropertyDefinition( "dataDefinedMapScale" , QObject::tr( "Map scale" ), QgsPropertyDefinition::DoublePositive ) },
5858
{ QgsComposerObject::MapXMin, QgsPropertyDefinition( "dataDefinedMapXMin" , QObject::tr( "Extent minimum X" ), QgsPropertyDefinition::Double ) },
5959
{ QgsComposerObject::MapYMin, QgsPropertyDefinition( "dataDefinedMapYMin" , QObject::tr( "Extent minimum Y" ), QgsPropertyDefinition::Double ) },

src/core/qgsdiagramrenderer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void QgsDiagramLayerSettings::initPropertyDefinitions()
4545
{ QgsDiagramLayerSettings::IsObstacle, QgsPropertyDefinition( "isObstacle", QObject::tr( "Diagram is an obstacle" ), QgsPropertyDefinition::Boolean ) },
4646
{ QgsDiagramLayerSettings::Show, QgsPropertyDefinition( "show", QObject::tr( "Show diagram" ), QgsPropertyDefinition::Boolean ) },
4747
{ QgsDiagramLayerSettings::AlwaysShow, QgsPropertyDefinition( "alwaysShow", QObject::tr( "Always show diagram" ), QgsPropertyDefinition::Boolean ) },
48-
{ QgsDiagramLayerSettings::StartAngle, QgsPropertyDefinition( "startAngle", QObject::tr( "Pie chart start angle" ), QgsPropertyDefinition::Double ) },
48+
{ QgsDiagramLayerSettings::StartAngle, QgsPropertyDefinition( "startAngle", QObject::tr( "Pie chart start angle" ), QgsPropertyDefinition::Rotation ) },
4949
};
5050
}
5151

src/core/qgspallabeling.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void QgsPalLayerSettings::initPropertyDefinitions()
142142
{ QgsPalLayerSettings::ShapeSizeY, QgsPropertyDefinition( "ShapeSizeY", QObject::tr( "Shape size (Y)" ), QgsPropertyDefinition::Double ) },
143143
{ QgsPalLayerSettings::ShapeSizeUnits, QgsPropertyDefinition( "ShapeSizeUnits", QObject::tr( "Shape size units" ), QgsPropertyDefinition::RenderUnits ) },
144144
{ QgsPalLayerSettings::ShapeRotationType, QgsPropertyDefinition( "ShapeRotationType", QgsPropertyDefinition::DataTypeString, QObject::tr( "Shape rotation type" ), QObject::tr( "string " ) + "[<b>Sync</b>|<b>Offset</b>|<b>Fixed</b>]" ) },
145-
{ QgsPalLayerSettings::ShapeRotation, QgsPropertyDefinition( "ShapeRotation", QObject::tr( "Shape rotation" ), QgsPropertyDefinition::Double ) },
145+
{ QgsPalLayerSettings::ShapeRotation, QgsPropertyDefinition( "ShapeRotation", QObject::tr( "Shape rotation" ), QgsPropertyDefinition::Rotation ) },
146146
{ QgsPalLayerSettings::ShapeOffset, QgsPropertyDefinition( "ShapeOffset", QObject::tr( "Shape offset" ), QgsPropertyDefinition::Offset ) },
147147
{ QgsPalLayerSettings::ShapeOffsetUnits, QgsPropertyDefinition( "ShapeOffsetUnits", QObject::tr( "Shape offset units" ), QgsPropertyDefinition::RenderUnits ) },
148148
{ QgsPalLayerSettings::ShapeRadii, QgsPropertyDefinition( "ShapeRadii", QObject::tr( "Shape radii" ), QgsPropertyDefinition::Size2D ) },
@@ -157,7 +157,7 @@ void QgsPalLayerSettings::initPropertyDefinitions()
157157
{ QgsPalLayerSettings::ShadowDraw, QgsPropertyDefinition( "ShadowDraw", QObject::tr( "Draw shadow" ), QgsPropertyDefinition::Boolean ) },
158158
{ QgsPalLayerSettings::ShadowUnder, QgsPropertyDefinition( "ShadowUnder", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), QObject::tr( "string " ) + QStringLiteral( "[<b>Lowest</b>|<b>Text</b>|<br>"
159159
"<b>Buffer</b>|<b>Background</b>]" ) ) },
160-
{ QgsPalLayerSettings::ShadowOffsetAngle, QgsPropertyDefinition( "ShadowOffsetAngle", QObject::tr( "Shadow offset angle" ), QgsPropertyDefinition::Double ) },
160+
{ QgsPalLayerSettings::ShadowOffsetAngle, QgsPropertyDefinition( "ShadowOffsetAngle", QObject::tr( "Shadow offset angle" ), QgsPropertyDefinition::Rotation ) },
161161
{ QgsPalLayerSettings::ShadowOffsetDist, QgsPropertyDefinition( "ShadowOffsetDist", QObject::tr( "Shadow offset distance" ), QgsPropertyDefinition::DoublePositive ) },
162162
{ QgsPalLayerSettings::ShadowOffsetUnits, QgsPropertyDefinition( "ShadowOffsetUnits", QObject::tr( "Shadow offset units" ), QgsPropertyDefinition::RenderUnits ) },
163163
{ QgsPalLayerSettings::ShadowRadius, QgsPropertyDefinition( "ShadowRadius", QObject::tr( "Shadow blur radius" ), QgsPropertyDefinition::DoublePositive ) },
@@ -175,7 +175,7 @@ void QgsPalLayerSettings::initPropertyDefinitions()
175175
{ QgsPalLayerSettings::OffsetUnits, QgsPropertyDefinition( "OffsetUnits", QObject::tr( "Offset units" ), QgsPropertyDefinition::RenderUnits ) },
176176
{ QgsPalLayerSettings::LabelDistance, QgsPropertyDefinition( "LabelDistance", QObject::tr( "Label distance" ), QgsPropertyDefinition::DoublePositive ) },
177177
{ QgsPalLayerSettings::DistanceUnits, QgsPropertyDefinition( "DistanceUnits", QObject::tr( "Label distance units" ), QgsPropertyDefinition::RenderUnits ) },
178-
{ QgsPalLayerSettings::OffsetRotation, QgsPropertyDefinition( "OffsetRotation", QObject::tr( "Offset rotation" ), QgsPropertyDefinition::Double ) },
178+
{ QgsPalLayerSettings::OffsetRotation, QgsPropertyDefinition( "OffsetRotation", QObject::tr( "Offset rotation" ), QgsPropertyDefinition::Rotation ) },
179179
{ QgsPalLayerSettings::CurvedCharAngleInOut, QgsPropertyDefinition( "CurvedCharAngleInOut", QgsPropertyDefinition::DataTypeString, QObject::tr( "Curved character angles" ), QObject::tr( "double coord [<b>in,out</b> as 20.0-60.0,20.0-95.0]" ) ) },
180180
{ QgsPalLayerSettings::RepeatDistance, QgsPropertyDefinition( "RepeatDistance", QObject::tr( "Repeat distance" ), QgsPropertyDefinition::DoublePositive ) },
181181
{ QgsPalLayerSettings::RepeatDistanceUnit, QgsPropertyDefinition( "RepeatDistanceUnit", QObject::tr( "Repeat distance unit" ), QgsPropertyDefinition::RenderUnits ) },
@@ -193,7 +193,7 @@ void QgsPalLayerSettings::initPropertyDefinitions()
193193
{ QgsPalLayerSettings::Hali, QgsPropertyDefinition( "Hali", QgsPropertyDefinition::DataTypeString, QObject::tr( "Horizontal alignment" ), QObject::tr( "string " ) + "[<b>Left</b>|<b>Center</b>|<b>Right</b>]" ) },
194194
{ QgsPalLayerSettings::Vali, QgsPropertyDefinition( "Vali", QgsPropertyDefinition::DataTypeString, QObject::tr( "Vertical alignment" ), QObject::tr( "string " ) + QStringLiteral( "[<b>Bottom</b>|<b>Base</b>|<br>"
195195
"<b>Half</b>|<b>Cap</b>|<b>Top</b>]" ) ) },
196-
{ QgsPalLayerSettings::Rotation, QgsPropertyDefinition( "Rotation", QObject::tr( "Label rotation" ), QgsPropertyDefinition::Double ) },
196+
{ QgsPalLayerSettings::Rotation, QgsPropertyDefinition( "Rotation", QObject::tr( "Label rotation" ), QgsPropertyDefinition::Rotation ) },
197197
{ QgsPalLayerSettings::ScaleVisibility, QgsPropertyDefinition( "ScaleVisibility", QObject::tr( "Scale based visibility" ), QgsPropertyDefinition::Boolean ) },
198198
{ QgsPalLayerSettings::MinScale, QgsPropertyDefinition( "MinScale", QObject::tr( "Minimum scale (denominator)" ), QgsPropertyDefinition::Double ) },
199199
{ QgsPalLayerSettings::MaxScale, QgsPropertyDefinition( "MaxScale", QObject::tr( "Maximum scale (denominator)" ), QgsPropertyDefinition::Double ) },

src/core/qgsproperty.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString& name, const QString
6969
mHelpText = QObject::tr( "double [0.0-1.0]" );
7070
break;
7171

72+
case Rotation:
73+
mTypes = DataTypeNumeric;
74+
mHelpText = QObject::tr( "double [0.0-360.0]" );
75+
break;
76+
7277
case String:
7378
mTypes = DataTypeString;
7479
mHelpText = QObject::tr( "string of variable length" );
@@ -179,7 +184,8 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString& name, DataType data
179184

180185
bool QgsPropertyDefinition::supportsAssistant() const
181186
{
182-
return mTypes == DataTypeNumeric || mStandardType == Size || mStandardType == StrokeWidth || mStandardType == ColorNoAlpha || mStandardType == ColorWithAlpha;
187+
return mTypes == DataTypeNumeric || mStandardType == Size || mStandardType == StrokeWidth || mStandardType == ColorNoAlpha || mStandardType == ColorWithAlpha
188+
|| mStandardType == Rotation;
183189
}
184190

185191
QString QgsPropertyDefinition::trString()

src/core/qgsproperty.h

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class CORE_EXPORT QgsPropertyDefinition
5656
Double, //!< Double value (including negative values)
5757
DoublePositive, //!< Positive double value (including 0)
5858
Double0To1, //!< Double value between 0-1 (inclusive)
59+
Rotation, //!< Rotation (value between 0-360 degrees)
5960
String, //!< Any string value
6061
Transparency, //!< Transparency (0-100)
6162
RenderUnits, //!< Render units (eg mm/pixels/map units)

src/core/symbology-ng/qgssymbollayer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void QgsSymbolLayer::initPropertyDefinitions()
4141
sPropertyDefinitions = QgsPropertiesDefinition
4242
{
4343
{ QgsSymbolLayer::PropertySize, QgsPropertyDefinition( "size", QObject::tr( "Symbol size" ), QgsPropertyDefinition::Size ) },
44-
{ QgsSymbolLayer::PropertyAngle, QgsPropertyDefinition( "angle", QObject::tr( "Rotation angle" ), QgsPropertyDefinition::Double ) },
44+
{ QgsSymbolLayer::PropertyAngle, QgsPropertyDefinition( "angle", QObject::tr( "Rotation angle" ), QgsPropertyDefinition::Rotation ) },
4545
{ QgsSymbolLayer::PropertyName, QgsPropertyDefinition( "name", QObject::tr( "Symbol name" ), QgsPropertyDefinition::String ) },
4646
{ QgsSymbolLayer::PropertyFillColor, QgsPropertyDefinition( "fillColor", QObject::tr( "Symbol fill color" ), QgsPropertyDefinition::ColorWithAlpha ) },
4747
{ QgsSymbolLayer::PropertyOutlineColor, QgsPropertyDefinition( "outlineColor", QObject::tr( "Symbol outline color" ), QgsPropertyDefinition::ColorWithAlpha ) },
@@ -54,7 +54,7 @@ void QgsSymbolLayer::initPropertyDefinitions()
5454
{ QgsSymbolLayer::PropertyFillStyle, QgsPropertyDefinition( "fillStyle", QObject::tr( "Symbol fill style" ), QgsPropertyDefinition::FillStyle )},
5555
{ QgsSymbolLayer::PropertyJoinStyle, QgsPropertyDefinition( "joinStyle", QObject::tr( "Outline join style" ), QgsPropertyDefinition::PenJoinStyle )},
5656
{ QgsSymbolLayer::PropertySecondaryColor, QgsPropertyDefinition( "color2", QObject::tr( "Secondary fill color" ), QgsPropertyDefinition::ColorWithAlpha )},
57-
{ QgsSymbolLayer::PropertyLineAngle, QgsPropertyDefinition( "lineAngle", QObject::tr( "Angle for line fills" ), QgsPropertyDefinition::Double )},
57+
{ QgsSymbolLayer::PropertyLineAngle, QgsPropertyDefinition( "lineAngle", QObject::tr( "Angle for line fills" ), QgsPropertyDefinition::Rotation )},
5858
{ QgsSymbolLayer::PropertyGradientType, QgsPropertyDefinition( "gradientType", QgsPropertyDefinition::DataTypeString, QObject::tr( "Gradient type" ), QObject::tr( "string " ) + QLatin1String( "[<b>linear</b>|<b>radial</b>|<b>conical</b>]" ) )},
5959
{ QgsSymbolLayer::PropertyCoordinateMode, QgsPropertyDefinition( "gradientMode", QgsPropertyDefinition::DataTypeString, QObject::tr( "Gradient mode" ), QObject::tr( "string " ) + QLatin1String( "[<b>feature</b>|<b>viewport</b>]" ) )},
6060
{ QgsSymbolLayer::PropertyGradientSpread, QgsPropertyDefinition( "gradientSpread", QgsPropertyDefinition::DataTypeString, QObject::tr( "Gradient spread" ), QObject::tr( "string " ) + QLatin1String( "[<b>pad</b>|<b>repeat</b>|<b>reflect</b>]" ) )},

src/gui/qgspropertyassistantwidget.cpp

+30-2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ QgsPropertyAssistantWidget::QgsPropertyAssistantWidget( QWidget* parent ,
8787
break;
8888
}
8989

90+
case QgsPropertyDefinition::Rotation:
91+
{
92+
mTransformerWidget = new QgsPropertyGenericNumericAssistantWidget( this, mDefinition, initialState );
93+
break;
94+
}
95+
9096
default:
9197
{
9298
if ( mDefinition.dataType() == QgsPropertyDefinition::DataTypeNumeric )
@@ -467,10 +473,32 @@ QgsPropertyGenericNumericAssistantWidget::QgsPropertyGenericNumericAssistantWidg
467473
layout()->setContentsMargins( 0, 0, 0, 0 );
468474
layout()->setMargin( 0 );
469475

470-
minOutputSpinBox->setShowClearButton( false );
471-
maxOutputSpinBox->setShowClearButton( false );
472476
nullOutputSpinBox->setShowClearButton( false );
473477

478+
if ( definition.standardTemplate() == QgsPropertyDefinition::Rotation )
479+
{
480+
// tweak dialog for rotation
481+
minOutputSpinBox->setMaximum( 360.0 );
482+
minOutputSpinBox->setValue( 0.0 );
483+
minOutputSpinBox->setShowClearButton( true );
484+
minOutputSpinBox->setClearValue( 0.0 );
485+
minOutputSpinBox->setSuffix( tr( " °" ) );
486+
maxOutputSpinBox->setMaximum( 360.0 );
487+
maxOutputSpinBox->setValue( 360.0 );
488+
maxOutputSpinBox->setShowClearButton( true );
489+
maxOutputSpinBox->setClearValue( 360.0 );
490+
maxOutputSpinBox->setSuffix( tr( " °" ) );
491+
exponentSpinBox->hide();
492+
mExponentLabel->hide();
493+
mLabelMinOutput->setText( tr( "Angle from" ) );
494+
mLabelNullOutput->setText( tr( "Angle when NULL" ) );
495+
}
496+
else
497+
{
498+
minOutputSpinBox->setShowClearButton( false );
499+
maxOutputSpinBox->setShowClearButton( false );
500+
}
501+
474502
if ( const QgsGenericNumericTransformer* transform = dynamic_cast< const QgsGenericNumericTransformer* >( initialState.transformer() ) )
475503
{
476504
minOutputSpinBox->setValue( transform->minOutputValue() );

src/ui/qgspropertygenericnumericassistantwidget.ui

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@
2525
</widget>
2626
</item>
2727
<item row="0" column="0">
28-
<widget class="QLabel" name="label_5">
28+
<widget class="QLabel" name="mLabelMinOutput">
2929
<property name="text">
3030
<string>Output from</string>
3131
</property>
3232
</widget>
3333
</item>
3434
<item row="3" column="0">
35-
<widget class="QLabel" name="label_8">
35+
<widget class="QLabel" name="mLabelNullOutput">
3636
<property name="text">
3737
<string>Output when NULL</string>
3838
</property>
3939
</widget>
4040
</item>
4141
<item row="2" column="0">
42-
<widget class="QLabel" name="label_2">
42+
<widget class="QLabel" name="mExponentLabel">
4343
<property name="text">
4444
<string>Exponent</string>
4545
</property>

0 commit comments

Comments
 (0)