QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgsmaskpaintdevice.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaskpaintdevice.h
3 --------------------------------------
4 Date : February 2022
5 Copyright : (C) 2022 by Julien Cabieces
6 Email : julien dot cabieces at oslandia 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 QGSMASKPAINTDEVICE_H
17#define QGSMASKPAINTDEVICE_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21
22#include <QPainterPath>
23#include <QPaintDevice>
24#include <QPaintEngine>
25#include <memory>
26
27#ifndef SIP_RUN
29class QgsMaskPaintEngine: public QPaintEngine
30{
31
32 public:
33
34 QgsMaskPaintEngine( bool usePathStroker = false );
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 drawPath( const QPainterPath & ) override;
42 void drawPolygon( const QPointF *, int, PolygonDrawMode ) override;
43 void drawPixmap( const QRectF &, const QPixmap &, const QRectF & ) override { return; };
44
45 QPainterPath maskPainterPath() const;
46
47 private:
48
49 bool mUsePathStroker = false;
50 QPainterPath mMaskPainterPath;
51
52};
54#endif
55
56
63class CORE_EXPORT QgsMaskPaintDevice: public QPaintDevice
64{
65
66 public:
67
73 QgsMaskPaintDevice( bool usePathStroker = false );
74
75 QPaintEngine *paintEngine() const override;
76
77 int metric( PaintDeviceMetric metric ) const override;
78
82 QPainterPath maskPainterPath() const;
83
84 private:
85
86 std::unique_ptr<QgsMaskPaintEngine> mPaintEngine;
87
88 QSize mSize;
89
90};
91
92
93#endif // QGSMASKPAINTDEVICE_H
Mask painter device that can be used to register everything painted into a QPainterPath used later as...