-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpdfwidget.h
More file actions
82 lines (68 loc) · 1.57 KB
/
pdfwidget.h
File metadata and controls
82 lines (68 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef PDFWIDGET_H
#define PDFWIDGET_H
#include <QtOpenGL/QGLWidget>
#include <poppler/qt4/poppler-qt4.h>
#include <QThread>
#include <QList>
#ifndef DEFMAXTEXTURES
#define DEFMAXTEXTURES 50
#endif
class pdfLoader;
class pdfWidget : public QGLWidget
{
Q_OBJECT
public:
explicit pdfWidget(QWidget *parent = 0);
~pdfWidget();
int pageCount();
int pageNumber();
int pageWidth();
int pageHeight();
void setClearColor(const QColor &c);
void setMaxTextures(unsigned);
signals:
void readyGL();
void pdfLoaded(QString name);
void readyLoad(Poppler::Document *pdf);
public slots:
void loadPDF(QString pdfName);
void scalePDF(double scale);
void rotatePDF(double angle);
void changePage(int page);
protected:
void paintGL();
void resizeGL(int w, int h);
void initializeGL();
private slots:
void pageLoaded(int page, QImage img, unsigned w, unsigned h);
private:
void createTex(unsigned pnum);
Poppler::Document *pdf;
int page;
double scale;
double rotation;
struct PageData {
bool valid;
bool activeTex;
unsigned width;
unsigned height;
GLuint texture;
QImage img;
} *pages;
QThread worker;
pdfLoader *loader;
QList<unsigned> activeTexs;
unsigned maxTextures, curTextures;
};
class pdfLoader : public QObject
{
Q_OBJECT
public:
pdfLoader(QObject *parent = 0);
bool stop;
public slots:
void loadPDF(Poppler::Document *pdf);
signals:
void pageLoaded(int page, QImage, unsigned, unsigned);
};
#endif // PDFWIDGET_H