Skip to content
Permalink
Browse files

Merge pull request #4646 from nyalldawson/rotation

Unify UX behavior, pt 2: rotation
  • Loading branch information
nyalldawson committed May 31, 2017
2 parents 8ce847f + c019314 commit 77fd7e63eada4d3d0f997bc1f1360dfaac690166
Showing with 460 additions and 244 deletions.
  1. +2 −0 doc/api_break.dox
  2. +6 −5 python/core/composer/qgscomposermap.sip
  3. +4 −6 python/core/effects/qgstransformeffect.sip
  4. +6 −1 python/core/qgsdiagramrenderer.sip
  5. +6 −1 python/core/qgsmapsettings.sip
  6. +7 −1 python/core/qgspallabeling.sip
  7. +2 −3 python/core/qgstextrenderer.sip
  8. +2 −0 src/app/composer/qgscomposeritemwidget.cpp
  9. +4 −3 src/app/composer/qgscomposermapwidget.cpp
  10. +1 −1 src/app/composer/qgscomposermapwidget.h
  11. +1 −1 src/app/dwg/qgsdwgimportdialog.cpp
  12. +1 −1 src/app/qgisapp.cpp
  13. +5 −5 src/app/qgsdiagramproperties.cpp
  14. +1 −1 src/app/qgslabelinggui.cpp
  15. +4 −3 src/app/qgslabelpropertydialog.cpp
  16. +1 −1 src/app/qgsmaptoollabel.cpp
  17. +3 −6 src/core/composer/qgscomposeritem.cpp
  18. +7 −6 src/core/composer/qgscomposeritem.h
  19. +3 −3 src/core/composer/qgscomposermap.cpp
  20. +8 −5 src/core/composer/qgscomposermap.h
  21. +2 −2 src/core/composer/qgscomposerpicture.cpp
  22. +9 −8 src/core/composer/qgscomposerpicture.h
  23. +1 −1 src/core/diagram/qgspiediagram.cpp
  24. +6 −6 src/core/effects/qgstransformeffect.h
  25. +7 −4 src/core/qgsdiagramrenderer.cpp
  26. +7 −2 src/core/qgsdiagramrenderer.h
  27. +2 −1 src/core/qgsmapsettings.cpp
  28. +12 −7 src/core/qgsmapsettings.h
  29. +40 −8 src/core/qgspallabeling.cpp
  30. +6 −2 src/core/qgspallabeling.h
  31. +4 −3 src/core/qgstextrenderer.h
  32. +1 −1 src/core/qgsvectorlayer.cpp
  33. +2 −0 src/gui/effects/qgspainteffectwidget.cpp
  34. +0 −4 src/gui/qgstextformatwidget.cpp
  35. +1 −0 src/gui/symbology-ng/qgs25drendererwidget.cpp
  36. +9 −0 src/gui/symbology-ng/qgssymbollayerwidget.cpp
  37. +1 −0 src/gui/symbology-ng/qgssymbolslistwidget.cpp
  38. +6 −0 src/ui/composer/qgscomposeritemwidgetbase.ui
  39. +47 −17 src/ui/composer/qgscomposermapwidgetbase.ui
  40. +25 −19 src/ui/composer/qgscomposerpicturewidgetbase.ui
  41. +10 −7 src/ui/effects/widget_shadoweffect.ui
  42. +3 −0 src/ui/effects/widget_transform.ui
  43. +22 −16 src/ui/qgslabelpropertydialogbase.ui
  44. +13 −12 src/ui/qgstextformatwidgetbase.ui
  45. +8 −2 src/ui/raster/qgshillshaderendererwidget.ui
  46. +18 −7 src/ui/symbollayer/qgs25drendererwidgetbase.ui
  47. +9 −6 src/ui/symbollayer/widget_ellipse.ui
  48. +6 −0 src/ui/symbollayer/widget_filledmarker.ui
  49. +17 −11 src/ui/symbollayer/widget_fontmarker.ui
  50. +17 −6 src/ui/symbollayer/widget_gradientfill.ui
  51. +6 −0 src/ui/symbollayer/widget_linepatternfill.ui
  52. +6 −0 src/ui/symbollayer/widget_rasterfill.ui
  53. +12 −6 src/ui/symbollayer/widget_simplemarker.ui
  54. +20 −14 src/ui/symbollayer/widget_svgfill.ui
  55. +12 −6 src/ui/symbollayer/widget_svgmarker.ui
  56. +7 −1 src/ui/symbollayer/widget_symbolslist.ui
  57. +12 −12 tests/src/core/testqgsdiagram.cpp
