QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgsnullpainterdevice.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsnullpainterdevice.h
3 --------------------------------------
4 Date : December 2021
5 Copyright : (C) 2013 by Mathieu Pellerin
6 Email : nirvn dot asia 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 QGSNULLPAINTERDEVICE_H
17#define QGSNULLPAINTERDEVICE_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21
22#include <QPaintDevice>
23#include <QPaintEngine>
24#include <memory>
25
26
27#ifndef SIP_RUN
29class QgsNullPaintEngine: public QPaintEngine
30{
31
32 public:
33
34 QgsNullPaintEngine() : QPaintEngine( QPaintEngine::AllFeatures ) {};
35
36 bool begin( QPaintDevice * ) override { return true; };
37 bool end() override { return true; };
38 QPaintEngine::Type type() const override { return QPaintEngine::User; };
39 void updateState( const QPaintEngineState & ) override { return; };
40
41 void drawRects( const QRect *, int ) override { return; };
42 void drawRects( const QRectF *, int ) override { return; };
43 void drawLines( const QLine *, int ) override { return; };
44 void drawLines( const QLineF *, int ) override { return; };
45 void drawEllipse( const QRectF & ) override { return; };
46 void drawEllipse( const QRect & ) override { return; };
47 void drawPath( const QPainterPath & ) override { return; };
48 void drawPoints( const QPointF *, int ) override { return; };
49 void drawPoints( const QPoint *, int ) override { return; };
50 void drawPolygon( const QPointF *, int, PolygonDrawMode ) override { return; };
51 void drawPolygon( const QPoint *, int, PolygonDrawMode ) override { return; };
52 void drawPixmap( const QRectF &, const QPixmap &, const QRectF & ) override { return; };
53 void drawTextItem( const QPointF &, const QTextItem & ) override { return; };
54 void drawTiledPixmap( const QRectF &, const QPixmap &, const QPointF & ) override { return; };
55 void drawImage( const QRectF &, const QImage &, const QRectF &, Qt::ImageConversionFlags ) override { return; };
56
57};
59#endif
60
61
67class CORE_EXPORT QgsNullPaintDevice: public QPaintDevice
68{
69
70 public:
71
73
74 QPaintEngine *paintEngine() const override;
75
76 int metric( PaintDeviceMetric metric ) const override;
77
81 void setOutputSize( const QSize &size ) { mSize = size; };
82
86 void setOutputDpi( const int dpi ) { mDpi = dpi; };
87
88 private:
89
90 std::unique_ptr<QgsNullPaintEngine> mPaintEngine;
91
92 QSize mSize;
93 int mDpi = 96;
94
95};
96
97
98#endif // QGSNULLPAINTERDEVICE_H
Null painter device that can be used for map renderer jobs which use custom painters.
void setOutputSize(const QSize &size)
Sets the size of the device in pixels.
void setOutputDpi(const int dpi)
Sets the dpi of the device.