Skip to content

Commit 2d7b2ec

Browse files
committedApr 30, 2017
- Supporting automated sip generation for qgsdataitem and qgsvector classes
- Removed qgsdataitem.sip and qgsvector.sip from auto_sip.blacklist - Annotated qgsdataitem.h for sip - regenerated automatically qgsdataitem.sip and qgsvector.sip
1 parent fe2f111 commit 2d7b2ec

File tree

4 files changed

+596
-239
lines changed

4 files changed

+596
-239
lines changed
 

‎python/auto_sip.blacklist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
core/conversions.sip
22
core/qgsexception.sip
33
core/qgis.sip
4-
core/qgsdataitem.sip
54
core/qgsdataitemprovider.sip
65
core/qgsdataitemproviderregistry.sip
76
core/qgsdbfilterproxymodel.sip
@@ -98,7 +97,6 @@ core/qgstolerance.sip
9897
core/qgstracer.sip
9998
core/qgstrackedvectorlayertools.sip
10099
core/qgsunittypes.sip
101-
core/qgsvector.sip
102100
core/qgsvectordataprovider.sip
103101
core/qgsvectorfilewriter.sip
104102
core/qgsvectorfilewritertask.sip

‎python/core/qgsdataitem.sip

Lines changed: 444 additions & 223 deletions
Large diffs are not rendered by default.

‎python/core/qgsvector.sip

Lines changed: 120 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,163 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsvector.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
111
class QgsVector
212
{
3-
%TypeHeaderCode
4-
#include <qgsvector.h>
13+
%Docstring
14+
A class to represent a vector.
15+
Currently no Z axis / 2.5D support is implemented.
516
%End
617

18+
%TypeHeaderCode
19+
#include "qgsvector.h"
20+
%End
721
public:
22+
823
QgsVector();
24+
%Docstring
25+
Default constructor for QgsVector. Creates a vector with length of 0.0.
26+
%End
927

1028
QgsVector( double x, double y );
29+
%Docstring
30+
Constructor for QgsVector taking x and y component values.
31+
\param x x-component
32+
\param y y-component
33+
%End
1134

1235
QgsVector operator-() const;
36+
%Docstring
37+
Swaps the sign of the x and y components of the vector.
38+
:rtype: QgsVector
39+
%End
1340

1441
QgsVector operator*( double scalar ) const;
42+
%Docstring
43+
Returns a vector where the components have been multiplied by a scalar value.
44+
\param scalar factor to multiply by
45+
:rtype: QgsVector
46+
%End
1547

1648
QgsVector operator/( double scalar ) const;
49+
%Docstring
50+
Returns a vector where the components have been divided by a scalar value.
51+
\param scalar factor to divide by
52+
:rtype: QgsVector
53+
%End
1754

1855
double operator*( QgsVector v ) const;
56+
%Docstring
57+
Returns the dot product of two vectors, which is the sum of the x component
58+
of this vector multiplied by the x component of another
59+
vector plus the y component of this vector multiplied by the y component of another vector.
60+
:rtype: float
61+
%End
1962

2063
QgsVector operator+( QgsVector other ) const;
64+
%Docstring
65+
Adds another vector to this vector.
66+
.. versionadded:: 3.0
67+
:rtype: QgsVector
68+
%End
2169

22-
QgsVector& operator+=( QgsVector other );
70+
QgsVector &operator+=( QgsVector other );
71+
%Docstring
72+
Adds another vector to this vector in place.
73+
.. versionadded:: 3.0
74+
:rtype: QgsVector
75+
%End
2376

2477
QgsVector operator-( QgsVector other ) const;
78+
%Docstring
79+
Subtracts another vector to this vector.
80+
.. versionadded:: 3.0
81+
:rtype: QgsVector
82+
%End
2583

26-
QgsVector& operator-=( QgsVector other );
84+
QgsVector &operator-=( QgsVector other );
85+
%Docstring
86+
Subtracts another vector to this vector in place.
87+
.. versionadded:: 3.0
88+
:rtype: QgsVector
89+
%End
2790

2891
double length() const;
92+
%Docstring
93+
Returns the length of the vector.
94+
:rtype: float
95+
%End
2996

3097
double x() const;
98+
%Docstring
99+
Returns the vector's x-component.
100+
\see y()
101+
:rtype: float
102+
%End
31103

32104
double y() const;
105+
%Docstring
106+
Returns the vector's y-component.
107+
\see x()
108+
:rtype: float
109+
%End
33110

34111
QgsVector perpVector() const;
112+
%Docstring
113+
Returns the perpendicular vector to this vector (rotated 90 degrees counter-clockwise)
114+
:rtype: QgsVector
115+
%End
35116

36117
double angle() const;
118+
%Docstring
119+
Returns the angle of the vector in radians.
120+
:rtype: float
121+
%End
37122

38123
double angle( QgsVector v ) const;
124+
%Docstring
125+
Returns the angle between this vector and another vector in radians.
126+
:rtype: float
127+
%End
39128

40129
QgsVector rotateBy( double rot ) const;
130+
%Docstring
131+
Rotates the vector by a specified angle.
132+
\param rot angle in radians
133+
:rtype: QgsVector
134+
%End
41135

42136
QgsVector normalized() const;
137+
%Docstring
138+
Returns the vector's normalized (or "unit") vector (ie same angle but length of 1.0).
139+
Will throw a QgsException if called on a vector with length of 0.
140+
:rtype: QgsVector
141+
%End
43142

44143
bool operator==( QgsVector other ) const;
144+
%Docstring
145+
Equality operator
146+
:rtype: bool
147+
%End
45148

46149
bool operator!=( QgsVector other ) const;
150+
%Docstring
151+
Inequality operator
152+
:rtype: bool
153+
%End
154+
47155
};
156+
157+
/************************************************************************
158+
* This file has been generated automatically from *
159+
* *
160+
* src/core/qgsvector.h *
161+
* *
162+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
163+
************************************************************************/

