6 #ifndef GMSHPOPPLERWRAPPER_PDF_H
7 #define GMSHPOPPLERWRAPPER_PDF_H
9 #include "GmshConfig.h"
14 #if defined(HAVE_POPPLER)
17 #include <poppler/cpp/poppler-document.h>
18 #include <poppler/cpp/poppler-page.h>
19 #include <poppler/cpp/poppler-image.h>
20 #if defined(HAVE_OPENGL)
21 #if defined(__APPLE__) || defined(HAVE_OPENGL_GL_H)
22 #include <OpenGL/gl.h>
28 class gmshPopplerWrapper {
30 static int _currentPage;
31 static poppler::document *_currentDoc;
32 static gmshPopplerWrapper *_instance;
33 static std::map<int, std::pair<GModel *, std::string> > _macros;
35 #if defined(HAVE_OPENGL)
36 static std::map<int, GLuint> _pages2textures;
40 static gmshPopplerWrapper *instance();
41 static int loadFromFile(
const std::string &file_name,
42 const std::string &owner_password = std::string(),
43 const std::string &user_password = std::string());
44 static int width() {
return _w; }
45 static int height() {
return _h; }
46 static int getNumPages();
48 static void setMacroForPages(std::vector<int> &is,
const std::string &s,
53 _macros[-1] = std::make_pair(gm,
"NULL");
58 for(
size_t i = 0; i < is.size(); i++)
59 _macros[is[i]] = std::make_pair(gmNew, o);
64 static void setCurrentPage(
int num)
67 if(_currentPage >= getNumPages()) _currentPage = getNumPages() - 1;
68 if(_currentPage < 0) _currentPage = 0;
70 auto it = _macros.find(_currentPage);
71 if(it == _macros.end()) it = _macros.find(-1);
72 if(it != _macros.end()) {
76 if(it->second.second !=
"NULL")
MergeFile(it->second.second,
true);
77 it->second.first->setVisibility(1);
81 static int getCurrentPage() {
return _currentPage; }
82 static void setCurrentPageUp()
85 if(_currentPage >= getNumPages()) _currentPage = getNumPages() - 1;
88 static void setCurrentPageDown()
91 if(_currentPage < 0) _currentPage = 0;
94 #if defined(HAVE_OPENGL)
95 static GLuint getTextureForPage(
double xres,
double yres);