Skip to content
Permalink
Browse files
switch to XY coordinate types when using label move tool
  • Loading branch information
domi4484 committed Jan 10, 2022
1 parent fd1b819 commit 9f7353b91c8e0e95bddd2adbcec19bd181212ec0
@@ -0,0 +1,7 @@
# The following has been generated automatically from src/core/labeling/qgslabeling.h
# monkey patching scoped based enum
QgsLabeling.CoordinateType.XY.__doc__ = "Coordinate defined by X and Y values"
QgsLabeling.CoordinateType.Point.__doc__ = "Coordinate defined by a point"
QgsLabeling.CoordinateType.__doc__ = 'Types of coordinate definitions\n\n.. versionadded:: 3.22\n\n' + '* ``XY``: ' + QgsLabeling.CoordinateType.XY.__doc__ + '\n' + '* ``Point``: ' + QgsLabeling.CoordinateType.Point.__doc__
# --
QgsLabeling.CoordinateType.baseClass = QgsLabeling
@@ -20,6 +20,9 @@ Contains constants and enums relating to labeling.
%TypeHeaderCode
#include "qgslabeling.h"
%End
public:
static const QMetaObject staticMetaObject;

public:

enum LinePlacementFlag
@@ -40,6 +43,12 @@ Contains constants and enums relating to labeling.
typedef QFlags<QgsLabeling::PolygonPlacementFlag> PolygonPlacementFlags;


enum class CoordinateType
{
XY,
Point
};

};

QFlags<QgsLabeling::LinePlacementFlag> operator|(QgsLabeling::LinePlacementFlag f1, QFlags<QgsLabeling::LinePlacementFlag> f2);
@@ -218,6 +218,7 @@ Contains settings for how a map layer will be labeled.
// (data defined only)
PositionX,
PositionY,
PositionPoint,
Hali,
Vali,
Rotation,
@@ -419,6 +420,24 @@ Set unit for rotation of labels.

int priority;

QgsLabeling::CoordinateType placementCoordinateType() const;
%Docstring
Coordinates type for data defined placement.

.. seealso:: :py:func:`setPlacementCoordinateType`

.. versionadded:: 3.22
%End

void setPlacementCoordinateType( QgsLabeling::CoordinateType placementCoordinateType );
%Docstring
Set coordinates type for data defined placement.

.. seealso:: :py:func:`placementCoordinateType`

.. versionadded:: 3.22
%End


bool scaleVisibility;

@@ -11,7 +11,7 @@



class QgsAbstractVectorLayerLabeling
class QgsAbstractVectorLayerLabeling : QObject
{
%Docstring(signature="appended")
Abstract base class - its implementations define different approaches to the labeling of a vector layer.
@@ -112,6 +112,10 @@ Returns the default layer settings to use for the specified vector ``layer``.
.. versionadded:: 3.20
%End

signals:

void labelingChanged();

protected:

virtual void writeTextSymbolizer( QDomNode &parent, QgsPalLayerSettings &settings, const QVariantMap &props ) const;
@@ -145,11 +145,9 @@ Sets the background color for the text preview widget.
:param color: background color
%End

void enableDataDefinedAlignment( bool enable );
void updateDataDefinedAlignment();
%Docstring
Controls whether data defined alignment buttons are enabled.

:param enable: set to ``True`` to enable alignment controls
Update the enabled state of the data defined alignment buttons.
%End

virtual QgsExpressionContext createExpressionContext() const;
@@ -354,6 +354,14 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )
}
}

if ( !isCalloutMove
&& vlayer->labeling()->settings().placementCoordinateType() != QgsLabeling::CoordinateType::XY )
{
QgsPalLayerSettings *settings = new QgsPalLayerSettings( mCurrentLabel.settings );
settings->setPlacementCoordinateType( QgsLabeling::CoordinateType::XY );
vlayer->labeling()->setSettings( settings );
}

bool success = vlayer->changeAttributeValue( featureId, xCol, xNewPos );
success = vlayer->changeAttributeValue( featureId, yCol, yNewPos ) && success;

@@ -18,6 +18,7 @@

#include "qgis_core.h"
#include "qgis_sip.h"
#include <QObject>
#include <QFlags>

/**
@@ -30,6 +31,8 @@
*/
class CORE_EXPORT QgsLabeling
{
Q_GADGET

public:

/**
@@ -56,6 +59,18 @@ class CORE_EXPORT QgsLabeling
};
Q_DECLARE_FLAGS( PolygonPlacementFlags, PolygonPlacementFlag )

/**
* Types of coordinate definitions
*
* \since QGIS 3.22
*/
enum class CoordinateType : int
{
XY, //!< Coordinate defined by X and Y values
Point //!< Coordinate defined by a point
};
Q_ENUM( CoordinateType )

};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLabeling::LinePlacementFlags )

0 comments on commit 9f7353b

Please sign in to comment.