[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.
This commit is contained in:
Nyall Dawson 2017-05-30 15:24:01 +10:00
parent 6f368bed6a
commit aaddfedda8
6 changed files with 67 additions and 35 deletions

View File

@ -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

View File

@ -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 );
@ -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 );
}
@ -451,7 +452,7 @@ void QgsComposerMapWidget::on_mScaleLineEdit_editingFinished()
mComposerMap->endCommand();
}
void QgsComposerMapWidget::rotationChanged()
void QgsComposerMapWidget::rotationChanged( double value )
{
if ( !mComposerMap )
{
@ -459,7 +460,7 @@ void QgsComposerMapWidget::rotationChanged()
}
mComposerMap->beginCommand( tr( "Map rotation changed" ), QgsComposerMergeCommand::ComposerMapRotation );
mComposerMap->setMapRotation( mMapRotationSpinBox->value() );
mComposerMap->setMapRotation( value );
mComposerMap->endCommand();
mComposerMap->invalidateCache();
}

View File

@ -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 );

View File

@ -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();
}

View File

@ -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;

View File

@ -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>
@ -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>
@ -797,20 +793,27 @@
<header>qgsspinbox.h</header>
</customwidget>
<customwidget>
<class>QgsComposerItemComboBox</class>
<extends>QComboBox</extends>
<header>qgscomposeritemcombobox.h</header>
</customwidget>
<customwidget>
<class>QgsPropertyOverrideButton</class>
<extends>QToolButton</extends>
<header>qgspropertyoverridebutton.h</header>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsComposerItemComboBox</class>
<extends>QComboBox</extends>
<header>qgscomposeritemcombobox.h</header>
</customwidget>
<customwidget>
<class>QgsProjectionSelectionWidget</class>
<extends>QWidget</extends>
@ -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>