2021-03-27 16:06:07 +01:00
|
|
|
// Copyright (C) 2021 Jakub Melka
|
|
|
|
//
|
|
|
|
// This file is part of Pdf4Qt.
|
|
|
|
//
|
|
|
|
// Pdf4Qt is free software: you can redistribute it and/or modify
|
|
|
|
// 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
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Pdf4Qt is distributed in the hope that it will be useful,
|
|
|
|
// 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
|
|
|
|
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#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,
|
|
|
|
InkCoverage
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2021-03-28 19:12:50 +02:00
|
|
|
QColor getAlarmColor() const;
|
|
|
|
void setAlarmColor(const QColor& alarmColor);
|
|
|
|
|
2021-03-27 16:06:07 +01:00
|
|
|
protected:
|
|
|
|
virtual void paintEvent(QPaintEvent* event) override;
|
2021-03-28 19:12:50 +02:00
|
|
|
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-03-31 19:55:26 +02:00
|
|
|
const std::vector<pdf::PDFColorComponent>& getInkCoverage() const;
|
|
|
|
|
|
|
|
std::vector<pdf::PDFColorComponent> getInkCoverageImpl() const;
|
|
|
|
|
2021-03-27 16:06:07 +01:00
|
|
|
enum InfoBoxStyle
|
|
|
|
{
|
|
|
|
Header,
|
|
|
|
Separator,
|
2021-03-28 19:12:50 +02:00
|
|
|
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;
|
2021-03-28 19:12:50 +02:00
|
|
|
QColor m_alarmColor;
|
|
|
|
std::optional<QPoint> m_imagePointUnderCursor;
|
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-03-27 16:06:07 +01:00
|
|
|
QImage m_pageImage;
|
|
|
|
pdf::PDFFloatBitmapWithColorSpace m_originalProcessBitmap;
|
|
|
|
QSizeF m_pageSizeMM;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // pdfplugin
|
|
|
|
|
|
|
|
#endif // OUTPUTPREVIEWWIDGET_H
|