Skip to content

Commit

Permalink
Move QgsVector to its own header
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Feb 24, 2017
1 parent 77bc28f commit 520e3c0
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 407 deletions.
1 change: 1 addition & 0 deletions python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
%Include qgstracer.sip
%Include qgstrackedvectorlayertools.sip
%Include qgsunittypes.sip
%Include qgsvector.sip
%Include qgsvectordataprovider.sip
%Include qgsvectorfilewriter.sip
%Include qgsvectorfilewritertask.sip
Expand Down
109 changes: 0 additions & 109 deletions python/core/qgspoint.sip
Original file line number Diff line number Diff line change
@@ -1,112 +1,3 @@
/** \ingroup core
* A class to represent a vector.
* Currently no Z axis / 2.5D support is implemented.
*/

class QgsVector
{
%TypeHeaderCode
#include <qgspoint.h>
%End

public:

/** Default constructor for QgsVector. Creates a vector with length of 0.0.
*/
QgsVector();

/** Constructor for QgsVector taking x and y component values.
* @param x x-component
* @param y y-component
*/
QgsVector( double x, double y );

//! Swaps the sign of the x and y components of the vector.
QgsVector operator-() const;

/** Returns a vector where the components have been multiplied by a scalar value.
* @param scalar factor to multiply by
*/
QgsVector operator*( double scalar ) const;

/** Returns a vector where the components have been divided by a scalar value.
* @param scalar factor to divide by
*/
QgsVector operator/( double scalar ) const;

/** Returns the sum of the x component of this vector multiplied by the x component of another
* vector plus the y component of this vector multiplied by the y component of another vector.
*/
double operator*( QgsVector v ) const;

/**
* Adds another vector to this vector.
* @node added in QGIS 3.0
*/
QgsVector operator+( QgsVector other ) const;

/**
* Adds another vector to this vector in place.
* @node added in QGIS 3.0
*/
QgsVector& operator+=( QgsVector other );

/**
* Subtracts another vector to this vector.
* @node added in QGIS 3.0
*/
QgsVector operator-( QgsVector other ) const;

/**
* Subtracts another vector to this vector in place.
* @node added in QGIS 3.0
*/
QgsVector& operator-=( QgsVector other );

/** Returns the length of the vector.
*/
double length() const;

/** Returns the vector's x-component.
* @see y()
*/
double x() const;

/** Returns the vector's y-component.
* @see x()
*/
double y() const;

/** Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
*/
QgsVector perpVector() const;

/** Returns the angle of the vector in radians.
*/
double angle() const;

/** Returns the angle between this vector and another vector in radians.
*/
double angle( QgsVector v ) const;

/** Rotates the vector by a specified angle.
* @param rot angle in radians
*/
QgsVector rotateBy( double rot ) const;

/** Returns the vector's normalized (or "unit") vector (ie same angle but length of 1.0). Will throw an exception
* if called on a vector with length of 0.
*/
QgsVector normalized() const;

//! Equality operator
bool operator==( QgsVector other ) const;

//! Inequality operator
bool operator!=( QgsVector other ) const;
};


/** \ingroup core
* A class to represent a point.
* Currently no Z axis / 2.5D support is implemented.
Expand Down
47 changes: 47 additions & 0 deletions python/core/qgsvector.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class QgsVector
{
%TypeHeaderCode
#include <qgsvector.h>
%End

public:
QgsVector();

QgsVector( double x, double y );

QgsVector operator-() const;

QgsVector operator*( double scalar ) const;

QgsVector operator/( double scalar ) const;

double operator*( QgsVector v ) const;

QgsVector operator+( QgsVector other ) const;

QgsVector& operator+=( QgsVector other );

QgsVector operator-( QgsVector other ) const;

QgsVector& operator-=( QgsVector other );

double length() const;

double x() const;

double y() const;

QgsVector perpVector() const;

double angle() const;

double angle( QgsVector v ) const;

QgsVector rotateBy( double rot ) const;

QgsVector normalized() const;

bool operator==( QgsVector other ) const;

bool operator!=( QgsVector other ) const;
};
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ SET(QGIS_CORE_SRCS
qgstransaction.cpp
qgstransactiongroup.cpp
qgsunittypes.cpp
qgsvector.cpp
qgsvectordataprovider.cpp
qgsvectorfilewriter.cpp
qgsvectorfilewritertask.cpp
Expand Down Expand Up @@ -781,6 +782,7 @@ SET(QGIS_CORE_HDRS
qgsvectorsimplifymethod.h
qgsmapthemecollection.h
qgsxmlutils.h
qgsvector.h
qgswebpage.h
qgswebframe.h
qgswebview.h
Expand Down
Loading

0 comments on commit 520e3c0

Please sign in to comment.