Skip to content
Permalink
Browse files

Make QgsCoordinateTransform implicitly shared, no longer a QObject

There was no code in core using the signals/slots associated with
QgsCoordinateTransform, and little reason to keep the class a
QObject. Making it not a QObject simplifies code and allows
QgsCoordinateTransform objects to be easily copied and passed
around without complication.
  • Loading branch information
nyalldawson committed Jul 16, 2016
1 parent 6fefbea commit 736aab195f91105bd30f1ce7ccb4f57b74041225
@@ -21,6 +21,8 @@ This page tries to maintain a list with incompatible changes that happened in pr
\subsection qgis_api_break_3_0_QgsCoordinateTransform QgsCoordinateTransform

<ul>
<li>QgsCoordinateTransform is no longer a QObject. readXml, writeXml and initialise are all normal public members now,
not slots. The invalidTransformInput() signal has been removed.</li>
<li>sourceCrs() and destCrs() now return a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
plugins calling these methods will need to be updated.</li>
</ul>
@@ -7,19 +7,29 @@
* layer's coordinate system and the coordinate system of the map canvas, although
* it can be used in a more general sense to transform coordinates.
*
* All references to source and destination coordinate systems refer to
* layer and map canvas respectively. All operations are from the perspective
* of the layer. For example, a forward transformation transforms coordinates from the
* layers coordinate system to the map canvas.
* When used to transform between a layer and the map canvas, all references to source
* and destination coordinate systems refer to layer and map canvas respectively. All
* operations are from the perspective of the layer. For example, a forward transformation
* transforms coordinates from the layer's coordinate system to the map canvas.
* \note Since QGIS 3.0 QgsCoordinateReferenceSystem objects are implicitly shared.
*/
class QgsCoordinateTransform : QObject

class QgsCoordinateTransform
{
%TypeHeaderCode
#include <qgscoordinatetransform.h>
%End

public:
/** Default constructor. Make sure you use initialized() manually if you use this one! */

//! Enum used to indicate the direction (forward or inverse) of the transform
enum TransformDirection
{
ForwardTransform, /*!< Transform from source to destination CRS. */
ReverseTransform /*!< Transform from destination to source CRS. */
};

/** Default constructor, creates an invalid QgsCoordinateTransform. */
QgsCoordinateTransform();

/** Constructs a QgsCoordinateTransform using QgsCoordinateReferenceSystem objects.
@@ -56,13 +66,6 @@ class QgsCoordinateTransform : QObject

QgsCoordinateTransform* clone() const /Factory/;

//! Enum used to indicate the direction (forward or inverse) of the transform
enum TransformDirection
{
ForwardTransform, /*!< Transform from source to destination CRS. */
ReverseTransform /*!< Transform from destination to source CRS. */
};

/*!
* Set the source (layer) QgsCoordinateReferenceSystem
* @param theCRS QgsCoordinateReferenceSystem representation of the layer's coordinate system
@@ -196,24 +199,20 @@ class QgsCoordinateTransform : QObject
int destinationDatumTransform() const;
void setDestinationDatumTransform( int dt );

public slots:
//!initialize is used to actually create the Transformer instance
void initialise();

/** Restores state from the given Dom node.
* @param theNode The node from which state will be restored
* @return bool True on success, False on failure
*/
bool readXML( QDomNode & theNode );
bool readXML( const QDomNode & theNode );

/** Stores state to the given Dom node in the given document
* @param theNode The node in which state will be restored
* @param theDoc The document in which state will be stored
* @return bool True on success, False on failure
*/
bool writeXML( QDomNode & theNode, QDomDocument & theDoc );
bool writeXML( QDomNode & theNode, QDomDocument & theDoc ) const;

signals:
/** Signal when an invalid pj_transform() has occurred */
void invalidTransformInput() const;
};
@@ -454,7 +454,6 @@ SET(QGIS_CORE_MOC_HDRS
qgsapplication.h
qgsbrowsermodel.h
qgscontexthelp.h
qgscoordinatetransform.h
qgscredentials.h
qgsdataitem.h
qgsdataprovider.h
@@ -620,6 +619,8 @@ SET(QGIS_CORE_HDRS
qgsconditionalstyle.h
qgscoordinatereferencesystem.h
qgscoordinatereferencesystem_p.h
qgscoordinatetransform.h
qgscoordinatetransform_p.h
qgscoordinateutils.h
qgscrscache.h
qgscsexception.h

0 comments on commit 736aab1

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