mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Editor plugin: Building stream
This commit is contained in:
@@ -59,6 +59,10 @@ public:
|
||||
/// \param painter Painter
|
||||
/// \param rect Draw rectangle (usually viewport rectangle of the pdf widget)
|
||||
virtual void drawPostRendering(QPainter* painter, QRect rect) const;
|
||||
|
||||
/// Returns true if drawing of the page content should be suppressed.
|
||||
/// This is used for special purposes, such as rendering edited page content.
|
||||
virtual bool isPageContentDrawSuppressed() const;
|
||||
};
|
||||
|
||||
/// Input interface for handling events. Implementations should react on these events,
|
||||
|
@@ -809,9 +809,19 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::F
|
||||
|
||||
const PDFPage* page = m_controller->getDocument()->getCatalog()->getPage(item.pageIndex);
|
||||
QTransform matrix = QTransform(createPagePointToDevicePointMatrix(page, placedRect)) * baseMatrix;
|
||||
compiledPage->draw(painter, page->getCropBox(), matrix, features, groupInfo.transparency);
|
||||
PDFTextLayoutGetter layoutGetter = m_textLayoutCompiler->getTextLayoutLazy(item.pageIndex);
|
||||
|
||||
bool isPageContentDrawSuppressed = false;
|
||||
for (IDocumentDrawInterface* drawInterface : m_drawInterfaces)
|
||||
{
|
||||
isPageContentDrawSuppressed = isPageContentDrawSuppressed || drawInterface->isPageContentDrawSuppressed();
|
||||
}
|
||||
|
||||
if (!isPageContentDrawSuppressed)
|
||||
{
|
||||
compiledPage->draw(painter, page->getCropBox(), matrix, features, groupInfo.transparency);
|
||||
}
|
||||
|
||||
// Draw text blocks/text lines, if it is enabled
|
||||
if (features.testFlag(PDFRenderer::DebugTextBlocks))
|
||||
{
|
||||
@@ -1629,4 +1639,9 @@ void IDocumentDrawInterface::drawPostRendering(QPainter* painter, QRect rect) co
|
||||
Q_UNUSED(rect);
|
||||
}
|
||||
|
||||
bool IDocumentDrawInterface::isPageContentDrawSuppressed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace pdf
|
||||
|
@@ -333,6 +333,7 @@ PDFPageContentScene::PDFPageContentScene(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_firstFreeId(1),
|
||||
m_isActive(false),
|
||||
m_isPageContentDrawSuppressed(false),
|
||||
m_widget(nullptr),
|
||||
m_manipulator(this, nullptr)
|
||||
{
|
||||
@@ -642,6 +643,11 @@ int PDFPageContentScene::getInputPriority() const
|
||||
return ToolPriority + 1;
|
||||
}
|
||||
|
||||
bool PDFPageContentScene::isPageContentDrawSuppressed() const
|
||||
{
|
||||
return isActive() && m_isPageContentDrawSuppressed;
|
||||
}
|
||||
|
||||
void PDFPageContentScene::drawElements(QPainter* painter,
|
||||
PDFInteger pageIndex,
|
||||
PDFTextLayoutGetter& layoutGetter,
|
||||
@@ -823,6 +829,11 @@ void PDFPageContentScene::onSelectionChanged()
|
||||
Q_EMIT selectionChanged();
|
||||
}
|
||||
|
||||
void PDFPageContentScene::setIsPageContentDrawSuppressed(bool newIsPageContentDrawSuppressed)
|
||||
{
|
||||
m_isPageContentDrawSuppressed = newIsPageContentDrawSuppressed;
|
||||
}
|
||||
|
||||
PDFWidget* PDFPageContentScene::widget() const
|
||||
{
|
||||
return m_widget;
|
||||
|
@@ -561,6 +561,7 @@ public:
|
||||
virtual QString getTooltip() const override;
|
||||
virtual const std::optional<QCursor>& getCursor() const override;
|
||||
virtual int getInputPriority() const override;
|
||||
virtual bool isPageContentDrawSuppressed() const;
|
||||
|
||||
virtual void drawPage(QPainter* painter,
|
||||
PDFInteger pageIndex,
|
||||
@@ -579,6 +580,8 @@ public:
|
||||
const PDFPrecompiledPage* compiledPage,
|
||||
QList<PDFRenderError>& errors) const;
|
||||
|
||||
void setIsPageContentDrawSuppressed(bool newIsPageContentDrawSuppressed);
|
||||
|
||||
signals:
|
||||
/// This signal is emitted when scene has changed (including graphics)
|
||||
void sceneChanged(bool graphicsOnly);
|
||||
@@ -637,6 +640,7 @@ private:
|
||||
|
||||
PDFInteger m_firstFreeId;
|
||||
bool m_isActive;
|
||||
bool m_isPageContentDrawSuppressed;
|
||||
PDFWidget* m_widget;
|
||||
std::vector<std::unique_ptr<PDFPageContentElement>> m_elements;
|
||||
std::optional<QCursor> m_cursor;
|
||||
|
Reference in New Issue
Block a user