/usr/include/osgWidget/PdfReader is in libopenscenegraph-3.4-dev 3.4.0+dfsg1-4+b3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library 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
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGWIDGET_PDFREADER
#define OSGWIDGET_PDFREADER
#include <osg/Image>
#include <osg/Geode>
#include <osgWidget/Export>
namespace osgWidget {
/** Hints structure that can be passed to PdfReader and VncClient classes to help guide them on what geometry to build.*/
struct GeometryHints
{
enum AspectRatioPolicy
{
RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO,
RESIZE_WIDTH_TO_MAINTAINCE_ASPECT_RATIO,
IGNORE_DOCUMENT_ASPECT_RATIO
};
GeometryHints():
position(0.0f,0.0f,0.0f),
widthVec(1.0f,0.0f,0.0f),
heightVec(0.0f,1.0f,0.0f),
backgroundColor(1.0f,1.0f,1.0f,1.0f),
aspectRatioPolicy(RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO),
widthResolution(1024),
heightResolution(1024) {}
GeometryHints(const osg::Vec3& pos,
const osg::Vec3& wVec,
const osg::Vec3& hVec,
const osg::Vec4& bColor,
AspectRatioPolicy asp=RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO,
unsigned int wRes=1024,
unsigned int hRes=1024):
position(pos),
widthVec(wVec),
heightVec(hVec),
backgroundColor(bColor),
aspectRatioPolicy(asp),
widthResolution(wRes),
heightResolution(hRes) {}
osg::Vec3 position;
osg::Vec3 widthVec;
osg::Vec3 heightVec;
osg::Vec4 backgroundColor;
AspectRatioPolicy aspectRatioPolicy;
unsigned int widthResolution;
unsigned int heightResolution;
};
/** Pure virtual base class for interfacing with implementation of PDF reader.*/
class PdfImage : public osg::Image
{
public:
PdfImage():
_backgroundColor(1.0f,1.0f,1.0f,1.0f),
_pageNum(0),
_nextPageKeyEvent('n'),
_previousPageKeyEvent('p') {}
void setBackgroundColor(const osg::Vec4& backgroundColor) { _backgroundColor = backgroundColor; }
const osg::Vec4& getBackgroundColor() const { return _backgroundColor; }
int getPageNum() const { return _pageNum; }
virtual int getNumOfPages() = 0;
virtual bool page(int pageNum) = 0;
bool previous()
{
return page(_pageNum-1);
}
bool next()
{
return page(_pageNum+1);
}
void setNextPageKeyEvent(int key) { _nextPageKeyEvent = key; }
int getNextPageKeyEvent() const { return _nextPageKeyEvent; }
void setPreviousPageKeyEvent(int key) { _previousPageKeyEvent = key; }
int getPreviousPageKeyEvent() const { return _previousPageKeyEvent; }
protected:
virtual ~PdfImage() {}
osg::Vec4 _backgroundColor;
int _pageNum;
int _nextPageKeyEvent;
int _previousPageKeyEvent;
};
/** Convenience class that provides a interactive quad that can be placed directly in the scene.*/
class OSGWIDGET_EXPORT PdfReader : public osg::Geode
{
public:
PdfReader() {}
PdfReader(const std::string& filename, const GeometryHints& hints = GeometryHints());
bool assign(PdfImage* pdfImage, const GeometryHints& hints = GeometryHints());
bool open(const std::string& filename, const GeometryHints& hints = GeometryHints());
bool page(int pageNum);
bool previous();
bool next();
protected:
osg::ref_ptr<PdfImage> _pdfImage;
};
}
#endif
|