From 2bece090f5389d8f867cf4a76c2a4270f22f96ee Mon Sep 17 00:00:00 2001 From: Martin Dobias Date: Thu, 5 Dec 2013 18:27:45 +0700 Subject: [PATCH] Update Python bindings to match changes in core/gui libraries. --- python/core/composer/qgscomposermap.sip | 3 +- python/core/composer/qgscomposition.sip | 15 ++- python/core/core.sip | 2 + python/core/diagram/qgsdiagram.sip | 3 + python/core/diagram/qgshistogramdiagram.sip | 2 + python/core/diagram/qgspiediagram.sip | 2 + python/core/diagram/qgstextdiagram.sip | 3 + python/core/qgsdiagramrendererv2.sip | 10 ++ python/core/qgsfeaturerequest.sip | 20 +++ python/core/qgsfield.sip | 14 +- python/core/qgsgeometrycache.sip | 4 +- python/core/qgslabelsearchtree.sip | 4 +- python/core/qgsmaplayer.sip | 51 +++----- python/core/qgsmaplayerregistry.sip | 3 +- python/core/qgsmaplayerrenderer.sip | 20 +++ python/core/qgsmaprenderer.sip | 38 ++++-- python/core/qgsmapsettings.sip | 122 ++++++++++++++++++ python/core/qgspallabeling.sip | 50 +++++-- python/core/qgsrendercontext.sip | 4 + python/core/qgssnapper.sip | 6 +- python/core/qgsspatialindex.sip | 15 ++- python/core/qgstolerance.sip | 34 ++++- python/core/qgsvectordataprovider.sip | 22 +++- python/core/qgsvectorlayer.sip | 15 +-- python/core/qgsvectorlayerfeatureiterator.sip | 5 + python/core/raster/qgsrasterlayer.sip | 17 ++- .../qgscategorizedsymbolrendererv2.sip | 2 +- .../qgsgraduatedsymbolrendererv2.sip | 2 +- .../qgspointdisplacementrenderer.sip | 2 +- python/core/symbology-ng/qgsrendererv2.sip | 5 +- .../symbology-ng/qgsrulebasedrendererv2.sip | 4 +- .../qgssinglesymbolrendererv2.sip | 2 +- python/core/symbology-ng/qgssymbollayerv2.sip | 2 +- python/core/symbology-ng/qgssymbolv2.sip | 12 +- python/gui/qgsmapcanvas.sip | 88 +++++++++---- python/gui/qgsmapcanvasitem.sip | 3 +- python/gui/qgsmapcanvasmap.sip | 35 +++-- python/gui/qgsmapoverviewcanvas.sip | 11 +- python/gui/qgsmaptool.sip | 3 +- src/app/nodetool/qgsselectedfeature.cpp | 2 +- src/app/qgisapp.cpp | 8 +- src/app/qgisapp.h | 2 +- src/app/qgsdecorationgrid.cpp | 2 +- src/app/qgsmaptoolmeasureangle.cpp | 2 +- src/app/qgsmeasuretool.cpp | 2 +- src/core/composer/qgscomposermap.cpp | 2 +- src/core/composer/qgscomposition.h | 1 + src/core/qgsfeaturerequest.h | 4 +- src/core/qgsmaprenderer.cpp | 24 ++-- src/core/qgsmaprenderer.h | 5 +- src/core/qgsmapsettings.cpp | 4 +- src/core/qgsmapsettings.h | 6 +- src/core/qgsrendercontext.h | 1 + src/core/qgsspatialindex.cpp | 6 + src/core/qgsspatialindex.h | 3 + src/gui/CMakeLists.txt | 1 - src/gui/qgsmapcanvas.cpp | 30 ++--- src/gui/qgsmapcanvas.h | 13 +- src/gui/qgsmapcanvasmap.h | 2 +- src/gui/qgsmapoverviewcanvas.cpp | 2 +- src/gui/qgsmapoverviewcanvas.h | 3 + .../coordinate_capture/coordinatecapture.cpp | 2 +- src/plugins/grass/qgsgrassplugin.cpp | 2 +- src/plugins/grass/qgsgrassregion.cpp | 2 +- tests/src/core/testqgsatlascomposition.cpp | 2 +- tests/src/core/testqgscomposerlabel.cpp | 2 +- tests/src/core/testqgscomposermap.cpp | 2 +- tests/src/core/testqgscomposerscalebar.cpp | 2 +- 68 files changed, 589 insertions(+), 205 deletions(-) create mode 100644 python/core/qgsmaplayerrenderer.sip create mode 100644 python/core/qgsmapsettings.sip diff --git a/python/core/composer/qgscomposermap.sip b/python/core/composer/qgscomposermap.sip index e1ea96a5129..3f067e6e0ef 100644 --- a/python/core/composer/qgscomposermap.sip +++ b/python/core/composer/qgscomposermap.sip @@ -141,7 +141,8 @@ class QgsComposerMap : QgsComposerItem 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)*/ void setOffset( double xOffset, double yOffset ); diff --git a/python/core/composer/qgscomposition.sip b/python/core/composer/qgscomposition.sip index f55906c9b00..55465d19280 100644 --- a/python/core/composer/qgscomposition.sip +++ b/python/core/composer/qgscomposition.sip @@ -28,7 +28,9 @@ class QgsComposition : QGraphicsScene Crosses }; - QgsComposition( QgsMapRenderer* mapRenderer ); + //! @deprecated since 2.1 - use the constructor with QgsMapSettings + QgsComposition( QgsMapRenderer* mapRenderer ) /Deprecated/; + explicit QgsComposition( const QgsMapSettings& mapSettings ); ~QgsComposition(); /**Changes size of paper item*/ @@ -151,7 +153,12 @@ class QgsComposition : QGraphicsScene void setWorldFileMap( QgsComposerMap* map ); /**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; void setPlotStyle( QgsComposition::PlotStyle style ); @@ -310,6 +317,10 @@ class QgsComposition : QGraphicsScene public slots: /**Casts object to the proper subclass type and calls corresponding itemAdded signal*/ void sendItemAddedSignal( QgsComposerItem* item ); + + protected: + void init(); + signals: void paperSizeChanged(); void nPagesChanged(); diff --git a/python/core/core.sip b/python/core/core.sip index e941fd69b80..1ddcd6e6fda 100644 --- a/python/core/core.sip +++ b/python/core/core.sip @@ -45,7 +45,9 @@ %Include qgslogger.sip %Include qgsmaplayer.sip %Include qgsmaplayerregistry.sip +%Include qgsmaplayerrenderer.sip %Include qgsmaprenderer.sip +%Include qgsmapsettings.sip %Include qgsmaptopixel.sip %Include qgsmessagelog.sip %Include qgsmessageoutput.sip diff --git a/python/core/diagram/qgsdiagram.sip b/python/core/diagram/qgsdiagram.sip index 2c93f28ee77..a35ffbdb251 100644 --- a/python/core/diagram/qgsdiagram.sip +++ b/python/core/diagram/qgsdiagram.sip @@ -5,6 +5,9 @@ class QgsDiagram %End public: 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)*/ virtual void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position ) = 0; virtual QString diagramName() const = 0; diff --git a/python/core/diagram/qgshistogramdiagram.sip b/python/core/diagram/qgshistogramdiagram.sip index 2f27b64105d..4333ce0bc62 100644 --- a/python/core/diagram/qgshistogramdiagram.sip +++ b/python/core/diagram/qgshistogramdiagram.sip @@ -7,6 +7,8 @@ class QgsHistogramDiagram: QgsDiagram QgsHistogramDiagram(); ~QgsHistogramDiagram(); + virtual QgsDiagram* clone() const; + 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, const QgsDiagramInterpolationSettings& is ); diff --git a/python/core/diagram/qgspiediagram.sip b/python/core/diagram/qgspiediagram.sip index ad87cff9160..5402130320a 100644 --- a/python/core/diagram/qgspiediagram.sip +++ b/python/core/diagram/qgspiediagram.sip @@ -7,6 +7,8 @@ class QgsPieDiagram: QgsDiagram QgsPieDiagram(); ~QgsPieDiagram(); + virtual QgsDiagram* clone() const; + 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, const QgsDiagramInterpolationSettings& is ); diff --git a/python/core/diagram/qgstextdiagram.sip b/python/core/diagram/qgstextdiagram.sip index bc3fc60cc30..011442afbe4 100644 --- a/python/core/diagram/qgstextdiagram.sip +++ b/python/core/diagram/qgstextdiagram.sip @@ -20,6 +20,9 @@ class QgsTextDiagram: QgsDiagram QgsTextDiagram(); ~QgsTextDiagram(); + + virtual QgsDiagram* clone() const; + 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, const QgsDiagramInterpolationSettings& is ); diff --git a/python/core/qgsdiagramrendererv2.sip b/python/core/qgsdiagramrendererv2.sip index 5e619a96737..d08b969a98e 100644 --- a/python/core/qgsdiagramrendererv2.sip +++ b/python/core/qgsdiagramrendererv2.sip @@ -24,6 +24,8 @@ struct QgsDiagramLayerSettings QgsDiagramLayerSettings(); + ~QgsDiagramLayerSettings(); + //pal placement properties Placement placement; LinePlacementFlags placementFlags; @@ -118,6 +120,10 @@ class QgsDiagramRendererV2 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*/ virtual QSizeF sizeMapUnits( const QgsAttributes& attributes, const QgsRenderContext& c ); @@ -171,6 +177,8 @@ class QgsSingleCategoryDiagramRenderer : QgsDiagramRendererV2 QgsSingleCategoryDiagramRenderer(); ~QgsSingleCategoryDiagramRenderer(); + QgsDiagramRendererV2* clone() const; + QString rendererName() const; QList diagramAttributes() const; @@ -198,6 +206,8 @@ class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRendererV2 QgsLinearlyInterpolatedDiagramRenderer(); ~QgsLinearlyInterpolatedDiagramRenderer(); + QgsDiagramRendererV2* clone() const; + /**Returns list with all diagram settings in the renderer*/ QList diagramSettings() const; diff --git a/python/core/qgsfeaturerequest.sip b/python/core/qgsfeaturerequest.sip index d0865300465..495f44e98ea 100644 --- a/python/core/qgsfeaturerequest.sip +++ b/python/core/qgsfeaturerequest.sip @@ -63,3 +63,23 @@ class QgsFeatureRequest 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 +%End + +public: + virtual ~QgsAbstractFeatureSource(); + + virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request ) = 0; + +protected: + void iteratorOpened( QgsAbstractFeatureIterator* it ); + void iteratorClosed( QgsAbstractFeatureIterator* it ); +}; diff --git a/python/core/qgsfield.sip b/python/core/qgsfield.sip index 2127eaac230..7b2b512e071 100644 --- a/python/core/qgsfield.sip +++ b/python/core/qgsfield.sip @@ -126,6 +126,7 @@ class QgsFields void clear(); void append( const QgsField& field, FieldOrigin origin = OriginProvider, int originIndex = -1 ); void remove( int fieldIdx ); + void extend( const QgsFields& other ); bool isEmpty() const; // __len__ annotation since sip 4.10.3 @@ -139,7 +140,6 @@ class QgsFields //const QgsField& operator[](int i) const; //QgsField& operator[](int i); const QgsField& at(int i) const; - QList toList() const; const QgsField& field( int fieldIdx ) const; const QgsField& field( const QString& name ) const; @@ -147,8 +147,17 @@ class QgsFields int fieldOriginIndex( int fieldIdx ) 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 toList() const; QgsField& operator[](int i) /Factory/; %MethodCode @@ -181,5 +190,6 @@ void __setitem__(int key, const QgsField& field); (*sipCpp)[idx] = *a1; %End + }; diff --git a/python/core/qgsgeometrycache.sip b/python/core/qgsgeometrycache.sip index a909569b3a8..3d04410bb19 100644 --- a/python/core/qgsgeometrycache.sip +++ b/python/core/qgsgeometrycache.sip @@ -4,7 +4,7 @@ class QgsGeometryCache #include %End public: - QgsGeometryCache( QgsVectorLayer* layer ); + QgsGeometryCache(); ~QgsGeometryCache(); QgsGeometryMap& cachedGeometries(); @@ -25,6 +25,4 @@ class QgsGeometryCache void setCachedGeometriesRect( const QgsRectangle& extent ); const QgsRectangle& cachedGeometriesRect(); - protected: - QgsVectorLayerEditBuffer *editBuffer(); }; diff --git a/python/core/qgslabelsearchtree.sip b/python/core/qgslabelsearchtree.sip index 69c5a4ab5b9..533ca6ea0ad 100644 --- a/python/core/qgslabelsearchtree.sip +++ b/python/core/qgslabelsearchtree.sip @@ -12,10 +12,10 @@ class QgsLabelSearchTree void clear(); /**Returns label position(s) at a given point. QgsLabelSearchTree keeps ownership, don't delete the LabelPositions*/ - // void label( const QgsPoint& p, QList& posList ); + // void label( const QgsPoint& p, QList& posList ) const; /**Returns label position(s) in given rectangle. QgsLabelSearchTree keeps ownership, don't delete the LabelPositions*/ - // void labelsInRect( const QgsRectangle& r, QList& posList ); + // void labelsInRect( const QgsRectangle& r, QList& posList ) const; /**Inserts label position. Does not take ownership of labelPos @return true in case of success*/ diff --git a/python/core/qgsmaplayer.sip b/python/core/qgsmaplayer.sip index b7bd26fe9f0..bfb2aaa2579 100644 --- a/python/core/qgsmaplayer.sip +++ b/python/core/qgsmaplayer.sip @@ -116,6 +116,11 @@ class QgsMapLayer : QObject @note added in version 1.6*/ 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 * drawing the layer onto a paint device. * @param rendererContext describes the extents, @@ -210,21 +215,11 @@ class QgsMapLayer : QObject void removeCustomProperty( const QString& key ); - /** - * If an operation returns 0 (e.g. draw()), this function - * 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 + virtual QString lastErrorTitle() /Deprecated/; - /** - * If an operation returns 0 (e.g. draw()), this function - * 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(); + //! @deprecated since 2.1 - returns empty string + virtual QString lastError() /Deprecated/; /** 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 @@ -346,18 +341,12 @@ class QgsMapLayer : QObject /** Return pointer to layer's undo stack */ QUndoStack* undoStack(); - /** Get the QImage used for caching render operations - * @note This method was added in QGIS 1.4 **/ - QImage *cacheImage(); - /** Set the QImage used for caching render operations - * @note This method was added in QGIS 1.4 **/ - void setCacheImage( QImage * thepImage /Transfer/ ); - - /** - * @brief Is called when the cache image is being deleted. Overwrite and use to clean up. - * @note added in 2.0 - */ - virtual void onCacheImageDelete(); + /** @deprecated since 2.1 - returns NULL */ + QImage *cacheImage() /Deprecated/; + /** @deprecated since 2.1 - does nothing */ + void setCacheImage( QImage * thepImage /Transfer/ ) /Deprecated/; + /** @deprecated since 2.1 - does nothing */ + virtual void onCacheImageDelete() /Deprecated/; public slots: @@ -376,9 +365,8 @@ class QgsMapLayer : QObject void toggleScaleBasedVisibility( bool theVisibilityFlag ); bool hasScaleBasedVisibility(); - /** Clear cached image - * added in 1.5 */ - void clearCacheImage(); + /** @deprecated since 2.1 - does nothing */ + void clearCacheImage() /Deprecated/; /** \brief Obtain Metadata for this layer */ virtual QString metadata(); @@ -388,7 +376,7 @@ class QgsMapLayer : QObject signals: - /** Emit a signal to notify of a progress event */ + //! @deprecated in 2.1 - not emitted anymore 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) */ @@ -407,8 +395,7 @@ class QgsMapLayer : QObject */ void repaintRequested(); - /**The layer emits this signal when a screen update is requested. - This signal should be connected with the slot QgsMapCanvas::updateMap()*/ + //! \note Deprecated in 2.1 and not emitted anymore void screenUpdateRequested(); /** This is used to send a request that any mapcanvas using this layer update its extents */ diff --git a/python/core/qgsmaplayerregistry.sip b/python/core/qgsmaplayerregistry.sip index d79bdfc51dc..f2244d755de 100644 --- a/python/core/qgsmaplayerregistry.sip +++ b/python/core/qgsmaplayerregistry.sip @@ -119,7 +119,8 @@ class QgsMapLayerRegistry : QObject * * @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) diff --git a/python/core/qgsmaplayerrenderer.sip b/python/core/qgsmaplayerrenderer.sip new file mode 100644 index 00000000000..e2328631926 --- /dev/null +++ b/python/core/qgsmaplayerrenderer.sip @@ -0,0 +1,20 @@ + +class QgsMapLayerRenderer +{ +%TypeHeaderCode +#include +%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; +}; diff --git a/python/core/qgsmaprenderer.sip b/python/core/qgsmaprenderer.sip index 7cc344d17a1..22a06091d34 100644 --- a/python/core/qgsmaprenderer.sip +++ b/python/core/qgsmaprenderer.sip @@ -36,7 +36,10 @@ class QgsLabelingEngineInterface virtual ~QgsLabelingEngineInterface(); //! called when we're going to start with rendering - virtual void init( QgsMapRenderer* mp ) = 0; + //! @deprecated since 2.1 - use override with QgsMapSettings + virtual void init( QgsMapRenderer* mp ) = 0 /Deprecated/; + //! called when we're going to start with rendering + virtual void init( const QgsMapSettings& mapSettings ) = 0; //! called to find out whether the layer is used for labeling virtual bool willUseLayer( QgsVectorLayer* layer ) = 0; //! clears all PAL layer settings for registered layers @@ -44,29 +47,31 @@ class QgsLabelingEngineInterface virtual void clearActiveLayers() = 0; //! clears data defined objects from PAL layer settings for a registered layer //! @note: this method was added in version 1.9 - virtual void clearActiveLayer( QgsVectorLayer* layer ) = 0; + virtual void clearActiveLayer( const QString& layerID ) = 0; //! called when starting rendering of a layer //! @note: this method was added in version 1.6 - virtual int prepareLayer( QgsVectorLayer* layer, QSet& attrIndices, QgsRenderContext& ctx ) = 0; + virtual int prepareLayer( QgsVectorLayer* layer, QStringList& attrNames, QgsRenderContext& ctx ) = 0; //! returns PAL layer settings for a registered layer //! @note: this method was added in version 1.9 virtual QgsPalLayerSettings& layer( const QString& layerName ) = 0; //! adds a diagram layer to the labeling engine virtual int addDiagramLayer( QgsVectorLayer* layer, QgsDiagramLayerSettings* s ); //! called for every feature - virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ) = 0; + virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ) = 0; //! called for every diagram feature - virtual void registerDiagramFeature( QgsVectorLayer* layer, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ); + virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ); //! called when the map is drawn and labels should be placed virtual void drawLabeling( QgsRenderContext& context ) = 0; //! called when we're done with rendering virtual void exit() = 0; //! return infos about labels at a given (map) position //! @note: this method was added in version 1.7 - virtual QList labelsAtPosition( const QgsPoint& p ) = 0; + //! @deprecated since 2.1 - use takeResults() and methods of QgsLabelingResults + virtual QList labelsAtPosition( const QgsPoint& p ) = 0 /Deprecated/; //! return infos about labels within a given (map) rectangle //! @note: this method was added in version 1.9 - virtual QList labelsWithinRect( const QgsRectangle& r ) = 0; + //! @deprecated since 2.1 - use takeResults() and methods of QgsLabelingResults + virtual QList labelsWithinRect( const QgsRectangle& r ) = 0 /Deprecated/; //! called when passing engine among map renderers virtual QgsLabelingEngineInterface* clone() = 0 /Factory/; @@ -245,6 +250,17 @@ class QgsMapRenderer : QObject //! Added in QGIS v1.4 void setLabelingEngine( QgsLabelingEngineInterface* iface /Transfer/ ); + //! Returns a QPainter::CompositionMode corresponding to a BlendMode + //! Added in 1.9 + static QPainter::CompositionMode getCompositionMode( const QgsMapRenderer::BlendMode blendMode ); + //! Returns a BlendMode corresponding to a QPainter::CompositionMode + //! Added in 1.9 + static QgsMapRenderer::BlendMode getBlendModeEnum( const QPainter::CompositionMode blendMode ); + + //! bridge to QgsMapSettings + //! @note added in 2.1 + const QgsMapSettings& mapSettings(); + signals: void drawingProgress( int current, int total ); @@ -260,10 +276,14 @@ class QgsMapRenderer : QObject //! emitted when layer's draw() returned false void drawError( QgsMapLayer* ); + //! emitted when the current extent gets changed + //! @note added in 2.1 + void extentsChanged(); + public slots: - //! called by signal from layer current being drawn - void onDrawingProgress( int current, int total ); + //! @deprecated in 2.1 - does nothing + void onDrawingProgress( int current, int total ) /Deprecated/; protected: diff --git a/python/core/qgsmapsettings.sip b/python/core/qgsmapsettings.sip new file mode 100644 index 00000000000..60e14dbe4cd --- /dev/null +++ b/python/core/qgsmapsettings.sip @@ -0,0 +1,122 @@ + +class QgsMapSettings +{ +%TypeHeaderCode +#include +%End + +public: + QgsMapSettings(); + + QgsRectangle extent() const; + void setExtent(const QgsRectangle& rect); + + QSize outputSize() const; + void setOutputSize(const QSize& size); + + int outputDpi() const; + void setOutputDpi(int dpi); + + QStringList layers() const; + void setLayers(const QStringList& layers); + + //! sets whether to use projections for this layer set + void setCrsTransformEnabled( bool enabled ); + //! returns true if projections are enabled for this layer set + bool hasCrsTransformEnabled() const; + + //! sets destination coordinate reference system + void setDestinationCrs( const QgsCoordinateReferenceSystem& crs ); + //! returns CRS of destination coordinate reference system + const QgsCoordinateReferenceSystem& destinationCrs() const; + + QGis::UnitType mapUnits() const; + void setMapUnits( QGis::UnitType u ); + + void setBackgroundColor( const QColor& color ); + QColor backgroundColor() const; + + void setSelectionColor( const QColor& color ); + QColor selectionColor() const; + + enum Flag + { + Antialiasing = 0x01, + DrawEditingInfo = 0x02, + ForceVectorOutput = 0x04, + UseAdvancedEffects = 0x08, + DrawLabeling = 0x10 + // TODO: ignore scale-based visibiity (overview) + }; + //Q_DECLARE_FLAGS(Flags, Flag) + typedef QFlags Flags; + + void setFlags( Flags flags ); + void setFlag( Flag flag, bool on = true ); + Flags flags() const; + bool testFlag( Flag flag ) const; + + bool hasValidSettings() const; + QgsRectangle visibleExtent() const; + double mapUnitsPerPixel() const; + double scale() const; + + + // -- utility functions -- + + const QgsMapToPixel& mapToPixel() const; + + /** + * @brief transform bounding box from layer's CRS to output CRS + * @see layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) if you want to transform a rectangle + * @return a bounding box (aligned rectangle) containing the transformed extent + */ + QgsRectangle layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const; + + /** + * @brief transform bounding box from output CRS to layer's CRS + * @see mapToLayerCoordinates( QgsMapLayer* theLayer,QgsRectangle rect ) if you want to transform a rectangle + * @return a bounding box (aligned rectangle) containing the transformed extent + */ + QgsRectangle outputExtentToLayerExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const; + + /** + * @brief transform point coordinates from layer's CRS to output CRS + * @return the transformed point + */ + QgsPoint layerToMapCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const; + + /** + * @brief transform rectangle from layer's CRS to output CRS + * @see layerExtentToOutputExtent() if you want to transform a bounding box + * @return the transformed rectangle + */ + QgsRectangle layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const; + + /** + * @brief transform point coordinates from output CRS to layer's CRS + * @return the transformed point + */ + QgsPoint mapToLayerCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const; + + /** + * @brief transform rectangle from output CRS to layer's CRS + * @see outputExtentToLayerExtent() if you want to transform a bounding box + * @return the transformed rectangle + */ + QgsRectangle mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const; + + + //! returns current extent of layer set + QgsRectangle fullExtent() const; + + /* serialization */ + + void readXML( QDomNode& theNode ); + + void writeXML( QDomNode& theNode, QDomDocument& theDoc ); + +}; + +//Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapSettings::Flags ) +QFlags operator|(QgsMapSettings::Flag f1, QFlags f2); diff --git a/python/core/qgspallabeling.sip b/python/core/qgspallabeling.sip index a25d0776de9..3bcf000d4c5 100644 --- a/python/core/qgspallabeling.sip +++ b/python/core/qgspallabeling.sip @@ -89,6 +89,9 @@ class QgsPalLayerSettings QgsPalLayerSettings( const QgsPalLayerSettings& s ); ~QgsPalLayerSettings(); + //! @note added in 2.1 + static QgsPalLayerSettings fromLayer( QgsVectorLayer* layer ); + enum Placement { AroundPoint, // Point / Polygon @@ -433,7 +436,7 @@ class QgsPalLayerSettings void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = 0 ); // implementation of register feature hook - void registerFeature( QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context ); + void registerFeature( QgsFeature& f, const QgsRenderContext& context ); void readFromLayer( QgsVectorLayer* layer ); void writeToLayer( QgsVectorLayer* layer ); @@ -579,6 +582,24 @@ class QgsLabelComponent void setDpiRatio( double ratio ); }; + +/** + * Class that stores computed placement from labeling engine. + * @note added in 2.1 + */ +class QgsLabelingResults +{ +public: + QgsLabelingResults(); + ~QgsLabelingResults(); + + //! return infos about labels at a given (map) position + QList labelsAtPosition( const QgsPoint& p ) const; + //! return infos about labels within a given (map) rectangle + QList labelsWithinRect( const QgsRectangle& r ) const; +}; + + class QgsPalLabeling : QgsLabelingEngineInterface { %TypeHeaderCode @@ -624,7 +645,10 @@ class QgsPalLabeling : QgsLabelingEngineInterface // implemented methods from labeling engine interface //! called when we're going to start with rendering - virtual void init( QgsMapRenderer* mr ); + //! @deprecated since 2.1 - use override with QgsMapSettings + virtual void init( QgsMapRenderer* mr ) /Deprecated/; + //! called when we're going to start with rendering + virtual void init( const QgsMapSettings& mapSettings ); //! called to find out whether the layer is used for labeling virtual bool willUseLayer( QgsVectorLayer* layer ); //! clears all PAL layer settings for registered layers @@ -632,22 +656,26 @@ class QgsPalLabeling : QgsLabelingEngineInterface virtual void clearActiveLayers(); //! clears data defined objects from PAL layer settings for a registered layer //! @note: this method was added in version 1.9 - virtual void clearActiveLayer( QgsVectorLayer* layer ); + virtual void clearActiveLayer( const QString& layerID ); //! hook called when drawing layer before issuing select() - virtual int prepareLayer( QgsVectorLayer* layer, QSet& attrIndices, QgsRenderContext& ctx ); + virtual int prepareLayer( QgsVectorLayer* layer, QStringList &attrNames, QgsRenderContext& ctx ); //! adds a diagram layer to the labeling engine virtual int addDiagramLayer( QgsVectorLayer* layer, QgsDiagramLayerSettings *s ); //! hook called when drawing for every feature in a layer - virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ); - virtual void registerDiagramFeature( QgsVectorLayer* layer, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ); + virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ); + virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ); //! called when the map is drawn and labels should be placed virtual void drawLabeling( QgsRenderContext& context ); //! called when we're done with rendering virtual void exit(); //! return infos about labels at a given (map) position - virtual QList labelsAtPosition( const QgsPoint& p ); + virtual QList labelsAtPosition( const QgsPoint& p ) /Deprecated/; //! return infos about labels within a given (map) rectangle - virtual QList labelsWithinRect( const QgsRectangle& r ); + virtual QList labelsWithinRect( const QgsRectangle& r ) /Deprecated/; + + //! Return pointer to recently computed results (in drawLabeling()) and pass the ownership of results to the caller + //! @note added in 2.1 + QgsLabelingResults* takeResults() /TransferBack/; //! called when passing engine among map renderers virtual QgsLabelingEngineInterface* clone() /Factory/; @@ -674,6 +702,8 @@ class QgsPalLabeling : QgsLabelingEngineInterface void loadEngineSettings(); void saveEngineSettings(); void clearEngineSettings(); - bool isStoredWithProject() const; - void setStoredWithProject( bool store ); + //! @deprecated since 2.1 - settings are always stored in project + bool isStoredWithProject() const /Deprecated/; + //! @deprecated since 2.1 - settings are always stored in project + void setStoredWithProject( bool store ) /Deprecated/; }; diff --git a/python/core/qgsrendercontext.sip b/python/core/qgsrendercontext.sip index 9a1bdd8972e..342bbbb573c 100644 --- a/python/core/qgsrendercontext.sip +++ b/python/core/qgsrendercontext.sip @@ -10,6 +10,10 @@ class QgsRenderContext QgsRenderContext(); ~QgsRenderContext(); + //! create initialized QgsRenderContext instance from given QgsMapSettings + //! @note added in 2.1 + static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings ); + //getters QPainter* painter(); diff --git a/python/core/qgssnapper.sip b/python/core/qgssnapper.sip index 5a8a7fd33d1..044da04c1da 100644 --- a/python/core/qgssnapper.sip +++ b/python/core/qgssnapper.sip @@ -69,7 +69,11 @@ class QgsSnapper QgsTolerance::UnitType mUnitType; }; - QgsSnapper( QgsMapRenderer* mapRender ); + //!@ deprecated since 2.1 - use constructor with QgsMapSettings + QgsSnapper( QgsMapRenderer* mapRender ) /Deprecated/; + + explicit QgsSnapper( const QgsMapSettings& mapSettings ); + ~QgsSnapper(); /**Does the snapping operation @param startPoint the start point for snapping (in pixel coordinates) diff --git a/python/core/qgsspatialindex.sip b/python/core/qgsspatialindex.sip index 419fefe53fa..f8564695757 100644 --- a/python/core/qgsspatialindex.sip +++ b/python/core/qgsspatialindex.sip @@ -12,30 +12,35 @@ class QgsSpatialIndex /** constructor - creates R-tree */ QgsSpatialIndex(); + /** copy constructor */ + QgsSpatialIndex( const QgsSpatialIndex& other ); + /** destructor finalizes work with spatial index */ ~QgsSpatialIndex(); + /** implement assignment operator */ + //QgsSpatialIndex& operator=( const QgsSpatialIndex& other ); /* operations */ /** add feature to index */ - bool insertFeature( QgsFeature& f ); + bool insertFeature( const QgsFeature& f ); /** remove feature from index */ - bool deleteFeature( QgsFeature& f ); + bool deleteFeature( const QgsFeature& f ); /* queries */ /** returns features that intersect the specified rectangle */ - QList intersects( QgsRectangle rect ); + QList intersects( QgsRectangle rect ) const; /** returns nearest neighbors (their count is specified by second parameter) */ - QList nearestNeighbor( QgsPoint point, int neighbors ); + QList nearestNeighbor( QgsPoint point, int neighbors ) const; protected: - // SpatialIndex::Region rectToRegion( QgsRectangle rect ); + // static SpatialIndex::Region rectToRegion( QgsRectangle rect ); // bool featureInfo( QgsFeature& f, SpatialIndex::Region& r, QgsFeatureId &id ); diff --git a/python/core/qgstolerance.sip b/python/core/qgstolerance.sip index 7c5f7672b80..44884bbc985 100644 --- a/python/core/qgstolerance.sip +++ b/python/core/qgstolerance.sip @@ -20,14 +20,40 @@ class QgsTolerance * The value is read from settings and transformed if necessary. * @return value of vertex tolerance in map units */ - static double vertexSearchRadius( QgsMapLayer* layer, QgsMapRenderer* renderer ); + static double vertexSearchRadius( QgsMapLayer* layer, const QgsMapSettings& mapSettings ); + + /** + * Static function to get vertex tolerance value for a layer. + * The value is read from settings and transformed if necessary. + * @return value of vertex tolerance in map units + */ + //! @deprecated since 2.1 - use override with QgsMapSettings + static double vertexSearchRadius( QgsMapLayer* layer, QgsMapRenderer* renderer ) /Deprecated/; /** * Static function to get default tolerance value for a layer. * The value is read from settings and transformed if necessary. * @return value of default tolerance in map units */ - static double defaultTolerance( QgsMapLayer* layer, QgsMapRenderer* renderer ); + static double defaultTolerance( QgsMapLayer* layer, const QgsMapSettings& mapSettings ); + + /** + * Static function to get default tolerance value for a layer. + * The value is read from settings and transformed if necessary. + * @return value of default tolerance in map units + */ + //! @deprecated since 2.1 - use override with QgsMapSettings + static double defaultTolerance( QgsMapLayer* layer, QgsMapRenderer* renderer ) /Deprecated/; + + /** + * Static function to translate tolerance value into current map unit value + * @param tolerance tolerance value to be translated + * @param layer reference layer + * @param mapSettings settings of the map + * @param units type of units to be translated + * @return value of tolerance in map units + */ + static double toleranceInMapUnits( double tolerance, QgsMapLayer* layer, const QgsMapSettings& mapSettings, UnitType units = MapUnits ); /** * Static function to translate tolerance value into current map unit value @@ -37,6 +63,6 @@ class QgsTolerance * @param units type of units to be translated * @return value of tolerance in map units */ - static double toleranceInMapUnits( double tolerance, QgsMapLayer* layer, QgsMapRenderer* renderer, UnitType units = MapUnits ); - + //! @deprecated since 2.1 - use the override with QgsMapSettings + static double toleranceInMapUnits( double tolerance, QgsMapLayer* layer, QgsMapRenderer* renderer, UnitType units = MapUnits ) /Deprecated/; }; diff --git a/python/core/qgsvectordataprovider.sip b/python/core/qgsvectordataprovider.sip index e5e37ecec94..d933b057b40 100644 --- a/python/core/qgsvectordataprovider.sip +++ b/python/core/qgsvectordataprovider.sip @@ -44,6 +44,24 @@ class QgsVectorDataProvider : QgsDataProvider */ virtual ~QgsVectorDataProvider(); + /** + * Return feature source object that can be used for querying provider's data. The returned feature source + * is independent from provider - any changes to provider's state (e.g. change of subset string) will not be + * reflected in the feature source, therefore it can be safely used for processing in background without + * having to care about possible changes within provider that may happen concurrently. Also, even in the case + * of provider being deleted, any feature source obtained from the provider will be kept alive and working + * (they are independent and owned by the caller). + * + * Sometimes there are cases when some data needs to be shared between vector data provider and its feature source. + * In such cases, the implementation must ensure that the data is not susceptible to run condition. For example, + * if it is possible that both feature source and provider may need reading/writing to some shared data at the + * same time, some synchronization mechanisms must be used (e.g. mutexes) to prevent data corruption. + * + * @note added in 2.1 + * @return new instance of QgsAbstractFeatureSource (caller is responsible for deleting it) + */ + virtual QgsAbstractFeatureSource* featureSource() const /Factory/; + /** * Returns the permanent storage type for this layer as a friendly name. */ @@ -275,9 +293,9 @@ class QgsVectorDataProvider : QgsDataProvider */ virtual bool isSaveAndLoadStyleToDBSupported(); - protected: - QVariant convertValue( QVariant::Type type, QString value ); + static QVariant convertValue( QVariant::Type type, QString value ); +protected: void clearMinMaxCache(); void fillMinMaxCache(); diff --git a/python/core/qgsvectorlayer.sip b/python/core/qgsvectorlayer.sip index f214defb246..6d3061eef7e 100644 --- a/python/core/qgsvectorlayer.sip +++ b/python/core/qgsvectorlayer.sip @@ -350,16 +350,6 @@ class QgsVectorLayer : QgsMapLayer */ void setRendererV2( QgsFeatureRendererV2* r /Transfer/ ); - /** Draw layer with renderer V2. QgsFeatureRenderer::startRender() needs to be called before using this method - * @note added in 1.4 - */ - void drawRendererV2( QgsFeatureIterator &fit, QgsRenderContext& rendererContext, bool labeling ); - - /** Draw layer with renderer V2 using symbol levels. QgsFeatureRenderer::startRender() needs to be called before using this method - * @note added in 1.4 - */ - void drawRendererV2Levels( QgsFeatureIterator &fit, QgsRenderContext& rendererContext, bool labeling ); - /** Returns point, line or polygon */ QGis::GeometryType geometryType() const; @@ -642,6 +632,11 @@ class QgsVectorLayer : QgsMapLayer @note added in version 1.6*/ 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/; + /** Draws the layer * @return false if an error occurred during drawing */ diff --git a/python/core/qgsvectorlayerfeatureiterator.sip b/python/core/qgsvectorlayerfeatureiterator.sip index adcf6867a37..3e7e9c3f0a4 100644 --- a/python/core/qgsvectorlayerfeatureiterator.sip +++ b/python/core/qgsvectorlayerfeatureiterator.sip @@ -1,3 +1,7 @@ + +// abstract feature iterator implementations are not part of public API + +/* class QgsVectorLayerFeatureIterator : QgsAbstractFeatureIterator { %TypeHeaderCode @@ -27,3 +31,4 @@ class QgsVectorLayerFeatureIterator : QgsAbstractFeatureIterator bool nextFeatureFid( QgsFeature& f ); void addJoinedAttributes( QgsFeature &f ); }; +*/ diff --git a/python/core/raster/qgsrasterlayer.sip b/python/core/raster/qgsrasterlayer.sip index 296a6bb23df..23b26ba78f2 100644 --- a/python/core/raster/qgsrasterlayer.sip +++ b/python/core/raster/qgsrasterlayer.sip @@ -146,6 +146,11 @@ class QgsRasterLayer : QgsMapLayer @note added in version 1.6*/ 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/; + /** \brief This is called when the view on the raster layer needs to be redrawn */ bool draw( QgsRenderContext& rendererContext ); @@ -154,11 +159,11 @@ class QgsRasterLayer : QgsMapLayer QgsRasterViewPort * myRasterViewPort, const QgsMapToPixel* theQgsMapToPixel = 0 ); - /** \brief [ data provider interface ] If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure */ - QString lastError(); + //! @deprecated since 2.1 - returns empty string + QString lastError() /Deprecated/; - /** \brief [ data provider interface ] If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure */ - QString lastErrorTitle(); + //! @deprecated since 2.1 - returns empty string + QString lastErrorTitle() /Deprecated/; /**Returns a list with classification items (Text and color) @note this method was added in version 1.8*/ @@ -233,8 +238,8 @@ class QgsRasterLayer : QgsMapLayer public slots: void showStatusMessage( const QString & theMessage ); - /** \brief Propagate progress updates from GDAL up to the parent app */ - void updateProgress( int, int ); + //! @deprecated since 2.1 - does nothing + void updateProgress( int, int ) /Deprecated/; /** \brief receive progress signal from provider */ void onProgress( int, double, QString ); diff --git a/python/core/symbology-ng/qgscategorizedsymbolrendererv2.sip b/python/core/symbology-ng/qgscategorizedsymbolrendererv2.sip index 189f2ffe0e3..08cf7df71a2 100644 --- a/python/core/symbology-ng/qgscategorizedsymbolrendererv2.sip +++ b/python/core/symbology-ng/qgscategorizedsymbolrendererv2.sip @@ -43,7 +43,7 @@ class QgsCategorizedSymbolRendererV2 : QgsFeatureRendererV2 virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature ); - virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ); + virtual void startRender( QgsRenderContext& context, const QgsFields& fields ); virtual void stopRender( QgsRenderContext& context ); diff --git a/python/core/symbology-ng/qgsgraduatedsymbolrendererv2.sip b/python/core/symbology-ng/qgsgraduatedsymbolrendererv2.sip index 4eb05baae1c..857d2db1fcc 100644 --- a/python/core/symbology-ng/qgsgraduatedsymbolrendererv2.sip +++ b/python/core/symbology-ng/qgsgraduatedsymbolrendererv2.sip @@ -42,7 +42,7 @@ class QgsGraduatedSymbolRendererV2 : QgsFeatureRendererV2 virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature ); - virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ); + virtual void startRender( QgsRenderContext& context, const QgsFields& fields ); virtual void stopRender( QgsRenderContext& context ); diff --git a/python/core/symbology-ng/qgspointdisplacementrenderer.sip b/python/core/symbology-ng/qgspointdisplacementrenderer.sip index 1e7d2ec80b0..ad304c55bc8 100644 --- a/python/core/symbology-ng/qgspointdisplacementrenderer.sip +++ b/python/core/symbology-ng/qgspointdisplacementrenderer.sip @@ -16,7 +16,7 @@ class QgsPointDisplacementRenderer : QgsFeatureRendererV2 QgsSymbolV2* symbolForFeature( QgsFeature& feature ); - void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ); + void startRender( QgsRenderContext& context, const QgsFields& fields ); void stopRender( QgsRenderContext& context ); diff --git a/python/core/symbology-ng/qgsrendererv2.sip b/python/core/symbology-ng/qgsrendererv2.sip index 752e81df60d..685c21036c7 100644 --- a/python/core/symbology-ng/qgsrendererv2.sip +++ b/python/core/symbology-ng/qgsrendererv2.sip @@ -57,7 +57,10 @@ class QgsFeatureRendererV2 // to be overridden virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature ) = 0; - virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ) = 0; + virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) = 0; + + //! @deprecated since 2.1 - not using QgsVectorLayer directly anymore + virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ) /Deprecated/; virtual void stopRender( QgsRenderContext& context ) = 0; diff --git a/python/core/symbology-ng/qgsrulebasedrendererv2.sip b/python/core/symbology-ng/qgsrulebasedrendererv2.sip index 5c427d132f3..77560e05418 100644 --- a/python/core/symbology-ng/qgsrulebasedrendererv2.sip +++ b/python/core/symbology-ng/qgsrulebasedrendererv2.sip @@ -91,7 +91,7 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2 QDomElement save( QDomDocument& doc, QgsSymbolV2Map& symbolMap ); //! prepare the rule for rendering and its children (build active children array) - bool startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ); + bool startRender( QgsRenderContext& context, const QgsFields& fields ); //! get all used z-levels from this rule and children QSet collectZLevels(); //! assign normalized z-levels [0..N-1] for this rule's symbol for quick access during rendering @@ -147,7 +147,7 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2 virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false ); - virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ); + virtual void startRender( QgsRenderContext& context, const QgsFields& fields ); virtual void stopRender( QgsRenderContext& context ); diff --git a/python/core/symbology-ng/qgssinglesymbolrendererv2.sip b/python/core/symbology-ng/qgssinglesymbolrendererv2.sip index c94506288a3..4db012c7fed 100644 --- a/python/core/symbology-ng/qgssinglesymbolrendererv2.sip +++ b/python/core/symbology-ng/qgssinglesymbolrendererv2.sip @@ -11,7 +11,7 @@ class QgsSingleSymbolRendererV2 : QgsFeatureRendererV2 virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature ); - virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ); + virtual void startRender( QgsRenderContext& context, const QgsFields& fields ); virtual void stopRender( QgsRenderContext& context ); diff --git a/python/core/symbology-ng/qgssymbollayerv2.sip b/python/core/symbology-ng/qgssymbollayerv2.sip index 4184d782e21..b4b1ea1df13 100644 --- a/python/core/symbology-ng/qgssymbollayerv2.sip +++ b/python/core/symbology-ng/qgssymbollayerv2.sip @@ -109,7 +109,7 @@ class QgsSymbolLayerV2 protected: QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false ); - virtual void prepareExpressions( const QgsVectorLayer* vl ); + virtual void prepareExpressions( const QgsFields* fields, double scale = -1 ); virtual QgsExpression* expression( const QString& property ); /**Saves data defined properties to string map*/ void saveDataDefinedProperties( QgsStringMap& stringMap ) const; diff --git a/python/core/symbology-ng/qgssymbolv2.sip b/python/core/symbology-ng/qgssymbolv2.sip index fae6e793b4c..5d5edebc8d9 100644 --- a/python/core/symbology-ng/qgssymbolv2.sip +++ b/python/core/symbology-ng/qgssymbolv2.sip @@ -73,7 +73,7 @@ class QgsSymbolV2 //! delete layer at specified index and set a new one bool changeSymbolLayer( int index, QgsSymbolLayerV2 *layer /Transfer/ ); - void startRender( QgsRenderContext& context, const QgsVectorLayer* layer = 0 ); + void startRender( QgsRenderContext& context, const QgsFields* fields = 0 ); void stopRender( QgsRenderContext& context ); void setColor( const QColor& color ); @@ -124,7 +124,7 @@ class QgsSymbolV2RenderContext %End public: - QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u , qreal alpha = 1.0, bool selected = false, int renderHints = 0, const QgsFeature* f = 0 ); + QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u , qreal alpha = 1.0, bool selected = false, int renderHints = 0, const QgsFeature* f = 0, const QgsFields* fields = 0 ); ~QgsSymbolV2RenderContext(); QgsRenderContext& renderContext(); @@ -147,10 +147,14 @@ class QgsSymbolV2RenderContext void setRenderHints( int hints ); void setFeature( const QgsFeature* f ); + //! Current feature being rendered - may be null const QgsFeature* feature() const; - void setLayer( const QgsVectorLayer* layer ); - const QgsVectorLayer* layer() const; + //! Fields of the layer. Currently only available in startRender() calls + //! to allow symbols with data-defined properties prepare the expressions + //! (other times fields() returns null) + //! @note added in 2.1 + const QgsFields* fields() const; double outputLineWidth( double width ) const; double outputPixelSize( double size ) const; diff --git a/python/gui/qgsmapcanvas.sip b/python/gui/qgsmapcanvas.sip index 64b178d10f0..8811e8e0ab8 100644 --- a/python/gui/qgsmapcanvas.sip +++ b/python/gui/qgsmapcanvas.sip @@ -55,18 +55,39 @@ class QgsMapCanvas : QGraphicsView void enableOverviewMode( QgsMapOverviewCanvas* overview ); + //! Get access to properties used for map rendering + //! @note added in 2.1 + const QgsMapSettings& mapSettings() const; + + //! sets whether to use projections for this layer set + //! @note added in 2.1 + void setCrsTransformEnabled( bool enabled ); + + //! sets destination coordinate reference system + //! @note added in 2.1 + void setDestinationCrs( const QgsCoordinateReferenceSystem& crs ); + + //! Get access to the labeling results (may be null) + //! @note added in 2.1 + const QgsLabelingResults* labelingResults() const; + + //! @deprecated since 2.1 - there could be more than just one "map" items QgsMapCanvasMap* map(); - QgsMapRenderer* mapRenderer() /Transfer/; + //! @deprecated since 2.1 - use mapRendererSettings() for anything related to current renderer settings + //// SIP: removed /Transfer/ because it crashes after few calls to iface.mapCanvas().mapRenderer().hasCrsTransformEnabled() + //// and in fact there is no transfer of ownership from c++ to python! + //// Actually the problem comes from the fact that "hasCrsTransformEnabled" is both a signal and a normal method + QgsMapRenderer* mapRenderer() /Deprecated/; - //! Accessor for the canvas paint device - QPaintDevice &canvasPaintDevice(); + //! @deprecated since 2.1 + QPaintDevice &canvasPaintDevice() /Deprecated/; //! Get the last reported scale of the canvas double scale(); - //! Clear the map canvas - void clear(); + //! @deprecated since 2.1 - use refresh() - clear does the same thing + void clear() /Deprecated/; //! Returns the mapUnitsPerPixel (map units per pixel) for the canvas double mapUnitsPerPixel() const; @@ -118,11 +139,15 @@ class QgsMapCanvas : QGraphicsView /** Read property of QColor bgColor. */ virtual QColor canvasColor() const; + /** Set color of selected vector features */ + //! @note added in 2.1 + void setSelectionColor( const QColor& color ); + /** Emits signal scaleChanged to update scale in main window */ void updateScale(); - /** Updates the full extent */ - void updateFullExtent(); + //! @deprecated since v2.1 - does nothing + void updateFullExtent() /Deprecated/; //! return the map layer at position index in the layer stack QgsMapLayer *layer( int index ); @@ -143,11 +168,11 @@ class QgsMapCanvas : QGraphicsView /*! Accessor for frozen status of canvas */ bool isFrozen(); - //! Flag the canvas as dirty and needed a refresh - void setDirty( bool _dirty ); + //! @deprecated since 2.1 - use refresh() to trigger a refresh (clients should not decide explicitly whether canvas is dirty or not) + void setDirty( bool _dirty ) /Deprecated/; - //! Return the state of the canvas (dirty or not) - bool isDirty() const; + //! @deprecated since 2.1 - dirty flag is not kept anymore - always returns false + bool isDirty() const /Deprecated/; //! Set map units (needed by project properties dialog) void setMapUnits( QGis::UnitType mapUnits ); @@ -189,8 +214,8 @@ class QgsMapCanvas : QGraphicsView //! true if antialising is enabled bool antiAliasingEnabled() const; - //! Select which Qt class to render with - void useImageToRender( bool theFlag ); + //! @deprecated since 2.1 - does nothing because now we always render to QImage + void useImageToRender( bool theFlag ) /Deprecated/; // following 2 methods should be moved elsewhere or changed to private // currently used by pan map tool @@ -225,14 +250,15 @@ class QgsMapCanvas : QGraphicsView /** A simple helper method to find out if on the fly projections are enabled or not */ bool hasCrsTransformEnabled(); - /** The map units may have changed, so cope with that */ - void mapUnitsChanged(); + //! @deprecated in 2.1 - does nothing - kept for API compatibility + void updateMap() /Deprecated/; - /** updates pixmap on render progress */ - void updateMap(); + //! stop rendering (if there is any right now) + //! @note added in 2.1 + void stopRendering(); - //! show whatever error is exposed by the QgsMapLayer. - void showError( QgsMapLayer * mapLayer ); + //! @deprecated since 2.1 - does nothing - errors are reported by different means + void showError( QgsMapLayer * mapLayer ) /Deprecated/; //! called to read map canvas settings from project void readProject( const QDomDocument & ); @@ -242,7 +268,8 @@ class QgsMapCanvas : QGraphicsView signals: /** Let the owner know how far we are with render operations */ - void setProgress( int, int ); + //! @deprecated since 2.1 - already unused in 2.0 anyway + void setProgress( int, int ) /Deprecated/; /** emits current mouse position \note changed in 1.3 */ @@ -262,15 +289,20 @@ class QgsMapCanvas : QGraphicsView being rendered onto a pixmap other than the mapCanvas own pixmap member. */ + //! TODO: deprecate when decorations are reimplemented as map canvas items + //! - anything related to rendering progress is not visible outside of map canvas + //! - additional drawing shall be done directly within the renderer job or independently as a map canvas item void renderComplete( QPainter * ); /** Emitted when canvas finished a refresh request. \note Added in 2.0 */ - void mapCanvasRefreshed(); + //! @deprecated since 2.1 - anything related to rendering progress is not visible outside of map canvas + void mapCanvasRefreshed() /Deprecated/; /** Emitted when the canvas is about to be rendered. \note Added in 1.5 */ - void renderStarting(); + //! @deprecated since 2.1 - anything related to rendering progress is not visible outside of map canvas + void renderStarting() /Deprecated/; //! Emitted when a new set of layers has been received void layersChanged(); @@ -295,6 +327,18 @@ class QgsMapCanvas : QGraphicsView //! @note: this signal was added in version 1.4 void zoomNextStatusChanged( bool ); + //! Emitted when on-the-fly projection has been turned on/off + //! @note added in 2.1 + void hasCrsTransformEnabledChanged( bool flag ); + + //! Emitted when map CRS has changed + //! @note added in 2.1 + void destinationCrsChanged(); + + //! Emmitted when map units are changed + //! @note added in 2.1 + void mapUnitsChanged(); + protected: //! Overridden standard event to be gestures aware bool event( QEvent * e ); diff --git a/python/gui/qgsmapcanvasitem.sip b/python/gui/qgsmapcanvasitem.sip index beb352aa78f..0762e899b6f 100644 --- a/python/gui/qgsmapcanvasitem.sip +++ b/python/gui/qgsmapcanvasitem.sip @@ -39,7 +39,8 @@ class QgsMapCanvasItem : QGraphicsItem virtual QRectF boundingRect() const; //! sets current offset, to be called from QgsMapCanvas - void setPanningOffset( const QPoint& point ); + //! @deprecated since v2.1 - not called by QgsMapCanvas anymore + void setPanningOffset( const QPoint& point ) /Deprecated/; //! returns canvas item rectangle QgsRectangle rect() const; diff --git a/python/gui/qgsmapcanvasmap.sip b/python/gui/qgsmapcanvasmap.sip index 43cde053084..08f18faab8a 100644 --- a/python/gui/qgsmapcanvasmap.sip +++ b/python/gui/qgsmapcanvasmap.sip @@ -6,7 +6,7 @@ #include %End -class QgsMapCanvasMap : QGraphicsRectItem +class QgsMapCanvasMap : QgsMapCanvasItem { %TypeHeaderCode #include @@ -28,25 +28,32 @@ class QgsMapCanvasMap : QGraphicsRectItem //! constructor QgsMapCanvasMap( QgsMapCanvas* canvas /TransferThis/ ); - //! resize canvas item and pixmap - void resize( QSize size ); + //! @note added in 2.1 + void setContent( const QImage& image, const QgsRectangle& rect ); - void enableAntiAliasing( bool flag ); + //! @note added in 2.1 + QImage contentImage() const; - //! renders map using QgsMapRenderer to mPixmap - void render(); + virtual void paint( QPainter * painter ); - void setBackgroundColor( const QColor& color ); + //! @deprecated in 2.1 - does nothing. Kept for API compatibility + void resize( QSize size ) /Deprecated/; - void setPanningOffset( const QPoint& point ); + //! @deprecated in 2.1 - does nothing. Kept for API compatibility + void enableAntiAliasing( bool flag ) /Deprecated/; - QPaintDevice& paintDevice(); + //! @deprecated in 2.1 - does nothing. Kept for API compatibility + void render() /Deprecated/; - void paint( QPainter* p, const QStyleOptionGraphicsItem*, QWidget* ); + //! @deprecated in 2.1 - does nothing. Kept for API compatibility + void setBackgroundColor( const QColor& color ) /Deprecated/; - QRectF boundingRect() const; + //! @deprecated in 2.1 - does nothing. Kept for API compatibility + void setPanningOffset( const QPoint& point ) /Deprecated/; - //! Update contents - can be called while drawing to show the status. - //! Added in version 1.2 - void updateContents(); + //! @deprecated in 2.1 + QPaintDevice& paintDevice() /Deprecated/; + + //! @deprecated in 2.1 - does nothing. Kept for API compatibility + void updateContents() /Deprecated/; }; diff --git a/python/gui/qgsmapoverviewcanvas.sip b/python/gui/qgsmapoverviewcanvas.sip index 82b8831725d..798a81106b1 100644 --- a/python/gui/qgsmapoverviewcanvas.sip +++ b/python/gui/qgsmapoverviewcanvas.sip @@ -10,9 +10,6 @@ class QgsMapOverviewCanvas : QWidget ~QgsMapOverviewCanvas(); - //! used for overview canvas to reflect changed extent in main map canvas - void drawExtentRect(); - //! renders overview and updates panning widget void refresh(); @@ -22,7 +19,7 @@ class QgsMapOverviewCanvas : QWidget //! updates layer set for overview void setLayerSet( const QStringList& layerSet ); - QStringList& layerSet(); + QStringList layerSet() const; void enableAntiAliasing( bool flag ); @@ -30,10 +27,16 @@ class QgsMapOverviewCanvas : QWidget public slots: + //! used for overview canvas to reflect changed extent in main map canvas + void drawExtentRect(); + void hasCrsTransformEnabled( bool flag ); void destinationSrsChanged(); + protected slots: + void mapRenderingFinished(); + protected: //! Overridden paint event diff --git a/python/gui/qgsmaptool.sip b/python/gui/qgsmaptool.sip index 5c2b9a9f6ac..ebe48520356 100644 --- a/python/gui/qgsmaptool.sip +++ b/python/gui/qgsmaptool.sip @@ -64,7 +64,8 @@ class QgsMapTool : QObject %End //! Called when rendering has finished. Default implementation does nothing. - virtual void renderComplete(); + //! @deprecated since 2.1 - not called anymore - map tools must not directly depend on rendering progress + virtual void renderComplete() /Deprecated/; /** Use this to associate a QAction to this maptool. Then when the setMapTool diff --git a/src/app/nodetool/qgsselectedfeature.cpp b/src/app/nodetool/qgsselectedfeature.cpp index 0bfa409f5ef..b9a7dc3018e 100644 --- a/src/app/nodetool/qgsselectedfeature.cpp +++ b/src/app/nodetool/qgsselectedfeature.cpp @@ -116,7 +116,7 @@ void QgsSelectedFeature::setSelectedFeature( QgsFeatureId featureId, QgsVectorLa connect( mVlayer, SIGNAL( beforeRollBack() ), this, SLOT( beforeRollBack() ) ); // projection or extents changed - connect( canvas, SIGNAL( destinationSrsChanged() ), this, SLOT( updateVertexMarkersPosition() ) ); + connect( canvas, SIGNAL( destinationCrsChanged() ), this, SLOT( updateVertexMarkersPosition() ) ); connect( canvas, SIGNAL( extentsChanged() ), this, SLOT( updateVertexMarkersPosition() ) ); // geometry was changed diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 480d904dead..d71d655a3d6 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1889,10 +1889,10 @@ void QgisApp::setupConnections() mMapCanvas, SLOT( setRenderFlag( bool ) ) ); // connect renderer - connect( mMapCanvas, SIGNAL( hasCrsTransformEnabled( bool ) ), + connect( mMapCanvas, SIGNAL( hasCrsTransformEnabledChanged( bool ) ), this, SLOT( hasCrsTransformEnabled( bool ) ) ); - connect( mMapCanvas, SIGNAL( destinationSrsChanged() ), - this, SLOT( destinationSrsChanged() ) ); + connect( mMapCanvas, SIGNAL( destinationCrsChanged() ), + this, SLOT( destinationCrsChanged() ) ); // connect legend signals connect( mMapLegend, SIGNAL( currentLayerChanged( QgsMapLayer * ) ), @@ -7627,7 +7627,7 @@ void QgisApp::updateCRSStatusBar() } } -void QgisApp::destinationSrsChanged() +void QgisApp::destinationCrsChanged() { // save this information to project long srsid = mMapCanvas->mapSettings().destinationCrs().srsid(); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 94bf2d018df..598d1c81d5f 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -1001,7 +1001,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow void showStatusMessage( QString theMessage ); void updateMouseCoordinatePrecision(); void hasCrsTransformEnabled( bool theFlag ); - void destinationSrsChanged(); + void destinationCrsChanged(); // void debugHook(); //! Add a vector layer to the map void addVectorLayer(); diff --git a/src/app/qgsdecorationgrid.cpp b/src/app/qgsdecorationgrid.cpp index a081ffbdc87..e623dc4fb13 100644 --- a/src/app/qgsdecorationgrid.cpp +++ b/src/app/qgsdecorationgrid.cpp @@ -63,7 +63,7 @@ QgsDecorationGrid::QgsDecorationGrid( QObject* parent ) mMarkerSymbol = 0; projectRead(); - connect( QgisApp::instance()->mapCanvas()->mapRenderer(), SIGNAL( mapUnitsChanged() ), + connect( QgisApp::instance()->mapCanvas(), SIGNAL( mapUnitsChanged() ), this, SLOT( checkMapUnitsChanged() ) ); } diff --git a/src/app/qgsmaptoolmeasureangle.cpp b/src/app/qgsmaptoolmeasureangle.cpp index 176b616acf9..eb2e7b667c4 100644 --- a/src/app/qgsmaptoolmeasureangle.cpp +++ b/src/app/qgsmaptoolmeasureangle.cpp @@ -29,7 +29,7 @@ QgsMapToolMeasureAngle::QgsMapToolMeasureAngle( QgsMapCanvas* canvas ): QgsMapTo { mSnapper.setMapCanvas( canvas ); - connect( canvas, SIGNAL( destinationSrsChanged() ), + connect( canvas, SIGNAL( destinationCrsChanged() ), this, SLOT( updateSettings() ) ); } diff --git a/src/app/qgsmeasuretool.cpp b/src/app/qgsmeasuretool.cpp index e493a6753dd..0fe4aca662e 100644 --- a/src/app/qgsmeasuretool.cpp +++ b/src/app/qgsmeasuretool.cpp @@ -47,7 +47,7 @@ QgsMeasureTool::QgsMeasureTool( QgsMapCanvas* canvas, bool measureArea ) mDialog = new QgsMeasureDialog( this, Qt::WindowStaysOnTopHint ); mSnapper.setMapCanvas( canvas ); - connect( canvas, SIGNAL( destinationSrsChanged() ), + connect( canvas, SIGNAL( destinationCrsChanged() ), this, SLOT( updateSettings() ) ); } diff --git a/src/core/composer/qgscomposermap.cpp b/src/core/composer/qgscomposermap.cpp index a09f0691425..5745aafc185 100644 --- a/src/core/composer/qgscomposermap.cpp +++ b/src/core/composer/qgscomposermap.cpp @@ -164,7 +164,7 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const //use stored layer set or read current set from main canvas jobMapSettings.setLayers( mKeepLayerSet ? mLayerSet : ms.layers() ); jobMapSettings.setDestinationCrs( ms.destinationCrs() ); - jobMapSettings.setProjectionsEnabled( ms.hasCrsTransformEnabled() ); + jobMapSettings.setCrsTransformEnabled( ms.hasCrsTransformEnabled() ); jobMapSettings.setFlags( ms.flags() ); // composer-specific overrides of flags diff --git a/src/core/composer/qgscomposition.h b/src/core/composer/qgscomposition.h index 7ff880521ea..7264d723abb 100644 --- a/src/core/composer/qgscomposition.h +++ b/src/core/composer/qgscomposition.h @@ -245,6 +245,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene Q_DECL_DEPRECATED QgsMapRenderer* mapRenderer() {return mMapRenderer;} //! Return setting of QGIS map canvas + //! @note added in 2.1 const QgsMapSettings& mapSettings() const { return mMapSettings; } QgsComposition::PlotStyle plotStyle() const {return mPlotStyle;} diff --git a/src/core/qgsfeaturerequest.h b/src/core/qgsfeaturerequest.h index 847d29057dd..f4904515e8f 100644 --- a/src/core/qgsfeaturerequest.h +++ b/src/core/qgsfeaturerequest.h @@ -149,7 +149,9 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFeatureRequest::Flags ) class QgsFeatureIterator; class QgsAbstractFeatureIterator; -/** base class that can be used for any class that is capable of returning features */ +/** base class that can be used for any class that is capable of returning features + * @note added in 2.1 + */ class QgsAbstractFeatureSource { public: diff --git a/src/core/qgsmaprenderer.cpp b/src/core/qgsmaprenderer.cpp index e784b486907..55c25299143 100644 --- a/src/core/qgsmaprenderer.cpp +++ b/src/core/qgsmaprenderer.cpp @@ -224,11 +224,6 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale ) //Lock render method for concurrent threads (e.g. from globe) QMutexLocker renderLock( &mRenderMutex ); - //flag to see if the render context has changed - //since the last time we rendered. If it hasnt changed we can - //take some shortcuts with rendering - bool mySameAsLastFlag = true; - QgsDebugMsg( "========== Rendering ==========" ); if ( mExtent.isEmpty() ) @@ -309,28 +304,24 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale ) if ( mRenderContext.rasterScaleFactor() != rasterScaleFactor ) { mRenderContext.setRasterScaleFactor( rasterScaleFactor ); - mySameAsLastFlag = false; } if ( mRenderContext.scaleFactor() != scaleFactor ) { mRenderContext.setScaleFactor( scaleFactor ); - mySameAsLastFlag = false; } if ( mRenderContext.rendererScale() != mScale ) { //add map scale to render context mRenderContext.setRendererScale( mScale ); - mySameAsLastFlag = false; } if ( mLastExtent != mExtent ) { mLastExtent = mExtent; - mySameAsLastFlag = false; } mRenderContext.setLabelingEngine( mLabelingEngine ); if ( mLabelingEngine ) - mLabelingEngine->init( this ); + mLabelingEngine->init( mapSettings() ); // render all layers in the stack, starting at the base QListIterator li( mLayerSet ); @@ -981,7 +972,7 @@ bool QgsMapRenderer::writeXML( QDomNode & theNode, QDomDocument & theDoc ) tmpSettings.setOutputSize( outputSize() ); tmpSettings.setMapUnits( mapUnits() ); tmpSettings.setExtent( extent() ); - tmpSettings.setProjectionsEnabled( hasCrsTransformEnabled() ); + tmpSettings.setCrsTransformEnabled( hasCrsTransformEnabled() ); tmpSettings.setDestinationCrs( destinationCrs() ); tmpSettings.writeXML( theNode, theDoc ); @@ -1079,9 +1070,16 @@ QgsMapRenderer::BlendMode QgsMapRenderer::getBlendModeEnum( const QPainter::Comp } } -const QgsMapSettings& QgsMapRenderer::mapSettings() const +const QgsMapSettings& QgsMapRenderer::mapSettings() { - // TODO: keep up-to-date with real settings + // make sure the settings object is up-to-date + mMapSettings.setExtent( extent() ); + mMapSettings.setOutputSize( outputSize() ); + mMapSettings.setOutputDpi( outputDpi() ); + mMapSettings.setLayers( layerSet() ); + mMapSettings.setCrsTransformEnabled( hasCrsTransformEnabled() ); + mMapSettings.setDestinationCrs( destinationCrs() ); + mMapSettings.setMapUnits( mapUnits() ); return mMapSettings; } diff --git a/src/core/qgsmaprenderer.h b/src/core/qgsmaprenderer.h index 099c0b2026c..ca1b62a6f99 100644 --- a/src/core/qgsmaprenderer.h +++ b/src/core/qgsmaprenderer.h @@ -117,6 +117,7 @@ class CORE_EXPORT QgsLabelingEngineInterface }; +// ### QGIS 3: remove QgsMapRenderer in favor of QgsMapRendererJob /** \ingroup core * A non GUI class for rendering a map layer set onto a QPainter. @@ -296,7 +297,8 @@ class CORE_EXPORT QgsMapRenderer : public QObject static QgsMapRenderer::BlendMode getBlendModeEnum( const QPainter::CompositionMode blendMode ); //! bridge to QgsMapSettings - const QgsMapSettings& mapSettings() const; + //! @note added in 2.1 + const QgsMapSettings& mapSettings(); signals: @@ -391,6 +393,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject //! Locks rendering loop for concurrent draws QMutex mRenderMutex; + //! map settings - used only for export in mapSettings() for use in classes that deal with QgsMapSettings QgsMapSettings mMapSettings; private: diff --git a/src/core/qgsmapsettings.cpp b/src/core/qgsmapsettings.cpp index 2977fe06f05..a4db45dc069 100644 --- a/src/core/qgsmapsettings.cpp +++ b/src/core/qgsmapsettings.cpp @@ -171,7 +171,7 @@ void QgsMapSettings::setLayers(const QStringList& layers) mLayers = layers; } -void QgsMapSettings::setProjectionsEnabled( bool enabled ) +void QgsMapSettings::setCrsTransformEnabled( bool enabled ) { mProjectionsEnabled = enabled; } @@ -473,7 +473,7 @@ void QgsMapSettings::readXML( QDomNode& theNode ) // set projections flag QDomNode projNode = theNode.namedItem( "projections" ); - setProjectionsEnabled( projNode.toElement().text().toInt() ); + setCrsTransformEnabled( projNode.toElement().text().toInt() ); // set destination CRS QgsCoordinateReferenceSystem srs; diff --git a/src/core/qgsmapsettings.h b/src/core/qgsmapsettings.h index e8a58f4cf18..15527777c46 100644 --- a/src/core/qgsmapsettings.h +++ b/src/core/qgsmapsettings.h @@ -36,7 +36,7 @@ public: void setLayers(const QStringList& layers); //! sets whether to use projections for this layer set - void setProjectionsEnabled( bool enabled ); + void setCrsTransformEnabled( bool enabled ); //! returns true if projections are enabled for this layer set bool hasCrsTransformEnabled() const; @@ -76,9 +76,7 @@ public: double scale() const; - - // TODO: utility functions - + // -- utility functions -- const QgsMapToPixel& mapToPixel() const { return mMapToPixel; } diff --git a/src/core/qgsrendercontext.h b/src/core/qgsrendercontext.h index 50f7f1f393a..d1b1138c8e8 100644 --- a/src/core/qgsrendercontext.h +++ b/src/core/qgsrendercontext.h @@ -42,6 +42,7 @@ class CORE_EXPORT QgsRenderContext ~QgsRenderContext(); //! create initialized QgsRenderContext instance from given QgsMapSettings + //! @note added in 2.1 static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings ); //getters diff --git a/src/core/qgsspatialindex.cpp b/src/core/qgsspatialindex.cpp index 938f31249a0..8cc04629c3a 100644 --- a/src/core/qgsspatialindex.cpp +++ b/src/core/qgsspatialindex.cpp @@ -143,6 +143,12 @@ QgsSpatialIndex:: ~QgsSpatialIndex() { } +QgsSpatialIndex& QgsSpatialIndex::operator=( const QgsSpatialIndex& other ) +{ + if ( this != &other ) + d = other.d; + return *this; +} Region QgsSpatialIndex::rectToRegion( QgsRectangle rect ) { diff --git a/src/core/qgsspatialindex.h b/src/core/qgsspatialindex.h index 5e807749c09..866e4e805bd 100644 --- a/src/core/qgsspatialindex.h +++ b/src/core/qgsspatialindex.h @@ -57,6 +57,9 @@ class CORE_EXPORT QgsSpatialIndex /** destructor finalizes work with spatial index */ ~QgsSpatialIndex(); + /** implement assignment operator */ + QgsSpatialIndex& operator=( const QgsSpatialIndex& other ); + /* operations */ diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 20c2cea3567..41627cac56b 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -148,7 +148,6 @@ ENDIF (WITH_TOUCH) SET(QGIS_GUI_MOC_HDRS qgscolorbutton.h -qgsmapcanvasmap.h raster/qgsrasterminmaxwidget.h raster/qgspalettedrendererwidget.h diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index 41f1ac34f71..48f6e090924 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -92,10 +92,10 @@ QgsMapCanvasRendererSync::QgsMapCanvasRendererSync( QgsMapCanvas* canvas, QgsMap connect( mCanvas, SIGNAL(mapUnitsChanged()), this, SLOT(onMapUnitsC2R()) ); connect( mRenderer, SIGNAL(mapUnitsChanged()), this, SLOT(onMapUnitsR2C()) ); - connect( mCanvas, SIGNAL(hasCrsTransformEnabled(bool)), this, SLOT(onCrsTransformC2R()) ); + connect( mCanvas, SIGNAL(hasCrsTransformEnabledChanged(bool)), this, SLOT(onCrsTransformC2R()) ); connect( mRenderer, SIGNAL(hasCrsTransformEnabled(bool)), this, SLOT(onCrsTransformR2C()) ); - connect( mCanvas, SIGNAL(destinationSrsChanged()), this, SLOT(onDestCrsC2R()) ); + connect( mCanvas, SIGNAL(destinationCrsChanged()), this, SLOT(onDestCrsC2R()) ); connect( mRenderer, SIGNAL(destinationSrsChanged()), this, SLOT(onDestCrsR2C()) ); connect( mCanvas, SIGNAL(layersChanged()), this, SLOT(onLayersC2R()) ); @@ -194,9 +194,6 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name ) mMap = new QgsMapCanvasMap( this ); mScene->addItem( mMap ); - // TODO: propagate signals to map renderer? - //connect( mMapRenderer, SIGNAL( hasCrsTransformEnabled( bool ) ), this, SLOT( crsTransformEnabled( bool ) ) ); - // project handling connect( QgsProject::instance(), SIGNAL( readProject( const QDomDocument & ) ), this, SLOT( readProject( const QDomDocument & ) ) ); @@ -425,9 +422,9 @@ void QgsMapCanvas::enableOverviewMode( QgsMapOverviewCanvas* overview ) if ( mMapOverview ) { // disconnect old map overview if exists - disconnect( this, SIGNAL( hasCrsTransformEnabled( bool ) ), + disconnect( this, SIGNAL( hasCrsTransformEnabledChanged( bool ) ), mMapOverview, SLOT( hasCrsTransformEnabled( bool ) ) ); - disconnect( this, SIGNAL( destinationSrsChanged() ), + disconnect( this, SIGNAL( destinationCrsChanged() ), mMapOverview, SLOT( destinationSrsChanged() ) ); // map overview is not owned by map canvas so don't delete it... @@ -438,9 +435,9 @@ void QgsMapCanvas::enableOverviewMode( QgsMapOverviewCanvas* overview ) if ( overview ) { // connect to the map render to copy its projection settings - connect( this, SIGNAL( hasCrsTransformEnabled( bool ) ), + connect( this, SIGNAL( hasCrsTransformEnabledChanged( bool ) ), overview, SLOT( hasCrsTransformEnabled( bool ) ) ); - connect( this, SIGNAL( destinationSrsChanged() ), + connect( this, SIGNAL( destinationCrsChanged() ), overview, SLOT( destinationSrsChanged() ) ); } } @@ -452,15 +449,14 @@ const QgsMapSettings &QgsMapCanvas::mapSettings() const void QgsMapCanvas::setCrsTransformEnabled(bool enabled) { - mSettings.setProjectionsEnabled( enabled ); + if ( mSettings.hasCrsTransformEnabled() == enabled ) + return; - if ( enabled ) - { - QgsDebugMsg( "refreshing after reprojection was enabled" ); - refresh(); - } + mSettings.setCrsTransformEnabled( enabled ); - emit hasCrsTransformEnabled( enabled ); + refresh(); + + emit hasCrsTransformEnabledChanged( enabled ); } void QgsMapCanvas::setDestinationCrs(const QgsCoordinateReferenceSystem &crs) @@ -485,7 +481,7 @@ void QgsMapCanvas::setDestinationCrs(const QgsCoordinateReferenceSystem &crs) mSettings.setDestinationCrs( crs ); - emit destinationSrsChanged(); + emit destinationCrsChanged(); } const QgsLabelingResults *QgsMapCanvas::labelingResults() const diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index b764b2b356c..99a316194d5 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -119,10 +119,14 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView void setCurrentLayer( QgsMapLayer* layer ); + // ### QGIS 3: make QgsMapCanvas independent from overview void updateOverview(); + // ### QGIS 3: make QgsMapCanvas independent from overview void enableOverviewMode( QgsMapOverviewCanvas* overview ); + //! Get access to properties used for map rendering + //! @note added in 2.1 const QgsMapSettings& mapSettings() const; //! sets whether to use projections for this layer set @@ -205,6 +209,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView virtual QColor canvasColor() const; /** Set color of selected vector features */ + //! @note added in 2.1 void setSelectionColor( const QColor& color ); /** Emits signal scaleChanged to update scale in main window */ @@ -212,7 +217,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView /** Updates the full extent */ //! @deprecated since v2.1 - does nothing - void updateFullExtent(); + Q_DECL_DEPRECATED void updateFullExtent() {} //! return the map layer at position index in the layer stack QgsMapLayer *layer( int index ); @@ -395,6 +400,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView //! Emit map tool changed event void mapToolSet( QgsMapTool *tool ); + // ### QGIS 3: remove the signal //! Emitted when selection in any layer gets changed void selectionChanged( QgsMapLayer * layer ); @@ -408,11 +414,11 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView //! Emitted when on-the-fly projection has been turned on/off //! @note added in 2.1 - void hasCrsTransformEnabled( bool flag ); + void hasCrsTransformEnabledChanged( bool flag ); //! Emitted when map CRS has changed //! @note added in 2.1 - void destinationSrsChanged(); + void destinationCrsChanged(); //! Emmitted when map units are changed //! @note added in 2.1 @@ -481,6 +487,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView */ QgsMapCanvas( QgsMapCanvas const & ); + //! encompases all map settings necessary for map rendering QgsMapSettings mSettings; //! all map rendering is done in this class diff --git a/src/gui/qgsmapcanvasmap.h b/src/gui/qgsmapcanvasmap.h index a5bc9e26937..6cf0718e243 100644 --- a/src/gui/qgsmapcanvasmap.h +++ b/src/gui/qgsmapcanvasmap.h @@ -55,7 +55,7 @@ class GUI_EXPORT QgsMapCanvasMap : public QgsMapCanvasItem // public QObject, p Q_DECL_DEPRECATED void resize( QSize size ) { Q_UNUSED( size ); } //! @deprecated in 2.1 - does nothing. Kept for API compatibility - Q_DECL_DEPRECATED void enableAntiAliasing( bool flag ); + Q_DECL_DEPRECATED void enableAntiAliasing( bool flag ) { Q_UNUSED( flag ); } //! @deprecated in 2.1 - does nothing. Kept for API compatibility Q_DECL_DEPRECATED void render() {} diff --git a/src/gui/qgsmapoverviewcanvas.cpp b/src/gui/qgsmapoverviewcanvas.cpp index 2b36471ca78..8d65d704900 100644 --- a/src/gui/qgsmapoverviewcanvas.cpp +++ b/src/gui/qgsmapoverviewcanvas.cpp @@ -324,7 +324,7 @@ void QgsMapOverviewCanvas::updateFullExtent() void QgsMapOverviewCanvas::hasCrsTransformEnabled( bool flag ) { - mSettings.setProjectionsEnabled( flag ); + mSettings.setCrsTransformEnabled( flag ); } void QgsMapOverviewCanvas::destinationSrsChanged() diff --git a/src/gui/qgsmapoverviewcanvas.h b/src/gui/qgsmapoverviewcanvas.h index db1881a07fd..5b5def1f39c 100644 --- a/src/gui/qgsmapoverviewcanvas.h +++ b/src/gui/qgsmapoverviewcanvas.h @@ -62,11 +62,14 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget public slots: + // ### QGIS 3: make protected //! used for overview canvas to reflect changed extent in main map canvas void drawExtentRect(); + // ### QGIS 3: rename so it does not look like getter, make protected void hasCrsTransformEnabled( bool flag ); + // ### QGIS 3: rename Srs to Crs, make protected void destinationSrsChanged(); protected slots: diff --git a/src/plugins/coordinate_capture/coordinatecapture.cpp b/src/plugins/coordinate_capture/coordinatecapture.cpp index 466483e4d6f..2d45da85b80 100644 --- a/src/plugins/coordinate_capture/coordinatecapture.cpp +++ b/src/plugins/coordinate_capture/coordinatecapture.cpp @@ -85,7 +85,7 @@ void CoordinateCapture::initGui() { mCrs.createFromSrsId( GEOCRS_ID ); // initialize the CRS object - connect( mQGisIface->mapCanvas(), SIGNAL( destinationSrsChanged() ), this, SLOT( setSourceCrs() ) ); + connect( mQGisIface->mapCanvas(), SIGNAL( destinationCrsChanged() ), this, SLOT( setSourceCrs() ) ); connect( mQGisIface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) ); setSourceCrs(); //set up the source CRS diff --git a/src/plugins/grass/qgsgrassplugin.cpp b/src/plugins/grass/qgsgrassplugin.cpp index 3b861f8e821..7f62b1bd921 100644 --- a/src/plugins/grass/qgsgrassplugin.cpp +++ b/src/plugins/grass/qgsgrassplugin.cpp @@ -122,7 +122,7 @@ void QgsGrassPlugin::initGui() mCanvas = qGisInterface->mapCanvas(); QWidget* qgis = qGisInterface->mainWindow(); - connect( mCanvas, SIGNAL( destinationSrsChanged() ), this, SLOT( setTransform() ) ); + connect( mCanvas, SIGNAL( destinationCrsChanged() ), this, SLOT( setTransform() ) ); // Connect project connect( qgis, SIGNAL( projectRead() ), this, SLOT( projectRead() ) ); diff --git a/src/plugins/grass/qgsgrassregion.cpp b/src/plugins/grass/qgsgrassregion.cpp index 21f640f5207..9203d3d4b5e 100644 --- a/src/plugins/grass/qgsgrassregion.cpp +++ b/src/plugins/grass/qgsgrassregion.cpp @@ -45,7 +45,7 @@ QgsGrassRegionEdit::QgsGrassRegionEdit( QgsMapCanvas* canvas ) mCrs = QgsGrass::crs( gisdbase, location ); QgsDebugMsg( "mCrs: " + mCrs.toWkt() ); setTransform(); - connect( canvas, SIGNAL( destinationSrsChanged() ), this, SLOT( setTransform() ) ); + connect( canvas, SIGNAL( destinationCrsChanged() ), this, SLOT( setTransform() ) ); } QgsGrassRegionEdit::~QgsGrassRegionEdit() diff --git a/tests/src/core/testqgsatlascomposition.cpp b/tests/src/core/testqgsatlascomposition.cpp index 8ad76e3248b..9bfe72dcd53 100644 --- a/tests/src/core/testqgsatlascomposition.cpp +++ b/tests/src/core/testqgsatlascomposition.cpp @@ -78,7 +78,7 @@ void TestQgsAtlasComposition::initTestCase() //create composition with composer map mMapSettings.setLayers( QStringList() << mVectorLayer->id() ); - mMapSettings.setProjectionsEnabled( true ); + mMapSettings.setCrsTransformEnabled( true ); // select epsg:2154 QgsCoordinateReferenceSystem crs; diff --git a/tests/src/core/testqgscomposerlabel.cpp b/tests/src/core/testqgscomposerlabel.cpp index 85f76aae00a..27201b36b8a 100644 --- a/tests/src/core/testqgscomposerlabel.cpp +++ b/tests/src/core/testqgscomposerlabel.cpp @@ -62,7 +62,7 @@ void TestQgsComposerLabel::initTestCase() //create composition with composer map mMapSettings.setLayers( QStringList() << mVectorLayer->id() ); - mMapSettings.setProjectionsEnabled( false ); + mMapSettings.setCrsTransformEnabled( false ); mComposition = new QgsComposition( mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape diff --git a/tests/src/core/testqgscomposermap.cpp b/tests/src/core/testqgscomposermap.cpp index d5c8a116f0b..2eea208b34d 100644 --- a/tests/src/core/testqgscomposermap.cpp +++ b/tests/src/core/testqgscomposermap.cpp @@ -67,7 +67,7 @@ void TestQgsComposerMap::initTestCase() //create composition with composer map mMapSettings.setLayers( QStringList() << mRasterLayer->id() ); - mMapSettings.setProjectionsEnabled( false ); + mMapSettings.setCrsTransformEnabled( false ); mComposition = new QgsComposition( mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 ); diff --git a/tests/src/core/testqgscomposerscalebar.cpp b/tests/src/core/testqgscomposerscalebar.cpp index 75fcecce938..69fca4b463e 100644 --- a/tests/src/core/testqgscomposerscalebar.cpp +++ b/tests/src/core/testqgscomposerscalebar.cpp @@ -69,7 +69,7 @@ void TestQgsComposerScaleBar::initTestCase() QgsCoordinateReferenceSystem destCRS; destCRS.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId ); mMapSettings.setDestinationCrs( destCRS ); - mMapSettings.setProjectionsEnabled( true ); + mMapSettings.setCrsTransformEnabled( true ); mComposition = new QgsComposition( mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape