Skip to content

Commit

Permalink
Update Python bindings to match changes in core/gui libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Dec 5, 2013
1 parent 412eaf4 commit 2bece09
Show file tree
Hide file tree
Showing 68 changed files with 589 additions and 205 deletions.
3 changes: 2 additions & 1 deletion python/core/composer/qgscomposermap.sip
Expand Up @@ -141,7 +141,8 @@ class QgsComposerMap : QgsComposerItem


QgsRectangle extent() const; QgsRectangle extent() const;


const QgsMapRenderer* mapRenderer() const; //! @deprecated since 2.1 - use mapSettings() - may return 0 if not initialized with QgsMapRenderer
const QgsMapRenderer* mapRenderer() const /Deprecated/;


/**Sets offset values to shift image (useful for live updates when moving item content)*/ /**Sets offset values to shift image (useful for live updates when moving item content)*/
void setOffset( double xOffset, double yOffset ); void setOffset( double xOffset, double yOffset );
Expand Down
15 changes: 13 additions & 2 deletions python/core/composer/qgscomposition.sip
Expand Up @@ -28,7 +28,9 @@ class QgsComposition : QGraphicsScene
Crosses Crosses
}; };


QgsComposition( QgsMapRenderer* mapRenderer ); //! @deprecated since 2.1 - use the constructor with QgsMapSettings
QgsComposition( QgsMapRenderer* mapRenderer ) /Deprecated/;
explicit QgsComposition( const QgsMapSettings& mapSettings );
~QgsComposition(); ~QgsComposition();


/**Changes size of paper item*/ /**Changes size of paper item*/
Expand Down Expand Up @@ -151,7 +153,12 @@ class QgsComposition : QGraphicsScene
void setWorldFileMap( QgsComposerMap* map ); void setWorldFileMap( QgsComposerMap* map );


/**Returns pointer to map renderer of qgis map canvas*/ /**Returns pointer to map renderer of qgis map canvas*/
QgsMapRenderer* mapRenderer(); //! @deprecated since 2.1 - use mapSettings() instead. May return null if not initialized with QgsMapRenderer
QgsMapRenderer* mapRenderer() /Deprecated/;

//! Return setting of QGIS map canvas
//! @note added in 2.1
const QgsMapSettings& mapSettings() const;


QgsComposition::PlotStyle plotStyle() const; QgsComposition::PlotStyle plotStyle() const;
void setPlotStyle( QgsComposition::PlotStyle style ); void setPlotStyle( QgsComposition::PlotStyle style );
Expand Down Expand Up @@ -310,6 +317,10 @@ class QgsComposition : QGraphicsScene
public slots: public slots:
/**Casts object to the proper subclass type and calls corresponding itemAdded signal*/ /**Casts object to the proper subclass type and calls corresponding itemAdded signal*/
void sendItemAddedSignal( QgsComposerItem* item ); void sendItemAddedSignal( QgsComposerItem* item );

protected:
void init();

signals: signals:
void paperSizeChanged(); void paperSizeChanged();
void nPagesChanged(); void nPagesChanged();
Expand Down
2 changes: 2 additions & 0 deletions python/core/core.sip
Expand Up @@ -45,7 +45,9 @@
%Include qgslogger.sip %Include qgslogger.sip
%Include qgsmaplayer.sip %Include qgsmaplayer.sip
%Include qgsmaplayerregistry.sip %Include qgsmaplayerregistry.sip
%Include qgsmaplayerrenderer.sip
%Include qgsmaprenderer.sip %Include qgsmaprenderer.sip
%Include qgsmapsettings.sip
%Include qgsmaptopixel.sip %Include qgsmaptopixel.sip
%Include qgsmessagelog.sip %Include qgsmessagelog.sip
%Include qgsmessageoutput.sip %Include qgsmessageoutput.sip
Expand Down
3 changes: 3 additions & 0 deletions python/core/diagram/qgsdiagram.sip
Expand Up @@ -5,6 +5,9 @@ class QgsDiagram
%End %End
public: public:
virtual ~QgsDiagram(); virtual ~QgsDiagram();
/** Returns an instance that is equivalent to this one
* @note added in 2.1 */
virtual QgsDiagram* clone() const = 0;
/**Draws the diagram at the given position (in pixel coordinates)*/ /**Draws the diagram at the given position (in pixel coordinates)*/
virtual void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position ) = 0; virtual void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position ) = 0;
virtual QString diagramName() const = 0; virtual QString diagramName() const = 0;
Expand Down
2 changes: 2 additions & 0 deletions python/core/diagram/qgshistogramdiagram.sip
Expand Up @@ -7,6 +7,8 @@ class QgsHistogramDiagram: QgsDiagram
QgsHistogramDiagram(); QgsHistogramDiagram();
~QgsHistogramDiagram(); ~QgsHistogramDiagram();


