KItinerary

popplerutils.cpp
1/*
2 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include <config-kitinerary.h>
8
9#include "popplerutils_p.h"
10
11#include <QBrush>
12#include <QPainterPath>
13#include <QPen>
14
15#include <memory>
16
17#include <GfxState.h>
18
19using namespace KItinerary;
20
21QPen PopplerUtils::currentPen(GfxState *state)
22{
23 QPen pen;
25 pen.setWidthF(state->getLineWidth());
26
27 GfxRGB rgb;
28 state->getStrokeRGB(&rgb);
29 QColor c;
30 c.setRgbF(colToDbl(rgb.r), colToDbl(rgb.g), colToDbl(rgb.b), 1.0f);
31 pen.setColor(c);
32
33 switch (state->getLineCap()) {
34 case 0: pen.setCapStyle(Qt::FlatCap); break;
35 case 1: pen.setCapStyle(Qt::RoundCap); break;
36 case 2: pen.setCapStyle(Qt::SquareCap); break;
37 }
38
39 switch (state->getLineJoin()) {
40 case 0: pen.setJoinStyle(Qt::SvgMiterJoin); break;
41 case 1: pen.setJoinStyle(Qt::RoundJoin); break;
42 case 2: pen.setJoinStyle(Qt::BevelJoin); break;
43 }
44
45 pen.setMiterLimit(state->getMiterLimit());
46
47 return pen;
48}
49
50QBrush PopplerUtils::currentBrush(GfxState* state)
51{
52 QBrush brush;
54
55 GfxRGB rgb;
56 state->getFillRGB(&rgb);
57 QColor c;
58 c.setRgbF(colToDbl(rgb.r), colToDbl(rgb.g), colToDbl(rgb.b), 1.0f);
59 brush.setColor(c);
60
61 return brush;
62}
63
64QTransform KItinerary::PopplerUtils::currentTransform(GfxState *state)
65{
66 const auto ctm = state->getCTM();
67 return QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
68}
69
70QPainterPath PopplerUtils::convertPath(const GfxPath *path, Qt::FillRule fillRule)
71{
72 QPainterPath qpp;
73 qpp.setFillRule(fillRule);
74
75 for (auto i = 0; i < path->getNumSubpaths(); ++i) {
76 const auto subpath = path->getSubpath(i);
77 if (subpath->getNumPoints() > 0) {
78 qpp.moveTo(subpath->getX(0), subpath->getY(0));
79 for (auto j = 1;j < subpath->getNumPoints();) {
80 if (subpath->getCurve(j)) {
81 qpp.cubicTo(subpath->getX(j), subpath->getY(j), subpath->getX(j+1), subpath->getY(j+1), subpath->getX(j+2), subpath->getY(j+2));
82 j += 3;
83 } else {
84 qpp.lineTo(subpath->getX(j), subpath->getY(j));
85 ++j;
86 }
87 }
88 if (subpath->isClosed()) {
89 qpp.closeSubpath();
90 }
91 }
92 }
93 return qpp;
94}
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
QString path(const QString &relativePath)
void setColor(Qt::GlobalColor color)
void setStyle(Qt::BrushStyle style)
void setRgbF(float r, float g, float b, float a)
void closeSubpath()
void cubicTo(const QPointF &c1, const QPointF &c2, const QPointF &endPoint)
void lineTo(const QPointF &endPoint)
void moveTo(const QPointF &point)
void setFillRule(Qt::FillRule fillRule)
void setCapStyle(Qt::PenCapStyle style)
void setColor(const QColor &color)
void setJoinStyle(Qt::PenJoinStyle style)
void setMiterLimit(qreal limit)
void setStyle(Qt::PenStyle style)
void setWidthF(qreal width)
SolidPattern
FillRule
SvgMiterJoin
SolidLine
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.