Skip to content
Permalink
Browse files

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

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

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

@@ -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,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>
@@ -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.
You can’t perform that action at this time.