virtual QgsDiagram* clone() const;

void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position ); void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position );
QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s ); QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s );
QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ); QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is );
Expand Down
2 changes: 2 additions & 0 deletions python/core/diagram/qgspiediagram.sip
Expand Up @@ -7,6 +7,8 @@ class QgsPieDiagram: QgsDiagram
QgsPieDiagram(); QgsPieDiagram();
~QgsPieDiagram(); ~QgsPieDiagram();


virtual QgsDiagram* clone() const;

void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position ); void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position );
QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s ); QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s );
QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ); QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is );
Expand Down
3 changes: 3 additions & 0 deletions python/core/diagram/qgstextdiagram.sip
Expand Up @@ -20,6 +20,9 @@ class QgsTextDiagram: QgsDiagram


QgsTextDiagram(); QgsTextDiagram();
~QgsTextDiagram(); ~QgsTextDiagram();

virtual QgsDiagram* clone() const;

void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position ); void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position );
QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s ); QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s );
QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ); QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is );
Expand Down
10 changes: 10 additions & 0 deletions python/core/qgsdiagramrendererv2.sip
Expand Up @@ -24,6 +24,8 @@ struct QgsDiagramLayerSettings


QgsDiagramLayerSettings(); QgsDiagramLayerSettings();


~QgsDiagramLayerSettings();

//pal placement properties //pal placement properties
Placement placement; Placement placement;
LinePlacementFlags placementFlags; LinePlacementFlags placementFlags;
Expand Down Expand Up @@ -118,6 +120,10 @@ class QgsDiagramRendererV2
QgsDiagramRendererV2(); QgsDiagramRendererV2();
virtual ~QgsDiagramRendererV2(); virtual ~QgsDiagramRendererV2();


/** Returns new instance that is equivalent to this one
* @note added in 2.1 */
virtual QgsDiagramRendererV2* clone() const = 0;

/**Returns size of the diagram for feature f in map units. Returns an invalid QSizeF in case of error*/ /**Returns size of the diagram for feature f in map units. Returns an invalid QSizeF in case of error*/
virtual QSizeF sizeMapUnits( const QgsAttributes& attributes, const QgsRenderContext& c ); virtual QSizeF sizeMapUnits( const QgsAttributes& attributes, const QgsRenderContext& c );


Expand Down Expand Up @@ -171,6 +177,8 @@ class QgsSingleCategoryDiagramRenderer : QgsDiagramRendererV2
QgsSingleCategoryDiagramRenderer(); QgsSingleCategoryDiagramRenderer();
~QgsSingleCategoryDiagramRenderer(); ~QgsSingleCategoryDiagramRenderer();


QgsDiagramRendererV2* clone() const;

QString rendererName() const; QString rendererName() const;


QList<int> diagramAttributes() const; QList<int> diagramAttributes() const;
Expand Down Expand Up @@ -198,6 +206,8 @@ class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRendererV2
QgsLinearlyInterpolatedDiagramRenderer(); QgsLinearlyInterpolatedDiagramRenderer();
~QgsLinearlyInterpolatedDiagramRenderer(); ~QgsLinearlyInterpolatedDiagramRenderer();


QgsDiagramRendererV2* clone() const;

/**Returns list with all diagram settings in the renderer*/ /**Returns list with all diagram settings in the renderer*/
QList<QgsDiagramSettings> diagramSettings() const; QList<QgsDiagramSettings> diagramSettings() const;


Expand Down
20 changes: 20 additions & 0 deletions python/core/qgsfeaturerequest.sip
Expand Up @@ -63,3 +63,23 @@ class QgsFeatureRequest
QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields ); QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields );


}; };


/** base class that can be used for any class that is capable of returning features
* @note added in 2.1
*/
class QgsAbstractFeatureSource
{
%TypeHeaderCode
#include <qgsfeaturerequest.h>
%End

public:
virtual ~QgsAbstractFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request ) = 0;

protected:
void iteratorOpened( QgsAbstractFeatureIterator* it );
void iteratorClosed( QgsAbstractFeatureIterator* it );
};
14 changes: 12 additions & 2 deletions python/core/qgsfield.sip
Expand Up @@ -126,6 +126,7 @@ class QgsFields
void clear(); void clear();
void append( const QgsField& field, FieldOrigin origin = OriginProvider, int originIndex = -1 ); void append( const QgsField& field, FieldOrigin origin = OriginProvider, int originIndex = -1 );
void remove( int fieldIdx ); void remove( int fieldIdx );
void extend( const QgsFields& other );


