Skip to content

Commit 6f368be

Browse files
committedMay 30, 2017
[composer] Allow item rotation from -360->360
Fix #12696
1 parent efe6109 commit 6f368be

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed
 

‎src/app/composer/qgscomposeritemwidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ QgsComposerItemWidget::QgsComposerItemWidget( QWidget *parent, QgsComposerItem *
150150

151151
setupUi( this );
152152

153+
mItemRotationSpinBox->setClearValue( 0 );
154+
153155
//make button exclusive
154156
QButtonGroup *buttonGroup = new QButtonGroup( this );
155157
buttonGroup->addButton( mUpperLeftCheckBox );

‎src/core/composer/qgscomposeritem.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,13 +1009,10 @@ double QgsComposerItem::rectHandlerBorderTolerance() const
10091009

10101010
void QgsComposerItem::setItemRotation( const double r, const bool adjustPosition )
10111011
{
1012-
if ( r >= 360 )
1012+
mItemRotation = r;
1013+
if ( mItemRotation >= 360.0 || mItemRotation <= -360.0 )
10131014
{
1014-
mItemRotation = ( static_cast< int >( r ) ) % 360;
1015-
}
1016-
else
1017-
{
1018-
mItemRotation = r;
1015+
mItemRotation = fmod( mItemRotation, 360.0 );
10191016
}
10201017

10211018
QgsExpressionContext context = createExpressionContext();

‎src/core/composer/qgscomposeritem.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,13 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
427427
*/
428428
bool positionLock() const { return mItemPositionLocked; }
429429

430-
/** Returns the current rotation for the composer item.
431-
* \returns rotation for composer item
430+
/**
431+
* Returns the current rotation for the composer item, in degrees clockwise.
432432
* \param valueType controls whether the returned value is the user specified rotation,
433433
* or the current evaluated rotation (which may be affected by data driven rotation
434434
* settings).
435435
* \since QGIS 2.1
436-
* \see setItemRotation
436+
* \see setItemRotation()
437437
*/
438438
double itemRotation( const QgsComposerObject::PropertyValueType valueType = QgsComposerObject::EvaluatedValue ) const;
439439

@@ -555,14 +555,15 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
555555

556556
public slots:
557557

558-
/** Sets the item rotation
559-
* \param r item rotation in degrees
558+
/**
559+
* Sets the item \a rotation, in degrees clockwise.
560+
* \param rotation item rotation in degrees
560561
* \param adjustPosition set to true if item should be shifted so that rotation occurs
561562
* around item center. If false, rotation occurs around item origin
562563
* \since QGIS 2.1
563564
* \see itemRotation
564565
*/
565-
virtual void setItemRotation( const double r, const bool adjustPosition = false );
566+
virtual void setItemRotation( const double rotation, const bool adjustPosition = false );
566567

567568
void repaint() override;
568569

‎src/ui/composer/qgscomposeritemwidgetbase.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@
374374
<property name="suffix">
375375
<string> °</string>
376376
</property>
377+
<property name="minimum">
378+
<double>-360.000000000000000</double>
379+
</property>
377380
<property name="maximum">
378381
<double>360.000000000000000</double>
379382
</property>

0 commit comments

Comments
 (0)
Please sign in to comment.