2021-04-20 19:33:54 +02:00
|
|
|
// Copyright (C) 2021 Jakub Melka
|
|
|
|
//
|
2021-08-10 19:22:56 +02:00
|
|
|
// This file is part of PDF4QT.
|
2021-04-20 19:33:54 +02:00
|
|
|
//
|
2021-08-10 19:22:56 +02:00
|
|
|
// PDF4QT is free software: you can redistribute it and/or modify
|
2021-04-20 19:33:54 +02: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-04-20 19:33:54 +02:00
|
|
|
//
|
2021-08-10 19:22:56 +02:00
|
|
|
// PDF4QT is distributed in the hope that it will be useful,
|
2021-04-20 19:33:54 +02: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-04-20 19:33:54 +02:00
|
|
|
|
|
|
|
#ifndef INKCOVERAGEDIALOG_H
|
|
|
|
#define INKCOVERAGEDIALOG_H
|
|
|
|
|
|
|
|
#include "pdfdocument.h"
|
|
|
|
#include "pdfdrawwidget.h"
|
|
|
|
#include "pdftransparencyrenderer.h"
|
|
|
|
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
|
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class InkCoverageDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace pdfplugin
|
|
|
|
{
|
|
|
|
class InkCoverageStatisticsModel;
|
|
|
|
|
|
|
|
using ChannelCoverageInfo = pdf::PDFInkCoverageCalculator::InkCoverageChannelInfo;
|
|
|
|
using CoverageInfo = std::vector<ChannelCoverageInfo>;
|
|
|
|
|
|
|
|
struct InkCoverageResults
|
|
|
|
{
|
|
|
|
std::vector<CoverageInfo> pageInfo;
|
|
|
|
CoverageInfo sumInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InkCoverageDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
using BaseClass = QDialog;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit InkCoverageDialog(const pdf::PDFDocument* document, pdf::PDFWidget* widget, QWidget* parent);
|
|
|
|
virtual ~InkCoverageDialog() override;
|
|
|
|
|
|
|
|
void updateInkCoverage();
|
|
|
|
|
|
|
|
virtual void closeEvent(QCloseEvent* event) override;
|
|
|
|
|
|
|
|
virtual void accept() override;
|
|
|
|
virtual void reject() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::InkCoverageDialog* ui;
|
|
|
|
|
|
|
|
static constexpr int RESOLUTION = 1920;
|
|
|
|
|
|
|
|
void onInkCoverageCalculated();
|
|
|
|
bool isInkCoverageCalculated() const;
|
|
|
|
|
|
|
|
pdf::PDFInkMapper m_inkMapper;
|
|
|
|
const pdf::PDFDocument* m_document;
|
|
|
|
pdf::PDFWidget* m_widget;
|
|
|
|
InkCoverageStatisticsModel* m_model;
|
|
|
|
|
|
|
|
QFuture<InkCoverageResults> m_future;
|
|
|
|
QFutureWatcher<InkCoverageResults>* m_futureWatcher;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InkCoverageStatisticsModel : public QAbstractItemModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
using BaseClass = QAbstractItemModel;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit InkCoverageStatisticsModel(QObject* parent);
|
|
|
|
|
|
|
|
enum EStandardColumn
|
|
|
|
{
|
|
|
|
StandardColumnPageIndex,
|
|
|
|
LastStandardColumn
|
|
|
|
};
|
|
|
|
|
|
|
|
enum EChannelColumn
|
|
|
|
{
|
|
|
|
ChannelColumnColorant,
|
|
|
|
ChannelColumnCoverageArea,
|
|
|
|
ChannelColumnCoverageRatio,
|
|
|
|
LastChannelColumn
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual QModelIndex index(int row, int column, const QModelIndex& parent) const override;
|
|
|
|
virtual QModelIndex parent(const QModelIndex& child) const override;
|
|
|
|
virtual int rowCount(const QModelIndex& parent) const override;
|
|
|
|
virtual int columnCount(const QModelIndex& parent) const override;
|
|
|
|
virtual QVariant data(const QModelIndex& index, int role) const override;
|
|
|
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
|
|
|
|
|
|
|
void setInkCoverageResults(InkCoverageResults inkCoverageResults);
|
|
|
|
int getChannelCount() const;
|
|
|
|
EChannelColumn getChannelColumn(int index) const;
|
|
|
|
int getChannelIndex(int index) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
InkCoverageResults m_inkCoverageResults;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace pdfplugin
|
|
|
|
|
|
|
|
#endif // INKCOVERAGEDIALOG_H
|