File indexing completed on 2025-01-05 03:59:15
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2009 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // 0006 0007 #ifndef MARBLE_CLIPPAINTER_H 0008 #define MARBLE_CLIPPAINTER_H 0009 0010 #include <QPainter> 0011 #include "digikam_export.h" 0012 #include "MarbleGlobal.h" 0013 0014 class QPaintDevice; 0015 class QPolygonF; 0016 class QPointF; 0017 0018 namespace Marble 0019 { 0020 /** 0021 * @short A QPainter that does viewport clipping for polygons 0022 * 0023 * This class introduces fast polygon/polyline clipping for QPainter 0024 * to increase the performance. 0025 * Clipping is accomplished using an algorithm (by Torsten Rahn) that 0026 * processes each polyline once. 0027 * To keep things fast each possible scenario of two subsequent 0028 * points is implemented case by case in a specialized handler which 0029 * creates interpolated points and helper points. 0030 */ 0031 0032 // The reason for this class is a terrible bug in some versions of the 0033 // X Server. Suppose the widget size is, say, 1000 x 1000 and we have 0034 // a high zoom so that we want to draw a vector from (-100000, 0035 // -100000) to (100000, 100000). Then the X server will create a 0036 // bitmap that is at least 100000 x 100000 and in the process eat all 0037 // available memory. 0038 // 0039 // So we introduce the ClipPainter that clips all polylines and polygons 0040 // to the area that is actually visible in the viewport. 0041 // 0042 // @internal 0043 0044 class ClipPainterPrivate; 0045 class DIGIKAM_EXPORT ClipPainter : public QPainter 0046 { 0047 public: 0048 ClipPainter(); 0049 ClipPainter(QPaintDevice*, bool); 0050 0051 ~ClipPainter(); 0052 0053 void setScreenClip( bool enable ); 0054 bool hasScreenClip() const; 0055 0056 void drawPolygon( const QPolygonF &, 0057 Qt::FillRule fillRule = Qt::OddEvenFill ); 0058 0059 void drawPolyline( const QPolygonF & ); 0060 void drawPolyline( const QPolygonF &, QVector<QPointF>& labelNodes, 0061 LabelPositionFlags labelPositionFlag = LineCenter ); 0062 0063 void labelPosition(const QPolygonF &polygon, QVector<QPointF> &labelNodes, 0064 LabelPositionFlags labelPositionFlags) const; 0065 0066 void setPen(const QColor &); 0067 void setPen(const QPen & pen); 0068 void setPen(Qt::PenStyle style); 0069 void setBrush(const QBrush & brush); 0070 0071 void setDebugPolygonsLevel( int ); 0072 void setDebugBatchRender( bool ); 0073 0074 // void clearNodeCount(){ m_debugNodeCount = 0; } 0075 // int nodeCount(){ return m_debugNodeCount; } 0076 0077 private: 0078 ClipPainterPrivate * const d; 0079 }; 0080 0081 } 0082 0083 #endif