Skip to content

Commit aaddfed

Browse files
committedMay 30, 2017
[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.
1 parent 6f368be commit aaddfed

File tree

6 files changed

+66
-34
lines changed

6 files changed

+66
-34
lines changed
 

‎python/core/composer/qgscomposermap.sip

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,20 +373,21 @@ In case of annotations, the bounding rectangle can be larger than the map item r
373373
reimplement setFrameStrokeWidth, so that updateBoundingRect() is called after setting the frame width */
374374
%End
375375

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

383384
double mapRotation( QgsComposerObject::PropertyValueType valueType = QgsComposerObject::EvaluatedValue ) const;
384385
%Docstring
385-
Returns the rotation used for drawing the map within the composer item
386-
:return: rotation for map
386+
Returns the rotation used for drawing the map within the composer item, in degrees clockwise.
387387
\param valueType controls whether the returned value is the user specified rotation,
388388
or the current evaluated rotation (which may be affected by data driven rotation
389389
settings).
390+
.. seealso:: setMapRotation()
390391
:rtype: float
391392
%End
392393

‎src/app/composer/qgscomposermapwidget.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap *composerMap )
4747
{
4848
setupUi( this );
4949
setPanelTitle( tr( "Map properties" ) );
50+
mMapRotationSpinBox->setClearValue( 0 );
5051

5152
//add widget for general composer item properties
5253
QgsComposerItemWidget *itemPropertiesWidget = new QgsComposerItemWidget( this, composerMap );
@@ -116,7 +117,7 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap *composerMap )
116117
loadGridEntries();
117118
loadOverviewEntries();
118119

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

121122
blockAllSignals( false );
122123
}
@@ -451,15 +452,15 @@ void QgsComposerMapWidget::on_mScaleLineEdit_editingFinished()
451452
mComposerMap->endCommand();
452453
}
453454

454-
void QgsComposerMapWidget::rotationChanged()
455+
void QgsComposerMapWidget::rotationChanged( double value )
455456
{
456457
if ( !mComposerMap )
457458
{
458459
return;
459460
}
460461

461462
mComposerMap->beginCommand( tr( "Map rotation changed" ), QgsComposerMergeCommand::ComposerMapRotation );
462-
mComposerMap->setMapRotation( mMapRotationSpinBox->value() );
463+
mComposerMap->setMapRotation( value );
463464
mComposerMap->endCommand();
464465
mComposerMap->invalidateCache();
465466
}

‎src/app/composer/qgscomposermapwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class QgsComposerMapWidget: public QgsComposerItemBaseWidget, private Ui::QgsCom
130130
//! Blocks / unblocks the signals of all GUI elements
131131
void blockAllSignals( bool b );
132132

133-
void rotationChanged();
133+
void rotationChanged( double value );
134134

135135
void handleChangedFrameDisplay( QgsComposerMapGrid::BorderSide border, const QgsComposerMapGrid::DisplayMode mode );
136136
void handleChangedAnnotationDisplay( QgsComposerMapGrid::BorderSide border, const QString &text );

‎src/core/composer/qgscomposermap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,12 +901,12 @@ void QgsComposerMap::setOffset( double xOffset, double yOffset )
901901
mYOffset = yOffset;
902902
}
903903

904-
void QgsComposerMap::setMapRotation( double r )
904+
void QgsComposerMap::setMapRotation( double rotation )
905905
{
906-
mMapRotation = r;
906+
mMapRotation = rotation;
907907
mEvaluatedMapRotation = mMapRotation;
908908
invalidateCache();
909-
emit mapRotationChanged( r );
909+
emit mapRotationChanged( rotation );
910910
emit itemChanged();
911911
}
912912

‎src/core/composer/qgscomposermap.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,20 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
329329
/* reimplement setFrameStrokeWidth, so that updateBoundingRect() is called after setting the frame width */
330330
virtual void setFrameStrokeWidth( const double strokeWidth ) override;
331331

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

338-
/** Returns the rotation used for drawing the map within the composer item
339-
* \returns rotation for map
340+
/**
341+
* Returns the rotation used for drawing the map within the composer item, in degrees clockwise.
340342
* \param valueType controls whether the returned value is the user specified rotation,
341343
* or the current evaluated rotation (which may be affected by data driven rotation
342344
* settings).
345+
* \see setMapRotation()
343346
*/
344347
double mapRotation( QgsComposerObject::PropertyValueType valueType = QgsComposerObject::EvaluatedValue ) const;
345348

