mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
DocDiff application: create document report, overlay
This commit is contained in:
@ -195,7 +195,7 @@ void PDFDrawSpaceController::recalculate()
|
||||
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(leftIndex)->getRotatedMediaBoxMM(), m_pageRotation).size();
|
||||
PDFReal xPos = -pageSize.width() - m_horizontalSpacingMM * 0.5;
|
||||
QRectF rect(xPos, yPos, pageSize.width(), pageSize.height());
|
||||
m_layoutItems.emplace_back(blockIndex, leftIndex, rect);
|
||||
m_layoutItems.emplace_back(blockIndex, leftIndex, -1, rect);
|
||||
yPosAdvance = qMax(yPosAdvance, pageSize.height());
|
||||
boundingRect = boundingRect.united(rect);
|
||||
}
|
||||
@ -205,7 +205,7 @@ void PDFDrawSpaceController::recalculate()
|
||||
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(rightIndex)->getRotatedMediaBoxMM(), m_pageRotation).size();
|
||||
PDFReal xPos = m_horizontalSpacingMM * 0.5;
|
||||
QRectF rect(xPos, yPos, pageSize.width(), pageSize.height());
|
||||
m_layoutItems.emplace_back(blockIndex, rightIndex, rect);
|
||||
m_layoutItems.emplace_back(blockIndex, rightIndex, -1, rect);
|
||||
yPosAdvance = qMax(yPosAdvance, pageSize.height());
|
||||
boundingRect = boundingRect.united(rect);
|
||||
}
|
||||
@ -267,7 +267,7 @@ void PDFDrawSpaceController::recalculate()
|
||||
{
|
||||
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(i)->getRotatedMediaBoxMM(), m_pageRotation).size();
|
||||
QRectF rect(-pageSize.width() * 0.5, -pageSize.height() * 0.5, pageSize.width(), pageSize.height());
|
||||
m_layoutItems.emplace_back(i, i, rect);
|
||||
m_layoutItems.emplace_back(i, i, -1, rect);
|
||||
m_blockItems.emplace_back(rect);
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ void PDFDrawSpaceController::recalculate()
|
||||
// Top of current page is at yPos.
|
||||
QSizeF pageSize = PDFPage::getRotatedBox(catalog->getPage(i)->getRotatedMediaBoxMM(), m_pageRotation).size();
|
||||
QRectF rect(-pageSize.width() * 0.5, yPos, pageSize.width(), pageSize.height());
|
||||
m_layoutItems.emplace_back(0, i, rect);
|
||||
m_layoutItems.emplace_back(0, i, -1, rect);
|
||||
yPos += pageSize.height() + m_verticalSpacingMM;
|
||||
boundingRectangle = boundingRectangle.united(rect);
|
||||
}
|
||||
@ -382,10 +382,10 @@ void PDFDrawSpaceController::recalculate()
|
||||
// We do not support page rotation for custom layout
|
||||
Q_ASSERT(m_pageRotation == PageRotation::None);
|
||||
|
||||
// Assure, that layout items are sorted by block
|
||||
// Assure, that layout items are sorted by block and page group
|
||||
auto comparator = [](const LayoutItem& l, const LayoutItem& r)
|
||||
{
|
||||
return l.blockIndex < r.blockIndex;
|
||||
return std::tie(l.blockIndex, l.groupIndex) < std::tie(r.blockIndex, r.groupIndex);
|
||||
};
|
||||
std::stable_sort(m_layoutItems.begin(), m_layoutItems.end(), comparator);
|
||||
|
||||
@ -566,7 +566,7 @@ void PDFDrawWidgetProxy::update()
|
||||
m_layout.items.reserve(items.size());
|
||||
for (const PDFDrawSpaceController::LayoutItem& item : items)
|
||||
{
|
||||
m_layout.items.emplace_back(item.pageIndex, fromDeviceSpace(item.pageRectMM).toRect());
|
||||
m_layout.items.emplace_back(item.pageIndex, item.groupIndex, fromDeviceSpace(item.pageRectMM).toRect());
|
||||
}
|
||||
|
||||
m_layout.blockRect = fromDeviceSpace(rectangle).toRect();
|
||||
@ -762,8 +762,13 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::F
|
||||
QRect placedRect = item.pageRect.translated(m_horizontalOffset - m_layout.blockRect.left(), m_verticalOffset - m_layout.blockRect.top());
|
||||
if (placedRect.intersects(rect))
|
||||
{
|
||||
GroupInfo groupInfo = getGroupInfo(item.groupIndex);
|
||||
|
||||
// Clear the page space by paper color
|
||||
painter->fillRect(placedRect, paperColor);
|
||||
if (groupInfo.drawPaper)
|
||||
{
|
||||
painter->fillRect(placedRect, paperColor);
|
||||
}
|
||||
|
||||
const PDFPrecompiledPage* compiledPage = m_compiler->getCompiledPage(item.pageIndex, true);
|
||||
if (compiledPage && compiledPage->isValid())
|
||||
@ -773,7 +778,7 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::F
|
||||
|
||||
const PDFPage* page = m_controller->getDocument()->getCatalog()->getPage(item.pageIndex);
|
||||
QMatrix matrix = createPagePointToDevicePointMatrix(page, placedRect) * baseMatrix;
|
||||
compiledPage->draw(painter, page->getCropBox(), matrix, features);
|
||||
compiledPage->draw(painter, page->getCropBox(), matrix, features, groupInfo.transparency);
|
||||
PDFTextLayoutGetter layoutGetter = m_textLayoutCompiler->getTextLayoutLazy(item.pageIndex);
|
||||
|
||||
// Draw text blocks/text lines, if it is enabled
|
||||
@ -1001,6 +1006,22 @@ PDFWidgetSnapshot PDFDrawWidgetProxy::getSnapshot() const
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
void PDFDrawWidgetProxy::setGroupTransparency(PDFInteger groupIndex, bool drawPaper, PDFReal transparency)
|
||||
{
|
||||
GroupInfo groupInfo;
|
||||
groupInfo.drawPaper = drawPaper;
|
||||
groupInfo.transparency = transparency;
|
||||
|
||||
if (groupInfo == GroupInfo())
|
||||
{
|
||||
m_groupInfos.erase(groupIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_groupInfos[groupIndex] = std::move(groupInfo);
|
||||
}
|
||||
}
|
||||
|
||||
QRect PDFDrawWidgetProxy::getPagesIntersectingRectBoundingBox(QRect rect) const
|
||||
{
|
||||
QRect resultRect;
|
||||
@ -1385,6 +1406,17 @@ void PDFDrawWidgetProxy::updateVerticalScrollbarFromOffset()
|
||||
}
|
||||
}
|
||||
|
||||
PDFDrawWidgetProxy::GroupInfo PDFDrawWidgetProxy::getGroupInfo(int groupIndex) const
|
||||
{
|
||||
auto it = m_groupInfos.find(groupIndex);
|
||||
if (it != m_groupInfos.cend())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return GroupInfo();
|
||||
}
|
||||
|
||||
PDFWidgetAnnotationManager* PDFDrawWidgetProxy::getAnnotationManager() const
|
||||
{
|
||||
return m_widget->getAnnotationManager();
|
||||
|
Reference in New Issue
Block a user