GUI adjustments, display settings

This commit is contained in:
Jakub Melka 2021-03-27 12:18:56 +01:00
parent 39ebe08847
commit 40bbdd531a
5 changed files with 251 additions and 15 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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<double>::of(&QDoubleSpinBox::valueChanged), this, &OutputPreviewDialog::onPaperColorChanged);
connect(ui->bluePaperColorEdit, QOverload<double>::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

View File

@ -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;

View File

@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>852</width>
<height>503</height>
<width>955</width>
<height>677</height>
</rect>
</property>
<property name="windowTitle">
<string>Output Preview</string>
</property>
<layout class="QVBoxLayout" name="outputPreviewDialogLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="3,1">
<item>
<widget class="QFrame" name="frame">
@ -145,6 +145,144 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="displayGroupBox">
<property name="title">
<string>Display</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="displayImagesCheckBox">
<property name="text">
<string>Images</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="displayTextCheckBox">
<property name="text">
<string>Text</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="displayVectorGraphicsCheckBox">
<property name="text">
<string>Vector graphics</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="displayShadingCheckBox">
<property name="text">
<string>Shading patterns</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="displayTilingPatternsCheckBox">
<property name="text">
<string>Tiling patterns</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="displayModeComboBox"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="colorWarningsGroupBox">
<property name="title">
<string>Color Warnings</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QLabel" name="alarmColorLabel">
<property name="text">
<string>Alarm color</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="inkCoverageLimitEdit">
<property name="suffix">
<string> %</string>
</property>
<property name="maximum">
<double>1000.000000000000000</double>
</property>
<property name="singleStep">
<double>10.000000000000000</double>
</property>
<property name="value">
<double>300.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="coverageLimitLabel">
<property name="text">
<string>Coverage limit</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="alarmColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="richBlackLimitEdit">
<property name="suffix">
<string> %</string>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="richBlackLabel">
<property name="text">
<string>Rich black limit</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="inksGroupBox">
<property name="title">
@ -170,7 +308,7 @@
</item>
</layout>
</item>
<item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>