‎src/ui/composer/qgscomposermapwidgetbase.ui

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
<property name="suffix">
105105
<string> °</string>
106106
</property>
107+
<property name="minimum">
108+
<double>-360.000000000000000</double>
109+
</property>
107110
<property name="maximum">
108111
<double>360.000000000000000</double>
109112
</property>
@@ -775,16 +778,9 @@
775778
<layoutdefault spacing="6" margin="11"/>
776779
<customwidgets>
777780
<customwidget>
778-
<class>QgsScrollArea</class>
779-
<extends>QScrollArea</extends>
780-
<header>qgsscrollarea.h</header>
781-
<container>1</container>
782-
</customwidget>
783-
<customwidget>
784-
<class>QgsCollapsibleGroupBoxBasic</class>
785-
<extends>QGroupBox</extends>
786-
<header>qgscollapsiblegroupbox.h</header>
787-
<container>1</container>
781+
<class>QgsPropertyOverrideButton</class>
782+
<extends>QToolButton</extends>
783+
<header>qgspropertyoverridebutton.h</header>
788784
</customwidget>
789785
<customwidget>
790786
<class>QgsDoubleSpinBox</class>
@@ -797,19 +793,26 @@
797793
<header>qgsspinbox.h</header>
798794
</customwidget>
799795
<customwidget>
800-
<class>QgsComposerItemComboBox</class>
796+
<class>QgsCollapsibleGroupBoxBasic</class>
797+
<extends>QGroupBox</extends>
798+
<header location="global">qgscollapsiblegroupbox.h</header>
799+
<container>1</container>
800+
</customwidget>
801+
<customwidget>
802+
<class>QgsBlendModeComboBox</class>
801803
<extends>QComboBox</extends>
802-
<header>qgscomposeritemcombobox.h</header>
804+
<header>qgsblendmodecombobox.h</header>
803805
</customwidget>
804806
<customwidget>
805-
<class>QgsPropertyOverrideButton</class>
806-
<extends>QToolButton</extends>
807-
<header>qgspropertyoverridebutton.h</header>
807+
<class>QgsScrollArea</class>
808+
<extends>QScrollArea</extends>
809+
<header>qgsscrollarea.h</header>
810+
<container>1</container>
808811
</customwidget>
809812
<customwidget>
810-
<class>QgsBlendModeComboBox</class>
813+
<class>QgsComposerItemComboBox</class>
811814
<extends>QComboBox</extends>
812-
<header>qgsblendmodecombobox.h</header>
815+
<header>qgscomposeritemcombobox.h</header>
813816
</customwidget>
814817
<customwidget>
815818
<class>QgsProjectionSelectionWidget</class>
@@ -877,6 +880,30 @@
877880
</tabstops>
878881
<resources>
879882
<include location="../../../images/images.qrc"/>
883+
<include location="../../../images/images.qrc"/>
884+
<include location="../../../images/images.qrc"/>
885+
<include location="../../../images/images.qrc"/>
886+
<include location="../../../images/images.qrc"/>
887+
<include location="../../../images/images.qrc"/>
888+
<include location="../../../images/images.qrc"/>
889+
<include location="../../../images/images.qrc"/>
890+
<include location="../../../images/images.qrc"/>
891+
<include location="../../../images/images.qrc"/>
892+
<include location="../../../images/images.qrc"/>
893+
<include location="../../../images/images.qrc"/>
894+
<include location="../../../images/images.qrc"/>
895+
<include location="../../../images/images.qrc"/>
896+
<include location="../../../images/images.qrc"/>
897+
<include location="../../../images/images.qrc"/>
898+
<include location="../../../images/images.qrc"/>
899+
<include location="../../../images/images.qrc"/>
900+
<include location="../../../images/images.qrc"/>
901+
<include location="../../../images/images.qrc"/>
902+
<include location="../../../images/images.qrc"/>
903+
<include location="../../../images/images.qrc"/>
904+
<include location="../../../images/images.qrc"/>
905+
<include location="../../../images/images.qrc"/>
906+
<include location="../../../images/images.qrc"/>
880907
</resources>
881908
<connections/>
882909
</ui>

0 commit comments

Comments
 (0)