Object stastistics (first part)

This commit is contained in:
Jakub Melka
2021-06-18 19:06:11 +02:00
parent 7264a45e30
commit b8464ed4fa
18 changed files with 530 additions and 26 deletions

View File

@@ -35,14 +35,18 @@ CONFIG += c++11
SOURCES += \
objectinspectordialog.cpp \
objectinspectorplugin.cpp \
objectstatisticsdialog.cpp \
objectviewerwidget.cpp \
pdfobjectinspectortreeitemmodel.cpp
pdfobjectinspectortreeitemmodel.cpp \
statisticsgraphwidget.cpp
HEADERS += \
objectinspectordialog.h \
objectinspectorplugin.h \
objectstatisticsdialog.h \
objectviewerwidget.h \
pdfobjectinspectortreeitemmodel.h
pdfobjectinspectortreeitemmodel.h \
statisticsgraphwidget.h
CONFIG += force_debug_info
@@ -54,4 +58,6 @@ RESOURCES += \
FORMS += \
objectinspectordialog.ui \
objectviewerwidget.ui
objectstatisticsdialog.ui \
objectviewerwidget.ui \
statisticsgraphwidget.ui

View File

@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/pdfplugins/objectinspector">
<file>object-inspector.svg</file>
<file>object-statistics.svg</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="30mm"
height="30mm"
viewBox="0 0 30 30"
version="1.1"
id="svg8"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
sodipodi:docname="object-statistics.svg">
<defs
id="defs2">
<inkscape:path-effect
effect="spiro"
id="path-effect831"
is_visible="true" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.919596"
inkscape:cx="110.52031"
inkscape:cy="57.025756"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="3840"
inkscape:window-height="2035"
inkscape:window-x="-13"
inkscape:window-y="-13"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
<dc:creator>
<cc:Agent>
<dc:title>Jakub Melka</dc:title>
</cc:Agent>
</dc:creator>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-267)">
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 11.646391,283.58184 v 0 0"
id="path837"
inkscape:connector-curvature="0" />
<path
style="opacity:1;fill:#be0000;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
id="path859"
sodipodi:type="arc"
sodipodi:cx="15.239737"
sodipodi:cy="282.52869"
sodipodi:rx="12"
sodipodi:ry="12"
sodipodi:start="0"
sodipodi:end="0.78539816"
d="m 27.239737,282.52869 a 12,12 0 0 1 -3.514719,8.48528 l -8.485281,-8.48528 z" />
<path
style="opacity:1;fill:#0000a9;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
id="path861"
sodipodi:type="arc"
sodipodi:cx="13.936797"
sodipodi:cy="283.29706"
sodipodi:rx="12"
sodipodi:ry="12"
sodipodi:start="0.87266463"
sodipodi:end="2.3561945"
d="M 21.650248,292.48959 A 12,12 0 0 1 5.4515157,291.78234 l 8.4852813,-8.48528 z" />
<path
style="opacity:1;fill:#cdc800;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
id="path865"
sodipodi:type="arc"
sodipodi:cx="13.201805"
sodipodi:cy="281.00259"
sodipodi:rx="12"
sodipodi:ry="12"
sodipodi:start="2.443461"
sodipodi:end="4.7996554"
d="M 4.0092714,288.71604 A 12,12 0 0 1 2.5576751,275.46161 12,12 0 0 1 14.247674,269.04826 l -1.045869,11.95433 z" />
<path
style="opacity:1;fill:#00be00;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
id="path867"
sodipodi:type="arc"
sodipodi:cx="15.167545"
sodipodi:cy="281.00259"
sodipodi:rx="12"
sodipodi:ry="12"
sodipodi:start="4.8869219"
sodipodi:end="6.1959188"
d="m 17.251323,269.1849 a 12,12 0 0 1 9.870559,10.77182 l -11.954337,1.04587 z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -22,6 +22,7 @@
#include "pdfdrawwidget.h"
#include "objectinspectordialog.h"
#include "objectstatisticsdialog.h"
#include <QAction>
@@ -30,7 +31,8 @@ namespace pdfplugin
ObjectInspectorPlugin::ObjectInspectorPlugin() :
pdf::PDFPlugin(nullptr),
m_objectInspectorAction(nullptr)
m_objectInspectorAction(nullptr),
m_objectStatisticsAction(nullptr)
{
}
@@ -47,6 +49,12 @@ void ObjectInspectorPlugin::setWidget(pdf::PDFWidget* widget)
connect(m_objectInspectorAction, &QAction::triggered, this, &ObjectInspectorPlugin::onObjectInspectorTriggered);
m_objectStatisticsAction = new QAction(QIcon(":/pdfplugins/objectinspector/object-statistics.svg"), tr("Object Statistics"), this);
m_objectStatisticsAction->setCheckable(false);
m_objectStatisticsAction->setObjectName("actionObjectInspector_ObjectStatistics");
connect(m_objectStatisticsAction, &QAction::triggered, this, &ObjectInspectorPlugin::onObjectStatisticsTriggered);
updateActions();
}
@@ -67,7 +75,7 @@ void ObjectInspectorPlugin::setDocument(const pdf::PDFModifiedDocument& document
std::vector<QAction*> ObjectInspectorPlugin::getActions() const
{
return { m_objectInspectorAction };
return { m_objectInspectorAction, m_objectStatisticsAction };
}
void ObjectInspectorPlugin::onObjectInspectorTriggered()
@@ -77,9 +85,16 @@ void ObjectInspectorPlugin::onObjectInspectorTriggered()
dialog.exec();
}
void ObjectInspectorPlugin::onObjectStatisticsTriggered()
{
ObjectStatisticsDialog dialog(m_document, m_widget);
dialog.exec();
}
void ObjectInspectorPlugin::updateActions()
{
m_objectInspectorAction->setEnabled(m_widget && m_document);
m_objectStatisticsAction->setEnabled(m_widget && m_document);
}
}

