Skip to content

Commit

Permalink
Goodbye to QgsMapRenderer (#3333)
Browse files Browse the repository at this point in the history
For the time being the class is kept in the server code while it is still being used there.
  • Loading branch information
wonder-sk committed Jul 24, 2016
1 parent 2bbfe8a commit ab4a83b
Show file tree
Hide file tree
Showing 114 changed files with 592 additions and 1,260 deletions.
47 changes: 47 additions & 0 deletions doc/api_break.dox
Expand Up @@ -22,6 +22,8 @@ This page tries to maintain a list with incompatible changes that happened in pr

<ul>
<li>QgsLabel and QgsLabelAttributes. Replaced by labeling based on PAL library, see QgsLabelingEngineV2.</li>
<li>QgsMapCanvasMap. It is an internal class used by map canvas.</li>
<li>QgsMapRenderer. It has been replaced by QgsMapRendererJob with subclasses and QgsMapSettings.</li>
</ul>

\subsection qgis_api_break_3_0_global General changes
Expand Down Expand Up @@ -72,6 +74,7 @@ qgsPermissiveToInt()</li>

<ul>
<li>containsWMSLayer() has been renamed to containsWmsLayer()</li>
<li>mapRenderer() has been removed. Use mapSettings() instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsComposerNodesItem QgsComposerNodesItem
Expand All @@ -93,6 +96,8 @@ qgsPermissiveToInt()</li>

<ul>
<li>addItemsFromXML() has been renamed to addItemsFromXml()</li>
<li>Constructor with QgsMapRenderer parameter has been removed. Use the variant with QgsMapSettings parameter.</li>
<li>mapRenderer() has been removed. Use mapSettings() instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsCoordinateReferenceSystem QgsCoordinateReferenceSystem
Expand Down Expand Up @@ -201,6 +206,12 @@ objects are implicitly shared, returning a copy helps simplify and make code mor
only affects third party c++ providers, and does not affect PyQGIS scripts.</li>
</ul>

\subsection qgis_api_break_3_0_QgsLabelingEngineInterface QgsLabelingEngineInterface

<ul>
<li>init(QgsMapRenderer*) has been removed. Use init(const QgsMapSettings&) instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsLayerTreeGroup QgsLayerTreeGroup

<ul>
Expand All @@ -218,6 +229,17 @@ only affects third party c++ providers, and does not affect PyQGIS scripts.</li>

<ul>
<li>rotationEnabled() and enableRotation() have been removed, since map rotation is now always supported</li>
<li>The "name" parameter has been removed from constructor. Use QObject::setObjectName() to set canvas name if necessary.</li>
<li>map() has been removed because QgsMapCanvasMap is not available in API anymore.</li>
<li>mapRenderer() has been removed. Use directly map canvas methods to get/set configuration or mapSettings() (for reading only).</li>
<li>canvasPaintDevice() has been removed. Use map canvas items to draw anything on top of canvas.</li>
<li>clear() has been removed. Use refresh() instead.</li>
<li>setCanvasColor() and canvasColor() are not virtual methods anymore.</li>
<li>updateFullExtent() has been removed. No need to call it explicitly. Full extent calculation is done in QgsMapSettings.</li>
<li>setDirty() and isDirty() have been removed. Use refresh() to refresh canvas content.</li>
<li>setWheelAction() and WheelAction enum have been removed. Custom wheel actions are not supported anymore.</li>
<li>updateMap(), showError(), useImageToRender() have been removed. They did nothing since 2.4.</li>
<li>setProgress() signal has been removed. It was not emitted since 2.0.</li>
</ul>

\subsection qgis_api_break_3_0_QgsMapLayer QgsMapLayer
Expand Down Expand Up @@ -254,6 +276,7 @@ screenUpdateRequested() were removed. These members have had no effect for a num
<li>transformation() now returns a QgsCoordinateTransform object, not a pointer. An invalid QgsCoordinateTransform will
be returned instead of a null pointer if no transformation is required.</li>
<li>destinationSrsChanged() was renamed to destinationCrsChanged()</li>
<li>getCompositionMode(), getBlendModeEnum() and BlendMode enum have been moved to QgsPainting utility class.</li>
</ul>

\subsection qgis_api_break_3_0_QgsMapRendererJob QgsMapRendererJob
Expand All @@ -272,6 +295,12 @@ be used instead of a null pointer if no transformation is required.</li>
be returned instead of a null pointer if no transformation is required.</li>
</ul>

\subsection qgis_api_break_3_0_QgsPalLabeling QgsPalLabeling

<ul>
<li>init(QgsMapRenderer*) has been removed. Use init(const QgsMapSettings&) instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsOSMElement QgsOSMElement

<ul>
Expand Down Expand Up @@ -318,6 +347,12 @@ be returned instead of a null pointer if no transformation is required.</li>
<li>createFromXML() has been renamed to createFromXml()</li>
</ul>

\subsection qgis_api_break_3_0_QgsRenderChecker QgsRenderChecker

<ul>
<li>setMapRenderer() has been removed. Use setMapSettings() instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsRenderContext QgsRenderContext

<ul>
Expand All @@ -334,6 +369,18 @@ be used instead of a null pointer if no transformation is required.</li>
<li>prepareGeometry() and geometryRequiresPreparation() now take a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSnapper QgsSnapper

<ul>
<li>Constructor variant with QgsMapRenderer has been removed. Use the variant with QgsMapSettings.</li>
</ul>

\subsection qgis_api_break_3_0_QgsTolerance QgsTolerance

<ul>
<li>vertexSearchRadius(), defaultTolerance(), toleranceInMapUnits() do not have variant with QgsMapRenderer anymore. Use the variants with QgsMapSettings.</li>
</ul>

\subsection qgis_api_break_3_0_QgsJSONExporter QgsJSONExporter

<ul>
Expand Down
3 changes: 0 additions & 3 deletions python/core/composer/qgscomposermap.sip
Expand Up @@ -249,9 +249,6 @@ class QgsComposerMap : QgsComposerItem

QgsRectangle extent() const;

//! @deprecated since 2.4 - 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 );

Expand Down
6 changes: 0 additions & 6 deletions python/core/composer/qgscomposition.sip
Expand Up @@ -40,8 +40,6 @@ class QgsComposition : QGraphicsScene
Landscape
};

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