@@ -1024,6 +1024,7 @@ QgsDiagramSettings {#qgis_api_break_3_0_QgsDiagramSettings}
- The SizeType enum was removed. Use QgsUnitTypes.RenderUnit instead.
- readXml() and writeXml() do not take QgsVectorLayer as an argument anymore.
- transparency was removed. Use opacity instead.
- angleOffset was removed. Use rotationOffset instead.


QgsDial {#qgis_api_break_3_0_QgsDial}
@@ -1731,6 +1732,7 @@ members were removed. Use the QgsProperty framework through dataDefinedPropertie
and setDataDefinedProperties() instead.
- readXml() and writeXml() now expect a reference to QgsReadWriteContext.
- fromLayer() has been reoved. Labeling is read/written in QgsAbstractVectorLayerLabeling and its subclasses.
- angleOffset is now in degrees clockwise. QGIS 2.x used degrees counterclockwise.


QgsPanelWidgetStack {#qgis_api_break_3_0_QgsPanelWidgetStack}
@@ -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

@@ -157,16 +157,14 @@ class QgsTransformEffect : QgsPaintEffect

void setRotation( const double rotation );
%Docstring
Sets the transform rotation.
\param rotation degrees to rotate, clockwise
.. seealso:: rotation
Sets the transform ``rotation``, in degrees clockwise.
.. seealso:: rotation()
%End

double rotation() const;
%Docstring
Returns the transform rotation.
:return: rotation in degrees clockwise
.. seealso:: setRotation
Returns the transform rotation, in degrees clockwise.
.. seealso:: setRotation()
:rtype: float
%End

@@ -365,7 +365,12 @@ Opacity, from 0 (transparent) to 1.0 (opaque)
%End

bool scaleByArea;
int angleOffset;

double rotationOffset;
%Docstring
Rotation offset, in degrees clockwise from horizontal.
.. versionadded:: 3.0
%End

bool scaleBasedVisibility;
double minScaleDenominator;
@@ -57,12 +57,17 @@ Set the size of the resulting map image

double rotation() const;
%Docstring
Returns the rotation of the resulting map image, in degrees clockwise.
.. versionadded:: 2.8
.. seealso:: setRotation()
:rtype: float
%End
void setRotation( double degrees );

void setRotation( double rotation );
%Docstring
Sets the ``rotation`` of the resulting map image, in degrees clockwise.
.. versionadded:: 2.8
.. seealso:: rotation()
%End

double outputDpi() const;
@@ -239,6 +239,7 @@ class QgsPalLayerSettings
Hali,
Vali,
Rotation,
LabelRotation,
RepeatDistance,
RepeatDistanceUnit,
Priority,
@@ -346,7 +347,12 @@ Offset type for layer (only applies in certain placement modes)
double yOffset; // offset from point in mm or map units
bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
QgsMapUnitScale labelOffsetMapUnitScale;
double angleOffset; // rotation applied to offset labels

double angleOffset;
%Docstring
Label rotation, in degrees clockwise
%End

bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations

double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
@@ -405,16 +405,15 @@ class QgsTextBackgroundSettings

double rotation() const;
%Docstring
Returns the rotation for the background shape.
Returns the rotation for the background shape, in degrees clockwise.
.. seealso:: rotationType()
.. seealso:: setRotation()
:rtype: float
%End

void setRotation( double rotation );
%Docstring
Sets the rotation for the background shape.
\param rotation angle in degrees to rotate
Sets the ``rotation`` for the background shape, in degrees clockwise.
.. seealso:: rotation()
.. seealso:: setRotationType()
%End
@@ -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 );
@@ -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 );
@@ -396,7 +396,7 @@ void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, QString name, QS
" WHEN alignv=3 THEN 'Top'"
" END"
" END" ).arg( DRW::MTEXT ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::Rotation, QgsProperty::fromExpression( QStringLiteral( "angle*180.0/pi()" ) ) );
pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::LabelRotation, QgsProperty::fromExpression( QStringLiteral( "360-angle*180.0/pi()" ) ) );

pls.placement = QgsPalLayerSettings::OrderedPositionsAroundPoint;
l->setLabeling( new QgsVectorLayerSimpleLabeling( pls ) );
@@ -2589,7 +2589,7 @@ void QgisApp::createStatusBar()
mRotationEdit->setKeyboardTracking( false );
mRotationEdit->setMaximumWidth( 120 );
mRotationEdit->setDecimals( 1 );
mRotationEdit->setRange( -180.0, 180.0 );
mRotationEdit->setRange( -360.0, 360.0 );
mRotationEdit->setWrapping( true );
mRotationEdit->setSingleStep( 5.0 );
mRotationEdit->setFont( myFont );
@@ -147,10 +147,10 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
mScaleDependencyComboBox->addItem( tr( "Area" ), true );
mScaleDependencyComboBox->addItem( tr( "Diameter" ), false );

