Repository navigation
Expand file tree
/
Copy pathnsrrenderrequest.h
More file actions
332 lines (295 loc) · 7.83 KB
/
Copy pathnsrrenderrequest.h
File metadata and controls
332 lines (295 loc) · 7.83 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
#ifndef __NSRRENDERREQUEST_H__
#define __NSRRENDERREQUEST_H__
/**
* @file nsrrenderrequest.h
* @author Alexander Saprykin
* @brief Rendering request
*/
#include "nsrabstractdocument.h"
#include "nsrcroppads.h"
#include "nsrreadercore_global.h"
#include <QString>
#include <qmath.h>
/**
* @class NSRRenderRequest nsrrenderrequest.h
* @brief Rendering request class
*
* Rendering request is an input data for NSR rendering engine. It
* describes how engine should render page from the file. Rendering
* request can be of different types, i.e. ordinary page or thumbnail.
* Engine processes requests through queue one by one.
* Rendering reason defines the source of the request. Different reasons
* affect rendering in different threads.
* By default #NSR_RENDER_TYPE_PAGE is used.
* Thumbnails are always rendered with both image and text, with autocrop
* and inverted colors disabled, zoomed to specified screen width.
*/
class NSRREADERCORE_SHARED NSRRenderRequest
{
Q_ENUMS (NSRRenderReason)
Q_ENUMS (NSRRenderType)
public:
/** Rendering reason */
enum NSRRenderReason {
NSR_RENDER_REASON_NONE = 0, /**< Empty reason */
NSR_RENDER_REASON_NAVIGATION = 1, /**< Navigation or page selection */
NSR_RENDER_REASON_SETTINGS = 2, /**< Some settings have been changed */
NSR_RENDER_REASON_ZOOM = 3, /**< Zoom operation */
NSR_RENDER_REASON_ZOOM_TO_WIDTH = 4, /**< Zoom to screen width */
NSR_RENDER_REASON_ROTATION = 5, /**< Page rotation */
NSR_RENDER_REASON_PRELOAD = 6, /**< Preload page ahead */
NSR_RENDER_REASON_THUMBNAIL = 7 /**< Thumbnail rendering */
};
/** Request type */
enum NSRRenderType {
NSR_RENDER_TYPE_PAGE = 1, /**< Render as common page */
NSR_RENDER_TYPE_THUMBNAIL = 2 /**< Render as thumbnail, both image and text */
};
/**
* @brief Constructor
*/
NSRRenderRequest ();
/**
* @brief Constructor with page number
* @param number Page number for request.
* @since 1.4.0
*/
NSRRenderRequest (int number);
/**
* @brief Constructor with page number and render reason
* @param number Page number for request.
* @param reason Rendering reason.
* @since 1.4.0
*/
NSRRenderRequest (int number, NSRRenderReason reason);
/**
* @brief Destructor
*/
virtual ~NSRRenderRequest ();
/**
* @brief Gets text encoding to use when extracting the text
* @return Text encoding.
* @since 1.4.0
*/
inline QString getEncoding () const {
return _encoding;
}
/**
* @brief Gets rendering reason
* @return Rendering reason.
* @since 1.4.0
*/
inline NSRRenderRequest::NSRRenderReason getRenderReason () const {
return _reason;
}
/**
* @brief Gets rendering type
* @return Rendering type.
* @since 1.4.0
*/
inline NSRRenderRequest::NSRRenderType getRenderType () const {
return _type;
}
/**
* @brief Gets requested page number
* @return Requested page number.
* @since 1.4.0
*/
inline int getNumber () const {
return _number;
}
/**
* @brief Gets requested zoom, in %
* @return Requested zoom.
* @since 1.4.0
*/
inline double getZoom () const {
return _zoom;
}
/**
* @brief Gets rotation angle, clockwise
* @return Rotation angle.
* @since 1.4.0
*/
inline NSRAbstractDocument::NSRDocumentRotation getRotation () const {
return _rotation;
}
/**
* @brief Gets screen width used to zoom to width
* @return Screen width for zoom to width.
* @since 1.4.0
*/
inline double getScreenWidth () const {
return _screenWidth;
}
/**
* @brief Gets page crop pads
* @return Page crop pads.
* @since 1.4.2
*
* If page crop pads are empty and page crop autodetection flag
* is enabled then crop pads will be calculated automatically.
*/
inline NSRCropPads getCropPads () const {
return _cropPads;
}
/**
* @brief Checks if request is valid
* @return True if request is valid (page number > 0), false otherwise.
* @since 1.4.0
*/
inline bool isValid () const {
return _number > 0;
}
/**
* @brief Checks autocrop flag
* @return True if autocrop is enabled, false otherwise.
* @since 1.4.0
*/
inline bool isAutoCrop () const {
return _autoCrop;
}
/**
* @brief Checks inverted colors flag
* @return True if inverted colors are enabled, false otherwise.
* @since 1.4.0
*/
inline bool isInvertColors () const {
return _invertColors;
}
/**
* @brief Checks text only flag
* @return True if text only rendering requested, false otherwise.
* @since 1.4.0
*/
inline bool isTextOnly () const {
return _textOnly;
}
/**
* @brief Checks zoom to width flag
* @return True if zoom to screen width is enabled, false otherwise.
* @since 1.4.0
* @sa getScreenWidth(), setScreenWidth()
*/
inline bool isZoomToWidth () const {
return _zoomToWidth;
}
/**
* @brief Sets encoding used for text extracting
* @param encoding Text encoding.
* @since 1.4.0
* @note Not all formats support text data and encoding selection.
*/
inline void setEncoding (const QString& encoding) {
_encoding = encoding;
}
/**
* @brief Sets rendering reason
* @param reason Rendering reason.
* @since 1.4.0
*/
inline void setRenderReason (NSRRenderRequest::NSRRenderReason reason) {
_reason = reason;
}
/**
* @brief Sets rendering type
* @param type Rendering type.
* @since 1.4.0
*/
inline void setRenderType (NSRRenderRequest::NSRRenderType type) {
_type = type;
}
/**
* @brief Sets requested page number
* @param number Requested page number.
* @since 1.4.0
*/
inline void setNumber (int number) {
_number = number;
}
/**
* @brief Sets requested zoom, in %
* @param zoom Requested zoom.
* @since 1.4.0
*/
inline void setZoom (double zoom) {
_zoom = qBound (0.0, zoom, zoom);
}
/**
* @brief Sets page rotation angle, clockwise
* @param rotation Rotation angle.
* @since 1.4.0
*/
inline void setRotation (NSRAbstractDocument::NSRDocumentRotation rotation) {
_rotation = rotation;
}
/**
* @brief Sets screen width for zoom to width
* @param screenWidth Screen width to zoom page to.
* @since 1.4.0
* @sa setZoomToWidth(), isZoomToWidth()
*
* For ordinary page requests this value used only if zoom to width
* is enabled. For thumbnails it used as a width.
*/
inline void setScreenWidth (double screenWidth) {
_screenWidth = screenWidth;
}
/**
* @brief Sets autocrop flag
* @param autoCrop Autocrop flag to set.
* @since 1.4.0
*/
inline void setAutoCrop (bool autoCrop) {
_autoCrop = autoCrop;
}
/**
* @brief Sets inverted colors flag
* @param invertColors Inverted colors flag to set.
* @since 1.4.0
*/
inline void setInvertColors (bool invertColors) {
_invertColors = invertColors;
}
/**
* @brief Sets text only flag
* @param textOnly Text only flag to set.
* @since 1.4.0
*/
inline void setTextOnly (bool textOnly) {
_textOnly = textOnly;
}
/**
* @brief Sets zoom to width flag
* @param zoomToWidth Zoom to width flag.
* @since 1.4.0
* @sa setScreenWidth()
*
* Use setScreenWidth() to set screen width to zoom to.
*/
inline void setZoomToWidth (bool zoomToWidth) {
_zoomToWidth = zoomToWidth;
}
/**
* @brief Sets page crop pads
* @param pads Page crop pads.
* @since 1.4.2
*/
inline void setCropPads (const NSRCropPads& pads) {
_cropPads = pads;
}
private:
QString _encoding; /**< Text encoding */
NSRCropPads _cropPads; /**< Page crop pads */
NSRRenderReason _reason; /**< Rendering reason */
NSRRenderType _type; /**< Rendering type */
NSRAbstractDocument::NSRDocumentRotation _rotation; /**< Rotation angle, clockwise */
double _zoom; /**< Zoom, % */
double _screenWidth; /**< Screen width */
int _number; /**< Page number */
bool _autoCrop; /**< Autocrop flag */
bool _invertColors; /**< Inverted colors flag */
bool _textOnly; /**< Text only flag */
bool _zoomToWidth; /**< Zoom to width flag */
};
#endif /* __NSRRENDERREQUEST_H__ */