View File

@@ -43,10 +43,12 @@ public:
private:
void onObjectInspectorTriggered();
void onObjectStatisticsTriggered();
void updateActions();
QAction* m_objectInspectorAction;
QAction* m_objectStatisticsAction;
};
} // namespace pdfplugin

View File

@@ -0,0 +1,41 @@
// 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
// with the written consent of the copyright owner, 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/>.
#include "objectstatisticsdialog.h"
#include "ui_objectstatisticsdialog.h"
namespace pdfplugin
{
ObjectStatisticsDialog::ObjectStatisticsDialog(const pdf::PDFDocument* document, QWidget *parent) :
QDialog(parent),
ui(new Ui::ObjectStatisticsDialog),
m_document(document)
{
ui->setupUi(this);
pdf::PDFObjectClassifier classifier;
classifier.classify(document);
m_statistics = classifier.calculateStatistics(document);
}
ObjectStatisticsDialog::~ObjectStatisticsDialog()
{
delete ui;
}
} // namespace pdfplugin

View File

@@ -0,0 +1,56 @@
// 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
// with the written consent of the copyright owner, 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 OBJECTSTATISTICSDIALOG_H
#define OBJECTSTATISTICSDIALOG_H
#include "pdfdocument.h"
#include "pdfobjectutils.h"
#include <QDialog>
namespace Ui
{
class ObjectStatisticsDialog;
}
namespace pdfplugin
{
class ObjectStatisticsDialog : public QDialog
{
Q_OBJECT
public:
explicit ObjectStatisticsDialog(const pdf::PDFDocument* document, QWidget* parent);
virtual ~ObjectStatisticsDialog() override;
private:
Ui::ObjectStatisticsDialog* ui;
enum StatisticsType
{
};
const pdf::PDFDocument* m_document;
pdf::PDFObjectClassifier::Statistics m_statistics;
};
} // namespace pdfplugin
#endif // OBJECTSTATISTICSDIALOG_H

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ObjectStatisticsDialog</class>
<widget class="QDialog" name="ObjectStatisticsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>924</width>
<height>504</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
<item>
<widget class="pdfplugin::StatisticsGraphWidget" name="graphWidget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>pdfplugin::StatisticsGraphWidget</class>
<extends>QWidget</extends>
<header>StatisticsGraphWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,36 @@
// 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
// with the written consent of the copyright owner, 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/>.
#include "statisticsgraphwidget.h"
#include "ui_statisticsgraphwidget.h"
namespace pdfplugin
{
StatisticsGraphWidget::StatisticsGraphWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::StatisticsGraphWidget)
{
ui->setupUi(this);
}
StatisticsGraphWidget::~StatisticsGraphWidget()
{
delete ui;
}
} // namespace pdfplugin

View File

@@ -0,0 +1,45 @@
// 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
// with the written consent of the copyright owner, 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 STATISTICSGRAPHWIDGET_H
#define STATISTICSGRAPHWIDGET_H
#include <QWidget>
namespace Ui
{
class StatisticsGraphWidget;
}
namespace pdfplugin
{
class StatisticsGraphWidget : public QWidget
{
Q_OBJECT
public:
explicit StatisticsGraphWidget(QWidget* parent);
virtual ~StatisticsGraphWidget() override;
private:
Ui::StatisticsGraphWidget* ui;
};
} // namespace pdfplugin
#endif // STATISTICSGRAPHWIDGET_H

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StatisticsGraphWidget</class>
<widget class="QWidget" name="StatisticsGraphWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<resources/>
<connections/>
</ui>