QGIS API Documentation  3.19.0-Master (f616be29d3)
qgsmaplayerrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaplayerrenderer.h
3  --------------------------------------
4  Date : December 2013
5  Copyright : (C) 2013 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSMAPLAYERRENDERER_H
17 #define QGSMAPLAYERRENDERER_H
18 
19 #include <QStringList>
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 
24 class QgsFeedback;
25 class QgsRenderContext;
26 
53 class CORE_EXPORT QgsMapLayerRenderer
54 {
55  public:
56 
60  QgsMapLayerRenderer( const QString &layerID, QgsRenderContext *context = nullptr )
61  : mLayerID( layerID )
62  , mContext( context )
63  {}
64 
65  virtual ~QgsMapLayerRenderer() = default;
66 
73  virtual bool render() = 0;
74 
91  virtual bool forceRasterRender() const { return false; }
92 
97  virtual QgsFeedback *feedback() const { return nullptr; }
98 
100  QStringList errors() const { return mErrors; }
101 
103  QString layerId() const { return mLayerID; }
104 
110  QgsRenderContext *renderContext() { return mContext; }
111 
118  const QgsRenderContext *renderContext() const SIP_SKIP { return mContext; }
119 
126  bool isReadyToCompose() const { return mReadyToCompose; }
127 
138  virtual void setLayerRenderingTimeHint( int time ) SIP_SKIP { Q_UNUSED( time ) }
139 
140  protected:
141  QStringList mErrors;
142  QString mLayerID;
143 
144  // TODO QGIS 4.0 - make false as default
145 
160  bool mReadyToCompose = true;
161 
170  static constexpr int MAX_TIME_TO_USE_CACHED_PREVIEW_IMAGE = 3000 SIP_SKIP;
171 
172  private:
173 
174  // TODO QGIS 4.0 - make reference instead of pointer!
175 
181  QgsRenderContext *mContext = nullptr;
182 };
183 
184 #endif // QGSMAPLAYERRENDERER_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Base class for utility classes that encapsulate information necessary for rendering of map layers.
virtual bool render()=0
Do the rendering (based on data stored in the class).
bool isReadyToCompose() const
Returns whether the renderer has already drawn (at least partially) some data.
QString layerId() const
Gets access to the ID of the layer rendered by this class.
virtual QgsFeedback * feedback() const
Access to feedback object of the layer renderer (may be nullptr)
virtual bool forceRasterRender() const
Returns true if the renderer must be rendered to a raster paint device (e.g.
virtual ~QgsMapLayerRenderer()=default
QStringList errors() const
Returns list of errors (problems) that happened during the rendering.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
QgsMapLayerRenderer(const QString &layerID, QgsRenderContext *context=nullptr)
Constructor for QgsMapLayerRenderer, with the associated layerID and render context.
const QgsRenderContext * renderContext() const
Returns the render context associated with the renderer.
virtual void setLayerRenderingTimeHint(int time)
Sets approximate render time (in ms) for the layer to render.
Contains information about the context of a rendering operation.
#define SIP_SKIP
Definition: qgis_sip.h:126