PDF4QT/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewwidget.h

170 lines
5.2 KiB
C
Raw Normal View History

2021-03-27 16:06:07 +01:00
// Copyright (C) 2021 Jakub Melka
//
2021-08-10 19:22:56 +02:00
// This file is part of PDF4QT.
2021-03-27 16:06:07 +01:00
//
2021-08-10 19:22:56 +02:00
// PDF4QT is free software: you can redistribute it and/or modify
2021-03-27 16:06:07 +01:00
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
2021-04-30 20:12:10 +02:00
// with the written consent of the copyright owner, any later version.
2021-03-27 16:06:07 +01:00
//
2021-08-10 19:22:56 +02:00
// PDF4QT is distributed in the hope that it will be useful,
2021-03-27 16:06:07 +01:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
2021-08-10 19:22:56 +02:00
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
2021-03-27 16:06:07 +01:00
#ifndef OUTPUTPREVIEWWIDGET_H
#define OUTPUTPREVIEWWIDGET_H
#include "pdftransparencyrenderer.h"
#include <QWidget>
namespace pdfplugin
{
class OutputPreviewWidget : public QWidget
{
Q_OBJECT
private:
using BaseClass = QWidget;
public:
explicit OutputPreviewWidget(QWidget* parent);
enum DisplayMode
{
Separations,
ColorWarningInkCoverage,
ColorWarningRichBlack,
2021-04-05 19:21:45 +02:00
InkCoverage,
ShapeChannel,
OpacityChannel
2021-03-27 16:06:07 +01:00
};
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
/// Clears all widget contents
void clear();
/// Set active image
void setPageImage(QImage image, pdf::PDFFloatBitmapWithColorSpace originalProcessBitmap, QSizeF pageSizeMM);
const pdf::PDFInkMapper* getInkMapper() const;
void setInkMapper(const pdf::PDFInkMapper* inkMapper);
/// Returns page image size hint (ideal size of page image)
QSize getPageImageSizeHint() const;
QColor getAlarmColor() const;
void setAlarmColor(const QColor& alarmColor);
DisplayMode getDisplayMode() const;
void setDisplayMode(const DisplayMode& displayMode);
pdf::PDFColorComponent getInkCoverageLimit() const;
void setInkCoverageLimit(pdf::PDFColorComponent inkCoverageLimit);
pdf::PDFColorComponent getRichBlackLimit() const;
void setRichBlackLimit(pdf::PDFColorComponent richBlackLimit);
2021-03-27 16:06:07 +01:00
protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
2021-03-27 16:06:07 +01:00
private:
QMargins getDrawMargins() const;
QRect getContentRect() const;
QRect getPageImageRect(QRect contentRect) const;
int getInfoBoxWidth() const;
int getInfoBoxContentHorizontalMargin() const;
void buildInfoBoxItems();
void addInfoBoxHeader(QString caption);
void addInfoBoxSeparator();
void addInfoBoxColoredItem(QColor color, QString caption, QString value);
2021-03-29 20:02:30 +02:00
void addInfoBoxColoredRect(QColor color);
2021-03-27 16:06:07 +01:00
2021-04-02 18:51:38 +02:00
struct AlarmImageInfo
{
QImage image;
pdf::PDFColorComponent areaValid = 0.0f;
pdf::PDFColorComponent areaInvalid = 0.0f;
};
2021-04-02 20:20:53 +02:00
struct InkCoverageInfo
{
QImage image;
pdf::PDFColorComponent minValue = 0.0f;
pdf::PDFColorComponent maxValue = 0.0f;
2021-04-03 18:28:34 +02:00
pdf::PDFColorScale colorScale;
2021-04-02 20:20:53 +02:00
};
2021-03-31 19:55:26 +02:00
const std::vector<pdf::PDFColorComponent>& getInkCoverage() const;
2021-04-02 18:51:38 +02:00
const AlarmImageInfo& getAlarmCoverageImage() const;
const AlarmImageInfo& getAlarmRichBlackImage() const;
2021-04-02 20:20:53 +02:00
const InkCoverageInfo& getInkCoverageInfo() const;
2021-04-05 19:21:45 +02:00
const QImage& getShapeImage() const;
const QImage& getOpacityImage() const;
2021-03-31 19:55:26 +02:00
std::vector<pdf::PDFColorComponent> getInkCoverageImpl() const;
2021-04-02 18:51:38 +02:00
AlarmImageInfo getAlarmCoverageImageImpl() const;
AlarmImageInfo getAlarmRichBlackImageImpl() const;
2021-04-02 20:20:53 +02:00
InkCoverageInfo getInkCoverageInfoImpl() const;
2021-04-05 19:21:45 +02:00
QImage getShapeImageImpl() const;
QImage getOpacityImageImpl() const;
2021-03-31 19:55:26 +02:00
2021-03-27 16:06:07 +01:00
enum InfoBoxStyle
{
Header,
Separator,
ColoredItem,
2021-03-29 20:02:30 +02:00
ColorOnly
2021-03-27 16:06:07 +01:00
};
struct InfoBoxItem
{
InfoBoxItem(InfoBoxStyle style, QColor color, QString caption, QString value) :
style(style),
color(color),
caption(caption),
value(value)
{
}
InfoBoxStyle style = InfoBoxStyle::Separator;
QColor color;
QString caption;
QString value;
};
const pdf::PDFInkMapper* m_inkMapper;
DisplayMode m_displayMode;
std::vector<InfoBoxItem> m_infoBoxItems;
QColor m_alarmColor;
std::optional<QPoint> m_imagePointUnderCursor;
pdf::PDFColorComponent m_inkCoverageLimit;
pdf::PDFColorComponent m_richBlackLimit;
2021-03-27 16:06:07 +01:00
2021-03-31 19:55:26 +02:00
mutable pdf::PDFCachedItem<std::vector<pdf::PDFColorComponent>> m_inkCoverageMM;
2021-04-02 18:51:38 +02:00
mutable pdf::PDFCachedItem<AlarmImageInfo> m_alarmCoverageImage;
mutable pdf::PDFCachedItem<AlarmImageInfo> m_alarmRichBlackImage;
2021-04-02 20:20:53 +02:00
mutable pdf::PDFCachedItem<InkCoverageInfo> m_inkCoverageImage;
2021-04-05 19:21:45 +02:00
mutable pdf::PDFCachedItem<QImage> m_opacityMask;
mutable pdf::PDFCachedItem<QImage> m_shapeMask;
2021-03-31 19:55:26 +02:00
2021-03-27 16:06:07 +01:00
QImage m_pageImage;
pdf::PDFFloatBitmapWithColorSpace m_originalProcessBitmap;
QSizeF m_pageSizeMM;
};
} // pdfplugin
#endif // OUTPUTPREVIEWWIDGET_H