Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[composer] Allow map rotation from -360 to 360
Fix #15823

Also reenable instant map refresh as map rotation changes. Since
map refresh is done in the background now, this is safe to reenable.
  • Loading branch information
nyalldawson committed May 30, 2017
1 parent 6f368be commit aaddfed
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 34 deletions.
11 changes: 6 additions & 5 deletions python/core/composer/qgscomposermap.sip
Expand Up @@ -373,20 +373,21 @@ In case of annotations, the bounding rectangle can be larger than the map item r
reimplement setFrameStrokeWidth, so that updateBoundingRect() is called after setting the frame width */
%End

void setMapRotation( double r );
void setMapRotation( double rotation );
%Docstring
Sets rotation for the map - this does not affect the composer item shape, only the
way the map is drawn within the item
Sets the ``rotation`` for the map - this does not affect the composer item shape, only the
way the map is drawn within the item. Rotation is in degrees, clockwise.
.. versionadded:: 2.1
.. seealso:: mapRotation()
%End

double mapRotation( QgsComposerObject::PropertyValueType valueType = QgsComposerObject::EvaluatedValue ) const;
%Docstring
Returns the rotation used for drawing the map within the composer item
:return: rotation for map
Returns the rotation used for drawing the map within 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).
.. seealso:: setMapRotation()
:rtype: float
%End

Expand Down
7 changes: 4 additions & 3 deletions src/app/composer/qgscomposermapwidget.cpp
Expand Up @@ -47,6 +47,7 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap *composerMap )
{
setupUi( this );
setPanelTitle( tr( "Map properties" ) );
mMapRotationSpinBox->setClearValue( 0 );

//add widget for general composer item properties
QgsComposerItemWidget *itemPropertiesWidget = new QgsComposerItemWidget( this, composerMap );
Expand Down Expand Up @@ -116,7 +117,7 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap *composerMap )
loadGridEntries();
loadOverviewEntries();

connect( mMapRotationSpinBox, &QgsDoubleSpinBox::editingFinished, this, &QgsComposerMapWidget::rotationChanged );
connect( mMapRotationSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsComposerMapWidget::rotationChanged );

blockAllSignals( false );
}
Expand Down Expand Up @@ -451,15 +452,15 @@ void QgsComposerMapWidget::on_mScaleLineEdit_editingFinished()
mComposerMap->endCommand();
}

void QgsComposerMapWidget::rotationChanged()
void QgsComposerMapWidget::rotationChanged( double value )
{
if ( !mComposerMap )
{
return;
}

mComposerMap->beginCommand( tr( "Map rotation changed" ), QgsComposerMergeCommand::ComposerMapRotation );
mComposerMap->setMapRotation( mMapRotationSpinBox->value() );
mComposerMap->setMapRotation( value );
mComposerMap->endCommand();
mComposerMap->invalidateCache();
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposermapwidget.h
Expand Up @@ -130,7 +130,7 @@ class QgsComposerMapWidget: public QgsComposerItemBaseWidget, private Ui::QgsCom
//! Blocks / unblocks the signals of all GUI elements
void blockAllSignals( bool b );

void rotationChanged();
void rotationChanged( double value );

void handleChangedFrameDisplay( QgsComposerMapGrid::BorderSide border, const QgsComposerMapGrid::DisplayMode mode );
void handleChangedAnnotationDisplay( QgsComposerMapGrid::BorderSide border, const QString &text );
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -901,12 +901,12 @@ void QgsComposerMap::setOffset( double xOffset, double yOffset )
mYOffset = yOffset;
}

void QgsComposerMap::setMapRotation( double r )
void QgsComposerMap::setMapRotation( double rotation )
{
mMapRotation = r;
mMapRotation = rotation;
mEvaluatedMapRotation = mMapRotation;
invalidateCache();
emit mapRotationChanged( r );
emit mapRotationChanged( rotation );
emit itemChanged();
}

Expand Down
13 changes: 8 additions & 5 deletions src/core/composer/qgscomposermap.h
Expand Up @@ -329,17 +329,20 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
/* reimplement setFrameStrokeWidth, so that updateBoundingRect() is called after setting the frame width */
virtual void setFrameStrokeWidth( const double strokeWidth ) override;

/** Sets rotation for the map - this does not affect the composer item shape, only the
* way the map is drawn within the item
/**
* Sets the \a rotation for the map - this does not affect the composer item shape, only the
* way the map is drawn within the item. Rotation is in degrees, clockwise.
* \since QGIS 2.1
* \see mapRotation()
*/
void setMapRotation( double r );
void setMapRotation( double rotation );

/** Returns the rotation used for drawing the map within the composer item
* \returns rotation for map
/**
* Returns the rotation used for drawing the map within 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).
* \see setMapRotation()
*/
double mapRotation( QgsComposerObject::PropertyValueType valueType = QgsComposerObject::EvaluatedValue ) const;

Expand Down
61 changes: 44 additions & 17 deletions src/ui/composer/qgscomposermapwidgetbase.ui
Expand Up @@ -104,6 +104,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 Expand Up @@ -775,16 +778,9 @@
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
<class>QgsPropertyOverrideButton</class>
<extends>QToolButton</extends>
<header>qgspropertyoverridebutton.h</header>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
Expand All @@ -797,19 +793,26 @@
<header>qgsspinbox.h</header>
</customwidget>
<customwidget>
<class>QgsComposerItemComboBox</class>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgscomposeritemcombobox.h</header>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsPropertyOverrideButton</class>
<extends>QToolButton</extends>
<header>qgspropertyoverridebutton.h</header>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<class>QgsComposerItemComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
<header>qgscomposeritemcombobox.h</header>
</customwidget>
<customwidget>
<class>QgsProjectionSelectionWidget</class>
Expand Down Expand Up @@ -877,6 +880,30 @@
</tabstops>
<resources>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit aaddfed

Please sign in to comment.