Skip to content

Commit

Permalink
[composer] Allow item rotation from -360->360
Browse files Browse the repository at this point in the history
Fix #12696
  • Loading branch information
nyalldawson committed May 30, 2017
1 parent efe6109 commit 6f368be
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/app/composer/qgscomposeritemwidget.cpp
Expand Up @@ -150,6 +150,8 @@ QgsComposerItemWidget::QgsComposerItemWidget( QWidget *parent, QgsComposerItem *

setupUi( this );

mItemRotationSpinBox->setClearValue( 0 );

//make button exclusive
QButtonGroup *buttonGroup = new QButtonGroup( this );
buttonGroup->addButton( mUpperLeftCheckBox );
Expand Down
9 changes: 3 additions & 6 deletions src/core/composer/qgscomposeritem.cpp
Expand Up @@ -1009,13 +1009,10 @@ double QgsComposerItem::rectHandlerBorderTolerance() const

void QgsComposerItem::setItemRotation( const double r, const bool adjustPosition )
{
if ( r >= 360 )
mItemRotation = r;
if ( mItemRotation >= 360.0 || mItemRotation <= -360.0 )
{
mItemRotation = ( static_cast< int >( r ) ) % 360;
}
else
{
mItemRotation = r;
mItemRotation = fmod( mItemRotation, 360.0 );
}

QgsExpressionContext context = createExpressionContext();
Expand Down
13 changes: 7 additions & 6 deletions src/core/composer/qgscomposeritem.h
Expand Up @@ -427,13 +427,13 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
*/
bool positionLock() const { return mItemPositionLocked; }

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

Expand Down Expand Up @@ -555,14 +555,15 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec

public slots:

/** Sets the item rotation
* \param r item rotation in degrees
/**
* Sets the item \a rotation, in degrees clockwise.
* \param rotation item rotation in degrees
* \param adjustPosition set to true if item should be shifted so that rotation occurs
* around item center. If false, rotation occurs around item origin
* \since QGIS 2.1
* \see itemRotation
*/
virtual void setItemRotation( const double r, const bool adjustPosition = false );
virtual void setItemRotation( const double rotation, const bool adjustPosition = false );

void repaint() override;

Expand Down
3 changes: 3 additions & 0 deletions src/ui/composer/qgscomposeritemwidgetbase.ui
Expand Up @@ -374,6 +374,9 @@
<property name="suffix">
<string> °</string>
</property>
<property name="minimum">
<double>-360.000000000000000</double>
</property>
<property name="maximum">
<double>360.000000000000000</double>
</property>
Expand Down

0 comments on commit 6f368be

Please sign in to comment.