Skip to content
Permalink
Browse files

Move QgsVector to its own header

  • Loading branch information
m-kuhn committed Feb 24, 2017
1 parent 77bc28f commit 520e3c082e7015c74159e5b1474a3993360f04f8
Showing with 380 additions and 407 deletions.
  1. +1 −0 python/core/core.sip
  2. +0 −109 python/core/qgspoint.sip
  3. +47 −0 python/core/qgsvector.sip
  4. +2 −0 src/core/CMakeLists.txt
  5. +34 −159 src/core/qgspoint.cpp
  6. +30 −139 src/core/qgspoint.h
  7. +135 −0 src/core/qgsvector.cpp
  8. +131 −0 src/core/qgsvector.h
@@ -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
@@ -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.
@@ -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;
};
@@ -234,6 +234,7 @@ SET(QGIS_CORE_SRCS
qgstransaction.cpp
qgstransactiongroup.cpp
qgsunittypes.cpp
qgsvector.cpp
qgsvectordataprovider.cpp
qgsvectorfilewriter.cpp
qgsvectorfilewritertask.cpp
@@ -781,6 +782,7 @@ SET(QGIS_CORE_HDRS
qgsvectorsimplifymethod.h
qgsmapthemecollection.h
qgsxmlutils.h
qgsvector.h
qgswebpage.h
qgswebframe.h
qgswebview.h

0 comments on commit 520e3c0

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