Inflict Qt4 upon the codebase
[ipdf/code.git] / src / ipdf.h
1 #ifndef _IPDF_H
2 #define _IPDF_H
3
4 #include "common.h"
5 #include "real.h"
6 #include "bezier.h"
7 #include "rect.h"
8
9 #define C_RED Colour(1,0,0,1)
10 #define C_GREEN Colour(0,1,0,1)
11 #define C_BLUE Colour(0,0,1,1)
12 #define C_BLACK Colour(0,0,0,1);
13
14 namespace IPDF
15 {
16
17         inline Real Random(Real max=1, Real min=0)
18         {
19                 return min + (max-min) * (Real(rand() % (int)1e6) / Real(1e6));
20         }
21
22         typedef unsigned ObjectID;
23         /** Type of object
24      * NOTE: Extra entry in the enum so we can use this as an array index
25          */
26         typedef enum 
27         {
28                 CIRCLE_FILLED = 0, 
29                 RECT_FILLED,
30                 RECT_OUTLINE,
31                 BEZIER,
32                 GROUP,
33                 NUMBER_OF_OBJECT_TYPES
34         } ObjectType;
35
36         enum DocChunkTypes
37         {
38                 CT_NUMOBJS,
39                 CT_OBJTYPES,
40                 CT_OBJBOUNDS,
41                 CT_OBJINDICES,
42                 CT_OBJBEZIERS,
43                 CT_OBJGROUPS
44         };
45
46
47
48         
49         
50         struct Colour
51         {
52                 float r; float g; float b; float a;
53                 Colour() = default;
54                 Colour(float _r, float _g, float _b, float _a) : r(_r), g(_g), b(_b), a(_a) {}
55         };
56         
57         struct Group
58         {
59                 Colour shading;
60         };
61
62         struct Objects
63         {
64                 /** Used by all objects **/
65                 std::vector<ObjectType> types; // types of objects
66                 std::vector<Rect> bounds; // rectangle bounds of objects
67                 
68                 /** Used by BEZIER to identify data position in relevant vector **/
69                 std::vector<unsigned> data_indices;
70
71                 /** Used by BEZIER only **/
72                 std::vector<Bezier> beziers; // bezier curves - look up by data_indices
73                 
74                 std::vector<std::pair<unsigned, unsigned> > groups;
75         };
76
77         class View;
78 }
79
80
81 #endif //_IPDF_H

UCC git Repository :: git.ucc.asn.au