bool isEmpty() const; bool isEmpty() const;
// __len__ annotation since sip 4.10.3 // __len__ annotation since sip 4.10.3
Expand All @@ -139,16 +140,24 @@ class QgsFields
//const QgsField& operator[](int i) const; //const QgsField& operator[](int i) const;
//QgsField& operator[](int i); //QgsField& operator[](int i);
const QgsField& at(int i) const; const QgsField& at(int i) const;
QList<QgsField> toList() const;


const QgsField& field( int fieldIdx ) const; const QgsField& field( int fieldIdx ) const;
const QgsField& field( const QString& name ) const; const QgsField& field( const QString& name ) const;
FieldOrigin fieldOrigin( int fieldIdx ) const; FieldOrigin fieldOrigin( int fieldIdx ) const;
int fieldOriginIndex( int fieldIdx ) const; int fieldOriginIndex( int fieldIdx ) const;


int indexFromName( const QString& name ) const; int indexFromName( const QString& name ) const;
void extend( const QgsFields& other );


//! Look up field's index from name - case insensitive
//! TODO: sort out case sensitive (indexFromName()) vs insensitive (fieldNameIndex()) calls
//! @note added in 2.1
int fieldNameIndex( const QString& fieldName ) const;

//! Utility function to get list of attribute indexes
//! @note added in 2.1
QgsAttributeList allAttributesList() const;

QList<QgsField> toList() const;


QgsField& operator[](int i) /Factory/; QgsField& operator[](int i) /Factory/;
%MethodCode %MethodCode
Expand Down Expand Up @@ -181,5 +190,6 @@ void __setitem__(int key, const QgsField& field);
(*sipCpp)[idx] = *a1; (*sipCpp)[idx] = *a1;
%End %End



}; };


4 changes: 1 addition & 3 deletions python/core/qgsgeometrycache.sip
Expand Up @@ -4,7 +4,7 @@ class QgsGeometryCache
#include <qgsgeometrycache.h> #include <qgsgeometrycache.h>
%End %End
public: public:
QgsGeometryCache( QgsVectorLayer* layer ); QgsGeometryCache();
~QgsGeometryCache(); ~QgsGeometryCache();


QgsGeometryMap& cachedGeometries(); QgsGeometryMap& cachedGeometries();
Expand All @@ -25,6 +25,4 @@ class QgsGeometryCache
void setCachedGeometriesRect( const QgsRectangle& extent ); void setCachedGeometriesRect( const QgsRectangle& extent );
const QgsRectangle& cachedGeometriesRect(); const QgsRectangle& cachedGeometriesRect();


protected:
QgsVectorLayerEditBuffer *editBuffer();
}; };
4 changes: 2 additions & 2 deletions python/core/qgslabelsearchtree.sip
Expand Up @@ -12,10 +12,10 @@ class QgsLabelSearchTree
void clear(); void clear();


/**Returns label position(s) at a given point. QgsLabelSearchTree keeps ownership, don't delete the LabelPositions*/ /**Returns label position(s) at a given point. QgsLabelSearchTree keeps ownership, don't delete the LabelPositions*/
// void label( const QgsPoint& p, QList<QgsLabelPosition*>& posList ); // void label( const QgsPoint& p, QList<QgsLabelPosition*>& posList ) const;


/**Returns label position(s) in given rectangle. QgsLabelSearchTree keeps ownership, don't delete the LabelPositions*/ /**Returns label position(s) in given rectangle. QgsLabelSearchTree keeps ownership, don't delete the LabelPositions*/
// void labelsInRect( const QgsRectangle& r, QList<QgsLabelPosition*>& posList ); // void labelsInRect( const QgsRectangle& r, QList<QgsLabelPosition*>& posList ) const;


/**Inserts label position. Does not take ownership of labelPos /**Inserts label position. Does not take ownership of labelPos
@return true in case of success*/ @return true in case of success*/
Expand Down
51 changes: 19 additions & 32 deletions python/core/qgsmaplayer.sip
Expand Up @@ -116,6 +116,11 @@ class QgsMapLayer : QObject
@note added in version 1.6*/ @note added in version 1.6*/
virtual void reload(); virtual void reload();


/** Return new instance of QgsMapLayerRenderer that will be used for rendering of given context
* @note added in 2.1
*/
virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) /Factory/;