mAngleOffsetComboBox->addItem( tr( "Top" ), 90 * 16 );
mAngleOffsetComboBox->addItem( tr( "Top" ), 270 );
mAngleOffsetComboBox->addItem( tr( "Right" ), 0 );
mAngleOffsetComboBox->addItem( tr( "Bottom" ), 270 * 16 );
mAngleOffsetComboBox->addItem( tr( "Left" ), 180 * 16 );
mAngleOffsetComboBox->addItem( tr( "Bottom" ), 90 );
mAngleOffsetComboBox->addItem( tr( "Left" ), 180 );

QgsSettings settings;

@@ -283,7 +283,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
mLabelPlacementComboBox->setCurrentIndex( 1 );
}

mAngleOffsetComboBox->setCurrentIndex( mAngleOffsetComboBox->findData( settingList.at( 0 ).angleOffset ) );
mAngleOffsetComboBox->setCurrentIndex( mAngleOffsetComboBox->findData( settingList.at( 0 ).rotationOffset ) );

mOrientationLeftButton->setProperty( "direction", QgsDiagramSettings::Left );
mOrientationRightButton->setProperty( "direction", QgsDiagramSettings::Right );
@@ -779,7 +779,7 @@ void QgsDiagramProperties::apply()
ds.scaleBasedVisibility = mScaleVisibilityGroupBox->isChecked();

// Diagram angle offset (pie)
ds.angleOffset = mAngleOffsetComboBox->currentData().toInt();
ds.rotationOffset = mAngleOffsetComboBox->currentData().toInt();

// Diagram orientation (histogram)
ds.diagramOrientation = static_cast<QgsDiagramSettings::DiagramOrientation>( mOrientationButtonGroup->checkedButton()->property( "direction" ).toInt() );
@@ -545,7 +545,7 @@ void QgsLabelingGui::populateDataDefinedButtons()
mCoordAlignmentHDDBtn->setUsageInfo( ddPlaceInfo );
registerDataDefinedButton( mCoordAlignmentVDDBtn, QgsPalLayerSettings::Vali );
mCoordAlignmentVDDBtn->setUsageInfo( ddPlaceInfo );
registerDataDefinedButton( mCoordRotationDDBtn, QgsPalLayerSettings::Rotation );
registerDataDefinedButton( mCoordRotationDDBtn, QgsPalLayerSettings::LabelRotation );
mCoordRotationDDBtn->setUsageInfo( ddPlaceInfo );

// rendering
@@ -36,6 +36,7 @@ QgsLabelPropertyDialog::QgsLabelPropertyDialog( const QString &layerId, const QS
QDialog( parent, f ), mLabelFont( labelFont ), mCurLabelField( -1 )
{
setupUi( this );
mRotationSpinBox->setClearValue( 0 );
fillHaliComboBox();
fillValiComboBox();

@@ -314,7 +315,7 @@ void QgsLabelPropertyDialog::setDataDefinedValues( QgsVectorLayer *vlayer )
case QgsPalLayerSettings::Color:
mFontColorButton->setColor( QColor( result.toString() ) );
break;
case QgsPalLayerSettings::Rotation:
case QgsPalLayerSettings::LabelRotation:
{
double rot = result.toDouble( &ok );
if ( ok )
@@ -407,7 +408,7 @@ void QgsLabelPropertyDialog::enableDataDefinedWidgets( QgsVectorLayer *vlayer )
case QgsPalLayerSettings::Color:
mFontColorButton->setEnabled( true );
break;
case QgsPalLayerSettings::Rotation:
case QgsPalLayerSettings::LabelRotation:
mRotationSpinBox->setEnabled( true );
break;
//font related properties
@@ -618,7 +619,7 @@ void QgsLabelPropertyDialog::on_mRotationSpinBox_valueChanged( double d )
//null value so that size is reset to default
rotation.clear();
}
insertChangedValue( QgsPalLayerSettings::Rotation, rotation );
insertChangedValue( QgsPalLayerSettings::LabelRotation, rotation );
}

void QgsLabelPropertyDialog::on_mFontColorButton_colorChanged( const QColor &color )
@@ -485,7 +485,7 @@ bool QgsMapToolLabel::layerIsRotatable( QgsVectorLayer *vlayer, int &rotationCol

bool QgsMapToolLabel::labelIsRotatable( QgsVectorLayer *layer, const QgsPalLayerSettings &settings, int &rotationCol ) const
{
QString rColName = dataDefinedColumnName( QgsPalLayerSettings::Rotation, settings );
QString rColName = dataDefinedColumnName( QgsPalLayerSettings::LabelRotation, settings );
rotationCol = layer->fields().lookupField( rColName );
return rotationCol != -1;
}
@@ -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();
@@ -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;

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

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

0 comments on commit 77fd7e6

Please sign in to comment.
You can’t perform that action at this time.