OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PdfReader.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGWIDGET_PDFREADER
15 #define OSGWIDGET_PDFREADER
16 
17 #include <osg/Image>
18 #include <osg/Geode>
19 
20 #include <osgWidget/Export>
21 
22 namespace osgWidget {
23 
24 
27 {
29  {
33  };
34 
36  position(0.0f,0.0f,0.0f),
37  widthVec(1.0f,0.0f,0.0f),
38  heightVec(0.0f,1.0f,0.0f),
39  backgroundColor(1.0f,1.0f,1.0f,1.0f),
41  widthResolution(1024),
42  heightResolution(1024) {}
43 
45  const osg::Vec3& wVec,
46  const osg::Vec3& hVec,
47  const osg::Vec4& bColor,
49  unsigned int wRes=1024,
50  unsigned int hRes=1024):
51  position(pos),
52  widthVec(wVec),
53  heightVec(hVec),
54  backgroundColor(bColor),
55  aspectRatioPolicy(asp),
56  widthResolution(wRes),
57  heightResolution(hRes) {}
58 
62 
64 
66 
67  unsigned int widthResolution;
68  unsigned int heightResolution;
69 
70 };
71 
73 class PdfImage : public osg::Image
74 {
75  public:
76 
78  _backgroundColor(1.0f,1.0f,1.0f,1.0f),
79  _pageNum(0),
80  _nextPageKeyEvent('n'),
81  _previousPageKeyEvent('p') {}
82 
83  void setBackgroundColor(const osg::Vec4& backgroundColor) { _backgroundColor = backgroundColor; }
84  const osg::Vec4& getBackgroundColor() const { return _backgroundColor; }
85 
86  int getPageNum() const { return _pageNum; }
87 
88  virtual int getNumOfPages() = 0;
89 
90  virtual bool page(int pageNum) = 0;
91 
92  bool previous()
93  {
94  return page(_pageNum-1);
95  }
96 
97  bool next()
98  {
99  return page(_pageNum+1);
100  }
101 
102  void setNextPageKeyEvent(int key) { _nextPageKeyEvent = key; }
103  int getNextPageKeyEvent() const { return _nextPageKeyEvent; }
104 
107 
108  protected:
109 
110  virtual ~PdfImage() {}
111 
113 
114  int _pageNum;
117 
118 };
119 
120 
123 {
124  public:
125 
127 
128  PdfReader(const std::string& filename, const GeometryHints& hints = GeometryHints());
129 
130  bool assign(PdfImage* pdfImage, const GeometryHints& hints = GeometryHints());
131 
132  bool open(const std::string& filename, const GeometryHints& hints = GeometryHints());
133 
134  bool page(int pageNum);
135 
136  bool previous();
137 
138  bool next();
139 
140  protected:
141 
143 };
144 
145 }
146 
147 #endif
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)
Definition: PdfReader.h:44
virtual bool page(int pageNum)=0
void setNextPageKeyEvent(int key)
Definition: PdfReader.h:102
int getPreviousPageKeyEvent() const
Definition: PdfReader.h:106
Definition: Box.h:21
#define OSGWIDGET_EXPORT
Definition: Export.h:42
void OSGDB_EXPORT open(std::fstream &fs, const char *filename, std::ios_base::openmode mode)
int getPageNum() const
Definition: PdfReader.h:86
unsigned int widthResolution
Definition: PdfReader.h:67
void setBackgroundColor(const osg::Vec4 &backgroundColor)
Definition: PdfReader.h:83
virtual ~PdfImage()
Definition: PdfReader.h:110
virtual int getNumOfPages()=0
void setPreviousPageKeyEvent(int key)
Definition: PdfReader.h:105
osg::ref_ptr< PdfImage > _pdfImage
Definition: PdfReader.h:142
osg::Vec4 backgroundColor
Definition: PdfReader.h:63
osg::Vec4 _backgroundColor
Definition: PdfReader.h:112
AspectRatioPolicy aspectRatioPolicy
Definition: PdfReader.h:65
int getNextPageKeyEvent() const
Definition: PdfReader.h:103
const osg::Vec4 & getBackgroundColor() const
Definition: PdfReader.h:84
unsigned int heightResolution
Definition: PdfReader.h:68