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 <QPainter>
11#include "marble_export.h"
12#include "MarbleGlobal.h"
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{
47 public:
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 &,
57 Qt::FillRule fillRule = Qt::OddEvenFill );
58
59 void drawPolyline( const QPolygonF & );
60 void drawPolyline( const QPolygonF &, QVector<QPointF>& labelNodes,
61 LabelPositionFlags labelPositionFlag = LineCenter );
62
63 void labelPosition(const QPolygonF &polygon, QVector<QPointF> &labelNodes,
64 LabelPositionFlags labelPositionFlags) const;
65
66 void setPen(const QColor &);
67 void setPen(const QPen & pen);
68 void setPen(Qt::PenStyle style);
69 void setBrush(const QBrush & brush);
70
71 void setDebugPolygonsLevel( int );
72 void setDebugBatchRender( bool );
73
74 // void clearNodeCount(){ m_debugNodeCount = 0; }
75 // int nodeCount(){ return m_debugNodeCount; }
76
77 private:
78 ClipPainterPrivate * const d;
79};
80
81}
82
83#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 Jun 14 2024 11:54:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.