/** Composition atlas modes*/
Expand Down Expand Up @@ -413,10 +411,6 @@ class QgsComposition : QGraphicsScene
/** Used to enable or disable advanced effects such as blend modes in a composition */
void setUseAdvancedEffects( const bool effectsEnabled );

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

//! Return setting of QGIS map canvas
//! @note added in 2.4
const QgsMapSettings& mapSettings() const;
Expand Down
2 changes: 1 addition & 1 deletion python/core/core.sip
Expand Up @@ -80,7 +80,6 @@
%Include qgsmaplayerregistry.sip
%Include qgsmaplayerrenderer.sip
%Include qgsmaplayerstylemanager.sip
%Include qgsmaprenderer.sip
%Include qgsmaprenderercache.sip
%Include qgsmaprenderercustompainterjob.sip
%Include qgsmaprendererjob.sip
Expand All @@ -100,6 +99,7 @@
%Include qgsogcutils.sip
%Include qgsowsconnection.sip
%Include qgspaintenginehack.sip
%Include qgspainting.sip
%Include qgspallabeling.sip
%Include qgspluginlayer.sip
%Include qgspluginlayerregistry.sip
Expand Down
45 changes: 45 additions & 0 deletions python/core/qgspainting.sip
@@ -0,0 +1,45 @@
class QgsPainting
{
%TypeHeaderCode
#include <qgspainting.h>
%End

public:

/** Blending modes enum defining the available composition modes that can
* be used when rendering a layer
*/
enum BlendMode
{
BlendNormal,
BlendLighten,
BlendScreen,
BlendDodge,
BlendAddition,
BlendDarken,
BlendMultiply,
BlendBurn,
BlendOverlay,
BlendSoftLight,
BlendHardLight,
BlendDifference,
BlendSubtract,
BlendSource,
BlendDestinationOver,
BlendClear,
BlendDestination,
BlendSourceIn,
BlendDestinationIn,
BlendSourceOut,
BlendDestinationOut,
BlendSourceAtop,
BlendDestinationAtop,
BlendXor,
};

//! Returns a QPainter::CompositionMode corresponding to a BlendMode
static QPainter::CompositionMode getCompositionMode( QgsPainting::BlendMode blendMode );
//! Returns a BlendMode corresponding to a QPainter::CompositionMode
static QgsPainting::BlendMode getBlendModeEnum( QPainter::CompositionMode blendMode );

};
79 changes: 76 additions & 3 deletions python/core/qgspallabeling.sip
Expand Up @@ -77,6 +77,82 @@
%End
};


class QgsLabelPosition
{
%TypeHeaderCode
#include <qgspallabeling.h>
%End
public:
QgsLabelPosition( int id, double r, const QVector< QgsPoint >& corners, const QgsRectangle& rect, double w, double h, const QString& layer, const QString& labeltext, const QFont& labelfont, bool upside_down, bool diagram = false, bool pinned = false, const QString& providerId = QString() );
QgsLabelPosition();
int featureId;
double rotation;
QVector< QgsPoint > cornerPoints;
QgsRectangle labelRect;
double width;
double height;
QString layerID;
QString labelText;
QFont labelFont;
bool upsideDown;
bool isDiagram;
bool isPinned;
//! @note added in 2.14
QString providerID;
};

