Changeset View
Changeset View
Standalone View
Standalone View
ui/pagepainter.h
| 1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
|---|---|---|---|---|---|
| 2 | * Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> * | 2 | * Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> * | ||
| 3 | * * | 3 | * * | ||
| 4 | * This program is free software; you can redistribute it and/or modify * | 4 | * This program is free software; you can redistribute it and/or modify * | ||
| 5 | * it under the terms of the GNU General Public License as published by * | 5 | * it under the terms of the GNU General Public License as published by * | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or * | 6 | * the Free Software Foundation; either version 2 of the License, or * | ||
| 7 | * (at your option) any later version. * | 7 | * (at your option) any later version. * | ||
| 8 | ***************************************************************************/ | 8 | ***************************************************************************/ | ||
| 9 | 9 | | |||
| 10 | #ifndef _OKULAR_PAGEPAINTER_H_ | 10 | #ifndef _OKULAR_PAGEPAINTER_H_ | ||
| 11 | #define _OKULAR_PAGEPAINTER_H_ | 11 | #define _OKULAR_PAGEPAINTER_H_ | ||
| 12 | 12 | | |||
| 13 | #include <QBrush> | 13 | #include <QBrush> | ||
| 14 | #include <QImage> | 14 | #include <QImage> | ||
| 15 | #include <QPen> | 15 | #include <QPen> | ||
| 16 | 16 | | |||
| 17 | #include "core/annotations.h" | ||||
| 17 | #include "core/area.h" // for NormalizedPoint | 18 | #include "core/area.h" // for NormalizedPoint | ||
| 18 | 19 | | |||
| 19 | class QPainter; | 20 | class QPainter; | ||
| 20 | class QRect; | 21 | class QRect; | ||
| 21 | namespace Okular { | 22 | namespace Okular { | ||
| 22 | class DocumentObserver; | 23 | class DocumentObserver; | ||
| 23 | class Page; | 24 | class Page; | ||
| 24 | } | 25 | } | ||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 66 | static void drawShapeOnImage( | |||
| 67 | const NormalizedPath & imagePoints, | 68 | const NormalizedPath & imagePoints, | ||
| 68 | bool closeShape, | 69 | bool closeShape, | ||
| 69 | const QPen & pen, | 70 | const QPen & pen, | ||
| 70 | const QBrush & brush = QBrush(), | 71 | const QBrush & brush = QBrush(), | ||
| 71 | double penWidthMultiplier = 1.0, | 72 | double penWidthMultiplier = 1.0, | ||
| 72 | RasterOperation op = Normal | 73 | RasterOperation op = Normal | ||
| 73 | //float antiAliasRadius = 1.0 | 74 | //float antiAliasRadius = 1.0 | ||
| 74 | ); | 75 | ); | ||
| 76 | static void drawEllipseOnImage( | ||||
| 77 | QImage & image, | ||||
| 78 | const NormalizedPath & rect, | ||||
| 79 | const QPen & pen, | ||||
| 80 | const QBrush & brush, | ||||
| 81 | double penWidthMultiplier, | ||||
| 82 | RasterOperation op | ||||
| 83 | ); | ||||
| 84 | | ||||
| 85 | friend class LineAnnotPainter; | ||||
| 86 | }; | ||||
| 87 | | ||||
| 88 | class LineAnnotPainter { | ||||
| 89 | public: | ||||
| 90 | LineAnnotPainter( const Okular::LineAnnotation * a, QSizeF pageSizeA, double pageScale, const QTransform &toNormalizedImage ); | ||||
| 91 | void draw( QImage &image ) const; | ||||
| 92 | | ||||
| 93 | private: | ||||
| 94 | void drawMainLine( QImage &image ) const; | ||||
| 95 | void drawShortenedLine( double mainSegmentLength, double size, QImage &image, const QTransform& toNormalizedPage ) const; | ||||
| 96 | void drawLineEnds( double mainSegmentLength, double size, QImage &image, const QTransform& transform ) const; | ||||
| 97 | void drawLineEndArrow( double xEndPos, double size, double flipX, bool close, const QTransform& toNormalizedPage, QImage &image ) const; | ||||
| 98 | void drawLineEndButt( double xEndPos, double size, const QTransform& toNormalizedPage, QImage &image ) const; | ||||
| 99 | void drawLineEndCircle( double xEndPos, double size, const QTransform& toNormalizedPage, QImage &image ) const; | ||||
| 100 | void drawLineEndSquare( double xEndPos, double size, const QTransform& toNormalizedPage, QImage &image ) const; | ||||
| 101 | void drawLineEndDiamond( double xEndPos, double size, const QTransform& toNormalizedPage, QImage &image ) const; | ||||
| 102 | void drawLineEndSlash( double xEndPos, double size, const QTransform& toNormalizedPage, QImage &image ) const; | ||||
| 103 | void drawLeaderLine( double xEndPos, QImage &image, const QTransform& toNormalizedPage ) const; | ||||
| 104 | template <typename T> QList<Okular::NormalizedPoint> transformPath( const T& path, const QTransform& transform ) const | ||||
| 105 | { | ||||
| 106 | QList<Okular::NormalizedPoint> transformedPath; | ||||
| 107 | for( const Okular::NormalizedPoint &item : path ) | ||||
| 108 | { | ||||
| 109 | Okular::NormalizedPoint p; | ||||
| 110 | transform.map( item.x, item.y, &p.x, &p.y ); | ||||
| 111 | transformedPath.append(p); | ||||
| 112 | } | ||||
| 113 | return transformedPath; | ||||
| 114 | } | ||||
| 115 | | ||||
| 116 | static double shortenForArrow( double size, Okular::LineAnnotation::TermStyle endStyle ); | ||||
| 117 | | ||||
| 118 | private: | ||||
| 119 | const Okular::LineAnnotation* la; | ||||
| 120 | QSizeF pageSize; | ||||
| 121 | double pageScale; | ||||
| 122 | QTransform toNormalizedImage; | ||||
| 123 | double aspectRatio; | ||||
| 124 | const QPen linePen; | ||||
| 125 | QBrush fillBrush; | ||||
| 75 | }; | 126 | }; | ||
| 76 | 127 | | |||
| 77 | #endif | 128 | #endif | ||