‎src/core/qgsdataitem.h

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,28 @@ typedef QgsDataItem *dataItem_t( QString, QgsDataItem * );
4545
*/
4646
class CORE_EXPORT QgsDataItem : public QObject
4747
{
48+
49+
#ifdef SIP_RUN
50+
SIP_CONVERT_TO_SUBCLASS_CODE
51+
if ( sipCpp->inherits( "QgsLayerItem" ) )
52+
sipType = sipType_QgsLayerItem;
53+
if ( sipCpp->inherits( "QgsErrorItem" ) )
54+
sipType = sipType_QgsErrorItem;
55+
if ( sipCpp->inherits( "QgsDirectoryItem" ) )
56+
sipType = sipType_QgsDirectoryItem;
57+
if ( sipCpp->inherits( "QgsFavoritesItem" ) )
58+
sipType = sipType_QgsFavoritesItem;
59+
if ( sipCpp->inherits( "QgsZipItem" ) )
60+
sipType = sipType_QgsZipItem;
61+
if ( sipCpp->inherits( "QgsDataCollectionItem" ) )
62+
sipType = sipType_QgsDataCollectionItem;
63+
if ( sipCpp->inherits( "QgsProjectItem" ) )
64+
sipType = sipType_QgsProjectItem;
65+
else
66+
sipType = 0;
67+
SIP_END
68+
#endif
69+
4870
Q_OBJECT
4971
Q_ENUMS( Type )
5072
Q_ENUMS( State )
@@ -60,7 +82,7 @@ class CORE_EXPORT QgsDataItem : public QObject
6082
};
6183

6284
//! Create new data item.
63-
QgsDataItem( QgsDataItem::Type type, QgsDataItem *parent, const QString &name, const QString &path );
85+
QgsDataItem( QgsDataItem::Type type, QgsDataItem *parent SIP_TRANSFERTHIS, const QString &name, const QString &path );
6486
virtual ~QgsDataItem();
6587

6688
bool hasChildren();
@@ -69,7 +91,7 @@ class CORE_EXPORT QgsDataItem : public QObject
6991

