Editor plugin: Color convertor

This commit is contained in:
Jakub Melka 2024-06-21 18:34:06 +02:00
parent c52e487b04
commit 1ffd5c6a16
28 changed files with 200 additions and 88 deletions

View File

@ -302,6 +302,7 @@ void DifferencesDrawInterface::drawPage(QPainter* painter,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -329,7 +330,7 @@ void DifferencesDrawInterface::drawPage(QPainter* painter,
const auto& item = *it;
if (item.first == leftPageIndex)
{
QColor color = getColorForIndex(i);
QColor color = convertor.convert(getColorForIndex(i), false, true);
drawRectangle(painter, pagePointToDevicePointMatrix, item.second, color);
drawMarker(painter, pagePointToDevicePointMatrix, item.second, color, true);
}
@ -352,7 +353,7 @@ void DifferencesDrawInterface::drawPage(QPainter* painter,
const auto& item = *it;
if (item.first == rightPageIndex)
{
QColor color = getColorForIndex(i);
QColor color = convertor.convert(getColorForIndex(i), false, true);
drawRectangle(painter, pagePointToDevicePointMatrix, item.second, color);
drawMarker(painter, pagePointToDevicePointMatrix, item.second, color, false);
}
@ -388,7 +389,7 @@ void DifferencesDrawInterface::drawPage(QPainter* painter,
break;
}
QColor color = getColorForIndex(*pageMoveIndex);
QColor color = convertor.convert(getColorForIndex(*pageMoveIndex), false, true);
QPointF targetPoint = pagePointToDevicePointMatrix.map(QPointF(5, 5));
pdf::PDFPainterHelper::drawBubble(painter, targetPoint.toPoint(), color, text, Qt::AlignRight | Qt::AlignTop);
}

View File

@ -93,6 +93,7 @@ public:
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const override;
virtual void drawPostRendering(QPainter* painter, QRect rect) const override;

View File

@ -20,6 +20,7 @@
#include "pdfwidgettool.h"
#include "pdfutils.h"
#include "pdfwidgetutils.h"
#include "pdfcms.h"
#include "audiobookcreator.h"
#include <QAction>
@ -170,6 +171,7 @@ void AudioBookPlugin::drawPage(QPainter* painter,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -208,8 +210,8 @@ void AudioBookPlugin::drawPage(QPainter* painter,
fillColor.setAlphaF(0.2f);
pen.setColor(strokeColor);
painter->setPen(pen);
painter->setBrush(QBrush(fillColor));
painter->setPen(convertor.convert(pen));
painter->setBrush(convertor.convert(QBrush(fillColor)));
QPainterPath path;
path.addRect(boundingRect);

View File

@ -53,6 +53,7 @@ public:
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const override;
// IDrawWidgetInputInterface interface

View File

@ -18,6 +18,7 @@
#include "dimensionsplugin.h"
#include "pdfdrawwidget.h"
#include "pdfwidgetutils.h"
#include "pdfcms.h"
#include "settingsdialog.h"
#include <QPainter>
@ -149,6 +150,7 @@ void DimensionsPlugin::drawPage(QPainter* painter,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -196,7 +198,7 @@ void DimensionsPlugin::drawPage(QPainter* painter,
QPointF unitVector = unitVectorLine.p2() - unitVectorLine.p1();
qreal extensionLineSize = pdf::PDFWidgetUtils::scaleDPI_y(painter->device(), 5);
painter->setPen(Qt::black);
painter->setPen(convertor.convert(QColor(Qt::black), false, true));
painter->drawLine(line);
QLineF extensionLineLeft(p1 - unitVector * extensionLineSize, p1 + unitVector * extensionLineSize);
@ -237,14 +239,14 @@ void DimensionsPlugin::drawPage(QPainter* painter,
QColor brushColor = Qt::black;
brushColor.setAlphaF(0.1f);
painter->setPen(qMove(pen));
painter->setBrush(QBrush(brushColor, isArea ? Qt::SolidPattern : Qt::DiagCrossPattern));
painter->setPen(convertor.convert(pen));
painter->setBrush(convertor.convert(QBrush(brushColor, isArea ? Qt::SolidPattern : Qt::DiagCrossPattern)));
painter->setTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->drawPolygon(polygon.data(), int(polygon.size()), Qt::OddEvenFill);
painter->restore();
QPen penPoint(Qt::black);
QPen penPoint(convertor.convert(QColor(Qt::black), false, true));
penPoint.setCapStyle(Qt::RoundCap);
penPoint.setWidthF(pointSize);
painter->setPen(penPoint);
@ -287,7 +289,7 @@ void DimensionsPlugin::drawPage(QPainter* painter,
line1.setLength(maxLength);
line2.setLength(maxLength);
QPen pen(Qt::black);
QPen pen(convertor.convert(QColor(Qt::black), false, true));
pen.setWidthF(lineSize);
painter->setPen(qMove(pen));
@ -301,7 +303,7 @@ void DimensionsPlugin::drawPage(QPainter* painter,
rect.translate(line1.p1());
painter->drawArc(rect, startAngle - angleLength, angleLength);
QPen penPoint(Qt::black);
QPen penPoint(convertor.convert(QColor(Qt::black), false, true));
penPoint.setCapStyle(Qt::RoundCap);
penPoint.setWidthF(pointSize);
painter->setPen(penPoint);

View File

@ -47,6 +47,7 @@ public:
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const override;
private:

View File

@ -18,6 +18,7 @@
#include "dimensiontool.h"
#include "pdfwidgetutils.h"
#include "pdfdrawwidget.h"
#include "pdfcms.h"
#include <QPainter>
@ -41,6 +42,7 @@ void DimensionTool::drawPage(QPainter* painter,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -59,7 +61,7 @@ void DimensionTool::drawPage(QPainter* painter,
return;
}
painter->setPen(Qt::black);
painter->setPen(convertor.convert(QColor(Qt::black), false, true));
const std::vector<QPointF>& points = m_pickTool->getPickedPoints();
for (size_t i = 1; i < points.size(); ++i)
{

View File

@ -111,6 +111,7 @@ public:
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const override;
signals:

View File

@ -193,6 +193,8 @@ bool EditorPlugin::save()
{
pdf::PDFDocumentModifier modifier(m_document);
pdf::PDFColorConvertor convertor;
std::set<pdf::PDFInteger> pageIndices;
for (const auto& item : m_editedPageContent)
{
@ -229,8 +231,6 @@ bool EditorPlugin::save()
const pdf::PDFPageContentImageElement* elementImage = element->asElementImage();
const pdf::PDFPageContentElementTextBox* elementTextBox = element->asElementTextBox();
// TODO: Implement all things
if (editedElement)
{
contentStreamBuilder.writeEditedElement(editedElement->getElement());
@ -298,7 +298,7 @@ bool EditorPlugin::save()
QList<pdf::PDFRenderError> errors;
pdf::PDFTextLayoutGetter textLayoutGetter(nullptr, pageIndex);
elementImage->drawPage(&painter, &m_scene, pageIndex, nullptr, textLayoutGetter, QTransform(), errors);
elementImage->drawPage(&painter, &m_scene, pageIndex, nullptr, textLayoutGetter, QTransform(), convertor, errors);
}
}
@ -309,7 +309,7 @@ bool EditorPlugin::save()
QList<pdf::PDFRenderError> errors;
pdf::PDFTextLayoutGetter textLayoutGetter(nullptr, pageIndex);
elementTextBox->drawPage(&painter, &m_scene, pageIndex, nullptr, textLayoutGetter, QTransform(), errors);
elementTextBox->drawPage(&painter, &m_scene, pageIndex, nullptr, textLayoutGetter, QTransform(), convertor, errors);
}
}
}

View File

@ -288,6 +288,8 @@ void SignaturePlugin::onSignElectronically()
Q_ASSERT(m_document);
Q_ASSERT(!m_scene.isEmpty());
pdf::PDFColorConvertor convertor;
if (QMessageBox::question(m_dataExchangeInterface->getMainWindow(), tr("Confirm Signature"), tr("Document will be signed electronically. Do you want to continue?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{
pdf::PDFDocumentModifier modifier(m_document);
@ -302,7 +304,7 @@ void SignaturePlugin::onSignElectronically()
QPainter* painter = pageContentStreamBuilder.begin(page->getPageReference());
QList<pdf::PDFRenderError> errors;
pdf::PDFTextLayoutGetter nullGetter(nullptr, pageIndex);
m_scene.drawElements(painter, pageIndex, nullGetter, QTransform(), nullptr, errors);
m_scene.drawElements(painter, pageIndex, nullGetter, QTransform(), nullptr, convertor, errors);
pageContentStreamBuilder.end(painter);
modifier.markPageContentsChanged();
}
@ -369,12 +371,13 @@ void SignaturePlugin::onSignDigitally()
Q_ASSERT(!m_scene.isEmpty());
const pdf::PDFInteger pageIndex = *m_scene.getPageIndices().begin();
const pdf::PDFPage* page = catalog->getPage(pageIndex);
pdf::PDFColorConvertor convertor;
pdf::PDFContentStreamBuilder contentBuilder(page->getMediaBox().size(), pdf::PDFContentStreamBuilder::CoordinateSystem::PDF);
QPainter* painter = contentBuilder.begin();
QList<pdf::PDFRenderError> errors;
pdf::PDFTextLayoutGetter nullGetter(nullptr, pageIndex);
m_scene.drawPage(painter, pageIndex, nullptr, nullGetter, QTransform(), errors);
m_scene.drawPage(painter, pageIndex, nullptr, nullGetter, QTransform(), convertor, errors);
pdf::PDFContentStreamBuilder::ContentStream contentStream = contentBuilder.end(painter);
QRectF boundingRect = m_scene.getBoundingBox(pageIndex);

View File

@ -225,6 +225,20 @@ QColor PDFColorConvertor::getForegroundColor() const
return m_foregroundColor;
}
QPen PDFColorConvertor::convert(const QPen& pen, bool background, bool foreground) const
{
QPen newPen = pen;
newPen.setColor(convert(pen.color(), background, foreground));
return newPen;
}
QBrush PDFColorConvertor::convert(const QBrush& brush, bool background, bool foreground) const
{
QBrush newBrush = brush;
newBrush.setColor(convert(brush.color(), background, foreground));
return newBrush;
}
QColor PDFColorConvertor::getBackgroundColor() const
{
return m_backgroundColor;

View File

@ -20,6 +20,8 @@
#include "pdfglobal.h"
#include <QPen>
#include <QBrush>
#include <QColor>
#include <QImage>
@ -103,6 +105,9 @@ public:
QColor getBackgroundColor() const;
QColor getForegroundColor() const;
QPen convert(const QPen& pen, bool background = false, bool foreground = true) const;
QBrush convert(const QBrush& brush, bool background = false, bool foreground = true) const;
private:
/// Correct lightness using sigmoid function
/// \return Adjusted lightness normalized in range [0.0, 1.0]

View File

@ -18,6 +18,7 @@
#include "pdftextlayout.h"
#include "pdfutils.h"
#include "pdfexecutionpolicy.h"
#include "pdfcms.h"
#include <QtMath>
#include <QMutex>
@ -1509,7 +1510,11 @@ PDFTextLayout PDFTextLayoutStorageGetter::getTextLayoutImpl() const
return m_storage ? m_storage->getTextLayout(m_pageIndex) : PDFTextLayout();
}
void PDFTextSelectionPainter::draw(QPainter* painter, PDFInteger pageIndex, PDFTextLayoutGetter& textLayoutGetter, const QTransform& matrix)
void PDFTextSelectionPainter::draw(QPainter* painter,
PDFInteger pageIndex,
PDFTextLayoutGetter& textLayoutGetter,
const QTransform& matrix,
const PDFColorConvertor& convertor)
{
Q_ASSERT(painter);
@ -1548,8 +1553,8 @@ void PDFTextSelectionPainter::draw(QPainter* painter, PDFInteger pageIndex, PDFT
QColor brushColor = item.color;
brushColor.setAlphaF(SELECTION_ALPHA);
painter->setPen(penColor);
painter->setBrush(QBrush(brushColor, Qt::SolidPattern));
painter->setPen(convertor.convert(QPen(penColor)));
painter->setBrush(convertor.convert(QBrush(brushColor, Qt::SolidPattern)));
painter->drawPath(path);
}

View File

@ -35,6 +35,7 @@ namespace pdf
class PDFTextLayout;
class PDFTextLayoutStorage;
struct PDFCharacterPointer;
class PDFColorConvertor;
struct PDFTextCharacterInfo
{
@ -522,7 +523,7 @@ public:
/// \param pageIndex Page index
/// \param textLayoutGetter Text layout getter
/// \param matrix Matrix which translates from page space to device space
void draw(QPainter* painter, PDFInteger pageIndex, PDFTextLayoutGetter& textLayoutGetter, const QTransform& matrix);
void draw(QPainter* painter, PDFInteger pageIndex, PDFTextLayoutGetter& textLayoutGetter, const QTransform& matrix, const PDFColorConvertor& convertor);
/// Prepares geometry for text selection drawing, using text layout and matrix. If current text selection
/// doesn't contain items from active page, then text layout is not accessed.

View File

@ -18,6 +18,7 @@
#include "pdfadvancedfindwidget.h"
#include "ui_pdfadvancedfindwidget.h"
#include "pdfcms.h"
#include "pdfcompiler.h"
#include "pdfdocument.h"
#include "pdfdrawspacecontroller.h"
@ -196,6 +197,7 @@ void PDFAdvancedFindWidget::drawPage(QPainter* painter,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -203,7 +205,7 @@ void PDFAdvancedFindWidget::drawPage(QPainter* painter,
const pdf::PDFTextSelection& textSelection = getTextSelection();
pdf::PDFTextSelectionPainter textSelectionPainter(&textSelection);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix, convertor);
}
void PDFAdvancedFindWidget::performSearch()

View File

@ -54,6 +54,7 @@ public:
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<pdf::PDFRenderError>& errors) const override;
void setDocument(const pdf::PDFModifiedDocument& document);

View File

@ -461,6 +461,7 @@ void PDFCreateLineTypeTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(pageIndex);
@ -468,7 +469,7 @@ void PDFCreateLineTypeTool::drawPage(QPainter* painter,
Q_UNUSED(layoutGetter);
Q_UNUSED(errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
if (pageIndex != m_pickTool->getPageIndex())
{
@ -485,8 +486,8 @@ void PDFCreateLineTypeTool::drawPage(QPainter* painter,
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
QPen pen(m_strokeColor);
QBrush brush(m_fillColor, Qt::SolidPattern);
QPen pen = convertor.convert(QPen(m_strokeColor));
QBrush brush = convertor.convert(QBrush(m_fillColor, Qt::SolidPattern));
pen.setWidthF(m_penWidth);
painter->setPen(qMove(pen));
painter->setBrush(qMove(brush));
@ -592,9 +593,10 @@ void PDFCreateEllipseTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
if (pageIndex != m_pickTool->getPageIndex())
{
@ -611,8 +613,8 @@ void PDFCreateEllipseTool::drawPage(QPainter* painter,
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
QPen pen(m_strokeColor);
QBrush brush(m_fillColor, Qt::SolidPattern);
QPen pen = convertor.convert(QPen(m_strokeColor));
QBrush brush = convertor.convert(QBrush(m_fillColor, Qt::SolidPattern));
pen.setWidthF(m_penWidth);
painter->setPen(qMove(pen));
painter->setBrush(qMove(brush));
@ -672,9 +674,10 @@ void PDFCreateFreehandCurveTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
if (pageIndex != m_pageIndex || m_pickedPoints.empty())
{
@ -683,7 +686,7 @@ void PDFCreateFreehandCurveTool::drawPage(QPainter* painter,
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
QPen pen(m_strokeColor);
QPen pen = convertor.convert(QPen(m_strokeColor));
pen.setWidthF(m_penWidth);
painter->setPen(qMove(pen));
painter->setRenderHint(QPainter::Antialiasing);
@ -833,6 +836,7 @@ void PDFCreateStampTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -854,7 +858,7 @@ void PDFCreateStampTool::drawPage(QPainter* painter,
parameters.painter = painter;
parameters.annotation = const_cast<PDFStampAnnotation*>(&m_stampAnnotation);
parameters.key.first = PDFAppeareanceStreams::Appearance::Normal;
parameters.colorConvertor = getProxy()->getCMSManager()->getColorConvertor();
parameters.colorConvertor = convertor;
PDFRenderer::applyFeaturesToColorConvertor(getProxy()->getFeatures(), parameters.colorConvertor);
m_stampAnnotation.draw(parameters);
@ -933,13 +937,15 @@ void PDFCreateHighlightTextTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
Q_UNUSED(errors);
Q_UNUSED(convertor);
pdf::PDFTextSelectionPainter textSelectionPainter(&m_textSelection);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix, convertor);
}
void PDFCreateHighlightTextTool::mousePressEvent(QWidget* widget, QMouseEvent* event)
@ -1173,13 +1179,15 @@ void PDFCreateRedactTextTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
Q_UNUSED(errors);
Q_UNUSED(convertor);
pdf::PDFTextSelectionPainter textSelectionPainter(&m_textSelection);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix, convertor);
}
void PDFCreateRedactTextTool::mousePressEvent(QWidget* widget, QMouseEvent* event)

View File

@ -130,10 +130,12 @@ public:
virtual void keyPressEvent(QWidget* widget, QKeyEvent* event) override;
virtual void keyReleaseEvent(QWidget* widget, QKeyEvent* event) override;
virtual void drawPage(QPainter* painter, PDFInteger pageIndex,
virtual void drawPage(QPainter* painter,
PDFInteger pageIndex,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
PDFReal getPenWidth() const;
@ -176,6 +178,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
PDFReal getPenWidth() const;
@ -211,6 +214,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual void mousePressEvent(QWidget* widget, QMouseEvent* event) override;
@ -249,6 +253,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual void mouseMoveEvent(QWidget* widget, QMouseEvent* event) override;
@ -289,6 +294,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual void mousePressEvent(QWidget* widget, QMouseEvent* event) override;
@ -353,6 +359,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual void mousePressEvent(QWidget* widget, QMouseEvent* event) override;

View File

@ -31,6 +31,7 @@ class QWheelEvent;
namespace pdf
{
class PDFColorConvertor;
class PDFPrecompiledPage;
class PDFTextLayoutGetter;
@ -47,12 +48,14 @@ public:
/// \param compiledPage Compiled page
/// \param layoutGetter Layout getter
/// \param pagePointToDevicePointMatrix Matrix mapping page space to device point space
/// \param convertor Color convertor
/// \param[out] errors Output parameter - rendering errors
virtual void drawPage(QPainter* painter,
pdf::PDFInteger pageIndex,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const;
/// Performs drawing of additional graphics after all pages are drawn onto the painter.

View File

@ -784,6 +784,11 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::F
// Use current paper color (it can be a bit different from white)
QColor paperColor = getPaperColor();
// Color management system
PDFCMSPointer cms = getCMSManager()->getCurrentCMS();
PDFColorConvertor convertor = cms->getColorConvertor();
PDFRenderer::applyFeaturesToColorConvertor(features, convertor);
// Iterate trough pages and display them on the painter device
for (const LayoutItem& item : m_layout.items)
{
@ -879,7 +884,7 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::F
for (IDocumentDrawInterface* drawInterface : m_drawInterfaces)
{
painter->save();
drawInterface->drawPage(painter, item.pageIndex, compiledPage, layoutGetter, matrix, drawInterfaceErrors);
drawInterface->drawPage(painter, item.pageIndex, compiledPage, layoutGetter, matrix, convertor, drawInterfaceErrors);
painter->restore();
}
}
@ -1623,6 +1628,7 @@ void IDocumentDrawInterface::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const pdf::PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(painter);
@ -1630,6 +1636,7 @@ void IDocumentDrawInterface::drawPage(QPainter* painter,
Q_UNUSED(compiledPage);
Q_UNUSED(layoutGetter);
Q_UNUSED(pagePointToDevicePointMatrix);
Q_UNUSED(convertor);
Q_UNUSED(errors);
}

View File

@ -148,9 +148,10 @@ void PDFCreatePCElementRectangleTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
if (pageIndex != m_pickTool->getPageIndex())
{
@ -166,7 +167,7 @@ void PDFCreatePCElementRectangleTool::drawPage(QPainter* painter,
m_element->setPageIndex(pageIndex);
m_element->setRectangle(rectangle);
m_element->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
m_element->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
}
const PDFPageContentElement* PDFCreatePCElementRectangleTool::getElement() const
@ -242,9 +243,10 @@ void PDFCreatePCElementLineTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
if (pageIndex != m_pickTool->getPageIndex() || !m_startPoint)
{
@ -262,7 +264,7 @@ void PDFCreatePCElementLineTool::drawPage(QPainter* painter,
m_element->setLine(line);
}
m_element->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
m_element->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
}
const PDFPageContentElement* PDFCreatePCElementLineTool::getElement() const
@ -339,9 +341,10 @@ void PDFCreatePCElementImageTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
if (pageIndex != m_pickTool->getPageIndex())
{
@ -361,12 +364,12 @@ void PDFCreatePCElementImageTool::drawPage(QPainter* painter,
PDFPainterStateGuard guard(painter);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(Qt::DotLine);
painter->setPen(convertor.convert(QPen(Qt::DotLine)));
painter->setBrush(Qt::NoBrush);
painter->drawRect(rectangle);
}
m_element->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
m_element->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
}
const PDFPageContentElement* PDFCreatePCElementImageTool::getElement() const
@ -486,17 +489,18 @@ void PDFCreatePCElementDotTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
QPointF point = pagePointToDevicePointMatrix.inverted().map(m_pickTool->getSnappedPoint());
PDFPainterStateGuard guard(painter);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(m_element->getPen());
painter->setBrush(m_element->getBrush());
painter->setPen(convertor.convert(m_element->getPen()));
painter->setBrush(convertor.convert(m_element->getBrush()));
painter->drawPoint(point);
}
@ -547,16 +551,17 @@ void PDFCreatePCElementFreehandCurveTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
if (pageIndex != m_element->getPageIndex() || m_element->isEmpty())
{
return;
}
m_element->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
m_element->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
}
const PDFPageContentElement* PDFCreatePCElementFreehandCurveTool::getElement() const
@ -691,9 +696,10 @@ void PDFCreatePCElementTextTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
if (pageIndex != m_element->getPageIndex())
{
@ -707,7 +713,7 @@ void PDFCreatePCElementTextTool::drawPage(QPainter* painter,
parameters.painter = painter;
parameters.boundingRectangle = m_element->getRectangle();
parameters.key.first = PDFAppeareanceStreams::Appearance::Normal;
parameters.colorConvertor = getProxy()->getCMSManager()->getColorConvertor();
parameters.colorConvertor = convertor;
PDFRenderer::applyFeaturesToColorConvertor(getProxy()->getFeatures(), parameters.colorConvertor);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);

View File

@ -79,6 +79,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual const PDFPageContentElement* getElement() const override;
@ -113,6 +114,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual const PDFPageContentElement* getElement() const override;
@ -153,6 +155,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual const PDFPageContentElement* getElement() const override;
@ -187,6 +190,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual const PDFPageContentElement* getElement() const override;
@ -219,6 +223,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual const PDFPageContentElement* getElement() const override;
@ -257,6 +262,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual const PDFPageContentElement* getElement() const override;

View File

@ -21,6 +21,7 @@
#include "pdfdrawspacecontroller.h"
#include "pdfwidgetutils.h"
#include "pdfutils.h"
#include "pdfcms.h"
#include "pdfpagecontenteditorprocessor.h"
#include <QBuffer>
@ -276,6 +277,7 @@ void PDFPageContentElementRectangle::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -290,8 +292,8 @@ void PDFPageContentElementRectangle::drawPage(QPainter* painter,
PDFPainterStateGuard guard(painter);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setPen(getPen());
painter->setBrush(getBrush());
painter->setPen(convertor.convert(getPen()));
painter->setBrush(convertor.convert(getBrush()));
painter->setRenderHint(QPainter::Antialiasing);
QRectF rect = getRectangle();
@ -657,6 +659,7 @@ void PDFPageContentScene::drawElements(QPainter* painter,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFPrecompiledPage* compiledPage,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
for (const auto& element : m_elements)
@ -666,7 +669,7 @@ void PDFPageContentScene::drawElements(QPainter* painter,
continue;
}
element->drawPage(painter, this, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
element->drawPage(painter, this, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
}
}
@ -675,6 +678,7 @@ void PDFPageContentScene::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
if (!m_isActive)
@ -682,8 +686,8 @@ void PDFPageContentScene::drawPage(QPainter* painter,
return;
}
drawElements(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix, compiledPage, errors);
m_manipulator.drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
drawElements(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix, compiledPage, convertor, errors);
m_manipulator.drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
}
PDFPageContentScene::MouseEventInfo PDFPageContentScene::getMouseEventInfo(QWidget* widget, QPoint point)
@ -985,6 +989,7 @@ void PDFPageContentElementLine::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -999,8 +1004,8 @@ void PDFPageContentElementLine::drawPage(QPainter* painter,
PDFPainterStateGuard guard(painter);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setPen(getPen());
painter->setBrush(getBrush());
painter->setPen(convertor.convert(getPen()));
painter->setBrush(convertor.convert(getBrush()));
painter->setRenderHint(QPainter::Antialiasing);
painter->drawLine(getLine());
@ -1169,6 +1174,7 @@ void PDFPageContentImageElement::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -1219,7 +1225,8 @@ void PDFPageContentImageElement::drawPage(QPainter* painter,
painter->scale(1.0, -1.0);
targetRenderBox.moveTopLeft(QPointF(0, 0));
painter->drawImage(targetRenderBox, m_image);
QImage image = convertor.convert(image);
painter->drawImage(targetRenderBox, image);
}
}
@ -1313,6 +1320,7 @@ void PDFPageContentElementDot::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -1328,8 +1336,8 @@ void PDFPageContentElementDot::drawPage(QPainter* painter,
PDFPainterStateGuard guard(painter);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(getPen());
painter->setBrush(getBrush());
painter->setPen(convertor.convert(getPen()));
painter->setBrush(convertor.convert(getBrush()));
painter->drawPoint(m_point);
}
@ -1403,6 +1411,7 @@ void PDFPageContentElementFreehandCurve::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -1417,8 +1426,8 @@ void PDFPageContentElementFreehandCurve::drawPage(QPainter* painter,
PDFPainterStateGuard guard(painter);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setPen(getPen());
painter->setBrush(getBrush());
painter->setPen(convertor.convert(getPen()));
painter->setBrush(convertor.convert(getBrush()));
painter->setRenderHint(QPainter::Antialiasing);
painter->drawPath(getCurve());
@ -2319,6 +2328,7 @@ void PDFPageContentElementManipulator::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
// Draw selection
@ -2344,8 +2354,8 @@ void PDFPageContentElementManipulator::drawPage(QPainter* painter,
QBrush brush(Qt::SolidPattern);
brush.setColor(QColor::fromRgbF(1.0f, 1.0f, 0.0f, 0.2f));
painter->setPen(std::move(pen));
painter->setBrush(std::move(brush));
painter->setPen(convertor.convert(pen));
painter->setBrush(convertor.convert(brush));
selectionPath = pagePointToDevicePointMatrix.map(selectionPath);
painter->drawPath(selectionPath);
@ -2360,7 +2370,7 @@ void PDFPageContentElementManipulator::drawPage(QPainter* painter,
for (const auto& manipulatedElement : m_manipulatedElements)
{
manipulatedElement->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
manipulatedElement->drawPage(painter, m_scene, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
}
}
}
@ -2430,6 +2440,7 @@ void PDFPageContentElementTextBox::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -2452,8 +2463,8 @@ void PDFPageContentElementTextBox::drawPage(QPainter* painter,
PDFPainterStateGuard guard(painter);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setPen(getPen());
painter->setBrush(getBrush());
painter->setPen(convertor.convert(getPen()));
painter->setBrush(convertor.convert(getBrush()));
painter->setFont(font);
painter->setRenderHint(QPainter::Antialiasing);
painter->setClipRect(rect, Qt::IntersectClip);
@ -2613,6 +2624,7 @@ void PDFPageContentElementEdited::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
PDFPainterStateGuard guard(painter);
@ -2623,7 +2635,7 @@ void PDFPageContentElementEdited::drawPage(QPainter* painter,
Q_UNUSED(errors);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setPen(Qt::SolidLine);
painter->setPen(convertor.convert(QPen(Qt::SolidLine)));
painter->setBrush(Qt::NoBrush);
painter->setFont(QApplication::font());
painter->setRenderHint(QPainter::Antialiasing);
@ -2648,7 +2660,7 @@ void PDFPageContentElementEdited::drawPage(QPainter* painter,
QRect transformedRect(0.0, 0.0, rect.width(), rect.height());
QImage image = imageElement->getImage();
QImage image = convertor.convert(imageElement->getImage());
painter->fillRect(transformedRect, Qt::white);
painter->drawImage(transformedRect, image);
}
@ -2656,8 +2668,8 @@ void PDFPageContentElementEdited::drawPage(QPainter* painter,
if (const PDFEditedPageContentElementPath* pathElement = m_element->asPath())
{
const PDFPageContentProcessorState& state = m_element->getState();
QPen pen = pdf::PDFPainterHelper::createPenFromState(&state, state.getAlphaStroking());
QBrush brush = pdf::PDFPainterHelper::createBrushFromState(&state, state.getAlphaFilling());
QPen pen = convertor.convert(pdf::PDFPainterHelper::createPenFromState(&state, state.getAlphaStroking()));
QBrush brush = convertor.convert(pdf::PDFPainterHelper::createBrushFromState(&state, state.getAlphaFilling()));
painter->setPen(pathElement->getStrokePath() ? pen : QPen(Qt::NoPen));
painter->setBrush(pathElement->getFillPath() ? brush : QBrush(Qt::NoBrush));
painter->drawPath(pathElement->getPath());
@ -2666,7 +2678,7 @@ void PDFPageContentElementEdited::drawPage(QPainter* painter,
if (const PDFEditedPageContentElementText* textElement = m_element->asText())
{
const PDFPageContentProcessorState& state = m_element->getState();
painter->setBrush(pdf::PDFPainterHelper::createBrushFromState(&state, state.getAlphaFilling()));
painter->setBrush(convertor.convert(pdf::PDFPainterHelper::createBrushFromState(&state, state.getAlphaFilling())));
painter->fillPath(textElement->getTextPath(), painter->brush());
}
}

View File

@ -34,6 +34,7 @@ class QSvgRenderer;
namespace pdf
{
class PDFCMS;
class PDFWidget;
class PDFDocument;
class PDFPageContentScene;
@ -60,6 +61,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const = 0;
/// Returns manipulation mode. If manipulation mode is zero, then element
@ -173,6 +175,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual uint getManipulationMode(const QPointF& point,
@ -209,6 +212,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual uint getManipulationMode(const QPointF& point,
@ -244,6 +248,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual uint getManipulationMode(const QPointF& point,
@ -275,6 +280,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual uint getManipulationMode(const QPointF& point,
@ -312,6 +318,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual uint getManipulationMode(const QPointF& point,
@ -355,6 +362,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual uint getManipulationMode(const QPointF& point,
@ -399,6 +407,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual uint getManipulationMode(const QPointF& point, PDFReal snapPointDistanceThreshold) const override;
virtual void performManipulation(uint mode, const QPointF& offset) override;
@ -503,6 +512,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const;
/// Returns bounding box of whole selection
@ -608,6 +618,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
PDFWidget* widget() const;
@ -618,6 +629,7 @@ public:
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFPrecompiledPage* compiledPage,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const;
void setIsPageContentDrawSuppressed(bool newIsPageContentDrawSuppressed);

View File

@ -645,14 +645,14 @@ void PDFTextEditPseudowidget::draw(AnnotationDrawParameters& parameters, bool ed
if (edit)
{
pdf::PDFPainterStateGuard guard2(painter);
painter->setPen(parameters.colorConvertor.convert(Qt::black, false, true));
painter->setPen(parameters.colorConvertor.convert(QColor(Qt::black), false, true));
painter->setBrush(Qt::NoBrush);
painter->drawRect(parameters.boundingRectangle);
}
painter->setClipRect(parameters.boundingRectangle, Qt::IntersectClip);
painter->setWorldTransform(QTransform(createTextBoxTransformMatrix(edit)), true);
painter->setPen(parameters.colorConvertor.convert(Qt::black, false, true));
painter->setPen(parameters.colorConvertor.convert(QColor(Qt::black), false, true));
if (isComb())
{

View File

@ -1344,7 +1344,7 @@ void PDFFormFieldComboBoxEditor::draw(AnnotationDrawParameters& parameters, bool
AnnotationDrawParameters listBoxParameters = parameters;
listBoxParameters.boundingRectangle = m_listBoxPopupRectangle;
QColor color = parameters.colorConvertor.convert(Qt::white, true, false);
QColor color = parameters.colorConvertor.convert(QColor(Qt::white), true, false);
listBoxParameters.painter->fillRect(listBoxParameters.boundingRectangle, color);
m_listBox.draw(listBoxParameters, true);
@ -1751,7 +1751,7 @@ void PDFListBoxPseudowidget::draw(AnnotationDrawParameters& parameters, bool edi
if (edit)
{
pdf::PDFPainterStateGuard guard2(painter);
painter->setPen(parameters.colorConvertor.convert(Qt::black, false, true));
painter->setPen(parameters.colorConvertor.convert(QColor(Qt::black), false, true));
painter->setBrush(Qt::NoBrush);
painter->drawRect(parameters.boundingRectangle);
}

View File

@ -20,6 +20,7 @@
#include "pdfcompiler.h"
#include "pdfwidgetutils.h"
#include "pdfpainterutils.h"
#include "pdfcms.h"
#include <QLabel>
#include <QAction>
@ -346,6 +347,7 @@ void PDFFindTextTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -353,7 +355,7 @@ void PDFFindTextTool::drawPage(QPainter* painter,
const pdf::PDFTextSelection& textSelection = getTextSelection();
pdf::PDFTextSelectionPainter textSelectionPainter(&textSelection);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix, convertor);
}
void PDFFindTextTool::clearResults()
@ -713,13 +715,14 @@ void PDFSelectTextTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
Q_UNUSED(errors);
pdf::PDFTextSelectionPainter textSelectionPainter(&m_textSelection);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix);
textSelectionPainter.draw(painter, pageIndex, layoutGetter, pagePointToDevicePointMatrix, convertor);
}
void PDFSelectTextTool::mousePressEvent(QWidget* widget, QMouseEvent* event)
@ -1305,6 +1308,7 @@ void PDFPickTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
@ -1330,14 +1334,14 @@ void PDFPickTool::drawPage(QPainter* painter,
QRect selectionRectangle(xMin, yMin, xMax - xMin, yMax - yMin);
if (selectionRectangle.isValid())
{
painter->fillRect(selectionRectangle, m_selectionRectangleColor);
painter->fillRect(selectionRectangle, convertor.convert(m_selectionRectangleColor, false, true));
}
}
if (m_mode == Mode::Images && m_snapper.getSnappedImage())
{
const PDFSnapper::ViewportSnapImage* snappedImage = m_snapper.getSnappedImage();
painter->fillPath(snappedImage->viewportPath, m_selectionRectangleColor);
painter->fillPath(snappedImage->viewportPath, convertor.convert(m_selectionRectangleColor, false, true));
}
}
@ -1644,9 +1648,10 @@ void PDFSelectTableTool::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
if (isTablePicked() && pageIndex == m_pageIndex)
{
@ -1658,8 +1663,8 @@ void PDFSelectTableTool::drawPage(QPainter* painter,
QPen pen(Qt::SolidLine);
pen.setWidthF(lineWidth);
painter->setPen(std::move(pen));
painter->setBrush(QBrush(color));
painter->setPen(convertor.convert(pen));
painter->setBrush(convertor.convert(QBrush(color)));
painter->drawRect(rectangle);
for (const PDFReal columnPosition : m_horizontalBreaks)

View File

@ -188,6 +188,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
protected:
@ -265,6 +266,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual void mousePressEvent(QWidget* widget, QMouseEvent* event) override;
@ -360,6 +362,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual void drawPostRendering(QPainter* painter, QRect rect) const override;
virtual void mousePressEvent(QWidget* widget, QMouseEvent* event) override;
@ -428,6 +431,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
virtual void shortcutOverrideEvent(QWidget* widget, QKeyEvent* event) override;