/** This is the method that does the actual work of /** This is the method that does the actual work of
* drawing the layer onto a paint device. * drawing the layer onto a paint device.
* @param rendererContext describes the extents, * @param rendererContext describes the extents,
Expand Down Expand Up @@ -210,21 +215,11 @@ class QgsMapLayer : QObject
void removeCustomProperty( const QString& key ); void removeCustomProperty( const QString& key );




/** //! @deprecated since 2.1 - returns empty string
* If an operation returns 0 (e.g. draw()), this function virtual QString lastErrorTitle() /Deprecated/;
* returns the text of the error associated with the failure.
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
virtual QString lastErrorTitle();


/** //! @deprecated since 2.1 - returns empty string
* If an operation returns 0 (e.g. draw()), this function virtual QString lastError() /Deprecated/;
* returns the text of the error associated with the failure.
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
virtual QString lastError();


/** Get current status error. This error describes some principal problem /** Get current status error. This error describes some principal problem
* for which layer cannot work and thus is not valid. It is not last error * for which layer cannot work and thus is not valid. It is not last error
Expand Down Expand Up @@ -346,18 +341,12 @@ class QgsMapLayer : QObject
/** Return pointer to layer's undo stack */ /** Return pointer to layer's undo stack */
QUndoStack* undoStack(); QUndoStack* undoStack();


/** Get the QImage used for caching render operations /** @deprecated since 2.1 - returns NULL */
* @note This method was added in QGIS 1.4 **/ QImage *cacheImage() /Deprecated/;
QImage *cacheImage(); /** @deprecated since 2.1 - does nothing */
/** Set the QImage used for caching render operations void setCacheImage( QImage * thepImage /Transfer/ ) /Deprecated/;
* @note This method was added in QGIS 1.4 **/ /** @deprecated since 2.1 - does nothing */
void setCacheImage( QImage * thepImage /Transfer/ ); virtual void onCacheImageDelete() /Deprecated/;

/**
* @brief Is called when the cache image is being deleted. Overwrite and use to clean up.
* @note added in 2.0
*/
virtual void onCacheImageDelete();


public slots: public slots:


Expand All @@ -376,9 +365,8 @@ class QgsMapLayer : QObject
void toggleScaleBasedVisibility( bool theVisibilityFlag ); void toggleScaleBasedVisibility( bool theVisibilityFlag );
bool hasScaleBasedVisibility(); bool hasScaleBasedVisibility();


/** Clear cached image /** @deprecated since 2.1 - does nothing */
* added in 1.5 */ void clearCacheImage() /Deprecated/;
void clearCacheImage();


/** \brief Obtain Metadata for this layer */ /** \brief Obtain Metadata for this layer */
virtual QString metadata(); virtual QString metadata();
Expand All @@ -388,7 +376,7 @@ class QgsMapLayer : QObject


signals: signals:


/** Emit a signal to notify of a progress event */ //! @deprecated in 2.1 - not emitted anymore
void drawingProgress( int theProgress, int theTotalSteps ); void drawingProgress( int theProgress, int theTotalSteps );


/** Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar) */ /** Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar) */
Expand All @@ -407,8 +395,7 @@ class QgsMapLayer : QObject
*/ */
void repaintRequested(); void repaintRequested();


/**The layer emits this signal when a screen update is requested. //! \note Deprecated in 2.1 and not emitted anymore
This signal should be connected with the slot QgsMapCanvas::updateMap()*/
void screenUpdateRequested(); void screenUpdateRequested();


/** This is used to send a request that any mapcanvas using this layer update its extents */ /** This is used to send a request that any mapcanvas using this layer update its extents */
Expand Down
3 changes: 2 additions & 1 deletion python/core/qgsmaplayerregistry.sip
Expand Up @@ -119,7 +119,8 @@ class QgsMapLayerRegistry : QObject
* *
* @note Added in QGIS 1.4 * @note Added in QGIS 1.4
*/ */
void clearAllLayerCaches(); //! @deprecated since 2.1 - does nothing
void clearAllLayerCaches() /Deprecated/;


/** /**
* Reload all provider data caches (currently used for WFS and WMS providers) * Reload all provider data caches (currently used for WFS and WMS providers)
Expand Down
20 changes: 20 additions & 0 deletions python/core/qgsmaplayerrenderer.sip
@@ -0,0 +1,20 @@

class QgsMapLayerRenderer
{
%TypeHeaderCode
#include <qgsmaplayerrenderer.h>
%End

public:
QgsMapLayerRenderer( const QString& layerID );
virtual ~QgsMapLayerRenderer();

//! Do the rendering (based on data stored in the class)
virtual bool render() = 0;

//! Return list of errors (problems) that happened during the rendering
QStringList errors() const;

//! Get access to the ID of the layer rendered by this class
QString layerID() const;
};

0 comments on commit 2bece09

Please sign in to comment.