7092
/** Create children. Children are not expected to have parent set.
7193
* This method MUST BE THREAD SAFE. */
72-
virtual QVector<QgsDataItem *> createChildren();
94+
virtual QVector<QgsDataItem *> createChildren() SIP_FACTORY;
7395

7496
enum State
7597
{
@@ -92,7 +114,7 @@ class CORE_EXPORT QgsDataItem : public QObject
92114
* \param refresh - set to true to refresh populated item, emitting relevant signals to the model
93115
* \see deleteChildItem()
94116
*/
95-
virtual void addChildItem( QgsDataItem *child, bool refresh = false );
117+
virtual void addChildItem( QgsDataItem *child SIP_TRANSFER, bool refresh = false );
96118

97119
/** Removes and deletes a child item, emitting relevant signals to the model.
98120
* \param child child to remove. Item must exist as a current child.
@@ -104,13 +126,13 @@ class CORE_EXPORT QgsDataItem : public QObject
104126
* \param child child to remove
105127
* \returns pointer to the removed item or null if no such item was found
106128
*/
107-
virtual QgsDataItem *removeChildItem( QgsDataItem *child );
129+
virtual QgsDataItem *removeChildItem( QgsDataItem *child ) SIP_TRANSFERBACK;
108130

109131
/** Returns true if this item is equal to another item (by testing item type and path).
110132
*/
111133
virtual bool equal( const QgsDataItem *other );
112134

113-
virtual QWidget *paramWidget() { return nullptr; }
135+
virtual QWidget *paramWidget() SIP_FACTORY { return nullptr; }
114136

115137
/** Returns the list of actions available for this item. This is usually used for the popup menu on right-clicking
116138
* the item. Subclasses should override this to provide actions.
@@ -383,7 +405,7 @@ class CORE_EXPORT QgsDataCollectionItem : public QgsDataItem
383405
QgsDataCollectionItem( QgsDataItem *parent, const QString &name, const QString &path = QString::null );
384406
~QgsDataCollectionItem();
385407

386-
void addChild( QgsDataItem *item ) { mChildren.append( item ); }
408+
void addChild( QgsDataItem *item SIP_TRANSFER ) { mChildren.append( item ); }
387409

388410
static QIcon iconDir(); // shared icon: open/closed directory
389411
static QIcon iconDataCollection(); // default icon for data collection
@@ -423,7 +445,7 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
423445
QString dirPath() const { return mDirPath; }
424446
virtual bool equal( const QgsDataItem *other ) override;
425447
virtual QIcon icon() override;
426-
virtual QWidget *paramWidget() override;
448+
virtual QWidget *paramWidget() override SIP_FACTORY;
427449

428450
//! Check if the given path is hidden from the browser model
429451
static bool hiddenPath( const QString &path );
@@ -484,7 +506,7 @@ class CORE_EXPORT QgsDirectoryParamWidget : public QTreeWidget
484506
Q_OBJECT
485507

486508
public:
487-
QgsDirectoryParamWidget( const QString &path, QWidget *parent = nullptr );
509+
QgsDirectoryParamWidget( const QString &path, QWidget *parent SIP_TRANSFERTHIS = nullptr );
488510

489511
protected:
490512
void mousePressEvent( QMouseEvent *event ) override;
@@ -557,13 +579,13 @@ class CORE_EXPORT QgsZipItem : public QgsDataCollectionItem
557579
/**
558580
* Creates a new data item from the specified path.
559581
*/
560-
static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &path, const QString &name );
582+
static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &path, const QString &name ) SIP_FACTORY;
561583

562584
/**
563585
* Creates a new data item from the specified path.
564586
* \note available in Python as itemFromFilePath
565587
*/
566-
static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &filePath, const QString &name, const QString &path );
588+
static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &filePath, const QString &name, const QString &path ) SIP_FACTORY, SIP_PYNAME(itemFromFilePath);
567589

568590
static QIcon iconZip();
569591

0 commit comments

Comments
 (0)
Please sign in to comment.