diff --git a/python/core/auto_generated/callouts/qgscallout.sip.in b/python/core/auto_generated/callouts/qgscallout.sip.in index 20fd5fe995a..c760d4e050e 100644 --- a/python/core/auto_generated/callouts/qgscallout.sip.in +++ b/python/core/auto_generated/callouts/qgscallout.sip.in @@ -247,7 +247,7 @@ Returns the feature's anchor point position. %Docstring Sets the feature's ``anchor`` point position. -.. seealso:: :py:func:`drawCalloutToAllParts` +.. seealso:: :py:func:`anchorPoint` %End static QString encodeAnchorPoint( AnchorPoint anchor ); @@ -261,11 +261,11 @@ Encodes an ``anchor`` point to its string representation. static QgsCallout::AnchorPoint decodeAnchorPoint( const QString &name, bool *ok = 0 ); %Docstring -Attempts to decode a string representation of an anchoir point name to the corresponding +Attempts to decode a string representation of an anchor point name to the corresponding anchor point. -:param name: encoded anchoir point name -:param ok: if specified, will be set to ``True`` if the anchoir point was successfully decoded +:param name: encoded anchor point name +:param ok: if specified, will be set to ``True`` if the anchor point was successfully decoded :return: decoded name diff --git a/python/gui/auto_generated/callouts/qgscalloutwidget.sip.in b/python/gui/auto_generated/callouts/qgscalloutwidget.sip.in index c0b70e3ef2e..dcc91a7139f 100644 --- a/python/gui/auto_generated/callouts/qgscalloutwidget.sip.in +++ b/python/gui/auto_generated/callouts/qgscalloutwidget.sip.in @@ -51,8 +51,6 @@ Sets the context in which the symbol widget is shown, e.g., the associated map c :param context: symbol widget context .. seealso:: :py:func:`context` - -.. versionadded:: 3.0 %End QgsSymbolWidgetContext context() const; @@ -60,18 +58,17 @@ Sets the context in which the symbol widget is shown, e.g., the associated map c Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. .. seealso:: :py:func:`setContext` - -.. versionadded:: 3.0 %End const QgsVectorLayer *vectorLayer() const; %Docstring Returns the vector layer associated with the widget. - -.. versionadded:: 2.12 %End virtual void setGeometryType( QgsWkbTypes::GeometryType type ) = 0; +%Docstring +Sets the geometry ``type`` of the features to customize the widget accordingly. +%End protected: diff --git a/src/core/callouts/qgscallout.cpp b/src/core/callouts/qgscallout.cpp index ebae603af66..326649db22e 100644 --- a/src/core/callouts/qgscallout.cpp +++ b/src/core/callouts/qgscallout.cpp @@ -38,7 +38,7 @@ void QgsCallout::initPropertyDefinitions() { QgsCallout::OffsetFromAnchor, QgsPropertyDefinition( "OffsetFromAnchor", QObject::tr( "Offset from feature" ), QgsPropertyDefinition::DoublePositive, origin ) }, { QgsCallout::OffsetFromLabel, QgsPropertyDefinition( "OffsetFromLabel", QObject::tr( "Offset from label" ), QgsPropertyDefinition::DoublePositive, origin ) }, { QgsCallout::DrawCalloutToAllParts, QgsPropertyDefinition( "DrawCalloutToAllParts", QObject::tr( "Draw lines to all feature parts" ), QgsPropertyDefinition::Boolean, origin ) }, - { QgsCallout::AnchorPointPosition, QgsPropertyDefinition( "AnchorPointPosition", QObject::tr( "Feature's anchor point position" ), QgsPropertyDefinition::String, origin ) }, + { QgsCallout::AnchorPointPosition, QgsPropertyDefinition( "AnchorPointPosition", QgsPropertyDefinition::DataTypeString, QObject::tr( "Feature's anchor point position" ), QObject::tr( "string " ) + "[pole_of_inaccessibility|point_on_exterior|point_on_surface|centroid]", origin ) }, }; } @@ -74,7 +74,6 @@ bool QgsCallout::saveProperties( QDomDocument &doc, QDomElement &element, const QDomElement calloutElement = doc.createElement( QStringLiteral( "callout" ) ); calloutElement.setAttribute( QStringLiteral( "type" ), type() ); - calloutElement.setAttribute( QStringLiteral( "anchorPoint" ), encodeAnchorPoint( mAnchorPoint ) ); calloutElement.appendChild( calloutPropsElement ); element.appendChild( calloutElement ); @@ -352,7 +351,6 @@ void QgsSimpleLineCallout::draw( QgsRenderContext &context, QRectF rect, const d line = label.shortestLine( partAnchor ); break; case QgsCallout::Centroid: - default: line = label.shortestLine( partAnchor.centroid() ); break; } @@ -492,7 +490,6 @@ void QgsManhattanLineCallout::draw( QgsRenderContext &context, QRectF rect, cons line = label.shortestLine( partAnchor ); break; case QgsCallout::Centroid: - default: line = label.shortestLine( partAnchor.centroid() ); break; } diff --git a/src/core/callouts/qgscallout.h b/src/core/callouts/qgscallout.h index 0e4cc259470..c62399ae94b 100644 --- a/src/core/callouts/qgscallout.h +++ b/src/core/callouts/qgscallout.h @@ -85,10 +85,10 @@ class CORE_EXPORT QgsCallout //! Feature's anchor point position enum AnchorPoint { - PoleOfInaccessibility = 0, //!< The surface's pole of inaccessibility used as anchor - PointOnExterior, //!< A point on the surface's outline closest to the label is used as anchor - PointOnSurface, //!< A point guaranteed to be on the surface is used as anchor - Centroid, //!< The surface's centroid is used as anchor + PoleOfInaccessibility = 0, //!< The surface's pole of inaccessibility used as anchor for polygon geometries + PointOnExterior, //!< A point on the surface's outline closest to the label is used as anchor for polygon geometries + PointOnSurface, //!< A point guaranteed to be on the surface is used as anchor for polygon geometries + Centroid, //!< The surface's centroid is used as anchor for polygon geometries }; /** @@ -272,7 +272,7 @@ class CORE_EXPORT QgsCallout /** * Sets the feature's \a anchor point position. * - * \see drawCalloutToAllParts() + * \see anchorPoint() */ void setAnchorPoint( AnchorPoint anchor ) { mAnchorPoint = anchor; } @@ -284,10 +284,10 @@ class CORE_EXPORT QgsCallout static QString encodeAnchorPoint( AnchorPoint anchor ); /** - * Attempts to decode a string representation of an anchoir point name to the corresponding + * Attempts to decode a string representation of an anchor point name to the corresponding * anchor point. - * \param name encoded anchoir point name - * \param ok if specified, will be set to TRUE if the anchoir point was successfully decoded + * \param name encoded anchor point name + * \param ok if specified, will be set to TRUE if the anchor point was successfully decoded * \returns decoded name * \see encodeAnchorPoint() */ diff --git a/src/gui/callouts/qgscalloutwidget.cpp b/src/gui/callouts/qgscalloutwidget.cpp index c3e10cb565b..2674471c4e3 100644 --- a/src/gui/callouts/qgscalloutwidget.cpp +++ b/src/gui/callouts/qgscalloutwidget.cpp @@ -212,8 +212,13 @@ void QgsSimpleLineCalloutWidget::setCallout( QgsCallout *callout ) void QgsSimpleLineCalloutWidget::setGeometryType( QgsWkbTypes::GeometryType type ) { - mAnchorPointComboBox->setEnabled( type == QgsWkbTypes::PolygonGeometry ); - mAnchorPointDDBtn->setEnabled( type == QgsWkbTypes::PolygonGeometry ); + bool isPolygon = type == QgsWkbTypes::PolygonGeometry; + mAnchorPointLbl->setEnabled( isPolygon ); + mAnchorPointLbl->setVisible( isPolygon ); + mAnchorPointComboBox->setEnabled( isPolygon ); + mAnchorPointComboBox->setVisible( isPolygon ); + mAnchorPointDDBtn->setEnabled( isPolygon ); + mAnchorPointDDBtn->setVisible( isPolygon ); } QgsCallout *QgsSimpleLineCalloutWidget::callout() diff --git a/src/gui/callouts/qgscalloutwidget.h b/src/gui/callouts/qgscalloutwidget.h index 6ec4e63d0fb..d9f1d8ed605 100644 --- a/src/gui/callouts/qgscalloutwidget.h +++ b/src/gui/callouts/qgscalloutwidget.h @@ -64,23 +64,23 @@ class GUI_EXPORT QgsCalloutWidget : public QWidget, protected QgsExpressionConte * Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * \param context symbol widget context * \see context() - * \since QGIS 3.0 */ virtual void setContext( const QgsSymbolWidgetContext &context ); /** * Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts. * \see setContext() - * \since QGIS 3.0 */ QgsSymbolWidgetContext context() const; /** * Returns the vector layer associated with the widget. - * \since QGIS 2.12 */ const QgsVectorLayer *vectorLayer() const { return mVectorLayer; } + /** + * Sets the geometry \a type of the features to customize the widget accordingly. + */ virtual void setGeometryType( QgsWkbTypes::GeometryType type ) = 0; protected: diff --git a/src/ui/callouts/widget_simplelinecallout.ui b/src/ui/callouts/widget_simplelinecallout.ui index 67b3f8b8c65..eb7ab514cf0 100644 --- a/src/ui/callouts/widget_simplelinecallout.ui +++ b/src/ui/callouts/widget_simplelinecallout.ui @@ -225,7 +225,7 @@ - + Anchor point