mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Magnifier tool
This commit is contained in:
@ -647,15 +647,35 @@ QMatrix PDFDrawWidgetProxy::createPagePointToDevicePointMatrix(const PDFPage* pa
|
||||
|
||||
void PDFDrawWidgetProxy::draw(QPainter* painter, QRect rect)
|
||||
{
|
||||
painter->fillRect(rect, Qt::lightGray);
|
||||
drawPages(painter, rect);
|
||||
|
||||
// Use current paper color (it can be a bit different from white)
|
||||
for (IDocumentDrawInterface* drawInterface : m_drawInterfaces)
|
||||
{
|
||||
painter->save();
|
||||
drawInterface->drawPostRendering(painter, rect);
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
QColor PDFDrawWidgetProxy::getPaperColor()
|
||||
{
|
||||
QColor paperColor = getCMSManager()->getCurrentCMS()->getPaperColor();
|
||||
if (m_features.testFlag(PDFRenderer::InvertColors))
|
||||
{
|
||||
paperColor = invertColor(paperColor);
|
||||
}
|
||||
|
||||
return paperColor;
|
||||
}
|
||||
|
||||
void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect)
|
||||
{
|
||||
painter->fillRect(rect, Qt::lightGray);
|
||||
QMatrix baseMatrix = painter->worldMatrix();
|
||||
|
||||
// Use current paper color (it can be a bit different from white)
|
||||
QColor paperColor = getPaperColor();
|
||||
|
||||
// Iterate trough pages and display them on the painter device
|
||||
for (const LayoutItem& item : m_layout.items)
|
||||
{
|
||||
@ -675,7 +695,7 @@ void PDFDrawWidgetProxy::draw(QPainter* painter, QRect rect)
|
||||
timer.start();
|
||||
|
||||
const PDFPage* page = m_controller->getDocument()->getCatalog()->getPage(item.pageIndex);
|
||||
QMatrix matrix = createPagePointToDevicePointMatrix(page, placedRect);
|
||||
QMatrix matrix = createPagePointToDevicePointMatrix(page, placedRect) * baseMatrix;
|
||||
compiledPage->draw(painter, page->getCropBox(), matrix, m_features);
|
||||
PDFTextLayoutGetter layoutGetter = m_textLayoutCompiler->getTextLayoutLazy(item.pageIndex);
|
||||
|
||||
@ -1314,4 +1334,10 @@ void IDocumentDrawInterface::drawPage(QPainter* painter,
|
||||
Q_UNUSED(pagePointToDevicePointMatrix);
|
||||
}
|
||||
|
||||
void IDocumentDrawInterface::drawPostRendering(QPainter* painter, QRect rect) const
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(rect);
|
||||
}
|
||||
|
||||
} // namespace pdf
|
||||
|
Reference in New Issue
Block a user