/** Labeling engine interface. */
class QgsLabelingEngineInterface
{
%TypeHeaderCode
#include <qgspallabeling.h>
%End

public:

virtual ~QgsLabelingEngineInterface();

//! 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
virtual void clearActiveLayers() = 0;
//! clears data defined objects from PAL layer settings for a registered layer
virtual void clearActiveLayer( const QString& layerID ) = 0;
//! called when starting rendering of a layer
virtual int prepareLayer( QgsVectorLayer* layer, QStringList& attrNames, QgsRenderContext& ctx ) = 0;
//! returns PAL layer settings for a registered layer
//! @deprecated since 2.12 - if direct access to QgsPalLayerSettings is necessary, use QgsPalLayerSettings::fromLayer()
virtual QgsPalLayerSettings &layer( const QString &layerName ) = 0 /Deprecated/;
//! adds a diagram layer to the labeling engine
//! @note added in QGIS 2.12
virtual int prepareDiagramLayer( QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx );
//! adds a diagram layer to the labeling engine
//! @deprecated since 2.12 - use prepareDiagramLayer()
virtual int addDiagramLayer( QgsVectorLayer *layer, const QgsDiagramLayerSettings *s ) /Deprecated/;
//! called for every feature
virtual void registerFeature( const QString &layerID, QgsFeature &feat, QgsRenderContext &context ) = 0;
//! called for every diagram feature
virtual void registerDiagramFeature( const QString &layerID, QgsFeature &feat, QgsRenderContext &context );
//! 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
//! @deprecated since 2.4 - use takeResults() and methods of QgsLabelingResults
virtual QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) = 0 /Deprecated/;
//! return infos about labels within a given (map) rectangle
//! @deprecated since 2.4 - use takeResults() and methods of QgsLabelingResults
virtual QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) = 0 /Deprecated/;

//! called when passing engine among map renderers
virtual QgsLabelingEngineInterface* clone() = 0 /Factory/;
};



class QgsPalLayerSettings
{
%TypeHeaderCode
Expand Down Expand Up @@ -835,9 +911,6 @@ class QgsPalLabeling : QgsLabelingEngineInterface

// implemented methods from labeling engine interface

//! called when we're going to start with rendering
//! @deprecated since 2.4 - 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
Expand Down
3 changes: 0 additions & 3 deletions python/core/qgsrenderchecker.sip
Expand Up @@ -49,9 +49,6 @@ class QgsRenderChecker
*/
QString renderedImage();

//! @deprecated since 2.4 - use setMapSettings()
void setMapRenderer( QgsMapRenderer *thepMapRenderer ) /Deprecated/;

//! @note added in 2.4
void setMapSettings( const QgsMapSettings& mapSettings );

Expand Down
3 changes: 0 additions & 3 deletions python/core/qgssnapper.sip
Expand Up @@ -70,9 +70,6 @@ class QgsSnapper
QgsTolerance::UnitType mUnitType;
};

//!@deprecated since 2.4 - use constructor with QgsMapSettings
QgsSnapper( QgsMapRenderer *mapRender ) /Deprecated/;

explicit QgsSnapper( const QgsMapSettings& mapSettings );

/** Does the snapping operation
Expand Down
26 changes: 0 additions & 26 deletions python/core/qgstolerance.sip
Expand Up @@ -36,29 +36,13 @@ class QgsTolerance
*/
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 layer units
*/
//! @deprecated since 2.4 - 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 layer units
*/
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 layer units
*/
//! @deprecated since 2.4 - use override with QgsMapSettings
static double defaultTolerance( QgsMapLayer* layer, QgsMapRenderer* renderer ) /Deprecated/;

/**
* Static function to translate tolerance value into map units
* @param tolerance tolerance value to be translated
Expand All @@ -80,14 +64,4 @@ class QgsTolerance
*/
static double toleranceInMapUnits( double tolerance, QgsMapLayer* layer, const QgsMapSettings& mapSettings, UnitType units = LayerUnits );

/**
* Static function to translate tolerance value into layer units
* @param tolerance tolerance value to be translated
* @param layer reference layer
* @param renderer renderer
* @param units type of units to be translated
* @return value of tolerance in layer units
*/
//! @deprecated since 2.4 - use the override with QgsMapSettings
static double toleranceInMapUnits( double tolerance, QgsMapLayer* layer, QgsMapRenderer* renderer, UnitType units = LayerUnits ) /Deprecated/;
};
1 change: 0 additions & 1 deletion python/gui/gui.sip
Expand Up @@ -98,7 +98,6 @@
%Include qgsmanageconnectionsdialog.sip
%Include qgsmapcanvas.sip
%Include qgsmapcanvasitem.sip
%Include qgsmapcanvasmap.sip
%Include qgsmapcanvassnapper.sip
%Include qgsmapcanvassnappingutils.sip
%Include qgsmapcanvastracer.sip
Expand Down

0 comments on commit ab4a83b

Please sign in to comment.