Marble

ClipPainter.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2006-2009 Torsten Rahn <tackat@kde.org>
4// SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
5//
6
7#ifndef MARBLE_CLIPPAINTER_H
8#define MARBLE_CLIPPAINTER_H
9
10#include "MarbleGlobal.h"
11#include "marble_export.h"
12#include <QPainter>
13
14class QPaintDevice;
15class QPolygonF;
16class QPointF;
17
18namespace Marble
19{
20/**
21 * @short A QPainter that does viewport clipping for polygons
22 *
23 * This class introduces fast polygon/polyline clipping for QPainter
24 * to increase the performance.
25 * Clipping is accomplished using an algorithm (by Torsten Rahn) that
26 * processes each polyline once.
27 * To keep things fast each possible scenario of two subsequent
28 * points is implemented case by case in a specialized handler which
29 * creates interpolated points and helper points.
30 */
31
32// The reason for this class is a terrible bug in some versions of the
33// X Server. Suppose the widget size is, say, 1000 x 1000 and we have
34// a high zoom so that we want to draw a vector from (-100000,
35// -100000) to (100000, 100000). Then the X server will create a
36// bitmap that is at least 100000 x 100000 and in the process eat all
37// available memory.
38//
39// So we introduce the ClipPainter that clips all polylines and polygons
40// to the area that is actually visible in the viewport.
41//
42// @internal
43
44class ClipPainterPrivate;
45class MARBLE_EXPORT ClipPainter : public QPainter
46{
47public:
48 ClipPainter();
49 ClipPainter(QPaintDevice *, bool);
50
51 ~ClipPainter();
52
53 void setScreenClip(bool enable);
54 bool hasScreenClip() const;
55
56 void drawPolygon(const QPolygonF &, Qt::FillRule fillRule = Qt::OddEvenFill);
57
58 void drawPolyline(const QPolygonF &);
59 void drawPolyline(const QPolygonF &, QList<QPointF> &labelNodes, LabelPositionFlags labelPositionFlag = LineCenter);
60
61 void labelPosition(const QPolygonF &polygon, QList<QPointF> &labelNodes, LabelPositionFlags labelPositionFlags) const;
62
63 void setPen(const QColor &);
64 void setPen(const QPen &pen);
65 void setPen(Qt::PenStyle style);
66 void setBrush(const QBrush &brush);
67
68 void setDebugPolygonsLevel(int);
69 void setDebugBatchRender(bool);
70
71 // void clearNodeCount(){ m_debugNodeCount = 0; }
72 // int nodeCount(){ return m_debugNodeCount; }
73
74private:
75 ClipPainterPrivate *const d;
76};
77
78}
79
80#endif
Binds a QML item to a specific geodetic location in screen coordinates.
FillRule
PenStyle
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:55:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.