Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jul 30, 2019
1 parent b68a9c3 commit 0ffd117
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
8 changes: 4 additions & 4 deletions python/core/auto_generated/callouts/qgscallout.sip.in
Expand Up @@ -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 );
Expand All @@ -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

Expand Down
9 changes: 3 additions & 6 deletions python/gui/auto_generated/callouts/qgscalloutwidget.sip.in
Expand Up @@ -51,27 +51,24 @@ 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;
%Docstring
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:

Expand Down
5 changes: 1 addition & 4 deletions src/core/callouts/qgscallout.cpp
Expand Up @@ -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 " ) + "[<b>pole_of_inaccessibility</b>|<b>point_on_exterior</b>|<b>point_on_surface</b>|<b>centroid</b>]", origin ) },
};
}

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions src/core/callouts/qgscallout.h
Expand Up @@ -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
};

/**
Expand Down Expand Up @@ -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; }

Expand All @@ -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()
*/
Expand Down
9 changes: 7 additions & 2 deletions src/gui/callouts/qgscalloutwidget.cpp
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/gui/callouts/qgscalloutwidget.h
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/ui/callouts/widget_simplelinecallout.ui
Expand Up @@ -225,7 +225,7 @@
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_48">
<widget class="QLabel" name="mAnchorPointLbl">
<property name="text">
<string>Anchor point</string>
</property>
Expand Down

0 comments on commit 0ffd117

Please sign in to comment.