From 40bbdd531a3fb87445e10f330025cfc8795de857 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Sat, 27 Mar 2021 12:18:56 +0100 Subject: [PATCH] GUI adjustments, display settings --- Pdf4QtLib/sources/pdftransparencyrenderer.cpp | 47 ++++++ Pdf4QtLib/sources/pdftransparencyrenderer.h | 28 +++- .../outputpreviewdialog.cpp | 29 +++- .../OutputPreviewPlugin/outputpreviewdialog.h | 14 +- .../outputpreviewdialog.ui | 148 +++++++++++++++++- 5 files changed, 251 insertions(+), 15 deletions(-) diff --git a/Pdf4QtLib/sources/pdftransparencyrenderer.cpp b/Pdf4QtLib/sources/pdftransparencyrenderer.cpp index 49ee6f7..4c1dce8 100644 --- a/Pdf4QtLib/sources/pdftransparencyrenderer.cpp +++ b/Pdf4QtLib/sources/pdftransparencyrenderer.cpp @@ -1169,6 +1169,53 @@ void PDFTransparencyRenderer::clearColor(const PDFColor& color) } } +bool PDFTransparencyRenderer::isContentKindSuppressed(ContentKind kind) const +{ + switch (kind) + { + case ContentKind::Shapes: + if (!m_settings.flags.testFlag(PDFTransparencyRendererSettings::DisplayVectorGraphics)) + { + return true; + } + break; + + case ContentKind::Text: + if (!m_settings.flags.testFlag(PDFTransparencyRendererSettings::DisplayText)) + { + return true; + } + break; + + case ContentKind::Images: + if (!m_settings.flags.testFlag(PDFTransparencyRendererSettings::DisplayImages)) + { + return true; + } + break; + + case ContentKind::Shading: + if (!m_settings.flags.testFlag(PDFTransparencyRendererSettings::DisplayShadings)) + { + return true; + } + break; + + case ContentKind::Tiling: + if (!m_settings.flags.testFlag(PDFTransparencyRendererSettings::DisplayTilingPatterns)) + { + return true; + } + break; + + default: + Q_ASSERT(false); + break; + } + + return BaseClass::isContentKindSuppressed(kind); +} + void PDFTransparencyRenderer::performPixelSampling(const PDFReal shape, const PDFReal opacity, const uint8_t shapeChannel, diff --git a/Pdf4QtLib/sources/pdftransparencyrenderer.h b/Pdf4QtLib/sources/pdftransparencyrenderer.h index a7d8481..3bca7b9 100644 --- a/Pdf4QtLib/sources/pdftransparencyrenderer.h +++ b/Pdf4QtLib/sources/pdftransparencyrenderer.h @@ -569,30 +569,45 @@ struct PDFTransparencyRendererSettings /// Use precise path sampler, which uses paths instead /// of filling polygon. - PrecisePathSampler = 0x0001, + PrecisePathSampler = 0x0001, /// Use multithreading when painter paths are painted? /// Multithreading is used to - MultithreadedPathSampler = 0x0002, + MultithreadedPathSampler = 0x0002, /// When using CMYK process color space, transfer spot /// colors to the CMYK color space. - SeparationSimulation = 0x0004, + SeparationSimulation = 0x0004, /// Use active color mask (so we can clear channels, /// which are not active) - ActiveColorMask = 0x0008, + ActiveColorMask = 0x0008, /// Use smooth image transform, if it is possible. For /// images, which doesn't have Interpolate set to true, /// fast image transformation is used. - SmoothImageTransformation = 0x0010, + SmoothImageTransformation = 0x0010, + + /// Display images (if this flag is false, images aren't processed) + DisplayImages = 0x0020, + + /// Display text (if this flag is false, text isnn't processed) + DisplayText = 0x0040, + + /// Display vector graphics (if this flag is false, vector graphics isn't processed) + DisplayVectorGraphics = 0x0080, + + /// Display shading patterns (if this flag is false, shading patterns aren't processed) + DisplayShadings = 0x0100, + + /// Display tiling patterns (if this flag is false, tiling patterns aren't processed) + DisplayTilingPatterns = 0x0200, }; Q_DECLARE_FLAGS(Flags, Flag) /// Flags - Flags flags = None; + Flags flags = DisplayImages | DisplayText | DisplayVectorGraphics | DisplayShadings | DisplayTilingPatterns; /// Active color mask uint32_t activeColorMask = PDFPixelFormat::getAllColorsMask(); @@ -656,6 +671,7 @@ public: /// \param color Color void clearColor(const PDFColor& color); + virtual bool isContentKindSuppressed(ContentKind kind) const override; virtual void performPathPainting(const QPainterPath& path, bool stroke, bool fill, bool text, Qt::FillRule fillRule) override; virtual bool performPathPaintingUsingShading(const QPainterPath& path, bool stroke, bool fill, const PDFShadingPattern* shadingPattern) override; virtual void performFinishPathPainting() override; diff --git a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.cpp b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.cpp index cd3ecf3..d77cec1 100644 --- a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.cpp +++ b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.cpp @@ -44,6 +44,12 @@ OutputPreviewDialog::OutputPreviewDialog(const pdf::PDFDocument* document, pdf:: ui->pageIndexScrollBar->setValue(1); ui->pageIndexScrollBar->setMaximum(int(document->getCatalog()->getPageCount())); + ui->displayModeComboBox->addItem(tr("Separations"), Separations); + ui->displayModeComboBox->addItem(tr("Color Warnings | Ink Coverage"), ColorWarningInkCoverage); + ui->displayModeComboBox->addItem(tr("Color Warnings | Rich Black"), ColorWarningRichBlack); + ui->displayModeComboBox->addItem(tr("Ink Coverage"), InkCoverage); + ui->displayModeComboBox->setCurrentIndex(0); + m_inkMapper.createSpotColors(ui->simulateSeparationsCheckBox->isChecked()); connect(ui->simulateSeparationsCheckBox, &QCheckBox::clicked, this, &OutputPreviewDialog::onSimulateSeparationsChecked); connect(ui->simulatePaperColorCheckBox, &QCheckBox::clicked, this, &OutputPreviewDialog::onSimulatePaperColorChecked); @@ -51,6 +57,11 @@ OutputPreviewDialog::OutputPreviewDialog(const pdf::PDFDocument* document, pdf:: connect(ui->greenPaperColorEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &OutputPreviewDialog::onPaperColorChanged); connect(ui->bluePaperColorEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &OutputPreviewDialog::onPaperColorChanged); connect(ui->pageIndexScrollBar, &QScrollBar::valueChanged, this, &OutputPreviewDialog::updatePageImage); + connect(ui->displayImagesCheckBox, &QCheckBox::clicked, this, &OutputPreviewDialog::updatePageImage); + connect(ui->displayShadingCheckBox, &QCheckBox::clicked, this, &OutputPreviewDialog::updatePageImage); + connect(ui->displayTextCheckBox, &QCheckBox::clicked, this, &OutputPreviewDialog::updatePageImage); + connect(ui->displayTilingPatternsCheckBox, &QCheckBox::clicked, this, &OutputPreviewDialog::updatePageImage); + connect(ui->displayVectorGraphicsCheckBox, &QCheckBox::clicked, this, &OutputPreviewDialog::updatePageImage); connect(ui->inksTreeWidget->model(), &QAbstractItemModel::dataChanged, this, &OutputPreviewDialog::onInksChanged); updatePageImage(); @@ -238,11 +249,18 @@ void OutputPreviewDialog::updatePageImage() paperColor[2] = ui->bluePaperColorEdit->value(); } + pdf::PDFTransparencyRendererSettings::Flags flags = pdf::PDFTransparencyRendererSettings::None; + flags.setFlag(pdf::PDFTransparencyRendererSettings::DisplayImages, ui->displayImagesCheckBox->isChecked()); + flags.setFlag(pdf::PDFTransparencyRendererSettings::DisplayText, ui->displayTextCheckBox->isChecked()); + flags.setFlag(pdf::PDFTransparencyRendererSettings::DisplayVectorGraphics, ui->displayVectorGraphicsCheckBox->isChecked()); + flags.setFlag(pdf::PDFTransparencyRendererSettings::DisplayShadings, ui->displayShadingCheckBox->isChecked()); + flags.setFlag(pdf::PDFTransparencyRendererSettings::DisplayTilingPatterns, ui->displayTilingPatternsCheckBox->isChecked()); + m_inkMapperForRendering = m_inkMapper; QSize renderSize = ui->imageLabel->size(); - auto renderImage = [this, page, renderSize, paperColor, activeColorMask]() -> RenderedImage + auto renderImage = [this, page, renderSize, paperColor, activeColorMask, flags]() -> RenderedImage { - return renderPage(page, renderSize, paperColor, activeColorMask); + return renderPage(page, renderSize, paperColor, activeColorMask, flags); }; m_future = QtConcurrent::run(renderImage); @@ -251,7 +269,11 @@ void OutputPreviewDialog::updatePageImage() m_futureWatcher->setFuture(m_future); } -OutputPreviewDialog::RenderedImage OutputPreviewDialog::renderPage(const pdf::PDFPage* page, QSize renderSize, pdf::PDFRGB paperColor, uint32_t activeColorMask) +OutputPreviewDialog::RenderedImage OutputPreviewDialog::renderPage(const pdf::PDFPage* page, + QSize renderSize, + pdf::PDFRGB paperColor, + uint32_t activeColorMask, + pdf::PDFTransparencyRendererSettings::Flags additionalFlags) { RenderedImage result; @@ -266,6 +288,7 @@ OutputPreviewDialog::RenderedImage OutputPreviewDialog::renderPage(const pdf::PD } pdf::PDFTransparencyRendererSettings settings; + settings.flags = additionalFlags; // Jakub Melka: debug is very slow, use multithreading #ifdef QT_DEBUG diff --git a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.h b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.h index d51c7cb..16110c8 100644 --- a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.h +++ b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.h @@ -51,6 +51,14 @@ public: private: + enum DisplayMode + { + Separations, + ColorWarningInkCoverage, + ColorWarningRichBlack, + InkCoverage + }; + void updateInks(); void updatePaperColorWidgets(); @@ -67,7 +75,11 @@ private: void updatePageImage(); void onPageImageRendered(); - RenderedImage renderPage(const pdf::PDFPage* page, QSize renderSize, pdf::PDFRGB paperColor, uint32_t activeColorMask); + RenderedImage renderPage(const pdf::PDFPage* page, + QSize renderSize, + pdf::PDFRGB paperColor, + uint32_t activeColorMask, + pdf::PDFTransparencyRendererSettings::Flags additionalFlags); bool isRenderingDone() const; Ui::OutputPreviewDialog* ui; diff --git a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.ui b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.ui index 6acd91e..66a345f 100644 --- a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.ui +++ b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.ui @@ -6,15 +6,15 @@ 0 0 - 852 - 503 + 955 + 677 Output Preview - - + + @@ -145,6 +145,144 @@ + + + + Display + + + + + + Images + + + true + + + + + + + Text + + + true + + + + + + + Vector graphics + + + true + + + + + + + Shading patterns + + + true + + + + + + + Tiling patterns + + + Ctrl+S + + + true + + + + + + + Qt::Horizontal + + + + + + + + + + + + + Color Warnings + + + + + + Alarm color + + + + + + + % + + + 1000.000000000000000 + + + 10.000000000000000 + + + 300.000000000000000 + + + + + + + Coverage limit + + + + + + + + + + + + + + % + + + 100.000000000000000 + + + 10.000000000000000 + + + + + + + Rich black limit + + + + + + @@ -170,7 +308,7 @@ - + Qt::Horizontal