4041bca776ef5145bab4f161fd713b94ceedf6e5
[ipdf/code.git] / src / ipdf.h
1 #ifndef _IPDF_H
2 #define _IPDF_H
3
4 #include "common.h"
5
6 namespace IPDF
7 {
8         typedef float Real;
9         
10         inline float RealToFloat(Real r) {return r;}
11         inline Real Random(Real max=1, Real min=0)
12         {
13                 return min + (max-min) * ((Real)(rand() % (int)1e6) / 1e6);
14         }
15
16         typedef unsigned ObjectID;
17         typedef enum {RECT_FILLED, RECT_OUTLINE} ObjectType;
18
19         struct Rect
20         {
21                 Real x; Real y; Real w; Real h;
22                 Rect() = default; // Needed so we can fread/fwrite this struct
23                 Rect(Real _x, Real _y, Real _w, Real _h) : x(_x), y(_y), w(_w), h(_h) {}
24                 std::string Str() 
25                 {
26                         std::stringstream s;
27                         s << "{" << x << ", " << y << ", " << w << ", " << h << "}";
28                         return s.str();
29                 }
30         };
31
32         struct Objects
33         {
34                 std::vector<ObjectType> types;          
35                 std::vector<Rect> bounds;
36         };
37
38         class View;
39 }
40
41
42 #endif //_IPDF_H

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